diff --git a/Core/display.c b/Core/display.c index aa6e681..30f5f63 100755 --- a/Core/display.c +++ b/Core/display.c @@ -299,11 +299,11 @@ static void update_display_state(GB_gameboy_t *gb, uint8_t cycles) for (; cycles; cycles -= atomic_increase) { gb->display_cycles += atomic_increase; - /* The very first line is 2 (4 from the CPU's perseptive) clocks shorter when the LCD turns on. - Todo: Verify on the 3 CGB modes, especially double speed mode. */ - if (gb->first_scanline && gb->display_cycles >= LINE_LENGTH - atomic_increase) { + /* The very first line is 4 clocks shorter when the LCD turns on. Verified on SGB2, CGB in CGB mode and + CGB in double speed mode. */ + if (gb->first_scanline && gb->display_cycles >= LINE_LENGTH - 4) { gb->first_scanline = false; - gb->display_cycles += atomic_increase; + gb->display_cycles += 4; } bool should_compare_ly = true; uint8_t ly_for_comparison = gb->io_registers[GB_IO_LY] = gb->display_cycles / LINE_LENGTH; diff --git a/Core/memory.c b/Core/memory.c index 8d34917..d8f7df7 100644 --- a/Core/memory.c +++ b/Core/memory.c @@ -454,8 +454,6 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value) case GB_IO_LCDC: if ((value & 0x80) && !(gb->io_registers[GB_IO_LCDC] & 0x80)) { - /* It appears that there's a slight delay after enabling the screen? */ - /* Todo: verify this. */ gb->display_cycles = 0; gb->first_scanline = true; if (gb->frame_skip_state == GB_FRAMESKIP_SECOND_FRAME_RENDERED) {