What the TIA does
The TIA (Television Interface Adaptor) has no video memory. It draws one television line at a time from a few registers and repeats the same line until the program writes new values. A playfield and five movable objects (two players, two missiles and a ball) are drawn; the program decides the vertical position of everything by changing the registers line by line. The register addresses and bit masks are on the
memory map page; this page says what the bits do. Sources: the Stella Programmer’s Guide (the TIA 1A hardware description, 1979; the page numbers below are those of the copy in samples/a26/sources) and, where marked Nocash, the Atari 2600 Specifications by Martin Korth.
Frame and line timing
A line is 228 colour clocks: 68 of horizontal blank (not seen) and 160 of picture. The TIA counts them itself from a 3.58 MHz oscillator; the sync and the colour burst are 16 counts of the blank (Guide, Detailed description 2A). The oscillator is divided by three to give the 6507’s clock, so one machine cycle is three colour clocks and one line is 76 machine cycles. A write to WSYNC halts the processor (through its RDY pin) until the start of the next horizontal blank; RSYNC resets the horizontal counter and is meant for chip testing.
The program makes the vertical timing: VSYNC bit 1 starts and stops the vertical sync, VBLANK bit 1 the vertical blank. Counts of lines (Guide, PAL/SECAM conversions; the split of the blank into sync and blank is Nocash’s):
| NTSC | PAL and SECAM | |
|---|---|---|
| Vertical sync | 3 lines | 3 lines |
| Vertical blank (Guide: 40 and 48 including the sync lines) | 37 lines | 45 lines |
| Picture (the Guide’s “kernel”) | 192 lines | 228 lines |
| Overscan | 30 lines | 36 lines |
| Frame | 262 lines, 16,686 µs | 312 lines, 20,055 µs |
| Frame rate | 60 Hz | 50 Hz |
| Colour clock (Nocash) | 3.579545 MHz | 3.546894 MHz |
| Machine clock (Nocash) | 1.193182 MHz | 1.182298 MHz |
Nocash adds that many PAL games draw only 192 picture lines and make the borders taller. The Guide says sounds drop in pitch on PAL (the crystal is slower) and that game speed tied to the frame rate falls by 17 %.
The playfield
The playfield is a 20-bit pattern in PF0, PF1 and PF2. Each bit is 4 colour clocks wide, so the 20 bits cover the left half of the line (80 clocks). A 1 shows the playfield colour, a 0 the background colour. Only the upper four bits of PF0 are used. The scan order, left to right (Guide, figure 5 and the register list; the same in Nocash):
| Reflect bit (CTRLPF bit 0) | Left half | Right half |
|---|---|---|
| 0: duplicate | PF0 bits 4 to 7, PF1 bits 7 to 0, PF2 bits 0 to 7 | the same sequence again |
| 1: reflect | PF0 bits 4 to 7, PF1 bits 7 to 0, PF2 bits 0 to 7 | PF2 bits 7 to 0, PF1 bits 0 to 7, PF0 bits 7 to 4 |
The registers can be written at any time, but a register changed while it is being scanned may show part of the new value on that line (Guide, 3D). To clear the playfield write zero to all three. CTRLPF: bit 0 reflect, bit 1 score (the left half takes the colour of player 0, the right half that of player 1), bit 2 playfield priority (below), bits 4 and 5 the ball width (1, 2, 4 or 8 clocks).
Players
A player is 8 pixels wide. GRP0 and GRP1 hold the pattern, scanned from bit 7 to bit 0; bit 3 of REFP0 or REFP1 scans it from bit 0 to bit 7 (a mirror image). A 1 shows the player’s colour, a 0 shows what is behind. Writing 0 to the register hides the player, which is how a program moves it vertically.
NUSIZ0 and NUSIZ1 bits 0 to 2 choose the number of copies and the width. Each position below is one 8-clock cell of half a line (80 clocks), an X is a copy (Guide, NUSIZ, and Nocash’s drawing):
| Bits 2-0 | Shape |
|---|---|
| 000 | one copy: X......... |
| 001 | two copies, close: X.X....... |
| 010 | two copies, medium: X...X..... |
| 011 | three copies, close: X.X.X..... |
| 100 | two copies, wide: X.......X. |
| 101 | double-size player: each pixel 2 clocks (16 clocks) |
| 110 | three copies, medium: X...X...X. |
| 111 | quad-size player: each pixel 4 clocks (32 clocks) |
Only three player widths exist because the same three bits also drive the copy decoders (Guide, 6C). The missile of a player gets the same number of copies. VDELP0 and VDELP1 bit 0 select the delayed copy of the pattern: each GRP register is really two registers, and the second is loaded from the first when the other player’s GRP is written. With the delay on, a player shows the value written one write earlier (Guide, Detailed description 6D; Nocash). The name is vertical because programs update the players every second line and use the delay to move them one line at a time.
Missiles and ball
A missile or the ball is one pixel stretched to 1, 2, 4 or 8 clocks: NUSIZ0 and NUSIZ1 bits 5 and 4 for a missile, CTRLPF bits 5 and 4 for the ball. ENAM0, ENAM1 and ENABL bit 1 turn them on (the Guide’s function list says data bit D1). The ball has a vertical delay like the players: VDELBL bit 0 selects the copy loaded from ENABL when GRP1 is written, so ENABL should be written together with GRP0 (Guide, 6E). A missile can be locked to its player: while bit 1 of RESMP0 or RESMP1 is 1 the missile is hidden and centred on the player; writing 0 releases it for firing (Guide, 7.0 and 4D).
Horizontal position and motion
There is no horizontal position register. Writing to RESP0, RESP1, RESM0, RESM1 or RESBL (strobes: any value) starts the object where the beam is at that moment: written 60 colour clocks into a line, the object appears at 60 on the next line. Written during the horizontal blank, it appears at the left edge. A write takes up to five machine cycles and a cycle is three clocks, so a program can place an object only at steps of 15 clocks; the motion registers fill the gaps (Guide, 7.0). Nocash measures the left-edge case at 3 pixels in for the players and 2 for the missiles and ball.
HMP0, HMP1, HMM0, HMM1 and HMBL take a signed 4-bit value in bits 7 to 4. Nothing moves until HMOVE is written, which moves all five objects at once; it can be repeated and HMCLR clears all five registers. The value is the number of clocks to the left, +7 to -8 (Guide, HMP0):
| Bits 7-4 | Motion | Bits 7-4 | Motion |
|---|---|---|---|
| 0111 | +7 left | 1111 | -1 (1 right) |
| 0110 | +6 left | 1110 | -2 |
| 0101 | +5 left | 1101 | -3 |
| 0100 | +4 left | 1100 | -4 |
| 0011 | +3 left | 1011 | -5 |
| 0010 | +2 left | 1010 | -6 |
| 0001 | +1 left | 1001 | -7 |
| 0000 | no motion | 1000 | -8 (8 right) |
Timing rules (Guide, 8.0): HMOVE must come straight after a WSYNC, so that it starts at the beginning of the horizontal blank and has all of it to supply the extra clocks; the motion registers must not be changed for at least 24 machine cycles after an HMOVE. Nocash adds two effects the Guide does not mention: an HMOVE inside the blank covers the leftmost 8 pixels of the following line with the border colour (black; collisions are still detected below it), and an HMOVE at other times adds extra offsets. Nocash does not settle the second effect (see below).
Priorities and colours
Four colour registers serve seven objects: COLUP0 for player 0 and missile 0, COLUP1 for player 1 and missile 1, COLUPF for the playfield and ball, COLUBK for the background. Where objects overlap, the one with the higher priority is drawn (Guide, 9.0 and 8.5):
| Priority | Normal (CTRLPF bit 2 = 0) | Playfield first (bit 2 = 1) |
|---|---|---|
| 1 (front) | P0, M0 | PF, BL |
| 2 | P1, M1 | P0, M0 |
| 3 | PF, BL | P1, M1 |
| 4 (behind) | BK | BK |
In score mode (bit 1) the left half of the playfield uses the colour of player 0 and the right half that of player 1. Nocash states the score bit is ignored when the playfield priority bit is set, and that in score mode only the ball is drawn with COLUPF; the Guide gives neither detail.
A colour register holds 4 bits of colour (bits 7 to 4) and 3 bits of luminance (bits 3 to 1; bit 0 is unused). Colour 0 is no colour (grey), colour 1 has the phase of the colour burst (gold in NTSC) and colours 2 to 15 step through almost 360 degrees of phase (Guide, 10.0). The names Nocash gives:
| Colour | NTSC | PAL |
|---|---|---|
| 0 | grey to white | grey to white |
| 1 | gold | same as 0 |
| 2 | orange | yellow |
| 3 | bright orange | green-yellow |
| 4 | pink | orange |
| 5 | purple | green |
| 6 | purple-blue | pink-orange |
| 7 | blue | green-blue |
| 8 | blue | pink |
| 9 | light blue | turquoise |
| 10 ($A) | turquoise | pink-blue |
| 11 ($B) | green-blue | light blue |
| 12 ($C) | green | blue-red |
| 13 ($D) | yellow-green | dark blue |
| 14 ($E) | orange-green | same as 0 |
| 15 ($F) | light orange | same as 0 |
Nocash counts 128 colours for NTSC (16 × 8), 104 for PAL and 8 for SECAM (the PAL table repeats colour 0 for 1, 14 and 15, which leaves 13 different colour values; 13 × 8 = 104). The Guide gives only the names of every second colour with a scan that cannot be read reliably, so these names are Nocash’s. SECAM ignores the colour bits: the three luminance bits choose one of eight fixed colours (black, blue, red, magenta, green, cyan, yellow, white; the Guide lists them by the even luminance values 0, 2, 4, 6, 8, A, C, E). Luminance 0 is black and 7 white. The border (blank) is black. The exact colour values of a real display are an analogue matter and are not given by any source read.
Collisions
The TIA compares the six objects (playfield, two players, two missiles, ball) and keeps the 15 possible pairs in 15 latches. Each read register returns two of them in bits 7 and 6 (1 = the two objects overlapped since the last clear). The registers can be read at any time; programs read them in the vertical blank. A write to CXCLR (any value) clears all 15 at once, usually near the end of the vertical blank (Guide, 10.0 and 7).
| Address | Register | Bit 7 | Bit 6 |
|---|---|---|---|
| $00 | CXM0P | M0 and P1 | M0 and P0 |
| $01 | CXM1P | M1 and P0 | M1 and P1 |
| $02 | CXP0FB | P0 and PF | P0 and BL |
| $03 | CXP1FB | P1 and PF | P1 and BL |
| $04 | CXM0FB | M0 and PF | M0 and BL |
| $05 | CXM1FB | M1 and PF | M1 and BL |
| $06 | CXBLPF | BL and PF | not used |
| $07 | CXPPMM | P0 and P1 | M0 and M1 |
That is seven registers with two pairs and one with one pair: 7 × 2 + 1 = 15 (the Guide’s read address summary).
Not described
Known, not yet covered
- Reference: the exact cycle-by-cycle behaviour of the TIA: the position of an object after
RESxxandHMOVEat each cycle of the line, and the extra motionHMOVEgives outside the blank (Nocash lists offsets and says they “seem to apply only when HMxx = 0”). The Programmer’s Guide does not give them and Nocash does not settle them. - Reference: the analogue side: the real colour values and the output voltages of the luminance and sync pins.
Unknown
- Reference: the timing-diagram pages of the Programmer’s Guide (pages 47 to 52 of the copy) are figures and were not readable as text.