diff --git a/BizHawk.Client.Common/movie/MovieImport.cs b/BizHawk.Client.Common/movie/MovieImport.cs index 62056839b6..bbb2e76093 100644 --- a/BizHawk.Client.Common/movie/MovieImport.cs +++ b/BizHawk.Client.Common/movie/MovieImport.cs @@ -55,18 +55,13 @@ namespace BizHawk.Client.Common } else { - messageCallback(Path.GetFileName(fn) + " imported as " + "Movies\\" + - Path.GetFileName(fn) + "." + Global.MovieSession.Movie.PreferredExtension); + messageCallback(Path.GetFileName(fn) + " imported as " + m.Filename); } if (!Directory.Exists(d)) { Directory.CreateDirectory(d); } - - var outPath = Path.Combine(d, Path.GetFileName(fn) + "." + Global.MovieSession.Movie.PreferredExtension); - m.Filename = outPath; - m.Save(); } // Attempt to import another type of movie file into a movie object. @@ -953,7 +948,7 @@ namespace BizHawk.Client.Common } else { - controllers.Type.Name = "Genesis 3-Button Controller"; + controllers.Type.Name = "GPGX 3-Button Controller"; } // 016 special flags (Version A and up only) byte flags = r.ReadByte(); diff --git a/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs b/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs index a9caa3640a..186debdf0d 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs @@ -135,7 +135,15 @@ namespace BizHawk.Client.Common if (ControlType == "GPGX Genesis Controller") { - SetGensis6ControllersAsMnemonic(mnemonic); + if (IsGenesis6Button()) + { + SetGenesis6ControllersAsMnemonic(mnemonic); + } + else + { + SetGenesis3ControllersAsMnemonic(mnemonic); + } + return; } @@ -242,6 +250,11 @@ namespace BizHawk.Client.Common private readonly WorkingDictionary MyBoolButtons = new WorkingDictionary(); private readonly WorkingDictionary MyFloatControls = new WorkingDictionary(); + private bool IsGenesis6Button() + { + return this.Type.BoolButtons.Contains("P1 X"); + } + private void Force(string button, bool state) { MyBoolButtons[button] = state; @@ -273,7 +286,7 @@ namespace BizHawk.Client.Common } } - private void SetGensis6ControllersAsMnemonic(string mnemonic) + private void SetGenesis6ControllersAsMnemonic(string mnemonic) { MnemonicChecker c = new MnemonicChecker(mnemonic); MyBoolButtons.Clear(); @@ -314,6 +327,47 @@ namespace BizHawk.Client.Common } } + private void SetGenesis3ControllersAsMnemonic(string mnemonic) + { + MnemonicChecker c = new MnemonicChecker(mnemonic); + MyBoolButtons.Clear(); + + if (mnemonic.Length < 2) + { + return; + } + + if (mnemonic[1] == 'P') + { + Force("Power", true); + } + else if (mnemonic[1] != '.' && mnemonic[1] != '0') + { + Force("Reset", true); + } + + if (mnemonic.Length < 9) + { + return; + } + + for (int player = 1; player <= BkmMnemonicConstants.PLAYERS[ControlType]; player++) + { + int srcindex = (player - 1) * (BkmMnemonicConstants.BUTTONS["GPGX 3-Button Controller"].Count + 1); + + if (mnemonic.Length < srcindex + 3 + BkmMnemonicConstants.BUTTONS["GPGX 3-Button Controller"].Count - 1) + { + return; + } + + int start = 3; + foreach (string button in BkmMnemonicConstants.BUTTONS["GPGX 3-Button Controller"].Keys) + { + Force("P" + player + " " + button, c[srcindex + start++]); + } + } + } + private void SetSNESControllersAsMnemonic(string mnemonic) { var c = new MnemonicChecker(mnemonic); diff --git a/BizHawk.Client.Common/movie/bkm/BkmLogEntryGenerator.cs b/BizHawk.Client.Common/movie/bkm/BkmLogEntryGenerator.cs index f6c1bac0b7..cc7fc6c71a 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmLogEntryGenerator.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmLogEntryGenerator.cs @@ -72,6 +72,11 @@ namespace BizHawk.Client.Common return GetGeneis6ButtonControllersAsMnemonic(); } + if (_controlType == "GPGX 3-Button Controller") + { + return GetGeneis3ButtonControllersAsMnemonic(); + } + var input = new StringBuilder("|"); if (_controlType == "PC Engine Controller") @@ -557,6 +562,38 @@ namespace BizHawk.Client.Common return input.ToString(); } + private string GetGeneis3ButtonControllersAsMnemonic() + { + var input = new StringBuilder("|"); + + if (IsBasePressed("Power")) + { + input.Append(BkmMnemonicConstants.COMMANDS[_controlType]["Power"]); + } + else if (IsBasePressed("Reset")) + { + input.Append(BkmMnemonicConstants.COMMANDS[_controlType]["Reset"]); + } + else + { + input.Append('.'); + } + + input.Append("|"); + for (int player = 1; player <= BkmMnemonicConstants.PLAYERS[_controlType]; player++) + { + foreach (var button in BkmMnemonicConstants.BUTTONS[_controlType].Keys) + { + input.Append(IsBasePressed("P" + player + " " + button) ? BkmMnemonicConstants.BUTTONS[_controlType][button] : "."); + } + + input.Append("|"); + } + + input.Append("|"); + return input.ToString(); + } + #endregion } } diff --git a/BizHawk.Client.Common/movie/bkm/BkmMnemonicConstants.cs b/BizHawk.Client.Common/movie/bkm/BkmMnemonicConstants.cs index bb419e3be6..0b2e7b944a 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmMnemonicConstants.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmMnemonicConstants.cs @@ -35,6 +35,13 @@ namespace BizHawk.Client.Common {"Start", "S"}, {"X", "X"}, {"Y", "Y"}, {"Z", "Z"}, {"Mode", "M"} } }, + { + "GPGX 3-Button Controller", new Dictionary + { + {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"A", "A"}, {"B", "B"}, + {"C", "C"}, {"Start", "S"}, + } + }, { "NES Controller", new Dictionary { @@ -150,13 +157,15 @@ namespace BizHawk.Client.Common {"TI83 Controller", new Dictionary()}, {"Nintento 64 Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, {"Saturn Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, + {"GPGX 3-Button Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, }; public static readonly Dictionary PLAYERS = new Dictionary { {"Gameboy Controller", 1}, {"GBA Controller", 1}, {"Genesis 3-Button Controller", 2}, {"GPGX Genesis Controller", 2}, {"NES Controller", 4}, {"SNES Controller", 4}, {"PC Engine Controller", 5}, {"SMS Controller", 2}, {"TI83 Controller", 1}, {"Atari 2600 Basic Controller", 2}, {"Atari 7800 ProLine Joystick Controller", 2}, - {"ColecoVision Basic Controller", 2}, {"Commodore 64 Controller", 2}, {"Nintento 64 Controller", 4}, {"Saturn Controller", 2} + {"ColecoVision Basic Controller", 2}, {"Commodore 64 Controller", 2}, {"Nintento 64 Controller", 4}, {"Saturn Controller", 2}, + {"GPGX 3-Button Controller", 2} }; // just experimenting with different possibly more painful ways to handle mnemonics diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 000f77cda0..84472e2e95 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -2327,8 +2327,6 @@ namespace BizHawk.Client.EmuHawk // fix movie extension to something palatable for these purposes. // for instance, something which doesnt clobber movies you already may have had. // i'm evenly torn between this, and a file in %TEMP%, but since we dont really have a way to clean up this tempfile, i choose this: - movie.Filename = Path.ChangeExtension(movie.Filename, ".autoimported." + MovieService.DefaultExtension); - movie.Save(); StartNewMovie(movie, false); }