mirror of
https://github.com/TomHarte/CLK.git
synced 2024-07-17 13:29:02 +00:00
Simplified CommaVid test.
This commit is contained in:
parent
b671df9906
commit
a9964ee0c8
@ -27,48 +27,12 @@ static void DeterminePagingFor2kCartridge(StaticAnalyser::Target &target, const
|
|||||||
address &= 0x1fff;
|
address &= 0x1fff;
|
||||||
return (size_t)(address - 0x1800);
|
return (size_t)(address - 0x1800);
|
||||||
};
|
};
|
||||||
std::function<size_t(uint16_t address)> 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::Disassembly high_location_disassembly =
|
||||||
StaticAnalyser::MOS6502::Disassemble(segment.data, high_location_mapper, {entry_address, break_address});
|
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
|
// assume that any kind of store that looks likely to be intended for large amounts of memory implies
|
||||||
bool has_appropriate_subroutine_calls = false;
|
// large amounts of memory
|
||||||
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<uint16_t> 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
|
|
||||||
bool has_wide_area_store = false;
|
bool has_wide_area_store = false;
|
||||||
if(!has_appropriate_accesses)
|
|
||||||
{
|
|
||||||
for(std::map<uint16_t, StaticAnalyser::MOS6502::Instruction>::value_type &entry : high_location_disassembly.instructions_by_address)
|
for(std::map<uint16_t, StaticAnalyser::MOS6502::Instruction>::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)
|
||||||
@ -76,7 +40,8 @@ static void DeterminePagingFor2kCartridge(StaticAnalyser::Target &target, const
|
|||||||
has_wide_area_store |= entry.second.addressing_mode == StaticAnalyser::MOS6502::Instruction::Indirect;
|
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::IndexedIndirectX;
|
||||||
has_wide_area_store |= entry.second.addressing_mode == StaticAnalyser::MOS6502::Instruction::IndirectIndexedY;
|
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
|
// 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
|
// 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
|
// attempts to modify itself but it probably doesn't
|
||||||
if(has_appropriate_accesses || has_wide_area_store)
|
if(has_wide_area_store) target.atari.paging_model = StaticAnalyser::Atari2600PagingModel::CommaVid;
|
||||||
target.atari.paging_model = StaticAnalyser::Atari2600PagingModel::CommaVid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DeterminePagingFor8kCartridge(StaticAnalyser::Target &target, const Storage::Cartridge::Cartridge::Segment &segment, const StaticAnalyser::MOS6502::Disassembly &disassembly)
|
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<std::shared_ptr<Storage::Cartridge::Cartridge>> &cartridges,
|
const std::list<std::shared_ptr<Storage::Cartridge::Cartridge>> &cartridges,
|
||||||
std::list<StaticAnalyser::Target> &destination)
|
std::list<StaticAnalyser::Target> &destination)
|
||||||
{
|
{
|
||||||
// TODO: any sort of sanity checking at all; at the minute just trust the file type
|
// TODO: sanity checking; is this image really for an Atari 2600?
|
||||||
// approximation already performed.
|
|
||||||
Target target;
|
Target target;
|
||||||
target.machine = Target::Atari2600;
|
target.machine = Target::Atari2600;
|
||||||
target.probability = 1.0;
|
target.probability = 1.0;
|
||||||
|
Loading…
Reference in New Issue
Block a user