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

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-10-21 05:12:23 -03:00
parent 4885a86833
commit 6d253cc74e
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: { const pal_id = if (!is_8bpp) blk: {
tile = if (col & 1 == 1) tile >> 4 else tile & 0xF; tile = if (col & 1 == 1) tile >> 4 else tile & 0xF;
const pal_bank: u16 = @as(u8, entry.palette_bank.read()) << 4; 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; } else tile;
std.mem.copy(u8, scanline_buf[i * 2 ..][0..2], self.palette.buf[pal_id * 2 ..][0..2]); std.mem.copy(u8, scanline_buf[i * 2 ..][0..2], self.palette.buf[pal_id * 2 ..][0..2]);