I'm a noob and I have a noob question for you. :)
I'm trying to play with sceDisplaySetBrightness but my program freeze when executing sceDisplaySetBrightness() the first time I press L or R.
Here's the code:
Code: Select all
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <psppower.h>
PSP_MODULE_INFO("Brightness Test ", 0x1000, 1, 1);
void sceDisplay_driver_9E3C6DC6(int a0,int a1);//a0 0-100,a1 = 0/1 (set to 0)
#define sceDisplaySetBrightness sceDisplay_driver_9E3C6DC6
void sceDisplay_driver_31C4BAA8(int *a0,int *a1);
#define sceDisplayGetBrightness sceDisplay_driver_31C4BAA8
// TWILIGHT ZONE! <do doo do doo>
/* 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;
}
// END OF TWILIGHT ZONE! <do doo do do>
int main() {
scePowerSetClockFrequency(222, 222, 111);
pspDebugScreenInit();
SetupCallbacks();
int curBrightness = 0;
SceCtrlData pad;
curBrightness = 100;
pspDebugScreenSetTextColor(0xffffff);
pspDebugScreenSetBackColor(0x000000);
pspDebugScreenInit();
pspDebugScreenSetXY(0, 23);
pspDebugScreenPrintf("Press L or R to change brightness");
pspDebugScreenSetXY(0, 24);
pspDebugScreenPrintf("Press TRIANGLE to exit");
while(1) {
pspDebugScreenSetXY(0, 15);
pspDebugScreenPrintf("Current brightness: %i", curBrightness);
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_LTRIGGER) {
if (curBrightness > 0){
curBrightness--;
sceDisplaySetBrightness(curBrightness, 0);
}
}else if(pad.Buttons & PSP_CTRL_RTRIGGER) {
if (curBrightness < 100){
curBrightness++;
sceDisplaySetBrightness(curBrightness, 0);
}
}else if(pad.Buttons & PSP_CTRL_TRIANGLE) {
break;
}
sceKernelDelayThread(100000);
}
sceKernelExitGame();
return(0);
}
Code: Select all
TARGET = bright
OBJS = main.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lpsppower -lpspdisplay_driver
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Brightness Test
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Many thanks. :)
Ciaooo
Sakya