#136428 - mr_munk - Wed Aug 01, 2007 5:45 pm
Hi,
I have been working through the 'Introduction to DS Development Tutorial' Chapter six. I wondered if anyone could tell me what the following code in the tutorial is for ? (I added the comments btw)
Specifically, why is it necessary to bitmask and shift the incoming U16 var angle?
My second question regards the ATTR1_ROTDATA(n) constant, from the #define in ndslib/video.h I think that this sets the upper 7 bitsof a sprite entry register (?) but what does this mean for the sprites attributes ?
Any help appreciated - I just want to develop my understanding of what the code I am writing actually does.
Last edited by mr_munk on Wed Aug 01, 2007 8:00 pm; edited 1 time in total
I have been working through the 'Introduction to DS Development Tutorial' Chapter six. I wondered if anyone could tell me what the following code in the tutorial is for ? (I added the comments btw)
Code: |
//rotate a sprite
void rotateSprite(SpriteRotation * spriteRotation, u16 angle) { s16 s = -SIN[angle & 0x1FF] >> 4; //bitmask lower 9 bits of u16 (& 0001 1111 1111) //then divide Sine by 8 s16 c = COS[angle & 0x1FF] >> 4; //bitmask lower 9 bits of u16 (& 0001 1111 1111) //then divide Cosine by 8 spriteRotation->hdx = c; spriteRotation->hdy = -s; spriteRotation->vdx = s; spriteRotation->vdy = c; } |
Specifically, why is it necessary to bitmask and shift the incoming U16 var angle?
My second question regards the ATTR1_ROTDATA(n) constant, from the #define in ndslib/video.h I think that this sets the upper 7 bitsof a sprite entry register (?) but what does this mean for the sprites attributes ?
Any help appreciated - I just want to develop my understanding of what the code I am writing actually does.
Last edited by mr_munk on Wed Aug 01, 2007 8:00 pm; edited 1 time in total