1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-13 00:29:14 +00:00

Improve loop detection.

This commit is contained in:
Thomas Harte 2024-12-05 17:30:30 -05:00
parent 85d4c24aba
commit 7a1153be65
2 changed files with 9 additions and 2 deletions

View File

@ -21,6 +21,7 @@
#include <algorithm>
#include <cstring>
#include <sstream>
#include <unordered_set>
using namespace Analyser::Static::Commodore;
@ -84,7 +85,7 @@ std::optional<BASICAnalysis> analyse(const File &file) {
// a machine code entry point.
BASICAnalysis analysis;
std::set<uint16_t> visited_lines;
std::unordered_set<uint16_t> visited_lines;
while(true) {
// Analysis has failed if there isn't at least one complete BASIC line from here.
if(size_t(line_address - file.starting_address) + 5 >= file.data.size()) {
@ -123,7 +124,7 @@ std::optional<BASICAnalysis> analyse(const File &file) {
// Exit if a formal end of the program has been declared or if, as some copy protections do,
// the linked list of line contents has been made circular.
visited_lines.insert(line_number);
visited_lines.insert(line_address);
if(!next_line_address || visited_lines.find(next_line_address) != visited_lines.end()) {
break;
}

View File

@ -46,6 +46,7 @@ struct HitRate {
continue;
}
NSLog(@"%@", diskItem);
const auto list = Analyser::Static::GetTargets([path stringByAppendingPathComponent:diskItem].UTF8String);
if(list.empty()) {
continue;
@ -58,6 +59,11 @@ struct HitRate {
const auto &first = *list.begin();
hits.matches += first->machine == machine;
// if(!(hits.files % 100)) {
NSLog(@"Currently %d in %d, i.e. %0.2f",
hits.matches, hits.files, float(hits.matches) / float(hits.files));
// }
}
return hits;