mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-29 15:32:01 +00:00
Split up rarch_main_state_new into two - rarch_main_state_alloc
allocates all state, rarch_main_state_new actually 'initializes' the drivers, etc.
This commit is contained in:
parent
ff83aab195
commit
83947f473b
@ -284,16 +284,19 @@ returntype main_entry(signature())
|
||||
settings_t *settings = NULL;
|
||||
driver_t *driver = driver_get_ptr();
|
||||
|
||||
rarch_main_state_new();
|
||||
rarch_main_state_alloc();
|
||||
|
||||
driver->frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first();
|
||||
if (driver)
|
||||
driver->frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first();
|
||||
|
||||
if (!driver->frontend_ctx)
|
||||
if (!driver || !driver->frontend_ctx)
|
||||
RARCH_WARN("Frontend context could not be initialized.\n");
|
||||
|
||||
if (driver->frontend_ctx && driver->frontend_ctx->init)
|
||||
driver->frontend_ctx->init(args);
|
||||
|
||||
rarch_main_state_new();
|
||||
|
||||
if (driver->frontend_ctx)
|
||||
{
|
||||
if (!(ret = (main_load_content(argc, argv, args,
|
||||
|
50
retroarch.c
50
retroarch.c
@ -1665,16 +1665,25 @@ static void free_temporary_content(void)
|
||||
string_list_free(global->temporary_content);
|
||||
}
|
||||
|
||||
/* main_clear_state_extern:
|
||||
*
|
||||
* Clears all external state.
|
||||
*/
|
||||
static void main_clear_state_extern(void)
|
||||
static void main_clear_state_drivers(bool inited)
|
||||
{
|
||||
rarch_main_command(RARCH_CMD_HISTORY_DEINIT);
|
||||
if (!inited)
|
||||
return;
|
||||
|
||||
rarch_main_clear_state();
|
||||
rarch_main_data_clear_state();
|
||||
rarch_main_command(RARCH_CMD_DRIVERS_DEINIT);
|
||||
rarch_main_command(RARCH_CMD_DRIVERS_INIT);
|
||||
}
|
||||
|
||||
static void main_init_state_config(void)
|
||||
{
|
||||
unsigned i;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!settings)
|
||||
return;
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
settings->input.libretro_device[i] = RETRO_DEVICE_JOYPAD;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1688,36 +1697,33 @@ static void main_clear_state_extern(void)
|
||||
**/
|
||||
static void main_clear_state(bool inited)
|
||||
{
|
||||
unsigned i;
|
||||
main_clear_state_drivers(inited);
|
||||
init_state();
|
||||
main_init_state_config();
|
||||
}
|
||||
|
||||
void rarch_main_state_alloc(void)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (settings)
|
||||
config_free();
|
||||
|
||||
settings = config_init();
|
||||
|
||||
if (!settings)
|
||||
return;
|
||||
|
||||
if (inited)
|
||||
rarch_main_command(RARCH_CMD_DRIVERS_DEINIT);
|
||||
rarch_main_command(RARCH_CMD_HISTORY_DEINIT);
|
||||
|
||||
main_clear_state_extern();
|
||||
|
||||
if (inited)
|
||||
rarch_main_command(RARCH_CMD_DRIVERS_INIT);
|
||||
|
||||
init_state();
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
settings->input.libretro_device[i] = RETRO_DEVICE_JOYPAD;
|
||||
rarch_main_clear_state();
|
||||
rarch_main_data_clear_state();
|
||||
}
|
||||
|
||||
void rarch_main_state_new(void)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
main_clear_state(global ? global->main_is_init: false);
|
||||
main_clear_state(global->main_is_init);
|
||||
rarch_main_command(RARCH_CMD_MSG_QUEUE_INIT);
|
||||
}
|
||||
|
||||
|
@ -218,6 +218,8 @@ struct rarch_main_wrap
|
||||
bool touched;
|
||||
};
|
||||
|
||||
void rarch_main_state_alloc(void);
|
||||
|
||||
void rarch_main_state_new(void);
|
||||
|
||||
void rarch_main_state_free(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user