HAM Tutorial :: Day 11 :: Backgrounds - Rotation

 

For Day 11 I'll explain how to rotate backgrounds. HAM makes this very simple with the RotBgEx() function. This function is very powerful because not only can you rotate backgrounds but also zoom in or out and scroll backgrounds.
NOTE: There is also a RotBg() function, but I prefer the newer RotBgEx() because you have more control over the rotation.

Oh, and don't forget. You can only rotate in Mode 1 and 2. In Mode 1, background 2 can rotate/scale. In Mode 2, backgrounds 2 & 3 can rotate/scale. In case you forgot, take a look at Day 1 again.

To convert the graphic, use the following:
gfx2gba -fsrc -m -protate.pal -rs -t8 rotate.bmp

Your gfx directory should have the following files:
rotate.map.c
rotate.pal.c
rotate.raw.c

On to the code:

// The Main HAM Library
#include "mygba.h"

// Graphics Includes
// gfx2gba -fsrc -m -protate.pal -rs -t8 rotate.bmp
#include "gfx/rotate.map.c"
#include "gfx/