diff --git a/Storage/Tape/Parsers/Acorn.cpp b/Storage/Tape/Parsers/Acorn.cpp index 4c8895ec2..65c976adb 100644 --- a/Storage/Tape/Parsers/Acorn.cpp +++ b/Storage/Tape/Parsers/Acorn.cpp @@ -24,12 +24,13 @@ int Parser::get_next_bit(const std::shared_ptr &tape) { } int Parser::get_next_byte(const std::shared_ptr &tape) { - int value = 0; - int c = 8; if(get_next_bit(tape)) { set_error_flag(); return -1; } + + int value = 0; + int c = 8; while(c--) { value = (value >> 1) | (get_next_bit(tape) << 7); } @@ -74,7 +75,7 @@ Shifter::Shifter() : void Shifter::process_pulse(const Storage::Tape::Tape::Pulse &pulse) { pll_.run_for(Cycles(int(float(PLLClockRate) * pulse.length.get()))); - bool is_high = pulse.type == Storage::Tape::Tape::Pulse::High; + const bool is_high = pulse.type == Storage::Tape::Tape::Pulse::High; if(is_high != was_high_) { pll_.add_pulse(); } diff --git a/Storage/Tape/Parsers/Acorn.hpp b/Storage/Tape/Parsers/Acorn.hpp index 5d4673701..394f19bac 100644 --- a/Storage/Tape/Parsers/Acorn.hpp +++ b/Storage/Tape/Parsers/Acorn.hpp @@ -57,10 +57,10 @@ class Parser: public Storage::Tape::Parser, public Shifter::Delegate void reset_crc(); uint16_t get_crc(); - void acorn_shifter_output_bit(int value); - void process_pulse(const Storage::Tape::Tape::Pulse &pulse); - private: + void acorn_shifter_output_bit(int value) override; + void process_pulse(const Storage::Tape::Tape::Pulse &pulse) override; + bool did_update_shifter(int new_value, int length); CRC::Generator crc_; Shifter shifter_; diff --git a/Storage/Tape/Parsers/Commodore.cpp b/Storage/Tape/Parsers/Commodore.cpp index a8a15d3bd..7e33c1596 100644 --- a/Storage/Tape/Parsers/Commodore.cpp +++ b/Storage/Tape/Parsers/Commodore.cpp @@ -76,7 +76,7 @@ std::unique_ptr
Parser::get_next_header_body(const std::shared_ptrtype = Header::Unknown; break; case 0x01: header->type = Header::RelocatableProgram; break; @@ -92,7 +92,7 @@ std::unique_ptr
Parser::get_next_header_body(const std::shared_ptrdata.push_back(get_next_byte(tape)); } - uint8_t parity_byte = get_parity_byte(); + const uint8_t parity_byte = get_parity_byte(); header->parity_was_valid = get_next_byte(tape) == parity_byte; // parse if this is not pure data @@ -110,7 +110,7 @@ std::unique_ptr
Parser::get_next_header_body(const std::shared_ptr */ void Parser::proceed_to_symbol(const std::shared_ptr &tape, SymbolType required_symbol) { while(!tape->is_at_end()) { - SymbolType symbol = get_next_symbol(tape); + const SymbolType symbol = get_next_symbol(tape); if(symbol == required_symbol) return; } } @@ -187,7 +186,7 @@ void Parser::proceed_to_symbol(const std::shared_ptr &tape, Swallows the next byte; sets the error flag if it is not equal to @c value. */ void Parser::expect_byte(const std::shared_ptr &tape, uint8_t value) { - uint8_t next_byte = get_next_byte(tape); + const uint8_t next_byte = get_next_byte(tape); if(next_byte != value) set_error_flag(); } @@ -247,7 +246,7 @@ void Parser::process_pulse(const Storage::Tape::Tape::Pulse &pulse) { // short: 182us => 0.000364s cycle // medium: 262us => 0.000524s cycle // long: 342us => 0.000684s cycle - bool is_high = pulse.type == Storage::Tape::Tape::Pulse::High; + const bool is_high = pulse.type == Storage::Tape::Tape::Pulse::High; if(!is_high && previous_was_high_) { if(wave_period_ >= 0.000764) push_wave(WaveType::Unrecognised); else if(wave_period_ >= 0.000604) push_wave(WaveType::Long); diff --git a/Storage/Tape/Parsers/Commodore.hpp b/Storage/Tape/Parsers/Commodore.hpp index 0a64728f4..b7cc8aecb 100644 --- a/Storage/Tape/Parsers/Commodore.hpp +++ b/Storage/Tape/Parsers/Commodore.hpp @@ -126,7 +126,7 @@ class Parser: public Storage::Tape::PulseClassificationParser &waves); + void inspect_waves(const std::vector &waves) override; }; } diff --git a/Storage/Tape/Parsers/Oric.cpp b/Storage/Tape/Parsers/Oric.cpp index ffb98cab2..cc3019bc4 100644 --- a/Storage/Tape/Parsers/Oric.cpp +++ b/Storage/Tape/Parsers/Oric.cpp @@ -45,7 +45,7 @@ void Parser::process_pulse(const Storage::Tape::Tape::Pulse &pulse) { constexpr float maximum_medium_length = 0.000728f; constexpr float maximum_long_length = 0.001456f; - bool wave_is_high = pulse.type == Storage::Tape::Tape::Pulse::High; + const bool wave_is_high = pulse.type == Storage::Tape::Tape::Pulse::High; if(!wave_was_high_ && wave_is_high != wave_was_high_) { if(cycle_length_ < maximum_short_length) push_wave(WaveType::Short); else if(cycle_length_ < maximum_medium_length) push_wave(WaveType::Medium); diff --git a/Storage/Tape/Parsers/Oric.hpp b/Storage/Tape/Parsers/Oric.hpp index 0b46541e9..4a5f2d403 100644 --- a/Storage/Tape/Parsers/Oric.hpp +++ b/Storage/Tape/Parsers/Oric.hpp @@ -32,8 +32,8 @@ class Parser: public Storage::Tape::PulseClassificationParser &tape); private: - void process_pulse(const Storage::Tape::Tape::Pulse &pulse); - void inspect_waves(const std::vector &waves); + void process_pulse(const Storage::Tape::Tape::Pulse &pulse) override; + void inspect_waves(const std::vector &waves) override; enum DetectionMode { FastData, diff --git a/Storage/Tape/Parsers/ZX8081.cpp b/Storage/Tape/Parsers/ZX8081.cpp index 1e11502b5..487c6a398 100644 --- a/Storage/Tape/Parsers/ZX8081.cpp +++ b/Storage/Tape/Parsers/ZX8081.cpp @@ -15,8 +15,8 @@ Parser::Parser() : pulse_was_high_(false), pulse_time_(0) {} void Parser::process_pulse(const Storage::Tape::Tape::Pulse &pulse) { // If this is anything other than a transition from low to high, just add it to the // count of time. - bool pulse_is_high = pulse.type == Storage::Tape::Tape::Pulse::High; - bool pulse_did_change = pulse_is_high != pulse_was_high_; + const bool pulse_is_high = pulse.type == Storage::Tape::Tape::Pulse::High; + const bool pulse_did_change = pulse_is_high != pulse_was_high_; pulse_was_high_ = pulse_is_high; if(!pulse_did_change || !pulse_is_high) { pulse_time_ += pulse.length; @@ -31,7 +31,7 @@ void Parser::process_pulse(const Storage::Tape::Tape::Pulse &pulse) { void Parser::post_pulse() { constexpr float expected_pulse_length = 300.0f / 1000000.0f; constexpr float expected_gap_length = 1300.0f / 1000000.0f; - auto pulse_time = pulse_time_.get(); + const auto pulse_time = pulse_time_.get(); if(pulse_time > expected_gap_length * 1.25f) { push_wave(WaveType::LongGap); diff --git a/Storage/Tape/Parsers/ZX8081.hpp b/Storage/Tape/Parsers/ZX8081.hpp index bb32f7cdd..a3f3b8de7 100644 --- a/Storage/Tape/Parsers/ZX8081.hpp +++ b/Storage/Tape/Parsers/ZX8081.hpp @@ -50,10 +50,9 @@ class Parser: public Storage::Tape::PulseClassificationParser &waves); + void process_pulse(const Storage::Tape::Tape::Pulse &pulse) override; + void mark_end() override; + void inspect_waves(const std::vector &waves) override; std::shared_ptr> get_next_file_data(const std::shared_ptr &tape); };