# Memory maps, interrupts and bus timing Sources and their tags: `[mame]` MAME 0.285 `capcom/cps2.cpp` / `cps1.cpp` (tier 5, detector); `[die]` Loïc Petit's `cps2-reverse` die and board traces (tier 1 by origin, read as documents, never simulated); `[jt]` jtcps2 HDL and its notes (tier 4; its GPL source was read in Phase 0 and is not fetched since 2026-11-24, so a `[jt]` statement about what the HDL does is HYPOTHESIS, for review); `[mad]` the MAD diagnostic's README (tier 3, runs on boards); `[ac]` Eduardo Cruz's article (pinned). "Measured" means run here. ## Which board holds what | Board | Holds | Source | | --- | --- | --- | | A-board 93646A (base, stays in the cabinet) | CPS-A-01 (DL-0311), CPS-B-21 (DL-0921, battery-less default mode), DL-1123 (I/O), DL-1625 + DL-2227 (object frame buffer control and final composition), the Z80, the QSound DSP DL-1425 and DAC, 2 x 128K x 8 work/graphics RAM, 8K x 8 sound RAM, palette RAM, 2 x HM514260 frame-buffer DRAM | `[die]` `DLs/README.md`, `DL-0311/doc/vram.md`; `[mad]` RAM table | | B-board 93646B (game) | **DL-1525: the 68000 core + cipher + key store**, DL-1727 (bus interface, `$804xxx` registers), DL-1827 (object RAM, bus control, interrupts, security pins), DL-1927 / DL-2027 (graphics ROM address mangling and data selection), 2 x 8K x 8 object RAM, program, graphics, Z80 and QSound sample ROMs, the battery, CN9 (from revision 5) | `[die]` `DLs/README.md`; `[ac]`; `[mad]` | | Extension boards | 93646C/93661G ROM extension, 93646D network, 93646E QSound ROM extension, 00716C flash | `[die]` README (only 93646E traced) | **The 68000 is on the B-board**, inside DL-1525 `[die]` `[ac]`; MAME's overview prose puts the CPU on the base board while its own B-board drawing shows it on the B-board (C1). For an emulator the consequence is nil (one machine), but the docs follow the die. ## 68000 map (24-bit, 16-bit bus) | Range | What | Notes | | --- | --- | --- | | `000000-3FFFFF` | program ROM (0.5-4 MiB in the 40 parents) | encrypted for opcode fetches in `[0, upper)` ([encryption.md](encryption.md)); MAME maps a parallel opcodes image here | | `400000-40000B` | object output registers (write) | `+0` base?, `+2` usually `807D` (`808E` flipped), `+4` **layer priorities**, `+6` usually 0, `+8` X offset (usually `0040`), `+A` Y offset (`0010`) `[mame]`; see [video.md](video.md) | | `618000-619FFF` | QSound shared RAM, low byte of each word | the Z80's `C000-CFFF`; reads return `FF` in the high byte `[mame]` `qsound_sharedram1_r` | | `620000-620021` | network adapter (uPD71051 USART + routing PAL) | only on boards with the 93646D; `ssf2tb` family `[mame]` `cps2_comm_map` | | `660000-663FFF` | extra RAM on the add-on board, present when `804030` bit 14 = 0 | "many games store highscores" `[mame]` | | `664000-664001` | unknown, used only when the extra RAM exists | `[mame]` | | `700000-701FFF` | object RAM bank "1" (write only in MAME; "no game seems to use it directly") | `[mame]` | | `708000-709FFF` (mirror to `70FFFF`) | object RAM bank "2" (read/write) | the two 8 KiB banks swap with `8040E0` bit 0 `[mame]`; 2 x 8K x 8 SRAM at 3A/4A on the B-board `[mad]`; banking in DL-1827 `[die]` | | `800100-80017F` | mirror of CPS-A / CPS-B registers | "Mirror (sfa)" `[mame]` | | `804000` | IN0: players 1-2 | [inputs.md](inputs.md) | | `804010` | IN1: players 3-4 / extra buttons | | | `804020` | IN2: bit 0 EEPROM data out, bit 1 service (test), bit 2 service coin, bits 8-11 start 1-4, bits 12-15 coin 1-4 | | | `804030` | read: digital volume, bit 14 = 0 extra RAM present, bit 15 = 0 network adapter present | `[mame]` `cps2_qsound_volume_r` | | `804040` | write: high byte = EEPROM DI (bit 12), CLK (13), CS (14); low byte = coin counters (0-1), **Z80 reset release (bit 3)**, coin lockouts (4-7) | [eeprom.md](eeprom.md) | | `804080`, `804090` | DL-1727 REG8 (read: MISC-D bus, pulled up) and REG9 | `[die]` `DL-1727/README.md` | | `8040A0` | DL-1727 REGA: **active at power-up, must be cleared before the A-board bus works** | `[die]`; MAME just ignores the write ("reset once on startup") | | `8040B0-8040B2` | DIP switches, development hardware only | `[mame]`; production boards read nothing (MAME returns `FF` when "Production") | | `8040E0` | object RAM bank swap (bit 0) | DL-1727 passes the write strobe to DL-1827 `[die]` | | `804100-80413F` | CPS-A-01 registers (write) | the CPS-1 register set ([video.md](video.md)) | | `804140-80417F` | CPS-B-21 registers (read/write) | default-mode addresses; raster counters at `+0E/10/12` | | `900000-92FFFF` | graphics RAM (tiles, row scroll, palette source) | same two 128K x 8 chips as work RAM `[mad]` | | `FF0000-FFFFFF` | work RAM | | DL-1727 decodes `$804xxx-$807xxx` (mask `1000 0000 01xx ...`) `[die]`, so the `$8040xx` registers mirror over that range; MAME maps only the listed words. `ssf2tb`'s network map and the dead-board map (`dead_cps2_map`: object output at `FFFFF0-FFFFFB`) are MAME variants for special sets. ## Z80 map (8 MHz, program from the B-board's Z80 ROM) | Range | What `[mame]` `qsound_sub_map` (shared with CPS-1.5) | | --- | --- | | `0000-7FFF` | Z80 ROM (not encrypted on CPS-2; CPS-1.5 used Kabuki) | | `8000-BFFF` | banked Z80 ROM, 16 KiB pages from ROM offset `0x10000`, bank = `D003` bits 0-3 | | `C000-CFFF` | RAM shared with the 68000 (`618000-619FFF`) | | `D000`, `D001`, `D002` | QSound: data high, data low, then address (the write that raises the DSP's INT) | | `D003` | bank select | | `D007` | QSound status, bit 7 = DSP ready for the next command | | `F000-FFFF` | private RAM | The Z80 is held in reset until the 68000 sets `804040` bit 3. Measured on `spf2t`: 15 Z80 instructions in the first emulated second, 874,738 in two seconds. IRQ (mode 1) at `8 MHz / 32000` = 250 Hz, "measured" per MAME's comment, held until acknowledged. **Bus request for the shared RAM** `[die]` `DL-0311/doc/bus-requests.md`: on CPS-2 the 68000 side reaches the sound RAM by requesting the Z80's bus, and while the Z80 has released it, the CPS-A cannot take the 68000's bus. MAME models neither the Z80 stall nor the interaction (U9). ## Interrupts (68000, autovectored) - **IPL1 (level 2): vblank**, asserted at line 240 `[mame]` `raster_scanline`. - **IPL2 (level 4): raster**, from the CPS-B-21's counters through `/OBJUP` "transmitted to IPL2 on the CPU" `[die]` `DL-0921/doc/raster-effects.md`. Both at once read as level 6. - One interrupt-acknowledge cycle (any FC = 7 cycle with BGACK, VPA asserted) **clears both** lines `[mame]` `irqack_r`; the vector is the autovector. DL-1827 carries the interrupt logic `[die]` (sheet `interrupt-out`, not yet read gate by gate). - MAME's raster counters: counters 1 and 2 (`+10`, `+12`, 9 bits) are reloaded at line 0 and decremented each line; when one reaches 0 the IRQ fires `2 x reload(+0E)` pixels later. Bit 15 of a write reloads immediately. jtcps2 (HYPOTHESIS, source-read) instead raises the IRQ when the column counter **and** a line counter are both zero, counting at 4 MHz. The die document says the function "is still unknown". See [video.md](video.md) and U7/C5. ## Bus timing (the "11.8 MHz" question) - Clock: 16 MHz crystal, the 68000 at 16 MHz `[mame]` `M68000(config, m_maincpu, 16_MHz_XTAL)`. - **MAME slows the CPU by `set_clock_scale(0.7375)`** for every CPS-2 set (`init_cps2nc`, comment: "HACK: RAM access waitstates etc. aren't emulated - slow the CPU to compensate"). 16 x 0.7375 = 11.8 MHz: this is where the "CPS-2 runs at 11.8 MHz" lore comes from. (The 2026-11-11 status page said MAME clocks a flat 16 MHz: corrected here.) The driver's "Known problems" note says "various timing loops show 11.8 being the average speed of the cpu and this does run true when comparing emulation and real hardware when timing is not based on Vsync (ssf2 and ssf2t for example)", and suspects RAM wait states. Who timed which loops is not stated: an uncited comparison against boards, tier 3 at best, and an average, not a rule. - **jtcps2's derivation from the DL-1827 sheets** (its README notes on the bus timing, citing the die sheets `control-states`, `addr-decoder`, `objram-control-in`, `interrupt-out`; prose read in Phase 0, HYPOTHESIS until the sheets themselves are read): **one wait state on every external bus cycle in `$000000-$4FFFFF` and `$800000-$FFFFFF`**; `$500000-$7FFFFF` (QSound RAM, extra RAM, object RAM) is not in that decode. Its four-fx68k bench: a read-modify-write loop of 38 clocks takes 47 with the delay; TAS 63 (52 + 11). Not a hardware measurement: a tier-4 reading of a tier-1 trace, the best source there is. - **Bus stolen by the CPS-A**: per line, row scroll, scroll 1/2/3 tile fetches and the palette copy (`DL-0311/doc/bus-requests.md`; the object fetch "WSTOBJ" of CPS-1 does not apply on CPS-2, whose object RAM is separate). MAME does not model this either. Its known problems: Giga Wing's attract mode loses sync with the music and its sprites are one frame out against the background; Progear "slows down more than it should". All three are attributed there to the unmodelled wait states, and are the natural exit tests for a wait-state model. - m68000-python counts clocks per access (`cpu.step_clocks`) and models no wait states; the board adds them per access from the address (an accounting the brief puts in the board).