Car parameters

From Stunts Wiki
Revision as of 00:35, 19 January 2008 by Duplode (talk | contribs)

This article discuss how the car*.res parameters control the performance, handling, aestethics and other aspects of a Stunts car. The parameters are grouped by function, in order to allow more fluent reading and discussion. A quick reference chart of byte addresses may be found at the Car files article.

Preliminary notes

  • Byte offsets will always be refered to as hex-addresses. That is the normal behaviour for any usual hex-editor, but not that of Car Blaster, where you must press "h" to display offsets in hexadecimal. More importantly, on this document bytes are classified as even or odd depending on the hex address, giving opposite results to what one gets with decimal counting (for the first byte of a file is offset 0h). Byte values may be quoted both ways for the sake of convenience; thus an "h" will be appended to any hex number on this article.
  • Several important parameters have their value defined by two consecutive bytes defining a four digit hexadecimal, xxyyh. The first one of them sets the yy algarisms and the last one the xx, so that a change of 1 in the first byte causes a change 1/256 (or 1/100h) smaller than a change of 1 in the second byte. Any mention to one byte doing the gross adjustment and another the fine tuning of a parameter implies such kind of control. Also, when quoting values that way, italics will be used for clarity.

Engine and Transmission

Torque curve

Address: 60h-C7h

Defining how much acceleration the engine can impart on a car at every given engine speed (rpm), the torque curve is naturally a very important factor in determining performance. Every byte corresponds to increments of about 125rpm. The curve works as expected: raising a byte increases linearly acceleration at a given rpm. A more peaky torque curve means a narrower range of useful engine speeds - and thus, the driver will have to shift more often. Another important point is to remember adjusting offsets 32h and 33h properly depending on where the torque curve is intended to end.

Number of gears

Address: 26h

Self-explanatory. Valid optoins go from 1 to 6 gears. Note that for a 6th gear the appropriate parameters will have to be defined elsewhere.

Idle rpm

Address: 2Ch - fine tuning (1rpm units); 2Dh - gross adjustment (256rpm units).

This parameter controls the minimum rpm value to be shown on the rev meter, supposedly while the car is stopped or starting to accelerate. Since engine speed and car speed are always vinculated in Stunts (in other words, the clutch is always engaged!), the parameter is purely cosmetical.

Useful note on all rpm parameters: As raising a byte on the gross ajdjustment offset raises the value in rpm by about 250, it is reasonable to assume the variation is exactly 256rpm. That way, the xxyyh value mentioned in the preliminary notes can be taken as the true rpm value in hexadecimals. For instance, 2Ch = F0h and 2Dh = 02h would give an idle rpm of 02F0h = 752rpm.

Downshift rpm

Address: 2Eh - fine tuning (1rpm units); 2Fh - gross adjustment (256rpm units).

This is the downshift rpm ponit used by the automatic transmission. For optimal performance, it should match the rpm position of the torque curve's peak.

Upshift rpm

Address: 30h - fine tuning (1rpm units); 31h - gross adjustment (256rpm units).

This is the upshift rpm ponit used by the automatic transmission. For optimal performance, it should match the rpm position of the power curve's peak - remember that, at any given rpm, power = torque * rpm; you may estimate a power curve in arbitrary units from the torque curve that way.

Maximum rpm

Address: 32h - fine tuning (1rpm units); 33h - gross adjustment (256rpm units).

This parameter is the maximum rpm (the "redline") of the engine. Unlike the Idle rpm parameter, this one is not cosmetical - the torque curve will be cut off at the chose rpm, and thus the value should be djusted whenever the torque curve is extended to higher rpms.

Gear ratios

Address: 37h - 41h (odd addresses only)

These parameters set the gear ratios of the car, and are thus very important ones. 37h sets 1st gear, 39h the second one, and so on - unlike for the rpm parameters, the even addresses have no effect whatsoever. A higher value means a shorter ratio, and thus higher acceleration but less final car speed for that certain gear (at any rpm effective torque is proportional, but wheel speed is inversely proportional, to gear ratio). A realistic car need of course to have decreasing gear ratios, and for smoother engine operation a near-exponential decrease would be more adequate.

Physics parameters

Car mass

Address: 27h - fine tuning; 28h - gross adjustment.

This parameter has ben variously described over the years as "inverse power amplification" (Mark Nailwood) or "aerodynamic resistance" (Juha Liukkonen / Lukas Loehrer). A true aeroynamic coefficient effect, however, would affect more the car when at high speeds. Raising this parameter causes a decrease in acceleration directly proportional to the increment, all gear being affected equally. Therefore, the parameter is best regarded as being the car mass. Clearly, it has crucial importance to the car performance, being the only non engine/transmission parameter to limit acceleration.

Braking effectiveness

Address: 2Ah - fine tuning; 2Bh - gross adjustment.

As the name says, those addresses tell how poweful the car brakes will be. The relation is approximately linear, so 0100h will make a car go from 97mph to a full stop in ~4.6s, 0200h will halve that time and 0000h will require several minutes... Other parameters, such as mass or grip, have no effect on braking.


Grip

Address: CAh - fine tuning; CBh - gross adjustment.

This is the lone handling parameter. Higher values mean extra adhesion and thus less tendency of sliding and loss of control in corners. Since there is no reliable way of doing a corner at constant speed, this parameter is harder to quantify. A crude idea may be gained from attempting to do narrow snake lines around the central line in asphalt. With grip at 0100h, the car starts to skid at ~70mph. Raising to 0200h allows one to swerve without skidding almost up to 150mph.

Dashboard controls

Shifting knob positions

Address: 46h - 5Ch (even addresses only)

Those parameters control where the knob will appear at each gear. Like most positioning parameters, those act according to a rather obscure set of internal coordinates. Bytes 46h, 4Ah, etc. set horizontal positions of each gear; increasing those moves the knob rightwards. Their counterparts 48h, 4Ch, etc. set vertical positions; however for some reason raising them move the knob downwards (that behaviour is observed elsewhere). A funny thing is that those parameters are not purely aestethical, as setting a position very far from the previous one will raise the time needed to engage the gear!

Car height

Address: F6h

This sets the apppearant height from the ground on cockpit (F1) view. The parameter has no effect on the 3D model, so if you fancy setting this to a ridiculosly high value the car won't carsh into roofs - rather, you'd better worry with things below your eyes...

Steering wheel dot movement

Address: 110h - 14Dh

Now those are quite capricious. The first pair of bytes control the dot position with the wheel centered. As for the other 33 pairs, each one controls dot position for a certain ammount of steering applied both when turning to the right (actual coordinate value) and to the left (horizontal coordinate is mirrored relative to the central dot). This also means that displacing the center point without adjusting the other points will cause the left-side points do be displaced with the central, but not the right side points... Anyway, even bytes control horizontal position (increase displaces rightwards) and odd bytes define vertical position (increase displaces downwards). The internal coordinates system employed is unrelated to the one applied elsewhere.

Speedometer needle movement

Address: 14Eh - 223h

Like the other meters, the movement is contolled by the position of individual points; each point being assigned a pair of bytes, the first byte setting horizontal position (increases displace rightwards) and the second setting vertical (increases displace downards) with reference to some internal coordinates system. The pair 14Eh/150h defines the center point (horiz. and vert., respectively). The tip of the needle for each speed is controlled by consecutive pairs from 154h on (104 positions avilable), even bytes setting horizontal positon and odd bytes vertical position. In case one needs to get rid of the needle altogether (like for IMSA dshboards), the quick'n dirty solution is to set 14Eh and 150h to FFh and 154h - 223h to zero.

Digital speedometer

Address: 150h - 159h

This is a funny one. To have a digital speedometer first one needs to use the Corvette shifting knob (that is, a copy of STDBVETT.PVS), for the graphics are stored there. Also, a dashboard with proper contrast must be chosen (even if the game can switch number colours automatically depending on the background, some dashboards will still look awful). Then, byte 150h must be set to 0h. That will trigger the analog needle to disappear and be replaced by the set of numbers, whose coordinates are controlled in the usual fashion (first byte of the pair controls horizontal position moving rightwards when increased, and second byte moves vertically downwards when increased) by the pairs 154h/155h, 156h/157h and 158h/159h (first, second and third digits from left to right respectively).

Rev meter needle movement

Address: 224h - 32Dh

The rev meter is completely analogous to the analog speedometer. The pair 224h/226h sets the center point and the pairs from 22Ah to 32Dh define the tip positions (130 positions available), workings and details being the same as those discussed for the speedometer.

Text

Car information

Address: 32Eh - ???h

Quoting Lukas Loehrer directly:

Car information displayed on the 'choose your car' screen. Use ] (5Dh) for linebreaks. The end of this block can not be given by an absolute address. Look for a byte with the value 00h. It is followed by a 4 byte long car id which is again terminated by a 00h.

The "4 byte long car id" mentioned above is the abbreviation displayed alongside opponent name in the scoreboard. Car information is most conveniently edited via Car Blaster, which has a specific WYSIWYG interface for dealing with it.

Scoreboard car name

Address: ???h - EOF

The final bytes of the file (after the terminating 00h mentioned above) make up the scoreboard designation of the car. It can be edited via Car Blaster like the other text pieces as well.

Miscellaneous

"Header" bytes

Address: 00h - 1Fh

The first few bytes of car*.res seem to be mostly vinculated with internal workings of the game. The sequence 01h - 19h is constant for all cars, and changing any byte in it is sure to break something, either minor (like making text at "choose your car" screen disappear) or major (like crashing the game at car selection). Byte 00h, however, is different for all original cars, so it might have some identification role - Car Blaster ensures that when saving a new car it will have an unique 00h value. Anyway, there is little reason to change any of those bytes.

"Graphical displacement ratio offset"

Address: 10Fh

This looks like some sort of Easter Egg... Default value for all cars is between F8h and FAh depending on the car (and is supposed to be kept as it is...). Now try lowering it by some 30 (1Eh) units and see what happens! [{Cateogry:Driving]]