C93
C93 is a video format used in Interplay's game Cyberia. It is not seems that is has been used anywhere else (Cyberia 2 comes with a slightly modified version named M95). 93 is most likely refers to format creation year.
C93 operates in standard VGA 320x200x256 resolution and based on BTC encoding and simple block copying.
File structure
File begins with a 512-entries blocks table:
word sector - index of the frames block byte length - length of the block's data (in sectors) byte frames - number of frames in the block
Zero length field indicates end of the table. Sector means 2048-bytes chunk of data. Thus, block with sector index 1 starts at offset 2048, 2 - 4096, etc.
Each block contains variable number of actual frames (usually 11) and starts with it's own index table, holding (dword) offsets of the particular frame, relative to the block base.
Frame structure:
word video_size - size of the following video data byte video[video_size] - compressed frame word palette_size - size of the following palette byte palette[256 * 3] - 256 BGR triplets of the palette word sound_size - size of the following sound chunk byte sound[sound_size] - sound data, stored as a complete VOC file
Video compression
Video encoded as a pairs of adjacent 8x8 blocks. Each pair starts with a byte, describing block's (de)compression mode. Lower nybble used for the first (left) block, high - for the second (right) block. Compression modes, in hex:
- 2
Read two bytes of the offset. Copy 8x8 block at that offset from the previous frame.
- 6
Same as method 2, but split 8x8 block on to four 4x4 block and copy each one independingly. Left to right, top to bottom.
- 7
Similar to method 6, but copy blocks from the current frame.
- 8
Here comes BTC encoding. Read one byte for color0 and next one for color1. Now, for each row of pixels, read mask byte and paint pixels either with color1 if it's bit (starting from the 0) is set or color0 if it's not.
- A
Exactly as 8, but for four 4x4 blocks, each with it's own pair of color0/color1 and mask.
- B
This one similar to A, with small enhancement. For each 4x4 block read 4 color bytes. Paint pixels using following colors combinations:
01 01 02 02 01 01 02 02 31 31 32 32 31 31 32 32
- D
Again, work with four 4x4 blocks. Read 4 colors from the stream. Now, for every pixel of the block, read 2 bits from the stream and use it as the index of the color you just read before.
- E
Draw nothing
- F
Just read 8*8 bytes from the stream and use them to draw whole block.