Westwood SHP Format (Lands of Lore)

From ModdingWiki
Jump to navigation Jump to search
Westwood SHP Format (Lands of Lore)
There is no image of a tileset in this format — upload one!
Format typeTileset
HardwareVGA
Max tile count65535
PaletteShared. Technically possible to have it Internal but this is unused.
Tile names?No
Minimum tile size (pixels)1x1
Maximum tile size (pixels)65535×256
Plane count1
Plane arrangementLinear
Transparent pixels?Palette-based
Hitmap pixels?No
Metadata?None
Supports sub-tilesets?No
Compressed tiles?Yes
Hidden data?Yes
Games

The most commonly used sprite format in Lands of Lore: The Throne of Chaos is a compressed collection of 8-bit frames, where each frame can have its own set of dimensions. There is one single file in the first Legend of Kyrandia game that also uses this format, namely bead.cps.

Despite generally using the .CMP extension, these files are not related to the Westwood CMP Format. The "CMP" extension most likely just indicated compressed content.

File format

The format is identical to the SHP format used in Dune II v1.07, but the entire file is embedded in a file of the CPS format, typically using LCW compression.

This structure does not really offer much advantage over the original format, given the fact index tables generally don't compress well since they contain little repetition, and the frames data itself already supports compression in the Dune II SHP format. The only way a significant file size decrease can be gained is if the data in the different frames contain sufficient duplicate byte ranges, and if the frames in the embedded Dune II SHP file are left uncompressed. The game files in Lands of Lore generally don't disable the internal frame compression, though, resulting in files that are rarely smaller than the embedded one.

Header

The file starts with the same header also found in the CPS format:

Data type Name Description
UINT16LE FileSize File size. For compression method 0 and 4, this only counts the bytes behind this value, making it two bytes less than the actual file size.
UINT16LE CompressionType Compression type.
UINT32LE UncompressedSize Uncompressed size.
UINT16LE PaletteSize Palette size.

If PaletteSize is not 0, this header is followed by an array of PaletteSize containing the embedded palette. The rest of the file is the compressed data. The embedded palette is most likely never used; SHP files are typically sprites drawn onto a scene that already has a palette, and even for the later TD SHP format, which has an option to embed a palette as well, no files were ever found that use it.

Compression types

The five different used compression methods are simply the ones found in the CPS format:

Contents

As mentioned, the decompressed data is simply a file in the 1.07 variant of the Dune II SHP Format. Many of the files in the game have frames processed with the index remapping system which changes the colour indices on the index to consecutive numbers, though besides the battle opponent files (see next section), the function of this remapping is unknown. It is possible that the game uses it to change the used palette ranges with the aid of internal tables.

Battle opponents

All shape files that define battle opponents have the same frame structure. The normal content frames all have the same dimensions, and are remapped with the index remapping system. Frame #16 is special: it contains a table defining custom remap colours for the character, is only as large as it needs to be for the table, and is never remapped.

The frame ranges are defined as follows:

Frames range Description
0-3 Walking towards the player.
4-7 Walking to the left. These are mirrored by the game for walking to the right.
8-11 Walking away from the player.
12 Hit by the player.
13-15 Attacking the player
16 Remap table. This is a series of vertical columns, with the first column defining the original colours in the graphics, and the following columns defining alternate colour ranges for them. It has a 1-pixel transparent edge at the right side and the bottom. If no remap is defined, this ends up as a 1×1 transparent frame, though if there are no further frames, this frame is sometimes left off altogether.

Beyond frame 16 can be more sets of 16 frames which contain overlays for the 0-15 frames range to add variations to the opponent, changing details like the face, armour or armament.

The frame configurations in the different shapes of the final boss in the game are slightly different, but like the normal ones, they have remapped frames, with a remap table frame at index 16.

Tools

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