From 5a443d229ad06df11f0595a0ee5499d8b1b9b241 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 21 Mar 2015 05:42:49 +0100 Subject: [PATCH] global_get_ptr update pt. 2 --- apple/OSX/platform.m | 81 ++--- apple/iOS/menu.m | 17 +- configuration.c | 309 +++++++++--------- gfx/d3d/d3d.cpp | 26 +- gfx/d3d/render_chain.cpp | 7 +- gfx/d3d/render_chain_xdk.h | 16 +- gfx/drivers/exynos_gfx.c | 9 +- gfx/drivers/gx_gfx.c | 53 +-- gfx/drivers/omap_gfx.c | 10 +- gfx/drivers/sdl2_gfx.c | 16 +- gfx/drivers/sdl_gfx.c | 7 +- gfx/drivers/xvideo.c | 10 +- input/drivers/android_input.c | 8 +- input/drivers/gx_input.c | 5 +- input/drivers/ps3_input.c | 4 +- input/drivers/psp_input.c | 6 +- input/drivers/qnx_input.c | 34 +- input/drivers/xdk_xinput_input.c | 6 +- input/drivers/xenon360_input.c | 3 +- input/drivers_joypad/gx_input_joypad.c | 7 +- input/drivers_joypad/ps3_input_joypad.c | 5 +- input/drivers_joypad/psp_input_joypad.c | 3 +- .../drivers_joypad/xdk_xinput_input_joypad.c | 6 +- input/keyboard_line.c | 5 +- menu/drivers/glui.c | 12 +- menu/drivers/rgui.c | 9 +- menu/drivers/rmenu.c | 9 +- menu/drivers/rmenu_xui.cpp | 17 +- menu/drivers/shared.h | 6 +- menu/drivers/xmb.c | 42 ++- menu/menu_entries_cbs_deferred_push.c | 86 ++--- menu/menu_entries_cbs_iterate.c | 13 +- menu/menu_entries_cbs_ok.c | 61 ++-- menu/menu_entries_cbs_representation.c | 28 +- menu/menu_entries_cbs_start.c | 10 +- menu/menu_entries_cbs_toggle.c | 40 ++- runloop.c | 2 +- settings.c | 127 +++---- 38 files changed, 616 insertions(+), 499 deletions(-) diff --git a/apple/OSX/platform.m b/apple/OSX/platform.m index 3109ea2fb9..816fd2a7dc 100644 --- a/apple/OSX/platform.m +++ b/apple/OSX/platform.m @@ -250,11 +250,12 @@ static void poll_iteration(void) - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { - NSApplicationTerminateReply reply = NSTerminateNow; + NSApplicationTerminateReply reply = NSTerminateNow; + global_t *global = global_get_ptr(); + + if (global->main_is_init) + reply = NSTerminateCancel; - if (g_extern.main_is_init) - reply = NSTerminateCancel; - rarch_main_command(RARCH_CMD_QUIT); return reply; @@ -265,15 +266,16 @@ static void poll_iteration(void) { if (filenames.count == 1 && [filenames objectAtIndex:0]) { - NSString *__core = [filenames objectAtIndex:0]; - const char *core_name = g_extern.menu.info.library_name; - strlcpy(g_extern.fullpath, __core.UTF8String, sizeof(g_extern.fullpath)); - - if (core_name) - rarch_main_command(RARCH_CMD_LOAD_CONTENT); - else + global_t *global = global_get_ptr(); + NSString *__core = [filenames objectAtIndex:0]; + const char *core_name = global->menu.info.library_name; + strlcpy(global->fullpath, __core.UTF8String, sizeof(global->fullpath)); + + if (core_name) + rarch_main_command(RARCH_CMD_LOAD_CONTENT); + else [self chooseCore]; - + [sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess]; } else @@ -290,22 +292,23 @@ static void poll_iteration(void) [panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) { [[NSApplication sharedApplication] stopModal]; - + if (result == NSOKButton && panel.URL) { - NSURL *url = (NSURL*)panel.URL; - NSString *__core = url.path; - const char *core_name = g_extern.menu.info.library_name; - strlcpy(g_extern.fullpath, __core.UTF8String, sizeof(g_extern.fullpath)); - - if (core_name) - rarch_main_command(RARCH_CMD_LOAD_CONTENT); - else - [self performSelector:@selector(chooseCore) withObject:nil afterDelay:.5f]; + global_t *global = global_get_ptr(); + NSURL *url = (NSURL*)panel.URL; + NSString *__core = url.path; + const char *core_name = global->menu.info.library_name; + strlcpy(global->fullpath, __core.UTF8String, sizeof(global->fullpath)); + + if (core_name) + rarch_main_command(RARCH_CMD_LOAD_CONTENT); + else + [self performSelector:@selector(chooseCore) withObject:nil afterDelay:.5f]; } }]; #else - [panel beginSheetForDirectory:nil file:nil modalForWindopw:[self window] modalDelegate:self didEndSelector:@selector(didEndSaveSheet:returnCode:contextInfo:) contextInfo:NULL]; + [panel beginSheetForDirectory:nil file:nil modalForWindopw:[self window] modalDelegate:self didEndSelector:@selector(didEndSaveSheet:returnCode:contextInfo:) contextInfo:NULL]; #endif [[NSApplication sharedApplication] runModalForWindow:panel]; } @@ -318,31 +321,32 @@ static void poll_iteration(void) - (IBAction)coreWasChosen:(id)sender { - NSComboBox* cb; - + NSComboBox* cb = NULL; + global_t *global = global_get_ptr(); + [[NSApplication sharedApplication] stopModal]; [[NSApplication sharedApplication] endSheet:self.coreSelectSheet returnCode:0]; [self.coreSelectSheet orderOut:self]; - if (g_extern.system.shutdown) + if (global->system.shutdown) return; - + /* TODO - rewrite this. */ cb = (NSComboBox*)[[self.coreSelectSheet contentView] viewWithTag:1]; #if defined(MAC_OS_X_VERSION_10_6) - /* FIXME - Rewrite this so that this is no longer an associated object - requires ObjC 2.0 runtime */ + /* FIXME - Rewrite this so that this is no longer an associated object - requires ObjC 2.0 runtime */ self.core = objc_getAssociatedObject(cb.objectValueOfSelectedItem, associated_core_key); #endif - - if (!g_extern.main_is_init) - { - /* TODO/FIXME: Set core/content here. */ + + if (!global->main_is_init) + { + /* TODO/FIXME: Set core/content here. */ rarch_main_command(RARCH_CMD_LOAD_CORE); rarch_main_command(RARCH_CMD_LOAD_CONTENT); - } - else - rarch_main_command(RARCH_CMD_QUIT); + } + else + rarch_main_command(RARCH_CMD_QUIT); } #pragma mark RetroArch_Platform @@ -371,8 +375,9 @@ static void poll_iteration(void) - (IBAction)basicEvent:(id)sender { - unsigned sender_tag, cmd; - sender_tag = (unsigned)[sender tag]; + unsigned cmd; + unsigned sender_tag = (unsigned)[sender tag]; + global_t *global = global_get_ptr(); RARCH_LOG("Gets here, sender tag is: %d\n", sender_tag); @@ -416,7 +421,7 @@ static void poll_iteration(void) if (sender_tag >= 10 && sender_tag <= 19) { unsigned idx = (sender_tag - (10-1)); - g_extern.pending.windowed_scale = idx; + global->pending.windowed_scale = idx; cmd = RARCH_CMD_RESIZE_WINDOWED_SCALE; } diff --git a/apple/iOS/menu.m b/apple/iOS/menu.m index edeae23e3b..77f4cfc364 100644 --- a/apple/iOS/menu.m +++ b/apple/iOS/menu.m @@ -605,12 +605,13 @@ static void RunActionSheet(const char* title, const struct string_list* items, U char title[256], title_msg[256]; NSMutableArray *everything; RAMainMenu* __weak weakSelf; - const char *core_name = g_extern.menu.info.library_name; - const char *core_version = g_extern.menu.info.library_version; - const char *dir = NULL; - const char *label = NULL; - unsigned menu_type = 0; - menu_handle_t *menu = menu_driver_resolve(); + global_t *global = global_get_ptr(); + const char *core_name = global->menu.info.library_name; + const char *core_version = global->menu.info.library_version; + const char *dir = NULL; + const char *label = NULL; + unsigned menu_type = 0; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -624,12 +625,12 @@ static void RunActionSheet(const char* title, const struct string_list* items, U self.sections = [NSMutableArray array]; if (!core_name) - core_name = g_extern.system.info.library_name; + core_name = global->system.info.library_name; if (!core_name) core_name = "No Core"; if (!core_version) - core_version = g_extern.system.info.library_version; + core_version = global->system.info.library_version; if (!core_version) core_version = ""; diff --git a/configuration.c b/configuration.c index 833fe4574c..299df36ec3 100644 --- a/configuration.c +++ b/configuration.c @@ -351,6 +351,7 @@ static void config_set_defaults(void) { unsigned i, j; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); const char *def_video = config_get_default_video(); const char *def_audio = config_get_default_audio(); const char *def_audio_resampler = config_get_default_audio_resampler(); @@ -392,20 +393,20 @@ static void config_set_defaults(void) settings->history_list_enable = def_history_list_enable; settings->load_dummy_on_core_shutdown = load_dummy_on_core_shutdown; - settings->video.scale = scale; - settings->video.fullscreen = g_extern.force_fullscreen ? true : fullscreen; - settings->video.windowed_fullscreen = windowed_fullscreen; - settings->video.monitor_index = monitor_index; - settings->video.fullscreen_x = fullscreen_x; - settings->video.fullscreen_y = fullscreen_y; - settings->video.disable_composition = disable_composition; - settings->video.vsync = vsync; - settings->video.hard_sync = hard_sync; - settings->video.hard_sync_frames = hard_sync_frames; - settings->video.frame_delay = frame_delay; + settings->video.scale = scale; + settings->video.fullscreen = global->force_fullscreen ? true : fullscreen; + settings->video.windowed_fullscreen = windowed_fullscreen; + settings->video.monitor_index = monitor_index; + settings->video.fullscreen_x = fullscreen_x; + settings->video.fullscreen_y = fullscreen_y; + settings->video.disable_composition = disable_composition; + settings->video.vsync = vsync; + settings->video.hard_sync = hard_sync; + settings->video.hard_sync_frames = hard_sync_frames; + settings->video.frame_delay = frame_delay; settings->video.black_frame_insertion = black_frame_insertion; - settings->video.swap_interval = swap_interval; - settings->video.threaded = video_threaded; + settings->video.swap_interval = swap_interval; + settings->video.threaded = video_threaded; if (g_defaults.settings.video_threaded_enable != video_threaded) settings->video.threaded = g_defaults.settings.video_threaded_enable; @@ -467,7 +468,7 @@ static void config_set_defaults(void) settings->audio.rate_control_delta = rate_control_delta; settings->audio.max_timing_skew = max_timing_skew; settings->audio.volume = audio_volume; - g_extern.audio_data.volume_gain = db_to_gain(settings->audio.volume); + global->audio_data.volume_gain = db_to_gain(settings->audio.volume); settings->rewind_enable = rewind_enable; settings->rewind_buffer_size = rewind_buffer_size; @@ -568,33 +569,32 @@ static void config_set_defaults(void) { settings->input.joypad_map[i] = i; settings->input.analog_dpad_mode[i] = ANALOG_DPAD_NONE; - if (!g_extern.has_set_libretro_device[i]) + if (!global->has_set_libretro_device[i]) settings->input.libretro_device[i] = RETRO_DEVICE_JOYPAD; } - g_extern.console.screen.viewports.custom_vp.width = 0; - g_extern.console.screen.viewports.custom_vp.height = 0; - g_extern.console.screen.viewports.custom_vp.x = 0; - g_extern.console.screen.viewports.custom_vp.y = 0; - + global->console.screen.viewports.custom_vp.width = 0; + global->console.screen.viewports.custom_vp.height = 0; + global->console.screen.viewports.custom_vp.x = 0; + global->console.screen.viewports.custom_vp.y = 0; /* Make sure settings from other configs carry over into defaults * for another config. */ - if (!g_extern.has_set_save_path) - *g_extern.savefile_dir = '\0'; - if (!g_extern.has_set_state_path) - *g_extern.savestate_dir = '\0'; + if (!global->has_set_save_path) + *global->savefile_dir = '\0'; + if (!global->has_set_state_path) + *global->savestate_dir = '\0'; *settings->libretro_info_path = '\0'; - if (!g_extern.has_set_libretro_directory) + if (!global->has_set_libretro_directory) *settings->libretro_directory = '\0'; - if (!g_extern.has_set_ups_pref) - g_extern.ups_pref = false; - if (!g_extern.has_set_bps_pref) - g_extern.bps_pref = false; - if (!g_extern.has_set_ips_pref) - g_extern.ips_pref = false; + if (!global->has_set_ups_pref) + global->ups_pref = false; + if (!global->has_set_bps_pref) + global->bps_pref = false; + if (!global->has_set_ips_pref) + global->ips_pref = false; *settings->core_options_path = '\0'; *settings->content_history_path = '\0'; @@ -626,12 +626,11 @@ static void config_set_defaults(void) settings->core_specific_config = default_core_specific_config; settings->user_language = 0; - g_extern.console.sound.system_bgm_enable = false; + global->console.sound.system_bgm_enable = false; #ifdef RARCH_CONSOLE - g_extern.console.screen.gamma_correction = DEFAULT_GAMMA; - - g_extern.console.screen.resolutions.current.id = 0; - g_extern.console.sound.mode = SOUND_MODE_NORMAL; + global->console.screen.gamma_correction = DEFAULT_GAMMA; + global->console.screen.resolutions.current.id = 0; + global->console.sound.mode = SOUND_MODE_NORMAL; #endif if (*g_defaults.extraction_dir) @@ -670,12 +669,12 @@ static void config_set_defaults(void) #ifdef HAVE_OVERLAY if (*g_defaults.overlay_dir) { - fill_pathname_expand_special(g_extern.overlay_dir, - g_defaults.overlay_dir, sizeof(g_extern.overlay_dir)); + fill_pathname_expand_special(global->overlay_dir, + g_defaults.overlay_dir, sizeof(global->overlay_dir)); #ifdef RARCH_MOBILE if (!*settings->input.overlay) fill_pathname_join(settings->input.overlay, - g_extern.overlay_dir, + global->overlay_dir, "gamepads/retropad/retropad.cfg", sizeof(settings->input.overlay)); #endif @@ -683,19 +682,19 @@ static void config_set_defaults(void) if (*g_defaults.osk_overlay_dir) { - fill_pathname_expand_special(g_extern.osk_overlay_dir, - g_defaults.osk_overlay_dir, sizeof(g_extern.osk_overlay_dir)); + fill_pathname_expand_special(global->osk_overlay_dir, + g_defaults.osk_overlay_dir, sizeof(global->osk_overlay_dir)); #ifdef RARCH_MOBILE if (!*settings->input.overlay) fill_pathname_join(settings->osk.overlay, - g_extern.osk_overlay_dir, + global->osk_overlay_dir, "overlays/keyboards/US-101/US-101.cfg", sizeof(settings->osk.overlay)); #endif } else - strlcpy(g_extern.osk_overlay_dir, - g_extern.overlay_dir, sizeof(g_extern.osk_overlay_dir)); + strlcpy(global->osk_overlay_dir, + global->overlay_dir, sizeof(global->osk_overlay_dir)); #endif #ifdef HAVE_MENU if (*g_defaults.menu_config_dir) @@ -711,12 +710,12 @@ static void config_set_defaults(void) g_defaults.autoconfig_dir, sizeof(settings->input.autoconfig_dir)); - if (!g_extern.has_set_state_path && *g_defaults.savestate_dir) - strlcpy(g_extern.savestate_dir, - g_defaults.savestate_dir, sizeof(g_extern.savestate_dir)); - if (!g_extern.has_set_save_path && *g_defaults.sram_dir) - strlcpy(g_extern.savefile_dir, - g_defaults.sram_dir, sizeof(g_extern.savefile_dir)); + if (!global->has_set_state_path && *g_defaults.savestate_dir) + strlcpy(global->savestate_dir, + g_defaults.savestate_dir, sizeof(global->savestate_dir)); + if (!global->has_set_save_path && *g_defaults.sram_dir) + strlcpy(global->savefile_dir, + g_defaults.sram_dir, sizeof(global->savefile_dir)); if (*g_defaults.system_dir) strlcpy(settings->system_directory, g_defaults.system_dir, sizeof(settings->system_directory)); @@ -734,13 +733,13 @@ static void config_set_defaults(void) sizeof(settings->content_history_directory)); if (*g_defaults.config_path) - fill_pathname_expand_special(g_extern.config_path, - g_defaults.config_path, sizeof(g_extern.config_path)); + fill_pathname_expand_special(global->config_path, + g_defaults.config_path, sizeof(global->config_path)); settings->config_save_on_exit = config_save_on_exit; /* Avoid reloading config on every content load */ - g_extern.block_config_read = default_block_config_read; + global->block_config_read = default_block_config_read; } #ifndef GLOBAL_CONFIG_DIR @@ -760,9 +759,10 @@ static void config_set_defaults(void) **/ static config_file_t *open_default_config_file(void) { - bool saved = false; char conf_path[PATH_MAX_LENGTH], app_path[PATH_MAX_LENGTH]; config_file_t *conf = NULL; + bool saved = false; + global_t *global = global_get_ptr(); (void)conf_path; (void)app_path; @@ -940,8 +940,8 @@ static config_file_t *open_default_config_file(void) if (!conf) return NULL; - strlcpy(g_extern.config_path, conf_path, - sizeof(g_extern.config_path)); + strlcpy(global->config_path, conf_path, + sizeof(global->config_path)); return conf; } @@ -1068,7 +1068,7 @@ static bool config_load_file(const char *path, bool set_defaults) unsigned msg_color = 0; config_file_t *conf = NULL; settings_t *settings = config_get_ptr(); - global_t *global = &g_extern; + global_t *global = global_get_ptr(); if (path) { @@ -1085,7 +1085,7 @@ static bool config_load_file(const char *path, bool set_defaults) if (set_defaults) config_set_defaults(); - strlcpy(tmp_append_path, g_extern.append_config_path, + strlcpy(tmp_append_path, global->append_config_path, sizeof(tmp_append_path)); extra_path = strtok_r(tmp_append_path, ",", &save); @@ -1099,7 +1099,7 @@ static bool config_load_file(const char *path, bool set_defaults) extra_path = strtok_r(NULL, ",", &save); } - if (g_extern.verbosity) + if (global->verbosity) { RARCH_LOG_OUTPUT("=== Config ===\n"); config_file_dump_all(conf); @@ -1111,7 +1111,7 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_INT(video.fullscreen_x, "video_fullscreen_x"); CONFIG_GET_INT(video.fullscreen_y, "video_fullscreen_y"); - if (!g_extern.force_fullscreen) + if (!global->force_fullscreen) CONFIG_GET_BOOL(video.fullscreen, "video_fullscreen"); CONFIG_GET_BOOL(video.windowed_fullscreen, "video_windowed_fullscreen"); @@ -1189,11 +1189,11 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_BOOL_EXTERN(console.screen.gamma_correction, "gamma_correction"); config_get_bool(conf, "custom_bgm_enable", - &g_extern.console.sound.system_bgm_enable); + &global->console.sound.system_bgm_enable); config_get_bool(conf, "flicker_filter_enable", - &g_extern.console.flickerfilter_enable); + &global->console.flickerfilter_enable); config_get_bool(conf, "soft_filter_enable", - &g_extern.console.softfilter_enable); + &global->console.softfilter_enable); CONFIG_GET_INT_EXTERN(console.screen.flicker_filter_index, "flicker_filter_index"); @@ -1266,22 +1266,22 @@ static bool config_load_file(const char *path, bool set_defaults) snprintf(buf, sizeof(buf), "input_player%u_analog_dpad_mode", i + 1); CONFIG_GET_INT(input.analog_dpad_mode[i], buf); - if (!g_extern.has_set_libretro_device[i]) + if (!global->has_set_libretro_device[i]) { snprintf(buf, sizeof(buf), "input_libretro_device_p%u", i + 1); CONFIG_GET_INT(input.libretro_device[i], buf); } } - if (!g_extern.has_set_ups_pref) + if (!global->has_set_ups_pref) { CONFIG_GET_BOOL_EXTERN(ups_pref, "ups_pref"); } - if (!g_extern.has_set_bps_pref) + if (!global->has_set_bps_pref) { CONFIG_GET_BOOL_EXTERN(bps_pref, "bps_pref"); } - if (!g_extern.has_set_ips_pref) + if (!global->has_set_ips_pref) { CONFIG_GET_BOOL_EXTERN(ips_pref, "ips_pref"); } @@ -1299,7 +1299,7 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_FLOAT(audio.max_timing_skew, "audio_max_timing_skew"); CONFIG_GET_FLOAT(audio.volume, "audio_volume"); CONFIG_GET_STRING(audio.resampler, "audio_resampler"); - g_extern.audio_data.volume_gain = db_to_gain(settings->audio.volume); + global->audio_data.volume_gain = db_to_gain(settings->audio.volume); CONFIG_GET_STRING(camera.device, "camera_device"); CONFIG_GET_BOOL(camera.allow, "camera_allow"); @@ -1317,9 +1317,9 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_STRING(input.joypad_driver, "input_joypad_driver"); CONFIG_GET_STRING(input.keyboard_layout, "input_keyboard_layout"); - if (!g_extern.has_set_libretro) + if (!global->has_set_libretro) config_get_path(conf, "libretro_path", settings->libretro, sizeof(settings->libretro)); - if (!g_extern.has_set_libretro_directory) + if (!global->has_set_libretro_directory) config_get_path(conf, "libretro_directory", settings->libretro_directory, sizeof(settings->libretro_directory)); /* Safe-guard against older behavior. */ @@ -1376,7 +1376,7 @@ static bool config_load_file(const char *path, bool set_defaults) #endif CONFIG_GET_INT(libretro_log_level, "libretro_log_level"); - if (!g_extern.has_set_verbosity) + if (!global->has_set_verbosity) CONFIG_GET_BOOL_EXTERN(verbosity, "log_verbosity"); CONFIG_GET_BOOL_EXTERN(perfcnt_enable, "perfcnt_enable"); @@ -1384,18 +1384,18 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_INT(archive.mode, "archive_mode"); #ifdef HAVE_OVERLAY - config_get_path(conf, "overlay_directory", g_extern.overlay_dir, sizeof(g_extern.overlay_dir)); - if (!strcmp(g_extern.overlay_dir, "default")) - *g_extern.overlay_dir = '\0'; + config_get_path(conf, "overlay_directory", global->overlay_dir, sizeof(global->overlay_dir)); + if (!strcmp(global->overlay_dir, "default")) + *global->overlay_dir = '\0'; config_get_path(conf, "input_overlay", settings->input.overlay, sizeof(settings->input.overlay)); CONFIG_GET_BOOL(input.overlay_enable, "input_overlay_enable"); CONFIG_GET_FLOAT(input.overlay_opacity, "input_overlay_opacity"); CONFIG_GET_FLOAT(input.overlay_scale, "input_overlay_scale"); - config_get_path(conf, "osk_overlay_directory", g_extern.osk_overlay_dir, sizeof(g_extern.osk_overlay_dir)); - if (!strcmp(g_extern.osk_overlay_dir, "default")) - *g_extern.osk_overlay_dir = '\0'; + config_get_path(conf, "osk_overlay_directory", global->osk_overlay_dir, sizeof(global->osk_overlay_dir)); + if (!strcmp(global->osk_overlay_dir, "default")) + *global->osk_overlay_dir = '\0'; config_get_path(conf, "input_osk_overlay", settings->osk.overlay, sizeof(settings->osk.overlay)); CONFIG_GET_BOOL(osk.enable, "input_osk_overlay_enable"); @@ -1451,58 +1451,58 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_BOOL(input.autodetect_enable, "input_autodetect_enable"); CONFIG_GET_PATH(input.autoconfig_dir, "joypad_autoconfig_dir"); - if (!g_extern.has_set_username) + if (!global->has_set_username) CONFIG_GET_PATH(username, "netplay_nickname"); CONFIG_GET_INT(user_language, "user_language"); #ifdef HAVE_NETPLAY - if (!g_extern.has_set_netplay_mode) + if (!global->has_set_netplay_mode) CONFIG_GET_BOOL_EXTERN(netplay_is_spectate, "netplay_spectator_mode_enable"); - if (!g_extern.has_set_netplay_mode) + if (!global->has_set_netplay_mode) CONFIG_GET_BOOL_EXTERN(netplay_is_client, "netplay_mode"); - if (!g_extern.has_set_netplay_ip_address) + if (!global->has_set_netplay_ip_address) CONFIG_GET_PATH_EXTERN(netplay_server, "netplay_ip_address"); - if (!g_extern.has_set_netplay_delay_frames) + if (!global->has_set_netplay_delay_frames) CONFIG_GET_INT_EXTERN(netplay_sync_frames, "netplay_delay_frames"); - if (!g_extern.has_set_netplay_ip_port) + if (!global->has_set_netplay_ip_port) CONFIG_GET_INT_EXTERN(netplay_port, "netplay_ip_port"); #endif CONFIG_GET_BOOL(config_save_on_exit, "config_save_on_exit"); - if (!g_extern.has_set_save_path && + if (!global->has_set_save_path && config_get_path(conf, "savefile_directory", tmp_str, sizeof(tmp_str))) { if (!strcmp(tmp_str, "default")) - strlcpy(g_extern.savefile_dir, g_defaults.sram_dir, - sizeof(g_extern.savefile_dir)); + strlcpy(global->savefile_dir, g_defaults.sram_dir, + sizeof(global->savefile_dir)); else if (path_is_directory(tmp_str)) { - strlcpy(g_extern.savefile_dir, tmp_str, - sizeof(g_extern.savefile_dir)); - strlcpy(g_extern.savefile_name, tmp_str, - sizeof(g_extern.savefile_name)); - fill_pathname_dir(g_extern.savefile_name, g_extern.basename, - ".srm", sizeof(g_extern.savefile_name)); + strlcpy(global->savefile_dir, tmp_str, + sizeof(global->savefile_dir)); + strlcpy(global->savefile_name, tmp_str, + sizeof(global->savefile_name)); + fill_pathname_dir(global->savefile_name, global->basename, + ".srm", sizeof(global->savefile_name)); } else RARCH_WARN("savefile_directory is not a directory, ignoring ...\n"); } - if (!g_extern.has_set_state_path && + if (!global->has_set_state_path && config_get_path(conf, "savestate_directory", tmp_str, sizeof(tmp_str))) { if (!strcmp(tmp_str, "default")) - strlcpy(g_extern.savestate_dir, g_defaults.savestate_dir, - sizeof(g_extern.savestate_dir)); + strlcpy(global->savestate_dir, g_defaults.savestate_dir, + sizeof(global->savestate_dir)); else if (path_is_directory(tmp_str)) { - strlcpy(g_extern.savestate_dir, tmp_str, - sizeof(g_extern.savestate_dir)); - strlcpy(g_extern.savestate_name, tmp_str, - sizeof(g_extern.savestate_name)); - fill_pathname_dir(g_extern.savestate_name, g_extern.basename, - ".state", sizeof(g_extern.savestate_name)); + strlcpy(global->savestate_dir, tmp_str, + sizeof(global->savestate_dir)); + strlcpy(global->savestate_name, tmp_str, + sizeof(global->savestate_name)); + fill_pathname_dir(global->savestate_name, global->basename, + ".state", sizeof(global->savestate_name)); } else RARCH_WARN("savestate_directory is not a directory, ignoring ...\n"); @@ -1520,7 +1520,7 @@ static bool config_load_file(const char *path, bool set_defaults) else { fill_pathname_resolve_relative(settings->content_history_path, - g_extern.config_path, "retroarch-content-history.txt", + global->config_path, "retroarch-content-history.txt", sizeof(settings->content_history_path)); } } @@ -1546,12 +1546,13 @@ static bool config_load_file(const char *path, bool set_defaults) static void config_load_core_specific(void) { settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); - *g_extern.core_specific_config_path = '\0'; + *global->core_specific_config_path = '\0'; if (!*settings->libretro #ifdef HAVE_DYNAMIC - || g_extern.libretro_dummy + || global->libretro_dummy #endif ) return; @@ -1561,29 +1562,29 @@ static void config_load_core_specific(void) { path_resolve_realpath(settings->menu_config_directory, sizeof(settings->menu_config_directory)); - strlcpy(g_extern.core_specific_config_path, + strlcpy(global->core_specific_config_path, settings->menu_config_directory, - sizeof(g_extern.core_specific_config_path)); + sizeof(global->core_specific_config_path)); } else #endif { /* Use original config file's directory as a fallback. */ - fill_pathname_basedir(g_extern.core_specific_config_path, - g_extern.config_path, sizeof(g_extern.core_specific_config_path)); + fill_pathname_basedir(global->core_specific_config_path, + global->config_path, sizeof(global->core_specific_config_path)); } - fill_pathname_dir(g_extern.core_specific_config_path, settings->libretro, - ".cfg", sizeof(g_extern.core_specific_config_path)); + fill_pathname_dir(global->core_specific_config_path, settings->libretro, + ".cfg", sizeof(global->core_specific_config_path)); if (settings->core_specific_config) { char tmp[PATH_MAX_LENGTH]; strlcpy(tmp, settings->libretro, sizeof(tmp)); RARCH_LOG("Loading core-specific config from: %s.\n", - g_extern.core_specific_config_path); + global->core_specific_config_path); - if (!config_load_file(g_extern.core_specific_config_path, true)) + if (!config_load_file(global->core_specific_config_path, true)) RARCH_WARN("Core-specific config not found, reusing last config.\n"); /* Force some parameters which are implied when using core specific configs. @@ -1597,29 +1598,29 @@ static void config_load_core_specific(void) static void parse_config_file(void) { - bool ret = config_load_file((*g_extern.config_path) - ? g_extern.config_path : NULL, false); + global_t *global = global_get_ptr(); + bool ret = config_load_file((*global->config_path) + ? global->config_path : NULL, false); - if (*g_extern.config_path) + if (*global->config_path) { - RARCH_LOG("Loading config from: %s.\n", g_extern.config_path); + RARCH_LOG("Loading config from: %s.\n", global->config_path); } else { RARCH_LOG("Loading default config.\n"); - if (*g_extern.config_path) - RARCH_LOG("Found default config: %s.\n", g_extern.config_path); + if (*global->config_path) + RARCH_LOG("Found default config: %s.\n", global->config_path); } if (ret) return; RARCH_ERR("Couldn't find config at path: \"%s\"\n", - g_extern.config_path); + global->config_path); } - #if 0 static bool config_read_keybinds(const char *path) { @@ -1775,16 +1776,17 @@ static void save_keybinds_user(config_file_t *conf, unsigned user) void config_load(void) { settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); /* Flush out per-core configs before loading a new config. */ - if (*g_extern.core_specific_config_path && + if (*global->core_specific_config_path && settings->config_save_on_exit && settings->core_specific_config) - config_save_file(g_extern.core_specific_config_path); + config_save_file(global->core_specific_config_path); /* Flush out some states that could have been set by core environment variables */ - g_extern.has_set_input_descriptors = false; + global->has_set_input_descriptors = false; - if (!g_extern.block_config_read) + if (!global->block_config_read) { config_set_defaults(); parse_config_file(); @@ -1838,6 +1840,7 @@ bool config_save_file(const char *path) bool ret = false; config_file_t *conf = config_file_new(path); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (!conf) conf = config_file_new(NULL); @@ -1959,12 +1962,12 @@ bool config_save_file(const char *path) config_set_float(conf, "video_font_size", settings->video.font_size); config_set_bool(conf, "video_font_enable", settings->video.font_enable); - if (!g_extern.has_set_ups_pref) - config_set_bool(conf, "ups_pref", g_extern.ups_pref); - if (!g_extern.has_set_bps_pref) - config_set_bool(conf, "bps_pref", g_extern.bps_pref); - if (!g_extern.has_set_ips_pref) - config_set_bool(conf, "ips_pref", g_extern.ips_pref); + if (!global->has_set_ups_pref) + config_set_bool(conf, "ups_pref", global->ups_pref); + if (!global->has_set_bps_pref) + config_set_bool(conf, "bps_pref", global->bps_pref); + if (!global->has_set_ips_pref) + config_set_bool(conf, "ips_pref", global->ips_pref); config_set_path(conf, "system_directory", *settings->system_directory ? @@ -1979,9 +1982,9 @@ bool config_save_file(const char *path) settings->resampler_directory); config_set_string(conf, "audio_resampler", settings->audio.resampler); config_set_path(conf, "savefile_directory", - *g_extern.savefile_dir ? g_extern.savefile_dir : "default"); + *global->savefile_dir ? global->savefile_dir : "default"); config_set_path(conf, "savestate_directory", - *g_extern.savestate_dir ? g_extern.savestate_dir : "default"); + *global->savestate_dir ? global->savestate_dir : "default"); config_set_path(conf, "video_shader_dir", *settings->video.shader_dir ? settings->video.shader_dir : "default"); @@ -2037,7 +2040,7 @@ bool config_save_file(const char *path) #ifdef HAVE_OVERLAY config_set_path(conf, "overlay_directory", - *g_extern.overlay_dir ? g_extern.overlay_dir : "default"); + *global->overlay_dir ? global->overlay_dir : "default"); config_set_path(conf, "input_overlay", settings->input.overlay); config_set_bool(conf, "input_overlay_enable", settings->input.overlay_enable); config_set_float(conf, "input_overlay_opacity", @@ -2046,7 +2049,7 @@ bool config_save_file(const char *path) settings->input.overlay_scale); config_set_path(conf, "osk_overlay_directory", - *g_extern.osk_overlay_dir ? g_extern.osk_overlay_dir : "default"); + *global->osk_overlay_dir ? global->osk_overlay_dir : "default"); config_set_path(conf, "input_osk_overlay", settings->osk.overlay); config_set_bool(conf, "input_osk_overlay_enable", settings->osk.enable); #endif @@ -2056,26 +2059,26 @@ bool config_save_file(const char *path) config_set_float(conf, "video_message_pos_y", settings->video.msg_pos_y); config_set_bool(conf, "gamma_correction", - g_extern.console.screen.gamma_correction); + global->console.screen.gamma_correction); config_set_bool(conf, "soft_filter_enable", - g_extern.console.softfilter_enable); + global->console.softfilter_enable); config_set_bool(conf, "flicker_filter_enable", - g_extern.console.flickerfilter_enable); + global->console.flickerfilter_enable); config_set_int(conf, "flicker_filter_index", - g_extern.console.screen.flicker_filter_index); + global->console.screen.flicker_filter_index); config_set_int(conf, "soft_filter_index", - g_extern.console.screen.soft_filter_index); + global->console.screen.soft_filter_index); config_set_int(conf, "current_resolution_id", - g_extern.console.screen.resolutions.current.id); + global->console.screen.resolutions.current.id); config_set_int(conf, "custom_viewport_width", - g_extern.console.screen.viewports.custom_vp.width); + global->console.screen.viewports.custom_vp.width); config_set_int(conf, "custom_viewport_height", - g_extern.console.screen.viewports.custom_vp.height); + global->console.screen.viewports.custom_vp.height); config_set_int(conf, "custom_viewport_x", - g_extern.console.screen.viewports.custom_vp.x); + global->console.screen.viewports.custom_vp.x); config_set_int(conf, "custom_viewport_y", - g_extern.console.screen.viewports.custom_vp.y); + global->console.screen.viewports.custom_vp.y); config_set_float(conf, "video_font_size", settings->video.font_size); config_set_bool(conf, "block_sram_overwrite", @@ -2095,22 +2098,22 @@ bool config_save_file(const char *path) config_set_bool(conf, "config_save_on_exit", settings->config_save_on_exit); - config_set_int(conf, "sound_mode", g_extern.console.sound.mode); + config_set_int(conf, "sound_mode", global->console.sound.mode); config_set_int(conf, "state_slot", settings->state_slot); #ifdef HAVE_NETPLAY config_set_bool(conf, "netplay_spectator_mode_enable", - g_extern.netplay_is_spectate); - config_set_bool(conf, "netplay_mode", g_extern.netplay_is_client); - config_set_string(conf, "netplay_ip_address", g_extern.netplay_server); - config_set_int(conf, "netplay_ip_port", g_extern.netplay_port); - config_set_int(conf, "netplay_delay_frames", g_extern.netplay_sync_frames); + global->netplay_is_spectate); + config_set_bool(conf, "netplay_mode", global->netplay_is_client); + config_set_string(conf, "netplay_ip_address", global->netplay_server); + config_set_int(conf, "netplay_ip_port", global->netplay_port); + config_set_int(conf, "netplay_delay_frames", global->netplay_sync_frames); #endif config_set_string(conf, "netplay_nickname", settings->username); config_set_int(conf, "user_language", settings->user_language); config_set_bool(conf, "custom_bgm_enable", - g_extern.console.sound.system_bgm_enable); + global->console.sound.system_bgm_enable); config_set_string(conf, "input_driver", settings->input.driver); config_set_string(conf, "input_joypad_driver", @@ -2137,8 +2140,8 @@ bool config_save_file(const char *path) config_set_bool(conf, "core_specific_config", settings->core_specific_config); config_set_int(conf, "libretro_log_level", settings->libretro_log_level); - config_set_bool(conf, "log_verbosity", g_extern.verbosity); - config_set_bool(conf, "perfcnt_enable", g_extern.perfcnt_enable); + config_set_bool(conf, "log_verbosity", global->verbosity); + config_set_bool(conf, "perfcnt_enable", global->perfcnt_enable); config_set_int(conf, "archive_mode", settings->archive.mode); diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 26f6832c2d..4b296c6d70 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -234,6 +234,7 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) { bool ret = true; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (!d3d) return false; @@ -287,7 +288,7 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) return ret; d3d_calculate_rect(d3d, d3d->screen_width, d3d->screen_height, - info->force_aspect, g_extern.system.aspect_ratio); + info->force_aspect, global->system.aspect_ratio); #ifdef HAVE_SHADERS if (!d3d_init_shader(d3d)) @@ -357,6 +358,7 @@ static void d3d_calculate_rect(d3d_video_t *d3d, bool keep, float desired_aspect) { settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (settings->video.scale_integer) { @@ -371,7 +373,7 @@ static void d3d_calculate_rect(d3d_video_t *d3d, if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { const video_viewport_t *custom = - &g_extern.console.screen.viewports.custom_vp; + &global->console.screen.viewports.custom_vp; if (custom) d3d_set_viewport(d3d, custom->x, custom->y, @@ -459,13 +461,14 @@ static bool d3d_has_windowed(void *data) static void d3d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { d3d_video_t *d3d = (d3d_video_t*)data; + global_t *global = global_get_ptr(); switch (aspect_ratio_idx) { case ASPECT_RATIO_SQUARE: video_viewport_set_square_pixel( - g_extern.system.av_info.geometry.base_width, - g_extern.system.av_info.geometry.base_height); + global->system.av_info.geometry.base_width, + global->system.av_info.geometry.base_height); break; case ASPECT_RATIO_CORE: @@ -480,13 +483,13 @@ static void d3d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) break; } - g_extern.system.aspect_ratio = aspectratio_lut[aspect_ratio_idx].value; + global->system.aspect_ratio = aspectratio_lut[aspect_ratio_idx].value; - if (d3d) - { - d3d->video_info.force_aspect = true; - d3d->should_resize = true; - } + if (!d3d) + return; + + d3d->video_info.force_aspect = true; + d3d->should_resize = true; } static void d3d_apply_state_changes(void *data) @@ -1625,6 +1628,7 @@ static bool d3d_frame(void *data, const void *frame, runloop_t *runloop = rarch_main_get_ptr(); driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); (void)i; @@ -1649,7 +1653,7 @@ static bool d3d_frame(void *data, const void *frame, { d3d_calculate_rect(d3d, d3d->screen_width, d3d->screen_height, d3d->video_info.force_aspect, - g_extern.system.aspect_ratio); + global->system.aspect_ratio); #ifndef _XBOX renderchain_set_final_viewport(d3d->chain, &d3d->final_viewport); diff --git a/gfx/d3d/render_chain.cpp b/gfx/d3d/render_chain.cpp index 6ad07a3306..7707435f9e 100644 --- a/gfx/d3d/render_chain.cpp +++ b/gfx/d3d/render_chain.cpp @@ -278,8 +278,9 @@ bool renderchain_render(void *chain_data, const void *data, { LPDIRECT3DSURFACE back_buffer, target; unsigned i, current_width, current_height, out_width = 0, out_height = 0; - renderchain_t *chain = (renderchain_t*)chain_data; + renderchain_t *chain = (renderchain_t*)chain_data; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)chain->dev; + global_t *global = global_get_ptr(); renderchain_start_render(chain); @@ -290,8 +291,8 @@ bool renderchain_render(void *chain_data, const void *data, current_width, current_height, chain->final_viewport); #ifdef _XBOX1 - d3dr->SetFlickerFilter(g_extern.console.screen.flicker_filter_index); - d3dr->SetSoftDisplayFilter(g_extern.console.softfilter_enable); + d3dr->SetFlickerFilter(global->console.screen.flicker_filter_index); + d3dr->SetSoftDisplayFilter(global->console.softfilter_enable); #endif renderchain_blit_to_texture(chain, data, width, height, pitch); diff --git a/gfx/d3d/render_chain_xdk.h b/gfx/d3d/render_chain_xdk.h index 5be1de4ec3..419b6d901e 100644 --- a/gfx/d3d/render_chain_xdk.h +++ b/gfx/d3d/render_chain_xdk.h @@ -93,19 +93,20 @@ static bool renderchain_create_first_pass(void *data, static bool renderchain_init(void *data, const video_info_t *info) { - d3d_video_t *chain = (d3d_video_t*)data; + d3d_video_t *chain = (d3d_video_t*)data; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)chain->dev; + global_t *global = global_get_ptr(); chain->pixel_size = info->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t); if (!renderchain_create_first_pass(chain, info)) return false; - if (g_extern.console.screen.viewports.custom_vp.width == 0) - g_extern.console.screen.viewports.custom_vp.width = chain->screen_width; + if (global->console.screen.viewports.custom_vp.width == 0) + global->console.screen.viewports.custom_vp.width = chain->screen_width; - if (g_extern.console.screen.viewports.custom_vp.height == 0) - g_extern.console.screen.viewports.custom_vp.height = chain->screen_height; + if (global->console.screen.viewports.custom_vp.height == 0) + global->console.screen.viewports.custom_vp.height = chain->screen_height; return true; } @@ -116,10 +117,11 @@ static void renderchain_render_pass(void *data, const void *frame, unsigned widt LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; runloop_t *runloop = rarch_main_get_ptr(); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); #if defined(_XBOX1) - d3dr->SetFlickerFilter(g_extern.console.screen.flicker_filter_index); - d3dr->SetSoftDisplayFilter(g_extern.console.softfilter_enable); + d3dr->SetFlickerFilter(global->console.screen.flicker_filter_index); + d3dr->SetSoftDisplayFilter(global->console.softfilter_enable); #endif renderchain_blit_to_texture(d3d, frame, width, height, pitch); diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index c299a777f3..7b0ca5c2c0 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -1541,14 +1541,15 @@ static void exynos_gfx_viewport_info(void *data, struct video_viewport *vp) static void exynos_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { - struct exynos_video *vid = data; + struct exynos_video *vid = (struct exynos_video*)data; + global_t *global = global_get_ptr(); switch (aspect_ratio_idx) { case ASPECT_RATIO_SQUARE: video_viewport_set_square_pixel( - g_extern.system.av_info.geometry.base_width, - g_extern.system.av_info.geometry.base_height); + global->system.av_info.geometry.base_width, + global->system.av_info.geometry.base_height); break; case ASPECT_RATIO_CORE: @@ -1563,7 +1564,7 @@ static void exynos_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) break; } - g_extern.system.aspect_ratio = aspectratio_lut[aspect_ratio_idx].value; + global->system.aspect_ratio = aspectratio_lut[aspect_ratio_idx].value; vid->aspect_changed = true; } diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index a92368c3c3..5e44fba561 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -236,6 +236,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, gx_video_t *gx = (gx_video_t*)data; menu_handle_t *menu = menu_driver_resolve(); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); (void)level; @@ -422,10 +423,10 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, } /* custom viewports for older resolutions will most likely be corrupted, reset them */ - g_extern.console.screen.viewports.custom_vp.x = 0; - g_extern.console.screen.viewports.custom_vp.y = 0; - g_extern.console.screen.viewports.custom_vp.width = 0; - g_extern.console.screen.viewports.custom_vp.height = 0; + global->console.screen.viewports.custom_vp.x = 0; + global->console.screen.viewports.custom_vp.y = 0; + global->console.screen.viewports.custom_vp.width = 0; + global->console.screen.viewports.custom_vp.height = 0; g_current_framebuf = 0; } @@ -433,24 +434,25 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, static void gx_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { driver_t *driver = driver_get_ptr(); + global_t *global = global_get_ptr(); gx_video_t *gx = (gx_video_t*)driver->video_data; if (aspect_ratio_idx == ASPECT_RATIO_SQUARE) video_viewport_set_square_pixel( - g_extern.system.av_info.geometry.base_width, - g_extern.system.av_info.geometry.base_height); + global->system.av_info.geometry.base_width, + global->system.av_info.geometry.base_height); else if (aspect_ratio_idx == ASPECT_RATIO_CORE) video_viewport_set_core(); else if (aspect_ratio_idx == ASPECT_RATIO_CONFIG) video_viewport_set_config(); - g_extern.system.aspect_ratio = aspectratio_lut[aspect_ratio_idx].value; + global->system.aspect_ratio = aspectratio_lut[aspect_ratio_idx].value; - if (gx) - { - gx->keep_aspect = true; - gx->should_resize = true; - } + if (!gx) + return; + + gx->keep_aspect = true; + gx->should_resize = true; } static void setup_video_mode(void *data) @@ -833,15 +835,16 @@ static void gx_resize(void *data) int x = 0, y = 0; unsigned width = gx->vp.full_width, height = gx->vp.full_height; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); #ifdef HW_RVL - VIDEO_SetTrapFilter(g_extern.console.softfilter_enable); + VIDEO_SetTrapFilter(global->console.softfilter_enable); #endif - GX_SetDispCopyGamma(g_extern.console.screen.gamma_correction); + GX_SetDispCopyGamma(global->console.screen.gamma_correction); if (gx->keep_aspect && gx_mode.efbHeight >= 240) /* ignore this for custom resolutions */ { - float desired_aspect = g_extern.system.aspect_ratio; + float desired_aspect = global->system.aspect_ratio; if (desired_aspect == 0.0) desired_aspect = 1.0; #ifdef HW_RVL @@ -858,19 +861,19 @@ static void gx_resize(void *data) #ifdef RARCH_CONSOLE if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { - if (!g_extern.console.screen.viewports.custom_vp.width || - !g_extern.console.screen.viewports.custom_vp.height) + if (!global->console.screen.viewports.custom_vp.width || + !global->console.screen.viewports.custom_vp.height) { - g_extern.console.screen.viewports.custom_vp.x = 0; - g_extern.console.screen.viewports.custom_vp.y = 0; - g_extern.console.screen.viewports.custom_vp.width = gx->vp.full_width; - g_extern.console.screen.viewports.custom_vp.height = gx->vp.full_height; + global->console.screen.viewports.custom_vp.x = 0; + global->console.screen.viewports.custom_vp.y = 0; + global->console.screen.viewports.custom_vp.width = gx->vp.full_width; + global->console.screen.viewports.custom_vp.height = gx->vp.full_height; } - x = g_extern.console.screen.viewports.custom_vp.x; - y = g_extern.console.screen.viewports.custom_vp.y; - width = g_extern.console.screen.viewports.custom_vp.width; - height = g_extern.console.screen.viewports.custom_vp.height; + x = global->console.screen.viewports.custom_vp.x; + y = global->console.screen.viewports.custom_vp.y; + width = global->console.screen.viewports.custom_vp.width; + height = global->console.screen.viewports.custom_vp.height; } else #endif diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index ea48cdd064..b1523eb98d 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -388,9 +388,10 @@ static int omapfb_alloc_mem(omapfb_data_t *pdata) { struct omapfb_plane_info pi; struct omapfb_mem_info mi; - const struct retro_game_geometry *geom; unsigned mem_size; - void* mem; + void* mem = NULL; + const struct retro_game_geometry *geom = NULL; + global_t *global = global_get_ptr(); assert(pdata->current_state == NULL); @@ -420,7 +421,7 @@ static int omapfb_alloc_mem(omapfb_data_t *pdata) } } - geom = &g_extern.system.av_info.geometry; + geom = &global->system.av_info.geometry; mem_size = geom->max_width * geom->max_height * pdata->bpp * pdata->num_pages; @@ -916,10 +917,11 @@ static void *omap_gfx_init(const video_info_t *video, { omap_video_t *vid = NULL; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); /* Don't support filters at the moment since they make estimations * * on the maximum used resolution difficult. */ - if (g_extern.filter.filter) + if (global->filter.filter) { RARCH_ERR("video_omap: filters are not supported\n"); return NULL; diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index eaa04f746c..8a006854dd 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -266,6 +266,7 @@ static void sdl_refresh_viewport(sdl2_video_t *vid) { int win_w, win_h; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); SDL_GetWindowSize(vid->window, &win_w, &win_h); @@ -277,11 +278,11 @@ static void sdl_refresh_viewport(sdl2_video_t *vid) vid->vp.full_height = win_h; if (settings->video.scale_integer) - video_viewport_get_scaled_integer(&vid->vp, win_w, win_h, g_extern.system.aspect_ratio, + video_viewport_get_scaled_integer(&vid->vp, win_w, win_h, global->system.aspect_ratio, vid->video.force_aspect); else if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { - const struct video_viewport *custom = &g_extern.console.screen.viewports.custom_vp; + const struct video_viewport *custom = &global->console.screen.viewports.custom_vp; if (custom) { @@ -295,7 +296,7 @@ static void sdl_refresh_viewport(sdl2_video_t *vid) { float delta; float device_aspect = (float)win_w / win_h; - float desired_aspect = g_extern.system.aspect_ratio; + float desired_aspect = global->system.aspect_ratio; if (fabsf(device_aspect - desired_aspect) < 0.0001f) { @@ -647,13 +648,14 @@ void sdl2_poke_set_filtering(void *data, unsigned index, bool smooth) static void sdl2_poke_set_aspect_ratio(void *data, unsigned aspectratio_index) { - sdl2_video_t *vid = (sdl2_video_t*)data; + sdl2_video_t *vid = (sdl2_video_t*)data; + global_t *global = global_get_ptr(); switch (aspectratio_index) { case ASPECT_RATIO_SQUARE: - video_viewport_set_square_pixel(g_extern.system.av_info.geometry.base_width, - g_extern.system.av_info.geometry.base_height); + video_viewport_set_square_pixel(global->system.av_info.geometry.base_width, + global->system.av_info.geometry.base_height); break; case ASPECT_RATIO_CORE: @@ -668,7 +670,7 @@ static void sdl2_poke_set_aspect_ratio(void *data, unsigned aspectratio_index) break; } - g_extern.system.aspect_ratio = aspectratio_lut[aspectratio_index].value; + global->system.aspect_ratio = aspectratio_lut[aspectratio_index].value; vid->video.force_aspect = true; vid->should_resize = true; diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 7d700ae22f..22f826602c 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -450,12 +450,13 @@ static void sdl_set_filtering(void *data, unsigned index, bool smooth) static void sdl_set_aspect_ratio(void *data, unsigned aspectratio_index) { sdl_video_t *vid = (sdl_video_t*)data; + global_t *global = global_get_ptr(); switch (aspectratio_index) { case ASPECT_RATIO_SQUARE: - video_viewport_set_square_pixel(g_extern.system.av_info.geometry.base_width, - g_extern.system.av_info.geometry.base_height); + video_viewport_set_square_pixel(global->system.av_info.geometry.base_width, + global->system.av_info.geometry.base_height); break; case ASPECT_RATIO_CORE: @@ -470,7 +471,7 @@ static void sdl_set_aspect_ratio(void *data, unsigned aspectratio_index) break; } - g_extern.system.aspect_ratio = aspectratio_lut[aspectratio_index].value; + global->system.aspect_ratio = aspectratio_lut[aspectratio_index].value; } static void sdl_apply_state_changes(void *data) diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index 95e6423cb6..1b0686f8ce 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -357,12 +357,13 @@ static void calc_out_rect(bool keep_aspect, struct video_viewport *vp, unsigned vp_width, unsigned vp_height) { settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); vp->full_width = vp_width; vp->full_height = vp_height; if (settings->video.scale_integer) - video_viewport_get_scaled_integer(vp, vp_width, vp_height, g_extern.system.aspect_ratio, keep_aspect); + video_viewport_get_scaled_integer(vp, vp_width, vp_height, global->system.aspect_ratio, keep_aspect); else if (!keep_aspect) { vp->x = 0; vp->y = 0; @@ -371,8 +372,8 @@ static void calc_out_rect(bool keep_aspect, struct video_viewport *vp, } else { - float desired_aspect = g_extern.system.aspect_ratio; - float device_aspect = (float)vp_width / vp_height; + float desired_aspect = global->system.aspect_ratio; + float device_aspect = (float)vp_width / vp_height; /* If the aspect ratios of screen and desired aspect ratio * are sufficiently equal (floating point stuff), @@ -421,6 +422,7 @@ static void *xv_init(const video_info_t *video, const struct retro_game_geometry *geom = NULL; driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); xv_t *xv = (xv_t*)calloc(1, sizeof(*xv)); if (!xv) return NULL; @@ -428,7 +430,7 @@ static void *xv_init(const video_info_t *video, XInitThreads(); xv->display = XOpenDisplay(NULL); - geom = &g_extern.system.av_info.geometry; + geom = &global->system.av_info.geometry; if (!XShmQueryExtension(xv->display)) { diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 9c50998d68..d1f2b38c98 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -747,12 +747,14 @@ static int16_t android_input_state(void *data, static bool android_input_key_pressed(void *data, int key) { android_input_t *android = (android_input_t*)data; - driver_t *driver = driver_get_ptr(); - settings_t *settings = config_get_ptr(); + driver_t *driver = driver_get_ptr(); + global_t *global = global_get_ptr(); + settings_t *settings = config_get_ptr(); if (!android) return false; - return ((g_extern.lifecycle_state | driver->overlay_state.buttons) + + return ((global->lifecycle_state | driver->overlay_state.buttons) & (1ULL << key)) || input_joypad_pressed(android->joypad, 0, settings->input.binds[0], key); } diff --git a/input/drivers/gx_input.c b/input/drivers/gx_input.c index 2c78ef71aa..77ce402a69 100644 --- a/input/drivers/gx_input.c +++ b/input/drivers/gx_input.c @@ -91,8 +91,9 @@ static void gx_input_poll(void *data) static bool gx_input_key_pressed(void *data, int key) { settings_t *settings = config_get_ptr(); - gx_input_t *gx = (gx_input_t*)data; - return (g_extern.lifecycle_state & (1ULL << key)) || + global_t *global = global_get_ptr(); + gx_input_t *gx = (gx_input_t*)data; + return (global->lifecycle_state & (1ULL << key)) || input_joypad_pressed(gx->joypad, 0, settings->input.binds[0], key); } diff --git a/input/drivers/ps3_input.c b/input/drivers/ps3_input.c index 7549192a74..b3466a1b3c 100644 --- a/input/drivers/ps3_input.c +++ b/input/drivers/ps3_input.c @@ -176,10 +176,12 @@ static bool ps3_input_key_pressed(void *data, int key) { ps3_input_t *ps3 = (ps3_input_t*)data; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (!ps3) return false; - return (g_extern.lifecycle_state & (1ULL << key)) || + + return (global->lifecycle_state & (1ULL << key)) || input_joypad_pressed(ps3->joypad, 0, settings->input.binds[0], key); } diff --git a/input/drivers/psp_input.c b/input/drivers/psp_input.c index cccfd19277..f8a3f51a24 100644 --- a/input/drivers/psp_input.c +++ b/input/drivers/psp_input.c @@ -95,8 +95,10 @@ static void* psp_input_initialize(void) static bool psp_input_key_pressed(void *data, int key) { settings_t *settings = config_get_ptr(); - psp_input_t *psp = (psp_input_t*)data; - return (g_extern.lifecycle_state & (1ULL << key)) || + global_t *global = global_get_ptr(); + psp_input_t *psp = (psp_input_t*)data; + + return (global->lifecycle_state & (1ULL << key)) || input_joypad_pressed(psp->joypad, 0, settings->input.binds[0], key); } diff --git a/input/drivers/qnx_input.c b/input/drivers/qnx_input.c index 9cb3f35a9b..e7dcb53c49 100644 --- a/input/drivers/qnx_input.c +++ b/input/drivers/qnx_input.c @@ -92,8 +92,10 @@ static void process_gamepad_event(void *data, int i; screen_device_t device; input_device_t* controller = NULL; - settings_t *settings = config_get_ptr(); qnx_input_t *qnx = (qnx_input_t*)data; + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + uint64_t *state_cur = NULL; (void)type; @@ -116,9 +118,9 @@ static void process_gamepad_event(void *data, screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_BUTTONS, &controller->buttons); - uint64_t *state_cur = (uint64_t*)&qnx->pad_state[controller->port]; - + state_cur = (uint64_t*)&qnx->pad_state[controller->port]; *state_cur = 0; + for (i = 0; i < 20; i++) *state_cur |= (controller->buttons & (1 << i) ? (1 << i) : 0); @@ -135,7 +137,7 @@ static void process_gamepad_event(void *data, if((controller->port == 0) && (controller->buttons & settings->input.binds[0][RARCH_MENU_TOGGLE].joykey)) - g_extern.lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE); + global->lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE); } static void handle_device(void *data, input_device_t* controller) @@ -325,6 +327,7 @@ static void process_keyboard_event(void *data, int i, b, sym, modifiers, flags, scan, cap; qnx_input_t *qnx = (qnx_input_t*)data; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); (void)type; @@ -397,7 +400,7 @@ static void process_keyboard_event(void *data, == (unsigned int)(sym&0xFF))) { if (flags & KEY_DOWN) - g_extern.lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE); + global->lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE); } } @@ -588,9 +591,10 @@ static void handle_screen_event(void *data, bps_event_t *event) static void handle_navigator_event(void *data, bps_event_t *event) { + int rc; navigator_window_state_t state; bps_event_t *event_pause = NULL; - int rc; + global_t *global = global_get_ptr(); (void)data; (void)rc; @@ -598,7 +602,7 @@ static void handle_navigator_event(void *data, bps_event_t *event) switch (bps_event_get_code(event)) { case NAVIGATOR_SWIPE_DOWN: - g_extern.lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE); + global->lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE); break; case NAVIGATOR_EXIT: /* Catch this in thumbnail loop. */ @@ -622,7 +626,7 @@ static void handle_navigator_event(void *data, bps_event_t *event) } else if (bps_event_get_code(event_pause) == NAVIGATOR_EXIT) { - g_extern.system.shutdown = true; + global->system.shutdown = true; break; } } @@ -676,12 +680,13 @@ static void *qnx_input_init(void) static void qnx_input_poll(void *data) { - (void)data; - /* Request and process all available BPS events. */ - int rc, domain; + global_t *global = global_get_ptr(); - g_extern.lifecycle_state &= ~(1ULL << RARCH_MENU_TOGGLE); + (void)data; + global->lifecycle_state &= ~(1ULL << RARCH_MENU_TOGGLE); + + /* Request and process all available BPS events. */ while(true) { @@ -794,10 +799,11 @@ static int16_t qnx_input_state(void *data, static bool qnx_input_key_pressed(void *data, int key) { - qnx_input_t *qnx = (qnx_input_t*)data; + qnx_input_t *qnx = (qnx_input_t*)data; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); - return ((g_extern.lifecycle_state | driver.overlay_state.buttons ) & (1ULL << key) || + return ((global->lifecycle_state | driver.overlay_state.buttons ) & (1ULL << key) || input_joypad_pressed(qnx->joypad, 0, settings->input.binds[0], key)); } diff --git a/input/drivers/xdk_xinput_input.c b/input/drivers/xdk_xinput_input.c index 4f5e7ff66f..24f272f5b2 100644 --- a/input/drivers/xdk_xinput_input.c +++ b/input/drivers/xdk_xinput_input.c @@ -87,9 +87,11 @@ static void *xdk_input_init(void) static bool xdk_input_key_pressed(void *data, int key) { - xdk_input_t *xdk = (xdk_input_t*)data; + xdk_input_t *xdk = (xdk_input_t*)data; settings_t *settings = config_get_ptr(); - return (g_extern.lifecycle_state & (1ULL << key)) || + global_t *global = global_get_ptr(); + + return (global->lifecycle_state & (1ULL << key)) || input_joypad_pressed(xdk->joypad, 0, settings->input.binds[0], key); } diff --git a/input/drivers/xenon360_input.c b/input/drivers/xenon360_input.c index 4580506efe..8fa3df56c4 100644 --- a/input/drivers/xenon360_input.c +++ b/input/drivers/xenon360_input.c @@ -89,7 +89,8 @@ static void* xenon360_input_init(void) static bool xenon360_input_key_pressed(void *data, int key) { - return (g_extern.lifecycle_state & (1ULL << key)); + global_t *global = global_get_ptr(); + return (global->lifecycle_state & (1ULL << key)); } static uint64_t xenon360_get_capabilities(void *data) diff --git a/input/drivers_joypad/gx_input_joypad.c b/input/drivers_joypad/gx_input_joypad.c index 3415b83036..1a5f8ef417 100644 --- a/input/drivers_joypad/gx_input_joypad.c +++ b/input/drivers_joypad/gx_input_joypad.c @@ -401,7 +401,8 @@ static s8 WPAD_StickY(WPADData *data, u8 chan, u8 right) static void gx_joypad_poll(void) { unsigned i, j, port; - uint8_t gcpad = 0; + uint8_t gcpad = 0; + global_t *global = global_get_ptr(); pad_state[0] = 0; pad_state[1] = 0; @@ -592,8 +593,8 @@ static void gx_joypad_poll(void) analog_state[port][i][j] = -0x7fff; } - uint64_t *state_p1 = &pad_state[0]; - uint64_t *lifecycle_state = &g_extern.lifecycle_state; + uint64_t *state_p1 = &pad_state[0]; + uint64_t *lifecycle_state = &global->lifecycle_state; *lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE)); diff --git a/input/drivers_joypad/ps3_input_joypad.c b/input/drivers_joypad/ps3_input_joypad.c index f6554e3f87..ab953fcfdc 100644 --- a/input/drivers_joypad/ps3_input_joypad.c +++ b/input/drivers_joypad/ps3_input_joypad.c @@ -120,8 +120,9 @@ static void ps3_joypad_poll(void) { unsigned port; CellPadInfo2 pad_info; - uint64_t *lifecycle_state = (uint64_t*)&g_extern.lifecycle_state; - runloop_t *runloop = rarch_main_get_ptr(); + global_t *global = global_get_ptr(); + runloop_t *runloop = rarch_main_get_ptr(); + uint64_t *lifecycle_state = (uint64_t*)&global->lifecycle_state; for (port = 0; port < MAX_PADS; port++) { diff --git a/input/drivers_joypad/psp_input_joypad.c b/input/drivers_joypad/psp_input_joypad.c index 5127989aec..7d2bb0db8c 100644 --- a/input/drivers_joypad/psp_input_joypad.c +++ b/input/drivers_joypad/psp_input_joypad.c @@ -102,8 +102,9 @@ static int16_t psp_joypad_axis(unsigned port_num, uint32_t joyaxis) static void psp_joypad_poll(void) { int32_t ret; - uint64_t *lifecycle_state = (uint64_t*)&g_extern.lifecycle_state; SceCtrlData state_tmp; + global_t *global = global_get_ptr(); + uint64_t *lifecycle_state = (uint64_t*)&global->lifecycle_state; #ifdef PSP sceCtrlSetSamplingCycle(0); diff --git a/input/drivers_joypad/xdk_xinput_input_joypad.c b/input/drivers_joypad/xdk_xinput_input_joypad.c index 4570f9001b..5bc6fcc46b 100644 --- a/input/drivers_joypad/xdk_xinput_input_joypad.c +++ b/input/drivers_joypad/xdk_xinput_input_joypad.c @@ -137,8 +137,10 @@ static int16_t xdk_joypad_axis(unsigned port_num, uint32_t joyaxis) static void xdk_joypad_poll(void) { - uint64_t *state_p1, *lifecycle_state; unsigned port; + uint64_t *state_p1 = NULL; + uint64_t *lifecycle_state = NULL; + global_t *global = global_get_ptr(); #if defined(_XBOX1) unsigned int dwInsertions, dwRemovals; @@ -247,7 +249,7 @@ static void xdk_joypad_poll(void) } state_p1 = &pad_state[0]; - lifecycle_state = &g_extern.lifecycle_state; + lifecycle_state = &global->lifecycle_state; *lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE)); diff --git a/input/keyboard_line.c b/input/keyboard_line.c index 373233f6fb..359ebc3f94 100644 --- a/input/keyboard_line.c +++ b/input/keyboard_line.c @@ -242,6 +242,7 @@ void input_keyboard_event(bool down, unsigned code, { static bool deferred_wait_keys; driver_t *driver = driver_get_ptr(); + global_t *global = global_get_ptr(); if (deferred_wait_keys) { @@ -285,7 +286,7 @@ void input_keyboard_event(bool down, unsigned code, /* Unblock all hotkeys. */ driver->block_input = false; } - else if (g_extern.system.key_event) - g_extern.system.key_event(down, code, character, mod); + else if (global->system.key_event) + global->system.key_event(down, code, character, mod); } diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 211bf2acd3..d5fd9e4525 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -124,6 +124,7 @@ static void glui_render_background(settings_t *settings, 0.0f, 0.0f, 0.0f, alpha, 0.0f, 0.0f, 0.0f, alpha, }; + global_t *global = global_get_ptr(); glViewport(0, 0, gl->win_width, gl->win_height); @@ -133,7 +134,7 @@ static void glui_render_background(settings_t *settings, coords.lut_tex_coord = tex_coord; if ((settings->menu.pause_libretro - || !g_extern.main_is_init || g_extern.libretro_dummy) + || !global->main_is_init || global->libretro_dummy) && !force_transparency && glui->textures.bg.id) { @@ -335,6 +336,7 @@ static void glui_frame(void) const uint32_t normal_color = FONT_COLOR_ARGB_TO_RGBA(settings->menu.entry_normal_color); const uint32_t hover_color = FONT_COLOR_ARGB_TO_RGBA(settings->menu.entry_hover_color); runloop_t *runloop = rarch_main_get_ptr(); + global_t *global = global_get_ptr(); if (!menu) return; @@ -372,17 +374,17 @@ static void glui_frame(void) glui_blit_line(gl, glui->margin * 2, glui->margin + glui->line_height, title_buf, FONT_COLOR_ARGB_TO_RGBA(settings->menu.title_color)); - core_name = g_extern.menu.info.library_name; + core_name = global->menu.info.library_name; if (!core_name) - core_name = g_extern.system.info.library_name; + core_name = global->system.info.library_name; if (!core_name) core_name = "No Core"; if (settings->menu.core_enable) { - core_version = g_extern.menu.info.library_version; + core_version = global->menu.info.library_version; if (!core_version) - core_version = g_extern.system.info.library_version; + core_version = global->system.info.library_version; if (!core_version) core_version = ""; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 07d6e0c401..55392af620 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -357,6 +357,7 @@ static void rgui_render(void) menu_handle_t *menu = menu_driver_resolve(); 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(); (void)driver; @@ -416,17 +417,17 @@ static void rgui_render(void) blit_line(menu, RGUI_TERM_START_X + RGUI_TERM_START_X, RGUI_TERM_START_X, title_buf, TITLE_COLOR(settings)); - core_name = g_extern.menu.info.library_name; + core_name = global->menu.info.library_name; if (!core_name) - core_name = g_extern.system.info.library_name; + core_name = global->system.info.library_name; if (!core_name) core_name = "No Core"; if (settings->menu.core_enable) { - core_version = g_extern.menu.info.library_version; + core_version = global->menu.info.library_version; if (!core_version) - core_version = g_extern.system.info.library_version; + core_version = global->system.info.library_version; if (!core_version) core_version = ""; diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index a3a655ca10..be731e8434 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -154,6 +154,7 @@ static void rmenu_render(void) const char *core_version = NULL; unsigned menu_type = 0; menu_handle_t *menu = menu_driver_resolve(); + global_t *global = global_get_ptr(); runloop_t *runloop = rarch_main_get_ptr(); if (!menu) @@ -209,15 +210,15 @@ static void rmenu_render(void) driver.video_poke->set_osd_msg(driver.video_data, title_buf, &font_parms, NULL); - core_name = g_extern.menu.info.library_name; + core_name = global->menu.info.library_name; if (!core_name) - core_name = g_extern.system.info.library_name; + core_name = global->system.info.library_name; if (!core_name) core_name = "No Core"; - core_version = g_extern.menu.info.library_version; + core_version = global->menu.info.library_version; if (!core_version) - core_version = g_extern.system.info.library_version; + core_version = global->system.info.library_version; if (!core_version) core_version = ""; diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index d1d6b9485a..c9a42e5124 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -166,6 +166,8 @@ HRESULT CRetroArch::UnregisterXuiClasses (void) HRESULT CRetroArchMain::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) { + global_t *global = global_get_ptr(); + GetChildById(L"XuiMenuList", &m_menulist); GetChildById(L"XuiTxtTitle", &m_menutitle); GetChildById(L"XuiTxtBottom", &m_menutitlebottom); @@ -174,7 +176,7 @@ HRESULT CRetroArchMain::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) if (XuiHandleIsValid(m_menutitlebottom)) { char str[PATH_MAX_LENGTH]; - snprintf(str, sizeof(str), "%s - %s", PACKAGE_VERSION, g_extern.title_buf); + snprintf(str, sizeof(str), "%s - %s", PACKAGE_VERSION, global->title_buf); mbstowcs(strw_buffer, str, sizeof(strw_buffer) / sizeof(wchar_t)); XuiTextElementSetText(m_menutitlebottom, strw_buffer); } @@ -477,7 +479,9 @@ static void blit_line(int x, int y, const char *message, bool green) static void rmenu_xui_render_background(void) { - if (g_extern.content_is_init) + global_t *global = global_get_ptr(); + + if (global->content_is_init) XuiElementSetShow(m_background, FALSE); else XuiElementSetShow(m_background, TRUE); @@ -580,15 +584,16 @@ static void rmenu_xui_render(void) if (XuiHandleIsValid(m_menutitle)) { const char *core_version = NULL; - const char *core_name = g_extern.menu.info.library_name; + global_t *global = global_get_ptr(); + const char *core_name = global->menu.info.library_name; if (!core_name) - core_name = g_extern.system.info.library_name; + core_name = global->system.info.library_name; if (!core_name) core_name = "No Core"; - core_version = g_extern.menu.info.library_version; + core_version = global->menu.info.library_version; if (!core_version) - core_version = g_extern.system.info.library_version; + core_version = global->system.info.library_version; if (!core_version) core_version = ""; diff --git a/menu/drivers/shared.h b/menu/drivers/shared.h index d49193caed..ab2f300786 100644 --- a/menu/drivers/shared.h +++ b/menu/drivers/shared.h @@ -346,9 +346,11 @@ static INLINE void get_title(const char *label, const char *dir, snprintf(title, sizeof_title, "CONTENT %s", dir); else { - const char *core_name = g_extern.menu.info.library_name; + global_t *global = global_get_ptr(); + const char *core_name = global->menu.info.library_name; + if (!core_name) - core_name = g_extern.system.info.library_name; + core_name = global->system.info.library_name; if (!core_name) core_name = "No Core"; snprintf(title, sizeof_title, "CONTENT (%s) %s", core_name, dir); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index d1ad27d940..9503369f2d 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -426,6 +426,7 @@ static void xmb_frame_background(settings_t *settings, 0, 1, 1, 1, }; + global_t *global = global_get_ptr(); static const GLfloat tex_coord[] = { 0, 1, @@ -460,7 +461,7 @@ static void xmb_frame_background(settings_t *settings, coords.lut_tex_coord = tex_coord; if ((settings->menu.pause_libretro - || !g_extern.main_is_init || g_extern.libretro_dummy) + || !global->main_is_init || global->libretro_dummy) && !force_transparency && xmb->textures.bg.id) { @@ -662,8 +663,9 @@ static void xmb_list_open_new(xmb_handle_t *xmb, file_list_t *list, int dir, siz static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, core_info_t *info, unsigned i) { - core_info_list_t *info_list = (core_info_list_t*)g_extern.core_info; xmb_node_t *node = NULL; + global_t *global = global_get_ptr(); + core_info_list_t *info_list = (core_info_list_t*)global->core_info; if (!info_list) return NULL; @@ -706,7 +708,8 @@ static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, core_info_t *in static xmb_node_t* xmb_get_userdata_from_core(xmb_handle_t *xmb, core_info_t *info, unsigned i) { - core_info_list_t *info_list = (core_info_list_t*)g_extern.core_info; + global_t *global = global_get_ptr(); + core_info_list_t *info_list = (core_info_list_t*)global->core_info; if (!info_list) return NULL; @@ -810,8 +813,9 @@ static void xmb_set_title(xmb_handle_t *xmb) } else { - core_info_t *info = NULL; - core_info_list_t *info_list = (core_info_list_t*)g_extern.core_info; + core_info_t *info = NULL; + global_t *global = global_get_ptr(); + core_info_list_t *info_list = (core_info_list_t*)global->core_info; if (!info_list) return; @@ -1248,6 +1252,7 @@ static void xmb_frame(void) gl_t *gl = NULL; menu_handle_t *menu = menu_driver_resolve(); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (!menu) return; @@ -1278,17 +1283,17 @@ static void xmb_frame(void) if (settings->menu.core_enable) { - core_name = g_extern.menu.info.library_name; + core_name = global->menu.info.library_name; if (!core_name) - core_name = g_extern.system.info.library_name; + core_name = global->system.info.library_name; if (!core_name) core_name = "No Core"; - core_version = g_extern.menu.info.library_version; + core_version = global->menu.info.library_version; if (!core_version) - core_version = g_extern.system.info.library_version; + core_version = global->system.info.library_version; if (!core_version) core_version = ""; @@ -1384,11 +1389,12 @@ static void xmb_frame(void) static void *xmb_init(void) { - menu_handle_t *menu = NULL; - xmb_handle_t *xmb = NULL; + menu_handle_t *menu = NULL; + xmb_handle_t *xmb = NULL; const video_driver_t *video_driver = NULL; - float scale_factor = 1; - gl_t *gl = (gl_t*)video_driver_resolve(&video_driver); + float scale_factor = 1; + gl_t *gl = (gl_t*)video_driver_resolve(&video_driver); + global_t *global = global_get_ptr(); if (video_driver != &video_gl || !gl) { @@ -1477,8 +1483,8 @@ static void *xmb_init(void) menu->categories.size = 1; - if (g_extern.core_info) - menu->categories.size = g_extern.core_info->count + 1; + if (global->core_info) + menu->categories.size = global->core_info->count + 1; return menu; @@ -1505,9 +1511,10 @@ static bool xmb_font_init_first(const gl_font_renderer_t **font_driver, float xmb_font_size) { settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (settings->video.threaded - && !g_extern.system.hw_render_callback.context_type) + && !global->system.hw_render_callback.context_type) { driver_t *driver = driver_get_ptr(); thread_video_t *thr = (thread_video_t*)driver->video_data; @@ -1571,6 +1578,7 @@ static void xmb_context_reset(void) xmb_node_t *node = NULL; menu_handle_t *menu = menu_driver_resolve(); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (!menu) return; @@ -1688,7 +1696,7 @@ static void xmb_context_reset(void) xmb->settings_node.alpha = xmb->categories.active.alpha; xmb->settings_node.zoom = xmb->categories.active.zoom; - info_list = (core_info_list_t*)g_extern.core_info; + info_list = (core_info_list_t*)global->core_info; if (!info_list) return; diff --git a/menu/menu_entries_cbs_deferred_push.c b/menu/menu_entries_cbs_deferred_push.c index 2b59feeb40..a437079872 100644 --- a/menu/menu_entries_cbs_deferred_push.c +++ b/menu/menu_entries_cbs_deferred_push.c @@ -133,11 +133,12 @@ static int deferred_push_core_information(void *data, void *userdata, file_list_t *menu_list = (file_list_t*)userdata; driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (!list || !menu_list) return -1; - info = (core_info_t*)g_extern.core_info_current; + info = (core_info_t*)global->core_info_current; menu_list_clear(list); if (info && info->data) @@ -218,7 +219,7 @@ static int deferred_push_core_information(void *data, void *userdata, if (info->firmware_count > 0) { core_info_list_update_missing_firmware( - g_extern.core_info, info->path, + global->core_info, info->path, settings->system_directory); menu_list_push(list, "Firmware: ", "", @@ -560,9 +561,10 @@ static int deferred_push_core_list_deferred(void *data, void *userdata, unsigned i; size_t list_size = 0; const core_info_t *info = NULL; - file_list_t *list = NULL; - file_list_t *menu_list = NULL; - menu_handle_t *menu = menu_driver_resolve(); + file_list_t *list = NULL; + file_list_t *menu_list = NULL; + global_t *global = global_get_ptr(); + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return -1; @@ -573,7 +575,7 @@ static int deferred_push_core_list_deferred(void *data, void *userdata, return -1; menu_list_clear(list); - core_info_list_get_supported_cores(g_extern.core_info, + core_info_list_get_supported_cores(global->core_info, menu->deferred_path, &info, &list_size); for (i = 0; i < list_size; i++) @@ -777,12 +779,13 @@ static int deferred_push_core_information(void *data, void *userdata, core_info_t *info = NULL; file_list_t *list = (file_list_t*)data; file_list_t *menu_list = (file_list_t*)userdata; - driver_t *driver = driver_get_ptr(); + driver_t *driver = driver_get_ptr(); + global_t *global = global_get_ptr(); if (!list || !menu_list) return -1; - info = (core_info_t*)g_extern.core_info_current; + info = (core_info_t*)global->core_info_current; menu_list_clear(list); if (info->data) @@ -863,7 +866,7 @@ static int deferred_push_core_information(void *data, void *userdata, if (info->firmware_count > 0) { core_info_list_update_missing_firmware( - g_extern.core_info, info->path, + global->core_info, info->path, settings->system_directory); menu_list_push(list, "Firmware: ", "", @@ -1249,7 +1252,8 @@ static int deferred_push_options(void *data, void *userdata, { file_list_t *list = (file_list_t*)data; file_list_t *menu_list = (file_list_t*)userdata; - driver_t *driver = driver_get_ptr(); + driver_t *driver = driver_get_ptr(); + global_t *global = global_get_ptr(); if (!list || !menu_list) return -1; @@ -1257,14 +1261,14 @@ static int deferred_push_options(void *data, void *userdata, menu_list_clear(list); menu_list_push(list, "Core Options", "core_options", MENU_SETTING_ACTION, 0); - if (g_extern.main_is_init) + if (global->main_is_init) { - if (g_extern.has_set_input_descriptors) + if (global->has_set_input_descriptors) menu_list_push(list, "Core Input Remapping Options", "core_input_remapping_options", MENU_SETTING_ACTION, 0); menu_list_push(list, "Core Cheat Options", "core_cheat_options", MENU_SETTING_ACTION, 0); - if (!g_extern.libretro_dummy && g_extern.system.disk_control.get_num_images) + if (!global->libretro_dummy && global->system.disk_control.get_num_images) menu_list_push(list, "Core Disk Options", "core_disk_options", MENU_SETTING_ACTION, 0); } @@ -1373,8 +1377,9 @@ static int deferred_push_core_cheat_options(void *data, void *userdata, { unsigned i; file_list_t *list = (file_list_t*)data; - cheat_manager_t *cheat = g_extern.cheat; - driver_t *driver = driver_get_ptr(); + global_t *global = global_get_ptr(); + driver_t *driver = driver_get_ptr(); + cheat_manager_t *cheat = global->cheat; (void)userdata; (void)type; @@ -1384,11 +1389,11 @@ static int deferred_push_core_cheat_options(void *data, void *userdata, if (!cheat) { - g_extern.cheat = cheat_manager_new(0); + global->cheat = cheat_manager_new(0); - if (!g_extern.cheat) + if (!global->cheat) return -1; - cheat = g_extern.cheat; + cheat = global->cheat; } menu_list_clear(list); @@ -1423,6 +1428,7 @@ static int deferred_push_core_input_remapping_options(void *data, void *userdata file_list_t *list = (file_list_t*)data; driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); (void)userdata; (void)type; @@ -1442,7 +1448,7 @@ static int deferred_push_core_input_remapping_options(void *data, void *userdata { char desc_label[64]; unsigned user = p + 1; - const char *description = g_extern.system.input_desc_btn[p][retro_id]; + const char *description = global->system.input_desc_btn[p][retro_id]; if (!description) continue; @@ -1466,7 +1472,8 @@ static int deferred_push_core_options(void *data, void *userdata, { unsigned i; file_list_t *list = (file_list_t*)data; - driver_t *driver = driver_get_ptr(); + driver_t *driver = driver_get_ptr(); + global_t *global = global_get_ptr(); (void)userdata; @@ -1475,13 +1482,13 @@ static int deferred_push_core_options(void *data, void *userdata, menu_list_clear(list); - if (g_extern.system.core_options) + if (global->system.core_options) { - size_t opts = core_option_size(g_extern.system.core_options); + size_t opts = core_option_size(global->system.core_options); for (i = 0; i < opts; i++) menu_list_push(list, - core_option_get_desc(g_extern.system.core_options, i), "", + core_option_get_desc(global->system.core_options, i), "", MENU_SETTINGS_CORE_OPTION_START + i, 0); } else @@ -1657,8 +1664,9 @@ static int deferred_push_history_list(void *data, void *userdata, static int deferred_push_content_actions(void *data, void *userdata, const char *path, const char *label, unsigned type) { - file_list_t *list = (file_list_t*)data; + file_list_t *list = (file_list_t*)data; menu_handle_t *menu = menu_driver_resolve(); + global_t *global = global_get_ptr(); if (!menu) return -1; @@ -1669,19 +1677,18 @@ static int deferred_push_content_actions(void *data, void *userdata, menu_list_clear(list); - - if (g_extern.main_is_init && !g_extern.libretro_dummy && - !strcmp(menu->deferred_path, g_extern.fullpath)) + if (global->main_is_init && !global->libretro_dummy && + !strcmp(menu->deferred_path, global->fullpath)) { menu_list_push(list, "Resume", "file_load_or_resume", MENU_SETTING_ACTION_RUN, 0); menu_list_push(list, "Save State", "savestate", MENU_SETTING_ACTION_SAVESTATE, 0); menu_list_push(list, "Load State", "loadstate", MENU_SETTING_ACTION_LOADSTATE, 0); menu_list_push(list, "Core Information", "core_information", MENU_SETTING_ACTION_CORE_INFORMATION, 0); menu_list_push(list, "Core Options", "core_options", MENU_SETTING_ACTION_CORE_OPTIONS, 0); - if (g_extern.has_set_input_descriptors) + if (global->has_set_input_descriptors) menu_list_push(list, "Core Input Remapping Options", "core_input_remapping_options", MENU_SETTING_ACTION_CORE_INPUT_REMAPPING_OPTIONS, 0); menu_list_push(list, "Core Cheat Options", "core_cheat_options", MENU_SETTING_ACTION_CORE_CHEAT_OPTIONS, 0); - if ( !g_extern.libretro_dummy && g_extern.system.disk_control.get_num_images) + if ( !global->libretro_dummy && global->system.disk_control.get_num_images) menu_list_push(list, "Core Disk Options", "disk_options", MENU_SETTING_ACTION_CORE_DISK_OPTIONS, 0); menu_list_push(list, "Take Screenshot", "take_screenshot", MENU_SETTING_ACTION_SCREENSHOT, 0); menu_list_push(list, "Reset", "restart_content", MENU_SETTING_ACTION_RESET, 0); @@ -1813,38 +1820,41 @@ static int deferred_push_content_history_path(void *data, void *userdata, static int deferred_push_detect_core_list(void *data, void *userdata, const char *path, const char *label, unsigned type) { + global_t *global = global_get_ptr(); + return menu_entries_parse_list((file_list_t*)data, (file_list_t*)userdata, path, label, type, MENU_FILE_PLAIN, - g_extern.core_info ? core_info_list_get_all_extensions( - g_extern.core_info) : "", NULL); + global->core_info ? core_info_list_get_all_extensions( + global->core_info) : "", NULL); } static int deferred_push_default(void *data, void *userdata, const char *path, const char *label, unsigned type) { char ext_buf[PATH_MAX_LENGTH]; - const char *exts = NULL; - file_list_t *list = (file_list_t*)data; - file_list_t *menu_list = (file_list_t*)userdata; + const char *exts = NULL; + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; rarch_setting_t *setting = (rarch_setting_t*) menu_setting_find(label); + global_t *global = global_get_ptr(); if (!list || !menu_list) return -1; if (setting && setting->browser_selection_type == ST_DIR) exts = ""; /* we ignore files anyway */ - else if (g_extern.menu.info.valid_extensions) + else if (global->menu.info.valid_extensions) { exts = ext_buf; - if (*g_extern.menu.info.valid_extensions) + if (*global->menu.info.valid_extensions) snprintf(ext_buf, sizeof(ext_buf), "%s", - g_extern.menu.info.valid_extensions); + global->menu.info.valid_extensions); else *ext_buf = '\0'; } else - exts = g_extern.system.valid_extensions; + exts = global->system.valid_extensions; menu_entries_parse_list(list, menu_list, path, label, type, MENU_FILE_PLAIN, exts, setting); diff --git a/menu/menu_entries_cbs_iterate.c b/menu/menu_entries_cbs_iterate.c index 8c1d840aa2..f613a45e71 100644 --- a/menu/menu_entries_cbs_iterate.c +++ b/menu/menu_entries_cbs_iterate.c @@ -70,6 +70,7 @@ static int archive_load(void) unsigned int type = 0; menu_handle_t *menu = menu_driver_resolve(); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (!menu) return -1; @@ -85,7 +86,7 @@ static int archive_load(void) menu_list_get_at_offset(menu->menu_list->selection_buf, menu->navigation.selection_ptr, &path, NULL, &type); - ret = rarch_defer_core(g_extern.core_info, menu_path, path, menu_label, + ret = rarch_defer_core(global->core_info, menu_path, path, menu_label, menu->deferred_path, sizeof(menu->deferred_path)); switch (ret) @@ -379,7 +380,8 @@ static int action_iterate_menu_viewport(const char *label, unsigned action) struct retro_game_geometry *geom = NULL; const char *base_msg = NULL; unsigned type = 0; - video_viewport_t *custom = &g_extern.console.screen.viewports.custom_vp; + global_t *global = global_get_ptr(); + video_viewport_t *custom = &global->console.screen.viewports.custom_vp; menu_handle_t *menu = menu_driver_resolve(); driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); @@ -389,7 +391,7 @@ static int action_iterate_menu_viewport(const char *label, unsigned action) menu_list_get_last_stack(menu->menu_list, NULL, NULL, &type); - geom = (struct retro_game_geometry*)&g_extern.system.av_info.geometry; + geom = (struct retro_game_geometry*)&global->system.av_info.geometry; if (settings->video.scale_integer) { @@ -683,7 +685,8 @@ static int action_iterate_main(const char *label, unsigned action) const char *path_offset = NULL; menu_file_list_cbs_t *cbs = NULL; menu_handle_t *menu = menu_driver_resolve(); - driver_t *driver = driver_get_ptr(); + driver_t *driver = driver_get_ptr(); + global_t *global = global_get_ptr(); if (!menu) return 0; @@ -715,7 +718,7 @@ static int action_iterate_main(const char *label, unsigned action) !strcmp(label, "custom_bind_defaults") ) { - if (g_extern.menu.bind_mode_keyboard) + if (global->menu.bind_mode_keyboard) return action_iterate_custom_bind_keyboard(label, action); else return action_iterate_custom_bind(label, action); diff --git a/menu/menu_entries_cbs_ok.c b/menu/menu_entries_cbs_ok.c index ad977a4cd0..d1b71873a0 100644 --- a/menu/menu_entries_cbs_ok.c +++ b/menu/menu_entries_cbs_ok.c @@ -73,7 +73,8 @@ static int action_ok_playlist_entry(const char *path, static int action_ok_cheat_apply_changes(const char *path, const char *label, unsigned type, size_t idx) { - cheat_manager_t *cheat = g_extern.cheat; + global_t *global = global_get_ptr(); + cheat_manager_t *cheat = global->cheat; if (!cheat) return -1; @@ -389,7 +390,8 @@ static int action_ok_cheat_file_load(const char *path, { const char *menu_path = NULL; char cheat_path[PATH_MAX_LENGTH]; - menu_handle_t *menu = menu_driver_resolve(); + menu_handle_t *menu = menu_driver_resolve(); + global_t *global = global_get_ptr(); if (!menu) return -1; @@ -400,12 +402,12 @@ static int action_ok_cheat_file_load(const char *path, fill_pathname_join(cheat_path, menu_path, path, sizeof(cheat_path)); - if (g_extern.cheat) - cheat_manager_free(g_extern.cheat); + if (global->cheat) + cheat_manager_free(global->cheat); - g_extern.cheat = cheat_manager_load(cheat_path); + global->cheat = cheat_manager_load(cheat_path); - if (!g_extern.cheat) + if (!global->cheat) return -1; menu_list_flush_stack_by_needle(menu->menu_list, "core_cheat_options"); @@ -538,14 +540,15 @@ static int action_ok_core_load_deferred(const char *path, { menu_handle_t *menu = menu_driver_resolve(); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (!menu) return -1; if (path) strlcpy(settings->libretro, path, sizeof(settings->libretro)); - strlcpy(g_extern.fullpath, menu->deferred_path, - sizeof(g_extern.fullpath)); + strlcpy(global->fullpath, menu->deferred_path, + sizeof(global->fullpath)); menu_entries_common_load_content(false); @@ -588,6 +591,7 @@ static int action_ok_core_load(const char *path, const char *menu_path = NULL; menu_handle_t *menu = menu_driver_resolve(); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (!menu) return -1; @@ -603,7 +607,7 @@ static int action_ok_core_load(const char *path, /* No content needed for this core, load core immediately. */ if (menu->load_no_content) { - *g_extern.fullpath = '\0'; + *global->fullpath = '\0'; menu_entries_common_load_content(false); return -1; @@ -761,6 +765,7 @@ static int action_ok_file_load_with_detect_core(const char *path, const char *menu_path = NULL; menu_handle_t *menu = menu_driver_resolve(); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (!menu) return -1; @@ -768,7 +773,7 @@ static int action_ok_file_load_with_detect_core(const char *path, menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); - ret = rarch_defer_core(g_extern.core_info, + ret = rarch_defer_core(global->core_info, menu_path, path, label, menu->deferred_path, sizeof(menu->deferred_path)); @@ -795,7 +800,8 @@ static int action_ok_file_load(const char *path, const char *menu_label = NULL; const char *menu_path = NULL; rarch_setting_t *setting = NULL; - menu_handle_t *menu = menu_driver_resolve(); + menu_handle_t *menu = menu_driver_resolve(); + global_t *global = global_get_ptr(); if (!menu) return -1; @@ -813,11 +819,11 @@ static int action_ok_file_load(const char *path, else { if (type == MENU_FILE_IN_CARCHIVE) - fill_pathname_join_delim(g_extern.fullpath, menu_path, path, - '#',sizeof(g_extern.fullpath)); + fill_pathname_join_delim(global->fullpath, menu_path, path, + '#',sizeof(global->fullpath)); else - fill_pathname_join(g_extern.fullpath, menu_path, path, - sizeof(g_extern.fullpath)); + fill_pathname_join(global->fullpath, menu_path, path, + sizeof(global->fullpath)); menu_entries_common_load_content(true); @@ -856,7 +862,8 @@ static int action_ok_custom_viewport(const char *path, const char *label, unsigned type, size_t idx) { /* Start with something sane. */ - video_viewport_t *custom = &g_extern.console.screen.viewports.custom_vp; + global_t *global = global_get_ptr(); + video_viewport_t *custom = &global->console.screen.viewports.custom_vp; menu_handle_t *menu = menu_driver_resolve(); driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); @@ -971,17 +978,18 @@ static int action_ok_screenshot(const char *path, static int action_ok_file_load_or_resume(const char *path, const char *label, unsigned type, size_t idx) { - menu_handle_t *menu = menu_driver_resolve(); + menu_handle_t *menu = menu_driver_resolve(); + global_t *global = global_get_ptr(); if (!menu) return -1; - if (!strcmp(menu->deferred_path, g_extern.fullpath)) + if (!strcmp(menu->deferred_path, global->fullpath)) return generic_action_ok_command(RARCH_CMD_RESUME); else { - strlcpy(g_extern.fullpath, - menu->deferred_path, sizeof(g_extern.fullpath)); + strlcpy(global->fullpath, + menu->deferred_path, sizeof(global->fullpath)); rarch_main_command(RARCH_CMD_LOAD_CORE); rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT); return -1; @@ -1090,19 +1098,20 @@ static int action_ok_help(const char *path, static int action_ok_video_resolution(const char *path, const char *label, unsigned type, size_t idx) { + global_t *global = global_get_ptr(); #ifdef __CELLOS_LV2__ - if (g_extern.console.screen.resolutions.list[ - g_extern.console.screen.resolutions.current.idx] == + if (global->console.screen.resolutions.list[ + global->console.screen.resolutions.current.idx] == CELL_VIDEO_OUT_RESOLUTION_576) { - if (g_extern.console.screen.pal_enable) - g_extern.console.screen.pal60_enable = true; + if (global->console.screen.pal_enable) + global->console.screen.pal60_enable = true; } else { - g_extern.console.screen.pal_enable = false; - g_extern.console.screen.pal60_enable = false; + global->console.screen.pal_enable = false; + global->console.screen.pal60_enable = false; } rarch_main_command(RARCH_CMD_REINIT); diff --git a/menu/menu_entries_cbs_representation.c b/menu/menu_entries_cbs_representation.c index e38a534933..c038756ded 100644 --- a/menu/menu_entries_cbs_representation.c +++ b/menu/menu_entries_cbs_representation.c @@ -30,9 +30,11 @@ static void menu_action_setting_disp_set_label_cheat_num_passes( const char *path, char *path_buf, size_t path_buf_size) { + global_t *global = global_get_ptr(); + *w = 19; strlcpy(path_buf, path, path_buf_size); - snprintf(type_str, type_str_size, "%u", g_extern.cheat->buf_size); + snprintf(type_str, type_str_size, "%u", global->cheat->buf_size); } static void menu_action_setting_disp_set_label_remap_file_load( @@ -61,10 +63,12 @@ static void menu_action_setting_disp_set_label_configurations( const char *path, char *path_buf, size_t path_buf_size) { + global_t *global = global_get_ptr(); + *w = 19; strlcpy(path_buf, path, path_buf_size); - if (*g_extern.config_path) - fill_pathname_base(type_str, g_extern.config_path, + if (*global->config_path) + fill_pathname_base(type_str, global->config_path, type_str_size); else strlcpy(type_str, "", type_str_size); @@ -362,13 +366,14 @@ static void menu_action_setting_disp_set_label_cheat( const char *path, char *path_buf, size_t path_buf_size) { + global_t *global = global_get_ptr(); unsigned cheat_index = type - MENU_SETTINGS_CHEAT_BEGIN; - if (cheat_index < g_extern.cheat->buf_size) + if (cheat_index < global->cheat->buf_size) snprintf(type_str, type_str_size, "%s : (%s)", - (g_extern.cheat->cheats[cheat_index].code != NULL) - ? g_extern.cheat->cheats[cheat_index].code : "N/A", - g_extern.cheat->cheats[cheat_index].state ? "ON" : "OFF" + (global->cheat->cheats[cheat_index].code != NULL) + ? global->cheat->cheats[cheat_index].code : "N/A", + global->cheat->cheats[cheat_index].state ? "ON" : "OFF" ); *w = 19; strlcpy(path_buf, path, path_buf_size); @@ -470,10 +475,11 @@ static void menu_action_setting_disp_set_label_menu_disk_index( const char *path, char *path_buf, size_t path_buf_size) { + unsigned images = 0, current = 0; + global_t *global = global_get_ptr(); const struct retro_disk_control_callback *control = (const struct retro_disk_control_callback*) - &g_extern.system.disk_control; - unsigned images = 0, current = 0; + &global->system.disk_control; *w = 19; *type_str = '\0'; @@ -738,6 +744,8 @@ static void menu_action_setting_disp_set_label(file_list_t* list, const char *path, char *path_buf, size_t path_buf_size) { + global_t *global = global_get_ptr(); + *type_str = '\0'; *w = 19; @@ -750,7 +758,7 @@ static void menu_action_setting_disp_set_label(file_list_t* list, if (type >= MENU_SETTINGS_CORE_OPTION_START) strlcpy( type_str, - core_option_get_val(g_extern.system.core_options, + core_option_get_val(global->system.core_options, type - MENU_SETTINGS_CORE_OPTION_START), type_str_size); else diff --git a/menu/menu_entries_cbs_start.c b/menu/menu_entries_cbs_start.c index 5464be51f1..51ceb023ed 100644 --- a/menu/menu_entries_cbs_start.c +++ b/menu/menu_entries_cbs_start.c @@ -220,8 +220,9 @@ static int action_start_shader_num_passes(unsigned type, const char *label, static int action_start_cheat_num_passes(unsigned type, const char *label, unsigned action) { - cheat_manager_t *cheat = g_extern.cheat; - menu_handle_t *menu = menu_driver_resolve(); + global_t *global = global_get_ptr(); + cheat_manager_t *cheat = global->cheat; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return -1; @@ -258,11 +259,12 @@ static int action_start_performance_counters_frontend(unsigned type, const char static int action_start_core_setting(unsigned type, const char *label, unsigned action) { - unsigned idx = type - MENU_SETTINGS_CORE_OPTION_START; + global_t *global = global_get_ptr(); + unsigned idx = type - MENU_SETTINGS_CORE_OPTION_START; (void)label; - core_option_set_default(g_extern.system.core_options, idx); + core_option_set_default(global->system.core_options, idx); return 0; } diff --git a/menu/menu_entries_cbs_toggle.c b/menu/menu_entries_cbs_toggle.c index d182f8afbe..d935ab6d7d 100644 --- a/menu/menu_entries_cbs_toggle.c +++ b/menu/menu_entries_cbs_toggle.c @@ -93,8 +93,9 @@ static int shader_action_parameter_preset_toggle(unsigned type, const char *labe static int action_toggle_cheat(unsigned type, const char *label, unsigned action, bool wraparound) { - cheat_manager_t *cheat = g_extern.cheat; - size_t idx = type - MENU_SETTINGS_CHEAT_BEGIN; + global_t *global = global_get_ptr(); + cheat_manager_t *cheat = global->cheat; + size_t idx = type - MENU_SETTINGS_CHEAT_BEGIN; if (!cheat) return -1; @@ -342,8 +343,9 @@ static int action_toggle_cheat_num_passes(unsigned type, const char *label, unsigned action, bool wraparound) { unsigned new_size = 0; - cheat_manager_t *cheat = g_extern.cheat; - menu_handle_t *menu = menu_driver_resolve(); + global_t *global = global_get_ptr(); + cheat_manager_t *cheat = global->cheat; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return -1; @@ -409,27 +411,28 @@ static int action_toggle_video_resolution(unsigned type, const char *label, unsigned action, bool wraparound) { driver_t *driver = driver_get_ptr(); + global_t *global = global_get_ptr(); #if defined(__CELLOS_LV2__) switch (action) { case MENU_ACTION_LEFT: - if (g_extern.console.screen.resolutions.current.idx) + if (global->console.screen.resolutions.current.idx) { - g_extern.console.screen.resolutions.current.idx--; - g_extern.console.screen.resolutions.current.id = - g_extern.console.screen.resolutions.list - [g_extern.console.screen.resolutions.current.idx]; + global->console.screen.resolutions.current.idx--; + global->console.screen.resolutions.current.id = + global->onsole.screen.resolutions.list + [global->console.screen.resolutions.current.idx]; } break; case MENU_ACTION_RIGHT: - if (g_extern.console.screen.resolutions.current.idx + 1 < - g_extern.console.screen.resolutions.count) + if (global->console.screen.resolutions.current.idx + 1 < + global->console.screen.resolutions.count) { - g_extern.console.screen.resolutions.current.idx++; - g_extern.console.screen.resolutions.current.id = - g_extern.console.screen.resolutions.list - [g_extern.console.screen.resolutions.current.idx]; + global->console.screen.resolutions.current.idx++; + global->console.screen.resolutions.current.id = + global->console.screen.resolutions.list + [global->console.screen.resolutions.current.idx]; } break; } @@ -459,18 +462,19 @@ static int action_toggle_video_resolution(unsigned type, const char *label, static int core_setting_toggle(unsigned type, const char *label, unsigned action, bool wraparound) { - unsigned idx = type - MENU_SETTINGS_CORE_OPTION_START; + unsigned idx = type - MENU_SETTINGS_CORE_OPTION_START; + global_t *global = global_get_ptr(); (void)label; switch (action) { case MENU_ACTION_LEFT: - core_option_prev(g_extern.system.core_options, idx); + core_option_prev(global->system.core_options, idx); break; case MENU_ACTION_RIGHT: - core_option_next(g_extern.system.core_options, idx); + core_option_next(global->system.core_options, idx); break; } diff --git a/runloop.c b/runloop.c index e1a498363a..e3cd3e8abe 100644 --- a/runloop.c +++ b/runloop.c @@ -1016,7 +1016,7 @@ static void rarch_main_global_deinit(void) rarch_main_command(RARCH_CMD_LOG_FILE_DEINIT); #if 0 - global_t *global = &g_extern; + global_t *global = global_get_ptr(); if (!global) return; diff --git a/settings.c b/settings.c index a345b1d6e5..b1c4b1b85c 100644 --- a/settings.c +++ b/settings.c @@ -856,6 +856,7 @@ static int setting_action_ok_bind_all(void *data, unsigned action) rarch_setting_t *setting = (rarch_setting_t*)data; menu_handle_t *menu = menu_driver_resolve(); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (!setting || !menu) return -1; @@ -869,12 +870,12 @@ static int setting_action_ok_bind_all(void *data, unsigned action) menu->menu_list, "", "custom_bind_all", - g_extern.menu.bind_mode_keyboard ? + global->menu.bind_mode_keyboard ? MENU_SETTINGS_CUSTOM_BIND_KEYBOARD : MENU_SETTINGS_CUSTOM_BIND, menu->navigation.selection_ptr); - if (g_extern.menu.bind_mode_keyboard) + if (global->menu.bind_mode_keyboard) { menu->binds.timeout_end = rarch_get_time_usec() + @@ -898,7 +899,8 @@ static int setting_action_ok_bind_defaults(void *data, unsigned action) const struct retro_keybind *def_binds = NULL; rarch_setting_t *setting = (rarch_setting_t*)data; menu_handle_t *menu = menu_driver_resolve(); - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (!menu) return -1; @@ -919,7 +921,7 @@ static int setting_action_ok_bind_defaults(void *data, unsigned action) for (i = MENU_SETTINGS_BIND_BEGIN; i <= MENU_SETTINGS_BIND_LAST; i++, target++) { - if (g_extern.menu.bind_mode_keyboard) + if (global->menu.bind_mode_keyboard) target->key = def_binds[i - MENU_SETTINGS_BIND_BEGIN].key; else { @@ -1060,8 +1062,9 @@ static int setting_action_action_ok(void *data, unsigned action) static int setting_bind_action_ok(void *data, unsigned action) { struct retro_keybind *keybind = NULL; - rarch_setting_t *setting = (rarch_setting_t*)data; - menu_handle_t *menu = menu_driver_resolve(); + rarch_setting_t *setting = (rarch_setting_t*)data; + menu_handle_t *menu = menu_driver_resolve(); + global_t *global = global_get_ptr(); if (!setting) return -1; @@ -1082,11 +1085,11 @@ static int setting_bind_action_ok(void *data, unsigned action) menu->menu_list, "", "custom_bind", - g_extern.menu.bind_mode_keyboard ? + global->menu.bind_mode_keyboard ? MENU_SETTINGS_CUSTOM_BIND_KEYBOARD : MENU_SETTINGS_CUSTOM_BIND, menu->navigation.selection_ptr); - if (g_extern.menu.bind_mode_keyboard) + if (global->menu.bind_mode_keyboard) { menu->binds.timeout_end = rarch_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; @@ -1303,13 +1306,14 @@ static void setting_get_string_representation_uint_libretro_device(void *data, const char *name = NULL; rarch_setting_t *setting = (rarch_setting_t*)data; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (!setting) return; - if (setting->index_offset < g_extern.system.num_ports) + if (setting->index_offset < global->system.num_ports) desc = libretro_find_controller_description( - &g_extern.system.ports[setting->index_offset], + &global->system.ports[setting->index_offset], settings->input.libretro_device [setting->index_offset]); @@ -2994,6 +2998,7 @@ static void general_write_handler(void *data) rarch_setting_t *setting = (rarch_setting_t*)data; settings_t *settings = config_get_ptr(); driver_t *driver = driver_get_ptr(); + global_t *global = global_get_ptr(); if (!setting) return; @@ -3039,7 +3044,7 @@ static void general_write_handler(void *data) } else if (!strcmp(setting->name, "pal60_enable")) { - if (*setting->value.boolean && g_extern.console.screen.pal_enable) + if (*setting->value.boolean && global->console.screen.pal_enable) rarch_cmd = RARCH_CMD_REINIT; else *setting->value.boolean = false; @@ -3049,7 +3054,7 @@ static void general_write_handler(void *data) if (driver->video && driver->video->set_rotation) driver->video->set_rotation(driver->video_data, (*setting->value.unsigned_integer + - g_extern.system.rotation) % 4); + global->system.rotation) % 4); } else if (!strcmp(setting->name, "system_bgm_enable")) { @@ -3067,7 +3072,7 @@ static void general_write_handler(void *data) } } else if (!strcmp(setting->name, "audio_volume")) - g_extern.audio_data.volume_gain = db_to_gain(*setting->value.fraction); + global->audio_data.volume_gain = db_to_gain(*setting->value.fraction); else if (!strcmp(setting->name, "audio_latency")) rarch_cmd = RARCH_CMD_AUDIO_REINIT; else if (!strcmp(setting->name, "audio_rate_control_delta")) @@ -3114,25 +3119,25 @@ static void general_write_handler(void *data) settings->input.joypad_map[4] = *setting->value.integer; #ifdef HAVE_NETPLAY else if (!strcmp(setting->name, "netplay_ip_address")) - g_extern.has_set_netplay_ip_address = (setting->value.string[0] != '\0'); + global->has_set_netplay_ip_address = (setting->value.string[0] != '\0'); else if (!strcmp(setting->name, "netplay_mode")) { - if (!g_extern.netplay_is_client) - *g_extern.netplay_server = '\0'; - g_extern.has_set_netplay_mode = true; + if (!global->netplay_is_client) + *global->netplay_server = '\0'; + global->has_set_netplay_mode = true; } else if (!strcmp(setting->name, "netplay_spectator_mode_enable")) { - if (g_extern.netplay_is_spectate) - *g_extern.netplay_server = '\0'; + if (global->netplay_is_spectate) + *global->netplay_server = '\0'; } else if (!strcmp(setting->name, "netplay_delay_frames")) - g_extern.has_set_netplay_delay_frames = (g_extern.netplay_sync_frames > 0); + global->has_set_netplay_delay_frames = (global->netplay_sync_frames > 0); #endif else if (!strcmp(setting->name, "log_verbosity")) { - g_extern.verbosity = *setting->value.boolean; - g_extern.has_set_verbosity = *setting->value.boolean; + global->verbosity = *setting->value.boolean; + global->has_set_verbosity = *setting->value.boolean; } if (rarch_cmd || setting->cmd_trigger.triggered) @@ -3311,6 +3316,7 @@ static bool setting_append_list_main_menu_options( rarch_setting_group_info_t subgroup_info; driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); START_GROUP(group_info, "Main Menu"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); @@ -3350,8 +3356,8 @@ static bool setting_append_list_main_menu_options( } if ( driver->menu - && g_extern.core_info - && core_info_list_num_info_files(g_extern.core_info)) + && global->core_info + && core_info_list_num_info_files(global->core_info)) { CONFIG_ACTION( "detect_core_list", @@ -3365,8 +3371,8 @@ static bool setting_append_list_main_menu_options( "Load Content", group_info.name, subgroup_info.name); - (*list)[list_info->index - 1].size = sizeof(g_extern.fullpath); - (*list)[list_info->index - 1].value.string = g_extern.fullpath; + (*list)[list_info->index - 1].size = sizeof(global->fullpath); + (*list)[list_info->index - 1].value.string = global->fullpath; (*list)[list_info->index - 1].action_toggle = load_content_action_toggle; (*list)[list_info->index - 1].change_handler = load_content_change_handler; settings_data_list_current_add_flags(list, list_info, SD_FLAG_BROWSER_ACTION); @@ -3396,7 +3402,7 @@ static bool setting_append_list_main_menu_options( group_info.name, subgroup_info.name); - if (g_extern.perfcnt_enable) + if (global->perfcnt_enable) { CONFIG_ACTION( "performance_counters", @@ -3405,7 +3411,7 @@ static bool setting_append_list_main_menu_options( subgroup_info.name); settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); } - if (g_extern.main_is_init && !g_extern.libretro_dummy) + if (global->main_is_init && !global->libretro_dummy) { CONFIG_ACTION( "savestate", @@ -3619,6 +3625,7 @@ static bool setting_append_list_general_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); START_GROUP(group_info, "General Settings"); @@ -3655,7 +3662,7 @@ static bool setting_append_list_general_options( START_SUB_GROUP(list, list_info, "Logging", group_info.name, subgroup_info); CONFIG_BOOL( - g_extern.verbosity, + global->verbosity, "log_verbosity", "Logging Verbosity", false, @@ -3683,7 +3690,7 @@ static bool setting_append_list_general_options( START_SUB_GROUP(list, list_info, "Performance Counters", group_info.name, subgroup_info); - CONFIG_BOOL(g_extern.perfcnt_enable, + CONFIG_BOOL(global->perfcnt_enable, "perfcnt_enable", "Performance Counters", false, @@ -3870,6 +3877,7 @@ static bool setting_append_list_video_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); START_GROUP(group_info, "Video Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); @@ -4102,7 +4110,7 @@ static bool setting_append_list_video_options( general_read_handler); CONFIG_INT( - g_extern.console.screen.viewports.custom_vp.x, + global->console.screen.viewports.custom_vp.x, "custom_viewport_x", "Custom Viewport X", 0, @@ -4113,7 +4121,7 @@ static bool setting_append_list_video_options( settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); CONFIG_INT( - g_extern.console.screen.viewports.custom_vp.y, + global->console.screen.viewports.custom_vp.y, "custom_viewport_y", "Custom Viewport Y", 0, @@ -4124,7 +4132,7 @@ static bool setting_append_list_video_options( settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); CONFIG_UINT( - g_extern.console.screen.viewports.custom_vp.width, + global->console.screen.viewports.custom_vp.width, "custom_viewport_width", "Custom Viewport Width", 0, @@ -4135,7 +4143,7 @@ static bool setting_append_list_video_options( settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); CONFIG_UINT( - g_extern.console.screen.viewports.custom_vp.height, + global->console.screen.viewports.custom_vp.height, "custom_viewport_height", "Custom Viewport Height", 0, @@ -4184,7 +4192,7 @@ static bool setting_append_list_video_options( #if defined(__CELLOS_LV2__) CONFIG_BOOL( - g_extern.console.screen.pal60_enable, + global->console.screen.pal60_enable, "pal60_enable", "Use PAL60 Mode", false, @@ -4212,7 +4220,7 @@ static bool setting_append_list_video_options( #if defined(HW_RVL) || defined(_XBOX360) CONFIG_UINT( - g_extern.console.screen.gamma_correction, + global->console.screen.gamma_correction, "video_gamma", "Gamma", 0, @@ -4409,7 +4417,7 @@ static bool setting_append_list_video_options( #if defined(_XBOX1) || defined(HW_RVL) CONFIG_BOOL( - g_extern.console.softfilter_enable, + global->console.softfilter_enable, "soft_filter", "Soft Filter Enable", false, @@ -4570,7 +4578,7 @@ static bool setting_append_list_audio_options( #ifdef __CELLOS_LV2__ CONFIG_BOOL( - g_extern.console.sound.system_bgm_enable, + global->console.sound.system_bgm_enable, "system_bgm_enable", "System BGM Enable", false, @@ -4726,6 +4734,7 @@ static bool setting_append_list_input_options( rarch_setting_group_info_t subgroup_info; unsigned i, user; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); START_GROUP(group_info, "Input Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); @@ -4811,7 +4820,7 @@ static bool setting_append_list_input_options( subgroup_info); CONFIG_BOOL( - g_extern.menu.bind_mode_keyboard, + global->menu.bind_mode_keyboard, "input_bind_mode", "Bind Mode", false, @@ -5027,13 +5036,13 @@ static bool setting_append_list_input_options( if ( settings->input.input_descriptor_label_show && (i < RARCH_FIRST_META_KEY) - && (g_extern.has_set_input_descriptors) + && (global->has_set_input_descriptors) && (i != RARCH_TURBO_ENABLE) ) { - if (g_extern.system.input_desc_btn[user][i]) + if (global->system.input_desc_btn[user][i]) snprintf(label, sizeof(label), "%s %s", buffer[user], - g_extern.system.input_desc_btn[user][i]); + global->system.input_desc_btn[user][i]); else { snprintf(label, sizeof(label), "%s %s", buffer[user], "N/A"); @@ -5077,6 +5086,7 @@ static bool setting_append_list_overlay_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); START_GROUP(group_info, "Overlay Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); @@ -5098,7 +5108,7 @@ static bool setting_append_list_overlay_options( settings->input.overlay, "input_overlay", "Overlay Preset", - g_extern.overlay_dir, + global->overlay_dir, group_info.name, subgroup_info.name, general_write_handler, @@ -5150,6 +5160,7 @@ static bool setting_append_list_osk_overlay_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); START_GROUP(group_info, "Onscreen Keyboard Overlay Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); @@ -5170,7 +5181,7 @@ static bool setting_append_list_osk_overlay_options( settings->osk.overlay, "input_osk_overlay", "OSK Overlay Preset", - g_extern.osk_overlay_dir, + global->osk_overlay_dir, group_info.name, subgroup_info.name, general_write_handler, @@ -5561,13 +5572,14 @@ static bool setting_append_list_netplay_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); START_GROUP(group_info, "Network Settings"); START_SUB_GROUP(list, list_info, "Netplay", group_info.name, subgroup_info); CONFIG_BOOL( - g_extern.netplay_enable, + global->netplay_enable, "netplay_enable", "Netplay Enable", false, @@ -5591,7 +5603,7 @@ static bool setting_append_list_netplay_options( general_read_handler); CONFIG_STRING( - g_extern.netplay_server, + global->netplay_server, "netplay_ip_address", "IP Address", "", @@ -5602,7 +5614,7 @@ static bool setting_append_list_netplay_options( settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); CONFIG_BOOL( - g_extern.netplay_is_client, + global->netplay_is_client, "netplay_mode", "Netplay Client Enable", false, @@ -5614,7 +5626,7 @@ static bool setting_append_list_netplay_options( general_read_handler); CONFIG_BOOL( - g_extern.netplay_is_spectate, + global->netplay_is_spectate, "netplay_spectator_mode_enable", "Netplay Spectator Enable", false, @@ -5626,7 +5638,7 @@ static bool setting_append_list_netplay_options( general_read_handler); CONFIG_UINT( - g_extern.netplay_sync_frames, + global->netplay_sync_frames, "netplay_delay_frames", "Netplay Delay Frames", 0, @@ -5638,7 +5650,7 @@ static bool setting_append_list_netplay_options( settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); CONFIG_UINT( - g_extern.netplay_port, + global->netplay_port, "netplay_tcp_udp_port", "Netplay TCP/UDP Port", RARCH_DEFAULT_PORT, @@ -5715,7 +5727,7 @@ static bool setting_append_list_patch_options( START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( - g_extern.ups_pref, + global->ups_pref, "ups_pref", "UPS Patching Enable", true, @@ -5727,7 +5739,7 @@ static bool setting_append_list_patch_options( general_read_handler); CONFIG_BOOL( - g_extern.bps_pref, + global->bps_pref, "bps_pref", "BPS Patching Enable", true, @@ -5739,7 +5751,7 @@ static bool setting_append_list_patch_options( general_read_handler); CONFIG_BOOL( - g_extern.ips_pref, + global->ips_pref, "ips_pref", "IPS Patching Enable", true, @@ -5853,6 +5865,7 @@ static bool setting_append_list_path_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); START_GROUP(group_info, "Path Settings"); @@ -6057,7 +6070,7 @@ static bool setting_append_list_path_options( #ifdef HAVE_OVERLAY CONFIG_DIR( - g_extern.overlay_dir, + global->overlay_dir, "overlay_directory", "Overlay Directory", g_defaults.overlay_dir, @@ -6072,7 +6085,7 @@ static bool setting_append_list_path_options( SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR | SD_FLAG_BROWSER_ACTION); CONFIG_DIR( - g_extern.osk_overlay_dir, + global->osk_overlay_dir, "osk_overlay_directory", "OSK Overlay Directory", g_defaults.osk_overlay_dir, @@ -6148,7 +6161,7 @@ static bool setting_append_list_path_options( SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR | SD_FLAG_BROWSER_ACTION); CONFIG_DIR( - g_extern.savefile_dir, + global->savefile_dir, "savefile_directory", "Savefile Directory", "", @@ -6163,7 +6176,7 @@ static bool setting_append_list_path_options( SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR | SD_FLAG_BROWSER_ACTION); CONFIG_DIR( - g_extern.savestate_dir, + global->savestate_dir, "savestate_directory", "Savestate Directory", "",