Difference between revisions of "Resource file format"
m (→Plain text: Typo.) |
m (Syntax highlighting.) |
||
Line 53: | Line 53: | ||
The resource file header consists of two integer fields denoting the total length of the file and the number of resources contained. The following table of contents has a list of ids and a corresponding list of offsets into the remaining data section. | The resource file header consists of two integer fields denoting the total length of the file and the number of resources contained. The following table of contents has a list of ids and a corresponding list of offsets into the remaining data section. | ||
− | < | + | <span style="color:#777; font-style: italic">// Header</span> |
− | // Header | + | <span style="color:#933">uint32</span> fileLength |
− | uint32 fileLength | + | <span style="color:#933">uint16</span> numResources |
− | uint16 numResources | + | |
− | + | <span style="color:#777; font-style: italic">// Table of contents</span> | |
− | // Table of contents | + | <span style="color:#933">char</span> ids<span style="color:#6c6">[</span>numResources<span style="color:#6c6">][</span><span style="color:#c6c">4</span><span style="color:#6c6">]</span> |
− | char ids[numResources][4] | + | <span style="color:#933">uint32</span> offsets<span style="color:#6c6">[</span>numResources<span style="color:#6c6">]</span> |
− | uint32 offsets[numResources] | + | |
− | + | <span style="color:#777; font-style: italic">// Resource data</span> | |
− | // Resource data | + | <span style="color:#933">char</span> data<span style="color:#6c6">[]</span> |
− | char data[] | ||
− | </ | ||
==Types== | ==Types== | ||
Line 76: | Line 74: | ||
Bitmaps are images with 8-bit color depth using a [[:Image:Stunts-pal-vga.png|fixed palette]] in VGA mode. Special bitmaps using the naming scheme <tt>!cg_</tt> and <tt>!eg_</tt> provides color mapping for graphics modes with fewer available colors. | Bitmaps are images with 8-bit color depth using a [[:Image:Stunts-pal-vga.png|fixed palette]] in VGA mode. Special bitmaps using the naming scheme <tt>!cg_</tt> and <tt>!eg_</tt> provides color mapping for graphics modes with fewer available colors. | ||
− | < | + | <span style="color:#933">uint16</span> width |
− | uint16 width | + | <span style="color:#933">uint16</span> height |
− | uint16 height | + | <span style="color:#933">uint16</span> unknown1<span style="color:#6c6">[</span><span style="color:#c6c">4</span><span style="color:#6c6">]</span> |
− | uint16 unknown1[4] | + | <span style="color:#933">uint8</span> unknown2<span style="color:#6c6">[</span><span style="color:#c6c">4</span><span style="color:#6c6">]</span> |
− | uint8 unknown2[4] | + | |
− | + | <span style="color:#933">uint8</span> image<span style="color:#6c6">[</span>width * height<span style="color:#6c6">]</span> | |
− | uint8 image[width * height] | ||
− | </ | ||
Parts of this structure are not fully understood. <tt>unknown1</tt> appears to be related to Stunts' image memory management. <tt>unknown2</tt> seems to affect how image pixels are organized in compressed resource files, likely to gain more effective [http://en.wikipedia.org/wiki/Run-length_encoding run-length compression]. | Parts of this structure are not fully understood. <tt>unknown1</tt> appears to be related to Stunts' image memory management. <tt>unknown2</tt> seems to affect how image pixels are organized in compressed resource files, likely to gain more effective [http://en.wikipedia.org/wiki/Run-length_encoding run-length compression]. |
Revision as of 20:27, 21 April 2008
Stunts game data are stored in a common container format. Files of this format can hold multiple resources of any type, identified only by a 4-byte name. A resource file can be encapsulated by compression.
This document focuses on BB Stunts 1.1, but details described here may still—partly or wholly—cover other versions, or even other games developed by DSI at the time.
File names
Different file name extensions are used to indicate the content of the files. Compressed files has "P" (packed) as the first letter of their extensions. Whether the game prefers raw or compressed files varies based on file type.
File contents | Raw | Compressed | Preferred |
---|---|---|---|
Text and misc. settings | RES | PRE | Raw |
Bitmap images | VSH | PVS | Compressed |
Icons | ESH | PES | Compressed |
3d shapes | 3SH | P3S | Compressed |
Music tracks | KMS | PKM | Raw |
Instrument samples | VCE | PVC | Raw |
Sound effects | SFX | PSF | Raw |
Structure
The resource file header consists of two integer fields denoting the total length of the file and the number of resources contained. The following table of contents has a list of ids and a corresponding list of offsets into the remaining data section.
// Header uint32 fileLength uint16 numResources // Table of contents char ids[numResources][4] uint32 offsets[numResources] // Resource data char data[]
Types
Resource type can be determined by looking at the resource's id string and/or the source file name.
Plain text
Text resources are null-terminated C strings found in RES/PRE files. Strings can contain non-alphanumeric codes used by the game to achieve certain effects. Most prominent is the "]" (right square bracket) used to represent newline in multi-line text.
Bitmap images
Bitmaps are images with 8-bit color depth using a fixed palette in VGA mode. Special bitmaps using the naming scheme !cg_ and !eg_ provides color mapping for graphics modes with fewer available colors.
uint16 width uint16 height uint16 unknown1[4] uint8 unknown2[4] uint8 image[width * height]
Parts of this structure are not fully understood. unknown1 appears to be related to Stunts' image memory management. unknown2 seems to affect how image pixels are organized in compressed resource files, likely to gain more effective run-length compression.