1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-19 08:31:11 +00:00

Made sure that unrecognised waves don't block the symbol queue, and allowed any type of nonsense to be skipped before finding a byte.

This commit is contained in:
Thomas Harte 2017-07-21 20:23:26 -04:00
parent d69b1e2d11
commit 06ea81fdb2

View File

@ -58,6 +58,11 @@ void Parser::inspect_waves(const std::vector<WaveType> &waves) {
return; return;
} }
if(waves[0] == WaveType::Unrecognised) {
push_symbol(SymbolType::Unrecognised, 1);
return;
}
if(waves.size() >= 4) { if(waves.size() >= 4) {
size_t wave_offset = 0; size_t wave_offset = 0;
// If the very first thing is a gap, swallow it. // If the very first thing is a gap, swallow it.
@ -92,14 +97,18 @@ void Parser::inspect_waves(const std::vector<WaveType> &waves) {
int Parser::get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &tape) { int Parser::get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &tape) {
int c = 8; int c = 8;
int result = 0; int result = 0;
while(c--) { while(c) {
if(is_at_end(tape)) return -1; if(is_at_end(tape)) return -1;
SymbolType symbol = get_next_symbol(tape); SymbolType symbol = get_next_symbol(tape);
if(symbol != SymbolType::One && symbol != SymbolType::Zero) { if(symbol != SymbolType::One && symbol != SymbolType::Zero) {
if(c == 8) continue;
return_symbol(symbol); return_symbol(symbol);
return -1; return -1;
} }
result = (result << 1) | (symbol == SymbolType::One ? 1 : 0); result = (result << 1) | (symbol == SymbolType::One ? 1 : 0);
c--;
} }
return result; return result;
} }