Oops, I broke the window

This commit is contained in:
Lior Halphon 2022-05-09 00:43:49 +03:00
parent 6337e3e43a
commit cb73e0b91a

View File

@ -19,6 +19,7 @@ static void fifo_clear(GB_fifo_t *fifo)
static GB_fifo_item_t *fifo_pop(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]; GB_fifo_item_t *ret = &fifo->fifo[fifo->read_end];
fifo->read_end++; fifo->read_end++;
fifo->read_end &= (GB_FIFO_LENGTH - 1); 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 draw_oam = false;
bool bg_enabled = true, bg_priority = 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); fifo_item = fifo_pop(&gb->bg_fifo);
bg_priority = fifo_item->bg_priority; bg_priority = fifo_item->bg_priority;