snes: support trace logging GB and SMP cores (C# side and dlls)
This commit is contained in:
parent
4eaf17c6c1
commit
5b44f0960f
|
@ -108,6 +108,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
||||||
NUM
|
NUM
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public enum eTRACE : uint
|
||||||
|
{
|
||||||
|
CPU = 0,
|
||||||
|
SMP = 1,
|
||||||
|
GB = 2
|
||||||
|
}
|
||||||
|
|
||||||
public enum eCDLog_Flags
|
public enum eCDLog_Flags
|
||||||
{
|
{
|
||||||
ExecFirst = 0x01,
|
ExecFirst = 0x01,
|
||||||
|
@ -142,7 +149,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
||||||
public delegate void snes_audio_sample_t(ushort left, ushort right);
|
public delegate void snes_audio_sample_t(ushort left, ushort right);
|
||||||
public delegate void snes_scanlineStart_t(int line);
|
public delegate void snes_scanlineStart_t(int line);
|
||||||
public delegate string snes_path_request_t(int slot, string hint);
|
public delegate string snes_path_request_t(int slot, string hint);
|
||||||
public delegate void snes_trace_t(string msg);
|
public delegate void snes_trace_t(uint which, string msg);
|
||||||
|
|
||||||
|
|
||||||
public struct CPURegs
|
public struct CPURegs
|
||||||
|
|
|
@ -85,10 +85,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
||||||
Message(eMessage.eMessage_QUERY_state_hook_write);
|
Message(eMessage.eMessage_QUERY_state_hook_write);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void QUERY_set_trace_callback(snes_trace_t callback)
|
public void QUERY_set_trace_callback(int mask, snes_trace_t callback)
|
||||||
{
|
{
|
||||||
this.traceCallback = callback;
|
this.traceCallback = callback;
|
||||||
comm->value = (callback != null) ? 1u : 0u;
|
comm->value = (uint)mask;
|
||||||
Message(eMessage.eMessage_QUERY_enable_trace);
|
Message(eMessage.eMessage_QUERY_enable_trace);
|
||||||
}
|
}
|
||||||
public void QUERY_set_scanlineStart(snes_scanlineStart_t scanlineStart)
|
public void QUERY_set_scanlineStart(snes_scanlineStart_t scanlineStart)
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
||||||
case eMessage.eMessage_SIG_trace_callback:
|
case eMessage.eMessage_SIG_trace_callback:
|
||||||
{
|
{
|
||||||
if (traceCallback != null)
|
if (traceCallback != null)
|
||||||
traceCallback(comm->GetAscii());
|
traceCallback(comm->value, comm->GetAscii());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eMessage.eMessage_SIG_allocSharedMemory:
|
case eMessage.eMessage_SIG_allocSharedMemory:
|
||||||
|
|
|
@ -24,11 +24,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
||||||
|
|
||||||
if (!_nocallbacks && _tracer.Enabled)
|
if (!_nocallbacks && _tracer.Enabled)
|
||||||
{
|
{
|
||||||
Api.QUERY_set_trace_callback(_tracecb);
|
//Api.QUERY_set_trace_callback(1<<(int)LibsnesApi.eTRACE.SMP, _tracecb); //TEST -- it works but theres no way to control it from the frontend now
|
||||||
|
|
||||||
|
if(IsSGB)
|
||||||
|
Api.QUERY_set_trace_callback(1<<(int)LibsnesApi.eTRACE.GB, _tracecb);
|
||||||
|
else
|
||||||
|
Api.QUERY_set_trace_callback(1<<(int)LibsnesApi.eTRACE.CPU, _tracecb);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Api.QUERY_set_trace_callback(null);
|
Api.QUERY_set_trace_callback(0,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for deterministic emulation, save the state we're going to use before frame advance
|
// for deterministic emulation, save the state we're going to use before frame advance
|
||||||
|
|
|
@ -323,18 +323,43 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void snes_trace(string msg)
|
private void snes_trace(uint which, string msg)
|
||||||
{
|
{
|
||||||
// TODO: get them out of the core split up and remove this hackery
|
// TODO: get them out of the core split up and remove this hackery
|
||||||
string splitStr = "A:";
|
const string splitStr = "A:";
|
||||||
|
|
||||||
var split = msg.Split(new[] {splitStr }, 2, StringSplitOptions.None);
|
if (which == (uint)LibsnesApi.eTRACE.CPU)
|
||||||
|
|
||||||
_tracer.Put(new TraceInfo
|
|
||||||
{
|
{
|
||||||
Disassembly = split[0].PadRight(34),
|
var split = msg.Split(new[] { splitStr }, 2, StringSplitOptions.None);
|
||||||
RegisterInfo = splitStr + split[1]
|
|
||||||
});
|
_tracer.Put(new TraceInfo
|
||||||
|
{
|
||||||
|
Disassembly = split[0].PadRight(34),
|
||||||
|
RegisterInfo = splitStr + split[1]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (which == (uint)LibsnesApi.eTRACE.SMP)
|
||||||
|
{
|
||||||
|
int idx = msg.IndexOf("YA:");
|
||||||
|
string dis = msg.Substring(0,idx).TrimEnd();
|
||||||
|
string regs = msg.Substring(idx);
|
||||||
|
_tracer.Put(new TraceInfo
|
||||||
|
{
|
||||||
|
Disassembly = dis,
|
||||||
|
RegisterInfo = regs
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (which == (uint)LibsnesApi.eTRACE.GB)
|
||||||
|
{
|
||||||
|
int idx = msg.IndexOf("AF:");
|
||||||
|
string dis = msg.Substring(0,idx).TrimEnd();
|
||||||
|
string regs = msg.Substring(idx);
|
||||||
|
_tracer.Put(new TraceInfo
|
||||||
|
{
|
||||||
|
Disassembly = dis,
|
||||||
|
RegisterInfo = regs
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetPalette(SnesColors.ColorType pal)
|
private void SetPalette(SnesColors.ColorType pal)
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue