 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
fergie4000
Joined: 19 Jan 2007 Posts: 25
|
Posted: Sat Mar 03, 2007 10:14 pm Post subject: Check if a file exists? Threads in a prx? |
|
|
is there any way to do this in a prx? i have it working in an eboot, but the same code doesn't seem to work. can anyone point me in the right direction?
i am trying to make 2 threads in the prx. i have these:
| Code: | /* fat_plugin -- alias for module_start. Creates plugin worker thread and exits */
int fat_plugin (SceSize argc, void* argp)
{
u32 func = 0x80000000 | (u32)fat_ninja;
SceUID thread = sceKernelCreateThread("fat_ninja",(void*)func, 0x30, 0x10000, 0, NULL);
if (thread >= 0) {
sceKernelStartThread (thread, argc, argp);
}
return 0;
}
/* ninja_plugin -- alias for module_start. Creates plugin worker thread and exits */
int ninja_plugin (SceSize argc, void* argp)
{
u32 func = 0x80000000 | (u32)ninja_style;
SceUID thread = sceKernelCreateThread("ninja_style",(void*)func, 0x30, 0x10000, 0, NULL);
if (thread >= 0) {
sceKernelStartThread (thread, argc, argp);
}
return 0;
} |
and
| Code: | int module_start (SceSize argc, void* argp) __attribute__((alias("fat_plugin")));
int module_start (SceSize argc, void* argp) __attribute__((alias("ninja_plugin")));
|
but i'm not sure what it all means for example what is the 0x30?
tia |
|
| Back to top |
|
 |
Anissian
Joined: 26 Jan 2007 Posts: 16
|
Posted: Sat Mar 03, 2007 11:42 pm Post subject: |
|
|
I don't know exactly what you are trying to do, a more detailed explanation of the problem would help. Maybe you are confusing the concept of module entry point and the action of launching a thread?. In any case, yes, it is possible to lauch a thread from the PRX, and that's what the code seems to be trying.
First, a given module should have a single entry point (usually named module:start, the alias is to give it another name). e.g. the part
int fat_plugin (SceSize argc, void* argp)
defines the (a) "module entry point". it could be named "module_start" without the alias line (it seems that you are incorrectly? aliasing module_start to two different functions, fat and ninja). Use just one.
Something like
| Code: |
int module_start (SceSize argc, void* argp)
{
u32 func = 0x80000000 | (u32)ninja_style;
SceUID thread = sceKernelCreateThread("ninja_style",(void*)func, 0x30, 0x10000, 0, NULL);
if (thread >= 0) {
sceKernelStartThread (thread, argc, argp);
}
return 0;
} |
Once the module is started, it creates and starts the thread, who will execute the ninja_style function.
Otoh, is that supposed to be in kernel mode, I guess? (ORing with the 0x8000... address?) bear in mind that OE firmwares require a user mode PRX inside the EBOOT.PBP if you put them in e.g. GAME303 dir.
For sceKernelCreateThread , the parameters are the thread name, the thread proc (function to be exectued by the thread), the thread priority, the thread stack size, attributes and thread options (afaik, the thread options is usually NULL, maybe you can force the memory partition you want the thread stack to be placed at). You may want to look at the PSPSDK documentation for function parameters (http://psp.jim.sh/pspsdk-doc/) .
And last, the easiest way to check if a file exists (there are others) is to try to open it in read mode, and see if you fail.
Last edited by Anissian on Sat Mar 03, 2007 11:51 pm; edited 1 time in total |
|
| Back to top |
|
 |
fergie4000
Joined: 19 Jan 2007 Posts: 25
|
Posted: Sat Mar 03, 2007 11:49 pm Post subject: |
|
|
| ok. i am kinda trying to launch both threads at the same time, but when i use that neither works. how do i go about starting 2? |
|
| Back to top |
|
 |
Anissian
Joined: 26 Jan 2007 Posts: 16
|
Posted: Sat Mar 03, 2007 11:59 pm Post subject: |
|
|
Use a single entry point and then create two threads. This is a skeleton, a few things are missing (such as the exit callbacks for "home key", etc). Not sure if you want user mode, kernel mode, a main thread or not, or whether you don't want a "main" function.
| Code: |
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspdebug.h>
...
PSP_MODULE_INFO("ModName", 0x1000, 1, 0);
PSP_MAIN_THREAD_ATTR(0);
int
threadproc1 (SceSize argc, void* argp)
{
/*
Your thread proc goes here
*/
return 0;
}
int
threadproc2 (SceSize argc, void* argp)
{
/*
Your thread proc goes here
*/
return 0;
}
int
module_start (SceSize argc, void* argp)
{
u32 func1 = 0x80000000 | (u32)threadproc1;
u32 func2 = 0x80000000 | (u32)threadproc2;
SceUID thread1 = sceKernelCreateThread("thread1",(void*)func1, 0x30, 0x10000, 0, NULL);
// argc and argp don't need to be the module entry point argc and argp
if (thread1 >= 0) {
sceKernelStartThread (thread1, argc, argp);
}
SceUID thread2 = sceKernelCreateThread("thread2",(void*)func2, 0x30, 0x10000, 0, NULL);
if (thread2 >= 0) {
sceKernelStartThread (thread2, argc, argp);
}
// you should wait for thread termination here
return 0;
}
|
The 0x8000... may not be needed. use (void*) threadproc1 and 2 instead of func. |
|
| Back to top |
|
 |
fergie4000
Joined: 19 Jan 2007 Posts: 25
|
Posted: Sun Mar 04, 2007 12:43 am Post subject: |
|
|
ok now i think both threads are loading. is this code right?
| Code: | sceCtrlReadBufferPositive(&pad, 1);{
if (pad.Buttons == 0)
reveal(); |
trying to make it reveal when no buttons are pressed[/code] |
|
| Back to top |
|
 |
fergie4000
Joined: 19 Jan 2007 Posts: 25
|
Posted: Mon Mar 05, 2007 10:49 pm Post subject: |
|
|
rather than making a pointless new thread i thought i would ask here. is it possible to use libpng in a prx? if so how? i get errors when i try, so does it need to be edited to work in a prx.
| Code: | $ make
psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150 -L. -L/usr/local/ps
pdev/psp/sdk/lib -Wl,-q,-T/usr/local/pspdev/psp/sdk/lib/linkfile.prx -mno-crt0 -nostartfiles main.o graphics.o framebuffer.o -lpspgu -lpng -ljp
eg -lz -lm -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lpsplibc -lpsputility -lpspuser -lpspkernel -o mymodule.elf
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/bin/ld: warning: cannot find entry symbol module_start; defaulting to 0000000000000000
/usr/local/pspdev/psp/sdk/lib/libpng.a(pngerror.o): In function `png_warning':
pngerror.c:(.text+0x14c): undefined reference to `_impure_ptr'
pngerror.c:(.text+0x14c): relocation truncated to fit: R_MIPS_GPREL16 against `_impure_ptr'
pngerror.c:(.text+0x1a8): undefined reference to `_impure_ptr'
pngerror.c:(.text+0x1a8): relocation truncated to fit: R_MIPS_GPREL16 against `_impure_ptr'
pngerror.c:(.text+0x1ac): undefined reference to `_impure_ptr'
pngerror.c:(.text+0x1ac): relocation truncated to fit: R_MIPS_GPREL16 against `_impure_ptr'
/usr/local/pspdev/psp/sdk/lib/libpng.a(pngerror.o): In function `png_error':
pngerror.c:(.text+0x2a8): undefined reference to `_impure_ptr'
pngerror.c:(.text+0x2a8): relocation truncated to fit: R_MIPS_GPREL16 against `_impure_ptr'
pngerror.c:(.text+0x310): undefined reference to `_impure_ptr'
pngerror.c:(.text+0x310): relocation truncated to fit: R_MIPS_GPREL16 against `_impure_ptr'
/usr/local/pspdev/psp/sdk/lib/libpng.a(pngerror.o):pngerror.c:(.text+0x314): more undefined references to `_impure_ptr' follow
/usr/local/pspdev/psp/sdk/lib/libpng.a(pngerror.o): In function `png_error':
pngerror.c:(.text+0x314): relocation truncated to fit: R_MIPS_GPREL16 against `_impure_ptr'
/usr/local/pspdev/psp/sdk/lib/libpng.a(pngrutil.o): In function `png_handle_gAMA':
pngrutil.c:(.text+0xd08): relocation truncated to fit: R_MIPS_GPREL16 against `_impure_ptr'
/usr/local/pspdev/psp/sdk/lib/libpng.a(pngrutil.o): In function `png_handle_cHRM':
pngrutil.c:(.text+0x146c): relocation truncated to fit: R_MIPS_GPREL16 against `_impure_ptr'
pngrutil.c:(.text+0x14dc): relocation truncated to fit: R_MIPS_GPREL16 against `_impure_ptr'
/usr/local/pspdev/psp/sdk/lib/libpng.a(pngrutil.o): In function `png_handle_sRGB':
pngrutil.c:(.text+0x178c): relocation truncated to fit: R_MIPS_GPREL16 against `_impure_ptr'
/usr/local/pspdev/psp/sdk/lib/libpng.a(pngwrite.o): In function `png_convert_from_time_t':
pngwrite.c:(.text+0xac4): undefined reference to `gmtime'
/usr/local/pspdev/psp/sdk/lib/libpng.a(pngwutil.o): In function `png_write_cHRM':
pngwutil.c:(.text+0x10e8): undefined reference to `_impure_ptr'
pngwutil.c:(.text+0x10e8): additional relocation overflows omitted from the output
/usr/local/pspdev/psp/sdk/lib/libpng.a(pngwutil.o): In function `png_write_cHRM_fixed':
pngwutil.c:(.text+0x163c): undefined reference to `_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libjpeg.a(jerror.o): In function `output_message':
jerror.c:(.text+0x44): undefined reference to `_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libjpeg.a(jmemmgr.o): In function `jinit_memory_mgr':
jmemmgr.c:(.text+0x153c): undefined reference to `sscanf'
collect2: ld returned 1 exit status
make: *** [mymodule.elf] Error 1
|
hopefully all that means something to somebody.
tia |
|
| Back to top |
|
 |
|
|
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
|