extern unsigned char formatted_bram[4*0x10];
static unsigned int mcd_m68k_cycle_mult;
+static unsigned int mcd_s68k_cycle_mult;
static unsigned int mcd_m68k_cycle_base;
static unsigned int mcd_s68k_cycle_base;
#elif defined(EMU_F68K)
SekCycleCntS68k += fm68k_emulate(&PicoCpuFS68k, cyc_do, 0) - cyc_do;
#endif
+ SekCyclesLeftS68k = 0;
pprof_end(s68k);
}
static void pcd_set_cycle_mult(void)
{
- // ~1.63 for NTSC, ~1.645 for PAL
+ unsigned int div;
+
if (Pico.m.pal)
- mcd_m68k_cycle_mult = ((12500000ull << 16) / (50*313*488));
+ div = 50*313*488;
else
- mcd_m68k_cycle_mult = ((12500000ull << 16) / (60*262*488)) + 1;
+ div = 60*262*488;
+
+ // ~1.63 for NTSC, ~1.645 for PAL; round to nearest, x/y+0.5 -> (x+y/2)/y
+ mcd_m68k_cycle_mult = ((12500000ull << 16) + div/2) / div;
+ mcd_s68k_cycle_mult = ((1ull*div << 16) + 6250000) / 12500000;
}
unsigned int pcd_cycles_m68k_to_s68k(unsigned int c)
if (Pico_mcd->m.busreq != 1) { /* busreq/reset */
SekCycleCntS68k = SekCycleAimS68k = s68k_target;
- pcd_run_events(m68k_target);
+ pcd_run_events(s68k_target);
return 0;
}
Pico.t.m68c_cnt = Pico.t.m68c_aim;
return;
}
- Pico.t.m68c_cnt = Pico.t.m68c_aim - (s68k_left * 40220 >> 16);
+ Pico.t.m68c_cnt = Pico.t.m68c_aim - (s68k_left * mcd_s68k_cycle_mult >> 16);
}
while (CYCLES_GT(Pico.t.m68c_aim, Pico.t.m68c_cnt)) {