main.c:
Code: Select all
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspctrl.h>
PSP_MODULE_INFO("psplugin", 0x1000, 1, 0);
PSP_MAIN_THREAD_ATTR(0);
int module_start (SceSize argc, void* argp) __attribute__((alias("plugin_entry")));
int plugin_dump_file(){
    SceUID fd= sceIoOpen("ms0:/plugin_pspain.dat", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
    
    if(fd < 0)
        return -1;
    
    int a=1;
    int rc;
    rc= sceIoWrite(fd, &a, sizeof(int));
    if(rc < sizeof(int)) 
        rc= -1; else
        rc= 0;
        
    sceIoClose(fd); 
    return rc;
}
int plugin_thread (SceSize argc, void* argp){
    SceCtrlData pad;
    sceCtrlSetSamplingCycle(0);
    sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);
    while(1){
        sceCtrlPeekBufferPositive(&pad, 1);
        if(pad.Buttons != 0){
                if(pad.Buttons & PSP_CTRL_LTRIGGER){
                                int res= plugin_dump_file;                
                        }
                if(pad.Buttons & PSP_CTRL_RTRIGGER){
                                break;
                        }       
        }
        sceKernelDelayThread(100000);
    }
    sceKernelExitDeleteThread(0);
    return 0;
}
int plugin_entry (SceSize argc, void* argp){
    u32 func= 0x80000000 | (u32)plugin_thread;
    SceUID thread= sceKernelCreateThread("plugin_thread", (void*)func,0x30,0x10000,0,NULL);
    if(thread >= 0){
        sceKernelStartThread(thread, argc, argp);
    }
    return 0;
}Code: Select all
TARGET = prx_test
OBJS = main.o
USE_KERNEL_LIBC = 1
USE_KERNEL_LIBS = 1
PRX_EXPORTS = exports.exp
INCDIR = 
CFLAGS = -DNOEXIT -DFPM_MIPS -O2 -G0 -Wall
#CFLAGS = -DNOEXIT -DFPM_MIPS -O2 -G0 -Wall -fno-builtin-printf
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lpspdisplay_driver -lpspkernel
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build_prx.makCode: Select all
# 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
# Export our function
PSP_EXPORT_START(prx_test, 0, 0x0001)
PSP_EXPORT_FUNC_HASH(plugin_entry)
PSP_EXPORT_END
PSP_END_EXPORTS ps. i'm using 3.52 m33-4
