From 9f450b3ccbb0c0a3b7235459118a5384d1a3af2b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 13 Jan 2023 14:16:12 -0500 Subject: [PATCH] Expose the extension ROM to an MSX 2. --- Machines/MSX/MSX.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Machines/MSX/MSX.cpp b/Machines/MSX/MSX.cpp index aeeb2b517..9b5c4b363 100644 --- a/Machines/MSX/MSX.cpp +++ b/Machines/MSX/MSX.cpp @@ -147,6 +147,10 @@ class ConcreteMachine: static constexpr int RAMMemorySlot = 3; static constexpr int RAMMemorySubSlot = 0; + static constexpr int ExtensionROMSubSlot = 1; + + // Provide 512kb of memory for an MSX 2; 64kb for an MSX 1. 'Slightly' arbitrary. + static constexpr size_t RAMSize = model == Target::Model::MSX2 ? 512 * 1024 : 64 * 1024; public: ConcreteMachine(const Target &target, const ROMMachine::ROMFetcher &rom_fetcher): @@ -247,7 +251,6 @@ class ConcreteMachine: has_bios = true; } } - if(!has_bios) { std::vector &bios = roms.find(bios_name)->second; @@ -266,8 +269,24 @@ class ConcreteMachine: memory_slots_[0].map(0, 0, 0, 32768); - memory_slots_[RAMMemorySlot].resize_source(65536); - memory_slots_[RAMMemorySlot].template map(RAMMemorySubSlot, 0, 0, 65536); + if constexpr (model == Target::Model::MSX2) { + // If there's an extension ROM, add it as a subslot in the same slot as RAM. + std::vector ram_plus; + + ram_plus.resize(RAMSize); + + const auto extension = roms.find(ROM::Name::MSX2Extension); + std::copy(extension->second.begin(), extension->second.end(), std::back_inserter(ram_plus)); + + memory_slots_[RAMMemorySlot].supports_secondary_paging = true; + memory_slots_[RAMMemorySlot].set_source(ram_plus); + + memory_slots_[RAMMemorySlot].template map(RAMMemorySubSlot, 0, 0, 65536); + memory_slots_[RAMMemorySlot].map(ExtensionROMSubSlot, 0, 0, 32768); + } else { + memory_slots_[RAMMemorySlot].resize_source(65536); + memory_slots_[RAMMemorySlot].template map(RAMMemorySubSlot, RAMSize, 0, 65536); + } // Add a disk cartridge if any disks were supplied. if(target.has_disk_drive) {