feat(ppu): implement transparency + backdrop in mode 0

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-02-26 18:33:16 -06:00
parent ac0486be1b
commit b65f833b28
1 changed files with 5 additions and 1 deletions

View File

@ -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]);