From de085fc1ff3d0ac242002a225adb26fc11df98ab Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Tue, 18 Jul 2023 20:23:11 +0100 Subject: [PATCH] Use wrapping add and mul --- agb/src/sound/mixer/sw_mixer.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/agb/src/sound/mixer/sw_mixer.rs b/agb/src/sound/mixer/sw_mixer.rs index 0e71faeb..f7f64d39 100644 --- a/agb/src/sound/mixer/sw_mixer.rs +++ b/agb/src/sound/mixer/sw_mixer.rs @@ -496,7 +496,10 @@ impl MixerBuffer { unsafe { *channel.data.get_unchecked(channel.pos.floor() as usize) } as i8 as i32; // SAFETY: working buffer length = self.frequency.buffer_size() - unsafe { *working_buffer_i32.get_unchecked_mut(i) += value * mul_amount }; + unsafe { + let value_ref = working_buffer_i32.get_unchecked_mut(i); + *value_ref = value_ref.wrapping_add(value.wrapping_mul(mul_amount)); + }; channel.pos += playback_speed; } }