Advertising (This ad goes away for registered users. You can Login or Register)

[Solved] OSLibMODv2 not loading PNGs [MinPSPW][Windows 7]

Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
Post Reply
yazder
Posts: 8
Joined: Thu Aug 28, 2014 1:49 pm

[Solved] OSLibMODv2 not loading PNGs [MinPSPW][Windows 7]

Post by yazder » Sun Dec 28, 2014 2:22 am

First of all sorry for the length of the post :oops: .

I need help loading PNG files with OsLibMODv2, I recently installed MinPSPW 0.11.2r3 and I compiled the OSLib "hello world" sample located at C:\pspsdk\psp\sdk\samples\oslib_mod. It compiled fine but when executed on a PSP 3000 (on 6.60 PRO-C) & PSP 1000 (on 5.00 m33) a message box is displayed saying that "bkg.png" couldn't be located (I copied it inside the folder containing the eboot), so reading around somebody said that the version of OSLibMod included in MinPSPW had some bugs and had broken PNG file support and that it should be updated.

So I downloaded a copy of the OSLibModv2 headers, samples and the libols.a from here: https://github.com/dogo/oslibmodv2
and then I replaced libosl.a from the git repository to C:\pspsdk\psp\lib, then I deleted the contents of C:\pspsdk\psp\include\oslib and replaced them by the haders and folders of oslibmodv2-master\src, and then the samples from the git repository to C:\pspsdk\psp\sdk\samples\oslib_mod

So after the previous steps I took, I recompiled the sample, copied it to psp's PSP\GAME\OslibHello\ folder along with the bkg.png provided by the OSLibMODv2 samples and I got the same message as before (could not locate "bkg.png") so It didn't fix the problem, then I created my own bkg.png file in Paint.NET saving it with a 24-bit depth, replaced the one I copied before and got the same error message box.

Then I modified the main.c file of the sample and I could confirm that it has a problem loading PNG files:

main.c

Code: Select all

#include <pspkernel.h>
#include <oslib/oslib.h>

PSP_MODULE_INFO("Hello World", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
PSP_HEAP_SIZE_KB(12*1024);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Init OSLib:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int initOSLib(){
    oslInit(0);
    oslInitGfx(OSL_PF_4444, 1);
    oslInitAudio();
    //oslSetQuitOnLoadFailure(1);
    oslSetKeyAutorepeatInit(40);
    oslSetKeyAutorepeatInterval(10);
    return 0;
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(){
    int skip = 0;

    initOSLib();
    oslIntraFontInit(INTRAFONT_CACHE_MED);

    //Loads image:
    OSL_IMAGE *bkg = oslLoadImageFilePNG("bkg.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_4444);
	if(bkg == NULL)
		oslPrintf_xy(0, 0, "Image: 'bkg.png' - not loaded");
	
    //Load font:
    OSL_FONT *pgfFont = oslLoadFontFile("flash0:/font/ltn0.pgf");
    oslIntraFontSetStyle(pgfFont, 1.0, RGBA(255,255,255,255), RGBA(0,0,0,0), INTRAFONT_ALIGN_LEFT);
    oslSetFont(pgfFont);

    while(!osl_quit){
        if (!skip){
            oslStartDrawing();
			
			if(bkg != NULL)
				oslDrawImageXY(bkg, 0, 0);
            oslDrawString(180, 150, "Hello world");
            oslDrawString(150, 250, "Press X to quit");

            oslEndDrawing();
        }
        oslEndFrame();
        skip = oslSyncFrame();

        oslReadKeys();
        if (osl_keys->released.cross)
            oslQuit();
    }
    //Quit OSL:
	oslDeleteImage(bkg);
    oslEndGfx();

    sceKernelExitGame();
    return 0;

}
^ By commenting out oslSetQuitOnLoadFailure(1) and checking for the return of oslLoadImageFilePNG I'm able to get the Hello World message, although it doesn't load the PNG file since oslLoadImageFilePNG returns NULL.

Makefile:

Code: Select all

TARGET = helloworld
OBJS = main.o

#To build for custom firmware:
BUILD_PRX = 1
PSP_FW_VERSION=371

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

MYLIBS=
STDLIBS= -losl -lpng -lz \
         -lpsphprm -lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspgum  -lpspaudiolib -lpspaudio -lpsphttp -lpspssl -lpspwlan \
         -lpspnet_adhocmatching -lpspnet_adhoc -lpspnet_adhocctl -lm -ljpeg
LIBS=$(STDLIBS) $(MYLIBS)

LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Hello World
#PSP_EBOOT_ICON = ICON0.PNG
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
So now after browsing the headers of the OSLibMODv2 I realized that OSLibMODv2 (C:\pspsdk\psp\include\oslib) contains a PNG header that says its version is 1.5.7.

The MinPSPW has another png header in C:\pspsdk\psp\include\libpng14\ which says its version is 1.4.4,
and yet another one in C:\pspsdk\psp\include\ which is also 1.4.4, so at this point I'm wondering if those 3 headers interfere with each other when creating the eboot of the hello world sample and if it is how should I avoid it?

Thanks for reading everything I wrote :D and please be easy on me, I'm a noob on the PSP scene and also I don't have much experience in general development. (But I'm working on it ;) )

P.S. I choose OSLibMOD since it seems simple and easy to use and I want to port a game I made using Allegro 5 with C... It is a clone of ConSumo (the arcade game from Bully and Bully: Scholarship Edition by Rockstar Games)
Advertising
Last edited by yazder on Sun Dec 28, 2014 4:38 pm, edited 1 time in total.

yazder
Posts: 8
Joined: Thu Aug 28, 2014 1:49 pm

Re: Help with OSLibMODv2 and loading PNGs [MinPSPW][Windows

Post by yazder » Sun Dec 28, 2014 5:39 am

EDIT: I got it working after some trial and error!

All I did was download this repository: https://github.com/pspdev/psp-ports and extract the libpng folder, then build it and replace every header of png (just png.h and pngconf.h)in C:\pspsdk for the ones in \psp-ports-master\libpng\ and also replaced the generated libpng.a to C:\pspsdk\psp\lib\ (replacing the one it was there) and that's it.

Well, I guess I'll have to switch to linux (since you have to build everything you install) or stay on Windows and try to build the libs as I use them :D (You know?, I prefer Windows because I do most of my coding with Notepad++ :lol: )

I hope this helps someone in the future that encounters the same problem.
Advertising

Post Reply

Return to “Programming and Security”