return 0;
}
-static __inline void SekRunS68k(unsigned int to)
+static void SekRunM68kOnce(void)
+{
+ int cyc_do;
+ pevt_log_m68k_o(EVT_RUN_START);
+
+ if ((cyc_do = SekCycleAim - SekCycleCnt) > 0) {
+ SekCycleCnt += cyc_do;
+
+#if defined(EMU_C68K)
+ PicoCpuCM68k.cycles = cyc_do;
+ CycloneRun(&PicoCpuCM68k);
+ SekCycleCnt -= PicoCpuCM68k.cycles;
+#elif defined(EMU_M68K)
+ SekCycleCnt += m68k_execute(cyc_do) - cyc_do;
+#elif defined(EMU_F68K)
+ SekCycleCnt += fm68k_emulate(cyc_do, 0) - cyc_do;
+#endif
+ }
+
+ SekCyclesLeft = 0;
+
+ SekTrace(0);
+ pevt_log_m68k_o(EVT_RUN_END);
+}
+
+static void SekRunS68k(unsigned int to)
{
int cyc_do;
SekCycleCnt = SekCycleAim - (s68k_left * 40220 >> 16);
}
- SekSyncM68k();
+ while (CYCLES_GT(SekCycleAim, SekCycleCnt)) {
+ SekRunM68kOnce();
+ if (Pico_mcd->m.need_sync) {
+ Pico_mcd->m.need_sync = 0;
+ pcd_sync_s68k(SekCycleCnt, 0);
+ }
+ }
}
void pcd_run_cpus_lockstep(int m68k_cycles)
void m68k_comm_check(u32 a)\r
{\r
pcd_sync_s68k(SekCyclesDone(), 0);\r
+ if (a >= 0x0e && !Pico_mcd->m.need_sync) {\r
+ // there are cases when slave updates comm and only switches RAM\r
+ // over after that (mcd1b), so there must be a resync..\r
+ SekEndRun(64);\r
+ Pico_mcd->m.need_sync = 1;\r
+ }\r
if (SekNotPolling || a != Pico_mcd->m.m68k_poll_a) {\r
Pico_mcd->m.m68k_poll_a = a;\r
Pico_mcd->m.m68k_poll_cnt = 0;\r
\r
struct mcd_misc\r
{\r
- unsigned short hint_vector;\r
- unsigned char busreq; // not s68k_regs[1]\r
- unsigned char s68k_pend_ints;\r
- unsigned int state_flags; // 04\r
- unsigned int stopwatch_base_c;\r
- unsigned short m68k_poll_a;\r
- unsigned short m68k_poll_cnt;\r
- unsigned short s68k_poll_a;\r
- unsigned short s68k_poll_cnt;\r
- unsigned int s68k_poll_clk;\r
- unsigned char bcram_reg; // 18: battery-backed RAM cart register\r
- unsigned char dmna_ret_2m;\r
- unsigned short pad3;\r
- int pad4[9];\r
+ unsigned short hint_vector;\r
+ unsigned char busreq; // not s68k_regs[1]\r
+ unsigned char s68k_pend_ints;\r
+ unsigned int state_flags; // 04\r
+ unsigned int stopwatch_base_c;\r
+ unsigned short m68k_poll_a;\r
+ unsigned short m68k_poll_cnt;\r
+ unsigned short s68k_poll_a;\r
+ unsigned short s68k_poll_cnt;\r
+ unsigned int s68k_poll_clk;\r
+ unsigned char bcram_reg; // 18: battery-backed RAM cart register\r
+ unsigned char dmna_ret_2m;\r
+ unsigned char need_sync;\r
+ unsigned char pad3;\r
+ int pad4[9];\r
};\r
\r
typedef struct\r