(RARCH_CONSOLE) One main() function to rule them all - PS3

port currently set up - callback system needs to be done
later for system/platform-specific functions
This commit is contained in:
twinaphex 2013-01-08 01:26:18 +01:00
parent fe62828fb1
commit c721ddd560
3 changed files with 139 additions and 115 deletions

View File

@ -377,7 +377,7 @@ MAIN
#elif defined(GEKKO)
#include "../../frontend/frontend_gx.c"
#elif defined(__CELLOS_LV2__)
#include "../../frontend/frontend_ps3.c"
#include "../../frontend/frontend_console.c"
#elif defined(PSP)
#include "../../frontend/frontend_psp.c"
#elif defined(ANDROID)

123
frontend/frontend_console.c Normal file
View File

@ -0,0 +1,123 @@
/* 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 <stdint.h>
#include "../boolean.h"
#include <stddef.h>
#include <string.h>
#include "../console/rmenu/rmenu.h"
#if defined(__CELLOS_LV2__)
#include "frontend_ps3.c"
#endif
int main(int argc, char *argv[])
{
system_init();
rarch_main_clear_state();
get_environment_settings(argc, argv);
config_set_defaults();
init_drivers_pre();
driver.input->init();
rarch_settings_set_default();
rarch_input_set_controls_default(driver.input);
rarch_config_load();
#ifdef HAVE_LIBRETRO_MANAGEMENT
char core_exe_path[PATH_MAX];
char path_prefix[PATH_MAX];
const char *extension = default_paths.executable_extension;
snprintf(path_prefix, sizeof(path_prefix), "%s/", default_paths.core_dir);
snprintf(core_exe_path, sizeof(core_exe_path), "%sCORE%s", path_prefix, extension);
if (path_file_exists(core_exe_path))
{
if (rarch_libretro_core_install(core_exe_path, path_prefix, path_prefix,
g_extern.config_path, extension))
{
RARCH_LOG("New default libretro core saved to config file: %s.\n", g_settings.libretro);
config_save_file(g_extern.config_path);
}
}
#endif
init_libretro_sym();
driver.input->post_init();
system_post_init();
driver.video->start();
menu_init();
system_process_args(argc, argv);
begin_loop:
if(g_extern.console.rmenu.mode == MODE_EMULATION)
{
driver.input->poll(NULL);
driver.video->set_aspect_ratio(driver.video_data, g_settings.video.aspect_ratio_idx);
while(rarch_main_iterate());
}
else if (g_extern.console.rmenu.mode == MODE_INIT)
{
if(g_extern.main_is_init)
rarch_main_deinit();
struct rarch_main_wrap args = {0};
args.verbose = g_extern.verbose;
args.config_path = g_extern.config_path;
args.sram_path = g_extern.console.main_wrap.state.default_sram_dir.enable ? g_extern.console.main_wrap.paths.default_sram_dir : NULL,
args.state_path = g_extern.console.main_wrap.state.default_savestate_dir.enable ? g_extern.console.main_wrap.paths.default_savestate_dir : NULL,
args.rom_path = g_extern.file_state.rom_path;
args.libretro_path = g_settings.libretro;
int init_ret = rarch_main_init_wrap(&args);
if (init_ret == 0)
RARCH_LOG("rarch_main_init succeeded.\n");
else
RARCH_ERR("rarch_main_init failed.\n");
}
else if(g_extern.console.rmenu.mode == MODE_MENU)
while(rmenu_iterate());
else
goto begin_shutdown;
goto begin_loop;
begin_shutdown:
config_save_file(g_extern.config_path);
if(g_extern.main_is_init)
rarch_main_deinit();
driver.input->free(NULL);
driver.video->stop();
menu_free();
system_deinit();
system_exitspawn();
return 1;
}

View File

@ -1,30 +1,8 @@
/* 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 <stdint.h>
#include "../boolean.h"
#include <stddef.h>
#include <string.h>
#include <sys/process.h>
#include "../ps3/sdk_defines.h"
#include "../ps3/ps3_input.h"
#include "../gfx/gl_common.h"
#include "../console/rarch_console.h"
#ifdef HAVE_RARCH_EXEC
@ -32,12 +10,9 @@
#endif
#include "../console/rarch_console_libretro_mgmt.h"
#include "../console/rarch_console_input.h"
#include "../console/rarch_console_config.h"
#include "../console/rarch_console_settings.h"
#include "../console/rarch_console_video.h"
#include "../conf/config_file.h"
#include "../conf/config_file_macros.h"
#include "../general.h"
#include "../file.h"
@ -54,8 +29,6 @@
static uint8_t np_pool[NP_POOL_SIZE];
#endif
int rarch_main(int argc, char *argv[]);
SYS_PROCESS_PARAM(1001, 0x200000)
#undef main
@ -223,7 +196,7 @@ static void get_environment_settings(int argc, char *argv[])
g_extern.verbose = false;
}
int main(int argc, char *argv[])
static void system_init(void)
{
#ifdef HAVE_SYSUTILS
RARCH_LOG("Registering system utility callback...\n");
@ -261,42 +234,10 @@ int main(int argc, char *argv[])
#ifndef __PSL1GHT__
sceNpInit(NP_POOL_SIZE, np_pool);
#endif
}
rarch_main_clear_state();
get_environment_settings(argc, argv);
config_set_defaults();
init_drivers_pre();
driver.input->init();
rarch_settings_set_default();
rarch_input_set_controls_default(driver.input);
rarch_config_load();
#ifdef HAVE_LIBRETRO_MANAGEMENT
char core_exe_path[PATH_MAX];
char path_prefix[PATH_MAX];
const char *extension = default_paths.executable_extension;
snprintf(path_prefix, sizeof(path_prefix), "%s/", default_paths.core_dir);
snprintf(core_exe_path, sizeof(core_exe_path), "%sCORE%s", path_prefix, extension);
if (path_file_exists(core_exe_path))
{
if (rarch_libretro_core_install(core_exe_path, path_prefix, path_prefix,
g_extern.config_path, extension))
{
RARCH_LOG("New default libretro core saved to config file: %s.\n", g_settings.libretro);
config_save_file(g_extern.config_path);
}
}
#endif
init_libretro_sym();
driver.input->post_init();
static void system_post_init(void)
{
#if (CELL_SDK_VERSION > 0x340000) && !defined(__PSL1GHT__)
if (g_extern.console.screen.state.screenshots.enable)
{
@ -318,15 +259,14 @@ int main(int argc, char *argv[])
#endif
#endif
driver.video->start();
#ifdef HAVE_OSKUTIL
oskutil_params *osk = &g_extern.console.misc.oskutil_handle;
oskutil_init(osk, 0);
#endif
}
menu_init();
static void system_process_args(int argc, char *argv[])
{
switch(g_extern.console.external_launch.support)
{
case EXTERN_LAUNCHER_SALAMANDER:
@ -342,53 +282,13 @@ int main(int argc, char *argv[])
default:
break;
}
}
begin_loop:
if(g_extern.console.rmenu.mode == MODE_EMULATION)
{
driver.input->poll(NULL);
driver.video->set_aspect_ratio(driver.video_data, g_settings.video.aspect_ratio_idx);
while(rarch_main_iterate());
}
else if (g_extern.console.rmenu.mode == MODE_INIT)
{
if(g_extern.main_is_init)
rarch_main_deinit();
struct rarch_main_wrap args = {0};
args.verbose = g_extern.verbose;
args.config_path = g_extern.config_path;
args.sram_path = g_extern.console.main_wrap.state.default_sram_dir.enable ? g_extern.console.main_wrap.paths.default_sram_dir : NULL,
args.state_path = g_extern.console.main_wrap.state.default_savestate_dir.enable ? g_extern.console.main_wrap.paths.default_savestate_dir : NULL,
args.rom_path = g_extern.file_state.rom_path;
args.libretro_path = g_settings.libretro;
int init_ret = rarch_main_init_wrap(&args);
if (init_ret == 0)
RARCH_LOG("rarch_main_init succeeded.\n");
else
RARCH_ERR("rarch_main_init failed.\n");
}
else if(g_extern.console.rmenu.mode == MODE_MENU)
while(rmenu_iterate());
else
goto begin_shutdown;
goto begin_loop;
begin_shutdown:
config_save_file(g_extern.config_path);
if(g_extern.main_is_init)
rarch_main_deinit();
driver.input->free(NULL);
driver.video->stop();
menu_free();
static void system_deinit(void)
{
#ifdef HAVE_OSKUTIL
oskutil_params *osk = &g_extern.console.misc.oskutil_handle;
if(osk)
oskutil_unload(osk);
#endif
@ -431,11 +331,12 @@ begin_shutdown:
RARCH_ERR("System cache partition could not be cleared on exit.\n");
}
#endif
}
static void system_exitspawn(void)
{
#ifdef HAVE_RARCH_EXEC
if(g_extern.console.external_launch.enable)
rarch_console_exec(g_extern.console.external_launch.launch_app);
#endif
return 1;
}