Merge pull request #731 from aliaspider/master
(PSP) add support for kernel-mode functions through a loadable module.
This commit is contained in:
commit
f394dcc52a
|
@ -1,5 +1,5 @@
|
||||||
BUILD_PRX = 1
|
BUILD_PRX = 1
|
||||||
DEBUG = 0
|
DEBUG = 0
|
||||||
HAVE_FILE_LOGGER = 0
|
HAVE_FILE_LOGGER = 0
|
||||||
HAVE_THREADS = 0
|
HAVE_THREADS = 0
|
||||||
|
|
||||||
|
@ -15,11 +15,11 @@ INCDIR = $(PSPPATH)/include
|
||||||
CFLAGS = $(OPTIMIZE_LV) -G0 -std=gnu99 -ffast-math
|
CFLAGS = $(OPTIMIZE_LV) -G0 -std=gnu99 -ffast-math
|
||||||
ASFLAGS = $(CFLAGS)
|
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 =
|
LIBDIR =
|
||||||
LDFLAGS =
|
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)
|
ifeq ($(HAVE_THREADS), 1)
|
||||||
RARCH_DEFINES += -DHAVE_THREADS
|
RARCH_DEFINES += -DHAVE_THREADS
|
||||||
|
@ -36,7 +36,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
|
PSP_OBJECTS = griffin/griffin.o psp1/kernelFunctions.o
|
||||||
|
|
||||||
OBJS = $(PSP_OBJECTS)
|
OBJS = $(PSP_OBJECTS)
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <pspdebug.h>
|
#include <pspdebug.h>
|
||||||
#include <pspfpu.h>
|
#include <pspfpu.h>
|
||||||
#include <psppower.h>
|
#include <psppower.h>
|
||||||
|
#include <pspsdk.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "../../boolean.h"
|
#include "../../boolean.h"
|
||||||
|
@ -126,6 +127,8 @@ 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);
|
||||||
|
|
||||||
|
pspSdkLoadStartModule("kernelFunctions.prx", PSP_MEMORY_PARTITION_KERNEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void frontend_psp_deinit(void *data)
|
static void frontend_psp_deinit(void *data)
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "../driver.h"
|
#include "../driver.h"
|
||||||
#include "../libretro.h"
|
#include "../libretro.h"
|
||||||
#include "../general.h"
|
#include "../general.h"
|
||||||
|
#include "../psp1/kernelFunctions.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PSP_GAMEPAD_CROSS = 1ULL << 0,
|
PSP_GAMEPAD_CROSS = 1ULL << 0,
|
||||||
|
@ -128,6 +129,7 @@ static void psp_input_poll(void *data)
|
||||||
#endif
|
#endif
|
||||||
sceCtrlSetSamplingMode(DEFAULT_SAMPLING_MODE);
|
sceCtrlSetSamplingMode(DEFAULT_SAMPLING_MODE);
|
||||||
ret = CtrlPeekBufferPositive(0, &state_tmp, 1);
|
ret = CtrlPeekBufferPositive(0, &state_tmp, 1);
|
||||||
|
state_tmp.Buttons = (state_tmp.Buttons&0x0000FFFF)|(readSystemButtons()&0xFFFF0000);
|
||||||
(void)ret;
|
(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;
|
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));
|
*lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE));
|
||||||
|
|
||||||
if (
|
if (STATE_BUTTON(state_tmp) & PSP_CTRL_NOTE)
|
||||||
(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))
|
|
||||||
)
|
|
||||||
*lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
|
*lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
|
||||||
|
|
||||||
if (g_settings.input.autodetect_enable)
|
if (g_settings.input.autodetect_enable)
|
||||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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 */
|
|
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue