The NES was built in three timing families. The NTSC console (Ricoh 2A03 and 2C02) is the base. The PAL console (2A07 and 2C07) changes the clock and the divider. The “Dendy” is a clone sold in the 50 Hz markets, with a PAL-style picture and NTSC-style CPU timing. The NES 2.0 header records which one a game expects (see the NES 2.0 header). This page follows the NESdev Wiki pages named under Sources.
Clocks, lines and frames
| Property | NTSC (2C02) | PAL (2C07) | Dendy (UA6527P, UA6538) | RGB PPUs (2C03, 2C04, 2C05) |
|---|---|---|---|---|
| Master clock | 21.477272 MHz | 26.601712 MHz | like PAL | like NTSC |
| CPU | Ricoh 2A03 | Ricoh 2A07 | UMC UA6527P | Ricoh 2A03 |
| CPU clock | master ÷ 12 = 1.789773 MHz | master ÷ 16 = 1.662607 MHz | master ÷ 15 = 1.773448 MHz | like NTSC |
| Master clocks per PPU dot | 4 | 5 | 5 | 4 |
| PPU dots per CPU cycle | 3 | 3.2 | 3 | 3 |
| CPU cycles per scanline (341 dots) | 113⅔ | 106 9/16 | 113⅔ | 113⅔ |
| Picture height | 240 lines | 239 lines | like PAL | like NTSC |
| Post-render blank lines before NMI | 1 | 1 | 51 | 1 |
| Vblank after the NMI line | 20 lines (about 2,273 CPU cycles) | 70 lines (about 7,459 CPU cycles) | like NTSC (20 lines) | like NTSC |
| Pre-render lines | 1 | 1 | 1 | 1 |
| PPU dots per frame | 89,341.5 (341 × 261 + 340.5; one dot shorter on odd frames) | 106,392 (341 × 312) | like PAL | 89,342 |
| CPU cycles per frame | 29,780.5 | 33,247.5 | 35,464 | 29,780⅔ |
| Frame rate | 60.0988 Hz | 50.0070 Hz | like PAL | 60.0985 Hz |
| APU frame counter rate | 60.00 Hz | 50.00 Hz | 59.46 Hz | like NTSC |
| Time OAM can be written | vblank or forced blanking | only the first 24 lines after the NMI (about 2,557 CPU cycles) | like NTSC | like NTSC |
| Colour emphasis (PPUMASK bits 7, 6, 5) | blue, green, red | blue, red, green | like PAL | blue, green, red |
| Nominal visible height (overscan) | 224 lines | 268 lines | like PAL | like NTSC |
| Top border colour | black ($0E) | black | black | black |
| Side and bottom borders | palette entry at $3F00 | always black, covering 2 pixels left and right and 1 at the top | like PAL | like NTSC |
The Dendy’s PPU is the UMC UA6538. The NTSC frame is 29,780.5 cycles if rendering is on during the 20th line, 29,780⅔ otherwise. The PAL colour emphasis bits have red and green swapped in PPUMASK. The RGB PPUs belong to the Vs. System and PlayChoice-10 arcade machines (and RGB-modified consoles). Two Brazilian and Argentine famiclones, whose chip and clock details are listed on the wiki, are poorly researched and not tabulated here. The NES sold in Brazil is an NTSC console with an adapter that turns the video into PAL-M. Dendy is the name given to a whole class of 50 Hz Micro Genius-type clones. Their chipset is designed for compatibility with Famicom games, including cycle-counting mappers such as the VRC4 and cycle-timed NMI handlers such as the one in Balloon Fight. That explains the faster divider and the longer post-render period. A program can detect the TV system at power-on. (NESdev Wiki, “Cycle reference chart”.)
CPU cycle counts
| Property | NTSC | PAL | Dendy |
|---|---|---|---|
| Scanline (341 dots) | 113⅔ | 106 9/16 | 113⅔ |
| Horizontal blank (85 dots) | 28⅓ | 26 9/16 | 28⅓ |
| NMI to the start of rendering | 2,273⅓ | 7,459⅜ | 2,273⅓ |
| Frame | 29,780.5 | 33,247.5 | 35,464 |
| OAM DMA | 513, plus 1 if it starts on a get cycle | ||
(NESdev Wiki, “Cycle reference chart”.)
Even and odd frames
- The PPU toggles an even/odd flag every frame, rendering or not.
- With rendering off every frame is 341 × 262 = 89,342 dots.
- With rendering on, each odd frame is one dot shorter. The first idle dot of the first visible line is skipped: the PPU jumps from (339, 261) on the pre-render line to (0, 0) on the first visible line.
- Keeping rendering off until after that skip gives a different colour dot crawl, closer to interlace (two states instead of three). Battletoads and others seem to see this because they keep the background off late.
This is tested by the ppu_vbl_nmi_timing ROMs, which cover the NTSC PPU only. (NESdev Wiki, “PPU frame timing”.)
CPU and PPU alignment
The NTSC PPU runs at three times the CPU clock, so for a given power-up PPU events fall on one of three alignments against the CPU clock. The PPU divides the master clock by four, so the start of a CPU cycle can be 0 to 3 master clocks from the next PPU tick; the wiki’s results cover the single alignment with the fewest special cases. If rendering is off a frame is 341 × 262 ÷ 3 = 29,780⅔ CPU cycles. A program that checks the vblank flag every 29,781 cycles drifts one PPU dot per frame and so, after some frames, lands on the dot where the flag is set; from then on the CPU and PPU are synchronised to the dot. (NESdev Wiki, “PPU frame timing”.)
Vblank flag timing
- Reading
$2002within a few PPU dots of the moment vblank is set behaves specially. If it is read as clear one dot before the flag is set, the flag is not set and no NMI occurs that frame. - If it is read as set on the same dot or one later, the flag is cleared, but the NMI for that frame is still not generated.
- Reads two or more dots before or after behave normally.
- The reason is that the read pulls the (active low) NMI line back up too quickly for the CPU, which samples its inputs every cycle, to see it.
- On NTSC the flag is cleared 6,820 PPU dots (exactly 20 lines) after it is set, at the start of the pre-render line. The PAL and famiclone values are marked unconfirmed on the wiki.
(NESdev Wiki, “PPU frame timing”.) For the NMI and the vblank flag in the registers see PPU registers.
What else differs by region
- APU frame counter: the step cycles for NTSC and PAL are in APU registers.
- Noise and DMC period tables: PAL has its own; Dendy clones use the NTSC DMC table. Both are on the APU page.
- PAL has the 24-line OAM write window, a longer vblank and the DMC halt forced onto an opcode fetch, which avoids the DPCM read conflict. See DMA.
- The Dendy needs the faster 1/15 divider for games with cycle-timed code to work.
Sources
- NESdev Wiki: Cycle reference chart (the wiki’s “Clock rate” page redirects here)
- NESdev Wiki: PPU frame timing
- NESdev Wiki: PPU registers
The NESdev Wiki text is available under CC BY-SA 3.0. This page is written in our own words. The per-dot rendering sequence is on PPU rendering sequence and the cycle-by-cycle CPU interrupt timing on CPU interrupts.