mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-28 06:29:37 +00:00
This'll do for getting the ADF into the machine.
This commit is contained in:
parent
de863719d0
commit
523dbb9678
@ -248,7 +248,30 @@ std::unique_ptr<Catalogue> StaticAnalyser::Acorn::GetADFSCatalogue(const std::sh
|
||||
FMParser parser(true);
|
||||
parser.set_disk(disk);
|
||||
|
||||
std::shared_ptr<Storage::Encodings::MFM::Sector> directory = parser.get_sector(0, 2);
|
||||
std::shared_ptr<Storage::Encodings::MFM::Sector> free_space_map_second_half = parser.get_sector(0, 1);
|
||||
if(!free_space_map_second_half) return nullptr;
|
||||
|
||||
std::vector<uint8_t> root_directory;
|
||||
root_directory.reserve(5 * 256);
|
||||
for(uint8_t c = 2; c < 7; c++)
|
||||
{
|
||||
std::shared_ptr<Storage::Encodings::MFM::Sector> sector = parser.get_sector(0, c);
|
||||
if(!sector) return nullptr;
|
||||
root_directory.insert(root_directory.end(), sector->data.begin(), sector->data.end());
|
||||
}
|
||||
|
||||
// Quick sanity checks.
|
||||
if(root_directory[0x4cb]) return nullptr;
|
||||
if(root_directory[1] != 'H' || root_directory[2] != 'u' || root_directory[3] != 'g' || root_directory[4] != 'o') return nullptr;
|
||||
if(root_directory[0x4FB] != 'H' || root_directory[0x4FC] != 'u' || root_directory[0x4FD] != 'g' || root_directory[0x4FE] != 'o') return nullptr;
|
||||
|
||||
switch(free_space_map_second_half->data[0xfd])
|
||||
{
|
||||
default: catalogue->bootOption = Catalogue::BootOption::None; break;
|
||||
case 1: catalogue->bootOption = Catalogue::BootOption::LoadBOOT; break;
|
||||
case 2: catalogue->bootOption = Catalogue::BootOption::RunBOOT; break;
|
||||
case 3: catalogue->bootOption = Catalogue::BootOption::ExecBOOT; break;
|
||||
}
|
||||
|
||||
return catalogue;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ AcornADF::AcornADF(const char *file_name) : _file(nullptr)
|
||||
// very loose validation: the file needs to be a multiple of 256 bytes
|
||||
// and not ungainly large
|
||||
if(file_stats.st_size & 255) throw ErrorNotAcornADF;
|
||||
if(file_stats.st_size < 2048) throw ErrorNotAcornADF;
|
||||
if(file_stats.st_size < 7 * 256) throw ErrorNotAcornADF;
|
||||
|
||||
_file = fopen(file_name, "rb");
|
||||
if(!_file) throw ErrorCantOpen;
|
||||
|
Loading…
x
Reference in New Issue
Block a user