#26566 - Mephisto - Sat Sep 18, 2004 11:59 pm
I really dont understand ...
i initialize 12 sprites :
sprite0 with rotation0
sprite1 with rotation1
sprite2 with rotation2
sprite3 with rotation3
sprite4 with rotation4
sprite5 with rotation5
sprite6 with rotation6
sprite7 with rotation7
sprite8 with rotation8
sprite9 with rotation9
sprite10 with rotation10
sprite11 with rotation11
with differents parameters
but i saw that
sprite0 use rotation0
sprite1 use rotation1
sprite2 use rotation2
sprite3 use rotation3
sprite4 use rotation4
sprite5 use rotation5
sprite6 use rotation6
sprite7 use rotation7
sprite8 use rotation0
sprite9 use rotation1
sprite10 use rotation2
sprite11 use rotation3
i really dont understand ...
Here is my sprite initialisation :
here is the sprite refreshing code i use :
here is the rotation code i use :
i initialize 12 sprites :
sprite0 with rotation0
sprite1 with rotation1
sprite2 with rotation2
sprite3 with rotation3
sprite4 with rotation4
sprite5 with rotation5
sprite6 with rotation6
sprite7 with rotation7
sprite8 with rotation8
sprite9 with rotation9
sprite10 with rotation10
sprite11 with rotation11
with differents parameters
but i saw that
sprite0 use rotation0
sprite1 use rotation1
sprite2 use rotation2
sprite3 use rotation3
sprite4 use rotation4
sprite5 use rotation5
sprite6 use rotation6
sprite7 use rotation7
sprite8 use rotation0
sprite9 use rotation1
sprite10 use rotation2
sprite11 use rotation3
i really dont understand ...
Here is my sprite initialisation :
Code: |
typedef struct spriteOAM_struct { u16 Attribute0; u16 Attribute1; u16 Attribute2; u16 Unused; } spriteOAM_struct; typedef struct spriteRot_struct { u16 Unused0[3]; u16 PA; u16 Unused1[3]; u16 PB; u16 Unused2[3]; u16 PC; u16 Unused3[3]; u16 PD; } spriteRot_struct; u16 *SpritesData_VRAM = (u16*)0x6010000; u16 *SpritesOAM_RAM = (u16*)0x7000000; spriteOAM_struct SpritesOAM[128]; spriteRot_struct *RotData = (spriteRot_struct*)SpritesOAM; u32 numrotation = 0; sprite->SpriteOAM->Attribute0 = ROTATION_FLAG | COLOR_16 | SQUARE; sprite->SpriteOAM->Attribute1 = ROTDATA(numrotation) | SIZE_32; sprite->SpriteOAM->Attribute2 = PRIORITY(3) | PALETTE(0) | ( ... ); sprite->NumRot = numrotation++; |
here is the sprite refreshing code i use :
Code: |
void RefreshSprite_All(void)
{ u16 i; u16* temp; temp = (u16*)SpritesOAM; for(i = 0; i < 128 * 4; i++) { SpritesOAM_RAM[i] = temp[i]; } } |
here is the rotation code i use :
Code: |
void matrixMultiply( int * dest, int * one, int * two )
{ int a, b, c, d; a = ( (one[0]*two[0]) >> 8) + ( (one[1]*two[2]) >> 8 ); b = ( (one[0]*two[1]) >> 8) + ( (one[1]*two[3]) >> 8 ); c = ( (one[2]*two[0]) >> 8) + ( (one[3]*two[2]) >> 8 ); d = ( (one[2]*two[1]) >> 8) + ( (one[3]*two[3]) >> 8 ); dest[0] = a; dest[1] = b; dest[2] = c; dest[3] = d; } void createShearXMatrix( int * mat, int xshear ) { mat[0] = 256; mat[1] = xshear; mat[2] = 0; mat[3] = 256; } void createShearYMatrix( int * mat, int yshear ) { mat[0] = 256; mat[1] = 0; mat[2] = yshear; mat[3] = 256; } void createScaleMatrix( int * mat, int xscale, int yscale ) { mat[0] = xscale; mat[1] = 0; mat[2] = 0; mat[3] = yscale; } void createRotateMatrix( int * mat, int angle ) { mat[0] = getCos( angle ); mat[1] = getSin( angle ); mat[2] = -getSin( angle ); mat[3] = getCos( angle ); } void ApplyRotateScale(sprite_struct *sprite, int scalex, int scaley, int shearx, int sheary, int angle) { static int mat0[4], mat1[4], mat2[4], mat3[4], result[4]; createScaleMatrix( mat0, scalex, scaley ); createShearXMatrix( mat1, shearx ); createShearYMatrix( mat2, sheary ); createRotateMatrix( mat3, angle ); matrixMultiply( result, mat0, mat1 ); matrixMultiply( result, result, mat2 ); matrixMultiply( result, result, mat3 ); RotData[sprite->NumRot].PA = result[0]; RotData[sprite->NumRot].PB = result[1]; RotData[sprite->NumRot].PC = result[2]; RotData[sprite->NumRot].PD = result[3]; } |