mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-13 00:29:14 +00:00
Infer more from first file starting address; reduce reallocations.
This commit is contained in:
parent
a508f7a463
commit
19f815eeff
@ -174,15 +174,13 @@ std::vector<File> Analyser::Static::Commodore::GetFiles(const std::shared_ptr<St
|
|||||||
CommodoreGCRParser parser;
|
CommodoreGCRParser parser;
|
||||||
parser.set_disk(disk);
|
parser.set_disk(disk);
|
||||||
|
|
||||||
// find any sector whatsoever to establish the current track
|
// Assemble directory.
|
||||||
std::shared_ptr<CommodoreGCRParser::Sector> sector;
|
|
||||||
|
|
||||||
// assemble directory
|
|
||||||
std::vector<uint8_t> directory;
|
std::vector<uint8_t> directory;
|
||||||
uint8_t next_track = 18;
|
uint8_t next_track = 18;
|
||||||
uint8_t next_sector = 1;
|
uint8_t next_sector = 1;
|
||||||
|
directory.reserve(20 * 1024); // Probably more than plenty.
|
||||||
while(true) {
|
while(true) {
|
||||||
sector = parser.sector(next_track, next_sector);
|
auto sector = parser.sector(next_track, next_sector);
|
||||||
if(!sector) break;
|
if(!sector) break;
|
||||||
directory.insert(directory.end(), sector->data.begin(), sector->data.end());
|
directory.insert(directory.end(), sector->data.begin(), sector->data.end());
|
||||||
next_track = sector->data[0];
|
next_track = sector->data[0];
|
||||||
@ -224,7 +222,7 @@ std::vector<File> Analyser::Static::Commodore::GetFiles(const std::shared_ptr<St
|
|||||||
|
|
||||||
bool is_first_sector = true;
|
bool is_first_sector = true;
|
||||||
while(next_track) {
|
while(next_track) {
|
||||||
sector = parser.sector(next_track, next_sector);
|
auto sector = parser.sector(next_track, next_sector);
|
||||||
if(!sector) break;
|
if(!sector) break;
|
||||||
|
|
||||||
next_track = sector->data[0];
|
next_track = sector->data[0];
|
||||||
|
@ -226,7 +226,8 @@ Analyser::Static::TargetList Analyser::Static::Commodore::GetTargets(
|
|||||||
analysis->machine_code_addresses
|
analysis->machine_code_addresses
|
||||||
);
|
);
|
||||||
|
|
||||||
// Very dumb check: if FF3E or FF3F were touched, this is for the +4.
|
// If FF3E or FF3F is touched, this is for the +4.
|
||||||
|
// TODO: probably require a very early touch.
|
||||||
for(const auto address: {0xff3e, 0xff3f}) {
|
for(const auto address: {0xff3e, 0xff3f}) {
|
||||||
for(const auto &collection: {
|
for(const auto &collection: {
|
||||||
disassembly.external_loads,
|
disassembly.external_loads,
|
||||||
@ -243,28 +244,37 @@ Analyser::Static::TargetList Analyser::Static::Commodore::GetTargets(
|
|||||||
string_stream << "\nRUN\n";
|
string_stream << "\nRUN\n";
|
||||||
if(it == files.begin()) {
|
if(it == files.begin()) {
|
||||||
target->loading_command = string_stream.str();
|
target->loading_command = string_stream.str();
|
||||||
|
|
||||||
|
// Make a guess for the Vic-20, if ultimately selected, based on loading address.
|
||||||
|
// TODO: probably also discount other machines if starting address isn't 0x1001?
|
||||||
|
switch(files.front().starting_address) {
|
||||||
|
default:
|
||||||
|
Log::Logger<Log::Source::CommodoreStaticAnalyser>().error().append(
|
||||||
|
"Unrecognised loading address for Commodore program: %04x", files.front().starting_address);
|
||||||
|
[[fallthrough]];
|
||||||
|
case 0x1001:
|
||||||
|
vic_memory_model = Target::MemoryModel::Unexpanded;
|
||||||
|
// TODO: could be Vic-20 or Plus4.
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x1201:
|
||||||
|
vic_memory_model = Target::MemoryModel::ThirtyTwoKB;
|
||||||
|
target->machine = Machine::Vic20;
|
||||||
|
break;
|
||||||
|
case 0x0401:
|
||||||
|
vic_memory_model = Target::MemoryModel::EightKB;
|
||||||
|
target->machine = Machine::Vic20;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x0801:
|
||||||
|
// TODO: assume C64.
|
||||||
|
break;
|
||||||
|
case 0x1c01:
|
||||||
|
// TODO: assume C128.
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make a first guess based on loading address
|
|
||||||
switch(files.front().starting_address) {
|
|
||||||
default:
|
|
||||||
Log::Logger<Log::Source::CommodoreStaticAnalyser>().error().append(
|
|
||||||
"Unrecognised loading address for Commodore program: %04x", files.front().starting_address);
|
|
||||||
[[fallthrough]];
|
|
||||||
case 0x1001:
|
|
||||||
vic_memory_model = Target::MemoryModel::Unexpanded;
|
|
||||||
break;
|
|
||||||
case 0x1201:
|
|
||||||
vic_memory_model = Target::MemoryModel::ThirtyTwoKB;
|
|
||||||
break;
|
|
||||||
case 0x0401:
|
|
||||||
vic_memory_model = Target::MemoryModel::EightKB;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x1c01:
|
|
||||||
Log::Logger<Log::Source::CommodoreStaticAnalyser>().info().append("Unimplemented: C128");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The Vic-20 never has RAM after 0x8000.
|
// The Vic-20 never has RAM after 0x8000.
|
||||||
if(file.ending_address >= 0x8000) {
|
if(file.ending_address >= 0x8000) {
|
||||||
|
Loading…
Reference in New Issue
Block a user