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.

Graphics > Background Scaling

#76713 - thegamefreak0134 - Thu Mar 23, 2006 9:13 pm

Yay! Hotels are so nice...

I have a question. I have a picture (tiled of course) of a large level that I will need to be scaling and panning for a camera effect in the game. I have a function that gives me the coordinates of the level that need to be on the GBA screen edges. (ie, the top corner of the GBA screen should be here, etc.) I need to know how to scale the screen, and have never messed with something like this.

I am familiar with the tiled modes, of course. I intend to do the game in Mode1, if that helps. What I need is a tutorial that can teach me how to do screen scaling without boggling me down with math. Also, I only need to do scaling, not rotating. If there was a function that I could give x% of scale and Y% of scale (with 100% being normal) that would be perfect. Does anyone know of such a thing?

Thanks in GBAdvance.

-thegamefreak0134
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]

#76715 - tepples - Thu Mar 23, 2006 9:25 pm

To scale without rotating, set the X and Y origin elements of the BG2 matrix to the upper left corner of the portion of the map that you want to display, and then set the PA and PD elements to the scale factor. A scale factor smaller than 256 enlarges the image, while a scale factor larger than 256 shrinks the image.

If you are using pin8gba.h, the relevant registers are named BGAFFINE[2].pa, BGAFFINE[2].pd, BGAFFINE[2].x_origin, BGAFFINE[2].y_origin.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#76718 - thegamefreak0134 - Thu Mar 23, 2006 10:10 pm

Oh. Well that's easier than I thought. I don't even have to use matrix math then That's cool Thanks a bunch. The function I have gives me the scale needed already, so it'll work out great.

I assume that a value of 128 equals 2x, 512 would be .5, ect. ect. My function gives the scale as a percentage with 1 being normal. (It's floating point on a calc.) I think I can still use it though. Is this an integer for the value?
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]

#76722 - tepples - Thu Mar 23, 2006 10:40 pm

thegamefreak0134 wrote:
Oh. Well that's easier than I thought. I don't even have to use matrix math then That's cool Thanks a bunch.

You are still using matrix math; I just gave a shortcut to construct a special case for the matrix you want (no rotation, no shear, rigid scaling).

Quote:
I assume that a value of 128 equals 2x, 512 would be .5, ect. ect.

Correct. Consider it almost like a distance from the camera.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#76727 - thegamefreak0134 - Thu Mar 23, 2006 10:50 pm

OK. That would explain why TONCs demo on the scaling appeared to go all glitchy when it got really far away or really close. Thanks again! I should be able to make a rough walking around and jumping demo for the game now that I can do my level drawing routine.
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]