diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 7aeb4950ff..b9682855d9 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -815,8 +815,8 @@ void audio_driver_sample(int16_t left, int16_t right) config_get_ptr()->bools.audio_fastforward_mute, audio_st->output_samples_conv_buf, audio_st->data_ptr, - runloop_st->slowmotion, - runloop_st->fastmotion); + runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION, + runloop_st->flags & RUNLOOP_FLAG_FASTMOTION); audio_st->data_ptr = 0; } @@ -863,8 +863,8 @@ size_t audio_driver_sample_batch(const int16_t *data, size_t frames) config_get_ptr()->bools.audio_fastforward_mute, data, frames_to_write << 1, - runloop_st->slowmotion, - runloop_st->fastmotion); + runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION, + runloop_st->flags & RUNLOOP_FLAG_FASTMOTION); frames_remaining -= frames_to_write; data += frames_to_write << 1; @@ -1685,8 +1685,8 @@ void audio_driver_frame_is_reverse(void) audio_st->rewind_ptr, audio_st->rewind_size - audio_st->rewind_ptr, - runloop_st->slowmotion, - runloop_st->fastmotion); + runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION, + runloop_st->flags & RUNLOOP_FLAG_FASTMOTION); } } #endif @@ -1825,7 +1825,7 @@ void audio_driver_menu_sample(void) unsigned sample_count = (info->sample_rate / info->fps) * 2; audio_driver_state_t *audio_st = &audio_driver_st; bool check_flush = !( - runloop_st->paused + (runloop_st->paused) || !(audio_st->flags & AUDIO_FLAG_ACTIVE) || !audio_st->output_samples_buf); if ((audio_st->flags & AUDIO_FLAG_SUSPENDED)) @@ -1851,8 +1851,8 @@ void audio_driver_menu_sample(void) settings->bools.audio_fastforward_mute, samples_buf, 1024, - runloop_st->slowmotion, - runloop_st->fastmotion); + runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION, + runloop_st->flags & RUNLOOP_FLAG_FASTMOTION); sample_count -= 1024; } if ( recording_st->data && @@ -1873,7 +1873,7 @@ void audio_driver_menu_sample(void) settings->bools.audio_fastforward_mute, samples_buf, sample_count, - runloop_st->slowmotion, - runloop_st->fastmotion); + runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION, + runloop_st->flags & RUNLOOP_FLAG_FASTMOTION); } #endif diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 18457e45d4..52efcc2769 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -860,7 +860,7 @@ void rcheevos_leaderboards_enabled_changed(void) static void rcheevos_enforce_hardcore_settings(void) { /* disable slowdown */ - runloop_state_get_ptr()->slowmotion = false; + runloop_state_get_ptr()->flags &= ~RUNLOOP_FLAG_SLOWMOTION; } static void rcheevos_toggle_hardcore_active(rcheevos_locals_t* locals) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 8e7cdf3f6c..7702de5e92 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2833,7 +2833,7 @@ VIDEO_FLAG_WIDGETS_FAST_FORWARD; #endif video_info->runloop_is_paused = runloop_st->paused; - video_info->runloop_is_slowmotion = runloop_st->slowmotion; + video_info->runloop_is_slowmotion = runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION; video_info->fastforward_frameskip = settings->bools.fastforward_frameskip; video_info->input_driver_nonblock_state = input_st ? diff --git a/retroarch.c b/retroarch.c index 5bdccbbd37..ff9282cb52 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1755,15 +1755,16 @@ bool command_event(enum event_command cmd, void *data) break; #if defined(HAVE_RUNAHEAD) && (defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)) case CMD_EVENT_LOAD_SECOND_CORE: - if (!(runloop_st->flags & RUNLOOP_FLAG_CORE_RUNNING) || - !(runloop_st->runahead_secondary_core_available)) + if ( !(runloop_st->flags & RUNLOOP_FLAG_CORE_RUNNING) + || !(runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE)) return false; if (runloop_st->secondary_lib_handle) return true; if (!secondary_core_ensure_exists(settings)) { runloop_secondary_core_destroy(); - runloop_st->runahead_secondary_core_available = false; + runloop_st->flags &= + ~RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE; return false; } return true; @@ -2369,7 +2370,7 @@ bool command_event(enum event_command cmd, void *data) * runtime variables, otherwise runahead will * remain disabled until the user restarts * RetroArch */ - if (!runloop_st->runahead_available) + if (!(runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_AVAILABLE)) runloop_runahead_clear_variables(runloop_st); #endif @@ -3788,13 +3789,15 @@ int rarch_main(int argc, char *argv[], void *data) runloop_state_t *runloop_st = runloop_state_get_ptr(); video_driver_state_t *video_st = video_state_get_ptr(); #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) - video_st->flags |= VIDEO_FLAG_SHADER_PRESETS_NEED_RELOAD; + video_st->flags |= VIDEO_FLAG_SHADER_PRESETS_NEED_RELOAD; #endif #ifdef HAVE_RUNAHEAD - video_st->flags |= VIDEO_FLAG_RUNAHEAD_IS_ACTIVE; - runloop_st->runahead_available = true; - runloop_st->runahead_secondary_core_available = true; - runloop_st->runahead_force_input_dirty = true; + video_st->flags |= VIDEO_FLAG_RUNAHEAD_IS_ACTIVE; + runloop_st->flags |= ( + RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE + | RUNLOOP_FLAG_RUNAHEAD_AVAILABLE + | RUNLOOP_FLAG_RUNAHEAD_FORCE_INPUT_DIRTY + ); #endif #if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__) if (FAILED(CoInitialize(NULL))) @@ -3915,7 +3918,7 @@ void emscripten_mainloop(void) bool input_driver_nonblock_state = input_st ? (input_st->flags & INP_FLAG_NONBLOCKING) : false; runloop_state_t *runloop_st = runloop_state_get_ptr(); - bool runloop_is_slowmotion = runloop_st->slowmotion; + bool runloop_is_slowmotion = runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION; bool runloop_is_paused = runloop_st->paused; RWebAudioRecalibrateTime(); @@ -5634,7 +5637,7 @@ bool retroarch_ctl(enum rarch_ctl_state state, void *data) case RARCH_CTL_IS_SECOND_CORE_AVAILABLE: return (runloop_st->flags & RUNLOOP_FLAG_CORE_RUNNING) - && (runloop_st->runahead_secondary_core_available); + && (runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE); case RARCH_CTL_IS_SECOND_CORE_LOADED: return (runloop_st->flags & RUNLOOP_FLAG_CORE_RUNNING) @@ -5797,11 +5800,12 @@ bool retroarch_ctl(enum rarch_ctl_state state, void *data) runloop_st->perfcnt_enable = false; runloop_st->idle = false; runloop_st->paused = false; - runloop_st->slowmotion = false; #ifdef HAVE_CONFIGFILE runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE; #endif - runloop_st->flags &= ~RUNLOOP_FLAG_AUTOSAVE; + runloop_st->flags &= ~(RUNLOOP_FLAG_AUTOSAVE + | RUNLOOP_FLAG_SLOWMOTION + ); runloop_frame_time_free(); runloop_audio_buffer_status_free(); input_game_focus_free(); diff --git a/runloop.c b/runloop.c index dc16fa4c1c..2eee982648 100644 --- a/runloop.c +++ b/runloop.c @@ -1452,7 +1452,7 @@ bool runloop_environment_cb(unsigned cmd, void *data) #ifdef HAVE_RUNAHEAD if (runloop_st->core_options->updated) - runloop_st->has_variable_update = true; + runloop_st->flags |= RUNLOOP_FLAG_HAS_VARIABLE_UPDATE; #endif runloop_st->core_options->updated = false; @@ -3059,9 +3059,9 @@ bool runloop_environment_cb(unsigned cmd, void *data) #if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB) settings_t *settings = config_get_ptr(); - if (settings->bools.run_ahead_secondary_instance && - runloop_st->runahead_secondary_core_available && - secondary_core_ensure_exists(settings)) + if ( settings->bools.run_ahead_secondary_instance + && (runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE) + && secondary_core_ensure_exists(settings)) result = RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_BINARY; else #endif @@ -3094,7 +3094,7 @@ bool runloop_environment_cb(unsigned cmd, void *data) } case RETRO_ENVIRONMENT_GET_FASTFORWARDING: - *(bool *)data = runloop_st->fastmotion; + *(bool *)data = ((runloop_st->flags & RUNLOOP_FLAG_FASTMOTION) > 0); break; case RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE: @@ -3163,13 +3163,14 @@ bool runloop_environment_cb(unsigned cmd, void *data) throttle_state->mode = RETRO_THROTTLE_NONE; throttle_state->rate = core_fps; - if (runloop_st->fastmotion) + if (runloop_st->flags & RUNLOOP_FLAG_FASTMOTION) { throttle_state->mode = RETRO_THROTTLE_FAST_FORWARD; throttle_state->rate *= runloop_get_fastforward_ratio( settings, &runloop_st->fastmotion_override.current); } - else if (runloop_st->slowmotion && !no_audio) + else if ((runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION) + && !no_audio) { throttle_state->mode = RETRO_THROTTLE_SLOW_MOTION; throttle_state->rate /= (settings->floats.slowmotion_ratio > 0.0f ? @@ -4007,17 +4008,17 @@ static bool runloop_environment_secondary_core_hook( runloop_state_t *runloop_st = &runloop_state; bool result = runloop_environment_cb(cmd, data); - if (runloop_st->has_variable_update) + if (runloop_st->flags & RUNLOOP_FLAG_HAS_VARIABLE_UPDATE) { if (cmd == RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE) { bool *bool_p = (bool*)data; *bool_p = true; - runloop_st->has_variable_update = false; + runloop_st->flags &= ~RUNLOOP_FLAG_HAS_VARIABLE_UPDATE; return true; } else if (cmd == RETRO_ENVIRONMENT_GET_VARIABLE) - runloop_st->has_variable_update = false; + runloop_st->flags &= ~RUNLOOP_FLAG_HAS_VARIABLE_UPDATE; } return result; } @@ -4065,7 +4066,7 @@ static bool secondary_core_create(runloop_state_t *runloop_st, runloop_st->secondary_core.retro_set_environment( runloop_environment_secondary_core_hook); #ifdef HAVE_RUNAHEAD - runloop_st->has_variable_update = true; + runloop_st->flags |= RUNLOOP_FLAG_HAS_VARIABLE_UPDATE; #endif runloop_st->secondary_core.retro_init(); @@ -4428,7 +4429,7 @@ static int16_t input_state_with_logging(unsigned port, int16_t last_input = input_state_get_last(port, device, index, id); if (result != last_input) - runloop_st->input_is_dirty = true; + runloop_st->flags |= RUNLOOP_FLAG_INPUT_IS_DIRTY; /*arbitrary limit of up to 65536 elements in state array*/ if (id < 65536) input_state_set_last(runloop_st, port, device, index, id, result); @@ -4440,20 +4441,16 @@ static int16_t input_state_with_logging(unsigned port, static void reset_hook(void) { - runloop_state_t *runloop_st = &runloop_state; - - runloop_st->input_is_dirty = true; - + runloop_state_t *runloop_st = &runloop_state; + runloop_st->flags |= RUNLOOP_FLAG_INPUT_IS_DIRTY; if (runloop_st->retro_reset_callback_original) runloop_st->retro_reset_callback_original(); } static bool unserialize_hook(const void *buf, size_t size) { - runloop_state_t *runloop_st = &runloop_state; - - runloop_st->input_is_dirty = true; - + runloop_state_t *runloop_st = &runloop_state; + runloop_st->flags |= RUNLOOP_FLAG_INPUT_IS_DIRTY; if (runloop_st->retro_unserialize_callback_original) return runloop_st->retro_unserialize_callback_original(buf, size); return false; @@ -4525,8 +4522,8 @@ static void *runahead_save_state_alloc(void) savestate->data_const = NULL; savestate->size = 0; - if ( (runloop_st->runahead_save_state_size > 0) - && runloop_st->runahead_save_state_size_known) + if ( (runloop_st->runahead_save_state_size > 0) + && (runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_SAVE_STATE_SIZE_KNOWN)) { savestate->data = malloc(runloop_st->runahead_save_state_size); savestate->data_const = savestate->data; @@ -4550,7 +4547,7 @@ static void runahead_save_state_list_init( size_t save_state_size) { runloop_st->runahead_save_state_size = save_state_size; - runloop_st->runahead_save_state_size_known = true; + runloop_st->flags |= RUNLOOP_FLAG_RUNAHEAD_SAVE_STATE_SIZE_KNOWN; mylist_create(&runloop_st->runahead_save_state_list, 16, runahead_save_state_alloc, runahead_save_state_free); @@ -4626,11 +4623,11 @@ static void runahead_add_hooks(runloop_state_t *runloop_st) static void runahead_error(runloop_state_t *runloop_st) { - runloop_st->runahead_available = false; + runloop_st->flags &= ~RUNLOOP_FLAG_RUNAHEAD_AVAILABLE; mylist_destroy(&runloop_st->runahead_save_state_list); runahead_remove_hooks(runloop_st); runloop_st->runahead_save_state_size = 0; - runloop_st->runahead_save_state_size_known = true; + runloop_st->flags |= RUNLOOP_FLAG_RUNAHEAD_SAVE_STATE_SIZE_KNOWN; } static bool runahead_create(runloop_state_t *runloop_st) @@ -4647,15 +4644,15 @@ static bool runahead_create(runloop_state_t *runloop_st) else video_st->flags &= ~VIDEO_FLAG_RUNAHEAD_IS_ACTIVE; - if ( (runloop_st->runahead_save_state_size == 0) || - !runloop_st->runahead_save_state_size_known) + if ( (runloop_st->runahead_save_state_size == 0) + || !(runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_SAVE_STATE_SIZE_KNOWN)) { runahead_error(runloop_st); return false; } runahead_add_hooks(runloop_st); - runloop_st->runahead_force_input_dirty = true; + runloop_st->flags |= RUNLOOP_FLAG_RUNAHEAD_FORCE_INPUT_DIRTY; if (runloop_st->runahead_save_state_list) mylist_resize(runloop_st->runahead_save_state_list, 1, true); return true; @@ -4683,11 +4680,12 @@ static bool runahead_load_state(runloop_state_t *runloop_st) retro_ctx_serialize_info_t *serialize_info = (retro_ctx_serialize_info_t*) runloop_st->runahead_save_state_list->data[0]; - bool last_dirty = runloop_st->input_is_dirty; - bool ret = - core_unserialize_special(serialize_info); - - runloop_st->input_is_dirty = last_dirty; + bool last_dirty = runloop_st->flags & RUNLOOP_FLAG_INPUT_IS_DIRTY; + bool ret = core_unserialize_special(serialize_info); + if (last_dirty) + runloop_st->flags |= RUNLOOP_FLAG_INPUT_IS_DIRTY; + else + runloop_st->flags &= ~RUNLOOP_FLAG_INPUT_IS_DIRTY; if (!ret) runahead_error(runloop_st); @@ -4706,7 +4704,7 @@ static bool runahead_load_state_secondary(void) if (!secondary_core_deserialize(settings, serialize_info->data_const, serialize_info->size)) { - runloop_st->runahead_secondary_core_available = false; + runloop_st->flags &= ~RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE; runahead_error(runloop_st); return false; @@ -4757,10 +4755,11 @@ static void do_runahead( audio_driver_state_t *audio_st = audio_state_get_ptr(); - if (runahead_count <= 0 || !runloop_st->runahead_available) + if ( runahead_count <= 0 + || !(runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_AVAILABLE)) goto force_input_dirty; - if (!runloop_st->runahead_save_state_size_known) + if (!(runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_SAVE_STATE_SIZE_KNOWN)) { /* Disable runahead if current core reports * that it has an insufficient savestate @@ -4796,13 +4795,13 @@ static void do_runahead( /* Check for GUI */ /* Hack: If we were in the GUI, force a resync. */ if (frame_count != runloop_st->runahead_last_frame_count + 1) - runloop_st->runahead_force_input_dirty = true; + runloop_st->flags |= RUNLOOP_FLAG_RUNAHEAD_FORCE_INPUT_DIRTY; - runloop_st->runahead_last_frame_count = frame_count; + runloop_st->runahead_last_frame_count = frame_count; if ( !use_secondary || !have_dynamic - || !runloop_st->runahead_secondary_core_available) + || !(runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE)) { /* TODO: multiple savestates for higher performance * when not using secondary core */ @@ -4865,7 +4864,7 @@ static void do_runahead( const char *runahead_failed_str = msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_CREATE_SECONDARY_INSTANCE); runloop_secondary_core_destroy(); - runloop_st->runahead_secondary_core_available = false; + runloop_st->flags &= ~RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE; runloop_msg_queue_push(runahead_failed_str, 0, 3 * 60, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); RARCH_WARN("[Run-Ahead]: %s\n", runahead_failed_str); goto force_input_dirty; @@ -4879,10 +4878,10 @@ static void do_runahead( else video_st->flags &= ~VIDEO_FLAG_ACTIVE; - if ( runloop_st->input_is_dirty - || runloop_st->runahead_force_input_dirty) + if ( (runloop_st->flags & RUNLOOP_FLAG_INPUT_IS_DIRTY) + || (runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_FORCE_INPUT_DIRTY)) { - runloop_st->input_is_dirty = false; + runloop_st->flags &= ~RUNLOOP_FLAG_INPUT_IS_DIRTY; if (!runahead_save_state(runloop_st)) { @@ -4907,8 +4906,10 @@ static void do_runahead( video_st->flags &= ~VIDEO_FLAG_ACTIVE; audio_st->flags |= AUDIO_FLAG_SUSPENDED | AUDIO_FLAG_HARD_DISABLE; - runloop_st->runahead_secondary_core_available = - secondary_core_run_use_last_input(); + if (secondary_core_run_use_last_input()) + runloop_st->flags |= RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE; + else + runloop_st->flags &= ~RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE; audio_st->flags &= ~(AUDIO_FLAG_SUSPENDED | AUDIO_FLAG_HARD_DISABLE); if (video_st->flags & VIDEO_FLAG_RUNAHEAD_IS_ACTIVE) @@ -4919,18 +4920,20 @@ static void do_runahead( } audio_st->flags |= AUDIO_FLAG_SUSPENDED | AUDIO_FLAG_HARD_DISABLE; - runloop_st->runahead_secondary_core_available = -secondary_core_run_use_last_input(); + if (secondary_core_run_use_last_input()) + runloop_st->flags |= RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE; + else + runloop_st->flags &= ~RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE; audio_st->flags &= ~(AUDIO_FLAG_SUSPENDED | AUDIO_FLAG_HARD_DISABLE); #endif } - runloop_st->runahead_force_input_dirty= false; + runloop_st->flags &= ~RUNLOOP_FLAG_RUNAHEAD_FORCE_INPUT_DIRTY; return; force_input_dirty: core_run(); - runloop_st->runahead_force_input_dirty= true; + runloop_st->flags |= RUNLOOP_FLAG_RUNAHEAD_FORCE_INPUT_DIRTY; } #endif @@ -4942,8 +4945,8 @@ static retro_time_t runloop_core_runtime_tick( video_driver_state_t *video_st = video_state_get_ptr(); retro_time_t frame_time = (1.0 / video_st->av_info.timing.fps) * 1000000; - bool runloop_slowmotion = runloop_st->slowmotion; - bool runloop_fastmotion = runloop_st->fastmotion; + bool runloop_slowmotion = runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION; + bool runloop_fastmotion = runloop_st->flags & RUNLOOP_FLAG_FASTMOTION; /* Account for slow motion */ if (runloop_slowmotion) @@ -5013,30 +5016,32 @@ static void runloop_apply_fastmotion_override(runloop_state_t *runloop_st, setti sizeof(runloop_st->fastmotion_override.current)); /* Check if 'fastmotion' state has changed */ - if (runloop_st->fastmotion != + if (((runloop_st->flags & RUNLOOP_FLAG_FASTMOTION) > 0) != runloop_st->fastmotion_override.current.fastforward) { input_driver_state_t *input_st = input_state_get_ptr(); - runloop_st->fastmotion = - runloop_st->fastmotion_override.current.fastforward; + if (runloop_st->fastmotion_override.current.fastforward) + runloop_st->flags |= RUNLOOP_FLAG_FASTMOTION; + else + runloop_st->flags &= ~RUNLOOP_FLAG_FASTMOTION; if (input_st) { - if (runloop_st->fastmotion) + if (runloop_st->flags & RUNLOOP_FLAG_FASTMOTION) input_st->flags |= INP_FLAG_NONBLOCKING; else input_st->flags &= ~INP_FLAG_NONBLOCKING; } - if (!runloop_st->fastmotion) + if (!(runloop_st->flags & RUNLOOP_FLAG_FASTMOTION)) runloop_st->fastforward_after_frames = 1; driver_set_nonblock_state(); /* Reset frame time counter when toggling * fast-forward off, if required */ - if (!runloop_st->fastmotion && - frame_time_counter_reset_after_fastforwarding) + if ( !(runloop_st->flags & RUNLOOP_FLAG_FASTMOTION) + && frame_time_counter_reset_after_fastforwarding) video_st->frame_time_count = 0; /* Ensure fast forward widget is disabled when @@ -5044,7 +5049,8 @@ static void runloop_apply_fastmotion_override(runloop_state_t *runloop_st, setti * (required if RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE * is called during core de-initialisation) */ #if defined(HAVE_GFX_WIDGETS) - if (p_dispwidget->active && !runloop_st->fastmotion) + if ( p_dispwidget->active + && !(runloop_st->flags & RUNLOOP_FLAG_FASTMOTION)) video_st->flags &= ~VIDEO_FLAG_WIDGETS_FAST_FORWARD; #endif } @@ -5633,14 +5639,14 @@ bool runloop_event_init_core( void runloop_runahead_clear_variables(runloop_state_t *runloop_st) { video_driver_state_t - *video_st = video_state_get_ptr(); - runloop_st->runahead_save_state_size = 0; - runloop_st->runahead_save_state_size_known = false; - video_st->flags |= VIDEO_FLAG_RUNAHEAD_IS_ACTIVE; - runloop_st->runahead_available = true; - runloop_st->runahead_secondary_core_available = true; - runloop_st->runahead_force_input_dirty = true; - runloop_st->runahead_last_frame_count = 0; + *video_st = video_state_get_ptr(); + runloop_st->runahead_save_state_size = 0; + runloop_st->flags &= ~RUNLOOP_FLAG_RUNAHEAD_SAVE_STATE_SIZE_KNOWN; + video_st->flags |= VIDEO_FLAG_RUNAHEAD_IS_ACTIVE; + runloop_st->flags |= RUNLOOP_FLAG_RUNAHEAD_AVAILABLE + | RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE + | RUNLOOP_FLAG_RUNAHEAD_FORCE_INPUT_DIRTY; + runloop_st->runahead_last_frame_count = 0; } #endif @@ -7322,21 +7328,21 @@ MENU_ST_FLAG_IS_BINDING; if (input_st->flags & INP_FLAG_NONBLOCKING) { input_st->flags &= ~INP_FLAG_NONBLOCKING; - runloop_st->fastmotion = false; + runloop_st->flags &= ~RUNLOOP_FLAG_FASTMOTION; runloop_st->fastforward_after_frames = 1; } else { input_st->flags |= INP_FLAG_NONBLOCKING; - runloop_st->fastmotion = true; + runloop_st->flags |= RUNLOOP_FLAG_FASTMOTION; } driver_set_nonblock_state(); /* Reset frame time counter when toggling * fast-forward off, if required */ - if (!runloop_st->fastmotion && - settings->bools.frame_time_counter_reset_after_fastforwarding) + if ( !(runloop_st->flags & RUNLOOP_FLAG_FASTMOTION) + && settings->bools.frame_time_counter_reset_after_fastforwarding) video_st->frame_time_count = 0; } @@ -7355,7 +7361,7 @@ MENU_ST_FLAG_IS_BINDING; { if (settings->bools.notification_show_fast_forward) { - if (runloop_st->fastmotion) + if (runloop_st->flags & RUNLOOP_FLAG_FASTMOTION) video_st->flags |= VIDEO_FLAG_WIDGETS_FAST_FORWARD; else video_st->flags &= ~VIDEO_FLAG_WIDGETS_FAST_FORWARD; @@ -7368,8 +7374,8 @@ MENU_ST_FLAG_IS_BINDING; { /* > If widgets are disabled, display fast-forward * status via OSD text for 1 frame every frame */ - if (runloop_st->fastmotion && - settings->bools.notification_show_fast_forward) + if ( (runloop_st->flags & RUNLOOP_FLAG_FASTMOTION) + && settings->bools.notification_show_fast_forward) runloop_msg_queue_push( msg_hash_to_str(MSG_FAST_FORWARD), 1, 1, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); } @@ -7476,11 +7482,21 @@ MENU_ST_FLAG_IS_BINDING; current_bits, RARCH_SLOWMOTION_HOLD_KEY); if (new_slowmotion_button_state && !old_slowmotion_button_state) - runloop_st->slowmotion = !runloop_st->slowmotion; + { + if (!(runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION)) + runloop_st->flags |= RUNLOOP_FLAG_SLOWMOTION; + else + runloop_st->flags &= ~RUNLOOP_FLAG_SLOWMOTION; + } else if (old_slowmotion_hold_button_state != new_slowmotion_hold_button_state) - runloop_st->slowmotion = new_slowmotion_hold_button_state; + { + if (new_slowmotion_hold_button_state) + runloop_st->flags |= RUNLOOP_FLAG_SLOWMOTION; + else + runloop_st->flags &= ~RUNLOOP_FLAG_SLOWMOTION; + } - if (runloop_st->slowmotion) + if (runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION) { if (settings->uints.video_black_frame_insertion) if (!runloop_st->idle) @@ -7694,7 +7710,7 @@ int runloop_iterate(void) { runloop_st->frame_time_last = current; - if (runloop_st->slowmotion) + if (runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION) delta /= slowmotion_ratio; } @@ -7890,13 +7906,13 @@ int runloop_iterate(void) video_st->frame_count % frame_time_interval == 0; /* A few frames need to get ignored after slowmotion is disabled */ - if (!runloop_st->slowmotion && slowmotion_prev) + if (!(runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION) && slowmotion_prev) skip_frames = frame_time_interval * 2; if (skip_frames) skip_frames--; - slowmotion_prev = runloop_st->slowmotion; + slowmotion_prev = runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION; /* Always skip when slowmotion is active */ if (slowmotion_prev) skip_frames = 1; @@ -7948,10 +7964,12 @@ int runloop_iterate(void) bool run_ahead_hide_warnings = settings->bools.run_ahead_hide_warnings; bool run_ahead_secondary_instance = settings->bools.run_ahead_secondary_instance; /* Run Ahead Feature replaces the call to core_run in this loop */ - bool want_runahead = run_ahead_enabled && - (run_ahead_num_frames > 0) && runloop_st->runahead_available; + bool want_runahead = run_ahead_enabled + && (run_ahead_num_frames > 0) + && (runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_AVAILABLE); #ifdef HAVE_NETWORKING - want_runahead = want_runahead && !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL); + want_runahead = want_runahead + && !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL); #endif if (want_runahead) @@ -8052,7 +8070,7 @@ end: } } - if (runloop_st->fastmotion) + if (runloop_st->flags & RUNLOOP_FLAG_FASTMOTION) runloop_st->frame_limit_minimum_time = runloop_set_frame_limit(&video_st->av_info, runloop_get_fastforward_ratio(settings, @@ -8314,8 +8332,9 @@ bool core_set_cheat(retro_ctx_cheat_info_t *info) run_ahead_enabled = settings->bools.run_ahead_enabled; run_ahead_frames = settings->uints.run_ahead_frames; run_ahead_secondary_instance = settings->bools.run_ahead_secondary_instance; - want_runahead = run_ahead_enabled && - (run_ahead_frames > 0) && runloop_st->runahead_available; + want_runahead = run_ahead_enabled + && (run_ahead_frames > 0) + && (runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_AVAILABLE); #ifdef HAVE_NETWORKING if (want_runahead) want_runahead = !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL); @@ -8326,11 +8345,11 @@ bool core_set_cheat(retro_ctx_cheat_info_t *info) runloop_st->current_core.retro_cheat_set(info->index, info->enabled, info->code); #if defined(HAVE_RUNAHEAD) && (defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)) - if ( want_runahead - && run_ahead_secondary_instance - && runloop_st->runahead_secondary_core_available - && secondary_core_ensure_exists(settings) - && runloop_st->secondary_core.retro_cheat_set) + if ( (want_runahead) + && (run_ahead_secondary_instance) + && (runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE) + && (secondary_core_ensure_exists(settings)) + && (runloop_st->secondary_core.retro_cheat_set)) runloop_st->secondary_core.retro_cheat_set( info->index, info->enabled, info->code); #endif @@ -8353,8 +8372,9 @@ bool core_reset_cheat(void) run_ahead_enabled = settings->bools.run_ahead_enabled; run_ahead_frames = settings->uints.run_ahead_frames; run_ahead_secondary_instance = settings->bools.run_ahead_secondary_instance; - want_runahead = run_ahead_enabled && - (run_ahead_frames > 0) && runloop_st->runahead_available; + want_runahead = run_ahead_enabled + && (run_ahead_frames > 0) + && (runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_AVAILABLE); #ifdef HAVE_NETWORKING if (want_runahead) want_runahead = !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL); @@ -8365,11 +8385,11 @@ bool core_reset_cheat(void) runloop_st->current_core.retro_cheat_reset(); #if defined(HAVE_RUNAHEAD) && (defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)) - if ( want_runahead - && run_ahead_secondary_instance - && runloop_st->runahead_secondary_core_available - && secondary_core_ensure_exists(settings) - && runloop_st->secondary_core.retro_cheat_reset) + if ( (want_runahead) + && (run_ahead_secondary_instance) + && (runloop_st->flags & RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE) + && (secondary_core_ensure_exists(settings)) + && (runloop_st->secondary_core.retro_cheat_reset)) runloop_st->secondary_core.retro_cheat_reset(); #endif diff --git a/runloop.h b/runloop.h index 027bd1a2bb..3fae73857d 100644 --- a/runloop.h +++ b/runloop.h @@ -133,25 +133,33 @@ typedef struct my_list_t enum runloop_flags { - RUNLOOP_FLAG_MAX_FRAMES_SCREENSHOT = (1 << 0), - RUNLOOP_FLAG_HAS_SET_CORE = (1 << 1), - RUNLOOP_FLAG_CORE_SET_SHARED_CONTEXT = (1 << 2), - RUNLOOP_FLAG_IGNORE_ENVIRONMENT_CB = (1 << 3), - RUNLOOP_FLAG_IS_SRAM_LOAD_DISABLED = (1 << 4), - RUNLOOP_FLAG_IS_SRAM_SAVE_DISABLED = (1 << 5), - RUNLOOP_FLAG_USE_SRAM = (1 << 6), - RUNLOOP_FLAG_PATCH_BLOCKED = (1 << 7), - RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE = (1 << 8), - RUNLOOP_FLAG_OVERRIDES_ACTIVE = (1 << 9), - RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE = (1 << 10), - RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE = (1 << 11), - RUNLOOP_FLAG_REMAPS_CORE_ACTIVE = (1 << 12), - RUNLOOP_FLAG_REMAPS_GAME_ACTIVE = (1 << 13), - RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE = (1 << 14), - RUNLOOP_FLAG_SHUTDOWN_INITIATED = (1 << 15), - RUNLOOP_FLAG_CORE_SHUTDOWN_INITIATED = (1 << 16), - RUNLOOP_FLAG_CORE_RUNNING = (1 << 17), - RUNLOOP_FLAG_AUTOSAVE = (1 << 18) + RUNLOOP_FLAG_MAX_FRAMES_SCREENSHOT = (1 << 0), + RUNLOOP_FLAG_HAS_SET_CORE = (1 << 1), + RUNLOOP_FLAG_CORE_SET_SHARED_CONTEXT = (1 << 2), + RUNLOOP_FLAG_IGNORE_ENVIRONMENT_CB = (1 << 3), + RUNLOOP_FLAG_IS_SRAM_LOAD_DISABLED = (1 << 4), + RUNLOOP_FLAG_IS_SRAM_SAVE_DISABLED = (1 << 5), + RUNLOOP_FLAG_USE_SRAM = (1 << 6), + RUNLOOP_FLAG_PATCH_BLOCKED = (1 << 7), + RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE = (1 << 8), + RUNLOOP_FLAG_OVERRIDES_ACTIVE = (1 << 9), + RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE = (1 << 10), + RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE = (1 << 11), + RUNLOOP_FLAG_REMAPS_CORE_ACTIVE = (1 << 12), + RUNLOOP_FLAG_REMAPS_GAME_ACTIVE = (1 << 13), + RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE = (1 << 14), + RUNLOOP_FLAG_SHUTDOWN_INITIATED = (1 << 15), + RUNLOOP_FLAG_CORE_SHUTDOWN_INITIATED = (1 << 16), + RUNLOOP_FLAG_CORE_RUNNING = (1 << 17), + RUNLOOP_FLAG_AUTOSAVE = (1 << 18), + RUNLOOP_FLAG_HAS_VARIABLE_UPDATE = (1 << 19), + RUNLOOP_FLAG_INPUT_IS_DIRTY = (1 << 20), + RUNLOOP_FLAG_RUNAHEAD_SAVE_STATE_SIZE_KNOWN = (1 << 21), + RUNLOOP_FLAG_RUNAHEAD_AVAILABLE = (1 << 22), + RUNLOOP_FLAG_RUNAHEAD_SECONDARY_CORE_AVAILABLE = (1 << 23), + RUNLOOP_FLAG_RUNAHEAD_FORCE_INPUT_DIRTY = (1 << 24), + RUNLOOP_FLAG_SLOWMOTION = (1 << 25), + RUNLOOP_FLAG_FASTMOTION = (1 << 26) }; struct runloop @@ -291,17 +299,7 @@ struct runloop bool paused; bool idle; bool focused; - bool slowmotion; - bool fastmotion; bool perfcnt_enable; -#ifdef HAVE_RUNAHEAD - bool has_variable_update; - bool input_is_dirty; - bool runahead_save_state_size_known; - bool runahead_available; - bool runahead_secondary_core_available; - bool runahead_force_input_dirty; -#endif }; typedef struct runloop runloop_state_t;