diff --git a/Machines/MSX/Cartridges/KonamiWithSCC.hpp b/Machines/MSX/Cartridges/KonamiWithSCC.hpp index 00bb7141e..7f1e8dc16 100644 --- a/Machines/MSX/Cartridges/KonamiWithSCC.hpp +++ b/Machines/MSX/Cartridges/KonamiWithSCC.hpp @@ -43,7 +43,7 @@ class KonamiWithSCCROMSlotHandler: public MemorySlotHandler { } if((value&0x3f) == 0x3f) { scc_is_visible_ = true; - slot_.unmap(0x8000, 0x2000); + slot_.map_handler(0x8000, 0x2000); } else { scc_is_visible_ = false; slot_.map(value * 0x2000, 0x8000, 0x2000); diff --git a/Machines/MSX/MSX.cpp b/Machines/MSX/MSX.cpp index fd5b9e972..52af973ef 100644 --- a/Machines/MSX/MSX.cpp +++ b/Machines/MSX/MSX.cpp @@ -291,7 +291,7 @@ class ConcreteMachine: disk_slot().set_source(dos); disk_slot().map(0, 0x4000, 0x2000); - disk_slot().unmap(0x6000, 0x2000); + disk_slot().map_handler(0x6000, 0x2000); } // Insert the media. diff --git a/Machines/MSX/MemorySlotHandler.cpp b/Machines/MSX/MemorySlotHandler.cpp index 7fb280603..79d4c69e3 100644 --- a/Machines/MSX/MemorySlotHandler.cpp +++ b/Machines/MSX/MemorySlotHandler.cpp @@ -16,10 +16,7 @@ PrimarySlot::PrimarySlot(MemorySlotChangeHandler &handler) : subslots_{handler, handler, handler, handler} {} MemorySlot::MemorySlot(MemorySlotChangeHandler &handler) : handler_(handler) { - for(int region = 0; region < 8; region++) { - read_pointers_[region] = unmapped.data(); - write_pointers_[region] = scratch.data(); - } + unmap(0x0000, 0x10000); } void PrimarySlot::set_secondary_paging(uint8_t value) { @@ -85,7 +82,7 @@ void MemorySlot::map(std::size_t source_address, uint16_t destination_address, s handler_.did_page(); } -void MemorySlot::unmap(uint16_t destination_address, std::size_t length) { +void MemorySlot::map_handler(uint16_t destination_address, std::size_t length) { assert(!(destination_address & 8191)); assert(!(length & 8191)); assert(size_t(destination_address) + length <= 65536); @@ -97,6 +94,19 @@ void MemorySlot::unmap(uint16_t destination_address, std::size_t length) { handler_.did_page(); } +void MemorySlot::unmap(uint16_t destination_address, std::size_t length) { + assert(!(destination_address & 8191)); + assert(!(length & 8191)); + assert(size_t(destination_address) + length <= 65536); + + for(std::size_t c = 0; c < (length >> 13); ++c) { + read_pointers_[(destination_address >> 13) + c] = unmapped.data(); + write_pointers_[(destination_address >> 13) + c] = scratch.data(); + } + + handler_.did_page(); +} + MemorySlot &PrimarySlot::subslot(int slot) { return subslots_[slot]; } diff --git a/Machines/MSX/MemorySlotHandler.hpp b/Machines/MSX/MemorySlotHandler.hpp index 874b76b4f..49f58ab09 100644 --- a/Machines/MSX/MemorySlotHandler.hpp +++ b/Machines/MSX/MemorySlotHandler.hpp @@ -69,9 +69,13 @@ class MemorySlot { std::size_t length); /// Marks the region indicated by @c destination_address and @c length - /// as unmapped. In practical terms that means that a @c MemorySlotHandler - /// will be used to field accesses to that area, allowing for areas that are not - /// backed by memory to be modelled. + /// as requiring calls into this slot's MemorySlotHandler. + void map_handler( + uint16_t destination_address, + std::size_t length); + + /// Marks the region indicated by @c destination_address and @c length + /// as unoccupied. void unmap( uint16_t destination_address, std::size_t length);