Fixed a bug in scx_delay’s calculation

This commit is contained in:
Lior Halphon 2017-09-11 23:56:35 +03:00
parent 14f267b4fa
commit 09b7e2fff4
1 changed files with 3 additions and 3 deletions

View File

@ -292,12 +292,12 @@ static void update_display_state(GB_gameboy_t *gb, uint8_t cycles)
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: Is this correct for DMG mode CGB? */
uint8_t scx_delay = gb->effective_scx;
uint8_t scx_delay = gb->effective_scx & 7;
if (gb->cgb_double_speed) {
scx_delay = (scx_delay + 1) & ~1 & 7;
scx_delay = (scx_delay + 1) & ~1;
}
else {
scx_delay = (scx_delay + (gb->first_scanline ? 2 : 0)) & ~3 & 7;
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? */