diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index 7f99012e03..ba6f5b5b6b 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -673,6 +673,12 @@ BatchRun.cs + + Form + + + CDL.cs + UserControl @@ -917,12 +923,6 @@ PCEBGViewer.cs - - Form - - - PCECDL.cs - Form @@ -1349,6 +1349,9 @@ BatchRun.cs + + CDL.cs + CheatEdit.cs @@ -1446,9 +1449,6 @@ PCEBGViewer.cs - - PCECDL.cs - PCESoundDebugger.cs diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 72e7d66914..8c5bb077e1 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -1387,7 +1387,7 @@ namespace BizHawk.Client.EmuHawk private void CodeDataLoggerMenuItem_Click(object sender, EventArgs e) { - GlobalWin.Tools.Load(); + GlobalWin.Tools.Load(); } private void PCEAlwaysPerformSpriteLimitMenuItem_Click(object sender, EventArgs e) @@ -2610,8 +2610,8 @@ namespace BizHawk.Client.EmuHawk else if (ext.ToUpper() == ".CDL" && Global.Emulator is PCEngine) { - GlobalWin.Tools.Load(); - (GlobalWin.Tools.Get() as PCECDL).LoadFile(filePaths[0]); + GlobalWin.Tools.Load(); + (GlobalWin.Tools.Get() as CDL).LoadFile(filePaths[0]); } else if (MovieImport.IsValidMovieExtension(Path.GetExtension(filePaths[0]))) diff --git a/BizHawk.Client.EmuHawk/tools/PCE/PCECDL.Designer.cs b/BizHawk.Client.EmuHawk/tools/CDL.Designer.cs similarity index 96% rename from BizHawk.Client.EmuHawk/tools/PCE/PCECDL.Designer.cs rename to BizHawk.Client.EmuHawk/tools/CDL.Designer.cs index 73fbfee987..1674d4559b 100644 --- a/BizHawk.Client.EmuHawk/tools/PCE/PCECDL.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/CDL.Designer.cs @@ -1,6 +1,6 @@ namespace BizHawk.Client.EmuHawk { - partial class PCECDL + partial class CDL { /// /// Required designer variable. @@ -28,7 +28,7 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PCECDL)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CDL)); this.LoggingActiveCheckbox = new System.Windows.Forms.CheckBox(); this.menuStrip1 = new MenuStripEx(); this.FileSubMenu = new System.Windows.Forms.ToolStripMenuItem(); diff --git a/BizHawk.Client.EmuHawk/tools/PCE/PCECDL.cs b/BizHawk.Client.EmuHawk/tools/CDL.cs similarity index 94% rename from BizHawk.Client.EmuHawk/tools/PCE/PCECDL.cs rename to BizHawk.Client.EmuHawk/tools/CDL.cs index dc69b2c02a..d4e894e6f6 100644 --- a/BizHawk.Client.EmuHawk/tools/PCE/PCECDL.cs +++ b/BizHawk.Client.EmuHawk/tools/CDL.cs @@ -16,7 +16,7 @@ using BizHawk.Client.EmuHawk.ToolExtensions; namespace BizHawk.Client.EmuHawk { - public partial class PCECDL : Form, IToolFormAutoConfig + public partial class CDL : Form, IToolFormAutoConfig { [RequiredService] public IEmulator _emu { get; private set; } @@ -44,7 +44,7 @@ namespace BizHawk.Client.EmuHawk private string _currentFileName = string.Empty; - public PCECDL() + public CDL() { InitializeComponent(); } diff --git a/BizHawk.Client.EmuHawk/tools/PCE/PCECDL.resx b/BizHawk.Client.EmuHawk/tools/CDL.resx similarity index 100% rename from BizHawk.Client.EmuHawk/tools/PCE/PCECDL.resx rename to BizHawk.Client.EmuHawk/tools/CDL.resx diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index dc3bedcbe2..3f0794343d 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -118,6 +118,7 @@ TI83.cs + AppleII.cs @@ -825,6 +826,7 @@ + @@ -838,7 +840,6 @@ - diff --git a/BizHawk.Emulation.Cores/CPUs/HuC6280/CDL.cs b/BizHawk.Emulation.Cores/CDL.cs similarity index 69% rename from BizHawk.Emulation.Cores/CPUs/HuC6280/CDL.cs rename to BizHawk.Emulation.Cores/CDL.cs index c43c94b7af..9bc4818de6 100644 --- a/BizHawk.Emulation.Cores/CPUs/HuC6280/CDL.cs +++ b/BizHawk.Emulation.Cores/CDL.cs @@ -5,99 +5,12 @@ using System.Text; using System.IO; using BizHawk.Emulation.Common; -//TODO - reorg please +//needed for being a factory using BizHawk.Emulation.Cores.Nintendo.Gameboy; +using BizHawk.Emulation.Cores.Components.H6280; namespace BizHawk.Emulation.Cores.Components.H6280 { - public class CodeDataLog_PCE : CodeDataLog - { - public static CodeDataLog_PCE Create(IEnumerable mm) - { - var t = new CodeDataLog_PCE(); - foreach (var kvp in SizesFromHuMap(mm)) - { - t[kvp.Key] = new byte[kvp.Value]; - } - return t; - } - - public override string SubType { get { return "PCE"; } } - public override int SubVer { get { return 0; } } - - public override void Disassemble(Stream s, IMemoryDomains mem) - { - var w = new StreamWriter(s); - w.WriteLine("; Bizhawk CDL Disassembly"); - w.WriteLine(); - foreach (var kvp in this) - { - w.WriteLine(".\"{0}\" size=0x{1:x8}", kvp.Key, kvp.Value.Length); - - byte[] cd = kvp.Value; - var md = mem[kvp.Key]; - - for (int i = 0; i < kvp.Value.Length; i++) - { - if ((kvp.Value[i] & (byte)HuC6280.CDLUsage.Code) != 0) - { - int unused; - string dis = HuC6280.DisassembleExt( - 0, - out unused, - delegate(ushort addr) - { - return md.PeekByte(addr + i); - }, - delegate(ushort addr) - { - return md.PeekWord(addr + i, false); - } - ); - w.WriteLine("0x{0:x8}: {1}", i, dis); - } - } - w.WriteLine(); - } - w.WriteLine("; EOF"); - w.Flush(); - } - - public bool CheckConsistency(object arg) - { - var mm = (IEnumerable)arg; - var sizes = SizesFromHuMap(mm); - if (sizes.Count != Count) - return false; - foreach (var kvp in sizes) - { - if (!ContainsKey(kvp.Key)) - return false; - if (this[kvp.Key].Length != kvp.Value) - return false; - } - return true; - } - - private static Dictionary SizesFromHuMap(IEnumerable mm) - { - Dictionary sizes = new Dictionary(); - foreach (var m in mm) - { - if (!sizes.ContainsKey(m.Name) || m.MaxOffs >= sizes[m.Name]) - sizes[m.Name] = m.MaxOffs; - } - - List keys = new List(sizes.Keys); - foreach (var key in keys) - { - // becase we were looking at offsets, and each bank is 8192 big, we need to add that size - sizes[key] += 8192; - } - return sizes; - } - } - public abstract class CodeDataLog : Dictionary { public CodeDataLog() diff --git a/BizHawk.Emulation.Cores/CPUs/HuC6280/CodeDataLog_PCE.cs b/BizHawk.Emulation.Cores/CPUs/HuC6280/CodeDataLog_PCE.cs new file mode 100644 index 0000000000..a61dc2c6d9 --- /dev/null +++ b/BizHawk.Emulation.Cores/CPUs/HuC6280/CodeDataLog_PCE.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Components.H6280 +{ + public class CodeDataLog_PCE : CodeDataLog + { + public static CodeDataLog_PCE Create(IEnumerable mm) + { + var t = new CodeDataLog_PCE(); + foreach (var kvp in SizesFromHuMap(mm)) + { + t[kvp.Key] = new byte[kvp.Value]; + } + return t; + } + + public override string SubType { get { return "PCE"; } } + public override int SubVer { get { return 0; } } + + public override void Disassemble(Stream s, IMemoryDomains mem) + { + var w = new StreamWriter(s); + w.WriteLine("; Bizhawk CDL Disassembly"); + w.WriteLine(); + foreach (var kvp in this) + { + w.WriteLine(".\"{0}\" size=0x{1:x8}", kvp.Key, kvp.Value.Length); + + byte[] cd = kvp.Value; + var md = mem[kvp.Key]; + + for (int i = 0; i < kvp.Value.Length; i++) + { + if ((kvp.Value[i] & (byte)HuC6280.CDLUsage.Code) != 0) + { + int unused; + string dis = HuC6280.DisassembleExt( + 0, + out unused, + delegate(ushort addr) + { + return md.PeekByte(addr + i); + }, + delegate(ushort addr) + { + return md.PeekWord(addr + i, false); + } + ); + w.WriteLine("0x{0:x8}: {1}", i, dis); + } + } + w.WriteLine(); + } + w.WriteLine("; EOF"); + w.Flush(); + } + + public bool CheckConsistency(object arg) + { + var mm = (IEnumerable)arg; + var sizes = SizesFromHuMap(mm); + if (sizes.Count != Count) + return false; + foreach (var kvp in sizes) + { + if (!ContainsKey(kvp.Key)) + return false; + if (this[kvp.Key].Length != kvp.Value) + return false; + } + return true; + } + + private static Dictionary SizesFromHuMap(IEnumerable mm) + { + Dictionary sizes = new Dictionary(); + foreach (var m in mm) + { + if (!sizes.ContainsKey(m.Name) || m.MaxOffs >= sizes[m.Name]) + sizes[m.Name] = m.MaxOffs; + } + + List keys = new List(sizes.Keys); + foreach (var key in keys) + { + // becase we were looking at offsets, and each bank is 8192 big, we need to add that size + sizes[key] += 8192; + } + return sizes; + } + } +}