Trackdata

From Stunts Wiki
Revision as of 04:52, 23 February 2021 by Duplode (talk | contribs) (→‎Trackdata data structures)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Trackdata is a set of twenty three data structures which hold key information about the track in use and the lap being driven or replayed on it. Each of the individual data structures is referred to as trackdataXX, with XX being a two-digit number. The current systematisation of Trackdata is chiefly based on the results of the restunts project, though parts of it have been independently discovered and rediscovered over the years.

Finding Trackdata in memory

The most convenient targets to look for when using a debugger to locate Trackdata in memory are trackdata11 (highscore table), trackdata13 (replay file header) and trackdata14 (element map as in the track file). Keep in mind that different parts of Trackdata might be loaded or not depending on the current game phase (pre-lap, playing, replaying, or post-lap).

Trackdata data structures

Offsets and byte sizes assume the 1991 DOS versions of Stunts.

# Offset (hex) Size (hex) Size Layout Description Notes
01 0 70a 1802 901 words Track continuity: each value is the index of the next element in driving order. Alternative dual-way paths show up after the main one. The 901-value sizes of the driving-order structures is reflected by the "too many track pieces" validation error.
02 70a 70a 1802 901 words Split points: for dual-way splits, the value is the index of the first element of the alternative path, in driving order.
03 e14 70a 1802 901 words Opponent path: sequence of elements to be driven by the opponent. Starts from 0x0, the start/finish line. Occasionally changes upon restarting a race or reloading a replay.
04 151e 80 128 64 words Player aero table: aerodynamic resistance lookup table. Indexed by speed_mph >> 2.
05 159e 80 128 64 words Opponent aero table: aerodynamic resistance lookup table. Indexed by speed_mph >> 2.
06 161e 80 128
07 169e 80 128 64 words
08 171e 60 96 48 words?
09 18fe 180 384 64 3D word vectors F4 camera positions. Absolute coordinates, graphical units.
10 1a1e 120 288 48 3D word vectors Corner sign positions. Absolute coordinates, graphical units.
11 1b8a 16c 364 Highscore File Format Highscore table.
12 1c7a f0 240
13 1c9a 1a 26 Replay File Format Replay header.
14 2019 385 901 Track File Format Track file element map, plus the scenery byte Appears to control only the graphical rendering, and not the physical model.
15 239e 385 901 Track File Format Track file terrain map, plus the padding byte
16 527e 2ee0 12000 Replay File Format Replay input buffer. This is the safe memory area used by Bliss track metadata.
17 5603 385 901 901 bytes Track elements, in driving order
18 5988 385 901 901 bytes Likely related to element connectivity checks. The values appear to be structured as bit flags.
19 5d0d 385 901 Track file-like map Indices for trackdata10 (corner signs).
20 64b9 7ac 1964 The first 1802 bytes are a copy of the track file.
21 683e 385 901 901 bytes Grid column of track elements, in driving order
22 6bc3 385 901 901 bytes Grid row of track elements, in driving order
23 6bf3 30 48 48 bytes?