diff --git a/StaticAnalyser/Commodore/Tape.cpp b/StaticAnalyser/Commodore/Tape.cpp index 3676a0210..8d9963b2d 100644 --- a/StaticAnalyser/Commodore/Tape.cpp +++ b/StaticAnalyser/Commodore/Tape.cpp @@ -40,6 +40,12 @@ struct Header { bool duplicate_matched; }; +struct Data { + std::vector data; + bool parity_was_valid; + bool duplicate_matched; +}; + class CommodoreROMTapeParser: public StaticAnalyer::TapeParser { public: CommodoreROMTapeParser(const std::shared_ptr &tape) : @@ -113,20 +119,40 @@ class CommodoreROMTapeParser: public StaticAnalyer::TapeParser> get_next_data() + std::unique_ptr get_next_data() { - std::unique_ptr> data(new std::vector); + std::unique_ptr data(new Data); // find and proceed beyond lead-in tone to the next landing zone proceed_to_symbol(SymbolType::LeadIn); proceed_to_landing_zone(true); + reset_parity_byte(); - // accumulate until the next lead-in tone is hit -// while(!is_at_end()) -// { -// data->push_back(get_next_byte()); -// } + // accumulate until the next non-word marker is hit + while(!is_at_end()) + { + SymbolType start_symbol = get_next_symbol(); + if(start_symbol != SymbolType::Word) break; + data->data.push_back(get_next_byte_contents()); + } + // the above has reead the parity byte to the end of the data; if it matched the calculated parity it'll now be zero + data->parity_was_valid = !get_parity_byte(); + + // compare to the duplicate + proceed_to_symbol(SymbolType::LeadIn); + proceed_to_landing_zone(false); + reset_parity_byte(); + data->duplicate_matched = true; + for(size_t c = 0; c < data->data.size(); c++) + { + if(get_next_byte() != data->data[c]) data->duplicate_matched = false; + } + + // remove the captured parity + data->data.erase(data->data.end()-1); + + if(get_error_flag()) return nullptr; return data; } @@ -199,15 +225,22 @@ class CommodoreROMTapeParser: public StaticAnalyer::TapeParser StaticAnalyser::Commodore::GetFiles(const std::shared_ptr &tape) { CommodoreROMTapeParser parser(tape); - parser.get_next_header(); + std::unique_ptr
header = parser.get_next_header(); + std::unique_ptr data = parser.get_next_data(); parser.spin(); std::list file_list;