2013-02-25 07:29:09 +01:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2013 - Daniel De Matteis
|
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <bps/bps.h>
|
2013-02-27 08:05:36 +01:00
|
|
|
|
2013-04-08 21:32:06 -04:00
|
|
|
#include "menu/rgui.h"
|
|
|
|
|
2013-02-27 08:05:36 +01:00
|
|
|
int rarch_main(int argc, char *argv[])
|
2013-02-25 07:29:09 +01:00
|
|
|
{
|
2013-02-27 08:05:36 +01:00
|
|
|
//Initialize bps
|
2013-04-19 13:31:51 -04:00
|
|
|
#ifndef HAVE_BB10
|
2013-02-27 08:05:36 +01:00
|
|
|
bps_initialize();
|
2013-02-25 17:34:19 +01:00
|
|
|
rarch_main_clear_state();
|
2013-05-11 02:05:05 +02:00
|
|
|
strlcpy(g_settings.libretro, "app/native/lib", sizeof(g_settings.libretro));
|
2013-04-19 13:31:51 -04:00
|
|
|
#endif
|
|
|
|
strlcpy(g_extern.config_path, "app/native/retroarch.cfg", sizeof(g_extern.config_path));
|
2013-03-24 20:42:09 -04:00
|
|
|
|
2013-03-24 01:00:00 +01:00
|
|
|
config_load();
|
|
|
|
|
2013-05-11 01:48:03 +02:00
|
|
|
if (g_settings.input.overlay[0] == '\0')
|
|
|
|
{
|
|
|
|
RARCH_LOG("Setting default overlay %s ...\n", "app/native/overlays/snes-landscape.cfg");
|
|
|
|
strlcpy(g_settings.input.overlay, "app/native/overlays/snes-landscape.cfg", sizeof(g_settings.input.overlay));
|
|
|
|
}
|
|
|
|
|
2013-02-25 17:34:19 +01:00
|
|
|
g_extern.verbose = true;
|
|
|
|
|
2013-03-23 12:21:30 -04:00
|
|
|
menu_init();
|
2013-05-11 01:28:04 +02:00
|
|
|
|
2013-04-28 16:38:13 +02:00
|
|
|
g_extern.lifecycle_mode_state |= (1ULL << MODE_LOAD_GAME);
|
2013-03-23 12:21:30 -04:00
|
|
|
|
2013-05-17 21:07:19 +02:00
|
|
|
#ifdef HAVE_BB10
|
|
|
|
if (!g_extern.libretro_dummy)
|
|
|
|
menu_rom_history_push_current();
|
|
|
|
#endif
|
|
|
|
|
2013-03-23 12:21:30 -04:00
|
|
|
for (;;)
|
|
|
|
{
|
2013-04-06 19:10:26 +02:00
|
|
|
if (g_extern.system.shutdown)
|
|
|
|
break;
|
2013-04-28 15:00:37 +02:00
|
|
|
else if (g_extern.lifecycle_mode_state & (1ULL << MODE_LOAD_GAME))
|
|
|
|
{
|
2013-04-28 16:38:13 +02:00
|
|
|
load_menu_game_prepare();
|
2013-04-28 15:00:37 +02:00
|
|
|
|
2013-04-28 16:38:13 +02:00
|
|
|
// If ROM load fails, we exit RetroArch. On console it might make more sense to go back to menu though ...
|
|
|
|
if (load_menu_game())
|
|
|
|
g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME);
|
|
|
|
else
|
2013-04-28 15:00:37 +02:00
|
|
|
{
|
2013-05-11 01:28:04 +02:00
|
|
|
#if defined(RARCH_CONSOLE) || defined(__BLACKBERRY_QNX__)
|
2013-04-28 16:38:13 +02:00
|
|
|
g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU);
|
|
|
|
#else
|
|
|
|
return 1;
|
2013-04-28 15:00:37 +02:00
|
|
|
#endif
|
2013-04-28 16:38:13 +02:00
|
|
|
}
|
2013-04-28 15:00:37 +02:00
|
|
|
|
|
|
|
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_LOAD_GAME);
|
|
|
|
}
|
2013-04-06 19:10:26 +02:00
|
|
|
else if (g_extern.lifecycle_mode_state & (1ULL << MODE_GAME))
|
2013-03-23 12:21:30 -04:00
|
|
|
{
|
|
|
|
while ((g_extern.is_paused && !g_extern.is_oneshot) ? rarch_main_idle_iterate() : rarch_main_iterate());
|
|
|
|
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME);
|
|
|
|
}
|
|
|
|
else if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU))
|
|
|
|
{
|
|
|
|
g_extern.lifecycle_mode_state |= 1ULL << MODE_MENU_PREINIT;
|
2013-04-06 19:10:26 +02:00
|
|
|
while (!g_extern.system.shutdown && menu_iterate());
|
2013-03-23 12:21:30 -04:00
|
|
|
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-04-06 19:10:26 +02:00
|
|
|
g_extern.system.shutdown = false;
|
|
|
|
|
2013-03-23 12:21:30 -04:00
|
|
|
menu_free();
|
2013-05-11 02:19:09 +02:00
|
|
|
|
2013-05-22 15:35:28 +02:00
|
|
|
if (g_extern.config_save_on_exit)
|
|
|
|
config_save_file(g_extern.config_path);
|
2013-05-11 02:19:09 +02:00
|
|
|
|
2013-03-23 12:21:30 -04:00
|
|
|
if (g_extern.main_is_init)
|
|
|
|
rarch_main_deinit();
|
2013-03-22 17:01:59 +01:00
|
|
|
|
2013-02-25 07:29:09 +01:00
|
|
|
rarch_deinit_msg_queue();
|
|
|
|
|
|
|
|
#ifdef PERF_TEST
|
|
|
|
rarch_perf_log();
|
|
|
|
#endif
|
|
|
|
|
2013-02-27 08:05:36 +01:00
|
|
|
error:
|
|
|
|
bps_shutdown();
|
|
|
|
|
2013-02-25 07:29:09 +01:00
|
|
|
return 0;
|
|
|
|
}
|