1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-06-15 09:29:33 +00:00

change debug formatting

This commit is contained in:
Stephen Crane 2014-11-20 08:28:01 +00:00
parent 93403d5a8e
commit 10aec57131
3 changed files with 18 additions and 16 deletions

3
cpu.h
View File

@ -7,9 +7,8 @@
class CPU: public Checkpointable { class CPU: public Checkpointable {
public: public:
virtual Memory::address run(unsigned instructions) =0; virtual void run(unsigned instructions) =0;
virtual void reset () =0; virtual void reset () =0;
virtual Memory::address step() =0;
virtual void raise (int level) =0; virtual void raise (int level) =0;
virtual char *status () =0; virtual char *status () =0;

View File

@ -5,25 +5,31 @@
#include "cpu.h" #include "cpu.h"
#include "r6502.h" #include "r6502.h"
Memory::address r6502::step() { #define CPU_STATE_FMT "%02x %02x %02x %02x %d%d%d%d%d%d%d%d %04x\r",\
A,X,Y,S,P.bits.N,P.bits.V,P.bits._,P.bits.B,\
P.bits.D,P.bits.I,P.bits.Z,P.bits.C,PC
inline void r6502::step() {
byte op = (*_memory)[PC]; byte op = (*_memory)[PC];
#ifdef CPU_DEBUG #ifdef CPU_DEBUG
if (_debug) if (_debug) {
_status ("%04x: %02x [%02x %02x %02x, %02x]\r", PC, op, A, X, Y, flags()); flags();
_status(CPU_STATE_FMT);
}
#endif #endif
PC++; PC++;
(this->*_ops[op])(); (this->*_ops[op])();
return PC;
} }
Memory::address r6502::run(unsigned clocks) { void r6502::run(unsigned clocks) {
#ifdef CPU_DEBUG #ifdef CPU_DEBUG
if (_debug) if (_debug) {
return step(); step();
return;
}
#endif #endif
while (clocks--) while (clocks--)
step(); step();
return PC;
} }
byte r6502::flags() { byte r6502::flags() {
@ -38,10 +44,7 @@ byte r6502::flags() {
char *r6502::status () { char *r6502::status () {
static char buf[128]; static char buf[128];
flags(); flags();
sprintf (buf, "aa xx yy sp nv_bdizc _pc_\r\n" sprintf (buf, "aa xx yy sp nv_bdizc _pc_\r" CPU_STATE_FMT);
"%02x %02x %02x %02x %d%d%d%d%d%d%d%d %04x\r\n",
A, X, Y, S, P.bits.N, P.bits.V, P.bits._, P.bits.B,
P.bits.D, P.bits.I, P.bits.Z, P.bits.C, PC);
return buf; return buf;
} }

View File

@ -8,8 +8,7 @@ class r6502: public CPU {
public: public:
void raise(int); void raise(int);
void reset(); void reset();
Memory::address step(); void run(unsigned);
Memory::address run(unsigned);
char *status(); char *status();
void checkpoint(Stream &); void checkpoint(Stream &);
void restore(Stream &); void restore(Stream &);
@ -36,6 +35,7 @@ private:
byte _toBCD[256], _fromBCD[256]; // BCD maps byte _toBCD[256], _fromBCD[256]; // BCD maps
bool _irq; // interrupt pending? bool _irq; // interrupt pending?
void step();
void irq(); void irq();
void nmi(); void nmi();
byte flags(); byte flags();