Skip to contents

Reads CTAS versions 3 and 4 of CoffeeTools, a recording tool for the game UFO 50. Each row contains one frame's input for both players: four directions, ufo50_fire1, ufo50_fire2, and Start. The Start column records a press event; the other six columns record held states.

Usage

read_ctas(
  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 held states, press/release flags, and randomisation data.

Details

movie$pressed and movie$released retain the six controls' separate press and release flags as frame-by-player-by-control logical arrays. For example, movie$pressed[, 1, "ufo50_fire1"] selects player 1's first action-button press events. These flags are read from the file alongside held states, allowing a game's press and hold behaviour to be compared.

movie$randomization contains the recorded input_frame and seed pairs in source units. movie$source_words retains both players' input words, and movie$source_header retains the original header. Version 4 adds rerecord_count and current_time to movie$header; those fields are NA for version 3. Rows use the file's frame index; randomisation frame numbers are retained exactly as stored.

Examples

path <- system.file("extdata", "computers", "two-player-actions.ctas",
  package = "replayr")
movie <- read_ctas(path)
movie
#> <replayr_movie [ctas] observations=4 players=2 buttons=7 source=two-player-actions.ctas>
#> Header keys: format, emulator, game, version, frame_count, observation_unit, rerecord_count, current_time, ...
#> P1 active observations: dpad_right=3, a=2
as.data.frame(movie, idx = 2L)
#>   observation dpad_right dpad_left dpad_down dpad_up start     b     a commands
#> 1           1      FALSE     FALSE     FALSE   FALSE FALSE FALSE FALSE        0
#> 2           2      FALSE     FALSE     FALSE    TRUE FALSE FALSE FALSE        0
#> 3           3      FALSE     FALSE     FALSE    TRUE FALSE FALSE FALSE        0
#> 4           4      FALSE     FALSE     FALSE   FALSE  TRUE FALSE FALSE        0