Fixed a bug where skipping a sprite by modifying LCDC flags mid-scanline will disable sprites for the rest of the scalene.

This commit is contained in:
Lior Halphon 2018-04-05 00:51:37 +03:00
parent b1d65fd84f
commit d8e0683c35
1 changed files with 5 additions and 0 deletions

View File

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