From 205518ba75506b428310cd70cd50e7e80802b43c Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 25 Apr 2021 16:51:07 -0400 Subject: [PATCH] Switch to more efficient copy. --- Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp b/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp index 7a4bdd9c7..bde983d91 100644 --- a/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp +++ b/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp @@ -132,9 +132,9 @@ template class ConcreteMachine: // 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]; + const size_t num_banks = std::min(size_t(48*1024), state->ram.size()) >> 14; + for(size_t c = 0; c < num_banks; c++) { + memcpy(&write_pointers_[c + 1][(c+1) * 0x4000], &state->ram[c * 0x4000], 0x4000); } } else { memcpy(ram_.data(), state->ram.data(), std::min(ram_.size(), state->ram.size()));