mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 14:42:30 +00:00
Turn core boolean variables into flags
This commit is contained in:
parent
c0d6d6e750
commit
c7eee86fd5
12
driver.c
12
driver.c
@ -860,13 +860,13 @@ void retroarch_deinit_drivers(struct retro_callbacks *cbs)
|
|||||||
wifi_driver_ctl(RARCH_WIFI_CTL_DESTROY, NULL);
|
wifi_driver_ctl(RARCH_WIFI_CTL_DESTROY, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cbs->frame_cb = retro_frame_null;
|
cbs->frame_cb = retro_frame_null;
|
||||||
cbs->poll_cb = retro_input_poll_null;
|
cbs->poll_cb = retro_input_poll_null;
|
||||||
cbs->sample_cb = NULL;
|
cbs->sample_cb = NULL;
|
||||||
cbs->sample_batch_cb = NULL;
|
cbs->sample_batch_cb = NULL;
|
||||||
cbs->state_cb = NULL;
|
cbs->state_cb = NULL;
|
||||||
|
|
||||||
runloop_st->current_core.inited = false;
|
runloop_st->current_core.flags &= ~RETRO_CORE_FLAG_INITED;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool driver_ctl(enum driver_ctl_state state, void *data)
|
bool driver_ctl(enum driver_ctl_state state, void *data)
|
||||||
|
17
dynamic.h
17
dynamic.h
@ -55,6 +55,16 @@ const struct retro_controller_description *
|
|||||||
libretro_find_controller_description(
|
libretro_find_controller_description(
|
||||||
const struct retro_controller_info *info, unsigned id);
|
const struct retro_controller_info *info, unsigned id);
|
||||||
|
|
||||||
|
enum retro_core_flags
|
||||||
|
{
|
||||||
|
RETRO_CORE_FLAG_INITED = (1 << 0),
|
||||||
|
RETRO_CORE_FLAG_SYMBOLS_INITED = (1 << 1),
|
||||||
|
RETRO_CORE_FLAG_GAME_LOADED = (1 << 2),
|
||||||
|
RETRO_CORE_FLAG_INPUT_POLLED = (1 << 3),
|
||||||
|
RETRO_CORE_FLAG_HAS_SET_SUBSYSTEMS = (1 << 4),
|
||||||
|
RETRO_CORE_FLAG_HAS_SET_INPUT_DESCRIPTORS = (1 << 5)
|
||||||
|
};
|
||||||
|
|
||||||
struct retro_core_t
|
struct retro_core_t
|
||||||
{
|
{
|
||||||
uint64_t serialization_quirks_v;
|
uint64_t serialization_quirks_v;
|
||||||
@ -86,12 +96,7 @@ struct retro_core_t
|
|||||||
size_t (*retro_get_memory_size)(unsigned);
|
size_t (*retro_get_memory_size)(unsigned);
|
||||||
|
|
||||||
unsigned poll_type;
|
unsigned poll_type;
|
||||||
bool inited;
|
uint8_t flags;
|
||||||
bool symbols_inited;
|
|
||||||
bool game_loaded;
|
|
||||||
bool input_polled;
|
|
||||||
bool has_set_subsystems;
|
|
||||||
bool has_set_input_descriptors;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
@ -2665,7 +2665,7 @@ void video_driver_cached_frame(void)
|
|||||||
/* Cannot allow recording when pushing duped frames. */
|
/* Cannot allow recording when pushing duped frames. */
|
||||||
recording_st->data = NULL;
|
recording_st->data = NULL;
|
||||||
|
|
||||||
if (runloop_st->current_core.inited)
|
if (runloop_st->current_core.flags & RETRO_CORE_FLAG_INITED)
|
||||||
cbs->frame_cb(
|
cbs->frame_cb(
|
||||||
(video_st->frame_cache_data != RETRO_HW_FRAME_BUFFER_VALID)
|
(video_st->frame_cache_data != RETRO_HW_FRAME_BUFFER_VALID)
|
||||||
? video_st->frame_cache_data
|
? video_st->frame_cache_data
|
||||||
@ -2813,7 +2813,8 @@ VIDEO_FLAG_WIDGETS_FAST_FORWARD;
|
|||||||
settings->floats.menu_framebuffer_opacity;
|
settings->floats.menu_framebuffer_opacity;
|
||||||
video_info->overlay_behind_menu = settings->bools.input_overlay_behind_menu;
|
video_info->overlay_behind_menu = settings->bools.input_overlay_behind_menu;
|
||||||
|
|
||||||
video_info->libretro_running = runloop_st->current_core.game_loaded;
|
video_info->libretro_running = runloop_st->current_core.flags &
|
||||||
|
RETRO_CORE_FLAG_GAME_LOADED;
|
||||||
#else
|
#else
|
||||||
video_info->menu_is_alive = false;
|
video_info->menu_is_alive = false;
|
||||||
video_info->menu_screensaver_active = false;
|
video_info->menu_screensaver_active = false;
|
||||||
@ -3572,7 +3573,7 @@ VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st);
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!runloop_st->current_core.game_loaded)
|
if (!(runloop_st->current_core.flags & RETRO_CORE_FLAG_GAME_LOADED))
|
||||||
video_driver_cached_frame_set(&dummy_pixels, 4, 4, 8);
|
video_driver_cached_frame_set(&dummy_pixels, 4, 4, 8);
|
||||||
|
|
||||||
#if defined(PSP)
|
#if defined(PSP)
|
||||||
|
11
retroarch.c
11
retroarch.c
@ -3629,8 +3629,8 @@ static void global_free(struct rarch_state *p_rarch)
|
|||||||
| RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE);
|
| RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
runloop_st->current_core.has_set_input_descriptors = false;
|
runloop_st->current_core.flags &= ~(RETRO_CORE_FLAG_HAS_SET_INPUT_DESCRIPTORS
|
||||||
runloop_st->current_core.has_set_subsystems = false;
|
| RETRO_CORE_FLAG_HAS_SET_SUBSYSTEMS);
|
||||||
|
|
||||||
global = global_get_ptr();
|
global = global_get_ptr();
|
||||||
path_clear_all();
|
path_clear_all();
|
||||||
@ -4729,8 +4729,8 @@ static bool retroarch_parse_input_and_config(
|
|||||||
|
|
||||||
/* Flush out some states that could have been set
|
/* Flush out some states that could have been set
|
||||||
* by core environment variables. */
|
* by core environment variables. */
|
||||||
runloop_st->current_core.has_set_input_descriptors = false;
|
runloop_st->current_core.flags &= ~(RETRO_CORE_FLAG_HAS_SET_INPUT_DESCRIPTORS
|
||||||
runloop_st->current_core.has_set_subsystems = false;
|
| RETRO_CORE_FLAG_HAS_SET_SUBSYSTEMS);
|
||||||
|
|
||||||
/* Load the config file now that we know what it is */
|
/* Load the config file now that we know what it is */
|
||||||
#ifdef HAVE_CONFIGFILE
|
#ifdef HAVE_CONFIGFILE
|
||||||
@ -5577,7 +5577,8 @@ bool retroarch_ctl(enum rarch_ctl_state state, void *data)
|
|||||||
switch(state)
|
switch(state)
|
||||||
{
|
{
|
||||||
case RARCH_CTL_HAS_SET_SUBSYSTEMS:
|
case RARCH_CTL_HAS_SET_SUBSYSTEMS:
|
||||||
return runloop_st->current_core.has_set_subsystems;
|
return ((runloop_st->current_core.flags &
|
||||||
|
RETRO_CORE_FLAG_HAS_SET_SUBSYSTEMS) > 0);
|
||||||
#ifdef HAVE_BSV_MOVIE
|
#ifdef HAVE_BSV_MOVIE
|
||||||
case RARCH_CTL_BSV_MOVIE_IS_INITED:
|
case RARCH_CTL_BSV_MOVIE_IS_INITED:
|
||||||
return (input_state_get_ptr()->bsv_movie_state_handle != NULL);
|
return (input_state_get_ptr()->bsv_movie_state_handle != NULL);
|
||||||
|
72
runloop.c
72
runloop.c
@ -2146,7 +2146,8 @@ bool runloop_environment_cb(unsigned cmd, void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runloop_st->current_core.has_set_input_descriptors = true;
|
runloop_st->current_core.flags |=
|
||||||
|
RETRO_CORE_FLAG_HAS_SET_INPUT_DESCRIPTORS;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -2718,7 +2719,8 @@ bool runloop_environment_cb(unsigned cmd, void *data)
|
|||||||
memcpy(system->subsystem.data, info,
|
memcpy(system->subsystem.data, info,
|
||||||
i * sizeof(*system->subsystem.data));
|
i * sizeof(*system->subsystem.data));
|
||||||
system->subsystem.size = i;
|
system->subsystem.size = i;
|
||||||
runloop_st->current_core.has_set_subsystems = true;
|
runloop_st->current_core.flags |=
|
||||||
|
RETRO_CORE_FLAG_HAS_SET_SUBSYSTEMS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4063,16 +4065,19 @@ static bool secondary_core_create(runloop_state_t *runloop_st,
|
|||||||
&runloop_st->secondary_lib_handle))
|
&runloop_st->secondary_lib_handle))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
runloop_st->secondary_core.symbols_inited = true;
|
runloop_st->secondary_core.flags |= RETRO_CORE_FLAG_SYMBOLS_INITED;
|
||||||
runloop_st->secondary_core.retro_set_environment(
|
runloop_st->secondary_core.retro_set_environment(
|
||||||
runloop_environment_secondary_core_hook);
|
runloop_environment_secondary_core_hook);
|
||||||
#ifdef HAVE_RUNAHEAD
|
#ifdef HAVE_RUNAHEAD
|
||||||
runloop_st->flags |= RUNLOOP_FLAG_HAS_VARIABLE_UPDATE;
|
runloop_st->flags |= RUNLOOP_FLAG_HAS_VARIABLE_UPDATE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
runloop_st->secondary_core.retro_init();
|
runloop_st->secondary_core.retro_init();
|
||||||
|
|
||||||
runloop_st->secondary_core.inited = (flags & CONTENT_ST_FLAG_IS_INITED);
|
if (flags & CONTENT_ST_FLAG_IS_INITED)
|
||||||
|
runloop_st->secondary_core.flags |= RETRO_CORE_FLAG_INITED;
|
||||||
|
else
|
||||||
|
runloop_st->secondary_core.flags &= ~RETRO_CORE_FLAG_INITED;
|
||||||
|
|
||||||
/* Load Content */
|
/* Load Content */
|
||||||
/* disabled due to crashes */
|
/* disabled due to crashes */
|
||||||
@ -4083,23 +4088,29 @@ static bool secondary_core_create(runloop_state_t *runloop_st,
|
|||||||
if ( (runloop_st->load_content_info->content->size > 0) &&
|
if ( (runloop_st->load_content_info->content->size > 0) &&
|
||||||
runloop_st->load_content_info->content->elems[0].data)
|
runloop_st->load_content_info->content->elems[0].data)
|
||||||
{
|
{
|
||||||
runloop_st->secondary_core.game_loaded =
|
if (runloop_st->secondary_core.retro_load_game(
|
||||||
runloop_st->secondary_core.retro_load_game(
|
runloop_st->load_content_info->info))
|
||||||
runloop_st->load_content_info->info);
|
runloop_st->secondary_core.flags |= RETRO_CORE_FLAG_GAME_LOADED;
|
||||||
if (!runloop_st->secondary_core.game_loaded)
|
else
|
||||||
|
{
|
||||||
|
runloop_st->secondary_core.flags &= ~RETRO_CORE_FLAG_GAME_LOADED;
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)
|
else if (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)
|
||||||
{
|
{
|
||||||
runloop_st->secondary_core.game_loaded =
|
if (runloop_st->secondary_core.retro_load_game(NULL))
|
||||||
runloop_st->secondary_core.retro_load_game(NULL);
|
runloop_st->secondary_core.flags |= RETRO_CORE_FLAG_GAME_LOADED;
|
||||||
if (!runloop_st->secondary_core.game_loaded)
|
else
|
||||||
|
{
|
||||||
|
runloop_st->secondary_core.flags &= ~RETRO_CORE_FLAG_GAME_LOADED;
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
runloop_st->secondary_core.game_loaded = false;
|
runloop_st->secondary_core.flags &= ~RETRO_CORE_FLAG_GAME_LOADED;
|
||||||
|
|
||||||
if (!runloop_st->secondary_core.inited)
|
if (!(runloop_st->secondary_core.flags & RETRO_CORE_FLAG_INITED))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
core_set_default_callbacks(&runloop_st->secondary_callbacks);
|
core_set_default_callbacks(&runloop_st->secondary_callbacks);
|
||||||
@ -4982,12 +4993,12 @@ static bool core_unload_game(void)
|
|||||||
|
|
||||||
video_driver_set_cached_frame_ptr(NULL);
|
video_driver_set_cached_frame_ptr(NULL);
|
||||||
|
|
||||||
if (runloop_st->current_core.game_loaded)
|
if ((runloop_st->current_core.flags & RETRO_CORE_FLAG_GAME_LOADED))
|
||||||
{
|
{
|
||||||
RARCH_LOG("[Core]: Unloading game..\n");
|
RARCH_LOG("[Core]: Unloading game..\n");
|
||||||
runloop_st->current_core.retro_unload_game();
|
runloop_st->current_core.retro_unload_game();
|
||||||
runloop_st->core_poll_type_override = POLL_TYPE_OVERRIDE_DONTCARE;
|
runloop_st->core_poll_type_override = POLL_TYPE_OVERRIDE_DONTCARE;
|
||||||
runloop_st->current_core.game_loaded = false;
|
runloop_st->current_core.flags &= ~RETRO_CORE_FLAG_GAME_LOADED;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_driver_stop();
|
audio_driver_stop();
|
||||||
@ -5080,7 +5091,7 @@ void runloop_event_deinit_core(void)
|
|||||||
|
|
||||||
video_driver_set_cached_frame_ptr(NULL);
|
video_driver_set_cached_frame_ptr(NULL);
|
||||||
|
|
||||||
if (runloop_st->current_core.inited)
|
if (runloop_st->current_core.flags & RETRO_CORE_FLAG_INITED)
|
||||||
{
|
{
|
||||||
RARCH_LOG("[Core]: Unloading core..\n");
|
RARCH_LOG("[Core]: Unloading core..\n");
|
||||||
runloop_st->current_core.retro_deinit();
|
runloop_st->current_core.retro_deinit();
|
||||||
@ -5112,7 +5123,7 @@ void runloop_event_deinit_core(void)
|
|||||||
|
|
||||||
RARCH_LOG("[Core]: Unloading core symbols..\n");
|
RARCH_LOG("[Core]: Unloading core symbols..\n");
|
||||||
uninit_libretro_symbols(&runloop_st->current_core);
|
uninit_libretro_symbols(&runloop_st->current_core);
|
||||||
runloop_st->current_core.symbols_inited = false;
|
runloop_st->current_core.flags &= ~RETRO_CORE_FLAG_SYMBOLS_INITED;
|
||||||
|
|
||||||
/* Restore original refresh rate, if it has been changed
|
/* Restore original refresh rate, if it has been changed
|
||||||
* automatically in SET_SYSTEM_AV_INFO */
|
* automatically in SET_SYSTEM_AV_INFO */
|
||||||
@ -5381,10 +5392,10 @@ static bool core_verify_api_version(void)
|
|||||||
static int16_t core_input_state_poll_late(unsigned port,
|
static int16_t core_input_state_poll_late(unsigned port,
|
||||||
unsigned device, unsigned idx, unsigned id)
|
unsigned device, unsigned idx, unsigned id)
|
||||||
{
|
{
|
||||||
runloop_state_t *runloop_st = &runloop_state;
|
runloop_state_t *runloop_st = &runloop_state;
|
||||||
if (!runloop_st->current_core.input_polled)
|
if (!(runloop_st->current_core.flags & RETRO_CORE_FLAG_INPUT_POLLED))
|
||||||
input_driver_poll();
|
input_driver_poll();
|
||||||
runloop_st->current_core.input_polled = true;
|
runloop_st->current_core.flags |= RETRO_CORE_FLAG_INPUT_POLLED;
|
||||||
|
|
||||||
return input_driver_state_wrapper(port, device, idx, id);
|
return input_driver_state_wrapper(port, device, idx, id);
|
||||||
}
|
}
|
||||||
@ -5520,7 +5531,7 @@ bool runloop_event_init_core(
|
|||||||
return false;
|
return false;
|
||||||
if (!runloop_st->current_core.retro_run)
|
if (!runloop_st->current_core.retro_run)
|
||||||
runloop_st->current_core.retro_run = retro_run_null;
|
runloop_st->current_core.retro_run = retro_run_null;
|
||||||
runloop_st->current_core.symbols_inited = true;
|
runloop_st->current_core.flags |= RETRO_CORE_FLAG_SYMBOLS_INITED;
|
||||||
runloop_st->current_core.retro_get_system_info(&sys_info->info);
|
runloop_st->current_core.retro_get_system_info(&sys_info->info);
|
||||||
|
|
||||||
if (!sys_info->info.library_name)
|
if (!sys_info->info.library_name)
|
||||||
@ -5606,7 +5617,7 @@ bool runloop_event_init_core(
|
|||||||
video_driver_set_cached_frame_ptr(NULL);
|
video_driver_set_cached_frame_ptr(NULL);
|
||||||
|
|
||||||
runloop_st->current_core.retro_init();
|
runloop_st->current_core.retro_init();
|
||||||
runloop_st->current_core.inited = true;
|
runloop_st->current_core.flags |= RETRO_CORE_FLAG_INITED;
|
||||||
|
|
||||||
/* Attempt to set initial disk index */
|
/* Attempt to set initial disk index */
|
||||||
disk_control_set_initial_index(
|
disk_control_set_initial_index(
|
||||||
@ -8466,7 +8477,10 @@ bool core_load_game(retro_ctx_load_content_info_t *load_info)
|
|||||||
else if (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)
|
else if (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)
|
||||||
game_loaded = runloop_st->current_core.retro_load_game(NULL);
|
game_loaded = runloop_st->current_core.retro_load_game(NULL);
|
||||||
|
|
||||||
runloop_st->current_core.game_loaded = game_loaded;
|
if (game_loaded)
|
||||||
|
runloop_st->current_core.flags |= RETRO_CORE_FLAG_GAME_LOADED;
|
||||||
|
else
|
||||||
|
runloop_st->current_core.flags &= ~RETRO_CORE_FLAG_GAME_LOADED;
|
||||||
|
|
||||||
/* If 'game_loaded' is true at this point, then
|
/* If 'game_loaded' is true at this point, then
|
||||||
* core is actually running; register that any
|
* core is actually running; register that any
|
||||||
@ -8611,11 +8625,12 @@ bool core_run(void)
|
|||||||
if (early_polling)
|
if (early_polling)
|
||||||
input_driver_poll();
|
input_driver_poll();
|
||||||
else if (late_polling)
|
else if (late_polling)
|
||||||
current_core->input_polled = false;
|
current_core->flags &= ~RETRO_CORE_FLAG_INPUT_POLLED;
|
||||||
|
|
||||||
current_core->retro_run();
|
current_core->retro_run();
|
||||||
|
|
||||||
if (late_polling && !current_core->input_polled)
|
if ( late_polling
|
||||||
|
&& (!(current_core->flags & RETRO_CORE_FLAG_INPUT_POLLED)))
|
||||||
input_driver_poll();
|
input_driver_poll();
|
||||||
|
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
@ -8628,10 +8643,11 @@ bool core_run(void)
|
|||||||
bool core_has_set_input_descriptor(void)
|
bool core_has_set_input_descriptor(void)
|
||||||
{
|
{
|
||||||
runloop_state_t *runloop_st = &runloop_state;
|
runloop_state_t *runloop_st = &runloop_state;
|
||||||
return runloop_st->current_core.has_set_input_descriptors;
|
return ((runloop_st->current_core.flags &
|
||||||
|
RETRO_CORE_FLAG_HAS_SET_INPUT_DESCRIPTORS) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* crt_switch_core_name(void)
|
char *crt_switch_core_name(void)
|
||||||
{
|
{
|
||||||
return (char*)runloop_state.system.info.library_name;
|
return (char*)runloop_state.system.info.library_name;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user