📜 ⬆️ ⬇️

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

This is a post about the limitations of old video games. I myself have never programmed under NES, but I superficially acquainted with architecture. Now I can not play games for the NES, without thinking about how they are arranged. Sometimes it causes so much admiration that you unwittingly forget about the game itself. “What is there to admire?” - You say. Yes, just fit into all the limitations of the NES, but at the same time make the game beautiful - this is really a whole art.

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

On the NES, everything displayed on the screen is divided into sprites and backgrounds. Sprites are objects that move around the screen. As a rule, it is directly your hero and enemies. Sometimes these are some other items, but everything depends on the game. The background is actually what is behind. Both sprites and backgrounds have a lot of limitations.

Background


The background on the NES is divided into squares of 8 by 8 pixels, called tiles. Total of such squares 30 in height and 32 in width. At the same time, the background can smoothly move horizontally and / or vertically.
')


In many games, especially old ones, it can be noticed that the game consists of such repeating squares. Remember Super Mario Bros., Bomberman or Battle City. The fact is that a very limited number of such drawings can be simultaneously downloaded into NES memory, so you had to use the same ones again.

In addition, significant restrictions were imposed on the colors. In total, NES can display about 53-55 colors, considering repetitive and similar. In those times it was not so little, but everything is not so simple. Such things as palettes are used:



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

I illustrate clearly:



The color marked with an asterisk is constantly changing, so the coins and questions are twinkling. Yes, coins are part of the background. And that is why the clouds and bushes are the same picture: the tile is one, the palette is different. 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. At the same time, it is possible to divide the screen into two parts and move them separately from each other, this is how a fixed line with information about lives, health, glasses and other things is usually done.

Sprites


If you figure out the limitations of the background, everything will be easy with sprites. The bottom line is that these are moving objects on the screen measuring 8x8 or 8x16 pixels. Moreover, they all must simultaneously be either 8x8 or 8x16, which imposes several other restrictions. At best (depending on the size), there may be as many as 64 of them, but no more than eight can be displayed on one line, even if the corresponding area of ​​the sprite is transparent, therefore too many moving objects cannot be made. True, some games still do, forcing one of the sprites to disappear for a split second, which leads to unpleasant flickering. Surely many have noticed this. On the colors are about the same restrictions as for the background, but for the sprites are given four separate palettes, 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 - Mario has sleeves, eyes, hair and a mustache of the same color. That is why Luigi's eyes, hair and whiskers turned green.



How is that?


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

For example, Chip and Dale 2:



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

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



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

I have described above that the background can be divided into two parts, which move separately. This is the way the initial splash screen is made, where the Fat Bullet Airship flies:



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

There are very different techniques. Look carefully at the famous screensaver Megaman 2:



Windows and protrusions are sprites, and the building itself is a background of just vertical lines, the movement of which cannot be traced:



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

By the way, some will ask why Megamen himself has so many flowers? Yes, in fact, it consists of several sprites: faces and bodies, which are superimposed on 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 usually are really 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 make it even smarter:



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

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



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

You can continue for a very long time. Any fairly serious game is crammed with a variety of such "tricks" that squeezed out of the 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 this was done 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 price of production, so the developers did not spoil themselves very much.

Do not forget about the limited sound capabilities, but it is not so clear. Let me just say that in order to create pleasant music with the help of such iron, you really needed to have musical talent. The Game Boy was already a bit 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 break their heads.

upd: Thank you so much comrade VEG for many clarifications!

Source: https://habr.com/ru/post/229187/


All Articles