From 2448ad0dda684453687f89c1de421876dff988e6 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 22 Dec 2013 20:25:43 +0000 Subject: [PATCH] Wire up the Genesis Game Genie Encoder/Decoder to the GPGX core, but disable it since it doesn't seem to work right now --- BizHawk.Client.EmuHawk/MainForm.cs | 4 +- BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs | 10 +- .../tools/Genesis/GenGameGenie.cs | 157 ++++++++---------- .../Consoles/Sega/Genesis/Genesis.cs | 2 +- 4 files changed, 80 insertions(+), 93 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index de1c4c0838..ef96a80e99 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -709,10 +709,12 @@ namespace BizHawk.Client.EmuHawk { GlobalWin.Tools.Load(); } - else if (Global.Emulator is Genesis) + /* adelikat: Genesis decoding doesn't seem to work yet + else if (Global.Emulator.SystemId == "GEN") { GlobalWin.Tools.Load(); } + */ } public void LoadTraceLogger() diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs index db98cd4884..6900da92e4 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs @@ -71,7 +71,7 @@ namespace BizHawk.Client.EmuHawk public void UpdateValues() { - //Do nothing; + // Do nothing; } public void Restart() @@ -191,7 +191,7 @@ namespace BizHawk.Client.EmuHawk LoadConfigSettings(); ToggleGameGenieButton(); CheatEditor.SetAddEvent(AddCheat); - CheatEditor.SetEditEvent(AddCheat); //CheatList.Add is already an upsert, so there is nothing different to handle here + CheatEditor.SetEditEvent(AddCheat); // CheatList.Add is already an upsert, so there is nothing different to handle here UpdateDialog(); } @@ -200,7 +200,7 @@ namespace BizHawk.Client.EmuHawk GameGenieToolbarSeparator.Visible = LoadGameGenieToolbarItem.Visible = ((Global.Emulator is NES) - || (Global.Emulator is Genesis) + /*|| (Global.Emulator.SystemId == "GEN")*/ || (Global.Emulator.SystemId == "GB") || (Global.Game.System == "GG") || (Global.Emulator is LibsnesCore)); @@ -224,8 +224,8 @@ namespace BizHawk.Client.EmuHawk private void LoadConfigSettings() { - //Size and Positioning - _defaultWidth = Size.Width; //Save these first so that the user can restore to its original size + // Size and Positioning + _defaultWidth = Size.Width; _defaultHeight = Size.Height; if (Global.Config.CheatsSaveWindowPosition && Global.Config.CheatsWndx >= 0 && Global.Config.CheatsWndy >= 0) diff --git a/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs b/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs index 18a9524f7c..861b809b4a 100644 --- a/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs +++ b/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs @@ -6,7 +6,7 @@ using System.Globalization; using System.Text.RegularExpressions; using BizHawk.Client.Common; -using BizHawk.Emulation.Cores.Sega.Genesis; +//using BizHawk.Emulation.Cores.Sega.Genesis; #pragma warning disable 675 //TOOD: fix the potential problem this is masking @@ -21,14 +21,14 @@ namespace BizHawk.Client.EmuHawk public bool UpdateBefore { get { return false; } } public void Restart() { - if (!(Global.Emulator is Genesis)) + if (!(Global.Emulator.SystemId == "GEN")) { Close(); } } public void UpdateValues() { - if (!(Global.Emulator is Genesis)) + if (!(Global.Emulator.SystemId == "GEN")) { Close(); } @@ -39,41 +39,40 @@ namespace BizHawk.Client.EmuHawk InitializeComponent(); Closing += (o, e) => SaveConfigSettings(); - GameGenieTable.Add('A', 0); - GameGenieTable.Add('B', 1); - GameGenieTable.Add('C', 2); - GameGenieTable.Add('D', 3); - GameGenieTable.Add('E', 4); - GameGenieTable.Add('F', 5); - GameGenieTable.Add('G', 6); - GameGenieTable.Add('H', 7); - GameGenieTable.Add('J', 8); - GameGenieTable.Add('K', 9); - GameGenieTable.Add('L', 10); - GameGenieTable.Add('M', 11); - GameGenieTable.Add('N', 12); - GameGenieTable.Add('P', 13); - GameGenieTable.Add('R', 14); - GameGenieTable.Add('S', 15); - GameGenieTable.Add('T', 16); - GameGenieTable.Add('V', 17); - GameGenieTable.Add('W', 18); - GameGenieTable.Add('X', 19); - GameGenieTable.Add('Y', 20); - GameGenieTable.Add('Z', 21); - GameGenieTable.Add('0', 22); - GameGenieTable.Add('1', 23); - GameGenieTable.Add('2', 24); - GameGenieTable.Add('3', 25); - GameGenieTable.Add('4', 26); - GameGenieTable.Add('5', 27); - GameGenieTable.Add('6', 28); - GameGenieTable.Add('7', 29); - GameGenieTable.Add('8', 30); - GameGenieTable.Add('9', 31); + GameGenieTable.Add('A', 0); + GameGenieTable.Add('B', 1); + GameGenieTable.Add('C', 2); + GameGenieTable.Add('D', 3); + GameGenieTable.Add('E', 4); + GameGenieTable.Add('F', 5); + GameGenieTable.Add('G', 6); + GameGenieTable.Add('H', 7); + GameGenieTable.Add('J', 8); + GameGenieTable.Add('K', 9); + GameGenieTable.Add('L', 10); + GameGenieTable.Add('M', 11); + GameGenieTable.Add('N', 12); + GameGenieTable.Add('P', 13); + GameGenieTable.Add('R', 14); + GameGenieTable.Add('S', 15); + GameGenieTable.Add('T', 16); + GameGenieTable.Add('V', 17); + GameGenieTable.Add('W', 18); + GameGenieTable.Add('X', 19); + GameGenieTable.Add('Y', 20); + GameGenieTable.Add('Z', 21); + GameGenieTable.Add('0', 22); + GameGenieTable.Add('1', 23); + GameGenieTable.Add('2', 24); + GameGenieTable.Add('3', 25); + GameGenieTable.Add('4', 26); + GameGenieTable.Add('5', 27); + GameGenieTable.Add('6', 28); + GameGenieTable.Add('7', 29); + GameGenieTable.Add('8', 30); + GameGenieTable.Add('9', 31); } - // code is code to be converted, val is pointer to value, add is pointer to address private void GenGGDecode(string code, ref int val, ref int add) { @@ -241,59 +240,45 @@ namespace BizHawk.Client.EmuHawk private void addcheatbt_Click(object sender, EventArgs e) { - if (Global.Emulator is Genesis) + string NAME; + int ADDRESS = 0; + int VALUE = 0; + + if (!String.IsNullOrWhiteSpace(cheatname.Text)) { - string NAME; - int ADDRESS = 0; - int VALUE = 0; - int romDataDomainIndex = 0; - - - if (!String.IsNullOrWhiteSpace(cheatname.Text)) - { - NAME = cheatname.Text; - } - else - { - _processing = true; - GGCodeMaskBox.TextMaskFormat = MaskFormat.IncludeLiterals; - NAME = GGCodeMaskBox.Text; - GGCodeMaskBox.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; - _processing = false; - } - - if (!String.IsNullOrWhiteSpace(AddressBox.Text)) - { - ADDRESS = int.Parse(AddressBox.Text, NumberStyles.HexNumber); - } - - if (!String.IsNullOrWhiteSpace(ValueBox.Text)) - { - VALUE = ValueBox.ToRawInt().Value; - } - - for (int i = 0; i < Global.Emulator.MemoryDomains.Count; i++) - { - if (Global.Emulator.MemoryDomains[i].ToString() == "Rom Data") - { - romDataDomainIndex = i; - } - } - - Watch watch = Watch.GenerateWatch( - Global.Emulator.MemoryDomains[romDataDomainIndex], - ADDRESS, - Watch.WatchSize.Word, - Watch.DisplayType.Hex, - NAME, true - ); - - Global.CheatList.Add(new Cheat( - watch, - VALUE - )); + NAME = cheatname.Text; + } + else + { + _processing = true; + GGCodeMaskBox.TextMaskFormat = MaskFormat.IncludeLiterals; + NAME = GGCodeMaskBox.Text; + GGCodeMaskBox.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; + _processing = false; } + if (!String.IsNullOrWhiteSpace(AddressBox.Text)) + { + ADDRESS = int.Parse(AddressBox.Text, NumberStyles.HexNumber); + } + + if (!String.IsNullOrWhiteSpace(ValueBox.Text)) + { + VALUE = ValueBox.ToRawInt().Value; + } + + Watch watch = Watch.GenerateWatch( + Global.Emulator.MemoryDomains["MD CART"], + ADDRESS, + Watch.WatchSize.Word, + Watch.DisplayType.Hex, + NAME, true + ); + + Global.CheatList.Add(new Cheat( + watch, + VALUE + )); } private void autoloadToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs index 3edde3472c..4eced56453 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs @@ -460,7 +460,7 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis addr => VDP.VRAM[addr & 0xFFFF], (addr, value) => VDP.VRAM[addr & 0xFFFF] = value); - var RomDomain = new MemoryDomain("Rom Data", RomData.Length, MemoryDomain.Endian.Big, + var RomDomain = new MemoryDomain("MD CART", RomData.Length, MemoryDomain.Endian.Big, addr => RomData[addr], //adelikat: For speed considerations, I didn't mask this, every tool that uses memory domains is smart enough not to overflow, if I'm wrong let me know! (addr, value) => RomData[addr & (RomData.Length - 1)] = value);