From e6b9eb0491b2436b63d71564f59119e9b0b86803 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Sat, 2 Jul 2022 12:43:12 +0100
Subject: [PATCH] fix: issues related with height

---
 examples/sdl/src/main.rs | 1 +
 src/ppu.rs               | 7 ++++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/examples/sdl/src/main.rs b/examples/sdl/src/main.rs
index 011e83f9..6aa5f707 100644
--- a/examples/sdl/src/main.rs
+++ b/examples/sdl/src/main.rs
@@ -112,6 +112,7 @@ fn main() {
         // information presented to the user
         canvas.present();
 
+        // @todo this must be improved with proper timestamps
         graphics.timer_subsystem.delay(17);
     }
 }
diff --git a/src/ppu.rs b/src/ppu.rs
index 07e1aae1..0b321b17 100644
--- a/src/ppu.rs
+++ b/src/ppu.rs
@@ -11,7 +11,7 @@ pub const TILE_COUNT: usize = 384;
 pub const DISPLAY_WIDTH: usize = 160;
 
 /// The height of the Game Boy screen in pixels.
-pub const DISPLAY_HEIGHT: usize = 154;
+pub const DISPLAY_HEIGHT: usize = 144;
 
 // The size of the RGB frame buffer in bytes.
 pub const FRAME_BUFFER_SIZE: usize = DISPLAY_WIDTH * DISPLAY_HEIGHT * RGB_SIZE;
@@ -124,7 +124,7 @@ impl Ppu {
 
                     // in case we've reached the end of the
                     // screen we're now entering the v-blank
-                    if self.line == 143 {
+                    if self.line == 144 {
                         self.mode = PpuMode::VBlank;
                         // self.drawData
                         // @todo implement this one
@@ -142,7 +142,7 @@ impl Ppu {
                     // in case the end of v-blank has been reached then
                     // we must jump again to the OAM read mode and reset
                     // the scan line counter to the zero value
-                    if self.line == 153 {
+                    if self.line == 154 {
                         self.mode = PpuMode::OamRead;
                         self.line = 0;
                     }
@@ -246,6 +246,7 @@ impl Ppu {
         // Game Boy screen width and RGB pixel (3 bytes) size
         let mut frame_offset = self.line as usize * DISPLAY_WIDTH * RGB_SIZE;
 
+
         for _index in 0..DISPLAY_WIDTH {
             // obtains the current pixel data from the tile and
             // re-maps it according to the current palette
-- 
GitLab