From 7bebb665892b16ae889d4b961b9d08a3c638999d Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 20 Dec 2014 03:19:33 +0000 Subject: [PATCH] IDebuggable - refactor GetCpuFlagsAndRegisters to be IDictionary where Register is a value and a bitsize --- .../lua/EmuLuaLibrary.Emu.cs | 3 +- .../Debugger/GenericDebugger.IToolForm.cs | 3 +- .../tools/Debugger/RegisterBoxControl.cs | 4 +- .../Interfaces/IDebuggable.cs | 71 ++++++++++++++++++- .../Calculator/TI83.IDebuggable.cs | 20 +++--- .../Computers/Commodore64/C64.IDebuggable.cs | 20 +++--- .../Atari/2600/Atari2600.IDebuggable.cs | 20 +++--- .../Atari/7800/Atari7800.IDebuggable.cs | 18 ++--- .../Coleco/ColecoVision.IDebuggable.cs | 20 +++--- .../Consoles/Nintendo/GBA/Meteor.cs | 4 +- .../Consoles/Nintendo/GBA/VBANext.cs | 2 +- .../Nintendo/GBA/VBARegisterHelper.cs | 5 +- .../Consoles/Nintendo/Gameboy/Gambatte.cs | 24 +++---- .../Consoles/Nintendo/Gameboy/GambatteLink.cs | 6 +- .../Consoles/Nintendo/N64/N64.IDebuggable.cs | 4 +- .../Consoles/Nintendo/NES/NES.cs | 20 +++--- .../Consoles/Nintendo/QuickNES/QuickNES.cs | 16 ++--- .../Consoles/Nintendo/SNES/LibsnesCore.cs | 50 ++++++------- .../Consoles/PC Engine/PCEngine.cs | 4 +- .../Consoles/Sega/Genesis/Genesis.cs | 14 ++-- .../Consoles/Sega/SMS/SMS.cs | 20 +++--- .../Consoles/Sega/gpgx/GPGX.cs | 8 +-- .../Consoles/Sony/PSX/Octoshock.cs | 5 +- .../Consoles/WonderSwan/WonderSwan.cs | 7 +- 24 files changed, 221 insertions(+), 147 deletions(-) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs index 9b22d49e45..7bc1ccda54 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs @@ -57,6 +57,7 @@ namespace BizHawk.Client.Common return Global.Emulator.Frame; } + // TODO: what about 64 bit registers? [LuaMethodAttributes( "getregister", "returns the value of a cpu register or flag specified by name. For a complete list of possible registers or flags for a given core, use getregisters" @@ -73,7 +74,7 @@ namespace BizHawk.Client.Common var registers = debuggable.GetCpuFlagsAndRegisters(); return registers.ContainsKey(name) - ? registers[name] + ? (int)registers[name].Value : 0; } catch (NotImplementedException) diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.IToolForm.cs b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.IToolForm.cs index 3b2806e539..e976df0ff1 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.IToolForm.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.IToolForm.cs @@ -22,7 +22,8 @@ namespace BizHawk.Client.EmuHawk private int PC { - get { return Core.GetCpuFlagsAndRegisters()[Disassembler.PCRegisterName]; } + // TODO: is this okay for N64? + get { return (int)Core.GetCpuFlagsAndRegisters()[Disassembler.PCRegisterName].Value; } } #region Implementation checking diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/RegisterBoxControl.cs b/BizHawk.Client.EmuHawk/tools/Debugger/RegisterBoxControl.cs index dfc6b570c9..8c6a336b72 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/RegisterBoxControl.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/RegisterBoxControl.cs @@ -48,7 +48,7 @@ namespace BizHawk.Client.EmuHawk { if (checkbox.Name == register.Key) { - checkbox.Checked = register.Value == 1; + checkbox.Checked = register.Value.Value == 1; } }); @@ -135,7 +135,7 @@ namespace BizHawk.Client.EmuHawk { Name = register.Key, Text = "", - Checked = register.Value == 1 ? true : false, + Checked = register.Value.Value == 1 ? true : false, Location = new Point(40, y) }; diff --git a/BizHawk.Emulation.Common/Interfaces/IDebuggable.cs b/BizHawk.Emulation.Common/Interfaces/IDebuggable.cs index 02338f9c5d..dc7a45f738 100644 --- a/BizHawk.Emulation.Common/Interfaces/IDebuggable.cs +++ b/BizHawk.Emulation.Common/Interfaces/IDebuggable.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Common /// Returns a list of Cpu registers and their current state /// /// - IDictionary GetCpuFlagsAndRegisters(); + IDictionary GetCpuFlagsAndRegisters(); /// /// Sets a given Cpu register to the given value @@ -28,4 +28,73 @@ namespace BizHawk.Emulation.Common void Step(StepType type); } + + public class Register + { + public ulong Value { get; set; } + public byte BitSize { get; set; } + + public static implicit operator Register(bool val) + { + return new Register + { + Value = (ulong)(val ? 1 : 0), + BitSize = 1 + }; + } + + public static implicit operator Register(byte val) + { + return new Register + { + Value = val, + BitSize = 8 + }; + } + + public static implicit operator Register(ushort val) + { + return new Register + { + Value = val, + BitSize = 16 + }; + } + + public static implicit operator Register(int val) + { + return new Register + { + Value = (ulong)val, + BitSize = 32 + }; + } + + public static implicit operator Register(uint val) + { + return new Register + { + Value = val, + BitSize = 32 + }; + } + + public static implicit operator Register(long val) + { + return new Register + { + Value = (ulong)val, + BitSize = 64 + }; + } + + public static implicit operator Register(ulong val) + { + return new Register + { + Value = val, + BitSize = 64 + }; + } + } } diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs index 0c1036de5e..99d42e9441 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs @@ -8,9 +8,9 @@ namespace BizHawk.Emulation.Cores.Calculators { public partial class TI83 : IDebuggable { - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { - return new Dictionary + return new Dictionary { { "A", cpu.RegisterA }, { "AF", cpu.RegisterAF }, @@ -34,14 +34,14 @@ namespace BizHawk.Emulation.Cores.Calculators { "Shadow DE", cpu.RegisterShadowDE }, { "Shadow HL", cpu.RegisterShadowHL }, { "SP", cpu.RegisterSP }, - { "Flag C", cpu.RegisterF.Bit(0) ? 1 : 0 }, - { "Flag N", cpu.RegisterF.Bit(1) ? 1 : 0 }, - { "Flag P/V", cpu.RegisterF.Bit(2) ? 1 : 0 }, - { "Flag 3rd", cpu.RegisterF.Bit(3) ? 1 : 0 }, - { "Flag H", cpu.RegisterF.Bit(4) ? 1 : 0 }, - { "Flag 5th", cpu.RegisterF.Bit(5) ? 1 : 0 }, - { "Flag Z", cpu.RegisterF.Bit(6) ? 1 : 0 }, - { "Flag S", cpu.RegisterF.Bit(7) ? 1 : 0 } + { "Flag C", cpu.RegisterF.Bit(0) }, + { "Flag N", cpu.RegisterF.Bit(1) }, + { "Flag P/V", cpu.RegisterF.Bit(2) }, + { "Flag 3rd", cpu.RegisterF.Bit(3) }, + { "Flag H", cpu.RegisterF.Bit(4) }, + { "Flag 5th", cpu.RegisterF.Bit(5) }, + { "Flag Z", cpu.RegisterF.Bit(6) }, + { "Flag S", cpu.RegisterF.Bit(7) } }; } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs index 483176ffb0..b070460509 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs @@ -7,23 +7,23 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public partial class C64 : IDebuggable { - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { - return new Dictionary + return new Dictionary { { "A", board.cpu.A }, { "X", board.cpu.X }, { "Y", board.cpu.Y }, { "S", board.cpu.S }, { "PC", board.cpu.PC }, - { "Flag C", board.cpu.FlagC ? 1 : 0 }, - { "Flag Z", board.cpu.FlagZ ? 1 : 0 }, - { "Flag I", board.cpu.FlagI ? 1 : 0 }, - { "Flag D", board.cpu.FlagD ? 1 : 0 }, - { "Flag B", board.cpu.FlagB ? 1 : 0 }, - { "Flag V", board.cpu.FlagV ? 1 : 0 }, - { "Flag N", board.cpu.FlagN ? 1 : 0 }, - { "Flag T", board.cpu.FlagT ? 1 : 0 } + { "Flag C", board.cpu.FlagC }, + { "Flag Z", board.cpu.FlagZ }, + { "Flag I", board.cpu.FlagI }, + { "Flag D", board.cpu.FlagD }, + { "Flag B", board.cpu.FlagB }, + { "Flag V", board.cpu.FlagV }, + { "Flag N", board.cpu.FlagN }, + { "Flag T", board.cpu.FlagT } }; } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IDebuggable.cs index ea20175609..db8751a9a5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IDebuggable.cs @@ -7,9 +7,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { public partial class Atari2600 : IDebuggable { - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { - return new Dictionary + return new Dictionary { { "A", Cpu.A }, { "X", Cpu.X }, @@ -17,15 +17,15 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { "S", Cpu.S }, { "PC", Cpu.PC }, - { "Flag C", Cpu.FlagC ? 1 : 0 }, - { "Flag Z", Cpu.FlagZ ? 1 : 0 }, - { "Flag I", Cpu.FlagI ? 1 : 0 }, - { "Flag D", Cpu.FlagD ? 1 : 0 }, + { "Flag C", Cpu.FlagC }, + { "Flag Z", Cpu.FlagZ }, + { "Flag I", Cpu.FlagI }, + { "Flag D", Cpu.FlagD }, - { "Flag B", Cpu.FlagB ? 1 : 0 }, - { "Flag V", Cpu.FlagV ? 1 : 0 }, - { "Flag N", Cpu.FlagN ? 1 : 0 }, - { "Flag T", Cpu.FlagT ? 1 : 0 } + { "Flag B", Cpu.FlagB }, + { "Flag V", Cpu.FlagV }, + { "Flag N", Cpu.FlagN }, + { "Flag T", Cpu.FlagT } }; } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IDebuggable.cs index f218165864..e6da1f51f5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IDebuggable.cs @@ -7,9 +7,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800 { public partial class Atari7800 : IDebuggable { - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { - return new Dictionary + return new Dictionary { { "A", theMachine.CPU.A }, { "P", theMachine.CPU.P }, @@ -17,13 +17,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800 { "S", theMachine.CPU.S }, { "X", theMachine.CPU.X }, { "Y", theMachine.CPU.Y }, - { "Flag B", theMachine.CPU.fB ? 1 : 0 }, - { "Flag C", theMachine.CPU.fC ? 1 : 0 }, - { "Flag D", theMachine.CPU.fD ? 1 : 0 }, - { "Flag I", theMachine.CPU.fI ? 1 : 0 }, - { "Flag N", theMachine.CPU.fN ? 1 : 0 }, - { "Flag V", theMachine.CPU.fV ? 1 : 0 }, - { "Flag Z", theMachine.CPU.fZ ? 1 : 0 } + { "Flag B", theMachine.CPU.fB }, + { "Flag C", theMachine.CPU.fC }, + { "Flag D", theMachine.CPU.fD }, + { "Flag I", theMachine.CPU.fI }, + { "Flag N", theMachine.CPU.fN }, + { "Flag V", theMachine.CPU.fV }, + { "Flag Z", theMachine.CPU.fZ } }; } diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IDebuggable.cs index 6cc186d8d2..4d1873f356 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IDebuggable.cs @@ -9,9 +9,9 @@ namespace BizHawk.Emulation.Cores.ColecoVision { public partial class ColecoVision : IDebuggable { - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { - return new Dictionary + return new Dictionary { { "A", Cpu.RegisterA }, { "AF", Cpu.RegisterAF }, @@ -35,14 +35,14 @@ namespace BizHawk.Emulation.Cores.ColecoVision { "Shadow DE", Cpu.RegisterShadowDE }, { "Shadow HL", Cpu.RegisterShadowHL }, { "SP", Cpu.RegisterSP }, - { "Flag C", Cpu.RegisterF.Bit(0) ? 1 : 0 }, - { "Flag N", Cpu.RegisterF.Bit(1) ? 1 : 0 }, - { "Flag P/V", Cpu.RegisterF.Bit(2) ? 1 : 0 }, - { "Flag 3rd", Cpu.RegisterF.Bit(3) ? 1 : 0 }, - { "Flag H", Cpu.RegisterF.Bit(4) ? 1 : 0 }, - { "Flag 5th", Cpu.RegisterF.Bit(5) ? 1 : 0 }, - { "Flag Z", Cpu.RegisterF.Bit(6) ? 1 : 0 }, - { "Flag S", Cpu.RegisterF.Bit(7) ? 1 : 0 } + { "Flag C", Cpu.RegisterF.Bit(0) }, + { "Flag N", Cpu.RegisterF.Bit(1) }, + { "Flag P/V", Cpu.RegisterF.Bit(2) }, + { "Flag 3rd", Cpu.RegisterF.Bit(3) }, + { "Flag H", Cpu.RegisterF.Bit(4) }, + { "Flag 5th", Cpu.RegisterF.Bit(5) }, + { "Flag Z", Cpu.RegisterF.Bit(6) }, + { "Flag S", Cpu.RegisterF.Bit(7) } }; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs index f7f23e5d61..d6b620e057 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs @@ -17,9 +17,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA [ServiceNotApplicable(typeof(IDriveLight))] public class GBA : IEmulator, IVideoProvider, ISyncSoundProvider, IGBAGPUViewable, IMemoryDomains, ISaveRam, IDebuggable, IStatable, IInputPollable { - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { - var ret = new Dictionary(); + var ret = new Dictionary(); int[] data = new int[LibMeteor.regnames.Length]; LibMeteor.libmeteor_getregs(data); for (int i = 0; i < data.Length; i++) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs index 3e10c52a15..821d37b241 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs @@ -411,7 +411,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA regs = new VBARegisterHelper(Core); } - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { return regs.GetAllRegisters(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBARegisterHelper.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBARegisterHelper.cs index ab62be17e3..b6667ef068 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBARegisterHelper.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBARegisterHelper.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.GBA { @@ -31,9 +32,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA int* p = (int*)_locs[name]; *p = val; } - public Dictionary GetAllRegisters() + public Dictionary GetAllRegisters() { - Dictionary ret = new Dictionary(); + var ret = new Dictionary(); foreach (var kvp in _locs) { ret[kvp.Key] = GetRegister(kvp.Key); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index ba85e47599..f6e47e0456 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -238,23 +238,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy #region debug - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { int[] data = new int[10]; LibGambatte.gambatte_getregs(GambatteState, data); - return new Dictionary + return new Dictionary { - { "PC", data[(int)LibGambatte.RegIndicies.PC] & 0xffff }, - { "SP", data[(int)LibGambatte.RegIndicies.SP] & 0xffff }, - { "A", data[(int)LibGambatte.RegIndicies.A] & 0xff }, - { "B", data[(int)LibGambatte.RegIndicies.B] & 0xff }, - { "C", data[(int)LibGambatte.RegIndicies.C] & 0xff }, - { "D", data[(int)LibGambatte.RegIndicies.D] & 0xff }, - { "E", data[(int)LibGambatte.RegIndicies.E] & 0xff }, - { "F", data[(int)LibGambatte.RegIndicies.F] & 0xff }, - { "H", data[(int)LibGambatte.RegIndicies.H] & 0xff }, - { "L", data[(int)LibGambatte.RegIndicies.L] & 0xff } + { "PC", (ushort)(data[(int)LibGambatte.RegIndicies.PC] & 0xffff) }, + { "SP", (ushort)(data[(int)LibGambatte.RegIndicies.SP] & 0xffff) }, + { "A", (byte)(data[(int)LibGambatte.RegIndicies.A] & 0xff) }, + { "B", (byte)(data[(int)LibGambatte.RegIndicies.B] & 0xff) }, + { "C", (byte)(data[(int)LibGambatte.RegIndicies.C] & 0xff) }, + { "D", (byte)(data[(int)LibGambatte.RegIndicies.D] & 0xff) }, + { "E", (byte)(data[(int)LibGambatte.RegIndicies.E] & 0xff) }, + { "F", (byte)(data[(int)LibGambatte.RegIndicies.F] & 0xff) }, + { "H", (byte)(data[(int)LibGambatte.RegIndicies.H] & 0xff) }, + { "L", (byte)(data[(int)LibGambatte.RegIndicies.L] & 0xff) } }; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs index 9d8a0916a3..ae575529e0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs @@ -413,13 +413,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy public MemoryDomainList MemoryDomains { get; private set; } - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { var left = L.GetCpuFlagsAndRegisters() - .Select(reg => new KeyValuePair("Left " + reg.Key, reg.Value)); + .Select(reg => new KeyValuePair("Left " + reg.Key, reg.Value)); var right = R.GetCpuFlagsAndRegisters() - .Select(reg => new KeyValuePair("Right " + reg.Key, reg.Value)); + .Select(reg => new KeyValuePair("Right " + reg.Key, reg.Value)); return left.Union(right).ToList().ToDictionary(pair => pair.Key, pair => pair.Value); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs index c1273a239e..198b3d9cd2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs @@ -8,10 +8,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 { public partial class N64 : IDebuggable { - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { // note: the approach this code takes is highly bug-prone - var ret = new Dictionary(); + var ret = new Dictionary(); var data = new byte[32 * 8 + 4 + 4 + 8 + 8 + 4 + 4 + 32 * 4 + 32 * 8]; api.getRegisters(data); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs index 130d71319c..f76afd9d9c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs @@ -899,23 +899,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public bool BinarySaveStatesPreferred { get { return false; } } - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { - return new Dictionary + return new Dictionary { { "A", cpu.A }, { "X", cpu.X }, { "Y", cpu.Y }, { "S", cpu.S }, { "PC", cpu.PC }, - { "Flag C", cpu.FlagC ? 1 : 0 }, - { "Flag Z", cpu.FlagZ ? 1 : 0 }, - { "Flag I", cpu.FlagI ? 1 : 0 }, - { "Flag D", cpu.FlagD ? 1 : 0 }, - { "Flag B", cpu.FlagB ? 1 : 0 }, - { "Flag V", cpu.FlagV ? 1 : 0 }, - { "Flag N", cpu.FlagN ? 1 : 0 }, - { "Flag T", cpu.FlagT ? 1 : 0 } + { "Flag C", cpu.FlagC }, + { "Flag Z", cpu.FlagZ }, + { "Flag I", cpu.FlagI }, + { "Flag D", cpu.FlagD }, + { "Flag B", cpu.FlagB }, + { "Flag V", cpu.FlagV }, + { "Flag N", cpu.FlagN }, + { "Flag T", cpu.FlagT } }; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index a9a8c7f392..82336b085b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs @@ -377,17 +377,17 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES public MemoryDomainList MemoryDomains { get; private set; } - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { int[] regs = new int[6]; - var ret = new Dictionary(); + var ret = new Dictionary(); LibQuickNES.qn_get_cpuregs(Context, regs); - ret["A"] = regs[0]; - ret["X"] = regs[1]; - ret["Y"] = regs[2]; - ret["SP"] = regs[3]; - ret["PC"] = regs[4]; - ret["P"] = regs[5]; + ret["A"] = (byte)regs[0]; + ret["X"] = (byte)regs[1]; + ret["Y"] = (byte)regs[2]; + ret["SP"] = (ushort)regs[3]; + ret["PC"] = (ushort)regs[4]; + ret["P"] = (byte)regs[5]; return ret; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs index 83a643da5a..ea19eaf5c3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -204,7 +204,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES api.Dispose(); } - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { LibsnesApi.CpuRegs regs; api.QUERY_peek_cpu_regs(out regs); @@ -218,31 +218,31 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES bool fz = (regs.p & 0x02)!=0; bool fc = (regs.p & 0x01)!=0; - return new Dictionary + return new Dictionary { - { "PC", (int)regs.pc }, - { "A", (int)regs.a }, - { "X", (int)regs.x }, - { "Y", (int)regs.y }, - { "Z", (int)regs.z }, - { "S", (int)regs.s }, - { "D", (int)regs.d }, - { "Vector", (int)regs.vector }, - { "P", (int)regs.p }, - { "AA", (int)regs.aa }, - { "RD", (int)regs.rd }, - { "SP", (int)regs.sp }, - { "DP", (int)regs.dp }, - { "DB", (int)regs.db }, - { "MDR", (int)regs.mdr }, - { "Flag N", fn?1:0 }, - { "Flag V", fv?1:0 }, - { "Flag M", fm?1:0 }, - { "Flag X", fx?1:0 }, - { "Flag D", fd?1:0 }, - { "Flag I", fi?1:0 }, - { "Flag Z", fz?1:0 }, - { "Flag C", fc?1:0 }, + { "PC", regs.pc }, + { "A", regs.a }, + { "X", regs.x }, + { "Y", regs.y }, + { "Z", regs.z }, + { "S", regs.s }, + { "D", regs.d }, + { "Vector", regs.vector }, + { "P", regs.p }, + { "AA", regs.aa }, + { "RD", regs.rd }, + { "SP", regs.sp }, + { "DP", regs.dp }, + { "DB", regs.db }, + { "MDR", regs.mdr }, + { "Flag N", fn }, + { "Flag V", fv }, + { "Flag M", fm }, + { "Flag X", fx }, + { "Flag D", fd }, + { "Flag I", fi }, + { "Flag Z", fz }, + { "Flag C", fc }, }; } diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs index 18fd7d66c3..ceb86b6204 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs @@ -546,9 +546,9 @@ namespace BizHawk.Emulation.Cores.PCEngine MemoryDomainList memoryDomains; public MemoryDomainList MemoryDomains { get { return memoryDomains; } } - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { - return new Dictionary + return new Dictionary { { "A", Cpu.A }, { "X", Cpu.X }, diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs index ec402053ba..a5aa4165c4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs @@ -260,9 +260,9 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis #endif } - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { - return new Dictionary + return new Dictionary { { "A-0", MainCPU.A[0].s32 }, { "A-1", MainCPU.A[1].s32 }, @@ -284,11 +284,11 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis { "SR", MainCPU.SR }, - { "Flag X", MainCPU.X ? 1 : 0 }, - { "Flag N", MainCPU.N ? 1 : 0 }, - { "Flag Z", MainCPU.Z ? 1 : 0 }, - { "Flag V", MainCPU.V ? 1 : 0 }, - { "Flag C", MainCPU.C ? 1 : 0 } + { "Flag X", MainCPU.X }, + { "Flag N", MainCPU.N }, + { "Flag Z", MainCPU.Z }, + { "Flag V", MainCPU.V }, + { "Flag C", MainCPU.C } }; } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs index 71f6522d97..0839220213 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs @@ -488,9 +488,9 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public MemoryDomainList MemoryDomains { get { return memoryDomains; } } - public IDictionary GetCpuFlagsAndRegisters() + public IDictionary GetCpuFlagsAndRegisters() { - return new Dictionary + return new Dictionary { { "A", Cpu.RegisterA }, { "AF", Cpu.RegisterAF }, @@ -514,14 +514,14 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem { "Shadow DE", Cpu.RegisterShadowDE }, { "Shadow HL", Cpu.RegisterShadowHL }, { "SP", Cpu.RegisterSP }, - { "Flag C", Cpu.RegisterF.Bit(0) ? 1 : 0 }, - { "Flag N", Cpu.RegisterF.Bit(1) ? 1 : 0 }, - { "Flag P/V", Cpu.RegisterF.Bit(2) ? 1 : 0 }, - { "Flag 3rd", Cpu.RegisterF.Bit(3) ? 1 : 0 }, - { "Flag H", Cpu.RegisterF.Bit(4) ? 1 : 0 }, - { "Flag 5th", Cpu.RegisterF.Bit(5) ? 1 : 0 }, - { "Flag Z", Cpu.RegisterF.Bit(6) ? 1 : 0 }, - { "Flag S", Cpu.RegisterF.Bit(7) ? 1 : 0 }, + { "Flag C", Cpu.RegisterF.Bit(0) }, + { "Flag N", Cpu.RegisterF.Bit(1) }, + { "Flag P/V", Cpu.RegisterF.Bit(2) }, + { "Flag 3rd", Cpu.RegisterF.Bit(3) }, + { "Flag H", Cpu.RegisterF.Bit(4) }, + { "Flag 5th", Cpu.RegisterF.Bit(5) }, + { "Flag Z", Cpu.RegisterF.Bit(6) }, + { "Flag S", Cpu.RegisterF.Bit(7) }, }; } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs index 8503b7f399..e15b310254 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs @@ -629,17 +629,17 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx MemoryDomains = new MemoryDomainList(mm, 0); } - - public IDictionary GetCpuFlagsAndRegisters() + // TODO: are any of these registers not 16 bit? + public IDictionary GetCpuFlagsAndRegisters() { LibGPGX.RegisterInfo[] regs = new LibGPGX.RegisterInfo[LibGPGX.gpgx_getmaxnumregs()]; int n = LibGPGX.gpgx_getregs(regs); if (n > regs.Length) throw new InvalidOperationException("A buffer overrun has occured!"); - var ret = new Dictionary(); + var ret = new Dictionary(); for (int i = 0; i < n; i++) - ret[Marshal.PtrToStringAnsi(regs[i].Name)] = regs[i].Value; + ret[Marshal.PtrToStringAnsi(regs[i].Name)] = (ushort)regs[i].Value; return ret; } diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index 37289bee35..25c966cbdd 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -925,9 +925,10 @@ namespace BizHawk.Emulation.Cores.Sony.PSX #region IDebuggable - public IDictionary GetCpuFlagsAndRegisters() + // TODO: don't cast to int, and are any of these not 32 bit? + public IDictionary GetCpuFlagsAndRegisters() { - Dictionary ret = new Dictionary(); + Dictionary ret = new Dictionary(); var regs = new OctoshockDll.ShockRegisters_CPU(); OctoshockDll.shock_GetRegisters_CPU(psx, ref regs); diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs index e0a8be2d56..f9c6c96f4e 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs @@ -330,14 +330,15 @@ namespace BizHawk.Emulation.Cores.WonderSwan public MemoryDomainList MemoryDomains { get; private set; } - public IDictionary GetCpuFlagsAndRegisters() + // TODO: are all of these registers actually the same bit size? + public IDictionary GetCpuFlagsAndRegisters() { - var ret = new Dictionary(); + var ret = new Dictionary(); for (int i = (int)BizSwan.NecRegsMin; i <= (int)BizSwan.NecRegsMax; i++) { BizSwan.NecRegs en = (BizSwan.NecRegs)i; uint val = BizSwan.bizswan_getnecreg(Core, en); - ret[Enum.GetName(typeof(BizSwan.NecRegs), en)] = (int)val; + ret[Enum.GetName(typeof(BizSwan.NecRegs), en)] = (ushort)val; } return ret; }