diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 0b2f9ccb17..5afc6002dd 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -25,7 +25,6 @@ #include "d3d.h" #include "../video_viewport.h" #include "../video_monitor.h" -#include "../../runloop.h" #include "../../dynamic.h" #include "render_chain_driver.h" @@ -1633,7 +1632,6 @@ static bool d3d_frame(void *data, const void *frame, unsigned i = 0; d3d_video_t *d3d = (d3d_video_t*)data; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; - runloop_t *runloop = rarch_main_get_ptr(); driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); const font_renderer_t *font_ctx = driver->font_osd_driver; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 2488ba4407..3a121d9b34 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -837,10 +837,10 @@ void video_driver_get_video_output_prev(void) void video_driver_cached_frame(void) { driver_t *driver = driver_get_ptr(); - runloop_t *runloop = rarch_main_get_ptr(); + global_t *global = global_get_ptr(); void *recording = driver ? driver->recording_data : NULL; - if (runloop->is_idle) + if (global->is_idle) return; /* Cannot allow recording when pushing duped frames. */ diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 547b18a613..f88aec840b 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -295,7 +295,7 @@ static void engine_handle_cmd(void) { int8_t cmd; struct android_app *android_app = (struct android_app*)g_android; - runloop_t *runloop = rarch_main_get_ptr(); + global_t *global = global_get_ptr(); driver_t *driver = driver_get_ptr(); rarch_system_info_t *system = rarch_system_info_get_ptr(); @@ -331,7 +331,7 @@ static void engine_handle_cmd(void) scond_broadcast(android_app->cond); slock_unlock(android_app->mutex); - if (runloop->is_paused) + if (global->is_paused) event_command(EVENT_CMD_REINIT); break; @@ -358,8 +358,8 @@ static void engine_handle_cmd(void) if (!system->shutdown) { RARCH_LOG("Pausing RetroArch.\n"); - runloop->is_paused = true; - runloop->is_idle = true; + global->is_paused = true; + global->is_idle = true; } break; @@ -388,8 +388,8 @@ static void engine_handle_cmd(void) break; case APP_CMD_GAINED_FOCUS: - runloop->is_paused = false; - runloop->is_idle = false; + global->is_paused = false; + global->is_idle = false; if ((android_app->sensor_state_mask & (UINT64_C(1) << RETRO_SENSOR_ACCELEROMETER_ENABLE)) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 3fc25e3be1..9958efbe43 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -34,7 +34,6 @@ #include "../menu_video.h" #include "../../configuration.h" -#include "../../runloop.h" #include "../../gfx/drivers_font_renderer/bitmap.h" #define RGUI_TERM_START_X (frame_buf->width / 21) @@ -374,8 +373,8 @@ static void rgui_render(void) menu_display_t *disp = menu_display_get_ptr(); menu_framebuf_t *frame_buf = menu_display_fb_get_ptr(); menu_navigation_t *nav = menu_navigation_get_ptr(); - runloop_t *runloop = rarch_main_get_ptr(); driver_t *driver = driver_get_ptr(); + global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); menu_animation_t *anim = menu_animation_get_ptr(); uint64_t frame_count = video_driver_get_frame_count(); @@ -398,7 +397,7 @@ static void rgui_render(void) if (menu_entries_needs_refresh() && menu_driver_alive() && !disp->msg_force) return; - if (runloop->is_idle) + if (global->is_idle) return; if (!menu_display_update_pending()) diff --git a/menu/menu.c b/menu/menu.c index ae9a2bc486..b4cd42dfef 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -352,7 +352,7 @@ int menu_iterate(retro_input_t input, { int32_t ret = 0; unsigned action = 0; - runloop_t *runloop = rarch_main_get_ptr(); + global_t *global = global_get_ptr(); menu_display_t *disp = menu_display_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr(); @@ -364,7 +364,7 @@ int menu_iterate(retro_input_t input, ret = menu_entry_iterate(action); - if (menu_driver_alive() && !runloop->is_idle) + if (menu_driver_alive() && !global->is_idle) menu_display_fb(); menu_driver_set_texture(); diff --git a/retroarch.c b/retroarch.c index c347334c66..e7e9433c7a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1153,12 +1153,12 @@ static void validate_cpu_features(void) **/ void rarch_init_system_av_info(void) { - runloop_t *runloop = rarch_main_get_ptr(); struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); + global_t *global = global_get_ptr(); pretro_get_system_av_info(av_info); - runloop->frames.limit.last_time = rarch_get_time_usec(); + global->frames.limit.last_time = rarch_get_time_usec(); } /** diff --git a/runloop.c b/runloop.c index 651f2cd725..91defaaaab 100644 --- a/runloop.c +++ b/runloop.c @@ -42,7 +42,6 @@ #include "netplay.h" #endif -static struct runloop g_runloop; static struct global g_extern; /** @@ -511,9 +510,9 @@ static int do_pause_state_checks( * Returns: 1 if RetroArch is in pause mode, 0 otherwise. **/ static int do_state_checks(driver_t *driver, settings_t *settings, - global_t *global, runloop_t *runloop, event_cmd_state_t *cmd) + global_t *global, event_cmd_state_t *cmd) { - if (runloop->is_idle) + if (global->is_idle) return 1; if (cmd->screenshot_pressed) @@ -656,7 +655,7 @@ static void rarch_update_frame_time(driver_t *driver, settings_t *settings, * * Limit frame time if fast forward ratio throttle is enabled. **/ -static void rarch_limit_frame_time(settings_t *settings, runloop_t *runloop) +static void rarch_limit_frame_time(settings_t *settings, global_t *global) { retro_time_t target = 0; retro_time_t to_sleep_ms = 0; @@ -666,23 +665,23 @@ static void rarch_limit_frame_time(settings_t *settings, runloop_t *runloop) double effective_fps = av_info->timing.fps * settings->fastforward_ratio; double mft_f = 1000000.0f / effective_fps; - runloop->frames.limit.minimum_time = (retro_time_t) roundf(mft_f); + global->frames.limit.minimum_time = (retro_time_t) roundf(mft_f); - target = runloop->frames.limit.last_time + - runloop->frames.limit.minimum_time; + target = global->frames.limit.last_time + + global->frames.limit.minimum_time; to_sleep_ms = (target - current) / 1000; if (to_sleep_ms <= 0) { - runloop->frames.limit.last_time = rarch_get_time_usec(); + global->frames.limit.last_time = rarch_get_time_usec(); return; } rarch_sleep((unsigned int)to_sleep_ms); /* Combat jitter a bit. */ - runloop->frames.limit.last_time += - runloop->frames.limit.minimum_time; + global->frames.limit.last_time += + global->frames.limit.minimum_time; } /** @@ -866,14 +865,15 @@ global_t *global_get_ptr(void) return &g_extern; } -runloop_t *rarch_main_get_ptr(void) -{ - return &g_runloop; -} - void rarch_main_state_free(void) { - memset(&g_runloop, 0, sizeof(g_runloop)); + g_extern.is_idle = false; + g_extern.ui_companion_is_on_foreground = false; + g_extern.frames.limit.minimum_time = 0.0; + g_extern.frames.limit.last_time = 0.0; + g_extern.is_slowmotion = false; + g_extern.is_paused = false; + g_extern.max_frames = 0; } void rarch_main_global_free(void) @@ -913,10 +913,10 @@ void rarch_main_clear_state(void) bool rarch_main_is_idle(void) { - runloop_t *runloop = rarch_main_get_ptr(); - if (!runloop) + global_t *global = global_get_ptr(); + if (!global) return false; - return runloop->is_idle; + return global->is_idle; } static bool rarch_main_cmd_get_state_menu_toggle_button_combo( @@ -1022,7 +1022,6 @@ int rarch_main_iterate(void) driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - runloop_t *runloop = rarch_main_get_ptr(); retro_input_t input = input_keys_pressed(driver, settings, global); rarch_system_info_t *system = rarch_system_info_get_ptr(); @@ -1068,7 +1067,7 @@ int rarch_main_iterate(void) return rarch_main_iterate_quit(settings, global); } - if (do_state_checks(driver, settings, global, runloop, &cmd)) + if (do_state_checks(driver, settings, global, &cmd)) { /* RetroArch has been paused */ driver->retro_ctx.poll_cb(); @@ -1134,7 +1133,7 @@ int rarch_main_iterate(void) success: if (settings->fastforward_ratio_throttle_enable) - rarch_limit_frame_time(settings, runloop); + rarch_limit_frame_time(settings, global); return ret; } diff --git a/runloop.h b/runloop.h index 5c408d2438..ce03a7fd33 100644 --- a/runloop.h +++ b/runloop.h @@ -32,9 +32,15 @@ extern "C" { #endif -/* All libretro runloop-related globals go here. */ +typedef struct rarch_resolution +{ + unsigned idx; + unsigned id; +} rarch_resolution_t; -typedef struct runloop +/* All run-time- / command line flag-related globals go here. */ + +typedef struct global { /* Lifecycle state checks. */ bool is_idle; @@ -48,18 +54,7 @@ typedef struct runloop retro_time_t last_time; } limit; } frames; -} runloop_t; -typedef struct rarch_resolution -{ - unsigned idx; - unsigned id; -} rarch_resolution_t; - -/* All run-time- / command line flag-related globals go here. */ - -typedef struct global -{ bool is_slowmotion; bool is_paused; unsigned max_frames; @@ -318,8 +313,6 @@ typedef struct global retro_keyboard_event_t frontend_key_event; } global_t; -runloop_t *rarch_main_get_ptr(void); - global_t *global_get_ptr(void); /** diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 9d7bd48380..928b118bb9 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -44,9 +44,9 @@ void apple_rarch_exited(void); static void rarch_draw(void) { - runloop_t *runloop = rarch_main_get_ptr(); + global_t *global = global_get_ptr(); int ret = 0; - bool iterate = iterate_observer && !runloop->is_paused; + bool iterate = iterate_observer && !global->is_paused; if (iterate) { @@ -70,7 +70,7 @@ static void rarch_draw(void) return; } - if (runloop->is_idle) + if (global->is_idle) return; CFRunLoopWakeUp(CFRunLoopGetMain()); } @@ -398,7 +398,7 @@ void apple_stop_iterate_timer() - (void)showGameView { - runloop_t *runloop = rarch_main_get_ptr(); + global_t *global = global_get_ptr(); [self popToRootViewControllerAnimated:NO]; [self setToolbarHidden:true animated:NO]; @@ -406,20 +406,20 @@ void apple_stop_iterate_timer() [[UIApplication sharedApplication] setIdleTimerDisabled:true]; [self.window setRootViewController:[CocoaView get]]; - runloop->is_paused = false; - runloop->is_idle = false; - runloop->ui_companion_is_on_foreground = false; + global->is_paused = false; + global->is_idle = false; + global->ui_companion_is_on_foreground = false; } - (IBAction)showPauseMenu:(id)sender { - runloop_t *runloop = rarch_main_get_ptr(); + global_t *global = global_get_ptr(); - if (runloop) + if (global) { - runloop->is_paused = true; - runloop->is_idle = true; - runloop->ui_companion_is_on_foreground = true; + global->is_paused = true; + global->is_idle = true; + global->ui_companion_is_on_foreground = true; } [[UIApplication sharedApplication] setStatusBarHidden:false withAnimation:UIStatusBarAnimationNone]; @@ -429,9 +429,9 @@ void apple_stop_iterate_timer() - (void)toggleUI { - runloop_t *runloop = rarch_main_get_ptr(); + global_t *global = global_get_ptr(); - if (runloop->ui_companion_is_on_foreground) + if (global->ui_companion_is_on_foreground) { [self showGameView]; } @@ -505,15 +505,15 @@ typedef struct ui_companion_cocoatouch static void ui_companion_cocoatouch_switch_to_ios(void *data) { RetroArch_iOS *ap = NULL; - runloop_t *runloop = rarch_main_get_ptr(); + global_t *global = global_get_ptr(); (void)data; if (!apple_platform) return; - ap = (RetroArch_iOS *)apple_platform; - runloop->is_idle = true; + ap = (RetroArch_iOS *)apple_platform; + global->is_idle = true; [ap showPauseMenu:ap]; }