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 reset() =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 restore(Stream &s) = 0;
inline void debug() { _debug = !_debug; }
inline bool halted() { return _halted; }
protected:
CPU(Memory &mem): _mem(mem), _debug(false), _halted(false) {}
CPU(Memory &mem): _mem(mem), _halted(false) {}
Memory &_mem;
Memory::address PC;
bool _debug, _halted;
bool _halted;
};
#endif

View File

@ -39,10 +39,11 @@ void i8080::ei() {
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];
snprintf(buf, n, "_pc_ op aa _bc_ _de_ _hl_ _sp_ szih_p_c\r"
"%04x %02x %02x %04x %04x %04x %04x %d%d%d%d%d%d%d%d\r",
snprintf(buf, n,
"%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,
flags._, flags.P, flags.__, flags.C);
return buf;

View File

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

View File

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

View File

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

11
z80.cpp
View File

@ -5,12 +5,12 @@
#include "CPU.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];
snprintf(buf, n, "_pc_ op _af_ _bc_ _de_ _hl_ _af' _bc' _de' _hl' _ir_ imff "
"_sp_ sz5h3pnc\r\n"
"%04x %02x %04x %04x %04x %04x %04x %04x %04x %04x %04x %d%d%d "
"%04x %d%d%d%d%d%d%d%d\r\n",
snprintf(buf, n,
"%s%04x %02x %04x %04x %04x %04x %04x %04x %04x %04x %04x %d%d%d "
"%04x %d%d%d%d%d%d%d%d",
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,
SP, flags.S, flags.Z, flags._5, flags.H, flags._3, flags.P, flags.N, flags.C);
return buf;
@ -873,7 +873,6 @@ int z80::parity_table[] = {
z80::z80(Memory &m, PortDevice<z80> &ports): CPU(m)
{
_ports = &ports;
_debug = false;
OP *p = _ops;

2
z80.h
View File

@ -11,7 +11,7 @@ public:
void run(unsigned);
void reset();
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 restore(Stream &);