mirror of
https://github.com/TomHarte/CLK.git
synced 2024-07-06 01:28:57 +00:00
Adjusted to allow the very first thing found to be data, and ensured that unrecognised symbols break files just as gaps do.
This commit is contained in:
parent
9108495586
commit
2179edc7fe
@ -95,11 +95,8 @@ int Parser::get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
|||||||
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::FileGap) {
|
|
||||||
return_symbol(symbol);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(symbol != SymbolType::One && symbol != SymbolType::Zero) {
|
if(symbol != SymbolType::One && symbol != SymbolType::Zero) {
|
||||||
|
return_symbol(symbol);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
result = (result << 1) | (symbol == SymbolType::One ? 1 : 0);
|
result = (result << 1) | (symbol == SymbolType::One ? 1 : 0);
|
||||||
@ -110,10 +107,7 @@ int Parser::get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
|||||||
std::shared_ptr<std::vector<uint8_t>> Parser::get_next_file_data(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
std::shared_ptr<std::vector<uint8_t>> Parser::get_next_file_data(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
||||||
if(is_at_end(tape)) return nullptr;
|
if(is_at_end(tape)) return nullptr;
|
||||||
SymbolType symbol = get_next_symbol(tape);
|
SymbolType symbol = get_next_symbol(tape);
|
||||||
if(symbol != SymbolType::FileGap) {
|
while((symbol == SymbolType::FileGap || symbol == SymbolType::Unrecognised) && !is_at_end(tape)) {
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
while(symbol == SymbolType::FileGap && !is_at_end(tape)) {
|
|
||||||
symbol = get_next_symbol(tape);
|
symbol = get_next_symbol(tape);
|
||||||
}
|
}
|
||||||
if(is_at_end(tape)) return nullptr;
|
if(is_at_end(tape)) return nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user