#6719 - [squire] - Mon Jun 02, 2003 7:11 am
could someone out there please tell me what i'm doing wrong?
boomarang, is a 16x16 pixel sprite, in 16 colours.
as soon as i set either the roation bit or double size bit, the sprite will not
be displayed, it shows up fine if neither of those 2 bits are set.
any ideas anyone?
thanks, [squire]
boomarang, is a 16x16 pixel sprite, in 16 colours.
as soon as i set either the roation bit or double size bit, the sprite will not
be displayed, it shows up fine if neither of those 2 bits are set.
any ideas anyone?
thanks, [squire]
Code: |
#include <math.h> #include "headers\gba.h" #include "headers\screenmode.h" #include "headers\sprite.h" #include "boomarang.c" #define RADIAN(n) (((float)n)/(float)180*PI) FIXED angle,zoom; FIXED SIN[360],COS[360]; OAMEntry sprites[128]; u16 x,y,z; u16 n,m,i; s16 BoomarangX,BoomarangY; void CopyOAM() { u16* temp; temp=(u16*)sprites; for(i=0;i<128*4;i++) OAMmem[i]=temp[i]; } void InitializeSprites() { for(i=0;i<128;i++) { sprites[i].attribute0 = 160; sprites[i].attribute1 = 240; } } void WaitForVsync() { while((volatile u16)REG_VCOUNT == 160){} while((volatile u16)REG_VCOUNT != 160){} } void RotateSprite(int rotDataIndex, int angle, FIXED x_scale,FIXED y_scale) { FIXED pa,pb,pc,pd; pa = ((x_scale) * COS[angle])>>8; //(do my fixed point multiplies and shift back down) pb = ((y_scale) * SIN[angle])>>8; pc = ((x_scale) * -SIN[angle])>>8; pd = ((y_scale) * COS[angle])>>8; rotData[rotDataIndex].pa = pa; //put them in my data struct rotData[rotDataIndex].pb = pb; rotData[rotDataIndex].pc = pc; rotData[rotDataIndex].pd = pd; } int main() { //compute my Look up tables for(i=0;i<360;i++) { SIN[i]=(FIXED)(sin(RADIAN(i))*256); //sin and cos are computed and cast to fixed //fixed COS[i]=(FIXED)(cos(RADIAN(i))*256); } SetMode(MODE_2|OBJ_ENABLE|OBJ_MAP_1D); for(i=0;i!=16;i++) OBJPaletteMem[i+16]=boomarang_Palette[i]; InitializeSprites(); BoomarangX=64;BoomarangY=64; for(i=0;i<(16*16/4);i++) { OAMdata[i+2560]=boomarang_Char[(i<<1)+1]; OAMdata[i+2560]=(OAMdata[i+2560]<<8)+boomarang_Char[(i<<1)]; } while(1) { if(BoomarangX<0) x=512+BoomarangX; else x=BoomarangX; if(BoomarangY<0) y=256+BoomarangY; else y=BoomarangY; RotateSprite(0,180,1,1); sprites[ 0].attribute0 = COLOR_16|SQUARE|SIZE_DOUBLE|ROTATION_FLAG|y; sprites[ 0].attribute1 = SIZE_16|ROTDATA(0)|x; sprites[ 0].attribute2 = PALETTE(1)|160; WaitForVsync(); CopyOAM(); } } |