Westwood CPS Format

From ModdingWiki
Jump to: navigation, search
Westwood CPS Format
There is no example of an image in this format — upload one!
Format typeImage
Colour depth8-bit (VGA)
Minimum size (pixels)320×200
Maximum size (pixels)320×200
Plane count1 (PC), 5 (Amiga)
Transparent pixels?No
Hitmap pixels?No

CPS files are images with fixed 320x200 dimensions, 256 colors for PC version, 32 colors for Amiga version.

The images can be compressed with different compression methods, and may or may not contain an internal palette. If an internal palette is present, it is located just after the file header. The image data is located after the header and the palette.

File format

It start with an header, with is the same used for compressed file

struct FHeader {
    unsigned short FileSize;
    unsigned short CompressionType;
    unsigned int   UncompressedSize;
    unsigned short PaletteSize;


<Size of file with Header> for compression method 1, 2 and 3. <Size of file with Header>-02h for compression method 0 and 4.

Compression Type

Indicate the compression method used to store the image.

Uncompressed size

Size of uncompressed file without header. Usually is 64000, that is right 320x200

Palette size

The size of the palette.

* 0000h palette not present
* 0300h 256 colors palette (Lands Of Lore)
* 0040h 1 palette of 32 Colors for EOB2 AMIGA (Muli window screens CPS as ' SCOUx.CPS')
* 0080h 2 palettes of 32 Colors for EOB2 AMIGA (Muli window screens CPS as ' SCOUx.CPS')
* 00C0h 3 palettes of 32 Colors palettes for EOB2 AMIGA (Muli window screens CPS as ' SCOUx.CPS')
* 0100h 4 palettes of 32 Colors palettes for EOB2 AMIGA (Muli window screens CPS as ' SCOUx.CPS')

PC: Once decompressed, the image is in standard VGA format 320x200 pixel, where 1 byte is 1 pixel.

AMIGA: Once decompressed, the image is in standard 5 bimaps 320x200 screen (32 colors).

for EOB2 Amiga it can have 1 to 4 inside palettes of 16 colors for multiscreen CPS files such as SCOUx.CPS

For EOB1 Amiga palette can be found at the end of decompressed datas (offset $1f40*5 to see after)

Amiga specs

After image decompression the size is either 40000 bytes or 40064 bytes in size (EOB1).

The first 40000 bytes contain five 320x200 bitplanes. Each bitplane is 320x200/8 (8000) bytes big. This is standard for Amiga graphics data; look up planar graphics for more information.

Palette data The optional 64 bytes are palette data. Each palette entry is 16 bits in the following format:

Bit 5432109876543210

In other words, 12 bit RGB in _RGB pixel format.

In total there are 32 palette entries, consistent with 5 bitplanes (32 colors).

Image data

The resolution of the images are the same as in the PC version. However, since we only use 32 colors a pixel only need 5 bit each. The pixels are arranged as follows:

         byte 0   byte 1   byte 2   ... 40 bytes per line (40*8=320 pixels)
plane 0: .......x ........ ........
plane 1:        x
plane 2:        x
plane 3:        x
plane 4:        x

Each byte consists of 8 pixels. Each bit plane consists of 320*200 pixels = 320*200/8 bytes. The color of each pixel is made up of the corresponding bits down the same bit position in the bitplanes. This gives each pixels a 5-bit value which is an index into the 32-color palette. In the example above the pixel at position (0,7) is described.

Pseudo code for a planar to chunky implementation

unsigned char bitPlanes[5][8000];
int bytePos=x/8+y*40;
int bitPos=7-x&7;
unsigned char colorIndex=((!!(bitPlanes[0][bytePos]&(1<<bitPos)))<<0) |
                         ((!!(bitPlanes[1][bytePos]&(1<<bitPos)))<<1) |
                         ((!!(bitPlanes[2][bytePos]&(1<<bitPos)))<<2) |
                         ((!!(bitPlanes[3][bytePos]&(1<<bitPos)))<<3) |
unsigned short paletteValue=palette[colorIndex];

The above code can seem a bit unreadable to the untrained C-eye. !! simply turns a non zero value to 1, zero stays zero. It's actually a double negation, but I'd like to call it a normalize operator.


The following tools are able to work with files in this format.

Name PlatformView images in this format? Convert/export to another file/format? Import from another file/format? Access hidden data? Edit metadata? Notes
Engie File Converter WindowsYesYesYesN/AN/A Only supports the 256-color formats.
XCC Mixer WindowsYesYesYesN/AN/A Only supports the more recent versions, and can only convert to CPS with included palette.