From 2bbf8bc9faea5b121f6936e2b731890fa9f7386c Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 25 Apr 2021 13:27:11 -0400 Subject: [PATCH] Ensures 16/48kb snapshots are properly copied into place. --- Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp b/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp index 469e74fd8..7e026dfdb 100644 --- a/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp +++ b/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp @@ -127,7 +127,17 @@ template class ConcreteMachine: if(target.state) { const auto state = static_cast(target.state.get()); state->z80.apply(z80_); - memcpy(ram_.data(), state->ram.data(), std::min(ram_.size(), state->ram.size())); + + // If this is a 48k or 16k machine, remap source data from its original + // linear form to whatever the banks end up being; otherwise copy as is. + if(model <= Model::FortyEightK) { + for(size_t c = 0; c < 48*1024 && c < state->ram.size(); c++) { + const auto address = c + 0x4000; + write_pointers_[address >> 14][address] = state->ram[c]; + } + } else { + memcpy(ram_.data(), state->ram.data(), std::min(ram_.size(), state->ram.size())); + } LOG("TODO: apply rest of state"); }