Next Previous Contents

3. Data

The data starts in byte 0x0009 (old Duke Nukem 3D), 0x0018 (new Duke Nukem 3D) or 0x021F (Redneck Rampage) of the DMO file and is organized in several blocks.

3.1 Block

Each block consists of a header with some organizational information and the compressed data.

A block header is:


address type contents 0x0000 word size of the following blockin bytes 0x0002 word size of the uncompresseddata block in bytes 0x0004 word biggest code for Lempel-Zivdecompression

The compressed data starts in byte 0x0006 of the block. The block size (0x0000/0x0001) includes the rest of the header. This means there are only block size - 4 data bytes.

3.2 Compression technique

Duke Nukem 3D uses a modified Lempel-Ziv algorithm (similar to the UNIX command compress(1)) to compress the game tics. To reach an even better compression ratio not the game tic itself but the difference to the last one of the same player (difference per byte, without carry bits) will be compressed. This increases the number of 0 bytes enormously and allows long recording in short files.

In fact Steffen Winterfeldt changed the original compress.c until we could decompress a DMO file.

If you are really more interested in the compression/decompression routines look in the files lzw.c and unlzw.c included in LMPC, the Little Movie Processing Centre. You can get it from my Demo Specs page.

The compression algorithm used in Redneck Rampage seems to be similar but I did not get lzw.c and unlzw.c to work with Redneck Rampage recordings.

3.3 Macro block

Some blocks of data form a macro block. This has to do with both decompression and game tic difference storing. The first game tic in a macro block is the original game tic. All the following game tics are only the byte-per-byte difference game tics to its specific predecessors. There is no special code to signalize the end of a macro block. It is simply the number 2520/(player number) game tics, which makes a macro block. Note that 2520 is divisible by 1,2, ... ,8 without remainder. Only the last macro block may contain less game tics if the file ends before.

3.4 Data description

One game tic corresponds to 10 times player number bytes:
address type player contents 0x0000 word 1 go in x-direction 0x0002 word 1 go in y-direction 0x0004 word 1 turn 0x0006 long 1 use/open etc. 0x000a word 2 go in x-direction 0x000c word 2 go in y-direction . . .

Go x and y

The 2 words (signed short) are duke's speed or the displacement vector in length units per game tic.

To calculate the absolute value of his speed just calculate sqrt(x2+y2).

A standard speed is 1280 (with running 2560). The coordinate system used is like this:

            |
            |
            |
------------+-----------> x
            |
            |
            |
           \|/
            y

Turn

The turn word contains 2 bytes (signed short) which are the current turning speed or the angle difference per game tic. A positive turning speed means right and a negative means left.

Use

There are many ``use'' actions in Duke Nukem 3D. You can do all at once, because there is a single bit for each action. The apropriate bit is 1 as long as you press the corresponding key.


bit purpose 31 ?? 30 Inventory 29 Open 28 TurnAround 27 Inventory_Right 26 ?? 25 Jetpack 24 Holo_Duke 23 Mouse_Aimingnew in 1.1 22 ?? 21 Pause 20 Inventory_Left 19 Holster_Weapon 18 Center_View 17 AutoRun 16 MedKit 15 NightVision 14 Look_Down 13 Look_Up 12 Steroidsnew in 1.1 8-11 Weapon number 7 ?? 6 ?? 5 Run 4 Aim_Down 3 Aim_Up 2 Fire 1 Crouch 0 Jump


Next Previous Contents