Ratchet scrolling

From TheAlmightyGuru
Revision as of 22:44, 7 September 2022 by TheAlmightyGuru (talk | contribs) (Technical)
Jump to: navigation, search
Try as he might, Mario can never go back.

Ratchet scrolling is a video game term and mechanic used to describe games which feature a scrolling background, but, like a ratchet, you may only move in one direction. This can be distinguished from multi-directional scrolling where they player is free to move in multiple directions, or auto scrolling, which typically scrolls in a single direction, but the player cannot control it.

Ratchet scrolling was originally created, not because the designers liked it, but as a tradeoff to get more performance out of limited hardware. It didn't take long before video game hardware improved enough that the constraint could be eliminated, but the mechanic was used frequently enough in the 1980s for later gamers to give it a name.

Super Mario Bros. is the most popular video game to use ratchet scrolling, though several games used the mechanic before it. Games which feature horizontal ratchet scrolling typically just prevent the player from moving back, while games which use vertical ratchet scrolling typically kill the player's character if they get too close to the bottom.

Personal

Like most 1980s gamers, the first game I played with ratchet scrolling was Super Mario Bros., and, like most of my friends, I found it to be a bit annoying. Each time I would accidentally over-shoot a jump or run too far and miss a power-up, I would complain about the game not allowing me to go back for it. And, when I saw other NES games that didn't seem to have a problem with multi-directional scrolling, it made me even more annoyed, as though the developers just short-changed us. However, as an adult with a much better understanding of how the NES works, and what a technical marvel it was to get Super Mario Bros. working on stock hardware, I've since made my peace with it. Also, as someone who likes to study game design, I can now see how ratchet scrolling makes for a useful mechanic even though it no longer is needed to cover up technical limitations.

Games

These popular games use ratchet scrolling for all games, see the category.

Title Released Scrolling Direction
Chip 'N Dale: Rescue Rangers 1990-06-08 Alternates between right and up
Contra 1987-02-20 Right
Double Dragon 1987-04-22 Right
Dynamite Dux 1988-09-?? Right
Excitebike 1984-11-30 Right
Ice Climber 1984-10-?? Up
Kid Icarus: Angel Land Story 1986-12-19 Alternates between up and right
Super Mario Bros. 1985-09-13 Right
Wonder Boy 1986-03-03 Right

Technical

Nothing in early 8-bit hardware prevents bi-directional scrolling, in fact, NES games like Soccer and Kung Fu, both of which predate Super Mario Bros., feature bi-directional scrolling. However, these games are able to do so because they use simple maps. In the case of Soccer the map is only two screens wide so it can fit entirely into the NES's video memory, and, in the case of Kung Fu, the map doesn't contain any complex structures that need to be stored in memory. Later games which feature complex maps and still allow for bi-directional scrolling, like Metroid, are able to do this because they have additional hardware in their cartridge.

To understand why ratchet scrolling was used in Super Mario Bros., you must first understand how the game stores its maps. Like most games for the NES, maps are made up of 16x16 pixel tiles. In Super Mario Bros. , the visible portion of the map is 15 tiles tall, but the width varies in each map. Map 1-1, for example, is 224 tiles wide. Even if the game confined itself to short levels like this, each level would require 3,584 bytes to store the tiles, and, to store all 32 of the game's maps, it would require 114,688 bytes. However, the entire game, with its graphics, music, program code, and maps fits into only 40,960 bytes! The designers were able to have these long complex levels because they used clever tricks for storing the maps.

Super Mario Bros. - NES - Background Objects.png

One trick comes from building the bricks and blocks, not from individually placed tiles, but from programmable objects. One such object is the staircase of blocks seen before the flagpole. This object can have a width anywhere between 1 to 9 tiles and is built from an algorithm which states, each time it increases in tile width, it also increases in tile height, which results in stairs. The object only needs to be defined once, then the designers could place it many times throughout the game's maps and they could achieve variety by adjusting the size each time. Looking at map 1-1 you can see that the staircase object is used three times, one large one just before the flagpole, but also two smaller ones near the middle of the map.

Super Mario Bros. - NES - Background Rendering.png

Another important piece to understanding why ratchet scrolling is used comes from the NES's limited video memory. Using its stock hardware, the NES has enough memory to fit only two screens worth of background in memory. Super Mario Bros. uses the memory to process the visible screen, plus half a screen in front of the player, and half a screen behind the player. This allows the game to load new map tiles off-screen where the player can't see them being drawn, and also allows game to handle what enemies do slightly off-screen. This adds to the game's realism and explains why, if you kick a turtle shell where a pipe is off-screen, it bounces back at you.

The limited video memory and object-based mapping system by themselves don't prevent bi-directional, but both of them combined do. I've made a mock-up map to show what would happen if the game allowed for Mario to move backward.
In the diagrams below, the black area is not loaded in memory and the blue area is loaded in off-screen memory. Mario begins by moving right on an empty map.

Super Mario Bros. - NES - Ratchet Explanation - 1.png

As Mario moves to the right, the off-screen section loads a map object, represented by the tile highlighted in yellow dots. This is the horizontal brick object which is used all through the game's maps. This particular one is set to a width of 16 tiles, but, so far, only the first tile is loaded in memory.

Super Mario Bros. - NES - Ratchet Explanation - 2.png

As Mario continues forward, the game knows to continue loading more brick tiles to the right of the brick object. As he moves forwards, the tiles enter the visible portion of video memory, and Mario will see them. The game will continue to load more brick tiles until it reaches its full width of 16 seen below.

Super Mario Bros. - NES - Ratchet Explanation - 3.png

Mario continues forward until eventually the object which spawned the row of bricks is no longer in memory (although I left it in the diagram so you can tell how far tiles Mario has passed it). The bricks that are still in memory remain even though the object is gone, but those that move too far to the left disappear.

Super Mario Bros. - NES - Ratchet Explanation - 4.png

As Mario moves forward, more bricks are unloaded from memory until only two remain.

Super Mario Bros. - NES - Ratchet Explanation - 5.png

Now here's what would happen if Mario decided to turn around at this point. The two bricks that were still in memory are still there, and, going back far enough, Mario can see them again. However, the rest of the platform doesn't load because Mario hasn't yet gone back all the way to load the object which spawns them into memory.

Super Mario Bros. - NES - Ratchet Explanation - 6.png

Once Mario goes back far enough, the brick object will finally be loaded into memory again, and only then could the game could load all the missing bricks, but they would almost instantly be drawn across the screen. Also, if this were to happen with objects lower on the screen, Mario could find himself trapped in bricks!

Super Mario Bros. - NES - Ratchet Explanation - 7.png

This is just one of the problems the developers would have had to have solved if they allowed Mario to move backward. The complex mapping system would cause several other issues as well, but all of them were avoided simply by implementing ratchet scrolling.

Links

Link-TVTropes.png