It is currently Tue Dec 11, 2018 6:07 pm

All times are UTC - 7 hours



Forum rules





Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Scrolling the screen
PostPosted: Mon Oct 08, 2018 2:52 am 
Offline

Joined: Sat Apr 07, 2018 7:39 pm
Posts: 15
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?
Thanks,
Molive.


Top
 Profile  
 
 Post subject: Re: Scrolling the screen
PostPosted: Mon Oct 08, 2018 4:37 am 
Offline

Joined: Tue Feb 07, 2017 2:03 am
Posts: 629
So basically you have lines

Code:
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


etc
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:
....
636363636363
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.


Top
 Profile  
 
 Post subject: Re: Scrolling the screen
PostPosted: Mon Oct 08, 2018 5:10 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20853
Location: NE Indiana, USA (NTSC)
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group