mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-21 21:33:54 +00:00
Factgor out and reuse is-ZX test.
This commit is contained in:
parent
69ba94e379
commit
eece8c54a4
@ -232,9 +232,9 @@ Analyser::Static::TargetList Analyser::Static::AmstradCPC::GetTargets(const Medi
|
||||
const auto system_format = Storage::Disk::CPM::ParameterBlock::cpc_system_format();
|
||||
|
||||
for(auto &disk: media.disks) {
|
||||
// Check for an ordinary catalogue.
|
||||
// Check for an ordinary catalogue, making sure this isn't actually a ZX Spectrum disk.
|
||||
std::unique_ptr<Storage::Disk::CPM::Catalogue> data_catalogue = Storage::Disk::CPM::GetCatalogue(disk, data_format);
|
||||
if(data_catalogue) {
|
||||
if(data_catalogue && !data_catalogue->is_zx_spectrum_booter()) {
|
||||
InspectCatalogue(*data_catalogue, target);
|
||||
target->media.disks.push_back(disk);
|
||||
continue;
|
||||
@ -248,7 +248,7 @@ Analyser::Static::TargetList Analyser::Static::AmstradCPC::GetTargets(const Medi
|
||||
|
||||
// Failing that check for a system catalogue.
|
||||
std::unique_ptr<Storage::Disk::CPM::Catalogue> system_catalogue = Storage::Disk::CPM::GetCatalogue(disk, system_format);
|
||||
if(system_catalogue) {
|
||||
if(system_catalogue && !system_catalogue->is_zx_spectrum_booter()) {
|
||||
InspectCatalogue(*system_catalogue, target);
|
||||
target->media.disks.push_back(disk);
|
||||
continue;
|
||||
|
@ -98,12 +98,7 @@ bool IsSpectrumDisk(const std::shared_ptr<Storage::Disk::Disk> &disk) {
|
||||
|
||||
// ... otherwise read a CPM directory and look for a BASIC program called "DISK".
|
||||
const auto catalogue = Storage::Disk::CPM::GetCatalogue(disk, cpm_format);
|
||||
if(!catalogue) return false;
|
||||
const auto file = std::find_if(catalogue->files.begin(), catalogue->files.end(), [](const auto &file) { return file.name == "DISK "; });
|
||||
if(file == catalogue->files.end()) return false;
|
||||
|
||||
// TODO: check out contents of "DISK"
|
||||
return true;
|
||||
return catalogue && catalogue->is_zx_spectrum_booter();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -158,3 +158,13 @@ std::unique_ptr<Storage::Disk::CPM::Catalogue> Storage::Disk::CPM::GetCatalogue(
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Catalogue::is_zx_spectrum_booter() {
|
||||
// Check for a file called 'DISK'.
|
||||
const auto file = std::find_if(files.begin(), files.end(), [](const auto &file) { return file.name == "DISK "; });
|
||||
if(file == files.end()) return false;
|
||||
|
||||
// TODO: check the file is valid ZX Spectrum BASIC.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ struct File {
|
||||
|
||||
struct Catalogue {
|
||||
std::vector<File> files;
|
||||
|
||||
bool is_zx_spectrum_booter();
|
||||
};
|
||||
|
||||
std::unique_ptr<Catalogue> GetCatalogue(const std::shared_ptr<Storage::Disk::Disk> &disk, const ParameterBlock ¶meters);
|
||||
|
Loading…
Reference in New Issue
Block a user