From 523dbb9678b39723a5a356771d509c5c0fe5292d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 25 Sep 2016 18:32:26 -0400 Subject: [PATCH] This'll do for getting the ADF into the machine. --- StaticAnalyser/Acorn/Disk.cpp | 25 ++++++++++++++++++++++++- Storage/Disk/Formats/AcornADF.cpp | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/StaticAnalyser/Acorn/Disk.cpp b/StaticAnalyser/Acorn/Disk.cpp index b670e1e4f..61b078c2a 100644 --- a/StaticAnalyser/Acorn/Disk.cpp +++ b/StaticAnalyser/Acorn/Disk.cpp @@ -248,7 +248,30 @@ std::unique_ptr StaticAnalyser::Acorn::GetADFSCatalogue(const std::sh FMParser parser(true); parser.set_disk(disk); - std::shared_ptr directory = parser.get_sector(0, 2); + std::shared_ptr free_space_map_second_half = parser.get_sector(0, 1); + if(!free_space_map_second_half) return nullptr; + + std::vector root_directory; + root_directory.reserve(5 * 256); + for(uint8_t c = 2; c < 7; c++) + { + std::shared_ptr 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; } diff --git a/Storage/Disk/Formats/AcornADF.cpp b/Storage/Disk/Formats/AcornADF.cpp index 69d95a99f..13956ed3d 100644 --- a/Storage/Disk/Formats/AcornADF.cpp +++ b/Storage/Disk/Formats/AcornADF.cpp @@ -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;