Games for NES / Famicom / Dandy through the eyes of a programmer

    This post is about the limitations of old video games. I myself have never programmed under NES, but I met superficially with architecture. Now I can’t play games for NES without thinking about how they work. Sometimes it is so much admired that you involuntarily forget about the game itself. “What is there to admire?”, You say. Yes, just fit into all the limitations of NES, but at the same time making the game beautiful is really a whole art.

    Now I will try to tell you about it, simplifying everything as much as possible.

    On NES, everything displayed on the screen is divided into sprites and background. Sprites are objects that move around the screen. As a rule, this is directly your hero and enemies. Sometimes these are still some objects, but here everything is already very dependent on the game. The background is actually what is behind. Both sprites and background have a ton of restrictions.


    The background on NES is divided into 8 by 8 pixel squares called tiles. Total of these squares is 30 in height and 32 in width. In this case, the background can smoothly move horizontally and / or vertically.

    In many games, especially old ones, you will notice that the game consists of such repeating squares. Think of Super Mario Bros., Bomberman, or Battle City. The fact is that a very limited number of such drawings can be loaded into NES memory at the same time, so you had to use the same ones repeatedly.

    In addition, significant restrictions were imposed on the colors. In total, NES can display about 53-55 colors, considering duplicate and similar ones. In those days, it was not so small, but everything is not so simple. Things like palettes are used:

    • A palette is a set of four colors, i.e. some four colors from these 53-55 colors
    • There can be only four such palettes for the background, while one color in each of them should be the same
    • Each group of four tiles (2x2) displayed on the screen can be associated with one of these palettes

    It may not be so easy to understand the first time. I'll try to explain on the fingers. Take another look at the picture above. Each box is painted in no more than four colors. Moreover, they are divided into three types: black-white-blue, black-green-blue, black-brown. It is possible that the fourth is used, but I did not notice.

    I will illustrate clearly: The

    color marked with an asterisk is constantly changing, so the coins and questions flicker. Yes, coins are part of the background. And that is why clouds and bushes are one and the same picture: there is one tile, a different palette is selected. They saved a little memory, but it is completely imperceptible at first sight.

    As I said, the background can move. Mirroring is usually used for this, but I will not go into these details. In this case, it is possible to divide the screen into two parts and move them separately from each other, this is how a fixed line is usually done with information about lives, health, glasses and other things.


    If you figured out the limitations of the background, everything will be easy with sprites. The bottom line is that these are 8x8 or 8x16 pixels moving objects on the screen. Moreover, they all must be either 8x8 or 8x16 at the same time, which imposes several other restrictions. In the best case (depending on size) there can be as many as 64 of them, but no more than eight can be displayed on one line, even if the corresponding sprite area is transparent, so you won’t make too many moving objects. True, some games still do, causing one of the sprites to disappear for a split second, which leads to unpleasant flicker. Surely many noticed this. About the same restrictions are imposed on colors as for the background, but for sprites four separate palettes are given, one of the colors is considered to be transparency. That is, we get only three colors + background ...

    Luigi is just Mario with a different palette. Please note that Mario has the same sleeve, eyes, hair and mustache. That is why Luigi's eyes, hair and mustache turned green.

    How does this happen?

    Now take a look at NES games, given the limitations described above. How is it that the background can only be of 13 colors, but many games are remembered very colorful? How did we fight huge bosses with such small sprites? Games are starting to look very different.

    For example, Chip and Dale 2:

    Everything is very colorful and colorful, while the developers fit into all the restrictions.

    As soon as we get to the second half of the level, new colors appear:

    Just at the moment when we move to another location and the screen gets dark, new palette and tiles are loaded into the memory. So it seems that the game is much more colorful than it really is: these very 13 colors often change from level to level.

    I described above that the background can be divided into two parts that move separately. This is how the initial splash screen was made, where the Tolstopuz airship flies:

    The barbed wire below moves at one speed, the background at another, the airship itself is a sprite that moves at third speed. This creates the illusion of volume.

    There are completely different tricks. Look carefully at the famous Megaman 2 screensaver:

    Windows and ledges are sprites, and the building itself is a background of simply vertical lines, the movement of which is impossible to trace:

    In fact, the building moves at the same speed as the city in the background, but it is invisible. At the same time, due to the movement of the windows, one gets the impression that the building is still moving much faster, and this accordingly creates the feeling that it is closer.

    By the way, some will ask why Megamen has so many colors? Yes, it really just consists of several sprites: faces and bodies that overlap each other:

    Now think about how big mobile bosses were made, considering all the restrictions on the number of sprites? The answer is simple: such bosses are usually actually the background. That is why when fighting with them, the background is often either black or just plain. Here is an example from the same Chip and Dale 2:

    In the first case, such a background moves vertically, in the second horizontally. I think that you yourself will remember a lot of bosses on a black background.

    In some games like Jurassic Park they’re even trickier: the

    boss is still the background, but the bushes and stones in the background are sprites. That is, all the upside down! And yes, the sprite may be behind the background. That is why when a character passes through the bushes, they sometimes shine through him.

    By the way, for the same game in the screensaver, the inscription “Ocean” is large, moves in different directions at different speeds, and then it is completely displayed in waves:

    It's all very tricky. The game tracks the moment when a scanline (horizontal line) is drawn on the TV screen, after which it moves the background horizontally. This way you can get an effect like horizontal waves.

    You can go on for a very long time. Any fairly serious game is crammed with a variety of such "tricks" that squeezed out of NES much more than was originally intended. I must say that many of these restrictions could be removed by installing additional chips in the game cartridge. And they did it very actively, as a result, the cartridges could be very different from the hardware point of view, but then it was necessary not to forget about the final production price, so the developers did not spoil themselves very much.

    Do not forget about the limited sound capabilities, but this is not so obvious. I can only say that in order to create pleasant music with the help of such iron, one really needed to have musical talent. Game Boy was already a little more advanced in this regard and as a result spawned a whole musical genre and its culture.

    I hope that now you will look at the games differently, thinking about how the developers had to smash their heads.

    upd: Many thanks to VEG for many clarifications!

    Also popular now: