-// ~1463.8, but due to cache misses and slow mem
-// it's much lower than that
-//#define SH2_LINE_CYCLES 735
-#define CYCLES_M68K2MSH2(x) (((x) * p32x_msh2_multiplier) >> 10)
-#define CYCLES_M68K2SSH2(x) (((x) * p32x_ssh2_multiplier) >> 10)
-
-#define PICO_32X
-#define CPUS_RUN_SIMPLE(m68k_cycles,s68k_cycles) \
-{ \
- int slice; \
- SekCycleAim += m68k_cycles; \
- while (SekCycleCnt < SekCycleAim) { \
- slice = SekCycleCnt; \
- run_m68k(SekCycleAim - SekCycleCnt); \
- if (!(Pico32x.regs[0] & P32XS_nRES)) \
- continue; /* SH2s reseting */ \
- slice = SekCycleCnt - slice; /* real count from 68k */ \
- if (SekCycleCnt < SekCycleAim) \
- elprintf(EL_32X, "slice %d", slice); \
- if (!(Pico32x.emu_flags & (P32XF_SSH2POLL|P32XF_SSH2VPOLL))) { \
- pprof_start(ssh2); \
- sh2_execute(&ssh2, CYCLES_M68K2SSH2(slice)); \
- pprof_end(ssh2); \
- } \
- if (!(Pico32x.emu_flags & (P32XF_MSH2POLL|P32XF_MSH2VPOLL))) { \
- pprof_start(msh2); \
- sh2_execute(&msh2, CYCLES_M68K2MSH2(slice)); \
- pprof_end(msh2); \
- } \
- pprof_start(dummy); \
- pprof_end(dummy); \
- } \
+void sync_sh2s_normal(unsigned int m68k_target)
+{
+ unsigned int target = m68k_target;
+ int msh2_cycles, ssh2_cycles;
+ int done;
+
+ elprintf(EL_32X, "sh2 sync to %u (%u)", m68k_target, SekCycleCnt);
+
+ if (!(Pico32x.regs[0] & P32XS_nRES))
+ return; // rare
+
+ {
+ msh2_cycles = C_M68K_TO_SH2(msh2, target - msh2.m68krcycles_done);
+ ssh2_cycles = C_M68K_TO_SH2(ssh2, target - ssh2.m68krcycles_done);
+
+ while (msh2_cycles > 0 || ssh2_cycles > 0) {
+ elprintf(EL_32X, "sh2 exec %u,%u->%u",
+ msh2.m68krcycles_done, ssh2.m68krcycles_done, target);
+
+ if (Pico32x.emu_flags & (P32XF_SSH2POLL|P32XF_SSH2VPOLL)) {
+ ssh2.m68krcycles_done = target;
+ ssh2_cycles = 0;
+ }
+ else if (ssh2_cycles > 0) {
+ done = sh2_execute(&ssh2, ssh2_cycles);
+ ssh2.m68krcycles_done += C_SH2_TO_M68K(ssh2, done);
+
+ ssh2_cycles = C_M68K_TO_SH2(ssh2, target - ssh2.m68krcycles_done);
+ }
+
+ if (Pico32x.emu_flags & (P32XF_MSH2POLL|P32XF_MSH2VPOLL)) {
+ msh2.m68krcycles_done = target;
+ msh2_cycles = 0;
+ }
+ else if (msh2_cycles > 0) {
+ done = sh2_execute(&msh2, msh2_cycles);
+ msh2.m68krcycles_done += C_SH2_TO_M68K(msh2, done);
+
+ msh2_cycles = C_M68K_TO_SH2(msh2, target - msh2.m68krcycles_done);
+ }
+ }
+ }