From 18206718e35a7d94a59af06956072d4be3da17be Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Mon, 8 Jul 2024 00:18:27 +0300 Subject: [PATCH] Adjustment to SCX's write conflict implementation --- Core/sm83_cpu.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Core/sm83_cpu.c b/Core/sm83_cpu.c index bde385359..5272cc696 100644 --- a/Core/sm83_cpu.c +++ b/Core/sm83_cpu.c @@ -22,10 +22,10 @@ typedef enum { GB_CONFLICT_SGB_LCDC, GB_CONFLICT_WX, GB_CONFLICT_LCDC_CGB, - GB_CONFLICT_SCX_CGB, GB_CONFLICT_LCDC_CGB_DOUBLE, GB_CONFLICT_STAT_CGB_DOUBLE, GB_CONFLICT_NR10_CGB_DOUBLE, + GB_CONFLICT_SCX_CGB_DOUBLE, } conflict_t; static const conflict_t cgb_conflict_map[0x80] = { @@ -36,7 +36,7 @@ static const conflict_t cgb_conflict_map[0x80] = { [GB_IO_BGP] = GB_CONFLICT_PALETTE_CGB, [GB_IO_OBP0] = GB_CONFLICT_PALETTE_CGB, [GB_IO_OBP1] = GB_CONFLICT_PALETTE_CGB, - [GB_IO_SCX] = GB_CONFLICT_SCX_CGB, + [GB_IO_SCX] = GB_CONFLICT_READ_OLD, }; static const conflict_t cgb_double_conflict_map[0x80] = { @@ -45,7 +45,7 @@ static const conflict_t cgb_double_conflict_map[0x80] = { [GB_IO_LYC] = GB_CONFLICT_READ_OLD, [GB_IO_STAT] = GB_CONFLICT_STAT_CGB_DOUBLE, [GB_IO_NR10] = GB_CONFLICT_NR10_CGB_DOUBLE, - [GB_IO_SCX] = GB_CONFLICT_SCX_CGB, + [GB_IO_SCX] = GB_CONFLICT_SCX_CGB_DOUBLE, }; /* Todo: verify on an MGB */ @@ -308,17 +308,10 @@ static void cycle_write(GB_gameboy_t *gb, uint16_t addr, uint8_t value) break; } - case GB_CONFLICT_SCX_CGB: - if (gb->cgb_double_speed) { - GB_advance_cycles(gb, gb->pending_cycles - 2); - GB_write_memory(gb, addr, value); - gb->pending_cycles = 6; - } - else { - GB_advance_cycles(gb, gb->pending_cycles); - GB_write_memory(gb, addr, value); - gb->pending_cycles = 4; - } + case GB_CONFLICT_SCX_CGB_DOUBLE: + GB_advance_cycles(gb, gb->pending_cycles - 2); + GB_write_memory(gb, addr, value); + gb->pending_cycles = 6; break; case GB_CONFLICT_NR10_CGB_DOUBLE: {