Resource file format

From Stunts Wiki
Revision as of 20:27, 21 April 2008 by Dstien (talk | contribs) (Syntax highlighting.)

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' image memory management. unknown2 seems to affect how image pixels are organized in compressed resource files, likely to gain more effective run-length compression.

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