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 

controller.c

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



Joined: 20 Jun 2005
Posts: 82

PostPosted: Tue Jun 21, 2005 8:14 am    Post subject: controller.c Reply with quote

hey..i have successfully compiled and ran my program to draw my bmp to the screen using nem's PG.c

now im trying to use the controller.c to control the location of the bmp on the screen..however..now that I added that code..when i run my program..i just get a black screen..and then my psp turns off.. it compiles perfectly tho..

Code:

#include "pg.h"
#include "controller.c"
#include "bitmap.c"


int exit_callback(void)
{
   sceKernelExitGame();
   return 0;
}

#define POWER_CB_POWER      0x80000000
#define POWER_CB_HOLDON      0x40000000
#define POWER_CB_STANDBY   0x00080000
#define POWER_CB_RESCOMP   0x00040000
#define POWER_CB_RESUME      0x00020000
#define POWER_CB_SUSPEND   0x00010000
#define POWER_CB_EXT      0x00001000
#define POWER_CB_BATLOW      0x00000100
#define POWER_CB_BATTERY    0x00000080
#define POWER_CB_BATTPOWER   0x0000007F

void power_callback(int unknown, int pwrflags)
{

}

// Thread to create the callbacks and then begin polling
int CallbackThread(void *arg)
{
   int cbid;

   cbid = sceKernelCreateCallback("Exit Callback", exit_callback);
   SetExitCallback(cbid);
   cbid = sceKernelCreateCallback("Power Callback", power_callback);
   PowerSetCallback(0, cbid);

   KernelPollCallbacks();
}

/* 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);
   sceKernelStartThread(thid, 0, 0);


   return thid;
}


int pacDir=1;
unsigned long pacX=230;
unsigned long pacY=136;
int pacSpeed=5;
int isRunning=1;

const int maxX=452;
const int maxY=252;
const int minX=0;
const int minY=0;

void checkPress(void)
{
   switch(Control()) {
   
      case 5:
         pacDir=2;
         break;
      case 6:
         pacDir=4;
         break;
      case 7:
         pacDir=1;
         break;
      case 8:
         pacDir=3;
         break;
   }
   
   
}

void updatePac(void)
{
   
   switch(pacDir)
   {
      case 1:
         if(pacX-pacSpeed>minX)
         {
            pacX-=pacSpeed;
         }
         break;
      case 2:
         if(pacY-pacSpeed >minY)
         {
            pacY-=pacSpeed;
         }
         break;
      case 3:
         if(pacX+pacSpeed<maxX)
         {
            pacX+=pacSpeed;
         }
         break;
      case 4:
         if(pacY+pacSpeed<maxY)
         {
            pacY+=pacSpeed;
         }
         break;
   }
   
}
   
   


int xmain(void)
{
   
   pgInit();
   SetupCallbacks();
   pgScreenFrame(2,0);
   sceCtrlInit(0);
   sceCtrlSetAnalogMode(0);
   
      
   
   
   while(isRunning == 1)
   {
      
   checkPress();
   updatePac();
   
   pgFillvram(0);
   pgBitBlt(pacX,pacY,20,20,2,image_pacR);
   pgScreenFlipV();
   pgWaitVn(10);
   
   }
   
   return 0;
}



thats the code for my main program...

could someone take a look?

im not sure whats wrong..

oh and yes, i added all the stub stuff in my startup.s and im using the psp-gcc to compile....it compiles fine tho.

thanks for any help..
Back to top
View user's profile Send private message
JJPeerless



Joined: 20 Jun 2005
Posts: 82

PostPosted: Tue Jun 21, 2005 8:42 am    Post subject: Reply with quote

ok, ive narrowed the problem down to something having to do with me having a 1.5 psp..

i was able to write, compile, and run homebrew i wrote myself on my 1.5psp..then soon as i started using the Controller.c for button presses..i could no longer boot my homebrew.. im using the psptoolchain (psp-gcc) to compile..

something new that i added has made me unable to boot my homebrew on my 1.5

is there a special way to compile the new controller.c stuff i added so it still works on 1.5?
Back to top
View user's profile Send private message
wulf



Joined: 13 Apr 2005
Posts: 81

PostPosted: Tue Jun 21, 2005 9:06 am    Post subject: Reply with quote

this is just a shot in the dark, but might it be your empty power callback?
Back to top
View user's profile Send private message
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