diff --git a/StaticAnalyser/Atari/StaticAnalyser.cpp b/StaticAnalyser/Atari/StaticAnalyser.cpp index 4fb8ac29e..d4bee728f 100644 --- a/StaticAnalyser/Atari/StaticAnalyser.cpp +++ b/StaticAnalyser/Atari/StaticAnalyser.cpp @@ -27,56 +27,21 @@ static void DeterminePagingFor2kCartridge(StaticAnalyser::Target &target, const address &= 0x1fff; return (size_t)(address - 0x1800); }; - std::function full_range_mapper = [](uint16_t address) { - if(!(address & 0x1000)) return (size_t)-1; - return (size_t)(address & 0x7ff); - }; - StaticAnalyser::MOS6502::Disassembly high_location_disassembly = StaticAnalyser::MOS6502::Disassemble(segment.data, high_location_mapper, {entry_address, break_address}); - // if there are no subroutines in the top 2kb of memory then this isn't a CommaVid - bool has_appropriate_subroutine_calls = false; - bool has_inappropriate_subroutine_calls = false; - for(uint16_t address : high_location_disassembly.internal_calls) - { - const uint16_t masked_address = address & 0x1fff; - has_appropriate_subroutine_calls |= (masked_address >= 0x1800); - has_inappropriate_subroutine_calls |= (masked_address < 0x1800); - } - - // assumption here: a CommaVid will never branch into RAM. Possibly unsafe: if it won't then what's the RAM for? - if(!has_appropriate_subroutine_calls || has_inappropriate_subroutine_calls) return; - - std::set all_writes = high_location_disassembly.external_stores; - all_writes.insert(high_location_disassembly.external_modifies.begin(), high_location_disassembly.external_modifies.end()); - - // a CommaVid will use its RAM - if(all_writes.empty()) return; - - bool has_appropriate_accesses = false; - for(uint16_t address : all_writes) - { - const uint16_t masked_address = address & 0x1fff; - if(masked_address >= 0x1400 && masked_address < 0x1800) - { - has_appropriate_accesses = true; - break; - } - } - - // in desperation, accept any kind of store that looks likely to be intended for large amounts of memory + // assume that any kind of store that looks likely to be intended for large amounts of memory implies + // large amounts of memory bool has_wide_area_store = false; - if(!has_appropriate_accesses) + for(std::map::value_type &entry : high_location_disassembly.instructions_by_address) { - for(std::map::value_type &entry : high_location_disassembly.instructions_by_address) + if(entry.second.operation == StaticAnalyser::MOS6502::Instruction::STA) { - if(entry.second.operation == StaticAnalyser::MOS6502::Instruction::STA) - { - has_wide_area_store |= entry.second.addressing_mode == StaticAnalyser::MOS6502::Instruction::Indirect; - has_wide_area_store |= entry.second.addressing_mode == StaticAnalyser::MOS6502::Instruction::IndexedIndirectX; - has_wide_area_store |= entry.second.addressing_mode == StaticAnalyser::MOS6502::Instruction::IndirectIndexedY; - } + has_wide_area_store |= entry.second.addressing_mode == StaticAnalyser::MOS6502::Instruction::Indirect; + has_wide_area_store |= entry.second.addressing_mode == StaticAnalyser::MOS6502::Instruction::IndexedIndirectX; + has_wide_area_store |= entry.second.addressing_mode == StaticAnalyser::MOS6502::Instruction::IndirectIndexedY; + + if(has_wide_area_store) break; } } @@ -84,8 +49,7 @@ static void DeterminePagingFor2kCartridge(StaticAnalyser::Target &target, const // caveat: false positives aren't likely to be problematic; a false positive is a 2KB ROM that always addresses // itself so as to land in ROM even if mapped as a CommaVid and this code is on the fence as to whether it // attempts to modify itself but it probably doesn't - if(has_appropriate_accesses || has_wide_area_store) - target.atari.paging_model = StaticAnalyser::Atari2600PagingModel::CommaVid; + if(has_wide_area_store) target.atari.paging_model = StaticAnalyser::Atari2600PagingModel::CommaVid; } static void DeterminePagingFor8kCartridge(StaticAnalyser::Target &target, const Storage::Cartridge::Cartridge::Segment &segment, const StaticAnalyser::MOS6502::Disassembly &disassembly) @@ -223,8 +187,7 @@ void StaticAnalyser::Atari::AddTargets( const std::list> &cartridges, std::list &destination) { - // TODO: any sort of sanity checking at all; at the minute just trust the file type - // approximation already performed. + // TODO: sanity checking; is this image really for an Atari 2600? Target target; target.machine = Target::Atari2600; target.probability = 1.0;