# 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`: the no-JIT path first). A proposal for the specification to confirm. ## Domains Three crystals (20 MHz CPU, 25.1748 MHz video, 8 MHz sound) plus the sample chips' own oscillators (JT16 crystal table; CMSND; CMP16). | Domain | Holds | Clock | Why one domain | | --- | --- | --- | --- | | **C: CPU** | the 68000 (or FD1089/FD1094), the 315-5195 (16B) or the fixed decode (16A), program ROM, work RAM, I/O ports and DIPs, the 8751 when fitted, the 315-5248/5250 on 171-5797 | 20 MHz / 2 | the 8751 is a second bus master on the 68000's bus (/HALT, latched address and data), drives the 68000's /IPL on Pre-16, and halts it at reset (CMP16; mame-oracle.md): the two are tightly coupled | | **V: video** | the 315-5196 sprite chip and its line buffers, the 315-5197 tile chip, tile/text/sprite RAM, colour RAM, the mixer | 25.1748 MHz / 4 (12.5874 MHz for sprite rendering) | its own crystal; meets C at the video RAMs, the control bits and the interrupt | | **S: sound** | the Z80 (or MC-8123), its RAM and ROMs, the YM2151, the uPD7759 (16B) or the uPD7751 + 8243 + DAC (16A), the sound control latch | 8 MHz (YM2151 / 2), the Z80's source (U1), 640 kHz (7759), 6 MHz (7751) | the uPD7759's /DRQ is the Z80's /NMI and the Z80 feeds it byte by byte (CMSND): one domain, stepped together; the 7751 is started and reset by the YM2151's CT pins (CMP16) | ## Channels | Channel | From -> to | Mechanism | Sync point | | --- | --- | --- | --- | | sound command | C -> S | 16B: mapper register 0x07 latches a byte and strobes the Z80's /INT; the Z80 reads port 0xC0. 16A: 8255 port A (mode 2), /OBF -> Z80 /NMI, the Z80's read strobes /ACK | the write's time; the Z80's read is a reply into C on 16A (handshake state) | | sound command from the 8751 | C -> S | through the 315-5195 (CMSND) | as above | | video RAM | C -> V | 68000 reads/writes of tile, text, sprite and colour RAM | every access (the sprite chip writes words 5 and 7 back in vblank, so C reads what V wrote) | | colour RAM during display | C <-> V | a CPU access wins the shared bus and colours the current pixel (CM16B §5) | every access during active display, at the dot | | control bits | C -> V | display enable, screen flip (16B misc control; 16A 8255 port B, latched per line / per pixel) | the write's time | | vblank interrupt | V -> C | level 4 at line 223 (16B); on Pre-16 vblank timing into the 8751's /INT0, which drives /IPL | the edge's time | | mute | C -> S (16A) | 8255 PC0 to the amplifier | sample-accurate enough | | audio out | S -> host | a sample stream | none (a pure producer) | ## Sync points and code invalidation (the JIT proposal's declarations) - **Sync points**: every row above, plus interrupt sampling on the 68000, the Z80 and the 8751. - **Memory kinds and writers**: | Memory | Kind | Written by | | --- | --- | --- | | 68000 program ROM | ROM | nobody; on FD1094 sets the opcode words seen depend on the key and the CPU's decryption state (U12): a decode cache must be keyed by that state | | 68000 work RAM | RAM, code possible (encrypted code runs from RAM, CM16B §9) | the 68000, the 8751 | | Z80 program ROM, sample ROM | ROM | nobody (the bank latch selects) | | Z80 work RAM | RAM | the Z80 | | 8751 internal EPROM (4 KB), uPD7751 mask ROM (1 KB) | ROM | nobody | - **Timing as data**: m68000-python and z80-python carry per-instruction bus timing; the 8751's is 1-4 machine cycles of 12 clocks (MCS51), the 7751's MCS-48 timing 15 clocks a machine cycle (mcs48-python README). ## The arithmetic: instructions per second | Processor | Clock | Rate per instruction | Instructions a second | | --- | --- | --- | --- | | 68000 | 10 MHz | 11.7 cycles (`shinobi`), 12.2 (`goldnaxe`): OBSERVED in MAME over 3 and 60 frames | 10 M / 12 = **0.83 M** | | Z80, 16B | 5 MHz (MAME; U1) | 12.0 cycles (`goldnaxe`, OBSERVED) | **0.42 M** | | Z80, 16A | 4 MHz | about 12 cycles (assumed as 16B) | 0.33 M | | 8751 | 8 MHz / 12 = 0.667 M machine cycles | 1.29 machine cycles (25,786 instructions in 33,301, OBSERVED) | **0.52 M** (0.26 M if CMP16's 4 MHz divider holds: C1) | | uPD7751 | 6 MHz / 15 = 0.4 M machine cycles | 1-2 machine cycles (MCS-48) | 0.2-0.4 M while a sample plays | | YM2151 | 4 MHz | 64 input clocks a sample, 32 operator slots | 62,500 samples, **2.0 M** operator steps (4 M input clocks if stepped per clock) | | uPD7759 | 640 kHz | ADPCM at 5-8 kHz (DS7759) | under 0.64 M clocks | | video | 6.2937 MHz dots | 400 x 262 x 60.05 | 6.29 M dots, 4.30 M visible pixels; sprite rendering up to 12.6 M line-buffer writes at its ceiling | **A 16B board with an 8751**: 0.83 + 0.42 + 0.52 = **1.8 M CPU instructions a second**, plus 2 M FM operator steps and 6.3 M dots. A 16A board: 0.83 + 0.33 + 0.4 = 1.6 M. A 10 MHz 68000 is easy: it is about one million instructions a second, the same order as the Mega Drive's 7.67 MHz 68000, which m68000-python already runs well above real time on PyPy. ## What that means per tier - **system16-python** (PyPy): m68000-python runs 18.7-33.5 M instructions a second on PyPy (its docs/validation.md, four workloads), 22-40 times the 68000's need. The CPUs are not the cost; the per-dot video and the per-clock FM are. The nearest precedent, megadrive-python (68000 + Z80 + VDP + YM2612 + PSG), makes 16-21 frames a second on PyPy with FM on and "close to 60" with `--no-fm` (its README). Expect the same order here: below real time with FM, near it without (HYPOTHESIS until the board runs). Reference boards are correct, not fast (Aubrey's rule), so this is acceptable. - **system16-rust**: m68000-rust measures 134 M instructions a second natively and about 112 M under Node 22 as WebAssembly (m68000-rust-fast README, the reference's base loop); z80-rust-fast runs 350-400 M. Against 1.8 M CPU instructions a second that is over 60 times real time for the CPUs in a browser. A phone at a tenth of a desktop's single-core speed still has six times the need. **The plain Rust transcription reaches real time on desktop, phone and browser**; FM and per-dot video are the budget, as on the Mega Drive sites (play-md runs the Mega Drive in a browser today). - **system16-rust-fast**: needed only for headroom (run-ahead of 1-2 frames, Aubrey's habit, doubles or triples the work), not for real time. Threads at the channels above are possible but not needed; keep the serial order unless a phone measurement says otherwise. - **Turbo / JIT**: not needed. `recompile: none` on every target, the iPhone included.