# The VIC: MOS 6560 (NTSC) and 6561 (PAL), video and sound Tags as in [memory-map.md](memory-map.md). **VDS** is MOS's data sheet (2/80, 18 scanned pages, OCR'd locally); **VICI** Marko Mäkelä's VIC-I document rev. 1.2, which says its register map was "enhanced with the results got by measuring the 6560-101 and 6561-101 chips" and that the sound formulas were revised from Levente Hársfalvi's experiments. ## What it is One chip does the picture, the sound, two paddle A/D converters and the light-pen latch, and generates the system's clocks: "System Clocks P-phi1 and P-phi2 ... the master timing generator for the VIC System" (VDS p. 10). It reads memory through its own 14-bit address and 12-bit data bus during phase 1; the CPU reads and writes its 16 registers during phase 2 (VDS p. 9). Mask variants by the OPTION pin (VDS p. 11): -001 a 2 MHz clock out, -201 sync reset in, **-101 light pen** (the VIC-20's), -301 bus available. ## Clocks and frame geometry | | 6560-101 (NTSC-M) | 6561-101 (PAL-B) | Source | | --- | --- | --- | --- | | crystal | 14,318,181 Hz | 4,433,618 Hz | VICI; SCH-E shows 14.31818 MHz; the funet schematic index notes the PAL board's 4433618 Hz crystal | | CPU clock | crystal / 14 = 1,022,727 Hz | crystal / 4 = 1,108,405 Hz | VICI | | cycles per line | 65 | 71 | VICI (MEASURED) | | lines per frame | 261 (525 interlaced) | 312 | VICI (MEASURED); C1 for NTSC | | frame rate | 60.28 Hz (65 x 261 cycles) | 50.04 Hz (71 x 312) | arithmetic from the rows above | | pixels per cycle | 4 ("the dot clock is only 4 times the bus clock") | 4 | VICI | | visible width/height | 201 x 252 (253.5 interlaced) | 229 x 303 | VICI (measured on a monitor) | Vertical blank is on lines 0-27 (VICI). The KERNAL sets VIA2's timer 1 for its 60 Hz jiffy interrupt on both standards (MAME trace: $4289 written to VIA2 T1 under the NTSC KERNAL, OBSERVED); the picture's rate is the VIC's. ## Registers ($9000-$900F) From VDS pp. 3-4 (register names CR0-CRF), PRG pp. 175-176 and VICI; VICI's measured ranges added. All registers are readable; $9004 and $9003 bit 7 are the raster counter. | Reg | Bits | Meaning | Notes | | --- | --- | --- | --- | | $9000 | 7: interlace (6560 only); 6-0: screen origin X, 4-pixel units | VDS: "Bits 0-6"; VICI: no effect of bit 7 on the 6561 | | $9001 | screen origin Y, 2-line units | VICI: no wraparound | | $9002 | 7: video matrix address bit 9 (and colour RAM select); 6-0: columns | VICI: >31 read as 31 (6560), >32 as 32 (6561) | | $9003 | 7: raster bit 0; 6-1: rows; 0: 8x16 characters | | | $9004 | raster bits 8-1 | `vic_line0`: on the 6560 the value 0 is reported 33 cycles late at the start of a frame (VTP, NTSC hardware) | | $9005 | 7-4: video matrix A13-A10; 3-0: character cells A13-A10 | the VIC's A13 is the CPU's inverted A15 | | $9006/$9007 | light pen X / Y latch | latched on the pin's falling edge (VDS p. 11) | | $9008/$9009 | POTX / POTY | RC integration (VDS p. 10) | | $900A-$900C | 7: voice on; 6-0: frequency (bass, alto, soprano) | | | $900D | 7: noise on; 6-0: frequency | | | $900E | 7-4: auxiliary colour; 3-0: volume | | | $900F | 7-4: background; 3: reverse off (1 = normal); 2-0: border | VDS p. 4 | ## Fetching and drawing Per character the VIC fetches the screen byte with its colour nybble (12 bits in one access), then the character's pattern byte: two accesses per 8 pixels, one per CPU cycle, "every line a bad line" without stealing cycles (VICI). Cell address = base + index x 8 (or x 16 for 8x16 characters) + row (VDS p. 2). Colour nybble bit 3 selects multicolour for that character (pairs of bits: 00 background, 01 border, 10 character colour, 11 auxiliary) or high resolution (VDS p. 5). Border colours are 0-7 only; background and auxiliary 0-15 (VDS p. 11 note 2). Known corners, each with a hardware-checked test (VICE-testprogs; tier 3 or better): - the text pointer is not reset in the lower border, so line 0 after vertical blank shows the next text row (`vic_vert0`, photographs of NTSC and PAL screens); - mid-line writes to $9000 garble or skip characters by a pattern (`vic_9000test`, tokra's reference pictures, PAL); - `split-tests/timing` and `split-tests/lightpen`: **dumps taken on named real machines** (chip markings and serial numbers in their readmes: 6560-101, 6561E, 6561-101), of when a register write takes effect in the line and where the light pen latches. These are the VIC's best judges (tier 1: captured on real units). - `vic6561/` (12 programs, no readme), `vic_interlace/` (demos): detectors. ## Sound Three square-wave voices an octave apart and a noise voice, one 4-bit volume, one output pin (VDS p. 1, p. 10: "a high impedance output (approximately 1K)"). Frequency formulas from VICI (revised after Hársfalvi's measurements), with n the register's low 7 bits: bass f = Phi2 / 256 / (128 - ((n + 1) & 127)) alto f = Phi2 / 128 / (128 - ((n + 1) & 127)) soprano f = Phi2 / 64 / (128 - ((n + 1) & 127)) noise f = Phi2 / 32 / (128 - ((n + 1) & 127)) **The noise generator's circuit is not documented** (U1). A VICE feature-request thread reports Lance Ewing's reading of the 6561 die shot: a 16-bit LFSR with taps 3, 12, 14 and 15 "and some very specific connections" (search result, the Denial thread it links was not opened: see provenance.md). Output mixing, the volume DAC's levels and the analogue stage after the pin are unknown (U2); the family's "sound: good enough" rule applies. ## Colours 16 colour names (VDS p. 11, VICI). **No measured luminance or chroma values for the 6560 or 6561 were found** in the pinned sources: funet's `656x-luminances.txt` is for the VIC-II (6567/6569), not the VIC-I. The palette is a table tagged HYPOTHESIS (U8) until a measurement is found; the board outputs colour indices, the host chooses the palette. ## Paddles and light pen POTX/POTY charge an external capacitor through the paddle (VDS p. 10). `paddlescope`'s readme shows the reading is coupled to the video signal on real hardware (noise with the frame's period). The board models the converter as a count with a documented model and a fitted constant (U9). The light pen latch is judged by `split-tests/lightpen`'s hardware dumps (U10). ## Unknowns and conflicts - U1 noise LFSR; U2 sound output; U8 palette; U9 paddle conversion; U10 light-pen offsets; U4 per-register write-to-effect delays (judged by the split-tests dumps); U11 the 6560's interlace (field order, $9004 per field: `vic_line0` covers one case). - **C1 NTSC lines per frame.** VDS p. 16: "262 per frame" non-interlaced, 262.5 interlaced. VICI: 261 (525 interlaced), measured. MAME 0.285 runs its legacy screen at 60.000 Hz: 120 frames took 2,045,451 CPU cycles, 17,045.4 a frame, which is neither 65 x 261 = 16,965 nor 65 x 262 = 17,030 (OBSERVED, mame-oracle.md). Proposal: 261, confirmed against the `split-tests/timing` NTSC dumps before milestone 2 closes. - **C2 the 6561's input clock.** VDS p. 10: "4.436187 MHz clock for PAL"; VICI and the PAL board: 4,433,618 Hz (the PAL colour subcarrier). Proposal: 4,433,618 Hz; the data sheet's figure reads like a transposition.