The core of rerecording is the use of savestates along with movie recording. These 2 events can create a complex logic that must be carefully implemented.
Terminology used in this section:

Movie mode and Emulator read-only/read+write states:

The interaction of user input, savestates, and other tools depend on various modes that a movie could be in. There are 4 possible movie modes.
implementation of movie mode is typically an Enum value.

Read-only vs read+write

The emulator will keep track of read-only and read+write states. These don't immediately affect a movie. The affect happens on a loadstate event. At that point, the emulator read-only status will determine the behavior of the loadstate.
implementation is typically a simple boolean value

Savestate interaction with movies

A movie savestate differs from a non-movie savestate in that it has movie data embedded into it. This data is embedded upon the savestate event. The entire movie contents are always stored in any movie mode other than inactive. In addition, the current frame count must be stored. This is critical information since the savestate movie-length can not be a reliable means of determining it. The relationship between savestate movie-length and the savestate framecount will play a vital role in various savestate logic decisions.

Loadstate interaction with movies

When a movie is loaded, savestates should store movie data. This is the hallmark of solid input recording and has been termed "Bulletproof Rerecording". The implementation of this logic can be rather complex due to the interaction of the four movie modes and the 2 read-only states. Here is a breakdown per mode of what should happen:
(note: in all logic chains, the act of "resuming" after loadstate error may require that a backup state was made before loadstate attempt)

Mode Inactive

Playback or Recording + Read-only

Playback, Recording + Read+write

Post-movie savestate event

Further study

FCEUX movie.cpp implements 100% of the documented material on this page.

LawsOfTAS/OnSavestates last edited by on 1/1/2022 6:13 PM
Page History Latest diff List referrers View Source