Sprite

From RuneScape Classic Wiki
Jump to navigation Jump to search
In this image, the bucket is a sprite, whereas the barrels are not.

A sprite is a two-dimensional image which is projected on the three-dimensional world of RuneScape Classic.

Players, items, monsters, and non-player characters are represented with sprites. The scenery and landscape are not.

Walls, while appearing to be sprites, are actually textures projected onto thin three-dimensional objects. They provide full viewing angles and do not appear to "snap" around or stay still as the camera is rotated.

File format[edit | edit source]

Features[edit | edit source]

Earlier versions of RuneScape Classic (before 2002) used standard colour-mapped Truevision TGA files inside JAG archives to store sprites. Since 2002, they have been stored in a custom Jagex file format using the .dat extension inside JAG archives.

Sprites are divided into "sprite sheets" which all share a colour map which is limited to 256 24-bit RGB colours. Because of this limitation, many sprites in RuneScape Classic display signs of posterization. This noticeably changed over time, with many sprites gaining or losing quality after the 2002 update that changed the sprite file format (see also graphical updates).

Animations for players and monsters are divided into sprite sheets, with 15 individual sprites used for walking and standing animations, and 3 sprites being used for attacking animations. When necessary, these sprites are mirrored so that the player or monster faces the opposite direction.

Data layout[edit | edit source]

Like most RuneScape Classic file formats, the .dat format for sprites is a simple binary format using big endian byte order for integers. Metadata and pixel data are stored separately, with the metadata being stored in a file called index.dat.

Metadata format[edit | edit source]

[uint16_t] sheet width
[uint16_t] sheet height
[uint8_t] sheet colour map size
[uint24_t] sheet colour map entries...
for each sprite in the sheet:
[uint8_t] x-offset
[uint8_t] y-offset
[uint16_t] width
[uint16_t] height
[uint8_t] pixel storage type (see below)

The first entry in a colour map is always 0xff00ff, which is bright magenta and is reserved for regions which should be invisible (i.e. solid transparency).

Pixel format[edit | edit source]

The first entry in the pixel data is a 16-bit integer pointing to the offset of the metadata for this sprite sheet.

There are two storage types for pixels, presumably chosen depending on compression efficiency. For type 1, the pixels are read as a series of vertical rows. For type 0, they are read as a series of horizontal rows. Every pixel is a single byte pointing to an entry in the colour map.