mirror of
https://github.com/TomHarte/CLK.git
synced 2025-04-05 04:37:41 +00:00
Sought to weed out further false positives on CommaVid, partly by introducing a record of internal calls, to pair with the now confusingly named outward_calls.
This commit is contained in:
parent
82c089cde4
commit
0273860018
@ -17,14 +17,30 @@ static void DeterminePagingFor2kCartridge(StaticAnalyser::Target &target, const
|
||||
// if this is a 2kb cartridge then it's definitely either unpaged or a CommaVid
|
||||
uint16_t entry_address, break_address;
|
||||
|
||||
entry_address = (uint16_t)(segment.data[0x7fc] | (segment.data[0x7fd] << 8));
|
||||
break_address = (uint16_t)(segment.data[0x7fe] | (segment.data[0x7ff] << 8));
|
||||
entry_address = ((uint16_t)(segment.data[0x7fc] | (segment.data[0x7fd] << 8))) & 0x1fff;
|
||||
break_address = ((uint16_t)(segment.data[0x7fe] | (segment.data[0x7ff] << 8))) & 0x1fff;
|
||||
|
||||
// a CommaVid start address needs to be outside of its RAM
|
||||
if(entry_address < 0x1800 || break_address < 0x1800) return;
|
||||
|
||||
StaticAnalyser::MOS6502::Disassembly disassembly =
|
||||
StaticAnalyser::MOS6502::Disassemble(segment.data, 0x1800, {entry_address, break_address}, 0x1fff);
|
||||
// StaticAnalyser::MOS6502::Disassembly standard_disassembly =
|
||||
// StaticAnalyser::MOS6502::Disassemble(segment.data, 0x1000, {entry_address, break_address}, 0x1fff);
|
||||
|
||||
// if there are no subroutines in the top 2kb of memory then this isn't a CommaVid
|
||||
bool has_subroutine_call = false;
|
||||
for(uint16_t address : disassembly.internal_calls)
|
||||
{
|
||||
const uint16_t masked_address = address & 0x1fff;
|
||||
if(masked_address >= 0x1800)
|
||||
{
|
||||
has_subroutine_call = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has_subroutine_call) return;
|
||||
|
||||
std::set<uint16_t> all_writes = disassembly.external_stores;
|
||||
all_writes.insert(disassembly.external_modifies.begin(), disassembly.external_modifies.end());
|
||||
|
||||
|
@ -18,6 +18,7 @@ struct PartialDisassembly {
|
||||
|
||||
static void AddToDisassembly(PartialDisassembly &disassembly, const std::vector<uint8_t> &memory, uint16_t start_address, uint16_t entry_point, uint16_t address_mask)
|
||||
{
|
||||
disassembly.disassembly.internal_calls.insert(start_address);
|
||||
uint16_t address = entry_point & address_mask;
|
||||
while(1)
|
||||
{
|
||||
|
@ -64,6 +64,7 @@ struct Instruction {
|
||||
struct Disassembly {
|
||||
std::map<uint16_t, Instruction> instructions_by_address;
|
||||
std::set<uint16_t> outward_calls;
|
||||
std::set<uint16_t> internal_calls;
|
||||
std::set<uint16_t> external_stores, external_loads, external_modifies;
|
||||
std::set<uint16_t> internal_stores, internal_loads, internal_modifies;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user