Pray for Death CDA

From MultimediaWiki
Jump to navigation Jump to search

This is a format used for cutscenes in the game.

File header:

 6 bytes - "LSANM\x01"
 1 byte  - version (only version 2 is known)
 1 byte  - audio channels
 2 bytes - sampling rate
 2 bytes - width
 2 bytes - height
 2 bytes - unknown, usually 17
 2 bytes - number of palettes
 4 bytes - data start offset
 4 bytes - number of frames
 4 bytes - audio block size

The header is followed by the frame properties structure (for each frame):

 4 bytes - video part size
 4 bytes - audio part size
 3 bytes - unknown
 1 byte  - frame repeat count
 1 byte  - frame type
 1 byte  - fade parameter

Then one or more palette records follow:

 1 byte  - number of colours minus one
 1 byte  - fade part present flag
 N*3 bytes - VGA palette entries
 N*16 bytes - some fade-related information (only when fade part present flag is set)

Known frame types are:

  • 0 - ordinary frame
  • 1 - frame uses a new palette
  • 2 - fade out start frame
  • 3 - fade out start frame with new palette
  • 5 - fade in start frame with new palette
  • 6 - fade in start frame

First frame should signal that it uses a new palette and when a new palette is desired a frame should signal that and the next palette from the set above will be selected.

Fading is performed by going from 0 to 64 (or from 64 down to 0) using fade increment/decrement value associated with the frame and scaling current palette by that value divided by 64.

Audio compression

Audio block starts with 32-bit number of samples in the block and one or two initial 8-bit sample values. The rest of the samples are coded as deltas to the previous value in interleaved order (i.e. left delta, right delta, left delta ...) using the following codes:

  • 0xxxx - use signed 4-bit delta value
  • 10xxxxx - use signed 5-bit delta plus or minus eight depending on the sign (e.g. 00001 = 9 and 11111 = -9)
  • 11xxxxxxxx - use new 8-bit value as is.

Video compression

Video part starts with frame type which should be 0 or 1 (compression seems to be identical but only type 1 frames were observed in the samples) and 32-bit number of opcodes. Opcodes are bytes with optional additional data. Their meanings are:

  • 0 -- read next byte, skip as many pixels plus 45;
  • 1 -- read next 16-bit value, skip as many pixels plus 45;
  • 2 -- read next byte, skip as many pixels plus 301;
  • 3 -- read next byte, skip as many pixels plus 557;
  • 4 -- RLE with 1-byte colour value and 16-bit run value;
  • 5 -- same as case 4 but with 8-bit run value;
  • 6-59 -- RLE of length 0-53 with 1-byte colour value;
  • 60-129 -- read 0-69 pixels;
  • 130-169 -- copy 6-45 pixels from the 16-bit reference offset;
  • 170-209 -- same but copying is done in backward direction (e.g. if offset=42 that means copy frm[42], frm[41], frm[40], ...);
  • 210-255 -- skip 0-45 pixels.