# Memory map, I/O registers, banking and interrupts Sources: KH (Horton's notes, tier 3), CC65 (`supervision.inc`, `supervision.h`, the `.cfg` files), MAME (closed box). Tags per row. ## The CPU's map | Range | What | Evidence | | --- | --- | --- | | 0000-1FFF | WRAM, 8 KB (zero page, stack at 0100) | DOC CC65 `supervision-128k.cfg` (`RAM start $0000 size $2000`); KH (two 8K SRAMs; his UART at 1FFE/1FFF was decoded by cutting WRAM's chip enable) | | 2000-202F | ASIC registers (table below) | DOC KH, CC65 | | 2030-3FFF | not described | **U1**: open bus, mirrors of 2000-202F, or nothing. Super Kong writes 2030-203F once at start (OBSERVED, MAME trace) | | 4000-5FFF | VRAM, 8 KB | DOC CC65 (`lcd_addr = $4000`, `VRAM start $4000 size $2000`); KH's DMA test wrote 40FF as a VRAM address | | 6000-7FFF | not described | **U2** | | 8000-BFFF | cartridge, 16 KB bank selected by 2026 bits 7-5 | DOC KH "Bankswitching" | | C000-FFFF | cartridge, fixed to the **last** 16 KB of the ROM | DOC KH; CC65's `reset32kcode` comment ("the 32Kbyte image can reside in the top of 64Kbyte and 128Kbyte ROMs") agrees | The cartridge port has A0-A16 (128 KB) and an unused /WR (KH "Cartridge pinout": "could be used to run a simple latch to effect more bankswitching"). CPU A16 is an ASIC pin (KH ASIC pin 26), so the ASIC drives a 17-bit cartridge address: bank number x 16 KB + A13-A0. ### Images larger than 128 KB (census.md) Two NI images exceed what three bank bits reach: **"4 in 1 - Hash Block + Challenger Tank + Brain Power + Jacky Lucky"** (256 KB, not in MAME's list) and **"Journey to the West"** (512 KB, in MAME's list with `supported="no"`). Their mapper is **U3**: a latch on /WR, as KH suggests, is a HYPOTHESIS. A multicart's menu at C000-FFFF that writes a latch would show in a trace of the 4-in-1 (to run in the build; MAME's base driver cannot be expected to run it). Six 32 KB images and 63 of 64 KB fit the plain rule. ## Registers (KH's list, checked against CC65) | Addr | KH name | Meaning (KH) | CC65 name and comment | Agree? | | --- | --- | --- | --- | --- | | 2000 | LCD_X_Size | pixels a line, upper 6 bits used (all games A0h) | `lcd_width` | yes | | 2001 | LCD_Y_Size | lines a field (A0h) | `lcd_height` | yes | | 2002 | X_Scroll | bits 7-2 byte offset, bits 1-0 a 0-3 pixel delay | `lcd_xpos` "in pixel, bit 0+1 not used" | **C3** | | 2003 | Y_Scroll | x 30h added to the start address | `lcd_ypos` "weird" | yes | | 2004-2007 | mirrors of 2000-2003 | | - | | | 2008/9 | DMA source | | - | | | 200A/B | DMA destination (VRAM only) | | - | | | 200C | DMA length | x 16 bytes, 0 = 4096 | - | | | 200D | DMA control | bit 7 starts | - | | | 2010/11 | CH1 (right) frequency, 11 bits | | `sv_audio_right_counter` (word), "frequency=125000/counter" | yes (KH: /(F+1)) | | 2012 | CH1 `?EDD VVVV` | E bit 6, duty bits 5-4, volume 3-0 | `SV_AUDIO_ON = $40`, "bits 0..3 volume" | yes | | 2013 | CH1 length | | "write activates tone for x/60 sec (0 means 256)" | KH: (L+1) x 65,536 clocks (61.04 Hz ticks): **C4** on L = 0 | | 2014-2017 | CH2 (left), same layout | | `sv_audio_left_*` | yes | | 2018/19 | CH3 (sample DMA) start address | | `sv_dma_start` (word) | yes | | 201A | CH3 length | x 16 bytes, 0 = 4096 | `sv_dma_size` "*32 samples" | yes (16 bytes = 32 samples) | | 201B | CH3 control `?BBB LRFF` | bank 6-4, left 3, right 2, rate 1-0 | "bit 0,1 speed: 0 15360, 11 15360/4; bit 2,3 volume" | **C5** | | 201C | CH3 trigger | bit 7 | `sv_dma_on`, "bit 7 true start, false stop" | yes | | 2020 | Controller | active low, `Start Select A B Up Down Left Right` bits 7-0 | `sv_control`, the same bits | yes | | 2021 | Link port DDR | bits 3-0, **1 = input** | `sv_port_r` | **C6** | | 2022 | Link port data | bits 3-0; upper 4 read open bus | `sv_port_w` | C6 | | 2023 | IRQ timer | counts down to 0 and stops; write resets the prescaler; writing 0 fires at once | `sv_timer_count` | yes | | 2024 | read: clear timer IRQ flag | | `sv_timer_quit` | yes | | 2025 | read: clear sample-DMA IRQ flag | | `sv_dma_quit` | yes | | 2026 | System control `BBBS D?IN` | bank 7-5; timer prescaler bit 4 (1 = /16384, 0 = /256); display enable bit 3; bit 2 "?"; IRQ enable bit 1; NMI enable bit 0. **Any write restarts the LCD scan at the top left** | `sv_bank`: `NMI_ENABLE 1, IRQ_ENABLE_TIMER 2, IRQ_ENABLE_DMA 4, LCD_ON 8, TIMER_MODE_240Hz $10` | **C7** on bit 2 (CC65: the sample-DMA IRQ enable) | | 2027 | IRQ status | bit 0 timer expired, bit 1 sample DMA finished | `sv_irq_source`, the same | yes | | 2028 | CH4 (noise) `FFFF VVVV` | | `sv_noise_volume` "and frequency" | yes | | 2029 | CH4 length | | `sv_noise_timer` | yes | | 202A | CH4 control `???N LREP` | | `sv_noise_control` | yes | | 202C-202E | mirrors of 2028-202A | | - | | | 200E/F, 201D-F, 202B, 202F | unused | | - | | Read-back values of each register (which bits read back, which read open bus) are **U4**: KH gives them only for the link port and the IRQ timer ("readable and writable"). ## Interrupts (KH "Interrupts & Bankswitching & System Control") - **NMI** every 65,536 clocks when 2026 bit 0 is set; nothing to acknowledge (CC65's NMI handler just counts). Its phase against reset, and whether enabling it mid-period fires at once, are **U5**. - **IRQ** (2026 bit 1): the OR of the timer flag and the sample-DMA flag (2027), cleared by reading 2024 / 2025. Whether 2026 bit 2 gates the DMA source separately (CC65) is C7. - The timer: 8 bits, counts down at 4 MHz / 256 (15,625 Hz) or 4 MHz / 16,384 (244.1 Hz). CC65 names the slow mode "240Hz" and the fast "15360" (approximations: KH's divisors give the exact values; FITTED by neither). The games idle by polling a zero-page byte the NMI handler changes (OBSERVED: in the three traced games the top opcodes are a `LDA zp / CMP / BEQ` or `DEY / BNE` wait loop). This is what makes the board cheap to run and why the 65C02's `WAI` never matters here (cpu.md).