diff --git a/dynamic.c b/dynamic.c index 8ff20e6480..74224bfb62 100644 --- a/dynamic.c +++ b/dynamic.c @@ -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) diff --git a/frontend/frontend.c b/frontend/frontend.c index af0883b3b7..88029715cf 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -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); diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 46982951a7..1240ab46f0 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -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; diff --git a/frontend/menu/backend/menu_lakka_backend.c b/frontend/menu/backend/menu_lakka_backend.c index c7b46e5f10..bec56acabc 100644 --- a/frontend/menu/backend/menu_lakka_backend.c +++ b/frontend/menu/backend/menu_lakka_backend.c @@ -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; diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index 536267eb0e..e8886934b1 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -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; } diff --git a/general.h b/general.h index bba17b6dee..4ab3cfe4f1 100644 --- a/general.h +++ b/general.h @@ -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, }; diff --git a/retroarch.c b/retroarch.c index 26ae0ce4c6..656fd8c4f4 100644 --- a/retroarch.c +++ b/retroarch.c @@ -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: