#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Census of the Redump "Panasonic - 3DO Interactive Multiplayer" set, from names and zip directories only. Reads `$REDUMP_DIR/Panasonic - 3DO Interactive Multiplayer` (or --dir): one .zip per disc, each holding a .cue and one or more .bin tracks. Nothing is extracted, copied or hashed; only file names and each zip's central directory (member names, sizes, CRC-32s) are read. REDUMP_DIR=... python -I scripts/census_redump.py # names only REDUMP_DIR=... python -I scripts/census_redump.py --tracks # also each zip's directory The output is plain text, meant to be saved under tests/detectors/. """ from __future__ import annotations import argparse import collections import os import re import sys import zipfile from pathlib import Path SET = "Panasonic - 3DO Interactive Multiplayer" REGIONS = ("USA", "Europe", "Japan", "Asia", "Korea", "Germany", "France", "Italy", "Spain", "UK", "Australia", "Brazil", "Netherlands", "Sweden", "Russia", "World", "Taiwan", "Canada") TAGS = ("Demo", "Beta", "Proto", "Sample", "Unl", "Rev", "Kiosk", "Taikenban", "Program", "Trial", "Promo", "Alt", "Photo CD", "Video CD", "Disc") SECTOR = 2352 # Redump .bin tracks are raw 2352-byte sectors def parens(name: str) -> list[str]: return re.findall(r"\(([^)]*)\)", name) def region_key(groups: list[str]) -> str: for group in groups: parts = [p.strip() for p in group.split(",")] if any(p in REGIONS for p in parts): return ", ".join(parts) return "(none)" def main() -> int: parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) default = os.environ.get("REDUMP_DIR") parser.add_argument("--dir", default=str(Path(default) / SET) if default else None, help="default $REDUMP_DIR/" + SET) parser.add_argument("--tracks", action="store_true", help="read each zip's directory") args = parser.parse_args() if not args.dir: print("set REDUMP_DIR or pass --dir", file=sys.stderr) return 2 root = Path(args.dir) names = sorted(p.name for p in root.iterdir() if p.suffix.lower() == ".zip") print(f"set: Redump '{SET}'") print(f"discs (zip files): {len(names)}") bases = {n.split(" (")[0] for n in names} print(f"distinct base titles (text before the first parenthesis): {len(bases)}") regions: collections.Counter[str] = collections.Counter() exact: collections.Counter[str] = collections.Counter() tags: collections.Counter[str] = collections.Counter() multi_disc = 0 for name in names: groups = parens(name) key = region_key(groups) exact[key] += 1 for part in key.split(", "): regions[part] += 1 for group in groups: for tag in TAGS: if group == tag or group.startswith(tag + " ") or group.startswith(tag + ","): tags[tag] += 1 if any(g.startswith("Disc ") for g in groups): multi_disc += 1 print(f"discs with a (Disc N) tag: {multi_disc}") print("\nregion field, each region counted:") for region, count in regions.most_common(): print(f" {region:12} {count}") print("\nmost common exact region fields:") for region, count in exact.most_common(12): print(f" {count:6} {region}") print("\ntags (a parenthesis starting with the word):") for tag, count in tags.most_common(): print(f" {tag:12} {count}") if not args.tracks: return 0 track_counts: collections.Counter[int] = collections.Counter() audio_discs = 0 total_bytes = 0 sizes: list[int] = [] odd = [] for name in names: with zipfile.ZipFile(root / name) as archive: members = archive.infolist() bins = [m for m in members if m.filename.lower().endswith(".bin")] cues = [m for m in members if m.filename.lower().endswith(".cue")] if len(cues) != 1 or not bins: odd.append(name) track_counts[len(bins)] += 1 if len(bins) > 1: audio_discs += 1 disc = sum(m.file_size for m in bins) total_bytes += disc sizes.append(disc) if any(m.file_size % SECTOR for m in bins): odd.append(name + " (a track not a multiple of 2352 bytes)") sizes.sort() print("\ntracks per disc (.bin members):") for tracks, count in sorted(track_counts.items()): print(f" {tracks:3} tracks: {count}") print(f"discs with more than one track (data + CD-DA): {audio_discs}") print(f"total uncompressed track bytes: {total_bytes} ({total_bytes / 2**30:.1f} GiB)") mid = sizes[len(sizes) // 2] print(f"disc size: min {sizes[0] // SECTOR} sectors, median {mid // SECTOR}, " f"max {sizes[-1] // SECTOR} (74 min = 333,000 sectors)") print(f"zips with an unusual layout: {len(odd)}") for name in odd[:20]: print(f" {name}") return 0 if __name__ == "__main__": sys.exit(main())