(Salamander) Reuse rarch_console_exec for Salamander

This commit is contained in:
Twinaphex 2012-07-28 18:26:30 +02:00
parent 9e3848e423
commit 7f269779ce
6 changed files with 43 additions and 67 deletions

View File

@ -8,7 +8,7 @@ include $(CELL_MK_DIR)/sdk.makedef.mk
STRIP = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-strip.exe STRIP = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-strip.exe
PPU_CFLAGS += -I. -D__CELLOS_LV2__ -DIS_SALAMANDER 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) ifeq ($(HAVE_LOGGER), 1)
PPU_CFLAGS += -DHAVE_LOGGER -Iconsole/logger PPU_CFLAGS += -DHAVE_LOGGER -Iconsole/logger

View File

@ -14,7 +14,7 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdint.h> #include <stdio.h>
#if defined(__CELLOS_LV2__) #if defined(__CELLOS_LV2__)
#include <cell/sysmodule.h> #include <cell/sysmodule.h>
@ -28,41 +28,42 @@
#endif #endif
#include "rarch_console_exec.h" #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", path);
{
RARCH_LOG("Attempt to load executable: [%s].\n", g_console.launch_app_on_exit);
#if defined(_XBOX) #if defined(_XBOX)
XLaunchNewImage(g_console.launch_app_on_exit, NULL); XLaunchNewImage(path, NULL);
#elif defined(__CELLOS_LV2__) #elif defined(__CELLOS_LV2__)
char spawn_data[256]; char spawn_data[256];
for(unsigned int i = 0; i < sizeof(spawn_data); ++i) for(unsigned int i = 0; i < sizeof(spawn_data); ++i)
spawn_data[i] = i & 0xff; spawn_data[i] = i & 0xff;
char spawn_data_size[16]; char spawn_data_size[16];
snprintf(spawn_data_size, sizeof(spawn_data_size), "%d", 256); snprintf(spawn_data_size, sizeof(spawn_data_size), "%d", 256);
const char * const spawn_argv[] = { const char * const spawn_argv[] = {
spawn_data_size, spawn_data_size,
"test argv for", "test argv for",
"sceNpDrmProcessExitSpawn2()", "sceNpDrmProcessExitSpawn2()",
NULL NULL
}; };
SceNpDrmKey * k_licensee = 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); 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)
{ 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); 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();
cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_NP);
cellSysmoduleUnloadModule(CELL_SYSMODULE_NET);
#else
RARCH_WARN("External loading of executables is not supported for this platform.\n");
#endif
} }
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
} }

View File

@ -17,6 +17,6 @@
#ifndef RARCH_CONSOLE_EXEC_H__ #ifndef RARCH_CONSOLE_EXEC_H__
#define RARCH_CONSOLE_EXEC_H__ #define RARCH_CONSOLE_EXEC_H__
void rarch_console_exec (void); void rarch_console_exec(const char *path);
#endif #endif

View File

@ -44,6 +44,8 @@
#define PATH_MAX 512 #define PATH_MAX 512
#endif #endif
#include "../rarch_console_exec.h"
#include "../../retroarch_logger.h" #include "../../retroarch_logger.h"
#include "../../file.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 main(int argc, char *argv[])
{ {
int ret;
#if defined(_XBOX) #if defined(_XBOX)
XINPUT_STATE state; XINPUT_STATE state;
@ -316,13 +317,8 @@ int main(int argc, char *argv[])
//normal executable loading path //normal executable loading path
init_settings(); init_settings();
} }
XLaunchNewImage(libretro_path, NULL);
RARCH_LOG("Launch libretro core: [%s] (return code: %x]).\n", libretro_path, ret);
#elif defined(__CELLOS_LV2__) #elif defined(__CELLOS_LV2__)
CellPadData pad_data; CellPadData pad_data;
char spawn_data[256], spawn_data_size[16];
SceNpDrmKey * k_licensee = NULL;
cellSysutilRegisterCallback(0, callback_sysutil_exit, NULL); cellSysutilRegisterCallback(0, callback_sysutil_exit, NULL);
@ -363,36 +359,12 @@ int main(int argc, char *argv[])
#ifdef HAVE_LOGGER #ifdef HAVE_LOGGER
logger_shutdown(); logger_shutdown();
#endif
#endif #endif
for(unsigned int i = 0; i < sizeof(spawn_data); ++i) rarch_console_exec(libretro_path);
spawn_data[i] = i & 0xff;
snprintf(spawn_data_size, sizeof(spawn_data_size), "%d", 256); #ifdef __CELLOS_LV2__
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);
cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME); cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME);
cellSysmoduleLoadModule(CELL_SYSMODULE_FS); cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
cellSysmoduleLoadModule(CELL_SYSMODULE_IO); cellSysmoduleLoadModule(CELL_SYSMODULE_IO);

View File

@ -368,7 +368,8 @@ begin_shutdown:
} }
#endif #endif
rarch_console_exec(); if(g_console.return_to_launcher)
rarch_console_exec(g_console.launch_app_on_exit);
return 1; return 1;
} }

View File

@ -177,7 +177,9 @@ begin_shutdown:
video_null.stop(); video_null.stop();
#endif #endif
input_xinput.free(NULL); input_xinput.free(NULL);
rarch_console_exec();
if(g_console.return_to_launcher)
rarch_console_exec(g_console.launch_app_on_exit);
return 0; return 0;
} }