Fixes to safe reads, closes
@@ -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)) {
+ 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;
