From 7f269779ce88faa0d3fec8fbdaad32415f051ba9 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 28 Jul 2012 18:26:30 +0200 Subject: [PATCH] (Salamander) Reuse rarch_console_exec for Salamander --- Makefile.ps3.salamander | 2 +- console/rarch_console_exec.c | 61 ++++++++++++++++++------------------ console/rarch_console_exec.h | 2 +- console/salamander/main.c | 38 +++------------------- ps3/frontend/main.c | 3 +- xdk/frontend/main.c | 4 ++- 6 files changed, 43 insertions(+), 67 deletions(-) diff --git a/Makefile.ps3.salamander b/Makefile.ps3.salamander index e3acc41ba6..a5e4b5c5ce 100644 --- a/Makefile.ps3.salamander +++ b/Makefile.ps3.salamander @@ -8,7 +8,7 @@ include $(CELL_MK_DIR)/sdk.makedef.mk STRIP = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-strip.exe PPU_CFLAGS += -I. -D__CELLOS_LV2__ -DIS_SALAMANDER -PPU_SRCS = console/salamander/main.c file_path.c compat/compat.c conf/config_file.c +PPU_SRCS = console/salamander/main.c console/rarch_console_exec.c file_path.c compat/compat.c conf/config_file.c ifeq ($(HAVE_LOGGER), 1) PPU_CFLAGS += -DHAVE_LOGGER -Iconsole/logger diff --git a/console/rarch_console_exec.c b/console/rarch_console_exec.c index 716e7f35b7..5f2e35673d 100644 --- a/console/rarch_console_exec.c +++ b/console/rarch_console_exec.c @@ -14,7 +14,7 @@ * If not, see . */ -#include +#include #if defined(__CELLOS_LV2__) #include @@ -28,41 +28,42 @@ #endif #include "rarch_console_exec.h" +#include "../retroarch_logger.h" -void rarch_console_exec (void) +void rarch_console_exec(const char *path) { - if(g_console.return_to_launcher) - { - RARCH_LOG("Attempt to load executable: [%s].\n", g_console.launch_app_on_exit); + RARCH_LOG("Attempt to load executable: [%s].\n", path); #if defined(_XBOX) - XLaunchNewImage(g_console.launch_app_on_exit, NULL); + XLaunchNewImage(path, NULL); #elif defined(__CELLOS_LV2__) - char spawn_data[256]; - for(unsigned int i = 0; i < sizeof(spawn_data); ++i) - spawn_data[i] = i & 0xff; + char spawn_data[256]; + for(unsigned int i = 0; i < sizeof(spawn_data); ++i) + spawn_data[i] = i & 0xff; - char spawn_data_size[16]; - snprintf(spawn_data_size, sizeof(spawn_data_size), "%d", 256); + char spawn_data_size[16]; + snprintf(spawn_data_size, sizeof(spawn_data_size), "%d", 256); - const char * const spawn_argv[] = { - spawn_data_size, - "test argv for", - "sceNpDrmProcessExitSpawn2()", - NULL - }; + const char * const spawn_argv[] = { + spawn_data_size, + "test argv for", + "sceNpDrmProcessExitSpawn2()", + NULL + }; - SceNpDrmKey * k_licensee = NULL; - int ret = sceNpDrmProcessExitSpawn2(k_licensee, g_console.launch_app_on_exit, (const char** const)spawn_argv, NULL, (sys_addr_t)spawn_data, 256, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); - if(ret < 0) - { - RARCH_WARN("SELF file is not of NPDRM type, trying another approach to boot it...\n"); - sys_game_process_exitspawn(g_console.launch_app_on_exit, NULL, NULL, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); - } - sceNpTerm(); - cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_NP); - cellSysmoduleUnloadModule(CELL_SYSMODULE_NET); -#else - RARCH_WARN("External loading of executables is not supported for this platform.\n"); -#endif + SceNpDrmKey * k_licensee = NULL; + int ret = sceNpDrmProcessExitSpawn2(k_licensee, path, (const char** const)spawn_argv, NULL, (sys_addr_t)spawn_data, 256, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); + + if(ret < 0) + { + RARCH_WARN("SELF file is not of NPDRM type, trying another approach to boot it...\n"); + sys_game_process_exitspawn(path, NULL, NULL, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); } + + sceNpTerm(); + sys_net_finalize_network(); + cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_NP); + cellSysmoduleUnloadModule(CELL_SYSMODULE_NET); +#else + RARCH_WARN("External loading of executables is not supported for this platform.\n"); +#endif } diff --git a/console/rarch_console_exec.h b/console/rarch_console_exec.h index 279dcec77c..8ad0c7a28f 100644 --- a/console/rarch_console_exec.h +++ b/console/rarch_console_exec.h @@ -17,6 +17,6 @@ #ifndef RARCH_CONSOLE_EXEC_H__ #define RARCH_CONSOLE_EXEC_H__ -void rarch_console_exec (void); +void rarch_console_exec(const char *path); #endif diff --git a/console/salamander/main.c b/console/salamander/main.c index 294b7b3a83..590612ce5c 100644 --- a/console/salamander/main.c +++ b/console/salamander/main.c @@ -44,6 +44,8 @@ #define PATH_MAX 512 #endif +#include "../rarch_console_exec.h" + #include "../../retroarch_logger.h" #include "../../file.h" @@ -294,7 +296,6 @@ static void callback_sysutil_exit(uint64_t status, uint64_t param, void *userdat int main(int argc, char *argv[]) { - int ret; #if defined(_XBOX) XINPUT_STATE state; @@ -316,13 +317,8 @@ int main(int argc, char *argv[]) //normal executable loading path init_settings(); } - - XLaunchNewImage(libretro_path, NULL); - RARCH_LOG("Launch libretro core: [%s] (return code: %x]).\n", libretro_path, ret); #elif defined(__CELLOS_LV2__) CellPadData pad_data; - char spawn_data[256], spawn_data_size[16]; - SceNpDrmKey * k_licensee = NULL; cellSysutilRegisterCallback(0, callback_sysutil_exit, NULL); @@ -363,36 +359,12 @@ int main(int argc, char *argv[]) #ifdef HAVE_LOGGER logger_shutdown(); +#endif #endif - for(unsigned int i = 0; i < sizeof(spawn_data); ++i) - spawn_data[i] = i & 0xff; + rarch_console_exec(libretro_path); - snprintf(spawn_data_size, sizeof(spawn_data_size), "%d", 256); - - const char * const spawn_argv[] = { - spawn_data_size, - "test argv for", - "sceNpDrmProcessExitSpawn2()", - NULL - }; - - ret = sceNpDrmProcessExitSpawn2(k_licensee, libretro_path, (const char** const)spawn_argv, NULL, (sys_addr_t)spawn_data, 256, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); - RARCH_LOG("Launch libretro core: [%s] (return code: %x]).\n", libretro_path, ret); - - if(ret < 0) - { - RARCH_LOG("Executable file is not of NPDRM type, trying another approach to boot it...\n"); - sys_game_process_exitspawn2(libretro_path, NULL, NULL, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); - } - - sceNpTerm(); - - sys_net_finalize_network(); - - cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_NP); - - cellSysmoduleUnloadModule(CELL_SYSMODULE_NET); +#ifdef __CELLOS_LV2__ cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME); cellSysmoduleLoadModule(CELL_SYSMODULE_FS); cellSysmoduleLoadModule(CELL_SYSMODULE_IO); diff --git a/ps3/frontend/main.c b/ps3/frontend/main.c index 11790711b6..d14faa7fa1 100644 --- a/ps3/frontend/main.c +++ b/ps3/frontend/main.c @@ -368,7 +368,8 @@ begin_shutdown: } #endif - rarch_console_exec(); + if(g_console.return_to_launcher) + rarch_console_exec(g_console.launch_app_on_exit); return 1; } diff --git a/xdk/frontend/main.c b/xdk/frontend/main.c index 2fdbe327e1..e4444be639 100644 --- a/xdk/frontend/main.c +++ b/xdk/frontend/main.c @@ -177,7 +177,9 @@ begin_shutdown: video_null.stop(); #endif input_xinput.free(NULL); - rarch_console_exec(); + + if(g_console.return_to_launcher) + rarch_console_exec(g_console.launch_app_on_exit); return 0; }