Problem with loading prx

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
septem
Posts: 21
Joined: Wed Aug 29, 2007 7:44 am

Problem with loading prx

Post by septem »

Hi! I'm newbie to this whole psp programming, so please be patient :) I have a problem with a prx, I'm putting it on ma ms in seplugins folder I set up evrything, but for some reason plugin's not working. This is the code:

main.c:

Code: Select all

#include <pspsdk.h>
#include <pspkernel.h>
#include <pspctrl.h>

PSP_MODULE_INFO&#40;"psplugin", 0x1000, 1, 0&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;

int module_start &#40;SceSize argc, void* argp&#41; __attribute__&#40;&#40;alias&#40;"plugin_entry"&#41;&#41;&#41;;

int plugin_dump_file&#40;&#41;&#123;
    SceUID fd= sceIoOpen&#40;"ms0&#58;/plugin_pspain.dat", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777&#41;;
    
    if&#40;fd < 0&#41;
        return -1;
    
    int a=1;
    int rc;
    rc= sceIoWrite&#40;fd, &a, sizeof&#40;int&#41;&#41;;
    if&#40;rc < sizeof&#40;int&#41;&#41; 
        rc= -1; else
        rc= 0;
        
    sceIoClose&#40;fd&#41;; 
    return rc;
&#125;

int plugin_thread &#40;SceSize argc, void* argp&#41;&#123;
    SceCtrlData pad;
    sceCtrlSetSamplingCycle&#40;0&#41;;
    sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_DIGITAL&#41;;
    while&#40;1&#41;&#123;
        sceCtrlPeekBufferPositive&#40;&pad, 1&#41;;
        if&#40;pad.Buttons != 0&#41;&#123;
                if&#40;pad.Buttons & PSP_CTRL_LTRIGGER&#41;&#123;
                                int res= plugin_dump_file;                
                        &#125;
                if&#40;pad.Buttons & PSP_CTRL_RTRIGGER&#41;&#123;
                                break;
                        &#125;       
        &#125;
        sceKernelDelayThread&#40;100000&#41;;
    &#125;
    sceKernelExitDeleteThread&#40;0&#41;;
    return 0;
&#125;

int plugin_entry &#40;SceSize argc, void* argp&#41;&#123;
    u32 func= 0x80000000 | &#40;u32&#41;plugin_thread;
    SceUID thread= sceKernelCreateThread&#40;"plugin_thread", &#40;void*&#41;func,0x30,0x10000,0,NULL&#41;;
    if&#40;thread >= 0&#41;&#123;
        sceKernelStartThread&#40;thread, argc, argp&#41;;
    &#125;
    return 0;
&#125;
makefile:

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 = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

LIBDIR =
LIBS = -lpspdisplay_driver -lpspkernel

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build_prx.mak
exports.exp:

Code: Select all

# Define the exports for the prx
PSP_BEGIN_EXPORTS

# These four lines are mandatory &#40;although you can add other functions like module_stop&#41;
# syslib is a psynonym for the single mandatory export.
PSP_EXPORT_START&#40;syslib, 0, 0x8000&#41;
PSP_EXPORT_FUNC_HASH&#40;module_start&#41;
PSP_EXPORT_VAR_HASH&#40;module_info&#41;
PSP_EXPORT_END

# Export our function
PSP_EXPORT_START&#40;prx_test, 0, 0x0001&#41;
PSP_EXPORT_FUNC_HASH&#40;plugin_entry&#41;
PSP_EXPORT_END

PSP_END_EXPORTS 
I guess the problem lies in makefile or exports.exp, cause main.c is from modules tutorial...

ps. i'm using 3.52 m33-4
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

Are you sure this compiled without warnings?

Code: Select all

                if&#40;pad.Buttons & PSP_CTRL_LTRIGGER&#41;&#123; 
                                int res= plugin_dump_file;                
should be

Code: Select all

                if&#40;pad.Buttons & PSP_CTRL_LTRIGGER&#41;&#123; 
                                int res= plugin_dump_file&#40;&#41;;                
Jim
septem
Posts: 21
Joined: Wed Aug 29, 2007 7:44 am

Post by septem »

Lol, it works... Thx man :)

I got another problem: my prx is not working when I add -lpspusb to LIBS in makefile. I checked it couple times and I'm 99% sure it's causing my prx to not load. Anybody knows this problem and knows how to fix it?
Post Reply