diff --git a/BizHawk.MultiClient/LuaImplementation.cs b/BizHawk.MultiClient/LuaImplementation.cs index d5bb185fdc..8777c3215a 100644 --- a/BizHawk.MultiClient/LuaImplementation.cs +++ b/BizHawk.MultiClient/LuaImplementation.cs @@ -548,6 +548,8 @@ namespace BizHawk.MultiClient "setdispbackground", "getdispsprites", "setdispsprites", + "addgamegenie", + "removegamegenie", }; /****************************************************/ /*************function definitions********************/ @@ -2538,5 +2540,50 @@ namespace BizHawk.MultiClient Global.Config.NESDispSprites = show; Global.MainForm.SyncCoreInputComm(); } + + public void nes_addgamegenie(string code) + { + if (Global.Emulator is NES) + { + NESGameGenie gg = new NESGameGenie(); + gg.DecodeGameGenieCode(code); + if (gg.address > 0 && gg.value > 0) + { + Cheat c = new Cheat(); + c.name = code; + c.domain = Global.Emulator.MemoryDomains[1]; + c.address = gg.address; + c.value = (byte)gg.value; + if (gg.compare != -1) + { + c.compare = (byte)gg.compare; + } + c.Enable(); + Global.MainForm.Cheats1.AddCheat(c); + } + } + } + + public void nes_removegamegenie(string code) + { + if (Global.Emulator is NES) + { + NESGameGenie gg = new NESGameGenie(); + gg.DecodeGameGenieCode(code); + if (gg.address > 0 && gg.value > 0) + { + Cheat c = new Cheat(); + c.name = code; + c.domain = Global.Emulator.MemoryDomains[1]; + c.address = gg.address; + c.value = (byte)gg.value; + if (gg.compare != -1) + { + c.compare = (byte)gg.compare; + } + Global.CheatList.RemoveCheat(Global.Emulator.MemoryDomains[1], c.address); + } + } + } } } diff --git a/BizHawk.MultiClient/NEStools/NESGameGenie.cs b/BizHawk.MultiClient/NEStools/NESGameGenie.cs index a2f341fd8f..f97b4c60cc 100644 --- a/BizHawk.MultiClient/NEStools/NESGameGenie.cs +++ b/BizHawk.MultiClient/NEStools/NESGameGenie.cs @@ -13,19 +13,16 @@ namespace BizHawk.MultiClient { public partial class NESGameGenie : Form { - int address = -1; - int value = -1; - int compare = -1; + public int address = -1; + public int value = -1; + public int compare = -1; Dictionary GameGenieTable = new Dictionary(); public NESGameGenie() { InitializeComponent(); Closing += (o, e) => SaveConfigSettings(); - } - private void NESGameGenie_Load(object sender, EventArgs e) - { GameGenieTable.Add('A', 0); //0000 GameGenieTable.Add('P', 1); //0001 GameGenieTable.Add('Z', 2); //0010 @@ -42,7 +39,10 @@ namespace BizHawk.MultiClient GameGenieTable.Add('S', 13); //1101 GameGenieTable.Add('V', 14); //1110 GameGenieTable.Add('N', 15); //1111 + } + private void NESGameGenie_Load(object sender, EventArgs e) + { AddCheat.Enabled = false; if (Global.Config.NESGGSaveWindowPosition && Global.Config.NESGGWndx >= 0 && Global.Config.NESGGWndy >= 0) @@ -82,7 +82,7 @@ namespace BizHawk.MultiClient return (value >> bit) & 1; } - private void DecodeGameGenieCode(string code) + public void DecodeGameGenieCode(string code) { //char 3 bit 3 denotes the code length. if (code.Length == 6) diff --git a/BizHawk.MultiClient/tools/CheatList.cs b/BizHawk.MultiClient/tools/CheatList.cs index 6666aaba9c..a149d86f15 100644 --- a/BizHawk.MultiClient/tools/CheatList.cs +++ b/BizHawk.MultiClient/tools/CheatList.cs @@ -176,6 +176,8 @@ namespace BizHawk.MultiClient cheatList.Remove(cheatList[x]); } } + + Global.OSD.AddMessage("Cheat removed"); } public string CheatsPath