Sign in to follow this  
Poitertjuh

[SOLVED] PSP development with SDL help needed

Recommended Posts

I hope there are people around on these forums who program games for psp...

anyway, for those of you who DO know something about it;

I need some help.

I wrote the following program (I know, it's rediculously simple program, but im just trying to make it work on psp)(Oh and I didnt really completely write it myself...)


main.c


#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <SDL.h>


#define printf pspDebugScreenPrintf


int main(int argc, char* args[])
{


//The images
SDL_Surface* hello =NULL;
SDL_Surface* screen = NULL;

//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );

//Set up screen
screen = SDL_SetVideoMode( 480, 272, 24, SDL_SWSURFACE );

//Load image
hello = SDL_LoadBMP( "hello.bmp" );

//Apply image to screen
SDL_BlitSurface( hello, NULL, screen, NULL );

//Update Screen
SDL_Flip( screen );

//Pause
SDL_Delay( 2000 );

SDL_FreeSurface( hello );

SDL_Quit();

return 0;
}





Makefile

TARGET = test
OBJS = main.o

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

LIBDIR =
LIBS = -lSDLmain -SDLmain
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = test

PSPSDK=$(shell psp-config --pspsdk-path)
PSPBIN = $(PSPSDK)/../bin
PSPBIN = $(PSPSDK)/../bin
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
LIBS += $(shell $(PSPBIN)/sdl-config --libs)
include $(PSPSDK)/lib/build.mak




I compile main.c, it completes without errors.

Then I make a folder in my psp under PSP/GAME and just dump all the files in there, the EBOOT.PBP, hello.bmp, Makefile (even though it's useless now)

When I start the game on my psp, It flashes 2 short lines of text for WAY too short to identify what it says, the screen stays black and after about 10 seconds my psp turns off.

Any ideas? I'd be very grateful.

[Edited by - Poitertjuh on September 26, 2010 7:15:24 AM]

Share this post


Link to post
Share on other sites
god, its been a LOOOOOONG time since I programmed with the unofficial SDK,

have you tried printf'ing after each line and pausing to see were it stops working?
Also, you shouldn't need the makefile in the psp/game folder




(ps. you should consider using the oslib rather than sdl on the PSP, it's hardware accelerated, so it's power is maximum.)

Share this post


Link to post
Share on other sites
yeah, Gage64 already pointed that out. Anyway, when I start the program, it now prints all the lines up to and including "sdl blitsurface works" (I edited the code to print the lines like gage said, but didnt edit my first post). So it freezes at SDL_Flip....

Share this post


Link to post
Share on other sites
I meant you should check the return values of the functions to make sure they succeed. The printfs won't tell you that. If a function fails, use SDL_GetError() to learn why.

Share this post


Link to post
Share on other sites
The problem lies with SDL_BlitSurface().

I modified main.c, it now says

//Apply image to screen
if (SDL_BlitSurface(hello, NULL, screen , NULL)==-1)
{
printf(SDL_GetError());
}

printf("blit surface works");

//Update Screen
if (SDL_Flip( screen ) == -1)
{
// Unrecoverable error, exit here.
printf("SDL_flip failed: %s\n", SDL_GetError());
}
The output is as follows:

SDL_Upperblit passed a NULL surface
blit surface works




So even though it seemed like the problem lies with SDL_Flip(), it says SDL_Upperblit passed a NULL surface, and the problem must lie there.

This COULD mean that the BMP actually never loads...

Share this post


Link to post
Share on other sites
Quote:
Original post by Poitertjuh
So even though it seemed like the problem lies with SDL_Flip(), it says SDL_Upperblit passed a NULL surface, and the problem must lie there.


Now you know why logging can't replace error-checking. [smile] (though it can certainly complement it.)

Quote:
This COULD mean that the BMP actually never loads...


So you should check SDL_LoadBMP() in the same way. [smile]

Share this post


Link to post
Share on other sites
Ok so I tried that... I updated main.c to include this:

//Load image
hello = SDL_LoadBMP( "hello.bmp" );
if (hello == NULL)
{
printf(SDL_GetError());
}

It doesnt print an error, meaning it should have loaded the image just fine. However SDL_Upperblit still passes a NULL surface... Really I don't understand what it could be anymore...


EDIT: And yes I sure did learn the purpose of SDL_GetError. Thank you!

Share this post


Link to post
Share on other sites
SDL_SetVideoMode fails and GetError says "Couldn't find requested mode". This has to do with the fourth parameter, "SDL_SWSURFACE". I'm gonna try using HWSURFACE, FULLSCREEN, any mode until I find what the psp understands.


EDIT: Changing SWSURFACE to HWSURFACE fixed it. Thanks a lot for helping me out here. I appreciate it! Consider this problem solved! This makes me so happy!!!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this