diff --git a/Machines/Atari2600/Atari2600.cpp b/Machines/Atari2600/Atari2600.cpp index 054460596..2985e485d 100644 --- a/Machines/Atari2600/Atari2600.cpp +++ b/Machines/Atari2600/Atari2600.cpp @@ -90,17 +90,20 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin 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 RAM access + bool was_ram_access = false; + if(has_ram_) { + if(masked_address >= ram_write_start_ && masked_address < ram_.size() + ram_write_start_) { + ram_[masked_address & ram_.size() - 1] = *value; + was_ram_access = true; + } else if(masked_address >= ram_read_start_ && masked_address < ram_.size() + ram_read_start_) { + returnValue &= ram_[masked_address & ram_.size() - 1]; + was_ram_access = true; + } } - // 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]; - } + if(isReadOperation(operation) && !was_ram_access) { + returnValue &= rom_pages_[(address >> 10)&3][address&1023]; } } @@ -277,7 +280,25 @@ void Machine::configure_as_target(const StaticAnalyser::Target &target) rom_pages_[2] = &rom_[2048 & romMask]; rom_pages_[3] = &rom_[3072 & romMask]; - uses_superchip_ = target.atari.uses_superchip; + switch(target.atari.paging_model) + { + default: + if(target.atari.uses_superchip) + { + ram_.resize(128); + has_ram_ = true; + ram_write_start_ = 0x1000; + ram_read_start_ = 0x1080; + } + break; + + case StaticAnalyser::Atari2600PagingModel::CommaVid: + ram_.resize(1024); + has_ram_ = true; + ram_write_start_ = 0x1400; + ram_read_start_ = 0x1000; + break; + } } #pragma mark - Audio and Video diff --git a/Machines/Atari2600/Atari2600.hpp b/Machines/Atari2600/Atari2600.hpp index c0ec017f1..68c45e97b 100644 --- a/Machines/Atari2600/Atari2600.hpp +++ b/Machines/Atari2600/Atari2600.hpp @@ -61,8 +61,9 @@ class Machine: size_t rom_size_; // cartridge RAM expansion store - uint8_t superchip_ram_[128]; - bool uses_superchip_; + std::vector ram_; + uint16_t ram_write_start_, ram_read_start_; + bool has_ram_; // the RIOT and TIA PIA mos6532_;