NES architecture - Falmouth-Games-Academy/comp310-wiki GitHub Wiki

(To be completed)

Introduction

The NES (Nintendo Entertainment System) was released in North America in 1985 and Europe during 1986/1987. The NES was initially released in Japan in 1983 but was known as the 'Family Computer' which was also known as the 'Famicom' from its release date in 1983. By the end of 1987, Nintendo controlled somewhere between 86% to 93% of the market. By the time Seg had sold 100,000 Master Systems, Nintendo had already sold more than 2 million NES units 10(https://books.google.co.uk/books?hl=en&lr=&id=PTrcTeAqeaEC&oi=fnd&pg=PT9&dq=The+Ultimate+History+of+Video+Games&ots=anEv-53Sfa&sig=w00gnyMOIZgF4MMC7kuEsR73pls#v=onepage&q=The%20Ultimate%20History%20of%20Video%20Games&f=false).

Developers had to have a deep understanding of the electronics in order to get even the simplest program working. They were pushing the very limits of what could be done and were driving custom electronics to push only a few thousand pixels to the screen 1(https://legoaler.wordpress.com/2011/04/10/a-peek-into-the-nes-architecture/). The NES consists of 3 main parts, the central processing unit (CPU), the picture processing unit (PPU), and the checking integrated circuit (CIC) 2(https://www.youtube.com/watch?v=ar9WRwCiSr0&t=283s). There is also an audio processing unit (APU) contained as a sound chip within the CPU 3(https://taywee.github.io/NerdyNights/nerdynights/nesarchitecture.html).

Architecture Diagram [3]

This diagram shows the components of the NES and its cartridges.

The CPU - 1.79Mhz [2]

Its 8-bit CPU is a variant of the MOS 6502 microprocessor, which is called the RP2A03 (NTSC) or RP2A07 (PAL) depending on the analogue TV colour encoding system used. the biggest difference between the 6502 and Ricoh units was the the inclusion of a decimal mode in the MOS 6502. It is developed by Ricoh, a Japanese imaging and electronics company. From today's standards the CPU was extremely weak but for its time it was really quite powerful and didn't require a fan of any kind to cool it down. The transistor speed was the limiting factor in speed rather than cooling as on a modern CPU 1(https://legoaler.wordpress.com/2011/04/10/a-peek-into-the-nes-architecture/). Unlike most modern CPUs, it didn't have/need a cache as the RAM and ROM were both fast enough to supply the CPU with as much data as it could handle at any given time. The memory read on the NES is around 2 cycles whereas, in a modern system, the L1 cache (16KB) is less than 10 cycles, the L2 cache (2MB) is less than 20 cycles, and an access to ram can be hundreds of cycles 1(https://legoaler.wordpress.com/2011/04/10/a-peek-into-the-nes-architecture/).

The PPU - 5.37Mhz (Not programmable) [2]

The PPU (Picture Processing Unit) is a co-processor that sits alongside the 6502 chip 1(https://legoaler.wordpress.com/2011/04/10/a-peek-into-the-nes-architecture/). The PPU performs all of the video rendering tasks that the CPU was too slow to process. The chip was unique in the fact that it used little memory and could render vertical and horizontal scrolling of backgrounds (this wasn't achieved on PCs until the early 90's). The PPU couldn't render vector graphics or bitmaps. Instead, it dealt with objects like tiles and sprites and would then colour them using schemes known as pallets. Due to the 2KB of RAM it had available, an image wasn't stored as a matrix of RGB pixels. Instead, an image was stored using a 'paint by numbers' scheme which enabled you to change the meaning of 1. An example of this is the tiles for both the clouds and also bushes in Super Mario, this was achieved by changing the palette for both tiles. The PPU supports two kinds of images, these are sprites and tiles. Both of these two images are set to 8x8 or 16x16. Tiles couldn't be animated or move, they are fixed to a grid but could be 'scrolled' giving the illusion that the player was moving along an environment. The PPU has a colour palette of up to 48 colours and 6 greys. A maximum of 25 colours can be used without writing any new values mid frame: a colour for the background, four sets of three tile colours and four sets of three colours for the sprites. The colour palette is based on NTSC(National Television System Committee) rather than RGB(Red, Green and Blue). The display resolution is 256x240 pixels. The PPU memory could also store 256 bytes for sprites, 32 bytes for the palette, and then access the 4KB ROM in the cartridge for tiles 1(https://legoaler.wordpress.com/2011/04/10/a-peek-into-the-nes-architecture/). The Ricoh 2A03's video output connections varied from one version of the console to another. The initial HVC-001 model only had a radio frequency (RF) modulator output. For the release of the console in North America and Europe they added support for composite video through RCA connectors in addition to the RF modulator 11(https://en.wikipedia.org/wiki/Nintendo_Entertainment_System#Technical_specifications). For the HVC-101 the RF modulator output was dropped entirely and composite video was solely supported by the inclusion of a proprietary 12-pin "multi-out" connector 11(https://en.wikipedia.org/wiki/Nintendo_Entertainment_System#Technical_specifications).

CIC - Lockout Chip

The Lockout chip is installed in the NES so that only cartridges with the appropriate chip are allowed to run on the system, more on the Lockout Chip.

Sound

The NES had an APU (Audio Processing Unit) on the CPU for generating sounds within the game. The APU has five channels. Below are the channels and their associated addresses 7(https://safiire.github.io/blog/2015/03/29/creating-sound-on-the-nes/):

  1. $4000 - $4003 - First pulse wave
  2. $4004 - $4007 - Second pulse wave
  3. $4008 - $400B - Triangle wave
  4. $400C - $400F - Noise
  5. $4010 - $4013 - Delta moderation channel (DMC)

$4015 - Enable channel

The difference between the DMC and the other channels is that the pulse, triangle and noise just play waves. The DMC plays samples 8(http://www.slack.net/~ant/nes-emu/apu_ref.txt).

.export periodTableLo, periodTableHi
.segment "RODATA"
periodTableLo:
  .byt $f1,$7f,$13,$ad,$4d,$f3,$9d,$4c,$00,$b8,$74,$34
  .byt $f8,$bf,$89,$56,$26,$f9,$ce,$a6,$80,$5c,$3a,$1a
  .byt $fb,$df,$c4,$ab,$93,$7c,$67,$52,$3f,$2d,$1c,$0c
  .byt $fd,$ef,$e1,$d5,$c9,$bd,$b3,$a9,$9f,$96,$8e,$86
  .byt $7e,$77,$70,$6a,$64,$5e,$59,$54,$4f,$4b,$46,$42
  .byt $3f,$3b,$38,$34,$31,$2f,$2c,$29,$27,$25,$23,$21
  .byt $1f,$1d,$1b,$1a,$18,$17,$15,$14
periodTableHi:
  .byt $07,$07,$07,$06,$06,$05,$05,$05,$05,$04,$04,$04
  .byt $03,$03,$03,$03,$03,$02,$02,$02,$02,$02,$02,$02
  .byt $01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01
  .byt $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  .byt $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  .byt $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  .byt $00,$00,$00,$00,$00,$00,$00,$00

9(https://wiki.nesdev.com/w/index.php/APU_period_table) The table above shows the addresses for the pulse waves and triangle wave to imitate piano keys. The difference between pulse and triangle is pulse makes a sound 1 octave higher when given the same address as triangle.

See Sound and music for more information about sounds and music on the NES.

Controllers

The game console's controller is built with ease in mind, featuring a rectangular design with a four button layout, as well as a cross-shaped joypad replacing previous bulkier joysticks. The NES controllers were among the first of their kind for providing onboard circuitry 1(https://legoaler.wordpress.com/2011/04/10/a-peek-into-the-nes-architecture/). This allowed a system that could expand to the use of 4 controllers and other devices such as the various other devices such as the 'NES Zapper', ' Power Glove' and 'NES Advantage'.

Cartridge

The NES game cartridges could be expanded to a total of 1MB of ROM by using memory banks. However, this requires a 20-bit address but the CPU only allows for 16-bit addressing, in order to do this, you need to switch between multiple memory banks to access more than 64KB. The cartridge contains a CPU ROM, PPU ROM and the CIC chip required for it to run on the NES 2(https://www.youtube.com/watch?v=ar9WRwCiSr0&t=283s).

References: