32x, fixes for comparing cycles

This commit is contained in:
kub 2024-06-02 07:53:04 +00:00
parent 38fd3bd866
commit 4af2edc365
3 changed files with 5 additions and 5 deletions

View file

@ -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

View file

@ -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);
}

View file

@ -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);