(Runloop) Turn some boolean variables into flags

This commit is contained in:
LibretroAdmin 2022-10-10 04:37:17 +02:00
parent 2218ea1d96
commit 076a1a398c
10 changed files with 229 additions and 192 deletions

View File

@ -1529,13 +1529,13 @@ bool command_event_save_core_config(
sizeof(config_path));
}
if (runloop_st->overrides_active)
if (runloop_st->flags & RUNLOOP_FLAG_OVERRIDES_ACTIVE)
{
/* Overrides block config file saving,
* make it appear as overrides weren't enabled
* for a manual save. */
runloop_st->overrides_active = false;
overrides_active = true;
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
overrides_active = true;
}
#ifdef HAVE_CONFIGFILE
@ -1546,7 +1546,10 @@ bool command_event_save_core_config(
runloop_msg_queue_push(msg, 1, 180, true, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
runloop_st->overrides_active = overrides_active;
if (overrides_active)
runloop_st->flags |= RUNLOOP_FLAG_OVERRIDES_ACTIVE;
else
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
return true;
}
@ -1584,7 +1587,7 @@ void command_event_save_current_config(enum override_type type)
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_SAVED_SUCCESSFULLY), sizeof(msg));
/* set overrides to active so the original config can be
restored after closing content */
runloop_st->overrides_active = true;
runloop_st->flags |= RUNLOOP_FLAG_OVERRIDES_ACTIVE;
}
else
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_ERROR_SAVING), sizeof(msg));
@ -1720,7 +1723,7 @@ bool command_event_disk_control_append_image(
return false;
#ifdef HAVE_THREADS
if (runloop_st->use_sram)
if (runloop_st->flags & RUNLOOP_FLAG_USE_SRAM)
autosave_deinit();
#endif

View File

@ -94,8 +94,6 @@ struct retro_core_t
bool has_set_input_descriptors;
};
bool libretro_get_shared_context(void);
RETRO_END_DECLS
#endif

View File

@ -55,6 +55,7 @@
#include "../../dynamic.h"
#include "../../retroarch.h"
#include "../../runloop.h"
#include "../../record/record_driver.h"
#include "../../verbosity.h"
#include "../common/gl2_common.h"
@ -3470,7 +3471,7 @@ static const gfx_ctx_driver_t *gl2_get_context(gl2_t *gl)
gl->shared_context_use = video_shared_context
&& hwr->context_type != RETRO_HW_CONTEXT_NONE;
if ( (libretro_get_shared_context())
if ( (runloop_get_flags() & RUNLOOP_FLAG_CORE_SET_SHARED_CONTEXT)
&& (hwr->context_type != RETRO_HW_CONTEXT_NONE))
gl->shared_context_use = true;

View File

@ -41,6 +41,7 @@
#include "../../driver.h"
#include "../../retroarch.h"
#include "../../runloop.h"
#include "../../verbosity.h"
#ifndef HAVE_THREADS
@ -90,7 +91,7 @@ static const gfx_ctx_driver_t* rsx_get_context(rsx_t* rsx)
rsx->shared_context_use = video_shared_context && hwr->context_type != RETRO_HW_CONTEXT_NONE;
if ((libretro_get_shared_context())
if ((runloop_get_flags() & RUNLOOP_FLAG_CORE_SET_SHARED_CONTEXT)
&& (hwr->context_type != RETRO_HW_CONTEXT_NONE))
rsx->shared_context_use = true;

View File

@ -2874,7 +2874,7 @@ static const gfx_ctx_driver_t *vk_context_driver_init_first(
if (i >= 0)
{
const gfx_ctx_driver_t *ctx = video_context_driver_init(
runloop_st->core_set_shared_context,
runloop_st->flags & RUNLOOP_FLAG_CORE_SET_SHARED_CONTEXT,
settings,
data,
gfx_ctx_vk_drivers[i], ident,
@ -2890,7 +2890,7 @@ static const gfx_ctx_driver_t *vk_context_driver_init_first(
{
const gfx_ctx_driver_t *ctx =
video_context_driver_init(
runloop_st->core_set_shared_context,
runloop_st->flags & RUNLOOP_FLAG_CORE_SET_SHARED_CONTEXT,
settings,
data,
gfx_ctx_vk_drivers[i], ident,
@ -2930,7 +2930,7 @@ static const gfx_ctx_driver_t *gl_context_driver_init_first(
if (i >= 0)
{
const gfx_ctx_driver_t *ctx = video_context_driver_init(
runloop_st->core_set_shared_context,
runloop_st->flags & RUNLOOP_FLAG_CORE_SET_SHARED_CONTEXT,
settings,
data,
gfx_ctx_gl_drivers[i], ident,
@ -2946,7 +2946,7 @@ static const gfx_ctx_driver_t *gl_context_driver_init_first(
{
const gfx_ctx_driver_t *ctx =
video_context_driver_init(
runloop_st->core_set_shared_context,
runloop_st->flags & RUNLOOP_FLAG_CORE_SET_SHARED_CONTEXT,
settings,
data,
gfx_ctx_gl_drivers[i], ident,

View File

@ -5295,7 +5295,7 @@ void input_remapping_update_port_map(void)
void input_remapping_deinit(bool save_remap)
{
runloop_state_t *runloop_st = runloop_state_get_ptr();
runloop_state_t *runloop_st = runloop_state_get_ptr();
if (runloop_st->name.remapfile)
{
if (save_remap)
@ -5303,10 +5303,10 @@ void input_remapping_deinit(bool save_remap)
free(runloop_st->name.remapfile);
}
runloop_st->name.remapfile = NULL;
runloop_st->remaps_core_active = false;
runloop_st->remaps_content_dir_active = false;
runloop_st->remaps_game_active = false;
runloop_st->name.remapfile = NULL;
runloop_st->flags &= ~(RUNLOOP_FLAG_REMAPS_CORE_ACTIVE
| RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE
| RUNLOOP_FLAG_REMAPS_GAME_ACTIVE);
}
void input_remapping_set_defaults(bool clear_cache)

View File

@ -1493,7 +1493,7 @@ bool command_event(enum event_command cmd, void *data)
switch (cmd)
{
case CMD_EVENT_SAVE_FILES:
event_save_files(runloop_st->use_sram);
event_save_files(runloop_st->flags & RUNLOOP_FLAG_USE_SRAM);
break;
case CMD_EVENT_OVERLAY_DEINIT:
#ifdef HAVE_OVERLAY
@ -1904,9 +1904,9 @@ bool command_event(enum event_command cmd, void *data)
settings->bools.savestate_auto_save,
runloop_st->current_core_type);
if ( runloop_st->remaps_core_active
|| runloop_st->remaps_content_dir_active
|| runloop_st->remaps_game_active
if ( (runloop_st->flags & RUNLOOP_FLAG_REMAPS_CORE_ACTIVE)
|| (runloop_st->flags & RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE)
|| (runloop_st->flags & RUNLOOP_FLAG_REMAPS_GAME_ACTIVE)
|| !string_is_empty(runloop_st->name.remapfile)
)
{
@ -1917,11 +1917,11 @@ bool command_event(enum event_command cmd, void *data)
input_remapping_restore_global_config(true);
#ifdef HAVE_CONFIGFILE
if (runloop_st->overrides_active)
if (runloop_st->flags & RUNLOOP_FLAG_OVERRIDES_ACTIVE)
{
/* Reload the original config */
config_unload_override();
runloop_st->overrides_active = false;
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
if (!settings->bools.video_fullscreen)
{
@ -2070,7 +2070,7 @@ bool command_event(enum event_command cmd, void *data)
break;
case CMD_EVENT_AUTOSAVE_INIT:
#ifdef HAVE_THREADS
if (runloop_st->use_sram)
if (runloop_st->flags & RUNLOOP_FLAG_USE_SRAM)
autosave_deinit();
{
#ifdef HAVE_NETWORKING
@ -3613,20 +3613,26 @@ static void global_free(struct rarch_state *p_rarch)
retro_main_log_file_deinit();
runloop_st->is_sram_load_disabled = false;
runloop_st->is_sram_save_disabled = false;
runloop_st->use_sram = false;
runloop_st->flags &= ~(
RUNLOOP_FLAG_IS_SRAM_LOAD_DISABLED
| RUNLOOP_FLAG_IS_SRAM_SAVE_DISABLED
| RUNLOOP_FLAG_USE_SRAM
);
#ifdef HAVE_PATCH
p_rarch->flags &= ~( RARCH_FLAGS_BPS_PREF | RARCH_FLAGS_IPS_PREF
| RARCH_FLAGS_UPS_PREF);
runloop_st->patch_blocked = false;
p_rarch->flags &= ~(
RARCH_FLAGS_BPS_PREF
| RARCH_FLAGS_IPS_PREF
| RARCH_FLAGS_UPS_PREF);
runloop_st->flags &= ~RUNLOOP_FLAG_PATCH_BLOCKED;
#endif
#ifdef HAVE_CONFIGFILE
p_rarch->flags &= ~RARCH_FLAGS_BLOCK_CONFIG_READ;
runloop_st->overrides_active = false;
runloop_st->remaps_core_active = false;
runloop_st->remaps_game_active = false;
runloop_st->remaps_content_dir_active = false;
p_rarch->flags &= ~RARCH_FLAGS_BLOCK_CONFIG_READ;
runloop_st->flags &= ~(RUNLOOP_FLAG_OVERRIDES_ACTIVE
| RUNLOOP_FLAG_REMAPS_CORE_ACTIVE
| RUNLOOP_FLAG_REMAPS_GAME_ACTIVE
| RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE
);
#endif
runloop_st->current_core.has_set_input_descriptors = false;
@ -4611,34 +4617,34 @@ static bool retroarch_parse_input_and_config(
* bogus arguments.
*/
if (!runloop_st->has_set_core)
if (!(runloop_st->flags & RUNLOOP_FLAG_HAS_SET_CORE))
runloop_set_current_core_type(CORE_TYPE_DUMMY, false);
path_clear(RARCH_PATH_SUBSYSTEM);
retroarch_override_setting_free_state();
p_rarch->flags &= ~RARCH_FLAGS_HAS_SET_USERNAME;
p_rarch->flags &= ~RARCH_FLAGS_HAS_SET_USERNAME;
#ifdef HAVE_PATCH
p_rarch->flags &= ~( RARCH_FLAGS_UPS_PREF | RARCH_FLAGS_IPS_PREF
| RARCH_FLAGS_BPS_PREF);
*runloop_st->name.ups = '\0';
*runloop_st->name.bps = '\0';
*runloop_st->name.ips = '\0';
p_rarch->flags &= ~( RARCH_FLAGS_UPS_PREF | RARCH_FLAGS_IPS_PREF
| RARCH_FLAGS_BPS_PREF);
*runloop_st->name.ups = '\0';
*runloop_st->name.bps = '\0';
*runloop_st->name.ips = '\0';
#endif
#ifdef HAVE_CONFIGFILE
runloop_st->overrides_active = false;
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
#endif
global->cli_load_menu_on_error = false;
global->cli_load_menu_on_error = false;
/* Make sure we can call retroarch_parse_input several times ... */
optind = 0;
optstring = "hs:fvS:A:U:DN:d:e:"
optind = 0;
optstring = "hs:fvS:A:U:DN:d:e:"
BSV_MOVIE_ARG NETPLAY_ARG DYNAMIC_ARG FFMPEG_RECORD_ARG CONFIG_FILE_ARG;
#if defined(WEBOS)
argv = &(argv[1]);
argc = argc - 1;
argv = &(argv[1]);
argc = argc - 1;
#endif
#ifndef HAVE_MENU
@ -4902,14 +4908,12 @@ static bool retroarch_parse_input_and_config(
case 'M':
if (string_is_equal(optarg, "noload-nosave"))
{
runloop_st->is_sram_load_disabled = true;
runloop_st->is_sram_save_disabled = true;
}
runloop_st->flags |= RUNLOOP_FLAG_IS_SRAM_LOAD_DISABLED
| RUNLOOP_FLAG_IS_SRAM_SAVE_DISABLED;
else if (string_is_equal(optarg, "noload-save"))
runloop_st->is_sram_load_disabled = true;
runloop_st->flags |= RUNLOOP_FLAG_IS_SRAM_LOAD_DISABLED;
else if (string_is_equal(optarg, "load-nosave"))
runloop_st->is_sram_save_disabled = true;
runloop_st->flags |= RUNLOOP_FLAG_IS_SRAM_SAVE_DISABLED;
else if (string_is_not_equal(optarg, "load-save"))
{
RARCH_ERR("Invalid argument in --sram-mode.\n");
@ -4991,7 +4995,7 @@ static bool retroarch_parse_input_and_config(
case RA_OPT_NO_PATCH:
#ifdef HAVE_PATCH
runloop_st->patch_blocked = true;
runloop_st->flags |= RUNLOOP_FLAG_PATCH_BLOCKED;
#endif
break;
@ -5032,7 +5036,7 @@ static bool retroarch_parse_input_and_config(
case RA_OPT_MAX_FRAMES_SCREENSHOT:
#ifdef HAVE_SCREENSHOTS
runloop_st->max_frames_screenshot = true;
runloop_st->flags |= RUNLOOP_FLAG_MAX_FRAMES_SCREENSHOT;
#endif
break;
@ -5411,9 +5415,9 @@ bool retroarch_main_init(int argc, char *argv[])
frontend_driver_set_screen_brightness(settings->uints.screen_brightness);
/* Attempt to initialize core */
if (runloop_st->has_set_core)
if (runloop_st->flags & RUNLOOP_FLAG_HAS_SET_CORE)
{
runloop_st->has_set_core = false;
runloop_st->flags &= ~RUNLOOP_FLAG_HAS_SET_CORE;
if (!command_event(CMD_EVENT_CORE_INIT,
&runloop_st->explicit_current_core_type))
init_failed = true;
@ -5439,9 +5443,9 @@ bool retroarch_main_init(int argc, char *argv[])
* that we:
* - Unload any active input remaps
* - Disable any active config overrides */
if ( runloop_st->remaps_core_active
|| runloop_st->remaps_content_dir_active
|| runloop_st->remaps_game_active
if ( (runloop_st->flags & RUNLOOP_FLAG_REMAPS_CORE_ACTIVE)
|| (runloop_st->flags & RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE)
|| (runloop_st->flags & RUNLOOP_FLAG_REMAPS_GAME_ACTIVE)
|| !string_is_empty(runloop_st->name.remapfile)
)
{
@ -5452,11 +5456,11 @@ bool retroarch_main_init(int argc, char *argv[])
input_remapping_restore_global_config(true);
#ifdef HAVE_CONFIGFILE
if (runloop_st->overrides_active)
if (runloop_st->flags & RUNLOOP_FLAG_OVERRIDES_ACTIVE)
{
/* Reload the original config */
config_unload_override();
runloop_st->overrides_active = false;
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
}
#endif
@ -5656,7 +5660,7 @@ bool retroarch_ctl(enum rarch_ctl_state state, void *data)
input_mapper_reset(&input_st->mapper);
#ifdef HAVE_THREADS
if (runloop_st->use_sram)
if (runloop_st->flags & RUNLOOP_FLAG_USE_SRAM)
autosave_deinit();
#endif
@ -5735,31 +5739,31 @@ bool retroarch_ctl(enum rarch_ctl_state state, void *data)
}
return false;
#ifdef HAVE_CONFIGFILE
case RARCH_CTL_IS_OVERRIDES_ACTIVE:
return runloop_st->overrides_active;
case RARCH_CTL_SET_REMAPS_CORE_ACTIVE:
/* Only one type of remap can be active
* at any one time */
runloop_st->remaps_core_active = true;
runloop_st->remaps_content_dir_active = false;
runloop_st->remaps_game_active = false;
runloop_st->flags &= ~(RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE
| RUNLOOP_FLAG_REMAPS_GAME_ACTIVE);
runloop_st->flags |= RUNLOOP_FLAG_REMAPS_CORE_ACTIVE;
break;
case RARCH_CTL_IS_REMAPS_CORE_ACTIVE:
return runloop_st->remaps_core_active;
case RARCH_CTL_SET_REMAPS_GAME_ACTIVE:
runloop_st->remaps_core_active = false;
runloop_st->remaps_content_dir_active = false;
runloop_st->remaps_game_active = true;
runloop_st->flags &= ~(RUNLOOP_FLAG_REMAPS_CORE_ACTIVE
| RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE);
runloop_st->flags |= RUNLOOP_FLAG_REMAPS_GAME_ACTIVE;
break;
case RARCH_CTL_IS_REMAPS_GAME_ACTIVE:
return runloop_st->remaps_game_active;
case RARCH_CTL_SET_REMAPS_CONTENT_DIR_ACTIVE:
runloop_st->remaps_core_active = false;
runloop_st->remaps_content_dir_active = true;
runloop_st->remaps_game_active = false;
runloop_st->flags &= ~(RUNLOOP_FLAG_REMAPS_CORE_ACTIVE
| RUNLOOP_FLAG_REMAPS_GAME_ACTIVE);
runloop_st->flags |= RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE;
break;
case RARCH_CTL_IS_OVERRIDES_ACTIVE:
return ((runloop_st->flags & RUNLOOP_FLAG_OVERRIDES_ACTIVE) > 0);
case RARCH_CTL_IS_REMAPS_CORE_ACTIVE:
return ((runloop_st->flags & RUNLOOP_FLAG_REMAPS_CORE_ACTIVE) > 0);
case RARCH_CTL_IS_REMAPS_GAME_ACTIVE:
return ((runloop_st->flags & RUNLOOP_FLAG_REMAPS_GAME_ACTIVE) > 0);
case RARCH_CTL_IS_REMAPS_CONTENT_DIR_ACTIVE:
return runloop_st->remaps_content_dir_active;
return ((runloop_st->flags & RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE) > 0);
#endif
case RARCH_CTL_SET_MISSING_BIOS:
runloop_st->missing_bios = true;
@ -5770,9 +5774,9 @@ bool retroarch_ctl(enum rarch_ctl_state state, void *data)
case RARCH_CTL_IS_MISSING_BIOS:
return runloop_st->missing_bios;
case RARCH_CTL_IS_GAME_OPTIONS_ACTIVE:
return runloop_st->game_options_active;
return ((runloop_st->flags & RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE) > 0);
case RARCH_CTL_IS_FOLDER_OPTIONS_ACTIVE:
return runloop_st->folder_options_active;
return ((runloop_st->flags & RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE) > 0);
case RARCH_CTL_GET_PERFCNT:
{
bool **perfcnt = (bool**)data;
@ -5805,7 +5809,7 @@ bool retroarch_ctl(enum rarch_ctl_state state, void *data)
runloop_st->paused = false;
runloop_st->slowmotion = false;
#ifdef HAVE_CONFIGFILE
runloop_st->overrides_active = false;
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
#endif
runloop_st->autosave = false;
runloop_frame_time_free();
@ -6213,9 +6217,9 @@ bool retroarch_main_quit(void)
* save state file may be truncated) */
content_wait_for_save_state_task();
if ( runloop_st->remaps_core_active
|| runloop_st->remaps_content_dir_active
|| runloop_st->remaps_game_active
if ( (runloop_st->flags & RUNLOOP_FLAG_REMAPS_CORE_ACTIVE)
|| (runloop_st->flags & RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE)
|| (runloop_st->flags & RUNLOOP_FLAG_REMAPS_GAME_ACTIVE)
|| !string_is_empty(runloop_st->name.remapfile)
)
{
@ -6226,11 +6230,11 @@ bool retroarch_main_quit(void)
input_remapping_restore_global_config(true);
#ifdef HAVE_CONFIGFILE
if (runloop_st->overrides_active)
if (runloop_st->flags & RUNLOOP_FLAG_OVERRIDES_ACTIVE)
{
/* Reload the original config */
config_unload_override();
runloop_st->overrides_active = false;
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
}
#endif
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)

178
runloop.c
View File

@ -539,9 +539,9 @@ void libretro_get_environment_info(
* Make sure we reset it to the actual environment callback.
* Ignore any environment callbacks here in case we're running
* on the non-current core. */
runloop_st->ignore_environment_cb = true;
runloop_st->flags |= RUNLOOP_FLAG_IGNORE_ENVIRONMENT_CB;
func(runloop_environment_cb);
runloop_st->ignore_environment_cb = false;
runloop_st->flags &= ~RUNLOOP_FLAG_IGNORE_ENVIRONMENT_CB;
}
static dylib_t load_dynamic_core(const char *path, char *buf,
@ -1201,8 +1201,8 @@ static void runloop_init_core_options_path(
/* Notify system that we have a valid core options
* override */
path_set(RARCH_PATH_CORE_OPTIONS, game_options_path);
runloop_st->game_options_active = true;
runloop_st->folder_options_active = false;
runloop_st->flags &= ~RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE;
runloop_st->flags |= RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE;
/* Copy options path */
strlcpy(path, game_options_path, len);
@ -1217,8 +1217,8 @@ static void runloop_init_core_options_path(
/* Notify system that we have a valid core options
* override */
path_set(RARCH_PATH_CORE_OPTIONS, folder_options_path);
runloop_st->game_options_active = false;
runloop_st->folder_options_active = true;
runloop_st->flags &= ~RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE;
runloop_st->flags |= RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE;
/* Copy options path */
strlcpy(path, folder_options_path, len);
@ -1280,8 +1280,8 @@ static void runloop_init_core_options_path(
/* Notify system that we *do not* have a valid core options
* options override */
runloop_st->game_options_active = false;
runloop_st->folder_options_active = false;
runloop_st->flags &= ~(RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE
| RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE);
}
}
@ -1394,10 +1394,10 @@ bool runloop_environment_cb(unsigned cmd, void *data)
unsigned p;
runloop_state_t *runloop_st = &runloop_state;
recording_state_t *recording_st = recording_state_get_ptr();
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = &runloop_st->system;
bool ignore_environment_cb = runloop_st->ignore_environment_cb;
bool ignore_environment_cb = runloop_st->flags &
RUNLOOP_FLAG_IGNORE_ENVIRONMENT_CB;
if (ignore_environment_cb)
return false;
@ -1538,11 +1538,12 @@ bool runloop_environment_cb(unsigned cmd, void *data)
if (runloop_st->core_options)
{
runloop_deinit_core_options(
runloop_st->game_options_active,
runloop_st->flags & RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE,
path_get(RARCH_PATH_CORE_OPTIONS),
runloop_st->core_options);
runloop_st->game_options_active = false;
runloop_st->folder_options_active = false;
runloop_st->flags &=
~(RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE
| RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE);
runloop_st->core_options = NULL;
}
if ((new_vars = runloop_init_core_variables(
@ -1566,11 +1567,12 @@ bool runloop_environment_cb(unsigned cmd, void *data)
if (runloop_st->core_options)
{
runloop_deinit_core_options(
runloop_st->game_options_active,
runloop_st->flags & RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE,
path_get(RARCH_PATH_CORE_OPTIONS),
runloop_st->core_options);
runloop_st->game_options_active = false;
runloop_st->folder_options_active = false;
runloop_st->flags &=
~(RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE
| RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE);
runloop_st->core_options = NULL;
}
@ -1599,11 +1601,12 @@ bool runloop_environment_cb(unsigned cmd, void *data)
if (runloop_st->core_options)
{
runloop_deinit_core_options(
runloop_st->game_options_active,
runloop_st->flags & RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE,
path_get(RARCH_PATH_CORE_OPTIONS),
runloop_st->core_options);
runloop_st->game_options_active = false;
runloop_st->folder_options_active = false;
runloop_st->flags &=
~(RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE
| RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE);
runloop_st->core_options = NULL;
}
@ -1634,11 +1637,12 @@ bool runloop_environment_cb(unsigned cmd, void *data)
if (runloop_st->core_options)
{
runloop_deinit_core_options(
runloop_st->game_options_active,
runloop_st->flags & RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE,
path_get(RARCH_PATH_CORE_OPTIONS),
runloop_st->core_options);
runloop_st->game_options_active = false;
runloop_st->folder_options_active = false;
runloop_st->flags &=
~(RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE
| RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE);
runloop_st->core_options = NULL;
}
@ -1673,11 +1677,12 @@ bool runloop_environment_cb(unsigned cmd, void *data)
if (runloop_st->core_options)
{
runloop_deinit_core_options(
runloop_st->game_options_active,
runloop_st->flags & RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE,
path_get(RARCH_PATH_CORE_OPTIONS),
runloop_st->core_options);
runloop_st->game_options_active = false;
runloop_st->folder_options_active = false;
runloop_st->flags &=
~(RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE
| RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE);
runloop_st->core_options = NULL;
}
@ -2940,7 +2945,7 @@ bool runloop_environment_cb(unsigned cmd, void *data)
return false;
#else
RARCH_LOG("[Environ]: SET_HW_SHARED_CONTEXT.\n");
runloop_st->core_set_shared_context = true;
runloop_st->flags |= RUNLOOP_FLAG_CORE_SET_SHARED_CONTEXT;
#endif
break;
@ -3026,7 +3031,7 @@ bool runloop_environment_cb(unsigned cmd, void *data)
/* Deprecated.
Use RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT instead. */
/* TODO/FIXME: Get rid of this ugly hack. */
if (runloop_st->request_special_savestate)
if (runloop_st->flags & RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE)
result |= 4;
#endif
if (data)
@ -3042,7 +3047,7 @@ bool runloop_environment_cb(unsigned cmd, void *data)
int result = RETRO_SAVESTATE_CONTEXT_NORMAL;
#if defined(HAVE_RUNAHEAD) || defined(HAVE_NETWORKING)
if (runloop_st->request_special_savestate)
if (runloop_st->flags & RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE)
{
#ifdef HAVE_NETWORKING
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
@ -3361,9 +3366,9 @@ bool libretro_get_system_info(
* Make sure we reset it to the actual environment callback.
* Ignore any environment callbacks here in case we're running
* on the non-current core. */
runloop_st->ignore_environment_cb = true;
runloop_st->flags |= RUNLOOP_FLAG_IGNORE_ENVIRONMENT_CB;
retro_set_environment(runloop_environment_cb);
runloop_st->ignore_environment_cb = false;
runloop_st->flags &= ~RUNLOOP_FLAG_IGNORE_ENVIRONMENT_CB;
}
retro_get_system_info(&dummy_info);
@ -3540,10 +3545,10 @@ static bool init_libretro_symbols(
return true;
}
bool libretro_get_shared_context(void)
uint32_t runloop_get_flags(void)
{
runloop_state_t *runloop_st = &runloop_state;
return runloop_st->core_set_shared_context;
return runloop_st->flags;
}
void runloop_system_info_free(void)
@ -3608,17 +3613,18 @@ static void uninit_libretro_symbols(
memset(current_core, 0, sizeof(struct retro_core_t));
runloop_st->core_set_shared_context = false;
runloop_st->flags &= ~RUNLOOP_FLAG_CORE_SET_SHARED_CONTEXT;
if (runloop_st->core_options)
{
runloop_deinit_core_options(
runloop_st->game_options_active,
runloop_st->flags & RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE,
path_get(RARCH_PATH_CORE_OPTIONS),
runloop_st->core_options);
runloop_st->game_options_active = false;
runloop_st->folder_options_active = false;
runloop_st->core_options = NULL;
runloop_st->flags &=
~(RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE
| RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE);
runloop_st->core_options = NULL;
}
runloop_system_info_free();
audio_st->callback.callback = NULL;
@ -4150,9 +4156,9 @@ static bool secondary_core_deserialize(settings_t *settings,
{
runloop_state_t *runloop_st = &runloop_state;
runloop_st->request_special_savestate = true;
ret = runloop_st->secondary_core.retro_unserialize(data, size);
runloop_st->request_special_savestate = false;
runloop_st->flags |= RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE;
ret = runloop_st->secondary_core.retro_unserialize(data, size);
runloop_st->flags &= ~RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE;
}
else
runloop_secondary_core_destroy();
@ -5085,9 +5091,9 @@ void runloop_event_deinit_core(void)
runloop_st->fastmotion_override.pending = false;
}
if ( runloop_st->remaps_core_active
|| runloop_st->remaps_content_dir_active
|| runloop_st->remaps_game_active
if ( (runloop_st->flags & RUNLOOP_FLAG_REMAPS_CORE_ACTIVE)
|| (runloop_st->flags & RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE)
|| (runloop_st->flags & RUNLOOP_FLAG_REMAPS_GAME_ACTIVE)
|| !string_is_empty(runloop_st->name.remapfile)
)
{
@ -5113,11 +5119,11 @@ void runloop_event_deinit_core(void)
driver_uninit(DRIVERS_CMD_ALL);
#ifdef HAVE_CONFIGFILE
if (runloop_st->overrides_active)
if (runloop_st->flags & RUNLOOP_FLAG_OVERRIDES_ACTIVE)
{
/* Reload the original config */
config_unload_override();
runloop_st->overrides_active = false;
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
}
#endif
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
@ -5150,7 +5156,10 @@ static bool event_init_content(
const enum rarch_core_type current_core_type = runloop_st->current_core_type;
uint8_t flags = content_get_flags();
runloop_st->use_sram = (current_core_type == CORE_TYPE_PLAIN);
if (current_core_type == CORE_TYPE_PLAIN)
runloop_st->flags |= RUNLOOP_FLAG_USE_SRAM;
else
runloop_st->flags &= ~RUNLOOP_FLAG_USE_SRAM;
/* No content to be loaded for dummy core,
* just successfully exit. */
@ -5172,7 +5181,8 @@ static bool event_init_content(
command_event_set_savestate_auto_index(settings);
if (!event_load_save_files(runloop_st->is_sram_load_disabled))
if (!event_load_save_files(runloop_st->flags &
RUNLOOP_FLAG_IS_SRAM_LOAD_DISABLED))
RARCH_LOG("[SRAM]: %s\n",
msg_hash_to_str(MSG_SKIPPING_SRAM_LOAD));
@ -5533,8 +5543,12 @@ bool runloop_event_init_core(
#ifdef HAVE_CONFIGFILE
if (auto_overrides_enable)
runloop_st->overrides_active =
config_load_override(&runloop_st->system);
{
if (config_load_override(&runloop_st->system))
runloop_st->flags |= RUNLOOP_FLAG_OVERRIDES_ACTIVE;
else
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
}
#endif
/* Cannot access these settings-related parameters
@ -5902,10 +5916,16 @@ void runloop_path_fill_names(void)
void runloop_path_init_savefile(void)
{
runloop_state_t *runloop_st = &runloop_state;
bool should_sram_be_used = runloop_st->use_sram
&& !runloop_st->is_sram_save_disabled;
bool should_sram_be_used =
(runloop_st->flags & RUNLOOP_FLAG_USE_SRAM)
&& !(runloop_st->flags & RUNLOOP_FLAG_IS_SRAM_SAVE_DISABLED);
if (!(runloop_st->use_sram = should_sram_be_used))
if (should_sram_be_used)
runloop_st->flags |= RUNLOOP_FLAG_USE_SRAM;
else
runloop_st->flags &= ~RUNLOOP_FLAG_USE_SRAM;
if (!(runloop_st->flags & RUNLOOP_FLAG_USE_SRAM))
{
RARCH_LOG("[SRAM]: %s\n",
msg_hash_to_str(MSG_SRAM_WILL_NOT_BE_SAVED));
@ -5939,7 +5959,7 @@ bool core_options_create_override(bool game_specific)
/* Sanity check - cannot create a folder-specific
* override if a game-specific override is
* already active */
if (runloop_st->game_options_active)
if (runloop_st->flags & RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE)
goto error;
/* Get options file path (folder-specific) */
@ -5966,8 +5986,14 @@ bool core_options_create_override(bool game_specific)
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
path_set(RARCH_PATH_CORE_OPTIONS, options_path);
runloop_st->game_options_active = game_specific;
runloop_st->folder_options_active = !game_specific;
if (game_specific)
runloop_st->flags |= RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE;
else
runloop_st->flags &= ~RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE;
if (!game_specific)
runloop_st->flags |= RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE;
else
runloop_st->flags &= ~RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE;
config_file_free(conf);
return true;
@ -5996,19 +6022,21 @@ bool core_options_remove_override(bool game_specific)
config_file_t *conf = NULL;
bool folder_options_active = false;
new_options_path[0] = '\0';
new_options_path[0] = '\0';
/* Sanity check 1 - if there are no core options
* or no overrides are active, there is nothing to do */
if ( !coreopts ||
( !runloop_st->game_options_active
&& !runloop_st->folder_options_active)
)
( (!(runloop_st->flags & RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE))
&& (!(runloop_st->flags & RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE))
))
return true;
/* Sanity check 2 - can only remove an override
* if the specified type is currently active */
if (game_specific && !runloop_st->game_options_active)
if ( game_specific
&& !(runloop_st->flags & RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE)
)
goto error;
/* Get current options file path */
@ -6103,14 +6131,14 @@ bool core_options_remove_override(bool game_specific)
if (folder_options_active)
{
path_set(RARCH_PATH_CORE_OPTIONS, new_options_path);
runloop_st->game_options_active = false;
runloop_st->folder_options_active = true;
runloop_st->flags &= ~RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE;
runloop_st->flags |= RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE;
}
else
{
path_clear(RARCH_PATH_CORE_OPTIONS);
runloop_st->game_options_active = false;
runloop_st->folder_options_active = false;
runloop_st->flags &= ~(RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE
| RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE);
/* Update config file path/object stored in
* core option manager struct */
@ -6701,7 +6729,7 @@ MENU_ST_FLAG_IS_BINDING;
if ((runloop_max_frames != 0)
&& (frame_count >= runloop_max_frames)
&& runloop_st->max_frames_screenshot)
&& (runloop_st->flags & RUNLOOP_FLAG_MAX_FRAMES_SCREENSHOT))
{
const char *screenshot_path = NULL;
bool fullpath = false;
@ -8200,12 +8228,12 @@ void runloop_set_current_core_type(
{
runloop_state_t *runloop_st = &runloop_state;
if (runloop_st->has_set_core)
if (runloop_st->flags & RUNLOOP_FLAG_HAS_SET_CORE)
return;
if (explicitly_set)
{
runloop_st->has_set_core = true;
runloop_st->flags |= RUNLOOP_FLAG_HAS_SET_CORE;
runloop_st->explicit_current_core_type = type;
}
runloop_st->current_core_type = type;
@ -8456,9 +8484,9 @@ bool core_unserialize_special(retro_ctx_serialize_info_t *info)
if (!info)
return false;
runloop_st->request_special_savestate = true;
runloop_st->flags |= RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE;
ret = runloop_st->current_core.retro_unserialize(info->data_const, info->size);
runloop_st->request_special_savestate = false;
runloop_st->flags &= ~RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE;
#ifdef HAVE_NETWORKING
if (ret)
@ -8484,9 +8512,9 @@ bool core_serialize_special(retro_ctx_serialize_info_t *info)
if (!info)
return false;
runloop_st->request_special_savestate = true;
ret = runloop_st->current_core.retro_serialize(info->data, info->size);
runloop_st->request_special_savestate = false;
runloop_st->flags |= RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE;
ret = runloop_st->current_core.retro_serialize(info->data, info->size);
runloop_st->flags &= ~RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE;
return ret;
}
@ -8507,9 +8535,9 @@ bool core_serialize_size_special(retro_ctx_size_info_t *info)
if (!info)
return false;
runloop_st->request_special_savestate = true;
info->size = runloop_st->current_core.retro_serialize_size();
runloop_st->request_special_savestate = false;
runloop_st->flags |= RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE;
info->size = runloop_st->current_core.retro_serialize_size();
runloop_st->flags &= ~RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE;
return true;
}

View File

@ -131,6 +131,25 @@ typedef struct my_list_t
} my_list;
#endif
enum runloop_flags
{
RUNLOOP_FLAG_MAX_FRAMES_SCREENSHOT = (1 << 0),
RUNLOOP_FLAG_HAS_SET_CORE = (1 << 1),
RUNLOOP_FLAG_CORE_SET_SHARED_CONTEXT = (1 << 2),
RUNLOOP_FLAG_IGNORE_ENVIRONMENT_CB = (1 << 3),
RUNLOOP_FLAG_IS_SRAM_LOAD_DISABLED = (1 << 4),
RUNLOOP_FLAG_IS_SRAM_SAVE_DISABLED = (1 << 5),
RUNLOOP_FLAG_USE_SRAM = (1 << 6),
RUNLOOP_FLAG_PATCH_BLOCKED = (1 << 7),
RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE = (1 << 8),
RUNLOOP_FLAG_OVERRIDES_ACTIVE = (1 << 9),
RUNLOOP_FLAG_GAME_OPTIONS_ACTIVE = (1 << 10),
RUNLOOP_FLAG_FOLDER_OPTIONS_ACTIVE = (1 << 11),
RUNLOOP_FLAG_REMAPS_CORE_ACTIVE = (1 << 12),
RUNLOOP_FLAG_REMAPS_GAME_ACTIVE = (1 << 13),
RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE = (1 << 14)
};
struct runloop
{
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
@ -232,6 +251,8 @@ struct runloop
enum rarch_core_type last_core_type;
#endif
uint32_t flags;
char runtime_content_path_basename[8192];
char current_library_name[NAME_MAX_LENGTH];
char current_library_version[256];
@ -272,18 +293,7 @@ struct runloop
bool core_shutdown_initiated;
bool core_running;
bool perfcnt_enable;
bool game_options_active;
bool folder_options_active;
bool autosave;
#ifdef HAVE_CONFIGFILE
bool overrides_active;
#endif
bool remaps_core_active;
bool remaps_game_active;
bool remaps_content_dir_active;
#ifdef HAVE_SCREENSHOTS
bool max_frames_screenshot;
#endif
#ifdef HAVE_RUNAHEAD
bool has_variable_update;
bool input_is_dirty;
@ -292,16 +302,6 @@ struct runloop
bool runahead_secondary_core_available;
bool runahead_force_input_dirty;
#endif
bool request_special_savestate;
#ifdef HAVE_PATCH
bool patch_blocked;
#endif
bool is_sram_load_disabled;
bool is_sram_save_disabled;
bool use_sram;
bool ignore_environment_cb;
bool core_set_shared_context;
bool has_set_core;
};
typedef struct runloop runloop_state_t;
@ -458,6 +458,8 @@ void runloop_path_init_savefile(void);
void runloop_path_set_names(void);
uint32_t runloop_get_flags(void);
runloop_state_t *runloop_state_get_ptr(void);
RETRO_END_DECLS

View File

@ -1936,7 +1936,7 @@ bool task_push_start_dummy_core(content_ctx_info_t *content_info)
content_ctx.flags |= CONTENT_INFO_FLAG_IS_BPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_UPS_PREF;
if (runloop_st->patch_blocked)
if (runloop_st->flags & RUNLOOP_FLAG_PATCH_BLOCKED)
content_ctx.flags |= CONTENT_INFO_FLAG_PATCH_IS_BLOCKED;
#endif
if (retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL))
@ -2023,7 +2023,7 @@ bool task_push_load_content_from_playlist_from_menu(
content_ctx.flags |= CONTENT_INFO_FLAG_IS_BPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_UPS_PREF;
if (runloop_st->patch_blocked)
if (runloop_st->flags & RUNLOOP_FLAG_PATCH_BLOCKED)
content_ctx.flags |= CONTENT_INFO_FLAG_PATCH_IS_BLOCKED;
#endif
if (retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL))
@ -2161,7 +2161,7 @@ bool task_push_start_current_core(content_ctx_info_t *content_info)
content_ctx.flags |= CONTENT_INFO_FLAG_IS_BPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_UPS_PREF;
if (runloop_st->patch_blocked)
if (runloop_st->flags & RUNLOOP_FLAG_PATCH_BLOCKED)
content_ctx.flags |= CONTENT_INFO_FLAG_PATCH_IS_BLOCKED;
#endif
if (retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL))
@ -2395,7 +2395,7 @@ bool task_push_load_content_with_new_core_from_menu(
content_ctx.flags |= CONTENT_INFO_FLAG_IS_BPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_UPS_PREF;
if (runloop_st->patch_blocked)
if (runloop_st->flags & RUNLOOP_FLAG_PATCH_BLOCKED)
content_ctx.flags |= CONTENT_INFO_FLAG_PATCH_IS_BLOCKED;
#endif
if (retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL))
@ -2500,7 +2500,7 @@ static bool task_load_content_internal(
content_ctx.flags |= CONTENT_INFO_FLAG_IS_BPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_UPS_PREF;
if (runloop_st->patch_blocked)
if (runloop_st->flags & RUNLOOP_FLAG_PATCH_BLOCKED)
content_ctx.flags |= CONTENT_INFO_FLAG_PATCH_IS_BLOCKED;
#endif
if (retroarch_ctl(RARCH_CTL_IS_MISSING_BIOS, NULL))
@ -3040,7 +3040,7 @@ bool content_init(void)
content_ctx.flags |= CONTENT_INFO_FLAG_IS_BPS_PREF;
if (retroarch_ctl(RARCH_CTL_IS_UPS_PREF, NULL))
content_ctx.flags |= CONTENT_INFO_FLAG_IS_UPS_PREF;
if (runloop_st->patch_blocked)
if (runloop_st->flags & RUNLOOP_FLAG_PATCH_BLOCKED)
content_ctx.flags |= CONTENT_INFO_FLAG_PATCH_IS_BLOCKED;
#endif
content_ctx.directory_system = NULL;