From: notaz Date: Tue, 8 Oct 2013 23:26:52 +0000 (+0300) Subject: fix yet another sync issue.. X-Git-Tag: v1.91~14 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=picodrive.git;a=commitdiff_plain;h=6901d0e45dbf77671d86cb9bf9af98c486db97c8 fix yet another sync issue.. --- diff --git a/pico/cd/mcd.c b/pico/cd/mcd.c index a20b01d..687dfc3 100644 --- a/pico/cd/mcd.c +++ b/pico/cd/mcd.c @@ -90,7 +90,32 @@ PICO_INTERNAL int PicoResetMCD(void) return 0; } -static __inline void SekRunS68k(unsigned int to) +static void SekRunM68kOnce(void) +{ + int cyc_do; + pevt_log_m68k_o(EVT_RUN_START); + + if ((cyc_do = SekCycleAim - SekCycleCnt) > 0) { + SekCycleCnt += cyc_do; + +#if defined(EMU_C68K) + PicoCpuCM68k.cycles = cyc_do; + CycloneRun(&PicoCpuCM68k); + SekCycleCnt -= PicoCpuCM68k.cycles; +#elif defined(EMU_M68K) + SekCycleCnt += m68k_execute(cyc_do) - cyc_do; +#elif defined(EMU_F68K) + SekCycleCnt += fm68k_emulate(cyc_do, 0) - cyc_do; +#endif + } + + SekCyclesLeft = 0; + + SekTrace(0); + pevt_log_m68k_o(EVT_RUN_END); +} + +static void SekRunS68k(unsigned int to) { int cyc_do; @@ -305,7 +330,13 @@ void pcd_run_cpus_normal(int m68k_cycles) SekCycleCnt = SekCycleAim - (s68k_left * 40220 >> 16); } - SekSyncM68k(); + while (CYCLES_GT(SekCycleAim, SekCycleCnt)) { + SekRunM68kOnce(); + if (Pico_mcd->m.need_sync) { + Pico_mcd->m.need_sync = 0; + pcd_sync_s68k(SekCycleCnt, 0); + } + } } void pcd_run_cpus_lockstep(int m68k_cycles) diff --git a/pico/cd/memory.c b/pico/cd/memory.c index 0551078..acf29c6 100644 --- a/pico/cd/memory.c +++ b/pico/cd/memory.c @@ -67,6 +67,12 @@ static void remap_word_ram(u32 r3); void m68k_comm_check(u32 a) { pcd_sync_s68k(SekCyclesDone(), 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_a = a; Pico_mcd->m.m68k_poll_cnt = 0; diff --git a/pico/pico_int.h b/pico/pico_int.h index 76c4812..48d5237 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -396,20 +396,21 @@ struct mcd_pcm struct mcd_misc { - unsigned short hint_vector; - unsigned char busreq; // not s68k_regs[1] - unsigned char s68k_pend_ints; - unsigned int state_flags; // 04 - unsigned int stopwatch_base_c; - unsigned short m68k_poll_a; - unsigned short m68k_poll_cnt; - unsigned short s68k_poll_a; - unsigned short s68k_poll_cnt; - unsigned int s68k_poll_clk; - unsigned char bcram_reg; // 18: battery-backed RAM cart register - unsigned char dmna_ret_2m; - unsigned short pad3; - int pad4[9]; + unsigned short hint_vector; + unsigned char busreq; // not s68k_regs[1] + unsigned char s68k_pend_ints; + unsigned int state_flags; // 04 + unsigned int stopwatch_base_c; + unsigned short m68k_poll_a; + unsigned short m68k_poll_cnt; + unsigned short s68k_poll_a; + unsigned short s68k_poll_cnt; + unsigned int s68k_poll_clk; + unsigned char bcram_reg; // 18: battery-backed RAM cart register + unsigned char dmna_ret_2m; + unsigned char need_sync; + unsigned char pad3; + int pad4[9]; }; typedef struct