Files
romm/backend/tests/handler/snapshots/test_neutral.py
MMagTech 0b1e449b0f feat(saves): convert DS, Sega cartridge and Game Boy Advance saves through sigil (#5643)
* feat(saves): convert Nintendo DS saves through sigil

Sigil now converts a DS save between melonDS's raw file and DeSmuME's
.dsv, so a download with core= gets the file that emulator reads instead
of the stored one as is. DS moves from the native list to the platforms
sigil restores; like Saturn and Sega CD it carries no title id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(saves): accept a single-file neutral unit as sigil names it, for DS and Game Boy

Sigil names a cart's single-file unit after the content, `{stem}.srm`, and
sets the unit format; the neutral check only took `save.raw` for DS and
`save.sram` for Game Boy, so a client pushing sigil's own unit got a 422.
A SINGLE unit's one file may now carry sigil's name on those platforms;
multi-file units and every other platform keep their names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(saves): name DS among the cartridges that take no companions

Sigil refuses companions on every cartridge platform, DS included now
that it converts DS saves, so the refusal says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(saves): convert Mega Drive, 32X, Master System and Game Gear saves through sigil

genesis_plus_gx and picodrive keep these carts' save RAM at the same
offsets but fill and size it differently. With sigil converting between
them, the four platforms move from NATIVE_SAVE_PLATFORM_SLUGS to
SIGIL_RESTORE_PLATFORM_SLUGS (sigil slugs genesis, 32x, sms, gamegear),
so a download with core= gets the file that core keeps. The companion
refusal message names the new cartridges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(saves): accept the Sega cartridges' single-file neutral unit as sigil names it

Sigil names a Mega Drive, 32X, Master System or Game Gear unit after the
content, `{stem}.srm`. A SINGLE unit's one file may now carry that name,
as DS and Game Boy's may; RomM's `save.sram` still passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(saves): convert Game Boy Advance saves between emulators with sigil

GBA moves from the native-save platforms to the ones sigil reads at scan
time and restores for a core. The stored file doesn't load everywhere:
VBA Next keeps an EEPROM save at 128 KiB into a 136 KiB file, gpSP pads
every save to 128 KiB, and standalone mGBA appends the cart clock. The
scan stores the cart's save chip and clock in sigil_features, which sigil
uses to size a padded save. The tests that used GBA as their native
example now use SNES.

Needs a sigil pin with GBA collect and restore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(saves): accept a single-file GBA neutral unit as sigil names it

Sigil names a GBA cart's unit as it does a Game Boy's: the save alone as
`{stem}.srm`, or a clock cart's zip of `save.sram` and `clock.rtc`.
GBA now takes Game Boy's form, so the single file may carry sigil's name.
The clock-only form had no other platform left and goes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(saves): pin sigil at the DS merge, and take only a plain file name as its single unit

Both SIGIL_VERSION pins move to baa96b8 (rommapp/argosy-sigil#22), the
first sigil commit with DS. _SIGIL_SINGLE is [^/]+\.srm, so a single unit
named with a folder in it is refused; test_neutral.py checks it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(deps): pin sigil at the GBA merge

rommapp/argosy-sigil#24 is merged as 4980f69. Both SIGIL_VERSION pins
(Dockerfile, docker/Dockerfile) move from baa96b8 to that commit on
sigil's main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(deps): pin sigil at the Mega Drive merge

rommapp/argosy-sigil#23 is merged as be0809d. Both SIGIL_VERSION pins
(Dockerfile, docker/Dockerfile) move from baa96b8 to that commit on
sigil's main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(deps): pin sigil at 650b265

Both SIGIL_VERSION pins (Dockerfile, docker/Dockerfile) move from
be0809d to 650b265, sigil's main. It holds rommapp/argosy-sigil#23
(be0809d) and is the commit rommapp/romm#5758 pins, so the two
pull requests set the same value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(deps): pin sigil at 650b265

Both SIGIL_VERSION pins (Dockerfile, docker/Dockerfile) move from
baa96b8 to 650b265, sigil's main. It holds rommapp/argosy-sigil#22
(baa96b8) and is the commit rommapp/romm#5758 pins, so the two
pull requests set the same value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(deps): pin sigil at 650b265

Both SIGIL_VERSION pins (Dockerfile, docker/Dockerfile) move from
4980f69 to 650b265, sigil's main. It holds rommapp/argosy-sigil#24
(4980f69) and is the commit rommapp/romm#5758 pins, so the two
pull requests set the same value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(saves): name no systems in the companion refusal

The message listed the cartridges that take no companions, so each
platform added to sigil's restores edited it, and the open save PRs
(#5643 to #5647) each edited it differently. It now says what holds for
every platform: companions go only on memory cards and volumes. All five
carry the same line, so they merge in any order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(saves): name no systems in the companion refusal

The message listed the cartridges that take no companions, so each
platform added to sigil's restores edited it, and the open save PRs
(#5643 to #5647) each edited it differently. It now says what holds for
every platform: companions go only on memory cards and volumes. All five
carry the same line, so they merge in any order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(saves): name no systems in the companion refusal

The message listed the cartridges that take no companions, so each
platform added to sigil's restores edited it, and the open save PRs
(#5643 to #5647) each edited it differently. It now says what holds for
every platform: companions go only on memory cards and volumes. All five
carry the same line, so they merge in any order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(saves): restore Sega cart saves through RomM's platform map and binding

From review: the Mega Drive, 32X, Master System and Game Gear tests mock
the binding, so a slug sigil doesn't take would still pass. A ROM on each
RomM platform now goes through stored_game and the real binding, and the
restored file is checked in the form sigil's genesis.md gives the core:
genesis_plus_gx without trailing 0xFF, picodrive's 32 KiB for Master
System and Game Gear. rom_game is the same helper in #5643 to #5647.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(saves): restore a DS save through RomM's platform map and the binding

From review: the DS tests mock the binding, so a slug sigil doesn't take
for DS would still pass. A ROM on RomM's nds platform now goes through
stored_game and the real binding, and the restored file is checked in
the form sigil's nds.md gives each core: DeSmuME's .dsv ends in its
122-byte footer, melonDS's .sav is the save. rom_game is the same helper
in #5643 to #5647.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(saves): restore a GBA save through RomM's platform map and the binding

From review: the GBA tests mock the binding, so a slug sigil doesn't take
for GBA would still pass. A ROM on RomM's gba platform now goes through
stored_game and the real binding, and the restored file is checked at the
size sigil's gba.md gives each core: gpSP 128 KiB padded with 0xFF, VBA
Next 136 KiB, mGBA the chip. rom_game is the same helper in #5643 to
#5647.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(deps): pin sigil at ef9b51e

Both SIGIL_VERSION pins move from 650b265 to ef9b51e, sigil's main
since rommapp/argosy-sigil#30 merged, the commit rommapp/romm#5758
pins now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(deps): pin sigil at ef9b51e

Both SIGIL_VERSION pins move from 650b265 to ef9b51e, sigil's main
since rommapp/argosy-sigil#30 merged, the commit rommapp/romm#5758
pins now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(deps): pin sigil at ef9b51e

Both SIGIL_VERSION pins move from 650b265 to ef9b51e, sigil's main
since rommapp/argosy-sigil#30 merged, the commit rommapp/romm#5758
pins now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: MMagTech <mmagtech@Mac.home>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com>
2026-11-28 10:39:13 -05:00

66 lines
2.9 KiB
Python

import pytest
from handler.snapshots.neutral import NeutralUnitRejected, check_neutral_unit
from models.assets import SaveShape
@pytest.mark.parametrize(
"platform,shape,members",
[
("gb", SaveShape.SINGLE, ["save.sram"]),
("gb", SaveShape.SINGLE, ["Pokemon Red.srm"]),
("gbc", SaveShape.SINGLE, ["Pokemon Crystal.srm"]),
("gbc", SaveShape.MULTI, ["save.sram", "clock.rtc"]),
("gba", SaveShape.SINGLE, ["Pokemon Emerald.srm"]),
("gba", SaveShape.SINGLE, ["save.sram"]),
("gba", SaveShape.MULTI, ["save.sram", "clock.rtc"]),
("snes", SaveShape.SINGLE, ["save.sram"]),
("n64", SaveShape.MULTI, ["eeprom", "pak1"]),
("nds", SaveShape.SINGLE, ["save.raw"]),
("nds", SaveShape.SINGLE, ["Mario Kart DS.srm"]),
("saturn", SaveShape.MULTI, ["backup.ram", "cart.ram"]),
("dc", SaveShape.MULTI, ["vmu_A1.bin", "vmu_B2.bin"]),
("psx", SaveShape.SINGLE, ["anything.mcd"]),
("genesis", SaveShape.SINGLE, ["Sonic The Hedgehog 3 (USA).srm"]),
("genesis", SaveShape.SINGLE, ["save.sram"]),
("sega32", SaveShape.SINGLE, ["36 Great Holes (Europe).srm"]),
("sms", SaveShape.SINGLE, ["Phantasy Star (USA, Europe).srm"]),
("gamegear", SaveShape.SINGLE, ["Defenders of Oasis (USA, Europe).srm"]),
("gamegear", SaveShape.MULTI, ["save.sram"]),
],
)
def test_a_platforms_neutral_names_pass(
platform: str, shape: SaveShape, members: list[str]
):
check_neutral_unit(platform, shape, members)
@pytest.mark.parametrize(
"platform,shape,members",
[
("gb", SaveShape.MULTI, ["Pokemon Red.srm", "clock.rtc"]),
("nds", SaveShape.SINGLE, ["Mario Kart DS.dsv"]),
("nds", SaveShape.MULTI, ["Mario Kart DS.srm"]),
("nds", SaveShape.SINGLE, ["saves/Mario Kart DS.srm"]),
("snes", SaveShape.SINGLE, ["Game.srm"]),
("gba", SaveShape.MULTI, ["save.sram", "Pokemon.rtc"]),
("gba", SaveShape.MULTI, ["Pokemon Emerald.srm", "clock.rtc"]),
("gba", SaveShape.SINGLE, ["Pokemon Emerald.sav"]),
("gba", SaveShape.SINGLE, ["clock.rtc"]),
("gb", SaveShape.SINGLE, ["clock.rtc"]),
("snes", SaveShape.MULTI, ["save.sram", "clock.rtc"]),
("gb", SaveShape.SINGLE, ["save.sram", "clock.rtc"]),
("dc", SaveShape.MULTI, ["vmu_E1.bin"]),
("fds", SaveShape.SINGLE, ["save.sram"]),
("arcade", SaveShape.SINGLE, ["nvram"]),
("genesis", SaveShape.SINGLE, ["Sonic.sav"]),
("genesis", SaveShape.MULTI, ["Sonic.srm"]),
("gamegear", SaveShape.MULTI, ["save.sram", "clock.rtc"]),
("sms", SaveShape.SINGLE, ["Game.srm", "save.sram"]),
("nes", SaveShape.SINGLE, ["Zelda.srm"]),
],
)
def test_other_names_are_refused(platform: str, shape: SaveShape, members: list[str]):
with pytest.raises(NeutralUnitRejected):
check_neutral_unit(platform, shape, members)