feat: serve the pc engine cards to turbografx-cd

This commit is contained in:
Abdessamad Derraz committed 2026-09-03 17:51:34 +02:00
1 parent 1b3575fa48
commit 562e3fb20c
3 files changed
+110 -23

No files matched your search

+24 -1
View File
@@ -6,6 +6,8 @@ import json
import sys
import urllib.error
import urllib.request
import yaml
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from pathlib import Path
@@ -198,6 +200,24 @@ def fetch_github_latest_version(repo: str) -> str | None:
return None
class _PlatformDumper(yaml.SafeDumper):
"""Quote scalars that a YAML reader could misparse.
Names such as "7800 BIOS (E).rom" or "Bandai - WonderSwan: x" are plain
text, and a bare "01" would be read back as an integer.
"""
def _quoted_str(dumper: yaml.SafeDumper, data: str) -> yaml.ScalarNode:
style = None
if any(c in data for c in "()[]{}:#") or data.strip() != data or data.isdigit():
style = '"'
return dumper.represent_scalar("tag:yaml.org,2002:str", data, style=style)
_PlatformDumper.add_representer(str, _quoted_str)
def scraper_cli(
scraper_class: type, description: str = "Scrape BIOS requirements"
) -> None:
@@ -294,7 +314,10 @@ def scraper_cli(
if field in old_sys and field not in sys_data:
sys_data[field] = old_sys[field]
with open(output_path, "w") as f:
yaml.dump(config, f, default_flow_style=False, sort_keys=False)
yaml.dump(
config, f, Dumper=_PlatformDumper,
default_flow_style=False, allow_unicode=True, sort_keys=False,
)
print(f"Written {len(reqs)} entries to {args.output}")
return
+24 -11
View File
@@ -90,6 +90,7 @@ SLUG_MAP: dict[str, str] = {
"sufami-turbo": "nintendo-sufami-turbo",
"super-gb": "nintendo-sgb",
"tg16": "nec-pc-engine",
"turbografx-cd": "nec-pc-engine-cd",
"tvc": "videoton-tvc",
"videopac-g7400": "philips-videopac",
"wolfenstein": "wolfenstein-3d",
@@ -99,6 +100,17 @@ SLUG_MAP: dict[str, str] = {
}
# Slugs whose player runs the same core as another slug and reads firmware
# from its own folder. RomM keys the fixture by tg16 only, but its player maps
# both tg16 and turbografx-cd to mednafen_pce (frontend/src/utils/index.ts:540-541)
# and lists firmware per platform folder (backend/handler/filesystem/
# firmware_handler.py get_firmware_fs_structure), so a CD library without the
# system cards under its own slug cannot boot a disc.
FIRMWARE_MIRRORS: dict[str, tuple[str, ...]] = {
"tg16": ("turbografx-cd",),
}
class Scraper(BaseScraper):
"""Scraper for RomM known_bios_files.json."""
@@ -142,18 +154,19 @@ class Scraper(BaseScraper):
crc32 = (entry.get("crc") or "").strip() or None
size = int(entry["size"]) if entry.get("size") else None
requirements.append(
BiosRequirement(
name=filename,
system=system,
sha1=sha1,
md5=md5,
crc32=crc32,
size=size,
destination=f"{igdb_slug}/{filename}",
required=True,
for slug in (igdb_slug, *FIRMWARE_MIRRORS.get(igdb_slug, ())):
requirements.append(
BiosRequirement(
name=filename,
system=SLUG_MAP[slug],
sha1=sha1,
md5=md5,
crc32=crc32,
size=size,
destination=f"{slug}/{filename}",
required=True,
)
)
)
return requirements