Difference between revisions of "Car parameters"

From Stunts Wiki
(→‎Torque curve: Fixing a serious mistake, see further explanations on the "Car model physics" companion edit)
(→‎Dashboard controls: 152h and 228h)
Line 105: Line 105:
 
'' '''Address:''' 14Eh - 223h ''
 
'' '''Address:''' 14Eh - 223h ''
  
Like the other meters, the movement is controlled by the position of individual points; each point being assigned a pair of bytes, the first byte setting horizontal position and the second setting vertical with reference to the coordinates of stda* ins2 bitmap. The pair 14Eh/150h defines the center point (horizontal and vertical, respectively). The tip of the needle for each speed is controlled by consecutive pairs from 154h on, even bytes setting horizontal position and odd bytes vertical position. Each pair of bytes covers an interval of 2.5 mph, starting from zero. Finally, in case one needs to get rid of the needle altogether (like for IMSA dashboards), the quick'n dirty solution is to set 14Eh and 150h to FFh and 154h - 223h to zero.
+
Like the other meters, the movement is controlled by the position of individual points; each point being assigned a pair of bytes, the first byte setting horizontal position and the second setting vertical with reference to the coordinates of stda* ins2 bitmap. The pair 14Eh/150h defines the center point (horizontal and vertical, respectively). Byte 152h sets the number of needle positions to be displayed. The tip of the needle for each speed is controlled by consecutive pairs from 154h on, even bytes setting horizontal position and odd bytes vertical position. Each pair of bytes covers an interval of 2.5 mph, starting from zero. Finally, in case one needs to get rid of the needle altogether (like for IMSA dashboards), the easiest solution is to set 14Eh and 150h to FFh and 154h - 223h to zero - simply setting 152h to zero won't work as expected.
  
 
===Digital speedometer===
 
===Digital speedometer===
Line 117: Line 117:
 
'' '''Address:''' 224h - 32Dh ''
 
'' '''Address:''' 224h - 32Dh ''
  
The rev meter is completely analogous to the [[Car parameters#Speedometer needle movement|analog speedometer]]. The pair 224h/226h sets the center point and the pairs from 22Ah to 32Dh define the tip positions, totaling 130 positions available. Every pair of bytes covers 125rpm, and like for the speedometer there's an offset as well (second byte range is 250-375rpm, and so on). Else, the workings and details being the same as those discussed for the speedometer. Again, the reference frame is provided by stda* ins2 bitmap.
+
The rev meter is completely analogous to the [[Car parameters#Speedometer needle movement|analog speedometer]]. The pair 224h/226h sets the center point, 228h sets the number of needle positions to be displayed and the pairs from 22Ah to 32Dh define the tip positions, totaling 130 positions available. Every pair of bytes covers 125rpm, and like for the speedometer there's an offset as well (second byte range is 250-375rpm, and so on). Else, the workings and details being the same as those discussed for the speedometer. Again, the reference frame is provided by stda* ins2 bitmap.
  
 
==Text data==
 
==Text data==

Revision as of 23:56, 20 April 2009

This article discuss how the car*.res parameters control the performance, handling, aesthetics 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. For a deeper discussion on the inner workings of physical parameters, refer to Car model physics .

Preliminary notes

  • Byte offsets will always be referred 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 are expressed as 2-byte little endian integer numbers. On layman terms, we could say their value is defined by two consecutive bytes defining a four digit hexadecimal, xxyyh. The first one of them sets the yy digits 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 navigated forward corresponds to increments of 125rpm. The curve works as expected: raising a byte increases linearly acceleration given by the engine 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 options 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 linked in Stunts (in other words, the clutch is always engaged!), the parameter is purely cosmetic.

Useful note on all rpm parameters: As raising a byte on the gross adjustment 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 point 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 point 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 cosmetic - the torque curve will be cut off at the chose rpm, and thus the value should be adjusted 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). In fact, the exact relation which dictates how the gear ratios work is astonishingly simple: car speed (mph) = engine speed (rpm)/ gear ratio value. 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: 28h - fine tuning; 29h - gross adjustment (of little use).

This parameter has ben variously described over the years as "inverse power amplification" (Mark Nailwood) or "aerodynamic resistance" (Juha Liukkonen / Lukas Loehrer). A true aerodynamic coefficient effect, however, would affect car more strongly at high speeds. Raising this parameter causes a decrease in acceleration directly proportional to the increment, all gears being equally affected. 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. An important observation is that raising 29h will cause a huge increase in the car mass, enough to make adjustment of that byte (changing it from zero) quite useless.

Braking effectiveness

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

As the name says, those addresses tell how powerful 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.

Aerodynamic resistance

Address: 5Eh - fine tuning; 5Fh - gross adjustment (of little use).

This elusive parameter controls aerodynamic resistance encountered by the car when thundering down a straight. Aerodynamic drag increases quadratically with speed (that is, proportional to the square of) up to the point the engine can't produce enough torque to overcome it and the car reaches its top speed. Therefore, increasing aeroydnamic resistance will lower the car top speed in a flat straight line (that is, no jumps or Power Gear), as well as significantly reduce acceleration at high speeds. One point to note about the parameter is that the "gross adjustment" of address 5Fh, like Car mass' 29h, is extremely brutal, to the point of making it nearly useless to raise it from zero - varying 5Eh is more than enough for any usual tuning needs.

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

The internal coordinate system for Lancia gearbox (image upscaled 2:1)

In addition to physical data, car*.res parameters are responsible for controlling the displacement of mobile elements of the dashboard, that is, bitmaps from stdb*.pvs, speedometer and tachometer needles. Those parameters, alongside with a few related ones, are described below. Positions of moving dashboard elements (such as the shifting knob) are defined using a set of internal coordinates relative to some fixed position bitmap in stda*.pvs. According to those, the (0,0) point corresponds to the top left pixel of the reference bitmap; thus horizontal coordinates raises when moving rightwards and vertical coordinates raise when moving downwards. An illustration of this scheme is presented on the image beside for the 48x52 pixels bitmap of Lancia's gearbox - the essentials presented apply to other instruments as well. Some of the discussions on this subsection refer to the structure of bitmap resource files (stda* and stdb*). In case of doubts about such issues, check the Car files and Resource file format articles.

Shifting knob positions

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

These parameters control where the knob will appear at each gear. Bytes 46h, 4Ah, etc. set horizontal positions of each gear, and their counterparts 48h, 4Ch, etc. set vertical positions. The reference frame for knob internal coordinates is the gbox bitmap at the stda* file (as the example image illustrates). Additionally, byte 44h is the vertical coordinate that sets the height at which the gear knob switches from one column to another on the shift pattern; most likely it is to be set halfway between the upper and lower rows of gear positions. It is important to notice the distance between two gear positions and the number of direction changes while moving from one to another affects the time needed to engage the gear. Such variations can have noticeable effects on straight-line acceleration; therefore car tuners should be wary when modifying knob positions of an existing car so as to not alter the car performance and thus compromise pre-existing replays.

Car height

Address: F6h - fine tuning ; F7h - gross adjustment

This sets the apparent height from the ground on cockpit (F1) view; F6h performs rather small increments and F7h truly massive ones. The parameter has no effect on the 3D model, so if you fancy setting this to a ridiculously high value the car won't crash 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 amount 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 and odd bytes define vertical position. The reference frame for internal coordinates is stda* whl2 bitmap.

Speedometer needle movement

Address: 14Eh - 223h

Like the other meters, the movement is controlled by the position of individual points; each point being assigned a pair of bytes, the first byte setting horizontal position and the second setting vertical with reference to the coordinates of stda* ins2 bitmap. The pair 14Eh/150h defines the center point (horizontal and vertical, respectively). Byte 152h sets the number of needle positions to be displayed. The tip of the needle for each speed is controlled by consecutive pairs from 154h on, even bytes setting horizontal position and odd bytes vertical position. Each pair of bytes covers an interval of 2.5 mph, starting from zero. Finally, in case one needs to get rid of the needle altogether (like for IMSA dashboards), the easiest solution is to set 14Eh and 150h to FFh and 154h - 223h to zero - simply setting 152h to zero won't work as expected.

Digital speedometer

Address: 150h - 159h

This is a funny one. To have a digital speedometer first one needs to use the Corvette moving dashboard elements file (that is, a copy of STDBVETT.PVS) or a custom stdb* containing the dig0...dig9 bitmaps of the individual digits. 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 digits, whose coordinates are controlled in the usual fashion by the pairs 154h/155h, 156h/157h and 158h/159h (first, second and third digits from left to right respectively). As for the coordinates' reference frame, it is stda* ins2 bitmap, just as for the analog speedometer.

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, 228h sets the number of needle positions to be displayed and the pairs from 22Ah to 32Dh define the tip positions, totaling 130 positions available. Every pair of bytes covers 125rpm, and like for the speedometer there's an offset as well (second byte range is 250-375rpm, and so on). Else, the workings and details being the same as those discussed for the speedometer. Again, the reference frame is provided by stda* ins2 bitmap.

Text data

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

File header

Address: 00h - 25h

The initial bytes of CAR*.RES files consist of a file header, structured just like the ones found in uncompressed graphic files and elsewhere. Essentially, it stores file length, text IDs for different sections of the file and the associated byte offsets. Since that data is actually used by the engine to parse the car data, there is no reason to modify it unless one is hand-editing text data for the car and intends to modify string length - and even in that case, using Car Blaster and allowing it to perform any necessary adjustment is the recommended option.

"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!

See Also