CDA2
This is a format used at least for intro and finale cutscenes in the CD version of Alien Incident. There is apparently an earlier version of the format using CDAH
magic but it is unclear where it was used.
File header (all values are little-endian):
4 bytes - "CDA2" or "CDAH" 4 bytes - number of frames 2 bytes - unknown 2 bytes - width 2 bytes - height 2 bytes - rate (FPS*100, forced to 7000 in CDAH) 2 bytes - audio rate (forced to 22050 in CDAH) 2 bytes - flags (1 - subtitles present, forced to 0 in CDAH)
The header is followed by subtitles block (if present), 32-bit CRCs for each frame (CDA2 only), 32-bit frame sizes and actual frame data.
Subtitles
Subtitle data starts with 32-bit total size, 32-bit number of languages present and a table for each language mapping frame to current subtitle offset (from the start of the data block). Each text entry starts with 16-bit X and Y position (negative positions are used for a different alignment). Symbol '@
' in a string means newline.
Frame data
Frame data starts with a flag telling what kind of payloads it contains:
0x02
- audio data present (starting with 16-bit size)0x08
- next byte will tell now many ticks will each frame last (until the next such command)0x20
- fade command (16-bit R,G,B fading factors, 8-bit fading mode, 8-bit padding)0x10
- leave last frame unchanged (otherwise video frame data and/or palette follow)0x04
- video data present (the rest of the frame)0x01
- VGA palette present (either first 768 bytes of unpacked video data or in the following frame data)
Video (and optionally palette) data, if present, is compressed with modified LZSS (it is the same but window is initially filled with zeroes and instead of unpacked data size a 16- (for CDAH
) or 32-bit (for CDA2
) number of LZ operations is transmitted before the actual data).
Video frame is split into 32x40 tiles and may be coded in one of several ways. Tile modes are packed into nibbles and transmitted before the rest of the data. Tile modes are:
- 0 - read update bitmap for the whole tile (160 bytes) and read new pixel values for the pixels requiring update;
- 1 - read update bitmap for 2x2 blocks (40 bytes) and read new block pixels when required
- 2 - read update bitmap for 4x4 blocks (10 bytes) and read new block pixels when required
- 3 - read new tile contents
- other values - leave tile unchanged