예제 #1
0
        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);
            }
        }
예제 #2
0
            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");
            }
예제 #3
0
        //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();
        }