Code: Select all
#include <SDL/SDL.h>
#include <pspdebug.h>
#include <pspkernel.h>
#define SCREEN_WIDTH 480
#define SCREEN_HEIGHT 272
PSP_MODULE_INFO("Przykladowa aplikacja SDL", 0, 1, 1);
PSP_HEAP_SIZE_KB(20480);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER|PSP_THREAD_ATTR_VFPU);
#define printf pspDebugScreenPrintf
int exit_callback( int arg1, int arg2, void *common )
{
sceKernelExitGame( );
return 0;
}
int CallbackThread( SceSize args, void *argp )
{
int cbid;
cbid = sceKernelCreateCallback( "Exit Callback", exit_callback, NULL );
sceKernelRegisterExitCallback( cbid );
sceKernelSleepThreadCB( );
return 0;
}
int SetupCallbacks( void )
{
int thid = 0;
thid = sceKernelCreateThread( "update_thread", CallbackThread, 0x11, 0xFA0, 0, 0 );
if(thid >= 0)
{
sceKernelStartThread( thid, 0, 0 );
}
return 0;
}
int InitVideo( )
{
if (SDL_Init( SDL_INIT_VIDEO ) != 0)
{
printf( "SDL_Init(): %s\n", SDL_GetError() );
SDL_Quit( );
return 1;
} else return 0;
}
int main( int argc, char **argv )
{
pspDebugScreenInit( );
SetupCallbacks( );
SDL_Surface *screen;
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE );
SDL_Surface *image;
SDL_Surface *temp;
temp = SDL_LoadBMP( "image.bmp" );
if( temp == NULL )
{
printf( "SDL_LoadBMP(): %s\n", SDL_GetError( ) );
}
image = SDL_DisplayFormat( temp );
if( image == NULL )
{
printf( "SDL_DisplayFormat( ): %s\n", SDL_GetError( ) );
}
SDL_FreeSurface( temp );
SDL_Rect src, dest;
src.x = 0;
src.y = 0;
src.w = image->w;
src.h = image->h;
dest.x = 100;
dest.y = 100;
dest.w = image->w;
dest.h = image->h;
SDL_Flip( screen );
SDL_Delay( 2500 );
SDL_FreeSurface( image );
return 0;
}
Here is my makefile:
Code: Select all
TARGET = hello
OBJS = sdl.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
EXTRA_TARGETS = EBOOT.PBP
LIBS = -lSDL -lGL -lz -lpng -lm -ljpeg -lpsppower_driver -lpspvfpu -lpsphprm -lpsprtc -lpspaudio -lpspgu -lpspirkeyb -lpsppower
PSP_EBOOT_TITLE = Test SDL
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
http://lysek.y0.pl/image.bmp