+#define PS_STEP_M68K ((488<<16)/20) // ~24
+//#define PS_STEP_S68K 13
+
+#ifdef _ASM_CD_PICO_C
+void SekRunPS(int cyc_m68k, int cyc_s68k);
+#else
+static __inline void SekRunPS(int cyc_m68k, int cyc_s68k)
+{
+ int cycn, cycn_s68k, cyc_do;
+ int d_cm = 0, d_cs = 0, ex;
+ 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)
+ {
+ ex = 0;
+ cycn_s68k = (cycn + cycn/2 + cycn/8) >> 16;
+//fprintf(stderr, "%3i/%3i: ", cycn>>16, cycn_s68k);
+ if ((cyc_do = SekCycleAim-SekCycleCnt-(cycn>>16)) > 0) {
+#if defined(EMU_C68K)
+ PicoCpu.cycles = cyc_do;
+ CycloneRun(&PicoCpu);
+ SekCycleCnt += cyc_do - PicoCpu.cycles;
+#elif defined(EMU_M68K)
+ m68k_set_context(&PicoM68kCPU);
+ SekCycleCnt += (ex = m68k_execute(cyc_do));
+#endif
+ }
+//fprintf(stderr, "%3i ", ex); d_cm += ex; ex = 0;
+ if ((cyc_do = SekCycleAimS68k-SekCycleCntS68k-cycn_s68k) > 0) {
+#if defined(EMU_C68K)
+ PicoCpuS68k.cycles = cyc_do;
+ CycloneRun(&PicoCpuS68k);
+ SekCycleCntS68k += cyc_do - PicoCpuS68k.cycles;
+#elif defined(EMU_M68K)
+ m68k_set_context(&PicoS68kCPU);
+ SekCycleCntS68k += (ex = m68k_execute(cyc_do));
+#endif
+ }
+//fprintf(stderr, "%3i\n", ex); d_cs += ex;
+ }
+
+//fprintf(stderr, "== end %3i/%3i ==\n", d_cm, d_cs);
+}
+#endif
+
+