From 231f3dd0f45a93931054afd3b2559d8ea5b6ddf0 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 18 Sep 2016 22:18:01 -0400 Subject: [PATCH] This is exactly as far as I'm going to get with DFS parsing today, I think. --- StaticAnalyser/Acorn/Disk.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/StaticAnalyser/Acorn/Disk.cpp b/StaticAnalyser/Acorn/Disk.cpp index 0bbfdf2ea..1d03067ae 100644 --- a/StaticAnalyser/Acorn/Disk.cpp +++ b/StaticAnalyser/Acorn/Disk.cpp @@ -141,11 +141,27 @@ class FMParser: public Storage::Disk::Drive { std::list StaticAnalyser::Acorn::GetDFSFiles(const std::shared_ptr &disk) { + // c.f. http://beebwiki.mdfs.net/Acorn_DFS_disc_format std::list files; FMParser parser; parser.set_disk(disk); - parser.get_sector(0, 0); + std::shared_ptr names = parser.get_sector(0, 0); + std::shared_ptr details = parser.get_sector(0, 1); + + if(!names || !details) return files; + if(names->data.size() != 256 || details->data.size() != 256) return files; + + uint8_t final_file_offset = details->data[5]; + if(final_file_offset&7) return files; + + size_t number_of_files = (final_file_offset >> 3)-1; + for(size_t file = 0; file < number_of_files; file++) + { + char name[10]; + snprintf(name, 10, "%c.%7s", names->data[file * 8 + 7], &names->data[file * 8]); + printf("%s\n", name); + } return files; }