Skip to content

Commit 27d5653

Browse files
Keny Cmichelhe
authored andcommitted
Fixed overflow panic
1 parent 1dfdec3 commit 27d5653

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/gba.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,15 @@ impl GameBoyAdvance {
215215
pub fn frame(&mut self) {
216216
static mut OVERSHOOT: usize = 0;
217217
unsafe {
218-
OVERSHOOT = CYCLES_FULL_REFRESH - self.run::<false>(CYCLES_FULL_REFRESH - OVERSHOOT);
218+
OVERSHOOT = CYCLES_FULL_REFRESH.saturating_sub(self.run::<false>(CYCLES_FULL_REFRESH - OVERSHOOT));
219219
}
220220
}
221221

222222
/// like frame() but stop if a breakpoint is reached
223223
fn frame_interruptible(&mut self) {
224224
static mut OVERSHOOT: usize = 0;
225225
unsafe {
226-
OVERSHOOT = CYCLES_FULL_REFRESH - self.run::<true>(CYCLES_FULL_REFRESH - OVERSHOOT);
226+
OVERSHOOT = CYCLES_FULL_REFRESH.saturating_sub(self.run::<true>(CYCLES_FULL_REFRESH - OVERSHOOT));
227227
}
228228
}
229229

0 commit comments

Comments
 (0)