| View previous topic :: View next topic |
| Author |
Message |
coolkehon
Joined: 20 Oct 2008 Posts: 355
|
Posted: Mon Oct 20, 2008 5:53 am Post subject: Prxes in C++ with libraries (OSLib) |
|
|
I posted this on another forum and no one could help me so i was hoping i could get some help here i've been trying to change my program in progress over to use prx's where possible like large games (umds) do so that i can conserve memory and update it easily when necessary through the program but i got this error after i included oslib and linked it
| Code: | C:/pspsdk/psp/sdk/lib\libpsplibc.a(glue__sbrk.o): In function `_sbrk':
../../../../pspsdk/src/libc/libcglue.c:95: undefined reference to `sceKernelMaxF
reeMemSize' |
How can i fix this and when i include this -lpspuser or -lpspsysmem_user when i try to load it in a test i get this error 8002013C
Here is the makefile
| Code: | TARGET = mylib
OBJS = main.o
# Use the kernel's small inbuilt libc
USE_KERNEL_LIBC = 1
# Use only kernel libraries
USE_KERNEL_LIBS = 1
INCDIR =
CFLAGS = -O2 -G0 -Wall -fno-builtin-printf
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
PRX_EXPORTS = mylib.exp
STDLIBS = -losl -lpspgu -lpspge -lpspaudio -lpsppower -lpsplibc
#-losl -mp3 -lmikmod -lpng -lz
# STDLIBS += -lpspctrl -lpspumd -lpsprtc -lpsppower
# STDLIBS += -lpspgu -lpspaudiolib -lpspaudio
# STDLIBS += -lmikmod -lm -lc -lstdc++ -lpspmpeg -lpsprtc
# STDLIBS += -lpspaudiocodec -lpspatrac3 -lpspdisplay_driver
# STDLIBS += -lpspge -lpspsysmem_kernel -lpspkernel
LIBS = $(STDLIBS)
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build_prx.mak
|
main.c
| Code: | #include <pspkernel.h>
#include <stdio.h>
#include <oslib/oslib.h>
#include <malloc.h>
PSP_MODULE_INFO("template", PSP_MODULE_KERNEL, 1, 1);
int main_thread(SceSize args, void *argp)
{
printf("Hello World\n");
return 0;
}
void startDrawing(void)
{
oslInit(0);
oslInitGfx(OSL_PF_8888,1);
oslDebug("prx loaded and osl inited from main");
while(!osl_quit)
{
oslStartDrawing();
oslDrawFillRect(0,0,100,100,RGB(255,0,0));
oslEndDrawing();
oslSyncFrame();
}
}
/* Entry point */
int module_start(SceSize args, void *argp)
{
int thid;
thid = sceKernelCreateThread("template", main_thread, 7, 0x800, 0, NULL);
if(thid >= 0)
{
sceKernelStartThread(thid, args, argp);
}
return 0;
}
/* Module stop entry */
int module_stop(SceSize args, void *argp)
{
return 0;
}
|
hope this isnt to much if so i can remove some new to boards |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
|
| Back to top |
|
 |
coolkehon
Joined: 20 Oct 2008 Posts: 355
|
Posted: Tue Oct 21, 2008 10:53 pm Post subject: |
|
|
| that sample doesnt use any libraries i need to use oslib in it can you explain how i can use that to help mabye a sample or something |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Wed Oct 22, 2008 6:36 am Post subject: |
|
|
| coolkehon wrote: | | that sample doesnt use any libraries i need to use oslib in it can you explain how i can use that to help mabye a sample or something |
The process for using user mode prxs is the same as with kernel mode prxs, it's just one uses kernel mode and the other doesn't. Just change the prx mode in the example to user mode (so don't use kernel mode calls or the SetK1 calls), and change it to load into user memory instead of kernel memory. Everything else should be the same. Be sure to leave space in the user memory for the prx and its heap (using PSP_HEAP_SIZE_MAX() will prevent user prxs from being able to load as they won't have any memory). |
|
| Back to top |
|
 |
coolkehon
Joined: 20 Oct 2008 Posts: 355
|
Posted: Thu Oct 23, 2008 6:17 am Post subject: |
|
|
| no what i'm trying to do is load a prx then call a function in the prx that uses oslib so the prx uses oslib sakya already gave me that example and when i included oslib i got that error here is The sample could someone take a look at it and see why it doesnt compile[/url] |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Oct 23, 2008 7:04 am Post subject: |
|
|
Okay, I'll look it over and see what's what. :)
EDIT: Okay, the sample you have needed some fixing. It was trying to make a kernel mode prx out of the library. Here's my working code:
http://www.mediafire.com/download.php?dss3itmelre
It's now a user prx loaded into user memory. I modified the oslib test code in the prx to clear the screen properly and to move the rect around via the dpad. Remember that the prx doesn't know where anything in the main app is. If you want the prx to operate on vars/structs in the main app, be sure to pass a pointer to them.
Anywho, as both the app and the prx are user mode, I modified the export table to use direct jumps for the functions. That should be faster anyway.
You only need to "psp-build-exports -s exports.exp" and copy the resulting S file to the main app directory to use the prx. The other S file you were making isn't needed. I also set it to not create a thread in the prx, so module_start/stop will be called on the main app thread.
Note that this is really the basis for "DLL" type libs on the PSP. Not many devs use them, but they could be handy in a number of cases. For example, if you used a prx like this to do the dynamic recompiling on an emu, you could replace just the prx on updates instead of the whole emulator.
To try the code as it is in the arc, just copy the EBOOT.PBP from the "KJA PDA Prx" directory and the testlib.prx from the "Test Prx" directory into a folder in GAME4XX (for 4.01M33). If you don't copy the testlib.prx file, you'll get an error message stating it couldn't be loaded and the app will exit. If it works, you'll get the osl debug alert, then if you press X, you'll get a red square that you can move around with the dpad. Use Home to exit. |
|
| Back to top |
|
 |
coolkehon
Joined: 20 Oct 2008 Posts: 355
|
Posted: Fri Oct 24, 2008 12:11 am Post subject: |
|
|
| thank you so much you dont know how long i've been trying to get this working/fixed now one more question what if i want the prx to be able to use kernel function so like a kernel 0x1000 module flags will that work and also how can i send arguments to the prx mabye args[] will work |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Fri Oct 24, 2008 5:53 am Post subject: |
|
|
| Use a separate prx for kernel functions. That prx can be made and loaded just like the example I linked above from the old OE SDK. However, I'd recommend against using kernel functions. There's no reason for using them beyond something like using the MediaEngine. Something like that is best not mixed with a user library for rendering or such as well. |
|
| Back to top |
|
 |
coolkehon
Joined: 20 Oct 2008 Posts: 355
|
Posted: Mon Nov 03, 2008 10:46 am Post subject: |
|
|
| i needed it to read controls and i wanna split my code up into prx's so that i can load and unload memory cause this is probably gonna become a big thing trying to put windows on psp and making it easy to update using prx's |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Mon Nov 03, 2008 11:54 am Post subject: |
|
|
| coolkehon wrote: | | i needed it to read controls and i wanna split my code up into prx's so that i can load and unload memory cause this is probably gonna become a big thing trying to put windows on psp and making it easy to update using prx's |
Unless you need to read the Home/Volume/Display/Sound buttons, just use the user control functions. If you DO need to read Home/etc, look at the prx already out that reads Home. You'll find it with the 3.xx version of SNES9x, among other places. |
|
| Back to top |
|
 |
coolkehon
Joined: 20 Oct 2008 Posts: 355
|
Posted: Mon Nov 03, 2008 1:00 pm Post subject: |
|
|
| well i already made one and it works i even got pressed and other functions |
|
| Back to top |
|
 |
|