+#define PS_STEP_M68K ((488<<16)/20) // ~24
+//#define PS_STEP_S68K 13
+
+#if defined(_ASM_CD_PICO_C)
+extern void SekRunPS(int cyc_m68k, int cyc_s68k);
+#elif defined(EMU_F68K)
+static __inline void SekRunPS(int cyc_m68k, int cyc_s68k)
+{
+ SekCycleAim+=cyc_m68k;
+ SekCycleAimS68k+=cyc_s68k;
+ fm68k_emulate(0, 1);
+}
+#else
+static __inline void SekRunPS(int cyc_m68k, int cyc_s68k)
+{
+ int cycn, cycn_s68k, cyc_do;
+ SekCycleAim+=cyc_m68k;
+ SekCycleAimS68k+=cyc_s68k;
+
+// fprintf(stderr, "=== start %3i/%3i [%3i/%3i] {%05i.%i} ===\n", cyc_m68k, cyc_s68k,
+// SekCycleAim-SekCycleCnt, SekCycleAimS68k-SekCycleCntS68k, Pico.m.frame_count, Pico.m.scanline);
+
+ /* loop 488 downto 0 in steps of PS_STEP */
+ for (cycn = (488<<16)-PS_STEP_M68K; cycn >= 0; cycn -= PS_STEP_M68K)
+ {
+ cycn_s68k = (cycn + cycn/2 + cycn/8) >> 16;
+ if ((cyc_do = SekCycleAim-SekCycleCnt-(cycn>>16)) > 0) {
+#if defined(EMU_C68K)
+ PicoCpuCM68k.cycles = cyc_do;
+ CycloneRun(&PicoCpuCM68k);
+ SekCycleCnt += cyc_do - PicoCpuCM68k.cycles;
+#elif defined(EMU_M68K)
+ m68k_set_context(&PicoCpuMM68k);
+ SekCycleCnt += m68k_execute(cyc_do);
+#elif defined(EMU_F68K)
+ g_m68kcontext = &PicoCpuFM68k;
+ SekCycleCnt += fm68k_emulate(cyc_do, 0);
+#endif
+ }
+ if ((cyc_do = SekCycleAimS68k-SekCycleCntS68k-cycn_s68k) > 0) {
+#if defined(EMU_C68K)
+ PicoCpuCS68k.cycles = cyc_do;
+ CycloneRun(&PicoCpuCS68k);
+ SekCycleCntS68k += cyc_do - PicoCpuCS68k.cycles;
+#elif defined(EMU_M68K)
+ m68k_set_context(&PicoCpuMS68k);
+ SekCycleCntS68k += m68k_execute(cyc_do);
+#elif defined(EMU_F68K)
+ g_m68kcontext = &PicoCpuFS68k;
+ SekCycleCntS68k += fm68k_emulate(cyc_do, 0);
+#endif
+ }
+ }
+}
+#endif
+
+