Code: Select all
/*
Program Name: Fuckin Around - Part Deux
Author: Mark Pereira
Date: Wed Feb 8, 1:19AM
*/
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"
#define printf pspDebugScreenPrintf
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
PSP_MODULE_INFO("Fuckin Around - Part Deux", 0, 1, 1);
/* 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 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;
}
int main(){
SceCtrlData pad;
char buffer[200];
Image* ourImage;
pspDebugScreenInit();
SetupCallbacks();
initGraphics();
sprintf(buffer, "meDude.png");
ourImage = loadImage(buffer);
if(!ourImage){
//Image load failed
printf("Image load failed!\n");
}else{
int x = 0;
int y = 0;
sceDisplayWaitVblank();
blitAlphaImageToScreen(0, 0, 32, 32, ourImage, x, y);
while(1){
sceDisplayWaitVblankStart();
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_LEFT){
if(x>0){x--;}
}
if(pad.Buttons & PSP_CTRL_RIGHT){
if(x<480-32){x++;}
}
if(pad.Buttons & PSP_CTRL_UP){
if(y>0){y--;}
}
if(pad.Buttons & PSP_CTRL_DOWN){
if(y<272-32){y++;}
}
}
flipScreen();
}
sceKernelSleepThread();
return 0;
}