From 22ee6f6ca2b78fe313ab962a3ef98c3264c24f3d Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Wed, 31 May 2017 23:58:14 +0300 Subject: [PATCH] =?UTF-8?q?Fixed=20incorrect=20calculation=20in=20renderin?= =?UTF-8?q?g=20timing.=20Fixes=20some=20of=20the=20issues=20in=20Prehistor?= =?UTF-8?q?ik=20Man=20(and=20doesn=E2=80=99t=20break=20GBVideoPlayer)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/display.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Core/display.c b/Core/display.c index 63847da..94a73b4 100755 --- a/Core/display.c +++ b/Core/display.c @@ -508,7 +508,8 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles) /* Render */ - int16_t current_lcdc_x = ((gb->display_cycles % LINE_LENGTH - MODE2_LENGTH) & ~7) - (gb->effective_scx & 0x7); + /* Todo: it appears that the actual rendering starts 4 cycles after mode 3 starts. Is this correct? */ + int16_t current_lcdc_x = gb->display_cycles % LINE_LENGTH - MODE2_LENGTH - (gb->effective_scx & 0x7) - 4; for (;gb->previous_lcdc_x < current_lcdc_x; gb->previous_lcdc_x++) { if (gb->previous_lcdc_x >= WIDTH) {