Realms of Chaos Sprite Format
A Realms of Chaos sprite contains multiple 256-colour VGA images (for example, an enemy sprite contains all the animation frames for that sprite.)
All sprite files begin with a string containing the sprite's filename and some unknown data.
|CHAR cFilename||Name of this sprite file (padded with 0's or random data?)|
|BYTE unknown||Unknown data (might even be more padding)|
A number of image blocks immediately follow the header, repeating until EOF:
|UINT16 iSize||Size of this sprite|
|BYTE cData[iSize]||Block of image data, iSize bytes long|
Each of the blocks of image data in the above structure contains an image header, followed by the pixel data. The header looks like this:
|UINT8 iHeight||Height of the image in pixels|
|UINT8 iWidth||Width of the image in pixels|
|BYTE bUnknown||might be collision data?|
|UINT16LE iDataSize||Size of pixel data, in bytes|
|BYTE bNulls||Always 0|
|BYTE[iDataSize] bPixelData||Pixel data (see below)|
|UINT16LE[iWidth] iColOffsets||Indices into pixel data for each column?|
The pixel data stores the pixel columns sequentially, using (iType, iCount) pairs to skip transparent pixels. Both values are stored as UINT8 values. Possible values for iType are:
|0||Skip iCount pixels (the pixels are transparent)|
|1||Write iCount pixels to the screen|
|2||Write iCount pixels to the screen and end this column (increase X and reset Y)|
|3||End of the image|
If iType is 1 or 2, iCount byte values follow after the iCount byte. These are the pixels to be drawn onto the screen.
Note: Each sprite image seems to always end with the (iType,iCount) pairs (2,0), (0,0), (3,0).
This file format was reverse engineered by K1n9_Duk3. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)