Zitat:
#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))
/* 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);
sceKernelRegisterExitCall back(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
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, 1666);
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;
}
}
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;
}
errors are