Merge pull request #732 from aliaspider/master

(PSP) implemented salamander and added support for switching between cores.
This commit is contained in:
Twinaphex 2014-06-05 02:03:02 +02:00
commit 77086bbf6c
9 changed files with 191 additions and 53 deletions

View File

@ -20,7 +20,7 @@ RARCH_DEFINES = -DPSP -D_MIPS_ARCH_ALLEGREX1 -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_Z
LIBDIR = LIBDIR =
LDFLAGS = LDFLAGS =
LIBS = -lretro_psp1 -lstdc++ -lpspgu -lpspgum -lm -lpspaudio -lpspfpu -lpsppower -lpsprtc LIBS = -lretro_psp1 -lstdc++ -lpspgu -lpspgum -lm -lpspaudio -lpspfpu -lpsppower -lpsprtc
ifeq ($(HAVE_THREADS), 1) ifeq ($(HAVE_THREADS), 1)
RARCH_DEFINES += -DHAVE_THREADS RARCH_DEFINES += -DHAVE_THREADS
@ -31,7 +31,7 @@ ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER CFLAGS += -DHAVE_FILE_LOGGER
endif endif
ifeq ($(HAVE_KERNEL_RX), 1) ifeq ($(HAVE_KERNEL_PRX), 1)
CFLAGS += -DHAVE_KERNEL_PRX CFLAGS += -DHAVE_KERNEL_PRX
endif endif
@ -41,7 +41,7 @@ CFLAGS += $(RARCH_DEFINES)
EXTRA_TARGETS = EBOOT.PBP EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = RetroArch PSP1 PSP_EBOOT_TITLE = RetroArch PSP1
PSP_OBJECTS = griffin/griffin.o psp1/kernelFunctions.o PSP_OBJECTS = griffin/griffin.o psp1/kernel_functions.o
OBJS = $(PSP_OBJECTS) OBJS = $(PSP_OBJECTS)

34
Makefile.psp1.salamander Normal file
View File

@ -0,0 +1,34 @@
BUILD_PRX = 1
DEBUG = 0
TARGET = retroarchpsp_salamander
ifeq ($(DEBUG), 1)
OPTIMIZE_LV := -O0 -g
else
OPTIMIZE_LV := -O2 -g
endif
INCDIR = $(PSPPATH)/include
CFLAGS = $(OPTIMIZE_LV) -G0 -std=gnu99 -ffast-math
ASFLAGS = $(CFLAGS)
RARCH_DEFINES = -DPSP -DIS_SALAMANDER -DRARCH_CONSOLE -DRARCH_INTERNAL
LIBDIR =
LDFLAGS =
LIBS = -lstdc++ -lm
ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER
endif
CFLAGS += $(RARCH_DEFINES)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = RetroArch PSP1
OBJS = frontend/frontend_salamander.o frontend/frontend_context.o frontend/platform/platform_null.o file_path.o compat/compat.o conf/config_file.o psp1/kernel_functions.o
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

View File

@ -26,24 +26,56 @@
#include <string.h> #include <string.h>
#include "../../psp/sdk_defines.h" #include "../../psp/sdk_defines.h"
#include "../../file.h"
#if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER)
#include "../../psp1/kernel_functions.h"
#endif
PSP_MODULE_INFO("RetroArch PSP", 0, 1, 1); PSP_MODULE_INFO("RetroArch PSP", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER|THREAD_ATTR_VFPU); PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER|THREAD_ATTR_VFPU);
PSP_HEAP_SIZE_MAX(); PSP_HEAP_SIZE_MAX();
static int exit_callback(int arg1, int arg2, void *common) char eboot_path[512];
#ifdef IS_SALAMANDER
#include "../../file_ext.h"
char libretro_path[512];
static void find_and_set_first_file(char *path, size_t sizeof_path, const char *ext);
static void frontend_psp_salamander_init(void)
{ {
g_extern.verbose = false; //normal executable loading path
char tmp_str[PATH_MAX];
bool config_file_exists = false;
#ifdef HAVE_FILE_LOGGER if (path_file_exists(default_paths.config_path))
if (g_extern.log_file) config_file_exists = true;
fclose(g_extern.log_file);
g_extern.log_file = NULL;
#endif
sceKernelExitGame(); if (config_file_exists)
return 0; {
config_file_t * conf = config_file_new(default_paths.config_path);
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
config_file_free(conf);
strlcpy(libretro_path, tmp_str, sizeof(libretro_path));
}
if (!config_file_exists || !strcmp(libretro_path, ""))
find_and_set_first_file(libretro_path, sizeof(libretro_path), EXT_EXECUTABLES);
else
RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path);
if (!config_file_exists)
{
config_file_t *new_conf = config_file_new(NULL);
config_set_string(new_conf, "libretro_path", libretro_path);
config_file_write(new_conf, default_paths.config_path);
config_file_free(new_conf);
}
} }
#endif
static void frontend_psp_get_environment_settings(int *argc, char *argv[], static void frontend_psp_get_environment_settings(int *argc, char *argv[],
void *args, void *params_data) void *args, void *params_data)
@ -59,6 +91,8 @@ static void frontend_psp_get_environment_settings(int *argc, char *argv[],
#endif #endif
#endif #endif
strlcpy(eboot_path, argv[0], sizeof(eboot_path));
fill_pathname_basedir(default_paths.port_dir, argv[0], sizeof(default_paths.port_dir)); fill_pathname_basedir(default_paths.port_dir, argv[0], sizeof(default_paths.port_dir));
RARCH_LOG("port dir: [%s]\n", default_paths.port_dir); RARCH_LOG("port dir: [%s]\n", default_paths.port_dir);
@ -97,6 +131,33 @@ static void frontend_psp_get_environment_settings(int *argc, char *argv[],
} }
} }
static void frontend_psp_deinit(void *data)
{
(void)data;
#ifndef IS_SALAMANDER
g_extern.verbose = false;
#endif
#ifdef HAVE_FILE_LOGGER
if (g_extern.log_file)
fclose(g_extern.log_file);
g_extern.log_file = NULL;
#endif
}
static void frontend_psp_shutdown(bool unused)
{
(void)unused;
sceKernelExitGame();
}
static int exit_callback(int arg1, int arg2, void *common)
{
frontend_psp_deinit(NULL);
frontend_psp_shutdown(false);
return 0;
}
int callback_thread(SceSize args, void *argp) int callback_thread(SceSize args, void *argp)
{ {
int cbid = sceKernelCreateCallback("Exit callback", exit_callback, NULL); int cbid = sceKernelCreateCallback("Exit callback", exit_callback, NULL);
@ -118,6 +179,7 @@ static int setup_callback(void)
static void frontend_psp_init(void *data) static void frontend_psp_init(void *data)
{ {
#ifndef IS_SALAMANDER
(void)data; (void)data;
//initialize debug screen //initialize debug screen
pspDebugScreenInit(); pspDebugScreenInit();
@ -127,16 +189,57 @@ static void frontend_psp_init(void *data)
pspFpuSetEnable(0);//disable FPU exceptions pspFpuSetEnable(0);//disable FPU exceptions
scePowerSetClockFrequency(333,333,166); scePowerSetClockFrequency(333,333,166);
#endif
#ifdef HAVE_KERNEL_PRX #if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER)
pspSdkLoadStartModule("kernelFunctions.prx", PSP_MEMORY_PARTITION_KERNEL); pspSdkLoadStartModule("kernel_functions.prx", PSP_MEMORY_PARTITION_KERNEL);
#endif #endif
} }
static void frontend_psp_deinit(void *data)
static void frontend_psp_exec(const char *path, bool should_load_game)
{ {
(void)data; #if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER)
sceKernelExitGame();
char argp[512];
SceSize args = 0;
argp[0] = '\0';
strlcpy(argp, eboot_path, sizeof(argp));
args = strlen(argp) + 1;
#ifndef IS_SALAMANDER
if (should_load_game && g_extern.fullpath[0] != '\0')
{
argp[args] = '\0';
strlcat(argp + args, g_extern.fullpath, sizeof(argp) - args);
args += strlen(argp + args) + 1;
}
#endif
RARCH_LOG("Attempt to load executable: [%s].\n", path);
exitspawn_kernel(path, args, argp);
#endif
}
static void frontend_psp_exitspawn(void)
{
#ifdef IS_SALAMANDER
frontend_psp_exec(libretro_path, false);
#else
char core_launch[256];
strlcpy(core_launch, g_settings.libretro, sizeof(core_launch));
bool should_load_game = false;
if (g_extern.lifecycle_state & (1ULL << MODE_EXITSPAWN_START_GAME))
should_load_game = true;
frontend_psp_exec(core_launch, should_load_game);
#endif
} }
static int frontend_psp_get_rating(void) static int frontend_psp_get_rating(void)
@ -148,14 +251,14 @@ const frontend_ctx_driver_t frontend_ctx_psp = {
frontend_psp_get_environment_settings, /* get_environment_settings */ frontend_psp_get_environment_settings, /* get_environment_settings */
frontend_psp_init, /* init */ frontend_psp_init, /* init */
frontend_psp_deinit, /* deinit */ frontend_psp_deinit, /* deinit */
NULL, /* exitspawn */ frontend_psp_exitspawn, /* exitspawn */
NULL, /* process_args */ NULL, /* process_args */
NULL, /* process_events */ NULL, /* process_events */
NULL, /* exec */ frontend_psp_exec, /* exec */
NULL, /* shutdown */ frontend_psp_shutdown, /* shutdown */
frontend_psp_get_rating, /* get_rating */ frontend_psp_get_rating, /* get_rating */
"psp", "psp",
#ifdef IS_SALAMANDER #ifdef IS_SALAMANDER
NULL, frontend_psp_salamander_init,
#endif #endif
}; };

View File

@ -31,7 +31,7 @@
#include "../libretro.h" #include "../libretro.h"
#include "../general.h" #include "../general.h"
#ifdef HAVE_KERNEL_PRX #ifdef HAVE_KERNEL_PRX
#include "../psp1/kernelFunctions.h" #include "../psp1/kernel_functions.h"
#endif #endif
enum { enum {
@ -132,7 +132,7 @@ static void psp_input_poll(void *data)
sceCtrlSetSamplingMode(DEFAULT_SAMPLING_MODE); sceCtrlSetSamplingMode(DEFAULT_SAMPLING_MODE);
ret = CtrlPeekBufferPositive(0, &state_tmp, 1); ret = CtrlPeekBufferPositive(0, &state_tmp, 1);
#ifdef HAVE_KERNEL_PRX #ifdef HAVE_KERNEL_PRX
state_tmp.Buttons = (state_tmp.Buttons&0x0000FFFF)|(readSystemButtons()&0xFFFF0000); state_tmp.Buttons = (state_tmp.Buttons&0x0000FFFF)|(read_system_buttons()&0xFFFF0000);
#endif #endif
(void)ret; (void)ret;

View File

@ -1,4 +1,4 @@
TARGET = kernelFunctions TARGET = kernel_functions
OBJS = main.o OBJS = main.o
PSP_FW_VERSION = 150 PSP_FW_VERSION = 150

View File

@ -1,15 +0,0 @@
#ifndef SYSTEMBUTTONS_PRX_H
#define SYSTEMBUTTONS_PRX_H
#ifdef __cplusplus
extern "C" {
#endif
unsigned int readSystemButtons(void);
void loadGame( const char* fileName, void * argp);
#ifdef __cplusplus
}
#endif
#endif /* SYSTEMBUTTONS_PRX_H */

View File

@ -8,9 +8,9 @@ PSP_EXPORT_FUNC_HASH(module_start)
PSP_EXPORT_VAR_HASH(module_info) PSP_EXPORT_VAR_HASH(module_info)
PSP_EXPORT_END PSP_EXPORT_END
PSP_EXPORT_START(kernelFunctions, 0, 0x4001) PSP_EXPORT_START(kernel_functions, 0, 0x4001)
PSP_EXPORT_FUNC(readSystemButtons) PSP_EXPORT_FUNC(read_system_buttons)
PSP_EXPORT_FUNC(loadGame) PSP_EXPORT_FUNC(exitspawn_kernel)
PSP_EXPORT_END PSP_EXPORT_END
PSP_END_EXPORTS PSP_END_EXPORTS

View File

@ -0,0 +1,17 @@
#ifndef KERNEL_FUNCTIONS_PRX_H
#define KERNEL_FUNCTIONS_PRX_H
#include <pspkerneltypes.h>
#ifdef __cplusplus
extern "C" {
#endif
unsigned int read_system_buttons(void);
void exitspawn_kernel( const char* fileName, SceSize args, void * argp);
#ifdef __cplusplus
}
#endif
#endif /* SYSTEMBUTTONS_PRX_H */

View File

@ -7,15 +7,15 @@
#include <pspthreadman_kernel.h> #include <pspthreadman_kernel.h>
#include <string.h> #include <string.h>
PSP_MODULE_INFO("kernelFunctions", PSP_MODULE_KERNEL, 0, 0); PSP_MODULE_INFO("kernel_functions", PSP_MODULE_KERNEL, 0, 0);
PSP_MAIN_THREAD_ATTR(0); PSP_MAIN_THREAD_ATTR(0);
static volatile int thread_active; static volatile int thread_active;
static unsigned int buttons; static unsigned int buttons;
static SceUID main_thread; static SceUID main_thread_id;
static int mainThread(SceSize args, void *argp) static int main_thread(SceSize args, void *argp)
{ {
SceCtrlData paddata; SceCtrlData paddata;
@ -34,20 +34,19 @@ static int mainThread(SceSize args, void *argp)
} }
unsigned int readSystemButtons(void) unsigned int read_system_buttons(void)
{ {
return buttons; return buttons;
} }
void loadGame(const char* fileName, void * argp){ void exitspawn_kernel( const char* fileName, SceSize args, void * argp){
thread_active = 0; thread_active = 0;
struct SceKernelLoadExecVSHParam game_param; struct SceKernelLoadExecVSHParam game_param;
pspDebugScreenClear();
memset(&game_param,0,sizeof(game_param)); memset(&game_param,0,sizeof(game_param));
game_param.size = sizeof(game_param); game_param.size = sizeof(game_param);
game_param.args = strlen(argp)+1; game_param.args = args;
game_param.argp = argp; game_param.argp = argp;
game_param.key = "game"; game_param.key = "game";
game_param.vshmain_args_size = 0; game_param.vshmain_args_size = 0;
@ -68,10 +67,10 @@ int module_start(SceSize args, void *argp)
buttons = 0; buttons = 0;
thread_active = 0; thread_active = 0;
main_thread = sceKernelCreateThread("main Thread", mainThread, 0x11, 0x200, 0, NULL); main_thread_id = sceKernelCreateThread("main Thread", main_thread, 0x11, 0x200, 0, NULL);
if (main_thread >= 0) if (main_thread >= 0)
sceKernelStartThread(main_thread, 0, 0); sceKernelStartThread(main_thread_id, 0, 0);
return 0; return 0;
} }
@ -79,10 +78,10 @@ int module_start(SceSize args, void *argp)
int module_stop(void) int module_stop(void)
{ {
if (main_thread >= 0) if (main_thread_id >= 0)
{ {
thread_active = 0; thread_active = 0;
sceKernelWaitThreadEnd(main_thread, NULL); sceKernelWaitThreadEnd(main_thread_id, NULL);
} }
return 0; return 0;
} }