Skip to contents

Imports Nintendo DS DSM versions 1 and 2 in text or binary form, with one row per recorded frame. player() includes the pad buttons, touch state, microphone activation, and lid state. button_layout() identifies the fields.

Usage

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

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.

...

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 with compact digital columns and source metadata.

Details

analog_channels() returns touch_x, touch_y, and touch_pressed. Touch coordinates use the screen's top-left origin, with a nominal extent of 256 by 192. Text recordings with a fourth numeric field also provide microphone_sample; absent samples are NA. The binary layout stores three touch fields. Stick options leave these source channels unchanged.

The commands component retains the original byte: microphone activation uses bit 0, reset uses bit 1, and lid state uses bit 2. Text records may be adjacent or separated by whitespace.

Examples

movie <- read_dsm(system.file("extdata", "legacy", "touch-v2.dsm", package = "replayr"))
movie
#> <replayr_movie [dsm] observations=6 players=1 buttons=14 source=touch-v2.dsm>
#> Header keys: version, emuVersion, microphoneSampleStored, system, commandEncoding, touchUnits
#> P1 active observations: start=1, select=1, l3=4, microphone=1
analog_channels(movie)
#>      touch_x touch_y touch_pressed microphone_sample
#> [1,]      20      10             1                 0
#> [2,]      50      30             1                 1
#> [3,]      80      50             1                 2
#> [4,]     110      70             1                 3
#> [5,]     140      90             0                 4
#> [6,]     170     110             0                 5