1
0
mirror of https://github.com/jscrane/r65emu.git synced 2025-01-02 13:30:53 +00:00

checkpointing

This commit is contained in:
Stephen Crane 2014-10-22 19:47:06 +01:00
parent e695cb91ab
commit 1df2a2d030
2 changed files with 33 additions and 31 deletions

View File

@ -36,25 +36,27 @@ bool hardware_init(CPU &cpu) {
} }
void hardware_checkpoint(Stream &s) { void hardware_checkpoint(Stream &s) {
_cpu->checkpoint(s); unsigned ds = 0;
Memory::Device *d = 0; for (unsigned i = 0; i < 0x10000; i += ds) {
for (unsigned i = 0; i < 0x10000; i += Memory::page_size) {
Memory::Device *dev = memory.get(i); Memory::Device *dev = memory.get(i);
if (dev && dev != d) { if (dev) {
d = dev; dev->checkpoint(s);
d->checkpoint(s); ds = dev->pages() * Memory::page_size;
} } else
ds = Memory::page_size;
} }
_cpu->checkpoint(s);
} }
void hardware_restore(Stream &s) { void hardware_restore(Stream &s) {
_cpu->restore(s); unsigned ds = 0;
Memory::Device *d = 0; for (unsigned i = 0; i < 0x10000; i += ds) {
for (unsigned i = 0; i < 0x10000; i += Memory::page_size) {
Memory::Device *dev = memory.get(i); Memory::Device *dev = memory.get(i);
if (dev && dev != d) { if (dev) {
d = dev; dev->restore(s);
d->restore(s); ds = dev->pages() * Memory::page_size;
} } else
ds = Memory::page_size;
} }
_cpu->restore(s);
} }

View File

@ -31,7 +31,7 @@ void spiram::checkpoint(Stream &s)
{ {
char buf[Memory::page_size]; char buf[Memory::page_size];
for (int i = 0; i < pages(); i++) { for (int i = 0; i < pages(); i++) {
spiRam.read_stream(i * Memory::page_size, buf, sizeof(buf)); spiRam.read_stream(i * 256, buf, sizeof(buf));
s.write((byte *)buf, sizeof(buf)); s.write((byte *)buf, sizeof(buf));
} }
} }
@ -41,7 +41,7 @@ void spiram::restore(Stream &s)
char buf[Memory::page_size]; char buf[Memory::page_size];
for (int i = 0; i < pages(); i++) { for (int i = 0; i < pages(); i++) {
s.readBytes(buf, sizeof(buf)); s.readBytes(buf, sizeof(buf));
spiRam.write_stream(i * Memory::page_size, buf, sizeof(buf)); spiRam.write_stream(i * 256, buf, sizeof(buf));
} }
} }