diff --git a/dynamic.c b/dynamic.c index 70966aaeb2..4d7d16326b 100644 --- a/dynamic.c +++ b/dynamic.c @@ -997,19 +997,8 @@ bool rarch_environment_cb(unsigned cmd, void *data) case RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK: { - const struct retro_frame_time_callback *info = - (const struct retro_frame_time_callback*)data; - RARCH_LOG("Environ SET_FRAME_TIME_CALLBACK.\n"); - -#ifdef HAVE_NETPLAY - /* retro_run() will be called in very strange and - * mysterious ways, have to disable it. */ - if (global->netplay.enable) - return false; -#endif - - system->frame_time = *info; + runloop_ctl(RUNLOOP_CTL_SET_FRAME_TIME, data); break; } diff --git a/runloop.c b/runloop.c index 1372347e44..00be61f0cf 100644 --- a/runloop.c +++ b/runloop.c @@ -97,6 +97,7 @@ typedef struct event_cmd_state } event_cmd_state_t; + global_t *global_get_ptr(void) { static struct global g_extern; @@ -411,6 +412,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) static char runloop_fullpath[PATH_MAX_LENGTH]; static rarch_system_info_t runloop_system; static unsigned runloop_pending_windowed_scale; + static struct retro_frame_time_callback runloop_frame_time; static retro_keyboard_event_t runloop_key_event = NULL; static retro_keyboard_event_t runloop_frontend_key_event = NULL; static unsigned runloop_max_frames = false; @@ -562,6 +564,30 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) break; case RUNLOOP_CTL_IS_PERFCNT_ENABLE: return runloop_perfcnt_enable; + case RUNLOOP_CTL_SET_FRAME_TIME: + { + const struct retro_frame_time_callback *info = + (const struct retro_frame_time_callback*)data; +#ifdef HAVE_NETPLAY + global_t *global = global_get_ptr(); + + /* retro_run() will be called in very strange and + * mysterious ways, have to disable it. */ + if (global->netplay.enable) + return false; +#endif + runloop_frame_time = *info; + } + break; + case RUNLOOP_CTL_GET_FRAME_TIME: + { + struct retro_frame_time_callback **frame_time = + (struct retro_frame_time_callback**)data; + if (!frame_time) + return false; + *frame_time = (struct retro_frame_time_callback*)&runloop_frame_time; + } + break; case RUNLOOP_CTL_GET_WINDOWED_SCALE: { unsigned **scale = (unsigned**)data; @@ -1225,6 +1251,7 @@ int runloop_iterate(unsigned *sleep_ms) unsigned i; event_cmd_state_t cmd; retro_time_t current, target, to_sleep_ms; + struct retro_frame_time_callback *frame_time = NULL; event_cmd_state_t *cmd_ptr = &cmd; static retro_usec_t frame_time_last = 0; static retro_time_t frame_limit_minimum_time = 0.0; @@ -1237,7 +1264,6 @@ int runloop_iterate(unsigned *sleep_ms) cmd.state[0] = input_keys_pressed(); last_input = cmd.state[0]; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (runloop_ctl(RUNLOOP_CTL_IS_FRAME_TIME_LAST, NULL)) { @@ -1274,8 +1300,10 @@ int runloop_iterate(unsigned *sleep_ms) input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL); } } + + runloop_ctl(RUNLOOP_CTL_GET_FRAME_TIME, &frame_time); - if (system->frame_time.callback) + if (frame_time->callback) { /* Updates frame timing if frame timing callback is in use by the core. * Limits frame time if fast forward ratio throttle is enabled. */ @@ -1288,7 +1316,7 @@ int runloop_iterate(unsigned *sleep_ms) if (!frame_time_last || is_locked_fps) - delta = system->frame_time.reference; + delta = frame_time->reference; if (!is_locked_fps && runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL)) delta /= settings->slowmotion_ratio; @@ -1298,7 +1326,7 @@ int runloop_iterate(unsigned *sleep_ms) if (is_locked_fps) frame_time_last = 0; - system->frame_time.callback(delta); + frame_time->callback(delta); } cmd.state[2] = cmd.state[0] & ~cmd.state[1]; /* trigger */ @@ -1400,6 +1428,8 @@ int runloop_iterate(unsigned *sleep_ms) if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) bsv_movie_ctl(BSV_MOVIE_CTL_SET_FRAME_START, NULL); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + if (system->camera_callback.caps) driver_camera_poll(); diff --git a/runloop.h b/runloop.h index 26a44cf231..651e8aa321 100644 --- a/runloop.h +++ b/runloop.h @@ -40,6 +40,8 @@ enum runloop_ctl_state RUNLOOP_CTL_GET_WINDOWED_SCALE, RUNLOOP_CTL_SET_WINDOWED_SCALE, RUNLOOP_CTL_SET_IDLE, + RUNLOOP_CTL_GET_FRAME_TIME, + RUNLOOP_CTL_SET_FRAME_TIME, RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, RUNLOOP_CTL_SET_OVERRIDES_ACTIVE, RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, diff --git a/system.h b/system.h index ec4419bb6b..b637b1583b 100644 --- a/system.h +++ b/system.h @@ -48,8 +48,6 @@ typedef struct rarch_system_info struct retro_camera_callback camera_callback; struct retro_location_callback location_callback; - struct retro_frame_time_callback frame_time; - core_option_manager_t *core_options; struct retro_subsystem_info *special;