Skip to contents

Mupen64 version 3 recordings. A single enabled controller returns a replayr_movie. Multiple enabled controllers return a replayr_poll_stream with all samples in source order, because M64 stores no per-sample port IDs. Digital columns are compact; button_layout() gives their stable IDs. Numeric source channels are always retained in analog_channels().

Usage

read_m64(
  path,
  analog = "raw",
  deadzone = NULL,
  triggers = "raw",
  aliases = TRUE,
  controller_order = NULL,
  ...
)

Arguments

path

Recording file path.

analog

Stick representation: "raw" (default), "cardinal4", "cardinal8", "angle", or "angle+magnitude". A scalar applies to both sticks; c(left = "cardinal8", right = "angle") selects them independently. Cardinal modes add separate left/right logical direction columns. Continuous modes return numeric fields through stick_channels(). Original X/Y values remain in analog_channels() in every mode. Absent sticks add no columns.

deadzone

Radial threshold in centred axis half-range units, from zero to one. One value applies to both sticks; named left/right values are allowed. NULL uses the default of the controller, whichever emulator recorded it: 0.125 for the sticks of Nintendo's consoles (Nintendo 64, GameCube, Wii extensions, 3DS) and 0.25 for all other sticks. The first is close to the 15 of 128 units that the GameCube's controller library discards on each axis (PAD_Clamp in libogc). The second covers the resting position of a released PlayStation stick, up to about 32 of 128 units from the centre (psx-spx), and is close to the 7849 and 8689 of 32767 that Microsoft gives for the thumbsticks of PC gamepads (XInput). A game applies a threshold of its own, which the recording does not store; give that value to study one game. Neutral observations have no direction and an NA angle. Magnitude is kept.

triggers

"raw" (default) or "digital". For DTM, digital additionally projects each analogue trigger at 128/255 into separate L2/R2 columns. Hardware L/R click bits remain distinct from thresholded analogue triggers.

aliases

TRUE (default) places the controls of a recording under the shared IDs that button_layout() describes. With FALSE, a control that would be placed under another control's ID keeps the key of its source, so every control of the recording has a column of its own and no two are combined.

controller_order

Optional sequence of distinct enabled controller ports (1–4) in an externally verified repeating polling order. NULL preserves an unassigned stream when multiple ports are enabled.

...

Reader-specific arguments, such as controller_order for M64 or DTM, or member for a recording inside a ZIP archive (see movie_members()).

Value

A replayr_movie for an assigned controller order, or a replayr_poll_stream for multiple controllers with unassigned ports.

Details

An externally verified repeating polling order can be supplied to construct per-player matrices. These use compact player indices in ascending physical port order; movie$header$controllerPorts gives the physical port for each player index. Enabled ports omitted from that order are treated as unpolled. Each output row is one supplied polling cycle, not a video frame. The source poll count and VI count remain in header$inputSampleCount and header$viCount; poll_bytes retains four original bytes per source poll. Import stops at the declared sample count, as Mupen playback does. Legacy writers can leave an extra terminal record or an older file suffix; these bytes remain in source_tail.

The header identifies the ROM by its internal name (header$romName), the CRC1 of its header (header$romHeaderCRC, "46039fb4" for the North American Kirby 64: The Crystal Shards), its country code (header$romCountry, such as "E" for North America and "J" for Japan) and its version (header$romVersion).

Examples

movie <- read_m64(system.file("extdata", "sample.m64", package = "replayr"))
observation_unit(movie)
#> [1] "controller poll"
head(analog_channels(movie), 3)
#>      left_x left_y
#> [1,]     70      0
#> [2,]     70      2
#> [3,]     70      4
# The stick as eight directions beside the buttons.
directions <- read_m64(system.file("extdata", "sample.m64", package = "replayr"),
  analog = "cardinal8")
n_buttons(directions)
#> [1] 22