Z Sprite Format

From ModdingWiki
Jump to navigation Jump to search
Z Sprite Format
There is no example of an image in this format — upload one!
Format typeImage
HardwareVGA
Colour depth8-bit
Minimum size (pixels)Unknown
Maximum size (pixels)Unknown
PaletteExternal
Plane count4
Transparent pixels?Palette-based
Hitmap pixels?No
Games
Z

Sprites in Z are stored in SPRITES.RSC. A shared offset table points to planar images, with one rendering-mode byte per row.

File format

Offset Data type Name Description
0 UINT16LE count Number used by the offset/group tables.
2 UINT32LE[count] offsets Absolute file offsets. Entry i ends at offsets[i+1].
2 + 4 * count BYTE[count] groups Group byte per table index, read by FUN_0006a5aa.

The asset viewer enumerates indices 0 through count - 2, retaining the last offset as the end boundary. Do not interpret the count as that many safely decodable images.

Sprite entry

Offset Data type Name Description
0 UINT8 height Height in pixels.
1 UINT8 widthUnits Width in pixels divided by 8.
2 UINT8[height] rowModes Rendering mode for each row.
align4(2 + height) BYTE[width * height] pixels Four equal planes, described below.

Alignment is relative to the start of the entry, not the start of the file. Each plane has width * height / 4 bytes. For plane p and byte k, write pixels[4*k+p] = plane[p][k]. These are full palette indices, not single-bit colour planes.

Row modes

Value Meaning
0 Opaque
2 Palette index 0 transparent
4 Apply remapping to all pixels
6 Apply remapping; palette index 0 transparent

Notes

Team remapping uses palette slots 0x10–0x1f. The palette is external; use a terrain palette for a preview. Row modes must be preserved independently of pixel indices.

Source code

From re-z, the open-source browser port:

Credits

This file format was reverse engineered by VorticonCmdr. 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!)