Refined the STAT bug behavior. Still not perfect.

This commit is contained in:
Lior Halphon 2018-05-26 17:06:49 +03:00
parent 855ffb490a
commit 9693b2de6a
2 changed files with 7 additions and 3 deletions

View File

@ -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);

View File

@ -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 */