snes: cpu tracelogging. <1% extra overhead incurred when the tracer is not active.
This commit is contained in:
parent
e61da61d5d
commit
e24d1efbd4
|
@ -79,6 +79,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||||
public delegate void snes_scanlineStart_t(int line);
|
public delegate void snes_scanlineStart_t(int line);
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public delegate string snes_path_request_t(int slot, string hint);
|
public delegate string snes_path_request_t(int slot, string hint);
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public delegate void snes_trace_t(string msg);
|
||||||
|
|
||||||
[DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void snes_set_video_refresh(snes_video_refresh_t video_refresh);
|
public static extern void snes_set_video_refresh(snes_video_refresh_t video_refresh);
|
||||||
|
@ -132,6 +134,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||||
[DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void snes_dequeue_message(IntPtr strBuffer);
|
public static extern void snes_dequeue_message(IntPtr strBuffer);
|
||||||
|
|
||||||
|
[DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void snes_set_trace_callback(snes_trace_t callback);
|
||||||
|
|
||||||
[DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void snes_set_color_lut(IntPtr colors);
|
public static extern void snes_set_color_lut(IntPtr colors);
|
||||||
|
|
||||||
|
@ -394,6 +399,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void snes_trace(string msg)
|
||||||
|
{
|
||||||
|
CoreInputComm.Tracer.Put(msg);
|
||||||
|
}
|
||||||
|
|
||||||
public SnesColors.ColorType CurrPalette { get; private set; }
|
public SnesColors.ColorType CurrPalette { get; private set; }
|
||||||
|
|
||||||
public void SetPalette(SnesColors.ColorType pal)
|
public void SetPalette(SnesColors.ColorType pal)
|
||||||
|
@ -439,9 +449,10 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||||
pathRequest_cb = new LibsnesDll.snes_path_request_t(snes_path_request);
|
pathRequest_cb = new LibsnesDll.snes_path_request_t(snes_path_request);
|
||||||
BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_path_request(pathRequest_cb);
|
BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_path_request(pathRequest_cb);
|
||||||
|
|
||||||
|
|
||||||
scanlineStart_cb = new LibsnesDll.snes_scanlineStart_t(snes_scanlineStart);
|
scanlineStart_cb = new LibsnesDll.snes_scanlineStart_t(snes_scanlineStart);
|
||||||
|
|
||||||
|
tracecb = new LibsnesDll.snes_trace_t(snes_trace);
|
||||||
|
|
||||||
// set default palette. Should be overridden by frontend probably
|
// set default palette. Should be overridden by frontend probably
|
||||||
SetPalette(SnesColors.ColorType.BizHawk);
|
SetPalette(SnesColors.ColorType.BizHawk);
|
||||||
|
|
||||||
|
@ -483,6 +494,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||||
CoreOutputComm.VsyncDen = 1;
|
CoreOutputComm.VsyncDen = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CoreOutputComm.CpuTraceAvailable = true;
|
||||||
|
|
||||||
LibsnesDll.snes_power();
|
LibsnesDll.snes_power();
|
||||||
|
|
||||||
SetupMemoryDomains(romData);
|
SetupMemoryDomains(romData);
|
||||||
|
@ -509,6 +522,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||||
LibsnesDll.snes_audio_sample_t soundcb;
|
LibsnesDll.snes_audio_sample_t soundcb;
|
||||||
LibsnesDll.snes_scanlineStart_t scanlineStart_cb;
|
LibsnesDll.snes_scanlineStart_t scanlineStart_cb;
|
||||||
LibsnesDll.snes_path_request_t pathRequest_cb;
|
LibsnesDll.snes_path_request_t pathRequest_cb;
|
||||||
|
LibsnesDll.snes_trace_t tracecb;
|
||||||
|
|
||||||
ushort snes_input_state(int port, int device, int index, int id)
|
ushort snes_input_state(int port, int device, int index, int id)
|
||||||
{
|
{
|
||||||
|
@ -628,6 +642,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||||
savestatebuff = ms.ToArray();
|
savestatebuff = ms.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!nocallbacks && CoreInputComm.Tracer.Enabled)
|
||||||
|
LibsnesDll.snes_set_trace_callback(tracecb);
|
||||||
|
else
|
||||||
|
LibsnesDll.snes_set_trace_callback(null);
|
||||||
|
|
||||||
// speedup when sound rendering is not needed
|
// speedup when sound rendering is not needed
|
||||||
if (!rendersound)
|
if (!rendersound)
|
||||||
LibsnesDll.snes_set_audio_sample(null);
|
LibsnesDll.snes_set_audio_sample(null);
|
||||||
|
@ -1039,9 +1058,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||||
public IList<MemoryDomain> MemoryDomains { get; private set; }
|
public IList<MemoryDomain> MemoryDomains { get; private set; }
|
||||||
public MemoryDomain MainMemory { get; private set; }
|
public MemoryDomain MainMemory { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region audio stuff
|
#region audio stuff
|
||||||
|
|
||||||
Sound.Utilities.SpeexResampler resampler;
|
Sound.Utilities.SpeexResampler resampler;
|
||||||
|
|
Binary file not shown.
|
@ -86,7 +86,15 @@ void CPU::enter() {
|
||||||
|
|
||||||
void CPU::op_step() {
|
void CPU::op_step() {
|
||||||
debugger.op_exec(regs.pc.d);
|
debugger.op_exec(regs.pc.d);
|
||||||
|
|
||||||
|
if (interface->wanttrace)
|
||||||
|
{
|
||||||
|
char tmp[512];
|
||||||
|
disassemble_opcode(tmp, regs.pc.d);
|
||||||
|
tmp[511] = 0;
|
||||||
|
interface->cpuTrace(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
(this->*opcode_table[op_readpc()])();
|
(this->*opcode_table[op_readpc()])();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,9 @@ time_t Interface::randomSeed()
|
||||||
int Interface::getBackdropColor()
|
int Interface::getBackdropColor()
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Interface::cpuTrace(const char *msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,14 @@ struct Interface {
|
||||||
virtual time_t currentTime();
|
virtual time_t currentTime();
|
||||||
virtual time_t randomSeed();
|
virtual time_t randomSeed();
|
||||||
|
|
||||||
//zero 27-sep-2012
|
//zero 27-sep-2012
|
||||||
virtual void scanlineStart(int line) = 0;
|
virtual void scanlineStart(int line) = 0;
|
||||||
|
|
||||||
//zero 17-oct-2012
|
//zero 17-oct-2012
|
||||||
virtual int getBackdropColor();
|
virtual int getBackdropColor();
|
||||||
|
|
||||||
|
bool wanttrace = false;
|
||||||
|
virtual void cpuTrace(const char *msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Interface *interface;
|
extern Interface *interface;
|
||||||
|
|
|
@ -14,7 +14,8 @@ struct Interface : public SNES::Interface {
|
||||||
snes_input_poll_t pinput_poll;
|
snes_input_poll_t pinput_poll;
|
||||||
snes_input_state_t pinput_state;
|
snes_input_state_t pinput_state;
|
||||||
snes_input_notify_t pinput_notify;
|
snes_input_notify_t pinput_notify;
|
||||||
snes_path_request_t ppath_request;
|
snes_path_request_t ppath_request;
|
||||||
|
snes_trace_t ptrace;
|
||||||
string basename;
|
string basename;
|
||||||
uint32_t *buffer;
|
uint32_t *buffer;
|
||||||
uint32_t *palette;
|
uint32_t *palette;
|
||||||
|
@ -74,6 +75,11 @@ struct Interface : public SNES::Interface {
|
||||||
void message(const string &text) {
|
void message(const string &text) {
|
||||||
messages.push(text);
|
messages.push(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cpuTrace(const char *msg) {
|
||||||
|
if (ptrace)
|
||||||
|
ptrace((const char *)msg);
|
||||||
|
}
|
||||||
|
|
||||||
string path(SNES::Cartridge::Slot slot, const string &hint)
|
string path(SNES::Cartridge::Slot slot, const string &hint)
|
||||||
{
|
{
|
||||||
|
@ -93,7 +99,8 @@ struct Interface : public SNES::Interface {
|
||||||
pinput_state(0),
|
pinput_state(0),
|
||||||
pinput_notify(0),
|
pinput_notify(0),
|
||||||
ppath_request(0),
|
ppath_request(0),
|
||||||
backdropColor(-1)
|
backdropColor(-1),
|
||||||
|
ptrace(0)
|
||||||
{
|
{
|
||||||
buffer = new uint32_t[512 * 480];
|
buffer = new uint32_t[512 * 480];
|
||||||
palette = new uint32_t[16 * 32768];
|
palette = new uint32_t[16 * 32768];
|
||||||
|
@ -582,4 +589,18 @@ void snes_dequeue_message(char* buffer)
|
||||||
void snes_set_backdropColor(int color)
|
void snes_set_backdropColor(int color)
|
||||||
{
|
{
|
||||||
interface.backdropColor = color;
|
interface.backdropColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void snes_set_trace_callback(snes_trace_t callback)
|
||||||
|
{
|
||||||
|
if (callback)
|
||||||
|
{
|
||||||
|
interface.wanttrace = true;
|
||||||
|
interface.ptrace = callback;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
interface.wanttrace = false;
|
||||||
|
interface.ptrace = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ typedef void (*snes_audio_sample_t)(uint16_t left, uint16_t right);
|
||||||
typedef void (*snes_input_poll_t)(void);
|
typedef void (*snes_input_poll_t)(void);
|
||||||
typedef int16_t (*snes_input_state_t)(unsigned port, unsigned device, unsigned index, unsigned id);
|
typedef int16_t (*snes_input_state_t)(unsigned port, unsigned device, unsigned index, unsigned id);
|
||||||
typedef void (*snes_input_notify_t)(int index);
|
typedef void (*snes_input_notify_t)(int index);
|
||||||
|
typedef void (*snes_trace_t)(const char *msg);
|
||||||
|
|
||||||
const char* snes_library_id(void);
|
const char* snes_library_id(void);
|
||||||
unsigned snes_library_revision_major(void);
|
unsigned snes_library_revision_major(void);
|
||||||
|
@ -145,6 +146,8 @@ void snes_set_path_request(snes_path_request_t path_request);
|
||||||
|
|
||||||
void snes_set_color_lut(uint32_t * colors);
|
void snes_set_color_lut(uint32_t * colors);
|
||||||
|
|
||||||
|
void snes_set_trace_callback(void (*callback)(const char *));
|
||||||
|
|
||||||
// system bus implementation
|
// system bus implementation
|
||||||
uint8_t bus_read(unsigned addr);
|
uint8_t bus_read(unsigned addr);
|
||||||
void bus_write(unsigned addr, uint8_t val);
|
void bus_write(unsigned addr, uint8_t val);
|
||||||
|
|
Loading…
Reference in New Issue