WLSPRT Format
Warning! YAWN ALERT!
The WLSPRT file format is a custom binary format used by
If you end up making a tool to handle WLSPRT files, you should respect the version in the header and of course only work with known versions supported by your tool.
Note: All 16-bit integers are encoded with little-endian byte order.
A WLSPRT begins with a header with the following structure:
Type / Size | Description |
---|---|
Character (Ascii Byte) | 'W' |
Character (Ascii Byte) | 'L' |
Character (Ascii Byte) | 'S' |
Character (Ascii Byte) | 'P' |
Character (Ascii Byte) | 'R' |
Character (Ascii Byte) | 'T' |
Unsigned 16-bit Integer | WLSPRT format version = 0 |
Unsigned 8-bit Integer | Palette included? |
Palette (768 bytes) | Omitted when previous byte = 0 |
Unsigned 16-bit Integer | Number of sprites in file |
Note the header is variably sized. If the palette byte is 0, then the header will be 9 bytes total. Otherwise it will be 777 bytes total.
The header specifies the number of sprite entries that follow. Each entry has the following structure:
Type / Size | Description |
---|---|
Unsigned 16-bit Integer | Sprite Width |
Unsigned 16-bit Integer | Sprite Height |
Signed 16-bit Integer | Sprite X-Offset |
Signed 16-bit Integer | Sprite Y-Offset |
Sprite Data (Width*Height bytes) | Indexed pixel data in row-major order |
Sprite pixel data is 8bpp, in other words 1 byte per pixel. Each byte represents a color index in the palette. Color index 0 is special and treated as transparent.
Note that the sprite data is variably-sized, dependent on the sprite dimensions. It is crucial that the sprite entry header accurately describe the sprite dimensions, or iterating the sprites in the WLSPRT file may result in crashes, corruption, or other bugs.
Sprite offsets affect the center (sometimes called sprite origin) of the sprite in-game. Offsets can be positive or negative and are not bounded by the sprite dimensions.
NOTE: There is an upper-bound on the total amount of sprite data due to