# Memory, banking and I/O Citations: **TSHM** (TED System Hardware Manual), **SM** (Plus/4 service manual), **TEDX** (TED extra pages: a German memory map), **MOS82** (1982 MOS data catalog), **ACIA** (Rockwell R6551 data sheet), **MAME** (0.285, OBSERVED). ## The rows (machines) | Row | RAM | ROMs | I/O chips beyond TED | Source | | --- | --- | --- | --- | --- | | `plus4` (NTSC), `plus4p` (PAL) | 64 KB (8 x 64Kx1 DRAM) | BASIC 3.5 (U23), KERNAL (U24), 3-plus-1 low/high (U25, U26), PLA (U19) | 6551 ACIA (U3), 6529 user port (U5), 6529 keyboard (U27) | SM parts list; MAME device list | | `c16` (NTSC), `c16p` (PAL) | 16 KB | BASIC, KERNAL, PLA | 6529 keyboard only (MAME lists no ACIA, no second 6529) | MAME `-listdevices c16`; the C16 schematic 251788 exists as GIFs in the same archive folder (not pinned tonight; pin at M8) | | `c116` | 16 KB | as C16 | as C16 | MAME | | `c16_hu`, `c232`, `v364`, `c264` | | prototypes and a Hungarian KERNAL | | MAME (later rows, decision 1) | The C16's 16 KB mirror into the 64 KB space (a fact the KERNAL's RAM test depends on; U8 until the schematic is read). BASIC reports 60,671 bytes free on the Plus/4 (TSHM 2, SM p. 3, and MAME's boot screen) and 12,277 on the C16 (MAME's boot screen, OBSERVED). ## Memory map (CPU view) | Range | With ROM selected ($FF3E) | With RAM selected ($FF3F) | Source | | --- | --- | --- | --- | | $0000-$0001 | 7501 port (DDR, data: cpu-7501.md C1) | same | TSHM 2, 5 | | $0002-$7FFF | RAM | RAM | TSHM 2 | | $8000-$BFFF | low ROM bank (BASIC, function low, cartridge low) | RAM | TSHM 11.2 | | $C000-$FBFF | high ROM bank (KERNAL, function high, cartridge high); character ROM at $D000-$D7FF inside the KERNAL ROM | RAM | TSHM 11.2; TEDX | | $FC00-$FCFF | the KERNAL's banking routines, present whatever bank is selected (while ROM is selected) | RAM | TSHM 11.2 | | $FD00-$FEFF | I/O (below) | I/O | TSHM 2, TEDX | | $FF00-$FF3F | TED | TED | TEDDS | | $FF40-$FFFF | high ROM bank | RAM | TEDX | "A write operation to ROM will always bleed through to underlying RAM" (TSHM 2). TED's own fetches choose ROM or RAM by register 18 bit 2, separately from the CPU (ted.md). ## ROM banking ($FDD0-$FDDF) A write anywhere in $FDD0-$FDDF selects banks by the **address**, not the data (TSHM 11.2): A1:A0 select the low bank (00 BASIC, 01 function low, 10 cartridge low, 11 reserved), A3:A2 the high bank (00 KERNAL, 01 function high, 10 cartridge high, 11 reserved). Up to 64 KB internal and 32 KB cartridge ROM. (OCR of the range reads "$FD['O - !FDI'F"; $FDD0- $FDDF is the reading that fits the rest of the page: re-read at M1, U9.) ## I/O decode | Address | Chip | Source | | --- | --- | --- | | $FD00-$FD0F | 6551 ACIA (A1:A0 select its four registers) | TSHM 7.1 | | $FD10-$FD1F | 6529 user-port SPI: 7 bits for the user port; bit 2 is the cassette **sense** input | TSHM 7.1 | | $FD30-$FD3F | 6529 keyboard SPI: the row (column-select) output for the keyboard matrix | inferred from the MAME trace (writes $FD30 then $FF08) and SM p. 3 ("outputting the row data on the data bus while addressing a particular register in the TED chip"): HYPOTHESIS until the schematic | | $FDD0-$FDDF | ROM bank select (address-decoded latch) | TSHM 11.2 | | $FEC0-$FEDF | the 1551's TCBM interface (on the drive's cartridge, not on the main board) | community knowledge; MAME's c1551 device (drives.md) | | $FF00-$FF3F | TED | TEDDS | The MAME boot trace (OBSERVED) writes `$FD20 <- $09` and `$FD20 <- $89` at cycles 31 and 37, before anything else; no document read assigns $FD20. U10: the PLA decode (the 82S100 dump, 245 bytes, MAME's `251641-02.u19`) or the schematic must say what is there. ## The PLA (U19, 251641-02) An 82S100 FPLA programmed by Commodore (SM parts list). It decodes chip selects (ROMs, I/O pages) from the address, TED's CS0/CS1 and the bank latch. MAME carries its fuse map as a 245-byte image; the No-Intro BIOS zips do not include it. Proposal: like c64-python, **evaluate the PLA from its fuse map as a logic table**, not a hand-written map, once the dump's format is understood (U11; the fuse map is firmware-like and is identified by SHA-1, never committed). ## Keyboard and joysticks TSHM 2 and SM p. 3: keyboard and joystick scanning work by writing the row data and then writing TED's keyboard latch ($FF08), which latches the column lines K0-K7 (TSHM 4: TED pins 15-22 KEYBOARD LATCH 0-7, with active pull-ups). The joysticks are read through the same latch, selected by data-bus bits during the latch write (SM p. 3; exact bits U12). TED's K0 and K1 also carry test functions when driven to about 10 V (K0: system freeze; K1: force NTSC division) (TSHM 4): not emulated, recorded. ## Serial bus and cassette Both are bit-banged through the 7501 port (TSHM 2: "implemented using the zero page ports available on the 7501 and using software control of hardware handshake"); cassette sense on the user-port 6529's bit 2 (TSHM 7.1). The 1531 Datasette has a mini-DIN plug (SM), electrically the C2N's signals. The serial bus is the C64's IEC bus, "except for older peripherals that have a handshake timing problem" (TSHM 2). ## The ACIA and the user port The 6551A (Synertek, SM: "SYP6551A") with a **1.8432 MHz crystal** of its own (SM parts list Y2): its own clock domain, as far as baud rates go. A 6529 gives handshaking. The 6551 is documented in ACIA and MOS82 2-129; the 6529 SPI in MOS82 2-92. ## Expansion port ROM cartridges (two 16 KB halves, "cartridge low/high" banks), the 1551's interface cartridge (TCBM), and MAME's SID cartridge option. All ten No-Intro cartridge images carry "CBM" at offset 7 (census.md), where the KERNAL's cartridge scan is said to look (HYPOTHESIS). ## The chip rule here | Chip | Users in the family | Proposal | | --- | --- | --- | | 6551 ACIA | Plus/4; Oric **Telestrat** (oric-python later row: MAME's telstrat); Apple II Super Serial Card (apple2-python, not proposed tonight) | stays in this board until oric-python's Telestrat row is built; then extract `mos6551-python` (open decision 5) | | 6529 SPI | Plus/4, C16 only | board (`spi6529.py`) | | 6525 TPI | the 1551 only (and the CBM-II, not in the family) | in the drive board (drives.md) | | PLA 82S100 | here; c64-python's PLA is an 82S100 too | board, fuse-map evaluator; a shared evaluator only if both boards land one (decision 6) |