Window Y still advances if WX=166
@@ -1037,19 +1037,21 @@ abort_fetching_object:
/* Handle window */
/* Todo: verify timings */
if (!gb->wx_triggered && gb->wy_triggered && (gb->io_registers[GB_IO_LCDC] & 0x20)) {
- if (gb->io_registers[GB_IO_WX] >= 166) {
+ if (gb->io_registers[GB_IO_WX] >= 167) {
// Too late to enable the window
}
else if (gb->io_registers[GB_IO_WX] == (uint8_t) (gb->position_in_line + 7) ||
gb->io_registers[GB_IO_WX] == (uint8_t) (gb->position_in_line + 6)) {
- gb->wx_triggered = true;
gb->window_y++;
+ if (gb->io_registers[GB_IO_WX] != 166) {
+ gb->wx_triggered = true;
fifo_clear(&gb->bg_fifo);
gb->bg_fifo_paused = true;
gb->oam_fifo_paused = true;
gb->fetcher_state = 1;
}
}
+ }
render_pixel_if_possible(gb);
advance_fetcher_state_machine(gb);
