#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <stdio.h>
#include <psppower.h>
#include "graphics.h"
PSP_MODULE_INFO("Backgrou nd Changer",0,1,1);
#define RGB(r,g,b) ((r) \ ((g)<<8) \ ((b)<<16))
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);
sceKernelRegisterExitCall back(cbid);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("up date_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid , 0, 0);
}
return thid;
}
int main(void){
scePowerSetClockFrequency (333, 333, 166);
SetupCallbacks();
initGraphics();
SceCtrlData pad;
int i;
int selComponent = 0;
char filler[10];
int bgR = 0;
int bgG = 0;
int bgB = 0;
Color highlightColor = RGB(200, 200, 200);
Color dimmedColor = RGB(100, 100, 100);
Color shadowColorH = RGB(55, 55, 55);
Color shadowColorD = RGB(55, 55, 55);
while(1){
sceCtrlReadBufferPositive (&pad, 1);
if(pad.Buttons & PSP_CTRL_UP){
if(selComponent > 0){
selComponent--;
}
for(i=0; i<10; i++){
sceDisplayWaitVblankStart ();
}
} else if(pad.Buttons & PSP_CTRL_DOWN){
if(selComponent < 2){
selComponent++;
}
for(i=0; i<10; i++){
sceDisplayWaitVblankStart ();
}
}
if(pad.Buttons & PSP_CTRL_RIGHT){
switch(selComponent){
case 0:
bgR++;
break;
case 1:
bgG++;
break;
case 2:
bgB++;
break;
default:
//Should Never Execute
break;
}
}else if(pad.Buttons & PSP_CTRL_LEFT){
switch(selComponent){
case 0:
bgR--;
break;
case 1:
bgG--;
break;
case 2:
bgB--;
break;
default:
//Should Never Execute
break;
}
}
if(bgR < 0){
bgR = 0;
} else if(bgR > 255){
bgR = 255;
}
if(bgG < 0){
bgG = 0;
} else if(bgG > 255){
bgG = 255;
}
if(bgB < 0){
bgB = 0;
} else if(bgB > 255){
bgB = 255;
}
fillScreenRect(RGB(bgR, bgG, bgB), 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
sprintf(filler, "RED: %i", bgR);
if(selComponent == 0){
printTextScreen(11, 10, filler, shadowColorH);
printTextScreen(10, 10, filler, highlightColor);
}else{
printTextScreen(11, 10, filler, shadowColorD);
printTextScreen(10, 10, filler, dimmedColor);
}
sprintf(filler, "GREEN: %i", bgG);
if(selComponent == 1){
printTextScreen(11, 20, filler, shadowColorH);
printTextScreen(10, 20, filler, highlightColor);
}else{
printTextScreen(11, 20, filler, shadowColorD);
printTextScreen(10, 20, filler, dimmedColor);
}
sprintf(filler, " BLUE: %i", bgB);
if(selComponent == 2){
printTextScreen(11, 30, filler, shadowColorH);
printTextScreen(10, 30, filler, highlightColor);
}else{
printTextScreen(11, 30, filler, shadowColorD);
printTextScreen(10, 30, filler, dimmedColor);
}
flipScreen();
for(i=0; i<1; i++){
sceDisplayWaitVblankStart ();
}
}
return 0;
}