1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Merge pull request #209 from TomHarte/BootOnly

Generalises: an acceptable boot sector is always acceptable
This commit is contained in:
Thomas Harte 2017-08-17 14:29:37 -04:00 committed by GitHub
commit 6a09022896

View File

@ -53,7 +53,7 @@ static std::string RunCommandFor(const Storage::Disk::CPM::File &file) {
return command + "\n";
}
static void InspectDataCatalogue(
static void InspectCatalogue(
const Storage::Disk::CPM::Catalogue &catalogue,
StaticAnalyser::Target &target) {
std::vector<Storage::Disk::CPM::File> candidate_files = catalogue.files;
@ -145,13 +145,8 @@ static void InspectDataCatalogue(
target.loadingCommand = "cat\n";
}
static void InspectSystemCatalogue(
const std::shared_ptr<Storage::Disk::Disk> &disk,
const Storage::Disk::CPM::Catalogue &catalogue,
StaticAnalyser::Target &target) {
static bool CheckBootSector(const std::shared_ptr<Storage::Disk::Disk> &disk, StaticAnalyser::Target &target) {
Storage::Encodings::MFM::Parser parser(true, disk);
// Check that the boot sector exists and looks like it had content written to it.
std::shared_ptr<Storage::Encodings::MFM::Sector> boot_sector = parser.get_sector(0, 0, 0x41);
if(boot_sector != nullptr) {
// Check that the first 64 bytes of the sector aren't identical; if they are then probably
@ -167,11 +162,11 @@ static void InspectSystemCatalogue(
// This is a system disk, then launch it as though it were CP/M.
if(!matched) {
target.loadingCommand = "|cpm\n";
return;
return true;
}
}
InspectDataCatalogue(catalogue, target);
return false;
}
void StaticAnalyser::AmstradCPC::AddTargets(const Media &media, std::list<Target> &destination) {
@ -202,8 +197,9 @@ void StaticAnalyser::AmstradCPC::AddTargets(const Media &media, std::list<Target
std::unique_ptr<Storage::Disk::CPM::Catalogue> data_catalogue = Storage::Disk::CPM::GetCatalogue(target.media.disks.front(), data_format);
if(data_catalogue) {
InspectDataCatalogue(*data_catalogue, target);
InspectCatalogue(*data_catalogue, target);
} else {
if(!CheckBootSector(target.media.disks.front(), target)) {
Storage::Disk::CPM::ParameterBlock system_format;
system_format.sectors_per_track = 9;
system_format.tracks = 40;
@ -214,7 +210,8 @@ void StaticAnalyser::AmstradCPC::AddTargets(const Media &media, std::list<Target
std::unique_ptr<Storage::Disk::CPM::Catalogue> system_catalogue = Storage::Disk::CPM::GetCatalogue(target.media.disks.front(), system_format);
if(system_catalogue) {
InspectSystemCatalogue(target.media.disks.front(), *system_catalogue, target);
InspectCatalogue(*system_catalogue, target);
}
}
}
}