Westwood CMP Format
Like the CPS format, these files tend to be used both for fullscreen 320x200 images, and for collections of sprites.
Note that the .CMP extension is also used by the Lands of Lore SHP format, but that article was named "SHP Format" because the described format is a sprite format, like all other Westwood SHP formats. Both "CMP" and the later "CPS" extensions probably just refer to the file being "compressed".
The file starts with the following header:
|UINT16LE||FileSize||File size. This only counts the bytes behind this value, making it two bytes less than the actual file size.|
|UINT8||CompressionType||Compression type. Either 1 for horizontal compression, or 2 for vertical compression.|
This header is immediately followed by the compressed data.
The image data is compressed with the Westwood RLE compression, using little-endian 16-bit values for its large repeat values. If the CompressionType in the header is set to "2", decompressed bytes should be painted onto the image per column. Do note that the image is 4-bit, so each such column is two pixels wide.
To handle CompressionType 2, the game decompresses the data straight into the screen buffer vertically using a separate decompression function. For modern applications, it is probably simpler to swap the rows and columns as post-processing step, since that means both compression types can use the same decompression code.
The vertical compression is consistently used on images where compressing the bytes per column results in a lower file size.