# Video: the Data chip and the Address chip Both chips stay inside this board (the chip rule: their only other users are the Bally/Midway arcade boards, which this repository covers as rows; see [arcade-boards.md](arcade-boards.md)). ## Timing | Fact | Value | Source | | --- | --- | --- | | master clock 7M | 7.159090 MHz (period 140 ns) | DOC: SYS 114, 135 | | PX (pixel clock) | 7M / 2 | DOC: SYS 114, 131 | | Phi (Z80 clock) | 7M / 4 = 1.7898 MHz (period 560 ns) | DOC: SYS 114, 135 | | line | 455 7M cycles = 63.5 us; Phi and PX stalled for 3 7M cycles at the start of each line to resynchronise, so a line holds 113 whole Phi cycles | DOC: SYS 131 (it prints "133 3/4 Phi cycles per line": a typo for 113 3/4 in the retype, C1) | | frame | VERT DR once every 16.6 ms (60 Hz) | DOC: SYS 114 | | lines per field | 262 (MAME: vtotal 262, refresh 60.054 Hz) or 262 1/2 interlaced (MIL: "each NTSC field is 262 1/2 lines") | C2 | | displayed lines | low resolution: 102 RAM lines, each scanned twice ("each line is scanned twice per field", MIL) to give 204 active lines | DOC: SYS 85, MIL | | video RAM fetches | 40 RAS cycles a line for the screen | DOC: SYS 131 | MAME 0.285 reports the home screen as 352 x 240 visible of 455 x 262, pixel clock 7.159090 MHz (OBSERVED, `mame -listxml astrocde`). ## Pixels and colour Two bits a pixel; with the LEFT/RIGHT bit they select one of eight colour registers: registers 4-7 left of the boundary, 0-3 right of it (SYS 88-89). The boundary (port 09 bits 5-0) sits just left of the byte it names; 44 puts the whole screen, borders included, on the left (SYS 89). The border colour is port 09 bits 7-6 with the same LEFT/RIGHT rule (SYS 89). Below the vertical-blank line (port 0A) the background colour is shown and the RAM behind it becomes scratch (SYS 90). Mid-frame colour-register writes timed by the screen interrupt give "as many as 256 colour-intensity combinations" on one screen (SYS 93): the renderer must apply register writes at the dot they happen, not per frame. A colour register's value is 5 bits of colour and 3 of intensity (SYS 88). The palette (the 256 colours as RGB) has no hardware-measured source in this survey: **U3**. Dagger's note (PURPLE) records a purple line at the right of the BIOS menu on real consoles (OBSERVED by its author; MAME shows it too, our snapshot of 2026-11-26) and reasons about the boundary register's range: a judge for one pixel column, tier 3. ## The magic system Enabled by any write to 0000-3FFF; the result goes to X+4000 (SYS 82). Magic register bits (port 0C, SYS 94): 1-0 shift amount, 2 rotate, 3 expand, 4 OR, 5 XOR, 6 flop. Order: **expand, then rotate or shift, then flop, then OR or XOR**; up to four at once; rotate and shift exclude each other, as do OR and XOR (SYS 94). | Function | Rule | Source | | --- | --- | --- | | expand | one nibble of the data byte becomes four pixels: a 0 bit becomes the pixel in port 19 bits 1-0, a 1 bit the pixel in bits 3-2; an expand flip-flop picks the nibble (0: upper, 1: lower), reset by any write to port 0C, toggled after every magic write; data bit 0 or 4 becomes the least significant pixel | SYS 95 | | shift | 0-3 pixels right; pixels shifted out of one byte enter the next; zeros enter the first byte of a sequence, which starts at the first magic write after a port-0C write | SYS 96 | | flop | mirror: pixel 0 swaps with 3, 1 with 2 | SYS 96 | | rotate | a 4 x 4-pixel block turned 90 degrees clockwise: write four bytes at X, X+80, X+160, X+240, twice; the result appears after eight writes; re-initialised by a port-0C write and after every eight magic writes; **commercial mode only** | SYS 98 | | OR / XOR | with the RAM byte's old contents (the Data chip latches RAM data on reads: SYS 115) | SYS 100 | | intercept | an OR/XOR write that puts a non-zero pixel on a non-zero pixel sets a bit: bits 3-0 accumulate (pixel 3..0) until port 08 is read; bits 7-4 describe the last write | SYS 100 | The patents (P503, P172) describe the same functions at gate level; they are the second document to check each rule against (both tier 2). Lance Squire's "Bally's Blitter" (BLIT) is a programmer's account of the same (tier 3, unverified on hardware). Open questions: what the rotator does in consumer mode (**U4**); the exact pixel order of "shift into the next byte" across a line end (**U5**); whether a magic write also reads the old RAM byte (the OR/XOR needs it; the bus cost of that read is **U6**). ## Interrupts (Address chip) - Screen interrupt: when the scan completes the line in port 0F, if port 0E bit 3 is set (SYS 93). Light pen: when the trigger is held and the scan crosses the pen, if bit 1 is set; the scan address is latched for ports 0E/0F (SYS 93, 112). - Priority: screen over light pen (SYS 92). - The vector byte: port 0D as is for a screen interrupt; for a light-pen interrupt its low four bits are forced to 0 (SYS 92). The BIOS runs the Z80 in IM 2 (the vector is a table offset): HYPOTHESIS until the trace is read for an `IM 2` (MAME's trace shows the BIOS writing 0F and 0D every frame, OBSERVED). - Modes (port 0E bits 0 and 2): mode 0 holds the request until the Z80 accepts it; mode 1 drops it unless accepted by the next instruction, and SYS warns that CB/DD/ED/FD instructions then lose it (SYS 92). The board needs to know where an instruction boundary falls relative to the request: a requirement on the core ([cpu-z80.md](cpu-z80.md)). ## RAM arbitration and WAIT "WAIT# is also generated for one cycle every time the Z-80 requests a memory access, even if there is no conflict with the Scan Address", plus a wait when the scan and the Z80 collide; the scan never needs more than one consecutive memory cycle, so the Z80 waits at most one extra cycle (SYS 111-112). SYS 124-127 draw "memory read/write without extra wait state" and "with video wait state". MAME 0.285 charges no waits: its trace runs the BIOS's first instructions at 4 T-states each (OBSERVED: C3). The reference board should follow the documents and say so; the timing diagrams settle which T-state each wait occupies. ## Commercial (arcade) mode High resolution: 320 x 204, 80 bytes a line, 16 KB of RAM in four banks (SYS 85, 111); each screen-refresh access reads 16 pixels into an external shift register, so a consumer board cannot show commercial resolution (MIL). The colour boundary counts in pairs of bytes (SYS 89). This is the arcade rows' mode ([arcade-boards.md](arcade-boards.md)).