gpgx - support debug showing cpu flags and registers

This commit is contained in:
goyuken 2014-05-04 17:41:20 +00:00
parent 81a841057c
commit 912387fdef
4 changed files with 116 additions and 1 deletions

View File

@ -574,7 +574,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
public Dictionary<string, int> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
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>();
for (int i = 0; i < n; i++)
ret[Marshal.PtrToStringAnsi(regs[i].Name)] = regs[i].Value;
return ret;
}
public void UpdateVDPViewContext(LibGPGX.VDPView view)
@ -674,6 +682,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
#endregion
#region Settings
GPGXSyncSettings SyncSettings;
public object GetSettings() { return null; }
@ -722,5 +732,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
return x.UseSixButton != y.UseSixButton || x.ControlType != y.ControlType || x.Region != y.Region;
}
}
#endregion
}
}

View File

@ -253,5 +253,18 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void gpgx_get_vdp_view([Out] VDPView view);
[StructLayout(LayoutKind.Sequential)]
public struct RegisterInfo
{
public int Value;
public IntPtr Name;
}
[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int gpgx_getmaxnumregs();
[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int gpgx_getregs([Out] RegisterInfo[] regs);
}
}

View File

@ -518,3 +518,93 @@ GPGX_EX void gpgx_reset(int hard)
else
gen_reset(0);
}
typedef struct
{
unsigned int value;
const char *name;
} register_t;
GPGX_EX int gpgx_getmaxnumregs(void)
{
return 57;
}
GPGX_EX int gpgx_getregs(register_t *regs)
{
int ret = 0;
// 22
#define MAKEREG(x) regs->name = "M68K " #x; regs->value = m68k_get_reg(M68K_REG_##x); regs++; ret++;
MAKEREG(D0);
MAKEREG(D1);
MAKEREG(D2);
MAKEREG(D3);
MAKEREG(D4);
MAKEREG(D5);
MAKEREG(D6);
MAKEREG(D7);
MAKEREG(A0);
MAKEREG(A1);
MAKEREG(A2);
MAKEREG(A3);
MAKEREG(A4);
MAKEREG(A5);
MAKEREG(A6);
MAKEREG(A7);
MAKEREG(PC);
MAKEREG(SR);
MAKEREG(SP);
MAKEREG(USP);
MAKEREG(ISP);
MAKEREG(IR);
#undef MAKEREG
// 13
#define MAKEREG(x) regs->name = "Z80 " #x; regs->value = Z80.x.d; regs++; ret++;
MAKEREG(pc);
MAKEREG(sp);
MAKEREG(af);
MAKEREG(bc);
MAKEREG(de);
MAKEREG(hl);
MAKEREG(ix);
MAKEREG(iy);
MAKEREG(wz);
MAKEREG(af2);
MAKEREG(bc2);
MAKEREG(de2);
MAKEREG(hl2);
#undef MAKEREG
// 22
if (system_hw == SYSTEM_MCD)
{
#define MAKEREG(x) regs->name = "S68K " #x; regs->value = s68k_get_reg(M68K_REG_##x); regs++; ret++;
MAKEREG(D0);
MAKEREG(D1);
MAKEREG(D2);
MAKEREG(D3);
MAKEREG(D4);
MAKEREG(D5);
MAKEREG(D6);
MAKEREG(D7);
MAKEREG(A0);
MAKEREG(A1);
MAKEREG(A2);
MAKEREG(A3);
MAKEREG(A4);
MAKEREG(A5);
MAKEREG(A6);
MAKEREG(A7);
MAKEREG(PC);
MAKEREG(SR);
MAKEREG(SP);
MAKEREG(USP);
MAKEREG(ISP);
MAKEREG(IR);
#undef MAKEREG
}
return ret;
}

Binary file not shown.