void update_autoframeskip(void) { // don't adjust frameskip if we're paused or if the debugger was // visible this cycle or if we haven't run yet if (!game_was_paused && !debugger_was_visible && cpu_getcurrentframe() > 2 * FRAMESKIP_LEVELS) { const struct performance_info *performance = mame_get_performance_info(); // if we're too fast, attempt to increase the frameskip if (performance->game_speed_percent >= 99.5) { frameskipadjust++; // but only after 3 consecutive frames where we are too fast if (frameskipadjust >= 3) { frameskipadjust = 0; if (frameskip > 0) frameskip--; } } // if we're too slow, attempt to increase the frameskip else { // if below 80% speed, be more aggressive if (performance->game_speed_percent < 80) frameskipadjust -= (int)((90. - performance->game_speed_percent) / 5.); // if we're close, only force it up to frameskip 8 else if (frameskip < 8) frameskipadjust--; // perform the adjustment while (frameskipadjust <= -2) { frameskipadjust += 2; if (frameskip < FRAMESKIP_LEVELS - 1) frameskip++; } } } // clear the other states game_was_paused = game_is_paused; debugger_was_visible = 0; }
static void update_autoframeskip(void) { // skip if paused if (mame_is_paused(Machine)) return; // don't adjust frameskip if we're paused or if the debugger was // visible this cycle or if we haven't run yet if (cpu_getcurrentframe() > 2 * FRAMESKIP_LEVELS) { const performance_info *performance = mame_get_performance_info(); // if we're too fast, attempt to increase the frameskip if (performance->game_speed_percent >= 99.5) { frameskipadjust++; // but only after 3 consecutive frames where we are too fast if (frameskipadjust >= 3) { frameskipadjust = 0; if (video_config.frameskip > 0) video_config.frameskip--; } } // if we're too slow, attempt to increase the frameskip else { // if below 80% speed, be more aggressive if (performance->game_speed_percent < 80) frameskipadjust -= (90 - performance->game_speed_percent) / 5; // if we're close, only force it up to frameskip 8 else if (video_config.frameskip < 8) frameskipadjust--; // perform the adjustment while (frameskipadjust <= -2) { frameskipadjust += 2; if (video_config.frameskip < FRAMESKIP_LEVELS - 1) video_config.frameskip++; } } } }