#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Census of 3DO firmware by SHA-1: which known BIOS and font (kanji) ROMs are on hand. Hashes every file of the right size (512 KiB or 1 MiB) in the 3do_* / 3dobios / alg3do sets under $MAME_ROMPATH (zip members are hashed in memory, never extracted) and in each directory given with --dir or $FRONTEND_BIOS, and matches them against KNOWN below. The firmware is never copied or committed; the output names files and SHA-1s only. MAME_ROMPATH=... python -I scripts/census_bios.py --dir "$FRONTEND_BIOS" KNOWN holds identifying facts (name, size, SHA-1) as MAME 0.285's `-listroms` prints them for the 3do driver (run 2026-11-26; docs/bios.md), the model each belongs to, and its kind. """ from __future__ import annotations import argparse import hashlib import os import sys import zipfile from pathlib import Path # sha1: (MAME file name, size, model / MAME machine, kind) KNOWN: dict[str, tuple[str, int, str, str]] = { "34bf189111295f74d7b7dfc1f304d98b8d36325a": ("panafz1.bin", 1 << 20, "Panasonic FZ-1 USA (3do_fz1)", "BIOS"), "de3c55490733e6c69724d87e149b52ed955638ed": ("panafz1_dev_0.9.bin", 1 << 20, "FZ-1 development BIOS 0.9 (3do_fz1)", "BIOS"), "4cb4ee36e0f5bc0995d34992b4f241c420d49b2e": ("panafz1_dev.bin", 1 << 20, "FZ-1 development BIOS (3do_fz1)", "BIOS"), "3c912300775d1ad730dc35757e279c274c0acaad": ("panafz10.bin", 1 << 20, "Panasonic FZ-10 USA (3do_fz10)", "BIOS"), "f05e642322c03694f06a809c0b90fc27ac73c002": ("panafz10-norsa.bin", 1 << 20, "FZ-10, RSA check removed (3do_fz10)", "BIOS (modified)"), "a900371f0cdcdc03f79557f11d406fd71251a5fd": ("panafz10e-anvil.bin", 1 << 20, "FZ-10 Europe, Anvil chipset (3do_fz10e)", "BIOS"), "2765c7b4557cc838b32567d2428d088980295159": ("panafz10e-anvil-norsa.bin", 1 << 20, "FZ-10 Europe Anvil, RSA removed (3do_fz10e)", "BIOS (modified)"), "fe7f9c9c6a98910013bf13f2cf798de9fea52acd": ("panafz10j.bin", 1 << 20, "FZ-10 Japan (3do_fz10j)", "BIOS"), "2e857b957803d0331fd229328df01f3ffab69eee": ("panafz10ja-anvil-kanji.bin", 1 << 20, "FZ-10 Japan Anvil (3do_fz10j)", "font ROM (kanji)"), "1d0db81e171ebc1d07cefc8ce8ab082306186e56": ("panafz1e.bin", 1 << 20, "FZ-1 Europe (3do_fz1e)", "BIOS"), "4696951e492e5526772a860ea2c0f35411a80927": ("panafz1e-unencrypted.bin", 1 << 20, "FZ-1 Europe, unencrypted (3do_fz1e)", "BIOS (modified?)"), "ec7ec62d60ec0459a14ed56ebc66761ef3c80efc": ("panafz1j.bin", 1 << 20, "FZ-1 Japan (3do_fz1j)", "BIOS"), "a417587ae3b0b8ef00c830920c21af8bee88e419": ("panafz1j-norsa.bin", 1 << 20, "FZ-1 Japan, RSA removed (3do_fz1j)", "BIOS (modified)"), "884515605ee243577ab20767ef8c1a7368e4e407": ("panafz1j-kanji.bin", 1 << 20, "FZ-1 Japan (3do_fz1j, 3do_try)", "font ROM (kanji)"), "8ef7503c948314d242da47b7fdc272f68dac2aee": ("goldstar_fc1_enc.bin", 1 << 20, "Goldstar FC-1 (3do_fc1)", "BIOS"), "bd325c869e1dde8a3872fc21565e0646a3d5b525": ("3do_devkit_1.0fc2.bin", 1 << 20, "FC-2 development kit (3do_fc2)", "BIOS"), "c4a2e5336f77fb5f743de1eea2cda43675ee2de7": ("goldstar.bin", 1 << 20, "Goldstar GDO-101M (3do_gdo101)", "BIOS"), "29c40515dc1174ff13975baa59eb532083e4a3d3": ("sanyo_hc21_alpha.bin", 1 << 20, "Sanyo HC-21 prototype, alpha (3do_hc21)", "BIOS"), "c389af32bcadf0d86826927dc3d20b7072f90069": ("sanyo_hc21_b3_unenc.bin", 1 << 20, "Sanyo HC-21 prototype, b3 unencrypted (3do_hc21)", "BIOS"), "b01c53da256dde43ffec4ad3fc3adfa8d635e943": ("sanyotry.bin", 1 << 20, "Sanyo IMP-21J TRY (3do_try)", "BIOS"), "520d3d1b5897800af47f92efd2444a26b7a7dead": ("saot_rom2.bin", 1 << 19, "American Laser Games 3DO arcade (alg3do)", "ROM2"), } SETS = ("3do_fz1", "3do_fz10", "3do_fz10e", "3do_fz10j", "3do_fz1e", "3do_fz1j", "3do_fc1", "3do_fc2", "3do_gdo101", "3do_hc21", "3do_try", "3dobios", "alg3do", "orbatak") SIZES = (1 << 19, 1 << 20) # Loose files are hashed when their size is a BIOS size or their name looks like a 3DO # firmware file (frontends name the kanji ROM in several ways and some copies are short). NAMES = ("panafz", "3do", "goldstar", "sanyo", "kanji", "fz1", "fz10", "fc1", "fc2", "hc21") def main() -> int: parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) parser.add_argument("--dir", action="append", default=[], help="loose firmware directory (repeatable); default $FRONTEND_BIOS") args = parser.parse_args() dirs = args.dir or ([os.environ["FRONTEND_BIOS"]] if os.environ.get("FRONTEND_BIOS") else []) found: dict[str, list[str]] = {} unknown: list[str] = [] rompath = os.environ.get("MAME_ROMPATH", "") for root in [Path(p) for p in rompath.split(";") if p]: for name in SETS: archive = root / f"{name}.zip" if not archive.exists(): continue with zipfile.ZipFile(archive) as zf: for info in zf.infolist(): if info.file_size not in SIZES: continue sha1 = hashlib.sha1(zf.read(info)).hexdigest() where = f"$MAME_ROMPATH {name}.zip:{info.filename}" (found.setdefault(sha1, []) if sha1 in KNOWN else unknown).append( where if sha1 in KNOWN else f"{where} {sha1}") for index, directory in enumerate(dirs): for path in sorted(Path(directory).iterdir()): named = any(key in path.name.lower() for key in NAMES) if not path.is_file() or not (named or path.stat().st_size in SIZES): continue sha1 = hashlib.sha1(path.read_bytes()).hexdigest() where = f"--dir[{index}] {path.name}" if sha1 in KNOWN: found.setdefault(sha1, []).append(where) elif named: unknown.append(f"{where} {sha1} ({path.stat().st_size} bytes)") print(f"known firmware images: {len(KNOWN)}; on hand: {len(found)}") for sha1, (name, size, model, kind) in KNOWN.items(): mark = "have" if sha1 in found else "MISSING" print(f" {mark:7} {sha1} {size:8} {kind:18} {name} - {model}") for where in found.get(sha1, []): print(f" {where}") print(f"3DO-named or zip files not in the table: {len(unknown)}") for line in unknown: print(f" {line}") return 0 if __name__ == "__main__": sys.exit(main())