<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://moddingwiki.shikadi.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Matt</id>
	<title>ModdingWiki - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://moddingwiki.shikadi.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Matt"/>
	<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/wiki/Special:Contributions/Matt"/>
	<updated>2026-09-21T00:35:07Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.11</generator>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Westwood_SHP_Format_(TD)&amp;diff=10932</id>
		<title>Westwood SHP Format (TD)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Westwood_SHP_Format_(TD)&amp;diff=10932"/>
		<updated>2023-04-05T22:04:29Z</updated>

		<summary type="html">&lt;p&gt;Matt: /* Tools */ OpenRA&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Tileset Infobox&lt;br /&gt;
 | Hardware1 = VGA&lt;br /&gt;
 | MaxTiles = 65535, though internal addressing limits the file size to 16 MiB.&lt;br /&gt;
 | Palette = &#039;&#039;&#039;Shared&#039;&#039;&#039;. Technically possible to have it &#039;&#039;&#039;Internal&#039;&#039;&#039; but this is unused.&lt;br /&gt;
 | Names = N&lt;br /&gt;
 | TileMinSize = 1x1&lt;br /&gt;
 | TileMaxSize = 65535&amp;amp;times;65535&lt;br /&gt;
 | NumPlanes = 1&lt;br /&gt;
 | PlaneArrangement = Linear&lt;br /&gt;
 | HasTransparency = P&lt;br /&gt;
 | Metadata = None&lt;br /&gt;
 | Subtilesets = N&lt;br /&gt;
 | Compressed = Y&lt;br /&gt;
 | Hidden = Y&lt;br /&gt;
 | Games =&lt;br /&gt;
           {{Game|Command &amp;amp; Conquer}}&lt;br /&gt;
           {{Game|Command &amp;amp; Conquer: Sole Survivor}}&lt;br /&gt;
           {{Game|Command &amp;amp; Conquer: Red Alert}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The sprite format used in [[Command &amp;amp; Conquer]] (also known as &amp;quot;Tiberian Dawn&amp;quot;), [[Command &amp;amp; Conquer: Red Alert|Red Alert]] and [[Command &amp;amp; Conquer: Sole Survivor|Sole Survivor]] is a collection of compressed 8-bit frames that all have the same dimensions. It can use two different compression algorithms, namely [[Westwood LCW|LCW]] and [[Westwood XOR Delta|XOR Delta]], and normally uses the most optimal one for each frame, though the use of XOR Delta is optional. The format technically supports an internal colour palette and an X and Y offset for the frames, but these options are ignored by the games that use it.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
===Header===&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Offset||Data type!!Name!!Description&lt;br /&gt;
|-&lt;br /&gt;
|0x00||[[UINT16LE]]||Frames||Number of frames in the file.&lt;br /&gt;
|-&lt;br /&gt;
|0x02||[[UINT16LE]]||XPos||X-offset. Should be ignored.&lt;br /&gt;
|-&lt;br /&gt;
|0x04||[[UINT16LE]]||YPos||Y-offset. Should be ignored.&lt;br /&gt;
|-&lt;br /&gt;
|0x06||[[UINT16LE]]||Width||Width of the frames.&lt;br /&gt;
|-&lt;br /&gt;
|0x08||[[UINT16LE]]||Height||Height of the frames.&lt;br /&gt;
|-&lt;br /&gt;
|0x0A||[[UINT16LE]]||DeltaSize||Largest buffer size needed to decompress the frames.&lt;br /&gt;
|-&lt;br /&gt;
|0x0C||[[BYTE]][2]||Flags||Extra options. Bit 1 of this technically enables an embedded colour palette, but it is unused in the games.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;XPos&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;YPos&amp;lt;/tt&amp;gt; are often set in the headers of original game files as a side effect of Westwood&#039;s conversion process, but they are not applied by the games, and should be ignored. An embedded colour palette will most likely also be ignored by the games, since SHP files are typically small sprites drawn on a scene that already has a palette set.&lt;br /&gt;
&lt;br /&gt;
===Frames info table===&lt;br /&gt;
&lt;br /&gt;
After the header comes an array of size &amp;lt;code&amp;gt;Frames + 2&amp;lt;/code&amp;gt;, with 8-byte entries that each have the following structure:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Offset||Data type!!Name!!Description&lt;br /&gt;
|-&lt;br /&gt;
|0x00||UINT24LE||DataOffset||A three-byte integer value giving the offset to the frame&#039;s compressed data. Since both the LCW and XOR Delta compressions end their data with specific end markers, no end offset is needed.&lt;br /&gt;
|-&lt;br /&gt;
|0x03||[[BYTE]]||DataFormat||The compression format in which the data at &amp;lt;tt&amp;gt;DataOffset&amp;lt;/tt&amp;gt; is stored. See below.&lt;br /&gt;
|-&lt;br /&gt;
|0x04||UINT24LE||ReferenceOffset||Contains the referenced &amp;lt;tt&amp;gt;DataOffset&amp;lt;/tt&amp;gt; or frame number in case XOR chaining is used. See below.&lt;br /&gt;
|-&lt;br /&gt;
|0x07||[[BYTE]]||ReferenceFormat||Reference format in case XOR chaining is used. See below.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Technically, these are two [[UINT32LE]] values with bit flags enabled in their highest byte. This might also be the simplest way to read them; by reading a UINT32LE, bit-masking the value with 0xFFFFFF to get the offset, and down-shifting the value by 24 bits to get the format.&lt;br /&gt;
&lt;br /&gt;
It is unknown if the &amp;lt;tt&amp;gt;ReferenceFormat&amp;lt;/tt&amp;gt; is used in any way; the way to handle the data seems to be completely defined by the &amp;lt;tt&amp;gt;DataFormat&amp;lt;/tt&amp;gt;. It can of course be used as consistency check to confirm that the format is valid, and when writing a SHP file, it&#039;s better to conform to the known standards to ensure the game handles the file correctly.&lt;br /&gt;
&lt;br /&gt;
If the palette flag is enabled, this table is followed by a 768-byte array containing a [[VGA Palette#The .22Classic.22 format|256-colour 6-bit RGB VGA palette]]. After that follows the actual data referenced at the &amp;lt;tt&amp;gt;DataOffset&amp;lt;/tt&amp;gt; addresses in the table. Unlike in [[Westwood WSA Format|WSA format]], the palette is taken into account in the offsets, so no adjustments are needed on them.&lt;br /&gt;
&lt;br /&gt;
There are three possible ways in which a frame can be stored, depending on the &amp;lt;tt&amp;gt;DataFormat&amp;lt;/tt&amp;gt;. This is how the table entries look for each of these ways:&lt;br /&gt;
&lt;br /&gt;
====LCW Frame====&lt;br /&gt;
&lt;br /&gt;
The most straightforward frame type is an [[Westwood LCW|LCW-compressed]] frame.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;DataOffset&amp;lt;/tt&amp;gt;: points to the LCW data to uncompress to get the frame graphics.&lt;br /&gt;
* &amp;lt;tt&amp;gt;DataFormat&amp;lt;/tt&amp;gt;: set to 0x80, indicating &#039;&#039;&#039;LCW&#039;&#039;&#039;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;ReferenceOffset&amp;lt;/tt&amp;gt;: irrelevant, and left empty.&lt;br /&gt;
* &amp;lt;tt&amp;gt;ReferenceFormat&amp;lt;/tt&amp;gt;: irrelevant, and left empty.&lt;br /&gt;
&lt;br /&gt;
====XOR Base Frame====&lt;br /&gt;
&lt;br /&gt;
In case the differences with a previously-saved LCW frame are minimal, [[Westwood XOR Delta|XOR Delta compression]] is used to save instructions for transforming the previous frame&#039;s data into the new frame.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;DataOffset&amp;lt;/tt&amp;gt;: points to the XOR data to apply.&lt;br /&gt;
* &amp;lt;tt&amp;gt;DataFormat&amp;lt;/tt&amp;gt;: set to 0x40, indicating &#039;&#039;&#039;XOR Base&#039;&#039;&#039;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;ReferenceOffset&amp;lt;/tt&amp;gt;: Contains the &amp;lt;tt&amp;gt;DataOffset&amp;lt;/tt&amp;gt; of the referenced &#039;&#039;&#039;LCW frame&#039;&#039;&#039;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;ReferenceFormat&amp;lt;/tt&amp;gt;: set to 0x80 (&#039;&#039;&#039;LCW&#039;&#039;&#039;). It is unknown if (and unlikely that) any of the other formats are supported as reference.&lt;br /&gt;
&lt;br /&gt;
====XOR Chain Frame====&lt;br /&gt;
&lt;br /&gt;
The third case, chained XOR, is a bit peculiar: it is an XOR with the immediately preceding XOR frame. It can only chain from either an XOR Base frame, or another XOR Chain frame.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;DataOffset&amp;lt;/tt&amp;gt;: points to the XOR data to apply.&lt;br /&gt;
* &amp;lt;tt&amp;gt;DataFormat&amp;lt;/tt&amp;gt;: set to 0x20, indicating &#039;&#039;&#039;XOR Chain&#039;&#039;&#039;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;ReferenceOffset&amp;lt;/tt&amp;gt;: refers to the &#039;&#039;frame number&#039;&#039; of the &#039;&#039;&#039;XOR Base&#039;&#039;&#039; frame at the &#039;&#039;start&#039;&#039; of the chain.&lt;br /&gt;
* &amp;lt;tt&amp;gt;ReferenceFormat&amp;lt;/tt&amp;gt;: set to 0x48, indicating &#039;&#039;&#039;XOR Chain Reference&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
====Two final entries====&lt;br /&gt;
&lt;br /&gt;
As mentioned, the table has two more entries than the amount of frames. The first of these two extra entries normally serves as end point; its &amp;lt;tt&amp;gt;DataOffset&amp;lt;/tt&amp;gt; contains the file length, and all its other values are set to 0. The final entry is normally completely zeroed out.&lt;br /&gt;
&lt;br /&gt;
However, some games contain SHP files where the &#039;&#039;last&#039;&#039; entry contains the file size. In that case, the entry before that contains the information for a &#039;loop frame&#039;. Loop frames are normally not used in SHP format; they were conceived for the [[Westwood WSA Format|WSA format]], which, being purely based on XOR Delta compression, needed an extra XOR data entry as a smooth way to transform the final frame into the first one without needing to clear the graphics buffer. If such a loop frame exists in the SHP file, it should be ignored, and the file size should simply be taken from the last entry. It will most likely contain a duplicate of the first frame.&lt;br /&gt;
&lt;br /&gt;
===Implementation notes===&lt;br /&gt;
&lt;br /&gt;
The basic implementation is simple: compress the first frame as LCW, and for every following frame, attempt LCW, XOR Delta with a previous LCW frame, and (if the previous one is an XOR Delta) XOR chaining, and store the one which results in the lowest compressed size.&lt;br /&gt;
&lt;br /&gt;
The existing files seem to work with a system of LCW &amp;quot;key frames&amp;quot;; XOR Base frames never refer to LCW frames before the previously-saved LCW frame. Note that after an XOR chain, it is perfectly possible to have another XOR Base frame referring to this last key frame, and multiple XOR chains can occur after a single key frame.&lt;br /&gt;
&lt;br /&gt;
There also seems to be a rule applied to limit the length of XOR chains. Since the games do not sequentially preload SHP files, but instead interpret the data at the moment it is drawn to the screen, long chains can slow down the drawing process, since it needs to read, interpret and alter all chained frames in sequence. For example, the SAM Site SHP file in C&amp;amp;C1, when saved without chain limiting, would result in chains longer than 50 frames.&lt;br /&gt;
&lt;br /&gt;
To limit this, the used strategy appears to be to only allow chaining if the cumulative size of all chained frames after the original XOR frame does not exceed the size of that original XOR frame.&lt;br /&gt;
&lt;br /&gt;
This is just the saving strategy used in the original files, though; technically, the XOR Base frames can refer to any previous LCW frame in the file, and there is no length limit to XOR chains. The strategy seems to be a compromise between compression time, saved size and decompression time.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
&lt;br /&gt;
{{BeginFileFormatTools|Type=image}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [[Engie File Converter]]&lt;br /&gt;
| Platform = Windows&lt;br /&gt;
| canView = Yes&lt;br /&gt;
| canExport = Yes&lt;br /&gt;
| canImport = Yes&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
| notes = Uses the original algorithms and storage principles used by Westwood Studios, with further optimisations to avoid saving data of duplicate frames.&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [http://xhp.xwis.net/ XCC Mixer]&lt;br /&gt;
| Platform = Windows&lt;br /&gt;
| canView = Yes&lt;br /&gt;
| canExport = Yes&lt;br /&gt;
| canImport = Yes&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
| notes = The de facto standard modding tool in the C&amp;amp;C community, but like most older tools, its LCW compression is not very good, and it does not use XOR Delta when saving this type.&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = Mix Manager&lt;br /&gt;
| Platform = DOS&lt;br /&gt;
| canView = Yes&lt;br /&gt;
| canExport = Yes&lt;br /&gt;
| canImport = Yes&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
| notes = The most commonly used modding suite back in the DOS days.&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = RAMIX&lt;br /&gt;
| Platform = DOS&lt;br /&gt;
| canView = Yes&lt;br /&gt;
| canExport = Yes&lt;br /&gt;
| canImport = Yes&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
| notes = The spiritual successor of Mix Manager, created when people started digging into [[Command &amp;amp; Conquer Red Alert]].&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [https://web.archive.org/web/20130501143307/http://www.ultraq.net.nz/redhorizon/downloads/ Red Horizon Utilities]&lt;br /&gt;
| Platform = Java (command line)&lt;br /&gt;
| canView = No&lt;br /&gt;
| canExport = Yes&lt;br /&gt;
| canImport = Yes&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
| notes = Original site is defunct. Backups of the tools can be found [http://nyerguds.arsaneus-design.com/tools/redhorizon/ here].&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [https://github.com/OpenRA/OpenRA/wiki/Utility OpenRA Utility]&lt;br /&gt;
| Platform = Windows, Linux, Mac&lt;br /&gt;
| canView = No&lt;br /&gt;
| canExport = Yes&lt;br /&gt;
| canImport = Yes&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
| notes = Command line tool that can export/import from .png&lt;br /&gt;
}}&lt;br /&gt;
{{EndFileFormatTools}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Westwood Studios File Formats]]&lt;/div&gt;</summary>
		<author><name>Matt</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=MIX_Format_(Westwood)&amp;diff=10931</id>
		<title>MIX Format (Westwood)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=MIX_Format_(Westwood)&amp;diff=10931"/>
		<updated>2023-04-05T22:02:49Z</updated>

		<summary type="html">&lt;p&gt;Matt: /* Tools */ OpenRA&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archive Infobox&lt;br /&gt;
 | MaxFiles = 65,536&lt;br /&gt;
 | FAT = Beginning&lt;br /&gt;
 | Names = No&lt;br /&gt;
 | Metadata = None&lt;br /&gt;
 | Subdirectories = N&lt;br /&gt;
 | Compressed = N&lt;br /&gt;
 | Encrypted = Y&lt;br /&gt;
 | Hidden = Y&lt;br /&gt;
 | Games =&lt;br /&gt;
   {{Game|Command &amp;amp; Conquer}}&lt;br /&gt;
   {{Game|Command &amp;amp; Conquer: Red Alert}}&lt;br /&gt;
   {{Game|Command &amp;amp; Conquer: Tiberian Sun}}&lt;br /&gt;
   {{Game|Command &amp;amp; Conquer: Red Alert 2}}&lt;br /&gt;
   {{Game|Blade Runner}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Westwood&#039;s &#039;&#039;&#039;MIX Format&#039;&#039;&#039; is a simple group file used in their games from 1995-2001. It only stores file name hashes so some file names will result in the same hash and as a result will not be able to be stored together if they differ in content. Position and size of files are stored so size does not need to be inferred. It does not support compression.&lt;br /&gt;
There are 2 versions of the header, basic and advanced. The basic one only stores the file count and the total data size (not including the header or file index). The advanced one supports additional optional features such as encryption of the header and index and a sha1 checksum tailer to verify the data integrity. An additional flag field is used to indicate which features are present.&lt;br /&gt;
The hash algorithm used for the file name is a rolling hash in Command &amp;amp; Conquer and Red Alert and was replaced with crc32 in Tiberian Sun and later. There is nothing to indicate which hash scheme is used. Other games may use other hash methods.&lt;br /&gt;
&lt;br /&gt;
Apart from the original Command &amp;amp; Conquer, all the games can read both types of header provided the hash format is correct for that game.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
=== Signature ===&lt;br /&gt;
&lt;br /&gt;
MIX files have no signature. Usually they will have the extension .mix&lt;br /&gt;
&lt;br /&gt;
=== File Header ===&lt;br /&gt;
&lt;br /&gt;
The header consists of an optional flags section 4 bytes in size. The first 2 bytes are 0 in this case to distinguish between a mix without feature flags where this stores the file count as UNIT16LE. The flags are stored in the 3rd byte as a bit field with bit 0 indicating a checksum is present and bit 1 indicating that the header is encrypted.&lt;br /&gt;
&lt;br /&gt;
If the flags indicate encryption, an 80 byte block follows the flag section. This block is encrypted with an RSA private key with the public key used to decrypt being embedded in the games code. This block decrypts to a 56 byte Blowfish key that is used to decrypt the rest of the header.&lt;br /&gt;
&lt;br /&gt;
The standard header follows with a file count and a size which is the size of the data only. C&amp;amp;C games use this when caching a mix file. XCC uses this to validate the format and can be abused by making it larger to prevent XCC reading it correctly at the cost of the games reading additional garbage when caching them. This is used in so called &amp;quot;protection&amp;quot; schemes some mods use to prevent others using their assets.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Name!!Description&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT32LE]]||Flags||An optional field that specifies additional optional features that the archive uses.&lt;br /&gt;
|-&lt;br /&gt;
|[[BYTE]][80]||Key||An optional 80 byte block containing an RSA encrypted Blowfish key to use to decode the rest of the header.&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT16LE]]||FileCount||The number of files in the archive. Can be used to calculate the size of the file entry index.&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT32LE]]||DataSize||Size of the data section.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== File Entry ===&lt;br /&gt;
&lt;br /&gt;
The indexes file entries contain a hash of the filename, the offset of the file within the data section (header size needs to be added for absolute position in the archive) and the size of the file in bytes.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Name!!Description&lt;br /&gt;
|-&lt;br /&gt;
|[[INT32LE]]||Id||Hash of the filename. Hash algorithm varies between games.&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT32LE]]||Offset||File&#039;s starting offset within the data section.&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT32LE]]||Size||File&#039;s size.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In order to quickly locate files from their file name hashes, the index is sorted according to the hashes taken as signed integers.&lt;br /&gt;
&lt;br /&gt;
=== Encryption ===&lt;br /&gt;
&lt;br /&gt;
Header encryption can be detected by checking Flags &amp;amp; 0x00020000 does not equal zero. If it doesn&#039;t, then the next 80 bytes are two RSA encrypted blocks that need to be decrypted with the Westwood public key. For the purposes of the RSA algorithm, the blocks should be treated as 2 40 byte &amp;quot;big&amp;quot; integers in little endian byte order. 0x10001 should be used as the public exponent for the decryption.&lt;br /&gt;
&lt;br /&gt;
The result is a 56 byte block padded with zeros to use with the Blowfish algorithm in ECB mode. Blocks are 8 bytes long and you need to decode the first block to get the standard header. From that you can calculate the length of the index and thus how many additional blocks you need to decode to get the rest of the index. If the header and index together are not perfectly divisible by 8, then it is padded with zeros since blowfish operates on 8 byte blocks.&lt;br /&gt;
&lt;br /&gt;
Creating an encrypted header is the reverse of this process, a Blowfish key is generated somehow and used to encrypt the header and index and is itself padded with zeros and encrypted using the Westwood private key.&lt;br /&gt;
&lt;br /&gt;
The public key is encoded in the game binaries while the private key was leaked in the form of keys.ini included in one of the Tiberian Sun MIX files. Presumably this was a mistake as it cannot be used from that location. The full contents of the file are as follows.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
[PublicKey]&lt;br /&gt;
1=AihRvNoIbTn85FZRYNZRcT+i6KpU+maCsEqr3Q5q+LDB5tH7Tz2qQ38V&lt;br /&gt;
&lt;br /&gt;
[PrivateKey]&lt;br /&gt;
1=AigKVje8mROcR8QixnxUEF5b29Curkq01DNDWCdOG99XBqH79OaCiTCB&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The keys are Base64 encoded and DER encoded big endian &amp;quot;big&amp;quot; integers and represent the modulus and the private exponent respectively in the RSA encryption scheme.&lt;br /&gt;
&lt;br /&gt;
=== Checksum ===&lt;br /&gt;
&lt;br /&gt;
Data checksum presence can be detected by checking Flags &amp;amp; 0x00010000 does not equal zero. If it doesn&#039;t, then the last 20 bytes of the file are a SHA1 hash of the data contents of the file, not including the header.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
&lt;br /&gt;
{{BeginFileFormatTools|Type=group}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [http://xhp.xwis.net/ XCC Mixer]&lt;br /&gt;
| Platform = Windows&lt;br /&gt;
| canExtract = Yes&lt;br /&gt;
| canDecompress = N/A&lt;br /&gt;
| canCreate = Yes&lt;br /&gt;
| canModify = Yes&lt;br /&gt;
| canCompress = N/A&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = Mix Manager&lt;br /&gt;
| Platform = DOS&lt;br /&gt;
| canExtract = Yes&lt;br /&gt;
| canDecompress = N/A&lt;br /&gt;
| canCreate = Yes&lt;br /&gt;
| canModify = Yes&lt;br /&gt;
| canCompress = N/A&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = RAMIX&lt;br /&gt;
| Platform = DOS&lt;br /&gt;
| canExtract = Yes&lt;br /&gt;
| canDecompress = N/A&lt;br /&gt;
| canCreate = Yes&lt;br /&gt;
| canModify = Yes&lt;br /&gt;
| canCompress = N/A&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [https://github.com/OpenRA/OpenRA/wiki/Utility OpenRA Utility]&lt;br /&gt;
| Platform = Windows, Linux, Mac&lt;br /&gt;
| canExtract = Yes&lt;br /&gt;
| canDecompress = N/A&lt;br /&gt;
| canCreate = No&lt;br /&gt;
| canModify = No&lt;br /&gt;
| canCompress = N/A&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
}}&lt;br /&gt;
{{EndFileFormatTools}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Westwood Studios File Formats]]&lt;/div&gt;</summary>
		<author><name>Matt</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Westwood_SHP_Format_(TS)&amp;diff=10930</id>
		<title>Westwood SHP Format (TS)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Westwood_SHP_Format_(TS)&amp;diff=10930"/>
		<updated>2023-04-05T22:02:00Z</updated>

		<summary type="html">&lt;p&gt;Matt: /* Tools */ OpenRA&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Tileset Infobox&lt;br /&gt;
 | Hardware1 = VGA&lt;br /&gt;
 | MaxTiles = 65535&lt;br /&gt;
 | Palette = Shared&lt;br /&gt;
 | Names = N&lt;br /&gt;
 | TileMinSize = 1x1&lt;br /&gt;
 | TileMaxSize = 65535&amp;amp;times;65535&lt;br /&gt;
 | NumPlanes = 1&lt;br /&gt;
 | PlaneArrangement = Linear&lt;br /&gt;
 | HasTransparency = P&lt;br /&gt;
 | Metadata = None&lt;br /&gt;
 | Subtilesets = N&lt;br /&gt;
 | Compressed = Y&lt;br /&gt;
 | Hidden = Y&lt;br /&gt;
 | Games =&lt;br /&gt;
           {{Game|Command &amp;amp; Conquer: Tiberian Sun}}&lt;br /&gt;
           {{Game|Command &amp;amp; Conquer: Red Alert 2}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The sprite format used in [[Command &amp;amp; Conquer: Tiberian Sun]] and [[Command &amp;amp; Conquer: Red Alert 2|Red Alert 2]] is a collection of 8-bit frames that all have the same dimensions. The format uses the [[Westwood RLE-Zero]] algorithm to compact transparent areas, and uses X and Y offsets to align smaller frame data in the full frame size, but, unlike its predecessors, uses no real data compression like [[Westwood LCW|LCW]].&lt;br /&gt;
&lt;br /&gt;
An additional &#039;compression&#039;, though applied on game design level rather than on graphics level, is that all separate structure animations in these games are typically stored in separate files. This has the advantages that it both saves space by not including the entire structure graphics in the animation graphics (a problem previously solved by using [[Westwood XOR Delta|XOR Delta]]), and that it gives more freedom for playing multiple looping animations with different amounts of frames on the same structure.&lt;br /&gt;
&lt;br /&gt;
Note that Tiberian Sun and Red Alert 2 are not DOS games. This format is included on this wiki for the sake of completeness in the scope of documenting all indexed graphics formats in the Westwood Studios games, and as logical successor to the [[Westwood SHP Format (Dune II)|Dune II SHP]], [[Westwood SHP Format (Lands of Lore)|Lands of Lore SHP]] and [[Westwood SHP Format (TD)|C&amp;amp;C 1 SHP]] formats.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
=== Header ===&lt;br /&gt;
&lt;br /&gt;
The file starts with a very simple 8-byte header:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Offset||Data type!!Name!!Description&lt;br /&gt;
|-&lt;br /&gt;
|0x00||[[UINT16LE]]||Empty||Always zero. This allows a very simple first check to identify this file type.&lt;br /&gt;
|-&lt;br /&gt;
|0x02||[[UINT16LE]]||FullWidth||Width of the frames.&lt;br /&gt;
|-&lt;br /&gt;
|0x04||[[UINT16LE]]||FullHeight||Height of the frames.&lt;br /&gt;
|-&lt;br /&gt;
|0x06||[[UINT16LE]]||NrOfFrames||Number of frames in the file.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Frames info table ===&lt;br /&gt;
&lt;br /&gt;
After the header comes an array with &amp;lt;code&amp;gt;NrOfFrames&amp;lt;/code&amp;gt; entries, where each entry has the following structure:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Offset||Data type!!Name!!Description&lt;br /&gt;
|-&lt;br /&gt;
|0x00||[[UINT16LE]]||FrameX||X-offset to align the frame in the full &amp;lt;code&amp;gt;FullWidth*FullHeight&amp;lt;/code&amp;gt; image.&lt;br /&gt;
|-&lt;br /&gt;
|0x02||[[UINT16LE]]||FrameY||Y-offset to align the frame in the full &amp;lt;code&amp;gt;FullWidth*FullHeight&amp;lt;/code&amp;gt; image.&lt;br /&gt;
|-&lt;br /&gt;
|0x04||[[UINT16LE]]||FrameWidth||Width of the frame image data.&lt;br /&gt;
|-&lt;br /&gt;
|0x06||[[UINT16LE]]||FrameHeight||Height of the frame image data.&lt;br /&gt;
|-&lt;br /&gt;
|0x08||[[UINT32LE]]||Flags||A series of bit flags that determine how the game interprets the data. The two flags are &amp;lt;tt&amp;gt;HasTransparency&amp;lt;/tt&amp;gt; (bit 1) and &amp;lt;tt&amp;gt;UsesRle&amp;lt;/tt&amp;gt; (bit 2). Since the RLE compression only collapses transparency, bit 2 should never be enabled if bit 1 isn&#039;t.&lt;br /&gt;
|-&lt;br /&gt;
|0x0C||[[BYTE]][4]||FrameColor||The first three bytes of this contain R/G/B colour bytes that can be used on the game&#039;s minimap. Unlike the game&#039;s colour palettes, this uses 8 bits per colour component.&lt;br /&gt;
|-&lt;br /&gt;
|0x10||[[UINT32LE]]||Reserved||Always 0.&lt;br /&gt;
|-&lt;br /&gt;
|0x14||[[UINT32LE]]||DataOffset||Offset of the frame&#039;s data. If there is no data, this should be 0. In the original files, the data, and thus these offsets, are always aligned to multiples of 8 bytes, though this is technically not necessary. Since the zero-compression algorithm has line lengths in its format, and uncompressed data is exactly &amp;lt;code&amp;gt;FrameWidth * FrameHeight&amp;lt;/code&amp;gt; bytes, no end offset is needed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;flags&amp;lt;/tt&amp;gt; aren&#039;t really decompression options but options to tell the game&#039;s blitters how to paint the graphics on the screen. Because of this, it is important to enable the &amp;lt;tt&amp;gt;HasTransparency&amp;lt;/tt&amp;gt; bit if the graphics data contains zero-value bytes, otherwise they may get painted as actual zero-value colours, instead of getting handled as transparency.&lt;br /&gt;
&lt;br /&gt;
==== Image data decompression ====&lt;br /&gt;
&lt;br /&gt;
The main way the image data is reduced in size is by saving only a cropped frame, which needs to be realigned in the full frame size using the X and Y offsets. To get the cropped frame, though, the data first needs to be interpreted correctly.&lt;br /&gt;
&lt;br /&gt;
As mentioned, there are two flags that can be set on graphics, and the second should never be enabled if the first one isn&#039;t, giving three different types of stored data:&lt;br /&gt;
&lt;br /&gt;
* On fully opaque data, both the &amp;lt;tt&amp;gt;HasTransparency&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;UsesRle&amp;lt;/tt&amp;gt; flags are disabled.&lt;br /&gt;
* On data containing transparency which is not RLE-compressed, the &amp;lt;tt&amp;gt;HasTransparency&amp;lt;/tt&amp;gt; flag is enabled, but the &amp;lt;tt&amp;gt;UsesRle&amp;lt;/tt&amp;gt; flags isn&#039;t. Typically, this is only used in case the RLE algorithm gives larger output than the original data, however, the game&#039;s mouse cursor graphics are saved without RLE, and will not work correctly if RLE is enabled on them.&lt;br /&gt;
* On data containing transparency which is RLE-compressed, both the &amp;lt;tt&amp;gt;HasTransparency&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;UsesRle&amp;lt;/tt&amp;gt; flags are enabled.&lt;br /&gt;
&lt;br /&gt;
The used compression is the Tiberian Sun variant of the [[Westwood RLE-Zero]] algorithm, a [[RLE Compression#Flag|flag-based RLE]] triggering on value 00, which is treated per line, and which has a [[UINT16LE]] at the start of each line indicating that line&#039;s input data length.&lt;br /&gt;
&lt;br /&gt;
==== Frame colour ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;FrameColor&amp;lt;/tt&amp;gt; is the average colour of all non-transparent pixels in the frame&#039;s image data, when seen in its intended palette, or rather, in the graphics fed into the original encoder used by Westwood. Since reapplying an average-colour algorithm to existing game sprites gives slightly different values than the original ones, it is likely that the original images had 8-bit colour components, and that the process of mapping them to the intended game palette was done by the encoding tool itself.&lt;br /&gt;
&lt;br /&gt;
The main purpose of this colour is to serve as display colour on the game&#039;s &#039;radar&#039; minimap. Most units and structures in the game don&#039;t need this, since anything owned by either an AI or human player is displayed on the minimap with the colour of its owner, but it is important to have this for map resources and SHP-based terrain pieces such as bridges.&lt;br /&gt;
&lt;br /&gt;
The original encoder used by Westwood seems to have contained some system to compensate for remappable house colours, however, or had a way to override the house colours to the intended in-game colours, because the frames of the tiberium resource in the game, which is remappable, have green colours set, despite the game using red colours on the remapping range on its colour palette. Likewise, some of the tiberium-based mutated wildlife in the game, which is also typically remapped to green in the game, contains green frame colours that can only be achieved by using green-remapped graphics as source.&lt;br /&gt;
&lt;br /&gt;
It must be noted that, on the tiberium graphics, the game uses a somewhat odd system to change these colours when the tiberium in the game is remapped to a different colour than green. For that reason, it is advised that when editing the tiberium graphics, the original graphics&#039; frame colours are copied exactly, otherwise blue tiberium in the game has a tendency to look strangely purple on the minimap. The &#039;&#039;TS/RA2 SHP Radar Colour Editor&#039;&#039; (see [[#Tools|Tools]]) can apply this operation.&lt;br /&gt;
&lt;br /&gt;
=== Shadow filter area ===&lt;br /&gt;
&lt;br /&gt;
On the preceding games, unit and structure shadows are typically indicated on the graphics using colour index 4 (though in C&amp;amp;C1 this is technically defined by the game&#039;s [[Westwood Fading Table|fading table]] files), typically coloured bright green &amp;lt;span style=&amp;quot;background-color: #000000; color: #54FC54&amp;quot;&amp;gt;#54FC54&amp;lt;/span&amp;gt; on the palettes. Tiberian Sun and Red Alert 2 work differently; the shadows are split off into additional frames behind the normal graphics, and are painted in colour index 1.&lt;br /&gt;
&lt;br /&gt;
Such shadow frames are not a specific part of the format; there are plenty of graphics in the games (like UI graphics) that are not units or structures in the play field that need to cast a shadow, so these frames are not always an expected thing, but if they are present they should be somewhat detectable by the fact there is an even number of frames, and the pixels in the second half of the frames only use palette indices 0 and 1.&lt;br /&gt;
&lt;br /&gt;
Since shadows should never overlap the main graphics, the correct way to combine the frames is to draw the shadows &#039;&#039;under&#039;&#039; the main graphics. Most conversion tools convert the shadow data to the classic index 4, for the sake of compatibility, because index 4 is never really used in graphics, and because this index is still set to the clearly visible green colour on most default unit and structure palettes in Tiberian Sun and Red Alert 2.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
&lt;br /&gt;
{{BeginFileFormatTools|Type=image}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [[Engie File Converter]]&lt;br /&gt;
| Platform = Windows&lt;br /&gt;
| canView = Yes&lt;br /&gt;
| canExport = Yes&lt;br /&gt;
| canImport = Yes&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = Has save options to tweak &amp;lt;tt&amp;gt;FrameColor&amp;lt;/tt&amp;gt;.&lt;br /&gt;
| notes = Generates the &amp;lt;tt&amp;gt;FrameColor&amp;lt;/tt&amp;gt; data from the input frames, and has an option to override the red remap colours in that operation with tiberium-green.&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [http://xhp.xwis.net/ XCC Mixer]&lt;br /&gt;
| Platform = Windows&lt;br /&gt;
| canView = Yes&lt;br /&gt;
| canExport = Yes&lt;br /&gt;
| canImport = Yes&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = No&lt;br /&gt;
| notes = The main conversion tool used by the modding community.&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [https://www.ppmsite.com/?go=shpbuilderinfo OS SHP Builder]&lt;br /&gt;
| Platform = Windows&lt;br /&gt;
| canView = Yes&lt;br /&gt;
| canExport = Yes&lt;br /&gt;
| canImport = Yes&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = No&lt;br /&gt;
| notes = An actual graphical sprite editor&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [https://ppmforums.com/viewtopic.php?t=18679 TS/RA2 SHP Radar Colour Editor]&lt;br /&gt;
| Platform = Windows&lt;br /&gt;
| canView = No&lt;br /&gt;
| canExport = No&lt;br /&gt;
| canImport = No&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = Yes&lt;br /&gt;
| notes = Specific tool for editing the &amp;lt;tt&amp;gt;FrameColor&amp;lt;/tt&amp;gt; data, since most SHP tools have no support for setting it. Can only view the colours set for the SHP frames, not the graphics themselves.&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [https://github.com/OpenRA/OpenRA/wiki/Utility OpenRA Utility]&lt;br /&gt;
| Platform = Windows, Linux, Mac&lt;br /&gt;
| canView = No&lt;br /&gt;
| canExport = Yes&lt;br /&gt;
| canImport = Yes&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = No&lt;br /&gt;
| notes = Command line tool that can export/import from .png&lt;br /&gt;
}}&lt;br /&gt;
{{EndFileFormatTools}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Westwood Studios File Formats]]&lt;/div&gt;</summary>
		<author><name>Matt</name></author>
	</entry>
</feed>