Library Usage Help (Newbie)

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

Moderators: cheriff, TyRaNiD

Post Reply
ils
Posts: 6
Joined: Tue Apr 12, 2005 12:22 pm

Library Usage Help (Newbie)

Post by ils »

i'm aware there is alot of library list in other thread.
but how can i use them ?

i search every source code (nem's hello world for example) but can't find it in .c/.h file. but found it @ ASM Code.

anyone can explain this ? i understand ASM a little (very very little)
how can i link C/H file to an ASM code ?

thanks.
User avatar
alonetrio
Posts: 34
Joined: Sun May 15, 2005 12:10 am
Contact:

Post by alonetrio »

you can find very simple code sample, like plot a dot, display pic, etc... that i code to help coder to start at http://www.psp.to/download.php

hope it will help you a few.

AloneTrio
ils
Posts: 6
Joined: Tue Apr 12, 2005 12:22 pm

Post by ils »

yeah, thanks.
but i manage to understand it a little (well, thanks to many sources that everyone share, i can compare 1 with another)

right now i'm trying to use button in my program. but it didn't work :(
ils
Posts: 6
Joined: Tue Apr 12, 2005 12:22 pm

Post by ils »

ok, need help here..
i tried a few hours to use button/pad but didn't work.

i copy/paste RIN's (GBC emulator) PAD.H as follow

typedef struct _ctrl_data
{
u32 frame;
u32 buttons;
u8 analog[4];
u32 unused;
} ctrl_data_t;

and create variable name "pad"

in my xmain (main function), i code :

sceCtrlInit(0); //same as RIN's
while(1) { // always run
sceCtrlRead(pad, 1);
if (pad.buttons == CTRL_UP)
pgPrint(1,1, color, "UP Button");
}

but it didn't respon anything.
any suggestion ? (sorry if i'm not clear describing it)
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

ils wrote:and create variable name "pad"

in my xmain (main function), i code :

sceCtrlInit(0); //same as RIN's
while(1) { // always run
sceCtrlRead(pad, 1);
if (pad.buttons == CTRL_UP)
pgPrint(1,1, color, "UP Button");
}

but it didn't respon anything.
any suggestion ?
There are many possible errors. If you have declared "pad" not as a pointer, you have to write "sceCtrlRead(&pad, 1)" (note the "&"). And if you are using nem's original code, you have to call pgScreenFlipV() after the pgPrint. And would be better to call "sceCtrlSetAnalogMode(0)" after the "sceCtrlInit(0)", to be sure you are in digital mode. And finally you should mask the buttons you need:

Code: Select all

	sceCtrlInit(0);
	sceCtrlSetAnalogMode(0);
	ctrl_data_t ctrl;
	while(1) {
		sceCtrlRead(&ctrl, 1); 
		if (ctrl.buttons & CTRL_UP) {
			pgPrint4(0, 0, 0xffff, "UP Button"); 
			pgScreenFlipV();
			break;
		}
	} 
	sceKernelSleepThread();
ils
Posts: 6
Joined: Tue Apr 12, 2005 12:22 pm

Post by ils »

ok thanks!
i finally can use the buttons now :)
Post Reply