From a26716919c13e54df8399dbc2658ab1f57422b5f Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 22 Mar 2021 15:46:02 -0400 Subject: [PATCH] Switches to an is-in-video test that allows for video memory being paged twice. This is trivially possible even in plain 128kb mode. --- Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp b/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp index a164eb042..769717a62 100644 --- a/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp +++ b/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp @@ -169,7 +169,7 @@ template class ConcreteMachine: case PartialMachineCycle::Write: // Flush video if this access modifies screen contents. - if(address >= video_base_ && address < video_base_ + 6912) { + if(is_video_[address >> 14] && (address & 0x3fff) < 6912) { video_.flush(); } write_pointers_[address >> 14][address] = *cycle.value; @@ -386,7 +386,7 @@ template class ConcreteMachine: uint8_t *write_pointers_[4]; uint8_t pages_[4]; bool is_contended_[4]; - int video_base_ = 0x4000; + bool is_video_[4]; uint8_t port1ffd_ = 0; uint8_t port7ffd_ = 0; @@ -459,12 +459,10 @@ template class ConcreteMachine: void update_video_base() { const uint8_t video_page = (port7ffd_ & 0x08) ? 7 : 5; - video_base_ = 0x1'0000; // i.e. not in memory. - - if(pages_[0] == video_page) video_base_ = 0x0000; - else if(pages_[1] == video_page) video_base_ = 0x4000; - else if(pages_[2] == video_page) video_base_ = 0x8000; - else if(pages_[3] == video_page) video_base_ = 0xc000; + is_video_[0] = pages_[0] == video_page; + is_video_[1] = pages_[1] == video_page; + is_video_[2] = pages_[2] == video_page; + is_video_[3] = pages_[3] == video_page; } // MARK: - Audio.