# Domains and speed Read with the charter's "Domains and channels" and "Capabilities" and the accepted JIT proposal (emulator-lineage `docs/proposals/2026-11-jit.md`), whose family table puts era-1 machines at "one domain ... every bus cycle is observable ... JIT: no". The Apple II belongs in that row. Everything here is a proposal for the specification to confirm. ## Domains **One domain.** Everything on the II, II+, IIe and IIc runs from one 14.31818 MHz crystal: the CPU's PHASE 0 (with the long cycle), the video scanner (one fetch in PHASE 1 of every CPU cycle), the Disk II sequencer (Q3, 2 MHz, only while a drive is on), and every slot card's clocks (DOC: UA2 ch. 3, 9). The CPU and the scanner share RAM in alternate half cycles; the sequencer's data register is read by the CPU on the cycle it is addressed. Nothing waits for anything: the order of record is fixed by the clock. The order of record inside one CPU cycle (proposed): the scanner's fetch (PHASE 1); the sequencer's two Q3 edges that fall in this cycle (their exact 14M positions, the long cycle included: U9); each card's per-cycle work (VIA timers, PSG ticks); then the CPU's access (PHASE 0) with its side effects; then interrupt lines sampled by the CPU's poll. ## Channels (named now, for `-fast` producers and catch-up) Inside one domain the charter's channels are still worth naming: they are where a fast tier may run something lazily or beside the CPU without changing a bus cycle. | Channel | From -> to | Mechanism | Lazy or threaded in `-fast` | | --- | --- | --- | --- | | Video fetch | RAM -> picture | the scanner's address is a function of the cycle count; the byte is RAM at that cycle (the CPU's write in the same cycle comes after the fetch) | **picture as a producer**: log mode-switch writes with their cycle, render whole lines beside the CPU; the floating-bus byte computed on demand from (cycle, RAM) | | Floating bus | video -> CPU | any undriven CPU read returns the cycle's fetched byte | on demand, exact | | Disk II data register | sequencer -> CPU | CPU reads of the controller's even addresses; CPU loads while writing | **catch-up**: the sequencer's inputs change only at controller accesses and at read pulses, which are a function of time and the disk; run it up to the cycle of each access. The CPU's bus trace stays identical, so this is `-fast`, not `-turbo` (charter: "a shortcut that keeps every bus cycle identical belongs in `-fast`") | | Speaker, cassette out | CPU -> audio | toggles at a cycle | audio as a producer from the toggle log | | Mockingboard | CPU <-> VIAs -> PSGs -> audio; VIA -> IRQ | VIA register accesses; timer underflow raises IRQ at a computable cycle | VIA timers by catch-up with the next IRQ cycle as a sync point; PSG synthesis as a producer from register writes | | Keyboard, game port | host -> board | latched at a cycle; 558 timers run out at a computable cycle | catch-up | | Slot DMA (SoftCard, later) | card <-> CPU bus | DMA'/RDY | a sync point on every access | ## Instructions per second (the need, arithmetic shown) - CPU cycles: 14,318,180 x 65 / 912 = **1,020,484 cycles a second** (17,030 x 59.92). - Instructions: MAME's `apple2p` ran 403,852 instructions in 60 frames of the Monitor's boot (2.53 cycles each: mostly the WAIT loop) and 783,811 in 120 frames of a disk boot (2.61 cycles each) (OBSERVED, [mame-oracle.md](mame-oracle.md)); typical 6502 code averages 3 to 4 cycles. **Need: 0.3-0.4 M instructions and 1.02 M bus cycles a second.** - Video: 1.02 M fetches a second; 7 (or 14 on the IIe's double modes) dots out of each, by table, not by dot: 1.02 M lookups. - Disk II: two sequencer steps per CPU cycle while a drive is on: **2.04 M table lookups a second**, the heaviest single load, but only while the motor runs. - Mockingboard (when fitted): 2 VIAs and 2 PSGs ticked 1.02 M times a second each. - IIgs (later): a 65C816 at up to 2.8 MHz, about 0.8-1.0 M instructions a second, the 1 MHz Mega II side, and the DOC. ## Does the no-JIT path reach real time? | Target | Tier | Estimate | Basis | | --- | --- | --- | --- | | desktop, PyPy | `apple2-python` (the reference) | at or above real time with the drive off; near real time with it on (HYPOTHESIS) | famicom-python on PyPy runs a 1.79 MHz 6502 and a 5.37 MHz PPU at 0.89x real time (its notes, 2026-10-12); the Apple's per-second event count is about a third of that without the disk and about half with it. Reference boards are correct, not fast (Aubrey's rule), so this is a convenience, not a goal | | desktop, CPython | reference | 10-20% of real time (HYPOTHESIS) | famicom-python's CPython/PyPy ratio (~6x) | | desktop | `apple2-rust` / `-fast` | many times real time | a2600-rust-fast reaches about 4x real time natively with a TIA stepped at 3.58 MHz (its notes); the Apple's per-cycle work is lighter | | phone (native, no JIT allowed) | `-fast` | real time with margin (HYPOTHESIS: to measure) | as desktop at a phone's single-core speed; no executable memory needed | | browser (WebAssembly) | `-fast` | real time | play-2600's wasm build of a2600-rust-fast runs 59.9 fps in headless Chromium and about 3x real time under Node (its notes) | **Conclusion: `recompile: none` on every target.** No cached interpreter is needed; `-fast` with the catch-up channels above is the expected ceiling of effort; threads are optional and only for producers (picture, audio). A `-turbo` is not expected to be needed for the II/IIe/IIc (charter: "tiers exist only where a target needs them"); the IIgs may want one on phones (to measure in its own Phase 0). ## Capabilities (to measure when built) Snapshot: 48K-128K of RAM, the switches, the scanner position, the sequencer state, the drive (head, motor timer, bit position) and the disk image's written tracks: tens of kilobytes plus the disk image delta. Run-ahead and rewind should both be cheap. Concessions: none expected; colour decoding is a host choice, not a concession, because the board's output contract is the 1-bit signal ([video.md](video.md)).