gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Graphics > Sprite rotation

#21855 - doudou - Tue Jun 08, 2004 12:53 am

Is the a rotation matrix for each sprite or only one for all so we can't rotate sprites independantly.

#21857 - Nessie - Tue Jun 08, 2004 1:39 am

The answer is no...and...no. Well, sort of.

Instead, you have 32 rotation/scale matrices at your disposal...and each sprite can index into one of these 32 matrices if you want them to rotate/scale.

So, for a given sprite, you just set bit 8 of OBJ Attribute 0 in order to enabled rotation/scaling. You may also want to set bit 9 of this attribute to enabled double sized mode...this will help with clipping with rotation/scaling, but there will still be a limit on how large it can be scaled/rotated before clipping begins....there are some other problems with it as well.

Then, on OBJ Attribute 1 of the same sprite, you set bits 9-13 with a value that corresponds to index of the rotation/scale matrix you want that sprite to use. This value will be in the range of 0-31.

One other point is that, if I recall, H/V flipping of sprites does not work in rotation/scale mode...you have to apply a negative scale factor to the rotation/scale matrix to flip a sprite. (correct me if I'm wrong)

#21877 - Miked0801 - Tue Jun 08, 2004 6:24 pm

You are correct - no flipping with rotation as those bits are part of the scaling factor when in rotation mode.