Re-adding support for traceback

This commit is contained in:
SergioMartin86 2024-02-26 19:04:05 +00:00
parent 5170f5e983
commit f70db77e69
3 changed files with 26 additions and 1 deletions

View File

@ -262,6 +262,22 @@ loop:
if ( clock_count >= clock_limit ) [[unlikely]] goto stop;
// If traceback support is enabled, trigger it here
#ifdef _QUICKERNES_ENABLE_TRACEBACK_SUPPORT
if (tracecb)
{
unsigned int scratch[7];
scratch[0] = a;
scratch[1] = x;
scratch[2] = y;
scratch[3] = sp;
scratch[4] = pc - 1;
scratch[5] = status;
scratch[6] = opcode;
tracecb(scratch);
}
#endif
clock_count += clock_table [opcode];
switch ( opcode )

View File

@ -14,6 +14,14 @@ typedef unsigned nes_addr_t; // 16-bit address
class Cpu
{
public:
void set_tracecb(void (*cb)(unsigned int *data))
{
tracecb = cb;
}
void (*tracecb)(unsigned int *dest);
// NES 6502 registers. *Not* kept updated during a call to run().
struct registers_t
{

View File

@ -45,7 +45,8 @@ class Emu
const uint8_t *getHostPixels() const { return emu.ppu.host_pixels; }
int get_joypad_read_count() const { return emu.joypad_read_count; }
void set_tracecb(void (*cb)(unsigned int *dest)) { emu.set_tracecb(cb); }
// Save emulator state variants
void serializeState(jaffarCommon::serializer::Base& serializer) const { emu.serializeState(serializer); }
void deserializeState(jaffarCommon::deserializer::Base& deserializer) { emu.deserializeState(deserializer); }