# The memory map, the I/O block and the interrupts Three kinds of statement are kept apart here: - **DOC (PICODOC)**: notaz's Pico doc (2008), which says of itself that it was "based on information obtained by reverse engineering the game ROM images and without performing any hardware tests". It is the only register map there is, and it is not hardware-corrected. - **OBSERVED (games under MAME)**: what five cartridges did to the I/O block in MAME 0.285, logged by `scripts/mame_trace.py` ([mame-oracle.md](mame-oracle.md)). What the *game* writes and when is software behaviour and is reliable; what MAME *returns* is tier 5 and decides nothing. - **U/C numbers** refer to the unknowns and contradictions in [handoff-brief.md](handoff-brief.md). ## The 68000's space | Range | What | Evidence | | --- | --- | --- | | $000000-$3FFFFF | cartridge ROM | DOC; "Might actually smaller, games are usually 512KiB" | | $400000-$7FFFFF | nothing known | U1 | | $800000-$80001F | the Pico I/O block (below) | DOC; OBSERVED (every game logged uses it) | | $800020-$BFFFFF | nothing known; the Mega Drive's $A00000-$A1FFFF (Z80, I/O chip, TMSS, arbiter) is absent | DOC ("lacks Axxxxx area"); what a read there returns is U1 | | $C00000-$C0001F | the VDP | DOC; "may be mirrored elsewhere" (U2) | | $FF0000-$FFFFFF | 64 KB work RAM | DOC; "may be mirrored elsewhere" (U2) | Every game logged boots from the vectors at $000000 with the header at $100 as a Mega Drive cartridge does; the Copera's own cartridges do not (their header area is blank and the reset vector is SP=$00000000, PC=$00000400: [census.md](census.md)). ## The I/O block, byte by byte All registers sit on odd bytes (the 68000's lower data lane) except the PCM pair, which are words. MAME's taps report word offsets with a byte mask; the table gives byte addresses. | Address | Access | PICODOC's description | Seen in games under MAME | | --- | --- | --- | --- | | $800001 | R | version: bits 6-5 = 00 Japan, 01 Europe, 10 USA, 11 unknown | not read by the five games logged | | $800003 | R | buttons, 0 = pressed: bit 0 up (white), 1 down (orange), 2 left (blue), 3 right (green), 4 red, 5-6 unused?, 7 pen button | read every frame; MAME returns $9F idle (bits 5-6 read 0: U6) | | $800005/$800007 | R | pen X, high then low byte | read every frame or twice a frame | | $800009/$80000B | R | pen Y, high then low byte | read with X | | $80000D | R | page register: one bit per uncovered sensor; $00 closed, $01, $03, $07, $0F, $1F, $3F pages 1-6 | read every frame; MAME returns $92 (`picou`, `picoj`) and $33 (`copera`) with its inputs idle (C2) | | $80000F | ? | not described | read once by the Copera's Melody Land (U7) | | $800010 | R/W word | PCM data: a read gives the free bytes in the FIFO; a write puts data in | Sonic's Gameworld writes words after reading it (MAME returned $3B3B) | | $800012 | R/W word | PCM control: write `?p?? ???? ???? ?rrr`, p "enable playback?", r "sample rate / PCM data type?" (0 = 8 kHz 4-bit ADPCM?, 1-7 16 kHz variants?); a read with bit 15 clear means "busy" | the sequence written is $8000, $0880, then $0840, $4840 around the data; the game polls bit 15 (C3) | | $800017 | W | not described | written once at start-up with $40 by Sonic's Gameworld (US PAL and Japanese) (U8) | | $800019, $80001B, $80001D, $80001F | W | games write 'S', 'E', 'G', 'A'; "some sort of TMSS equivalent" | every game logged writes them once, from its start-up code (`move.l #$53454741,D0` at $00020C in Tails and the Music Maker) | ## Interrupts (DOC: PICODOC, hedged in the original) | Level | PICODOC | | --- | --- | | 2 | "seems to be available, but most games put empty handlers here" | | 3 | "PCM interrupt? Probably occurs when PCM hardware needs more data" | | 4 | "horizontal interrupt? Not widely used" | | 5 | "definitely used for something, but many games work without it" | | 6 | the vertical interrupt | On a Mega Drive the VDP alone drives the 68000's IPL lines and produces only levels 2 (external), 4 and 6. Levels 3 and 5 cannot come from the VDP's encoding, so on the Pico something else (the 315-5769 or 315-5640, HYPOTHESIS) merges at least one more source onto IPL. How, and what level 5 is, are U4. This is the one place where a Pico board cannot treat the VDP as the only interrupt source, which matters for the socket question in [shape.md](shape.md). ## Timing No measurement of the Pico's bus exists. Whether its 68000 sees the Mega Drive's cartridge-refresh stall, how many wait states the I/O block costs, and whether VDP DMA timing equals the Mega Drive's are all unknown (U9). Until evidence arrives the board should take the Mega Drive's figures from megadrive-python, tagged HYPOTHESIS ("same VDP part, same divider"), and say so in each constant.