DO/Updated Sprite Format
From Dark Omen Wiki
(Difference between revisions)
Line 1: | Line 1: | ||
- | =Overall Structure= | + | ==Overall Structure== |
The overall structure of a sprite file looks a like this (in this order): | The overall structure of a sprite file looks a like this (in this order): | ||
Line 10: | Line 10: | ||
For a description of each part, see below. | For a description of each part, see below. | ||
- | =File Header= | + | ==Sprite File Header== |
The file header consists of the first 32 bytes of the file | The file header consists of the first 32 bytes of the file | ||
Line 27: | Line 27: | ||
(* This is the total number of colours stored in the file, each of which belongs only to one palette. e.g. there may be 300 colours stored in the file, spread throughout 5 different palettes; the paletteEntryCount is 300, the paletteCount is 5 ) | (* This is the total number of colours stored in the file, each of which belongs only to one palette. e.g. there may be 300 colours stored in the file, spread throughout 5 different palettes; the paletteEntryCount is 300, the paletteCount is 5 ) | ||
+ | |||
+ | ==Frame Header== | ||
+ | |||
+ | There is one frame header for each animation frame in the sprite: | ||
+ | |||
+ | struct FrameHeader | ||
+ | { | ||
+ | byte frameType; // see table below (1) | ||
+ | byte compressionType; // 0: not compressed, 1: packbits, 2: unknown (2) | ||
+ | short colourCount; // = the number of unique colours in the frame | ||
+ | signed short X; // = X position of this frame | ||
+ | signed short Y; // = Y position of this frame | ||
+ | short frameWidth; // = width of this frame | ||
+ | short frameHeight; // = height of this frame | ||
+ | int frameDataOffset; // = offset into the frame data (3) | ||
+ | int compressedSize; // = length of the compressed frame data | ||
+ | int uncompressedSize; // = length of the uncompressed frame data | ||
+ | int paletteDataOffset; // = offset into the palette data | ||
+ | int unknown; // = 0 | ||
+ | } | ||
+ | |||
+ | #1: Each frame has a type: |
Revision as of 16:32, 19 July 2008
Overall Structure
The overall structure of a sprite file looks a like this (in this order):
SPRITE FILE HEADER (32 bytes) FRAME HEADERS x Number of frames (32 bytes each) PALETTE ENTRIES x Number of colors in palette (4 bytes each) FRAME DATA x Number of frames (size varies)
For a description of each part, see below.
Sprite File Header
The file header consists of the first 32 bytes of the file
struct SpriteFileHeader { char ID[4]; // = 'WHDO' int filesize; // = the size of the file in bytes int version?; // = 32 int frameDataOffset // = file offset to beginning of the frame data int paletteDataOffset // = file offset to beginning of the palette data int paletteEntryCount // = the total number of palette entries (*) int paletteCount // = how many unique palettes exist in this sprite int frameCount // = the number of frames of animation in this sprite }
(* This is the total number of colours stored in the file, each of which belongs only to one palette. e.g. there may be 300 colours stored in the file, spread throughout 5 different palettes; the paletteEntryCount is 300, the paletteCount is 5 )
Frame Header
There is one frame header for each animation frame in the sprite:
struct FrameHeader { byte frameType; // see table below (1) byte compressionType; // 0: not compressed, 1: packbits, 2: unknown (2) short colourCount; // = the number of unique colours in the frame signed short X; // = X position of this frame signed short Y; // = Y position of this frame short frameWidth; // = width of this frame short frameHeight; // = height of this frame int frameDataOffset; // = offset into the frame data (3) int compressedSize; // = length of the compressed frame data int uncompressedSize; // = length of the uncompressed frame data int paletteDataOffset; // = offset into the palette data int unknown; // = 0 }
- 1: Each frame has a type: