Skip to main content

Module movie

Module movie 

Source
Expand description

TAS movie record/playback — a deterministic input log plus a System::save_state-compatible start point.

docs/adr/0004’s determinism contract: same seed + ROM + input ⇒ bit-identical framebuffer/audio. Ported from RustyNES’s proven rustynes-core::movie shape (confirmed by reading its source directly), SNES-adapted: a single FrameInput per frame (the SNES auto-joypad latches one u16 per controller, unlike the NES’s separate button set), and the start point’s seed is recorded explicitly since System::new takes a caller-chosen seed rather than always defaulting to one value.

MovieRecorder/MoviePlayer are pure data + a capture/apply loop — no Lua/frontend coupling, and no System/Bus reach-around either (see MoviePlayer::next_frame’s doc for why). The frontend’s per-frame drive calls MovieRecorder::capture (recording) or MoviePlayer::next_frame (playback) and feeds the result through whatever input abstraction it already uses, immediately before crate::System::run_frame — the same place it already applies live controller input today.

§Format

HEADER:
    magic            : "RSNESMOV"  (8 bytes)
    format version   : u16 LE       (1 = MOVIE_FORMAT_VERSION)
    region           : u8           (0 = NTSC, 1 = PAL)
    seed             : u64 LE       (the System::new seed this recording used)
    rom sha-256      : [u8; 32]     (full hash — authoritative ROM identity, checked on replay)
    frame count      : u32 LE
START POINT:
    kind             : u8           (0 = power-on, 1 = embedded save-state)
    [save-state]     : u32 LE length-prefixed bytes (only when kind == 1)
INPUT STREAM:
    frame_count * 4 bytes; each frame = p1 (u16 LE), p2 (u16 LE)

Structs§

FrameInput
One frame’s worth of recorded controller input — the SNES auto-joypad’s latched u16 per port (the same value crate::bus::Bus::set_joypad takes).
Movie
A recorded TAS movie: a deterministic input log plus everything needed to reproduce the exact power-on/branch-point state it was recorded against.
MoviePlayer
Replays a recorded Movie’s input log against a System already positioned at its start point (via Movie::seek_to_start).
MovieRecorder
Records a movie frame-by-frame as the emulator runs.

Enums§

MovieError
Errors from decoding or replaying a movie.
StartPoint
Where a movie’s replay begins.

Functions§

hash_rom
SHA-256 of rom, in the form Movie::rom_sha256 / Movie::verify_rom compare against.