From c843c395eaa4f58b5fd1821121037bcbc236d393 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 24 Feb 2024 15:16:33 -0500 Subject: [PATCH] Correct envelope period for internal double-resolution. --- Components/AY38910/AY38910.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Components/AY38910/AY38910.cpp b/Components/AY38910/AY38910.cpp index 625ffb6d0..434f04146 100644 --- a/Components/AY38910/AY38910.cpp +++ b/Components/AY38910/AY38910.cpp @@ -127,9 +127,9 @@ void AY38910SampleSource::advance() { // Update the noise generator. This recomputes the new bit repeatedly but harmlessly, only shifting // it into the official 17 upon divider underflow. - if(noise_counter_) noise_counter_--; + if(noise_counter_) --noise_counter_; else { - noise_counter_ = noise_period_ << 1; // To cover the double resolution of envelopes. + noise_counter_ = noise_period_ << 1; // To cover the double resolution of envelopes. noise_output_ ^= noise_shift_register_&1; noise_shift_register_ |= ((noise_shift_register_ ^ (noise_shift_register_ >> 3))&1) << 17; noise_shift_register_ >>= 1; @@ -137,10 +137,10 @@ void AY38910SampleSource::advance() { // Update the envelope generator. Table based for pattern lookup, with a 'refill' step: a way of // implementing non-repeating patterns by locking them to the final table position. - if(envelope_divider_) envelope_divider_--; + if(envelope_divider_) --envelope_divider_; else { - envelope_divider_ = envelope_period_; - envelope_position_ ++; + envelope_divider_ = envelope_period_ << 1; + ++envelope_position_; if(envelope_position_ == 64) envelope_position_ = envelope_overflow_masks_[output_registers_[13]]; }