And then there were errors...

Published April 02, 2005
Advertisement
I finished the entire code for Pong Advanced, but now I'm getting this error that I can't get around. It's on this line of code:

*(unsigned long*)0x4000000 = (0x5 | 0x400);

Here is the error:

Quote:parse error before "unsigned"


Any suggestions?
0 likes 3 comments

Comments

choffstein
You are trying to set a constant to a constant?
I know what you mean to do, but thats my only guess as to why its buggin.
Quote:
Now, this would work just fine but there are some issues with this code. First there is the fact that since these are hardware registers we may not be the only ones changing them. This is something the compiler needs to know else it will try to optimize our code and likely break it. The way we tell the compiler that variables change outside of the c code is to declare them volatile. The last issue is that we are using a variable (RAM) to store a constant. We would be much better served if we just used a #define…this also allows us to dereference the register in its declaration and makes writing to it a bit simpler. Here is the new, more proper code.

#define REG_DISPCNT (*(volatile unsigned short*)0x4000000) 
REG_DISPCNT = 0x5|0x400;


Source: The Pern Project.

I was gonna write that myself...but its explained so well in The Pern Project tutorials.
April 02, 2005 04:54 PM
Stompy9999
Made that change, but It still dosen't work. Can't really find out whats wrong...
April 02, 2005 09:14 PM
choffstein
What is the issue now?

Try posting your code at gbadev.org
April 02, 2005 11:31 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement