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.

Coding > Mario Kart/F-Zero style graphics.

#2517 - TheGuru - Wed Feb 05, 2003 4:42 pm

I'm looking for an algorithm for rotating background tiles about the z axis such as in Mario Kart or Fzero. I saw one a while ago but didn't bookmark it and can't think of what this method would be called to look it up.

Thanks

#2518 - Splam - Wed Feb 05, 2003 4:59 pm

It's usually called "mode 7", even though that's not really what it is ;) Should help with your searches.

#2519 - tepples - Wed Feb 05, 2003 5:14 pm

You'll have to know about vector math (use Google). You'll have to know a bit about fixed point math (use Google). You'll have to know how to change the affine parameters by scanline, using hblank DMA from an array of structs into the GBA registers.

First create a 2D unit vector that points in the direction of the camera. Call this 'out'.

Multiply the height of the camera by a constant and divide it by y to get z. Similar triangles help you see the reasoning behind this.

Now fixed-point multiply this by the 'out' to get a vector 'zout'. Rotate 'zout' right by 90 degrees (trivial) and shift it right by 8 (divide by 256) to create 'right'.

For each scanline, set the hardware's per-pixel vector (pa, pc) to 'right' and scanline origin to 'zout' - 120 * 'right'.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#2520 - TheGuru - Wed Feb 05, 2003 5:25 pm

thanks guys/gals, that should help a lot