# The three Z80s and the RAM two of them share ## What is known | Fact | Evidence | | --- | --- | | Three Z80s: main, sub, sound | DOC: SCH-TNK3 sheet "CPU" (A5001 UC02 1/3) shows Z80s at 4D and 2D, each with three 27128 program ROMs (4E/4G/4H and 2E/2G/2H); sheet "SOUND, I/O" (A5001 UP04) shows the sound Z80 at 8F with two 27128s (6E, 6F) and one HM6116 RAM (4F). OBSERVED: `mame -listxml` | | Clocks: 3.35 MHz main and sub on the 1985-86 boards, 4 MHz on the 1987-88 ones; sound 4 MHz on all | OBSERVED (MAME only). The crystals and dividers are on SCH-TNK3 but not yet read (U1) | | The main and the sub see the same video, sprite and work RAM | OBSERVED: MAME's maps share `bg_videoram`, `spriteram`, `tx_videoram` (and on psychos/gwar `sharedram`) between `:maincpu` and `:sub` ([boards.md](boards.md)) | | On the A5001 family the two CPUs decode the shared RAMs at different addresses, and the sub has 2 KB of its own at $F000-$F7FF | OBSERVED (MAME `tnk3`, `athena` maps) | | Each CPU signals the other through one address: main $C700, sub $C000 (map B); the sub has $C700 too on map A | OBSERVED (MAME maps: read and write handlers at those addresses) | | At reset the sub takes an NMI almost at once and its handler at $0066 writes $C000 first; the main's boot code writes $C700, then polls it (`ld a,($C700)` at $0088, $0DDA) | OBSERVED: MAME traces `ikari-sub`, `ikari-main` (3 frames each) | | The sound CPU reads its command at $E000 (map B) and has a read/write port at $F800 (status or acknowledge) | OBSERVED (MAME map); the meaning is HYPOTHESIS until the schematics are read | ## What is not known, and why it matters - **U2: how two Z80s reach one RAM.** Possibilities: the CPUs are clocked in antiphase and the RAM is fast enough to serve both (no waits); or one CPU is held with WAIT (or BUSREQ) while the other is in the RAM; or the RAM is split so each half is local most of the time. MAME's maps say nothing about it (a MAME map has no timing). It decides whether a cycle-exact board needs **z80-python to stretch a bus cycle**: z80-python's README lists "cycle-accurate bus cycles, contention, WAIT, BUSREQ, or pin timing" outside its scope. If the boards use WAIT, that is a core corner to raise on z80-python (a per-access wait-state callback, as the charter's "boards are where cores' corners are found" asks), and open decision 3 applies. The answer is on SCH-TNK3's CPU sheet: the control logic around 3A/3B/4A/4B and the buffers 1A/1B/1C/2B/2C (component labels legible; pin-level reading not done in Phase 0). - **U4: the CPU-to-CPU signals.** Which line each write or read raises or clears (NMI seen on the sub in MAME; the main's mechanism unknown), whether reading acknowledges. - **U5: the sound latch and its handshake.** Who clears the latch, whether the sound CPU's NMI or INT is the doorbell, and what the main reads back (MAME's $F800 port). ## How the specification should hold them The main and the sub share memory on every access, so they are **one domain** in the charter's sense (tightly coupled processors usually stay one), stepped in a defined interleaving: the order of record is per bus cycle if U2 says the RAM is time-shared, per instruction otherwise ([domains-and-speed.md](domains-and-speed.md)). The sound CPU is its own domain; the latch and the status port are its channel.