[Interested?] OldSchool Library

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

Moderators: cheriff, TyRaNiD

Post Reply
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

BigNastyCurve wrote:question about 1.0:

This works:

intro = oslLoadImageFile("splash_32.png", OSL_IN_RAM, OSL_PF_8888);



This doesn't work:

intro = oslLoadImageFile(".\\images\\splash_32.png", OSL_IN_RAM, OSL_PF_8888);


The file is in both locations. I was extremely puzzled at first because I couldn't get an image loaded to save my life. Then I moved it out into the eboot directory, changed my code and it worked. Is there a particular reason that I can't use subdirectories? I'd rather not have my assets all over the main directory if I can help it.

Thanks...
I believe that you use unescaped forward slashes ( / ) in file paths for that function, and to make the path relative, just use like "images/splash_32.png", not "./images/splash_32.png".
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

BigNastyCurve wrote:question about 1.0:

This works:

intro = oslLoadImageFile("splash_32.png", OSL_IN_RAM, OSL_PF_8888);



This doesn't work:

intro = oslLoadImageFile(".\\images\\splash_32.png", OSL_IN_RAM, OSL_PF_8888);


The file is in both locations. I was extremely puzzled at first because I couldn't get an image loaded to save my life. Then I moved it out into the eboot directory, changed my code and it worked. Is there a particular reason that I can't use subdirectories? I'd rather not have my assets all over the main directory if I can help it.

Thanks...
The PSP, like every other sensible OS in creation, uses forward slashes for the path, not back slashes. Damn DOS...

A relative path would be like "data/datafile" while an absolute path would be like "ms0:/data/datafile".
goebish
Posts: 29
Joined: Sat Oct 14, 2006 11:59 pm

Post by goebish »

It's fantastic that you continue working on this project Brunni.
Keep up the good work !

edit: I just tested 2.0 alpha
- the install .bat files don't work, you have to copy includes and libs manually, in pspsdk and visual studio for the PC version
- filenames are now case sensitive when you load a file with an OSLib function, I took 1 hour to understand why my 1.0 code wouldn't work ;)
Last edited by goebish on Sat May 19, 2007 9:51 pm, edited 2 times in total.
nDEV
Posts: 48
Joined: Fri Apr 13, 2007 1:26 am

Post by nDEV »

Nice..!
BigNastyCurve
Posts: 9
Joined: Sun May 13, 2007 5:33 am

Post by BigNastyCurve »

J.F. wrote:The PSP, like every other sensible OS in creation, uses forward slashes for the path, not back slashes. Damn DOS...

A relative path would be like "data/datafile" while an absolute path would be like "ms0:/data/datafile".
Interestingly, the graphics.c/.h packages in the "standard" PSP tutorial allow you to use escaped backslashes when passing filenames, which is what confused me. Perhaps he does some translation behind the scenes, though I didn't look.

Another question, then: I want to adapt some TTF library code based on freetype2 that writes fonts to an image and/or screen as I've not had great success with the built-in font renderer in osl. I'm looking for a function call similar to

putPixelImage(pixel, i, j, image);

or

putPixelScreen(pixel, i, j);

in osl, but I'm not seeing either (obviously) or even a pixel data structure. Is this something I could remedy by rolling my own functions or am I just hosed?
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

goebish wrote:- the install .bat files don't work, you have to copy includes and libs manually, in pspsdk and visual studio for the PC version
You have to edit the .bat's to point to the right folder, it wont work usually by default.
goebish
Posts: 29
Joined: Sat Oct 14, 2006 11:59 pm

Post by goebish »

they point to the right folders, but not all files are copied.
seventoes
Posts: 79
Joined: Sun Oct 02, 2005 4:50 am

Post by seventoes »

goebish wrote:they point to the right folders, but not all files are copied.
Weird, it worked fine for me.
nDEV
Posts: 48
Joined: Fri Apr 13, 2007 1:26 am

Post by nDEV »

Is it possible to use vectors ?
I've tried this:

vector<OSL_IMAGE> *VEC;

but im just getting errors -.-..

Here's my make file:
TARGET = APP
OBJS = main.o core.o
INCDIR =
CFLAGS = -G4 -Wall -O2
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
STDLIBS= -losl -lpng -lz \
-lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm -lmad
LIBS=$(STDLIBS)$(YOURLIBS)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = APP
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
*******EDITED**********
I removed the first question , because i managed to fix the problem ;)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

BigNastyCurve wrote:
J.F. wrote:The PSP, like every other sensible OS in creation, uses forward slashes for the path, not back slashes. Damn DOS...

A relative path would be like "data/datafile" while an absolute path would be like "ms0:/data/datafile".
Interestingly, the graphics.c/.h packages in the "standard" PSP tutorial allow you to use escaped backslashes when passing filenames, which is what confused me. Perhaps he does some translation behind the scenes, though I didn't look.
Some examples/programs are written to compile in Windows/whatever for testing purposes. Prime example is SMS for the PS2. For those programs/examples, they need the ability to use backslashes for Windows when building for Windows for testing.
Another question, then: I want to adapt some TTF library code based on freetype2 that writes fonts to an image and/or screen as I've not had great success with the built-in font renderer in osl. I'm looking for a function call similar to

putPixelImage(pixel, i, j, image);

or

putPixelScreen(pixel, i, j);

in osl, but I'm not seeing either (obviously) or even a pixel data structure. Is this something I could remedy by rolling my own functions or am I just hosed?
http://brunni.dev-fr.org/oslib/doc/doxygen/index.html

Look at the images functions. You can oslCreateImage(), do oslGetImagePixelAdr() and fill in the pixel image, then oslDrawImage(). You can also create images from files. All sorts of good image functions in OSL. Just read the docs.
nDEV
Posts: 48
Joined: Fri Apr 13, 2007 1:26 am

Post by nDEV »

nDEV wrote:Is it possible to use vectors ?
I've tried this:

vector<OSL_IMAGE> *VEC;

but im just getting errors -.-..

Here's my make file:
TARGET = APP
OBJS = main.o core.o
INCDIR =
CFLAGS = -G4 -Wall -O2
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
STDLIBS= -losl -lpng -lz \
-lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm -lmad
LIBS=$(STDLIBS)$(YOURLIBS)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = APP
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
*******EDITED**********
I removed the first question , because i managed to fix the problem ;)
This one doesnt give any errors:

vector<OSL_IMAGE*> v;

but when i do this:

v.push_back(OSL_IMAGE*);

im getting errors....
Can someone help please???????????
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Thanks for your support and your bug reports ^^

I'm confused when you are saying that oslLoadImageFile is now case sensitive... there is no reason at all.
I'm using sceIoOpen and so on. Maybe fopen (like I was using before) wasn't? But fopen was a wrapper to sceIo anyway. That's something to investigate ^^
At least putting './directory' won't work because of a bug that I will correct (I take the first '.' to detect the extension instead of the last one). You don't need putting a . before the path anyway.

nDEV> What are the errors?

goebish> Which files are missing?
Sorry for my bad english
Image Oldschool library for PSP - PC version released
nDEV
Posts: 48
Joined: Fri Apr 13, 2007 1:26 am

Post by nDEV »

Brunni wrote:
nDEV> What are the errors?
I found out what i was doing wrong...with a little help!:
Link::
http://forums.ps2dev.org/viewtopic.php?t=8369

I have another question (hahaha!*evil laugh*).

When its time to release all objects , is it better to do it like this :

OSL_IMAGE *TEST;

if (TEST)oslDelteImage(TEST);
or this:
if (TEST)TEST=NULL;
or ..this:
if (TEST!=NULL)(TEST=NULL);

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

Post by Brunni »

I think you are mixing java objects and C structures (which are completely different)...
OSLib is C only, so setting a pointer to NULL won't free the associated memory (of course), it will just... set this pointer to NULL (which is usually a bad idea if your object hasn't been freed first because you'll loose any reference to that object, making a memory leak).
You HAVE to do oslDeleteImage, and maybe later set the pointer to null. If you want a clean way to eventually delete objects that may not have been loaded, you could do something like this:

Code: Select all

OSL_IMAGE *image = NULL;
//Creating an image &#40;if it doesn't exist yet&#41;
if &#40;image&#41;
    image = oslLoadImageFile&#40;....&#41;
//Deleting an image &#40;if it does exist; then set it to NULL to indicate it doesn't exist anymore&#41;
if &#40;image&#41;      &#123;
    oslDeleteImage&#40;image&#41;;
    image = NULL;
&#125;
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 »

I'm thinking about automatically swizzling images upon loading but I need your advice. You'll have to specify OSL_UNSWIZZLED to make sure it isn't swizzled, else it will be. Does this seem better to you?
Thanks in advance for your opinion
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 »

That sounds good to me! What would be the disadvantages?
Yodajr
Posts: 13
Joined: Sat Sep 24, 2005 7:04 pm

Post by Yodajr »

You can't modify swizzled images ;)
Tutorials about OSLib here
ector
Posts: 195
Joined: Thu May 12, 2005 10:22 pm

Post by ector »

Oh, you can absolutely modify swizzled images... It's just a tiny bit trickier :)
http://www.dtek.chalmers.se/~tronic/PSPTexTool.zip Free texture converter for PSP with source. More to come.
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Oh thank you. Now oslGet/SetImagePixel take swizzling in account. This is just a problem for people who are using the old method (raw access to image->data) but they will be warned (in the breaking changes section): if they want their old code to work, just put an oslSetImageAutoSwizzle(0) in the beginning of the code. For new projects, you can just specify the OSL_UNSWIZZLED flag at image loading.
I think this behaviour is ok. Many thanks for your advice ^^
Sorry for my bad english
Image Oldschool library for PSP - PC version released
KickinAezz
Posts: 328
Joined: Sun Jun 03, 2007 10:05 pm

Post by KickinAezz »

I've always wondered, Brunni = pspdonkey from psp-hacks? Bcoz he once updated osl to include OslShowpsphacksLogo.
User avatar
LOREK
Posts: 4
Joined: Fri Jun 08, 2007 4:45 pm
Location: Gliwice, Poland
Contact:

Post by LOREK »

How to use oslib2 pc version with "emu.h"?
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Hmm it's like the first version (OSLib 1.0). What is the problem?
No I'm not pspdonkey. Other people can use the logo if they want because the source is available on my site ;)
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 »

LOREK> Ok, now I can answer you precisely ^^
I'm sorry, I'll have to do something more about this PC version, I haven't tested it at all since the 2.0 release (I always use PSPLink, it's a bit more handy). I'll try to fix it and improve a bit for the next release. For now, here is what you can do if you want to begin from zero (you can also use the OSLib pack from Yodajr, which includes cygwin, pspsdk, OSLib, tools and everything you need; but it's always good to know how to do):
- Install Visual C++ Express 2008.
- Modify the Install.bat in the PC directory of the OSLib zip to make it point to C:\Program Files\Microsoft Visual Studio 9.0 instead of 8. Also, the script is missing to copy some files, so modify the lines that copy individual .h files with:
copy *.h "%VCDIR%\include\oslib"
- Execute that Install.bat.
- Create a new, empty Win32 project.
- Add a main.cpp file,
- Paste your sample code in it.
- Right click on your project (just below the solution, containing 1 project),
- Select Properties,
- In the left treeview, select Linker, Input. In the additional dependencies rightwards, add oslib.lib libpng.lib libz.lib opengl32.lib glu32.lib
- Compile with F7, it will probably give an error that "GL/GlExt.h" not found, double click on that error, it will bring you to the line #include "GL/glext.h", which you can comment out.
- Press Ctrl+F5 to compile and launch it directly.
Tip: For a better compilation time, you may try to put the following libraries in the linker, input, additional dependencies section: advapi32.lib gdi32.lib user32.lib oslib.lib opengl32.lib glu32.lib libcmt.lib libpng.lib libz.lib and set Yes (/NODEFAULTLIB) in the Ignore All Default Libraries section.
Hope it helps,
Brunni

Btw I'm sorry if this topic seems dead, I'm still developping this library actively but most people ask their questions on playeradvance and not here.

Has anyone found bugs, ideas or something that can help me for further development? :)
Last edited by Brunni on Sat Aug 11, 2007 4:21 am, edited 1 time in total.
Sorry for my bad english
Image Oldschool library for PSP - PC version released
User avatar
LOREK
Posts: 4
Joined: Fri Jun 08, 2007 4:45 pm
Location: Gliwice, Poland
Contact:

Post by LOREK »

Thank too answer Brunni! I needed this solution when I bricked my PSP because I couldn't test my games. Currently my PSP is OK and I can continue work over game already.
OSLib is the best for creation 2D games like GBA games! I wish you success in farthest deployment this library! I write on your library shooter game like Contra(NES).

PS.
I use devkitPSP from DevKitPro + Dev-Cpp + MinGw on the Win32 platform.
In the nearest future I will upload alpha demo to this topic.

---> Sorry for my bad English :) <---
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

You're welcome. I'm glad you could unbrick your psp :)
Sorry for my bad english
Image Oldschool library for PSP - PC version released
oldrider
Posts: 4
Joined: Tue Oct 09, 2007 10:40 pm
Contact:

..

Post by oldrider »

Hi Brunni, how to use a Thread for loading images??
I´m can try a make loading system resource.
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

I've answered your question in your topic at playeradvance.org.
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! :)

Sorry to bother, but: is it possible to have the source code of OSLib version 2.10?
It seems only 1.0 source code has been released...why?

Many thanks
Ciaooo
Sakya
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

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

Post by sakya »

Hi! :)
hibbyware wrote:Take a look here --> http://brunni.dev-fr.org/index.php?page=pspsoft_oslib
Uhhhh..yesterday wasn't there.
Many thanks. :)

Ciaooo
Sakya
Post Reply