32x: start reworking sheduling
[picodrive.git] / pico / pico_cmn.c
index 7960676..7178440 100644 (file)
@@ -1,5 +1,10 @@
-// common code for Pico.c and cd/Pico.c
-// (c) Copyright 2007-2009 Grazvydas "notaz" Ignotas
+/*
+ * common code for pico.c and cd/pico.c
+ * (C) notaz, 2007-2009
+ *
+ * This work is licensed under the terms of MAME license.
+ * See COPYING file in the top-level directory.
+ */
 
 #define CYCLES_M68K_LINE     488 // suitable for both PAL/NTSC
 #define CYCLES_M68K_VINT_LAG  68
   SekRunM68k(m68k_cycles)
 #endif
 
+static __inline void SekRunM68k(int cyc)
+{
+  int cyc_do;
+  pprof_start(m68k);
+
+  SekCycleAim+=cyc;
+  if ((cyc_do=SekCycleAim-SekCycleCnt) <= 0) return;
+#if defined(EMU_CORE_DEBUG)
+  // this means we do run-compare
+  SekCycleCnt+=CM_compareRun(cyc_do, 0);
+#elif defined(EMU_C68K)
+  PicoCpuCM68k.cycles=cyc_do;
+  CycloneRun(&PicoCpuCM68k);
+  SekCycleCnt+=cyc_do-PicoCpuCM68k.cycles;
+#elif defined(EMU_M68K)
+  SekCycleCnt+=m68k_execute(cyc_do);
+#elif defined(EMU_F68K)
+  SekCycleCnt+=fm68k_emulate(cyc_do+1, 0, 0);
+#endif
+
+  pprof_end(m68k);
+}
+
 static int PicoFrameHints(void)
 {
   struct PicoVideo *pv=&Pico.video;