Hide more manipulation of lifecycle_state behind rarch_main_set_state

function
This commit is contained in:
twinaphex 2014-09-03 18:36:46 +02:00
parent 51ed93d703
commit d539bed82c
7 changed files with 40 additions and 23 deletions

View File

@ -1046,11 +1046,11 @@ bool rarch_environment_cb(unsigned cmd, void *data)
*g_extern.fullpath = '\0';
#if defined(RARCH_CONSOLE)
g_extern.lifecycle_state &= ~(1ULL << MODE_GAME);
g_extern.lifecycle_state |= (1ULL << MODE_EXITSPAWN);
rarch_main_set_state(RARCH_ACTION_STATE_STOP_CONTENT);
rarch_main_set_state(RARCH_ACTION_STATE_EXITSPAWN);
g_extern.lifecycle_state |= (1ULL << MODE_EXITSPAWN_START_GAME);
#elif defined(HAVE_DYNAMIC)
g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);
rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT);
#endif
if (cmd == RETRO_ENVIRONMENT_EXEC_ESCAPE)

View File

@ -103,13 +103,14 @@ static int main_entry_iterate_shutdown(args_type() args)
static int main_entry_iterate_content(args_type() args)
{
if (rarch_main_iterate())
if (!rarch_main_iterate())
{
if (driver.frontend_ctx && driver.frontend_ctx->process_events)
driver.frontend_ctx->process_events(args);
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING_FINISHED);
return 0;
}
else
g_extern.lifecycle_state &= ~(1ULL << MODE_GAME);
if (driver.frontend_ctx && driver.frontend_ctx->process_events)
driver.frontend_ctx->process_events(args);
return 0;
}
@ -120,7 +121,7 @@ static int main_entry_iterate_load_content(args_type() args)
if (!load_menu_content())
g_extern.lifecycle_state = (1ULL << MODE_MENU_PREINIT);
g_extern.lifecycle_state &= ~(1ULL << MODE_LOAD_GAME);
rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT_FINISHED);
return 0;
}
@ -153,8 +154,8 @@ static int main_entry_iterate_menu_preinit(args_type() args)
driver.menu->need_refresh = true;
driver.menu->old_input_state |= 1ULL << RARCH_MENU_TOGGLE;
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU_PREINIT);
g_extern.lifecycle_state |= (1ULL << MODE_MENU);
rarch_main_set_state(RARCH_ACTION_STATE_MENU_PREINIT_FINISHED);
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING);
return 0;
}
@ -168,7 +169,7 @@ static int main_entry_iterate_menu(args_type() args)
return 0;
}
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU);
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED);
driver_set_nonblock_state(driver.nonblock_state);
rarch_main_command(RARCH_CMD_AUDIO_START);

View File

@ -1907,7 +1907,7 @@ static int menu_action_ok(const char *dir,
/* No content needed for this core, load core immediately. */
if (driver.menu->load_no_content)
{
g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);
rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT);
*g_extern.fullpath = '\0';
driver.menu->msg_force = true;
return -1;
@ -1976,7 +1976,7 @@ static int menu_action_ok(const char *dir,
{
fill_pathname_join(g_extern.fullpath, dir, path,
sizeof(g_extern.fullpath));
g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);
rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT);
menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS);
driver.menu->msg_force = true;

View File

@ -351,7 +351,7 @@ static int menu_lakka_iterate(unsigned action)
#ifdef HAVE_DYNAMIC
rarch_main_command(RARCH_CMD_LOAD_CORE);
g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);
rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT);
#endif
}
return -1;
@ -384,7 +384,7 @@ static int menu_lakka_iterate(unsigned action)
else if (depth == 0 && menu_active_category == 0 && active_category->active_item == active_category->num_items-1)
{
add_tween(DELAY, 1.0, &global_alpha, &inOutQuad, NULL);
g_extern.lifecycle_state &= ~(1ULL << MODE_GAME);
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING_FINISHED);
return -1;
}
break;

View File

@ -378,7 +378,7 @@ bool menu_iterate(void)
if (g_extern.lifecycle_state & (1ULL << MODE_MENU_PREINIT))
{
driver.menu->need_refresh = true;
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU_PREINIT);
rarch_main_set_state(RARCH_ACTION_STATE_MENU_PREINIT_FINISHED);
driver.menu->old_input_state |= 1ULL << RARCH_MENU_TOGGLE;
}

View File

@ -135,9 +135,13 @@ enum action_state
{
RARCH_ACTION_STATE_NONE = 0,
RARCH_ACTION_STATE_MENU_PREINIT,
RARCH_ACTION_STATE_MENU_PREINIT_FINISHED,
RARCH_ACTION_STATE_LOAD_CONTENT,
RARCH_ACTION_STATE_RUN_CONTENT,
RARCH_ACTION_STATE_STOP_CONTENT,
RARCH_ACTION_STATE_LOAD_CONTENT_FINISHED,
RARCH_ACTION_STATE_RUNNING,
RARCH_ACTION_STATE_RUNNING_FINISHED,
RARCH_ACTION_STATE_MENU_RUNNING,
RARCH_ACTION_STATE_MENU_RUNNING_FINISHED,
RARCH_ACTION_STATE_EXITSPAWN,
RARCH_ACTION_STATE_QUIT,
};

View File

@ -3292,15 +3292,27 @@ void rarch_main_set_state(unsigned cmd)
case RARCH_ACTION_STATE_MENU_PREINIT:
g_extern.lifecycle_state |= (1ULL << MODE_MENU_PREINIT);
break;
case RARCH_ACTION_STATE_MENU_PREINIT_FINISHED:
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU_PREINIT);
break;
case RARCH_ACTION_STATE_LOAD_CONTENT:
g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);
break;
case RARCH_ACTION_STATE_RUN_CONTENT:
case RARCH_ACTION_STATE_LOAD_CONTENT_FINISHED:
g_extern.lifecycle_state &= ~(1ULL << MODE_LOAD_GAME);
break;
case RARCH_ACTION_STATE_RUNNING:
g_extern.lifecycle_state |= (1ULL << MODE_GAME);
break;
case RARCH_ACTION_STATE_STOP_CONTENT:
case RARCH_ACTION_STATE_RUNNING_FINISHED:
g_extern.lifecycle_state &= ~(1ULL << MODE_GAME);
break;
case RARCH_ACTION_STATE_MENU_RUNNING:
g_extern.lifecycle_state |= (1ULL << MODE_MENU);
break;
case RARCH_ACTION_STATE_MENU_RUNNING_FINISHED:
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU);
break;
case RARCH_ACTION_STATE_EXITSPAWN:
g_extern.lifecycle_state |= (1ULL << MODE_EXITSPAWN);
break;
@ -3520,7 +3532,7 @@ void rarch_main_command(unsigned cmd)
rarch_main_set_state(RARCH_ACTION_STATE_QUIT);
break;
case RARCH_CMD_RESUME:
rarch_main_set_state(RARCH_ACTION_STATE_RUN_CONTENT);
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING);
break;
case RARCH_CMD_RESTART_RETROARCH:
#if defined(GEKKO) && defined(HW_RVL)
@ -3528,7 +3540,7 @@ void rarch_main_command(unsigned cmd)
SALAMANDER_FILE,
sizeof(g_extern.fullpath));
#endif
rarch_main_set_state(RARCH_ACTION_STATE_STOP_CONTENT);
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING_FINISHED);
rarch_main_set_state(RARCH_ACTION_STATE_EXITSPAWN);
break;
case RARCH_CMD_MENU_SAVE_CONFIG: