# Memory map, decoding, colour RAM, open bus and the expansion configurations Source tags: **PRG** the Programmer's Reference Guide (printed page), **SCH-E** the "Schematic Main Logic Version E" (1980, read from a 300 dpi render of the pinned scan), **TM** the Technical Manual PN 990440, **VDS** the 6560/6561 data sheet (page = scan number), **VICI** Mäkelä's VIC-I document, **VTP** a VICE-testprogs program (its readme). Evidence tags as the methodology's: DOC, MEASURED, TEST ROM, OBSERVED, HYPOTHESIS. ## The CPU's map | Range | What | Selected by (SCH-E) | Evidence | | --- | --- | --- | --- | | $0000-$03FF | 1K RAM (two 2114 4-bit chips on SCH-E) | the RAM decoder (74LS138 UC1, VA10-VA12) | DOC (PRG p. 115, SCH-E) | | $0400-$0FFF | expansion RAM1-RAM3 (1K each), empty on a bare machine | /RAM1-/RAM3 at the expansion port | DOC (PRG p. 242) | | $1000-$1FFF | 4K RAM (eight 2114s on SCH-E); screen at $1E00 on a bare machine | UC1 | DOC | | $2000-$7FFF | expansion BLK1-BLK3 (8K each, RAM or ROM) | the block decoder 74LS138 UB1 (CA13-CA15, enabled by SΦ2) | DOC | | $8000-$8FFF | character ROM (4K, a 2332 at UC7 on SCH-E) | BLK4 with A12 = 0 | DOC; the A12 split is HYPOTHESIS from the drawing | | $9000-$93FF | I/O0: the VIC ($9000-$900F) and the two VIAs ($9110, $9120) | UD2 output 4 | DOC (PRG p. 175-177; SCH-E) | | $9400-$97FF | I/O1: colour RAM, 1K x 4 (a 2114, UC3) | UD2 output 5 | DOC | | $9800-$9BFF | I/O2, at the expansion port (C3) | UD2 output 6 | DOC (SCH-E, PRG p. 177) | | $9C00-$9FFF | I/O3, at the expansion port | UD2 output 7 | DOC | | $A000-$BFFF | BLK5: cartridge ROM (the autostart block) | UB1 output 5 | DOC | | $C000-$DFFF | BASIC V2 ROM (901486-01) | UB1 output 6 | DOC | | $E000-$FFFF | KERNAL ROM (901486-06 NTSC, -07 PAL) | UB1 output 7 | DOC | **The I/O decoder** (SCH-E, UD2, 74LS138): A = CA10, B = CA11, C = CA12, G1 = CA15, /G2A = CA14, /G2B = CA13: enabled for $8000-$9FFF, outputs 4-7 are the four 1K I/O blocks, outputs 0-3 unconnected. **The VIAs** (SCH-E): register select RS0-RS3 = CA0-CA3; /CS2 = I/O0 on both; CS1 = CA4 on UDE8 (VIA1, $9110) and CA5 on UDE7 (VIA2, $9120). So within $9000-$93FF a VIA answers wherever its address bit is set, and **both answer where CA4 and CA5 are both 1** ($9130, $9170, ...): U6. **The VIC's chip select** (VDS p. 9): A13 = A11 = A10 = A9 = A8 = 0 and A12 = 1 on the VIC's own 14-bit address bus; A4-A7 are not decoded, so the 16 registers repeat through the VIC's $1000-$10FF, which is the CPU's $9000-$90FF (DOC; the mirror's effect where a VIA also answers, $9010-$903F and so on, is U6). ## What the VIC sees The VIC has a 14-bit address bus and a 12-bit data bus (VDS p. 9). On the VIC-20 the VIC's A13 is the inverse of the CPU's A15 (VICI; PRG p. 175's table for $9005), so the VIC's $0000-$1FFF is the CPU's $8000-$9FFF (character ROM, I/O, colour RAM) and the VIC's $2000-$3FFF is the CPU's $0000-$1FFF. **The VIC cannot see expansion memory**: "the VIC chip doesn't have access to that memory" (PRG p. 83, DOC); the $9005 table marks the VIC's $2400-$2FFF (CPU $0400-$0FFF) "unavail." (PRG p. 175). Its data lines D8-D11 read colour RAM in the same fetch as the screen byte (VDS p. 9; SCH-E shows UC3 on VD8-VD11). Which address the colour fetch uses is `$9400 + (screen address & $3FF)` with $9002 bit 7 choosing $9400 or $9600 (PRG p. 175 "$9400 with additional RAM at blk 1, $9600 normal": DOC). ## Phases: no stalls The VIC fetches during phase 1 and the CPU uses phase 2; the VIC "performs all memory accesses without blocking the processor, using the interleaved bus" (VICI) and the data sheet lists "no CPU wait states or screen hash" (VDS p. 1). The 6502's RDY is not driven by anything on SCH-E (pulled up to +5 V through 22K, as read from the 100 dpi render). **So the board has no DMA, no RDY and no cycle stealing**, unlike the C64. ## Open bus and unconnected reads - "By reading from unconnected address space, such as $9100-$910f, you can read the data fetched by the videochip on the previous clock cycle" (VICI, DOC from measurement on real chips). The board keeps the last VIC fetch as the open-bus value. - Colour RAM is 4 bits wide: what a CPU read returns in bits 4-7 is not documented by Commodore. Hannu Nuotio's `VIC20/unconnected` (VTP, 2009) tests the unconnected bus; its readme gives no hardware result, so it is a detector until one is found (U5). - When the beam is outside the text window the VIC "reads from $001c for most time (some videochips read from $181c instead)" (VICI): this decides what open bus shows in the border (U5). ## Power-on RAM `VIC20/raminitpattern` (VTP) collects RAM dumps from named real machines (serial numbers, RAM chip makers): the pattern differs between machines and RAM makers. The board offers a selectable pattern (one dump as the default, all-zero and random as options) and marks the default as one machine's MEASURED pattern, not "the" VIC-20's (U7). ## Expansion configurations (machine-table rows) What BASIC reports and where the KERNAL puts the screen depend only on which blocks hold RAM (PRG p. 117-118; the KERNAL's RAM test is code in the ROM, run as is): | Row | RAM present | Screen (KERNAL) | BASIC free | Real expansion | | --- | --- | --- | --- | --- | | `unexpanded` | $0000-$03FF, $1000-$1FFF | $1E00 | 3583 bytes (MAME 0.285 run, OBSERVED) | none | | `+3k` | + $0400-$0FFF | $1E00 | "6.65K" (PRG p. 116) | VIC-1210 3K, Super Expander (3K + ROM at BLK5) | | `+8k` | + BLK1 | $1000, colour at $9400 | (PRG p. 117 note) | VIC-1110 8K | | `+16k` | + BLK1-2 | $1000 | | VIC-1111 16K | | `+24k` | + BLK1-3 | $1000 | | combinations / an expander | | `+35k` | + RAM1-3, BLK1-3, BLK5 | $1000 | | modern RAM boards; BASIC uses only its continuous area (PRG p. 243) | The 3K area is not used by BASIC when block RAM is present ("BASIC demands a continuous area", PRG p. 243). A row is a set of blocks; the board's memory is built from the set, nothing hard-coded per row. Cartridges add ROM blocks on top (expansion-cartridges.md). ## Unknowns and conflicts this page raises - U5: the CPU's view of colour RAM's upper nybble and the VIC's idle fetch address. - U6: both VIAs selected at once ($9130), and the VIC/VIA overlap in $9010-$90FF. - U7: power-on RAM pattern. - C3: where I/O2 lives: **$9800** by the decoder on SCH-E and PRG p. 177's map; the PRG's own pin table says "I/O block 2 (located at $9600)" (p. 243), and Ward Shrake's pinout notes say "starting at $9130" and "$9140" for I/O3. The schematic decides: $9800 and $9C00.