mGBA trace logging

This commit is contained in:
feos 2020-02-03 12:50:21 +03:00
parent fd06504882
commit 335a55306f
4 changed files with 31 additions and 1 deletions

View File

@ -141,5 +141,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
[DllImport(dll, CallingConvention = cc)]
public static extern byte BizReadBus(IntPtr ctx, uint addr);
[UnmanagedFunctionPointer(cc)]
public delegate void TraceCallback(string msg);
[DllImport(dll, CallingConvention = cc)]
public static extern void BizSetTraceCallback(TraceCallback cb);
}
}

View File

@ -55,6 +55,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
CoreComm.NominalWidth = 240;
CoreComm.NominalHeight = 160;
PutSettings(_settings);
_tracer = new TraceBuffer()
{
Header = "ARM7: PC, mnemonic, operands, registers (r0-r16)"
};
_tracecb = new LibmGBA.TraceCallback((msg) => _tracer.Put(_traceInfo(msg)));
ser.Register(_tracer);
}
catch
{
@ -67,6 +74,21 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public ControllerDefinition ControllerDefinition => GBA.GBAController;
private ITraceable _tracer { get; set; }
private LibmGBA.TraceCallback _tracecb { get; set; }
private TraceInfo _traceInfo(string msg)
{
var split = msg.Split('|');
return new TraceInfo
{
Disassembly = split[1].Trim().PadRight(40),
RegisterInfo = split[0]
};
}
public bool FrameAdvance(IController controller, bool render, bool rendersound = true)
{
Frame++;
@ -78,6 +100,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
WireMemoryDomainPointers();
}
LibmGBA.BizSetTraceCallback(_tracer.Enabled ? _tracecb : null);
IsLagFrame = LibmGBA.BizAdvance(
_core,
VBANext.GetButtons(controller),

2
mgba

@ -1 +1 @@
Subproject commit 454d0e4244580ea27180b2bf6332f335e97b6d51
Subproject commit 87c358a2d474d9fbf5f705b37ab56c1d7fe2059c

Binary file not shown.