Skip to content

Commit

Permalink
32x, fixes for comparing cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
irixxxx committed Jun 2, 2024
1 parent 38fd3bd commit 4af2edc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cpu/sh2/sh2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pico/32x/32x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions pico/32x/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4af2edc

Please sign in to comment.