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 

Help with prx plugin...

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



Joined: 21 Feb 2008
Posts: 386

PostPosted: Sat Mar 15, 2008 7:10 am    Post subject: Help with prx plugin... Reply with quote

I try to make my first prx plugin, but the compiler give me some errors,
please help me...

Here is the complete source code:

http://nopaste.com/p/atfRrFUwJ

And here is the error:

In function 'unloadStopModule':
[Warning] assignment from incompatible pointer type
In function 'loadUsb':
[Warning] no return statement in function returning non-void
In function 'threadMain':
Line:292 invalid operands to binary |
Line:292 invalid operands to binary |
Line:297 invalid operands to binary |
Line:297 invalid operands to binary |
Line:303 invalid operands to binary |
Line:303 invalid operands to binary |
Line:308 invalid operands to binary |
Line:308 invalid operands to binary |
[Build Error] [main.o] Error 1

Please, someone give me help...
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sat Mar 15, 2008 8:22 am    Post subject: Reply with quote

Code:
if((pad.Buttons & ("HOME"|"NOTE")) == ("HOME"|"NOTE"))


GREAT GALLOPING GHOSTS! I guess you've never bothered to look at any PSP code for using the pads. You want something that looks more like this:

Code:
if((pad.Buttons & (PSP_CTRL_HOME|PSP_CTRL_NOTE)) == (PSP_CTRL_HOME|PSP_CTRL_NOTE))


.Buttons is a field whose individual bits represent a particular button. They all have defines with names like PSP_CTRL_SQUARE. They make INTERGER VALUES, not strings.
Back to top
View user's profile Send private message AIM Address
CpuWhiz



Joined: 04 Jun 2007
Posts: 42

PostPosted: Sat Mar 15, 2008 8:29 am    Post subject: Reply with quote

J.F. beat me to it :(

You are trying to binary or two strings and then binary and them with a unsigned integer. First off, to compare a or b it's a || b, not a | b. Second, you can't compare a string like that unless you are using the std::string class. Third, pad.Buttons is a bitmask (you should look up some information on binary math and bitmasks/bitfields to understand what is going on), you don't check it against strings. Look at the controller/basic sample for how to check button presses.

Wrong:
Code:
if((pad.Buttons & ("HOME"|"NOTE")) == ("HOME"|"NOTE")


Right:
Code:
if( (pad.Buttons & (PSP_CTRL_HOME | PSP_CTRL_NOTE)) == (PSP_CTRL_HOME | PSP_CTRL_NOTE) )
--or--
if( (pad.Buttons & PSP_CTRL_HOME) && (pad.Buttons & PSP_CTRL_NOTE) )
Back to top
View user's profile Send private message
FreePlay



Joined: 04 Jan 2006
Posts: 71
Location: Schenectady, New York, USA

PostPosted: Sat Mar 15, 2008 8:35 am    Post subject: Reply with quote

Alternative:
Code:
if( pad.Buttons & (PSP_CTRL_HOME | PSP_CTRL_NOTE)){...}


since that does the same thing.

Also,
Code:
                char tmp[32];
                strcpy(tmp, "lsm: Error loading module ");
                strcat(tmp, name);
                doBlit(tmp);

If 'name' is over 5 characters long, you will have a buffer overflow. 'tmp' starts with 26 chars, you add name, plus a null. 26+5+1=32. More than 5 chars... bad.

Also, you never change 'kill_display'... is this for debugging only?

Also, precisely what is the point of this?
Code:
        sprintf(strBuf0, "%s + %s = Shutdown PSP", "NOTE", "HOME");
        sprintf(strBuf4, "%s + %s = Set Max Brightness", "NOTE", "DOWN");
        sprintf(strBuf5, "%s + %s = Start/Stop Usb Mass", "NOTE", "L");
        sprintf(strBuf8, "%s + %s = Show this help", "NOTE", "VOL_DOWN");       


Especially when all the strings are used for is this:
Code:
                        blit_string(1, 12, strBuf0,0xffffff,0x000000);

Just do this:
Code:
                        blit_string(1, 12, "NOTE + DOWN = Shutdown PSP",0xffffff,0x000000);


Last edited by FreePlay on Sat Mar 15, 2008 8:39 am; edited 1 time in total
Back to top
View user's profile Send private message
CpuWhiz



Joined: 04 Jun 2007
Posts: 42

PostPosted: Sat Mar 15, 2008 8:39 am    Post subject: Reply with quote

@FreePlay How does that require both buttons to be down? If only one of the two bits was set, it would still evaluate to > 0 and execute the if block. Or am I missing something?
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Sat Mar 15, 2008 8:51 am    Post subject: Reply with quote

Nope, you are correct CpuWhiz.

Freeplay's method only requires one of the two buttons to be pressed.

The correct method was posted by yourself and J.F.
Back to top
View user's profile Send private message
FreePlay



Joined: 04 Jan 2006
Posts: 71
Location: Schenectady, New York, USA

PostPosted: Sat Mar 15, 2008 8:56 am    Post subject: Reply with quote

heh, you're absolutely right. I don't know what I was thinking.
Back to top
View user's profile Send private message
a_noob



Joined: 17 Sep 2006
Posts: 97
Location: _start: jr 0xDEADBEEF

PostPosted: Sat Mar 15, 2008 4:24 pm    Post subject: Reply with quote

the or operator means or for a reason ;)
_________________
Code:
.øOº'ºOø.
'ºOo.oOº'
Back to top
View user's profile Send private message AIM Address MSN Messenger
jean



Joined: 05 Jan 2008
Posts: 489

PostPosted: Sat Mar 15, 2008 8:13 pm    Post subject: Reply with quote

Quote:
the or operator means or for a reason ;)

the funny thing -if you think of it- is that's not always so easy...
e.g. !(a|b)=!a&!b
Back to top
View user's profile Send private message
Cpasjuste



Joined: 29 May 2005
Posts: 214

PostPosted: Sat Mar 15, 2008 9:26 pm    Post subject: Reply with quote

ne0h wrote:

http://nopaste.com/p/atfRrFUwJ


Hehe i saw this code somewhere in the past :)
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Sat Mar 15, 2008 10:41 pm    Post subject: Reply with quote

The buttons are defined by me in translateButtons.h!
But i use it wrong:
"NOTE" = wrong
NOTE = true
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