# Handoff: build `channelf-python`, the Fairchild Channel F board ## Context you are inheriting The family's shape: chips are cores, boards compose cores, CPUs always get their own core; a chip used by one machine stays in the board until a second board needs it (charter; the chip rule). The CPU core is `f8-python` (`../f8-python`, Phase 0 done in parallel: read its handoff brief first; it owns the F3850 **and** the memory chips F3851/F3856/F3853, its Open decision 1). Pin it by commit. A corner of the F8 found here is raised **on the core**. Era 1 (charter): one clock domain, cycle level everywhere. Python is the specification ("reference boards: correct, not fast"); Rust plays. Models to read: `a2600-python` (`../a2600-python`: an era-1 board whose CPU has no frame interrupt and whose picture is made by timing writes; machine rows; its MAME and census scripts), `odyssey2-python` (another 1970s console with an Intel MCS-48), `gameboy-python` (rows, smoke tests). Copy shapes, not code. Rules: Python >= 3.11, CPython and PyPy; modern forms; no dangerous-looking shell one-liners; local git only; MIT; MAME's Channel F driver (GPL-2.0+) and FreeChaF (GPL-3.0-or-later) are never read; no BIOS or game bytes committed (`NO_INTRO_DIR`, `MAME_ROMPATH`); run Python that reads `reference/` with `-I`. ### Read in this order README.md; docs/start-here.md; docs/machine.md; video.md; sound.md; input.md; cartridges.md; bios.md; channelf-ii.md; domains.md; validation.md; mame-oracle.md; then `../f8-python/docs/handoff-brief.md` and `romc-and-the-psus.md`; then the schematics in `reference/docs/` (FVE100 sheets 1 and 2 at full resolution, the Luxor 1909583 manual) and the veswiki pages in `reference/veswiki/`. ## Scope In: the console (both BIOS PSUs as f8-python F3851 instances with their mask options, ports 0/1/4/5, VRAM and its write path, the video counters and scan-out, the palette and colour decode, the tone generator and envelope, the controllers, the console buttons and reset), the cartridge kinds (`std`, `maze`, `hangman`, `chess`, and the homebrew multi-cart), machine rows (Channel F with SL31253 or SL90025, Channel F II, the PAL clones), a frame and audio output API, save states, a MAME-log comparison harness. Out: the F8 chips themselves (f8-python); a high-level BIOS (none; Open decision 4); the host (a later `play-chf` site or `channelf-play` window, Aubrey's call). ## Proposed names - Repository `channelf-python`, package **`channelf_python`**. - `channelf_python.ChannelF` (the board; `machine=` one of `channelf`, `channelf-sl90025`, `channelf2`, and the PAL rows named after MAME's sets where they are the same design). - `channelf_python.video.Video` (VRAM, write latch, counters, scan-out), `channelf_python.sound.Tone`, `channelf_python.input.Controller`, `ConsoleButtons`, `channelf_python.cart` (`Cartridge` kinds built from f8-python chips; a table generated from MAME's CC0 software list for kinds by SHA-1). ## Import boundary From f8-python: `F3850`, `F3851`, `F3853` (for the Schach-layout RAM, pending U7), the `RomcBus` and the `Port` objects. The board owns everything on the port pins and the cartridge wiring. The board never touches a chip's PC0/DC0: if it needs one (a debugger), it asks the chip. ## Sockets - **Cartridge**: a list of f8-python memory chips (with their mask options and any RAM) plus port devices; INT REQ from the cartridge connector. - **Controllers**: two `Controller` inputs (detachable on the Channel F II row only in the host's presentation). ## Unknowns (U) and contradictions (C) - U1 The VRAM write window: why a real console drops pixels written too soon after the previous one (VW), and how many phi the write needs. From SCH sheet 2 (the 74153 mux timing and ARM WRT path). - U2 The colour table: per palette code, what each pixel code shows (white on black rows?). From the 9322/7445 logic on SCH sheet 2; RGB values FITTED. - U3 What retriggers the tone envelope (any write to port 5, or a change of bits 6-7). - U4 Which counter tap each tone select picks (input 3 of A3 illegible on the redraw; the pin inversion of TONE AN/BN). - U5 The second-generation 9102 audio envelope. - U6 RESET's wiring (to the CPU's EXT RES pin) and what it resets in the video logic. - U7 Which F8 chips each cartridge carries (F3851 vs F3856 decides the XDC behaviour; the Schach RAM interface). - U8 How the port RAMs of Maze and Hangman are wired (a cartridge F3851 at port base 20h/24h, or discrete logic). - U9 What SL90025 changes from SL31253. - U10 Whether the Channel F II uses the 9111/9102 design of the Luxor 1909583. - U11 SL31254's port addresses and both BIOS PSUs' interrupt vectors (mask options). - U12 The visible area on a real TV (VW's 95 x 58 "safe area" vs MAME's 102 x 58). - C1 Line and frame rate: MAME 15,980 Hz / 264 lines / 60.53 Hz (NTSC), 15,625 / 312 / 50.08 (PAL); veswiki computes tones from 15,734.26 Hz (broadcast NTSC). Judge: SCH sheet 2's counter chain. - C2 Tone sources: veswiki 4V/8V/32V (line/16, /32, /128) vs SCH's A3 inputs 2V, 4V and 32V AND 8V. Judge: SCH, after U4. ## Milestones M1 bus and boot; M2 video; M3 cartridges; M4 input; M5 sound; M6 rows; M7 timing pass; M8 seeded faults. Exit tests in [validation.md](validation.md). ## Domains and speed (Full version with tables: [domains.md](domains.md).) **Domains and channels.** One domain: the CPU and every F8 memory chip, the port latches, and the inputs (all the CPU can observe). Two **pure producers**: the video scan-out (consumes the log of VRAM writes, each with its phi stamp) and the tone generator (consumes port 5 bits 6-7 with stamps). **Nothing flows back to the CPU**: there is no readable VRAM, counter, blanking flag or video interrupt on this console. So the producers have no sync point at all; the order of record runs them after the CPU to the same stamp. **Instructions per second, with the arithmetic.** phi = 1,789,772 Hz NTSC (2,000,000 PAL); the fastest F8 instruction is 4 phi, so the ceiling is 1,789,772 / 4 = **447,443 instructions/s** (500,000 PAL). MAME measures 211,186/s on the BIOS's polling loop. The scan-out at dot level is 256 x 264 x 60.53 = 4.09 M dots/s (MAME's raster, C1). **The no-JIT path.** - Desktop: `channelf-python` on PyPy about real time or better (estimate 5-20 M instructions/s against 0.45 M; the dot-level scan-out is the heavier part); CPython below real time, which is acceptable for the reference board. `channelf-rust` (a transcription) at 50x real time or more (z80-rust ~50 M/s, sh2-rust 30-47 M/s measured). - Phone (native app, no JIT allowed): `channelf-rust` at ~0.8x desktop: tens of times real time. - Browser (wasm, phone included): ~0.55-0.65x native (sh2-rust measured): still tens of times real time; run-ahead of 1-2 frames costs nothing noticeable. - Low-cost ARM handheld (~0.2x desktop): real time with margin. So `recompile: none` on every target; **no `-fast`, no cached interpreter, no JIT and no threads are needed** (threads would be trivial, since the producers need no sync, but they would not pay). Estimates until channelf-rust measures them. ## Open decisions for Aubrey 1. **The video and sound stay in this board** (chip rule: the Channel F's video logic is discrete TTL or the 9111/9102 customs, used by no other machine in the family). Recommended. 2. **Video modelled at dot level from the schematic's counters, with the scan-out as a producer over a stamped VRAM-write log.** Recommended: it is the modelling level the schematic supports and the only one that shows mid-frame writes; the log makes it cheap and threadable later. 3. **First-generation design first (FVE100 schematic), second-generation rows (9111/9102) after**, each row keeping its own timing and colour logic until a document shows they are equal. Recommended. 4. **No high-level BIOS; the player supplies SL31253 or SL90025 plus SL31254.** Recommended: all three are in the census; cartridges call into the BIOS. 5. **MAME's BSD-3 cartridge, F8 and F3853 files stay closed** (the driver is GPL-2.0+ anyway). Recommended, as for f8-python; the CC0 software list is used as data. 6. **Cartridge kinds by SHA-1 from a table generated from MAME's CC0 software list**, with a size-based default for unknown images. Recommended. 7. **Default provisional choices** (Aubrey's 2026-11-12 rule): C1 follow MAME's raster until SCH sheet 2 is read (mark HYPOTHESIS); U2 colours FITTED; U3 any write to port 5 retriggers; U7 F3851s on every cartridge except Schach (F3853 for its RAM); U8 a cartridge F3851 with port base 20h/24h. 8. **AtariAge stays set aside** (its robots.txt blocks ClaudeBot and anthropic-ai). Recommended: honour it; the Channel F knowledge there that matters (e.g. cartridge chip photos for U7) can be asked of its authors by Aubrey, or found elsewhere. 9. **A homebrew test cartridge** (later, in this repository, MIT): an F8 and board exerciser whose results a Channel F owner could photograph (write window, floating bus, XDC on F3851 vs F3853, tone frequencies). It is the only route to tier-1/3 evidence for this family; whether to ask the community to run it is Aubrey's call.