fix yet another sync issue..

This commit is contained in:
notaz 2013-10-09 02:26:52 +03:00
parent 7b3ddc11dc
commit 6901d0e45d
3 changed files with 54 additions and 16 deletions

View file

@ -90,7 +90,32 @@ PICO_INTERNAL int PicoResetMCD(void)
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;
@ -305,7 +330,13 @@ void pcd_run_cpus_normal(int m68k_cycles)
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)

View file

@ -67,6 +67,12 @@ static void remap_word_ram(u32 r3);
void m68k_comm_check(u32 a)
{
pcd_sync_s68k(SekCyclesDone(), 0);
if (a >= 0x0e && !Pico_mcd->m.need_sync) {
// there are cases when slave updates comm and only switches RAM
// over after that (mcd1b), so there must be a resync..
SekEndRun(64);
Pico_mcd->m.need_sync = 1;
}
if (SekNotPolling || a != Pico_mcd->m.m68k_poll_a) {
Pico_mcd->m.m68k_poll_a = a;
Pico_mcd->m.m68k_poll_cnt = 0;

View file

@ -396,20 +396,21 @@ struct mcd_pcm
struct mcd_misc
{
unsigned short hint_vector;
unsigned char busreq; // not s68k_regs[1]
unsigned char s68k_pend_ints;
unsigned int state_flags; // 04
unsigned int stopwatch_base_c;
unsigned short m68k_poll_a;
unsigned short m68k_poll_cnt;
unsigned short s68k_poll_a;
unsigned short s68k_poll_cnt;
unsigned int s68k_poll_clk;
unsigned char bcram_reg; // 18: battery-backed RAM cart register
unsigned char dmna_ret_2m;
unsigned short pad3;
int pad4[9];
unsigned short hint_vector;
unsigned char busreq; // not s68k_regs[1]
unsigned char s68k_pend_ints;
unsigned int state_flags; // 04
unsigned int stopwatch_base_c;
unsigned short m68k_poll_a;
unsigned short m68k_poll_cnt;
unsigned short s68k_poll_a;
unsigned short s68k_poll_cnt;
unsigned int s68k_poll_clk;
unsigned char bcram_reg; // 18: battery-backed RAM cart register
unsigned char dmna_ret_2m;
unsigned char need_sync;
unsigned char pad3;
int pad4[9];
};
typedef struct