pub struct MovieRecorder { /* private fields */ }Expand description
Records the per-frame input stream applied to an emulator.
Usage (caller-driven, mirrors the frontend’s per-frame loop):
let mut rec = MovieRecorder::power_on(&nes);
loop {
nes.set_buttons(0, p1);
nes.set_buttons(1, p2);
rec.capture(&nes); // BEFORE run_frame — captures the inputs it consumes
nes.run_frame();
}
let movie = rec.finish();Implementations§
Source§impl MovieRecorder
impl MovieRecorder
Sourcepub fn power_on(nes: &Nes) -> Self
pub fn power_on(nes: &Nes) -> Self
Begin recording a movie that starts from a fresh power-on of the ROM
nes is running. The caller is responsible for calling
power_on_for_movie on nes before the first captured frame so the
recording starts from the same state a replay will reconstruct.
v2.9.8: the machine’s HardwareOptions and BoardDescription are
captured here and written into the movie, so a host must set its
options before this call, not after.
Sourcepub fn from_current_state(nes: &Nes) -> Self
pub fn from_current_state(nes: &Nes) -> Self
Begin recording a movie that starts from nes’s current state (a
branch point). Captures a snapshot now and embeds it as the start
point; the input stream is recorded from here forward.
Sourcepub fn capture(&mut self, nes: &Nes)
pub fn capture(&mut self, nes: &Nes)
Record the controller inputs currently held on nes. Call this each
frame before Nes::run_frame, after the frontend has applied its
set_buttons calls — this captures exactly the inputs the upcoming
frame consumes.
§All four ports (v2.9.8)
Reads nes.buttons(0..=3). Until v2.9.8 FrameInput modelled ports
0 and 1 only, so a four-player session recorded half of what drove it
and diverged on playback; the .rnm format 3 epoch widened the record
and the struct together. Inputs that are not controller buttons –
expansion devices (Zapper, Vaus, keyboards …), the Famicom
microphone, Vs. coins / service, FDS disk swaps – are still not
recorded; see docs/frontend.md § “What a movie records”.
Sourcepub fn capture_input(&mut self, input: FrameInput)
pub fn capture_input(&mut self, input: FrameInput)
Record an explicit frame of input (for callers that drive input
programmatically rather than through set_buttons).
Sourcepub const fn options(&self) -> &HardwareOptions
pub const fn options(&self) -> &HardwareOptions
v2.9.8 — the options this recording was started with, which the movie
will carry. A host holds them in place for the length of the recording
(HardwareOptions::apply_live each frame), because the movie records
them once, at the start.
Sourcepub fn enable_attestation(&mut self)
pub fn enable_attestation(&mut self)
v2.3.2 “Lucid” — start accumulating a replay attestation.
Call before the first frame. The caller must then call
Self::attest_frame after every run_frame, in lockstep with
Self::capture, or the recorded hash will describe a different run
than the input stream does — which Movie::verify would then report as
a mismatch, correctly but unhelpfully.
Sourcepub fn disable_attestation(&mut self)
pub fn disable_attestation(&mut self)
Abandon an in-progress attestation, keeping the recording itself.
For a host that rewinds or otherwise moves the emulator off the timeline the accumulated hash describes. Once dropped it is not resumed: the prefix already folded in cannot be un-folded, and a partial hash that silently covers only part of the run would be worse than none.
Sourcepub fn attest_frame(&mut self, framebuffer: &[u8])
pub fn attest_frame(&mut self, framebuffer: &[u8])
Fold this frame’s video output into the attestation.
A no-op unless Self::enable_attestation was called. Pass the slice
Nes::run_frame returned (or Nes::framebuffer()), AFTER the frame ran.
Uses the input recorded by the matching Self::capture, so the two
must stay in lockstep — one capture then one attest_frame per frame.
If they drift the recorded frame counts disagree and Movie::deserialize
drops the tail, which is the safe direction.
Trait Implementations§
Source§impl Clone for MovieRecorder
impl Clone for MovieRecorder
Source§fn clone(&self) -> MovieRecorder
fn clone(&self) -> MovieRecorder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more