bugfixes, adjusted famec timing
[picodrive.git] / Pico / Pico.c
index ce3e340..38c8233 100644 (file)
@@ -202,11 +202,9 @@ static __inline void SekRunM68k(int cyc)
 {\r
   int cyc_do;\r
   SekCycleAim+=cyc;\r
-  //printf("aim: %i, cnt: %i\n", SekCycleAim, SekCycleCnt);\r
   if((cyc_do=SekCycleAim-SekCycleCnt) <= 0) return;\r
-  //printf("cyc_do: %i\n", cyc_do);\r
-#if   defined(EMU_C68K) && defined(EMU_M68K)\r
-  // this means we do run-compare Cyclone vs Musashi\r
+#if defined(EMU_CORE_DEBUG)\r
+  // this means we do run-compare\r
   SekCycleCnt+=CM_compareRun(cyc_do);\r
 #elif defined(EMU_C68K)\r
   PicoCpuCM68k.cycles=cyc_do;\r
@@ -215,7 +213,7 @@ static __inline void SekRunM68k(int cyc)
 #elif defined(EMU_M68K)\r
   SekCycleCnt+=m68k_execute(cyc_do);\r
 #elif defined(EMU_F68K)\r
-  SekCycleCnt+=m68k_emulate(cyc_do);\r
+  SekCycleCnt+=fm68k_emulate(cyc_do+1);\r
 #endif\r
 }\r
 \r
@@ -223,8 +221,7 @@ static __inline void SekStep(void)
 {\r
   // this is required for timing sensitive stuff to work\r
   int realaim=SekCycleAim; SekCycleAim=SekCycleCnt+1;\r
-#if   defined(EMU_C68K) && defined(EMU_M68K)\r
-  // this means we do run-compare Cyclone vs Musashi\r
+#if defined(EMU_CORE_DEBUG)\r
   SekCycleCnt+=CM_compareRun(1);\r
 #elif defined(EMU_C68K)\r
   PicoCpuCM68k.cycles=1;\r
@@ -233,7 +230,7 @@ static __inline void SekStep(void)
 #elif defined(EMU_M68K)\r
   SekCycleCnt+=m68k_execute(1);\r
 #elif defined(EMU_F68K)\r
-  SekCycleCnt+=m68k_emulate(1);\r
+  SekCycleCnt+=fm68k_emulate(1);\r
 #endif\r
   SekCycleAim=realaim;\r
 }\r
@@ -316,7 +313,7 @@ static int PicoFrameSimple(void)
   int cycles_68k_vblock,cycles_68k_block;\r
 \r
   // split to 16 run calls for active scan, for vblank split to 2 (ntsc), 3 (pal 240), 4 (pal 224)\r
-  if (Pico.m.pal && (pv->reg[1]&8)) { // 240 lines\r
+  if (Pico.m.pal && (pv->reg[1]&8)) {\r
     if(pv->reg[1]&8) { // 240 lines\r
       cycles_68k_block  = 7329;  // (488*240+148)/16.0, -4\r
       cycles_68k_vblock = 11640; // (72*488-148-68)/3.0, 0\r
@@ -378,14 +375,6 @@ static int PicoFrameSimple(void)
     PicoRunZ80Simple(line, lines);\r
   }\r
 \r
-  // here we render sound if ym2612 is disabled\r
-  if (!(PicoOpt&1) && PsndOut) {\r
-    int len = sound_render(0, PsndLen);\r
-    if (PicoWriteSound) PicoWriteSound(len);\r
-    // clear sound buffer\r
-    sound_clear();\r
-  }\r
-\r
   // render screen\r
   if (!PicoSkipFrame)\r
   {\r
@@ -401,6 +390,17 @@ static int PicoFrameSimple(void)
       for (y=0;y<224;y++) PicoLine(y);\r
 #endif\r
     else PicoFrameFull();\r
+#ifdef DRAW_FINISH_FUNC\r
+    DRAW_FINISH_FUNC();\r
+#endif\r
+  }\r
+\r
+  // here we render sound if ym2612 is disabled\r
+  if (!(PicoOpt&1) && PsndOut) {\r
+    int len = sound_render(0, PsndLen);\r
+    if (PicoWriteSound) PicoWriteSound(len);\r
+    // clear sound buffer\r
+    sound_clear();\r
   }\r
 \r
   // a gap between flags set and vint\r