diff --git a/Core/display.c b/Core/display.c index e0c1a53..c09764a 100644 --- a/Core/display.c +++ b/Core/display.c @@ -441,7 +441,6 @@ static void render_pixel_if_possible(GB_gameboy_t *gb) if (!gb->oam_fifo_paused && fifo_size(&gb->oam_fifo)) { oam_fifo_item = fifo_pop(&gb->oam_fifo); - /* Todo: Verify access timings */ if (oam_fifo_item->pixel && (gb->io_registers[GB_IO_LCDC] & 2)) { draw_oam = true; bg_priority |= oam_fifo_item->bg_priority; @@ -457,7 +456,6 @@ static void render_pixel_if_possible(GB_gameboy_t *gb) /* Mixing */ - /* Todo: Verify access timings */ if ((gb->io_registers[GB_IO_LCDC] & 0x1) == 0) { if (gb->cgb_mode) { bg_priority = false; diff --git a/Core/sm83_cpu.c b/Core/sm83_cpu.c index 5c491f8..53bca48 100644 --- a/Core/sm83_cpu.c +++ b/Core/sm83_cpu.c @@ -18,7 +18,7 @@ typedef enum { GB_CONFLICT_STAT_DMG, GB_CONFLICT_PALETTE_DMG, GB_CONFLICT_PALETTE_CGB, - GB_CONFLICT_READ_DMG_LCDC, + GB_CONFLICT_DMG_LCDC, } GB_conflict_t; /* Todo: How does double speed mode affect these? */ @@ -38,7 +38,7 @@ static const GB_conflict_t cgb_conflict_map[0x80] = { static const GB_conflict_t dmg_conflict_map[0x80] = { [GB_IO_IF] = GB_CONFLICT_WRITE_CPU, [GB_IO_LYC] = GB_CONFLICT_READ_OLD, - [GB_IO_LCDC] = GB_CONFLICT_READ_DMG_LCDC, + [GB_IO_LCDC] = GB_CONFLICT_DMG_LCDC, [GB_IO_SCY] = GB_CONFLICT_READ_NEW, [GB_IO_STAT] = GB_CONFLICT_STAT_DMG, @@ -194,10 +194,13 @@ static void cycle_write(GB_gameboy_t *gb, uint16_t addr, uint8_t value) return; } - case GB_CONFLICT_READ_DMG_LCDC: { + case GB_CONFLICT_DMG_LCDC: { /* Seems to be affected by screen? Both my DMG (B, blob) and Game Boy Light behave this way though. */ uint8_t old_value = GB_read_memory(gb, addr); GB_advance_cycles(gb, gb->pending_cycles - 2); + if (/* gb->model != GB_MODEL_MGB && */ gb->position_in_line == 0 && (old_value & 2) && !(value & 2)) { + old_value &= ~2; + } GB_write_memory(gb, addr, old_value | (value & 1)); GB_advance_cycles(gb, 1); GB_write_memory(gb, addr, value);