diff --git a/cpu.h b/cpu.h index 2e92061..6fbb034 100644 --- a/cpu.h +++ b/cpu.h @@ -20,10 +20,13 @@ public: virtual void checkpoint(Stream &s) = 0; virtual void restore(Stream &s) = 0; + void debug() { _debug = !_debug; } + protected: CPU (Memory *m, jmp_buf *e, statfn s): _memory(m), _err(e), _status(s){} Memory *_memory; jmp_buf *_err; statfn _status; + bool _debug; }; #endif diff --git a/r6502.cpp b/r6502.cpp index 0bcd739..0f49438 100644 --- a/r6502.cpp +++ b/r6502.cpp @@ -10,7 +10,8 @@ Memory::address r6502::run (unsigned clocks) { { byte op = (*_memory)[PC]; #ifdef CPU_DEBUG - _status ("%04x: %02x [%02x %02x %02x, %02x]\r", PC, op, A, X, Y, flags()); + if (_debug) + _status ("%04x: %02x [%02x %02x %02x, %02x]\r", PC, op, A, X, Y, flags()); #endif PC++; (this->*_ops[op])(); @@ -180,6 +181,7 @@ void r6502::ill () { void r6502::reset () { + _debug = false; P.value = 0; P.bits._ = 1; P.bits.B = 1;