fix: read MAME's sets through its search paths

MAME splits rompath, samplepath, hashpath and pluginspath on semicolons
and tries each directory in turn (src/emu/fileio.cpp:53-58, 330-392,
src/emu/emuopts.cpp:44-46, 53). The launcher records spell those lists
with the game's own folder in them, which handed_directories skipped:

- RetroBat passes -rp bios;<rom directory> (Mame64.Generator.cs:93-96)
  and -rompath bios/psxmame/bios;<rom directory> to pSxMAME
  (PSXMame.Generator.cs:38-48).
- KNULLI passes -rompath <romDirname>;/userdata/bios/mame;/userdata/bios
  (mameGenerator.py:116-122).
- RetroPie writes rompath $romdir/mame;$romdir/arcade;$biosdir/mame
  (mame.sh:133).

A semicolon list now gives each directory but the game's folder. A pool
that already lists the folder the files take keeps them there, and a
pool standing for the whole layout holds its files, never its folders.
The MAME profile names its sets at the top of the rompath and its
search settings as pools, pSxMAME its sets and rompath.

RetroBat's -sp and -hash records split on `bool hbmame = emulator ==
"hbmame"` (Mame64.Generator.cs:30): bios/mame/samples for mame64,
bios/hbmame/samples for hbmame.

Manifests: RetroBat gains the 12 pSxMAME sets in psxmame/bios and drops
samples/bbc.zip, read by nobody, which mame/samples/bbc.zip already
serves. KNULLI drops the same copy. RetroPie gains the 1427 MAME sets
in BIOS/mame, the root copies staying for the libretro cores. EmuDeck
names samples/bbc.zip as read outside the BIOS folder. RetroDECK's
samplepath is $bios_path/mame-sa/samples (mame/component_prepare.sh:94,
117): bbc.zip moves there from bios/samples/. Its MAME runs with the
-rompath ES-DE passes, %GAMEDIR%;%ROMPATH%/<system>, so the standalone
sets are named as read outside the BIOS folder and the root copies stay
for the libretro core. The 1427 sets
of RetroBat, KNULLI and EmuDeck stay at the BIOS root, listed in their
rompath. No file of any manifest is lost.
This commit is contained in:
Abdessamad Derraz committed 2026-11-10 13:05:59 +01:00
1 parent 5e13f11e3f
commit 6947df629a
7 files changed
+1665 -22

No files matched your search

+41 -1
View File
@@ -3336,7 +3336,11 @@ def mame(sources: dict[str, Source]) -> list[Record]:
raise LauncherPatternMissing(own.path, "MAME folder arguments")
records = _covered(
own,
[_with_conditions(record, conditions) for record, conditions in found],
[
split
for record, conditions in found
for split in _per_emulator(own, _with_conditions(record, conditions))
],
# The bezel artwork folder is read by the launcher, not passed.
skip=(_BIOS_GUARD, r"ConfigureBezels\("),
)
@@ -3424,6 +3428,42 @@ def xroar(sources: dict[str, Source]) -> list[Record]:
return _covered(src, records)
_EMULATOR_BRANCH = re.compile(r"([^\s;<>]+) when (\w+), else ([^\s;<>]+)")
def _per_emulator(src: Source, record: Record) -> list[Record]:
"""A directory chosen by the emulator the generator runs, one record each.
Mame64.Generator.cs sets `bool hbmame = emulator == "hbmame";` and passes
`-sp bios/hbmame/samples` for it, bios/mame/samples for mame64. A choice
on any other condition is left as it reads.
"""
rendered = str(record.get("search_dir", ""))
branch = _EMULATOR_BRANCH.fullmatch(rendered)
if branch is None:
return [record]
chosen, flag, default = branch.groups()
declared = re.search(rf'bool {flag} = emulator == "([\w.-]+)";', _code(src))
if declared is None:
return [record]
ref = str(record["source_ref"])
if not ref.startswith(src.path + ":"):
raise LauncherPatternMissing(src.path, f"source of the directory choice {rendered!r}")
spans = [
(int(first), int(last or first))
for first, _, last in (s.partition("-") for s in ref[len(src.path) + 1:].split(", "))
]
spans.append(src.lines(declared.start(), declared.end()))
prefix = str(record["passes_to"]).removesuffix(rendered).strip()
out = []
for emulator, directory in ((declared.group(1), chosen), (record["emulator"], default)):
split = {k: v for k, v in record.items() if k != "source_ref"}
split.update(emulator=emulator, search_dir=directory, passes_to=f"{prefix} {directory}")
split["source_ref"] = _path_parts(src, *spans)
out.append(split)
return out
_SYSTEM_BRANCH = re.compile(r'(\S+), or (\S+) when system == "([\w.-]+)"')