uae_u32 loaddelay;
uae_u8 preovfl;
uae_u8 cr;
+ uae_u32 timerval_prev;
};
struct CIA
static void timer_reset(struct CIATimer *t)
{
t->timer = t->latch;
+ t->timerval_prev = 0xffffffff;
if (acc_mode()) {
if (t->cr & CR_RUNMODE) {
t->inputpipe &= ~CIA_PIPE_CLR1;
if (t->loaddelay & 0x00000001) {
t->timer = t->latch;
t->inputpipe &= ~CIA_PIPE_CLR1;
+ t->timerval_prev = 0xffffffff;
}
// timer=0 special cases. TODO: better way to do this..
c->t[0].timer -= cc;
c->t[0].timer &= 0xffff;
if (c->t[0].timer == 0) {
+ c->t[0].timerval_prev = 0xffffffff;
// SP in output mode (data sent can be ignored if CIA-A)
if ((c->t[0].cr & (CR_SPMODE | CR_RUNMODE)) == CR_SPMODE && c->sdr_cnt > 0) {
c->sdr_cnt--;
if (cc > 0) {
if ((c->t[1].timer == 0 && (c->t[1].cr & (CR_INMODE | CR_INMODE1)))) {
ovfl[1] = 2;
+ c->t[1].timerval_prev = 0xffffffff;
} else {
c->t[1].timer -= cc;
c->t[1].timer &= 0xffff;
if ((c->t[1].timer == 0 && !(c->t[1].cr & (CR_INMODE | CR_INMODE1)))) {
ovfl[1] = 2;
+ c->t[1].timerval_prev = 0xffffffff;
}
}
}
icr |= 1 << num;
}
t->timer = t->latch;
+ t->timerval_prev = 0xffffffff;
}
if (!loaded[tn]) {
if (t->cr & CR_RUNMODE) {
case 7:
{
uae_u16 tval = t->timer - t->passed;
+ bool timer_prev = true;
// fast CPU timer hack
- if ((t->cr & CR_START) && !(t->cr & CR_INMODE1) && !(t->cr & CR_INMODE) && t->latch == t->timer) {
- if (currprefs.cachesize || currprefs.m68k_speed < 0) {
- uae_u16 adj = cia_timer_hack_adjust;
- if (adj >= tval && tval > 1) {
- adj = tval - 1;
+ if ((t->cr & CR_START) && !(t->cr & CR_INMODE1) && !(t->cr & CR_INMODE)) {
+ if (t->latch == t->timer) {
+ if (currprefs.cachesize || currprefs.m68k_speed < 0) {
+ uae_u16 adj = cia_timer_hack_adjust;
+ if (adj >= tval && (tval > 1 || !(t->cr & CR_RUNMODE))) {
+ adj = tval - 1;
+ }
+ tval -= adj;
+ }
+ }
+ if ((slow_cpu_access & 1) && (reg == 4 || reg == 6) && tval == t->timerval_prev) {
+ if (currprefs.cachesize || currprefs.m68k_speed < 0) {
+ uae_u16 adj = cia_timer_hack_adjust;
+ if (adj > 0 && ((tval > 1) || !(t->cr & CR_RUNMODE))) {
+ tval -= adj;
+ }
+ set_special(SPCFLAG_CPU_SLOW);
+ timer_prev = false;
+ t->timerval_prev = 0xffffffff;
}
- tval -= adj;
}
}
if (reg == 4 || reg == 6) {
+ if (timer_prev) {
+ t->timerval_prev = tval;
+ }
return tval & 0xff;
}
return tval >> 8;
if (!(t->cr & CR_START) || (t->cr & CR_RUNMODE)) {
t->timer = t->latch;
+ t->timerval_prev = 0xffffffff;
}
if (t->cr & CR_RUNMODE) {
if (val & CR_LOAD) {
val &= ~CR_LOAD;
t->timer = t->latch;
+ t->timerval_prev = 0xffffffff;
}
if (val & CR_START) {
+ t->timerval_prev = 0xffffffff;
if (!CIA_timer_inmode(tnum, val)) {
t->inputpipe = CIA_PIPE_ALL_MASK;
if (t->timer <= 1) {
switch (reg) {
case 4:
case 6:
+ t->timerval_prev = 0xffffffff;
t->latch = (t->latch & 0xff00) | val;
break;
case 5:
case 7:
+ t->timerval_prev = 0xffffffff;
CIA_thi_write(num, tnum, val);
break;
case 8:
* worth the trouble..
*/
static int vpos_lpen, hpos_lpen, hhpos_lpen, lightpen_triggered;
+static uae_u32 vhposr_prev;
int lightpen_x[2], lightpen_y[2];
int lightpen_cx[2], lightpen_cy[2], lightpen_active, lightpen_enabled, lightpen_enabled2;
if (0 || M68K_GETPC < 0x00f00000 || M68K_GETPC >= 0x10000000)
write_log (_T("VHPOSR %04x at %08x %04x\n"), vp, M68K_GETPC, bplcon0);
#endif
+
+ if (slow_cpu_access & 2) {
+ if (vp == vhposr_prev) {
+ if (currprefs.cachesize || currprefs.m68k_speed < 0) {
+ set_special(SPCFLAG_CPU_SLOW);
+ }
+ }
+ vhposr_prev = vp;
+ }
+
return vp;
}
vsync_handle_check();
vsync_cycles = get_cycles();
+ vhposr_prev = 0xffffffff;
}
static void copper_check(int n)
static int baseclock;
int m68k_pc_indirect;
bool m68k_interrupt_delay;
+int slow_cpu_access;
static bool m68k_accurate_ipl;
static bool m68k_reset_delay;
static bool ismoves_nommu;
#endif
}
+ if (spcflags & SPCFLAG_CPU_SLOW) {
+ evt_t c = get_cck_cycles();
+ int cnt = 0;
+ while(regs.spcflags == SPCFLAG_CPU_SLOW && c == get_cck_cycles()) {
+ x_do_cycles(4 * CYCLE_UNIT);
+ cnt++;
+ }
+ unset_special(SPCFLAG_CPU_SLOW);
+ }
+
if (spcflags & SPCFLAG_MMURESTART) {
// can't have interrupt when 040/060 CPU reruns faulted instruction
unset_special(SPCFLAG_MMURESTART);
extern uae_s64 max_avi_size;
extern int floppy_writemode;
extern int cia_timer_hack_adjust;
+extern int slow_cpu_access;
extern DWORD_PTR cpu_affinity, cpu_paffinity;
static DWORD_PTR original_affinity = -1;
cia_timer_hack_adjust = getval(np);
return 2;
}
+ if (!_tcscmp(arg, _T("slow_cpu_access"))) {
+ slow_cpu_access = getval(np);
+ return 2;
+ }
+
#endif
return 0;