Help with prx plugin...

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

Moderators: cheriff, TyRaNiD

Post Reply
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Help with prx plugin...

Post by ne0h »

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...
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Code: Select all

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

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.
CpuWhiz
Posts: 42
Joined: Mon Jun 04, 2007 1:30 am

Post by CpuWhiz »

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

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

Code: Select all

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) )
FreePlay
Posts: 71
Joined: Wed Jan 04, 2006 6:53 pm
Location: Schenectady, New York, USA

Post by FreePlay »

Alternative:

Code: Select all

if( pad.Buttons & (PSP_CTRL_HOME | PSP_CTRL_NOTE)){...}
since that does the same thing.

Also,

Code: Select all

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

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

                        blit_string(1, 12, strBuf0,0xffffff,0x000000);
Just do this:

Code: Select all

                        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.
CpuWhiz
Posts: 42
Joined: Mon Jun 04, 2007 1:30 am

Post by CpuWhiz »

@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?
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

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.
FreePlay
Posts: 71
Joined: Wed Jan 04, 2006 6:53 pm
Location: Schenectady, New York, USA

Post by FreePlay »

heh, you're absolutely right. I don't know what I was thinking.
a_noob
Posts: 97
Joined: Sun Sep 17, 2006 8:33 am
Location: _start: jr 0xDEADBEEF

Post by a_noob »

the or operator means or for a reason ;)

Code: Select all

.øOº'ºOø.
'ºOo.oOº'
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

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
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

Hehe i saw this code somewhere in the past :)
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

The buttons are defined by me in translateButtons.h!
But i use it wrong:
"NOTE" = wrong
NOTE = true
Post Reply