sceDisplaySetBrightness problem

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

sceDisplaySetBrightness problem

Post by sakya »

Hi! :)

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&#40;"Brightness Test ", 0x1000, 1, 1&#41;;

void sceDisplay_driver_9E3C6DC6&#40;int a0,int a1&#41;;//a0 0-100,a1 = 0/1 &#40;set to 0&#41;
#define sceDisplaySetBrightness sceDisplay_driver_9E3C6DC6
void sceDisplay_driver_31C4BAA8&#40;int *a0,int *a1&#41;;
#define sceDisplayGetBrightness sceDisplay_driver_31C4BAA8

// TWILIGHT ZONE! <do doo do doo>
/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
          sceKernelExitGame&#40;&#41;;
          return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
          int cbid;

          cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
          sceKernelRegisterExitCallback&#40;cbid&#41;;

          sceKernelSleepThreadCB&#40;&#41;;

          return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41; &#123;
          int thid = 0;

          thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
          if&#40;thid >= 0&#41; &#123;
                    sceKernelStartThread&#40;thid, 0, 0&#41;;
          &#125;

          return thid;
&#125;
// END OF TWILIGHT ZONE! <do doo do do>

int main&#40;&#41; &#123;
		  scePowerSetClockFrequency&#40;222, 222, 111&#41;;

          pspDebugScreenInit&#40;&#41;;
          SetupCallbacks&#40;&#41;;

		  int curBrightness = 0;
		  SceCtrlData pad;

		  curBrightness = 100;
		  pspDebugScreenSetTextColor&#40;0xffffff&#41;;
		  pspDebugScreenSetBackColor&#40;0x000000&#41;;
		  pspDebugScreenInit&#40;&#41;;

		  pspDebugScreenSetXY&#40;0, 23&#41;;
		  pspDebugScreenPrintf&#40;"Press L or R to change brightness"&#41;;
		  pspDebugScreenSetXY&#40;0, 24&#41;;
		  pspDebugScreenPrintf&#40;"Press TRIANGLE to exit"&#41;;

		  while&#40;1&#41; &#123;
			pspDebugScreenSetXY&#40;0, 15&#41;;
			pspDebugScreenPrintf&#40;"Current brightness&#58; %i", curBrightness&#41;;				

			sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
			if&#40;pad.Buttons & PSP_CTRL_LTRIGGER&#41; &#123;
				if &#40;curBrightness > 0&#41;&#123;
					curBrightness--;
					sceDisplaySetBrightness&#40;curBrightness, 0&#41;;
				&#125;
			&#125;else if&#40;pad.Buttons & PSP_CTRL_RTRIGGER&#41; &#123;
				if &#40;curBrightness < 100&#41;&#123;
					curBrightness++;
					sceDisplaySetBrightness&#40;curBrightness, 0&#41;;
				&#125;
			&#125;else if&#40;pad.Buttons & PSP_CTRL_TRIANGLE&#41; &#123;
				break;
			&#125;
			sceKernelDelayThread&#40;100000&#41;;
		  &#125;
		  sceKernelExitGame&#40;&#41;;
		  return&#40;0&#41;;
&#125;
And here's the makefile:

Code: Select all

TARGET = bright
OBJS = main.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;
LIBDIR =

LIBS = -lpsppower -lpspdisplay_driver
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Brightness Test 
PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
Can someone please tell me what I'm doing wrong?
Many thanks. :)

Ciaooo
Sakya
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Re: sceDisplaySetBrightness problem

Post by sakya »

Hi! :)

Sorry for the double post.
I fixed the problem: my toolchain was old and display_kernel.h didn't define the brightness functions. :)

Many thanks.

Ciaooo
Sakya
Post Reply