Gameboy Advance Development by Example: Drawing and Moving Sprites
kylehalladay.com
kylehalladay.com
>I’m using 32 bit integers to store tile data because the GBA is a 32 bit machine at heart, and I’ve found a couple places online that talk about how much faster the GBA hardware is at working with 32 bit integers vs 16 bit ones when possible. Since I have no way of verifying this right now (no timers yet!), this is also a matter of faith for the moment.
This is true if you're doing calculations. However, memcpy works in bytes (logically, anyway) so it wouldn't make any difference for tile data. Storing tile data as ints would complicate things if you ever want to modify any of your tiles.
Nitpicking aside, this is an excellent tutorial. The simplicity of the code makes it easy to understand.
0: https://github.com/lattera/glibc/blob/master/string/memcpy.c...
In the tutorial, Kyle already aligns the array to 4 bytes, so using ints instead of chars really isn't doing much.
Thanks for catching that! I'll remedy that line later this evening.
Although, evidently ARM chips have an optimized code path for 4 byte aligned data: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.... , I'm not sure if that would apply in this case or not?
That would apply here, since memcpy most likely uses ints internally. (It should, in any case.) If the data starts out aligned, most reads will also be aligned.
You already take care of the alignment by using __attribute__((aligned(4))) on the declarations of your tiles, so it should all be good as-is.
For memory copies you'd use DMA controller anyway.
It's of course severely limited due to the small amount of memory and lack of an MMU.