› Foros › Multiplataforma › Desarrollo
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#ifdef PSP
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#endif
int i_Salir = 0;
int SDL_main(int argc, char *argv[])
{
SDL_Event eKeys;
SDL_Surface *pMainWindow;
SDL_Surface *pWallpaper;
SDL_Rect rMainWindow;
pWallpaper = IMG_Load("sphere2.png");
rMainWindow.x = 0;
rMainWindow.y = 0;
#ifdef PSP
SceCtrlData pad;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
#endif
pMainWindow = SDL_SetVideoMode( 480,
272,
32,
SDL_HWSURFACE|SDL_DOUBLEBUF );
SDL_Init (SDL_INIT_EVERYTHING);
while(!i_Salir)
{
#ifdef PSP
pspDebugScreenSetXY(0, 2);
#endif
SDL_FillRect(pMainWindow, NULL, 0);
SDL_BlitSurface ( pWallpaper, NULL, pMainWindow, &rMainWindow );
SDL_Flip(pMainWindow);
while( SDL_PollEvent( &eKeys ) )
{
if( eKeys.key.keysym.sym == SDLK_ESCAPE ||
eKeys.type == SDL_QUIT ) {
i_Salir=1;
}
}
}
#ifdef PSP
sceKernelExitGame();
#endif
SDL_FreeSurface ( pMainWindow );
SDL_FreeSurface ( pWallpaper );
return 0;
}
# Nombre de la aplicación y ficheros para la compilación
TARGET = Ejemplo001
OBJS = main.o hddlib.o
PSPSDK = $(shell psp-config --pspsdk-path)
PSPDEV = $(shell psp-config -d)
PSPBIN = $(PSPDEV)/bin
SDL_CONFIG = $(PSPBIN)/sdl-config
CFLAGS = -O2 -G0 -Wall -D PSP
CFLAGS += $(shell $(SDL_CONFIG) --cflags)
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBS = -lstdc++ -lSDL_ttf -lfreetype -lSDL_image -ljpeg -lpng -lz -lm -lSDL_mixer -lvorbisidec -lmikmod -lmad $(shell $(SDL_CONFIG) --libs)
LIBS += -lpspaudiolib -lpspaudio -lpsppower
# Tipo de ejecutable que generara y titulo que tendra
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Ejemplo001
#PSP_EBOOT_PIC1 = hddissenyDev.png
include $(PSPSDK)/lib/build.mak
int exit_callback(int arg1, int arg2, void *common) {
i_Salir = 1;
sceKernelExitGame();
return 0;
}
// Llamada thread
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
// Configura llamada thread y vuelve a su thread id
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
#include "hddlib.hpp"
#include "press.hpp"
extern "C" int main(int argc, char** argv)
{
#ifdef PSP
SetupCallbacks();
#endif
gPressInit();
gPressLoadImages();
gPressLoop();
#ifdef PSP
SDL_Quit();
sceKernelExitGame();
#endif
}
#ifndef _HDDLIB_HPP_
#define _HDDLIB_HPP_
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_rotozoom.h>
#include <SDL/SDL_gfxPrimitives.h>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL_framerate.h>
#ifdef PSP
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
int exit_callback(int arg1, int arg2, void *common);
int CallbackThread(SceSize args, void *argp);
int SetupCallbacks(void);
#endif
...
...
...
...
...
#ifdef PSP
int exit_callback(int arg1, int arg2, void *common) {
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 thid;
}
#endif
...
...
...
while(! i_Salir)
{
...
}
class cHddFileSnd
{
public:
Mix_Music *p_music;
public:
void Load ( char *ch_UrlFile );
void Unload ();
void Play(int i_repeat);
void Pause() { Mix_PauseMusic ( );}
void Resume() { Mix_ResumeMusic ( );}
void Rewind() { Mix_RewindMusic ( );}
void Stop() { Mix_HaltMusic ( );}
void Uload() { Mix_FreeMusic ( p_music );}
void Volume(int i_volume) { Mix_VolumeMusic(i_volume); }
};
...
...
...
void cHddFileSnd::Load(char *ch_urlFile)
{
p_music = Mix_LoadMUS(ch_urlFile);
}
void cHddFileSnd::Play(int i_repeat)
{
Mix_PlayMusic(p_music , i_repeat) ;
}