Updated previous timing improvements to correctly implement double speed behavior

This commit is contained in:
Lior Halphon 2017-09-08 23:46:38 +03:00
parent e5d354e896
commit 742c9e95d3
1 changed files with 9 additions and 3 deletions

View File

@ -291,8 +291,14 @@ static void update_display_state(GB_gameboy_t *gb, uint8_t cycles)
these findings.
Todo: Investigate what causes the difference between our findings */
uint8_t stat_delay = gb->cgb_double_speed? 2 : 4; // (gb->cgb_mode? 0 : 4);
/* Todo: This is correct for DMG and single speed CGB. Is it correct for double speed and DMG mode CGB?*/
uint8_t scx_delay = (gb->effective_scx + (gb->first_scanline ? 2 : 0)) & (gb->cgb_double_speed? ~1 : ~3);
/* Todo: Is this correct for DMG mode CGB? */
uint8_t scx_delay = gb->effective_scx;
if (gb->cgb_double_speed) {
scx_delay = (scx_delay + 1) & ~1;
}
else {
scx_delay = (scx_delay + (gb->first_scanline ? 2 : 0)) & ~3;
}
/* Todo: These are correct for DMG, DMG-mode CGB, and single speed CGB. Is is correct for double speed CGB? */
uint8_t oam_blocking_rush = gb->cgb_double_speed? 2 : 4;
@ -544,7 +550,7 @@ static void update_display_state(GB_gameboy_t *gb, uint8_t cycles)
switch (gb->io_registers[GB_IO_STAT] & 3) {
case 0:
gb->stat_interrupt_line = (gb->io_registers[GB_IO_STAT] & 8);
if (just_entered_hblank && ((gb->effective_scx + (gb->first_scanline ? 2 : 0)) & 3) == 3) {
if (!gb->cgb_double_speed && just_entered_hblank && ((gb->effective_scx + (gb->first_scanline ? 2 : 0)) & 3) == 3) {
gb->stat_interrupt_line = false;
}
break;