# The sub-CPU (80C49): keyboard, clock, timers, cassette, TV ## What it is An Intel MCS-48 family microcontroller with mask ROM, running the keyboard scan, the real-time clock and calendar, eight software timers, the cassette deck's motor and sensors and the TV control (SX1 ch. 4, "サブ CPU 80C49"; the I/O map's 1900h entry). The Z80 talks to it only through **one data port at 1900h** and handshake bits on the 8255②: SX1 pp. 16-17 draw the interface from the 80C49's side (it sees the Z80 as an 8255-like peripheral whose port A is the data path), and "the only port that means anything to the Z80 is 1900h". The etiquette (SX1 ch. 4 §0): before each byte the Z80 checks 1A01h bit 6 (the sub-CPU's busy or ready flag) and only then reads or writes 1900h. **No dump of its ROM exists.** MAME 0.285 lists the part for every X1 driver as `80c48`, 4 KB, "NO GOOD DUMP KNOWN" (census.md), and still boots the IPL: MAME models the sub-CPU's behaviour, not its program (OBSERVED: the IPL's `E4h`/`00h` command pairs to 1900h and the polling of 1A01h, 27,626 pairs in 3 s, while "IPL is under preparing" shows). So the board's sub-CPU **must be high-level**, written from SX1's command table and the user's manuals, whatever core the family has. C4: the part. SX1 says 80C49 throughout ch. 0 and ch. 4; MAME names the ROM region `80c48`. The 8049 has 2 KB of ROM and the 8048 1 KB, so a 4 KB region fits neither; a 4 KB part would be an 8050-class device or MAME's placeholder size (HYPOTHESIS). Decide from a board photograph (U9); it matters only if a dump ever appears. ## The command set (SX1 table 4-1, printed p. 79) Each command is one byte from the Z80; the sub-CPU then sends or receives a fixed number of bytes (send the wrong count and it misbehaves: SX1 p. 79). | Command | Function | Direction, bytes | Notes | | --- | --- | --- | --- | | D0h-D7h | set timer 0-7 | Z80 to sub, 6 | | | D8h-DFh | read timer 0-7 | sub to Z80, 6 | | | E3h | game-key read | sub to Z80 | turbo only; in keyboard mode A the data is 00h (p. 79); sent before `RETI` in the key interrupt routine to read game keys (ch. 4 list 4-8) | | E4h | set keyboard interrupt vector | Z80 to sub, 1 | vector 00h disables the interrupt (p. 79); MAME's IPL run writes E4h, 00h | | E6h | key read (function part, ASCII) | sub to Z80, 2 | | | E7h | TV control | Z80 to sub, 1 | | | E8h | TV control read-back | sub to Z80, 1 | the last code sent to the TV | | E9h | cassette deck control | Z80 to sub, 1 | the `CMT=` codes | | EAh | cassette deck status | sub to Z80, 1 | | | EBh | cassette sensor read | sub to Z80, 1 | | | ECh | calendar set | Z80 to sub | (the OCR loses the byte count: read from the scan) | | EDh | calendar read | sub to Z80 | list 4-x uses ED then reads the date | | EEh | clock set | Z80 to sub, 3 | | | EFh | clock read | sub to Z80, 3 | | The OCR of table 4-1 is damaged in places (E3h-E5h, ECh-EEh); every row is to be checked against the scan before it becomes a constant. ## The keyboard interrupt The sub-CPU raises the Z80's /INT with the vector set by E4h when a key changes (SX1 ch. 4, list 4-8: vector 54h, handler at E060h; "on the turbo, send E3h before RETI and the game keys can be read too"). It takes part in the Z80's mode-2 acknowledge like a daisy-chain device (it must, to place a vector); its position in the chain relative to the CTC is U10. ## Timing (unknown, and it matters) The 80C49 takes time to answer, and software that ignores the busy bit fails: that is why SX1 dwells on the etiquette. With no ROM the delays cannot be derived; they have to be **FITTED** from observation (MAME's model: how long 1A01h stays busy after each command, as a detector) and tagged so. This is the X1's chief non-hardware-sourced constant (U11). ## Core reuse (decision 2) `../mcs48-python` is Phase 0 only (no core) and, with no firmware, could run nothing. Recommend **no MCS-48 core in the X1**: a high-level `SubCpu` class in the board with the command table above, a keyboard matrix, an RTC and the eight timers, its response delays in one FITTED table. Revisit only if the 80C49's ROM is dumped.