Compare commits

...
Author SHA1 Message Date
markwkidd 86676fd030 streamline 2026-10-23 08:49:42 -04:00
markwkidd 101a3c4615 only set cpu clock scale from core option when the value changes
Ensure CPU clock scale is only applied when changed and reset on game unload.

Currently this core calls cpunum_set_clockscale each frame with the value that is currently set by the CPU core option.

This in theory could cause a minor bug when a cheat code later alters the value of a CPU as some of them do. I haven't experienced this bug personally.

My PR also helps make it easier to reintegrate the legacy MAME menu for setting CPU clock values.

One thing I think I'm discovering is that MAME 0.78 doesn't seem to save CPU clock value settings in a file in order to persist. Possibly I am not understanding how that is persistent, yet.
2026-10-23 08:45:55 -04:00
+8 -6
View File
@@ -38,6 +38,7 @@ int orig_samples_per_frame = 0;
short* samples_buffer;
short* conversion_buffer;
int usestereo = 1;
static double applied_cpu_clock_scale = 0; /* last cpu_clock_scale core option value applied to CPU 0 */
/* MAME data structures to store and translate keyboard state */
@@ -397,13 +398,14 @@ void retro_run (void)
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
update_variables(false);
if (options.cpu_clock_scale)
/* only apply the core option when its value changes, so that other changes to
CPU 0's clock scale (for example cheats or the MAME overclock UI) are not
overwritten every frame */
if (options.cpu_clock_scale && options.cpu_clock_scale != applied_cpu_clock_scale)
{
if (cpunum_get_clockscale(0) != options.cpu_clock_scale)
{
log_cb(RETRO_LOG_DEBUG, LOGPRE "changing cpu clock scale from %lf to %lf\n",cpunum_get_clockscale(0),options.cpu_clock_scale);
cpunum_set_clockscale(0, options.cpu_clock_scale);
}
log_cb(RETRO_LOG_DEBUG, LOGPRE "changing cpu clock scale from %lf to %lf\n",cpunum_get_clockscale(0),options.cpu_clock_scale);
cpunum_set_clockscale(0, options.cpu_clock_scale);
applied_cpu_clock_scale = options.cpu_clock_scale;
}
mame_frame();
if(frameskip_counter <= 11)