Skip to main content

The NES, Nintendo Entertainment System (1985)

"Atari collapsed because they gave too much freedom to third-party developers and the market was swamped with rubbish games." - Hiroshi Yamauchi, Nintendo's president in 198616

The Nintendo Entertainment System (or NES for short) is an 8-bit home video game console developed and manufactured by Nintendo. It is a remodeled export version of the company's Family Computer (Famicom for short) which launched on July 15, 1983 and hit America during the 1985-1986

The NES was able to bring new life to the video game market, offering high quality 8-bit games.

Nintendo planned the marketing campaign very carefully, because after video game crash, consumer will not likely buy videogames so easily.

First of all game packages contained true image taken from the game, instead of 'artistic pictures'.

For instance compare E.T. and super Mario package pictures versus reality of the game:

E.T. Package vs E.T. Real game:

ET Game Package ET Game

The E.T. package seems taken from the film's storyboard.

Now take a look at the Super Mario Super Mario package vs Super Mario actual game:

Super Mario Package Actual Game

Nintendo games was "honest" in the sense they do not try to fool the customer: what you get is very similar to what you see in the picture of the game package.

As we will see, Nintendo will have a firm hand on its games, protecting them via copyright, avoiding third part game producers (like Activision). This will be a winning strategy for more than 20 years, and will be followed by the other company too.

The Nintendo Entertainment System launch​

The NES was launched through test markets in New York City and Los Angeles in 1985, before being given a wide release in the rest of North America and parts of Europe in 1986, followed by Australia and other European countries in 1987

When Nintendo released the NES in the US, the design styling was deliberately different from that of other game consoles: it resembles a VCR instead of a game console.

NES Hardware overview​

For its CPU, the NES uses the Ricoh 2A03, an 8-bit microprocessor based on a MOS Technology 6502 core, running at 1.79 MHz for the NTSC NES and 1.66 MHz for the PAL version.

The NES contains 2 kB of onboard work RAM. A game cartridge may contain expanded RAM to increase this amount. The sizes of NES games vary from 8 kB (Galaxian) to 1 MB (Metal Slader Glory), but 128 to 384 kB is the most common.

The NES uses a custom-made Picture Processing Unit (PPU) developed by Ricoh. All variations of the PPU feature 2 kB of video RAM, 256 bytes of on-die "object attribute memory" (OAM) to store the positions, colors, and tile indices of up to 64 sprites on the screen, and 28 bytes of on-die palette RAM to allow selection of background and sprite colors.

Sprites was very small: 8 × 8 or 8 × 16 and only 8 sprites was visible per scan line (like the C/64).

If you do the math, for storing 8x8 x 64 sprites you need only 512 bytes. For the 8x16 sprites you need 1Kb.

NES has little RAM in respect of other systems (like C/64) but ROM cartridges could mount a Memory Management unit to provide additional RAM, and also to address more of 64KB via bank switching.

To understand a bit more lets dive inside the NES. We borrow some technical notes from the nesdev wiki and make it a bit more "readable". We start with the memory map:

Address rangeSizeDescription
$0000-$07FF$08002KB internal RAM
$0800-$0FFF$0800Mirrors of $0000-$07FF
$1000-$17FF$0800Mirrors of $0000-$07FF
$1800-$1FFF$0800Mirrors of $0000-$07FF
$2000-$2007$0008NES Picture Processing Unit (PPU) registers, graphic chip
$2008-$3FFF$1FF8Mirrors of $2000-2007 (repeats every 8 bytes)
$4000-$400F$0010NES Audio Processing Unit (APU) registers
$4010-$4017$0008DMC, joystick. APU registers
$4020-$5FFF$1FE0Cartridge (maybe mapper registers)
$6000-$7FFF$1000Cartridge RAM (maybe battery-backed)
$8000-$FFFF$8000PRG ROM (maybe bank switched)
$FFFA-$FFFB$0002NMI vector
$FFFC-$FFFD$0002Reset vector
$FFFE-$FFFF$0002BRK vector

The 6502 chip has stack at fixed position $0100-$01FF so that 256 bytes cannot be used. Also page zero $00-$FF is often used as "support" registers.

The cartridge map space ($4020-$FFFF) is 49120 bytes, about 48 Kb, but the story is more complex:

NES games come in cartridges, and inside of those cartridges are various circuits and hardware.
Different games use different circuits and hardware, and the configuration and capabilities of such cartridges is commonly called their mapper.

From https://8bitworkshop.com/docs/platforms/nes/#programming

For instance, the first released games in 1983 ("Donkey Kong", "Donkey Kong Jr." and "Popeye") had 16 KB program memory and 8 KB character memory (for Sprites and tiles). "Metal Slader Glory", one of the last released (1991) had 512KB of PRG ROM and CHR ROM.

The simpler mapper: NROM​

The simpler mapper is mapper 0 which has no bank switching at all, and can provide up to 32Kb of program code and 8Kb of tiles/sprite space.

Below we show a simple memory map for a NROM cartridge of 8Kb:

Memory Map

Most complex mappers: UNROM and UOROM​

These ROMS was able to address up to 256Kb, seleting a 16KB bank in address $8000-BFFF. UNROM has 4 or 8 banks 16 KB in size; UOROM has 16 banks. The last of these banks is fixed at $C000-$FFFF. The rest (numbered 0-2, 0-6, or 0-14) are switchable at $8000-$BFFF.

Switching banks requires a write to $8000-$FFFF. When writing to $8000-$FFFF, the value you are writing must match the value located at the destination address in ROM, to avoid an hardware problem called "Bus Conflict". A bus conflict occurs when two logic devices output different values on the same bus line.

One way to ensure this is to have a bankswitch lookup: you read from this table and then immediately write back to the table the same value.

The lookup table and the bankswitching subroutine are normally located in the fixed bank ($C000-$FFFF).

An example code is:

.segment "RODATA"
banktable: ; Write to this table to switch banks.
.byte $00, $01, $02, $03, $04, $05, $06
.byte $07, $08, $09, $0A, $0B, $0C, $0D, $0E
; UNROM needs only the first line of this table (0-6)
; but UOROM needs both lines (0-14).

.segment "ZEROPAGE": ; The mapper is read-only; need to track its state separately
current_bank: .res 1

.segment "CODE"
bankswitch_y:
sty current_bank ; save the current bank in RAM so the NMI handler can restore it
bankswitch_nosave:
lda banktable, y ; read a byte from the banktable
sta banktable, y ; and write it back, switching banks
rts

Code credit: nesdev Programming UNROM.

As you see bank switching add some complexity and need to break your code in chunks of 16Kb ($8000-$BFFF). Some cartrdige also provide additional RAM, like the MMC3 mapper (they have up to 512 KiB of PRG ROM, 8 KiB of PRG RAM, 256 KiB of CHR ROM, and a scanline counter).

The following memory map show a complex MMC3 mapper with 4x16Kb PRG banks and 8x8KB CHaRacter banks.

Graphic​

The console's 2 kB of onboard RAM may be used for tile maps and attributes on the NES board and 8 kB of tile pattern ROM or RAM may be included on a cartridge. The system has an available color palette of 48 colors and 6 grays. Up to 25 simultaneous colors may be used without writing new values mid-frame: a background color, four sets of three tile colors, and four sets of three sprite colors. The NES palette is based on NTSC rather than RGB values. A total of 64 sprites may be displayed onscreen at a given time without reloading sprites mid-screen. The standard display resolution of the NES is 256 horizontal pixels by 240 vertical pixels.

C/64 has a 320 x 200 pixels resolution, so they are quite comparable.

Sound support​

The stock NES supports a total of five sound channels, two of which are pulse channels with 4 pulse width settings, one is a triangle wave generator, another is a noise generator (often used for percussion), and the fifth one plays low-quality digital samples.

The NES supports expansion chips contained in certain cartridges to add sound channels and help with data processing. Developers can add these chips to their games, such as the Konami VRC6, Konami VRC7, Sunsoft 5B, Namco 163, and two more by Nintendo itself: the Nintendo FDS wave generator (a modified Ricoh RP2C33 chip with single-cycle wave table-lookup sound support), and the Nintendo Memory Management Controller 5 (MMC5).

Cartige are a double edge sword: it allows to play instantaneously and custom chip expansion but had a higher price.

For instance Sony Playstation will innovate using CD-ROMs, which make the media cost negligible

NES Legacy​

The NES was released 35 years ago today. While official NES games haven't been released in over 20 years, a "homebrew" scene exists where developers are still creating NES games (playable on the original hardware or on emulators) in the original 6502 Assembly Language.

From https://github.blog/2018-07-16-how-the-nintendo-entertainment-system-lives-on-in-open-source-game-bytes/

There are some guys who develop NES games today.

NES Mini​

In 2016 Nintendo released a "NES Classic Mini", followed by the SuperNes the next year.

http://www.nintendolife.com/news/2016/07/nintendo_entertainment_system_nes_classic_edition_coming_this_november_ships_with_30_games

Other References

https://gutomaia.net/pyNES/