From 06ea81fdb29a99ce199f6ae29b15c7e167459d56 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 20:23:26 -0400 Subject: [PATCH] Made sure that unrecognised waves don't block the symbol queue, and allowed any type of nonsense to be skipped before finding a byte. --- Storage/Tape/Parsers/ZX8081.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Storage/Tape/Parsers/ZX8081.cpp b/Storage/Tape/Parsers/ZX8081.cpp index 0ad025d5f..68d3fc4b1 100644 --- a/Storage/Tape/Parsers/ZX8081.cpp +++ b/Storage/Tape/Parsers/ZX8081.cpp @@ -58,6 +58,11 @@ void Parser::inspect_waves(const std::vector &waves) { return; } + if(waves[0] == WaveType::Unrecognised) { + push_symbol(SymbolType::Unrecognised, 1); + return; + } + if(waves.size() >= 4) { size_t wave_offset = 0; // If the very first thing is a gap, swallow it. @@ -92,14 +97,18 @@ void Parser::inspect_waves(const std::vector &waves) { int Parser::get_next_byte(const std::shared_ptr &tape) { int c = 8; int result = 0; - while(c--) { + while(c) { if(is_at_end(tape)) return -1; + SymbolType symbol = get_next_symbol(tape); if(symbol != SymbolType::One && symbol != SymbolType::Zero) { + if(c == 8) continue; return_symbol(symbol); return -1; } + result = (result << 1) | (symbol == SymbolType::One ? 1 : 0); + c--; } return result; }