From e9d8e2eb2165ff7cce50be155d8d5080fb324d88 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 3 May 2013 19:22:43 +0000 Subject: [PATCH] N64 - add mnemonics (input display, movie recording). Don't know if it works, don't have a game handy to test --- BizHawk.MultiClient/Global.cs | 13 +++- BizHawk.MultiClient/movie/InputAdapters.cs | 73 +++++++++++++++++++++- 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/BizHawk.MultiClient/Global.cs b/BizHawk.MultiClient/Global.cs index 823c7b7816..14bb777dfa 100644 --- a/BizHawk.MultiClient/Global.cs +++ b/BizHawk.MultiClient/Global.cs @@ -175,6 +175,14 @@ namespace BizHawk.MultiClient {"Key1", "1"}, {"Key2", "2"}, {"Key3", "3"}, {"Key4", "4"}, {"Key5", "5"}, {"Key6", "6"}, {"Key7", "7"}, {"Key8", "8"}, {"Key9", "9"}, {"Star", "*"}, {"Key0", "0"}, {"Pound", "#"} } + }, + { + "Nintento 64 Controller", new Dictionary() + { + {"DPad U", "U"}, {"DPad D", "D"}, {"DPad L", "L"}, {"DPad R", "R"}, + {"A", "A"}, {"B", "B"}, {"Z", "Z"}, {"Start", "S"}, + {"C Up", "u"}, {"C Down", "d"}, {"C Left", "l"}, {"C Right", "r"} + } } }; @@ -189,14 +197,15 @@ namespace BizHawk.MultiClient {"SNES Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, {"PC Engine Controller", new Dictionary {}}, {"SMS Controller", new Dictionary {{"Pause", "p"}, {"Reset", "r"}}}, - {"TI83 Controller", new Dictionary {}} + {"TI83 Controller", new Dictionary {}}, + {"Nintento 64 Controller", new Dictionary {{"Pause", "p"}, {"Reset", "r"}}}, }; public static readonly Dictionary PLAYERS = new Dictionary { {"Gameboy Controller", 1}, {"GBA Controller", 1}, {"Genesis 3-Button 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} + {"ColecoVision Basic Controller", 2}, {"Commodore 64 Controller", 2}, {"Nintento 64 Controller", 4} }; // just experimenting with different possibly more painful ways to handle mnemonics diff --git a/BizHawk.MultiClient/movie/InputAdapters.cs b/BizHawk.MultiClient/movie/InputAdapters.cs index 170c4be007..0db8559acd 100644 --- a/BizHawk.MultiClient/movie/InputAdapters.cs +++ b/BizHawk.MultiClient/movie/InputAdapters.cs @@ -445,6 +445,8 @@ namespace BizHawk.MultiClient return "|.....|.....|..................................................................|"; case "GBA": return "|.|..........|"; + case "N64": + return "|.|............|............|............|............|"; } } } @@ -559,6 +561,35 @@ namespace BizHawk.MultiClient return input.ToString(); } + private string GetN64ControllersAsMnemonic() + { + StringBuilder input = new StringBuilder("|"); + if (IsBasePressed("Power")) + { + input.Append('P'); + } + else if (IsBasePressed("Reset")) + { + input.Append('r'); + } + else + { + input.Append('.'); + } + input.Append('|'); + + for (int player = 1; player <= Global.PLAYERS[ControlType]; player++) + { + foreach (string button in Global.BUTTONS[ControlType].Keys) + { + input.Append(IsBasePressed("P" + player + " " + button) ? Global.BUTTONS[ControlType][button] : "."); + } + input.Append('|'); + } + + return input.ToString(); + } + public string GetControllersAsMnemonic() { if (ControlType == "Null Controller") @@ -583,11 +614,11 @@ namespace BizHawk.MultiClient } else if (ControlType == "Dual Gameboy Controller") { - return GetDualGameBoyControllerAsMnemonic(); + return GetDualGameBoyControllerAsMnemonic(); } else if (ControlType == "Nintento 64 Controller") { - return ""; // TODO + return GetN64ControllersAsMnemonic(); } else if (ControlType == "Saturn Controller") { @@ -908,6 +939,42 @@ namespace BizHawk.MultiClient } } + private void SetN64ControllersAsMnemonic(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); + } + + for (int player = 1; player <= Global.PLAYERS[ControlType]; player++) + { + int srcindex = (player - 1) * (Global.BUTTONS[ControlType].Count + 1); + + if (mnemonic.Length < srcindex + 3 + Global.BUTTONS[ControlType].Count - 1) + { + return; + } + + int start = 3; + foreach (string button in Global.BUTTONS[ControlType].Keys) + { + Force("P" + player + " " + button, c[srcindex + start++]); + } + } + } + private void SetAtari7800AsMnemonic(string mnemonic) { MnemonicChecker c = new MnemonicChecker(mnemonic); @@ -1027,7 +1094,7 @@ namespace BizHawk.MultiClient } else if (ControlType == "Nintento 64 Controller") { - // TODO + SetN64ControllersAsMnemonic(mnemonic); return; } else if (ControlType == "Saturn Controller")