From 4af2edc365222c3cfc8a511b9be71405310b41ea Mon Sep 17 00:00:00 2001 From: kub Date: Sun, 2 Jun 2024 07:53:04 +0000 Subject: [PATCH] 32x, fixes for comparing cycles --- cpu/sh2/sh2.h | 2 +- pico/32x/32x.c | 4 ++-- pico/32x/memory.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cpu/sh2/sh2.h b/cpu/sh2/sh2.h index bb8debe0..95c5658f 100644 --- a/cpu/sh2/sh2.h +++ b/cpu/sh2/sh2.h @@ -54,7 +54,7 @@ typedef struct SH2_ #define SH2_IN_DRC (1 << 7) // DRC in use unsigned int state; uint32_t poll_addr; - int poll_cycles; + unsigned int poll_cycles; int poll_cnt; // NB MUST be a bit unused in SH2 SR, see also cpu/sh2/compiler.c! #define SH2_NO_POLLING (1 << 10) // poll detection control diff --git a/pico/32x/32x.c b/pico/32x/32x.c index 6e2cb4bc..00239a11 100644 --- a/pico/32x/32x.c +++ b/pico/32x/32x.c @@ -583,10 +583,10 @@ void sync_sh2s_lockstep(unsigned int m68k_target) unsigned int mcycles; mcycles = msh2.m68krcycles_done; - if (ssh2.m68krcycles_done < mcycles) + if (CYCLES_GT(mcycles, ssh2.m68krcycles_done)) mcycles = ssh2.m68krcycles_done; - while (mcycles < m68k_target) { + while (CYCLES_GT(m68k_target, mcycles)) { mcycles += STEP_LS; sync_sh2s_normal(mcycles); } diff --git a/pico/32x/memory.c b/pico/32x/memory.c index 7d964f20..1d17f9f6 100644 --- a/pico/32x/memory.c +++ b/pico/32x/memory.c @@ -72,7 +72,7 @@ static int m68k_poll_detect(u32 a, u32 cycles, u32 flags) // support polling on 2 addresses - seen in Wolfenstein int match = (a - m68k_poll.addr1 <= 3 || a - m68k_poll.addr2 <= 3); - if (match && cycles - m68k_poll.cycles <= 64 && !SekNotPolling) + if (match && CYCLES_GT(64, cycles - m68k_poll.cycles) && !SekNotPolling) { // detect split 32bit access by same cycle count, and ignore those if (cycles != m68k_poll.cycles && ++m68k_poll.cnt >= POLL_THRESHOLD) { @@ -160,7 +160,7 @@ void NOINLINE p32x_sh2_poll_event(u32 a, SH2 *sh2, u32 flags, u32 m68k_cycles) elprintf_sh2(sh2, EL_32X, "state: %02x->%02x", sh2->state, sh2->state & ~flags); - if (sh2->m68krcycles_done < m68k_cycles && !(sh2->state & SH2_STATE_RUN)) + if (CYCLES_GT(m68k_cycles, sh2->m68krcycles_done) && !(sh2->state & SH2_STATE_RUN)) sh2->m68krcycles_done = m68k_cycles; pevt_log_sh2_o(sh2, EVT_POLL_END); -- 2.39.2