From 9d7985c1e1d151f5da89ed4ab02cdedd8ba40036 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 26 Feb 2017 17:47:29 -0500 Subject: [PATCH] Added Super Chip emulation. --- Machines/Atari2600/Atari2600.cpp | 19 +++++++++++++++++-- Machines/Atari2600/Atari2600.hpp | 5 +++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Machines/Atari2600/Atari2600.cpp b/Machines/Atari2600/Atari2600.cpp index 50745cb9b..054460596 100644 --- a/Machines/Atari2600/Atari2600.cpp +++ b/Machines/Atari2600/Atari2600.cpp @@ -87,8 +87,21 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin } // check for a ROM read - if((address&0x1000) && isReadOperation(operation)) { - returnValue &= rom_pages_[(address >> 10)&3][address&1023]; + uint16_t masked_address = address & 0x1fff; + if(address&0x1000) + { + if(isReadOperation(operation) && (!uses_superchip_ || masked_address > 0x10ff)) { + returnValue &= rom_pages_[(address >> 10)&3][address&1023]; + } + + // check for a Super Chip RAM access + if(uses_superchip_ && masked_address < 0x1100) { + if(masked_address < 0x1080) { + superchip_ram_[masked_address & 0x7f] = *value; + } else { + returnValue &= superchip_ram_[masked_address & 0x7f]; + } + } } // check for a RAM access @@ -263,6 +276,8 @@ void Machine::configure_as_target(const StaticAnalyser::Target &target) rom_pages_[1] = &rom_[1024 & romMask]; rom_pages_[2] = &rom_[2048 & romMask]; rom_pages_[3] = &rom_[3072 & romMask]; + + uses_superchip_ = target.atari.uses_superchip; } #pragma mark - Audio and Video diff --git a/Machines/Atari2600/Atari2600.hpp b/Machines/Atari2600/Atari2600.hpp index f0970348e..c0ec017f1 100644 --- a/Machines/Atari2600/Atari2600.hpp +++ b/Machines/Atari2600/Atari2600.hpp @@ -56,9 +56,14 @@ class Machine: virtual void crt_did_end_batch_of_frames(Outputs::CRT::CRT *crt, unsigned int number_of_frames, unsigned int number_of_unexpected_vertical_syncs); private: + // ROM information uint8_t *rom_, *rom_pages_[4]; size_t rom_size_; + // cartridge RAM expansion store + uint8_t superchip_ram_[128]; + bool uses_superchip_; + // the RIOT and TIA PIA mos6532_; std::unique_ptr tia_;