From 1804a57d08dd993a84ce35dd5f288e947a218e73 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Sun, 10 Jul 2022 17:04:50 +0100
Subject: [PATCH] fix: issue in timer where the clock handles large
 instructions values

---
 src/timer.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/timer.rs b/src/timer.rs
index 2e4bb38a..23463381 100644
--- a/src/timer.rs
+++ b/src/timer.rs
@@ -29,14 +29,14 @@ impl Timer {
 
     pub fn clock(&mut self, cycles: u8) {
         self.div_clock += cycles as u16;
-        if self.div_clock >= 256 {
+        while self.div_clock >= 256 {
             self.div = self.div.wrapping_add(1);
             self.div_clock -= 256;
         }
 
         if self.tima_enabled {
             self.tima_clock += cycles as u16;
-            if self.tima_clock >= self.tima_ratio {
+            while self.tima_clock >= self.tima_ratio {
                 if self.tima == 0xff {
                     self.int_tima = true;
                     self.tima = self.tma;
-- 
GitLab