# Domains and speed ## Domains and channels | Domain | Parts | Clock | | --- | --- | --- | | **D1, the main bus** | 68000, VDP (and its PSG), work RAM, the I/O block's registers, the cartridge | MCLK 53,693,175 Hz (PAL 53,203,424); 68000 at MCLK/7, PSG at MCLK/15 (tier 5 + DOC) | | **D2, the PCM** | the 315-5641: FIFO, decoder, DAC | its own clock: 1.28 MHz per MAME (640 kHz on the Copera); whether it is a separate resonator or MCLK/42 is U5. Either way it can be scheduled apart, meeting D1 only at its channels | | **D3, the tablet and sensors** | the 315-5640's scan of the two matrices, the six opto-switches, the buttons | unknown scan rate (U11); modelled as the host's inputs latched into registers | Channels: | Channel | Direction | What crosses | | --- | --- | --- | | $800010 writes | D1 -> D2 | ADPCM bytes into the FIFO | | $800010 / $800012 reads | D2 -> D1 | the FIFO's free count, busy (bit 15) | | $800012 writes | D1 -> D2 | rate/type, enable, reset (meanings U14) | | IPL level 3 | D2 -> D1 | "needs more data" (PICODOC, hedged) | | audio samples | D2 -> mixer | a pure producer | | $800003-$80000D reads | D3 -> D1 | buttons, pen X/Y, page code | The order of record in pico-python: 68000-led, as megadrive-python's `System` (one 68000 instruction, then every other part caught up to its clock), with the PCM caught up before any access to $800010/$800012 and before the IPL is sampled. D3 is sampled at the scan instants the board chooses (once a frame until U11 is known), stated in the code. Pure producers that may run beside D1 from `-fast` on: the VDP's picture from its write log (as megadrive-rust-fast may), PSG synthesis, and the PCM's sample *values*. The PCM's *timing* (FIFO drain, busy, IRQ) depends only on the clock and the nibble rate, not on the decoded values, so it can stay in D1's thread cheaply while the values are decoded elsewhere. ## The instruction-per-second need, with the arithmetic - 68000: 7,670,453 clocks a second. At the 68000's shortest instruction (4 clocks) the ceiling is 1.92 M instructions a second; measured under MAME on Tails and the Music Maker, 2,047,512 instructions in 120 NTSC frames = 2,047,512 / (120 / 59.92) = **1.02 M instructions a second** (game code, with its idle loops). - VDP: 262 lines x 3,420 MCLK x 59.92 frames = MCLK; the visible picture is 256 x 224 (MAME's default display for these machines) or 320 x 224 in H40: 3.4 M to 4.3 M pixels a second, plus the slot-level work megadrive-python already does. - PSG: MCLK/15 = 3.58 MHz, counted in steps of 16: 224 k counter steps a second. - PCM: 1.28 MHz clock; at most 16 k samples a second if the hypothesis in [pcm.md](pcm.md) holds. Negligible. - Compared with a Mega Drive the Pico drops the Z80 (3.58 MHz, roughly 0.5-0.9 M instructions a second) and the YM2612 (about 53 k samples a second x 24 operators). In megadrive-rust-fast's profile the YM2612 was about 30 % of the time and the Z80 catch-ups about 19 % (family records, 2026-10-12, OBSERVED there). **The Pico is a strict subset of the Mega Drive's work.** ## Does the no-JIT path reach real time? `recompile: none` is expected to be enough everywhere; nothing in the Pico needs block caching. | Target | Evidence | Verdict | | --- | --- | --- | | Desktop, Python (PyPy) | megadrive-python makes 40-55 frames a second with the FM generator off and the Z80 still running (its README, measured 2026-09-27 on a shared machine) | close to real time; PAL (50 Hz) likely, NTSC (60 Hz) borderline. HYPOTHESIS until measured; Python is the specification and need not play | | Desktop, Rust | megadrive-rust: 246-376 frames a second with sound (4-6x real time); megadrive-rust-fast x1.56 on top (family records) | real time with a wide margin, plain `x-rust` | | Phone (native, no JIT allowed) | play-md runs the Mega Drive in a phone browser (played on an iPhone, 2026-10-16, family records) | real time without JIT; the Pico needs less | | Browser (wasm) | play-md: about 4.3 ms a frame in headless Chromium, 5.7-6.9x real time in Node (family records) | real time with margin | So the ladder for the Pico is: `pico-python` (the specification), then `pico-rust` (pinning megadrive-rust for the VDP) for play; a `-fast` tier only if a measured target needs it, which on this evidence none does. Threads at the domain channels are not needed.