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 > Help with simple rotations and mirroring

#102236 - Moeity - Tue Sep 12, 2006 3:19 am

I've been trying to do a simple background rotations. I've gone through Tonc's tutorial, and am at about a 50% understanding, I'd say. Getting there.

I've been experimenting, but must be doing something wrong. If anyone post some values for some simple rotations, maybe say 45 degrees, 90 degrees, 135 degrees, 180 degrees, I'd love you for it.

One specific thing I'm trying to do is a simple 90 degree rotation, so I figured
XDX = 0;
XDY = 1 << 8;
YDX = 1 << 8;
YDY = 0;

This is almost right, but now my image is flipped about the x-axis. Is there a way to flip a background image? ie. to mirror it about the middle of the screen along the x-axis, so that what was at the top middle of the screen moves to the bottom middle of the screen, and vice-versa. This can't be accomplished using rotations, I believe, so it is done with translations somehow? A seperate bit somewhere? Or should I do it myself in software?

Note I'm actually developing of the DS, though this shouldn't matter for 2D rotations, right?

#102239 - tepples - Tue Sep 12, 2006 3:48 am

To flip an axis, have you tried -1 << 8 ? Notice that this flips about the , so you'll probably have to set that axis of the matrix's initial displacement vector (REG_BG2X and REG_BG2Y) to the maximum value of that axis (e.g. 240<<8 or 160<<8).

As for the 45 degree series:
256 * sin(45 degrees) = 256 * sqrt(1/2) = 181
So try this:
PA=181, PB=-181, PC=181, PD=181
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#102242 - Moeity - Tue Sep 12, 2006 4:46 am

Thanks very much for the pointer. I had tried using -1 do the the flipping, but just got a black screen, so I figured the negative bit was unallowed. In fact, the rotation was performed correctly, but was being translated off the screen. Your notice was exactly what I needed. Thanks again!