diff --git a/Components/Serial/Line.cpp b/Components/Serial/Line.cpp index 12aaf8d4b..72088ce26 100644 --- a/Components/Serial/Line.cpp +++ b/Components/Serial/Line.cpp @@ -186,7 +186,7 @@ void Line::update_delegate(const bool level) { template Cycles::IntType Line::minimum_write_cycles_for_read_delegate_bit() { if(!read_delegate_) return 0; - return 1 + (read_delegate_bit_length_ * clock_rate_.as()).template get(); + return 1 + (read_delegate_bit_length_ * clock_rate_.as()).template as(); } // diff --git a/OSBindings/Mac/Clock SignalTests/PCMTrackTests.mm b/OSBindings/Mac/Clock SignalTests/PCMTrackTests.mm index d20e87477..5d20d45bf 100644 --- a/OSBindings/Mac/Clock SignalTests/PCMTrackTests.mm +++ b/OSBindings/Mac/Clock SignalTests/PCMTrackTests.mm @@ -83,7 +83,7 @@ XCTAssert(offset >= 0.0 && offset < 0.5, "Next event should occur soon"); auto next_event = track.get_next_event(); - double next_event_duration = next_event.length.get(); + double next_event_duration = next_event.length.as(); XCTAssert(next_event_duration >= 0.0 && next_event_duration < 0.005, "Next event should occur soon"); } diff --git a/Storage/Disk/Controller/DiskController.cpp b/Storage/Disk/Controller/DiskController.cpp index 6778fad3e..9f86d841d 100644 --- a/Storage/Disk/Controller/DiskController.cpp +++ b/Storage/Disk/Controller/DiskController.cpp @@ -86,7 +86,7 @@ void Controller::set_expected_bit_length(const Time bit_length) { // this conversion doesn't need to be exact because there's a lot of variation to be taken // account of in rotation speed, air turbulence, etc, so a direct conversion will do - const int clocks_per_bit = cycles_per_bit.get(); + const int clocks_per_bit = cycles_per_bit.as(); pll_.set_clocks_per_bit(clocks_per_bit); } diff --git a/Storage/Disk/DiskImage/Formats/MOOF.cpp b/Storage/Disk/DiskImage/Formats/MOOF.cpp index 77d185243..a9595f3bd 100644 --- a/Storage/Disk/DiskImage/Formats/MOOF.cpp +++ b/Storage/Disk/DiskImage/Formats/MOOF.cpp @@ -62,7 +62,7 @@ public: float time_observed = 0.0f; while(time_observed < time_since_index_hole) { auto prior = data_iterator_; - const auto next_time = get_next_event().length.get(); + const auto next_time = get_next_event().length.as(); if(time_observed + next_time > time_since_index_hole) { --bits_passed_; diff --git a/Storage/Disk/Drive.cpp b/Storage/Disk/Drive.cpp index 931877bd1..e00d6f28e 100644 --- a/Storage/Disk/Drive.cpp +++ b/Storage/Disk/Drive.cpp @@ -240,7 +240,7 @@ void Drive::run_for(const Cycles cycles) { const auto cycles_until_next_event = get_cycles_until_next_event(); auto cycles_to_run_for = std::min(cycles_until_next_event, number_of_cycles); if(!is_reading_ && cycles_until_bits_written_ > zero) { - auto write_cycles_target = cycles_until_bits_written_.get(); + auto write_cycles_target = cycles_until_bits_written_.as(); if(cycles_until_bits_written_.length % cycles_until_bits_written_.clock_rate) ++write_cycles_target; cycles_to_run_for = std::min(cycles_to_run_for, write_cycles_target); } @@ -323,7 +323,7 @@ void Drive::get_next_event(const float duration_already_passed) { if(track_) { const auto track_event = track_->get_next_event(); current_event_.type = track_event.type; - current_event_.length = track_event.length.get(); + current_event_.length = track_event.length.as(); } else { current_event_.length = 1.0f; current_event_.type = Track::Event::IndexHole; diff --git a/Storage/Disk/Track/PCMSegment.cpp b/Storage/Disk/Track/PCMSegment.cpp index b6ee3fa46..21d0f376f 100644 --- a/Storage/Disk/Track/PCMSegment.cpp +++ b/Storage/Disk/Track/PCMSegment.cpp @@ -118,7 +118,7 @@ Storage::Time PCMSegmentEventSource::get_length() { float PCMSegmentEventSource::seek_to(const float time_from_start) { // test for requested time being beyond the end - const float length = get_length().get(); + const float length = get_length().as(); if(time_from_start >= length) { next_event_.type = Track::Event::IndexHole; bit_pointer_ = segment_->data.size()+1; @@ -129,7 +129,7 @@ float PCMSegmentEventSource::seek_to(const float time_from_start) { next_event_.type = Track::Event::FluxTransition; // test for requested time being before the first bit - const float bit_length = segment_->length_of_a_bit.get(); + const float bit_length = segment_->length_of_a_bit.as(); const float half_bit_length = bit_length / 2.0f; if(time_from_start < half_bit_length) { bit_pointer_ = 0; diff --git a/Storage/Disk/Track/PCMTrack.cpp b/Storage/Disk/Track/PCMTrack.cpp index c4a8ebd9b..237684393 100644 --- a/Storage/Disk/Track/PCMTrack.cpp +++ b/Storage/Disk/Track/PCMTrack.cpp @@ -135,7 +135,7 @@ float PCMTrack::seek_to(const float time_since_index_hole) { do { // if this segment extends beyond the amount of time left to seek, trust it to complete // the seek - const float segment_time = segment_event_sources_[segment_pointer_].get_length().get(); + const float segment_time = segment_event_sources_[segment_pointer_].get_length().as(); if(segment_time > time_left_to_seek) { return accumulated_time + segment_event_sources_[segment_pointer_].seek_to(time_left_to_seek); } diff --git a/Storage/Disk/Track/TrackSerialiser.cpp b/Storage/Disk/Track/TrackSerialiser.cpp index 5b70cbeb6..6fe82193e 100644 --- a/Storage/Disk/Track/TrackSerialiser.cpp +++ b/Storage/Disk/Track/TrackSerialiser.cpp @@ -45,7 +45,7 @@ Storage::Disk::PCMSegment Storage::Disk::track_serialisation(const Track &track, Time extended_length = next_event.length * length_multiplier + time_error; time_error.clock_rate = extended_length.clock_rate; time_error.length = extended_length.length % extended_length.clock_rate; - pll.run_for(Cycles(int(extended_length.get()))); + pll.run_for(Cycles(int(extended_length.as()))); if(next_event.type == Track::Event::IndexHole) break; pll.add_pulse(); diff --git a/Storage/Storage.hpp b/Storage/Storage.hpp index bb06464f5..329d8feec 100644 --- a/Storage/Storage.hpp +++ b/Storage/Storage.hpp @@ -50,7 +50,7 @@ struct Time { /*! @returns the floating point conversion of this @c Time. This will often be less precise. */ - template T get() const { + template T as() const { return T(length) / T(clock_rate); } diff --git a/Storage/Tape/Parsers/Acorn.cpp b/Storage/Tape/Parsers/Acorn.cpp index 8b2fb0f61..3ad8889e9 100644 --- a/Storage/Tape/Parsers/Acorn.cpp +++ b/Storage/Tape/Parsers/Acorn.cpp @@ -73,7 +73,7 @@ Shifter::Shifter() : delegate_(nullptr) {} void Shifter::process_pulse(const Storage::Tape::Pulse &pulse) { - pll_.run_for(Cycles(int(float(PLLClockRate) * pulse.length.get()))); + pll_.run_for(Cycles(int(float(PLLClockRate) * pulse.length.as()))); const bool is_high = pulse.type == Storage::Tape::Pulse::High; if(is_high != was_high_) { diff --git a/Storage/Tape/Parsers/Commodore.cpp b/Storage/Tape/Parsers/Commodore.cpp index 21c8aa709..8c43dee1d 100644 --- a/Storage/Tape/Parsers/Commodore.cpp +++ b/Storage/Tape/Parsers/Commodore.cpp @@ -297,7 +297,7 @@ void Parser::process_pulse(const Storage::Tape::Pulse &pulse) { wave_period_ = 0.0f; } - wave_period_ += pulse.length.get(); + wave_period_ += pulse.length.as(); previous_was_high_ = is_high; } diff --git a/Storage/Tape/Parsers/Oric.cpp b/Storage/Tape/Parsers/Oric.cpp index 79cafece0..f821f5d13 100644 --- a/Storage/Tape/Parsers/Oric.cpp +++ b/Storage/Tape/Parsers/Oric.cpp @@ -55,7 +55,7 @@ void Parser::process_pulse(const Storage::Tape::Pulse &pulse) { cycle_length_ = 0.0f; } wave_was_high_ = wave_is_high; - cycle_length_ += pulse.length.get(); + cycle_length_ += pulse.length.as(); } void Parser::inspect_waves(const std::vector &waves) { diff --git a/Storage/Tape/Parsers/Spectrum.cpp b/Storage/Tape/Parsers/Spectrum.cpp index 89fea1ca9..0649588df 100644 --- a/Storage/Tape/Parsers/Spectrum.cpp +++ b/Storage/Tape/Parsers/Spectrum.cpp @@ -32,7 +32,7 @@ void Parser::process_pulse(const Storage::Tape::Pulse &pulse) { } // Only pulse duration matters; the ZX Spectrum et al do not rely on polarity. - const float t_states = pulse.length.get() * 3'500'000.0f; + const float t_states = pulse.length.as() * 3'500'000.0f; switch(speed_phase_) { case SpeedDetectionPhase::WaitingForGap: diff --git a/Storage/Tape/Parsers/ThomsonMO.cpp b/Storage/Tape/Parsers/ThomsonMO.cpp index 8283e17c1..ce80403d2 100644 --- a/Storage/Tape/Parsers/ThomsonMO.cpp +++ b/Storage/Tape/Parsers/ThomsonMO.cpp @@ -47,7 +47,7 @@ int Parser::calibrated_sample_delay(Storage::Tape::TapeSerialiser &serialiser) { while(!serialiser.is_at_end()) { const auto pulse = serialiser.next_pulse(); - time += pulse.length.get(); + time += pulse.length.as(); if(pulse.type != last_type) { last_type = pulse.type; @@ -88,7 +88,7 @@ std::optional Parser::bit(Storage::Tape::TapeSerialiser &serialiser, int s float time = 0.0f; const float bit_duration = float(sample_delay_us) / 1'000'000.0f; while(!serialiser.is_at_end()) { - time += pulse.length.get(); + time += pulse.length.as(); if(time >= bit_duration) break; pulse = serialiser.next_pulse(); } diff --git a/Storage/Tape/Parsers/ZX8081.cpp b/Storage/Tape/Parsers/ZX8081.cpp index c82527ddc..74a5aad24 100644 --- a/Storage/Tape/Parsers/ZX8081.cpp +++ b/Storage/Tape/Parsers/ZX8081.cpp @@ -31,7 +31,7 @@ void Parser::process_pulse(const Storage::Tape::Pulse &pulse) { void Parser::post_pulse() { static constexpr float expected_pulse_length = 300.0f / 1000000.0f; static constexpr float expected_gap_length = 1300.0f / 1000000.0f; - const auto pulse_time = pulse_time_.get(); + const auto pulse_time = pulse_time_.as(); if(pulse_time > expected_gap_length * 1.25f) { push_wave(WaveType::LongGap); diff --git a/Storage/TimedEventLoop.cpp b/Storage/TimedEventLoop.cpp index a1396b037..a5f4cae94 100644 --- a/Storage/TimedEventLoop.cpp +++ b/Storage/TimedEventLoop.cpp @@ -74,7 +74,7 @@ void TimedEventLoop::jump_to_next_event() { } void TimedEventLoop::set_next_event_time_interval(const Time interval) { - set_next_event_time_interval(interval.get()); + set_next_event_time_interval(interval.as()); } void TimedEventLoop::set_next_event_time_interval(const float interval) {