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.

Beginners > Tile rotation, before or after?

#53648 - jumperwillow - Sat Sep 10, 2005 5:41 am

This is my first question here, so please be gentle.

I am working on a small little program and I am trying to make a stop sign, minus text. I have two choices:
I can make four different sprites, one for each quadrant and be done with that.
I also might choose to just make the one quadrant and rotate it through all four quadrants using math.

To the layman (me), it would seem the first is faster (?) because it doesn't do any fancy stuff but it takes up 3 extra tiles (whoop-de-do). The second would take up less space but would be slower because of the extra work.

So the question is, "Is the second method actually slower in the long run? (sans setup time on the sprites)"
Anyone have previous experience to this sort of "trick"?

Thanks and I'll be back soon!
_________________
-h

#53649 - poslundc - Sat Sep 10, 2005 6:37 am

If you are talking a 16x16 pixel sprite, then it's probably not worth wasting the extra OAM entries to break it down into four separate sprites. Just have a single 16x16 OAM entry that points to 4 tiles of data, containing your entire image.

With 32K of sprite VRAM you've got enough for 1024 16-colour tiles, so using 1 instead of 4 in a single instance is unlikely to be your limiting factor. On the other hand, you only have 128 OAM entries, so if you use 4 of them to create four separate sprites to display your image, you are consuming more of a scarcer resource.

As for which method is "faster", I'm not sure what you mean. In terms of design time, the above strategy is definitely quickest, and you don't need a robust engine that supports breaking down high-level onscreen entities into individually stitched-together sprites. You just need the one sprite to associate with your onscreen entity.

In terms of execution speed on the GBA, well, you've got more data to copy into VRAM if you set up a single sprite with 4 tiles, or more complicated code to execute if you set up four sprites with a single, rotated tile, so it probably comes out in a wash. Neither will be very expensive, though.

That said, if you can set up a robust enough high-level sprite system to handle things such as the various transformations available to you, then it may pay off a thousand fold in the long run. What are your long-term goals? Is it more than this simple program? If so, then design for them.

(For the record, you don't need to use math to rotate the sprites, you can simply use the H/V flip bits in your OAM entries.)

Dan.