Understanding the Super Nintendo Video System

Last time I explored the contents of Super Nintendo cartridgesand now let's take a look at its video system.

To put myself in the shoes of a Nintendo engineer working on Masayuki Uemura's (上村雅之) team, I decided to study what was available in 1989. Namely, television. This allowed me to understand the decisions that had to be made when designing the SNES video system.

Here's a summary of what I learned, hope you find it interesting too.

What's inside a TV from the early 90s?

The screen that the SNES outputs video to is a standard television. It is typically used to watch Captain Tsubasa, Cobra, Astro Boy, Captain Herlock, Saint Seiya, or Dragon Ball.

At the top is the antenna that picks up analog TV broadcasts (NTSC), the cable that transmits the signal to the tuner, and finally the part that displays the picture, called the cathode ray tube (CRT).

And one more element, especially important for the topic we are considering, is the additional input socket (AUX). A regular TV will have a composite socket (yellow), which transmits a video signal. Auxiliary stereo audio signals are transmitted through special sockets (white and red in my ugly drawing).

How does CRT work?

The CRT is a super line-drawing machine. At the time, they were rated at 15 kHz, meaning they could draw about 15,000 lines per second.

Inside the CRT is a cell with three electron guns. The guns always fire electrons straight ahead, and two sets of magnets (one vertical and one horizontal) direct them up/down and left/right.

Don't be confused by the fact that the beams from the guns in the picture are of different colors. In reality, of course, electrons have no color. But for the diagram it was more convenient to color them so that the reader could distinguish them and track the trajectory of each. In front of the phosphor layer there is a mask, which is responsible for ensuring that the electrons from each gun fall into the strip of the corresponding color.

There are no pixels in the CRT world. A slot is not a pixel. The image below shows the scale of the scanline where the different parts of the slots fall. The only thing that can be guaranteed is that the electrons from the gun always fall in the correct color band.

HDTV has smaller slots, which allows for better color signal display. In the image below, the same line is displayed horizontally with greater accuracy due to the higher slot density.

How is CRT controlled?

The CRT receives five signals transmitted over four wires. There is one wire for each signal (Red, Green, and Blue). They are directly connected to the guns. The higher the signal, the more electrons are fired and the brighter the phosphor stripes. No signal on all three wires means that no electrons are fired, meaning the line will display black.

The white wire in the picture above carries the synchronization signals. There are two of them, Horizontal Sync (HSYNC) and Vertical Sync (VSYNC). Both signals use the same wire, so it is called Composite Sync (CSYNC).

Due to my experience programming on PC I am used to the phrase “Wait for VSYNC”, which creates a false impression that it is the CRT that emits. Which is fundamentally wrong. The CRT does not emit anything, it only consumes signals and tries to synchronize the gun with them.

How a CRT Draws an Image

The CRT draws a line (raster) from left to right. When it receives an HSYNC event, it “returns” to the left side of the screen (X=0). When it receives a VSYNC event, it returns to the top of the screen (Y=0).

Observant readers will see the problem here. There is no way to go down. The system that controls the CRT can output as much HSYNC and VSYNC as it wants, the same line at the top of the screen will be drawn over and over again.

The Key to Understanding CRT

The key to understanding the CRT is to understand that the gun moves toward the right side of the screen at a downward angle. After HSYNC, the CRT returns to X=0, but because the gun moves down a bit, the next line will be drawn below the previous one.

This opens up a bunch of possibilities. The image above shows a signal where VSYNC is issued at the same time as the last HSYNC. The lines are always drawn in the same place on the screen. But look below what happens if VSYNC is issued between two HSYNCs.

Since only half a line is drawn at the bottom, the CRT begins drawing the next line at the top of the screen at the same X position. The next set of lines will alternate with the previous set.

The sets of lines are called “fields.” The mode in which the fields are drawn in the same place is called “progressive” or sequential scanning (“p”). The mode in which the fields alternate is abbreviated “i.” In i mode, a compromise is made: the vertical resolution is doubled, but the refresh rate of each line is halved.

NTSC outputs two fields at 30 Hz. Therefore, all CRT monitors have enough space between the lines for interlaced scanning. When drawing in progressive mode, the space between the lines is visible. This results in the black space between the lines, which is typical of CRT rasterization.

Visible gaps in scanlines. Photo source: retrogameboards.com

Visible gaps in scan lines. Photo source: retrogameboards.com

What is inside the line?

When it comes to drawing lines, the CRT is numerical, but when we talk about what is inside the line, it becomes analog. As you can see in the picture, the three guns are directly connected to the three RGB wires. The system can vary the color signal as much as it wants (and therefore use any horizontal resolution). The only limitation is the signal spread and the density of the slot mask.

We work with what we have

While the SNES designers could send whatever they wanted over the wire, they still had to make sure the CRT could handle it. Since the hardware was designed to display an NTSC signal, whatever they decided on had to be close to the following specifications:

  • Aspect ratio 4:3

  • Number of lines: 262.5 per field

  • Number of dots per line: 341.25

  • Field frequency: 59.94 Hz

59.94 Hz – what a strange number… Doesn't the power grid run at 60 Hz, and TVs use that frequency directly from the AC power? Black and white NTSC used to use 60 Hz. But when broadcast engineers had to find a way to add color to the NTSC signal without breaking backward compatibility, they decided to lower the frequency by 0.1% to avoid artifacts.

As a Nintendo engineer

Now that we know how a CRT works, it's time to try our hand at being a Nintendo engineer and create a video system.

The first thing is to make as many lines as we need. NTSC uses 262.5 lines per field, but half of the line is used to interlace the fields. We can use 262 lines to make the scan progressive. At a target frequency of 59.94, that would require 15,734.26 lines per second, which is within 4% of the 15 kHz rating.

The CRT screen has an aspect ratio of 4:3. If we use 350 horizontal dots, we will hit that aspect ratio exactly, and there will be no distortion when converting the console image into scan lines.

So, 262 rows of 59.94 Hz, each with 350 dots. So we need a dot clock that pulses at 262 * 350 * 59.94 = 5,496,498 Hz. We can build an ASIC that counts the dot ticks. Every 350 ticks, it says HSYNC. Every 350 * 262 = 91,700 ticks, it says VSYNC. Think that's it? No, we're just getting started.

This naive construction has two problems:

  1. It requires a frequency of 5,496,498 Hz, which we do not have. The cost limitations of the SNES do not allow the video system to have its own oscillator. There is a main oscillator, which the subsystems must use through dividers.

  2. You can't draw color all the time. This is called overscan. It deserves its own section.

Off-screen scan

When the gun's position is reset horizontally or vertically, it continues to fire electrons. If it continues to fire, it creates visible artifacts.

TVs also have a tendency to overscan, which means the image on the screen is slightly larger than the display. The degree of overscan varies from TV to TV. This is to hide the jitter that occurs when the vertical position of the gun is reset to Y=0 (after VSYNC) and it wobbles up and down for a while. You get straight lines after a few microseconds. The same problem occurs horizontally after HSYNC.

The solution to all these problems is to “stop” the CRT gun a little after VSYNC and after HSYNC. These time intervals during which no electrons are fired are called VBLANK and HBLANK, respectively.

All gaming systems of the era used this technique. Here is a summary of the SNES's competitors:

Device

Year

Lines

VBLANK Lines

Visible lines

Lines per second

Frame frequency

Capcom arcade CPS-1

1989

262

38

224

15,622

59.6294

Sega Genesis

1989

262

38

224

15,700

59.9227

Neo-Geo AES

1990

264

40

224

15,734

59.18

Selecting SNES Vertical Resolution

If you look closely at the above summary table, you can see that all competing systems, namely the Megadrive, Neo-Geo, and Capcom's CPS-1, used 224 visible lines.

They probably didn't choose this number by accident. 224 is a number divisible by 16 (224/16 = 14), which means it fits well with the graphics rendering pipeline tiles.

I think Nintendo didn't want to reinvent the wheel. They didn't want higher resolution, they wanted better graphics. What really set the Nintendo system apart was its PPU.

In the end they took the safe route and divided their 262 lines into 224 visible + 38 empty (as shown in the picture on the left).

Arcade games were allowed to look as unusual as their creators wanted. R-Type developers at Irem were unhappy with the default 224 active lines of a CRT.

They calibrated their M72-System registers to draw 284 lines, 512 dots, and used a clock speed of 8 MHz. Leaving 128 dots for HBLANK and 28 lines for VBLANK gave an active resolution of 384×256, which was higher than other arcade games of the time.

The compromise was a vertical refresh rate of 55.017605 Hz, which was visually less pleasing and 10% off the recommended CRT values. This refresh rate is difficult to replicate for “modern” emulators, but what an impressive feat for a 1987 system!

Selecting SNES Horizontal Resolution

So far we have chosen the number of lines per frame (262). We also know that we cannot choose the dotclock (the clock signal for displaying images on a (dot) raster display). We need to use the Master clock (21.47727 MHz) and use a divider to get something close to the NTSC dotclock. The only thing left is to use a dotclock of 21.47727 MHz / 4 = 5.3693175 MHz.

Lines, dots, dot frequency, and refresh rate are related by the frame rate equation:

refresh rate = (lines * dots)/dotclock

Given that our target refresh rate is 59.94Hz, we don't have much choice in terms of the number of dots per line.

dots = 5369317.5 (dotclock) / (262 (lines) * 59.94 (frequency)) ≃ 342

For a number of reasons related to carrier artifacts when using composite outputs, Nintendo engineers had to use 341 dots per line instead of 342. As a result, the SNES frame rate was:

refresh rate = 5369317.5 / (341 * 262) = 60.098 Hz

60.098Hz is not NTSC's 59.94Hz, but since, as shown earlier with R-Type, CRTs have some tolerance, it works.

Selecting horizontal overscan on SNES

Of the 341 dots, all cannot be used for the same reasons: jitter, artifacts, and overscan. The SNES requires horizontal overscan, during which it outputs a blank signal.

The restrictions are as follows:

  • The result is an aspect ratio close to 4:3. That is, 224*(4/3) = 298 visible dots.

  • You need to play with the tilemaps graphics pipeline, which uses 16×16 tiles. The remaining values ​​are 304 (16×19), 288 (16×18), 272 (16×17), 256 (16×16), 240 (16*15), and so on. The best value, which results in almost no distortion on the screen, is 304 points.

The third constraint was to give the PPU enough time to fill the sprite line buffer during HBLANK. I suspect that up to 128 sprites was too much data to fetch, and the PPU needed more than the 7 µs provided by 37 HBLANK points if 304 visible points were chosen as the horizontal resolution.

In the end, Nintendo settled on 256 visible dots per line with 85 HBLANK dots. This means the PPU has 16 µs to fetch sprite data during HBLANK. This also means the aspect ratio was 8:7 instead of 4:3, which causes a bit of distortion when displayed on a CRT.

High vertical resolution mode: interlaced scanning

So far we have designed the SNES video system with progressive mode only in mind.

  • Off-screen resolution: 341×262

  • Visible resolution: 256×224

  • Frame rate: 60.098 Hz

While these are the settings that 99% of games ended up using, the SNES also had high-resolution modes. I can double the resolution vertically and/or horizontally.

Doubling the vertical resolution to 448 lines is easy. We can simply change the counter to output VSYNC half a line after the last HSYNC to interlace the frames. This means drawing 262.5 lines per frame, but each line will now only be refreshed at 60.098/2=30.049 Hz. This will cause flickering, and it won't be pretty, but the vertical resolution will be higher.

High Horizontal Resolution Mode: A Trick

However, doubling the horizontal resolution is much more difficult because the console does not have the required dot frequency.

The trick is that the SNES shifts every other field horizontally a little bit, so that the dots of a field end up between the dots of the previous field. You end up with something that runs at half the frame rate and has huge color leaks. Many titles used this, mostly for menu screens, as detailed in fullsnes.txt.

Hire Software

Air Strike Patrol (mission overview) (whatever mode? with Interlace)

Bishoujo Wrestler Retsuden (some text) (512×448, BgMode5+Interlace)

Ball Bullet Gun (in lower screen half) (512×224, BgMode5)

Battle Cross (in game) (but isn't hires?) (512×224, BgMode1+PseudoH)(Bug?)

BS Radical Dreamers (user name input only) (512×224, BgMode5)

Chrono Trigger (crash into Lavos sequence) (whatever mode? with Interlace)

Donkey Kong Country 1 (Nintendo logo) (512×224, BgMode5)

GOD (intro & lower screen half) (512×224, BgMode5)

Jurassic Park (score text) (512×224, BgMode1+PseudoH+Math)

Kirby's Dream Land 3 (leaves in 1st door) (512×224, BgMode1+PseudoH)

Lufia 2 (credits screen at end of game) (whatever mode?)

Moryo Senki Madara 2 (text) (512×224, BgMode5)

Power Drive (in intro) (512×448, BgMode5+Interlace)

Ranma 1/2: Chounai Gekitou Hen (256×448, BgMode1+InterlaceBug)

RPM Racing (in intro and in game) (512×448, BgMode5+Interlace)

Rudra no Hihou (RnH/Treasure of the Rudras)(512×224, BgMode5)

Seiken Densetsu 2 (Secret of Mana) (setup) (512×224, BgMode5)

Seiken Densetsu 3 (512×224, BgMode5)

Shock Issue 1 & 2 (homebrew eZine) (512×224, BgMode5)

SNES Test Program (by Nintendo) (Character Test includes BgMode5/BgMode6)

Super Play Action Football (text) (512×224, BgMode5)

World Cup Striker (intro/menu) (512×224, BgMode5)

Note: Ranma is actually only 256×224 (but is accidentally interlaced, which causes some completely useless flickering).

PAL vs NTSC

And that's not all. In Europe, TVs use PAL, not NTSC, and the French even use SECAM. The expected frame rate is exactly 50 Hz, and the field is 312.5 lines.

This is actually not a difficult problem to solve. These versions of the SNES come with a Master clock running at 17.7344750 MHz. The same divider gives a dot clock of 5.32034250 MHz. The over-the-screen resolution is 312 lines by 341 dots. The visible resolution is 224 lines by 256 dots. And the frame rate is 50.00697891 Hz.

The problem is that only 224 lines of graphics will result in large black bars above and below the active area. This is solved by using “Overscan mode”, which increases the number of visible lines to 240 (i.e. 16 lines, which is the height of one tile).

What a gift for game developers wanting to port a game to the European market, you might say. In practice, the “overscan mode” was never used. Most games were specifically designed for 224 lines, so developers didn't know what to put in those 16 extra lines. In total, only twelve games ever used the mode. Nintendo did manage to do something amazing with its flagship game Super Mario World, though, by increasing the vertical viewing range.

NTSC (256×224)

PAL (256×240)

Note that NTSC and PAL screens use the same 4:3 aspect ratio, so the PAL image is slightly more vertically compressed than the NTSC image.

NTSC Screen (4:3)

PAL screen (4:3)

Aside from the annoying black bar, the game code was also rarely revised to account for VSYNC, which was occurring at 50.00697891Hz instead of 60.098Hz. This resulted in the game running 17% slower than intended. In short, European gaming was a nightmare. But luckily, without the internet, we didn’t know about it.

Connectors

So far we've only looked at the “clean” signals needed to drive a CRT. However, very few TVs allowed a signal to be fed directly to a CRT. Most TVs only had a yellow composite input on the back, and some higher-end models had S-Video inputs.

To cope with this variety of options, the SNES does something very cool. It converts CRT signals to both composite and S-Video.

AV connector

No signals are dropped. The AV output design gives gamers selective access to clean RGB/CSync, Composite and S-Video signals.

1. Red

2. Green

3. C-Sync

4. Blue

5. Earth

6. Earth

7. Brightness (S-Video)

8. Color (S-Video)

9. Composite video

10. +5VDC

11. Left audio

12. Right audio

European TVs, especially in France, came with SCART (aka Prise peritel) connectors. This allowed them to create cables that plugged directly into the CRT.

This meant we could enjoy games slowed down by 17% and with black bars, but at the highest level of visual fidelity.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *