Skip to contents

Imports demos of Doom, Heretic and Hexen and of the source ports that keep their demo format: Doom 1.2 and earlier, Doom 1.4 to 1.9 (versions 104-109), TASDoom (110), Doom 1.91 (111), Boom (200-202), LxDoom and MBF (203), PrBoom (210-214) and MBF21 (221), with or without the outer header that dsda-doom or PrBoom+um put in front. Each row is a game tic at 35 tics per second. header$enabledPorts identifies the players whose commands were stored.

Usage

read_lmp(
  path,
  analog = "raw",
  deadzone = NULL,
  triggers = "raw",
  aliases = TRUE,
  game = NULL,
  longtics = 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.

game

"doom", "heretic" or "hexen". Required for a demo without a version byte; every other demo identifies its own layout.

longtics

For Heretic and Hexen demos: TRUE if turning was recorded with 16 bits and the header does not say so, FALSE to rule that out, NULL (default) to follow the header.

...

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

A demo stores what the game was asked to do in each tic, not the keys or buttons behind it. player() returns the actions Attack and Use, and Jump for Hexen and for demos with dsda-doom's header; button_layout() lists them with IDs of their own (action:attack, action:use, action:jump). analog_channels() returns signed forwardmove, sidemove and angleturn: how fast the player asked to move forward and sideways, and how far to turn in that tic, in 1/256 of a revolution. Demos with 16-bit turning keep the finer steps as fractions of that unit. Heretic and Hexen add look and fly, from -7 to 7; -8 asks to centre the view or to stop flying. All of these are commands assembled from the input devices, so stick options leave them unchanged.

Weapon selection and special-command flags remain in header$weaponselect and header$has_special; commands retains the special-command bytes. Artifact commands of Heretic and Hexen are in header$artifact, Hexen's player classes in header$playerClass, and dsda-doom's extended commands in header$extendedCommands. Game options remain in header$gameOptions.

Demos of Doom 1.2 and earlier, of Heretic and of Hexen begin with the skill level and do not name their game, and the three layouts differ, so game is required for them. Heretic and Hexen demos can store 16-bit turning; later ports mark this in the header, Heretic+ and Hexen+ do not, and longtics = TRUE reads such a demo. A demo that fits the file only when read that way is refused with a message that says so.

source_header and source_packets preserve the recorded bytes, and source_tail preserves bytes after the demo-end marker: c(source_header, t(source_packets), as.raw(0x80), source_tail) is the file.

Examples

demo <- read_lmp(system.file("extdata", "sample.lmp", package = "replayr"))
button_layout(demo)
#>   column            id           key        mnemonic   name   kind
#> 1      1 action:attack action_attack {action_attack} Attack action
#> 2      2    action:use    action_use    {action_use}    Use action
head(analog_channels(demo))
#>      forwardmove sidemove angleturn
#> [1,]          25        0         2
#> [2,]          25        0         2
#> [3,]          25        0         2
#> [4,]          25        0         2
#> [5,]          25        0         2
#> [6,]          25        0         2