#2044 - XeroxBoy - Tue Jan 28, 2003 5:07 am
My input function works; however, when I turn on optimization, it fails to do so.
Code: |
#define P1 *(volatile u16 * )0x04000130 // Definition of key pad reigster |
Code: |
u16 joypad() //joypad checking routine.
{
u16 j=P1;
P1 |= 0x03FF;
return j;
}
|
Code: |
u16 Input // Method for reading input
Input=(~joypad())&0x03FF;
if(Input & KEY_UP)
// ...etc |
Any help would be appreciated!
#2047 - tepples - Tue Jan 28, 2003 6:09 am
XeroxBoy wrote: |
My input function works; however, when I turn on optimization, it fails to do so.
Code: | #define P1 *(volatile u16 * )0x04000130 // Definition of key pad reigster |
|
When you use a #define to name a register, you should put parentheses around the definition, like this:
Code: |
#define P1 (*(volatile u16 * )0x04000130) |
Quote: |
Code: |
u16 joypad() //joypad checking routine.
{
u16 j=P1;
P1 |= 0x03FF;
return j;
}
|
|
As far as I know, you don't ever need to write anything to the controller read register. Were you thinking j ^= 0x3ff; to convert the inputs from active-low to active-high? In that case, you might as well just do this:
Code: |
u16 joypad()
{
return P1 ^ 0x03ff;
}
|
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#2062 - XeroxBoy - Tue Jan 28, 2003 4:27 pm
Thanks for the advice, but it didn't help. I don't really understand the logic behind the input function myself - I got it from an old demo quite a while ago (I think it's from Warder1's Chrono Trigger demo). I tried swapping it with the code from The PERN Project, but that hasn't helped either.
#2085 - Maddox - Wed Jan 29, 2003 5:09 am
It's your own fault for trusting the compiler to do your work for you. And probably GCC at that, isn't it? Admit it! You get what you pay for. GCC is garbage and optimizations should be turned off. Suck it up and be a winner -- go program in assembly if you want speed and give that poor, stupid compiler your crap code to chew on.
_________________
You probably suck. I hope you're is not a game programmer.
#2088 - XeroxBoy - Wed Jan 29, 2003 5:32 am
Quote: |
You get what you pay for. GCC is garbage |
I agree; I personally don't like GCC very much. But do you want to give me $6000 to spend on ARM SDT? No? Then shut up.
Quote: |
...optimizations should be turned off. |
Why? Is slower code preferable?
Quote: |
Suck it up and be a winner -- go program in assembly |
So your saying that Nintendo, Sega, Konami, Square, and every other company that makes games for the GBA are losers? Cuz, you know, I'm sure you could make better games than them.
Oh, and, are you the same Maddox who owns maddox.xmission.com (if not, you certainly take after your name sake)? In your article entitled "Love your kids? Prove it by beating them", you state, "The problem is that kids today think their opinions matter."
Hypocrite.
#2089 - Maddox - Wed Jan 29, 2003 5:48 am
Please stick to GBA topics in your posts.
I use GCC like most, but I don't cry about it. It's like a scared woodland animal -- you must respect it or you will get bitten. Turning on optimizations always breaks my code so...
Slower code is better when it works. Your the one who couldn't get ~10 lines of code to work, not me.
_________________
You probably suck. I hope you're is not a game programmer.
#2092 - XeroxBoy - Wed Jan 29, 2003 6:08 am
Stick to GBA topics, eh?
Quote: |
To Splam: That's right -- keep rockin' that boat. We need more coolness on this forum and less crybabies asking for solutions to problems that high school Hypercard students could answer.
THAT'S RIGHT: CRYBABIES!
|
Anyways, if your code breaks when you turn optimizations on, then it's not as though I'm all that inferior to you. Besides, I've read many people on these forums recommending turning on optimizations, and I doubt they'd do so if they couldn't even get input working. Hence, asking how they get input with optimizations on is a good idea.
Out of curiousity, why would you say that slower code is better, especially as your such an ASM advocate?[/quote]