mirror of
https://github.com/jscrane/r65emu.git
synced 2024-12-30 09:30:46 +00:00
checkpointing
This commit is contained in:
parent
e695cb91ab
commit
1df2a2d030
30
hardware.cpp
30
hardware.cpp
@ -36,25 +36,27 @@ bool hardware_init(CPU &cpu) {
|
||||
}
|
||||
|
||||
void hardware_checkpoint(Stream &s) {
|
||||
_cpu->checkpoint(s);
|
||||
Memory::Device *d = 0;
|
||||
for (unsigned i = 0; i < 0x10000; i += Memory::page_size) {
|
||||
unsigned ds = 0;
|
||||
for (unsigned i = 0; i < 0x10000; i += ds) {
|
||||
Memory::Device *dev = memory.get(i);
|
||||
if (dev && dev != d) {
|
||||
d = dev;
|
||||
d->checkpoint(s);
|
||||
}
|
||||
if (dev) {
|
||||
dev->checkpoint(s);
|
||||
ds = dev->pages() * Memory::page_size;
|
||||
} else
|
||||
ds = Memory::page_size;
|
||||
}
|
||||
_cpu->checkpoint(s);
|
||||
}
|
||||
|
||||
void hardware_restore(Stream &s) {
|
||||
_cpu->restore(s);
|
||||
Memory::Device *d = 0;
|
||||
for (unsigned i = 0; i < 0x10000; i += Memory::page_size) {
|
||||
unsigned ds = 0;
|
||||
for (unsigned i = 0; i < 0x10000; i += ds) {
|
||||
Memory::Device *dev = memory.get(i);
|
||||
if (dev && dev != d) {
|
||||
d = dev;
|
||||
d->restore(s);
|
||||
}
|
||||
if (dev) {
|
||||
dev->restore(s);
|
||||
ds = dev->pages() * Memory::page_size;
|
||||
} else
|
||||
ds = Memory::page_size;
|
||||
}
|
||||
_cpu->restore(s);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ void spiram::checkpoint(Stream &s)
|
||||
{
|
||||
char buf[Memory::page_size];
|
||||
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));
|
||||
}
|
||||
}
|
||||
@ -41,7 +41,7 @@ void spiram::restore(Stream &s)
|
||||
char buf[Memory::page_size];
|
||||
for (int i = 0; i < pages(); i++) {
|
||||
s.readBytes(buf, sizeof(buf));
|
||||
spiRam.write_stream(i * Memory::page_size, buf, sizeof(buf));
|
||||
spiRam.write_stream(i * 256, buf, sizeof(buf));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user