1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-06-10 21:29:39 +00:00

remove _debug

make status header optional
This commit is contained in:
Stephen Crane 2016-01-24 11:55:50 +00:00
parent 8dbba19309
commit 01def1ba15
7 changed files with 22 additions and 23 deletions

7
CPU.h
View File

@ -8,18 +8,17 @@ public:
virtual void run(unsigned instructions) =0; virtual void run(unsigned instructions) =0;
virtual void reset() =0; virtual void reset() =0;
virtual void raise(int level) =0; virtual void raise(int level) =0;
virtual char *status(char *buf, size_t n) =0; virtual char *status(char *buf, size_t n, bool hdr) =0;
virtual void checkpoint(Stream &s) = 0; virtual void checkpoint(Stream &s) = 0;
virtual void restore(Stream &s) = 0; virtual void restore(Stream &s) = 0;
inline void debug() { _debug = !_debug; }
inline bool halted() { return _halted; } inline bool halted() { return _halted; }
protected: protected:
CPU(Memory &mem): _mem(mem), _debug(false), _halted(false) {} CPU(Memory &mem): _mem(mem), _halted(false) {}
Memory &_mem; Memory &_mem;
Memory::address PC; Memory::address PC;
bool _debug, _halted; bool _halted;
}; };
#endif #endif

View File

@ -39,10 +39,11 @@ void i8080::ei() {
raise(_irq_pending); raise(_irq_pending);
} }
char *i8080::status(char *buf, size_t n) { char *i8080::status(char *buf, size_t n, bool hdr) {
byte op = _mem[PC]; byte op = _mem[PC];
snprintf(buf, n, "_pc_ op aa _bc_ _de_ _hl_ _sp_ szih_p_c\r" snprintf(buf, n,
"%04x %02x %02x %04x %04x %04x %04x %d%d%d%d%d%d%d%d\r", "%s%04x %02x %02x %04x %04x %04x %04x %d%d%d%d%d%d%d%d",
hdr? "_pc_ op aa _bc_ _de_ _hl_ _sp_ szih_p_c\r": "",
PC, op, A, BC, DE, HL, SP, flags.S, flags.Z, flags.I, flags.H, PC, op, A, BC, DE, HL, SP, flags.S, flags.Z, flags.I, flags.H,
flags._, flags.P, flags.__, flags.C); flags._, flags.P, flags.__, flags.C);
return buf; return buf;

View File

@ -11,7 +11,7 @@ public:
void run(unsigned); void run(unsigned);
void reset(); void reset();
void raise(int); void raise(int);
char *status(char *buf, size_t n); char *status(char *buf, size_t n, bool hdr);
void checkpoint(Stream &); void checkpoint(Stream &);
void restore(Stream &); void restore(Stream &);

View File

@ -24,13 +24,13 @@ byte r6502::flags() {
return P.flags; return P.flags;
} }
char *r6502::status(char *buf, size_t n) { char *r6502::status(char *buf, size_t n, bool hdr) {
flags(); flags();
snprintf(buf, n, "aa xx yy sp nv_bdizc _pc_\r" snprintf(buf, n,
"%02x %02x %02x %02x %d%d%d%d%d%d%d%d %04x\r", "%s%02x %02x %02x %02x %d%d%d%d%d%d%d%d %04x",
A, X, Y, S, P.bits.N, P.bits.V, P.bits._, P.bits.B, hdr? "aa xx yy sp nv_bdizc _pc_\r\n": "",
P.bits.D, P.bits.I, P.bits.Z, P.bits.C, PC); 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;
} }
@ -177,7 +177,7 @@ void r6502::ill() {
void r6502::reset() void r6502::reset()
{ {
_debug = _halted = false; _halted = false;
P.flags = 0; P.flags = 0;
P.bits._ = 1; P.bits._ = 1;
P.bits.B = 1; P.bits.B = 1;

View File

@ -9,7 +9,7 @@ public:
void raise(int); void raise(int);
void reset(); void reset();
void run(unsigned); void run(unsigned);
char *status(char *buf, size_t n); char *status(char *buf, size_t n, bool hdr);
void checkpoint(Stream &); void checkpoint(Stream &);
void restore(Stream &); void restore(Stream &);

11
z80.cpp
View File

@ -5,12 +5,12 @@
#include "CPU.h" #include "CPU.h"
#include "z80.h" #include "z80.h"
char *z80::status(char *buf, size_t n) { char *z80::status(char *buf, size_t n, bool hdr) {
byte op = _mem[PC]; byte op = _mem[PC];
snprintf(buf, n, "_pc_ op _af_ _bc_ _de_ _hl_ _af' _bc' _de' _hl' _ir_ imff " snprintf(buf, n,
"_sp_ sz5h3pnc\r\n" "%s%04x %02x %04x %04x %04x %04x %04x %04x %04x %04x %04x %d%d%d "
"%04x %02x %04x %04x %04x %04x %04x %04x %04x %04x %04x %d%d%d " "%04x %d%d%d%d%d%d%d%d",
"%04x %d%d%d%d%d%d%d%d\r\n", hdr? "_pc_ op _af_ _bc_ _de_ _hl_ _af' _bc' _de' _hl' _ir_ imff _sp_ sz5h3pnc\r\n": "",
PC, op, AF, BC, DE, HL, AF_, BC_, DE_, HL_, IR, _im, _iff1, _iff2, PC, op, AF, BC, DE, HL, AF_, BC_, DE_, HL_, IR, _im, _iff1, _iff2,
SP, flags.S, flags.Z, flags._5, flags.H, flags._3, flags.P, flags.N, flags.C); SP, flags.S, flags.Z, flags._5, flags.H, flags._3, flags.P, flags.N, flags.C);
return buf; return buf;
@ -873,7 +873,6 @@ int z80::parity_table[] = {
z80::z80(Memory &m, PortDevice<z80> &ports): CPU(m) z80::z80(Memory &m, PortDevice<z80> &ports): CPU(m)
{ {
_ports = &ports; _ports = &ports;
_debug = false;
OP *p = _ops; OP *p = _ops;

2
z80.h
View File

@ -11,7 +11,7 @@ public:
void run(unsigned); void run(unsigned);
void reset(); void reset();
void raise(int level) { _irq_pending = level; } void raise(int level) { _irq_pending = level; }
char *status(char *buf, size_t n); char *status(char *buf, size_t n, bool hdr);
void checkpoint(Stream &); void checkpoint(Stream &);
void restore(Stream &); void restore(Stream &);