From cb64e0179468e303c7590d2ad24d6368bf6f91e0 Mon Sep 17 00:00:00 2001 From: Keny C Date: Sat, 6 Jan 2024 22:33:47 +0100 Subject: [PATCH] Fixed overflow panic Former-commit-id: 849c5917d53e91eecb3aaa7954f04362ae06b8cd Former-commit-id: 056dbfa5911d74fb1fa5d99cbe47a642cc4edbd9 --- core/src/gba.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/gba.rs b/core/src/gba.rs index 1a5af23..9d67b77 100644 --- a/core/src/gba.rs +++ b/core/src/gba.rs @@ -215,7 +215,7 @@ impl GameBoyAdvance { pub fn frame(&mut self) { static mut OVERSHOOT: usize = 0; unsafe { - OVERSHOOT = CYCLES_FULL_REFRESH - self.run::(CYCLES_FULL_REFRESH - OVERSHOOT); + OVERSHOOT = CYCLES_FULL_REFRESH.saturating_sub(self.run::(CYCLES_FULL_REFRESH - OVERSHOOT)); } } @@ -223,7 +223,7 @@ impl GameBoyAdvance { fn frame_interruptible(&mut self) { static mut OVERSHOOT: usize = 0; unsafe { - OVERSHOOT = CYCLES_FULL_REFRESH - self.run::(CYCLES_FULL_REFRESH - OVERSHOOT); + OVERSHOOT = CYCLES_FULL_REFRESH.saturating_sub(self.run::(CYCLES_FULL_REFRESH - OVERSHOOT)); } }