mirror of
https://github.com/jscrane/r65emu.git
synced 2025-02-12 17:32:08 +00:00
change debug formatting
This commit is contained in:
parent
93403d5a8e
commit
10aec57131
3
cpu.h
3
cpu.h
@ -7,9 +7,8 @@
|
||||
|
||||
class CPU: public Checkpointable {
|
||||
public:
|
||||
virtual Memory::address run(unsigned instructions) =0;
|
||||
virtual void run(unsigned instructions) =0;
|
||||
virtual void reset () =0;
|
||||
virtual Memory::address step() =0;
|
||||
virtual void raise (int level) =0;
|
||||
virtual char *status () =0;
|
||||
|
||||
|
27
r6502.cpp
27
r6502.cpp
@ -5,25 +5,31 @@
|
||||
#include "cpu.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];
|
||||
#ifdef CPU_DEBUG
|
||||
if (_debug)
|
||||
_status ("%04x: %02x [%02x %02x %02x, %02x]\r", PC, op, A, X, Y, flags());
|
||||
if (_debug) {
|
||||
flags();
|
||||
_status(CPU_STATE_FMT);
|
||||
}
|
||||
#endif
|
||||
PC++;
|
||||
(this->*_ops[op])();
|
||||
return PC;
|
||||
}
|
||||
|
||||
Memory::address r6502::run(unsigned clocks) {
|
||||
void r6502::run(unsigned clocks) {
|
||||
#ifdef CPU_DEBUG
|
||||
if (_debug)
|
||||
return step();
|
||||
if (_debug) {
|
||||
step();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
while (clocks--)
|
||||
step();
|
||||
return PC;
|
||||
}
|
||||
|
||||
byte r6502::flags() {
|
||||
@ -38,10 +44,7 @@ byte r6502::flags() {
|
||||
char *r6502::status () {
|
||||
static char buf[128];
|
||||
flags();
|
||||
sprintf (buf, "aa xx yy sp nv_bdizc _pc_\r\n"
|
||||
"%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);
|
||||
sprintf (buf, "aa xx yy sp nv_bdizc _pc_\r" CPU_STATE_FMT);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
4
r6502.h
4
r6502.h
@ -8,8 +8,7 @@ class r6502: public CPU {
|
||||
public:
|
||||
void raise(int);
|
||||
void reset();
|
||||
Memory::address step();
|
||||
Memory::address run(unsigned);
|
||||
void run(unsigned);
|
||||
char *status();
|
||||
void checkpoint(Stream &);
|
||||
void restore(Stream &);
|
||||
@ -36,6 +35,7 @@ private:
|
||||
byte _toBCD[256], _fromBCD[256]; // BCD maps
|
||||
bool _irq; // interrupt pending?
|
||||
|
||||
void step();
|
||||
void irq();
|
||||
void nmi();
|
||||
byte flags();
|
||||
|
Loading…
x
Reference in New Issue
Block a user