diff --git a/Core/display.c b/Core/display.c index 3ebf48d..eb92cb0 100644 --- a/Core/display.c +++ b/Core/display.c @@ -610,6 +610,7 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles) gb->vram_read_blocked = true; gb->vram_write_blocked = true; + /* TODO: How does the window affect this line? */ gb->cycles_for_line += MODE3_LENGTH + (gb->io_registers[GB_IO_SCX] & 7) - 2; GB_SLEEP(gb, display, 3, MODE3_LENGTH + (gb->io_registers[GB_IO_SCX] & 7) - 2); diff --git a/Core/memory.c b/Core/memory.c index 254417c..1cb2eb9 100644 --- a/Core/memory.c +++ b/Core/memory.c @@ -665,9 +665,12 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value) case GB_IO_STAT: /* A DMG bug: http://www.devrs.com/gb/files/faqs.html#GBBugs */ - /* TODO: Confirm gb->mode_0_interrupt_disable usage */ - if (!gb->is_cgb && !gb->stat_interrupt_line && !gb->mode_0_interrupt_disable && - (gb->io_registers[GB_IO_STAT] & 0x3) < 2 && (gb->io_registers[GB_IO_LCDC] & 0x80)) { + if (!gb->is_cgb && /* Only occurs on DMGs */ + (gb->io_registers[GB_IO_LCDC] & 0x80) && /* LCD must be on */ + !gb->stat_interrupt_line && /* The interrupt line must be off */ + gb->display_state != 2 && /* State 2 is line 0's faux Mode 2 */ + !gb->oam_read_blocked /* OAM must be readable (Modes 0 and 1) */ + ) { gb->io_registers[GB_IO_IF] |= 2; } /* Delete previous R/W bits */