From: kub Date: Wed, 22 Apr 2020 18:34:20 +0000 (+0200) Subject: 32x, small improvement for poll detection X-Git-Tag: v2.00~748 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6432fb18baa0f9b6f41a68301c841dd58dc56cd4;p=picodrive.git 32x, small improvement for poll detection --- diff --git a/pico/32x/memory.c b/pico/32x/memory.c index 3f597288..69f70318 100644 --- a/pico/32x/memory.c +++ b/pico/32x/memory.c @@ -114,12 +114,13 @@ void p32x_m68k_poll_event(u32 flags) void NOINLINE p32x_sh2_poll_detect(u32 a, SH2 *sh2, u32 flags, int maxcnt) { u32 cycles_done = sh2_cycles_done_t(sh2); + u32 cycles_diff = cycles_done - sh2->poll_cycles; // reading 2 consecutive 16bit values is probably a 32bit access. detect this // by checking address (max 2 bytes away) and cycles (max 2 cycles later). // no polling if more than 20 cycles have passed since last detect call. - if (a - sh2->poll_addr <= 2 && CYCLES_GE(sh2->poll_cycles+20, cycles_done)) { - if (CYCLES_GT(cycles_done,sh2->poll_cycles+2) && ++sh2->poll_cnt >= maxcnt) { + if (a - sh2->poll_addr <= 2 && CYCLES_GE(20, cycles_diff)) { + if (CYCLES_GT(cycles_diff, 2) && ++sh2->poll_cnt >= maxcnt) { if (!(sh2->state & flags)) elprintf_sh2(sh2, EL_32X, "state: %02x->%02x", sh2->state, sh2->state | flags);