diff --git a/Analyser/Static/Commodore/StaticAnalyser.cpp b/Analyser/Static/Commodore/StaticAnalyser.cpp index 656ec9859..3ddfaa443 100644 --- a/Analyser/Static/Commodore/StaticAnalyser.cpp +++ b/Analyser/Static/Commodore/StaticAnalyser.cpp @@ -105,7 +105,7 @@ std::optional analyse(const File &file) { while(true) { const auto token = next(); - if(!token) break; + if(!token || token == 0x8f) break; switch(token) { case 0x9e: { // SYS; parse following ASCII argument. @@ -158,7 +158,11 @@ Analyser::Static::TargetList Analyser::Static::Commodore::GetTargets( std::vector disk_files = GetFiles(disk); if(!disk_files.empty()) { is_disk = true; - files.insert(files.end(), disk_files.begin(), disk_files.end()); + files.insert( + files.end(), + std::make_move_iterator(disk_files.begin()), + std::make_move_iterator(disk_files.end()) + ); target->media.disks.push_back(disk); if(!device) device = 8; } @@ -169,7 +173,11 @@ Analyser::Static::TargetList Analyser::Static::Commodore::GetTargets( std::vector tape_files = GetFiles(tape); tape->reset(); if(!tape_files.empty()) { - files.insert(files.end(), tape_files.begin(), tape_files.end()); + files.insert( + files.end(), + std::make_move_iterator(tape_files.begin()), + std::make_move_iterator(tape_files.end()) + ); target->media.tapes.push_back(tape); if(!device) device = 1; } @@ -181,11 +189,11 @@ Analyser::Static::TargetList Analyser::Static::Commodore::GetTargets( auto memory_model = Target::MemoryModel::Unexpanded; std::ostringstream string_stream; - string_stream << "LOAD\"" << (is_disk ? "*" : "") << "\"," << device << ","; + string_stream << "LOAD\"" << (is_disk ? "*" : "") << "\"," << device; const auto analysis = analyse(file); if(analysis && !analysis->machine_code_addresses.empty()) { - string_stream << "1"; + string_stream << ",1"; // Disassemble. const auto disassembly = Analyser::Static::MOS6502::Disassemble( @@ -232,6 +240,11 @@ Analyser::Static::TargetList Analyser::Static::Commodore::GetTargets( break; } + // The Vic-20 never has RAM after 0x8000. + if(file.ending_address >= 0x8000) { + target->machine = Machine::Plus4; + } + target->set_memory_model(memory_model); // General approach: increase memory size conservatively such that the largest file found will fit. diff --git a/Analyser/Static/Commodore/Tape.cpp b/Analyser/Static/Commodore/Tape.cpp index b7891614d..08ee5b109 100644 --- a/Analyser/Static/Commodore/Tape.cpp +++ b/Analyser/Static/Commodore/Tape.cpp @@ -26,7 +26,7 @@ std::vector Analyser::Static::Commodore::GetFiles(const std::shared_ptrtype) { case Storage::Tape::Commodore::Header::DataSequenceHeader: { - File new_file; + File &new_file = file_list.emplace_back(); new_file.name = header->name; new_file.raw_name = header->raw_name; new_file.starting_address = header->starting_address; @@ -40,8 +40,6 @@ std::vector Analyser::Static::Commodore::GetFiles(const std::shared_ptrtype != Storage::Tape::Commodore::Header::DataBlock) break; std::copy(header->data.begin(), header->data.end(), std::back_inserter(new_file.data)); } - - file_list.push_back(new_file); } break; @@ -49,7 +47,7 @@ std::vector Analyser::Static::Commodore::GetFiles(const std::shared_ptr data = parser.get_next_data(tape); if(data) { - File new_file; + File &new_file = file_list.emplace_back(); new_file.name = header->name; new_file.raw_name = header->raw_name; new_file.starting_address = header->starting_address; @@ -58,8 +56,6 @@ std::vector Analyser::Static::Commodore::GetFiles(const std::shared_ptrtype == Storage::Tape::Commodore::Header::RelocatableProgram ? File::RelocatableProgram : File::NonRelocatableProgram; - - file_list.push_back(new_file); } header = parser.get_next_header(tape);