My new prog im workin on, is basically just blending a few of the Yeldarb tut's, the Sprite, and MP3 . I boot it up, and after loading it just powers the PSP off.
Code: Select all
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspaudio.h>
#include <pspaudiolib.h>
#include <psppower.h>
#include <pspdisplay.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"
#include "mp3player.h"
#define printf pspDebugScreenPrintf
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common){
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp){
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its threat id */
int SetupCallbacks(void){
int thid;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0){
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int main(){
// Set the power frequency
scePowerSetClockFrequency(333, 333, 166);
SceCtrlData pad;
char hero_buffer[200];
/* char enemy_buffer[200]; */
Image* ourHero;
/* Image* ourEnemy; */
SetupCallbacks();
pspDebugScreenInit();
initGraphics();
pspAudioInit();
MP3_Init(1);
MP3_Load("Camron, Jim Jones - I Am Dame Dash.mp3");
MP3_Play();
sprintf(hero_buffer, "character.png");
ourHero = loadImage(hero_buffer);
/* sprintf(enemy_buffer, "enemyDude.png");
ourEnemy = loadImage(enemy_buffer); */
if(!ourHero){
//Image load failed
printf("Image load failed!\n");
}/*else if(!ourEnemy){
//Image load failed
printf("Image load failed!\n");
}*/else{
int hero_x = 0/*, enemy_x = 150*/;
int hero_y = 0/*, enemy_y = 0*/;
sceDisplayWaitVblankStart();
while(1){
clearScreen(0);
blitAlphaImageToScreen(0, 0, 32, 32, ourHero, hero_x, hero_y);
/* blitAlphaImageToScreen(0, 0, 32, 32, ourEnemy, enemy_x, enemy_y); */
sceCtrlReadBufferPositive(&pad, 1);
//meDude controls
if(pad.Buttons & PSP_CTRL_LEFT){
if(hero_x>0){hero_x--;}
}
if(pad.Buttons & PSP_CTRL_RIGHT){
if(hero_x<(480-32)){hero_x++;}
}
if(pad.Buttons & PSP_CTRL_UP){
if(hero_y>0){hero_y--;}
}
if(pad.Buttons & PSP_CTRL_DOWN){
if(hero_y<(272-32)){hero_y++;}
}
/* Enemy Controls
if(pad.Buttons & PSP_CTRL_SQUARE){
if(enemy_x>0){enemy_x--;}
}
if(pad.Buttons & PSP_CTRL_CIRCLE){
if(enemy_x<(480-32)){enemy_x++;}
}
if(pad.Buttons & PSP_CTRL_TRIANGLE){
if(enemy_y>0){enemy_y--;}
}
if(pad.Buttons & PSP_CTRL_CROSS){
if(enemy_y<(272-32)){enemy_y++;}
} */
//if the MP3 finishes, stop it.
if(MP3_EndOfStream() == 1){
MP3_Stop();
}
sceDisplayWaitVblank();
flipScreen();
}
}
/* Stop MP3 & Free Memory */
MP3_Stop();
MP3_FreeTune();
sceKernelSleepThread();
return 0;
}
Code: Select all
TARGET = gamebeta
OBJS = mp3player.o graphics.o framebuffer.o game.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lpspgu -lpng -lz -lm -lmad -lpspaudiolib -lpspaudio -lpsppower
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = MP3 Player Example
PSPSDK=/usr/local/pspdev/psp/sdk
include $(PSPSDK)/lib/build.mak