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 background for a large world

#20972 - aaronphughes - Thu May 20, 2004 10:09 pm

I am wondering what people generally do for a scrolling background (Mode 0). For instance, if I have a world map of say 4000x4000 tiles, I know you would have to dynamically update the gba map (somewhere in 0x06000000 memory region), but my question is, how do most people do this?

Thanks for any suggestions/explanations
AH
_________________
urpNO_SPAM_MAN@canerdian.ca
http://www.canerdian.ca

#20974 - alek - Thu May 20, 2004 10:14 pm

Here's a good example from the site www.thepernproject.com

www.thepernproject.com\Examples\BGDEMOS\BG_18.zip

#20979 - Miked0801 - Fri May 21, 2004 12:13 am

There's a few other threads about this, but in a nutshell, there are 2 basic ways to do this:

1. Every time the world position's X or Y value enters a new char value (newPos & (~0x07) != oldPos & (~0x07), redraw the entire map and reset the scroll registers.

2. Same check as above to see if a redraw is needed, but only fill in along the leading edge of the map and don't reset the scroll registers.

Advantages of method 1:
It's the simpler to code than method 2.
It frees up 34% of the VRAM that the Char LUT takes up as you will never leave a 31x21 area of VRAM.

Disadvantages of method 1:
You need to fill a lot more memory every time you want to scroll so it will run slower than method 2.

Advantages of method 2:
At worst filling in 52x2 bytes of RAM so it will run a lot faster if coded correctly.
It lends itself to dynamic char loading better than method 1.

Disadvantages of method 2:
It will take longer to get working.
While you can use the VRAM that is not being display, you must be very careful in doing so as it will be overwritten as the map scrolls around.

We use method 2 as we dynamically load chars here - though we used method 1 for the first 2 GBA projects we did due to its simpliciity and that it doesn't run too slow :)

#21012 - aaronphughes - Fri May 21, 2004 4:00 pm

Thanks for the sugestions and example

Miked0801 I like your approach, I am going to try this out.

Alek, where/how did you find that tutorial you sent me? I looked all over the PERN site for it.

Thanks again,
AH.
_________________
urpNO_SPAM_MAN@canerdian.ca
http://www.canerdian.ca

#21027 - alek - Fri May 21, 2004 7:56 pm

in the tutorial section go to day 6 making the game
here go to

21) Scrolling both ways the not so easy way