From fbe010a18d9564a302963086a9d3f9c8cefdc331 Mon Sep 17 00:00:00 2001 From: zeromus <zeromus@users.noreply.github.com> Date: Mon, 26 Oct 2015 19:22:07 -0500 Subject: [PATCH] CDL reorg --- .../BizHawk.Client.EmuHawk.csproj | 18 ++-- BizHawk.Client.EmuHawk/MainForm.Events.cs | 6 +- .../PCECDL.Designer.cs => CDL.Designer.cs} | 4 +- .../tools/{PCE/PCECDL.cs => CDL.cs} | 4 +- .../tools/{PCE/PCECDL.resx => CDL.resx} | 0 .../BizHawk.Emulation.Cores.csproj | 3 +- .../{CPUs/HuC6280 => }/CDL.cs | 91 +---------------- .../CPUs/HuC6280/CodeDataLog_PCE.cs | 97 +++++++++++++++++++ 8 files changed, 117 insertions(+), 106 deletions(-) rename BizHawk.Client.EmuHawk/tools/{PCE/PCECDL.Designer.cs => CDL.Designer.cs} (96%) rename BizHawk.Client.EmuHawk/tools/{PCE/PCECDL.cs => CDL.cs} (94%) rename BizHawk.Client.EmuHawk/tools/{PCE/PCECDL.resx => CDL.resx} (100%) rename BizHawk.Emulation.Cores/{CPUs/HuC6280 => }/CDL.cs (69%) create mode 100644 BizHawk.Emulation.Cores/CPUs/HuC6280/CodeDataLog_PCE.cs 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 @@ <DependentUpon>BatchRun.cs</DependentUpon> </Compile> <Compile Include="tools\BatchRunner.cs" /> + <Compile Include="tools\CDL.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="tools\CDL.designer.cs"> + <DependentUpon>CDL.cs</DependentUpon> + </Compile> <Compile Include="tools\Cheats\CheatEdit.cs"> <SubType>UserControl</SubType> </Compile> @@ -917,12 +923,6 @@ <Compile Include="tools\PCE\PCEBGViewer.Designer.cs"> <DependentUpon>PCEBGViewer.cs</DependentUpon> </Compile> - <Compile Include="tools\PCE\PCECDL.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="tools\PCE\PCECDL.Designer.cs"> - <DependentUpon>PCECDL.cs</DependentUpon> - </Compile> <Compile Include="tools\PCE\PCESoundDebugger.cs"> <SubType>Form</SubType> </Compile> @@ -1349,6 +1349,9 @@ <EmbeddedResource Include="tools\BatchRun.resx"> <DependentUpon>BatchRun.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="tools\CDL.resx"> + <DependentUpon>CDL.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="tools\Cheats\CheatEdit.resx"> <DependentUpon>CheatEdit.cs</DependentUpon> </EmbeddedResource> @@ -1446,9 +1449,6 @@ <EmbeddedResource Include="tools\PCE\PCEBGViewer.resx"> <DependentUpon>PCEBGViewer.cs</DependentUpon> </EmbeddedResource> - <EmbeddedResource Include="tools\PCE\PCECDL.resx"> - <DependentUpon>PCECDL.cs</DependentUpon> - </EmbeddedResource> <EmbeddedResource Include="tools\PCE\PCESoundDebugger.resx"> <DependentUpon>PCESoundDebugger.cs</DependentUpon> </EmbeddedResource> 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<PCECDL>(); + GlobalWin.Tools.Load<CDL>(); } 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<PCECDL>(); - (GlobalWin.Tools.Get<PCECDL>() as PCECDL).LoadFile(filePaths[0]); + GlobalWin.Tools.Load<CDL>(); + (GlobalWin.Tools.Get<CDL>() 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 { /// <summary> /// Required designer variable. @@ -28,7 +28,7 @@ /// </summary> 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 @@ <DependentUpon>TI83.cs</DependentUpon> </Compile> <Compile Include="Calculator\TI83LinkPort.cs" /> + <Compile Include="CDL.cs" /> <Compile Include="Computers\AppleII\AppleII.cs" /> <Compile Include="Computers\AppleII\AppleII.IAudioProvider.cs"> <DependentUpon>AppleII.cs</DependentUpon> @@ -825,6 +826,7 @@ <Compile Include="CoreInventory.cs" /> <Compile Include="CPUs\CP1610\CP1610.Disassembler.cs" /> <Compile Include="CPUs\CP1610\CP1610.Execute.cs" /> + <Compile Include="CPUs\HuC6280\CodeDataLog_PCE.cs" /> <Compile Include="CPUs\W65816\Disassembler.cs" /> <Compile Include="CPUs\68000\Diassembler.cs" /> <Compile Include="CPUs\68000\Instructions\BitArithemetic.cs" /> @@ -838,7 +840,6 @@ <Compile Include="CPUs\68000\Tables.cs" /> <Compile Include="CPUs\ARM\Darm.cs" /> <Compile Include="CPUs\CP1610\CP1610.cs" /> - <Compile Include="CPUs\HuC6280\CDL.cs" /> <Compile Include="CPUs\HuC6280\CDLOpcodes.cs" /> <Compile Include="CPUs\HuC6280\Disassembler.cs" /> <Compile Include="CPUs\HuC6280\Execute.cs" /> 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<HuC6280.MemMapping> 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<HuC6280.MemMapping>)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<string, int> SizesFromHuMap(IEnumerable<HuC6280.MemMapping> mm) - { - Dictionary<string, int> sizes = new Dictionary<string, int>(); - foreach (var m in mm) - { - if (!sizes.ContainsKey(m.Name) || m.MaxOffs >= sizes[m.Name]) - sizes[m.Name] = m.MaxOffs; - } - - List<string> keys = new List<string>(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<string, byte[]> { 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<HuC6280.MemMapping> 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<HuC6280.MemMapping>)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<string, int> SizesFromHuMap(IEnumerable<HuC6280.MemMapping> mm) + { + Dictionary<string, int> sizes = new Dictionary<string, int>(); + foreach (var m in mm) + { + if (!sizes.ContainsKey(m.Name) || m.MaxOffs >= sizes[m.Name]) + sizes[m.Name] = m.MaxOffs; + } + + List<string> keys = new List<string>(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; + } + } +}