# Cartridges WSDEV "ROM header", "Cartridge", "Mapper", "Bandai 2001", "Bandai 2003", "KARNAK", "WonderWitch", "WonderWitch/Flash", "WonderWitch/Memory map" at the pinned revisions. Counts are from this phase's census ([census.md](census.md)). ## The header (a footer) The last 16 bytes of the image: a far jump (EAh, offset, segment), a maintenance byte (low nibble must be 0; colour: splash-bypass bit), publisher id, colour flag, game id (BCD), version/safe mode (bit 7 disables internal-EEPROM write protect), ROM size, save type, flags (bit 0 vertical start, bit 2 16-bit bus, bit 3 one wait state; these two copy into port A0h), mapper (0 = 2001 or KARNAK, 1 = 2003; high nibble must be 0), and a 16-bit checksum (sum of all bytes but the checksum). Images smaller than a power of two are padded **at the start**, because the header must sit at the top of the address space ("ROM header"). Census: every image in the five folders starts with EAh. The checksum matches on every commercial image except 14 mono, 13 colour, 3 aftermarket and 1 PCV2 image; it fails on **all 249 WonderWitch images** (they are FreyaOS flash contents, not cartridge masks), so the board must not refuse a bad checksum. The bytes WSDEV marks as validated on colour models are the jump, maintenance, version/safe-mode, flags and mapper bytes, not the checksum ("ROM header"); whether the colour boot ROM ever looks at the sum is U10. ## The common mapper interface Ports C0h (linear bank, 1 MiB units: the top 768 KiB appear at 40000h-FFFFFh), C1h (RAM bank, 64 KiB at 10000h), C2h and C3h (ROM banks 0 and 1, 64 KiB at 20000h and 30000h). The mono console expects C3h to power up holding FFh ("Mapper"). | Mapper | Extra | Limit | Census (header byte) | | --- | --- | --- | --- | | Bandai 2001 (LUXSOR) | cartridge EEPROM controller at C4h-C8h | 16 MiB ROM | 124 mono, 108 colour, all 61 PCV2 (as KARNAK or 2001) | | Bandai 2003 (LUXSOR2) | S-3511A RTC (CAh, CBh), four GPO pins (CCh, CDh), self-flash (CEh: map ROM at 10000h for writing), 16-bit bank registers (CFh-D4h) for more than 16 MiB | 64 MiB | 132 mono, 134 colour | | KARNAK | the 2003 without the RTC; adds a timer IRQ ((period + 1) x 2 cartridge clocks at 384 kHz) and an ADPCM decoder | PCV2 carts only | not separable from the 2001 by header (U11) | Save types in the census: SRAM 32 KiB (84 mono, 76 colour, 32 PCV2), 128 KiB, 256 KiB (130 mono, 130 colour: the WonderWitch and some games), 512 KiB; EEPROM 128 B, 1 KiB, 2 KiB; none. WSDEV notes that save byte 01h is usually documented as 64 Kbit but all known carts with it carry 256 Kbit chips. MAME 0.285's software lists (CC0) classify the same carts as `ws_rom`, `ws_sram`, `ws_eeprom` and `wwitch` with an `rtc` feature (mono: 16/85/25, 2 RTC; colour: 2/78/26 and 2 WonderWitch, 10 RTC): a cross-check for the board's own classification. ## WonderWitch Qute Corporation's homebrew kit (2000): a 2003-mapper cartridge with the RTC and 512 KiB of Fujitsu MBM29DL400TC NOR flash, written through the RAM window with CEh, dual-bank so one part stays readable while the other is programmed; FreyaOS and FreyaBIOS live in the flash ("WonderWitch", "WonderWitch/Flash"). No-Intro tags 249 images WonderWitch (119 mono, 126 colour, 4 aftermarket); all 255 images in the mono and colour folders whose names mention WonderWitch are 512 KiB with mapper byte 1 and save byte 04h (SRAM 256 KiB). Model the flash's command set from "WonderWitch/Flash" and the datasheet it links (the up-n-atom/WonderWitch copy; not fetched here: U12). ## Cartridge bus 8- or 16-bit, 0 or 1 wait state (header flags, port A0h), SRAM and I/O waits on colour (port 60h), a 384 kHz (or 6 MHz?) cartridge clock (port 60h bit 0, "6 MHz?" on WSDEV), a cartridge IRQ line, and a boot-time "cartridge bus test OK" bit (A0h bit 7). Pinouts are on WSDEV ("Cartridge connector", "2001 Mapper pinout", "2003 Mapper pinout"). ## Sockets `CartridgeSlot` takes a mapper device (2001, 2003, KARNAK, WonderWitch-flash 2003) built from the header's mapper byte and save type, with a per-image override table for the exceptions (the census's checksum and header oddities, the KARNAK carts). Save data and the RTC's time travel in save states and in a `.sav`-style file named by the image's SHA-1.