[Interested?] OldSchool Library

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

Moderators: cheriff, TyRaNiD

Post Reply
silverbyte
Posts: 18
Joined: Sun Apr 10, 2005 1:05 pm

Post by silverbyte »

BRUNNI, ton anglais et marvelous, puis arret de dir votre anglais et pas bon, parceque mon francais is WORSE!!! ;)

Your lib kicks ass. Love it. I have a couple of questions.

1) what does oslCreateSwizzledImage do? is this meant for loading images into VRAM ? there seems to be no documentation on this

2) in your maps/sound sourcecode with the 8 layers (very cool example) how do you create the maps.h file? is there a tool to convert png to c code? and does that support ALPHA? OSL_PF_8888

3) OSL_MAP ; oslDrawMapSimple ; oslCreateMap ; where can i get information on this, i don't understand how you are infinately scrolling in that maps/sound example.

Code: Select all

	nuages = oslCreateMap(
		nuagestileset,					
		nuages_map,				
		8,8,	                       //<---???
		64,34,
		OSL_MF_U16&#41;;		//<--???
__count
Posts: 22
Joined: Thu Mar 23, 2006 8:40 pm

Post by __count »

silverbyte wrote:BRUNNI, ton anglais et marvelous, puis arret de dir votre anglais et pas bon, parceque mon francais is WORSE!!! ;)

Your lib kicks ass. Love it. I have a couple of questions.

1) what does oslCreateSwizzledImage do? is this meant for loading images into VRAM ? there seems to be no documentation on this
Swizzled textures have reordered pixel data to optimize read access. I general you should swizzle all your textures because the performance difference is very significant.
silverbyte
Posts: 18
Joined: Sun Apr 10, 2005 1:05 pm

Post by silverbyte »

ok so i load my image
tmpImg = oslLoadImageFile(filename, OSL_IN_RAM, OSL_PF_8888);

then i swizzle it, and use the swizzle image
newImg = oslCreateSwizzledImage(temp, OSL_IN_VRAM);

makes sense, thanx __count.

Anyone know the answer to #2 and #3 in my previous post?
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Post by Zettablade »

silverbyte wrote:ok so i load my image
tmpImg = oslLoadImageFile(filename, OSL_IN_RAM, OSL_PF_8888);

then i swizzle it, and use the swizzle image
newImg = oslCreateSwizzledImage(temp, OSL_IN_VRAM);

makes sense, thanx __count.

Anyone know the answer to #2 and #3 in my previous post?
Have you read the documentation? It's very good.

I've been wondering how he did the maps.h code too. Probably by hand, but I'm not sure. I'll figure it out someday. There are tools to convert png to c(gimp can save images as c or h), but that's not the case here. If it were, there would be no reson to include the tilesets. Another reason why I think it was written by hand.

As for your 3rd question, read through the documentation and source code til you understand how the whole thing works.
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Thanks ^^ I use GBA Graphics for converting & editing my maps, however it doesn't support alpha channel... :-(
Sorry for my bad english
Image Oldschool library for PSP - PC version released
silverbyte
Posts: 18
Joined: Sun Apr 10, 2005 1:05 pm

fantastic

Post by silverbyte »

thanx for the tip, heres a link for ppl who wanna convert there GRFX to C header style code (i have yet to try)

http://www.megagames.com/gba/files/gfx2gba.zip

(btw brunni you should include it in your tools as part of the OSLIB)

------------------------------------------------------------------------------------
nope.. it works but itz not what is used in his map.h file...

i spent several hours trying to find several tools, and none come close to the same output like the map.h

so brunni what do you use? is it your own converter?
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Yes, "GBA Graphics" is the software name (and yes it's written by me) ^^
Sorry for my bad english
Image Oldschool library for PSP - PC version released
silverbyte
Posts: 18
Joined: Sun Apr 10, 2005 1:05 pm

Post by silverbyte »

;) thanx for the tip

for others check out the thread (its a french forum)
http://www.playeradvance.org/forum/showthread.php?t=438

Pour télécharger le logiciel:
http://gbagraphics.palib.info/GBA_Graphics.zip (clic droit, enregistrer sous)

[translation]

To download the software:
http://gbagraphics.palib.info/GBA_Graphics.zip (right click, & save)

----------------------------------------------------------------------------------------

Im trying this here at work, and so far looks FANTASIC! the tool works great, better than all the tools i have seen so far, but i will better test this later on at home where i will try to get a working example.

[/img]
silverbyte
Posts: 18
Joined: Sun Apr 10, 2005 1:05 pm

Post by silverbyte »

i noticed your GBA graphics has something for COLLISION!!! ? does this mean you will be implementing a collision engine in OSLIB for PSP?
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Post by Zettablade »

silverbyte wrote:i noticed your GBA graphics has something for COLLISION!!! ? does this mean you will be implementing a collision engine in OSLIB for PSP?
oo, that would rock!
popcornx
Posts: 6
Joined: Tue Mar 14, 2006 7:56 am

Post by popcornx »

Everything works perfectly but, when I add sound, the screen starts to flicker, I'm not sure why.
23BDFFFCAFB1000423BD0004

"nothing is impossible, not if you could imagen it"
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Post by Zettablade »

popcornx wrote:Everything works perfectly but, when I add sound, the screen starts to flicker, I'm not sure why.
o rly? pm me the source and I'll see if I can fix it.
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Post by Zettablade »

ok, one quick question. How do I load my own font and use it? I know how to convert it into a oft, but how do I use the font?
nakuribon
Posts: 5
Joined: Mon Jul 10, 2006 6:45 am
Contact:

Post by nakuribon »

i have a problem... when i try to compile my code i get this:

Code: Select all

psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -G0 -Wall -O2   -c -o main.o main.c

psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -G0 -Wall -O2  -L. -L/usr/local/pspdev/psp/sdk/lib   main.o -losl -lpng -lz -lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspuser -lpspkernel -o theGame.elf

/usr/local/pspdev/psp/sdk/lib/libosl.a&#40;oslib.o&#41;&#58; In function `oslSystemMessage'&#58;
/home/Florian/oslib/oslib.c&#58;1071&#58; undefined reference to `sceUtilityGetSystemParamInt'
/home/Florian/oslib/oslib.c&#58;1073&#58; undefined reference to `sceUtilityGetSystemParamInt'
/home/Florian/oslib/oslib.c&#58;1092&#58; undefined reference to `sceUtilityMsgDialogInitStart'
/home/Florian/oslib/oslib.c&#58;1097&#58; undefined reference to `sceUtilityMsgDialogGetStatus'
/home/Florian/oslib/oslib.c&#58;1099&#58; undefined reference to `sceUtilityMsgDialogUpdate'
/home/Florian/oslib/oslib.c&#58;1103&#58; undefined reference to `sceUtilityMsgDialogShutdownStart'
/usr/local/pspdev/psp/sdk/lib/libpng.a&#40;pngerror.o&#41;&#58; In function `png_warning'&#58;
pngerror.c&#58;&#40;.text+0x14c&#41;&#58; relocation truncated to fit&#58; R_MIPS_GPREL16 against `_impure_ptr'
pngerror.c&#58;&#40;.text+0x1a8&#41;&#58; relocation truncated to fit&#58; R_MIPS_GPREL16 against `_impure_ptr'
pngerror.c&#58;&#40;.text+0x1ac&#41;&#58; relocation truncated to fit&#58; R_MIPS_GPREL16 against `_impure_ptr'
/usr/local/pspdev/psp/sdk/lib/libpng.a&#40;pngerror.o&#41;&#58; In function `png_error'&#58;
pngerror.c&#58;&#40;.text+0x2a8&#41;&#58; relocation truncated to fit&#58; R_MIPS_GPREL16 against `_impure_ptr'
pngerror.c&#58;&#40;.text+0x310&#41;&#58; relocation truncated to fit&#58; R_MIPS_GPREL16 against `_impure_ptr'
pngerror.c&#58;&#40;.text+0x314&#41;&#58; relocation truncated to fit&#58; R_MIPS_GPREL16 against `_impure_ptr'
/usr/local/pspdev/psp/sdk/lib/libpng.a&#40;pngrutil.o&#41;&#58; In function `png_handle_gAMA'&#58;
pngrutil.c&#58;&#40;.text+0xd08&#41;&#58; relocation truncated to fit&#58; R_MIPS_GPREL16 against `_impure_ptr'
/usr/local/pspdev/psp/sdk/lib/libpng.a&#40;pngrutil.o&#41;&#58; In function `png_handle_cHRM'&#58;
pngrutil.c&#58;&#40;.text+0x146c&#41;&#58; relocation truncated to fit&#58; R_MIPS_GPREL16 against `_impure_ptr'
pngrutil.c&#58;&#40;.text+0x14dc&#41;&#58; relocation truncated to fit&#58; R_MIPS_GPREL16 against `_impure_ptr'
/usr/local/pspdev/psp/sdk/lib/libpng.a&#40;pngrutil.o&#41;&#58; In function `png_handle_sRGB'&#58;
pngrutil.c&#58;&#40;.text+0x178c&#41;&#58; relocation truncated to fit&#58; R_MIPS_GPREL16 against `_impure_ptr'
collect2&#58; ld returned 1 exit status
make.exe&#58; *** &#91;theGame.elf&#93; Error 1

Execution terminated
does anyone know how to fix this? heres my Makefile:

Code: Select all

TARGET = theGame
OBJS = main.o

CFLAGS =  -G0 -Wall -O2
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

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

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = The Game

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include e&#58;/cygwin2/$&#40;PSPSDK&#41;/lib/build.mak
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Post by Zettablade »

Replace your makefile with this and tell me if it works.

Code: Select all

TARGET = theGame
OBJS = main.o

CFLAGS =  -G0 -Wall -O2
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

STDLIBS= -losl -lpng -lz \
		-lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm
LIBS=$&#40;STDLIBS&#41;$&#40;YOURLIBS&#41;

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = The Game

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
nakuribon
Posts: 5
Joined: Mon Jul 10, 2006 6:45 am
Contact:

Post by nakuribon »

nope, same thing

i have no idea whats going on, ive never had a problem with libpng before, i used the one that came with oslib and the one from the psp svn, both do the same thing. also whats with the undefined functions in oslib.o?
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Post by Zettablade »

you should probably update your libpng, your sdk, and maybe even the oslib.
nakuribon
Posts: 5
Joined: Mon Jul 10, 2006 6:45 am
Contact:

Post by nakuribon »

thats what im doing, im starting from scratch, and im going to use debian this time instead of stupid cygwin... windows never does anything right lol
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Post by Zettablade »

nakuribon wrote:thats what im doing, im starting from scratch, and im going to use debian this time instead of stupid cygwin... windows never does anything right lol
yeah, Cygwin installed perfectly on the computer I'm using, and my laptop, but for some reason it couldn't install on my other computer. Weird huh? Well, whatever works for you. Goodluck.
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Post by Zettablade »

Zettablade wrote:ok, one quick question. How do I load my own font and use it? I know how to convert it into a oft, but how do I use the font?
Just thought I'de resurface this. Brunni?
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Zettablade wrote:
Zettablade wrote:ok, one quick question. How do I load my own font and use it? I know how to convert it into a oft, but how do I use the font?
Just thought I'de resurface this. Brunni?
From the first page of this very thread...

oslLoadFontFile("yourfont")
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Post by Zettablade »

Insert_witty_name wrote:
Zettablade wrote:
Zettablade wrote:ok, one quick question. How do I load my own font and use it? I know how to convert it into a oft, but how do I use the font?
Just thought I'de resurface this. Brunni?
From the first page of this very thread...

oslLoadFontFile("yourfont")
Oh, didn't see that. I'll try it and see if it works :)

EDTI:: That just loads a font. thks, that helps, but how do I use the font I loaded?
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Post by Zettablade »

Also, The usb doesn't wanna work either... or I'm probably just doing it wrong.
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Sorry I didn't come for a while :-'
1) For USB you must be in kernel mode (you can create a user thread after you loaded the drivers, and use OSLib from either the user or kernel thread, but I recommend running it from the user one - as the rest of your code - for safety reasons).
* There is no more built-in support for USB in OSLib as it requires kernel mode (even if USB is not used), and I don't want to oblige using kernel mode.
2) yourfont = oslLoadFont("yourfont.oft"), then oslSetFont(yourfont) and oslPrintf, oslDrawString and so on ;)
Sorry for my bad english
Image Oldschool library for PSP - PC version released
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Hi,

I'm using OSlib to add sound to my engine, but I've run into a wierd problem.

If I play the sound once just before my main loop, it works fine.
But if I do this,

Code: Select all

	if&#40; joy->_triangle==1 &#41;
  	&#123;
  		oslStopSound&#40;snd&#41;;
  	oslPlaySound&#40;snd, 1&#41;;
  	&#125;
It's as if the sound is being played a thoushand times at quater of a second intervals.
Almost as if the oslstopsound was not working and it was buffering up a shedload of play calls. And it goes without saying what is audible is nothing like the original sound.
But the first method, play once before main loop sounds identical as to it does on the pc.

I think what you might need (Depending on what's causing this) is a channel system. Where by each play sound allocates a channel and returns it, and you can then stop the channel before playing the sound again.

Also will you be adding soundpitch to alter the pitch of a playing sound?


Nice lib btw.
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

ok I changed it to this,

Code: Select all

	if&#40; joy->_triangle==1 &#41;
  	&#123;
  		if&#40;playsnd==0&#41;
  		&#123;
  			playsnd = 1;
  			
  			oslPlaySound&#40;snd, 1&#41;;
  		&#125;
  		else
  		&#123;
  			
  		&#125;
  	&#125;
  	else
  	&#123;
  		playsnd = 0;
  	&#125;
and the sound now plays fine in the main loop, but only once. it never rings twice much to dismay of glenn close.
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Post by Zettablade »

You should use the oslib's built in control functions.

Code: Select all

	if&#40; osl_keys->pressed.triangle &#41;
  	&#123;
  		oslPlaySound&#40;snd, 1&#41;;
  	&#125;
That's a good technique for sound effects, and it should work if your playing music. Tell me how it goes.
SiW
Posts: 7
Joined: Wed Aug 10, 2005 2:31 am
Location: Whittemore, Iowa, USA
Contact:

Post by SiW »

How would I have an image scroll itself? I tried increasing offsetX0 and offsetX1, which works, but has a seam when it repeats. Any ideas?

Also, is there a complete example of drawing to an image? I tried the code snippet from the docs but that only worked in the PC test harness, not on the PSP.
nakuribon
Posts: 5
Joined: Mon Jul 10, 2006 6:45 am
Contact:

Post by nakuribon »

Brunni wrote:Sorry I didn't come for a while :-'
1) For USB you must be in kernel mode (you can create a user thread after you loaded the drivers, and use OSLib from either the user or kernel thread, but I recommend running it from the user one - as the rest of your code - for safety reasons).
* There is no more built-in support for USB in OSLib as it requires kernel mode (even if USB is not used), and I don't want to oblige using kernel mode.
2) yourfont = oslLoadFont("yourfont.oft"), then oslSetFont(yourfont) and oslPrintf, oslDrawString and so on ;)
Is there a new version of oslib out? oslDrawString doesn't seem to exist in the documentation or in oslib.h...
Fixed my compiler problems btw, everything's working perfectly under linux... stupid windows....
waterbottle
Posts: 3
Joined: Fri Jul 07, 2006 10:29 pm

Post by waterbottle »

Brunni wrote:It's not documented yet, but you have to create one with font2osl.exe (included in the tools folder) and then oslLoadFontFile("yourfont").
You can also convert an existing Windows font (run font2osl.exe without parameter for more info).
I tried running font2osl.exe but it only popsup for 1/10th of a second and then colses by it self..

it says:
Image

tried copying a font over to the directory but that didn't help.. Does anyone know whta to do?
Post Reply