Standardize frontends

This commit is contained in:
twinaphex 2013-04-06 19:10:26 +02:00
parent fde1ea7193
commit 129d54a478
3 changed files with 66 additions and 64 deletions

View File

@ -41,7 +41,9 @@ int rarch_main(int argc, char *argv[])
for (;;) for (;;)
{ {
if (g_extern.lifecycle_mode_state & (1ULL << MODE_GAME)) if (g_extern.system.shutdown)
break;
else if (g_extern.lifecycle_mode_state & (1ULL << MODE_GAME))
{ {
while ((g_extern.is_paused && !g_extern.is_oneshot) ? rarch_main_idle_iterate() : rarch_main_iterate()); while ((g_extern.is_paused && !g_extern.is_oneshot) ? rarch_main_idle_iterate() : rarch_main_iterate());
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME); g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME);
@ -54,16 +56,12 @@ int rarch_main(int argc, char *argv[])
struct rarch_main_wrap args = {0}; struct rarch_main_wrap args = {0};
args.verbose = g_extern.verbose; args.verbose = g_extern.verbose;
args.config_path = *g_extern.config_path ? g_extern.config_path : NULL;
args.sram_path = (g_extern.lifecycle_mode_state & (1ULL << MODE_LOAD_GAME_SRAM_DIR_ENABLE)) ? g_extern.console.main_wrap.default_sram_dir : NULL; args.sram_path = (g_extern.lifecycle_mode_state & (1ULL << MODE_LOAD_GAME_SRAM_DIR_ENABLE)) ? g_extern.console.main_wrap.default_sram_dir : NULL;
args.state_path = (g_extern.lifecycle_mode_state & (1ULL << MODE_LOAD_GAME_STATE_DIR_ENABLE)) ? g_extern.console.main_wrap.default_savestate_dir : NULL; args.state_path = (g_extern.lifecycle_mode_state & (1ULL << MODE_LOAD_GAME_STATE_DIR_ENABLE)) ? g_extern.console.main_wrap.default_savestate_dir : NULL;
args.rom_path = g_extern.fullpath; args.rom_path = g_extern.fullpath;
args.libretro_path = g_settings.libretro; args.libretro_path = g_settings.libretro;
if (path_file_exists(g_extern.config_path))
args.config_path = g_extern.config_path;
else
args.config_path = NULL;
int init_ret = rarch_main_init_wrap(&args); int init_ret = rarch_main_init_wrap(&args);
if (init_ret == 0) if (init_ret == 0)
{ {
@ -81,13 +79,15 @@ int rarch_main(int argc, char *argv[])
else if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU)) else if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU))
{ {
g_extern.lifecycle_mode_state |= 1ULL << MODE_MENU_PREINIT; g_extern.lifecycle_mode_state |= 1ULL << MODE_MENU_PREINIT;
while (menu_iterate()); while (!g_extern.system.shutdown && menu_iterate());
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU); g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU);
} }
else else
break; break;
} }
g_extern.system.shutdown = false;
menu_free(); menu_free();
if (g_extern.main_is_init) if (g_extern.main_is_init)
rarch_main_deinit(); rarch_main_deinit();

View File

@ -144,8 +144,11 @@ int rarch_main(int argc, char *argv[])
system_process_args(argc, argv); system_process_args(argc, argv);
begin_loop: for (;;)
if(g_extern.lifecycle_mode_state & (1ULL << MODE_GAME)) {
if (g_extern.system.shutdown)
break;
else if (g_extern.lifecycle_mode_state & (1ULL << MODE_GAME))
{ {
driver.input->poll(NULL); driver.input->poll(NULL);
@ -163,23 +166,20 @@ begin_loop:
} }
else if (g_extern.lifecycle_mode_state & (1ULL << MODE_INIT)) else if (g_extern.lifecycle_mode_state & (1ULL << MODE_INIT))
{ {
if(g_extern.main_is_init) if (g_extern.main_is_init)
rarch_main_deinit(); rarch_main_deinit();
struct rarch_main_wrap args = {0}; struct rarch_main_wrap args = {0};
args.verbose = g_extern.verbose; args.verbose = g_extern.verbose;
args.config_path = *g_extern.config_path ? g_extern.config_path : NULL;
args.sram_path = (g_extern.lifecycle_mode_state & (1ULL << MODE_LOAD_GAME_SRAM_DIR_ENABLE)) ? g_extern.console.main_wrap.default_sram_dir : NULL; args.sram_path = (g_extern.lifecycle_mode_state & (1ULL << MODE_LOAD_GAME_SRAM_DIR_ENABLE)) ? g_extern.console.main_wrap.default_sram_dir : NULL;
args.state_path = (g_extern.lifecycle_mode_state & (1ULL << MODE_LOAD_GAME_STATE_DIR_ENABLE)) ? g_extern.console.main_wrap.default_savestate_dir : NULL; args.state_path = (g_extern.lifecycle_mode_state & (1ULL << MODE_LOAD_GAME_STATE_DIR_ENABLE)) ? g_extern.console.main_wrap.default_savestate_dir : NULL;
args.rom_path = g_extern.fullpath; args.rom_path = g_extern.fullpath;
args.libretro_path = g_settings.libretro; args.libretro_path = g_settings.libretro;
if (path_file_exists(g_extern.config_path)) int init_ret = rarch_main_init_wrap(&args);
args.config_path = g_extern.config_path; if (init_ret == 0)
else
args.config_path = NULL;
if (rarch_main_init_wrap(&args) == 0)
{ {
RARCH_LOG("rarch_main_init succeeded.\n"); RARCH_LOG("rarch_main_init succeeded.\n");
g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME); g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME);
@ -190,28 +190,30 @@ begin_loop:
g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU); g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU);
msg_queue_push(g_extern.msg_queue, "ERROR - An error occurred during ROM loading.", 1, 180); msg_queue_push(g_extern.msg_queue, "ERROR - An error occurred during ROM loading.", 1, 180);
} }
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_INIT); g_extern.lifecycle_mode_state &= ~(1ULL << MODE_INIT);
} }
else if(g_extern.lifecycle_mode_state & (1ULL << MODE_MENU)) else if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU))
{ {
g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU_PREINIT); g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU_PREINIT);
while (menu_iterate()); while (!g_extern.system.shutdown && menu_iterate());
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU); g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU);
} }
else else
goto begin_shutdown; break;
}
goto begin_loop; g_extern.system.shutdown = false;
menu_free();
begin_shutdown:
config_save_file(g_extern.config_path); config_save_file(g_extern.config_path);
system_deinit_save(); system_deinit_save();
if(g_extern.main_is_init) if (g_extern.main_is_init)
rarch_main_deinit(); rarch_main_deinit();
menu_free();
global_uninit_drivers(); global_uninit_drivers();
#ifdef PERF_TEST #ifdef PERF_TEST
@ -219,6 +221,7 @@ begin_shutdown:
#endif #endif
system_deinit(); system_deinit();
if (g_extern.lifecycle_mode_state & (1ULL << MODE_EXITSPAWN)) if (g_extern.lifecycle_mode_state & (1ULL << MODE_EXITSPAWN))
system_exitspawn(); system_exitspawn();

View File

@ -98,9 +98,7 @@ void* rarch_main_ios(void* args)
for (;;) for (;;)
{ {
if (g_extern.system.shutdown) if (g_extern.system.shutdown)
{
break; break;
}
else if (g_extern.lifecycle_mode_state & (1ULL << MODE_GAME)) else if (g_extern.lifecycle_mode_state & (1ULL << MODE_GAME))
{ {
while ((g_extern.is_paused && !g_extern.is_oneshot) ? rarch_main_idle_iterate() : rarch_main_iterate()) while ((g_extern.is_paused && !g_extern.is_oneshot) ? rarch_main_idle_iterate() : rarch_main_iterate())
@ -132,6 +130,7 @@ void* rarch_main_ios(void* args)
{ {
RARCH_ERR("rarch_main_init() failed.\n"); RARCH_ERR("rarch_main_init() failed.\n");
g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU); g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU);
msg_queue_push(g_extern.msg_queue, "ERROR - An error occurred during ROM loading.", 1, 180);
} }
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_INIT); g_extern.lifecycle_mode_state &= ~(1ULL << MODE_INIT);