Skip to content

Commit

Permalink
Turn on the PPU to mimic CGB bootrom. (#149)
Browse files Browse the repository at this point in the history
Currently do it only for CGB mode when cgb enabled, mainly since some test roms are sensitive to timing.

In the future I want to mimic the bootroms behavior of both devices more accurately.
  • Loading branch information
alloncm authored Dec 14, 2024
1 parent 8037ae8 commit aad0702
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/src/mmu/gb_mmu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ impl<'a, D:AudioDevice, G:GfxDevice, J:JoypadProvider> GbMmu<'a, D, G, J>{
// Mimic the CGB bootrom behavior
if cgb_reg & BIT_7_MASK != 0{
mmu.write(KEY0_REGISTER_ADDRESS, cgb_reg, 0);

// Both bootroms leaves the PPU turned on, unfortunately turning it on for both modes makes some tests
// fail as they seem really sensitive to timing.
// Setting this only for CGB mode cgb enabled (mostly to make games the assumes the PPU is turned on to work).
// TODO: Turn on the PPU on both modes while preserving accurate timing.
mmu.write(LCDC_REGISTER_ADDRESS, 0x80, 0);
}
else{
mmu.write(KEY0_REGISTER_ADDRESS, 0x4, 0); // Set bit 2 that indicates DMG compatibility mode
Expand Down

0 comments on commit aad0702

Please sign in to comment.