SGDK - scrolling a background in sections
Moderator: Stef
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
SGDK - scrolling a background in sections
Hi,
One thing I haven't been able to wrap my head around is how to make it so that I can scroll a background plane at different speeds. The effect I'm most interested in is how the background scrolls in Sonic The Hedgehog 1. The far off mountains, the waterfalls and the ocean scroll at different rates. And the ocean scrolls at the pixel level.
How would I go and do that?
Thanks!
DJCC
One thing I haven't been able to wrap my head around is how to make it so that I can scroll a background plane at different speeds. The effect I'm most interested in is how the background scrolls in Sonic The Hedgehog 1. The far off mountains, the waterfalls and the ocean scroll at different rates. And the ocean scrolls at the pixel level.
How would I go and do that?
Thanks!
DJCC
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
That was just enough information to get me going, thanks!
I'm relying on SGDK since I'm not very familiar with the Genesis hardware, and there wasn't any obvious way (to me anyway) to set the scroll mode. But then I read that those settings are based on register values. SGDK doesn't seem to expose a function to set the scroll mode explicitly, but it does have a VPD_setReg() function. So I managed to find which register the scroll mode corresponds to, 0x0B, find the right value to set and call VDP_setReg() with them. Great!
I'm relying on SGDK since I'm not very familiar with the Genesis hardware, and there wasn't any obvious way (to me anyway) to set the scroll mode. But then I read that those settings are based on register values. SGDK doesn't seem to expose a function to set the scroll mode explicitly, but it does have a VPD_setReg() function. So I managed to find which register the scroll mode corresponds to, 0x0B, find the right value to set and call VDP_setReg() with them. Great!
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
There's a functon to set the hscroll value for a line:
You tell it the plane (A or B), the line number, and the scroll value.
Code: Select all
void VDP_setHorizontalScroll(u16 plan, u16 line, u16 value);
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
-
- Very interested
- Posts: 151
- Joined: Sun Apr 14, 2013 1:19 am
- Location: Auckland, New Zealand
- Contact:
If it's done per line, is this how you'd go about doing an outrun style game? Ie, manipulate the "lines" of the road for corners? I guess hills and some form of graphical effect to display speed would be other issues...Chilly Willy wrote:Set the horizontal scroll mode to per line, then the hscroll table has a scroll value for every line on the display. Then set different lines to different values to scroll them at different speeds.
-
- Very interested
- Posts: 616
- Joined: Thu Nov 30, 2006 6:30 am
I haven't actually pulled one of those games apart, but I believe that's how its done. Line scrolling for making the road bend. Palette cycling (and maybe some tile animation) to animate the road/ground to create the illusion of movement. Sprites for things like trees and signsPOLYGAMe wrote:If it's done per line, is this how you'd go about doing an outrun style game? Ie, manipulate the "lines" of the road for corners? I guess hills and some form of graphical effect to display speed would be other issues...Chilly Willy wrote:Set the horizontal scroll mode to per line, then the hscroll table has a scroll value for every line on the display. Then set different lines to different values to scroll them at different speeds.
-
- Very interested
- Posts: 151
- Joined: Sun Apr 14, 2013 1:19 am
- Location: Auckland, New Zealand
- Contact:
Awesome. I might have to give it a go. I built a 2.5D racing engine in unity... Uses same theory but manipulating quads, instead of lines of pixels. Works wellMask of Destiny wrote:I haven't actually pulled one of those games apart, but I believe that's how its done. Line scrolling for making the road bend. Palette cycling (and maybe some tile animation) to animate the road/ground to create the illusion of movement. Sprites for things like trees and signsPOLYGAMe wrote:If it's done per line, is this how you'd go about doing an outrun style game? Ie, manipulate the "lines" of the road for corners? I guess hills and some form of graphical effect to display speed would be other issues...Chilly Willy wrote:Set the horizontal scroll mode to per line, then the hscroll table has a scroll value for every line on the display. Then set different lines to different values to scroll them at different speeds.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Remember that scrolling on the MD allows for horizontal scrolling on the whole screen, each line of tiles, or every line, and vertical scrolling on the whole screen, or groups of two tiles. A great example of scrolling in both directions by a variable amount across the screen is the underwater parts of Earthworm Jim.
-
- Interested
- Posts: 30
- Joined: Mon May 06, 2013 2:27 am
- Location: Vermont, USA
I've been trying this out a bit, and I'm curious, what is the best way, (or any way at all franly that works ) to buffer up new tiles when scrolling?
This is something I have not been able to figure out.
(Also it seems like the VDP has an extra screen vertically and half of a screen horizontally unallocated when scrolling in either direction.)
This is something I have not been able to figure out.
(Also it seems like the VDP has an extra screen vertically and half of a screen horizontally unallocated when scrolling in either direction.)
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
You never refresh the whole screen, only the "diff" part (difference between new and old frame), and you do that "ahead" generally as the virtual screen is bigger than display screen. When you have only horizontal scrolling but in both way, it may be more convenient to use the 128x32 tilemap size so you can keep up to 3 screens in vram. Generally you try to keep as much tiles you can in vram to avoid tile refresh (except for sprite) during a singe level. At some point you can refresh some tiles for very large level but you have to use a nice method to divide you tile upload on several frame.