- For making cartridges of your Super NES games, see Reproduction.
How do I scroll the screen?
Not as in just moving the screen x and y, that's just updating a register, I mean scrolling past that and loading data into VRAM on the fly to get a really long/tall screen.
I'd probably have to sense when the screen got too far to the right or any other direction and load tiles in then, but how do I update the map? I'd have to load map data into a very specific spot in memory that has to be calculated on the fly.
Also, I'd have to store the large map in rom somehow so that it can be retrieved easily.
Can someone help with this?
Code: Select all
1 1 1 1 1 1... 2 2 2 2 2 2... 3 3 3 3 3 3... 4 4 4 4 4 4... .... 2929292929 3030303030
so as you scroll down, a new line becomes visible and an old line disappears.
So the SNES is 240 pixels high which is 30 "rows". So the next line needs to be plotted at line 31.
Then the scroll pos gets set to 1 char down, you then draw line 32...
and so on and so on, until you get to line 64(the snes having a 512pixel high buffer) to which the counters wrap around to 0
Code: Select all
.... 636363636363 0 0 0 0 0 0 1 1 1 1 1 1
ScreenVRAMPos + (y*64) note *64 is easily done by a shift
the row you want to plot next is (topY+30)AND63
However the SNES gives you a lot of breathing room so you may want to plot 4 rows ahead as you decode metatiles/blocks.
1. Find what part of the map will become visible next.
2. Write a row or column of tile numbers corresponding to that part of the map to VRAM.
3. Move the scroll position to bring that row or column within the 256x224-pixel viewport.
"PPU scrolling" on the wiki has an animation. Though that animation is of an NES game, the concept isn't really different between the platforms, except for a few things that make it less annoying:
1. No separate "attribute table".
2. The tilemap isn't fixed to a particular location in VRAM.
3. You have enough WRAM to cache a level without having to decompress everything on the fly.