diff --git a/Core/memory.c b/Core/memory.c index 43a9dde..ea9152f 100644 --- a/Core/memory.c +++ b/Core/memory.c @@ -434,7 +434,9 @@ static uint8_t read_high_memory(GB_gameboy_t *gb, uint16_t addr) if (addr < 0xFF00) { if (gb->oam_write_blocked && !GB_is_cgb(gb)) { - GB_trigger_oam_bug_read(gb, addr); + if (!gb->disable_oam_corruption) { + GB_trigger_oam_bug_read(gb, addr); + } return 0xff; } @@ -705,6 +707,9 @@ uint8_t GB_read_memory(GB_gameboy_t *gb, uint16_t addr) uint8_t GB_safe_read_memory(GB_gameboy_t *gb, uint16_t addr) { + if (unlikely(addr == 0xFF00 + GB_IO_JOYP)) { + return gb->io_registers[GB_IO_JOYP]; + } gb->disable_oam_corruption = true; uint8_t data = read_map[addr >> 12](gb, addr); gb->disable_oam_corruption = false;