From 388dd997624d78a263f66e188aa585863be9264c Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 11 Aug 2017 10:47:12 -0400 Subject: [PATCH] Advanced this just enough to suggest a loading command for most things. --- StaticAnalyser/AmstradCPC/StaticAnalyser.cpp | 68 +++++++++++++++++--- 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/StaticAnalyser/AmstradCPC/StaticAnalyser.cpp b/StaticAnalyser/AmstradCPC/StaticAnalyser.cpp index 73ee8930e..0a49946a2 100644 --- a/StaticAnalyser/AmstradCPC/StaticAnalyser.cpp +++ b/StaticAnalyser/AmstradCPC/StaticAnalyser.cpp @@ -9,6 +9,35 @@ #include "StaticAnalyser.hpp" #include "../../Storage/Disk/Parsers/CPM.hpp" +static void InspectDataCatalogue( + const std::unique_ptr &data_catalogue, + StaticAnalyser::Target &target) { + // If there's just one file, run that. + if(data_catalogue->files.size() == 1) { + target.loadingCommand = "run\"" + data_catalogue->files[0].name + "\n"; + return; + } + + // If only one file is [potentially] BASIC, run that one. + int basic_files = 0; + size_t last_basic_file = 0; + for(size_t c = 0; c < data_catalogue->files.size(); c++) { + if(!((data_catalogue->files[c].data[18] >> 1) & 7)) { + basic_files++; + last_basic_file = c; + } + } + if(basic_files == 1) { + target.loadingCommand = "run\"" + data_catalogue->files[last_basic_file].name + "\n"; + return; + } +} + +static void InspectSystemCatalogue( + const std::unique_ptr &data_catalogue, + StaticAnalyser::Target &target) { +} + void StaticAnalyser::AmstradCPC::AddTargets( const std::list> &disks, const std::list> &tapes, @@ -21,19 +50,38 @@ void StaticAnalyser::AmstradCPC::AddTargets( target.tapes = tapes; target.cartridges = cartridges; - target.amstradcpc.model = target.disks.empty() ? AmstradCPCModel::CPC464 : AmstradCPCModel::CPC6128; + target.amstradcpc.model = AmstradCPCModel::CPC6128; + + if(!target.tapes.empty()) { + target.loadingCommand = "|tape\nrun\"\n"; + } if(!target.disks.empty()) { - // This is CPC data format. - Storage::Disk::CPM::ParameterBlock parameters; - parameters.sectors_per_track = 9; - parameters.block_size = 1024; - parameters.first_sector = 0xc1; - parameters.catalogue_allocation_bitmap = 0xc000; - parameters.logic_extents_per_physical = 1; - parameters.reserved_tracks = 0; + Storage::Disk::CPM::ParameterBlock data_format; + data_format.sectors_per_track = 9; + data_format.tracks = 40; + data_format.block_size = 1024; + data_format.first_sector = 0xc1; + data_format.catalogue_allocation_bitmap = 0xc000; + data_format.reserved_tracks = 0; - Storage::Disk::CPM::GetCatalogue(target.disks.front(), parameters); + std::unique_ptr data_catalogue = Storage::Disk::CPM::GetCatalogue(target.disks.front(), data_format); + if(data_catalogue) { + InspectDataCatalogue(data_catalogue, target); + } else { + Storage::Disk::CPM::ParameterBlock system_format; + data_format.sectors_per_track = 9; + data_format.tracks = 40; + data_format.block_size = 1024; + data_format.first_sector = 0x41; + data_format.catalogue_allocation_bitmap = 0xc000; + data_format.reserved_tracks = 2; + + std::unique_ptr system_catalogue = Storage::Disk::CPM::GetCatalogue(target.disks.front(), system_format); + if(system_catalogue) { + InspectSystemCatalogue(data_catalogue, target); + } + } } destination.push_back(target);