(MSVC) Compatibility fixes
[picodrive.git] / pico / 32x / 32x.c
index 92d5216..14d1c84 100644 (file)
@@ -109,6 +109,10 @@ void Pico32xStartup(void)
   p32x_pwm_ctl_changed();
   p32x_timers_recalc();
 
+  Pico32x.sh2_regs[0] = P32XS2_ADEN;
+  if (Pico.m.ncart_in)
+    Pico32x.sh2_regs[0] |= P32XS_nCART;
+
   if (!Pico.m.pal)
     Pico32x.vdp_regs[0] |= P32XV_nPAL;
 
@@ -183,7 +187,6 @@ void PicoPower32x(void)
 
   Pico32x.regs[0] = P32XS_REN|P32XS_nRES; // verified
   Pico32x.vdp_regs[0x0a/2] = P32XV_VBLK|P32XV_PEN;
-  Pico32x.sh2_regs[0] = P32XS2_ADEN;
 }
 
 void PicoUnload32x(void)
@@ -200,7 +203,6 @@ void PicoUnload32x(void)
 void PicoReset32x(void)
 {
   if (PicoAHW & PAHW_32X) {
-    msh2.m68krcycles_done = ssh2.m68krcycles_done = SekCyclesDone();
     p32x_trigger_irq(NULL, SekCyclesDone(), P32XI_VRES);
     p32x_sh2_poll_event(&msh2, SH2_IDLE_STATES, 0);
     p32x_sh2_poll_event(&ssh2, SH2_IDLE_STATES, 0);
@@ -292,9 +294,9 @@ typedef void (event_cb)(unsigned int now);
 unsigned int p32x_event_times[P32X_EVENT_COUNT];
 static unsigned int event_time_next;
 static event_cb *p32x_event_cbs[P32X_EVENT_COUNT] = {
-  [P32X_EVENT_PWM]      = p32x_pwm_irq_event,
-  [P32X_EVENT_FILLEND]  = fillend_event,
-  [P32X_EVENT_HINT]     = hint_event,
+  p32x_pwm_irq_event,
+  fillend_event,
+  hint_event,
 };
 
 // schedule event at some time 'after', in m68k clocks
@@ -361,7 +363,7 @@ static void p32x_run_events(unsigned int until)
       oldest, event_time_next);
 }
 
-static inline void run_sh2(SH2 *sh2, int m68k_cycles)
+static INLINE void run_sh2(SH2 *sh2, int m68k_cycles)
 {
   int cycles, done;
 
@@ -516,7 +518,11 @@ void sync_sh2s_lockstep(unsigned int m68k_target)
 }
 
 #define CPUS_RUN(m68k_cycles) do { \
-  SekRunM68k(m68k_cycles); \
+  if (PicoAHW & PAHW_MCD) \
+    pcd_run_cpus(m68k_cycles); \
+  else \
+    SekRunM68k(m68k_cycles); \
+  \
   if ((Pico32x.emu_flags & P32XF_Z80_32X_IO) && Pico.m.z80Run \
       && !Pico.m.z80_reset && (PicoOpt & POPT_EN_Z80)) \
     PicoSyncZ80(SekCyclesDone()); \
@@ -525,6 +531,7 @@ void sync_sh2s_lockstep(unsigned int m68k_target)
 } while (0)
 
 #define PICO_32X
+#define PICO_CD
 #include "../pico_cmn.c"
 
 void PicoFrame32x(void)
@@ -540,6 +547,9 @@ void PicoFrame32x(void)
   p32x_sh2_poll_event(&msh2, SH2_STATE_VPOLL, 0);
   p32x_sh2_poll_event(&ssh2, SH2_STATE_VPOLL, 0);
 
+  if (PicoAHW & PAHW_MCD)
+    pcd_prepare_frame();
+
   PicoFrameStart();
   PicoFrameHints();
   sh2_drc_frame();