From 064fe7658cb35a035872c83329487d11f78e1d84 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 12 Mar 2021 18:43:20 -0500 Subject: [PATCH] Adds necessary interface to inherit a CPC tape-speed byte. --- Storage/Tape/Parsers/Spectrum.cpp | 19 +++++++++++++++---- Storage/Tape/Parsers/Spectrum.hpp | 7 +++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Storage/Tape/Parsers/Spectrum.cpp b/Storage/Tape/Parsers/Spectrum.cpp index bcf18194c..4a884875a 100644 --- a/Storage/Tape/Parsers/Spectrum.cpp +++ b/Storage/Tape/Parsers/Spectrum.cpp @@ -82,10 +82,7 @@ void Parser::process_pulse(const Storage::Tape::Tape::Pulse &pulse) { case MachineType::AmstradCPC: // CPC: pilot tone is length of bit 1; bit 0 is half that. // So no more detecting formal pilot waves. - is_one_ = mean * 0.75f; - too_long_ = mean * 1.0f / 0.75f; - too_short_ = is_one_ * 0.5f; - is_pilot_ = too_long_; + set_cpc_one_zero_boundary(mean * 0.75f); break; case MachineType::Enterprise: @@ -132,6 +129,20 @@ void Parser::process_pulse(const Storage::Tape::Tape::Pulse &pulse) { push_wave(t_states > is_one_ ? WaveType::One : WaveType::Zero); } +void Parser::set_cpc_read_speed(uint8_t speed) { + // This may not be exactly right; I wish there were more science here but + // instead it's empirical based on tape speed versus value stored plus + // a guess as to where the CPC puts the dividing line. + set_cpc_one_zero_boundary(float(speed) * 14.35f); +} + +void Parser::set_cpc_one_zero_boundary(float boundary) { + is_one_ = boundary; + too_long_ = is_one_ * 16.0f / 9.0f; + too_short_ = is_one_ * 0.5f; + is_pilot_ = too_long_; +} + void Parser::inspect_waves(const std::vector &waves) { switch(waves[0]) { // Gap and Pilot map directly. diff --git a/Storage/Tape/Parsers/Spectrum.hpp b/Storage/Tape/Parsers/Spectrum.hpp index e8a2d5b32..2b99fcbfb 100644 --- a/Storage/Tape/Parsers/Spectrum.hpp +++ b/Storage/Tape/Parsers/Spectrum.hpp @@ -63,6 +63,11 @@ class Parser: public Storage::Tape::PulseClassificationParser calibration_pulses_; size_t calibration_pulse_pointer_ = 0; + + void set_cpc_one_zero_boundary(float); }; }