[Interested?] OldSchool Library

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

Moderators: cheriff, TyRaNiD

Post Reply
reefbarman
Posts: 87
Joined: Mon Jan 08, 2007 12:16 pm
Location: Australia

Post by reefbarman »

im currently using OSLib to write my app called psp Super Portable Calendar, i absolutely love it even though i have come accross some bugs that could only have been produced by the library its self, but i found work arounds for them so im okay, but what i wanted to know is there a way to use OSLib in prxs cause im currently up to writing a plugin for my app for the vsh and i want to overlay some graphics and text onto the vsh is this possible with oslib??
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Hello :)

I've told you that I would release MMSPlus source code, here it is:
http://oslib.palib.info/samples/download/smspsp.7z
I've also told you that I would release the PC source code:
http://oslib.palib.info/OSLib_PC_src.7z

For the PC source code, open the MyOGL/MyOGL.sln, it should compile as long as you've got a working Visual C++ install with OSLib PC version.
By pressing Ctrl+F5 (execute) it will automatically execute the contents of the "blit.c" file (in OSLib directory).
The OSLib directory is a cut & paste version of the PSP folder. Files are used there for compiling.
MyOGL is an OpenGL wrapper that permits the PSP code to work.
The Library folder just containts the project that generates the OSLib.lib file. It's open at the same time with the MyOGL solution.
The PC directory contains all the files and an installation script (Install.bat), I think it's quite easy to understand ;)

For MMSPlus, you just need a working PSPSDK + OSLib install, and to type make -f Makefile.psp at command line prompt. This will specify to use Makefile.psp, because the original Makefile isn't designed for PSP.

If you've got any problem, please post there ;)

reefbarman> Please post there the problems you've got, and how you worked around them, so that I can fix them once for all ;)
NeoTechni wrote:Is there a standard map format? Or an editor?
If there is no editor I could make one for Windows
There is no official OSLib map editor. Personnaly I use GBA Graphics, it works quite good althrough it's lacking an export to a binary format, which would be extremely useful.
dot_blank wrote:why not work on this library on your long train rides :)
i know that for me the train is a nice quiet place to get
great work done as you see the country side pass by

so use natures own inspiration
Lol I've tried, but I can't work very well in the train in fact. And I don't like my laptop's screen, which is very grainy (excessive antiglare coating), it's hard to work seriously if you add the fact that I'm usually more than tired. But 4h30 train per day wasn't possible, I didn't have any social life anymore :p So I've rented a room for the rest of my year, it should go by far better ^^
Sorry for my bad english
Image Oldschool library for PSP - PC version released
goebish
Posts: 29
Joined: Sat Oct 14, 2006 11:59 pm

Post by goebish »

Thanks Brunni, you're a chief :)

In fact I did like to have a look at SMS Plus source code because I thought it had AdHoc network support ... but I was wrong. The only source code with AdHoc support I could find are NJ's emulators (MVSPSP, CPS1PSP ...), I can compile them but they crash (when I compile them without AdHoc support they run OK).
I really need some working AdHoc code to complete my OSLib game, it would be really wonderfull if someone post some :)
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Sorry, I can't help you, because I don't have two PSP (nor do I have a wifi network at home) so I've never been interested in wifi ^^
But I've heard that somebody did it with OSLib, but it was long ago. Anyway, it's no different from a standard software without using OSLib. You can look at the original SMSPlus port by Chris Swindle, it does feature Adhoc wifi ;)
Sorry for my bad english
Image Oldschool library for PSP - PC version released
goebish
Posts: 29
Joined: Sat Oct 14, 2006 11:59 pm

Post by goebish »

Thanks a lot for your support Brunni :)

Some friends can lend me their PSPs while the week ends so I can test my wifi code.

I'll try to find the original SMSPlus port by Chris Swindle (I didn't know this version)

Edit: I found Chris Swindle sources code on QJ, I'll have a look at it this weekend
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)

I'm trying to use the OSLib...I think it's great. Good job. :)
I've got a question: can I draw text on an image?
I found nothing in the documentation.

Many thanks.
Ciaooo
Sakya
goebish
Posts: 29
Joined: Sat Oct 14, 2006 11:59 pm

Post by goebish »

You can use oslPrintf_xy to print text where you want on the screen. If you use this function after drawing your image the text can be printed on it.
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)
goebish wrote:You can use oslPrintf_xy to print text where you want on the screen. If you use this function after drawing your image the text can be printed on it.
Thaks, I know. :)
I was asking because if I have "a lot" of text over an image I think it's faster to draw it once over the image and then draw only the image then drawing the image and all the text at every frame.

Ciaooo
Sakya
goebish
Posts: 29
Joined: Sat Oct 14, 2006 11:59 pm

Post by goebish »

Sorry, I can't understand what you want ... maybe you should have a look at the clipping functions, but I'm not sure.

Drawing a full screen of text on every frame should not drop performances too much anyway
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)
goebish wrote:Sorry, I can't understand what you want ... maybe you should have a look at the clipping functions, but I'm not sure.

Drawing a full screen of text on every frame should not drop performances too much anyway
Thanks for your reply.
Sorry for my english. :)

I want:
1.load an image
2.draw all the text over this image
3.draw this image at every frame

instead of
1.load an image
2.draw the image at every frame
3.draw all the text at every frame

Ciaooo
Sakya
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)

Is there a way to calculate the width/height of a text in pixel?
How can I adjust text to the right? :)

Many thanks
Ciaooo
Sakya
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Sorry for the late reply again, I was not at home these last days ^^
Sayka> You can, using oslSetDrawBuffer.
First, load your image, make sure to put it in VRAM, the GPU can't write to conventional RAM.
Set it as a drawbuffer (using oslSetDrawBuffer).
Draw your text on it like you would on the screen. It will be drawn to the image you set as drawbuffer instead of the screen.
Restore the original drawbuffer (the screen) using oslSetDrawBuffer(OSL_DEFAULT_BUFFER).
Do anything you want with your image ;)
sakya wrote:Hi! :)

Is there a way to calculate the width/height of a text in pixel?
How can I adjust text to the right? :)

Many thanks
Ciaooo
Sakya
Look at the text.c file in the source, I think you'll understand easily how oslDrawString works.
Basically you've got an array in the current font (osl_curFont) containing the width of every character. Use osl_curFont->charWidths[yourCar] to get its width. The height is fixed for all characters in each fonts, you can get it with osl_curFont->charHeight. I think MMSPlus includes a function that calculates the width of a string, but I'm not sure anymore.
goebish wrote:Drawing a full screen of text on every frame should not drop performances too much anyway
Effectively it doesn't. Drawing your text directly on the image is a bit faster but it becomes only critical if you draw that image say 20 or 50 times per frame.
The (only) advantage of drawing text directly on an image is if you want to get the whole thing transparent, else you'll get a semi-transparent image plus a semi-transparent text over it, making a double-semi-transparent = 1/4 transparent text instead of 1/2. It's also okay if you want to scale or rotate your text.
Please note that putting an image to VRAM (for drawing) is not always a good idea. It's much faster for drawing but the VRAM is quite small (2 MB, minus the screen drawbuffer, that is 557 kB or 1.12 MB respectively for 16 or 32-bit mode) and should be reserved to critical images (drawn a lot of times, like map tilesets).
If you only use that image once per frame, you can copy it back to RAM after you finished drawing on it and delete the original one in VRAM to spare some VRAM.
Sorry for my bad english
Image Oldschool library for PSP - PC version released
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)
Brunni wrote:Sayka> You can, using oslSetDrawBuffer.
[...]
If you only use that image once per frame, you can copy it back to RAM after you finished drawing on it and delete the original one in VRAM to spare some VRAM.
Wow, many thanks for the reply. I think I undestand (I'm not an experienced C/C++ coder). :)

Ciaooo
Sakya
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

sakya wrote:Hi! :)
Brunni wrote:Sayka> You can, using oslSetDrawBuffer.
[...]
If you only use that image once per frame, you can copy it back to RAM after you finished drawing on it and delete the original one in VRAM to spare some VRAM.
Wow, many thanks for the reply. I think I undestand (I'm not an experienced C/C++ coder). :)

Ciaooo
Sakya
You're welcome ^^
Btw that not really has to do with C/C++, look at oslCreateImageCopy(sourceImage, newLocation) and oslDeleteImage(anyImage). Please remember that for images placed in VRAM OSLib acts like a stack, so the last image created must be the first deleted, and so on ;)
Sorry for my bad english
Image Oldschool library for PSP - PC version released
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

Hey Brunni! Thanks for this awsome lib, im using it to make my next (first!) game, and im loving it so far, but i have one small problem.

Im not sure if its a bug, or me not understanding exactly what a buffer is, but i have this code:

Code: Select all

#define draw oslDrawImage

...

// Create draw buffer in VRAM
	OSL_IMAGE *screen = oslCreateImage(WIDTH,HEIGHT,OSL_IN_VRAM,OSL_PF_8888);
	oslSetDrawBuffer(screen);
			
	if (curState->menu == TRUE) {
		menuBack->angle++;
		if (menuBack->angle==360) menuBack->angle=0;
		draw(menuBack);
	}
	
	oslSetDrawBuffer(OSL_DEFAULT_BUFFER); // Restore default buffer
	screen->centerX = screen->sizeX/2; // Use center of screen buffer
	screen->centerY = screen->sizeY/2;
	screen->x = WIDTH/2;
	screen->y = HEIGHT/2;
	draw(screen);
	oslDeleteImage(screen);
	//End of display code
	oslEndDrawing();
	//Synchronization
	oslSyncFrame();
And 'menuBack' is being drawn under 'screen'. Shouldnt oslDrawImage draw onto the current buffer, which would be 'screen' in this case?
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Thanks :)
If I understand your code correctly, you are drawing 'menuback' on 'screen' and then drawing 'screen' on 'OSL_DEFAULT_BUFFER', so it's normal that 'menuback' appears, it's like if you draw a character (menuback) on a sheet of paper (screen) and then look at it with your eyes (OSL_DEFAULT_BUFFER), you'll see the character (menuback) ;)
Sorry for my bad english
Image Oldschool library for PSP - PC version released
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

Brunni wrote:Thanks :)
If I understand your code correctly, you are drawing 'menuback' on 'screen' and then drawing 'screen' on 'OSL_DEFAULT_BUFFER', so it's normal that 'menuback' appears, it's like if you draw a character (menuback) on a sheet of paper (screen) and then look at it with your eyes (OSL_DEFAULT_BUFFER), you'll see the character (menuback) ;)
Thats the thing though, thats what i expect to happen, but menuback isnt being shown at all, like its underneath screen, or being drawn onto OSL_DEFAULT_BUFFER before screen.
goonjamin
Posts: 1
Joined: Sun Mar 25, 2007 10:09 am

Maps Sample Freeze

Post by goonjamin »

Hi,

I've installed OSlib 1.0 from brunni.dev-fr.org and tried to compile the maps sample found at http://oslib.palib.info/samples/.

Everything compiled fine and the program loads on my PSP. Everything works (scrolling, sound, adding and removing layers) except the screenshot function just freezes when I press select? I have no choice but to shutdown the PSP and restart.

I am using 3.03oe-c and running this from the GAME150 directory would that cause any problems with the screenshot function in this example?

Thanks for a great programing lib! :)
Shatai
Posts: 1
Joined: Fri Apr 06, 2007 8:06 pm

Post by Shatai »

With OSLib, how can I access map-specific data as to what type of tile lies at a particular coordinate of an OSL_MAP?

edit: nevermind, I am retarded.
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Re: Maps Sample Freeze

Post by Brunni »

goonjamin wrote:I am using 3.03oe-c and running this from the GAME150 directory would that cause any problems with the screenshot function in this example?
This is not normal. At least it works perfectly for me (3.10 OE-A'). Anyway I don't want to debug this now as I'm preparing the next version and a lot of things changed, however if you're still getting this problem with the next version, please contact me ;-)
Sorry for my bad english
Image Oldschool library for PSP - PC version released
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

seventoes wrote:
Brunni wrote:Thanks :)
If I understand your code correctly, you are drawing 'menuback' on 'screen' and then drawing 'screen' on 'OSL_DEFAULT_BUFFER', so it's normal that 'menuback' appears, it's like if you draw a character (menuback) on a sheet of paper (screen) and then look at it with your eyes (OSL_DEFAULT_BUFFER), you'll see the character (menuback) ;)
Thats the thing though, thats what i expect to happen, but menuback isnt being shown at all, like its underneath screen, or being drawn onto OSL_DEFAULT_BUFFER before screen.
Now that I think about it, you must make sure that the alpha in the drawbuffer is nonzero (or disable alpha by calling oslSetAlpha(OSL_FX_NONE, 0), or use a format that doesn't contain alpha: OSL_PF_5650) else nothing will be drawn because alpha=0 means a transparent pixel. You can clear the image by yourself if you want:

Code: Select all

u32 backColor = oslConvertColor(image->pixelFormat, OSL_PF_8888, RGBA(0, 0, 0, 255));
oslClearImage(image, backColor);
Note that the convertcolor is not necessary, it's just here to ensure that the color will be in the same pixel format as the image. The important thing is: alpha is 255, that is, opaque.
Sorry for my bad english
Image Oldschool library for PSP - PC version released
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

Brunni wrote: Now that I think about it, you must make sure that the alpha in the drawbuffer is nonzero (or disable alpha by calling oslSetAlpha(OSL_FX_NONE, 0), or use a format that doesn't contain alpha: OSL_PF_5650) else nothing will be drawn because alpha=0 means a transparent pixel. You can clear the image by yourself if you want:

Code: Select all

u32 backColor = oslConvertColor(image->pixelFormat, OSL_PF_8888, RGBA(0, 0, 0, 255));
oslClearImage(image, backColor);
Note that the convertcolor is not necessary, it's just here to ensure that the color will be in the same pixel format as the image. The important thing is: alpha is 255, that is, opaque.
Aha! That worked perfectly, thanks brunni! Cant wait for the next version of OSLib! (feature request: drawing an image with specific alpha ;) )
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

seventoes wrote:Aha! That worked perfectly, thanks brunni! Cant wait for the next version of OSLib!
Thanks! I hope you'll be happy with it ;-)
seventoes wrote:(feature request: drawing an image with specific alpha ;) )
Huh? I don't understand what you're requesting. Can't oslSetAlpha do what you want?
Sorry for my bad english
Image Oldschool library for PSP - PC version released
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

Brunni wrote:
seventoes wrote:(feature request: drawing an image with specific alpha ;) )
Huh? I don't understand what you're requesting. Can't oslSetAlpha do what you want?
Not really, i mean kind of like oslDrawImageXY, but with alpha instead of XY, for example i could draw an image all blue and semi-transparent by calling oslDrawImageAlpha(image,RGBA(0,0,255,100));

Right now there isnt (or im not seeing!) a way to do anything like that. Any advice? :)
nDEV
Posts: 48
Joined: Fri Apr 13, 2007 1:26 am

Post by nDEV »

Please a little help here:
http://forums.ps2dev.org/viewtopic.php?t=8168
!!
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

seventoes wrote:
Brunni wrote:
seventoes wrote:(feature request: drawing an image with specific alpha ;) )
Huh? I don't understand what you're requesting. Can't oslSetAlpha do what you want?
Not really, i mean kind of like oslDrawImageXY, but with alpha instead of XY, for example i could draw an image all blue and semi-transparent by calling oslDrawImageAlpha(image,RGBA(0,0,255,100));

Right now there isnt (or im not seeing!) a way to do anything like that. Any advice? :)
With this version:

Code: Select all

void oslDrawImageAlpha(OSL_IMAGE *img, OSL_COLOR alpha)
{
   //Save current alpha params
   int oldEffect = osl_currentAlphaEffect, oldAlpha = osl_currentAlphaCoeff;
   //Temporarily set alpha
   oslSetAlpha(OSL_FX_ALPHA | OSL_FX_COLOR, alpha);
   oslDrawImage(img);
   //Restore old value
   oslSetAlpha(oldEffect, oldAlpha);
}
With the new version:

Code: Select all

void oslDrawImageAlpha(OSL_IMAGE *img, OSL_COLOR alpha)
{
   //Save current alpha params
   OSL_ALPHA_PARAMS p;
   oslGetAlphaEx(&p);
   oslSetAlpha(OSL_FX_TINT, alpha);
   oslDrawImage(img);
   oslSetAlphaEx(&p);
}
Raw method (the alpha mode must be OSL_FX_DEFAULT):

Code: Select all

void oslDrawImageAlpha(OSL_IMAGE *img, OSL_COLOR alpha)
{
   //Does not resotre original alpha value, so next images will also appear tinted unless you issue a oslSetAlpha(OSL_FX_DEFAULT, 0) after this call
   sceGuAmbientColor(alpha);
   oslDrawImage(img);
}
Sorry for my bad english
Image Oldschool library for PSP - PC version released
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

ohhh thanks, that should work just fine.

any release date estimate? :)
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

I don't know exactly yet, but there should be a beta very soon, and the final 2.0 (with new samples and documentation) in planned for summer (as Yodajr is unavailable until then) ;-)
Sorry for my bad english
Image Oldschool library for PSP - PC version released
Yodajr
Posts: 13
Joined: Sat Sep 24, 2005 7:04 pm

Post by Yodajr »

Huhuhu... I'll do my best ;)
Tutorials about OSLib here
nDEV
Posts: 48
Joined: Fri Apr 13, 2007 1:26 am

Post by nDEV »

Brunni , can you help me a little with your library?

Brunni, pouvez-vous m'aider avec votre bibliothèque ? (translation by babel fish)

Please because you're the only one who can.
Svp parce que vous êtes le seul qui peut. (translation by babel fish)

Here's my code for the animation!
Voici mon code pour l'animation ! (translation by babel fish)
s++;
oslSetImageTileSize(Soldier_dead,(s * 30),0,30,47);
if (s>soldier_max_frame) s=0;
Do you know how i can create a new instance of the object every time?
Savez-vous je peux créer un nouvel exemple de l'objet chaque fois ?(translation by babel fish)
Post Reply