[Interested?] OldSchool Library

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

Moderators: cheriff, TyRaNiD

Post Reply
Giuliano
Posts: 78
Joined: Tue Sep 13, 2005 10:26 am

Post by Giuliano »

monkey242 wrote:I'm fairly new to programming for the PSP so forgive me if this is really simple stuff. I'm trying to use oslib to do some C++ programming and I've hit a few snags.

First, on line 60 of oslib.h you typedef a bool as a short. g++ complains that you can't redefine bool so I just put an #ifndef __cplusplus around that line. Is that correct or will it break something else?

Assuming that it was correct to not include that line, the second thing is that I'm getting multiple definitions of 'osl_powerCallback' in 'oslSetupFTrigo' while linking. This then breaks every oslib function that appears in my code.

My code (just a little test stub at the moment) compiles when I change the extension from .cpp to .c and remove -lstdc++ from the makefile.

Does anyone know where I'm going wrong?
Actually I am just as we speak trying to get some C++ Code running and Brunni replied to my message saying that the current version didn't have C++ support and that the next version will.
monkey242
Posts: 3
Joined: Tue Apr 25, 2006 4:19 am

Post by monkey242 »

Actually I am just as we speak trying to get some C++ Code running and Brunni replied to my message saying that the current version didn't have C++ support and that the next version will.
Thanks for the quick reply. I was pulling what little hair I have left out.
albator
Posts: 4
Joined: Mon Mar 06, 2006 8:42 am

Post by albator »

I use OSLib in C++ code and i havn't any problem exept for the bool type.
monkey242
Posts: 3
Joined: Tue Apr 25, 2006 4:19 am

Post by monkey242 »

I use OSLib in C++ code and i havn't any problem exept for the bool type.
Are you using the latest version of OSLib? Did you have to do anything special in your makefile?

Any C++ code / makefiles that you could share, so that I could test, would be greatly appreciated.

Thanks.
albator
Posts: 4
Joined: Mon Mar 06, 2006 8:42 am

Post by albator »

this is my makefile
TARGET = test
OBJS = sprite.o

CFLAGS = -G0 -Wall -O2
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LDFLAGS =
LIBS= -losl -lpng -lz \
-lpspsdk -lpspctrl -lpspumd -lpsprtc \
-lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm -lstdc++

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = OSL Sample

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
And i include oslib.h like this in my cpp source code. I'm really not an expert but it works.
extern "C"
{
#include <oslib/oslib.h>
}
Giuliano
Posts: 78
Joined: Tue Sep 13, 2005 10:26 am

Post by Giuliano »

I can't wait to test it when I get home. You have actually been able to draw graphics to the screen using that method ?
albator
Posts: 4
Joined: Mon Mar 06, 2006 8:42 am

Post by albator »

Yes without problem. Try it, it's a great lib ;)
Giuliano
Posts: 78
Joined: Tue Sep 13, 2005 10:26 am

Post by Giuliano »

Okay I got it to work. The trick is the -G0 in the CFLAGS of the Makefile.
User avatar
hardhat
Posts: 17
Joined: Thu Mar 02, 2006 9:42 am
Contact:

Crash on exit with 2.6 + Super Bach.

Post by hardhat »

I find that both the samples and my app crash on exit. My beta tester sees it too. Specifically it crashes when the eLoader trys to start again. I've tried both the LTRIGGER+RTRIGGER+START method and the oslQuit() method. The MS light goes on, and the message "eLoader v0.97 by Fanjita and Ditlew
(based on the work by ..." which stays for 10 second and then of course turns itself off.

I (and my beta tester) have a 2.6 PSP (mine is US GTA, his is EU GTA) and we are both running eLoader 0.97 Alternative.

Other than that the oslib is everything I could want. Lightning fast, and nicely compact.

HardHat.
johnsto
Posts: 30
Joined: Wed Jan 18, 2006 8:52 am

Post by johnsto »

I get a similar problem to hardhat, on firmware 2.00 using eLoader as well, but I don't get any crashes.

If I load up the eLoader, I can successfully get into Test_oslib quite happily. However, if I quit Test_oslib, and then try to load it up again, all I get is a black screen. Pressing L+R+Start gets me back to the eLoader however, no crashes or anything. Trying to load it again still doesn't work - I have to quit the eLoader, reset the PSP, load the eLoader again and then Test_oslib will work.

This means I have to soft-reboot my PSP every time I do a new compile :(

I'd love to use the library though, it's just what I was looking for!

Update: Ok, I've just been playing around with it, and it seems that 'oslMessageBox' is causing the problems. Commenting out those lines and using L+R+Start to quit solves everything!

However, after a few quits+restarts of the program (3 or 4) the eLoader gives me an 80010018 error (can't load eboot) and I have to restart the PSP. Still, it's better than before.
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

this sounds like OSlib has issues with GE init on 2.0
might wanna check that out ;)
Last edited by dot_blank on Mon May 01, 2006 6:44 pm, edited 1 time in total.
10011011 00101010 11010111 10001001 10111010
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

I don't free up all memory when exiting, because the kernel actually does it by itself. But maybe eLoader doesn't, and this can make the program crash after several runs (but I would not say 3, at least 10 or 20). Do other programs have this problem as well?
Please PM me if you want to (seriously) do further tests :)
Could you test this and tell me what happens on a 2.0+ please? :

Code: Select all

oslInit&#40;&#41;;
oslInitGfx&#40;OSL_PF_8888, 1&#41;;
oslSwapBuffers&#40;&#41;;
oslSwapBuffers&#40;&#41;;
oslStartDrawing&#40;&#41;;
oslSetDrawBuffer&#40;OSL_SECONDARY_BUFFER&#41;;
oslDrawFillRect&#40;0, 0, 100, 100, RGB&#40;255, 0, 0&#41;&#41;;
oslEndDrawing&#40;&#41;;
oslWaitKey&#40;&#41;;
oslQuit&#40;&#41;;
I didn't tested it, I hope it works. I'm sorry I have very few free time for now, but I didn't given up ;-)
I'll post the source code once I have some free time to finalize the PC version and clean it.
Thanks for support ^^
Sorry for my bad english
Image Oldschool library for PSP - PC version released
johnsto
Posts: 30
Joined: Wed Jan 18, 2006 8:52 am

Post by johnsto »

Brunni: I compiled your code, copied it across and it runs fine. I'm able to run it over and over again (about 10 times so far) without any problems. It has not crashed yet.

I also just noticed that eLoader's memory indication does not decrease if I keep running an oslib app. It always says 23.6mb even after a few runs+exits. So maybe the eLoader IS freeing memory and it's a different issue?
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

why swap twice ?

Code: Select all

oslSwapBuffers&#40;&#41;;
oslSwapBuffers&#40;&#41;;
10011011 00101010 11010111 10001001 10111010
johnsto
Posts: 30
Joined: Wed Jan 18, 2006 8:52 am

Post by johnsto »

Brunni: Some more discoveries.

I've added oslAssert()'s after all my image/sound loads just to make sure they load ok. Again, the program works fine 2 or 3 times, but next time it will throw up a fatal error naming the file it just tried to load. So it sounds like it's failing to load the images after it has been run a few times.

Hope this helps. I'll post more as I get it :)
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Hm that's strange, you said just before that it worked 10 times?
Anyway oslLoadImageFile does a lot of things. Are your images in RAM or VRAM? Does using VRAM give the same problem? Can you try to create empty images (oslCreateImage) of the same dimension/pixelformat/location instead and tell me what happen after some runs?
By the way oslAssert (like oslDebug and all that routines) all call oslMessageBox (but incase of oslAssert, only if condition is false).
dot_blank> To simulate a program that already ran some time before executing this ;)
Sorry for my bad english
Image Oldschool library for PSP - PC version released
johnsto
Posts: 30
Joined: Wed Jan 18, 2006 8:52 am

Post by johnsto »

Brunni wrote:Hm that's strange, you said just before that it worked 10 times?
Anyway oslLoadImageFile does a lot of things. Are your images in RAM or VRAM? Does using VRAM give the same problem? Can you try to create empty images (oslCreateImage) of the same dimension/pixelformat/location instead and tell me what happen after some runs?
Yep, it worked at least 10 times before I got bored and stopped trying :)

My images are being loaded into normal RAM.

I'll try your suggestions this evening and let you know what happens.
johnsto
Posts: 30
Joined: Wed Jan 18, 2006 8:52 am

Post by johnsto »

Brunni wrote:Does using VRAM give the same problem?
Hmm, whenever I try to load or create an image in VRAM, I get a crash. Sometimes it shows an error box. Sometrimes it shows is a black screen and then my PSP turns off. Sometimes it just shows black and I have to use L+R+Start to get back to the eLoader. (My program should quit on 'Start' but it doesn't work when VRAM is used!)
Brunni wrote:Can you try to create empty images (oslCreateImage) of the same dimension/pixelformat/location instead and tell me what happen after some runs?
I tried that and it ran 10 times in a row without a problem! I didn't try any more than that.
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

VRAM crashes from the first time?
Sorry for my bad english
Image Oldschool library for PSP - PC version released
johnsto
Posts: 30
Joined: Wed Jan 18, 2006 8:52 am

Post by johnsto »

Yep, I think it crashes as soon as it tries to load the first file into VRAM.
Giuliano
Posts: 78
Joined: Tue Sep 13, 2005 10:26 am

Post by Giuliano »

Are you checking if your file has loaded into VRAM or do you just assume that it did and it crashes when you try to draw or do something with the image ?

I could only get 2 512x512 images loaded into ram so it's a very small space to work with
johnsto
Posts: 30
Joined: Wed Jan 18, 2006 8:52 am

Post by johnsto »

Giuliano wrote:Are you checking if your file has loaded into VRAM or do you just assume that it did and it crashes when you try to draw or do something with the image ?
I have an oslAssert check the pointer that oslLoadImage gives me back. However, this isn't throwing up anything so you're right - it's not clear if it happened on load or on drawing it.

I've just tried a different test: a very simple program whose only task is to load up the image into VRAM, and then exit. This crashes/hangs on a black screen and soft-resets my PSP. Change it to use normal RAM and it runs and exits normally.

So I would argue something is definitely going wrong whilst loading the image into VRAM.
johnsto
Posts: 30
Joined: Wed Jan 18, 2006 8:52 am

Post by johnsto »

Oh, also, the test image I'm using is a 480x272 loaded as 8888... so a bit heavy :)
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

I could only get 2 512x512 images loaded into ram so it's a very small space to work with
In VRAM you can put only 2 512x512 images because it's only 2 MB and in double-buffered 8888 mode you already loose more than 1 MB of it for the screen buffer itself (512*272*4*2). But in RAM you can put much more than that.
I have an oslAssert check the pointer that oslLoadImage gives me back. However, this isn't throwing up anything so you're right - it's not clear if it happened on load or on drawing it.
That's very strange, looks like you have no access to the VRAM (??). To make sure, can you try this please? (in a simple program that does this and exits then).

Code: Select all

u32 *ptr = &#40;u32*&#41;0x04110000;
*ptr = 0xaaaaaaaa;
Does it crash?
Sorry for my bad english
Image Oldschool library for PSP - PC version released
johnsto
Posts: 30
Joined: Wed Jan 18, 2006 8:52 am

Post by johnsto »

Brunni wrote: That's very strange, looks like you have no access to the VRAM (??). To make sure, can you try this please? (in a simple program that does this and exits then).

Code: Select all

u32 *ptr = &#40;u32*&#41;0x04110000;
*ptr = 0xaaaaaaaa;
Does it crash?
Nope, it went back to the eLoader normally. It did not crash.
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Okay, so I think it'll need some more investigation. If you (or someone else) want to help me, please PM me ;-)
Sorry for my bad english
Image Oldschool library for PSP - PC version released
Giuliano
Posts: 78
Joined: Tue Sep 13, 2005 10:26 am

Post by Giuliano »

Could it be that eLoader or some other programs that are running are taking up VRAM so he can not load any images?
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

most likely you are
1. loading to large an image into vram
2. loading image in address that one of the
frame buffers currently occupy or
3. some bug lies in OSL ;)

eloader does not touch vram
10011011 00101010 11010111 10001001 10111010
sg57
Posts: 144
Joined: Fri Oct 14, 2005 2:26 pm

Post by sg57 »

...nice lib, i have to admit, easy to install, since i edited the install.bat to C drive and thats it... now i have this font, its TTF (True Type Font) and i want to con vert it into an OSL compatible format...

I see the tool there for it, but the CMD goes away too quick for me to read what to do... please help as i need this font adn this lib is the only clean, fast, and down right old school way of doing this... thx
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Execute if from console (start, execute, "cmd" then type its name), then infos will stay on screen.
Anyway your font has to be installed, since the name you'll put on the command line is the name of the system font, like "Times New Roman" ;-)

Some news (I've got my exams now, so just wait a bit, but it's not given up)
1) It seems that the cause of problems with 2.6 has been found, the next version (that will come shortly) should work properly, even 10 times without rebooting :-)
2) The PC version is already in beta test on a french forum (I have no time to traduce and make documentation now, sorry):
* Download: http://www.playeradvance.org/forum/show ... #post48470
* Tutos: http://www.playeradvance.org/forum/show ... php?t=2174
But I need help, because this thing doesn't run on all computers and is very slow. It should really be implemented in software. If someone can give me some advice or help, he/she is very welcomed :-)

Thanks ^^
Sorry for my bad english
Image Oldschool library for PSP - PC version released
Post Reply