#11353 - jerkize - Fri Oct 03, 2003 2:13 am
I'm still new to GBA development. In all of the sample code that I've
seen, everyone is using symbols and bit shifting to modify sections of
GBA memory. Does anyone see any pros/cons with mapping a struct to
GBA memory? As an example, here's what I'm doing for sprites (please
excuse my variable names if they don't make sense):
These are what I see as the benefits:
Thanks for any feedback.
seen, everyone is using symbols and bit shifting to modify sections of
GBA memory. Does anyone see any pros/cons with mapping a struct to
GBA memory? As an example, here's what I'm doing for sprites (please
excuse my variable names if they don't make sense):
Code: |
typedef struct Sprite { u16 y : 8; u16 allow_transforms : 1; u16 double_it : 1; u16 alpha_mode : 2; u16 allow_zoom : 1; u16 color_mode : 1; u16 yshape : 2; u16 x : 9; u16 scale : 3; u16 hflip : 1; u16 vflip : 1; u16 xshape : 2; u16 id : 10; u16 priority : 2; u16 palette : 4; u16 rotation_register : 16; }; |
These are what I see as the benefits:
- The code is more self-documenting.
- It is simpler to modify a field, meaning you don't have to OR
everything together just to update, say, the x position.
- I'm hoping it is faster but this is just a gut feeling, nothing more.
Thanks for any feedback.