#171806 - vladimirsan - Fri Dec 25, 2009 10:34 am
Hello While I'm not new to programming I'm not very familiar with "GBA Style" programming.
I'm using the Tonc tutorial to learn GBA programming (I cheeked the HAM book before using Tonc). I don't understand this piece of code...
It's located in http://www.coranac.com/tonc/text/bitmaps.htm#ssec-data-align
I don't understand why he used fooSize/2 if both fooData and dst elements are 16 bits long
In a previous chapter is this code
http://www.coranac.com/tonc/text/first.htm
I thought that there he didn't put the *2 because he is casting fooBitmap to a u16 which is bigger than u8.
I've looked everywhere and I think that I got more confused every minute hahahahah please help
I'm using the Tonc tutorial to learn GBA programming (I cheeked the HAM book before using Tonc). I don't understand this piece of code...
Code: |
#define fooSize ...
const u16 fooData[]= { ... }; // copy via u16 array (the de facto standard) u16 *dst= (u16*)vid_mem, *src= (u16*)fooData; for(ii=0; ii<fooSize/2; ii++) dst[ii]= src[ii]; |
It's located in http://www.coranac.com/tonc/text/bitmaps.htm#ssec-data-align
I don't understand why he used fooSize/2 if both fooData and dst elements are 16 bits long
In a previous chapter is this code
Code: |
// An array representing a 240x160@16 bitmap, converted // to an array by some graphics conversion tool. const u8 fooBitmap[240*160*2]= { // Maaaaany, many lines of data. } int main() { REG_DISPCNT= DCNT_MODE3 | DCNT_BG2; u16 *src= (u16*)fooBitmap; // Cast source to u16-array // Copy 240x160 pixels to VRAM (YARLY!) int ii; for(ii=0; ii<240*160; ii++) vid_mem[ii]= src[ii]; return 0; } |
http://www.coranac.com/tonc/text/first.htm
I thought that there he didn't put the *2 because he is casting fooBitmap to a u16 which is bigger than u8.
I've looked everywhere and I think that I got more confused every minute hahahahah please help