Difference between revisions of "Demo"

From DoomWiki.org

[unchecked revision][unchecked revision]
(e)
(Tags: Mobile edit, Mobile web edit)
(e)
(Tags: Mobile edit, Mobile web edit)
Line 305: Line 305:
 
* [[Turning resolution is lowered when recording demos]]
 
* [[Turning resolution is lowered when recording demos]]
  
== Sources ==
+
e
 
 
* ''This article uses material from the [http://doom.wikia.com/wiki/Demo "Demo"] article on the [http://doom.wikia.com Doom wiki] at [[wikipedia:Wikia|Wikia]] and is licensed under the [https://creativecommons.org/licenses/by-sa/3.0/ Creative Commons Attribution-Share Alike License].''
 
  
 
== External links ==
 
== External links ==

Revision as of 16:15, 11 May 2022

A demo (also called LMP, from the lump file extension) is any recording of a game session that can be played back using the game engine. Internally, it is a sequence of tic commands, keeping track of just the input control states during each frame. Thus, a demo is much more compact than a video capture, or even than a recording of the states of all objects in the level.

e

Custom demos

Players can record demos of their own game sessions. This is done using the -record <name> command line argument, which places the recording in a file named <name>.lmp in the Doom program directory. You can also add the -warp <map number> command to start recording from a specific map. A recording can subsequently be played back using the -playdemo <name> command line argument, where <name>.lmp is the name of the recorded demo. Unlike in the built-in demo sequence and when using -timedemo (see below), it's possible to toggle the automap mode while using -playdemo, because the feature that brings up the menu when pressing input keys or buttons is disabled.

These demo files can then be uploaded to websites and FTP servers to aid other players in the completion of the game, show off tricks, reveal secrets, or for competitive purposes (see Speedrun). It is also possible to record multiplayer games.

The -timedemo <name> parameter can be used as an alternative to -playdemo. This will render every frame in a demo as quickly as possible for benchmarking purposes.

Technical information

A demo lump is a sequence of instructions which tells the game engine what actions the player will perform: when he will take a step forward, turn around, shoot, switch weapons, etc. It is interpreted by the engine as keyboard and mouse input, thereby allowing anyone to watch a recreation of the original recorded actions. While some elements of the game (such as damage done by attacks) are typically randomized, the usage of a pseudorandom number generator ensures they stay the same with every playback.

Doom

The file starts with a header that specifies the map, skill level, and number of players. Versions after 1.2 extend the 7-byte header to 13 (0xD) bytes to also include information about the game version the demo was recorded with, what multiplayer mode was used, whether the -respawn, -fast, and -nomonsters parameters were used, and which player's point of view should be used.

byte purpose
up to 1.2 post-1.2 1.11
N/A 0 0 game version: 109 for version 1.9
0 1 1 skill level: Values 0 through 4 indicate "I'm too young to die" through "Nightmare!", respectively.
1 2 2 episode: always 1 for Doom 2
N/A N/A 3 Doom Classic mission "pack":
Value Pack
0 Ultimate Doom
1 Doom II
2 TNT: Evilution
3 The Plutonia Experiment
4 Master Levels
5 Nerve levels
2 3 4 map
N/A 4 5 multi-player mode: 1 means deathmatch, 2 altdeath, 0 is used for single-player or cooperative multi-player
N/A 5 6 non-zero value implies use of -respawn
N/A 6 7 non-zero value implies use of -fast
N/A 7 8 non-zero value implies use of -nomonsters
N/A 8 9 which player's point of view to use, zero-indexed (0 means player 1)
3 9 A set to 1 if player 1 present
4 A B set to 1 if player 2 present
5 B C set to 1 if player 3 present
6 C D set to 1 if player 4 present
N/A N/A E Doom Classic player states: 84 bytes (21 ints of 32-bits) for each player present, storing their health, armor, weapons and ammo

Immediately after this header is a series of player actions for each tic encoded in 4 bytes. There are 35 tics in a second. The first 3 bytes encode movement including speed, strafing and turning. The last byte encodes other actions such as using/opening, shooting, and changing weapon in a special format.

For this last byte, game events - namely, saving the game and pausing - are signaled when the highest bit, bit 7, is set to 1. If so, the lowest two bits are then checked. If the value is 01, the game issues a pause or unpause command. If the value is 10, the game saves to the slot encoded in bits 2, 3, and 4, which is treated as a three-bit value from 000 to 101. If there is a game event, the game does not check for any other button presses.

If the highest bit is not set, the game next looks to see if bit 2 is set. If so, the game executes a weapon change, using the values in bits 3, 4, and 5, treating the value like a 3-bit number, from 000 to 111, and activating a change to the weapon number key corresponding to one greater than the value, namely, from 1 to 8.

Finally, the game checks for a use command on bit 1, and a fire command on bit 0.

This structure is repeated for every player in the game.

byte purpose
0 forward/backward movement: Positive values indicate forward movement, negative backward. 50 is normally the highest achievable speed if running. 24 is the walking speed. Any number from -50 to 50 can be achieved with a mouse.
1 strafing: Positive values indicate rightward movement, negative leftward. 40 is the running speed, 24 without running. 50 is also achievable in a somewhat complicated way.
2 turning: Positive values are left turns, negative right.
3 This byte encodes multiple actions in different bits. Indexing is from the least significant bit:
bit purpose
0 If set, the weapon is fired; or in special mode pause is toggled
1 opens a door or flips a switch; or in special mode the game to saved to the slot specified by the next three bits: 1xx0001x is slot 1, 1xx1011x is slot 6
2 changes to the weapon slot specified by the next three bits: xx0001xx is slot 1, xx1101xx is slot 7
6 unused
7 sets special mode, changing the meaning of the first two bits

Following the series is a 0x80 byte at the end of the lump.

Because the demo format is composed of a series of tic commands rather than a video of recorded gameplay, demo lumps are relatively small and were very practical back when computers were slow and Internet bandwidth was scarce. The size of an uncompressed single-player demo lump is 140 bytes per second (or 4 bytes per tic) plus a few (8 or 14) bytes of overhead. Back then, it would certainly have been nearly impossible to distribute demos as video captures due to their large size.

Over the years, a few utility programs have been written to convert LMPs between the original binary format and other formats. One such program is LMPC, which can also be used for hex editing of demos (see TAS).

Heretic

The structure in Heretic is similar to Doom, but features additional information as Heretic features three additional types of commands:

  • Looking up and down
  • Flying up and down
  • Using inventory items

To store them in tic commands, there are two additional bytes, one for looking and flying, and the other for artifact use.

The header is similar to 1.2 header, and does not store game version or other parameters.

byte purpose
0 skill level: values 0 through 4 indicate "thou needeth a wet-nurse" through "black plague possesses thee", respectively.
1 episode
2 map
3 set to 1 if player 1 present
4 set to 1 if player 2 present
5 set to 1 if player 3 present
6 set to 1 if player 4 present

The tic commands take six bytes:

byte purpose
0 forward/backward movement: Positive values indicate forward movement, negative backward. 50 is normally the highest achievable speed if running. 24 is the walking speed. Any number from -50 to 50 can be achieved with a mouse.
1 strafing: Positive values indicate rightward movement, negative leftward. 40 is the running speed, 24 without running. 50 is also achievable in a somewhat complicated way.
2 turning: Positive values are left turns, negative right.
3 This byte encodes multiple actions in different bits. Indexing is from the least significant bit:
bit purpose
0 If set, the weapon is fired; or in special mode pause is toggled
1 opens a door or flips a switch; or in special mode the game to saved to the slot specified by the next three bits: 1xx0001x is slot 1, 1xx1011x is slot 6
2 changes to the weapon slot specified by the next three bits: xx0001xx is slot 1, xx1101xx is slot 7
6 unused
7 sets special mode, changing the meaning of the first two bits
4 looking and flying: looking uses the lower four bits, and flying the upper four bits, forming two values between 0 and 15. They are translated as such:
Value Look Fly
Between 0 and 7 Looking up Flying up
8 Centering view Pausing flight and dropping to the ground
Between 8 and 15 Looking down Flying down
For looking and flying down, the value is made negative by subtracting 16 from it, obtaining a value between -1 and -7.
5 artifact use, value indicates which artifact is being used:
  1. Ring of Invulnerability
  2. Shadowsphere
  3. Quartz Flask
  4. Mystic Urn
  5. Tome of Power
  6. Torch
  7. Timebomb of the Ancients
  8. Morph Ovum
  9. Wings of Wrath
  10. Chaos Device

The special value 255 indicates an unsuccessful attempt at using an artifact.

Following the series is a 0x80 byte at the end of the lump.

e

Strife

The structure in Strife is similar to the post-1.2 version of Doom's demos, but it omits the episode entirely. As a result, Strife demos have odd sizes, while all other demos have even sizes.

byte purpose
0 version (101)
1 skill level: Values 0 through 4 indicate "Training" through "Bloodbath", respectively.
2 map
3 multi-player mode: 1 means deathmatch, 2 altdeath, 0 is used for single-player or cooperative multi-player
4 non-zero value implies use of -respawn
5 non-zero value implies use of -fast
6 non-zero value implies use of -nomonsters
7 which player's point of view to use, zero-indexed (0 means player 1)
8 set to 1 if player 1 present
9 set to 1 if player 2 present
10 set to 1 if player 3 present
11 set to 1 if player 4 present

Like in Heretic and Hexen, the tic commands take six bytes, with a byte used for additional player actions and another used to store inventory actions.

byte purpose
0 forward/backward movement: Positive values indicate forward movement, negative backward. 50 is normally the highest achievable speed if running. 24 is the walking speed. Any number from -50 to 50 can be achieved with a mouse.
1 strafing: Positive values indicate rightward movement, negative leftward. 40 is the running speed, 24 without running. 50 is also achievable in a somewhat complicated way.
2 turning: Positive values are left turns, negative right.
3 This byte encodes multiple actions in different bits. Indexing is from the least significant bit:
bit purpose
0 If set, the weapon is fired; or in special mode pause is toggled
1 opens a door or flips a switch; or in special mode the game to saved to the slot specified by the next three bits: 1xx0001x is slot 1, 1xx1011x is slot 6
2 changes to the weapon slot specified by the next two bits: xxx001xx is slot 1, xxx111xx is slot 4
5 unused
6 unused
7 sets special mode, changing the meaning of the first two bits
4 This byte encodes additional actions in different bits:
bit purpose
0 looking up
1 looking down
2 centering view
3 use selected inventory
4 drop selected inventory
5 jump
6 unused
7 use surgery kit
5 selected inventory: this is the number of the inventory item's sprite in the sprite table.

Following the series is a 0x80 byte at the end of the lump.

Demo issues

With few exceptions, demos can only be played back with the same versions of the Doom IWAD and executable or source port as those used during recording. If a demo is played on a different source port, using a different WAD(s), or even with a different version of the same source port or IWAD, it may refuse to run, or the actions of the player in the demo may become nonsensical, with the Doomguy crashing into walls and shooting apparently at random. This is known as a "desync", and indicates that the demo is not compatible with the playback method being used.

Display commands not affecting gameplay, such as chat text and the IDDT cheat code, are not recorded in a LMP file and may be used freely during playback. However, other cheat codes are not recorded either, and will almost certainly corrupt the demo if used during recording, or cause a desync if entered during playback.

Many of the demos on the Internet are of version 1.9 format, because it marks the final versions of the games. Older versions are rarer, as the engine versions they were recorded with are obsolete and did not have as much exposure to dedicated players over time. The idgames archive, for example, purged a number of older demos at one point, keeping only demos of the latest version. Additionally, this is the format used in Compet-n, the premier speedrunning site for demos in the original levels of the games. Newer demo sites do include a good number recordings for source ports, however, especially of levels from user-made PWADs.

For some players, it is not practical or even possible to use the original Doom executables to play demos. The original executables were written for DOS, and require DOS or a DOS-like OS environment to function properly. While this has been made easier with the development of the multi-platform DOSBox emulator, there are also alternatives among the source ports, as most, though not all, demos recorded with id Software's DOS executables will play properly in PrBoom, the Eternity Engine, or Chocolate Doom because these ports are specifically designed to emulate vanilla Doom as closely as possible. On the other hand, an assortment of modern source ports, such as Doomsday or ZDoom, do not record demos in Doom's original demo format, because their movement code requires the recording of extra data (such as Y-axis viewpoints and trajectories, jumping, or even flat heights and thing dispositions as in a savegame) even if the associated features are not being utilised.

Other issues that can affect recording or playback:

e

External links

References