Skip to main content

Module movie_interop

Module movie_interop 

Source
Expand description

FCEUX .fm2 movie interop: import + export of FCEUX’s plain-text TAS movie format to and from the native Movie type.

.fm2 is ASCII text (see ref-proj/fceux/documentation/fm2.txt): a block of key value header lines (the first of which must be version 3), followed by an input-log section whose every line begins and ends with a | (pipe). The movie length is implicit – it is the number of input-log lines (FCEUX .fm2 note A).

§Scope and deliberate limitations

  • Standard gamepads only. RustyNES’s input model here maps FCEUX SI_GAMEPAD ports onto FrameInput. A port0/port1 declaring a zapper (SI_ZAPPER = 2) is rejected with Fm2Error::Unsupported rather than silently mis-mapped.
  • Power-on start only. A savestate-anchored .fm2 is rejected on import (cross-emulator save-state blobs are not portable), and a StartPoint::SaveState Movie is rejected on export. Both surface Fm2Error::Unsupported.
  • Two controllers stored. FrameInput models players 1 and 2 only. A fourscore .fm2 (four pads) is imported by keeping pads 1 and 2 and dropping pads 3 and 4; the fourscore flag is preserved in Fm2Meta so the caller is not silently misled. (TODO: carry P3/P4 once FrameInput grows beyond two ports.)
  • Soft reset has no home on FrameInput. The per-frame command field’s MOVIECMD_RESET bit (value 1) is parsed without error but is not applied to any frame today; see import_fm2.

§The RLDUTSBA pad order (a classic footgun)

Each gamepad field is exactly eight characters. Per FCEUX, the column order is the deliberately-reversed RLDUTSBA = Right, Left, Down, Up, sTart, Select, B, A (kept for back-compat with FCEUX’s first release). So character index 0 is the Right button and index 7 is the A button. A character of ' ' (space) or '.' means released; any other character (conventionally the button’s own mnemonic letter) means pressed.

This module is no_std-clean: it uses only core + alloc.

Structs§

Fm2ExportOpts
Options the caller supplies on export that the Movie itself does not carry. Mirrors the extra header fields surfaced by Fm2Meta on import.
Fm2Meta
Header metadata parsed from an .fm2 that has no home on Movie yet.

Enums§

Fm2Error
Errors produced by .fm2 import / export.

Constants§

FM2_VERSION
The only FCEUX .fm2 format version this module understands.

Functions§

export_fm2
Serialize a Movie to .fm2 text.
import_fm2
Parse .fm2 text into a Movie plus the leftover header Fm2Meta.