# The EEPROM (game settings) CPS-2 games have no DIP switches on production boards: coinage, difficulty, region-specific options and high scores live in a serial EEPROM, edited in the game's service menu. ## The part and where it sits - MAME: one `EEPROM_93C46_16BIT` (`-listxml` device `93c46_16`): a 93C46 in 16-bit organisation, **64 words x 16 bits = 128 bytes** (`eepromser.cpp`: `DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c46, 93C46, 16, 64, 6)`: 16-bit data, 64 cells, 6 address bits). - MAME's board drawings (`cps2.cpp` notes, provenance not stated) show **three** 93C46 positions: `93C46(1)` on the A-board "tied to the custom I/O chip" (DL-1123); `93C46(2)` on the A-board "tied to the Kabuki chip" (the drawing labels the Z80 position "DL-030P (or Z80)"); and one on the B-board, "not populated on revision -7". `cps2-reverse` `93646B/README.md`: revision 5 added "an additional slot with a different size ... for the optional EEPROM". Which one a given game uses, and whether the A-board one is the only one ever written, is not settled (U10). The emulator needs one EEPROM per machine; the open question only matters for the sockets. - No CPS-2 set ships a default EEPROM image (0 `region="eeprom"` entries in the 323 sets, measured). A blank (all `FF`) EEPROM makes the game initialise its settings on first boot; after two emulated seconds of `spf2t`, MAME's saved image held two copies of a 48-byte settings block (offsets `00-2F` and `30-5F`; measured, `tests/mame_traces/spf2t/nvram/spf2t/eeprom`). ## The 68000's port | Address | Bits | Meaning (MAME `cps2_4p4b` ports and `cps2_eeprom_port_w`) | | --- | --- | --- | | `804040` write | bit 12 | DI (data to the EEPROM) | | | bit 13 | CLK | | | bit 14 | CS | | `804020` read | bit 0 | DO (data from the EEPROM), active high | MAME's prose comment on `804040` numbers the bits within the high byte ("bit 4 - Eeprom data, bit 5 - Eeprom clock", bits 6-7 blank); the port definition is what is wired: CS is bit 14. Eco Fighters also uses bit 8 of the same write to switch IN0 between joystick and dial ([inputs.md](inputs.md)). ## The protocol (93Cxx family) From MAME `eepromser.cpp` (BSD-3-Clause, Aaron Giles; a description of the standard 93Cxx part, tier 5 as code, but the command set is the manufacturer's, tier 2, whose data sheet is not pinned here): a command starts on a rising CS, then a start bit `1` clocked on a rising CLK, then a 2-bit opcode and 6 address bits: `10` READ, `01` WRITE (+16 data bits), `11` ERASE, `00 11xxxx` write enable, `00 00xxxx` write disable, `00 01xxxx` write all, `00 10xxxx` erase all. READ outputs a dummy `0` and then 16 data bits MSB first; DO also signals ready/busy after a write ("on the 93Cxx series, the DO pin serves double-duty"). How long a write keeps DO busy is a data-sheet value not read here (U11). ## Where the code lives Users in the family: cps2-python (93C46, 16-bit), cps1-python (the CPS-1.5 Q-Sound boards use a 93C46 in 8-bit organisation: MAME `cps1.cpp` maps DI/CLK/CS to bits 0, 6, 7 of a byte port and DO to bit 0; Pang! 3 has a 16-bit one and no QSound), and probably cps3-python and many other arcade boards. By the chip rule a second consumer makes it a candidate for its own small repository (open decision 4 in [handoff-brief.md](handoff-brief.md)); the board's interface is three output lines and one input line plus a 128-byte image, so the choice costs little either way. ## Saving The EEPROM image is the only per-game persistent state (`.nv` style). Bring-your-own: never commit one (`.gitignore` already excludes `*.nv`). The key RAM is **not** state the emulator saves: the key file is an input, read with the ROM set ([encryption.md](encryption.md)).