Skip to content

Commit

Permalink
Clear VRAM after Boot ROM
Browse files Browse the repository at this point in the history
Fixes blank areas in some CGB Games
  • Loading branch information
IsaacMarovitz committed May 7, 2024
1 parent 0a56aa9 commit d4b5bac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/mmu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ impl Memory for MMU {
0xFF04..=0xFF07 => self.timer.write(a, v),
0xFF10..=0xFF3F => self.apu.write(a, v),
0xFF0F => self.intf = Interrupts::from_bits_truncate(v),
0xFF50 => self.boot_rom_enabled = false,
0xFF50 => {
self.boot_rom_enabled = false;
self.ppu.clear_vram();
},
// TODO: RP
0xFF56 => { },
0xFF51..=0xFF6F => self.ppu.write(a, v),
Expand Down
4 changes: 4 additions & 0 deletions src/components/ppu/ppu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ impl PPU {
}
}

pub fn clear_vram(&mut self) {
self.vram = [0; 0x4000];
}

fn read_vram(&self, a: u16, bank: usize) -> u8 {
self.vram[(bank * 0x2000) + a as usize - 0x8000]
}
Expand Down

0 comments on commit d4b5bac

Please sign in to comment.