diff --git a/Core/display.c b/Core/display.c index fcaaee4..bb59ff8 100644 --- a/Core/display.c +++ b/Core/display.c @@ -19,6 +19,7 @@ static void fifo_clear(GB_fifo_t *fifo) static GB_fifo_item_t *fifo_pop(GB_fifo_t *fifo) { + assert(fifo->size); GB_fifo_item_t *ret = &fifo->fifo[fifo->read_end]; fifo->read_end++; fifo->read_end &= (GB_FIFO_LENGTH - 1); @@ -553,6 +554,8 @@ static void render_pixel_if_possible(GB_gameboy_t *gb) bool draw_oam = false; bool bg_enabled = true, bg_priority = false; + if (unlikely(gb->wx_triggered && !fifo_size(&gb->bg_fifo))) return; + fifo_item = fifo_pop(&gb->bg_fifo); bg_priority = fifo_item->bg_priority;