Skip to content

player: reset a ROM's memory, and read the game's identity through the packer - #53

Merged
freezy merged 2 commits into
masterfrom
dev/player-improvements
Nov 15, 2026
Merged

freezy merged 2 commits into
masterfrom
dev/player-improvements

Conversation

@freezy

@freezy freezy commented Nov 15, 2026

Copy link
Copy Markdown
Member

Two changes for the player.

Back up and reset a ROM's memory. Settings > Plugins > PinMAME > Selected game gets "Back up and reset ROM memory". With the table closed in every VPE window, it moves the ROM's .nv file to nvram-backups/<rom> and no longer imports that ROM's NVRAM from Visual PinMAME, so the next run starts with fresh memory. The reset applies to every table that uses the same ROM. The README says how to restore the backup.

Read the game's identity through the packer. The identity reader looked the game up by its key name in the packed JSON, and VPE now writes package keys in camelCase. It unpacks the component's packable instead, so it reads whatever names the packer writes.

The identity reader looked the game up by its key name in the packed JSON, and VPE now writes package keys in camelCase. It unpacks the component's packable instead, so it reads whatever names the packer writes.
@freezy
freezy merged commit be731ee into master Nov 15, 2026
16 checks passed
@freezy
freezy deleted the dev/player-improvements branch November 15, 2026 13:53
@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect PinMAME game identity and saved memory for selected games.

The PR appears safe to merge, with a non-blocking request for tests around saved memory.

Findings

  1. P2 Save resets lack tests ▶

Summary

Adds a selected-game action that backs up a ROM's saved memory and prevents its NVRAM from being imported again from Visual PinMAME.

  • PinMAME games can back up and reset their shared ROM memory.
  • Packaged PinMAME games get their identity from the packer's data format.

No runtime tests were run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Selected-game reset action] --> B{Local emulator stopped?}
  B -->|No| C[Ask user to close table]
  B -->|Yes| D[Write import opt-out]
  D --> E[Move existing save to backup]
  E --> F[Next run skips VPM NVRAM import]
  F --> G[ROM starts with fresh memory]
Loading

Reviews (1) · Last reviewed commit: "packaging: read the game's identity thro..." · Reviewed by Greptile

Comment on lines +90 to +102
internal static string ResetNvram(string romId)
{
if (string.IsNullOrEmpty(romId) || romId.Any(c => !(c is >= 'a' and <= 'z' or >= '0' and <= '9' or '_'))) {
throw new ArgumentException("The selected table has an invalid PinMAME ROM name.", nameof(romId));
}
var dataFolder = DataFolder;
var backupFolder = Path.Combine(dataFolder, "nvram-backups", romId);
Directory.CreateDirectory(backupFolder);
// Keep the import opt-out beside the active save so clearing backups does not re-enable import.
using (File.Open(NvramImportOptOut(dataFolder, romId), FileMode.OpenOrCreate, FileAccess.Write)) { }
var backup = Path.Combine(backupFolder, $"{DateTime.UtcNow:yyyyMMdd-HHmmss}-{Guid.NewGuid():N}.nv");
try {
File.Move(Path.Combine(dataFolder, "nvram", romId + ".nv"), backup);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Save resets lack tests

ResetNvram changes saved game files but has no automated tests. Add temporary-folder tests for backup bytes, repeated resets, a missing save, and the import opt-out. Also check that resetting one ROM leaves another ROM's files alone. These checks would catch changes that silently lose a backup or bring back memory the user just cleared.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant