NO_CHECKPOINT flag

This commit is contained in:
Stephen Crane 2019-02-24 11:50:10 +00:00
parent 76eb94202c
commit a275deb6ab
8 changed files with 24 additions and 0 deletions

View File

@ -104,6 +104,7 @@ const char *flash_filer::rewind() {
return advance(); return advance();
} }
#if !defined(NO_CHECKPOINT)
static char buf[32]; static char buf[32];
static char chkpt[] = { "CHKPOINT" }; static char chkpt[] = { "CHKPOINT" };
static int cpid = 0; static int cpid = 0;
@ -146,3 +147,4 @@ void flash_filer::restore(const char *filename) {
#endif #endif
start(::programs); start(::programs);
} }
#endif

View File

@ -79,6 +79,7 @@ void hardware_init(CPU &cpu) {
#endif #endif
} }
#if !defined(NO_CHECKPOINT)
void hardware_checkpoint(Stream &s) { void hardware_checkpoint(Stream &s) {
unsigned ds = 0; unsigned ds = 0;
for (unsigned i = 0; i < 0x10000; i += ds) { for (unsigned i = 0; i < 0x10000; i += ds) {
@ -98,3 +99,4 @@ void hardware_restore(Stream &s) {
} }
_cpu->restore(s); _cpu->restore(s);
} }
#endif

View File

@ -47,6 +47,7 @@ char *i8080::status(char *buf, size_t n, bool hdr) {
} }
void i8080::checkpoint(Stream &s) { void i8080::checkpoint(Stream &s) {
#if !defined(NO_CHECKPOINT)
s.write(A); s.write(A);
s.write(SR); s.write(SR);
s.write(BC); s.write(BC);
@ -55,9 +56,11 @@ void i8080::checkpoint(Stream &s) {
s.write(PC); s.write(PC);
s.write(SP); s.write(SP);
s.write(_irq_pending); s.write(_irq_pending);
#endif
} }
void i8080::restore(Stream &s) { void i8080::restore(Stream &s) {
#if !defined(NO_CHECKPOINT)
A = s.read(); A = s.read();
SR = s.read(); SR = s.read();
BC = s.read(); BC = s.read();
@ -66,6 +69,7 @@ void i8080::restore(Stream &s) {
PC = s.read(); PC = s.read();
SP = s.read(); SP = s.read();
_irq_pending = s.read(); _irq_pending = s.read();
#endif
} }
void i8080::daa() { void i8080::daa() {

View File

@ -38,6 +38,7 @@ char *r6502::status(char *buf, size_t n, bool hdr) {
void r6502::checkpoint(Stream &s) void r6502::checkpoint(Stream &s)
{ {
#if !defined(NO_CHECKPOINT)
s.write(PC / 0xff); s.write(PC / 0xff);
s.write(PC % 0xff); s.write(PC % 0xff);
s.write(S); s.write(S);
@ -52,10 +53,12 @@ void r6502::checkpoint(Stream &s)
s.write(Z); s.write(Z);
s.write(C); s.write(C);
s.write(P.flags); s.write(P.flags);
#endif
} }
void r6502::restore(Stream &s) void r6502::restore(Stream &s)
{ {
#if !defined(NO_CHECKPOINT)
uint8_t hi = s.read(), lo = s.read(); uint8_t hi = s.read(), lo = s.read();
PC = hi * 0xff + lo; PC = hi * 0xff + lo;
S = s.read(); S = s.read();
@ -70,6 +73,7 @@ void r6502::restore(Stream &s)
Z = s.read(); Z = s.read();
C = s.read(); C = s.read();
P.flags = s.read(); P.flags = s.read();
#endif
} }
void r6502::raise(int level) { void r6502::raise(int level) {

2
ram.h
View File

@ -6,8 +6,10 @@ public:
virtual void operator= (uint8_t c) { _mem[_acc] = c; } virtual void operator= (uint8_t c) { _mem[_acc] = c; }
virtual operator uint8_t () { return _mem[_acc]; } virtual operator uint8_t () { return _mem[_acc]; }
#if !defined NO_CHECKPOINT
virtual void checkpoint(Stream &s) { s.write(_mem, sizeof(_mem)); } virtual void checkpoint(Stream &s) { s.write(_mem, sizeof(_mem)); }
virtual void restore(Stream &s) { s.readBytes((char *)_mem, sizeof(_mem)); } virtual void restore(Stream &s) { s.readBytes((char *)_mem, sizeof(_mem)); }
#endif
ram (): Memory::Device(sizeof(_mem)) {} ram (): Memory::Device(sizeof(_mem)) {}

View File

@ -35,6 +35,7 @@ bool serial_filer::more() {
return Serial.available() > 0; return Serial.available() > 0;
} }
#if !defined(NO_CHECKPOINT)
const char *serial_filer::checkpoint() { const char *serial_filer::checkpoint() {
// FIXME // FIXME
return 0; return 0;
@ -43,3 +44,4 @@ const char *serial_filer::checkpoint() {
void serial_filer::restore(const char *) { void serial_filer::restore(const char *) {
// FIXME // FIXME
} }
#endif

View File

@ -22,20 +22,24 @@ spiram::operator uint8_t()
void spiram::checkpoint(Stream &s) void spiram::checkpoint(Stream &s)
{ {
#if !defined(NO_CHECKPOINT)
uint8_t buf[Memory::page_size]; uint8_t buf[Memory::page_size];
for (unsigned i = 0; i < pages(); i++) { for (unsigned i = 0; i < pages(); i++) {
spiRam.read_stream(i * 256, buf, sizeof(buf)); spiRam.read_stream(i * 256, buf, sizeof(buf));
s.write(buf, sizeof(buf)); s.write(buf, sizeof(buf));
} }
#endif
} }
void spiram::restore(Stream &s) void spiram::restore(Stream &s)
{ {
#if !defined(NO_CHECKPOINT)
uint8_t buf[Memory::page_size]; uint8_t buf[Memory::page_size];
for (unsigned i = 0; i < pages(); i++) { for (unsigned i = 0; i < pages(); i++) {
s.readBytes((char *)buf, sizeof(buf)); s.readBytes((char *)buf, sizeof(buf));
spiRam.write_stream(i * 256, buf, sizeof(buf)); spiRam.write_stream(i * 256, buf, sizeof(buf));
} }
#endif
} }
#endif #endif

View File

@ -20,6 +20,7 @@ char *z80::status(char *buf, size_t n, bool hdr) {
} }
void z80::checkpoint(Stream &s) { void z80::checkpoint(Stream &s) {
#if !defined(NO_CHECKPOINT)
s.write(AF); s.write(AF);
s.write(BC); s.write(BC);
s.write(DE); s.write(DE);
@ -39,9 +40,11 @@ void z80::checkpoint(Stream &s) {
s.write(_ts); s.write(_ts);
s.write(_halted); s.write(_halted);
s.write(_irq_pending); s.write(_irq_pending);
#endif
} }
void z80::restore(Stream &s) { void z80::restore(Stream &s) {
#if !defined(NO_CHECKPOINT)
AF = s.read(); AF = s.read();
BC = s.read(); BC = s.read();
DE = s.read(); DE = s.read();
@ -61,6 +64,7 @@ void z80::restore(Stream &s) {
_ts = s.read(); _ts = s.read();
_halted = s.read(); _halted = s.read();
_irq_pending = s.read(); _irq_pending = s.read();
#endif
} }
uint8_t z80::_fetch_op() { uint8_t z80::_fetch_op() {