diff --git a/lib/src/processor/memory/mmio/apu/channels.rs b/lib/src/processor/memory/mmio/apu/channels.rs index fea2095..7d2ecd3 100644 --- a/lib/src/processor/memory/mmio/apu/channels.rs +++ b/lib/src/processor/memory/mmio/apu/channels.rs @@ -217,7 +217,7 @@ impl PwmChannel { pub(super) fn length_tick(&mut self) { if self.length_enable { - self.length_timer += 1; + self.length_timer = self.length_timer.saturating_add(1); if self.length_timer >= 64 { self.enabled = false; } @@ -502,7 +502,7 @@ impl Lfsr { } fn tick(&mut self) { - self.timer += 1; + self.timer = self.timer.saturating_add(1); if self.timer > self.interval { self.timer = 0; self.next_value(); @@ -598,7 +598,7 @@ impl NoiseChannel { pub(super) fn length_tick(&mut self) { if self.length_enable { - self.length_timer += 1; + self.length_timer = self.length_timer.saturating_add(1); if self.length_timer >= 64 { self.enabled = false; }