# Memory map and I/O ports Evidence tags as the family uses them: DOC (a document), OBSERVED (seen in a run of MAME, a detector), HYPOTHESIS. Citations as in [start-here.md](start-here.md). ## Memory (home unit) | Range | Read | Write | Source | | --- | --- | --- | --- | | 0000-1FFF | BIOS ROM (8 KB) | magic write to X+4000 | DOC: SYS 82 | | 2000-3FFF | cartridge ROM | magic write to X+4000 | DOC: SYS 82 | | 4000-4FFF | screen RAM (low resolution: 4 KB; 4080 bytes displayed, 16 scratch) | plain write | DOC: SYS 82, 85 | | 5000-7FFF | expansion (low-resolution unit) | | DOC: SYS 82 | | 8000-FFFF | expansion (all units) | | DOC: SYS 82 | - Magic RAM "is the same size as standard screen RAM" (SYS 82): in a 4 KB home unit, which magic addresses reach real RAM, and what a magic write to 1000-3FFF does, is **U1** in the brief (the memory-map figures on SYS 83-84 are drawings without text in the retype; read them in the original scan when wiring). - Screen layout: 40 bytes a line, 102 lines, byte 0 top left, addresses increasing in scan order; within a byte the pixel in bits 1-0 is the **rightmost** (SYS 85). - Expansion RAM boards (Blue RAM, Viper, R&L 64K, Lil' White RAM) are cartridge- or expansion-port devices in MAME's software and device lists (`astrocade_br4/16/32`, `astrocade_vs1`, `astrocade_rl64`, `astrocade_lwr`: OBSERVED, `mame -listxml`); they are later sockets, not milestone work. ## Output ports (low address byte; SYS 106) | Port | Register | Chip | | --- | --- | --- | | 00-07 | colour registers 0-7: bits 7-3 colour, bits 2-0 intensity (SYS 88) | Data | | 08 | low/high resolution, bit 0 (not reset at power-up: software must set it before any RAM use, SYS 81) | Data + Address | | 09 | bits 5-0 horizontal colour boundary, bits 7-6 background colour (SYS 88-89) | Data | | 0A | vertical blank line (low resolution: line in bits 7-1) (SYS 90) | Data + Address | | 0B | colour block transfer: `OTIR` with C=0B, B=8; first byte to register 7 (SYS 88) | Data | | 0C | magic register (SYS 94) | Data | | 0D | interrupt feedback (the vector byte) (SYS 92) | Address | | 0E | interrupt enable and mode: bit 0 light-pen mode, bit 1 light-pen enable, bit 2 screen mode, bit 3 screen enable (SYS 92) | Address | | 0F | interrupt line (low resolution: line in bits 7-1) (SYS 93) | Address | | 10 | master oscillator | I/O | | 11-13 | tone A, B, C frequency | I/O | | 14 | vibrato: bits 5-0 depth, bits 7-6 speed | I/O | | 15 | bits 3-0 tone C volume, bit 4 noise modulation, bit 5 noise to output | I/O | | 16 | bits 3-0 tone A volume, bits 7-4 tone B volume | I/O | | 17 | noise volume (8 bits; the upper 4 are the noise's audio volume) | I/O | | 18 | sound block transfer: `OTIR` with C=18, B=8; first byte to port 17, last to 10 (SYS 104) | I/O | | 19 | expand register: bits 1-0 the pixel for a 0 bit, bits 3-2 for a 1 bit (SYS 95) | Data | **High-byte decoding (OBSERVED):** in MAME's trace of the BIOS the block transfers appear as port writes 0818, 0718, ... 0118 and 070B, ... 000B: the chips take the register number from the high address byte that `OTIR` puts out (B after its decrement). SYS's description of `OTIR` to port 18 sending "the data pointed to by HL ... to port 17H and the next 7 bytes ... to ports 16H through 10H" agrees (DOC). So a plain `OUT (18),A` writes the register the accumulator's high-byte position selects: **U2** (how ports 0B and 18 behave outside `OTIR`). ## Input ports (SYS 107) | Port | Register | | --- | --- | | 08 | intercept feedback (reading clears bits 3-0; SYS 100) | | 0E | vertical line feedback (light pen line; low resolution in bits 7-1) | | 0F | horizontal address feedback (light pen; subtract 8 for the pixel) | | 10-13 | player 1-4 hand control switches (five switches; not debounced; 0 when open) (SYS 101) | | 14-17 | keypad columns 0 (right) - 3 (left), bits 5-0 (SYS 101) | | 1C-1F | the four pots, 8-bit A/D (0 fully counter-clockwise) (SYS 101) | Reads from 10-17 have their own bus timing (SYS 128 versus 129: "I/O read from port 10H-17H" and "from other than port 10H-17H"); the timing diagrams are drawings to read in the scan.