Jump to content
  • Advertisement
Sign in to follow this  
Poitertjuh

[SOLVED] PSP development with SDL help needed

This topic is 2828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!