From b65f833b284ee5ab301cd0e3b39fa6812c616e11 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Sat, 26 Feb 2022 18:33:16 -0600 Subject: [PATCH] feat(ppu): implement transparency + backdrop in mode 0 --- src/ppu.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ppu.zig b/src/ppu.zig index f842781..be7ddd9 100644 --- a/src/ppu.zig +++ b/src/ppu.zig @@ -115,7 +115,11 @@ pub const Ppu = struct { const pal_id = if (!is_8bpp) blk: { tile = if (col & 1 == 1) tile >> 4 else tile & 0xF; const pal_bank: u16 = @as(u8, entry.palette_bank.read()) << 4; - break :blk pal_bank | tile; + + // If Tile is 0 then we need to access the Backdrop + // The backdrop is the first colour in Palette RAM + // AFAIK there is no special logic needed for doing this in 8bpp + break :blk if (tile == 0) 0 else pal_bank | tile; } else tile; std.mem.copy(u8, scanline_buf[i * 2 ..][0..2], self.palette.buf[pal_id * 2 ..][0..2]);