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 > Rotation problems!

#46122 - whodoo - Mon Jun 20, 2005 2:16 pm

I have a strange problem. My sprites are shown correctly but the other day I tried to add rotation/scaling. But when I do this, my sprite apperars as a rectangle with just one colour. (But it's shown correctly in the OAM viewer in the emulator) but not on the screen

#46124 - tepples - Mon Jun 20, 2005 2:43 pm

Blank rectangle means that one pixel in the center is being stretched to fill the sprite's entire box. This in turn means that you aren't setting up the affine matrices correctly or aren't properly addressing them in attribute 1.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#46129 - poslundc - Mon Jun 20, 2005 5:14 pm

tepples wrote:
Blank rectangle means that one pixel in the center is being stretched to fill the sprite's entire box. This in turn means that you aren't setting up the affine matrices correctly or aren't properly addressing them in attribute 1.


The easiest mistake to make in not having the affine matrices set up correctly is leaving the entries all zeroed... in order for a sprite to appear "normally" it must have scale values of 1.0, which translates to values of (1 << 8) in PA and PD.

Dan.

#46184 - whodoo - Tue Jun 21, 2005 1:55 pm

Thank's guys, works great :)

#46188 - vorpalarrow - Tue Jun 21, 2005 2:39 pm

I also tried adding scaling/rotation to my sprites and I ended up with the same problem. I was a bit confused how this was done. I have seen examples of it done in a 1D array setting, but not using OBJ_MAP_2D. Would the affine transformations be the same in either setting or would it have to be changed? If so could someone point me to an example. Thanks.

#46198 - poslundc - Tue Jun 21, 2005 5:38 pm

The affine matrices are unchanged using 2D mapping. 2D mapping only affects the order in which you load tile data into VRAM. 1D mapping is generally preferable because while 2D mapping makes more sense on a piece of graph paper, 1D mapping is generally simpler to implement and understand programatically and allows for more contiguous copies, since you aren't trying to spread a sprite's tiles over multiple sections of memory.

Dan.

#46217 - vorpalarrow - Tue Jun 21, 2005 8:01 pm

Ok, that cleared things up. Thanks.