diff --git a/Core/display.c b/Core/display.c index 94d7f77b..2eb8c424 100644 --- a/Core/display.c +++ b/Core/display.c @@ -128,7 +128,7 @@ static void display_vblank(GB_gameboy_t *gb) bool is_ppu_stopped = !GB_is_cgb(gb) && gb->stopped && gb->io_registers[GB_IO_LCDC] & 0x80; - if (!gb->disable_rendering && ((!(gb->io_registers[GB_IO_LCDC] & 0x80) || is_ppu_stopped) || gb->frame_skip_state == GB_FRAMESKIP_LCD_TURNED_ON)) { + if (!gb->disable_rendering && ((!(gb->io_registers[GB_IO_LCDC] & 0x80) || is_ppu_stopped) || gb->cgb_repeated_a_frame)) { /* LCD is off, set screen to white or black (if LCD is on in stop mode) */ if (!GB_is_sgb(gb)) { uint32_t color = 0; @@ -796,6 +796,7 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles) while (true) { GB_SLEEP(gb, display, 1, LCDC_PERIOD); display_vblank(gb); + gb->cgb_repeated_a_frame = true; } return; } @@ -1240,11 +1241,17 @@ abort_fetching_object: } } else { - gb->frame_skip_state = GB_FRAMESKIP_SECOND_FRAME_RENDERED; if (!GB_is_sgb(gb) || gb->current_lcd_line < LINES) { gb->is_odd_frame ^= true; display_vblank(gb); } + if (gb->frame_skip_state == GB_FRAMESKIP_FIRST_FRAME_SKIPPED) { + gb->cgb_repeated_a_frame = true; + gb->frame_skip_state = GB_FRAMESKIP_SECOND_FRAME_RENDERED; + } + else { + gb->cgb_repeated_a_frame = false; + } } } diff --git a/Core/gb.h b/Core/gb.h index 68c4ea9b..1376a12d 100644 --- a/Core/gb.h +++ b/Core/gb.h @@ -540,6 +540,7 @@ struct GB_gameboy_internal_s { bool is_odd_frame; uint16_t last_tile_data_address; uint16_t last_tile_index_address; + bool cgb_repeated_a_frame; ); /* Unsaved data. This includes all pointers, as well as everything that shouldn't be on a save state */