Scrolling the screen

Discussion of hardware and software development for Super NES and Super Famicom.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
Posts: 50
Joined: Sat Apr 07, 2018 7:39 pm
Location: EN

Scrolling the screen

Post by Molive » Mon Oct 08, 2018 2:52 am

This has most likely been asked in loads of other places before, but my searching of this forum doesn't seem to bring up anything useful, so I'm going to open a new topic. Feel free to redirect me elsewhere.

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?
SNES demos are great

Posts: 825
Joined: Tue Feb 07, 2017 2:03 am

Re: Scrolling the screen

Post by Oziphantom » Mon Oct 08, 2018 4:37 am

So basically you have lines

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...
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

0 0 0 0 0 0 
1 1 1 1 1 1
so the screens are also 2 screens wide. so each row is 64 tiles long. Thus the row you want to draw at is
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.

Posts: 21971
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)

Re: Scrolling the screen

Post by tepples » Mon Oct 08, 2018 5:10 am

The general technique:

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.
4. DMA.

Post Reply