# Memory map and I/O Sources: **KH** = Kevin Horton, "Gamate Inside" V1.00 (2016-06-29), "Address Map" and the sections named; **CC65** = cc65's `include/gamate.h`, `cfg/gamate.cfg` (zlib; based, it says, on PeT's technical reference); **MAME** = MAME 0.285 run as a closed box (mame-oracle.md). KH measured on real units; CC65 is a toolchain's view; MAME is a model. ## The CPU's 64 KB (KH) | Range | What | Evidence | | --- | --- | --- | | 0000-1FFF | 1 KB RAM, mirrored 8 times | DOC (KH); CC65 "0000-03ff is RAM" agrees | | 2000-3FFF | peripheral space, unused; /PERIPHERAL (cart pin 34) low here while phi2 high | DOC (KH, pinout) | | 4000-43FF | sound: the AY-compatible block's registers (sound.md); **reads are open bus** | DOC (KH) | | 4400-47FF | write: UART TX data; read: the pad (active low) | DOC (KH); CC65 `JOY_DATA 0x4400` | | 4800-4BFF | read: UART RX data (link-and-pad.md) | DOC (KH) | | 4C00-4FFF | any access clocks one TX bit out | DOC (KH) | | 5000-53FF | LCD controller, 8 registers, mirrored (lcd.md) | DOC (KH); CC65 `LCD_BASE 0x5000` | | 5400-57FF | reads external space, usually FFh | DOC (KH) | | 5800-58FF | reads open bus; **a write with bit 5 set locks the system up** | DOC (KH) | | 5900-59FF | written; no effect seen. The BIOS writes it 3 times at boot | DOC (KH); OBSERVED (MAME trace, both BIOSes) | | 5A00-5AFF | bits 1-0 read 11b, bits 7-2 open bus (reads 5Bh) | DOC (KH) | | 5B00-5FFF | open bus | DOC (KH) | | 6000-DFFF | cartridge, 32 KB window; /CE (cart pin 26) low here while phi2 high (cartridges.md) | DOC (KH) | | E000-FFFF | 4 KB BIOS inside the ASIC, repeated twice (bios.md) | DOC (KH) | **Open bus:** "reading an address will return the upper byte of the address usually" (KH): the last byte on the bus is the address high byte of the operand fetch. A board models open bus as the last value the data bus carried (the 6502's own last fetch), which gives KH's example (a read of 4100h after `LDA $4100` returns 41h). HYPOTHESIS for any access pattern other than absolute addressing (U4). ## Mirroring inside the I/O blocks KH gives each block's 1 KB range but not the decode inside it: the sound registers' mirror period (16 is the natural guess), the LCD's 8 registers "mirrored a lot of times" (period 8, by KH's wording). U3. ## Interrupts (KH "IRQ", "UART") - **IRQ:** a timer every 32,768 crystal clocks (16,384 CPU cycles; 4,433,000 / 32,768 = 135.28 Hz). No acknowledge register; KH: "a vector pull to RST or IRQ should reset the timer/IRQ flag", so the line is a level held until the vector fetch (his wording is a hypothesis: U5). CC65's `IRQStub` comment "(135 hz)" agrees on the rate. - **NMI:** the UART receiver, after 8 received clocks (link-and-pad.md). - **Reset:** the BIOS's vector; MAME's trace starts at FC0D after reset on both BIOS sets (OBSERVED; the vector bytes are firmware and are not quoted). ## BIOS zero page (CC65, from the BIOS's behaviour) 0A (a copy of 4800 at each NMI), 0B (IRQ counter), 0C (if 0, the cartridge's IRQ/NMI stubs are not called), 0E-11 (four free-running IRQ counters), E8 (set to FFh each NMI). The cartridge's entry points are jumps at 6020 (reset), 6023 (NMI), 6026 (IRQ) (CC65 `header.s`; KH: the BIOS jumps to 6020h). A tier-3 toolchain view; a board needs none of it (it runs the BIOS), but it explains what game code expects.