# Cartridges: the connector, the schemes, the sound chips, and the file formats Counts in this document are measured by `scripts/count_carts.py` on 2026-11-11 over the local sets, read in place. Sources: the 7800 Development Wiki pages pinned under `reference/8bitdev-wiki/` (the A78 header specification, Stolberg's bankswitching guide, the SuperGame, bankset, XM and HSC pages), MAME 0.285's `hash/a7800.xml` (CC0-1.0) and `bus/a7800` sources, and the emulators' own tables, each named where used. ## The connector 32 pins. Beyond the 2600's 24 it carries A13-A15 (so all 16 address lines), R/W, Φ2, HALT, an audio input and IRQ ([SG] "Cartridge"; wiki "Hardware interfacing guide"). A 2600 cartridge fits the middle 24 contacts and sees no R/W: `a2600-python`'s connector protocol stands for those. What the board passes to a 7800 cartridge on every bus cycle: ``` access(address, data, read: bool, halt: bool, t: int) -> int | None ``` - `address` is 16 bits, for **every** cycle, including the CPU's dummy cycles and **MARIA's DMA reads** (`halt` true). Bank-select hot spots are write decodes; banksets and SOUPER decode on HALT, so the flag is part of the protocol, not an extra. - The return value is the byte the cartridge drives, or `None` when it drives nothing (the bus keeps its last value). - `t` is the MARIA clock, for cartridge devices with their own time (POKEY, YM2151, BupChip). - Separate from the bus: `audio() -> samples`, `irq: bool`. The cartridge sees $0400-$047F, $0500-$17FF and $3000-$FFFF (start-here.md "Memory map"); the console's own devices win elsewhere. ## Why a raw dump is not enough A headerless dump is the ROM chips' contents and nothing else. It does not say whether the board had RAM at $4000, a POKEY and at which address, which bank select logic, a light gun or paddles, or which television standard. Two 128 KiB dumps can need different hardware (Commando has a POKEY at $4000, Summer Games has 16 KiB of RAM there, Rampage has Activision's bank logic). Emulators guess from size and from byte patterns; this project does not port those guesses (the detectors are GPL, and a guess is not a fact). It identifies a dump by hash instead: [Formats](#formats-one-loader). ## Schemes Local No-Intro dumps, 245 cartridges (124 licensed, 117 aftermarket, 4 private; the two BIOS zips in the licensed folder are not cartridges). The scheme is taken from the best source available for each dump, in the order of the [typing table](#how-many-dumps-can-be-typed) below. | Scheme | What the logic does | Licensed | Aftermarket | Private | | --- | --- | --- | --- | --- | | Linear | up to 48 KiB ending at $FFFF, no switching (52 KiB from $3000 exists in homebrew) | 57 | 94 | | | ... of which typed by a table | | 55 (3 with a POKEY at $4000, 1 with mirror RAM) | 60 | | | ... of which typed by size alone | | 2 | 34 | | | SuperGame | 16 KiB banks; a write of n to $8000-$BFFF maps bank n there; the last bank fixed at $C000 | 61 | 15 | | | ... nothing at $4000 | | 44 | 2 | | | ... 16 KiB RAM at $4000 (8 KiB at $6000 on some) | | 10 | 5, and 1 with twice the RAM, switched | | | ... bank 6 fixed at $4000 (EXFIX) | | 5 | 4 (1 with a POKEY at $450) | | | ... a further ROM bank at $4000 (EXROM; 144 KiB and larger) | | 0 by these tables | 3 | | | ... POKEY at $4000 | | 2 (Commando) | | | | Activision | 16 KiB banks at $A000-$DFFF selected by a write to $FF80-$FF87; fixed halves of banks 6 and 7 elsewhere | 3 (Double Dragon, Rampage) | | | | Absolute | 32 KiB fixed at $8000; two 16 KiB banks at $4000 selected by writing 1 or 2 to $8000 | 2 (F-18 Hornet) | | | | High Score Cartridge | 4 KiB ROM at $3000, 2 KiB battery RAM at $1000; a pass-through | 1 | | | | Unknown (over 48 KiB, in no table) | | | 8 | 4 | The tables do not agree on names for the $4000 options: MAME's `a78_sg9` ("9 x 16K banks", Alien Brigade and Crossbow, 144 KiB) is counted here as "bank 6 fixed", following ProSystem's type 4, while Stolberg's guide calls the 144 KiB carts "78S9" with a ninth bank at $4000 and the EXFIX ones "78S4". Which of the 5 licensed dumps are EXROM and which EXFIX is settled per dump in milestone 3 from their size (144 KiB means a ninth bank) (C9). Details per scheme, with the open points: - **SuperGame variants** are one decoder with options at $4000, exactly how the A78 v4 header states them: none, 16K RAM, 8K RAM mirrored (EXRAM/A8), 32K RAM switched by HALT (EXRAM/M2), EXROM, EXFIX, 32K RAM switched by the bank latch (EXRAM/X2). Dumps smaller than 128 KiB mirror their banks; PAL Karateka uses banks 4-7 (Stolberg). - **The bank-select address range**: any write to $8000-$BFFF (Planet Smashers uses $BFFF: wiki "Common emulator development issues"). Which data bits count for sizes over 128 KiB (256 and 512 KiB homebrew) follows the ROM size. - **Activision**: Stolberg is unsure whether addresses beyond $FF87 switch (U16). The dump's bank order differs between sources: 17 licensed dumps do not match MAME's software list byte for byte, the Activision titles among them (MAME stores them in a different chip order). - **Absolute**: what other values written to $8000 do is unknown (U17). - **Mirror RAM** (Rescue on Fractalus prototype): 2 KiB appearing as 256-byte blocks each repeated twice across $4000-$4FFF. - **SOUPER** (Rikki & Vikki): registers at $8000-$8007 choose the CPU's bank, two character banks MARIA sees, a mode byte and extra-RAM pages, and a command port for the **BupChip**, a microcontroller that plays music (ProSystem `Cartridge.h` names; JS7800 and ProSystem implement it; the wiki page "Converting Rikki & Vikki" describes the dump layout). The three private Rikki & Vikki dumps are 512 KiB without their music data. Written last, from the emulators' behaviour, labelled as such. - **Banksets**: two SuperGame (or linear) images concatenated; the CPU sees the first, MARIA the second, switched by HALT ("Sally's bankset remains active until the second falling edge of PHI2" after HALT falls). Variants: 2x32K, 2x48K, 2x52K, 2x128K with RAM, POKEY at $4000 (write-only when ROM is there) or $800. Attack of the PETSCII Robots is the first user. The designers' test suite is pinned (`reference/test_roms/Bankset_Test_Suite_v1.zip`, each variant as `.a78` and `.bin`). - **XM / XBoard** (a pass-through module): XCTRL at $0470 enables a POKEY at $0450, a YM2151 at $0460-$0461, banked RAM at $4000, and the High Score Cartridge's ROM and RAM (wiki "XBoard memory init", "XBoard POKEY init", "YM2151 detection"). 16 of the local dumps write to $0470. - **Covox** (a DAC at $0430) and the **ADPCM stream at $0420** exist in the v4 header; no local dump writes to $0430. ## Sound hardware on cartridges: interface requests ### POKEY (to `pokey-python`) POKEY's internals are that core's business. What 7800 cartridges need: | Need | Detail | | --- | --- | | Instances | 0, 1 or 2 per cartridge (header v4 audio field: none, @440, @450, @450 + @440, @800, @4000); the XM adds one at $450 | | Address decode | done by the cartridge: 16 registers, mirrored across $4000-$7FFF for the $4000 kind; $0440-$044F, $0450-$045F, $0800-$080F otherwise. The core should take a 4-bit register number, not an address | | Clock | the CPU clock MARIA makes, as the cartridge's Φ2 pin sees it. **Not a steady 1.79 MHz**: pulses are 4 or 6 MARIA clocks apart and what happens during DMA is U10. The core must accept "advance by one Φ2" (or by a count of pulses) rather than assume a rate; the board says how many | | Writes | all sound registers (AUDF1-4, AUDC1-4, AUDCTL, STIMER, SKCTL); games rely on 16-bit joined channels, 1.79 MHz channel clocks, two-tone and the high-pass filters (wiki: E.X.O., A.R.T.I.) | | Reads | RANDOM ($0A): Ballblazer's music needs it (wiki). Homebrew detection reads RANDOM and others (wiki "Detecting POKEY"). ALLPOT/POTn/KBCODE read as with nothing attached, unless a keyboard is fitted (the MiSTer core offers an XEGS keyboard through POKEY) | | IRQ | the pin exists and the v4 header's interrupt field says a POKEY may drive SALLY's IRQ; no local dump is known to need it (not measured) | | Output | the mixed analogue level per Φ2 (or a sample stream at a stated rate); the board sums cartridge audio with the TIA's. The ratio is U15 | | Write-only variant | banksets with ROM at $4000: POKEY sees writes; reads return ROM | | Revision | the 7800 cartridges used the same C012294 as the computers; no 7800-specific variant is known | Local dumps whose code stores to a POKEY location at least twice (indicative only: bytes that look like `STA abs`): $4000 41 (many are RAM at $4000), $0450 18, $0800 10, $0440 3. By the tables: 5 licensed dumps have a POKEY (Ballblazer USA/Europe, Commando USA/Europe, and one more by MAME's list), and at least 19 aftermarket dumps. ### YM2151 (no core in the family yet) The XM carries a YM2151 at $0460 (address) / $0461 (data), clocked at the colour-burst frequency per the wiki's programming page (to be confirmed, U18). Local dumps that store to $0460-$0461: **3** (1942, 1942 Extended, Pac-Man Collection 40th Anniversary), all aftermarket, all of which also have POKEY or TIA music. MAME's software list has one XM entry. A `ym2151-python` core would have other consumers in the family later (arcade boards); for this board it is optional sound on 3 of 245 dumps. Recorded as a need, not requested for milestone order. ### BupChip, Covox BupChip: Rikki & Vikki only (private set); an emulation of a modern microcontroller's synthesiser, from the emulators. Covox: an 8-bit DAC, a register and a resistor; no local user. ## Formats: one loader The board must load what people actually have. One front door, `cartridge.formats.load(path_or_bytes, *, machine=None, overrides=None)`, normalises everything to one description. ### What comes in | Input | How it is recognised | | --- | --- | | `.a78`: 128-byte header + payload | bytes 1-9 are `ATARI7800`; byte 0 is the version (1-4); bytes 100-127 are `ACTUAL CART DATA STARTS HERE`. Recognised by content, not by extension | | headerless `.bin` (No-Intro "BIN") | no header; the whole file is the payload | | either, inside `.zip` | `zipfile`, one cartridge member (other members ignored if they are not images; more than one image is an error naming them) | | either, inside `.7z` | through the `7z` program when present (the family has no pure-Python 7z reader; stated in the error when missing) | | a 2600 dump (`.a26`, `.bin`, archives) | see "2600 dumps" below | | ProSystem's `.cdf` (a text manifest naming a ROM and BupChip assets) | out of scope until SOUPER; recognised and refused with that message | Never written: the loader reads into memory and does not create files beside the input. ### What comes out ``` CartDescription payload: bytes the ROM contents, header stripped sha256, sha1, crc32 of the payload console: "7800" | "2600" scheme: linear | supergame | activision | absolute | souper bankset: bool at_4000: none | ram16 | ram8-mirror | ram32-halt | ram32-latch | rom | fixed-bank | mirror-ram-2k pokey: tuple of addresses ($440, $450, $800, $4000), write_only flag ym2151: bool covox: bool adpcm: bool bupchip: bool irq_sources: tuple hsc: bool xm: bool save: none | savekey controllers: (left, right) of the header's device list region: ntsc | pal | both composite_artifacts: bool title: str provenance: per field, where the value came from ("softlist", "a78 header v3", "a78 header v4", "table", "size", "override") certainty: every field's weakest source ``` The fields are the A78 v4 header's vocabulary (wiki "A78 header specification"; `reference/src/a78_asm_header/a78header.asm` v4.2), because that is what the flash carts and the homebrew toolchain write. v4 fields win over v3 fields in a v4 header (the specification says so). The v3 "cart type" bits allow contradictory combinations; the loader rejects those it cannot build, naming the bits. ### Identity is the payload's hash The key is SHA-256 of the payload (SHA-1 and CRC-32 kept for the tables that use them), so an `.a78` and the matching `.bin` are the same cartridge. Measured (`scripts/count_carts.py`, 2026-11-11): - **There is no `.a78` file on this machine.** All 150 files in the curated retrobat set's `atari7800` folder (`$RETROBAT_DIR/atari7800`) are `.7z` archives holding headerless `.bin`; all three No-Intro folders are headerless. So "strip the header from each .a78 we have" strips nothing: 0 headered files. - The join still runs on payloads: **150 of 150** retrobat payloads are byte-identical to a No-Intro BIN payload (0 misses). - The only headered files here are public test programs fetched into `reference/test_roms/`: the 7800 Utility Cart and the Bankset Test Suite, each as `.a78` and `.bin`. They show the one way a pair can fail to match: **padding**. The suite's `2x48K.a78` holds a 98,304-byte payload while its `2x48K.bin` is 131,072 bytes; the `.bin` was padded to a power of two for EPROMs. Other known causes of a miss, none measurable here: a header whose size field disagrees with the file, trailing bytes after the payload, overdumps, and patched "fixed" releases that keep the old name. - The loader therefore matches on the payload as given and, on a miss, retries with the header's size field applied and with leading/trailing fill removed to the next scheme size; a match found that way is reported as "matched after trimming". ### How many dumps can be typed A table of payload hash to description can be seeded without porting any detection code. The candidates and their standing: | Source | Licence | What it gives | Use | | --- | --- | --- | --- | | MAME `hash/a7800.xml` | **CC0-1.0** (file header) | per ROM chip: size, CRC-32, SHA-1; the slot device (scheme, RAM, POKEY incl. $450 variants, HSC, XM); NTSC/PAL; light gun; PCB notes | committed as generated data, with the MAME version it came from | | No-Intro DATs (local: the sibling rom-farmer repository's `dats/nointro/`, BIN and A78, version 20241223) | No-Intro's terms (hashes and names; attribution) | names, regions, release status; SHA-256 of the BIN files and of the **headered** A78 files | names and regions for table rows; the A78 hashes cannot be turned back into headers (the title field is free text) | | A78 headers of matching files | the file's own | every field, as the dumper or author set it | none available here (0 headered files); taken when a user loads one, see below | | `ProSystem.dat` (in JS7800's tree, 317 entries), A7800DS `Database.c` (195) | parts of GPL-2.0 projects | scheme, POKEY, controllers, region, HSC, switch defaults, keyed by MD5 of the payload | **not committed.** The census reads them from `reference/` as two detectors' answers. A fact both state, checked by a run, can be written into our table in our own words with both cited, one row at a time | | Trebor's 7800 ROM PROPack (wiki) | a ROM collection | correctly headered `.a78` files | not fetched: it is a ROM set. If the user obtains it, its headers type nearly everything (Open decisions) | How far each gets, per set (`count_carts.py`, best source per dump): | Set | Dumps | MAME list (CC0) | both emulator tables agree | one emulator table | size only (48 KiB or less) | nothing | | --- | --- | --- | --- | --- | --- | --- | | Licensed | 124 | 107 | 9 | 6 | 2 | 0 | | Aftermarket | 117 | 19 | 16 | 40 | 34 | 8 | | Private | 4 | 0 | 0 | 0 | 0 | 4 | | **All** | **245** | **126** | **25** | **46** | **36** | **12** | "With certainty" has to be said carefully: - **126 dumps (51 %)** get scheme, RAM, POKEY, region and light gun from a CC0 table keyed by their bytes. The software list does not record controllers other than the light gun, the save device, or composite artifacts; those default (ProLine sticks, no save, no artifacts) and are marked "default", not "certain". Where both know a dump, the software list and ProSystem.dat never disagree on the scheme family (0 of the overlap). - **36 more** are 48 KiB or less and in no table. Their scheme is certain (nothing but a flat mapping fits the connector); their sound hardware and controllers are not. - **71** are known only to GPL emulators' tables (25 to both, 46 to one). These become certain as rows are confirmed and written. - **12** (8 aftermarket, 4 private: 1942 Small, PETSCII Robots demo, Harpy's Curse, Keystone Koppers, Orion Assault, Plink, Sirius XM, Wordle, Popeye 2.40, three Rikki & Vikki) are over 48 KiB and in no table. The 17 licensed dumps missing from the software list are mostly real misses of its hashes against No-Intro's dumps (Donkey Kong, Donkey Kong Junior, Mario Bros., Desert Falcon, Hat Trick, Double Dragon, Rampage, Xevious Europe, betas); each needs a look at whether the bytes differ or only the chip order. ### 2600 dumps handed to this board The loader asks, in order: an A78 header (7800); the 7800 table (7800); `a2600_python.cartridge.identify` by hash (2600); then **the BIOS's own test** applied to the image mapped flat with its end at $FFFF: the region byte at $FFF8, the low bits of $FFF9, and on NTSC the signature over $FF80-$FFF7 (start-here.md). A pass means 7800, a fail means 2600 and the image goes to `a2600-python`'s identification. This is what the console does, so it is not a heuristic of ours; with a BIOS image present the BIOS itself repeats the test at run time and the two must agree (a test). Homebrew `.bin` files without a valid signature are the case this gets "wrong" exactly as an NTSC console does: they need a header or a table row. ### What the loader does with an unknown headerless dump Options, for the user to choose (Open decisions): refuse; or load with a labelled guess. Recommended: **48 KiB or less: load as linear, TIA only, ProLine sticks, region from the BIOS test byte, with `certainty = "size"` printed once and kept in the description; over 48 KiB: refuse**, with a message that names the payload's SHA-256, says the scheme cannot be read from the bytes, and lists the three ways forward (an `.a78` of the same game, an `--as supergame,ram@4000,pokey@450` override, or a table row). No byte-pattern guessing. ### When an `.a78` header contradicts the table Both happen in the wild: headers are wrong ("Commando. If the game doesn't play Pokey music, you have a dump with a bad A78 header", wiki), and tables lag behind homebrew revisions. Recommended (Open decisions): **a table row whose source is the CC0 software list or a row we confirmed wins over the header; the header wins over an unconfirmed row and over size; the disagreement is always reported, field by field; `--trust header` and `--trust table` override.** ### A converter Recommended: ship `python -m a7800_python.cartridge convert`: - `.bin` to `.a78`: writes a v4 header (with v3 fields filled for older readers) from the description, only when every field has a source better than "default" or the user passes the missing ones; - `.a78` to `.bin`: strips the header; - `--check`: prints the description and its provenance, changes nothing. It writes only to the path the user names. The reason beyond convenience: **MAME 0.285 and A7800 5.2 both refuse a loose headerless file** (measured: "Not a valid A7800 image" / "Unspecified error"), so comparing against either detector on a dump outside MAME's software list needs a headered copy ([mame-oracle.md](mame-oracle.md), trap 1). The header writer is specified by the wiki page and `a78header.asm`; `7800header.c` (GPL-2.0) is not consulted for code. ## The High Score Cartridge and saves 2 KiB of battery-backed RAM at $1000-$17FF and 4 KiB of ROM at $3000-$3FFF, with the game cartridge plugged into it (wiki "7800 HSC technical reference", "HSC layout"). The ROM is copyrighted: bring your own, by hash (MAME's `a78_hsc` entry). The XM provides the same. SaveKey and AtariVox are the 2600's serial EEPROM on a controller port (`a2600-python` has it; AtariVox's speech is not modelled).