From a167e3849b5ca39e79d102c6b26ca54fecab5249 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 18 Apr 2018 18:13:30 -0400 Subject: [PATCH] Allows multiple ROMs to be inserted into the Electron. --- Machines/Electron/Electron.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index b8e16c525..ef9eb8417 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -86,6 +86,7 @@ class ConcreteMachine: std::memcpy(&target[rom_ptr], data.data(), size_to_copy); rom_ptr += size_to_copy; } + rom_inserted_[slot] = true; } // Obtains the system ROMs. @@ -158,6 +159,7 @@ class ConcreteMachine: if(!media.tapes.empty()) { tape_.set_tape(media.tapes.front()); } + set_use_fast_tape_hack(); if(!media.disks.empty() && plus3_) { plus3_->set_disk(media.disks.front(), 0); @@ -165,11 +167,14 @@ class ConcreteMachine: ROMSlot slot = ROMSlot12; for(std::shared_ptr cartridge : media.cartridges) { + const ROMSlot first_slot_tried = slot; + while(rom_inserted_[slot]) { + slot = static_cast((static_cast(slot) + 1)&15); + if(slot == first_slot_tried) return false; + } set_rom(slot, cartridge->get_segments().front().data, false); - slot = static_cast((static_cast(slot) + 1)&15); } - set_use_fast_tape_hack(); return !media.tapes.empty() || !media.disks.empty() || !media.cartridges.empty(); } @@ -513,6 +518,7 @@ class ConcreteMachine: // Things that directly constitute the memory map. uint8_t roms_[16][16384]; + bool rom_inserted_[16] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; bool rom_write_masks_[16] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; uint8_t os_[16384], ram_[32768]; std::vector dfs_, adfs1_, adfs2_;