Sprite file format


The format of a Sprite file (or area) is as follows:
+---------+-------+--------+--------+- - - - +--------+-------+
| Control | Extn  |        |        |        |        | Free  |
| Block   | area  | Sprite | Sprite |        | Sprite | space |
|         | (opt) |        |        |        |        |       |
+---------+-------+--------+--------+- - - - +--------+-------+

There are two slight variations on the above arrangement:
  1. When saved as a file
  2. When stored in memory for use with the Sprite rendering and handling module (in which case it is known as a sprite area)
When in memory, the sprite area has an extra word at the start of the control block, and also may have the free space that sprite files don not have. The free space is used when preforming operations that add or extend the sprites in the area.

The format of the Control Block is as follows (remember multibyte values are little-endian):

Offset  Size   Description
------  -----  -------------------------------------------------
0       4      Byte offset to last byte + 1 (ie total size of
               sprite area, including free space)
4       4      Number of sprites in area
8       4      Byte offset to first sprite
12      4      Byte offset to first free word (ie byte after
               last sprite)
16      n      Extension words (usually none)

For sprite files the first word is not included, but all offsets are set as if it was still there (ie when examining the file, all offsets appear to be 4 bytes too large).

Also when saved as a file, the word at offset 12, should be set to point to the byte after the last sprite (ie the 'free space' should be removed).

Format of a sprite

The format of each sprite in the sprite area/file is as follows:
+---------+---------+--------+----------+
| Sprite  | Palette | Sprite | Plotting |
| Control | area    | image  | mask     |
| Block   | (opt)   |        | (opt)    |
+---------+---------+--------+----------+

The Sprite Control Block contains the following:
(Note sprite offsets are from the beginning of the sprite)
Offset  Size   Description
------  -----  -------------------------------------------------
0       4      Offset to next sprite (from here)
4       12     Sprite name (up to 12 characters with trailing zeroes)
16      4      Width in words - 1
20      4      Height in scan lines
24      4      First bit used (left end of row)
28      4      Last bit used (right end of row)
32      4      Offset to sprite image
36      4      Offset to transparency mask (or sprite image if
               there is no mask)
40      4      Screen mode sprite was defined in
44      n      Palette data (optional)

The Palette

The size of the palette data block depends on the number of bits per pixel in the sprites mode, since there will be one entry for each potential logical colour.

Each palette entry is two words long:

Offset  Size   Description
------  -----  -------------------------------------------------
0       4      First colour of flashing pair
4       4      Second colour of flashing pair

Note: although flashing colours are still supported, it is very rare to find flashing palettes in sprites nowadays.

Each palette value is of the form:

Bits        Meaning
----------  -------------------------
0 - 7       0
8 - 15      Amount of red
16 - 23     Amount of green
24 - 31     Amount of blue

-----Hot links to other pages-----
Acorn Computer Group Acorn Education


© 1995 Acorn Computer Group plc.
Design: © 1995 Cave Rock Software Ltd.
Contact: webmaster@acorn.co.uk