# Video: a 128 x 64 two-bit frame buffer written through ports Sources as in [machine.md](machine.md): SCH (FVE100 schematic sheet 2), VW (veswiki "VRAM", "Palette", "Resolution", "Accessing VRAM"), MAME (OBSERVED). ## The frame buffer (DOC: SCH sheet 2; VW "VRAM") - 128 columns x 64 rows x 2 bits = 16,384 bits in four 4096 x 1 DRAMs: ODD0, EVEN0, ODD1, EVEN1 (bit 0 and bit 1 of even and odd columns). The CPU writes it; **nothing reads it but the scan-out**: there is no path from VRAM to the CPU (VW: "except for the latest byte sent to the latched port it can't be read back"). - A write: the program puts the colour in port 1 bits 6-7, the complemented column in port 4 bits 0-6, the complemented row in port 5 bits 0-5, then pulses port 0 bit 5 (ARM WRT). The 74153s (E8-E10) switch the DRAM address between these port latches and the scan counters (SCH). - VW warns that a real console, "especially the 2MHz PAL model", needs a **delay after each write** before the next pixel's values are loaded, or pixels go missing; MAME needs none. The Fairchild BIOS's own plot routine waits in a short loop (VW quotes the routine). Why (the write is only performed in a window of the scan's memory cycle?) is U1 in the brief; the board must model the write timing from SCH, and a homebrew that skips the delay is the test. ## What is shown (OBSERVED MAME; VW) - About **102 x 58** pixels are visible, starting near column 4, row 4; the "safe" area on a real TV is about 95 x 58 (VW "VRAM", "Resolution"). The rest of the 128 x 64 exists but is off screen. MAME shows 102 x 58 from (4,4) and draws a 204 x 232 window (each pixel 2 x 4 output pixels at its 256-wide raster). - Pixels are wide: VW says the aspect is close to 16:9 on a 4:3 TV. ## Colours and the per-row palette (DOC/tier 3; details U) - **Columns 125 and 126 of each row hold that row's palette select**, two bits (VW "Palette", "VRAM"). They are off screen. The palette selects the row's background and how the three foreground codes look. - The pixel codes as software writes them to port 1 (VW "Accessing VRAM"): 00h green, 40h red, 80h blue, C0h background. Background colours by palette code (VW "Palette"): 00 black, 01 light grey, 10 light blue, 11 light green. On black rows the foreground shows as white (community knowledge, to confirm: U2). - On SCH the two bits shifted out of VRAM (FG0, FG1) and the two latched palette bits (BG0, BG1) feed a 9322 multiplexer and a 7445 decoder that drive three colour lines into the modulator. The board's colour table should be derived from that logic (a truth table is DOC) with RGB values FITTED to the composite levels, not copied from an emulator's palette. ## Timing (C1: the numbers disagree) | Quantity | MAME (OBSERVED) | veswiki (tier 3) | SCH | | --- | --- | --- | --- | | line frequency | 4,090,908 / 256 = **15,980 Hz** | 15,734.26 Hz ("horizontal line frequency" in "Outputting Sound": the broadcast NTSC rate, assumed) | counters F6-F10 from the 3.58 MHz clock: divide ratios to read | | lines per frame | 264 NTSC, 312 PAL | - | the vertical reset decode on sheet 2 | | frame rate | **60.53 Hz** NTSC, 50.08 Hz PAL | - | - | MAME's NTSC timing (15.98 kHz, 264 lines, 60.53 Hz) is not broadcast NTSC (15.734 kHz, 262.5 lines, 59.94 Hz). A console built from TTL counters may well run off-standard, so neither is wrong yet. **The judge is the schematic** (the counter chain and its resets on sheet 2, DOC) or a measurement of a real console's frame rate (tier 1, none available). The sound frequencies depend on the same counters (sound.md), so settling this settles both. ## Mid-frame writes The CPU can write VRAM while the beam is drawing: the picture is the VRAM contents at the moment each pixel is scanned. The board's scan-out must therefore use the phi stamp of every VRAM write (domains.md). There is no vertical-blank signal or interrupt the CPU can read (SCH shows none; INT REQ comes only from the cartridge connector), so games time everything by counting instructions.