From f32277ebd620efdde8683df185c694c33f371809 Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Sun, 27 Oct 2024 18:11:38 +0100 Subject: [PATCH] attempt to fix fm2 import This will now add reset and power buttons if fourscore is used (pretty sure not doing that was a bug as per comment) and ignore port0 and port1 values if fourscore is set as per movie format documentation. --- .../movie/import/Fm2Import.cs | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/BizHawk.Client.Common/movie/import/Fm2Import.cs b/src/BizHawk.Client.Common/movie/import/Fm2Import.cs index 43fa1fea9d..0fc19fa916 100644 --- a/src/BizHawk.Client.Common/movie/import/Fm2Import.cs +++ b/src/BizHawk.Client.Common/movie/import/Fm2Import.cs @@ -24,11 +24,9 @@ namespace BizHawk.Client.Common NesLeftPort = nameof(UnpluggedNES), NesRightPort = nameof(UnpluggedNES) }; + bool isFourScore = false; - _deck = controllerSettings.Instantiate((x, y) => true).AddSystemToControllerDef(); - _deck.ControllerDef.BuildMnemonicsCache(Bk2MnemonicLookup.MnemonicFunc(Result.Movie.SystemID)); - - Result.Movie.HeaderEntries[HeaderKeys.Platform] = platform; + Result.Movie.SystemID = platform; using var sr = SourceFile.OpenText(); string line; @@ -117,19 +115,19 @@ namespace BizHawk.Client.Common } else if (line.StartsWith("port0", StringComparison.OrdinalIgnoreCase)) { - if (ParseHeader(line, "port0") == "1") + if (!isFourScore && ParseHeader(line, "port0") == "1") { controllerSettings.NesLeftPort = nameof(ControllerNES); - _deck = controllerSettings.Instantiate((x, y) => false).AddSystemToControllerDef(); + _deck = controllerSettings.Instantiate((_, _) => false).AddSystemToControllerDef(); _deck.ControllerDef.BuildMnemonicsCache(Bk2MnemonicLookup.MnemonicFunc(Result.Movie.SystemID)); } } else if (line.StartsWith("port1", StringComparison.OrdinalIgnoreCase)) { - if (ParseHeader(line, "port1") == "1") + if (!isFourScore && ParseHeader(line, "port1") == "1") { controllerSettings.NesRightPort = nameof(ControllerNES); - _deck = controllerSettings.Instantiate((x, y) => false).AddSystemToControllerDef(); + _deck = controllerSettings.Instantiate((_, _) => false).AddSystemToControllerDef(); _deck.ControllerDef.BuildMnemonicsCache(Bk2MnemonicLookup.MnemonicFunc(Result.Movie.SystemID)); } } @@ -142,16 +140,15 @@ namespace BizHawk.Client.Common } else if (line.StartsWith("fourscore", StringComparison.OrdinalIgnoreCase)) { - bool fourscore = ParseHeader(line, "fourscore") == "1"; - if (fourscore) + isFourScore = ParseHeader(line, "fourscore") == "1"; + if (isFourScore) { // TODO: set controller config sync settings controllerSettings.NesLeftPort = nameof(FourScore); controllerSettings.NesRightPort = nameof(FourScore); + _deck = controllerSettings.Instantiate((_, _) => false).AddSystemToControllerDef(); + _deck.ControllerDef.BuildMnemonicsCache(Bk2MnemonicLookup.MnemonicFunc(Result.Movie.SystemID)); } - - _deck = controllerSettings.Instantiate((x, y) => false)/*.AddSystemToControllerDef()*/; //TODO call omitted on purpose? --yoshi - _deck.ControllerDef.BuildMnemonicsCache(Bk2MnemonicLookup.MnemonicFunc(Result.Movie.SystemID)); } else {