# Memory maps and banking One 16-bit address bus; the CPU and ANTIC are the only bus masters, and ANTIC only reads or refreshes ([AHRM] 2.3). Everything else answers by address. The tables below are DOC unless marked; the register-level facts are [AHRM] 2.3-2.8 and 14.1, [HWM] and [XLA]. ## 400/800 (machine rows `a400`, `a800`) | Range | What answers | Notes | | --- | --- | --- | | $0000-$BFFF | RAM (8K-48K) | RAM above the installed size floats ([AHRM] 2.3: $4000-$BFFF on a 16K 400) | | $8000-$9FFF | right cartridge (800 only) when RD4 is asserted | overlays RAM | | $A000-$BFFF | left cartridge when RD5 is asserted | overlays RAM | | $C000-$CFFF | nothing | floating (on the I/O data bus on the 800) | | $D000-$D0FF | CTIA/GTIA, 32 registers mirrored | main data bus | | $D100-$D1FF | nothing | floating | | $D200-$D2FF | POKEY, 16 registers mirrored | I/O bus on the 800 | | $D300-$D3FF | PIA, 4 registers mirrored 64 times | I/O bus on the 800 | | $D400-$D4FF | ANTIC, 16 registers mirrored | main data bus | | $D500-$D5FF | cartridge control (CCTL) | floating without a cartridge that decodes it | | $D600-$D7FF | nothing | floating | | $D800-$DFFF | OS ROM: floating-point package (2K) | the composite file is $D800-$FFFF, 10K ([AHRM] F.3) | | $E000-$FFFF | OS ROM (8K, two 4K chips) | | **The 800's two data buses** ([AHRM] 2.3, "Floating I/O data bus"): ROM, PIA, POKEY and the cartridges sit on an I/O bus split from the main bus (CPU, ANTIC, GTIA, RAM) by transceivers. The I/O bus is decoded for $C000-$CFFF, $D100-$D3FF and $D500-$FFFF; an unhandled read there returns the I/O bus's own last value, which main-memory cycles do not change. The 400, XL, XE and XEGS have one bus. Programs depend on it: the OS-A/B RAM sizing stops at $C000 because of it, and WarGames checks it ([AHRM] 2.9). The board needs two floating-value latches on the 800 row and one elsewhere. **Floating or pulled up**: XL and some XE machines pull the data bus up ($FF for an unhandled read); the 400/800 and other XEs float, returning the previous cycle's value, including a byte ANTIC just fetched; refresh cycles leave it unchanged; a CPU held by WSYNC keeps re-reading its address, which ANTIC can pick up ([AHRM] 2.3). Which XE units float is U4. **System Reset** on the 400/800 is a key wired to ANTIC's RNMI input: an NMI with NMIST bit 5 set, which the OS treats as a warm start ([AHRM] 2.4). The PIA is reset only at power-on on the 800 ([AHRM] 2.5). ## XL/XE (rows `a1200xl` ... `a130xe`, `xegs`) | Range | What answers (PORTB bit) | Notes | | --- | --- | --- | | $0000-$3FFF | RAM | | | $4000-$7FFF | RAM, or the 130XE's extended-memory window (bit 4 = 0, CPU; bit 5 = 0, ANTIC) | bank by bits 2-3 | | $5000-$57FF | self-test ROM when bit 7 = 0 **and** bit 0 = 1 | it is the ROM's $D000-$D7FF part, remapped; beats the extended window, writes discarded | | $8000-$9FFF | RAM, or a cartridge's RD4 area | | | $A000-$BFFF | cartridge (RD5) > BASIC (bit 1 = 0) > XEGS game ROM (bit 6 = 0) > RAM | priority order is [AHRM] 2.6 | | $C000-$CFFF | OS ROM (bit 0 = 1) or RAM | | | $D000-$D7FF | hardware, as on the 800; $D100-$D1FF and $D600-$D7FF are the PBI's | cannot be banked out | | $D800-$FFFF | OS ROM (bit 0 = 1) or RAM; a selected PBI device's ROM overlays $D800-$DFFF | | - [XLA]'s "XL PORTB ($D301) bit assignments" (OCR text) agrees: bit 0 = 0 disables the OS ROM ($C000-$FFFF except the $D000-$D7FF I/O), bit 1 = 0 enables BASIC, and LED bits on the 1200XL. - Port B bits 0, 7 (and 1, except on the 1200XL) have pull-ups, so the PIA's reset to all inputs maps the OS in and BASIC and self-test out ([AHRM] 2.6). Unused bits **float** and decay from 1 to 0 over about 100-500 ms after being switched to input (measured on real units, [AHRM] 2.5): 1200XL bits 1-6; 600XL/800XL/65XE bits 2-6; 130XE bit 6; XEGS bits 2-5. A board needs a per-bit decay with a configurable time (U3). - Writes to an address mapped to ROM are dropped; nothing writes through to the RAM below ([AHRM] 2.6). - The 130XE refreshes main and extended banks together on any access ([AHRM] 2.3). - **XL/XE reset** is a real line: the Reset key resets the 6502, ANTIC, FREDDIE and the PIA, so banking returns to its default; RNMI is tied high ([AHRM] 2.4). - **TRIG3 is cartridge sense** on the XL/XE (RD5 into GTIA's T3; reads 1 with a cartridge mapped, 0 when banked out or absent; subject to GTIA's trigger latch), and **TRIG2 is keyboard sense** on the XEGS ([AHRM] 2.8, 6.11). - MAME's a800xl boot writes PORTB = $FF, $FF, $FF, $FD early, $7D at about cycle 1.73 M (self-test ROM in), then $FD again (OBSERVED, [mame-oracle.md](mame-oracle.md)): the XL OS v2 maps the self-test region during start-up. ### Extended memory beyond the 130XE [AHRM] 2.7 Table 1 lists the common expansions (RAMBO 192K-1088K, COMPY 320K/576K, ...) by their PORTB banking bits. Proposed: the 130XE row first; the others as a machine-row field (banking bits, separate ANTIC access yes/no) with no milestone of their own (decision D7). ## Where it lives in the board `memory.py`: one decoder per machine family (400/800, XL/XE), a function from (address, ANTIC or CPU, PORTB outputs, RD4, RD5) to the device; the data-bus latches; the PORTB decay. The cartridge sits behind a socket that drives RD4/RD5 and decodes $8000-$BFFF and $D500-$D5FF ([cartridges.md](cartridges.md)).