IDebuggable - refactor GetCpuFlagsAndRegisters to be IDictionary<string, Register> where Register is a value and a bitsize

This commit is contained in:
adelikat 2014-12-20 03:19:33 +00:00
parent 360ca02b93
commit 7bebb66589
24 changed files with 221 additions and 147 deletions

View File

@ -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)

View File

@ -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

View File

@ -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)
};

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Common
/// Returns a list of Cpu registers and their current state
/// </summary>
/// <returns></returns>
IDictionary<string, int> GetCpuFlagsAndRegisters();
IDictionary<string, Register> GetCpuFlagsAndRegisters();
/// <summary>
/// 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
};
}
}
}

View File

@ -8,9 +8,9 @@ namespace BizHawk.Emulation.Cores.Calculators
{
public partial class TI83 : IDebuggable
{
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
return new Dictionary<string, int>
return new Dictionary<string, Register>
{
{ "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) }
};
}

View File

@ -7,23 +7,23 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
public partial class C64 : IDebuggable
{
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
return new Dictionary<string, int>
return new Dictionary<string, Register>
{
{ "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 }
};
}

View File

@ -7,9 +7,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
public partial class Atari2600 : IDebuggable
{
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
return new Dictionary<string, int>
return new Dictionary<string, Register>
{
{ "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 }
};
}

View File

@ -7,9 +7,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
{
public partial class Atari7800 : IDebuggable
{
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
return new Dictionary<string, int>
return new Dictionary<string, Register>
{
{ "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 }
};
}

View File

@ -9,9 +9,9 @@ namespace BizHawk.Emulation.Cores.ColecoVision
{
public partial class ColecoVision : IDebuggable
{
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
return new Dictionary<string, int>
return new Dictionary<string, Register>
{
{ "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) }
};
}

View File

@ -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<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
var ret = new Dictionary<string, int>();
var ret = new Dictionary<string, Register>();
int[] data = new int[LibMeteor.regnames.Length];
LibMeteor.libmeteor_getregs(data);
for (int i = 0; i < data.Length; i++)

View File

@ -411,7 +411,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
regs = new VBARegisterHelper(Core);
}
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
return regs.GetAllRegisters();
}

View File

@ -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<string, int> GetAllRegisters()
public Dictionary<string, Register> GetAllRegisters()
{
Dictionary<string, int> ret = new Dictionary<string,int>();
var ret = new Dictionary<string, Register>();
foreach (var kvp in _locs)
{
ret[kvp.Key] = GetRegister(kvp.Key);

View File

@ -238,23 +238,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
#region debug
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
int[] data = new int[10];
LibGambatte.gambatte_getregs(GambatteState, data);
return new Dictionary<string, int>
return new Dictionary<string, Register>
{
{ "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) }
};
}

View File

@ -413,13 +413,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
public MemoryDomainList MemoryDomains { get; private set; }
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
var left = L.GetCpuFlagsAndRegisters()
.Select(reg => new KeyValuePair<string, int>("Left " + reg.Key, reg.Value));
.Select(reg => new KeyValuePair<string, Register>("Left " + reg.Key, reg.Value));
var right = R.GetCpuFlagsAndRegisters()
.Select(reg => new KeyValuePair<string, int>("Right " + reg.Key, reg.Value));
.Select(reg => new KeyValuePair<string, Register>("Right " + reg.Key, reg.Value));
return left.Union(right).ToList().ToDictionary(pair => pair.Key, pair => pair.Value);
}

View File

@ -8,10 +8,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
{
public partial class N64 : IDebuggable
{
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
// note: the approach this code takes is highly bug-prone
var ret = new Dictionary<string, int>();
var ret = new Dictionary<string, Register>();
var data = new byte[32 * 8 + 4 + 4 + 8 + 8 + 4 + 4 + 32 * 4 + 32 * 8];
api.getRegisters(data);

View File

@ -899,23 +899,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public bool BinarySaveStatesPreferred { get { return false; } }
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
return new Dictionary<string, int>
return new Dictionary<string, Register>
{
{ "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 }
};
}

View File

@ -377,17 +377,17 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
public MemoryDomainList MemoryDomains { get; private set; }
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
int[] regs = new int[6];
var ret = new Dictionary<string, int>();
var ret = new Dictionary<string, Register>();
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;
}

View File

@ -204,7 +204,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
api.Dispose();
}
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> 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<string, int>
return new Dictionary<string, Register>
{
{ "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 },
};
}

View File

@ -546,9 +546,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
MemoryDomainList memoryDomains;
public MemoryDomainList MemoryDomains { get { return memoryDomains; } }
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
return new Dictionary<string, int>
return new Dictionary<string, Register>
{
{ "A", Cpu.A },
{ "X", Cpu.X },

View File

@ -260,9 +260,9 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis
#endif
}
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, BizHawk.Emulation.Common.Register> GetCpuFlagsAndRegisters()
{
return new Dictionary<string, int>
return new Dictionary<string, BizHawk.Emulation.Common.Register>
{
{ "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 }
};
}

View File

@ -488,9 +488,9 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
public MemoryDomainList MemoryDomains { get { return memoryDomains; } }
public IDictionary<string, int> GetCpuFlagsAndRegisters()
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
return new Dictionary<string, int>
return new Dictionary<string, Register>
{
{ "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) },
};
}

View File

@ -629,17 +629,17 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
MemoryDomains = new MemoryDomainList(mm, 0);
}
public IDictionary<string, int> GetCpuFlagsAndRegisters()
// TODO: are any of these registers not 16 bit?
public IDictionary<string, Register> 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<string, int>();
var ret = new Dictionary<string, Register>();
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;
}

View File

@ -925,9 +925,10 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
#region IDebuggable
public IDictionary<string, int> GetCpuFlagsAndRegisters()
// TODO: don't cast to int, and are any of these not 32 bit?
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
Dictionary<string, int> ret = new Dictionary<string, int>();
Dictionary<string, Register> ret = new Dictionary<string, Register>();
var regs = new OctoshockDll.ShockRegisters_CPU();
OctoshockDll.shock_GetRegisters_CPU(psx, ref regs);

View File

@ -330,14 +330,15 @@ namespace BizHawk.Emulation.Cores.WonderSwan
public MemoryDomainList MemoryDomains { get; private set; }
public IDictionary<string, int> GetCpuFlagsAndRegisters()
// TODO: are all of these registers actually the same bit size?
public IDictionary<string, Register> GetCpuFlagsAndRegisters()
{
var ret = new Dictionary<string, int>();
var ret = new Dictionary<string, Register>();
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;
}