1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-28 09:54:49 +00:00

Correct envelope period for internal double-resolution.

This commit is contained in:
Thomas Harte 2024-02-24 15:16:33 -05:00
parent 4ac2baeb9d
commit c843c395ea

View File

@ -127,9 +127,9 @@ void AY38910SampleSource<is_stereo>::advance() {
// Update the noise generator. This recomputes the new bit repeatedly but harmlessly, only shifting // Update the noise generator. This recomputes the new bit repeatedly but harmlessly, only shifting
// it into the official 17 upon divider underflow. // it into the official 17 upon divider underflow.
if(noise_counter_) noise_counter_--; if(noise_counter_) --noise_counter_;
else { 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_output_ ^= noise_shift_register_&1;
noise_shift_register_ |= ((noise_shift_register_ ^ (noise_shift_register_ >> 3))&1) << 17; noise_shift_register_ |= ((noise_shift_register_ ^ (noise_shift_register_ >> 3))&1) << 17;
noise_shift_register_ >>= 1; noise_shift_register_ >>= 1;
@ -137,10 +137,10 @@ void AY38910SampleSource<is_stereo>::advance() {
// Update the envelope generator. Table based for pattern lookup, with a 'refill' step: a way of // 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. // implementing non-repeating patterns by locking them to the final table position.
if(envelope_divider_) envelope_divider_--; if(envelope_divider_) --envelope_divider_;
else { else {
envelope_divider_ = envelope_period_; envelope_divider_ = envelope_period_ << 1;
envelope_position_ ++; ++envelope_position_;
if(envelope_position_ == 64) envelope_position_ = envelope_overflow_masks_[output_registers_[13]]; if(envelope_position_ == 64) envelope_position_ = envelope_overflow_masks_[output_registers_[13]];
} }