Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

And then there were errors...

Sign in to follow this  


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:

parse error before "unsigned"

Any suggestions?
Sign in to follow this  


Recommended Comments

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.

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.

Share this comment

Link to comment
Made that change, but It still dosen't work. Can't really find out whats wrong...

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!