From 5402223466ef33053e0f6ebe90b285bcd9914e33 Mon Sep 17 00:00:00 2001 From: kub Date: Fri, 14 May 2021 22:55:03 +0200 Subject: [PATCH] mcd, improve polling detection --- pico/cd/mcd.c | 2 +- pico/cd/memory.c | 9 ++++++--- pico/pico_int.h | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pico/cd/mcd.c b/pico/cd/mcd.c index 732a4299..602b6eb4 100644 --- a/pico/cd/mcd.c +++ b/pico/cd/mcd.c @@ -342,7 +342,7 @@ void pcd_run_cpus_normal(int m68k_cycles) Pico_mcd->m.m68k_poll_cnt = 0; #ifdef USE_POLL_DETECT - if (Pico_mcd->m.m68k_poll_cnt >= 16) { + if (Pico_mcd->m.m68k_poll_cnt >= 32) { int s68k_left; // main CPU is polling, (wake and) run sub only if (SekIsStoppedS68k()) diff --git a/pico/cd/memory.c b/pico/cd/memory.c index a7b47b91..a47d6a37 100644 --- a/pico/cd/memory.c +++ b/pico/cd/memory.c @@ -63,19 +63,22 @@ static void remap_prg_window(u32 r1, u32 r3); static void remap_word_ram(u32 r3); // poller detection -#define POLL_LIMIT 16 +#define POLL_LIMIT 32 #define POLL_CYCLES 64 void m68k_comm_check(u32 a) { - pcd_sync_s68k(SekCyclesDone(), 0); + u32 cycles = SekCyclesDone(); + u32 clkdiff = cycles - Pico_mcd->m.m68k_poll_clk; + pcd_sync_s68k(cycles, 0); if (a >= 0x0e && !Pico_mcd->m.need_sync) { // there are cases when slave updates comm and only switches RAM // over after that (mcd1b), so there must be a resync.. SekEndRun(64); Pico_mcd->m.need_sync = 1; } - if (SekNotPolling || a != Pico_mcd->m.m68k_poll_a) { + Pico_mcd->m.m68k_poll_clk = cycles; + if (SekNotPolling || a != Pico_mcd->m.m68k_poll_a || clkdiff > POLL_CYCLES) { Pico_mcd->m.m68k_poll_a = a; Pico_mcd->m.m68k_poll_cnt = 0; SekNotPolling = 0; diff --git a/pico/pico_int.h b/pico/pico_int.h index c4044167..6a393fbf 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -491,7 +491,8 @@ struct mcd_misc unsigned char dmna_ret_2m; unsigned char need_sync; unsigned char pad3; - int pad4[9]; + unsigned int m68k_poll_clk; + int pad4[8]; }; typedef struct -- 2.39.5