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.
This commit is contained in:
Morilli 2024-10-27 18:11:38 +01:00
parent 8f642d6b8f
commit f32277ebd6
1 changed files with 10 additions and 13 deletions

View File

@ -24,11 +24,9 @@ namespace BizHawk.Client.Common
NesLeftPort = nameof(UnpluggedNES), NesLeftPort = nameof(UnpluggedNES),
NesRightPort = nameof(UnpluggedNES) NesRightPort = nameof(UnpluggedNES)
}; };
bool isFourScore = false;
_deck = controllerSettings.Instantiate((x, y) => true).AddSystemToControllerDef(); Result.Movie.SystemID = platform;
_deck.ControllerDef.BuildMnemonicsCache(Bk2MnemonicLookup.MnemonicFunc(Result.Movie.SystemID));
Result.Movie.HeaderEntries[HeaderKeys.Platform] = platform;
using var sr = SourceFile.OpenText(); using var sr = SourceFile.OpenText();
string line; string line;
@ -117,19 +115,19 @@ namespace BizHawk.Client.Common
} }
else if (line.StartsWith("port0", StringComparison.OrdinalIgnoreCase)) else if (line.StartsWith("port0", StringComparison.OrdinalIgnoreCase))
{ {
if (ParseHeader(line, "port0") == "1") if (!isFourScore && ParseHeader(line, "port0") == "1")
{ {
controllerSettings.NesLeftPort = nameof(ControllerNES); controllerSettings.NesLeftPort = nameof(ControllerNES);
_deck = controllerSettings.Instantiate((x, y) => false).AddSystemToControllerDef(); _deck = controllerSettings.Instantiate((_, _) => false).AddSystemToControllerDef();
_deck.ControllerDef.BuildMnemonicsCache(Bk2MnemonicLookup.MnemonicFunc(Result.Movie.SystemID)); _deck.ControllerDef.BuildMnemonicsCache(Bk2MnemonicLookup.MnemonicFunc(Result.Movie.SystemID));
} }
} }
else if (line.StartsWith("port1", StringComparison.OrdinalIgnoreCase)) else if (line.StartsWith("port1", StringComparison.OrdinalIgnoreCase))
{ {
if (ParseHeader(line, "port1") == "1") if (!isFourScore && ParseHeader(line, "port1") == "1")
{ {
controllerSettings.NesRightPort = nameof(ControllerNES); controllerSettings.NesRightPort = nameof(ControllerNES);
_deck = controllerSettings.Instantiate((x, y) => false).AddSystemToControllerDef(); _deck = controllerSettings.Instantiate((_, _) => false).AddSystemToControllerDef();
_deck.ControllerDef.BuildMnemonicsCache(Bk2MnemonicLookup.MnemonicFunc(Result.Movie.SystemID)); _deck.ControllerDef.BuildMnemonicsCache(Bk2MnemonicLookup.MnemonicFunc(Result.Movie.SystemID));
} }
} }
@ -142,16 +140,15 @@ namespace BizHawk.Client.Common
} }
else if (line.StartsWith("fourscore", StringComparison.OrdinalIgnoreCase)) else if (line.StartsWith("fourscore", StringComparison.OrdinalIgnoreCase))
{ {
bool fourscore = ParseHeader(line, "fourscore") == "1"; isFourScore = ParseHeader(line, "fourscore") == "1";
if (fourscore) if (isFourScore)
{ {
// TODO: set controller config sync settings // TODO: set controller config sync settings
controllerSettings.NesLeftPort = nameof(FourScore); controllerSettings.NesLeftPort = nameof(FourScore);
controllerSettings.NesRightPort = 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 else
{ {