SCRYMAMEReferenceCapturessnapshotAlso in DOSBox-X

MAMECaptures

snapshot

Save a still of the screen as it is now to a PNG file.

snapshot(dest="")

Try it

On Gridlee, a free ROM from mamedev.org, stopped while the card that announces a level is on screen.
Ask

Save a picture of the screen as it is now to card.png.

Call
snapshot(dest="./tmp/demos/tour/card.png")
Reply 2 of 6 fields
{
  "path": "./tmp/demos/tour/card.png",
  "view": "native"
}

The still is a complete PNG at path. native is the MAME view it was drawn through.

The whole reply
JSON
{
  "summary": "<volatile>",
  "status": "ok",
  "path": "./tmp/demos/tour/card.png",
  "bytes": "<volatile>",
  "sha256": "<volatile>",
  "view": "native"
}

Arguments

dest string, default ""
A new path for the PNG, absolute or starting with ~, in a folder that exists. Left empty, the session's temporary folder, deleted at close.

What comes back

path
The PNG, checked to be complete.
sha256
The file's SHA-256: the value a line of reference checksums holds for image_compare(method="golden").
view
The MAME view the still was drawn through, chosen at start.
All 4 reply fields
  • bytes (integer)
  • path (string)
  • sha256 (string)
  • view (string or object)

What it refuses

Why it works this way

The still is MAME's own snapshot, and it works while the program runs. To capture a finished picture and not one half drawn, run_to the address where the drawing routine ends, then take the snapshot.

MAME's snap command treats even an absolute path as relative to its snapshot folder, so the tool takes the still under its own name and moves the file. MAME's command line cannot carry the characters refused in dest.

A dest is checked before MAME is asked, so a refused path costs no snapshot.

The contract your client receives
Text
Save a PNG of the screen now, through `view`, in the scratch or moved to `dest`, which must
be a new absolute or `~`-led path in an existing directory. Works while running.

Reply: `path`, `bytes`, `sha256`, `view`. An incomplete PNG is `INVALID`.

Reference: REFERENCE.md, Input and the screen.
Tools