From 4e3928df81652278a1f8623a888ba52c2669d60b Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 23 Mar 2018 20:01:27 +0300 Subject: [PATCH] =?UTF-8?q?Turns=20out=20the=20behavior=20differs=20betwee?= =?UTF-8?q?n=20DMG=20and=20CGB=20=E2=80=93=20in=20DMG=20mode,=20the=20obje?= =?UTF-8?q?cts=20enabled=20bit=20is=20checked=20before=20halting=20the=20F?= =?UTF-8?q?IFOs,=20meaning=20that=20disabled=20sprites=20do=20not=20affect?= =?UTF-8?q?=20Mode=203=E2=80=99s=20length=20on=20the=20DMG.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/display.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Core/display.c b/Core/display.c index 2eb758d..f95a252 100755 --- a/Core/display.c +++ b/Core/display.c @@ -536,7 +536,10 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles) gb->in_window = false; while (true) { /* 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->io_registers[GB_IO_LCDC] & 2 || gb->is_cgb) && objects[gb->visible_objs[gb->n_visible_objs - 1]].x == (uint8_t)(gb->position_in_line + 8)) { if (!gb->fetching_objects) {