# Video: the scanner, the modes, colour, the floating bus The Apple II has no video chip. Discrete logic on the II and II+ (the IOU and a timing HAL on the IIe) counts the screen and fetches one byte of RAM in the first half of every CPU cycle; the video generator shifts that byte out as dots. Steve Wozniak's patent US 4,136,359 describes the shared-memory scan and the colour generation as the designer filed them (DOC: PAT-VIDEO); Sather's chapters 3, 5 and 8 describe the circuit as built, revision by revision (DOC: UA2; UA2E ch. 3, 8). ## The scanner - **Horizontal**: a 7-bit counter of 65 states, 0000000 and then 1000000 to 1111111; the state 0000000 (HPE' low) presets the counter and causes the long cycle. 40 states are displayed, 25 blanked (right margin, retrace, left margin) (DOC: UA2 pp. 3-12, 3-16). - **Vertical**: a 9-bit counter of 262 states, $0FA to $1FF (presetting to 011111010 on overflow); 192 displayed, 70 blanked. The Eurapple presets to 011001000 instead: 312 states (DOC: UA2 p. 3-13, ch. 8, Table 8.1). - **One state per CPU cycle**: "during one microsecond, the electron beam travels the width of one text character, one LORES block, or seven HIRES dots" (DOC: UA2 p. 3-11). ### Address generation The scanner's address shares the CPU's address lines in a fixed correspondence (DOC: UA2 Table 5.4, pp. 5-8..5-9): A0-A2 are H0-H2; A3-A6 are a 4-bit sum of H5, H4, H3 with an offset chosen by V4 and V3, so that each 128-byte segment holds three 40-byte rows from the top, middle and bottom thirds of the screen and 8 unused bytes; A7-A9 are V0-V2. In TEXT/LO-RES, A10 is PAGE 1, A11 PAGE 2, **A12 is HBL** (the scanner reads a different range during horizontal blanking, for RAM refresh: DOC: UA2 p. 5-9), A13-A15 are zero. In HI-RES, A10-A12 are VA, VB, VC (the line within a character row), A13 is PAGE 1, A14 PAGE 2. The exact adder (Sather gives it with a carry input) is to be taken from UA2 pp. 5-8..5-9 and checked against the memory maps of Figures 5.5-5.10 by a unit test that walks all 17,030 states. ## The modes | Mode | Data | Output per byte | Source | | --- | --- | --- | --- | | TEXT 40 | ASCII-ish byte to the character ROM (2513 on early boards, 2316B from Revision 7); 8 rows of 7 dots per character; bits 7-6 select inverse, flashing, normal | 7 dots, each two 14M periods wide | DOC: UA2 ch. 8, p. G-3 | | Flashing | a 2 Hz flasher on the II (UA2 ch. 8, "the 2 Hz text flasher"); on the IIe a flash counter, vertical frequency / 32 = 1.87 Hz, which Sather says is his inference ("the flash counter is not mentioned in any published" Apple document) | | DOC: UA2 ch. 8; UA2E Table 3.3 (HYPOTHESIS in its source) | | LO-RES | each byte two 4-bit colour blocks (top: low nibble, bottom: high nibble); the nibble is repeated as a dot pattern, so colour comes from the pattern's phase against the colour reference | 40 x 48 blocks, 16 colours | DOC: UA2 ch. 8 | | HI-RES | 7 dots from bits 0-6 (LSB first); bit 7 delays the 7 dots by one 14M period (a quarter colour cycle) from Revision 1 on, giving orange and blue | 280 x 192, 6 colours by artifact | DOC: UA2 ch. 8 (pp. 8-17..8-19 region), p. G-2 | | MIXED | V2·V4 identifies text time: the last 32 displayed lines become TEXT | | DOC: UA2 p. 8-12 | | 80-column text, double lo-res, double hi-res (IIe with an 80-column card, Rev B board; IIc) | main and auxiliary bytes interleaved, 14 dots per CPU cycle | 560 x 192 | DOC: UA2E ch. 8; A2ETRM ch. 2 | **Mode switches take effect late**: "any time the screen mode is switched between GRAPHICS and TEXT, including a MIXED mode switching, the switchover is delayed until the third time RAS' rises after the switch logic changes", so the last HI-RES pattern is shifted out (DOC: UA2 p. 8-12). The board needs this to the 14M period for mid-line split-screen programs (UA2 Figure 3.10's half-LO-RES half-HI-RES line). **Revision 0** colours text and has no hi-res delay bit; **Revision 1** adds the colour killer for TEXT mode (MIXED text stays coloured) and the delay (DOC: UA2 p. G-2). Machine-row settings. ## Colour: NTSC artifacts The Apple generates no chroma signal. The colour reference (3.579545 MHz, 4 periods of 14M) is a burst in blanking; dots are a 1-bit luminance signal at up to 14M, and a TV decodes the pattern's phase against the burst as colour. With 3.5 colour-reference cycles per CPU cycle the phase alternates byte to byte, which is why a hi-res pattern at an even address shows other colours than at an odd one, and why the long cycle exists (it delays the video shift half a colour period once a line so that every line starts with the same phase) (DOC: UA2 pp. 3-12..3-13, ch. 8). **Proposal for the specification's output contract** (to be decided: open decision 5): the board emits, per scanned line, the 1-bit video signal at 14M resolution (560 displayed samples; 912 a line with blanking), the colour-burst state for that line (on, or killed in TEXT), and the mode; it does **not** decode colour. Colour decoding is a host-side producer with named, swappable decoders (a monochrome view, an idealised 16-colour LO-RES/6-colour HI-RES palette, a filtered NTSC decoder). The 1-bit signal is exact and testable; every decoder's colours are a presentation choice, not a hardware claim. The IIgs and the RGB cards (Video-7, the IIe's AppleColor RGB) are later rows that do produce colours digitally. ## The floating bus During PHASE 1 of every cycle the scanner's RAM read leaves its byte latched on the data bus; a CPU read that no device drives (most soft-switch reads, empty slots, unpopulated RAM) returns that byte (DOC: UA2 pp. 5-3, 5-27..5-28, Figure 5.13 "Floating bus stores video data"). Software uses it to find the beam ("vapor lock": a program polls a soft switch until it reads a byte planted in screen memory, then knows the scanner's position to the cycle; Sather's own synchronizer card does the same with flag bytes at $3FD0 and $3827, DOC: UA2 p. 3-19). So: - the board must know, for every CPU read, the byte the scanner fetched in that cycle (HBL fetches included, from the HBL address range); - reads of switches that drive only bit 7 on the IIe ($C011-$C01F) take bits 0-6 from somewhere: U7 ([memory.md](memory.md)); - a2audit's `floatbus/` program is a split-screen test built on the floating bus; its README lists floating-bus tests as still to do (sources.md). ## The IIe's differences The IIe's video is in the IOU and a timing HAL (DOC: UA2E ch. 3, 8): the same 65 x 262 timing, VBL readable at $C019 ("the display scan will be from zero to six cycles past the end of VBL" after a polling loop falls through, DOC: UA2E p. 3-23), ALTCHARSET and MouseText (enhanced), 80 columns and double hi-res from auxiliary memory, and revision-dependent details (the Rev A board lacks double hi-res). Sather's IIe book is the cycle-level source; Apple's manual the programmer's. ## What the board owns, what the host owns | The board | The host | | --- | --- | | the scanner counters, the address, the fetch per cycle, the mode and switch delays, the character ROM lookup (from the player's ROM), the 14M dot stream per line, the floating-bus byte | colour decoding, scaling, the frame cut, monitor emulation (persistence, scanlines) |