From f70a3c8ec9dd455463aa49b796fd272865e8d676 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 18 Dec 2022 15:57:03 +0200 Subject: [PATCH] 68040+ cycle count adjustment --- newcpu.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/newcpu.cpp b/newcpu.cpp index c05e2193..2fb95064 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -2100,6 +2100,9 @@ static void update_68k_cycles (void) } } cycles_mult &= ~0x7f; + if (cycles_mult < 0x80) { + cycles_mult = 0x80; + } currprefs.cpu_clock_multiplier = changed_prefs.cpu_clock_multiplier; currprefs.cpu_frequency = changed_prefs.cpu_frequency; @@ -5849,6 +5852,7 @@ static void m68k_run_3ce (void) check_debugger(); TRY(prb) { while (!exit) { + evt_t c = get_cycles(); r->instruction_pc = m68k_getpc(); r->opcode = get_iword_cache_040(0); // "prefetch" @@ -5866,13 +5870,16 @@ static void m68k_run_3ce (void) exit = true; } - regs.instruction_cnt++; // workaround for situation when all accesses are cached - extracycles++; - if (extracycles >= 8) { - extracycles = 0; - x_do_cycles(CYCLE_UNIT); + if (c == get_cycles()) { + extracycles++; + if (extracycles >= 4) { + extracycles = 0; + x_do_cycles(CYCLE_UNIT); + } } + + regs.instruction_cnt++; } } CATCH(prb) { bus_error(); @@ -5908,10 +5915,10 @@ static void m68k_run_3p(void) (*cpufunctbl_noret[r->opcode])(r->opcode); - cpu_cycles = 1 * CYCLE_UNIT; + cpu_cycles = 2 * CYCLE_UNIT; cycles = adjust_cycles(cpu_cycles); regs.instruction_cnt++; - do_cycles(cycles); + x_do_cycles(cycles); if (r->spcflags) { if (do_specialties(0)) -- 2.47.3