From 279ffb1a7f97e130fb0df6170eefa80bc4769969 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Sun, 19 Mar 2023 10:23:55 +1100 Subject: [PATCH] some overflows in debug mode --- lib/src/processor/memory/mmio/apu/channels.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; }