public static void ActiveGameGenie() { if (!NesEmu.EmulationON) { Program.VIDEO.WriteNotification("Game Genie can't be enabled while emulation is OFF.", 200, System.Drawing.Color.Red); return; } string filePath = Path.Combine(Settings.Folder_GameGenieCodes, Path.GetFileNameWithoutExtension(Program.CurrentGameFile) + ".ggc"); if (File.Exists(filePath)) { string[] lines = File.ReadAllLines(filePath); // Clear all if (lines.Length > 0) { GameGenie gameGenie = new GameGenie(); List <GameGenieCode> codes = new List <GameGenieCode>(); // Add code by code for (int i = 0; i < lines.Length; i++) { GameGenieCode newcode = new GameGenieCode(); newcode.Enabled = true; newcode.Name = lines[i]; if (lines[i].Length == 6) { newcode.Address = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(lines[i]), 6) | 0x8000; newcode.Value = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(lines[i]), 6); newcode.IsCompare = false; } else { newcode.Address = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(lines[i]), 8) | 0x8000; newcode.Value = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(lines[i]), 8); newcode.Compare = gameGenie.GetGGCompareValue(gameGenie.GetCodeAsHEX(lines[i])); newcode.IsCompare = true; } codes.Add(newcode); } if (codes.Count > 0) { NesEmu.SetupGameGenie(true, codes.ToArray()); Program.VIDEO.WriteNotification("Game Genie File Loaded; Game Genie enabled.", 200, System.Drawing.Color.Lime); } else { Program.VIDEO.WriteNotification("There is no Game Genie code to load.", 200, System.Drawing.Color.Red); } } else { Program.VIDEO.WriteNotification("Game Genie file is empty.", 200, System.Drawing.Color.Red); } } else { Program.VIDEO.WriteNotification("Game Genie file is not found.", 200, System.Drawing.Color.Red); } }
public override void Execute() { string filePath = Path.Combine(Settings.Folder_GameGenieCodes, Path.GetFileNameWithoutExtension(Program.CurrentGameFile) + ".ggc"); if (File.Exists(filePath)) { string[] lines = File.ReadAllLines(filePath); // Clear all if (lines.Length > 0) { page.Items[3].Options.Clear(); page.Items[4].Options.Clear(); page.Items[5].Options.Clear(); page.Items[6].Options.Clear(); page.Items[7].Options.Clear(); // Add code by code for (int i = 0; i < lines.Length; i++) { GameGenieCode newcode = new GameGenieCode(); newcode.Enabled = true; newcode.Name = lines[i]; if (lines[i].Length == 6) { newcode.Address = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(lines[i]), 6); newcode.Value = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(lines[i]), 6); newcode.IsCompare = false; } else { newcode.Address = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(lines[i]), 8); newcode.Value = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(lines[i]), 8); newcode.Compare = gameGenie.GetGGCompareValue(gameGenie.GetCodeAsHEX(lines[i])); newcode.IsCompare = true; } page.Items[3].Options.Add(i.ToString()); page.Items[4].Options.Add(lines[i]); page.Items[5].Options.Add(newcode.Address.ToString("X4")); page.Items[6].Options.Add(newcode.Value.ToString("X2")); page.Items[7].Options.Add(newcode.Compare.ToString("X2")); } page.SelectLastCode(); Program.VIDEO.WriteNotification("Game Genie File Loaded !!", 200, System.Drawing.Color.Lime); } else { Program.VIDEO.WriteNotification("Game Genie file is empty.", 200, System.Drawing.Color.Red); } } else { Program.VIDEO.WriteNotification("Game Genie file is not found.", 200, System.Drawing.Color.Red); } }
private void ShowValues() { if (textBox2.Text.Length == 6) { textBox_address.Text = string.Format("{0:X4}", gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(textBox2.Text), 6)); textBox_value.Text = string.Format("{0:X2}", gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(textBox2.Text), 6)); textBox1.Text = "00"; } else if (textBox2.Text.Length == 8)//8 code length { textBox_address.Text = string.Format("{0:X4}", gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(textBox2.Text), 8)); textBox_value.Text = string.Format("{0:X2}", gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(textBox2.Text), 8)); textBox1.Text = string.Format("{0:X2}", gameGenie.GetGGCompareValue(gameGenie.GetCodeAsHEX(textBox2.Text))); } else//code incomplete { textBox_address.Text = Program.ResourceManager.GetString("ERROR"); textBox_value.Text = textBox1.Text = Program.ResourceManager.GetString("ERROR"); } }
public override void Execute() { // Apply all codes ! page._gameGenieCodes = new List <GameGenieCode>(); bool enabled = page.Items[0].SelectedOptionIndex == 1; if (page.Items[3].Options[0] != "N/A") { for (int i = 0; i < page.Items[3].Options.Count; i++) { if (page.Items[4].Options[0] != "" && page.Items[5].Options[0] != "ERROR") { GameGenieCode newcode = new GameGenieCode(); newcode.Enabled = true; string code = page.Items[4].Options[0]; newcode.Name = code; if (code.Length == 6) { newcode.Address = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(code), 6) | 0x8000; newcode.Value = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(code), 6); newcode.IsCompare = false; } else { newcode.Address = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(code), 8) | 0x8000; newcode.Value = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(code), 8); newcode.Compare = gameGenie.GetGGCompareValue(gameGenie.GetCodeAsHEX(code)); newcode.IsCompare = true; } page._gameGenieCodes.Add(newcode); } } } NesEmu.SetupGameGenie(enabled, page._gameGenieCodes.ToArray()); Program.SelectRoom("main menu"); }
//ok private void button1_Click(object sender, EventArgs e) { if (listView1.Items.Count == 0) { MessageBox.Show(Program.ResourceManager.GetString("Message_ThereIsNoCodeInTheList")); return; } //Nes.Board.IsGameGenieActive = checkBox1.Checked; List <GameGenieCode> codes = new List <GameGenieCode>(); gameGenie = new GameGenie(); foreach (ListViewItem item in listView1.Items) { GameGenieCode code = new GameGenieCode(); code.Enabled = item.Checked; code.Name = item.Text; code.Descreption = item.SubItems[1].Text; if (item.Text.Length == 6) { code.Address = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(item.Text), 6) | 0x8000; code.Value = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(item.Text), 6); code.IsCompare = false; } else { code.Address = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(item.Text), 8) | 0x8000; code.Value = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(item.Text), 8); code.Compare = gameGenie.GetGGCompareValue(gameGenie.GetCodeAsHEX(item.Text)); code.IsCompare = true; } //add to active list codes.Add(code); } NesEmu.SetupGameGenie(checkBox1.Checked, codes.ToArray()); this.Close(); }