From e704c9b913cd462ab57370bfe80fdffa8ed60ace Mon Sep 17 00:00:00 2001 From: kub Date: Mon, 28 Jun 2021 21:43:35 +0200 Subject: [PATCH] 32x, fix comm sync (68k writing to comm area) --- pico/32x/memory.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pico/32x/memory.c b/pico/32x/memory.c index 5bac31b8..ac26ba4b 100644 --- a/pico/32x/memory.c +++ b/pico/32x/memory.c @@ -511,16 +511,17 @@ static void p32x_reg_write8(u32 a, u32 d) case 0x2d: case 0x2e: case 0x2f: - if (REG8IN16(r, a) != (u8)d) { - unsigned int cycles = SekCyclesDone(); + { unsigned int cycles = SekCyclesDone(); if (CYCLES_GT(cycles - msh2.m68krcycles_done, 64)) p32x_sync_sh2s(cycles); - REG8IN16(r, a) = d; - p32x_sh2_poll_event(&sh2s[0], SH2_STATE_CPOLL, cycles); - p32x_sh2_poll_event(&sh2s[1], SH2_STATE_CPOLL, cycles); - sh2_poll_write(a & ~1, r[a / 2], cycles, NULL); + if (REG8IN16(r, a) != (u8)d) { + REG8IN16(r, a) = d; + p32x_sh2_poll_event(&sh2s[0], SH2_STATE_CPOLL, cycles); + p32x_sh2_poll_event(&sh2s[1], SH2_STATE_CPOLL, cycles); + sh2_poll_write(a & ~1, r[a / 2], cycles, NULL); + } } return; case 0x30: @@ -608,16 +609,17 @@ static void p32x_reg_write16(u32 a, u32 d) case 0x2a/2: case 0x2c/2: case 0x2e/2: - if (r[a / 2] != (u16)d) { - unsigned int cycles = SekCyclesDone(); + { unsigned int cycles = SekCyclesDone(); if (CYCLES_GT(cycles - msh2.m68krcycles_done, 64)) p32x_sync_sh2s(cycles); - r[a / 2] = d; - p32x_sh2_poll_event(&sh2s[0], SH2_STATE_CPOLL, cycles); - p32x_sh2_poll_event(&sh2s[1], SH2_STATE_CPOLL, cycles); - sh2_poll_write(a, (u16)d, cycles, NULL); + if (r[a / 2] != (u16)d) { + r[a / 2] = d; + p32x_sh2_poll_event(&sh2s[0], SH2_STATE_CPOLL, cycles); + p32x_sh2_poll_event(&sh2s[1], SH2_STATE_CPOLL, cycles); + sh2_poll_write(a, (u16)d, cycles, NULL); + } } return; case 0x30/2: // PWM control -- 2.39.5