gba (vba): some roughing in for the tracelogger

This commit is contained in:
goyuken 2014-11-19 02:24:33 +00:00
parent d1f0bfd89c
commit eaf409d4af
4 changed files with 32 additions and 0 deletions

View File

@ -143,6 +143,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
[UnmanagedFunctionPointer(cc)]
public delegate void AddressCallback(uint addr);
/// <summary>
///
/// </summary>
/// <param name="addr">if bit 0 is set, thumb mode</param>
/// <param name="opcode"></param>
[UnmanagedFunctionPointer(cc)]
public delegate void TraceCallback(uint addr, uint opcode);
[DllImport(dllname, CallingConvention = cc)]
public static extern void SetPadCallback(IntPtr g, StandardCallback cb);
[DllImport(dllname, CallingConvention = cc)]
@ -151,6 +159,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public static extern void SetReadCallback(IntPtr g, AddressCallback cb);
[DllImport(dllname, CallingConvention = cc)]
public static extern void SetWriteCallback(IntPtr g, AddressCallback cb);
[DllImport(dllname, CallingConvention = cc)]
public static extern void SetTraceCallback(IntPtr g, TraceCallback cb);
[StructLayout(LayoutKind.Sequential)]

View File

@ -78,6 +78,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
InitRegisters();
InitCallbacks();
CoreComm.CpuTraceAvailable = true;
CoreComm.TraceHeader = "--ADDR-- ---OP---";
// todo: hook me up as a setting
SetupColors();
}
@ -266,6 +269,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
LibVBANext.AddressCallback fetchcb;
LibVBANext.AddressCallback readcb;
LibVBANext.AddressCallback writecb;
LibVBANext.TraceCallback tracecb;
void InitCallbacks()
{
@ -273,6 +277,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
fetchcb = new LibVBANext.AddressCallback((addr) => CoreComm.MemoryCallbackSystem.CallExecute(addr));
readcb = new LibVBANext.AddressCallback((addr) => CoreComm.MemoryCallbackSystem.CallRead(addr));
writecb = new LibVBANext.AddressCallback((addr) => CoreComm.MemoryCallbackSystem.CallWrite(addr));
tracecb = new LibVBANext.TraceCallback((addr, opcode) => CoreComm.Tracer.Put(string.Format("{0:x8} {1:x8}", addr, opcode)));
}
void SyncCallbacks()
@ -281,6 +286,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
LibVBANext.SetFetchCallback(Core, CoreComm.MemoryCallbackSystem.HasExecutes ? fetchcb : null);
LibVBANext.SetReadCallback(Core, CoreComm.MemoryCallbackSystem.HasReads ? readcb : null);
LibVBANext.SetWriteCallback(Core, CoreComm.MemoryCallbackSystem.HasWrites ? writecb : null);
LibVBANext.SetTraceCallback(Core, CoreComm.Tracer.Enabled ? tracecb : null);
}
LibVBANext.StandardCallback scanlinecb;

Binary file not shown.

View File

@ -5608,6 +5608,8 @@ int armExecute (void)
int oldArmNextPC = bus.armNextPC;
bus.armNextPC = bus.reg[15].I;
if (traceCallback)
traceCallback(bus.armNextPC, opcode);
if (fetchCallback)
fetchCallback(bus.armNextPC);
bus.reg[15].I += 4;
@ -7207,6 +7209,8 @@ int thumbExecute (void)
u32 oldArmNextPC = bus.armNextPC;
bus.armNextPC = bus.reg[15].I;
if (traceCallback) // low bit of addr is set on callback to indicate thumb mode
traceCallback(bus.armNextPC | 1, opcode);
if (fetchCallback)
fetchCallback(bus.armNextPC);
@ -12961,6 +12965,7 @@ int scanlineCallbackLine;
void (*fetchCallback)(u32 addr);
void (*writeCallback)(u32 addr);
void (*readCallback)(u32 addr);
void (*traceCallback)(u32 addr, u32 opcode);
void (*padCallback)();
@ -13443,6 +13448,12 @@ template<bool isReader>bool SyncBatteryRam(NewState *ns)
writeCallback = cb;
}
void SetTraceCallback(void (*cb)(u32 addr, u32 opcode))
{
// before each opcode fetch
traceCallback = cb;
}
}; // class Gigazoid
// zeroing mem operators: these are very important
@ -13589,6 +13600,11 @@ EXPORT void SetScanlineCallback(Gigazoid *g, void (*cb)(), int scanline)
g->SetScanlineCallback(cb, scanline);
}
EXPORT void SetTraceCallback(Gigazoid *g, void (*cb)(u32 addr, u32 opcode))
{
g->SetTraceCallback(cb);
}
EXPORT u32 *GetRegisters(Gigazoid *g)
{
return g->GetRegisters();