# Memory map, I/O map and the ASIC Sources: **TRG** = Atari Portfolio Technical Reference Guide (DIP, 1989), cited by section (`reference/docs/trg.pdf`, OCR in `trg_djvu.txt`). **OBS** = MAME 0.285 runs of the real DIP ROMs (mame-oracle.md): what the firmware does in a model, OBSERVED, not hardware. ## Memory (DOC, TRG 2.2.1-2.2.4) | Range | What | Notes | | --- | --- | --- | | 00000-1EFFF | system RAM, 124 KB | four 32 KB static RAMs (2.1.2); drive C: (the RAM disk) sits at the top of system RAM, configurable in 8 KB steps (3.1.2). The diagram labels this block's top **3F000**, which does not fit 124 KB (C1) | | 1F000-9EFFF | expansion RAM, "up to 512K bytes" ("up to 636 KBytes" in all, 2.2.2) | memory-expander peripherals; 124 + 512 = 636 KB ends at 9F000, the diagram's next label | | 9F000-AFFFF | not used (two blocks in the diagram, split at A0000) | | | B0000-B0FFF | video RAM, 4 KB, MDA layout | 4 KB of the 128 KB on-board RAM mapped here (2.2.2) | | B1000-BFFFF | "mirror of video RAM (not used)" | U2: exact mirroring | | C0000-DFFFF | system ROM B (128 KB), **or** the memory card ("equivalent to A: or B:") | ROM B "may be switched out of the memory map and replaced by either the internal memory card or an external memory card on a peripheral"; the BIOS disk services do it (2.2.4) | | E0000-FFFFF | system ROM A (128 KB): BIOS, DOS, some applications | cannot be mapped out; reset vector at FFFF0 (2.2.3) | OBS: the first instruction traced is `CS=FFFF IP=0000 EA` (a far jump), as on any 8088. Two display memories exist: the MDA-shaped buffer at B0000 in system RAM, and the LCD controller's own "dedicated Video RAM chip" (TRG 2.1.4). Software writes the first; the BIOS copies it to the second (Int 61h Fn 12h; lcd.md). **C1 (TRG against itself):** the scanned diagram (page 2-4, checked as an image) labels the system RAM's top 3F000 and the expansion area 3F000-9F000 (384 KB), while its own text says 124 KB and "up to 512K" (and 636 KB in all, 2.2.2). The sizes agree with each other and with 9F000; the label 3F000 does not. Planning reading: RAM 00000-1EFFF, expansion from 1F000 (HYPOTHESIS: the label is a typo); the BIOS's RAM sizing code decides it. ## I/O (partly DOC, mostly OBSERVED) The TRG documents only the peripheral corner of the ASIC's I/O space: | Port | DOC (TRG) | | --- | --- | | 8070-807F | reserved for peripherals; BCOM goes low for I/O 807x (2.6.2, 2.7.2) | | 807C | write 0/1 routes NCC1 (the external card select) to the through-peripheral or the peripheral (2.7.2) | | 807F | read: Peripheral ID (40h-7Fh for non-DIP peripherals) when PDET is high (2.7.1); write: the serial interface's SIVR (3.10) | Everything else (the keyboard scan-code register, the tick and interrupt status, the ROM B / card select, the contrast register, the tone chip's latch, the LCD controller ports) is a "control register" in the TRG's words (2.4) with **no address given**. The firmware's own accesses in MAME (first 10 s from reset, no card, no key): | Port | Reads | Writes (values) | Reading | | --- | ---: | --- | --- | | 8000 | 1 (FF) | - | HYPOTHESIS: keyboard data | | 8010 | - | 570 | LCD controller data register (RS = 0): the values fit HD61830 data (lcd.md), OBSERVED | | 8011 | - | 570 (00 01 02 03 04 08 09 0A 0B 0C ...) | LCD controller instruction register (RS = 1): HD61830 instruction codes, OBSERVED | | 8020 | - | 1 (80) | U3 | | 8040 | - | 1 (00) | U3 | | 8050 | 2 | 2 (00 02) | U3 | | 8051 | 52 (40 41 45 ...) | 7 (40 43 47 82) | U3: a status/control pair the BIOS polls | | 8060 | - | 1 (80) | U3 (HYPOTHESIS: contrast) | | 807C | - | 6 (00 01) | NCC1 routing (DOC above) | So the ASIC's register map is the board's main unknown (U3). Ways to close it, in order of evidence: the DIP BIOS's own code read from the player's ROMs (the firmware is the real program; facts only, nothing committed), MAME's `pofo.cpp` as a detector (BSD-3-Clause: open decision 2), a unit with a logic analyser (none on hand). ## The ASIC (DOC, TRG 2.4) A CMOS gate array that generates every select line and holds: the 4.9152 MHz clock (50 % duty, can stop; "a custom chip interrupt will cause the clock to restart"), the timer (a 32,768 Hz crystal, an interrupt "every 1 second or every 128 seconds"), the keyboard controller (scans an 8 x 8 matrix, interrupts on press and release, scan code read from a control register), the interrupt handler (memory-card critical error, keyboard, tick, and an external interrupt extended to the expansion port: EINT, level-triggered, lowest priority, acknowledged through EACK after INTA, 2.6.2), and the LCD contrast register (2.4.5). There is **no 8259 PIC, no 8253 PIT, no 8255 PPI, no DMA controller** (TRG 3.1.3: "The Portfolio does not have a Programmable Interrupt Controller (PIC) or a dedicated keyboard controller"). The CPU's INTA cycles fetch a vector from the ASIC (IACK, 2.6.2); which vector numbers (U4) the firmware's handlers sit at is in the ROM's interrupt table. READY: "This line indicates to the CPU that the custom chip is ready" (REDY, 2.6.2): the ASIC can insert wait states (U5: when and how many).