From d8e0683c3597f3f1fede037e471d6f126e54e104 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Thu, 5 Apr 2018 00:51:37 +0300 Subject: [PATCH] Fixed a bug where skipping a sprite by modifying LCDC flags mid-scanline will disable sprites for the rest of the scalene. --- Core/display.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Core/display.c b/Core/display.c index 7d71d1b..fbdc23b 100644 --- a/Core/display.c +++ b/Core/display.c @@ -572,6 +572,11 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles) /* Handle objects */ /* When the sprite enabled bit is off, this proccess is skipped entirely on the DMG, but not on the CGB. On the CGB, this bit is checked only when the pixel is actually popped from the FIFO. */ + + while (gb->n_visible_objs != 0 && + gb->obj_comperators[gb->n_visible_objs - 1] < (uint8_t)(gb->position_in_line + 8)) { + gb->n_visible_objs--; + } while (gb->n_visible_objs != 0 && (gb->io_registers[GB_IO_LCDC] & 2 || gb->is_cgb) && gb->obj_comperators[gb->n_visible_objs - 1] == (uint8_t)(gb->position_in_line + 8)) {