# Video: the bitmap the CPU draws, the counter and the colour RAM There are no sprites or tiles: the CPU (and from Robotron on the blitter) writes 4-bit pixels into DRAM, and the video circuit reads that DRAM back in step with the beam (DOC: DEF-T section 2; SR-BLIT). ## Timing - **Video address generator** (DEF-T fig. 3-6): four 9316 4-bit counters, 14 bits VA0-VA13, clocked by 4 MHz but counting once per E cycle (1 µs). After the first full count (16,383) it is preloaded to 16,128 (0x3F00) and counts to 16,383 again, then wraps to 0: **16,640 counts, 16.64 ms a frame** (DOC: DEF-T; SR-HW). Held reset by CR (the clocked reset) and released on an E edge, so the counter, the 6 MHz divider and E are in phase from reset (DEF-T "Reset circuit"). - VA0-VA5 count the 64 µs of a line, VA6-VA13 the line. Lines 0-255 come from the first count; the preload makes lines 252-255 run twice (0x3F00-0x3FFF a second time), giving 260 lines. **This is an inference from the counter description: which line numbers a program reads during the repeated part is settled by Riddle's measurement below.** - **Vertical count buffer**: reading CB00 (later boards) puts VA8-VA13 on D2-D7 (DEF-T "Vertical count buffer"). Riddle's WETS measurement on a real board: the register reads **0xFC for lines 256-259** before rolling over to 0x00, where MAME of his day returned 0x00 (MEASURED: SR-WETS, Update 2). Consistent with the preload: the repeated part has VA8-VA13 = all ones. What D0-D1 read is not stated (U5). - **COUNT 240**: VA10-VA13 all high (line 240 onwards) to the ROM-board PIA's CA1; asserted about 1.3 ms until the counter wraps (DEF-T "Count 240"). - **VA11** to the PIA's CB1: a square wave of 32 lines high, 32 low; the program picks the edge. VA11 is bit 5 of the line number, so it is high on lines 32-63, 96-127, 160-191, 224-255 and through the four repeated lines (VA8-VA13 = 0xFC-0xFF), and falls at lines 64, 128, 192 and 0: four falling edges a frame. Robotron's IRQ handler reads CB00 = 0x40, 0x80 (OBSERVED) and m6809-python's trace saw four IRQs a frame at lines 64, 128, 192 and 0 (its mame-oracle.md). - **Blanking**: horizontal blanking from the video address bus; vertical blanking from a flip-flop set when VA9-VA13 are all ones and clocked by VA6 (SR-LINES, from the schematic). - **Sync**: decoded from the video address bus (DEF-T "Monitor sync generator"); Riddle's Saleae captures of VA11-VA13, HSYNC and VSYNC exist (SR-TIME, not fetched yet). ## Pixels - Each microsecond the three RAM banks are read at the video address and latched into the shift registers (SRL at 1 MHz); a 6 MHz clock shifts out 4-bit pixels, bank 1's two pixels then bank 2's then bank 3's: **six pixels per microsecond** (DEF-T "Video shift registers"). Visible width 304 pixels = 152 bytes per line (SR-MAP: 304 x 256). - MAME draws a 292 x 240 window of a 512-pixel line at an 8 MHz pixel clock (OBSERVED: `display width=292 height=240 pixclock=8000000 htotal=512 vtotal=260`). DEF-T says 6 MHz shift; MAME's geometry is its own presentation (C2 in the brief). The board should follow DEF-T and emit the visible window as a parameter of the machine row. - Memory layout: the byte after a byte is the next line down; the next pixel pair to the right is 256 bytes on (SR-BLIT; SR-MAP: screen 0000-97FF). Within a byte, which nibble is the left pixel is to be read from the schematic (U7). - **Colour RAM**: 16 x 8 bits (two 7489s), written by the CPU (later boards C000-C00F); each entry is 3 bits red, 3 green, 2 blue (DEF-T section 2: "three bits define seven intensities for the Red gun ... two bits for three intensities"; the resistor values of the D-to-A driver are on the CPU board schematic, U8). The 7489's outputs drive the RGB DACs directly, so **a write to the colour RAM shows the written colour on the screen for the length of the write**: the coloured dashes at the top of every Williams screen (SR-LINES, MEASURED by his blanking experiments). The board can model this as a per-write pixel event (a concession switch if ever wanted off). - Screen flip for cocktail cabinets: C900 bit 1 (SR-HW); the "screen control" reverses and inverts the image (DEF-T section 2). ## Contention and why the blitter has a slow mode The video reads RAM once every microsecond, interleaved with the CPU's E-high access (DEF-T "Video RAM timing"). A blit that reads and writes RAM must synchronise with E or the two fight for the address bus (SR-BLIT, SR-WETS): see [blitter.md](blitter.md). ## Level Per microsecond fetch and per pixel output, with colour-RAM writes landing on the pixel being drawn at that microsecond. A per-line renderer is a turbo fast path, not the specification.