controller.c

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

Moderators: cheriff, TyRaNiD

Post Reply
JJPeerless
Posts: 82
Joined: Mon Jun 20, 2005 3:32 am

controller.c

Post by JJPeerless »

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: Select all

#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&#40;pacX+pacSpeed<maxX&#41;
			&#123;
				pacX+=pacSpeed;
			&#125;
			break;
		case 4&#58;
			if&#40;pacY+pacSpeed<maxY&#41;
			&#123;
				pacY+=pacSpeed;
			&#125;
			break;
	&#125;
	
&#125;
	
	


int xmain&#40;void&#41;
&#123;
	
	pgInit&#40;&#41;;
	SetupCallbacks&#40;&#41;;
	pgScreenFrame&#40;2,0&#41;;
	sceCtrlInit&#40;0&#41;;
	sceCtrlSetAnalogMode&#40;0&#41;;
	
		
	
	
	while&#40;isRunning == 1&#41;
	&#123;
		
	checkPress&#40;&#41;;
	updatePac&#40;&#41;;
	
	pgFillvram&#40;0&#41;;
	pgBitBlt&#40;pacX,pacY,20,20,2,image_pacR&#41;;
	pgScreenFlipV&#40;&#41;;
	pgWaitVn&#40;10&#41;;
	
	&#125;
    
	return 0;
&#125;

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..
JJPeerless
Posts: 82
Joined: Mon Jun 20, 2005 3:32 am

Post by JJPeerless »

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?
wulf
Posts: 81
Joined: Wed Apr 13, 2005 6:56 pm

Post by wulf »

this is just a shot in the dark, but might it be your empty power callback?
Post Reply