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 > Scrolling offsets and large maps

#25624 - DialogPimp - Thu Aug 26, 2004 4:20 am

Apologies for the pooly-worded explanation here. I'm confused about using the REG_BGxHOFS and REG_BGxVOFS registers. Obviously there's no way to apply a "negative" offset - it's only a positive offset to the origin (???)

My map implementation is the typical 256x256/leading-edge based system and works well if I originate the map at 0,0 (scrolls nicely in all directions). My game needs to start at the "bottom" of the map and scroll up. Now I'm guessing that I can't dump the first screen of map tiles at map ram locations 0 and set the scroll registers to 0, because that would mean I could only scroll down.

So, I'm unsure of how to setup the screenblocks and scroll registers for a map starting point other than absolute zero.

#25625 - sajiimori - Thu Aug 26, 2004 5:05 am

You can treat the registers as s16's and put regular two's-complement negative numbers in them. The hardware doesn't need to differentiate between positive and negative numbers because the backgrounds wrap, so a small negative number may as well be a big positive number. Recall that -1 as an s16 is 0xFFFF.

#25640 - poslundc - Thu Aug 26, 2004 1:47 pm

In case you have trouble wrapping your head around that, you can look to Wikipedia for an explanation of two's complement.

Dan.