Difference between revisions of "Resource file format"
m (→File names: Table styling) |
(Pseudo code styling and additional info on "unknown2" in bitmap struct) |
||
Line 29: | Line 29: | ||
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 | + | <span class="hlC">// Header</span> |
− | <span | + | <span class="hlP">uint32</span> fileLength |
− | <span | + | <span class="hlP">uint16</span> numResources |
− | <span | + | <span class="hlC">// Table of contents</span> |
− | <span | + | <span class="hlP">char</span> ids<span class="hlB">[</span>numResources<span class="hlB">][</span><span class="hlN">4</span><span class="hlB">]</span> |
− | <span | + | <span class="hlP">uint32</span> offsets<span class="hlB">[</span>numResources<span class="hlB">]</span> |
− | <span | + | <span class="hlC">// Resource data</span> |
− | <span | + | <span class="hlP">char</span> data<span class="hlB">[]</span> |
==Types== | ==Types== | ||
Line 50: | Line 50: | ||
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 | + | <span class="hlP">uint16</span> width |
− | <span | + | <span class="hlP">uint16</span> height |
− | <span | + | <span class="hlP">uint16</span> unknown1<span class="hlB">[</span><span class="hlN">4</span><span class="hlB">]</span> |
− | <span | + | <span class="hlP">uint8</span> unknown2<span class="hlB">[</span><span class="hlN">4</span><span class="hlB">]</span> |
− | <span | + | <span class="hlP">uint8</span> image<span class="hlB">[</span>width <span class="hlB">*</span> height<span class="hlB">]</span> |
− | Parts of this structure are not fully understood. <tt>unknown1</tt> appears to be related to Stunts' | + | Parts of this structure are not fully understood. <tt>unknown1</tt> appears to be related to Stunts' internal 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]. Images with pixel data stored as continuos horizontal lines has <tt>unknown2</tt> set to <code>{ 0x1, 0x2, 0x4, 0x8 }</code>. |
{{sectstub}} | {{sectstub}} |
Revision as of 13:11, 22 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' internal memory management. unknown2 seems to affect how image pixels are organized in compressed resource files, likely to gain more effective run-length compression. Images with pixel data stored as continuos horizontal lines has unknown2 set to { 0x1, 0x2, 0x4, 0x8 }
.