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:
commit
6a09022896
@ -53,7 +53,7 @@ static std::string RunCommandFor(const Storage::Disk::CPM::File &file) {
|
|||||||
return command + "\n";
|
return command + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InspectDataCatalogue(
|
static void InspectCatalogue(
|
||||||
const Storage::Disk::CPM::Catalogue &catalogue,
|
const Storage::Disk::CPM::Catalogue &catalogue,
|
||||||
StaticAnalyser::Target &target) {
|
StaticAnalyser::Target &target) {
|
||||||
std::vector<Storage::Disk::CPM::File> candidate_files = catalogue.files;
|
std::vector<Storage::Disk::CPM::File> candidate_files = catalogue.files;
|
||||||
@ -145,13 +145,8 @@ static void InspectDataCatalogue(
|
|||||||
target.loadingCommand = "cat\n";
|
target.loadingCommand = "cat\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InspectSystemCatalogue(
|
static bool CheckBootSector(const std::shared_ptr<Storage::Disk::Disk> &disk, StaticAnalyser::Target &target) {
|
||||||
const std::shared_ptr<Storage::Disk::Disk> &disk,
|
|
||||||
const Storage::Disk::CPM::Catalogue &catalogue,
|
|
||||||
StaticAnalyser::Target &target) {
|
|
||||||
Storage::Encodings::MFM::Parser parser(true, disk);
|
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);
|
std::shared_ptr<Storage::Encodings::MFM::Sector> boot_sector = parser.get_sector(0, 0, 0x41);
|
||||||
if(boot_sector != nullptr) {
|
if(boot_sector != nullptr) {
|
||||||
// Check that the first 64 bytes of the sector aren't identical; if they are then probably
|
// 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.
|
// This is a system disk, then launch it as though it were CP/M.
|
||||||
if(!matched) {
|
if(!matched) {
|
||||||
target.loadingCommand = "|cpm\n";
|
target.loadingCommand = "|cpm\n";
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectDataCatalogue(catalogue, target);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StaticAnalyser::AmstradCPC::AddTargets(const Media &media, std::list<Target> &destination) {
|
void StaticAnalyser::AmstradCPC::AddTargets(const Media &media, std::list<Target> &destination) {
|
||||||
@ -202,19 +197,21 @@ 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);
|
std::unique_ptr<Storage::Disk::CPM::Catalogue> data_catalogue = Storage::Disk::CPM::GetCatalogue(target.media.disks.front(), data_format);
|
||||||
if(data_catalogue) {
|
if(data_catalogue) {
|
||||||
InspectDataCatalogue(*data_catalogue, target);
|
InspectCatalogue(*data_catalogue, target);
|
||||||
} else {
|
} else {
|
||||||
Storage::Disk::CPM::ParameterBlock system_format;
|
if(!CheckBootSector(target.media.disks.front(), target)) {
|
||||||
system_format.sectors_per_track = 9;
|
Storage::Disk::CPM::ParameterBlock system_format;
|
||||||
system_format.tracks = 40;
|
system_format.sectors_per_track = 9;
|
||||||
system_format.block_size = 1024;
|
system_format.tracks = 40;
|
||||||
system_format.first_sector = 0x41;
|
system_format.block_size = 1024;
|
||||||
system_format.catalogue_allocation_bitmap = 0xc000;
|
system_format.first_sector = 0x41;
|
||||||
system_format.reserved_tracks = 2;
|
system_format.catalogue_allocation_bitmap = 0xc000;
|
||||||
|
system_format.reserved_tracks = 2;
|
||||||
|
|
||||||
std::unique_ptr<Storage::Disk::CPM::Catalogue> system_catalogue = Storage::Disk::CPM::GetCatalogue(target.media.disks.front(), system_format);
|
std::unique_ptr<Storage::Disk::CPM::Catalogue> system_catalogue = Storage::Disk::CPM::GetCatalogue(target.media.disks.front(), system_format);
|
||||||
if(system_catalogue) {
|
if(system_catalogue) {
|
||||||
InspectSystemCatalogue(target.media.disks.front(), *system_catalogue, target);
|
InspectCatalogue(*system_catalogue, target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user