diff --git a/CHANGES b/CHANGES index 0db36e95a..a597206d0 100644 --- a/CHANGES +++ b/CHANGES @@ -18,6 +18,7 @@ Features: Emulation fixes: - ARM: Add framework for coprocessor support - GB Memory: Initialize HRAM when skipping BIOS in GBC mode (fixes mgba.io/i/3420) + - GB Memory: Fix initial WRAM pattern when skipping BIOS in GBC mode (fixes mgba.io/i/2704) - GB Serialize: Add missing Pocket Cam state to savestates - GB Video: Implement DMG-style sprite ordering - GB Video: Fix window enable edge case (fixes mgba.io/i/2640) diff --git a/src/gb/memory.c b/src/gb/memory.c index 16cb43148..f2bfa17a4 100644 --- a/src/gb/memory.c +++ b/src/gb/memory.c @@ -184,7 +184,18 @@ void GBMemoryReset(struct GB* gb) { uint32_t* base = (uint32_t*) gb->memory.wram; size_t i; uint32_t pattern = 0; + // Banks 0, 1, 3, 6, and 7 are cleared with this pattern for (i = 0; i < GB_SIZE_WORKING_RAM / 4; i += 4) { + if ((i & 0x1FFF) == 0x800) { + // Skip bank 2 + i += 0x3FC; + continue; + } + if ((i & 0x1FFF) == 0x1000) { + // Skip banks 5 and 5 + i += 0x7FC; + continue; + } if ((i & 0x1FF) == 0) { pattern = ~pattern; }