mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-14 05:53:47 -06:00
feat: read libretro MAME's -rompath from ES-DE
ES-DE starts the libretro MAME core with a command line as its content
in 22 commands across 21 systems ("apple2e -rompath \"%GAMEDIRRAW%;
%ROMPATH%/apple2\" -flop1 ...", resources/systems/linux/es_systems.xml
at RetroDECK's 15e1b236 and EmuDeck's ES-DE v3.5.0), run through the
shell by popen (es-core/src/utils/PlatformUtil.cpp:231, 257).
At 5f5a0774 the core reads content that is no file as a command line
(retro_init.cpp:966-1008). Set_Path_Option passes its own -rompath
<content dir>;<system>/mame/bios;<system>/mame/roms (580-597), then
every word of the command line follows, -rompath included, only -rp
being dropped when mame_paths_enable is off (902-940, 914-919). MAME
keeps the later value of an option given twice at one priority
(src/lib/util/options.cpp:260-276, clifront.cpp:243). Those commands
read their sets in the folders they name, and mame/bios stays read by
every command that passes none.
The ES-DE parser records these commands in searched_by with their core,
the mame profile declares libretro_pools (-rompath and -rp stand for
mame/bios), and a set there also goes to each folder a command names
for a machine that reads it.
Manifests: EmuDeck gains 16 files below roms/ (apple2, apple2gs,
astrocde, crvision, gamate, gamecom, gmaster, intellivision, odyssey2,
scv, supracan, vectrex, videopac, vsmile). RetroDECK does not change:
its standalone MAME commands already put the same sets at the same
paths. No file leaves.
This commit is contained in:
1 parent
2173ba00d9
commit
7035da1154
10 files changed
+618
-52
No files matched your search
@@ -526,21 +526,55 @@ def _alternative_emulators(text: str, function: str) -> dict[str, tuple[str, int
|
||||
_ROMPATH_OPTIONS = ("-rompath", "-rp")
|
||||
|
||||
|
||||
def _core_words(command: str) -> tuple[str, list[str]] | None:
|
||||
"""The core and the words of the content RetroArch hands it.
|
||||
|
||||
ES-DE starts the libretro MAME core with a quoted command line as its
|
||||
content (`-L .../mame_libretro.so "apple2e -rompath \\"...\\" ..."`): popen
|
||||
runs it through the shell (es-core/src/utils/PlatformUtil.cpp:231, 257),
|
||||
and the core splits the content on spaces and quotes when it is no file
|
||||
(retro_init.cpp parse_cmdline, mmain2).
|
||||
"""
|
||||
core = _RA_CORE.search(command)
|
||||
if core is None:
|
||||
return None
|
||||
try:
|
||||
args = shlex.split(command)
|
||||
at = args.index("-L")
|
||||
content = shlex.split(args[at + 2]) if at + 2 < len(args) else []
|
||||
except ValueError:
|
||||
return None
|
||||
return core.group(1), content
|
||||
|
||||
|
||||
def _searched_by(commands: list[tuple[str, str, int | None]], key: str, path: str) -> list[dict]:
|
||||
"""The ROM folders each standalone emulator's commands pass it, by emulator.
|
||||
"""The ROM folders each emulator's commands pass it, by emulator and core.
|
||||
|
||||
ES-DE starts standalone MAME with `-rompath %GAMEDIR%\\;%ROMPATH%/<system>`
|
||||
and a machine, or %BASENAME% where the game is the machine. The command
|
||||
line outranks mame.ini. %GAMEDIR% is the game's own folder, no folder a
|
||||
pack fills.
|
||||
line outranks mame.ini. The libretro MAME core gets the same option in
|
||||
the command line it is handed as content, after the machine. %GAMEDIR%
|
||||
is the game's own folder, no folder a pack fills.
|
||||
"""
|
||||
found: dict[str, dict] = {}
|
||||
found: dict[tuple[str, str], dict] = {}
|
||||
for _label, command, line in commands:
|
||||
emulator = _EMULATOR.search(command)
|
||||
if emulator is None or _RA_CORE.search(command):
|
||||
continue
|
||||
words = command.replace("\\;", ";").split()
|
||||
at = next((i for i, w in enumerate(words) if w in _ROMPATH_OPTIONS), None)
|
||||
libretro = _core_words(command)
|
||||
if libretro is not None:
|
||||
core, words = libretro
|
||||
if words[:1] == [core]:
|
||||
# A first word naming the core is dropped (mmain2).
|
||||
words = words[1:]
|
||||
name = "retroarch"
|
||||
at = next((i for i, w in enumerate(words) if w in _ROMPATH_OPTIONS), None)
|
||||
machine = words[0] if words and at else ""
|
||||
else:
|
||||
emulator = _EMULATOR.search(command)
|
||||
if emulator is None:
|
||||
continue
|
||||
core, name = "", emulator.group(1).lower()
|
||||
words = command.replace("\\;", ";").split()
|
||||
at = next((i for i, w in enumerate(words) if w in _ROMPATH_OPTIONS), None)
|
||||
machine = words[at + 2] if at is not None and at + 2 < len(words) else ""
|
||||
if at is None or at + 1 >= len(words):
|
||||
continue
|
||||
reads = [
|
||||
@@ -549,11 +583,10 @@ def _searched_by(commands: list[tuple[str, str, int | None]], key: str, path: st
|
||||
]
|
||||
if not reads:
|
||||
continue
|
||||
name = emulator.group(1).lower()
|
||||
record = found.setdefault(name, {"emulator": name, "reads": [], "machines": [],
|
||||
"any_machine": False, "lines": []})
|
||||
record = found.setdefault((name, core), {"emulator": name, "core": core, "reads": [],
|
||||
"machines": [], "any_machine": False,
|
||||
"lines": []})
|
||||
record["reads"] += [r for r in reads if r not in record["reads"]]
|
||||
machine = words[at + 2] if at + 2 < len(words) else ""
|
||||
if not machine or machine.startswith("%"):
|
||||
record["any_machine"] = True
|
||||
elif machine not in record["machines"]:
|
||||
@@ -561,7 +594,10 @@ def _searched_by(commands: list[tuple[str, str, int | None]], key: str, path: st
|
||||
record["lines"].append(line)
|
||||
rows = []
|
||||
for record in found.values():
|
||||
row = {"emulator": record["emulator"], "reads": record["reads"]}
|
||||
row = {"emulator": record["emulator"]}
|
||||
if record["core"]:
|
||||
row["core"] = record["core"]
|
||||
row["reads"] = record["reads"]
|
||||
if record["machines"]:
|
||||
row["machines"] = record["machines"]
|
||||
if record["any_machine"]:
|
||||
|
||||
Reference in new issue
Block a user