Difference between revisions of "Resource file format"

From Stunts Wiki
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 style="color:#777; font-style: italic">// Header</span>
+
  <span class="hlC">// Header</span>
  <span style="color:#933">uint32</span> fileLength
+
  <span class="hlP">uint32</span> fileLength
  <span style="color:#933">uint16</span> numResources
+
  <span class="hlP">uint16</span> numResources
 
   
 
   
  <span style="color:#777; font-style: italic">// Table of contents</span>
+
  <span class="hlC">// Table of contents</span>
  <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>
+
  <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 style="color:#933">uint32</span> offsets<span style="color:#6c6">[</span>numResources<span style="color:#6c6">]</span>
+
  <span class="hlP">uint32</span> offsets<span class="hlB">[</span>numResources<span class="hlB">]</span>
 
   
 
   
  <span style="color:#777; font-style: italic">// Resource data</span>
+
  <span class="hlC">// Resource data</span>
  <span style="color:#933">char</span>  data<span style="color:#6c6">[]</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 style="color:#933">uint16</span> width
+
  <span class="hlP">uint16</span> width
  <span style="color:#933">uint16</span> height
+
  <span class="hlP">uint16</span> height
  <span style="color:#933">uint16</span> unknown1<span style="color:#6c6">[</span><span style="color:#c6c">4</span><span style="color:#6c6">]</span>
+
  <span class="hlP">uint16</span> unknown1<span class="hlB">[</span><span class="hlN">4</span><span class="hlB">]</span>
  <span style="color:#933">uint8</span>  unknown2<span style="color:#6c6">[</span><span style="color:#c6c">4</span><span style="color:#6c6">]</span>
+
  <span class="hlP">uint8</span>  unknown2<span class="hlB">[</span><span class="hlN">4</span><span class="hlB">]</span>
 
   
 
   
  <span style="color:#933">uint8</span>  image<span style="color:#6c6">[</span>width * height<span style="color:#6c6">]</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' 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' 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 14: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

VGA palette used by bitmap images. Value 255 is transparency.

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 }.

Icons

3d shapes

Car parameters

Main article: Car parameters

Opponent parameters

Music tracks

Instrument samples

Sound effects

Tools

  • stressed - Stunts/4D [Sports] Driving resource editor [1].