forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

sceDisplaySetBrightness problem

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
sakya



Joined: 28 Apr 2006
Posts: 190

PostPosted: Thu May 31, 2007 6:33 pm    Post subject: sceDisplaySetBrightness problem Reply with quote

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:

#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);
}


And here's the makefile:
Code:
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


Can someone please tell me what I'm doing wrong?
Many thanks. :)

Ciaooo
Sakya
Back to top
View user's profile Send private message Visit poster's website
sakya



Joined: 28 Apr 2006
Posts: 190

PostPosted: Thu Jun 07, 2007 1:36 am    Post subject: Re: sceDisplaySetBrightness problem Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group