#7063 - johnny_north - Sat Jun 07, 2003 5:53 pm
I can't figure this one. When I set the rotation flag on my sprites, the entire sprite cells turn into one solid color. Anyone know what I'm doing wrong?
#7065 - Touchstone - Sat Jun 07, 2003 6:44 pm
Are the scale coefficient values correct? 1:1 scaling/rotation should be
pa = 0x0100
pb = 0x0000
pc = 0x0000
pd = 0x0100
_________________
You can't beat our meat
#7072 - johnny_north - Sun Jun 08, 2003 12:31 am
Thanks for that tip. Last time I used rot/scale I didn't need to initialize the ro/scale parms. I should know better.
#7099 - Lupin - Mon Jun 09, 2003 3:17 pm
Do the rotation values and the Sprite mem change same memory area? This would mean that I have to be carefull to not overwrite sprite memory with my rotation flags :(
#9481 - johnny_north - Wed Aug 06, 2003 12:18 am
OK, this was working fine last project, but I'm stuck with the scaling sprite problem again. Here's what I've done:
Initialixe the rot/scale members:
for(loop = 0; loop < 32; loop++)
{
rotData[loop].pa = 0x0100;//pa; //put them in my data struct
rotData[loop].pb = 0x0000;//pb;
rotData[loop].pc = 0x0000;//pc;
rotData[loop].pd = 0x0100;//pd;
}
Now if I call this function:
void SpriteObj::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;
}
Like this:
sprite->RotateSprite(0, 0, 1<<8, 1<<8);
All my 16x16 sprites with rot index 0 turn to solid color square (I suspect they are all scaled very large.
If I do this:
sprite->RotateSprite(0, 0, scale, scale);
and increment the scale by one, I get sprites that alternate between different scale sizes and solid boxes without an apparent pattern.
What gives.
#9482 - hnager - Wed Aug 06, 2003 1:24 am
By any chance are you forgetting the following:
Code: |
sprites[loop].attribute1 = SIZE_16 | ROTDATA(loop); |
#9483 - johnny_north - Wed Aug 06, 2003 1:43 am
I'm not actually taking this approach. I want all of the sprites that are supposed to scale to use the same rot/scale parameters (index 0). Thanks for the suggestion though.
#9484 - hnager - Wed Aug 06, 2003 3:09 am
ah - I forgot the ROTDATA() once and I was getting odd results - not all of hte sprites were doing the same thing, but a bunch were in sync...have you tried:
sprites[loop].attribute1 = SIZE_16 | ROTDATA(0);
?
#9485 - johnny_north - Wed Aug 06, 2003 3:19 am
I wrapped up some of Dovoto's code into a sprite class:
u8 SpriteObj::CreateSprite(void* src, u16 size, u16 shape, u8 mode, bool mosaic,
bool hflip, bool vflip, u8 prio, bool dblSize, bool trans,
bool rotate, u8 rodatinx, u16 x, u16 y){
u16 byteCount;
u8 sprnum;
switch (size){
case SIZE_8:
switch (shape){
case SQUARE:
byteCount = 64;
break;
case TALL:
case WIDE:
byteCount = 128;
break;
default:
while(1){}
}
break;
case SIZE_16:
switch (shape){
case SQUARE:
byteCount = 256;
break;
case TALL:
case WIDE:
byteCount = 256;
break;
default:
while(1){}
}
break;
case SIZE_32:
switch (shape){
case SQUARE:
byteCount = 1024;
break;
case TALL:
case WIDE:
byteCount = 512;
break;
default:
while(1){}
}
break;
case SIZE_64:
switch (shape){
case SQUARE:
byteCount = 4096;
break;
case TALL:
case WIDE:
byteCount = 2048;
break;
default:
while(1){}
}
break;
}
sprites[spriteNum].attribute0 = (COLOR_256|(trans*MODE_TRANSPERANT)|(dblSize*SIZE_DOUBLE)|(rotate*ROTATION_FLAG)|shape|y);
sprites[spriteNum].attribute1 = ((BIT13*vflip)|(BIT12*hflip)|ROTDATA(rodatinx)|size|x);
sprites[spriteNum].attribute2 = charNum;
memcpy(&CharMem[charNum*32], (u8*)src, byteCount);
charNum += ((byteCount/64)*2);
attributes[spriteNum].spriteBytes = byteCount;
sprnum = spriteNum;
spriteNum++;
return sprnum;
}
#9555 - Mr. GBA - Fri Aug 08, 2003 1:45 pm
johnny_north, I've tried your code in my sprite program and it works well if I right shift your a values by 8.
_________________
my dev/business site:
http://codebytesdev.afraid.org
#9645 - johnny_north - Tue Aug 12, 2003 3:48 am
Hmm. Which values are you shifting? Do you mean that rot/scale is working?