From bebb5c7a41bf50c1fde702d82a1c0405dfac82de Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 6 Aug 2016 18:58:44 +0300 Subject: [PATCH] Correctly emulating the unused OAM memory in DMG mode --- Core/memory.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Core/memory.c b/Core/memory.c index 28454dcf..77dbfb4c 100644 --- a/Core/memory.c +++ b/Core/memory.c @@ -114,11 +114,15 @@ static uint8_t read_high_memory(GB_gameboy_t *gb, uint16_t addr) } if (addr < 0xFF00) { - /* Unusable, simulate Gameboy Color */ + /* Unusable. CGB results are verified, but DMG results were tested on a SGB2 */ if ((gb->io_registers[GB_IO_STAT] & 0x3) >= 2) { /* Seems to be disabled in Modes 2 and 3 */ return 0xFF; } - return (addr & 0xF0) | ((addr >> 4) & 0xF); + if (gb->is_cgb) { + return (addr & 0xF0) | ((addr >> 4) & 0xF); + } + return 0; + } if (addr < 0xFF80) {