forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with loading prx

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
septem



Joined: 29 Aug 2007
Posts: 21

PostPosted: Sun Sep 02, 2007 12:10 am    Post subject: Problem with loading prx Reply with quote

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:
#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;
}


makefile:
Code:
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.mak


exports.exp:
Code:
# 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


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
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sun Sep 02, 2007 10:23 am    Post subject: Reply with quote

Are you sure this compiled without warnings?
Code:

                if(pad.Buttons & PSP_CTRL_LTRIGGER){
                                int res= plugin_dump_file;               

should be
Code:

                if(pad.Buttons & PSP_CTRL_LTRIGGER){
                                int res= plugin_dump_file();               


Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
septem



Joined: 29 Aug 2007
Posts: 21

PostPosted: Sun Sep 02, 2007 10:10 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group