Since it seems I wasn't the only one to have problems with these functions, here's a simple program that uses sceDisplaySetBrightness/sceDisplayGetBrightness and sceDisplayDisable/sceDisplayEnable
Code: Select all
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <psppower.h>
#include <pspdisplay.h>
PSP_MODULE_INFO("Brightness Test ", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
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
int sceDisplayEnable(void);
int sceDisplayDisable(void);
//Flag for exit from loop when user exits with HOME:
static int runningFlag = 1;
// TWILIGHT ZONE! <do doo do doo>
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
runningFlag = 0;
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, PSP_THREAD_ATTR_USER, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
// END OF TWILIGHT ZONE! <do doo do do>
int main() {
scePowerSetClockFrequency(222, 222, 111);
SetupCallbacks();
sceDisplaySetFrameBuf(NULL,0,PSP_DISPLAY_PIXEL_FORMAT_4444, PSP_DISPLAY_SETBUF_IMMEDIATE);
pspDebugScreenInit();
pspDebugScreenSetTextColor(0xffffff);
pspDebugScreenSetBackColor(0x000000);
pspDebugScreenSetXY(0, 0);
pspDebugScreenPrintf("Brightness test");
static int curBrightness = 0;
static int displayStatus = 1;
SceCtrlData pad;
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
sceDisplayGetBrightness(&curBrightness, 0);
pspDebugScreenSetXY(0, 22);
pspDebugScreenPrintf("Press START to turn display on/off");
pspDebugScreenSetXY(0, 23);
pspDebugScreenPrintf("Press L or R to change brightness");
pspDebugScreenSetXY(0, 24);
pspDebugScreenPrintf("Press TRIANGLE to exit");
while(runningFlag) {
pspDebugScreenSetXY(0, 15);
pspDebugScreenPrintf("Current brightness: %3.3i", curBrightness);
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_LTRIGGER) {
if (curBrightness > 0){
sceDisplaySetBrightness(--curBrightness, 0);
sceKernelDelayThread(100000);
}
}else if(pad.Buttons & PSP_CTRL_RTRIGGER) {
if (curBrightness < 100){
sceDisplaySetBrightness(++curBrightness, 0);
sceKernelDelayThread(100000);
}
}else if(pad.Buttons & PSP_CTRL_START) {
if (displayStatus == 1){
sceDisplayDisable();
displayStatus = 0;
}else{
sceDisplayEnable();
displayStatus = 1;
}
sceKernelDelayThread(400000);
}else if(pad.Buttons & PSP_CTRL_TRIANGLE) {
break;
}
}
sceKernelExitGame();
return(0);
}
Code: Select all
TARGET = bright
OBJS = main.o
CFLAGS = -O3 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lpspgu -lpspdisplay_driver -lpsppower
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Brightness Test
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Thanks to Art for his help.
Just a question: the program works fine, but compiling it I get an "implicit declaration of function 'sceDisplayDisable'" but cannot find any header file with sceDisplayDisable declared in my sdk...
EDIT: fixed code, no more "implicit declaration..." warning. ;)
Ciaooo
Sakya