Move improvements to LCDC conflicts

This commit is contained in:
Lior Halphon 2020-02-21 14:22:25 +02:00
parent a8f63aea3c
commit 56118d2a67
2 changed files with 6 additions and 5 deletions

View File

@ -441,7 +441,6 @@ static void render_pixel_if_possible(GB_gameboy_t *gb)
if (!gb->oam_fifo_paused && fifo_size(&gb->oam_fifo)) { if (!gb->oam_fifo_paused && fifo_size(&gb->oam_fifo)) {
oam_fifo_item = fifo_pop(&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)) { if (oam_fifo_item->pixel && (gb->io_registers[GB_IO_LCDC] & 2)) {
draw_oam = true; draw_oam = true;
bg_priority |= oam_fifo_item->bg_priority; bg_priority |= oam_fifo_item->bg_priority;
@ -457,7 +456,6 @@ static void render_pixel_if_possible(GB_gameboy_t *gb)
/* Mixing */ /* Mixing */
/* Todo: Verify access timings */
if ((gb->io_registers[GB_IO_LCDC] & 0x1) == 0) { if ((gb->io_registers[GB_IO_LCDC] & 0x1) == 0) {
if (gb->cgb_mode) { if (gb->cgb_mode) {
bg_priority = false; bg_priority = false;

View File

@ -18,7 +18,7 @@ typedef enum {
GB_CONFLICT_STAT_DMG, GB_CONFLICT_STAT_DMG,
GB_CONFLICT_PALETTE_DMG, GB_CONFLICT_PALETTE_DMG,
GB_CONFLICT_PALETTE_CGB, GB_CONFLICT_PALETTE_CGB,
GB_CONFLICT_READ_DMG_LCDC, GB_CONFLICT_DMG_LCDC,
} GB_conflict_t; } GB_conflict_t;
/* Todo: How does double speed mode affect these? */ /* 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] = { static const GB_conflict_t dmg_conflict_map[0x80] = {
[GB_IO_IF] = GB_CONFLICT_WRITE_CPU, [GB_IO_IF] = GB_CONFLICT_WRITE_CPU,
[GB_IO_LYC] = GB_CONFLICT_READ_OLD, [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_SCY] = GB_CONFLICT_READ_NEW,
[GB_IO_STAT] = GB_CONFLICT_STAT_DMG, [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; 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. */ /* 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); uint8_t old_value = GB_read_memory(gb, addr);
GB_advance_cycles(gb, gb->pending_cycles - 2); 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_write_memory(gb, addr, old_value | (value & 1));
GB_advance_cycles(gb, 1); GB_advance_cycles(gb, 1);
GB_write_memory(gb, addr, value); GB_write_memory(gb, addr, value);