From 7ec06a744bbfb00dbab597fcc3d60908950bb205 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 15 Feb 2020 16:51:15 +0200 Subject: [PATCH] Support CPU frequency multpliers in prefetch mode. --- cfgfile.cpp | 4 ++++ newcpu.cpp | 16 ++++++++++++---- od-win32/win32gui.cpp | 32 +++++++++++++++++--------------- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/cfgfile.cpp b/cfgfile.cpp index e3097701..00e29c3e 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -8164,6 +8164,10 @@ static void set_68020_compa (struct uae_prefs *p, int compa, int cd32) case 2: p->cpu_compatible = true; p->m68k_speed = 0; + if (p->cpu_model == 68020) + p->cpu_clock_multiplier = 4 << 8; + else + p->cpu_clock_multiplier = 5 << 8; break; case 3: p->cpu_compatible = 0; diff --git a/newcpu.cpp b/newcpu.cpp index 29ea2eb8..f6fcd78f 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -1949,7 +1949,7 @@ static unsigned long cycles_mult; static void update_68k_cycles (void) { cycles_mult = 0; - if (currprefs.m68k_speed >= 0 && !currprefs.cpu_cycle_exact) { + if (currprefs.m68k_speed >= 0 && !currprefs.cpu_cycle_exact && !currprefs.cpu_compatible) { if (currprefs.m68k_speed_throttle < 0) { cycles_mult = (unsigned long)(CYCLES_DIV * 1000 / (1000 + currprefs.m68k_speed_throttle)); } else if (currprefs.m68k_speed_throttle > 0) { @@ -1998,7 +1998,15 @@ static void update_68k_cycles (void) } if (cpucycleunit < 1) cpucycleunit = 1; - if (currprefs.cpu_cycle_exact) + if (!currprefs.cpu_cycle_exact && currprefs.cpu_compatible) { + if (cpucycleunit == CYCLE_UNIT / 2) { + cycles_mult = 0; + } else { + cycles_mult = cpucycleunit * (CYCLES_DIV / (CYCLE_UNIT / 2)); + } + } + + if (currprefs.cpu_cycle_exact || currprefs.cpu_compatible) write_log (_T("CPU cycleunit: %d (%.3f)\n"), cpucycleunit, (float)cpucycleunit / CYCLE_UNIT); set_config_changed (); } @@ -4520,12 +4528,12 @@ static void m68k_run_1 (void) if (debug_opcode_watch) { debug_trainer_match(); } - do_cycles (cpu_cycles); r->instruction_pc = m68k_getpc (); cpu_cycles = (*cpufunctbl[r->opcode])(r->opcode) & 0xffff; if (!regs.loop_mode) regs.ird = regs.opcode; cpu_cycles = adjust_cycles (cpu_cycles); + do_cycles(cpu_cycles); regs.instruction_cnt++; if (r->spcflags) { if (do_specialties (cpu_cycles)) @@ -5810,7 +5818,7 @@ static void m68k_run_2p (void) } else { - cpu_cycles = (*cpufunctbl[r->opcode])(r->opcode) >> 16; + cpu_cycles = (*cpufunctbl[r->opcode])(r->opcode); cpu_cycles = adjust_cycles (cpu_cycles); regs.instruction_cnt++; diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 93959b8d..1e0b6d26 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -12557,7 +12557,7 @@ static void enable_for_cpudlg (HWND hDlg) #if 0 ew(hDlg, IDC_CPU_MULTIPLIER, workprefs.cpu_cycle_exact); #endif - ew(hDlg, IDC_CPU_FREQUENCY, workprefs.cpu_cycle_exact && workprefs.m68k_speed >= 0); + ew(hDlg, IDC_CPU_FREQUENCY, (workprefs.cpu_cycle_exact || workprefs.cpu_compatible) && workprefs.m68k_speed >= 0); ew(hDlg, IDC_CPU_FREQUENCY2, workprefs.cpu_cycle_exact && !workprefs.cpu_clock_multiplier && workprefs.m68k_speed >= 0); ew(hDlg, IDC_FPU1, workprefs.cpu_model < 68040 && (workprefs.cpu_model >= 68020 || !workprefs.cpu_compatible)); @@ -12641,13 +12641,11 @@ static void values_to_cpudlg (HWND hDlg) CheckRadioButton (hDlg, IDC_MMUENABLEOFF, IDC_MMUENABLE, mmu == 0 ? IDC_MMUENABLEOFF : (mmu && workprefs.mmu_ec) ? IDC_MMUENABLEEC : IDC_MMUENABLE); CheckDlgButton(hDlg, IDC_CPU_PPC, workprefs.ppc_mode || is_ppc_cpu(&workprefs)); - if (workprefs.cpu_cycle_exact) { - if (workprefs.cpu_clock_multiplier) { - TCHAR txt[20]; - double f = getcpufreq (workprefs.cpu_clock_multiplier); - _stprintf (txt, _T("%.6f"), f / 1000000.0); - SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY2, WM_SETTEXT, 0, (LPARAM)txt); - } + if ((workprefs.cpu_cycle_exact || workprefs.cpu_compatible) && workprefs.cpu_clock_multiplier) { + TCHAR txt[20]; + double f = getcpufreq (workprefs.cpu_clock_multiplier); + _stprintf (txt, _T("%.6f"), f / 1000000.0); + SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY2, WM_SETTEXT, 0, (LPARAM)txt); } else { SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY2, WM_SETTEXT, 0, (LPARAM)_T("")); } @@ -12822,12 +12820,12 @@ static void values_from_cpudlg (HWND hDlg) workprefs.cpu_clock_multiplier = 0; if (idx < 4) { workprefs.cpu_clock_multiplier = (1 << 8) << idx; - } else { + } else if (workprefs.cpu_cycle_exact) { TCHAR txt[20]; txt[0] = 0; - SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY2, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt); + SendDlgItemMessage(hDlg, IDC_CPU_FREQUENCY2, WM_GETTEXT, (WPARAM)sizeof(txt) / sizeof(TCHAR), (LPARAM)txt); workprefs.cpu_clock_multiplier = 0; - workprefs.cpu_frequency = (int)(_tstof (txt) * 1000000.0); + workprefs.cpu_frequency = (int)(_tstof(txt) * 1000000.0); if (workprefs.cpu_frequency < 1 * 1000000) workprefs.cpu_frequency = 0; if (workprefs.cpu_frequency >= 99 * 1000000) @@ -12861,7 +12859,9 @@ static INT_PTR CALLBACK CPUDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY, CB_ADDSTRING, 0, (LPARAM)_T("2x (A500)")); SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY, CB_ADDSTRING, 0, (LPARAM)_T("4x (A1200)")); SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY, CB_ADDSTRING, 0, (LPARAM)_T("8x")); - SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY, CB_ADDSTRING, 0, (LPARAM)_T("Custom")); + if (workprefs.cpu_cycle_exact) { + SendDlgItemMessage(hDlg, IDC_CPU_FREQUENCY, CB_ADDSTRING, 0, (LPARAM)_T("Custom")); + } SendDlgItemMessage(hDlg, IDC_FPU_MODE, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(hDlg, IDC_FPU_MODE, CB_ADDSTRING, 0, (LPARAM)_T("Host (64-bit)")); @@ -12882,12 +12882,14 @@ static INT_PTR CALLBACK CPUDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l idx = 2; // A1200 } if (!workprefs.cpu_cycle_exact) { - idx = 3; - workprefs.cpu_clock_multiplier = 0; workprefs.cpu_frequency = 0; + if (!workprefs.cpu_clock_multiplier && (idx == 1 || idx == 2)) { + workprefs.cpu_clock_multiplier = (1 << idx) << 8; + } } else { - if (!workprefs.cpu_frequency && (idx == 1 || idx == 2)) + if (!workprefs.cpu_frequency && (idx == 1 || idx == 2)) { workprefs.cpu_clock_multiplier = (1 << idx) << 8; + } } SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY, CB_SETCURSEL, idx, 0); if (!workprefs.cpu_clock_multiplier) { -- 2.47.3