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); } }
//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(); }