32x: some accuracy improvements

This commit is contained in:
notaz 2013-08-05 03:58:27 +03:00
parent 34280f9b42
commit 4d5dfee861
4 changed files with 20 additions and 16 deletions

View file

@ -29,11 +29,9 @@ static int REGPARM(2) sh2_irq_cb(SH2 *sh2, int level)
} }
} }
// if !nested_call, must sync CPUs before calling this void p32x_update_irls(SH2 *active_sh2, int m68k_cycles)
void p32x_update_irls(SH2 *active_sh2)
{ {
int irqs, mlvl = 0, slvl = 0; int irqs, mlvl = 0, slvl = 0;
int m68k_cycles = 0;
int mrun, srun; int mrun, srun;
if (active_sh2 != NULL) if (active_sh2 != NULL)
@ -170,7 +168,7 @@ void PicoReset32x(void)
{ {
if (PicoAHW & PAHW_32X) { if (PicoAHW & PAHW_32X) {
Pico32x.sh2irqs |= P32XI_VRES; Pico32x.sh2irqs |= P32XI_VRES;
p32x_update_irls(NULL); p32x_update_irls(NULL, SekCyclesDoneT2());
p32x_sh2_poll_event(&msh2, SH2_IDLE_STATES, 0); p32x_sh2_poll_event(&msh2, SH2_IDLE_STATES, 0);
p32x_sh2_poll_event(&ssh2, SH2_IDLE_STATES, 0); p32x_sh2_poll_event(&ssh2, SH2_IDLE_STATES, 0);
p32x_pwm_ctl_changed(); p32x_pwm_ctl_changed();
@ -218,7 +216,7 @@ static void p32x_start_blank(void)
} }
Pico32x.sh2irqs |= P32XI_VINT; Pico32x.sh2irqs |= P32XI_VINT;
p32x_update_irls(NULL); p32x_update_irls(NULL, SekCyclesDoneT2());
p32x_sh2_poll_event(&msh2, SH2_STATE_VPOLL, 0); p32x_sh2_poll_event(&msh2, SH2_STATE_VPOLL, 0);
p32x_sh2_poll_event(&ssh2, SH2_STATE_VPOLL, 0); p32x_sh2_poll_event(&ssh2, SH2_STATE_VPOLL, 0);
} }
@ -517,7 +515,7 @@ void Pico32xStateLoaded(int is_early)
SekCycleCnt = 0; SekCycleCnt = 0;
sh2s[0].m68krcycles_done = sh2s[1].m68krcycles_done = SekCycleCntT; sh2s[0].m68krcycles_done = sh2s[1].m68krcycles_done = SekCycleCntT;
p32x_update_irls(NULL); p32x_update_irls(NULL, SekCycleCntT);
p32x_pwm_state_loaded(); p32x_pwm_state_loaded();
run_events(SekCycleCntT); run_events(SekCycleCntT);
} }

View file

@ -237,15 +237,21 @@ static void p32x_reg_write8(u32 a, u32 d)
r[0] = (r[0] & ~P32XS_nRES) | (d & P32XS_nRES); r[0] = (r[0] & ~P32XS_nRES) | (d & P32XS_nRES);
return; return;
case 3: // irq ctl case 3: // irq ctl
if ((d & 1) && !(Pico32x.sh2irqi[0] & P32XI_CMD)) { if ((d & 1) != !!(Pico32x.sh2irqi[0] & P32XI_CMD)) {
p32x_sync_sh2s(SekCyclesDoneT()); p32x_sync_sh2s(SekCyclesDoneT());
Pico32x.sh2irqi[0] |= P32XI_CMD; if (d & 1)
p32x_update_irls(NULL); Pico32x.sh2irqi[0] |= P32XI_CMD;
else
Pico32x.sh2irqi[0] &= ~P32XI_CMD;
p32x_update_irls(NULL, SekCyclesDoneT2());
} }
if ((d & 2) && !(Pico32x.sh2irqi[1] & P32XI_CMD)) { if (!!(d & 2) != !!(Pico32x.sh2irqi[1] & P32XI_CMD)) {
p32x_sync_sh2s(SekCyclesDoneT()); p32x_sync_sh2s(SekCyclesDoneT());
Pico32x.sh2irqi[1] |= P32XI_CMD; if (d & 2)
p32x_update_irls(NULL); Pico32x.sh2irqi[1] |= P32XI_CMD;
else
Pico32x.sh2irqi[1] &= ~P32XI_CMD;
p32x_update_irls(NULL, SekCyclesDoneT2());
} }
return; return;
case 5: // bank case 5: // bank
@ -481,7 +487,7 @@ static void p32x_sh2reg_write8(u32 a, u32 d, int cpuid)
Pico32x.sh2_regs[0] |= d & 0x80; Pico32x.sh2_regs[0] |= d & 0x80;
if (d & 1) if (d & 1)
p32x_pwm_schedule_sh2(&sh2s[cpuid]); p32x_pwm_schedule_sh2(&sh2s[cpuid]);
p32x_update_irls(&sh2s[cpuid]); p32x_update_irls(&sh2s[cpuid], 0);
return; return;
case 5: // H count case 5: // H count
d &= 0xff; d &= 0xff;
@ -555,7 +561,7 @@ static void p32x_sh2reg_write16(u32 a, u32 d, int cpuid)
return; return;
irls: irls:
p32x_update_irls(&sh2s[cpuid]); p32x_update_irls(&sh2s[cpuid], 0);
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View file

@ -31,7 +31,7 @@ void p32x_pwm_ctl_changed(void)
static void do_pwm_irq(unsigned int m68k_cycles) static void do_pwm_irq(unsigned int m68k_cycles)
{ {
Pico32x.sh2irqs |= P32XI_PWM; Pico32x.sh2irqs |= P32XI_PWM;
p32x_update_irls(NULL); p32x_update_irls(NULL, m68k_cycles);
if (Pico32x.regs[0x30 / 2] & P32XP_RTP) { if (Pico32x.regs[0x30 / 2] & P32XP_RTP) {
p32x_event_schedule(m68k_cycles, P32X_EVENT_PWM, pwm_cycles / 3 + 1); p32x_event_schedule(m68k_cycles, P32X_EVENT_PWM, pwm_cycles / 3 + 1);

View file

@ -746,7 +746,7 @@ void PicoFrame32x(void);
void Pico32xStateLoaded(int is_early); void Pico32xStateLoaded(int is_early);
void p32x_sync_sh2s(unsigned int m68k_target); void p32x_sync_sh2s(unsigned int m68k_target);
void p32x_sync_other_sh2(SH2 *sh2, unsigned int m68k_target); void p32x_sync_other_sh2(SH2 *sh2, unsigned int m68k_target);
void p32x_update_irls(SH2 *active_sh2); void p32x_update_irls(SH2 *active_sh2, int m68k_cycles);
void p32x_reset_sh2s(void); void p32x_reset_sh2s(void);
void p32x_event_schedule(unsigned int now, enum p32x_event event, int after); void p32x_event_schedule(unsigned int now, enum p32x_event event, int after);
void p32x_event_schedule_sh2(SH2 *sh2, enum p32x_event event, int after); void p32x_event_schedule_sh2(SH2 *sh2, enum p32x_event event, int after);