diff --git a/Machines/Apple/AppleII/AppleII.cpp b/Machines/Apple/AppleII/AppleII.cpp index 857c07503..a447e88c7 100644 --- a/Machines/Apple/AppleII/AppleII.cpp +++ b/Machines/Apple/AppleII/AppleII.cpp @@ -102,10 +102,12 @@ template class ConcreteMachine: Cycles cycles_since_audio_update_; // MARK: - Cards - std::array, 7> cards_; + std::array, 9> cards_; // The final slot is a sentinel. Cycles cycles_since_card_update_; std::vector every_cycle_cards_; std::vector just_in_time_cards_; + static constexpr size_t NoActiveCard = 8; + size_t active_card_ = NoActiveCard; int stretched_cycles_since_card_update_ = 0; @@ -739,18 +741,32 @@ template class ConcreteMachine: Communication with cards follows. */ - if(!read_pages_[address >> 8] && address >= 0xc090 && address < 0xc800) { + if(!read_pages_[address >> 8] && address >= 0xc090 && address < 0xd000) { // If this is a card access, figure out which card is at play before determining // the totality of who needs messaging. size_t card_number = 0; Apple::II::Card::Select select = Apple::II::Card::None; - if(address >= 0xc100) { + if(address >= 0xc800) { + /* + Decode the 2kb area used for additional ROMs. + This is shared by all cards. + */ + card_number = active_card_; + select = Apple::II::Card::C8Region; + + // An access to $cfff will disable the active card. + if(address == 0xcfff) { + active_card_ = NoActiveCard; + } + } else if(address >= 0xc100) { /* Decode the area conventionally used by cards for ROMs: 0xCn00 to 0xCnff: card n. + + This also sets the active card for the C8 region. */ - card_number = (address - 0xc100) >> 8; + active_card_ = card_number = (address - 0xc100) >> 8; select = Apple::II::Card::Device; } else { /*