# Handoff: build `atari8bit-python`, the Atari 8-bit computer board ## Context you are inheriting The family's shape: chips are cores, boards compose cores; CPUs always get their own core; a non-CPU chip used by one machine stays in its board and is extracted, with history, when a second family project needs it; never copy a file between repositories, pin the sibling by commit. Read the charter first (emulator-lineage `docs/charter.md`), then [start-here.md](start-here.md) and [reuse.md](reuse.md). This is an era-1 board in the charter's table: one clock domain for the computer, cycle level everywhere; Python runs the tests, Rust plays. The board to model this one on is **a5200-python** (same CPU, ANTIC, GTIA and POKEY; its docs/architecture.md, sally-halt.md, timing.md and status.md). Cores it embeds, read and not touched by this phase: **6502-python** (pin 828b619, as a5200-python), **pokey-python** (pin ea20096), and, if decision D2 says so, **antic-python** and **gtia-python** extracted from a5200-python. Read in order before writing code: 1. [README.md](../README.md), [start-here.md](start-here.md), [reuse.md](reuse.md). 2. [memory-map.md](memory-map.md), [pia-keyboard-console.md](pia-keyboard-console.md), [cartridges.md](cartridges.md), [sio-disk-cassette.md](sio-disk-cassette.md), [firmware.md](firmware.md). 3. [domains-and-speed.md](domains-and-speed.md). 4. [sources.md](sources.md), [validation.md](validation.md), [mame-oracle.md](mame-oracle.md), [census.md](census.md). Then `python -I scripts/fetch_references.py --verify` (20 files and one sparse repository; two are held, see D1). Text versions of the PDFs are in `reference/text/`, OCR'd ones in `reference/ocr/`. ## Decided by Aubrey (standing rules that apply here) - Name `atari8bit-python`, package `atari8bit_python` (the x-python naming rule). - Local, no remote, until he says otherwise. Bring your own firmware and media, found by SHA-1 through `MAME_ROMPATH`, `NO_INTRO_DIR`; nothing of Atari's in the repository. - Python floor = PyPy's (3.11), PyPy must work, under 80 attributes per hot object; modern over compat; reference boards are correct, not fast; sound may be less exact than pictures; smoke lists before sweeps; technical choices are made, marked provisional and reported. - a5200-python's decision 2 (2026-11-12): ANTIC and GTIA extract "when an 8-bit-computer board starts". This is that board (D2 asks how). ## Proposed by this Phase 0 - **The 800 NTSC row first** (`a800`, OS-B, 48K, GTIA, BASIC as a left cartridge: rev C, whose bytes are in the local MAME set as co24947a and equal the cartridge's (MAME's CC0 `basicc`); rev A is not present locally), as the brief asks (400/800, then XL/XE); the 400 is the same board with one slot and 16K. Then `a800xl` (OS v2, BASIC rev B built in), `a130xe`, `xegs`, and the PAL rows. - **ANTIC and GTIA extracted into antic-python and gtia-python** as milestone 0 (D2). - **The SIO bus as a socket** with peripheral devices as domains; the disk drive at SIO protocol level first, chip-level drives as later boards (D4). - **pokey-python builds its serial shift registers** (its decision 2 deferred them to this board): the first upstream request, with Acid800's five serial tests as the repro. ## Package and classes (proposed) ``` atari8bit_python/ machine.py # machine rows: model, video standard, RAM, slots, PORTB wiring, floating # bits and decay, data-bus pull-ups, ANTIC/GTIA variants, firmware SHA-1s console.py # build(machine, cart=None, disks=(), tape=None, firmware_dir=...) -> Atari board.py # the cycle loop (a5200-python's order of record plus the PIA), the bus memory.py # decoders (400/800, XL/XE), the 800's two data-bus latches, PORTB banking, # 130XE window with separate ANTIC access, XEGS game ROM pia.py # Pia6520: ports, DDRs, control lines, flags, IRQ, reset keyboard.py # the key matrix behind POKEY's key_response; console keys; 1200XL keys controllers.py # joysticks (PIA + TRIG), paddles (pokey_python.rc.PotRC) cartridge/ # the socket (RD4, RD5, $8000-$BFFF, $D500-$D5FF), classes, table, loader sio.py # the SIO bus: lines, the socket protocol, device scheduling across domains disk.py # SioDisk: command frames, per-firmware timings, rotation; ATR/XFD/ATX tape.py # the recorder: motor, CAS bit stream, audio xex.py # the harness's XEX loader (labelled; see sio-disk-cassette.md) firmware.py # SHA-1 lookup, composites from MAME's chip images savestate.py # whole-machine states naming firmware and media by hash ``` ## What the board needs from its cores (the embedding contracts) From **6502-python**: what a5200-python uses (per-cycle bus callbacks with dummy accesses, NMI and IRQ inputs). HALT and RDY stay the board's. Nothing new. From **pokey-python**: (1) **the serial output and input shift registers** with SEROUT/SERIN, the serial-output-complete flag (IRQST bit 3, unlatched), SKSTAT's input-busy and overrun flags, the SKCTL clock modes, and the SID/SOD pins as channel lines; (2) the keyboard scan as built (rung 6); (3) pots as built. Repro: Acid800 `pokey_serclock`, `pokey_serdirect` (needs the SIO disk device too), `pokey_sertiming`, `pokey_skstat`, `pokey_twotone` (also a5200-python's open `pokey_twotone`, issue-pokey-0001). From **antic-python** (after D2): everything a5200-python's `antic.py` does, unchanged, plus RNMI (an input line setting NMIST bit 5 and firing an NMI: [AHRM] 2.4, 4.8), the light-pen latch inputs, PAL timing (312 lines; the VBLANK and VSYNC lines per standard: U11), and the refresh counter width as a variant field ([AHRM] 2.3). From **gtia-python** (after D2): everything `gtia.py` does, unchanged, plus CONSOL inputs (the console keys' levels ANDed with GTIA's pull-downs: [AHRM] 6.11), TRIG inputs as board lines (TRIG3 = RD5 on XL/XE, TRIG2 = keyboard present on XEGS), the PAL register value and the CTIA row. ## Unknowns - **U1** Whether the 400/800's 6502 with external HALT logic behaves on the bus exactly as SALLY's built-in HALT ([AHRM] 2.1 mentions both). Acid800's timing tests on the 800 row are the judge we have. - **U2** Power-on RAM: undefined; block patterns after long power-off ([AHRM] 2.3). Proposed: a seeded pattern field, default alternating $00/$FF, labelled HYPOTHESIS. - **U3** PORTB floating-bit decay: 100-500 ms, varying by bit and unit ([AHRM] 2.5). A per-row parameter, FITTED. - **U4** Which XE units float the data bus and which pull it up ([AHRM] 2.3: "other XE machines"). - **U5** ANTIC revision per model (refresh counter 7 or 8 bits). - **U6** Cartridge power-on bank (no reset line; MAME: bank 0, "TODO: random"). - **U7** Hardware verdicts of Acid800 1.2 per model: not recorded in any usable source. - **U8** SIO timing tolerances per drive firmware: [AHRM] Tables 50-56 give them; no second source. - **U9** A non-GPL description of the CAS format and of Atari800's `.car` type numbers. - **U10** ATR and ATX format descriptions with known terms. - **U11** PAL ANTIC and GTIA beyond the line count (VBLANK/VSYNC positions, colour). - **U12** The 1200XL OS: MAME's default "rev11" composite has no [AHRM] row (C4). - **U13** CTIA machines: which 400/800 serials carry CTIA; the CTIA row's behaviour beyond "no GTIA modes". - **U14** Analog audio and the console speaker's level ([AHRM] appendix E). - **U15** Scans without a text layer: [FSM-1050], [FSM-410], [MCS], [GTIA-DS], [POKEY-DS] (the XL Addendum and the 800XL manual were OCR'd here). - **U16** Whether the local No-Intro directory (36 zips) is the whole set: no DAT here. - **U17** Which XL/XE units have FREDDIE and how it changes refresh and the 130XE window. ## Contradictions between sources - **C1** [AHRM] F.4 heads SHA-1 `f03b9b93...` "Atari XEGS OS version 3" but describes it as "Updated OS for XE machines"; MAME files the same bytes under a800xe (c300717). Proposed name: XL/XE OS v3. - **C2** MAME flags the 400/800 OS chips and the 1200XL chips "baddump" ("ROM NEEDS REDUMP"), yet joined in address order they equal [AHRM]'s composite SHA-1s. The bytes agree with [AHRM]'s database; the flag is about MAME's dump provenance. - **C3** Altirra's page says GPL "version 2"; emulator-lineage sources.md has Altirra's source as GPL-2.0+. Not resolvable without opening the source; closed box either way. - **C4** MAME's default 1200XL OS (rev11) is not [AHRM]'s 1200XL OS (= MAME rev10). - **C5** No-Intro's "Centipede (Europe).atx" is a raw 8K cartridge (MAME `centiped`), not an ATX disk. - **C6** [AHRM] 2.2 gives the machine clock as "approximately 1.77-1.79 MHz"; 4.2 gives 1.789773 / 1.773447 MHz exactly. Use 4.2. ## Milestones | # | Milestone | Judge (tier) | Exit | | --- | --- | --- | --- | | M0 | **ANTIC and GTIA extracted** (D2) into antic-python and gtia-python with history; a5200-python repinned | a5200-python's own gate | Acid5200 still 46 of 48 (the same two misses) and the 78 Atari800-identical images still identical; no behaviour change in the extraction commit | | M1 | **The 800 NTSC row without video detail**: 6502-python, the 400/800 decoder with the two data-bus latches, the PIA, POKEY (as pinned) with the keyboard matrix, the antic-python and gtia-python cores as extracted, OS-B by SHA-1, a left cartridge | [AHRM] 2.3-2.5, [MCS] (2-3); Acid800 `cpu_*`, `pia_basic`, `pia_irq` via the labelled XEX loader (3); MAME trace (5) as detector | OS-B boots to the memo pad, and to BASIC READY with BASIC rev C in the left slot; `cpu_*` 8 pass (`cpu_65c816` skipped), `pia_*` 2 pass; the OS's first 3 frames of instructions equal MAME's trace or each difference named; seeded faults (port A read-back, ORA-read flag clear, I/O-bus latch) caught | | M2 | **The computer-only chip inputs, in the cores**: RNMI, light pen, PAL timing fields in ANTIC; CONSOL inputs, TRIG lines, PAL register in GTIA | [IJOR] (1, document), [AHRM] 2.4, 4, 6 (3); Acid800 `antic_*` 20 and `gtia_*` 11 (3) | each new input with its own core test; the 800 row passes 20/20 ANTIC and 11/11 GTIA (`gtia_vdelay` included) or each miss is named; a5200-python's gate unchanged at the cores' new pins | | M3 | **SIO**: pokey-python's shifters (upstream), the SIO socket, the disk device (ATR/XFD), the XEX boot-disk harness | [OSM], [AHRM] 9-10 (2-3); Acid800 POKEY 15 (3) | `acid800.atr` boots and runs to its summary on the 800 row; the POKEY tests pass or each miss is named; Caverns of Mars and The Shattered Alliance (ATR) boot to their title screens | | M4 | **Cartridges**: 8K, 16K, right 8K, XEGS, then OSS, Williams, SpartaDOS X, Atrax, Diamond, Express, Turbosoft | [MAME-BSD] (5, rules), [AHRM] 8 (3) | the 30 local cartridge dumps reach their title screens on the right row; MAME pictures as detector, differences triaged | | M5 | **XL/XE rows**: the MMU, PORTB banking and decay, the self-test, built-in BASIC, real reset, the 130XE window with ANTIC access, the XEGS game ROM and keyboard sense, the 1200XL | [XLA], [FSM-XL], [AHRM] 2.4-2.8 (2-3); `mmu_xlbanking` (3) | `mmu_xlbanking` passes on a800xl and a130xe and fails as expected on the 800; Missile Command (USA) shows the [AHRM] F.5 keyboard-option failure on XL and works on the 800; the full Acid800 run on a800xl | | M6 | **Cassette**: the tape domain, CAS input, motor, the audio sum | [OSM], [AHRM] 9.17, C (2-3) | a CAS image loads through the OS's C: handler (a self-made CAS from a known binary, since no local CAS exists) | | M7 | **PAL rows** | [AHRM] 4.2, D (3) | Acid800 detects PAL and passes as on NTSC; frame = 35,568 cycles | | M8 | **ATX timing, AcidOS, save states, frontend** | AcidOS (3) | the three local ATX images boot; AcidOS passes with Atari's OS rows; a save taken mid-SIO-transfer continues identically in a fresh machine | | later | chip-level 810/1050 boards (D4), more controllers, more cartridges | | | ## The gate (defined at milestone 1, before any socket device) Unit tests of the documented facts; the Acid800 standalone tests reached so far with their expected verdict per row; seeded faults, each caught; the MAME instruction-stream comparison for the first frames of each machine row's boot. With nothing in the cartridge slot and nothing on the SIO bus, adding a device must not move these. ## Domains and speed ([domains-and-speed.md](domains-and-speed.md) in full.) - **Domains**: C (the computer: CPU, ANTIC, GTIA, POKEY, PIA, memory, cartridge, all on the 1.789773 MHz machine clock), D (each disk drive, on its own 0.5 or 1 MHz clock), T (the tape). **Channels**: SIO DATA OUT, DATA IN, COMMAND, MOTOR, PROCEED, INTERRUPT, CLOCK, and the tape's audio into the mix. The order of record steps a drive or the tape up to the computer's time whenever a channel line changes or is read; inside C, a5200-python's order of record with the PIA added. - **The need, with arithmetic**: per machine cycle, not per instruction: 1,789,773 board cycles a second (each one an ANTIC step, two GTIA colour clocks and a POKEY tick), carrying about 0.4-0.6 M 6502 instructions (3-4 cycles each, ANTIC taking 10-40 % of cycles). A chip-level 1050 adds 1.0 M 6507 cycles a second (0.25-0.33 M instructions), hypothesised at +10-20 % of total cost. - **No-JIT path**: a5200-rust, the same chips, runs Pac-Man at 375 frames a second, 6.3x real time, natively on this loaded machine. So x-rust reaches real time on desktop (6.3x), in the browser (HYPOTHESIS 3-4.5x) and on a phone without JIT (HYPOTHESIS 2-3x). Run-ahead on phones and phone browsers wants x-rust-fast. A cached interpreter has little to cache; threads only at the SIO channel, and only if chip-level drives measure expensive. `recompile: none` on every target. ## Open decisions for Aubrey 1. **D1: virtualdub.org's robots.txt and the AHRM/Acid800.** The site (Avery Lee's own) disallows GPTBot and ChatGPT-User; it does not name ClaudeBot or anthropic-ai. The rule of 2026-11-26 lists GPTBot among the blocks that mean "do not fetch". Both files were fetched before the rule reached this run (and a5200-python and pokey-python already rely on them). Options: (a) treat the block as OpenAI-specific and keep using both; (b) set the site aside: stop fetching, keep the facts already cited and look for second sources; (c) set aside and remove what was taken. **Recommend (a), asked rather than assumed**: the block names one company's crawlers, Avery Lee states no wish about AI use on the page we read, and the AHRM is the best tier-3 source for this machine. If Aubrey reads it as a wish, (b), with the family's two Atari boards reviewed the same way. 2. **D2: ANTIC and GTIA.** (a) Extract both now into `antic-python` and `gtia-python`, with history, a5200-python repinned with an unchanged gate, computer features added in the cores afterwards; (b) one core `antic-gtia-python`; (c) leave them in a5200-python and import from it; (d) one board repository for 5200 and computers. **Recommend (a)**: it is the charter's rule and a5200-python's own recorded plan; the chips are separate parts that vary independently; (c) makes a board depend on a board; (d) reshapes a finished lineage. 3. **D3: first machine row.** (a) The 800 NTSC (as the brief orders: 400/800 first); (b) the 800XL first (the most common machine and the best-tested OS). **Recommend (a)**: no PORTB banking in the way, and Acid800 runs on it; the 800XL follows at M5. 4. **D4: disk drives.** (a) SIO protocol device first, chip-level 810/1050 as later boards behind the same socket; (b) chip-level first; (c) protocol level only. **Recommend (a)**; (b) costs a 6507 domain, a RIOT extraction from a2600-python and a WD279x core (with msx-python) before anything boots. 5. **D5: AltirraOS.** (a) Atari's ROMs only; (b) also accept AltirraOS and Altirra BASIC (FSFAP, notice kept) as optional, labelled firmware rows so the board can boot with nothing of Atari's; (c) ship AltirraOS in the repository. **Recommend (b)** once D1 is settled, with Atari's ROMs as the only reference rows; (c) only if a site needs a default OS (decide then). 6. **D6: pokey-python's serial shifters.** Ask pokey-python to build them now (its decision 2 deferred them to this board). **Recommend yes**, as the first upstream request, with the five Acid800 tests as repro. 7. **D7: memory expansions beyond the 130XE** (RAMBO, COMPY...). **Recommend** a machine-row field with no milestone of its own. 8. **D8: AtariAge.** Its robots.txt disallows ClaudeBot; this repository set its snapshot aside. a5200-python keeps Wayback snapshots of AtariAge threads and pokey-python holds a hand copy of ijor's POKEY schematic from AtariAge. **Recommend** a family review of those two (Aubrey's call; this Phase 0 did not touch them). 9. **D9: visibility.** Local until milestone 2, then a private GitHub repository like the other boards. **Recommend that.**