diff --git a/Analyser/Static/Acorn/Disk.cpp b/Analyser/Static/Acorn/Disk.cpp index e2c392d53..2b38aaca4 100644 --- a/Analyser/Static/Acorn/Disk.cpp +++ b/Analyser/Static/Acorn/Disk.cpp @@ -202,13 +202,19 @@ std::unique_ptr Analyser::Static::Acorn::GetADFSCatalogue(const std:: } // Include the directory title. - const uint8_t *title; + const char *title, *name; if(catalogue->has_large_sectors) { - title = &root_directory[0x7dd]; + title = reinterpret_cast(&root_directory[0x7dd]); + name = reinterpret_cast(&root_directory[0x7f0]); } else { - title = &root_directory[0x4d9]; + title = reinterpret_cast(&root_directory[0x4d9]); + name = reinterpret_cast(&root_directory[0x4cc]); + } + + catalogue->name = std::string(title, strnlen(title, 19)); + if(catalogue->name.empty() || catalogue->name == "$") { + catalogue->name = std::string(name, strnlen(name, 10)); } - catalogue->name = std::string(reinterpret_cast(title), 19); return catalogue; } diff --git a/Analyser/Static/Acorn/StaticAnalyser.cpp b/Analyser/Static/Acorn/StaticAnalyser.cpp index 612cdd083..7d2010ec4 100644 --- a/Analyser/Static/Acorn/StaticAnalyser.cpp +++ b/Analyser/Static/Acorn/StaticAnalyser.cpp @@ -62,7 +62,7 @@ static std::vector> return acorn_cartridges; } -Analyser::Static::TargetList Analyser::Static::Acorn::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { +Analyser::Static::TargetList Analyser::Static::Acorn::GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType) { auto target8bit = std::make_unique(); auto targetArchimedes = std::make_unique(); @@ -152,6 +152,8 @@ Analyser::Static::TargetList Analyser::Static::Acorn::GetTargets(const Media &me // Also look for the best possible startup program name, if it can be discerned. std::map> options; + const std::string &disk_title = + (adfs_catalogue->name.empty() || adfs_catalogue->name == "$") ? file_name : adfs_catalogue->name; for(const auto &file: adfs_catalogue->files) { // Skip non-Pling files. if(file.name[0] != '!') continue; @@ -168,7 +170,7 @@ Analyser::Static::TargetList Analyser::Static::Acorn::GetTargets(const Media &me } ) != file.name.end(); - const auto probability = Numeric::similarity(file.name, adfs_catalogue->name) * (has_read ? 0.5 : 1.0); + const auto probability = Numeric::similarity(file.name, disk_title) - (has_read ? 0.2 : 0.0); options.emplace(probability, file.name); }