# Memory maps, the 315-5195 mapper, I/O and ROM boards Facts are DOC from MacDonald's notes unless tagged otherwise; sections cited as CM16B §2 ("68000 memory map"), CMP16 ("68000 memory map", "I/O hardware"), CMSND, CM5797. ## System 16A and Pre-System 16: a fixed decode A PAL at 8J decodes 68000 A23, A22, A18, A17 and a buffered A16 that either bus master (the 68000 or the 8751) drives, so the space falls into four regions of eight 64 KB banks, repeated (CMP16): | Banks (repeat every 8) | Contents | | --- | --- | | 00-02 | program ROM pairs 0, 1, 2 | | 03-07 | lock up when accessed | | 40 / 41 | tile RAM (32 KB) / text RAM (4 KB) | | 42, 43 | unused, read 0xFFFF (some games test 0x430000 for 0 and then label chips by IC number) | | 44-47 | sprite RAM (2 KB) | | 80-83 | lock up | | 84-87 | colour RAM (4 KB) | | C0 / C1 | tile RAM / text RAM | | C4, C5 | I/O | | C6 | 0xFFFF (Major League's watchdog at 0xC60000, enabled by a jumper) | | C7 | work RAM (16 KB) | The addresses games use: 400000-407FFF tile RAM, 410000-410FFF text RAM, 440000-4407FF sprite RAM, 840000-840FFF colour RAM, C40000-C42FFF I/O, FFC000-FFFFFF work RAM. MAME's Shinobi (16A) run writes the 8255 at C40001-C40007 and work RAM at FFC000-FFFFFF (OBSERVED, mame-oracle.md), consistent with this map. **I/O (banks C4, C5)**, odd bytes, inputs and DIPs active low: 0000-0FFF the 8255 (port A C40001, B C40003, C C40005, control C40007), 1000-1FFF inputs 0-3, 2000-2FFF DIP switches (DIP 2 at C42001, DIP 1 at C42003), 3000-3FFF unused (0xFFFF). The 8255's control register reads back 0xFF/0xF7 at random (a uPD82C55 whose control register may not be readable). **8255 PPI.** Port A in mode 2 is the sound command to the Z80 (used write-only). Port B: D7 screen flip (latched each line), D6 the 8751's /INT1, D5 to PAL 315-5149 (no visible effect), D4 screen enable (latched each pixel; blank outputs black), D3/D2 lamps, D1/D0 coin meters (rising edge counts). Port C: D7-D3 port A handshake, D2/D1 to PALs 315-5107 and 315-5108 (SCONT1/0), D0 the MB3733 amplifier's MUTE (0 = silent); initialised to 0x07 by every game examined (CMP16; MAME's Shinobi writes 0x07: OBSERVED). JT16's 16A table adds PC7 /OBF -> the sound Z80's /NMI. **Bus waits (16A).** JT16: ROM and work RAM acknowledge at once (the 315-5149 PLA); object RAM, palette and I/O wait for an LS164 shift register tapped by a solder jumper: 2 wait states, "derived from the schematics and ... not checked on a PCB yet" (tier 4: U3). ## System 16B: the 315-5195 mapper At power on the first 64 KB of program ROM sits at 0x000000. 32 write-only byte registers appear at odd addresses in **any 64 KB bank not claimed by a region**, mirrored every 64 bytes; games use FE00xx, FF00xx or C000xx (CM16B §2). Word writes to even addresses work with the data in the low byte (Riot City does this). | Register | Effect | | --- | --- | | 0x01-0x1F (the first 16) | nothing, except: | | 0x05 | any write halts the 68000 | | 0x07 | the byte goes to the Z80's sound command latch and the Z80 gets its interrupt (CM16B §2 says NMI; CMSND says the 315-5195 strobes the Z80's **/INT** and the Z80's handler reads port 0xC0: C3) | | 0x09 | any write resets the 68000 repeatedly | | 0x21 + 4n | memory control of region n (n = 0-7) | | 0x23 + 4n | bits 23-16 of region n's base | Memory control `----mmss`: **ss** the size, 00 64 KB (mask 0xFF0000), 01 128 KB (0xFE0000), 10 512 KB (0xF80000), 11 2 MB (0xE00000); a device smaller than its region mirrors through it (2 MB of object RAM is 2 KB 1024 times). **mm**: for tile/text RAM both bits must be set, else the area returns prefetch mixed with garbage; for other regions none or one bit changes nothing and both lock up; E-Swat sets bit 3 for the I/O area and reads random low nibbles at 0000-0FFF and 3000-3FFF. Tile/text RAM needs 128 KB or more: tile RAM first, text RAM one bank up; with 64 KB an even bank shows only text RAM and an odd bank only tile RAM. JT16B states that bits 3-2 of the size register select the region's DTACK delay; that rests on an unattributed gate trace and is **not used** ([sources.md](sources.md), U2). Region use common to all games: 0 program ROM, 3 work RAM, 4 text/tile RAM, 5 object (sprite) RAM, 6 colour RAM, 7 I/O; 1 and 2 are for extra ROM or hardware on the ROM board. MAME's Golden Axe (8751 set) runs with text RAM at 0x100000-0x10FFFF and its 68000 never writes a mapper register in 40 frames (OBSERVED): with the MCU halting the 68000 at reset, the 8751 seems to set the map itself (HYPOTHESIS, U6). **Unmapped reads** return the last word on the data bus, normally the prefetched opcode of the next instruction (`move.w $330000,d0 / nop` leaves 0x4E71 in D0). Unpopulated program sockets read the same way. This makes open bus a function of the 68000's prefetch, which m68000-python models: the board must hand the core's last bus word back, not a constant. **I/O area (16 KB, mirrored through its 64 KB bank)**: 0000-0FFF reads open bus, writes go to the miscellaneous control register; 1000-1FFF inputs 0-3 in the low byte (A0, A1 decoded, high byte open bus); 2000-2FFF DIP switches (A0 decoded); 3000-3FFF reads open bus (Shinobi 16B writes C43007 once and changes bits 1-2 of C43001; unknown). Miscellaneous control: D6 screen flip (backgrounds and text flip both ways, sprites only horizontally), D5 display enable, D3/D2 lamps, D1/D0 coin counters, D7 also clears the sound control latch (CMSND, "Miscellaneous"). ## ROM boards (16B) and the banking they implement | Board | Games | Program | Sprite banking | Tile banking | Sample banking (sound latch bits) | | --- | --- | --- | --- | --- | --- | | 171-5358 | Shinobi, Tough Turf | six 27512 in three regions 0-2 | the 4-bit bank value is four active-low chip selects; two enabled = bus fight, none = a constant per 4 pixels | none (bit 12 of a tile index means nothing) | D5-D2 chip selects of four ROMs, D1/D0 A15/A14 | | 171-5704 (and 171-5521) | Tetris, Altered Beast, Cotton, Heavyweight Champ | four 27010; regions 0 and 1 | CGB3-1 into a 74LS138 (pairs a-h), CGB0 = A16 | a PLS153 in region 2: odd bytes 0x0001 (text and tiles with bit 12 clear) and 0x0003 (bit 12 set), 3 bits each, eight banks of 4096 tiles, power-on value 7 | D3 ROM select, D2 /OE, D1/D0 A15/A14 | | 171-5797 | E-Swat, Golden Axe | two 27020, region 0 | CGB3 = A17, CGB2-1 into a 74LS139, CGB0 = A16 | in region 1 at xx2000 (0x2001/0x2003 as above); region 1 also holds the 315-5248 multiplier (xx0000) and the 315-5250 comparator (xx1000) | D4 A17, D3 ROM select, D2-D0 A16-A14 | Sources: CM16B §1, CMSND "Sample ROM banking", CM5797. The **315-5248** multiplier: two signed 16-bit operands, a signed 32-bit result always ready; word registers 0 A, 2 B, 4 result high, 6 result low (writes to 4/6 set A/B); byte writes to even addresses copy the byte to both halves, to odd addresses do nothing (CM16B §1). The **315-5250** comparator (24 word registers) was not tested by MacDonald (U5).