From ad7a2ae903c18424b1d2d7b6de50f72f690864f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Tue, 5 Jul 2022 18:32:01 +0100
Subject: [PATCH] fix: small fixes

---
 examples/sdl/src/main.rs | 6 ++++++
 src/cpu.rs               | 7 +++++++
 src/ppu.rs               | 3 ++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/examples/sdl/src/main.rs b/examples/sdl/src/main.rs
index e2de571c..ff54cf48 100644
--- a/examples/sdl/src/main.rs
+++ b/examples/sdl/src/main.rs
@@ -100,7 +100,13 @@ fn main() {
     //game_boy.load_rom_file("../../res/roms/paradius/cpu/09-op r,r.gb"); // NO FINISH
     //game_boy.load_rom_file("../../res/roms/paradius/cpu/11-op a,(hl).gb"); // NO FINISH
 
+    let mut counter = 0u32;
+
     'main: loop {
+        // increments the counter that will keep track
+        // on the number of visual ticks since beginning
+        counter = counter.wrapping_add(1);
+
         while let Some(event) = graphics.event_pump.poll_event() {
             match event {
                 Event::Quit { .. } => break 'main,
diff --git a/src/cpu.rs b/src/cpu.rs
index 794c1364..e7f879ab 100644
--- a/src/cpu.rs
+++ b/src/cpu.rs
@@ -101,6 +101,13 @@ impl Cpu {
                 self.push_word(pc);
                 self.pc = 0x40;
                 self.mmu.ppu().ack_vblank();
+
+                // in case the CPU is currently halted waiting
+                // for an interrupt, releases it
+                if self.halted {
+                    self.halted = false;
+                }
+
                 return 16;
             }
         }
diff --git a/src/ppu.rs b/src/ppu.rs
index a42bd364..d4f9ec4a 100644
--- a/src/ppu.rs
+++ b/src/ppu.rs
@@ -77,7 +77,8 @@ pub struct Ppu {
     /// Defines the size in pixels of the object (false=8x8, true=8x16).
     obj_size: bool,
     /// Controls the map that is going to be drawn to screen, the
-    /// offset in VRAM will be adjusted according to this.
+    /// offset in VRAM will be adjusted according to this
+    /// (false=0x9800, true=0x9c000).
     bg_map: bool,
     /// If the background tile set is active meaning that the
     /// negative based indexes are going to be used.
-- 
GitLab