C93

From MultimediaWiki
Revision as of 01:06, 11 July 2006 by DonDiego (talk | contribs) (grammar fixes, slight reformatting)
Jump to navigation Jump to search

C93 is a video format used in the game Cyberia. It seems that is has not been used anywhere else (Cyberia 2 comes with a slightly modified version named M95). 93 most likely refers to the format creation year.

C93 operates in standard VGA 320x200x256 resolution and is based on BTC encoding and simple block copying.

File structure

Files begin with a 512-entries blocks table:

 word sector  - index of the frames block
 byte length  - length of the block data (in sectors)
 byte frames  - number of frames in the block

A zero length field indicates the end of the table. Sector means 2048-bytes chunk of data. Thus, a block with sector index 1 starts at offset 2048, 2 at 4096, etc.

Each block contains a variable number of actual frames (usually 11) and starts with its 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 is encoded as pairs of adjacent 8x8 blocks. Each pair starts with a byte describing the block's (de)compression mode. The lower nibble is used for the first (left) block, the higher for the second (right) block. Compression modes, in hex:

  • 2

Read two bytes at the offset. Copy 8x8 block at that offset from the previous frame.

  • 6

Same as method 2, but split 8x8 blocks into four 4x4 blocks and copy each one independently, 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 its bit (starting from the 0) is set or color0 if it's not set.

  • A

Exactly as 8, but for four 4x4 blocks, each with its own pair of color0/color1 and mask.

  • B

This one is similar to A, with a small enhancement. For each 4x4 block read 4 color bytes. Paint pixels using following color 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 the whole block.