fix: file RomM extras under their own system

This commit is contained in:
Abdessamad Derraz committed 2026-10-18 15:19:19 +02:00
1 parent 23551ba219
commit e3b17b04d2
5 files changed
+1426 -1225

No files matched your search

+1323 -1212
View File
File diff suppressed because it is too large. Load diff
+22
View File
@@ -252,6 +252,28 @@ systems:
crc32: f25cf3a8
size: 2189528
native_system: arcade
snk-neogeo-aes:
files:
- name: neogeo.zip
destination: neogeoaes/neogeo.zip
required: true
sha1: deb62b0074b8cae4f162c257662136733cfc76ad
md5: 00dad01abdbf8ea9e79ad2fe11bdb182
crc32: "81315163"
size: 1859335
native_system: neogeoaes
mirror_of: arcade
snk-neogeo-mvs:
files:
- name: neogeo.zip
destination: neogeomvs/neogeo.zip
required: true
sha1: deb62b0074b8cae4f162c257662136733cfc76ad
md5: 00dad01abdbf8ea9e79ad2fe11bdb182
crc32: "81315163"
size: 1859335
native_system: neogeomvs
mirror_of: arcade
atari-400-800:
files:
- name: ATARIBAS.ROM
+25 -10
View File
@@ -108,21 +108,24 @@ def _map_emulator_to_slug(
return ""
def _slug_for(
u: dict, profiles: dict, platform_systems: set, norm_map: dict, sys_to_slug: dict
u: dict, profiles: dict, platform_systems: set, norm_map: dict, sys_to_slug: dict,
native_systems: set | None = None,
) -> str:
"""The platform slug a report entry files under, or empty.
The entry's own system decides first: picodrive's Mega CD BIOS belongs
under segacd/, where RomM looks for a Mega CD game's firmware, not under
gamegear/, the first of the emulator's systems.
The entry's own system decides, and alone: picodrive's Mega CD BIOS
belongs under segacd/, where RomM looks for a Mega CD game's firmware,
and a file of a system the platform lacks has no folder there (MAME
2003's ZN-1 BIOS once fell back on its Neo Geo systems). A file of no
system takes the emulator's first system the platform declares for
itself: a folder present only as a mirror of another slug's firmware
(RomM's neogeoaes/) says nothing about the emulators that read it.
"""
own = u.get("system")
if own:
slug = _map_emulator_to_slug(
return _map_emulator_to_slug(
{"systems": [own]}, platform_systems, norm_map, sys_to_slug
)
if slug:
return slug
emu_name = u.get("profile") or u.get("emulator", "")
profile = profiles.get(emu_name, {})
if not profile:
@@ -130,7 +133,17 @@ def _slug_for(
profile = next(
(pp for pp in profiles.values() if pp.get("emulator") == emu_name), {}
)
return _map_emulator_to_slug(profile, platform_systems, norm_map, sys_to_slug)
systems = platform_systems if native_systems is None else native_systems
native_norm = {k: v for k, v in norm_map.items() if v in systems}
return _map_emulator_to_slug(profile, systems, native_norm, sys_to_slug)
def native_slug_systems(config: dict) -> set[str]:
"""Systems the platform declares at least one file of its own for."""
return {
sid for sid, data in (config.get("systems") or {}).items()
if any(not f.get("mirror_of") for f in data.get("files", []))
}
def hidden_extras(
@@ -223,11 +236,12 @@ def unplaceable_extras(config: dict, undeclared: list[dict], profiles: dict) ->
return set()
platform_systems = set(config.get("systems", {}).keys())
norm_map = {_norm_system_id(sid): sid for sid in platform_systems}
native = native_slug_systems(config)
return {
(u.get("emulator", ""), u.get("name", ""), u.get("path") or "")
for u in undeclared
if u.get("in_repo")
and not _slug_for(u, profiles, platform_systems, norm_map, sys_to_slug)
and not _slug_for(u, profiles, platform_systems, norm_map, sys_to_slug, native)
}
@@ -550,6 +564,7 @@ class ExtraPlacement:
self.prefix = _detect_extras_prefix(config, base_dest)
self.slug_based, self.sys_to_slug = _detect_slug_structure(config)
self.platform_systems = set(config.get("systems", {}).keys())
self.native_systems = native_slug_systems(config)
self.norm_map = (
{_norm_system_id(sid): sid for sid in self.platform_systems}
if self.slug_based
@@ -567,7 +582,7 @@ class ExtraPlacement:
if self.slug_based:
slug = _slug_for(
entry, self.profiles, self.platform_systems, self.norm_map,
self.sys_to_slug,
self.sys_to_slug, self.native_systems,
)
if not slug:
return None
+17 -3
View File
@@ -79,6 +79,8 @@ SLUG_MAP: dict[str, str] = {
"msx2": "microsoft-msx",
"nds": "nintendo-ds",
"neo-geo-cd": "snk-neogeo-cd",
"neogeoaes": "snk-neogeo-aes",
"neogeomvs": "snk-neogeo-mvs",
"nes": "nintendo-nes",
"ngc": "nintendo-gamecube",
"odyssey-2-slash-videopac-g7000": "magnavox-odyssey2",
@@ -114,8 +116,15 @@ SLUG_MAP: dict[str, str] = {
# 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",),
#
# Mirrors are per file, not per core: a slug sharing a core with another reads
# only the firmware that core needs for its own system. The Neo Geo slugs run
# fbneo, as arcade does (index.ts:410-418), and fbneo boots every Neo Geo
# game from neogeo.zip; the fixture gives it to arcade alone. None mirrors
# every file of the slug.
FIRMWARE_MIRRORS: dict[str, dict[str, tuple[str, ...] | None]] = {
"tg16": {"turbografx-cd": None},
"arcade": {"neogeoaes": ("neogeo.zip",), "neogeomvs": ("neogeo.zip",)},
}
@@ -163,7 +172,12 @@ class Scraper(BaseScraper):
crc32 = (entry.get("crc") or "").strip() or None
size = int(entry["size"]) if entry.get("size") else None
for slug in (igdb_slug, *FIRMWARE_MIRRORS.get(igdb_slug, ())):
mirrors = [
slug
for slug, names in FIRMWARE_MIRRORS.get(igdb_slug, {}).items()
if names is None or filename in names
]
for slug in (igdb_slug, *mirrors):
requirements.append(
BiosRequirement(
name=filename,
+39
View File
@@ -4821,5 +4821,44 @@ class AHashListIsReadOneWay(unittest.TestCase):
self.assertEqual(set(entry_hashes(entry)), {a, b.lower(), "deadbeef"})
class RommNeoGeoFoldersGetTheirBios(unittest.TestCase):
"""RomM runs fbneo for neogeoaes and neogeomvs as for arcade and reads
firmware per platform folder; the fixture gives neogeo.zip to arcade
alone, so a Neo Geo game in its own folder started without it."""
def test_the_mirror_is_per_file(self):
from scripts.scraper.romm_scraper import FIRMWARE_MIRRORS, SLUG_MAP
arcade = FIRMWARE_MIRRORS["arcade"]
self.assertEqual(arcade["neogeoaes"], ("neogeo.zip",))
self.assertEqual(arcade["neogeomvs"], ("neogeo.zip",))
self.assertIn("neogeoaes", SLUG_MAP)
def test_a_file_files_under_its_own_system_only(self):
# Adding the Neo Geo slugs sent MAME 2003's ZN-1 BIOS and data files
# into neogeoaes/, and FBNeo's CPS3 sets already sat in colecovision/:
# a system the platform lacks has no folder, and a mirror-only
# folder attracts no system-less file.
from scripts.packextras import _slug_for
config_systems = {"arcade", "snk-neogeo-aes", "nintendo-ds"}
sys_to_slug = {"arcade": "arcade", "snk-neogeo-aes": "neogeoaes",
"nintendo-ds": "nds"}
profiles = {"mame2003": {"systems": ["snk-neogeo-aes", "zn1-acclaim"]},
"melonds": {"systems": ["nintendo-ds", "nintendo-dsi"]}}
args = (profiles, config_systems, {}, sys_to_slug, {"arcade", "nintendo-ds"})
self.assertEqual(_slug_for({"profile": "mame2003", "system": "zn1-acclaim"}, *args), "")
self.assertEqual(_slug_for({"profile": "mame2003"}, *args), "")
self.assertEqual(_slug_for({"profile": "melonds", "system": "nintendo-dsi"}, *args), "")
self.assertEqual(_slug_for({"profile": "melonds"}, *args), "nds")
def test_the_platform_file_carries_it(self):
text = (ROOT / "platforms" / "romm.yml").read_text(encoding="utf-8")
self.assertIn("destination: neogeoaes/neogeo.zip", text)
self.assertIn("destination: neogeomvs/neogeo.zip", text)
self.assertNotIn("neogeoaes/pgm.zip", text)
if __name__ == "__main__":
unittest.main()