Search the web
Sign In
New User? Sign Up
gbadev
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
accessing memory   Message List  
Reply | Forward Message #13599 of 15019 |
Re: [gbadev] accessing memory

> i've been looking at various gba.h files and have a question about setting
up
> memory locations. I've notived 3 main ways people are doing this....
>
> #define OBJPaletteMem 0x5000200

Using this method you have an integer which still needs to be casted to a
pointer, so if you want to change color entry 0 to white, you'd do:

(u16*)OBJPaletteMem[0] = 0x7FFF;

or

*(u16*)OBJPaletteMem = 0x7FFF;

This method requires some extra typing as you can see, but you can see the
access size in your code.

> #define OBJPaletteMem (u16*)0x5000200

This is the same as above but saves typing:

OBJPaletteMem[0] = 0x7FFF;

or

*OBJPaletteMem = 0x7FFF;

> u16* OBJPaletteMem = (u16*)0x5000200;

This method will generate the same code as the others in an optimized build
(it might give you some overhead in a non-optimized build). I would say: use
a #define so that your code will be more readable. Up to you whether you
want to do the typecast in your code or within the macro.


Jan-Lieuwe





Wed Jan 1, 2003 10:31 pm

jan-lieuwe@...
Send Email Send Email

Forward
Message #13599 of 15019 |
Expand Messages Author Sort by Date

i've been looking at various gba.h files and have a question about setting up memory locations. I've notived 3 main ways people are doing this.... #define...
PurpleDecay@...
Send Email
Jan 1, 2003
10:15 pm

... up ... Using this method you have an integer which still needs to be casted to a pointer, so if you want to change color entry 0 to white, you'd do: ...
Jan-Lieuwe Koopmans
jan-lieuwe@...
Send Email
Jan 1, 2003
10:36 pm

#define OBJPaletteMem ((volatile u16 *)0x5000200) Is fastest and proper. If you don't declare it volatile, the compiler may optimize out references to the...
Mike Schwartz
mykes@...
Send Email
Jan 1, 2003
10:49 pm

... while that statement is true for some cisc-cpus, it doesnt apply to most (if not all) risc cpus.... ie, risc-cpus always do memory access indirect anyway ...
Groepaz
groepaz2000
Offline Send Email
Jan 2, 2003
8:57 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help