From c6a544a824a5f8c55003d24ded005580224bf716 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:12:25 -0300 Subject: [PATCH] feat: fix tile flipping issue --- src/ppu.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ppu.zig b/src/ppu.zig index 6c8784c..d85756d 100644 --- a/src/ppu.zig +++ b/src/ppu.zig @@ -102,13 +102,13 @@ pub const Ppu = struct { // Calculate the Address of the Tile in the designated Charblock // We also take this opportunity to flip tiles if necessary const tile_id: u32 = entry.tile_id.read(); - const row = if (entry.h_flip.read()) 7 - (y % 8) else y % 8; // Determine on which row in a tile we're on + const row = if (entry.v_flip.read()) 7 - (y % 8) else y % 8; // Determine on which row in a tile we're on const tile_addr = char_base + (tile_len * tile_id) + (tile_row_offset * row); // Calculate on which column in a tile we're on // Similarly to when we calculated the row, if we're in 4bpp we want to account // for 1 byte consisting of two pixels - const col = if (entry.v_flip.read()) 7 - (x % 8) else x % 8; + const col = if (entry.h_flip.read()) 7 - (x % 8) else x % 8; const tile = self.vram.buf[tile_addr + if (is_8bpp) col else col / 2]; // If we're in 8bpp, then the tile value is an index into the palette,