mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
(PSP) add support for kernel-mode functions through a loadable module.
This commit is contained in:
parent
9a2ee92045
commit
b185fc3901
@ -1,5 +1,5 @@
|
||||
BUILD_PRX = 1
|
||||
DEBUG = 0
|
||||
DEBUG = 0
|
||||
HAVE_FILE_LOGGER = 0
|
||||
HAVE_THREADS = 0
|
||||
|
||||
@ -15,11 +15,11 @@ INCDIR = $(PSPPATH)/include
|
||||
CFLAGS = $(OPTIMIZE_LV) -G0 -std=gnu99 -ffast-math
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
RARCH_DEFINES = -DPSP -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_ZLIB -DWANT_MINIZ -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_RGUI -DWANT_RPNG -DSINC_LOWEST_QUALITY -DHAVE_CC_RESAMPLER
|
||||
RARCH_DEFINES = -DPSP -D_MIPS_ARCH_ALLEGREX1 -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_ZLIB -DWANT_MINIZ -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_RGUI -DWANT_RPNG -DSINC_LOWEST_QUALITY -DHAVE_CC_RESAMPLER
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS =
|
||||
LIBS = -lretro_psp1 -lstdc++ -lpspgu -lpspgum -lm -lpspaudio -lpspfpu -lpsppower
|
||||
LIBS = -lretro_psp1 -lstdc++ -lpspgu -lpspgum -lm -lpspaudio -lpspfpu -lpsppower -lpsprtc
|
||||
|
||||
ifeq ($(HAVE_THREADS), 1)
|
||||
RARCH_DEFINES += -DHAVE_THREADS
|
||||
@ -36,7 +36,7 @@ CFLAGS += $(RARCH_DEFINES)
|
||||
EXTRA_TARGETS = EBOOT.PBP
|
||||
PSP_EBOOT_TITLE = RetroArch PSP1
|
||||
|
||||
PSP_OBJECTS = griffin/griffin.o
|
||||
PSP_OBJECTS = griffin/griffin.o psp1/kernelFunctions.o
|
||||
|
||||
OBJS = $(PSP_OBJECTS)
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <pspdebug.h>
|
||||
#include <pspfpu.h>
|
||||
#include <psppower.h>
|
||||
#include <pspsdk.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../../boolean.h"
|
||||
@ -61,7 +62,7 @@ static void frontend_psp_get_environment_settings(int *argc, char *argv[],
|
||||
fill_pathname_basedir(default_paths.port_dir, argv[0], sizeof(default_paths.port_dir));
|
||||
RARCH_LOG("port dir: [%s]\n", default_paths.port_dir);
|
||||
|
||||
fill_pathname_join(default_paths.asset_dir, default_paths.port_dir, "media", sizeof(default_paths.asset_dir));
|
||||
fill_pathname_join(default_paths.assets_dir, default_paths.port_dir, "media", sizeof(default_paths.assets_dir));
|
||||
fill_pathname_join(default_paths.core_dir, default_paths.port_dir, "cores", sizeof(default_paths.core_dir));
|
||||
fill_pathname_join(default_paths.core_info_dir, default_paths.port_dir, "cores", sizeof(default_paths.core_info_dir));
|
||||
fill_pathname_join(default_paths.savestate_dir, default_paths.core_dir, "savestates", sizeof(default_paths.savestate_dir));
|
||||
@ -126,6 +127,8 @@ static void frontend_psp_init(void *data)
|
||||
|
||||
pspFpuSetEnable(0);//disable FPU exceptions
|
||||
scePowerSetClockFrequency(333,333,166);
|
||||
|
||||
pspSdkLoadStartModule("kernelFunctions.prx", PSP_MEMORY_PARTITION_KERNEL);
|
||||
}
|
||||
|
||||
static void frontend_psp_deinit(void *data)
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "../driver.h"
|
||||
#include "../libretro.h"
|
||||
#include "../general.h"
|
||||
#include "../psp1/kernelFunctions.h"
|
||||
|
||||
enum {
|
||||
PSP_GAMEPAD_CROSS = 1ULL << 0,
|
||||
@ -128,6 +129,7 @@ static void psp_input_poll(void *data)
|
||||
#endif
|
||||
sceCtrlSetSamplingMode(DEFAULT_SAMPLING_MODE);
|
||||
ret = CtrlPeekBufferPositive(0, &state_tmp, 1);
|
||||
state_tmp.Buttons = (state_tmp.Buttons&0x0000FFFF)|(readSystemButtons()&0xFFFF0000);
|
||||
(void)ret;
|
||||
|
||||
psp->analog_state[0][0][0] = psp->analog_state[0][0][1] = psp->analog_state[0][1][0] = psp->analog_state[0][1][1] = 0;
|
||||
@ -159,12 +161,7 @@ static void psp_input_poll(void *data)
|
||||
|
||||
*lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE));
|
||||
|
||||
if (
|
||||
(psp->pad_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_L))
|
||||
&& (psp->pad_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_R))
|
||||
&& (psp->pad_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT))
|
||||
&& (psp->pad_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_START))
|
||||
)
|
||||
if (STATE_BUTTON(state_tmp) & PSP_CTRL_NOTE)
|
||||
*lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
|
||||
|
||||
if (g_settings.input.autodetect_enable)
|
||||
|
30
psp1/kernelFunctionsPrx/Makefile
Normal file
30
psp1/kernelFunctionsPrx/Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
TARGET = kernelFunctions
|
||||
OBJS = main.o
|
||||
PSP_FW_VERSION = 150
|
||||
|
||||
INCDIR =
|
||||
CFLAGS = -O2 -G0 -Wall
|
||||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
BUILD_PRX = 1
|
||||
PRX_EXPORTS = $(TARGET).exp
|
||||
|
||||
USE_KERNEL_LIBC=1
|
||||
USE_KERNEL_LIBS=1
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS = -mno-crt0 -nostartfiles
|
||||
LIBS = -lpspdebug -lpspge -lpspsdk -lc -lpspuser
|
||||
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||
include $(PSPSDK)/lib/build.mak
|
||||
|
||||
all:
|
||||
psp-build-exports -s $(PRX_EXPORTS)
|
||||
cp $(TARGET).prx ../../$(TARGET).prx
|
||||
cp $(TARGET).S ../$(TARGET).S
|
||||
cp $(TARGET).h ../$(TARGET).h
|
||||
rm -f $(TARGET).prx
|
||||
rm -f $(TARGET).S
|
||||
rm -f *.o
|
||||
rm -f *.elf
|
16
psp1/kernelFunctionsPrx/kernelFunctions.exp
Normal file
16
psp1/kernelFunctionsPrx/kernelFunctions.exp
Normal file
@ -0,0 +1,16 @@
|
||||
# Define the exports for the prx
|
||||
PSP_BEGIN_EXPORTS
|
||||
|
||||
# These four lines are mandatory (although you can add other functions like module_stop)
|
||||
# syslib is a psynonym for the single mandatory export.
|
||||
PSP_EXPORT_START(syslib, 0, 0x8000)
|
||||
PSP_EXPORT_FUNC_HASH(module_start)
|
||||
PSP_EXPORT_VAR_HASH(module_info)
|
||||
PSP_EXPORT_END
|
||||
|
||||
PSP_EXPORT_START(kernelFunctions, 0, 0x4001)
|
||||
PSP_EXPORT_FUNC(readSystemButtons)
|
||||
PSP_EXPORT_FUNC(loadGame)
|
||||
PSP_EXPORT_END
|
||||
|
||||
PSP_END_EXPORTS
|
15
psp1/kernelFunctionsPrx/kernelFunctions.h
Normal file
15
psp1/kernelFunctionsPrx/kernelFunctions.h
Normal file
@ -0,0 +1,15 @@
|
||||
#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 */
|
88
psp1/kernelFunctionsPrx/main.c
Normal file
88
psp1/kernelFunctionsPrx/main.c
Normal file
@ -0,0 +1,88 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <pspdebug.h>
|
||||
#include <pspsdk.h>
|
||||
#include <pspctrl.h>
|
||||
#include <psploadexec_kernel.h>
|
||||
#include <pspthreadman_kernel.h>
|
||||
#include <string.h>
|
||||
|
||||
PSP_MODULE_INFO("kernelFunctions", PSP_MODULE_KERNEL, 0, 0);
|
||||
PSP_MAIN_THREAD_ATTR(0);
|
||||
|
||||
|
||||
static volatile int thread_active;
|
||||
static unsigned int buttons;
|
||||
static SceUID main_thread;
|
||||
|
||||
static int mainThread(SceSize args, void *argp)
|
||||
{
|
||||
SceCtrlData paddata;
|
||||
|
||||
thread_active = 1;
|
||||
|
||||
while (thread_active)
|
||||
{
|
||||
sceCtrlPeekBufferPositive(&paddata, 1);
|
||||
buttons = paddata.Buttons;
|
||||
sceKernelDelayThread(1000000/60);
|
||||
}
|
||||
|
||||
sceKernelExitThread(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
unsigned int readSystemButtons(void)
|
||||
{
|
||||
return buttons;
|
||||
}
|
||||
|
||||
void loadGame(const char* fileName, void * argp){
|
||||
thread_active = 0;
|
||||
struct SceKernelLoadExecVSHParam game_param;
|
||||
pspDebugScreenClear();
|
||||
|
||||
memset(&game_param,0,sizeof(game_param));
|
||||
|
||||
game_param.size = sizeof(game_param);
|
||||
game_param.args = strlen(argp)+1;
|
||||
game_param.argp = argp;
|
||||
game_param.key = "game";
|
||||
game_param.vshmain_args_size = 0;
|
||||
game_param.vshmain_args = NULL;
|
||||
game_param.configfile = 0;
|
||||
game_param.unk4 = 0;
|
||||
game_param.unk5 = 0x10000;
|
||||
|
||||
pspSdkSetK1(0);
|
||||
sceKernelSuspendAllUserThreads();
|
||||
sceKernelLoadExecVSHMs2(fileName, &game_param);
|
||||
}
|
||||
|
||||
int module_start(SceSize args, void *argp)
|
||||
{
|
||||
(void)args;
|
||||
(void)argp;
|
||||
|
||||
buttons = 0;
|
||||
thread_active = 0;
|
||||
main_thread = sceKernelCreateThread("main Thread", mainThread, 0x11, 0x200, 0, NULL);
|
||||
|
||||
if (main_thread >= 0)
|
||||
sceKernelStartThread(main_thread, 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int module_stop(void)
|
||||
{
|
||||
if (main_thread >= 0)
|
||||
{
|
||||
thread_active = 0;
|
||||
sceKernelWaitThreadEnd(main_thread, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -487,8 +487,10 @@ void config_set_defaults(void)
|
||||
strlcpy(g_settings.libretro, default_paths.core_path, sizeof(g_settings.libretro));
|
||||
if (*default_paths.core_info_dir)
|
||||
strlcpy(g_settings.libretro_info_path, default_paths.core_info_dir, sizeof(g_settings.libretro_info_path));
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (*default_paths.overlay_dir)
|
||||
strlcpy(g_extern.overlay_dir, default_paths.overlay_dir, sizeof(g_extern.overlay_dir));
|
||||
#endif
|
||||
if (*default_paths.shader_dir)
|
||||
strlcpy(g_settings.video.shader_dir, default_paths.shader_dir, sizeof(g_settings.video.shader_dir));
|
||||
if (*default_paths.savestate_dir)
|
||||
|
Loading…
x
Reference in New Issue
Block a user