# Handoff: real-console timing for the 32X work For the session building the 32X emulator and rick-roll-32x. A 32X sits on a Mega Drive, so everything here about the 68000, Z80, VDP, YM2612 and the bus still holds under it. None of it has been checked with a 32X attached: treat it as the base system's behaviour, not the 32X's. **Private.** Nothing from this repo is to be posted publicly, and none of it goes to BlastEm (they decline AI-assisted contributions; comparisons with BlastEm stay internal). ## Where the numbers come from - One borrowed NTSC Genesis, Model 1601, hardware version A1 (VA unknown), through a flash cart (an EverDrive-MD V3 clone). One console: ranges are this unit's, not the population's. - The same ROM (`src/`, built by `build.py`) also runs on our emulators (the pin2 boards: megadrive-rust, megadrive-rust-fast, megadrive-python), BlastEm and the Nuked-MD die simulation (`NMD_DUMP_RAM` dumps the report). The console decides; the die is next best. - `hardware/reference.json`: the console's range for every metric, runs 3-11. `hardware/card*/*.SRM`: the raw saves. `hardware/card3/NEW6.SRM` is a 50-cycle long run, `NEW8.SRM` a 300-cycle one. - Reading them: `python tools/decode.py SAVE` (per-test report), `python tools/soak.py SAVE [--series|--csv OUT|--ref]` (long-run totals and time line), `python tools/hwref.py check SAVE` (any other report against the console's ranges). Test list and units: README.md. ## Findings that matter for an emulator 1. **WEDG locks the console for good.** Set the DMA registers ($93-$97) without starting a DMA, then send an ordinary VRAM write command: the 68000 stalls permanently in the command's second word. RESET does not free it; only power does. The die does the same; every emulator we tried (ours, BlastEm) carries on. A real 1-word DMA beforehand clears it (`dma_clean` in `src/tests.s`). Worth emulating, and worth avoiding in the cart's own code. 2. **RESET restarts the 68000's work-RAM refresh.** After a RESET press the first refresh comes about 800-980 MCLK after the first instruction. Our boards use 896 MCLK after the pulse; the console fits ~1,554-1,610 or ~2,436-2,492 better. Open. 3. **YM2612 status on ports 1-3 fades, and the fade depends on temperature.** After a write the status reads back through ports 1-3 for a while, then fades. Cold: ~1,820 lines. Warm: fit 356 + 1043·e^(-t/1.75 min) + 855·e^(-t/12 min) lines over the first ~50 min; after many hours on it reads ~280. Anything that reads YM status other than at port 0 depends on how long the console has been on. Our boards now use 4,000,000 MCLK. NEW8 (300 cycles, 433 min, `6aa3182`): the console was already warm, left on with no cart, in a cold early-morning room that warmed during the run. 280 lines in the first cycle, then flat at 264-276 for 7 h, drifting down slowly at the end as the room warmed. Once warm the value holds and does not keep decaying with time on. The late drift fits "warmer means a shorter fade". 4. **Z80 cartridge reads cost the 68000 more than our arbiter says** (ZRO1/ZRO2, ZSW1, ZSW2). Not one constant: the per-read cost depends on the phase. The arbiter's constants (`arbiter.rs`: CUTOFF 21, GRANT_GAP 17, IDLE_GRANT 29, OWN_CYCLE 29, RELEASE 37, RESUME 25, MIN_WAIT 2) need a fit against ZSW2's phase walk. 5. **DMA.** Console pace from a fit over 1-512 words: 68000-to-VRAM 33.2-33.5 MCLK/word with ~2,900-3,000 MCLK start-up (DMPR from ROM, DMPW from work RAM); to CRAM and VSRAM 17.22-17.29 MCLK/word with ~2,730-2,746 start-up (DMPC, DMPS). VRAM fill and copy (DFIL, DCPY) are new and not yet run on the console. Our board's start-up runs 15-35 MCLK short. Rare ~3,000 MCLK "outliers" are not DMA: an HV read landing as V steps (H $A4 in H40) can give the new V with the old H, a whole line late. The console does it too (run 4, DMPR 202: $F0ED to $F1A4, 6,392 MCLK), so measure across the V step with care. 6. **VINT on our board is ~46 MCLK early**; **VRAM reads per frame (RDV1) are 4-9 short** on the board (console 40,702-40,704), and 12 short in H32 against the die (RDV3). 7. **First die-vs-board differences in the third pass** (console: NEW8. The die is right on ZINC (console 83-87, die 84-86, board 110), HINC (226/113/29/3 on all three), RDV3 (console 37,097-37,104, die 37,102-37,104) and ACC1/WRV1 (within 1). SPOV: the console reports a fixed value every cycle where the die never sets the flag in the window; not yet converted to a line): the Z80 interrupt is held longer on our board (110 against 86 retakes of a 33-T handler per 16 frames, ZINC); the first HINT lands ~11 H steps earlier on the board (HINP); the sprite overflow flag sets on line 99 on the board but not in the window on the die (SPOV). YM timers on our board: A 20,192 MCLK (book 20,160), B 32,246 MCLK (book 32,256). Smaller console ranges (68000 loops, Z80 RAM vs ROM, idle loops, line reads): see reference.json; names are explained in README.md. ## Coming - Done: the 300-cycle warm run, `hardware/card3/NEW8.SRM` (all 66 tests, 300/300 cycles, 433 min). Apart from the YM fade, every metric shared with NEW6 agrees to within a cycle or two. - Still to do: the power-on check (off then straight on while warm: does the YM fade follow time since power-on or heat?). NEW8 doesn't answer it, because the console was never power-cycled. Planned: a cold-start long run, then off and straight back on while warm. - The cart can take more tests. If 32X work needs a base-system timing measured, add it to `src/main.c` (plans) / `src/tests*.s` (pieces); die-check a new group before it goes on the console (`build.py -DFIRST_TEST=n -DLAST_TEST=m`), since a hang costs a console session. ## Units and conventions MCLK = 53.693175 MHz NTSC master clock; a 68000 cycle is 7 MCLK, a Z80 cycle 15. H40: 210 H steps a line of 3,420 MCLK, the cart keeps half steps. H32: 171 steps of 20 MCLK. NTSC V counter jumps $EA to $E5. Board constants are what our emulators do today, not the truth.