Difference between revisions of "Car files"

From Stunts Wiki
(→‎Car behaviour (car*.res): fixing a few wrong addresses; adding shift pattern centre and air grip parameters)
(→‎Car behaviour (car*.res): Changed to reflect simd-based offsets and the general resource file format)
Line 53: Line 53:
 
==Car behaviour (car*.res)==
 
==Car behaviour (car*.res)==
  
All adjustable aspects of a car behaviour are stored in car*.res, a miscellaneous data resource file. It contains both physics data, such as power curves, and visual parameters, like car height in cockpit view or speedometer behaviour. Also, the file also contains the text data displayed at the car selection screen. Data in car*.res may be read and modified by any hex editor, or more conveniently by a specially-designed graphical editor (see the Tools section ahead).  
+
All adjustable aspects of a car behaviour are stored in car*.res, a miscellaneous data resource file. It contains both physics data, such as power curves, and visual parameters, like car height in cockpit view or speedometer behaviour. Also, the file contains the text data displayed at the car selection screen. Data in car*.res may be read and modified by any hex editor, or more conveniently by a specially-designed graphical editor (see the Tools section ahead).  
  
The function of a large fraction of car*.res hex addresses was elucidated over the years, allowing modifications of many car aspects. Here is a quick reference for those addresses, originally based on the chart available at [http://www.kalpen.de/luke/4dinfo.html#cs Lukas Loehrer's site]. A more throughout discussion on the effects and quirks of the parameters is available at [[Car parameters]]; clicking on a parameter description will lead to the corresponding entry there.
+
The structure of car*.res actually consists of four resources:
 +
*'''simd''', which contains all the numerical parameters;
 +
*'''edes''', a [[Resource file format#Plain text|text resource]] containing the description displayed in the car selection screen;
 +
*'''gsna''', the 4-letter scoreboard abbreviation stored as a text resource; and
 +
*'''gnam''', the scoreboard car name.
 +
 
 +
Only the '''simd''' chunk is of fixed length (306 bytes) while the other three are variable-length ASCIIZ strings. While the order in which these chunk indices and their corresponding file sections is irrelevant to Stunts, all of the original cars have come with the '''simd''' chunk content first, resulting in the positions of car parameters appearing absolute (that is, relative to the beginning of the file). However, new cars or cars modified with new tools may not follow this order. More info in the Tools section.
 +
 
 +
The function of a large fraction of car*.res hex addresses was elucidated over the years, allowing modifications of many car aspects. Here is a quick reference for those addresses, originally based on the chart available at [http://www.kalpen.de/luke/4dinfo.html#cs Lukas Loehrer's site]. A more throughout discussion on the effects and quirks of the parameters is available at [[Car parameters]]; clicking on a parameter description will lead to the corresponding entry there. In the following table, "simd offset" refers to the actual position of the parameter within the '''simd''' chunk, that is, the way Stunts interprets the file. "Absolute offset" refers to the position relative to the beginning of the file in the cases in which the '''simd''' chunk contents have been placed first:
  
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! Byte offset !! Function
+
! simd offset !! Absolute offset !! Function
 
|-
 
|-
| 26h        || [[Car_parameters#Number_of_gears|Number of gears]]
+
| 000h        || 26h        || [[Car_parameters#Number_of_gears|Number of gears]]
 
|-
 
|-
| 28h/29h    || [[Car_parameters#Car_mass|Car mass]]
+
| 002h        || 28h/29h    || [[Car_parameters#Car_mass|Car mass]]
 
|-
 
|-
| 2Ah/2Bh    || [[Car parameters#Braking effectiveness|Braking effectiveness]]
+
| 004h        || 2Ah/2Bh    || [[Car parameters#Braking effectiveness|Braking effectiveness]]
 
|-
 
|-
| 2Ch/2Dh    || [[Car parameters#Idle rpm|Idle rpm]]
+
| 006h        || 2Ch/2Dh    || [[Car parameters#Idle rpm|Idle rpm]]
 
|-
 
|-
| 2Eh/2Fh    || [[Car parameters#Downshift rpm|Downshift rpm (auto transm.)]]
+
| 008h        || 2Eh/2Fh    || [[Car parameters#Downshift rpm|Downshift rpm (auto transm.)]]
 
|-
 
|-
| 30h/31h    || [[Car parameters#Upshift rpm|Upshift rpm (auto transm.)]]
+
| 00Ah        || 30h/31h    || [[Car parameters#Upshift rpm|Upshift rpm (auto transm.)]]
 
|-
 
|-
| 32h/33h    || [[Car parameters#Maximum rpm|Maximum rpm]]
+
| 00Ch        || 32h/33h    || [[Car parameters#Maximum rpm|Maximum rpm]]
 
|-
 
|-
| 36h-41h    || [[Car parameters#Gear ratios|Gear ratios]]
+
| 010h        || 36h-41h    || [[Car parameters#Gear ratios|Gear ratios]]
 
|-
 
|-
| 44h/45h    || [[Car parameters#Shift pattern centre line|Shift pattern centre line]]
+
| 01Eh        || 44h/45h    || [[Car parameters#Shift pattern centre line|Shift pattern centre line]]
 
|-
 
|-
| 46h-5Ch    || [[Car parameters#Shifting knob positions|Shifting knob positions]]
+
| 020h        || 46h-5Ch    || [[Car parameters#Shifting knob positions|Shifting knob positions]]
 
|-
 
|-
| 5Eh/5Fh    || [[Car parameters#Aerodynamic resistance|Aerodynamic resistance]]
+
| 038h        || 5Eh/5Fh    || [[Car parameters#Aerodynamic resistance|Aerodynamic resistance]]
 
|-
 
|-
| 60h        || [[Car parameters#Idle rpm torque|Idle rpm torque]]
+
| 03Ah        || 60h        || [[Car parameters#Idle rpm torque|Idle rpm torque]]
 
|-
 
|-
| 61h-C7h    || [[Car parameters#Torque curve|Torque curve]]
+
| 03Bh        || 61h-C7h    || [[Car parameters#Torque curve|Torque curve]]
 
|-
 
|-
| CAh/CBh    || [[Car parameters#Grip|Grip]]
+
| 0A4h        || CAh/CBh    || [[Car parameters#Grip|Grip]]
 
|-
 
|-
| DAh/DBh    || [[Car parameters#Air grip|Air grip]]
+
| 0B4h        || DAh/DBh    || [[Car parameters#Air grip|Air grip]]
 
|-
 
|-
| DCh-E3h    || [[Car parameters#Surface grip modifiers|Surface grip modifiers]]
+
| 0B6h        || DCh-E3h    || [[Car parameters#Surface grip modifiers|Surface grip modifiers]]
 
|-
 
|-
| EEh-F5h    || [[Car parameters#Dimensions for car-car collisions|Dimensions for car-car collisions]]
+
| 0C8h        || EEh-F5h    || [[Car parameters#Dimensions for car-car collisions|Dimensions for car-car collisions]]
 
|-
 
|-
| F6h/F7h    || [[Car parameters#Apparent Car height|Car height (from inside view)]]
+
| 0D0h        || F6h/F7h    || [[Car parameters#Apparent Car height|Car height (from inside view)]]
 
|-
 
|-
| F8h-10Fh    || [[Car parameters#Car dimensions|Wheel coordinates / external dimensions]]
+
| 0D2h        || F8h-10Fh    || [[Car parameters#Car dimensions|Wheel coordinates / external dimensions]]
 
|-
 
|-
| 110h-14Dh  || [[Car parameters#Steering wheel dot movement|Steering wheel dot movement]]
+
| 0EAh        || 110h-14Dh  || [[Car parameters#Steering wheel dot movement|Steering wheel dot movement]]
 
|-
 
|-
| 14Eh-223h  || [[Car parameters#Speedometer needle movement|Speedometer needle movement]]
+
| 128h        || 14Eh-223h  || [[Car parameters#Speedometer needle movement|Speedometer needle movement]]
 
|-
 
|-
| 154h-159h  || [[Car parameters#Digital speedometer|Digital speedometer]]
+
| 12Eh        || 154h-159h  || [[Car parameters#Digital speedometer|Digital speedometer]]
 
|-
 
|-
| 224h-329h  || [[Car parameters#Rev meter needle movement|Rev meter needle movement]]
+
| 1FEh        || 224h-329h  || [[Car parameters#Rev meter needle movement|Rev meter needle movement]]
 
|-
 
|-
| 32Eh-EOF    || [[Car parameters#Text data|Text data (car selection screen and high score table)]]
+
| 308h        || 32Eh-EOF    || [[Car parameters#Text data|Text data (car selection screen and high score table)]]
 
|-
 
|-
 
|}
 
|}
 
The actual structure of car*.res consists of four resources:
 
*'''simd''', which contains all the numerical parameters;
 
*'''edes''', a [[Resource file format#Plain text|text resource]] containing the description displayed in the car selection screen;
 
*'''gsna''', the 4-letter scoreboard abbreviation stored as a text resource; and
 
*'''gnam''', the scoreboard car name.
 
  
 
==Version compatibility==
 
==Version compatibility==

Revision as of 20:03, 9 January 2022

Stunts cars are made of four different resource files. For the original Stunts cars, all of the car graphics are stored in the compressed st*.p3s, stda*.pvs, stdb*.pvs files ('*' stands for a four-letter abbreviation shared by files of the same car). On many custom cars, .p3s and .pvs files are replaced by their uncompressed counterparts, with extensions .3sh and .vsh respectively. The fourth file, car*.res, contains numerical and text parameters, including data about car performance essential to the creation of tuned cars.

Graphics files (.p3s/.pvs)

Different aspects of a car's appearance are stored in each of the graphic files:

  • st*.p3s - 3d shape resource file that stores the graphical 3D models of the car, including their colour data.
  • stda*.pvs - Bitmap resource file that contains the dashboard image, including the shifting stick's base.
  • stdb*.pvs - Bitmap resource file that contains the shifting knob. For the Corvette, it also stores the digital speedometer graphics.

Each of the files contain a number of independent resources, used on different places or in-game situations. Here a rundown of those resources contained within each file will be presented. For an explanation of internal structure of the resources, applicable to all files here discussed, check the Resource file format article. It is important to emphasize all graphics files are compressed, and thus any visualization or edition of the original cars' graphics calls for prior decompression. As a consequence, custom cars with modified graphics have the compressed .p3s and .pvs files substituted by their uncompressed .3sh and .vsh counterparts.

3D shapes (st*.p3s)

An illustration of the resolution differences between car0 and car1 shapes. On this image, car0 was used instead of the usual car1 to render the Indycar on-track. The screenshot was taken with the car on the ground, and under F3 camera fully zoomed out.

Standard st*.p3s files contain seven 3D shape resources, each being used in different circumstances:

  • car0 shape is the one used in the car selection screen. It is richly detailed for Stunts usual standards, and has pretty high internal resolution.
  • car1 shape corresponds to the car actually rendered on-track. Its resolution is much smaller than the car0 shape, the scaling down factor being 1:20, thus explaining why many fine details seen on the "showroom" car are not seen on-track.
  • car2 shape is the very long distance model, used only for the initial zoom-in animation that precedes the "Fasten your seatbelt!" message at the start of a race. It has very low resolution, to the point of being barely recognizable.
  • exp0, exp1, exp2 and exp3 aren't really proper 3D shapes, but rather individual lines and polygons that make up the bits of debris seen after a crash.

Dashboard static parts (stda*.pvs)

A car dashboard is composed by a number of separate bitmaps, not of them being used by all cars:

  • !cg0 and !eg0 are alternative palettes for non-VGA graphic modes.
  • dash is the base panel of the dashboard, covering most of its drawn area.
  • dast complements the top of the dash bitmap with curved areas, as seen on the Indy for instance. Since all bitmap resources correspond, naturally, to rectangular areas, there's an additional bitmap, dasm, which acts as an alpha mask in order to have the proper looks of a curved surface instead of a rectangular block.
  • roof is the strip seen atop above the windshield for a number of cars - for instance, the ones containing "PORSCHE" or "JAGUAR" inscriptions on the IMSA cars.
  • whl2 is the centered steering wheel bitmap. The internal pixel coordinates of it are used to define steering wheel dot positions in the car*.res.
  • whl1 and whl3 are graphics for the wheel steered left and right respectively.
  • ins2 corresponds to the meters - tachometer and/or analog speedometer. Although the bitmap itself is redundant for all default cars, since the meter graphics are included in dash as well, ins2 has an actual purpose: define the internal coordinates for speedometer/tachometer needle render, controlled by car*.res.
  • ins1 and ins3 are complementary graphics corresponding to small sections of the dashboard uncovered when the wheel is steered left or right (and so they are complementary to whl1 and whl3, in that order). Since the images are not rectangular, alpha masks inm1 and inm3 are needed, just like dasm was for dast.
  • gbox is the shifting stick base. Coordinates for shifting knob positions are defined within the reference frame of this bitmap.

Dashboard moving parts (stdb*.pvs)

The stdb*.pvs file contains a few auxiliary bitmaps that are not rendered all the time or change position within the screen often:

  • !cg0 and !eg0 are alternative palettes for non-VGA graphic modes.
  • dot is the blue steering wheel dot. As every non-rectangular bitmap, it calls for an alpha mask, in this case called dota.
  • dot1 and dot2 are strange versions of dot with a tiny palette-like strip inserted into its top. They are involved in the rendering of the dot at off-center wheel positions.
  • gnob is the shifting gear knob, and gnab, its alpha mask.
  • From dig0 to dig9 there are individually-stored digits for Corvette-style digital speedometers. Their rendering is not completely straightforward, as those digits do not are not placed over the dashboard as a rectangular block and yet there are no alpha masks.

All the dashboard moving parts are positioned according to various car*.res parameters, as described in the Car parameters article. The vector-drawn speedometer and tachometer needles are controlled by car*.res as well.

Editing and combining car graphics

Graphic files of different cars are independent, and thus can be mixed freely when constructing a new car. The main point of concern when doing so usually is adjusting car*.res so that moving parts of the dashboard behave properly. The classical example of this mix-and-match approach is Alan Rotoi's famous Melange. The actual edition of the graphics was a long-standing goal of the community that for many years was deemed impossible due the lack of information about the format employed by the developers to compress the files. In March 2008, this riddle was finally solved by dstien, and since then the possibilities for modding have grown a lot (see Tools section further down the article). As mentioned before, cars with custom graphics use uncompressed .3sh and .vsh resource files . Stunts 1.1 is able to read these uncompressed files correctly; however, if there are any compressed (.p3s and .pvs) files for the same car (that is, sharing the four-letter abbreviation) in the game folder these will be loaded in expense of the uncompressed files.

Car behaviour (car*.res)

All adjustable aspects of a car behaviour are stored in car*.res, a miscellaneous data resource file. It contains both physics data, such as power curves, and visual parameters, like car height in cockpit view or speedometer behaviour. Also, the file contains the text data displayed at the car selection screen. Data in car*.res may be read and modified by any hex editor, or more conveniently by a specially-designed graphical editor (see the Tools section ahead).

The structure of car*.res actually consists of four resources:

  • simd, which contains all the numerical parameters;
  • edes, a text resource containing the description displayed in the car selection screen;
  • gsna, the 4-letter scoreboard abbreviation stored as a text resource; and
  • gnam, the scoreboard car name.

Only the simd chunk is of fixed length (306 bytes) while the other three are variable-length ASCIIZ strings. While the order in which these chunk indices and their corresponding file sections is irrelevant to Stunts, all of the original cars have come with the simd chunk content first, resulting in the positions of car parameters appearing absolute (that is, relative to the beginning of the file). However, new cars or cars modified with new tools may not follow this order. More info in the Tools section.

The function of a large fraction of car*.res hex addresses was elucidated over the years, allowing modifications of many car aspects. Here is a quick reference for those addresses, originally based on the chart available at Lukas Loehrer's site. A more throughout discussion on the effects and quirks of the parameters is available at Car parameters; clicking on a parameter description will lead to the corresponding entry there. In the following table, "simd offset" refers to the actual position of the parameter within the simd chunk, that is, the way Stunts interprets the file. "Absolute offset" refers to the position relative to the beginning of the file in the cases in which the simd chunk contents have been placed first:

simd offset Absolute offset Function
000h 26h Number of gears
002h 28h/29h Car mass
004h 2Ah/2Bh Braking effectiveness
006h 2Ch/2Dh Idle rpm
008h 2Eh/2Fh Downshift rpm (auto transm.)
00Ah 30h/31h Upshift rpm (auto transm.)
00Ch 32h/33h Maximum rpm
010h 36h-41h Gear ratios
01Eh 44h/45h Shift pattern centre line
020h 46h-5Ch Shifting knob positions
038h 5Eh/5Fh Aerodynamic resistance
03Ah 60h Idle rpm torque
03Bh 61h-C7h Torque curve
0A4h CAh/CBh Grip
0B4h DAh/DBh Air grip
0B6h DCh-E3h Surface grip modifiers
0C8h EEh-F5h Dimensions for car-car collisions
0D0h F6h/F7h Car height (from inside view)
0D2h F8h-10Fh Wheel coordinates / external dimensions
0EAh 110h-14Dh Steering wheel dot movement
128h 14Eh-223h Speedometer needle movement
12Eh 154h-159h Digital speedometer
1FEh 224h-329h Rev meter needle movement
308h 32Eh-EOF Text data (car selection screen and high score table)

Version compatibility

Cars that use graphic files from Stunts 1.0 do not work properly on 1.1 versions, and vice-versa. Attempting to exchange cars between versions will cause crashes in the car selection screen due to file format incompatibilities. The simpler and naturally uncompressed car*.res files may be exchanged between versions, although car performance won't be the same due to the known differences between game versions in that respect.

Tools

The car*.res files can be read and edited by any hex-editor or text editor able to display files in hexadecimal mode - HT and Vim are examples of each case). A more convenient alternative are graphical hex-editors designed especially for Stunts car hacking. Mark Nailwood's Car Blaster, by far the most used of those, has resources such as tags on useful bytes and comparison between cars. Other editors include Caredit and Winedit.

It should be noted that modified cars are not recognized by the original RPL Info tool, created by Lukas Loehrer.

In 2008, dstien started development of stuntstools, a set of programs that allow decompression of packed resource files and manipulation of the resources contained within. stuntstools' flagship application, stressed, revolutionized custom car creation by making edition of in-game 3D shapes and bitmaps possible. Starting from revision 59, stressed can also be used to modify CAR*.RES parameters as raw binary data.

See also

External Links