diff --git a/BizHawk.Client.EmuHawk/tools/GameShark.Designer.cs b/BizHawk.Client.EmuHawk/tools/GameShark.Designer.cs index fcfc1ebf06..791aeb2853 100644 --- a/BizHawk.Client.EmuHawk/tools/GameShark.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/GameShark.Designer.cs @@ -53,7 +53,7 @@ this.btnClear.TabIndex = 4; this.btnClear.Text = "Clear"; this.btnClear.UseVisualStyleBackColor = true; - this.btnClear.Click += new System.EventHandler(this.btnClear_Click); + this.btnClear.Click += new System.EventHandler(this.BtnClear_Click); // // lblCheat // @@ -85,7 +85,7 @@ this.btnGo.TabIndex = 5; this.btnGo.Text = "Convert"; this.btnGo.UseVisualStyleBackColor = true; - this.btnGo.Click += new System.EventHandler(this.btnGo_Click); + this.btnGo.Click += new System.EventHandler(this.Go_Click); // // lblDescription // @@ -124,10 +124,8 @@ this.Name = "GameShark"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Cheat Code Converter"; - this.Load += new System.EventHandler(this.GameShark_Load); this.ResumeLayout(false); this.PerformLayout(); - } #endregion diff --git a/BizHawk.Client.EmuHawk/tools/GameShark.cs b/BizHawk.Client.EmuHawk/tools/GameShark.cs index 4dc11a6c73..3092d49586 100644 --- a/BizHawk.Client.EmuHawk/tools/GameShark.cs +++ b/BizHawk.Client.EmuHawk/tools/GameShark.cs @@ -1,134 +1,138 @@ using System; +using System.Collections.Generic; +using System.Globalization; using System.Windows.Forms; using BizHawk.Emulation.Common; using BizHawk.Client.Common; -using System.Globalization; -using System.Collections.Generic; +// TODO: +// Add Support/Handling for The Following Systems and Devices: +// GBA: Code Breaker (That uses unique Encryption keys) +// NES: Pro Action Rocky (When someone asks) +// SNES: GoldFinger (Action Replay II) Support? + +// Clean up the checks to be more robust/less "hacky" +// They work but feel bad + +// Verify all wording in the error reports namespace BizHawk.Client.EmuHawk { - - //TODO: - //Add Support/Handling for The Following Systems and Devices: - //GBA: Code Breaker (That uses unique Encryption keys) - //NES: Pro Action Rocky (When someone asks) - //SNES: GoldFinger (Action Replay II) Support? - - //Clean up the checks to be more robust/less "hacky" - //They work but feel bad - - //Verify all wording in the error reports - - - [Tool(released: true, supportedSystems: new[] { "GB", "GBA", "GEN", "N64", "NES", "PSX", "SAT", "SMS", "SNES" }, - unsupportedCores: new[] { "Snes9x" })] + [Tool(true, new[] { "GB", "GBA", "GEN", "N64", "NES", "PSX", "SAT", "SMS", "SNES" }, new[] { "Snes9x" })] public partial class GameShark : Form, IToolForm, IToolFormAutoConfig { - #region " Game Genie Dictionary " - private readonly Dictionary _GBGGgameGenieTable = new Dictionary + #region Game Genie Dictionary + + private readonly Dictionary _gbGgGameGenieTable = new Dictionary { - {'0', 0 }, - {'1', 1 }, - {'2', 2 }, - {'3', 3 }, - {'4', 4 }, - {'5', 5 }, - {'6', 6 }, - {'7', 7 }, - {'8', 8 }, - {'9', 9 }, - {'A', 10 }, - {'B', 11 }, - {'C', 12 }, - {'D', 13 }, - {'E', 14 }, - {'F', 15 } + ['0'] = 0, + ['1'] = 1, + ['2'] = 2, + ['3'] = 3, + ['4'] = 4, + ['5'] = 5, + ['6'] = 6, + ['7'] = 7, + ['8'] = 8, + ['9'] = 9, + ['A'] = 10, + ['B'] = 11, + ['C'] = 12, + ['D'] = 13, + ['E'] = 14, + ['F'] = 15 }; - private readonly Dictionary _GENgameGenieTable = new Dictionary + + private readonly Dictionary _genGameGenieTable = new Dictionary { - { 'A', 0 }, - { 'B', 1 }, - { 'C', 2 }, - { 'D', 3 }, - { 'E', 4 }, - { 'F', 5 }, - { 'G', 6 }, - { 'H', 7 }, - { 'J', 8 }, - { 'K', 9 }, - { 'L', 10 }, - { 'M', 11 }, - { 'N', 12 }, - { 'P', 13 }, - { 'R', 14 }, - { 'S', 15 }, - { 'T', 16 }, - { 'V', 17 }, - { 'W', 18 }, - { 'X', 19 }, - { 'Y', 20 }, - { 'Z', 21 }, - { '0', 22 }, - { '1', 23 }, - { '2', 24 }, - { '3', 25 }, - { '4', 26 }, - { '5', 27 }, - { '6', 28 }, - { '7', 29 }, - { '8', 30 }, - { '9', 31 } + ['A'] = 0, + ['B'] = 1, + ['C'] = 2, + ['D'] = 3, + ['E'] = 4, + ['F'] = 5, + ['G'] = 6, + ['H'] = 7, + ['J'] = 8, + ['K'] = 9, + ['L'] = 10, + ['M'] = 11, + ['N'] = 12, + ['P'] = 13, + ['R'] = 14, + ['S'] = 15, + ['T'] = 16, + ['V'] = 17, + ['W'] = 18, + ['X'] = 19, + ['Y'] = 20, + ['Z'] = 21, + ['0'] = 22, + ['1'] = 23, + ['2'] = 24, + ['3'] = 25, + ['4'] = 26, + ['5'] = 27, + ['6'] = 28, + ['7'] = 29, + ['8'] = 30, + ['9'] = 31 }; - //This only applies to the NES - private readonly Dictionary _NESgameGenieTable = new Dictionary + + // This only applies to the NES + private readonly Dictionary _nesGameGenieTable = new Dictionary { - { 'A', 0 }, // 0000 - { 'P', 1 }, // 0001 - { 'Z', 2 }, // 0010 - { 'L', 3 }, // 0011 - { 'G', 4 }, // 0100 - { 'I', 5 }, // 0101 - { 'T', 6 }, // 0110 - { 'Y', 7 }, // 0111 - { 'E', 8 }, // 1000 - { 'O', 9 }, // 1001 - { 'X', 10 }, // 1010 - { 'U', 11 }, // 1011 - { 'K', 12 }, // 1100 - { 'S', 13 }, // 1101 - { 'V', 14 }, // 1110 - { 'N', 15 }, // 1111 + ['A'] = 0, // 0000 + ['P'] = 1, // 0001 + ['Z'] = 2, // 0010 + ['L'] = 3, // 0011 + ['G'] = 4, // 0100 + ['I'] = 5, // 0101 + ['T'] = 6, // 0110 + ['Y'] = 7, // 0111 + ['E'] = 8, // 1000 + ['O'] = 9, // 1001 + ['X'] = 10, // 1010 + ['U'] = 11, // 1011 + ['K'] = 12, // 1100 + ['S'] = 13, // 1101 + ['V'] = 14, // 1110 + ['N'] = 15, // 1111 }; + // including transposition // Code: D F 4 7 0 9 1 5 6 B C 8 A 2 3 E // Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F - //This only applies to the SNES - private readonly Dictionary _SNESgameGenieTable = new Dictionary + // This only applies to the SNES + private readonly Dictionary _snesGameGenieTable = new Dictionary { - { 'D', 0 }, // 0000 - { 'F', 1 }, // 0001 - { '4', 2 }, // 0010 - { '7', 3 }, // 0011 - { '0', 4 }, // 0100 - { '9', 5 }, // 0101 - { '1', 6 }, // 0110 - { '5', 7 }, // 0111 - { '6', 8 }, // 1000 - { 'B', 9 }, // 1001 - { 'C', 10 }, // 1010 - { '8', 11 }, // 1011 - { 'A', 12 }, // 1100 - { '2', 13 }, // 1101 - { '3', 14 }, // 1110 - { 'E', 15 } // 1111 + ['D'] = 0, // 0000 + ['F'] = 1, // 0001 + ['4'] = 2, // 0010 + ['7'] = 3, // 0011 + ['0'] = 4, // 0100 + ['9'] = 5, // 0101 + ['1'] = 6, // 0110 + ['5'] = 7, // 0111 + ['6'] = 8, // 1000 + ['B'] = 9, // 1001 + ['C'] = 10, // 1010 + ['8'] = 11, // 1011 + ['A'] = 12, // 1100 + ['2'] = 13, // 1101 + ['3'] = 14, // 1110 + ['E'] = 15 // 1111 }; + #endregion - //We are using Memory Domains, so we NEED this. [RequiredService] + // ReSharper disable once UnusedAutoPropertyAccessor.Local private IMemoryDomains MemoryDomains { get; set; } + [RequiredService] + // ReSharper disable once UnusedAutoPropertyAccessor.Local private IEmulator Emulator { get; set; } + public GameShark() { InitializeComponent(); @@ -145,81 +149,81 @@ namespace BizHawk.Client.EmuHawk { } - public void NewUpdate(ToolFormUpdateType type) { } + public void NewUpdate(ToolFormUpdateType type) + { + } public void UpdateValues() { } - //My Variables - string parseString = null; - string RAMAddress = null; - string RAMValue = null; - int byteSize = 0; - string testo = null; - string SingleCheat = null; - int loopValue = 0; - private void btnGo_Click(object sender, EventArgs e) - { - //Reset Variables - parseString = null; - RAMAddress = null; - RAMValue = null; - byteSize = 0; + private string _parseString; + private string _ramAddress; + private string _ramValue; + private int _byteSize; + private string _testo; + private string _singleCheat; + private int _loopValue; - SingleCheat = null; + private void Go_Click(object sender, EventArgs e) + { + // Reset Variables + _parseString = null; + _ramAddress = null; + _ramValue = null; + _byteSize = 0; + + _singleCheat = null; for (int i = 0; i < txtCheat.Lines.Length; i++) { - loopValue = i; - SingleCheat = txtCheat.Lines[i].ToUpper(); - //What System are we running? + _loopValue = i; + _singleCheat = txtCheat.Lines[i].ToUpper(); + switch (Emulator.SystemId) { case "GB": - GB(); + GameBoy(); break; case "GBA": GBA(); break; case "GEN": - GEN(); + Gen(); break; case "N64": // This determines what kind of Code we have - testo = SingleCheat.Remove(2, 11); + _testo = _singleCheat.Remove(2, 11); N64(); break; case "NES": - NES(); + Nes(); break; case "PSX": - //This determies what kind of Code we have - testo = SingleCheat.Remove(2, 11); - PSX(); + // This determines what kind of Code we have + _testo = _singleCheat.Remove(2, 11); + Psx(); break; case "SAT": - //This determies what kind of Code we have - testo = SingleCheat.Remove(2, 11); - SAT(); + // This determines what kind of Code we have + _testo = _singleCheat.Remove(2, 11); + Saturn(); break; case "SMS": - SMS(); + Sms(); break; case "SNES": - SNES(); - break; - default: - //This should NEVER happen + Snes(); break; } } - //We did the lines. Let's clear. + txtCheat.Clear(); txtDescription.Clear(); } - //Original Code by adelikat - //Decodes GameGear and GameBoy - public void GBGGDecode(string code, ref int val, ref int add, ref int cmp) + + // Original Code by adelikat + // Decodes GameGear and GameBoy + public void GbGgDecode(string code, ref int val, out int add, out int cmp) { // No cypher on value // Char # | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | @@ -227,22 +231,24 @@ namespace BizHawk.Client.EmuHawk // maps to| Value |A|B|C|D|E|F|G|H|I|J|K|L|XOR 0xF|a|b|c|c|NotUsed|e|f|g|h| // proper | Value |XOR 0xF|A|B|C|D|E|F|G|H|I|J|K|L|g|h|a|b|Nothing|c|d|e|f| int x; + // Getting Value if (code.Length > 0) { - _GBGGgameGenieTable.TryGetValue(code[0], out x); + _gbGgGameGenieTable.TryGetValue(code[0], out x); val = x << 4; } if (code.Length > 1) { - _GBGGgameGenieTable.TryGetValue(code[1], out x); + _gbGgGameGenieTable.TryGetValue(code[1], out x); val |= x; } + // Address if (code.Length > 2) { - _GBGGgameGenieTable.TryGetValue(code[2], out x); + _gbGgGameGenieTable.TryGetValue(code[2], out x); add = x << 8; } else @@ -252,31 +258,30 @@ namespace BizHawk.Client.EmuHawk if (code.Length > 3) { - _GBGGgameGenieTable.TryGetValue(code[3], out x); + _gbGgGameGenieTable.TryGetValue(code[3], out x); add |= x << 4; } if (code.Length > 4) { - _GBGGgameGenieTable.TryGetValue(code[4], out x); + _gbGgGameGenieTable.TryGetValue(code[4], out x); add |= x; } if (code.Length > 5) { - _GBGGgameGenieTable.TryGetValue(code[5], out x); + _gbGgGameGenieTable.TryGetValue(code[5], out x); add |= (x ^ 0xF) << 12; } // compare need to be full if (code.Length > 8) { - int comp = 0; - _GBGGgameGenieTable.TryGetValue(code[6], out x); - comp = x << 2; + _gbGgGameGenieTable.TryGetValue(code[6], out x); + var comp = x << 2; // 8th character ignored - _GBGGgameGenieTable.TryGetValue(code[8], out x); + _gbGgGameGenieTable.TryGetValue(code[8], out x); comp |= (x & 0xC) >> 2; comp |= (x & 0x3) << 6; cmp = comp ^ 0xBA; @@ -286,216 +291,216 @@ namespace BizHawk.Client.EmuHawk cmp = -1; } } - private void GB() - { - string RAMCompare = null; - //Game Genie - if (SingleCheat.LastIndexOf("-") == 7 && SingleCheat.IndexOf("-") == 3) + private void GameBoy() + { + string ramCompare = null; + + // Game Genie + if (_singleCheat.LastIndexOf("-") == 7 && _singleCheat.IndexOf("-") == 3) { int val = 0; - int add = 0; - int cmp = 0; - parseString = SingleCheat.Replace("-", ""); - GBGGDecode(parseString, ref val, ref add, ref cmp); - RAMAddress = $"{add:X4}"; - RAMValue = $"{val:X2}"; - RAMCompare = $"{cmp:X2}"; + _parseString = _singleCheat.Replace("-", ""); + GbGgDecode(_parseString, ref val, out var add, out var cmp); + _ramAddress = $"{add:X4}"; + _ramValue = $"{val:X2}"; + ramCompare = $"{cmp:X2}"; } - //Game Genie - else if (SingleCheat.Contains("-") == true && SingleCheat.LastIndexOf("-") != 7 && SingleCheat.IndexOf("-") != 3) + else if (_singleCheat.Contains("-") && _singleCheat.LastIndexOf("-") != 7 && _singleCheat.IndexOf("-") != 3) { MessageBox.Show("All GameBoy Game Genie Codes need to have a dash after the third character and seventh character.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - //Game Shark codes - if (SingleCheat.Length != 8 && SingleCheat.Contains("-") == false) + // Game Shark codes + if (_singleCheat.Length != 8 && _singleCheat.Contains("-") == false) { MessageBox.Show("All GameShark Codes need to be Eight characters in Length", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - else if (SingleCheat.Length == 8 && SingleCheat.Contains("-") == false) + + if (_singleCheat.Length == 8 && _singleCheat.Contains("-") == false) { - testo = SingleCheat.Remove(2, 6); - //Let's make sure we start with zero. We have a good length, and a good starting zero, we should be good. Hopefully. - switch (testo) + _testo = _singleCheat.Remove(2, 6); + switch (_testo) { - //Is this 00 or 01? case "00": case "01": - //Good. break; default: - //No. MessageBox.Show("All GameShark Codes for GameBoy need to start with 00 or 01", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - //Sample Input for GB/GBC: - //010FF6C1 - //Becomes: - //Address C1F6 - //Value 0F - parseString = SingleCheat.Remove(0, 2); - //Now we need to break it down a little more. - RAMValue = parseString.Remove(2, 4); - parseString = parseString.Remove(0, 2); - //The issue is Endian... Time to get ultra clever. And Regret it. - //First Half - RAMAddress = parseString.Remove(0, 2); - RAMAddress = RAMAddress + parseString.Remove(2, 2); - //We now have our values. + // Sample Input for GB/GBC: + // 010FF6C1 + // Becomes: + // Address C1F6 + // Value 0F + _parseString = _singleCheat.Remove(0, 2); + // Now we need to break it down a little more. + _ramValue = _parseString.Remove(2, 4); + _parseString = _parseString.Remove(0, 2); + + // The issue is Endian... Time to get ultra clever. And Regret it. + // First Half + _ramAddress = _parseString.Remove(0, 2); + _ramAddress = _ramAddress + _parseString.Remove(2, 2); } - //This part, is annoying... + // This part, is annoying... try { - //A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. - //System Bus Domain, The Address to Watch, Byte size (Byte), Hex Display, Description. Not Big Endian. - var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, false, txtDescription.Text); - //Take Watch, Add our Value we want, and it should be active when addded? - if (RAMCompare == null) - { - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); - } - else if (RAMCompare != null) - { - //We have a Compare - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber), int.Parse(RAMCompare, NumberStyles.HexNumber))); - } + // A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. + // System Bus Domain, The Address to Watch, Byte size (Byte), Hex Display, Description. Not Big Endian. + var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, false, txtDescription.Text); + + // Take Watch, Add our Value we want, and it should be active when added? + Global.CheatList.Add(ramCompare == null + ? new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber)) + : new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber), int.Parse(ramCompare, NumberStyles.HexNumber))); } - //Someone broke the world? catch (Exception ex) { MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - //Provided by mGBA and endrift - UInt32[] GBAGameSharkSeeds = { UInt32.Parse("09F4FBBD", NumberStyles.HexNumber), UInt32.Parse("9681884A", NumberStyles.HexNumber), UInt32.Parse("352027E9", NumberStyles.HexNumber), UInt32.Parse("F3DEE5A7", NumberStyles.HexNumber) }; - UInt32[] GBAProActionReplaySeeds = { UInt32.Parse("7AA9648F", NumberStyles.HexNumber), UInt32.Parse("7FAE6994", NumberStyles.HexNumber), UInt32.Parse("C0EFAAD5", NumberStyles.HexNumber), UInt32.Parse("42712C57", NumberStyles.HexNumber) }; - //blnEncrypted is used to see if the previous line for Slide code was encrypted or not. - Boolean blnEncrypted = false; - //blnGameShark means, "This is a Game Shark/Action Replay (Not MAX) code." - Boolean blnGameShark = false; - //blnActionReplayMax means "This is an Action Replay MAX code." - Boolean blnActionReplayMax = false; - //blnCodeBreaker means "This is a CodeBreaker code." - //Boolean blnCodeBreaker = false; - //blnUnhandled means "BizHawk can't do this one or the tool can't." - Boolean blnUnhandled = false; - //blnUnneeded means "You don't need this code." - Boolean blnUnneeded = false; + + // Provided by mGBA and endrift + private readonly uint[] _gbaGameSharkSeeds = { uint.Parse("09F4FBBD", NumberStyles.HexNumber), uint.Parse("9681884A", NumberStyles.HexNumber), uint.Parse("352027E9", NumberStyles.HexNumber), uint.Parse("F3DEE5A7", NumberStyles.HexNumber) }; + private readonly uint[] _gbaProActionReplaySeeds = { uint.Parse("7AA9648F", NumberStyles.HexNumber), uint.Parse("7FAE6994", NumberStyles.HexNumber), uint.Parse("C0EFAAD5", NumberStyles.HexNumber), uint.Parse("42712C57", NumberStyles.HexNumber) }; + + // blnEncrypted is used to see if the previous line for Slide code was encrypted or not. + private bool _blnEncrypted; + + // blnGameShark means, "This is a Game Shark/Action Replay (Not MAX) code." + private bool _blnGameShark; + + // blnActionReplayMax means "This is an Action Replay MAX code." + private bool _blnActionReplayMax; + + // blnCodeBreaker means "This is a CodeBreaker code." + // Boolean blnCodeBreaker = false; + // blnUnhandled means "BizHawk can't do this one or the tool can't." + private bool _blnUnhandled; + + // blnUnneeded means "You don't need this code." + private bool _blnUnneeded; + private void GBA() { - blnEncrypted = false; - //bool blnNoCode = false; - //Super Ultra Mega HD BizHawk GameShark/Action Replay/Code Breaker Final Hyper Edition Arcade Remix EX + α GBA Code detection method. - //Seriously, it's that complex. + // Super Ultra Mega HD BizHawk GameShark/Action Replay/Code Breaker Final Hyper Edition Arcade Remix EX + α GBA Code detection method. + // Seriously, it's that complex. + _blnEncrypted = false; - //Check Game Shark/Action Replay (Not Max) Codes - if (SingleCheat.Length == 17 && SingleCheat.IndexOf(" ") == 8) + // Check Game Shark/Action Replay (Not Max) Codes + if (_singleCheat.Length == 17 && _singleCheat.IndexOf(" ") == 8) { - //blnNoCode = true; - //Super Ultra Mega HD BizHawk GameShark/Action Replay/Code Breaker Final Hyper Edition Arcade Remix EX + α GBA Code detection method. - //Seriously, it's that complex. + // blnNoCode = true; + // Super Ultra Mega HD BizHawk GameShark/Action Replay/Code Breaker Final Hyper Edition Arcade Remix EX + α GBA Code detection method. + // Seriously, it's that complex. - //Check Game Shark/Action Replay (Not Max) Codes - if (SingleCheat.Length == 17 && SingleCheat.IndexOf(" ") == 8) + // Check Game Shark/Action Replay (Not Max) Codes + if (_singleCheat.Length == 17 && _singleCheat.IndexOf(" ") == 8) { - //These are for the Decyption Values for GameShark and Action Replay MAX. - UInt32 op1 = 0; - UInt32 op2 = 0; - UInt32 sum = 0xC6EF3720; + // These are for the Decryption Values for GameShark and Action Replay MAX. + uint op1; + uint op2; + uint sum = 0xC6EF3720; - //Let's get the stuff seperated. - RAMAddress = SingleCheat.Remove(8, 9); - RAMValue = SingleCheat.Remove(0, 9); - //Let's see if this code matches the GameShark. + // Let's get the stuff separated. + _ramAddress = _singleCheat.Remove(8, 9); + _ramValue = _singleCheat.Remove(0, 9); + + // Let's see if this code matches the GameShark. GBAGameShark(); - //We got an Un-Needed code. - if (blnUnneeded == true) - { - return; - } - //We got an Unhandled code. - else if (blnUnhandled == true) - { - return; - } - if (blnGameShark == false) - { - //We don't have a GameShark code, or we have an encrypted code? - //Further testing required. - //GameShark Decryption Method - parseString = SingleCheat; - op1 = UInt32.Parse(parseString.Remove(8, 9), NumberStyles.HexNumber); - op2 = UInt32.Parse(parseString.Remove(0, 9), NumberStyles.HexNumber); - //Tiny Encryption Algorithm - int i; - for (i = 0; i < 32; ++i) + if (_blnUnneeded) + { + return; + } + + if (_blnUnhandled) + { + return; + } + + if (!_blnGameShark) + { + // We don't have a GameShark code, or we have an encrypted code? + // Further testing required. + // GameShark Decryption Method + _parseString = _singleCheat; + + op1 = uint.Parse(_parseString.Remove(8, 9), NumberStyles.HexNumber); + op2 = uint.Parse(_parseString.Remove(0, 9), NumberStyles.HexNumber); + + // Tiny Encryption Algorithm + for (int i = 0; i < 32; ++i) { - op2 -= ((op1 << 4) + GBAGameSharkSeeds[2]) ^ (op1 + sum) ^ ((op1 >> 5) + GBAGameSharkSeeds[3]); - op1 -= ((op2 << 4) + GBAGameSharkSeeds[0]) ^ (op2 + sum) ^ ((op2 >> 5) + GBAGameSharkSeeds[1]); + op2 -= ((op1 << 4) + _gbaGameSharkSeeds[2]) ^ (op1 + sum) ^ ((op1 >> 5) + _gbaGameSharkSeeds[3]); + op1 -= ((op2 << 4) + _gbaGameSharkSeeds[0]) ^ (op2 + sum) ^ ((op2 >> 5) + _gbaGameSharkSeeds[1]); sum -= 0x9E3779B9; } - //op1 has the Address - //op2 has the Value - //Sum, is pointless? - RAMAddress = $"{op1:X8}"; - RAMValue = $"{op2:X8}"; + + // op1 has the Address + // op2 has the Value + // Sum, is pointless? + _ramAddress = $"{op1:X8}"; + _ramValue = $"{op2:X8}"; GBAGameShark(); } - //We don't do Else If after the if here because it won't allow us to verify the second code check. - if (blnGameShark == true) + + // We don't do Else If after the if here because it won't allow us to verify the second code check. + if (_blnGameShark) { - //We got a Valid GameShark Code. Hopefully. + // We got a Valid GameShark Code. Hopefully. AddGBA(); return; } - //We are going to assume that we got an Action Replay MAX code, or at least try to guess that we did. - GBAActionReplay(); + // We are going to assume that we got an Action Replay MAX code, or at least try to guess that we did. + GbaActionReplay(); - if (blnActionReplayMax == false) + if (_blnActionReplayMax == false) { - //Action Replay Max decryption Method - parseString = SingleCheat; - op1 = 0; - op2 = 0; + // Action Replay Max decryption Method + _parseString = _singleCheat; sum = 0xC6EF3720; - op1 = UInt32.Parse(parseString.Remove(8, 9), NumberStyles.HexNumber); - op2 = UInt32.Parse(parseString.Remove(0, 9), NumberStyles.HexNumber); - //Tiny Encryption Algorithm + op1 = uint.Parse(_parseString.Remove(8, 9), NumberStyles.HexNumber); + op2 = uint.Parse(_parseString.Remove(0, 9), NumberStyles.HexNumber); + + // Tiny Encryption Algorithm int j; for (j = 0; j < 32; ++j) { - op2 -= ((op1 << 4) + GBAProActionReplaySeeds[2]) ^ (op1 + sum) ^ ((op1 >> 5) + GBAProActionReplaySeeds[3]); - op1 -= ((op2 << 4) + GBAProActionReplaySeeds[0]) ^ (op2 + sum) ^ ((op2 >> 5) + GBAProActionReplaySeeds[1]); + op2 -= ((op1 << 4) + _gbaProActionReplaySeeds[2]) ^ (op1 + sum) ^ ((op1 >> 5) + _gbaProActionReplaySeeds[3]); + op1 -= ((op2 << 4) + _gbaProActionReplaySeeds[0]) ^ (op2 + sum) ^ ((op2 >> 5) + _gbaProActionReplaySeeds[1]); sum -= 0x9E3779B9; } - //op1 has the Address - //op2 has the Value - //Sum, is pointless? - RAMAddress = $"{op1:X8}"; - RAMValue = $"{op2:X8}"; - blnEncrypted = true; - GBAActionReplay(); + + // op1 has the Address + // op2 has the Value + // Sum, is pointless? + _ramAddress = $"{op1:X8}"; + _ramValue = $"{op2:X8}"; + _blnEncrypted = true; + GbaActionReplay(); } - //MessageBox.Show(blnActionReplayMax.ToString()); - //We don't do Else If after the if here because it won't allow us to verify the second code check. - if (blnActionReplayMax == true) + + // MessageBox.Show(blnActionReplayMax.ToString()); + // We don't do Else If after the if here because it won't allow us to verify the second code check. + if (_blnActionReplayMax) { - //We got a Valid Action Replay Max Code. Hopefully. + // We got a Valid Action Replay Max Code. Hopefully. AddGBA(); - //MessageBox.Show("ARM"); return; } } - //Detect CodeBreaker/GameShark SP/Xploder codes - if (SingleCheat.Length == 12 && SingleCheat.IndexOf(" ") != 8) + + // Detect CodeBreaker/GameShark SP/Xploder codes + if (_singleCheat.Length == 12 && _singleCheat.IndexOf(" ") != 8) { MessageBox.Show("Codebreaker/GameShark SP/Xploder codes are not supported by this tool.", "Tool error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; @@ -554,7 +559,7 @@ namespace BizHawk.Client.EmuHawk // && RAMAddress[6] == '0' } - if (blnCodeBreaker == true) + if (blnCodeBreaker) { //We got a Valid Code Breaker Code. Hopefully. AddGBA(); @@ -574,1670 +579,1612 @@ namespace BizHawk.Client.EmuHawk } } } + public void GBAGameShark() { - //This is for the Game Shark/Action Replay (Not Max) - if (RAMAddress.StartsWith("0") == true && RAMValue.StartsWith("000000") == true) + // This is for the Game Shark/Action Replay (Not Max) + if (_ramAddress.StartsWith("0") && _ramValue.StartsWith("000000")) { - //0aaaaaaaa 000000xx 1 Byte Constant Write - //1 Byte Size Value - byteSize = 8; - blnGameShark = true; + // 0aaaaaaaa 000000xx 1 Byte Constant Write + // 1 Byte Size Value + _byteSize = 8; + _blnGameShark = true; } - else if (RAMAddress.StartsWith("1") == true && RAMValue.StartsWith("0000") == true) + else if (_ramAddress.StartsWith("1") && _ramValue.StartsWith("0000")) { - //1aaaaaaaa 0000xxxx 2 Byte Constant Write - //2 Byte Size Value - byteSize = 16; - blnGameShark = true; + // 1aaaaaaaa 0000xxxx 2 Byte Constant Write + // 2 Byte Size Value + _byteSize = 16; + _blnGameShark = true; } - else if (RAMAddress.StartsWith("2") == true) + else if (_ramAddress.StartsWith("2")) { - //2aaaaaaaa xxxxxxxx 4 Byte Constant Write - //4 Byte Size Value - byteSize = 32; - blnGameShark = true; + // 2aaaaaaaa xxxxxxxx 4 Byte Constant Write + // 4 Byte Size Value + _byteSize = 32; + _blnGameShark = true; } - else if (RAMAddress.StartsWith("3000") == true) + else if (_ramAddress.StartsWith("3000")) { - //3000cccc xxxxxxxx aaaaaaaa 4 Byte Group Write What? Is this like a Slide Code - //4 Byte Size Value - //Sample - //30000004 01010101 03001FF0 03001FF4 03001FF8 00000000 - //write 01010101 to 3 addresses - 01010101, 03001FF0, 03001FF4, and 03001FF8. '00000000' is used for padding, to ensure the last code encrypts correctly. - //Note: The device improperly writes the Value, to the address. We should ignore that. + // 3000cccc xxxxxxxx aaaaaaaa 4 Byte Group Write What? Is this like a Slide Code + // 4 Byte Size Value + // Sample + // 30000004 01010101 03001FF0 03001FF4 03001FF8 00000000 + // write 01010101 to 3 addresses - 01010101, 03001FF0, 03001FF4, and 03001FF8. '00000000' is used for padding, to ensure the last code encrypts correctly. + // Note: The device improperly writes the Value, to the address. We should ignore that. MessageBox.Show("Sorry, this tool does not support 3000XXXX codes.", "Tool error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("6") == true && RAMValue.StartsWith("0000") == true) + else if (_ramAddress.StartsWith("6") && _ramValue.StartsWith("0000")) { - //6aaaaaaa 0000xxxx 2 Byte ROM patch - byteSize = 16; - blnGameShark = true; + // 6aaaaaaa 0000xxxx 2 Byte ROM patch + _byteSize = 16; + _blnGameShark = true; } - else if (RAMAddress.StartsWith("6") == true && RAMValue.StartsWith("1000") == true) + else if (_ramAddress.StartsWith("6") && _ramValue.StartsWith("1000")) { - //6aaaaaaa 1000xxxx 4 Byte ROM patch - byteSize = 32; - blnGameShark = true; + // 6aaaaaaa 1000xxxx 4 Byte ROM patch + _byteSize = 32; + _blnGameShark = true; } - else if (RAMAddress.StartsWith("6") == true && RAMValue.StartsWith("2000") == true) + else if (_ramAddress.StartsWith("6") && _ramValue.StartsWith("2000")) { - //6aaaaaaa 2000xxxx 8 Byte ROM patch - byteSize = 32; - blnGameShark = true; + // 6aaaaaaa 2000xxxx 8 Byte ROM patch + _byteSize = 32; + _blnGameShark = true; } - else if (RAMAddress.StartsWith("8") == true && RAMAddress[2] == '1' == true && RAMValue.StartsWith("00") == true) + else if (_ramAddress.StartsWith("8") && _ramAddress[2] == '1' && _ramValue.StartsWith("00")) { - //8a1aaaaa 000000xx 1 Byte Write when GS Button Pushed - //Treat as Constant Write. - byteSize = 8; - blnGameShark = true; + // 8a1aaaaa 000000xx 1 Byte Write when GS Button Pushed + // Treat as Constant Write. + _byteSize = 8; + _blnGameShark = true; } - else if (RAMAddress.StartsWith("8") == true && RAMAddress[2] == '2' == true && RAMValue.StartsWith("00") == true) + else if (_ramAddress.StartsWith("8") && _ramAddress[2] == '2' && _ramValue.StartsWith("00")) { - //8a2aaaaa 000000xx 2 Byte Write when GS Button Pushed - //Treat as Constant Write. - byteSize = 16; - blnGameShark = true; + // 8a2aaaaa 000000xx 2 Byte Write when GS Button Pushed + // Treat as Constant Write. + _byteSize = 16; + _blnGameShark = true; } - else if (RAMAddress.StartsWith("80F00000") == true) + else if (_ramAddress.StartsWith("80F00000")) { - //80F00000 0000xxxx Slow down when GS Button Pushed. + // 80F00000 0000xxxx Slow down when GS Button Pushed. MessageBox.Show("The code you entered is not needed by Bizhawk.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnneeded = true; - return; + _blnUnneeded = true; } - else if (RAMAddress.StartsWith("D") == true && RAMAddress.StartsWith("DEADFACE") == false && RAMValue.StartsWith("0000") == true) + else if (_ramAddress.StartsWith("D") && !_ramAddress.StartsWith("DEADFACE") && _ramValue.StartsWith("0000")) { - //Daaaaaaa 0000xxxx 2 Byte If Equal, Activate next code + // Daaaaaaa 0000xxxx 2 Byte If Equal, Activate next code MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("E0") == true) + else if (_ramAddress.StartsWith("E0")) { - //E0zzxxxx aaaaaaaa 2 Byte if Equal, Activate ZZ Lines. + // E0zzxxxx aaaaaaaa 2 Byte if Equal, Activate ZZ Lines. MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("F") == true && RAMValue.StartsWith("0000") == true) + else if (_ramAddress.StartsWith("F") && _ramValue.StartsWith("0000")) { - //Faaaaaaa 0000xxxx Hook Routine. Probably not necessary? + // Faaaaaaa 0000xxxx Hook Routine. Probably not necessary? MessageBox.Show("The code you entered is not needed by Bizhawk.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnneeded = true; - return; + _blnUnneeded = true; } - else if (RAMAddress.StartsWith("001DC0DE") == true) + else if (_ramAddress.StartsWith("001DC0DE")) { - //xxxxxxxx 001DC0DE Auto-Detect Game. Useless for Us. + // xxxxxxxx 001DC0DE Auto-Detect Game. Useless for Us. MessageBox.Show("The code you entered is not needed by Bizhawk.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnneeded = true; - return; + _blnUnneeded = true; } - else if (RAMAddress.StartsWith("DEADFACE") == true) + else if (_ramAddress.StartsWith("DEADFACE")) { - //DEADFACE 0000xxxx Change Encryption Seeds. Unsure how this works. + // DEADFACE 0000xxxx Change Encryption Seeds. Unsure how this works. MessageBox.Show("Sorry, this tool does not support DEADFACE codes.", "Tool error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - blnUnhandled = true; - return; + _blnUnhandled = true; } else { - blnGameShark = false; + _blnGameShark = false; } - //It's not a GameShark/Action Replay (Not MAX) code, so we say False. - return; + // It's not a GameShark/Action Replay (Not MAX) code, so we say False. } - public void GBAActionReplay() + + public void GbaActionReplay() { - //These checks are done on the DECYPTED code, not the Encrypted one. - //ARM Code Types + // These checks are done on the Decrypted code, not the Encrypted one. + // ARM Code Types // 1) Normal RAM Write Codes - if (RAMAddress.StartsWith("002") == true) + if (_ramAddress.StartsWith("002")) { // 0022 Should be Changed to 020 // Fill area (XXXXXXXX) to (XXXXXXXX+YYYYYY) with Byte ZZ. // XXXXXXXX // YYYYYYZZ - //This corrects the value - RAMAddress = RAMAddress.Replace("002", "020"); - blnActionReplayMax = true; - byteSize = 8; + _ramAddress = _ramAddress.Replace("002", "020"); + _blnActionReplayMax = true; + _byteSize = 8; } - else if (RAMAddress.StartsWith("022") == true) + else if (_ramAddress.StartsWith("022")) { // 0222 Should be Changed to 020 // Fill area (XXXXXXXX) to (XXXXXXXX+YYYY*2) with Halfword ZZZZ. // XXXXXXXX // YYYYZZZZ - //This corrects the value - RAMAddress = RAMAddress.Replace("022", "020"); - blnActionReplayMax = true; - byteSize = 16; + _ramAddress = _ramAddress.Replace("022", "020"); + _blnActionReplayMax = true; + _byteSize = 16; } - - else if (RAMAddress.StartsWith("042") == true) + else if (_ramAddress.StartsWith("042")) { // 0422 Should be Changed to 020 // Write the Word ZZZZZZZZ to address XXXXXXXX. // XXXXXXXX // ZZZZZZZZ - //This corrects the value - RAMAddress = RAMAddress.Replace("042", "020"); - blnActionReplayMax = true; - byteSize = 32; + _ramAddress = _ramAddress.Replace("042", "020"); + _blnActionReplayMax = true; + _byteSize = 32; } // 2) Pointer RAM Write Codes - else if (RAMAddress.StartsWith("402") == true) + else if (_ramAddress.StartsWith("402")) { // 4022 Should be Changed to 020 // Writes Byte ZZ to ([the address kept in XXXXXXXX]+[YYYYYY]). // XXXXXXXX // YYYYYYZZ - //This corrects the value - RAMAddress = RAMAddress.Replace("402", "020"); - blnActionReplayMax = true; - byteSize = 8; + _ramAddress = _ramAddress.Replace("402", "020"); + _blnActionReplayMax = true; + _byteSize = 8; } - else if (RAMAddress.StartsWith("420") == true) + else if (_ramAddress.StartsWith("420")) { // 4202 Should be Changed to 020 // Writes Halfword ZZZZ ([the address kept in XXXXXXXX]+[YYYY*2]). // XXXXXXXX // YYYYZZZZ - //This corrects the value - RAMAddress = RAMAddress.Replace("420", "020"); - blnActionReplayMax = true; - byteSize = 16; + _ramAddress = _ramAddress.Replace("420", "020"); + _blnActionReplayMax = true; + _byteSize = 16; } - else if (RAMAddress.StartsWith("422") == true) + else if (_ramAddress.StartsWith("422")) { // 442 Should be Changed to 020 // Writes the Word ZZZZZZZZ to [the address kept in XXXXXXXX]. // XXXXXXXX // ZZZZZZZZ - RAMAddress = RAMAddress.Replace("422", "020"); - blnActionReplayMax = true; - byteSize = 32; + _ramAddress = _ramAddress.Replace("422", "020"); + _blnActionReplayMax = true; + _byteSize = 32; } // 3) Add Codes - else if (RAMAddress.StartsWith("802") == true) + else if (_ramAddress.StartsWith("802")) { // 802 Should be Changed to 020 // Add the Byte ZZ to the Byte stored in XXXXXXXX. // XXXXXXXX // 000000ZZ //RAMAddress = RAMAddress.Replace("8022", "020"); - byteSize = 8; + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("822") == true & RAMAddress.StartsWith("8222") == false) + else if (_ramAddress.StartsWith("822") && !_ramAddress.StartsWith("8222")) { // 822 Should be Changed to 020 // Add the Halfword ZZZZ to the Halfword stored in XXXXXXXX. // XXXXXXXX // 0000ZZZZ //RAMAddress = RAMAddress.Replace("822", "020"); - byteSize = 16; + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("842") == true) + else if (_ramAddress.StartsWith("842")) { - //NOTE! - //This is duplicated below with different function results. + // NOTE! + // This is duplicated below with different function results. // 842 Should be Changed to 020 // Add the Word ZZZZ to the Halfword stored in XXXXXXXX. // XXXXXXXX // ZZZZZZZZ //RAMAddress = RAMAddress.Replace("842", "020"); - byteSize = 32; + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } // 4) Write to $4000000 (IO Registers!) - else if (RAMAddress.StartsWith("C6000130") == true) + else if (_ramAddress.StartsWith("C6000130")) { // C6000130 Should be Changed to 00000130 // Write the Halfword ZZZZ to the address $4XXXXXX // 00XXXXXX // 0000ZZZZ - RAMAddress = RAMAddress.Replace("C6000130", "00000130"); - blnActionReplayMax = true; - byteSize = 16; + _ramAddress = _ramAddress.Replace("C6000130", "00000130"); + _blnActionReplayMax = true; + _byteSize = 16; } - else if (RAMAddress.StartsWith("C7000130") == true) + else if (_ramAddress.StartsWith("C7000130")) { // C7000130 Should be Changed to 00000130 // Write the Word ZZZZZZZZ to the address $4XXXXXX // 00XXXXXX // ZZZZZZZZ - RAMAddress = RAMAddress.Replace("C7000130", "00000130"); - blnActionReplayMax = true; - byteSize = 32; + _ramAddress = _ramAddress.Replace("C7000130", "00000130"); + _blnActionReplayMax = true; + _byteSize = 32; } // 5) If Equal Code (= Joker Code) - else if (RAMAddress.StartsWith("082") == true) + else if (_ramAddress.StartsWith("082")) { // 082 Should be Changed to 020 // If Byte at XXXXXXXX = ZZ then execute next code. // XXXXXXXX // 000000ZZ - RAMAddress = RAMAddress.Replace("082", "020"); - byteSize = 8; + _ramAddress = _ramAddress.Replace("082", "020"); + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("482") == true) + else if (_ramAddress.StartsWith("482")) { // 482 Should be Changed to 020 // If Byte at XXXXXXXX = ZZ then execute next 2 codes. // XXXXXXXX // 000000ZZ - RAMAddress = RAMAddress.Replace("482", "020"); - byteSize = 8; + _ramAddress = _ramAddress.Replace("482", "020"); + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("882") == true) + else if (_ramAddress.StartsWith("882")) { // 882 Should be Changed to 020 // If Byte at XXXXXXXX = ZZ execute all the codes below this one in the same row (else execute none of the codes below). // XXXXXXXX // 000000ZZ - RAMAddress = RAMAddress.Replace("882", "020"); - byteSize = 8; + _ramAddress = _ramAddress.Replace("882", "020"); + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("C82") == true) + else if (_ramAddress.StartsWith("C82")) { // C82 Should be Changed to 020 // While Byte at XXXXXXXX <> ZZ turn off all codes. // XXXXXXXX // 000000ZZ - RAMAddress = RAMAddress.Replace("C82", "020"); - byteSize = 8; + _ramAddress = _ramAddress.Replace("C82", "020"); + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("0A2") == true) + else if (_ramAddress.StartsWith("0A2")) { // 0A2 Should be Changed to 020 // If Halfword at XXXXXXXX = ZZZZ then execute next code. // XXXXXXXX // 0000ZZZZ - RAMAddress = RAMAddress.Replace("0A2", "020"); - byteSize = 16; + _ramAddress = _ramAddress.Replace("0A2", "020"); + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("4A2") == true) + else if (_ramAddress.StartsWith("4A2")) { // 4A2 Should be Changed to 020 // If Halfword at XXXXXXXX = ZZZZ then execute next 2 codes. // XXXXXXXX // 0000ZZZZ - RAMAddress = RAMAddress.Replace("4A2", "020"); - byteSize = 16; + _ramAddress = _ramAddress.Replace("4A2", "020"); + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("8A2") == true) + else if (_ramAddress.StartsWith("8A2")) { // 8A2 Should be Changed to 020 // If Halfword at XXXXXXXX = ZZZZ execute all the codes below this one in the same row (else execute none of the codes below). // XXXXXXXX // 0000ZZZZ - RAMAddress = RAMAddress.Replace("8A2", "020"); - byteSize = 16; + _ramAddress = _ramAddress.Replace("8A2", "020"); + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("CA2") == true) + else if (_ramAddress.StartsWith("CA2")) { // CA2 Should be Changed to 020 // While Halfword at XXXXXXXX <> ZZZZ turn off all codes. // XXXXXXXX // 0000ZZZZ - RAMAddress = RAMAddress.Replace("CA2", "020"); - byteSize = 16; + _ramAddress = _ramAddress.Replace("CA2", "020"); + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("0C2") == true) + else if (_ramAddress.StartsWith("0C2")) { // 0C2 Should be Changed to 020 // If Word at XXXXXXXX = ZZZZZZZZ then execute next code. // XXXXXXXX // ZZZZZZZZ - RAMAddress = RAMAddress.Replace("0C2", "020"); - byteSize = 32; + _ramAddress = _ramAddress.Replace("0C2", "020"); + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("4C2") == true) + else if (_ramAddress.StartsWith("4C2")) { // 4C2 Should be Changed to 020 // If Word at XXXXXXXX = ZZZZZZZZ then execute next 2 codes. // XXXXXXXX // ZZZZZZZZ - RAMAddress = RAMAddress.Replace("4C2", "020"); - byteSize = 32; + _ramAddress = _ramAddress.Replace("4C2", "020"); + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("8C2") == true) + else if (_ramAddress.StartsWith("8C2")) { // 8C2 Should be Changed to 020 // If Word at XXXXXXXX = ZZZZZZZZ execute all the codes below this one in the same row (else execute none of the codes below). // XXXXXXXX // ZZZZZZZZ - RAMAddress = RAMAddress.Replace("8C2", "020"); - byteSize = 32; + _ramAddress = _ramAddress.Replace("8C2", "020"); + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("CC2") == true) + else if (_ramAddress.StartsWith("CC2")) { // CC2 Should be Changed to 020 // While Word at XXXXXXXX <> ZZZZZZZZ turn off all codes. // XXXXXXXX // ZZZZZZZZ - RAMAddress = RAMAddress.Replace("CC2", "020"); - byteSize = 32; + _ramAddress = _ramAddress.Replace("CC2", "020"); + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } // 6) If Different Code - else if (RAMAddress.StartsWith("102") == true) + else if (_ramAddress.StartsWith("102")) { // 102 Should be Changed to 020 // If Byte at XXXXXXXX <> ZZ then execute next code. // XXXXXXXX // 000000ZZ - RAMAddress = RAMAddress.Replace("102", "020"); - byteSize = 8; + _ramAddress = _ramAddress.Replace("102", "020"); + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("502") == true) + else if (_ramAddress.StartsWith("502")) { // 502 Should be Changed to 020 // If Byte at XXXXXXXX <> ZZ then execute next 2 codes. // XXXXXXXX // 000000ZZ - RAMAddress = RAMAddress.Replace("502", "020"); - byteSize = 8; + _ramAddress = _ramAddress.Replace("502", "020"); + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("902") == true) + else if (_ramAddress.StartsWith("902")) { // 902 Should be Changed to 020 // If Byte at XXXXXXXX <> ZZ execute all the codes below this one in the same row (else execute none of the codes below). // XXXXXXXX // 000000ZZ - RAMAddress = RAMAddress.Replace("902", "020"); - byteSize = 8; + _ramAddress = _ramAddress.Replace("902", "020"); + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("D02") == true) + else if (_ramAddress.StartsWith("D02")) { // D02 Should be Changed to 020 // While Byte at XXXXXXXX = ZZ turn off all codes. // XXXXXXXX // 000000ZZ - RAMAddress = RAMAddress.Replace("D02", "020"); - byteSize = 8; + _ramAddress = _ramAddress.Replace("D02", "020"); + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("122") == true) + else if (_ramAddress.StartsWith("122")) { // 122 Should be Changed to 020 // If Halfword at XXXXXXXX <> ZZZZ then execute next code. // XXXXXXXX // 0000ZZZZ - RAMAddress = RAMAddress.Replace("122", "020"); - byteSize = 16; + _ramAddress = _ramAddress.Replace("122", "020"); + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("522") == true) + else if (_ramAddress.StartsWith("522")) { // 522 Should be Changed to 020 // If Halfword at XXXXXXXX <> ZZZZ then execute next 2 codes. // XXXXXXXX // 0000ZZZZ - RAMAddress = RAMAddress.Replace("522", "020"); - byteSize = 16; + _ramAddress = _ramAddress.Replace("522", "020"); + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("922") == true) + else if (_ramAddress.StartsWith("922")) { // 922 Should be Changed to 020 // If Halfword at XXXXXXXX <> ZZZZ disable all the codes below this one. // XXXXXXXX // 0000ZZZZ - RAMAddress = RAMAddress.Replace("922", "020"); - byteSize = 16; + _ramAddress = _ramAddress.Replace("922", "020"); + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("D22") == true) + else if (_ramAddress.StartsWith("D22")) { // D22 Should be Changed to 020 // While Halfword at XXXXXXXX = ZZZZ turn off all codes. // XXXXXXXX // 0000ZZZZ - RAMAddress = RAMAddress.Replace("D22", "020"); - byteSize = 16; + _ramAddress = _ramAddress.Replace("D22", "020"); + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("142") == true) + else if (_ramAddress.StartsWith("142")) { // 142 Should be Changed to 020 // If Word at XXXXXXXX <> ZZZZZZZZ then execute next code. // XXXXXXXX // ZZZZZZZZ - RAMAddress = RAMAddress.Replace("142", "020"); - byteSize = 32; + _ramAddress = _ramAddress.Replace("142", "020"); + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("542") == true) + else if (_ramAddress.StartsWith("542")) { // 542 Should be Changed to 020 // If Word at XXXXXXXX <> ZZZZZZZZ then execute next 2 codes. // XXXXXXXX // ZZZZZZZZ - RAMAddress = RAMAddress.Replace("542", "020"); - byteSize = 32; + _ramAddress = _ramAddress.Replace("542", "020"); + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("942") == true) + else if (_ramAddress.StartsWith("942")) { // 942 Should be Changed to 020 // If Word at XXXXXXXX <> ZZZZZZZZ disable all the codes below this one. // XXXXXXXX // ZZZZZZZZ - RAMAddress = RAMAddress.Replace("942", "020"); - byteSize = 32; + _ramAddress = _ramAddress.Replace("942", "020"); + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("D42") == true) + else if (_ramAddress.StartsWith("D42")) { // D42 Should be Changed to 020 // While Word at XXXXXXXX = ZZZZZZZZ turn off all codes. // XXXXXXXX // ZZZZZZZZ - RAMAddress = RAMAddress.Replace("D42", "020"); - byteSize = 32; + _ramAddress = _ramAddress.Replace("D42", "020"); + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } // 7) // [If Byte at address XXXXXXXX is lower than ZZ] (signed) Code // Signed means : For bytes : values go from -128 to +127. For Halfword : values go from -32768/+32767. For Words : values go from -2147483648 to 2147483647. For exemple, for the Byte comparison, 7F (127) will be > to FF (-1). - // - // - else if (RAMAddress.StartsWith("182") == true) + else if (_ramAddress.StartsWith("182")) { // 182 Should be Changed to 020 // If ZZ > Byte at XXXXXXXX then execute next code. // XXXXXXXX // 000000ZZ - if (RAMAddress.StartsWith("182") == true) + if (_ramAddress.StartsWith("182")) { - RAMAddress = RAMAddress.Replace("182", "020"); + _ramAddress = _ramAddress.Replace("182", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("582") == true) + else if (_ramAddress.StartsWith("582")) { // 582 Should be Changed to 020 // If ZZ > Byte at XXXXXXXX then execute next 2 codes. // XXXXXXXX // 000000ZZ - if (RAMAddress.StartsWith("582") == true) + if (_ramAddress.StartsWith("582")) { - RAMAddress = RAMAddress.Replace("582", "020"); + _ramAddress = _ramAddress.Replace("582", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("982") == true) + else if (_ramAddress.StartsWith("982")) { // 982 Should be Changed to 020 // If ZZ > Byte at XXXXXXXX then execute all following codes in the same row (else execute none of the codes below). // XXXXXXXX // 000000ZZ - if (RAMAddress.StartsWith("982") == true) + if (_ramAddress.StartsWith("982")) { - RAMAddress = RAMAddress.Replace("982", "020"); + _ramAddress = _ramAddress.Replace("982", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("D82") == true || (RAMAddress.StartsWith("E82") == true)) + else if (_ramAddress.StartsWith("D82") || _ramAddress.StartsWith("E82")) { // D82 or E82 Should be Changed to 020 // While ZZ <= Byte at XXXXXXXX turn off all codes. // XXXXXXXX // 000000ZZ - if (RAMAddress.StartsWith("D82") == true) + if (_ramAddress.StartsWith("D82")) { - RAMAddress = RAMAddress.Replace("D82", "020"); + _ramAddress = _ramAddress.Replace("D82", "020"); } - else if ((RAMAddress.StartsWith("E82") == true)) + else if (_ramAddress.StartsWith("E82")) { - RAMAddress = RAMAddress.Replace("E82", "020"); + _ramAddress = _ramAddress.Replace("E82", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("1A2") == true) + else if (_ramAddress.StartsWith("1A2")) { // 1A2 Should be Changed to 020 // If ZZZZ > Halfword at XXXXXXXX then execute next line. // XXXXXXXX 0000ZZZZ - if (RAMAddress.StartsWith("1A2") == true) + if (_ramAddress.StartsWith("1A2")) { - RAMAddress = RAMAddress.Replace("1A2", "020"); + _ramAddress = _ramAddress.Replace("1A2", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("5A2") == true) + else if (_ramAddress.StartsWith("5A2")) { // 5A2 Should be Changed to 020 // If ZZZZ > Halfword at XXXXXXXX then execute next 2 lines. // XXXXXXXX 0000ZZZZ - if (RAMAddress.StartsWith("5A2") == true) + if (_ramAddress.StartsWith("5A2")) { - RAMAddress = RAMAddress.Replace("5A2", "020"); + _ramAddress = _ramAddress.Replace("5A2", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("9A2") == true) + else if (_ramAddress.StartsWith("9A2")) { // 9A2 Should be Changed to 020 // If ZZZZ > Halfword at XXXXXXXX then execute all following codes in the same row (else execute none of the codes below). // XXXXXXXX 0000ZZZZ - if (RAMAddress.StartsWith("9A2") == true) + if (_ramAddress.StartsWith("9A2")) { - RAMAddress = RAMAddress.Replace("9A2", "020"); + _ramAddress = _ramAddress.Replace("9A2", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("DA2") == true) + else if (_ramAddress.StartsWith("DA2")) { // DA2 Should be Changed to 020 // While ZZZZ <= Halfword at XXXXXXXX turn off all codes. // XXXXXXXX 0000ZZZZ - if (RAMAddress.StartsWith("DA2") == true) + if (_ramAddress.StartsWith("DA2")) { - RAMAddress = RAMAddress.Replace("DA2", "020"); + _ramAddress = _ramAddress.Replace("DA2", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("1C2") == true) + else if (_ramAddress.StartsWith("1C2")) { // 1C2 or Should be Changed to 020 // If ZZZZ > Word at XXXXXXXX then execute next line. // XXXXXXXX 0000ZZZZ - if (RAMAddress.StartsWith("1C2") == true) + if (_ramAddress.StartsWith("1C2")) { - RAMAddress = RAMAddress.Replace("1C2", "020"); + _ramAddress = _ramAddress.Replace("1C2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("5C2") == true) + else if (_ramAddress.StartsWith("5C2")) { // 5C2 Should be Changed to 020 // If ZZZZ > Word at XXXXXXXX then execute next 2 lines. // XXXXXXXX 0000ZZZZ - if (RAMAddress.StartsWith("5C2") == true) + if (_ramAddress.StartsWith("5C2")) { - RAMAddress = RAMAddress.Replace("5C2", "020"); + _ramAddress = _ramAddress.Replace("5C2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("9C2") == true) + else if (_ramAddress.StartsWith("9C2")) { // 9C2 Should be Changed to 020 // If ZZZZZZZZ > Word at XXXXXXXX then execute all following codes in the same row (else execute none of the codes below). // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("9C2") == true) + if (_ramAddress.StartsWith("9C2")) { - RAMAddress = RAMAddress.Replace("9C2", "020"); + _ramAddress = _ramAddress.Replace("9C2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("DC2") == true) + else if (_ramAddress.StartsWith("DC2")) { // DC2 Should be Changed to 020 // While ZZZZZZZZ <= Word at XXXXXXXX turn off all codes. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("DC2") == true) + if (_ramAddress.StartsWith("DC2")) { - RAMAddress = RAMAddress.Replace("DC2", "020"); + _ramAddress = _ramAddress.Replace("DC2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } // 8) // [If Byte at address XXXXXXXX is higher than ZZ] (signed) Code // Signed means : For bytes : values go from -128 to +127. For Halfword : values go from -32768/+32767. For Words : values go from -2147483648 to 2147483647. For exemple, for the Byte comparison, 7F (127) will be > to FF (-1). - // - else if (RAMAddress.StartsWith("202") == true) + else if (_ramAddress.StartsWith("202")) { // 202 Should be Changed to 020 // If ZZ < Byte at XXXXXXXX then execute next code. // XXXXXXXX // 000000ZZ - if (RAMAddress.StartsWith("202") == true) + if (_ramAddress.StartsWith("202")) { - RAMAddress = RAMAddress.Replace("202", "020"); + _ramAddress = _ramAddress.Replace("202", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("602") == true) + else if (_ramAddress.StartsWith("602")) { // 602 Should be Changed to 020 // If ZZ < Byte at XXXXXXXX then execute next 2 codes. // XXXXXXXX // 000000ZZ - if (RAMAddress.StartsWith("602") == true) + if (_ramAddress.StartsWith("602")) { - RAMAddress = RAMAddress.Replace("602", "020"); + _ramAddress = _ramAddress.Replace("602", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("A02") == true) + else if (_ramAddress.StartsWith("A02")) { // A02 Should be Changed to 020 // If ZZ < Byte at XXXXXXXX then execute all following codes in the same row (else execute none of the codes below). // XXXXXXXX // 000000ZZ - if (RAMAddress.StartsWith("A02") == true) + if (_ramAddress.StartsWith("A02")) { - RAMAddress = RAMAddress.Replace("A02", "020"); + _ramAddress = _ramAddress.Replace("A02", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("E02") == true) + else if (_ramAddress.StartsWith("E02")) { // E02 Should be Changed to 020 // While ZZ => Byte at XXXXXXXX turn off all codes. // XXXXXXXX // 000000ZZ - if (RAMAddress.StartsWith("E02") == true) + if (_ramAddress.StartsWith("E02")) { - RAMAddress = RAMAddress.Replace("E02", "020"); + _ramAddress = _ramAddress.Replace("E02", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("222") == true) + else if (_ramAddress.StartsWith("222")) { // 222 Should be Changed to 020 // If ZZZZ < Halfword at XXXXXXXX then execute next line. // XXXXXXXX 0000ZZZZ - if (RAMAddress.StartsWith("222") == true) + if (_ramAddress.StartsWith("222")) { - RAMAddress = RAMAddress.Replace("222", "020"); + _ramAddress = _ramAddress.Replace("222", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("622") == true) + else if (_ramAddress.StartsWith("622")) { // 622 Should be Changed to 020 // If ZZZZ < Halfword at XXXXXXXX then execute next 2 lines. // XXXXXXXX 0000ZZZZ - if (RAMAddress.StartsWith("622") == true) + if (_ramAddress.StartsWith("622")) { - RAMAddress = RAMAddress.Replace("622", "020"); + _ramAddress = _ramAddress.Replace("622", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("A22") == true) + else if (_ramAddress.StartsWith("A22")) { // A22 Should be Changed to 020 // If ZZZZ < Halfword at XXXXXXXX then execute all following codes in the same row (else execute none of the codes below). // XXXXXXXX 0000ZZZZ - if (RAMAddress.StartsWith("A22") == true) + if (_ramAddress.StartsWith("A22")) { - RAMAddress = RAMAddress.Replace("A22", "020"); + _ramAddress = _ramAddress.Replace("A22", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("E22") == true) + else if (_ramAddress.StartsWith("E22")) { // E22 Should be Changed to 020 // While ZZZZ => Halfword at XXXXXXXX turn off all codes. // XXXXXXXX 0000ZZZZ - if (RAMAddress.StartsWith("E22") == true) + if (_ramAddress.StartsWith("E22")) { - RAMAddress = RAMAddress.Replace("E22", "020"); + _ramAddress = _ramAddress.Replace("E22", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("242") == true) + else if (_ramAddress.StartsWith("242")) { // 242 Should be Changed to 020 // If ZZZZ < Halfword at XXXXXXXX then execute next line. // XXXXXXXX 0000ZZZZ - if (RAMAddress.StartsWith("242") == true) + if (_ramAddress.StartsWith("242")) { - RAMAddress = RAMAddress.Replace("242", "020"); + _ramAddress = _ramAddress.Replace("242", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("642") == true) + else if (_ramAddress.StartsWith("642")) { // 642 Should be Changed to 020 // If ZZZZ < Halfword at XXXXXXXX then execute next 2 lines. // XXXXXXXX 0000ZZZZ - if (RAMAddress.StartsWith("642") == true) + if (_ramAddress.StartsWith("642")) { - RAMAddress = RAMAddress.Replace("642", "020"); + _ramAddress = _ramAddress.Replace("642", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("A42") == true) + else if (_ramAddress.StartsWith("A42")) { // A42 Should be Changed to 020 // If ZZZZ < Halfword at XXXXXXXX then execute all following codes in the same row (else execute none of the codes below). // XXXXXXXX 0000ZZZZ - if (RAMAddress.StartsWith("A42") == true) + if (_ramAddress.StartsWith("A42")) { - RAMAddress = RAMAddress.Replace("A42", "020"); + _ramAddress = _ramAddress.Replace("A42", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("E42") == true) + else if (_ramAddress.StartsWith("E42")) { // E42 Should be Changed to 020 // While ZZZZ => Halfword at XXXXXXXX turn off all codes. // XXXXXXXX 0000ZZZZ - if (RAMAddress.StartsWith("E42") == true) + if (_ramAddress.StartsWith("E42")) { - RAMAddress = RAMAddress.Replace("E42", "020"); + _ramAddress = _ramAddress.Replace("E42", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } // 9) // [If Value at adress XXXXXXXX is lower than...] (unsigned) Code // Unsigned means : For bytes : values go from 0 to +255. For Halfword : values go from 0 to +65535. For Words : values go from 0 to 4294967295. For exemple, for the Byte comparison, 7F (127) will be < to FF (255). - // - // - else if (RAMAddress.StartsWith("282") == true) + else if (_ramAddress.StartsWith("282")) { // 282 Should be Changed to 020 // If ZZZZZZZZ > Byte at XXXXXXXX then execute next line. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("282") == true) + if (_ramAddress.StartsWith("282")) { - RAMAddress = RAMAddress.Replace("282", "020"); + _ramAddress = _ramAddress.Replace("282", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("682") == true) + else if (_ramAddress.StartsWith("682")) { // 682 Should be Changed to 020 // If ZZZZZZZZ > Byte at XXXXXXXX then execute next 2 lines. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("682") == true) + if (_ramAddress.StartsWith("682")) { - RAMAddress = RAMAddress.Replace("682", "020"); + _ramAddress = _ramAddress.Replace("682", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("A82") == true) + else if (_ramAddress.StartsWith("A82")) { // A82 Should be Changed to 020 // If ZZZZZZZZ > Byte at XXXXXXXX then execute all following codes in the same row (else execute none of the codes below). // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("A82") == true) + if (_ramAddress.StartsWith("A82")) { - RAMAddress = RAMAddress.Replace("A82", "020"); + _ramAddress = _ramAddress.Replace("A82", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("2A2") == true) + else if (_ramAddress.StartsWith("2A2")) { // 2A2 Should be Changed to 020 // If ZZZZZZZZ > Halfword at XXXXXXXX then execute next line. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("2A2") == true) + if (_ramAddress.StartsWith("2A2")) { - RAMAddress = RAMAddress.Replace("2A2", "020"); + _ramAddress = _ramAddress.Replace("2A2", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("6A2") == true) + else if (_ramAddress.StartsWith("6A2")) { // 6A2 Should be Changed to 020 // If ZZZZZZZZ > Halfword at XXXXXXXX then execute next 2 lines. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("6A2") == true) + if (_ramAddress.StartsWith("6A2")) { - RAMAddress = RAMAddress.Replace("6A2", "020"); + _ramAddress = _ramAddress.Replace("6A2", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("AA2") == true) + else if (_ramAddress.StartsWith("AA2")) { // AA2 Should be Changed to 020 // If ZZZZZZZZ > Halfword at XXXXXXXX then execute all following codes in the same row (else execute none of the codes below). // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("AA2") == true) + if (_ramAddress.StartsWith("AA2")) { - RAMAddress = RAMAddress.Replace("AA2", "020"); + _ramAddress = _ramAddress.Replace("AA2", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("EA2") == true) + else if (_ramAddress.StartsWith("EA2")) { // EA2 Should be Changed to 020 // While ZZZZZZZZ <= Halfword at XXXXXXXX turn off all codes. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("EA2") == true) + if (_ramAddress.StartsWith("EA2")) { - RAMAddress = RAMAddress.Replace("EA2", "020"); + _ramAddress = _ramAddress.Replace("EA2", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("2C2") == true) + else if (_ramAddress.StartsWith("2C2")) { // 2C2 Should be Changed to 020 // If ZZZZZZZZ > Word at XXXXXXXX then execute next line. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("2C2") == true) + if (_ramAddress.StartsWith("2C2")) { - RAMAddress = RAMAddress.Replace("2C2", "020"); + _ramAddress = _ramAddress.Replace("2C2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("6C2") == true) + else if (_ramAddress.StartsWith("6C2")) { // 6C2 Should be Changed to 020 // If ZZZZZZZZ > Word at XXXXXXXX then execute next 2 lines. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("6C2") == true) + if (_ramAddress.StartsWith("6C2")) { - RAMAddress = RAMAddress.Replace("6C2", "020"); + _ramAddress = _ramAddress.Replace("6C2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("AC2") == true) + else if (_ramAddress.StartsWith("AC2")) { // AC2 Should be Changed to 020 // If ZZZZZZZZ > Word at XXXXXXXX then execute all following codes in the same row (else execute none of the codes below). // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("AC2") == true) + if (_ramAddress.StartsWith("AC2")) { - RAMAddress = RAMAddress.Replace("AC2", "020"); + _ramAddress = _ramAddress.Replace("AC2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("EC2") == true) + else if (_ramAddress.StartsWith("EC2")) { // EC2 Should be Changed to 020 // While ZZZZZZZZ <= Word at XXXXXXXX turn off all codes. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("EC2") == true) + if (_ramAddress.StartsWith("EC2")) { - RAMAddress = RAMAddress.Replace("EC2", "020"); + _ramAddress = _ramAddress.Replace("EC2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } // 10) - // [If Value at adress XXXXXXXX is higher than...] (unsigned) Code + // [If Value at address XXXXXXXX is higher than...] (unsigned) Code // Unsigned means For bytes : values go from 0 to +255. For Halfword : values go from 0 to +65535. For Words : values go from 0 to 4294967295. For exemple, for the Byte comparison, 7F (127) will be < to FF (255). - else if (RAMAddress.StartsWith("302") == true) + else if (_ramAddress.StartsWith("302")) { // 302 Should be Changed to 020 // If ZZZZZZZZ < Byte at XXXXXXXX then execute next line.. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("302") == true) + if (_ramAddress.StartsWith("302")) { - RAMAddress = RAMAddress.Replace("302", "020"); + _ramAddress = _ramAddress.Replace("302", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("702") == true) + else if (_ramAddress.StartsWith("702")) { // 702 Should be Changed to 020 // If ZZZZZZZZ < Byte at XXXXXXXX then execute next line.. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("702") == true) + if (_ramAddress.StartsWith("702")) { - RAMAddress = RAMAddress.Replace("702", "020"); + _ramAddress = _ramAddress.Replace("702", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("B02") == true) + else if (_ramAddress.StartsWith("B02")) { // B02 Should be Changed to 020 // If ZZZZZZZZ < Byte at XXXXXXXX then execute next line.. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("B02") == true) + if (_ramAddress.StartsWith("B02")) { - RAMAddress = RAMAddress.Replace("B02", "020"); + _ramAddress = _ramAddress.Replace("B02", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("F02") == true) + else if (_ramAddress.StartsWith("F02")) { // F02 Should be Changed to 020 // If ZZZZZZZZ < Byte at XXXXXXXX then execute next line.. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("F02") == true) + if (_ramAddress.StartsWith("F02")) { - RAMAddress = RAMAddress.Replace("F02", "020"); + _ramAddress = _ramAddress.Replace("F02", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("322") == true) + else if (_ramAddress.StartsWith("322")) { // 322 Should be Changed to 020 - //If ZZZZZZZZ < Halfword at XXXXXXXX then execute next line. + // If ZZZZZZZZ < Halfword at XXXXXXXX then execute next line. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("322") == true) + if (_ramAddress.StartsWith("322")) { - RAMAddress = RAMAddress.Replace("322", "020"); + _ramAddress = _ramAddress.Replace("322", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("722") == true) + else if (_ramAddress.StartsWith("722")) { // 722 Should be Changed to 020 // If ZZZZZZZZ < Halfword at XXXXXXXX then execute next line.. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("722") == true) + if (_ramAddress.StartsWith("722")) { - RAMAddress = RAMAddress.Replace("722", "020"); + _ramAddress = _ramAddress.Replace("722", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("B22") == true) + else if (_ramAddress.StartsWith("B22")) { // B22 Should be Changed to 020 // If ZZZZZZZZ < Halfword at XXXXXXXX then execute next line.. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("B22") == true) + if (_ramAddress.StartsWith("B22")) { - RAMAddress = RAMAddress.Replace("B22", "020"); + _ramAddress = _ramAddress.Replace("B22", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("F22") == true) + else if (_ramAddress.StartsWith("F22")) { // F22 Should be Changed to 020 // If ZZZZZZZZ < Halfword at XXXXXXXX then execute next line.. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("F22") == true) + if (_ramAddress.StartsWith("F22")) { - RAMAddress = RAMAddress.Replace("F22", "020"); + _ramAddress = _ramAddress.Replace("F22", "020"); } - byteSize = 16; + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - - else if (RAMAddress.StartsWith("342") == true) + else if (_ramAddress.StartsWith("342")) { // 342 Should be Changed to 020 - //If ZZZZZZZZ < Halfword at XXXXXXXX then execute next line. + // If ZZZZZZZZ < Halfword at XXXXXXXX then execute next line. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("342") == true) + if (_ramAddress.StartsWith("342")) { - RAMAddress = RAMAddress.Replace("342", "020"); + _ramAddress = _ramAddress.Replace("342", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("742") == true) + else if (_ramAddress.StartsWith("742")) { // 742 Should be Changed to 020 // If ZZZZZZZZ < Halfword at XXXXXXXX then execute next line.. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("742") == true) + if (_ramAddress.StartsWith("742")) { - RAMAddress = RAMAddress.Replace("742", "020"); + _ramAddress = _ramAddress.Replace("742", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("B42") == true) + else if (_ramAddress.StartsWith("B42")) { // B42 Should be Changed to 020 // If ZZZZZZZZ < Halfword at XXXXXXXX then execute next line.. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("B42") == true) + if (_ramAddress.StartsWith("B42")) { - RAMAddress = RAMAddress.Replace("B42", "020"); + _ramAddress = _ramAddress.Replace("B42", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("F42") == true) + else if (_ramAddress.StartsWith("F42")) { // F42 Should be Changed to 020 // If ZZZZZZZZ < Halfword at XXXXXXXX then execute next line.. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("F42") == true) + if (_ramAddress.StartsWith("F42")) { - RAMAddress = RAMAddress.Replace("F42", "020"); + _ramAddress = _ramAddress.Replace("F42", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } // 11) If AND Code - else if (RAMAddress.StartsWith("382") == true) + else if (_ramAddress.StartsWith("382")) { // 382 Should be Changed to 020 // If ZZ AND Byte at XXXXXXXX <> 0 (= True) then execute next code. // XXXXXXXX // 000000ZZ - if (RAMAddress.StartsWith("382") == true) + if (_ramAddress.StartsWith("382")) { - RAMAddress = RAMAddress.Replace("382", "020"); + _ramAddress = _ramAddress.Replace("382", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("782") == true) + else if (_ramAddress.StartsWith("782")) { // 782 Should be Changed to 020 // If ZZ AND Byte at XXXXXXXX <> 0 (= True) then execute next 2 codes. // XXXXXXXX // 000000ZZ - if (RAMAddress.StartsWith("782") == true) + if (_ramAddress.StartsWith("782")) { - RAMAddress = RAMAddress.Replace("782", "020"); + _ramAddress = _ramAddress.Replace("782", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("B82") == true) + else if (_ramAddress.StartsWith("B82")) { // B82 Should be Changed to 020 // If ZZ AND Byte at XXXXXXXX <> 0 (= True) then execute all following codes in the same row (else execute none of the codes below). // XXXXXXXX // 000000ZZ - if (RAMAddress.StartsWith("B82") == true) + if (_ramAddress.StartsWith("B82")) { - RAMAddress = RAMAddress.Replace("B82", "020"); + _ramAddress = _ramAddress.Replace("B82", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("F82") == true) + else if (_ramAddress.StartsWith("F82")) { // F82 Should be Changed to 020 // While ZZ AND Byte at XXXXXXXX = 0 (= False) then turn off all codes. // XXXXXXXX // 000000ZZ - if (RAMAddress.StartsWith("F82") == true) + if (_ramAddress.StartsWith("F82")) { - RAMAddress = RAMAddress.Replace("F82", "020"); + _ramAddress = _ramAddress.Replace("F82", "020"); } - byteSize = 8; + + _byteSize = 8; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("3A2") == true) + else if (_ramAddress.StartsWith("3A2")) { // 3A2 Should be Changed to 020 // If ZZZZ AND Halfword at XXXXXXXX <> 0 (= True) then execute next code. // XXXXXXXX // 0000ZZZZ - if (RAMAddress.StartsWith("3A2") == true) + if (_ramAddress.StartsWith("3A2")) { - RAMAddress = RAMAddress.Replace("3A2", "020"); + _ramAddress = _ramAddress.Replace("3A2", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("7A2") == true) + else if (_ramAddress.StartsWith("7A2")) { // 7A2 Should be Changed to 020 // If ZZZZ AND Halfword at XXXXXXXX <> 0 (= True) then execute next 2 codes. // XXXXXXXX // 0000ZZZZ - if (RAMAddress.StartsWith("7A2") == true) + if (_ramAddress.StartsWith("7A2")) { - RAMAddress = RAMAddress.Replace("7A2", "020"); + _ramAddress = _ramAddress.Replace("7A2", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("3C2") == true) + else if (_ramAddress.StartsWith("3C2")) { // 3C2 Should be Changed to 020 // If ZZZZZZZZ AND Word at XXXXXXXX <> 0 (= True) then execute next code. // XXXXXXXX // ZZZZZZZZ - if (RAMAddress.StartsWith("3C2") == true) + if (_ramAddress.StartsWith("3C2")) { - RAMAddress = RAMAddress.Replace("3C2", "020"); + _ramAddress = _ramAddress.Replace("3C2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("7C2") == true) + else if (_ramAddress.StartsWith("7C2")) { // 7C2 Should be Changed to 020 // If ZZZZZZZZ AND Word at XXXXXXXX <> 0 (= True) then execute next 2 codes. // XXXXXXXX // ZZZZZZZZ - if (RAMAddress.StartsWith("7C2") == true) + if (_ramAddress.StartsWith("7C2")) { - RAMAddress = RAMAddress.Replace("7C2", "020"); + _ramAddress = _ramAddress.Replace("7C2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("BC2") == true) + else if (_ramAddress.StartsWith("BC2")) { // BC2 Should be Changed to 020 // If ZZZZZZZZ AND Word at XXXXXXXX <> 0 (= True) then execute all following codes in the same row (else execute none of the codes below). // XXXXXXXX // ZZZZZZZZ - if (RAMAddress.StartsWith("BC2") == true) + if (_ramAddress.StartsWith("BC2")) { - RAMAddress = RAMAddress.Replace("BC2", "020"); + _ramAddress = _ramAddress.Replace("BC2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("FC2") == true) + else if (_ramAddress.StartsWith("FC2")) { // FC2 Should be Changed to 020 // While ZZZZZZZZ AND Word at XXXXXXXX = 0 (= False) then turn off all codes. // XXXXXXXX // ZZZZZZZZ - if (RAMAddress.StartsWith("FC2") == true) + if (_ramAddress.StartsWith("FC2")) { - RAMAddress = RAMAddress.Replace("FC2", "020"); + _ramAddress = _ramAddress.Replace("FC2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } // 12) "Always..." Codes - // For the "Always..." codes: -XXXXXXXX can be any authorised address BUT 00000000 (use 02000000 if you don't know what to choose). -ZZZZZZZZ can be anything. -The "y" in the code data must be in the [1-7] range (which means not 0). - // - // - else if (RAMAddress.StartsWith("0E2") == true) + // For the "Always..." codes: -XXXXXXXX can be any authorized address BUT 00000000 (use 02000000 if you don't know what to choose). -ZZZZZZZZ can be anything. -The "y" in the code data must be in the [1-7] range (which means not 0). + else if (_ramAddress.StartsWith("0E2")) { // 0E2 Should be Changed to 020 // Always skip next line. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("0E2") == true) + if (_ramAddress.StartsWith("0E2")) { - RAMAddress = RAMAddress.Replace("0E2", "020"); + _ramAddress = _ramAddress.Replace("0E2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("4E2") == true) + else if (_ramAddress.StartsWith("4E2")) { // 4E2 Should be Changed to 020 // Always skip next 2 lines. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("4E2") == true) + if (_ramAddress.StartsWith("4E2")) { - RAMAddress = RAMAddress.Replace("4E2", "020"); + _ramAddress = _ramAddress.Replace("4E2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("8E2") == true) + else if (_ramAddress.StartsWith("8E2")) { // 8E2 Should be Changed to 020 // Always Stops executing all the codes below. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("8E2") == true) + if (_ramAddress.StartsWith("8E2")) { - RAMAddress = RAMAddress.Replace("8E2", "020"); + _ramAddress = _ramAddress.Replace("8E2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("CE2") == true) + else if (_ramAddress.StartsWith("CE2")) { // CE2 Should be Changed to 020 // Always turn off all codes. // XXXXXXXX ZZZZZZZZ - if (RAMAddress.StartsWith("CE2") == true) + if (_ramAddress.StartsWith("CE2")) { - RAMAddress = RAMAddress.Replace("CE2", "020"); + _ramAddress = _ramAddress.Replace("CE2", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } // 13) 1 Line Special Codes (= starting with "00000000") - //Special Slide Code Detection Method - else if (RAMAddress.StartsWith("00000000") == true && RAMValue.StartsWith("8")) + // Special Slide Code Detection Method + else if (_ramAddress.StartsWith("00000000") && _ramValue.StartsWith("8")) { - //Code Sample - //00000000 82222C96 - //00000063 0032000C + // Code Sample + // 00000000 82222C96 + // 00000063 0032000C - //This says: + // This says: // Write to Address 2222C96 // The value 63 // Fifty (50) times (32 in Hex) - // Incriment the Address by 12 (Hex) + // Increment the Address by 12 (Hex) - //Sample Compare: + // Sample Compare: // 00222696 00000063 Unit 1 HP // 002226A2 00000063 Unit 2 HP // Goes up by C (12) - //Parse and go - //We reset RAM Address to the RAM Value, because the Value holds the address on the first line. + // Parse and go + // We reset RAM Address to the RAM Value, because the Value holds the address on the first line. + string realAddress = _ramValue.Remove(0, 1); - int incriment; - int looper; - string RealAddress = null; - string realValue = null; - RealAddress = RAMValue.Remove(0, 1); - //MessageBox.Show($"Real Address: {RealAddress}"); - //We need the next line + // We need the next line try { - loopValue += 1; - //MessageBox.Show($"Loop Value: {loopValue}"); - SingleCheat = txtCheat.Lines[loopValue].ToUpper(); - //We need to parse now. - if (SingleCheat.Length == 17 && SingleCheat.IndexOf(" ") == 8) + _loopValue += 1; + _singleCheat = txtCheat.Lines[_loopValue].ToUpper(); + + // We need to parse now. + if (_singleCheat.Length == 17 && _singleCheat.IndexOf(" ") == 8) { - if (blnEncrypted == true) + if (_blnEncrypted) { - //The code was Encrypted - //Decrypt before we do stuff. - //Action Replay Max decryption Method - parseString = SingleCheat; - UInt32 op1 = 0; - UInt32 op2 = 0; - UInt32 sum = 0xC6EF3720; - op1 = 0; - op2 = 0; - sum = 0xC6EF3720; - op1 = UInt32.Parse(parseString.Remove(8, 9), NumberStyles.HexNumber); - op2 = UInt32.Parse(parseString.Remove(0, 9), NumberStyles.HexNumber); - //Tiny Encryption Algorithm + // The code was Encrypted + // Decrypt before we do stuff. + // Action Replay Max decryption Method + _parseString = _singleCheat; + var sum = 0xC6EF3720; + var op1 = uint.Parse(_parseString.Remove(8, 9), NumberStyles.HexNumber); + var op2 = uint.Parse(_parseString.Remove(0, 9), NumberStyles.HexNumber); + + // Tiny Encryption Algorithm int j; for (j = 0; j < 32; ++j) { - op2 -= ((op1 << 4) + GBAProActionReplaySeeds[2]) ^ (op1 + sum) ^ ((op1 >> 5) + GBAProActionReplaySeeds[3]); - op1 -= ((op2 << 4) + GBAProActionReplaySeeds[0]) ^ (op2 + sum) ^ ((op2 >> 5) + GBAProActionReplaySeeds[1]); + op2 -= ((op1 << 4) + _gbaProActionReplaySeeds[2]) ^ (op1 + sum) ^ ((op1 >> 5) + _gbaProActionReplaySeeds[3]); + op1 -= ((op2 << 4) + _gbaProActionReplaySeeds[0]) ^ (op2 + sum) ^ ((op2 >> 5) + _gbaProActionReplaySeeds[1]); sum -= 0x9E3779B9; } - //op1 has the Address - //op2 has the Value - //Sum, is pointless? - RAMAddress = $"{op1:X8}"; - RAMValue = $"{op2:X8}"; + + // op1 has the Address + // op2 has the Value + // Sum, is pointless? + _ramAddress = $"{op1:X8}"; + _ramValue = $"{op2:X8}"; } - else if (blnEncrypted == false) + else if (_blnEncrypted == false) { - RAMAddress = SingleCheat.Remove(8, 9); - RAMValue = SingleCheat.Remove(0, 9); + _ramAddress = _singleCheat.Remove(8, 9); + _ramValue = _singleCheat.Remove(0, 9); } - //We need to determine the Byte Size. - //Determine how many leading Zeros there are. - realValue = RAMAddress; + + // We need to determine the Byte Size. + // Determine how many leading Zeros there are. + string realValue = _ramAddress; if (realValue.StartsWith("000000")) { - //Byte - byteSize = 8; + _byteSize = 8; } else if (realValue.StartsWith("0000")) { - //2 Byte - byteSize = 16; + _byteSize = 16; } else { - //4 Byte - byteSize = 32; + _byteSize = 32; } - //I need the Increment Value (Add to RAM Address) - //I also need the Loop Value - incriment = int.Parse(RAMValue.Remove(0, 4), NumberStyles.HexNumber); - looper = int.Parse(RAMValue.Remove(4, 4), NumberStyles.HexNumber); - //We set the RAMAddress to our RealAddress - RAMAddress = RealAddress; - //We set the RAMValue to our RealValue - RAMValue = realValue; + + var increment = int.Parse(_ramValue.Remove(0, 4), NumberStyles.HexNumber); + var looper = int.Parse(_ramValue.Remove(4, 4), NumberStyles.HexNumber); + + // We set the RAMAddress to our RealAddress + _ramAddress = realAddress; + + // We set the RAMValue to our RealValue + _ramValue = realValue; for (int i = 0; i < looper; i++) { - //We need to Bulk Add codes - //Add our Cheat + // We need to Bulk Add codes + // Add our Cheat AddGBA(); - //Time to add - RAMAddress = (int.Parse(RAMAddress) + incriment).ToString(); + _ramAddress = (int.Parse(_ramAddress) + increment).ToString(); } } } catch (Exception ex) { - //We should warn the user. MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - else if (RAMAddress.StartsWith("080") == true) + else if (_ramAddress.StartsWith("080")) { // End of the code list (even if you put values in the 2nd line). // 00000000 - //Let's ignore the user's input on this one? - if (RAMAddress.StartsWith("080") == true) + // Let's ignore the user's input on this one? + if (_ramAddress.StartsWith("080")) { - RAMAddress = RAMAddress.Replace("080", "020"); + _ramAddress = _ramAddress.Replace("080", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not needed by Bizhawk.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnneeded = true; + _blnUnneeded = true; return; } - else if (RAMAddress.StartsWith("0800") == true && RAMAddress[6] == '0' == true && RAMAddress[7] == '0' == true) + else if (_ramAddress.StartsWith("0800") && _ramAddress[6] == '0' && _ramAddress[7] == '0') { // AR Slowdown : loops the AR XX times // 0800XX00 - if (RAMAddress.StartsWith("0800") == true && RAMAddress[6] == '0' == true && RAMAddress[7] == '0' == true) + if (_ramAddress.StartsWith("0800") && _ramAddress[6] == '0' && _ramAddress[7] == '0') { - RAMAddress = RAMAddress.Replace("0800", "020"); + _ramAddress = _ramAddress.Replace("0800", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not needed by Bizhawk.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnneeded = true; - return; + _blnUnneeded = true; } // 14) 2 Lines Special Codes (= starting with '00000000' and padded (if needed) with "00000000") // Note: You have to add the 0es manually, after clicking the "create" button. - //Ocean Prince's note: - //Several of these appear to be conflicted with above detections. - else if (RAMAddress.StartsWith("1E2") == true) + // Ocean Prince's note: + // Several of these appear to be conflicted with above detections. + else if (_ramAddress.StartsWith("1E2")) { // 1E2 Should be Changed to 020 // Patches ROM address (XXXXXXXX << 1) with Halfword ZZZZ. Does not work on V1/2 upgraded to V3. Only for a real V3 Hardware? // XXXXXXXX // 0000ZZZZ - if (RAMAddress.StartsWith("1E2") == true) + if (_ramAddress.StartsWith("1E2")) { - RAMAddress = RAMAddress.Replace("1E2", "020"); + _ramAddress = _ramAddress.Replace("1E2", "020"); } - byteSize = 16; - blnActionReplayMax = true; + + _byteSize = 16; + _blnActionReplayMax = true; } - else if (RAMAddress.StartsWith("40000000") == true) + else if (_ramAddress.StartsWith("40000000")) { // 40000000 Should be Changed to 00000000 // (SP = 0) (means : stops the "then execute all following codes in the same row" and stops the "else execute none of the codes below)". // 00000000 // 00000000 - if (RAMAddress.StartsWith("40000000") == true) + if (_ramAddress.StartsWith("40000000")) { - RAMAddress = RAMAddress.Replace("40000000", "020"); + _ramAddress = _ramAddress.Replace("40000000", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("60000000") == true) + else if (_ramAddress.StartsWith("60000000")) { // 60000000 Should be Changed to 00000000 // (SP = 1) (means : start to execute all codes until end of codes or SP = 0). (bypass the number of codes to executes set by the master code). Should be Changed to (If SP <> 2) // 00000000 // 00000000 - if (RAMAddress.StartsWith("60000000") == true) + if (_ramAddress.StartsWith("60000000")) { - RAMAddress = RAMAddress.Replace("60000000", "020"); + _ramAddress = _ramAddress.Replace("60000000", "020"); } - byteSize = 16; + + _byteSize = 16; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - //TODO: - //Figure out how these work. - //NOTE: - //This is a Three Line Checker - else if (RAMAddress.StartsWith("8022") == true) + + // TODO: + // Figure out how these work. + // NOTE: + // This is a Three Line Checker + else if (_ramAddress.StartsWith("8022")) { // 802 Should be Changed to 020 // Writes Byte YY at address XXXXXXXX. Then makes YY = YY + Z1, XXXXXXXX = XXXXXXXX + Z3Z3, Z2 = Z2 - 1, and repeats until Z2 < 0. // XXXXXXXX // 000000YY // Z1Z2Z3Z3 - if (RAMAddress.StartsWith("8022") == true) + if (_ramAddress.StartsWith("8022")) { - RAMAddress = RAMAddress.Replace("8022", "0200"); + _ramAddress = _ramAddress.Replace("8022", "0200"); } - byteSize = 8; + _byteSize = 8; MessageBox.Show("Sorry, this tool does not support 8022 codes.", "Tool error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - blnUnhandled = true; - return; + _blnUnhandled = true; } - //I Don't get what this is doing. - else if (RAMAddress.StartsWith("8222") == true) + // I Don't get what this is doing. + else if (_ramAddress.StartsWith("8222")) { // 822 Should be Changed to 020 // Writes Halfword YYYY at address XXXXXXXX. Then makes YYYY = YYYY + Z1, XXXXXXXX = XXXXXXXX + Z3Z3*2, // XXXXXXXX // 0000YYYY // Z1Z2Z3Z3 - if (RAMAddress.StartsWith("8222") == true) + if (_ramAddress.StartsWith("8222")) { - RAMAddress = RAMAddress.Replace("8222", "0200"); + _ramAddress = _ramAddress.Replace("8222", "0200"); } - byteSize = 16; + _byteSize = 16; MessageBox.Show("Sorry, this tool does not support 8222 codes.", "Tool error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("842") == true) + else if (_ramAddress.StartsWith("842")) { // 842 Should be Changed to 020 // Writes Word YYYYYYYY at address XXXXXXXX. Then makes YYYYYYYY = YYYYYYYY + Z1, XXXXXXXX = XXXXXXXX + Z3Z3*4, Z2 = Z2 - 1, and repeats until Z2<0. @@ -2245,14 +2192,14 @@ namespace BizHawk.Client.EmuHawk // YYYYYYYY // Z1Z2Z3Z3 // WARNING: There is a BUG on the REAL AR (v2 upgraded to v3, and maybe on real v3) with the 32Bits Increment Slide code. You HAVE to add a code (best choice is 80000000 00000000 : add 0 to value at address 0) right after it, else the AR will erase the 2 last 8 digits lines of the 32 Bits Inc. Slide code when you enter it !!! - if (RAMAddress.StartsWith("842") == true) + if (_ramAddress.StartsWith("842")) { - RAMAddress = RAMAddress.Replace("842", "020"); + _ramAddress = _ramAddress.Replace("842", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("Sorry, this tool does not support 8222 codes.", "Tool error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - blnUnhandled = true; - return; + _blnUnhandled = true; } // (end three line) // 15) Special Codes @@ -2261,368 +2208,353 @@ namespace BizHawk.Client.EmuHawk // Master Code settings. // XXXXXXXX // 0000YYYY - // - else if (RAMValue.StartsWith("001DC0DE") == true) + else if (_ramValue.StartsWith("001DC0DE")) { // -ID Code- // Word at address 080000AC // Must always be 001DC0DE // XXXXXXXX // 001DC0DE - if (RAMValue.StartsWith("001DC0DE") == true) + if (_ramValue.StartsWith("001DC0DE")) { - RAMValue = RAMValue.Replace("001DC0DE", "020"); + _ramValue = _ramValue.Replace("001DC0DE", "020"); } - byteSize = 32; + + _byteSize = 32; MessageBox.Show("The code you entered is not needed by Bizhawk.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnneeded = true; - return; + _blnUnneeded = true; } - else if (RAMAddress.StartsWith("DEADFACE") == true) + else if (_ramAddress.StartsWith("DEADFACE")) { // -DEADFACE- // New Encryption seed. // DEADFACE // 0000XXXX MessageBox.Show("Sorry, this tool does not support DEADFACE codes.", "Tool error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (blnActionReplayMax == false) + else if (_blnActionReplayMax == false) { - //Is it a bad code? Check the others. - blnActionReplayMax = false; + // Is it a bad code? Check the others. + _blnActionReplayMax = false; } - return; } + public void GBACodeBreaker() { - //These checks are done on the DECYPTED code, not the Encrypted one. - if (RAMAddress.StartsWith("0000") == true && RAMValue.StartsWith("0008") == true || RAMAddress.StartsWith("0000") == true && RAMValue.StartsWith("0002") == true) + // These checks are done on the Decrypted code, not the Encrypted one. + if (_ramAddress.StartsWith("0000") && _ramValue.StartsWith("0008") || _ramAddress.StartsWith("0000") && _ramValue.StartsWith("0002")) { - //Master Code #1 - //0000xxxx yyyy + // Master Code #1 + // 0000xxxx yyyy - //xxxx is the CRC value (the "Game ID" converted to hex) - //Flags("yyyy"): - //0008 - CRC Exists(CRC is used to autodetect the inserted game) - //0002 - Disable Interupts + // xxxx is the CRC value (the "Game ID" converted to hex) + // Flags("yyyy"): + // 0008 - CRC Exists(CRC is used to autodetect the inserted game) + // 0002 - Disable Interrupts MessageBox.Show("The code you entered is not needed by Bizhawk.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnneeded = true; + _blnUnneeded = true; return; } - else if (RAMAddress.StartsWith("1") == true && RAMValue.StartsWith("1000") == true || RAMAddress.StartsWith("1") == true && RAMValue.StartsWith("2000") == true || RAMAddress.StartsWith("1") == true && RAMValue.StartsWith("3000") == true || RAMAddress.StartsWith("1") == true && RAMValue.StartsWith("4000") == true || RAMAddress.StartsWith("1") == true && RAMValue.StartsWith("0020") == true) - { - //Master Code #2 - //1aaaaaaa xxxy - //'y' is the CBA Code Handler Store Address(0 - 7)[address = ((d << 0x16) + 0x08000100)] - //1000 - 32 - bit Long - Branch Type(Thumb) - //2000 - 32 - bit Long - Branch Type(ARM) - //3000 - 8 - bit(?) Long - Branch Type(Thumb) - //4000 - 8 - bit(?) Long - Branch Type(ARM) - //0020 - Unknown(Odd Effect) + if (_ramAddress.StartsWith("1") && _ramValue.StartsWith("1000") || _ramAddress.StartsWith("1") && _ramValue.StartsWith("2000") || _ramAddress.StartsWith("1") && _ramValue.StartsWith("3000") || _ramAddress.StartsWith("1") && _ramValue.StartsWith("4000") || _ramAddress.StartsWith("1") && _ramValue.StartsWith("0020")) + { + // Master Code #2 + // 1aaaaaaa xxxy + // 'y' is the CBA Code Handler Store Address(0 - 7)[address = ((d << 0x16) + 0x08000100)] + + // 1000 - 32 - bit Long - Branch Type(Thumb) + // 2000 - 32 - bit Long - Branch Type(ARM) + // 3000 - 8 - bit(?) Long - Branch Type(Thumb) + // 4000 - 8 - bit(?) Long - Branch Type(ARM) + // 0020 - Unknown(Odd Effect) MessageBox.Show("The code you entered is not needed by Bizhawk.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnneeded = true; + _blnUnneeded = true; return; } - else if (RAMAddress.StartsWith("3") == true) + + if (_ramAddress.StartsWith("3")) { - //8 - Bit Constant RAM Write - //3aaaaaaa 00yy - //Continuosly writes the 8 - Bit value specified by 'yy' to address aaaaaaa. - RAMAddress = RAMAddress.Remove(0, 1); - byteSize = 16; + // 8 - Bit Constant RAM Write + // 3aaaaaaa 00yy + // Continuosly writes the 8 - Bit value specified by 'yy' to address aaaaaaa. + _ramAddress = _ramAddress.Remove(0, 1); + _byteSize = 16; } - else if (RAMAddress.StartsWith("4") == true) + else if (_ramAddress.StartsWith("4")) { - //Slide Code - //4aaaaaaa yyyy - //xxxxxxxx iiii - //This is one of those two - line codes.The "yyyy" set is the data to store at the address (aaaaaaa), with xxxxxxxx being the number of addresses to store to, and iiii being the value to increment the addresses by. The codetype is usually use to fill memory with a certain value. - RAMAddress = RAMAddress.Remove(0, 1); - byteSize = 32; + // Slide Code + // 4aaaaaaa yyyy + // xxxxxxxx iiii + // This is one of those two - line codes.The "yyyy" set is the data to store at the address (aaaaaaa), with xxxxxxxx being the number of addresses to store to, and iiii being the value to increment the addresses by. The codetype is usually use to fill memory with a certain value. + _ramAddress = _ramAddress.Remove(0, 1); + _byteSize = 32; MessageBox.Show("Sorry, this tool does not support 4 codes.", "Tool error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("6") == true) + else if (_ramAddress.StartsWith("6")) { - //16 - Bit Logical AND - //6aaaaaaa yyyy - //Performs the AND function on the address provided with the value provided. I'm not going to explain what AND does, so if you'd like to know I suggest you see the instruction manual for a graphing calculator. - //This is another advanced code type you'll probably never need to use. + // 16 - Bit Logical AND + // 6aaaaaaa yyyy + // Performs the AND function on the address provided with the value provided. I'm not going to explain what AND does, so if you'd like to know I suggest you see the instruction manual for a graphing calculator. + // This is another advanced code type you'll probably never need to use. - //Ocean Prince's note: - //AND means "If ALL conditions are True then Do" - //I don't understand how this would be applied/works. Samples are requested. + // Ocean Prince's note: + // AND means "If ALL conditions are True then Do" + // I don't understand how this would be applied/works. Samples are requested. MessageBox.Show("Sorry, this tool does not support 6 codes.", "Tool error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("7") == true) + else if (_ramAddress.StartsWith("7")) { - //16 - Bit 'If Equal To' Activator - //7aaaaaaa yyyy - //If the value at the specified RAM address(aaaaaaa) is equal to yyyy value, active the code on the next line. - byteSize = 32; + // 16 - Bit 'If Equal To' Activator + // 7aaaaaaa yyyy + // If the value at the specified RAM address(aaaaaaa) is equal to yyyy value, active the code on the next line. + _byteSize = 32; MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - return; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("8") == true) + else if (_ramAddress.StartsWith("8")) { - //16 - Bit Constant RAM Write - //8aaaaaaa yyyy - //Continuosly writes yyyy values to the specified RAM address(aaaaaaa). - //Continuosly writes the 8 - Bit value specified by 'yy' to address aaaaaaa. - RAMAddress = RAMAddress.Remove(0, 1); - byteSize = 32; + // 16 - Bit Constant RAM Write + // 8aaaaaaa yyyy + // Continuously writes yyyy values to the specified RAM address(aaaaaaa). + // Continuously writes the 8 - Bit value specified by 'yy' to address aaaaaaa. + _ramAddress = _ramAddress.Remove(0, 1); + _byteSize = 32; } - else if (RAMAddress.StartsWith("9") == true) + else if (_ramAddress.StartsWith("9")) { - //Change Encryption Seeds - //9yyyyyyy yyyy - //(When 1st Code Only!) - //Works like the DEADFACE on GSA.Changes the encryption seeds used for the rest of the codes. + // Change Encryption Seeds + // 9yyyyyyy yyyy + // (When 1st Code Only!) + // Works like the DEADFACE on GSA.Changes the encryption seeds used for the rest of the codes. MessageBox.Show("Sorry, this tool does not support 9 codes.", "Tool error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - byteSize = 32; - blnUnhandled = true; - return; + _byteSize = 32; + _blnUnhandled = true; } - else if (RAMAddress.StartsWith("A") == true) + else if (_ramAddress.StartsWith("A")) { - //16 - Bit 'If Not Equal' Activator - //Axxxxxxx yyyy - //Basicly the opposite of an 'If Equal To' Activator.Activates the code on the next line if address xxxxxxx is NOT equal to yyyy + // 16 - Bit 'If Not Equal' Activator + // Axxxxxxx yyyy + // Basically the opposite of an 'If Equal To' Activator.Activates the code on the next line if address xxxxxxx is NOT equal to yyyy MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - byteSize = 32; - return; + _blnUnhandled = true; + _byteSize = 32; } - else if (RAMAddress.StartsWith("D00000") == true) + else if (_ramAddress.StartsWith("D00000")) { - //16 - Bit Conditional RAM Write - //D00000xx yyyy - //No Description available at this time. + // 16 - Bit Conditional RAM Write + // D00000xx yyyy + // No Description available at this time. MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - blnUnhandled = true; - byteSize = 32; - return; + _blnUnhandled = true; + _byteSize = 32; } - return; } + public void AddGBA() { - if (byteSize == 8) + if (_byteSize == 8) { - var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, false, txtDescription.Text); - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); + var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, false, txtDescription.Text); + Global.CheatList.Add(new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber))); } - else if (byteSize == 16) + else if (_byteSize == 16) { - var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, false, txtDescription.Text); - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); + var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, false, txtDescription.Text); + Global.CheatList.Add(new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber))); } - else if (byteSize == 32) + else if (_byteSize == 32) { - var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, false, txtDescription.Text); - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); + var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, false, txtDescription.Text); + Global.CheatList.Add(new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber))); } } - private void GEN() + + private void Gen() { - //Game Genie only, for now. - //This applies to the Game Genie - if (SingleCheat.Length == 9 && SingleCheat.Contains("-")) + // Game Genie only, for now. + // This applies to the Game Genie + if (_singleCheat.Length == 9 && _singleCheat.Contains("-")) { - if (SingleCheat.IndexOf("-") != 4) + if (_singleCheat.IndexOf("-") != 4) { MessageBox.Show("All Genesis Game Genie Codes need to contain a dash after the fourth character", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (SingleCheat.Contains("I") == true | SingleCheat.Contains("O") == true | SingleCheat.Contains("Q") == true | SingleCheat.Contains("U") == true) + if (_singleCheat.Contains("I") | _singleCheat.Contains("O") | _singleCheat.Contains("Q") | _singleCheat.Contains("U")) { MessageBox.Show("All Genesis Game Genie Codes do not use I, O, Q or U.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - //This is taken from the GenGameGenie.CS file. - string code = SingleCheat; - int val = 0; - int add = 0; - string address = null; - string value = null; - //Remove the - + + // This is taken from the GenGameGenie.CS file. + string code = _singleCheat; + + // Remove the - code = code.Remove(4, 1); - long hexcode = 0; + long hexCode = 0; // convert code to a long binary string foreach (var t in code) { - hexcode <<= 5; - _GENgameGenieTable.TryGetValue(t, out var y); - hexcode |= y; + hexCode <<= 5; + _genGameGenieTable.TryGetValue(t, out var y); + hexCode |= y; } - long decoded = (hexcode & 0xFF00000000) >> 32; - decoded |= hexcode & 0x00FF000000; - decoded |= (hexcode & 0x0000FF0000) << 16; - decoded |= (hexcode & 0x00000000700) << 5; - decoded |= (hexcode & 0x000000F800) >> 3; - decoded |= (hexcode & 0x00000000FF) << 16; - val = (int)(decoded & 0x000000FFFF); - add = (int)((decoded & 0xFFFFFF0000) >> 16); - //Make our Strings get the Hex Values. - address = add.ToString("X6"); - value = val.ToString("X4"); - //Game Genie, modifies the "ROM" which is why it says, "MD CART" + long decoded = (hexCode & 0xFF00000000) >> 32; + decoded |= hexCode & 0x00FF000000; + decoded |= (hexCode & 0x0000FF0000) << 16; + decoded |= (hexCode & 0x00000000700) << 5; + decoded |= (hexCode & 0x000000F800) >> 3; + decoded |= (hexCode & 0x00000000FF) << 16; + + var val = (int)(decoded & 0x000000FFFF); + var add = (int)((decoded & 0xFFFFFF0000) >> 16); + + // Make our Strings get the Hex Values. + string address = add.ToString("X6"); + + // Game Genie, modifies the "ROM" which is why it says, "MD CART" var watch = Watch.GenerateWatch(MemoryDomains["M68K BUS"], long.Parse(address, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, true, txtDescription.Text); - //Add Cheat + + // Add Cheat Global.CheatList.Add(new Cheat(watch, val)); } - //Action Replay? - if (SingleCheat.Contains(":")) + + // Action Replay? + if (_singleCheat.Contains(":")) { - //We start from Zero. - if (SingleCheat.IndexOf(":") != 6) + // We start from Zero. + if (_singleCheat.IndexOf(":") != 6) { MessageBox.Show("All Genesis Action Replay/Pro Action Replay Codes need to contain a colon after the sixth character", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - //Problem: I don't know what the Non-FF Style codes are. - //TODO: Fix that. - if (SingleCheat.StartsWith("FF") == false) + + // Problem: I don't know what the Non-FF Style codes are. + // TODO: Fix that. + if (_singleCheat.StartsWith("FF") == false) { MessageBox.Show("This Action Replay Code, is not understood by this tool.", "Tool Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } - //Now to do some work. - //Determine Length, to Determine Byte Size - parseString = SingleCheat.Remove(0, 2); - switch (SingleCheat.Length) + // Now to do some work. + // Determine Length, to Determine Byte Size + _parseString = _singleCheat.Remove(0, 2); + switch (_singleCheat.Length) { case 9: - //Sample Code of 1-Byte: - //FFF761:64 - //Becomes: - //Address: F761 - //Value: 64 - RAMAddress = parseString.Remove(4, 3); - RAMValue = parseString.Remove(0, 5); - byteSize = 1; + // Sample Code of 1-Byte: + // FFF761:64 + // Becomes: + // Address: F761 + // Value: 64 + _ramAddress = _parseString.Remove(4, 3); + _ramValue = _parseString.Remove(0, 5); + _byteSize = 1; break; case 11: - //Sample Code of 2-Byte: - //FFF761:6411 - //Becomes: - //Address: F761 - //Value: 6411 - RAMAddress = parseString.Remove(4, 5); - RAMValue = parseString.Remove(0, 5); - byteSize = 2; + // Sample Code of 2-Byte: + // FFF761:6411 + // Becomes: + // Address: F761 + // Value: 6411 + _ramAddress = _parseString.Remove(4, 5); + _ramValue = _parseString.Remove(0, 5); + _byteSize = 2; break; default: - //We could have checked above but here is fine, since it's a quick check due to one of three possibilities. + // We could have checked above but here is fine, since it's a quick check due to one of three possibilities. MessageBox.Show("All Genesis Action Replay/Pro Action Replay Codes need to be either 9 or 11 characters in length", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - //Try and add. + try { - //A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. - //System Bus Domain, The Address to Watch, Byte size (Byte), Hex Display, Description, Big Endian. - if (byteSize == 1) + if (_byteSize == 1) { - var watch = Watch.GenerateWatch(MemoryDomains["68K RAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, false, txtDescription.Text); - //Take Watch, Add our Value we want, and it should be active when addded? - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); + var watch = Watch.GenerateWatch(MemoryDomains["68K RAM"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, false, txtDescription.Text); + Global.CheatList.Add(new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber))); } - if (byteSize == 2) + else if (_byteSize == 2) { - var watch = Watch.GenerateWatch(MemoryDomains["68K RAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, true, txtDescription.Text); - //Take Watch, Add our Value we want, and it should be active when addded? - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); + var watch = Watch.GenerateWatch(MemoryDomains["68K RAM"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, true, txtDescription.Text); + Global.CheatList.Add(new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber))); } - } - //Someone broke the world? catch (Exception ex) { MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } + private void N64() { - //These codes, more or less work without Needing much work. - if (SingleCheat.IndexOf(" ") != 8) + // These codes, more or less work without Needing much work. + if (_singleCheat.IndexOf(" ") != 8) { MessageBox.Show("All N64 GameShark Codes need to contain a space after the eighth character", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (SingleCheat.Length != 13) + + if (_singleCheat.Length != 13) { MessageBox.Show("All N64 GameShark Codes need to be 13 characters in length.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - //We need to determine what kind of cheat this is. - //I need to determine if this is a Byte or Word. - switch (testo) + + // We need to determine what kind of cheat this is. + // I need to determine if this is a Byte or Word. + switch (_testo) { - //80 and 81 are the most common, so let's not get all worried. + // 80 and 81 are the most common, so let's not get all worried. case "80": - //Byte - byteSize = 8; + _byteSize = 8; break; case "81": - //Word - byteSize = 16; + _byteSize = 16; break; - //Case A0 and A1 means "Write to Uncached address. + // Case A0 and A1 means "Write to Uncached address. case "A0": - //Byte - byteSize = 8; + _byteSize = 8; break; case "A1": - //Word - byteSize = 16; + _byteSize = 16; break; - //Do we support the GameShark Button? No. But these cheats, can be toggled. Which "Counts" - // Consequences be damned! + // Do we support the GameShark Button? No. But these cheats, can be toggled. Which "Counts" + // Consequences be damned! case "88": - //Byte - byteSize = 8; + _byteSize = 8; break; case "89": - //Word - byteSize = 16; + _byteSize = 16; break; - //These are compare Address X to Value Y, then apply Value B to Address A - //This is not supported, yet - //TODO: When BizHawk supports a compare RAM Address's value is true then apply a value to another address, make it a thing. + // These are compare Address X to Value Y, then apply Value B to Address A + // This is not supported, yet + // TODO: When BizHawk supports a compare RAM Address's value is true then apply a value to another address, make it a thing. case "D0": - //Byte case "D1": - //Word case "D2": - //Byte case "D3": - //Word MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; - //These codes are for Disabling the Expansion Pak. that's a bad thing? Assuming bad codes, until told otherwise. + // These codes are for Disabling the Expansion Pak. that's a bad thing? Assuming bad codes, until told otherwise. case "EE": case "DD": case "CC": MessageBox.Show("The code you entered is for Disabling the Expansion Pak. This is not allowed by this tool.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; - //Enable Code - //Not Necessary? Think so? + // Enable Code + // Not Necessary? Think so? case "DE": - //Single Write ON-Boot code. - //Not Necessary? Think so? + // Single Write ON-Boot code. + // Not Necessary? Think so? case "F0": case "F1": case "2A": @@ -2630,320 +2562,299 @@ namespace BizHawk.Client.EmuHawk case "FF": MessageBox.Show("The code you entered is not needed by Bizhawk.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; - //TODO: Make Patch Code (5000XXYY) work. + // TODO: Make Patch Code (5000XXYY) work. case "50": - //Word? MessageBox.Show("The code you entered is not supported by this tool. Please Submit the Game's Name, Cheat/Code and Purpose to the BizHawk forums.", "Tool Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; - //I hope this isn't a thing. default: MessageBox.Show("The GameShark code entered is not a recognized format.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - //Leave this Method, before someone gets hurt. return; } - //Now to get clever. - //Sample Input for N64: - //8133B21E 08FF - //Becomes: - //Address 33B21E - //Value 08FF - //Note, 80XXXXXX 00YY - //Is Byte, not Word - //Remove the 80 Octect - parseString = SingleCheat.Remove(0, 2); - //Get RAM Address - RAMAddress = parseString.Remove(6, 5); - //Get RAM Value - RAMValue = parseString.Remove(0, 7); + // Sample Input for N64: + // 8133B21E 08FF + // Becomes: + // Address 33B21E + // Value 08FF + + // Note, 80XXXXXX 00YY + // Is Byte, not Word + // Remove the 80 Octect + _parseString = _singleCheat.Remove(0, 2); + + // Get RAM Address + _ramAddress = _parseString.Remove(6, 5); + + // Get RAM Value + _ramValue = _parseString.Remove(0, 7); try { - //A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. - //System Bus Domain, The Address to Watch, Byte size (Word), Hex Display, Description, Big Endian. - if (byteSize == 8) + if (_byteSize == 8) { - //We have a Byte sized value - var watch = Watch.GenerateWatch(MemoryDomains["RDRAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, true, txtDescription.Text); - //Take Watch, Add our Value we want, and it should be active when added? - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); + var watch = Watch.GenerateWatch(MemoryDomains["RDRAM"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, true, txtDescription.Text); + Global.CheatList.Add(new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber))); } - if (byteSize == 16) + else if (_byteSize == 16) { - //We have a Word (Double Byte) sized Value - var watch = Watch.GenerateWatch(MemoryDomains["RDRAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, true, txtDescription.Text); - //Take Watch, Add our Value we want, and it should be active when added? - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); + var watch = Watch.GenerateWatch(MemoryDomains["RDRAM"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, true, txtDescription.Text); + Global.CheatList.Add(new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber))); } } - //Someone broke the world? catch (Exception ex) { MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void NES() + + private void Nes() { string strCompare = null; - //Original code from adelikat - if (SingleCheat.Length != 6 || SingleCheat.Length != 8) + if (_singleCheat.Length != 6 || _singleCheat.Length != 8) { - int Value = 0; - int Address = 0x8000; + int value = 0; + int address = 0x8000; int x; - int Compare = 0; + int compare = 0; + // char 3 bit 3 denotes the code length. - string code = SingleCheat; - if (SingleCheat.Length == 6) + string code = _singleCheat; + if (_singleCheat.Length == 6) { // Char # | 1 | 2 | 3 | 4 | 5 | 6 | // Bit # |3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0| // maps to|1|6|7|8|H|2|3|4|-|I|J|K|L|A|B|C|D|M|N|O|5|E|F|G| + _nesGameGenieTable.TryGetValue(code[0], out x); + value |= x & 0x07; + value |= (x & 0x08) << 4; - _NESgameGenieTable.TryGetValue(code[0], out x); - Value |= x & 0x07; - Value |= (x & 0x08) << 4; + _nesGameGenieTable.TryGetValue(code[1], out x); + value |= (x & 0x07) << 4; + address |= (x & 0x08) << 4; - _NESgameGenieTable.TryGetValue(code[1], out x); - Value |= (x & 0x07) << 4; - Address |= (x & 0x08) << 4; + _nesGameGenieTable.TryGetValue(code[2], out x); + address |= (x & 0x07) << 4; - _NESgameGenieTable.TryGetValue(code[2], out x); - Address |= (x & 0x07) << 4; + _nesGameGenieTable.TryGetValue(code[3], out x); + address |= (x & 0x07) << 12; + address |= x & 0x08; - _NESgameGenieTable.TryGetValue(code[3], out x); - Address |= (x & 0x07) << 12; - Address |= x & 0x08; + _nesGameGenieTable.TryGetValue(code[4], out x); + address |= x & 0x07; + address |= (x & 0x08) << 8; - _NESgameGenieTable.TryGetValue(code[4], out x); - Address |= x & 0x07; - Address |= (x & 0x08) << 8; - - _NESgameGenieTable.TryGetValue(code[5], out x); - Address |= (x & 0x07) << 8; - Value |= x & 0x08; - RAMAddress = $"{Address:X4}"; - RAMValue = $"{Value:X2}"; - strCompare = $"{Compare:X2}"; + _nesGameGenieTable.TryGetValue(code[5], out x); + address |= (x & 0x07) << 8; + value |= x & 0x08; + _ramAddress = $"{address:X4}"; + _ramValue = $"{value:X2}"; + strCompare = $"{compare:X2}"; } - else if (SingleCheat.Length == 8) + else if (_singleCheat.Length == 8) { // Char # | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | // Bit # |3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0| // maps to|1|6|7|8|H|2|3|4|-|I|J|K|L|A|B|C|D|M|N|O|%|E|F|G|!|^|&|*|5|@|#|$| - Value = 0; - Address = 0x8000; - Compare = 0; + value = 0; + address = 0x8000; + compare = 0; + _nesGameGenieTable.TryGetValue(code[0], out x); + value |= x & 0x07; + value |= (x & 0x08) << 4; - _NESgameGenieTable.TryGetValue(code[0], out x); - Value |= x & 0x07; - Value |= (x & 0x08) << 4; + _nesGameGenieTable.TryGetValue(code[1], out x); + value |= (x & 0x07) << 4; + address |= (x & 0x08) << 4; - _NESgameGenieTable.TryGetValue(code[1], out x); - Value |= (x & 0x07) << 4; - Address |= (x & 0x08) << 4; + _nesGameGenieTable.TryGetValue(code[2], out x); + address |= (x & 0x07) << 4; - _NESgameGenieTable.TryGetValue(code[2], out x); - Address |= (x & 0x07) << 4; + _nesGameGenieTable.TryGetValue(code[3], out x); + address |= (x & 0x07) << 12; + address |= x & 0x08; - _NESgameGenieTable.TryGetValue(code[3], out x); - Address |= (x & 0x07) << 12; - Address |= x & 0x08; + _nesGameGenieTable.TryGetValue(code[4], out x); + address |= x & 0x07; + address |= (x & 0x08) << 8; - _NESgameGenieTable.TryGetValue(code[4], out x); - Address |= x & 0x07; - Address |= (x & 0x08) << 8; + _nesGameGenieTable.TryGetValue(code[5], out x); + address |= (x & 0x07) << 8; + compare |= x & 0x08; - _NESgameGenieTable.TryGetValue(code[5], out x); - Address |= (x & 0x07) << 8; - Compare |= x & 0x08; + _nesGameGenieTable.TryGetValue(code[6], out x); + compare |= x & 0x07; + compare |= (x & 0x08) << 4; - _NESgameGenieTable.TryGetValue(code[6], out x); - Compare |= x & 0x07; - Compare |= (x & 0x08) << 4; - - _NESgameGenieTable.TryGetValue(code[7], out x); - Compare |= (x & 0x07) << 4; - Value |= x & 0x08; - RAMAddress = $"{Address:X4}"; - RAMValue = $"{Value:X2}"; - strCompare = $"{Compare:X2}"; + _nesGameGenieTable.TryGetValue(code[7], out x); + compare |= (x & 0x07) << 4; + value |= x & 0x08; + _ramAddress = $"{address:X4}"; + _ramValue = $"{value:X2}"; + strCompare = $"{compare:X2}"; } } - if (SingleCheat.Length != 6 && SingleCheat.Length != 8) + + if (_singleCheat.Length != 6 && _singleCheat.Length != 8) { - //Not a proper Code MessageBox.Show("Game Genie codes need to be six or eight characters in length.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } + try { - - //A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. - //System Bus Domain, The Address to Watch, Byte size (Word), Hex Display, Description. Big Endian. - //We have a Byte sized value - - var description = SingleCheat; + // A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. + // System Bus Domain, The Address to Watch, Byte size (Word), Hex Display, Description. Big Endian. + // We have a Byte sized value + var description = _singleCheat; if (!string.IsNullOrWhiteSpace(txtDescription.Text)) { description = txtDescription.Text; } - var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, false, description); - //Take Watch, Add our Value we want, and it should be active when addded? - if (strCompare == "00") - { - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); - } - if (strCompare != "00") - { - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber), int.Parse(strCompare, NumberStyles.HexNumber), true, Cheat.CompareType.Equal)); - } - //Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber), ) + var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, false, description); + Global.CheatList.Add( + strCompare == "00" + ? new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber)) + : new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber), int.Parse(strCompare, NumberStyles.HexNumber), true, Cheat.CompareType.Equal)); } - //Someone broke the world? catch (Exception ex) { MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void PSX() + + private void Psx() { - //These codes, more or less work without Needing much work. - if (SingleCheat.IndexOf(" ") != 8) + // These codes, more or less work without Needing much work. + if (_singleCheat.IndexOf(" ") != 8) { MessageBox.Show("All PSX GameShark Codes need to contain a space after the eighth character", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (SingleCheat.Length != 13) + + if (_singleCheat.Length != 13) { MessageBox.Show("All PSX GameShark Cheats need to be 13 characters in length.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - //We need to determine what kind of cheat this is. - //I need to determine if this is a Byte or Word. - switch (testo) + + switch (_testo) { - //30 80 Cheats mean, "Write, don't care otherwise." + // 30 80 Cheats mean, "Write, don't care otherwise." case "30": - byteSize = 8; + _byteSize = 8; break; case "80": - byteSize = 16; + _byteSize = 16; break; - //When value hits YYYY, make the next cheat go off + // When value hits YYYY, make the next cheat go off case "E0": - //E0 byteSize = 8; + // E0 byteSize = 8; case "E1": - //E1 byteSize = 8; + // E1 byteSize = 8; case "E2": - //E2 byteSize = 8; + // E2 byteSize = 8; case "D0": - //D0 byteSize = 16; + // D0 byteSize = 16; case "D1": - //D1 byteSize = 16; + // D1 byteSize = 16; case "D2": - //D2 byteSize = 16; + // D2 byteSize = 16; case "D3": - //D3 byteSize = 16; + // D3 byteSize = 16; case "D4": - //D4 byteSize = 16; + // D4 byteSize = 16; case "D5": - //D5 byteSize = 16; + // D5 byteSize = 16; case "D6": - //D6 byteSize = 16; + // D6 byteSize = 16; - //Increment/Decrement Codes + // Increment/Decrement Codes case "10": - //10 byteSize = 16; + // 10 byteSize = 16; case "11": - //11 byteSize = 16; + // 11 byteSize = 16; case "20": - //20 byteSize = 8 + // 20 byteSize = 8 case "21": - //21 byteSize = 8 + // 21 byteSize = 8 MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; case "C0": case "C1": - //Slow-Mo + // Slow-Mo case "40": MessageBox.Show("The code you entered is not needed by Bizhawk.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; case "C2": case "50": - //Word? MessageBox.Show("The code you entered is not supported by this tool. Please Submit the Game's Name, Cheat/Code and Purpose to the BizHawk forums.", "Tool Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; - //Something wrong with their input. default: MessageBox.Show("The GameShark code entered is not a recognized format.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - //Leave this Method, before someone gets hurt. return; } - //Sample Input for PSX: - //800D10BA 0009 - //Address: 0D10BA - //Value: 0009 - //Remove first two octets - parseString = SingleCheat.Remove(0, 2); - //Get RAM Address - RAMAddress = parseString.Remove(6, 5); - //Get RAM Value - RAMValue = parseString.Remove(0, 7); + + // Sample Input for PSX: + // 800D10BA 0009 + // Address: 0D10BA + // Value: 0009 + // Remove first two octets + _parseString = _singleCheat.Remove(0, 2); + + // Get RAM Address + _ramAddress = _parseString.Remove(6, 5); + + // Get RAM Value + _ramValue = _parseString.Remove(0, 7); try { - //A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. - //System Bus Domain, The Address to Watch, Byte size (Word), Hex Display, Description. Big Endian. - - //My Consern is that Work RAM High may be incorrect? - if (byteSize == 8) + // A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. + // System Bus Domain, The Address to Watch, Byte size (Word), Hex Display, Description. Big Endian. + // My Concern is that Work RAM High may be incorrect? + if (_byteSize == 8) { - //We have a Byte sized value - var watch = Watch.GenerateWatch(MemoryDomains["MainRAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, false, txtDescription.Text); - //Take Watch, Add our Value we want, and it should be active when addded? - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); + var watch = Watch.GenerateWatch(MemoryDomains["MainRAM"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, false, txtDescription.Text); + Global.CheatList.Add(new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber))); } - if (byteSize == 16) + else if (_byteSize == 16) { - //We have a Word (Double Byte) sized Value - var watch = Watch.GenerateWatch(MemoryDomains["MainRAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, false, txtDescription.Text); - //Take Watch, Add our Value we want, and it should be active when addded? - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); + var watch = Watch.GenerateWatch(MemoryDomains["MainRAM"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, false, txtDescription.Text); + Global.CheatList.Add(new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber))); } } - //Someone broke the world? catch (Exception ex) { MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } - } - private void SAT() + + private void Saturn() { - //Not yet. - if (SingleCheat.IndexOf(" ") != 8) + if (_singleCheat.IndexOf(" ") != 8) { MessageBox.Show("All Saturn GameShark Codes need to contain a space after the eighth character", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (SingleCheat.Length != 13) + + if (_singleCheat.Length != 13) { MessageBox.Show("All Saturn GameShark Cheats need to be 13 characters in length.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - //This is a special test. Only the first character really matters? 16 or 36? - testo = testo.Remove(1, 1); - switch (testo) + + // This is a special test. Only the first character really matters? 16 or 36? + _testo = _testo.Remove(1, 1); + switch (_testo) { case "1": - byteSize = 16; + _byteSize = 16; break; case "3": - byteSize = 8; + _byteSize = 8; break; - //0 writes once. + // 0 writes once. case "0": - //D is RAM Equal To Activator, do Next Value + // D is RAM Equal To Activator, do Next Value case "D": MessageBox.Show("The code you entered is not supported by BizHawk.", "Emulator Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; @@ -2952,108 +2863,100 @@ namespace BizHawk.Client.EmuHawk return; default: MessageBox.Show("The GameShark code entered is not a recognized format.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - //Leave this Method, before someone gets hurt. return; } - //Sample Input for Saturn: - //160949FC 0090 - //Address: 0949FC - //Value: 90 - //Note, 3XXXXXXX are Big Endian - //Remove first two octets - parseString = SingleCheat.Remove(0, 2); - //Get RAM Address - RAMAddress = parseString.Remove(6, 5); - //Get RAM Value - RAMValue = parseString.Remove(0, 7); + + // Sample Input for Saturn: + // 160949FC 0090 + // Address: 0949FC + // Value: 90 + // Note, 3XXXXXXX are Big Endian + // Remove first two octets + _parseString = _singleCheat.Remove(0, 2); + + // Get RAM Address + _ramAddress = _parseString.Remove(6, 5); + + // Get RAM Value + _ramValue = _parseString.Remove(0, 7); try { - //A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. - //System Bus Domain, The Address to Watch, Byte size (Word), Hex Display, Description. Big Endian. - - //My Consern is that Work RAM High may be incorrect? - if (byteSize == 8) + // A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. + // System Bus Domain, The Address to Watch, Byte size (Word), Hex Display, Description. Big Endian. + // My Concern is that Work RAM High may be incorrect? + if (_byteSize == 8) { - //We have a Byte sized value - var watch = Watch.GenerateWatch(MemoryDomains["Work Ram High"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, true, txtDescription.Text); - //Take Watch, Add our Value we want, and it should be active when addded? - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); + var watch = Watch.GenerateWatch(MemoryDomains["Work Ram High"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, true, txtDescription.Text); + Global.CheatList.Add(new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber))); } - if (byteSize == 16) + else if (_byteSize == 16) { - //We have a Word (Double Byte) sized Value - var watch = Watch.GenerateWatch(MemoryDomains["Work Ram High"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, true, txtDescription.Text); - //Take Watch, Add our Value we want, and it should be active when addded? - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); + var watch = Watch.GenerateWatch(MemoryDomains["Work Ram High"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, true, txtDescription.Text); + Global.CheatList.Add(new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber))); } } - //Someone broke the world? catch (Exception ex) { MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - //This also handles Game Gear due to shared hardware. Go figure. - private void SMS() + + // This also handles Game Gear due to shared hardware. Go figure. + private void Sms() { - string RAMCompare = null; - //Game Genie - if (SingleCheat.LastIndexOf("-") == 7 && SingleCheat.IndexOf("-") == 3) + string ramCompare = null; + + // Game Genie + if (_singleCheat.LastIndexOf("-") == 7 && _singleCheat.IndexOf("-") == 3) { int val = 0; - int add = 0; - int cmp = 0; - parseString = SingleCheat.Replace("-", ""); - GBGGDecode(parseString, ref val, ref add, ref cmp); - RAMAddress = $"{add:X4}"; - RAMValue = $"{val:X2}"; - RAMCompare = $"{cmp:X2}"; + _parseString = _singleCheat.Replace("-", ""); + GbGgDecode(_parseString, ref val, out var add, out var cmp); + _ramAddress = $"{add:X4}"; + _ramValue = $"{val:X2}"; + ramCompare = $"{cmp:X2}"; } - //Action Replay - else if (SingleCheat.IndexOf("-") == 3 && SingleCheat.Length == 9) + + // Action Replay + else if (_singleCheat.IndexOf("-") == 3 && _singleCheat.Length == 9) { - parseString = SingleCheat; - parseString = parseString.Remove(0, 2); - RAMAddress = parseString.Remove(4, 2); - RAMAddress = RAMAddress.Replace("-", ""); - RAMValue = parseString.Remove(0, 5); + _parseString = _singleCheat; + _parseString = _parseString.Remove(0, 2); + _ramAddress = _parseString.Remove(4, 2); + _ramAddress = _ramAddress.Replace("-", ""); + _ramValue = _parseString.Remove(0, 5); } - //It's an Action Replay - if (SingleCheat.Length != 9 && SingleCheat.LastIndexOf("-") != 7) + + // It's an Action Replay + if (_singleCheat.Length != 9 && _singleCheat.LastIndexOf("-") != 7) { - MessageBox.Show("All Master System Action Replay Codes need to be nine charaters in length.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("All Master System Action Replay Codes need to be nine characters in length.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - //Game Genie - else if (SingleCheat.LastIndexOf("-") != 7 && SingleCheat.IndexOf("-") != 3) + + // Game Genie + if (_singleCheat.LastIndexOf("-") != 7 && _singleCheat.IndexOf("-") != 3) { MessageBox.Show("All Master System Game Genie Codes need to have a dash after the third character and seventh character.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { - //A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. - //System Bus Domain, The Address to Watch, Byte size (Byte), Hex Display, Description. Not Big Endian. - var watch = Watch.GenerateWatch(MemoryDomains["Main RAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, false, txtDescription.Text); - //Take Watch, Add our Value we want, and it should be active when addded - - if (RAMCompare == null) - { - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); - } - else if (RAMCompare != null) - { - //We have a Compare - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber), int.Parse(RAMCompare, NumberStyles.HexNumber))); - } + // A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. + // System Bus Domain, The Address to Watch, Byte size (Byte), Hex Display, Description. Not Big Endian. + var watch = Watch.GenerateWatch(MemoryDomains["Main RAM"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, false, txtDescription.Text); + + // Take Watch, Add our Value we want, and it should be active when added + Global.CheatList.Add(ramCompare == null + ? new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber)) + : new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber), int.Parse(ramCompare, NumberStyles.HexNumber))); } - //Someone broke the world? catch (Exception ex) { MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - //Original code from adelikat + private void SnesGGDecode(string code, ref int val, ref int add) { // Code: D F 4 7 0 9 1 5 6 B C 8 A 2 3 E @@ -3068,147 +2971,145 @@ namespace BizHawk.Client.EmuHawk // Getting Value if (code.Length > 0) { - _SNESgameGenieTable.TryGetValue(code[0], out x); + _snesGameGenieTable.TryGetValue(code[0], out x); val = x << 4; } if (code.Length > 1) { - _SNESgameGenieTable.TryGetValue(code[1], out x); + _snesGameGenieTable.TryGetValue(code[1], out x); val |= x; } // Address if (code.Length > 2) { - _SNESgameGenieTable.TryGetValue(code[2], out x); + _snesGameGenieTable.TryGetValue(code[2], out x); add = x << 12; } if (code.Length > 3) { - _SNESgameGenieTable.TryGetValue(code[3], out x); + _snesGameGenieTable.TryGetValue(code[3], out x); add |= x << 4; } if (code.Length > 4) { - _SNESgameGenieTable.TryGetValue(code[4], out x); + _snesGameGenieTable.TryGetValue(code[4], out x); add |= (x & 0xC) << 6; add |= (x & 0x3) << 22; } if (code.Length > 5) { - _SNESgameGenieTable.TryGetValue(code[5], out x); + _snesGameGenieTable.TryGetValue(code[5], out x); add |= (x & 0xC) << 18; add |= (x & 0x3) << 2; } if (code.Length > 6) { - _SNESgameGenieTable.TryGetValue(code[6], out x); + _snesGameGenieTable.TryGetValue(code[6], out x); add |= (x & 0xC) >> 2; add |= (x & 0x3) << 18; } if (code.Length > 7) { - _SNESgameGenieTable.TryGetValue(code[7], out x); + _snesGameGenieTable.TryGetValue(code[7], out x); add |= (x & 0xC) << 14; add |= (x & 0x3) << 10; } } - private void SNES() + + private void Snes() { - Boolean GameGenie = false; - if (SingleCheat.Contains("-") && SingleCheat.Length == 9) + bool gameGenie = false; + if (_singleCheat.Contains("-") && _singleCheat.Length == 9) { int val = 0, add = 0; - string input; - //We have to remove the - since it will cause issues later on. - input = SingleCheat.Replace("-", ""); - SnesGGDecode(input, ref val, ref add); - RAMAddress = $"{add:X6}"; - RAMValue = $"{val:X2}"; - //We trim the first value here to make it work. - RAMAddress = RAMAddress.Remove(0, 1); - //Note, it's not actually a byte, but a Word. However, we are using this to keep from repeating code. - byteSize = 8; - GameGenie = true; + // We have to remove the - since it will cause issues later on. + var input = _singleCheat.Replace("-", ""); + SnesGGDecode(input, ref val, ref add); + _ramAddress = $"{add:X6}"; + _ramValue = $"{val:X2}"; + + // We trim the first value here to make it work. + _ramAddress = _ramAddress.Remove(0, 1); + + // Note, it's not actually a byte, but a Word. However, we are using this to keep from repeating code. + _byteSize = 8; + gameGenie = true; } - //This ONLY applies to Action Replay. - if (SingleCheat.Length == 8) + + // This ONLY applies to Action Replay. + if (_singleCheat.Length == 8) { - //Sample Code: - //7E18A428 - //Address: 7E18A4 - //Value: 28 - //Remove last two octets - RAMAddress = SingleCheat.Remove(6, 2); - //Get RAM Value - RAMValue = SingleCheat.Remove(0, 6); - //Note, it's a Word. However, we are using this to keep from repeating code. - byteSize = 16; + // Sample Code: + // 7E18A428 + // Address: 7E18A4 + // Value: 28 + // Remove last two octets + _ramAddress = _singleCheat.Remove(6, 2); + + // Get RAM Value + _ramValue = _singleCheat.Remove(0, 6); + + // Note, it's a Word. However, we are using this to keep from repeating code. + _byteSize = 16; } - if (SingleCheat.Contains("-") && SingleCheat.Length != 9) + + if (_singleCheat.Contains("-") && _singleCheat.Length != 9) { MessageBox.Show("Game Genie Codes need to be nine characters in length.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } - if (SingleCheat.Length != 9 && SingleCheat.Length != 8) + + if (_singleCheat.Length != 9 && _singleCheat.Length != 8) { MessageBox.Show("Pro Action Replay Codes need to be eight characters in length.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } + try { - //A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. - //Action Replay - if (byteSize == 16) + // Action Replay + if (_byteSize == 16) { - //System Bus Domain, The Address to Watch, Byte size (Byte), Hex Display, Description. Not Big Endian. - var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, false, txtDescription.Text); - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); + var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Word, Common.DisplayType.Hex, false, txtDescription.Text); + Global.CheatList.Add(new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber))); } - if (byteSize == 8) + else if (_byteSize == 8) { - //Is this correct? - if (GameGenie == true) + // Is this correct? + if (gameGenie) { MessageBox.Show("Game genie codes are not currently supported for SNES", "SNES Game Genie not supported", MessageBoxButtons.OK, MessageBoxIcon.Error); ////var watch = Watch.GenerateWatch(MemoryDomains["CARTROM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, false, txtDescription.Text); ////Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); } - else if (GameGenie == false) + else { - var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, false, txtDescription.Text); - Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); + var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(_ramAddress, NumberStyles.HexNumber), WatchSize.Byte, Common.DisplayType.Hex, false, txtDescription.Text); + Global.CheatList.Add(new Cheat(watch, int.Parse(_ramValue, NumberStyles.HexNumber))); } } - //Take Watch, Add our Value we want, and it should be active when addded? } - //Someone broke the world? catch (Exception ex) { MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void btnClear_Click(object sender, EventArgs e) + + private void BtnClear_Click(object sender, EventArgs e) { - //Clear old Inputs - DialogResult result = MessageBox.Show("Are you sure you want to clear this form?", "Clear Form", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + // Clear old Inputs + var result = MessageBox.Show("Are you sure you want to clear this form?", "Clear Form", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { txtDescription.Clear(); txtCheat.Clear(); } } - - private void GameShark_Load(object sender, EventArgs e) - { - //TODO? - //Add special handling for cores that need special things? - //GBA may need a special thing. - } } } \ No newline at end of file diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index f81408114e..4f65d99bfc 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -185,6 +185,8 @@ True True True + True + True True True True @@ -208,6 +210,7 @@ True True True + True True True True @@ -256,10 +259,12 @@ True True True + True True True True True + True True True True @@ -282,10 +287,13 @@ True True True + True + True True True True True + True True True True @@ -327,6 +335,7 @@ True True True + True True True True @@ -351,6 +360,7 @@ True True True + True True True True @@ -531,8 +541,16 @@ True True True + True + True + True + True True True + True + True + True + True True True True