movie.hpp

Classes to read and write data from Mupen64 input files.

struct frame

Represents a frame of input.

enum class button : uint16_t

An enum representing the button bitmask. One can apply bitwise operators to it.

enumerator A = 0x8000

The A button.

enumerator B = 0x4000

The B button.

enumerator Z = 0x2000

The Z button.

enumerator START = 0x1000

The START button.

enumerator D_UP = 0x0800

The up button on the D-pad.

enumerator D_DOWN = 0x0400

The down button on the D-pad.

enumerator D_LEFT = 0x0200

The left button on the D-pad.

enumerator D_RIGHT = 0x0100

The right button on the D-pad.

enumerator L = 0x0020

The L button.

enumerator R = 0x0010

The R button.

enumerator C_UP = 0x0008

The C-up (also written C^) button.

enumerator C_DOWN = 0x0004

The C-down (also written Cv) button.

enumerator C_LEFT = 0x0002

The C-left (also written C< or in TASInput as C) button.

enumerator C_RIGHT = 0x0001

The C-right (also written C>) button.

A single input frame.

m64::button buttons

A bitmask representing buttons.

int8_t stick_x

The joystick’s X-value as a signed byte.

int8_t stick_y

The joystick’s Y-value as a signed byte.

void apply(sm64 &game)

Sets the input variables on the libsm64 instance to the inputs of this frame.

Parameters

game – The game to set inputs on

class m64 final

A Mupen64 input movie. I plan to add metadata access and saving soon, stay tuned!

m64(std::filesystem::path path)

Loads an .m64 from a file path.

Frame list operations

type iterator

An iterator over the frames of this M64.

type const_iterator

A const iterator over the frames of this M64.

m64::frame &operator[](uint32_t index)
const m64::frame &operator[](uint32_t index) const

Returns a reference to the indexth input frame of this M64. Does not check input bounds.

Parameters

index – The index of the frame to get

Returns

the requested frame

m64::frame &at(uint32_t index)
const m64::frame &at(uint32_t index) const

Returns a reference to the indexth input frame of this M64. Unlike m64::operator[](), at() checks input bounds.

Parameters

index – The index of the frame to get

Returns

the requested frame

Throws

std::out_of_range – if index >= this->size()

m64::frame &front()
const m64::frame &front() const

Returns a reference to the first frame of this M64. Equivalent to (*this)[0] or *(this->begin()).

Returns

the first frame of this M64

m64::frame &back()
const m64::frame &back() const

Returns a reference to the last frame of this M64. Equivalent to (*this)[this->size() - 1] or *(this->end()).

Returns

the first frame of this M64

uint32_t size() const

Returns the number of frames in this M64.

Returns

the number of frames

iterator begin()
const_iterator begin() const

Returns an iterator at the start of this M64.

Returns

an iterator at the start of this M64.

iterator end()
const_iterator end() const

Returns an iterator at the end of this M64.

Returns

a const iterator at the end of this M64.

const_iterator cbegin() const

Returns a const iterator at the start of this M64.

Returns

a const iterator at the start of this M64.

const_iterator cend() const

Returns a const iterator at the end of this M64.

Returns

a const iterator at the end of this M64.

void push_back(const m64::frame &frame)

Appends a frame onto the end of this M64.

Parameters

const m64::frame& frame – The frame to append. Will be copied.

void push_back(m64::frame &&frame)

Appends a frame onto the end of this M64.

Parameters

frame – The frame to append. Will be moved.

void pop_back()

Removes the last frame of this M64.

Metadata and serialization

struct metadata_s

A struct holding metadata about the M64.

uint32_t version

The version of this M64. Should be 3, otherwise you have a REALLY old file.

uint32_t timestamp

The recording timestamp. Used as a UID of sorts for linking to savestates. I don’t know the specifics of the whole UID thing, ask someone who works on Mupen64.

uint32_t num_vis

The length of this M64 in VIs (visual frames). Hex editing tools will usually max this value out.

uint32_t rerecords

The number of rerecords (times that a savestate was used).

uint8_t vis_per_s

Essentially amounts to frames per second.

uint8_t num_controllers

The number of controllers used.

uint32_t num_input_frames()

Returns the number of input frames. This is a function rather than a reference in order to avoid copying issues.

enum class start_flags

A flag deciding how to start this M64.

enumerator FROM_SNAPSHOT = 0x01

Starts this M64 from a savestate of the same name.

enumerator FROM_START = 0x02

Starts this M64 from reset.

enumerator FROM_EEPROM = 0x04

Not sure what this does, I just know that this is a thing in new Mupen.

start_flags start_type

The start flag used by this M64.

enum class ctrler_flags

A bitfield for controller info. One can perform bitwise operations on it.

enumerator CONTROLLER1_PRESENT = 0x0001
enumerator CONTROLLER2_PRESENT = 0x0002
enumerator CONTROLLER3_PRESENT = 0x0004
enumerator CONTROLLER4_PRESENT = 0x0008

Indicates the presence of a controller.

enumerator CONTROLLER1_MEMORY = 0x0010
enumerator CONTROLLER2_MEMORY = 0x0020
enumerator CONTROLLER3_MEMORY = 0x0040
enumerator CONTROLLER4_MEMORY = 0x0080

Indicates the presence of a controller’s Memory Pak.

enumerator CONTROLLER1_RUMBLE = 0x0100
enumerator CONTROLLER2_RUMBLE = 0x0200
enumerator CONTROLLER3_RUMBLE = 0x0400
enumerator CONTROLLER4_RUMBLE = 0x0800

Indicates the presence of a controller’s Rumble Pak.

ctrler_flags controllers

The controller flags for this controller.

std::string rom_name

The internal ROM name, in ASCII.

Note

Only the first 31 characters will be serialized, if this field exceeds that length.

uint32_t crc

The CRC of the ROM, taken directly from the ROM file. The field is read as little-endian during deserialization.

uint32_t country_code

The country code of the ROM, taken directly from the ROM file. THe field is read as little-endian during deserialization.

std::string video_plugin
std::string input_plugin
std::string sound_plugin
std::string rsp_plugin

The emulator plugins used (as ASCII strings).

Note

Only the first 63 characters of each of these fields will be serialized, should any of them exceed that length.

std::string authors

The authors of this M64.

Note

Only the first 221 characters of this field will be serialized, should this field exceed that length.

std::string description

The description of this M64.

Note

Only the first 255 characters of this field will be serialized, should this field exceed that length.