From 59744ed2dd337f2d86fe60470ebfcbf654f71442 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sun, 27 Feb 2011 22:44:06 +0000 Subject: [PATCH] Implement SetControllersAsMnemonic() in NES core --- .../Consoles/Nintendo/NES/NES.cs | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs index dac1c9c79d..17764890b9 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs @@ -382,12 +382,61 @@ namespace BizHawk.Emulation.Consoles.Nintendo return null; } - public string GetControllersAsMnemonic() + public void SetControllersAsMnemonic(string mnemonic) { - return "|........|........|0|"; //TODO: implement + if (mnemonic.Length == 0) return; + + if (mnemonic[1] != '.') + Controller.ForceButton("Up"); + if (mnemonic[2] != '.') + Controller.ForceButton("Down"); + if (mnemonic[3] != '.') + Controller.ForceButton("Left"); + if (mnemonic[4] != '.') + Controller.ForceButton("Right"); + if (mnemonic[5] != '.') + Controller.ForceButton("B"); + if (mnemonic[6] != '.') + Controller.ForceButton("A"); + if (mnemonic[7] != '.') + Controller.ForceButton("Select"); + if (mnemonic[8] != '.') + Controller.ForceButton("Start"); + + if (mnemonic[10] != '.' && mnemonic[10] != '0') + Controller.ForceButton("Reset"); } - public void SetControllersAsMnemonic(string mnemonic) { return; } //TODO + public string GetControllersAsMnemonic() + { + string input = "|"; + + if (Controller.IsPressed("Up")) input += "U"; + else input += "."; + if (Controller.IsPressed("Down")) input += "D"; + else input += "."; + if (Controller.IsPressed("Left")) input += "L"; + else input += "."; + if (Controller.IsPressed("Right")) input += "R"; + else input += "."; + if (Controller.IsPressed("A")) input += "A"; + else input += "."; + if (Controller.IsPressed("B")) input += "B"; + else input += "."; + if (Controller.IsPressed("Select")) input += "s"; + else input += "."; + if (Controller.IsPressed("Start")) input += "S"; + else input += "."; + + input += "|"; + + if (Controller.IsPressed("Reset")) input += "R"; + else input += "."; + + input += "|"; + + return input; + } public class RomInfo {