# SPDX-License-Identifier: MIT """Census of the Amiga disk and CD sets and of the Kickstart ROMs we hold, read in place. python -I scripts/census.py disks # $NO_INTRO_DIR/"Commodore - Amiga" python -I scripts/census.py discs # $REDUMP_DIR/"Commodore - Amiga CD|CD32|CDTV" python -I scripts/census.py kickstart # $MAME_ROMPATH sets and $AMIGA_BIOS_DIR Nothing is copied or written except the report on stdout. `disks` counts the No-Intro floppy set by region, tag, disks per title and image format, reading only the zip directories. `discs` counts the Redump CD sets (later machine rows). `kickstart` hashes every member of MAME's Amiga romsets and every file of a BIOS directory by SHA-1, and for each 256 KB / 512 KB / 1 MB image reads only the ROM header's version and revision words (offset 12, two big-endian 16-bit words: HRM appendix and the exec ROM tag) and the first ASCII name strings, so a file is named by what it is, not by its file name. Where the sets live is an environment variable, never a path in this repository: NO_INTRO_DIR, REDUMP_DIR, MAME_ROMPATH, AMIGA_BIOS_DIR (a folder of loose ROMs). """ from __future__ import annotations import argparse import collections import hashlib import os import re import sys import zipfile from pathlib import Path # MAME 0.285's Amiga drivers, the sets that hold Kickstarts (and the keyboard MCU's ROM). MAME_SETS = ( "a1000", "a500", "a500n", "a500p", "a500pn", "a2000", "a2000n", "a600", "a600n", "a1200", "a1200n", "a3000", "a3000n", "a4000", "a4000n", "a4000t", "cdtv", "cdtvn", "cd32", "cd32n", "a500kbd_us", "a1000kbd_us", "a2000kbd_us", "a1200kbd_rb", ) # fmt: skip # The images MAME 0.285 names (mame -listxml, 2026-11-26), by SHA-1: what each one is. KNOWN = { "11f9e62cf299f72184835b7b2a70a16333fc0d88": "Kickstart 1.2 (33.180), 256 KB (a500/a2000: 315093-01)", "891e9a547772fe0c6c19b610baf8bc4ea7fcb785": "Kickstart 1.3 (34.5), 256 KB (a500/a2000 default, cdtv: 315093-02)", "c5839f5cb98a7a8947065c3ed2f14f5f42e334a1": "Kickstart 2.04 (37.175), 512 KB (a500/a600/a2000: 390979-01)", "87508de834dc7eb47359cede72d2e3c8a2e5d8db": "Kickstart 2.05 (37.299), 512 KB (a600: 391388-01)", "f72d89148dac39c696e30b10859ebc859226637b": "Kickstart 2.05 (37.300), 512 KB (a600: 391304-01)", "02843c4253bbd29aba535b0aa3bd9a85034ecde4": "Kickstart 2.05 (37.350), 512 KB (a600 default: 391304-02)", "3b7f1493b27e212830f989f26ca76c02049f09ca": "Kickstart 3.1 (40.63), 512 KB (a500/a600/a2000: kick40063)", "999eb81c65dfd07a71ee19315d99c7eb858ab186": "Kickstart 3.0 (39.106) A1200, even half (391523-01)", "3341108d3a402882b5ef9d3b242cbf3c8ab1a3e9": "Kickstart 3.0 (39.106) A1200, odd half (391524-01)", "b8800f5f909298109ea69690b1b8523fa22ddb37": "Kickstart 3.1 (40.68) A1200, even half (391773-01)", "90e331be1970b0e53f53a9b0390b51b59b3869c2": "Kickstart 3.1 (40.68) A1200, odd half (391774-01)", "196e9f3f9cad934e181c07da33083b1f0a3c702f": "Kickstart 3.0 (39.106) A4000, even half (391513-02)", "42fbed3453d1f11ccbde89a9826f2d1175cca5cc": "Kickstart 3.0 (39.106) A4000, odd half (391514-02)", "d1713d7f31474a5948e6d488e33686061cf3d1e2": "Kickstart 2.0 (36.16) A3000, even half (390629-02)", "06807db3181637455f4d46582d9972afec8956d9": "CD32 Kickstart 3.1 + extended ROM, 1 MB (391640-03)", "277a1778924496353ffe56be68063d2a334360e4": "CDTV extended ROM, even half (391008-01)", "41b06d1679c6e6933c3378b7626025f7641ebc5c": "CDTV extended ROM, odd half (391009-01)", "2155b4887f064c5e01e0a2ebb4a0cc2a3e88d9e8": "A1000 bootstrap ROM, even (252179-01)", "2c307d02f10ad332a479b50767fd0463efc2844b": "A1000 bootstrap ROM, odd (252180-01)", "83b21d0c8b93fc9b9b3b287fde4ec8f3badac5a2": "keyboard MCU ROM, MOS 6570-036 (A500/A2000/A3000/A4000 keyboards), 2 KB", "ba10d16166b2e2d6177c979c99edf8462b21651e": "Logica Diagnostic 2.0, 512 KB (not a Kickstart)", } ROM_SIZES = (256 << 10, 512 << 10, 1 << 20) def tags_of(name: str) -> list[str]: return re.findall(r"\(([^)]*)\)", name) def disks(_: argparse.Namespace) -> int: base = os.environ.get("NO_INTRO_DIR") if not base: print("set NO_INTRO_DIR to the directory holding 'Commodore - Amiga'", file=sys.stderr) return 2 folder = Path(base) / "Commodore - Amiga" names = sorted(p.name for p in folder.iterdir() if p.suffix == ".zip") regions, tags, formats, per_title = (collections.Counter() for _ in range(4)) images = 0 sizes = collections.Counter() for name in names: groups = tags_of(name) regions[groups[0] if groups else "?"] += 1 for group in groups[1:]: key = re.sub(r"[ .\d]+$", "", group) if group.startswith(("Rev", "v", "r0")) else group tags[key] += 1 with zipfile.ZipFile(folder / name) as archive: members = [i for i in archive.infolist() if not i.is_dir()] per_title[len(members)] += 1 for info in members: formats[Path(info.filename).suffix.lower()] += 1 sizes[info.file_size // 1024] += 1 images += 1 print(f"{len(names)} zips, {images} disk images") print("image formats:", dict(formats)) print("disks per zip:", dict(sorted(per_title.items()))) print("regions (first tag):", dict(regions.most_common(15))) print("other tags (top 30):", dict(tags.most_common(30))) print("image sizes in KB (top 10):", dict(sizes.most_common(10))) return 0 def discs(_: argparse.Namespace) -> int: base = os.environ.get("REDUMP_DIR") if not base: print("set REDUMP_DIR", file=sys.stderr) return 2 for system in ("Commodore - Amiga CD", "Commodore - Amiga CD32", "Commodore - Amiga CDTV"): folder = Path(base) / system if not folder.is_dir(): print(f"{system}: not present") continue names = [p.name for p in folder.iterdir() if p.suffix == ".zip"] regions = collections.Counter((tags_of(n) or ["?"])[0] for n in names) print(f"{system}: {len(names)} zips; regions {dict(regions.most_common(8))}") return 0 def header(data: bytes) -> str: """The version/revision words at offset 12 and the first name strings, as text.""" if len(data) not in ROM_SIZES: return "" version, revision = int.from_bytes(data[12:14], "big"), int.from_bytes(data[14:16], "big") doubled = len(data) == 512 << 10 and data[: 256 << 10] == data[256 << 10 :] strings = re.findall(rb"[ -~]{8,}", data[: 64 << 10]) names = [s.decode() for s in strings if re.search(rb"(?i)exec|kick|aros|amiga ROM", s)][:2] tail = "" if doubled: half = hashlib.sha1(data[: 256 << 10]).hexdigest() tail = ( f", a 256 KB image doubled (the half's SHA-1 {half}: {KNOWN.get(half, 'not in MAME')})" ) return f"header {version}.{revision}{tail}; strings {names}" def kickstart(_: argparse.Namespace) -> int: seen: dict[str, list[str]] = {} info: dict[str, str] = {} rompath = os.environ.get("MAME_ROMPATH") if rompath: for name in MAME_SETS: path = Path(rompath) / f"{name}.zip" if not path.exists(): print(f"missing MAME set {name}.zip") continue with zipfile.ZipFile(path) as archive: for member in archive.namelist(): data = archive.read(member) digest = hashlib.sha1(data).hexdigest() seen.setdefault(digest, []).append(f"{name}.zip:{member}") info.setdefault(digest, header(data)) no_intro = os.environ.get("NO_INTRO_DIR") if no_intro: # No-Intro keeps its Amiga firmware as "[BIOS] ..." zips inside the floppy set. for path in sorted((Path(no_intro) / "Commodore - Amiga").glob("[[]BIOS[]]*.zip")): with zipfile.ZipFile(path) as archive: for member in archive.namelist(): data = archive.read(member) digest = hashlib.sha1(data).hexdigest() seen.setdefault(digest, []).append(f"No-Intro:{member}") info.setdefault(digest, header(data) or f"{len(data)} bytes") bios_dir = os.environ.get("AMIGA_BIOS_DIR") if bios_dir: for path in sorted(Path(bios_dir).iterdir()): if path.is_file() and path.stat().st_size in ROM_SIZES: data = path.read_bytes() digest = hashlib.sha1(data).hexdigest() seen.setdefault(digest, []).append(f"$AMIGA_BIOS_DIR/{path.name}") info.setdefault(digest, header(data)) for digest, role in KNOWN.items(): where = ", ".join(sorted(set(seen.get(digest, [])))) or "NOT FOUND" print(f"{digest} {role}\n {where}") # Other ROM-sized files: those from MAME's Amiga sets, and loose files whose first # 64 KB name an Amiga ROM (a shared BIOS folder holds other consoles' images too). unknown = [ d for d in seen if d not in KNOWN and info.get(d) and (any(w.startswith("No-Intro:") or ".zip:" in w for w in seen[d]) or "strings []" not in info[d]) and "Execute the boot file" not in info[d] ] # fmt: skip print(f"\n{len(unknown)} other Amiga ROM-sized image(s), not in MAME's list:") for digest in unknown: print(f"{digest} {info[digest]}\n {', '.join(seen[digest])}") return 0 def main() -> int: parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) parser.add_argument("what", choices=("disks", "discs", "kickstart")) args = parser.parse_args() return {"disks": disks, "discs": discs, "kickstart": kickstart}[args.what](args) if __name__ == "__main__": sys.exit(main())