mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
Create RUNLOOP_CTL_{GET/SET}_FRAME_TIME
This commit is contained in:
parent
81e13aa2c1
commit
9ba753993b
13
dynamic.c
13
dynamic.c
@ -997,19 +997,8 @@ bool rarch_environment_cb(unsigned cmd, void *data)
|
|||||||
|
|
||||||
case RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK:
|
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");
|
RARCH_LOG("Environ SET_FRAME_TIME_CALLBACK.\n");
|
||||||
|
runloop_ctl(RUNLOOP_CTL_SET_FRAME_TIME, data);
|
||||||
#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;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
38
runloop.c
38
runloop.c
@ -97,6 +97,7 @@ typedef struct event_cmd_state
|
|||||||
} event_cmd_state_t;
|
} event_cmd_state_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
global_t *global_get_ptr(void)
|
global_t *global_get_ptr(void)
|
||||||
{
|
{
|
||||||
static struct global g_extern;
|
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 char runloop_fullpath[PATH_MAX_LENGTH];
|
||||||
static rarch_system_info_t runloop_system;
|
static rarch_system_info_t runloop_system;
|
||||||
static unsigned runloop_pending_windowed_scale;
|
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_key_event = NULL;
|
||||||
static retro_keyboard_event_t runloop_frontend_key_event = NULL;
|
static retro_keyboard_event_t runloop_frontend_key_event = NULL;
|
||||||
static unsigned runloop_max_frames = false;
|
static unsigned runloop_max_frames = false;
|
||||||
@ -562,6 +564,30 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
|||||||
break;
|
break;
|
||||||
case RUNLOOP_CTL_IS_PERFCNT_ENABLE:
|
case RUNLOOP_CTL_IS_PERFCNT_ENABLE:
|
||||||
return runloop_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:
|
case RUNLOOP_CTL_GET_WINDOWED_SCALE:
|
||||||
{
|
{
|
||||||
unsigned **scale = (unsigned**)data;
|
unsigned **scale = (unsigned**)data;
|
||||||
@ -1225,6 +1251,7 @@ int runloop_iterate(unsigned *sleep_ms)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
event_cmd_state_t cmd;
|
event_cmd_state_t cmd;
|
||||||
retro_time_t current, target, to_sleep_ms;
|
retro_time_t current, target, to_sleep_ms;
|
||||||
|
struct retro_frame_time_callback *frame_time = NULL;
|
||||||
event_cmd_state_t *cmd_ptr = &cmd;
|
event_cmd_state_t *cmd_ptr = &cmd;
|
||||||
static retro_usec_t frame_time_last = 0;
|
static retro_usec_t frame_time_last = 0;
|
||||||
static retro_time_t frame_limit_minimum_time = 0.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();
|
cmd.state[0] = input_keys_pressed();
|
||||||
last_input = cmd.state[0];
|
last_input = cmd.state[0];
|
||||||
|
|
||||||
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
|
|
||||||
|
|
||||||
if (runloop_ctl(RUNLOOP_CTL_IS_FRAME_TIME_LAST, NULL))
|
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);
|
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.
|
/* Updates frame timing if frame timing callback is in use by the core.
|
||||||
* Limits frame time if fast forward ratio throttle is enabled. */
|
* 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)
|
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))
|
if (!is_locked_fps && runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL))
|
||||||
delta /= settings->slowmotion_ratio;
|
delta /= settings->slowmotion_ratio;
|
||||||
@ -1298,7 +1326,7 @@ int runloop_iterate(unsigned *sleep_ms)
|
|||||||
if (is_locked_fps)
|
if (is_locked_fps)
|
||||||
frame_time_last = 0;
|
frame_time_last = 0;
|
||||||
|
|
||||||
system->frame_time.callback(delta);
|
frame_time->callback(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.state[2] = cmd.state[0] & ~cmd.state[1]; /* trigger */
|
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))
|
if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
||||||
bsv_movie_ctl(BSV_MOVIE_CTL_SET_FRAME_START, NULL);
|
bsv_movie_ctl(BSV_MOVIE_CTL_SET_FRAME_START, NULL);
|
||||||
|
|
||||||
|
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
|
||||||
|
|
||||||
if (system->camera_callback.caps)
|
if (system->camera_callback.caps)
|
||||||
driver_camera_poll();
|
driver_camera_poll();
|
||||||
|
|
||||||
|
@ -40,6 +40,8 @@ enum runloop_ctl_state
|
|||||||
RUNLOOP_CTL_GET_WINDOWED_SCALE,
|
RUNLOOP_CTL_GET_WINDOWED_SCALE,
|
||||||
RUNLOOP_CTL_SET_WINDOWED_SCALE,
|
RUNLOOP_CTL_SET_WINDOWED_SCALE,
|
||||||
RUNLOOP_CTL_SET_IDLE,
|
RUNLOOP_CTL_SET_IDLE,
|
||||||
|
RUNLOOP_CTL_GET_FRAME_TIME,
|
||||||
|
RUNLOOP_CTL_SET_FRAME_TIME,
|
||||||
RUNLOOP_CTL_IS_OVERRIDES_ACTIVE,
|
RUNLOOP_CTL_IS_OVERRIDES_ACTIVE,
|
||||||
RUNLOOP_CTL_SET_OVERRIDES_ACTIVE,
|
RUNLOOP_CTL_SET_OVERRIDES_ACTIVE,
|
||||||
RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE,
|
RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE,
|
||||||
|
2
system.h
2
system.h
@ -48,8 +48,6 @@ typedef struct rarch_system_info
|
|||||||
struct retro_camera_callback camera_callback;
|
struct retro_camera_callback camera_callback;
|
||||||
struct retro_location_callback location_callback;
|
struct retro_location_callback location_callback;
|
||||||
|
|
||||||
struct retro_frame_time_callback frame_time;
|
|
||||||
|
|
||||||
core_option_manager_t *core_options;
|
core_option_manager_t *core_options;
|
||||||
|
|
||||||
struct retro_subsystem_info *special;
|
struct retro_subsystem_info *special;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user