Skip to main content

CPS field reference

File page · Format catalogue · Schema source

This page is generated from the Kaitai schema CPS.ksy each time the site is built. The schema is the authoritative description; statements are established unless marked inferred or unknown, and the evidence is listed on the file page (see the reading guide).

  • Schema: Eye of the Beholder II DOS Westwood CPS-style container
  • Byte order: little-endian
  • Schema license: MIT

Description​

A Westwood CPS-style container: a short header giving the stored size, the compression method and the decoded size, an optional palette area, then the compressed payload. In EOB II for DOS it wraps level information (INF), dungeon graphics (VCN) and images (CPS). This schema reads the container only; decode the payload with the method given by compression_method before applying INF.ksy or VCN.ksy. A decoded CPS image is 64,000 bytes: 320 x 200 pixels, row by row from the top, one byte per pixel, each a palette index. See the format overview.

In the original files (116 CPS, 16 INF and 5 VCN files): method 4 in 136 containers, method 3 in SKELWAR.CPS only, method 0 in none; decoded size 64,000 in every CPS file; palette size 768 in HEROES.CPS and MENU.CPS, 0 elsewhere.

The game reads the stored size, the next 8 header bytes, then the palette area into a caller buffer or skips it, then stored size - 8 - palette size bytes, and decodes them. The level loader reads INF containers the same way and uses the same decoder. The decoder reads the method as a byte: 0 copies decoded_size bytes, 3 runs the run-length decoder, 4 runs the LCW decoder with a 65,535-byte limit; other values write nothing.

Not covered: other Westwood CPS variants; methods other than 0, 3 and 4 are not decoded by this game.

File structure​

FieldTypeSize, repetition and constraints
stored_sizeu2—
compression_methodu2—
decoded_sizeu4—
auxiliary_sizeu2—
auxiliary_dataauxiliary_size bytes—
encoded_payloadbytes to end of stream—

stored_size

Number of bytes after this field in 136 of the 137 original containers; SKELWAR.CPS gives the whole file length (two more). The game reads stored_size - 8 - auxiliary_size payload bytes and ignores a short read, so the excess has no effect.

compression_method

Payload encoding, read by the game as its low byte only. 0: stored unchanged, decoded_size bytes (no original file). 3: run-length encoding (SKELWAR.CPS): a signed control byte c; c > 0 copies c bytes, c < 0 repeats the next byte -c times, c = 0 reads a big-endian 16-bit count then a byte to repeat; ends when decoded_size bytes are written. 4: LCW (all other files): 0x00-0x7f relative copy of (b >> 4) + 3 bytes at distance (b & 15) * 256 + next byte; 0x80 end; 0x81-0xbf copy b & 63 literal bytes; 0xfe count word and fill byte; 0xff count word and offset word; 0xc0-0xfd (b & 63) + 3 bytes from an offset word; offsets from the start of the output; counts clamped to 65,535 bytes of output. Other values: the game writes nothing.

decoded_size

Size of the decoded payload. Methods 0 and 3 use it as the amount to produce; the method 4 decoder ignores it and stops on its end command, which every original file reaches at exactly this size and at its last byte.

auxiliary_size

Size of the palette area; 768 in HEROES.CPS and MENU.CPS, 0 elsewhere. The game clears it in its loaded copy of the header.

auxiliary_data

A VGA palette of 256 entries of three 6-bit values (red, green, blue; bytes 0-63). The picture loader that accepts a palette reads it into the caller's buffer in display modes 3, 5 and 6, and the game then sends entries 0-255 to the display driver, which writes them to the VGA colour registers. The usual image loader skips it. See the palette section.

encoded_payload

Encoded content, kept verbatim: level information in INF files, graphics blocks in VCN files and image data in CPS files. Parsing the container does not check the compressed stream.