F1GP Track File Format
The game comes with the 16 tracks used in the 1991 F1 season, with tracks as varied as the tight streets of Monaco to the long, long straights of Hockenheim.
The track files are named “F1CTxx.DAT”, where “xx” is a number from “01” to “16”.
Because of the similarity between the F1GP and GP2 file formats, a lot of the information below has been deduced using Maxime Labelle’s “The Grand Prix 2 Track File Format (Beta 0.5)” and by playing around with Paul Hoad’s GP2 Track Editor. Another invaluable resource has been the Chequered Flag F1GP track editor by Barrie Millar, Klaus Six and René Smit. René Smit and Alejandro Caceres have also contributed a large amount of research and code.
|Size||Varying (original tracks between 13,368 to 20,497 bytes)|
The documentation below uses “$…” to describe a location in the file, and “0x..” to describe a hex value.
The first 4,096 bytes represent the horizon image, as a 512 x 8 bitmap. This means that the first 512 bytes represent the first horizontal line of the image, the next 512 bytes are the second line, etc.
Each byte indicates the color in the palette.
The Offset section begins at $1000.
|$1000||Base offset, always 0x1010 (4112)|
|$1004||Unknown short (or two unknown shorts?)|
|$1008||Checksum offset||Add 0x1010 (4112) to get location in file|
|$100A||Object list data offset||Add 0x1010 (4112) to get location in file|
|$100C||Track data offset||Add 0x1010 (4112) to get location in file|
This data contains the 3D representation of various track side objects such as buildings, billboards and grandstands.
|$100E||Number of object shapes|
|$1010||Offset of first internal object|
|+4*n||Offset of n'th internal object|
The shape data for each object starts at the offsets specified. For each item in the list of offsets, data goes from offset position to last byte before next offset.
For the last item, the shape data ends when we reach the $100A object list data offset.
Object Shape Details
Object shapes contain some ids and identifiers.
They also contain five different groups of data, which are indicated by a number of offset values at the beginning of the data.
The different groups are: graphic elements (polygons/bitmaps), scale values, points, vectors and graphic element lists.
This section will be expanded soon.
16 bytes repeated until we reach the $100C track data header.
The object settings represent instances of 3D objects, or other special objects, that are placed around the track.
For example, the same 3D object can be reused but with differing rotations, distance from track and colors.
|Id||byte||If 17 or greater, represents the Id of the 3D object defined at index (Id-17) in the Object Shape section.|
|Detail Level||byte||Flag determining which detail levels will show the object, and also affects drawing order|
|Unknown||short||Possibly color related for 3D objects (bit flags?)|
|Distance from Track||short||The distance between the object and the center of the track, negative values indicate left side, positive values indicate right side|
|Angle X||short||Angle X|
|Angle Y/Z||short||Angle Y/Z, except when Id=5 (or 1 or 13), then it represents the index of a track-side object|
|Unknown 2||short||Possibly related to drawing order (bit flags?)|
|Height||short||Height above ground|
The first 17 (or so) object settings for each track are very similar, and refer to such items as road signs, etc.
Track Data Header
The track data header starts at the short value at $100C + 0x1010, e.g. $384A for the Phoenix track. This is the starting position called $TDH in the table below.
The header is either 28 or 32 bytes long depending on whether the kerbs have two or three colors.
|$TDH||short||Starting angle of first track segment|
|+2||short||Starting height of first segment|
|+4||short||X-coordinate of track center||? in GP2|
|+6||short||Z-coordinate of track center|
|+8||short||Y-coordinate of track center|
|+10||short||Start width of 1st track segment|
|+12||short||Pole position side||768 = right, -768 = left|
|+14||short||Pit side||0 = right, ? = left|
|+15||byte||Surrounding area color||0 = green, 0xC0/192 = gray, 128=gray|
|+16||byte||Starting width of right verge|
|+17||byte||Starting width of left verge|
|+18||byte||Kerb type (two or three colors)||4 = three colors, otherwise 3|
|+22||byte||Kerb upper color||Index in special kerb palette|
|+24||byte||Kerb lower color||Index in special kerb palette|
|+28||byte||Kerb upper color 2 (if triple color)||Index in special kerb palette|
|+30||byte||Kerb lower color 2 (if triple color)||Index in special kerb palette|
After the track data header comes the different track section.
Each track section can have a number of related track commands defined. Commands are defined before the section that they belong to.
The track section attributes are 10 bytes long.
|Section Length||ushort||Length of section in units of 16 feet (approx 4.87m)|
|Arc||short||Angle value as a signed integer|
|Height||short||Height gradient along the section|
|Flags||short||Various flags, see below|
|Right verge width||byte||Width of right verge|
|Left verge width||byte||Width of left verge|
Track section definitions end with 0xFF FF.
Track Section Flags
|0||Pitlane entrance||Used on all pit lane sections that have garages?||0x1|
|1||Pitlane exit||Used on all pit lane sections that have garages?||0x2|
|2||Kerb height selector||Set for low kerbs, not set for high kerbs||0x4|
|3||Road signs (300/200/100)||0x8|
|4||Join the right-side fence from the starting point of the section with the starting point of the next non-bridged section.||0x10|
|5||Join the left-side fence from the starting point of the section with the starting point of the next non-bridged section.||0x20|
|6||Road sign (arrow)||0x40|
|7||Road signs (arrow/100)||0x80|
|8||Unknown 1||Never used in default tracks||0x100|
|9||Unknown 2||Never used in default tracks||0x200|
|10||Right Kerb||Section has kerb on the right side of the track||0x400|
|11||Left Kerb||Section has kerb on the left side of the track||0x800|
|12||Remove Right Wall||Hides the right wall, can still be hit||0x1000|
|13||Remove Left Wall||Hides the left wall, can still be hit||0x2000|
|15||Unknown 4||Never used in default tracks||0x8000|
Road sign flags can be combined in various ways, e.g. by setting both bit 3 and 6, the signs will appear on track as 300/Arrow/100.
Best Line Segments
This defines the line that computer cars drive around the track, and also applies steering help to the player’s car, especially keyboard users.
The first segment is always 8 bytes long, defined like this:
|Length||byte||Length of first segment|
|byte||Always 0x80 (128)|
After this, a number of segments appear. The segments are of two kinds, either “Normal” or a “Wide Radius” variant. The “Wide Radius” version is used for pieces of track that have a very long curvature, e.g. the back straight between turns 7 and 8 at Montreal which isn’t really a straight, but in fact a very long curve. Of the total number of best line segments, “Wide Radius” segments don’t appear very often. In fact, they only account for around 1% of all best line segments.
The type of segment is identified by the second byte in each segment.
Normal segments, 6 bytes long:
|Length||byte||Length of segment|
|Radius||short||Positive values for right-hand turns, negative values for left-hand turns. Smaller value for sharper turns.|
Wide radius segments, 8 bytes long:
|Length||byte||Length of segment|
The Best Line Segment part of the file is ended by two null values, i.e. 0x00 00.
Computer Car Setup and Behavior
Contains the default computer car setup, and various computer car behavior.
Always 38 bytes.
|$CCS||byte||Front wing||Subtract 151 to get actual value|
|+1||byte||Rear wing||Subtract 151 to get actual value|
|+2||byte||1st Gear Ratio||Subtract 151 to get actual value|
|+3||byte||2nd Gear Ratio||Subtract 151 to get actual value|
|+4||byte||3rd Gear Ratio||Subtract 151 to get actual value|
|+5||byte||4th Gear Ratio||Subtract 151 to get actual value|
|+6||byte||5th Gear Ratio||Subtract 151 to get actual value|
|+7||byte||6th Gear Ratio||Subtract 151 to get actual value|
|+8||byte||Tyre Compound||52=A, 55=D, actual compound used may vary|
|+10||short||Grip Factor||Multiplies driver corner speed factor|
|+12||short||CC non-race late braking factor|
|+14||short||CC race late braking factor|
|+16||short||Time factor non-race|
|+18||short||Acceleration||16384 everywhere except Mexico, where it's 13017|
|+20||short||Air Resistance||16384 everywhere except Mexico, where it's 13017|
|+22||short||Tyre wear qualifying|
|+24||short||Tyre wear non-qualifying|
|+26||short||Fuel load||100% race, measured in pounds (lbs). Fuel is consumed linearly with the distance covered. Shorter races decrease the fuel load.|
|+28||short||Time factor race|
|+30||short||CC power factor|
|+32||short||CC wet race late braking factor|
|+34||short||Unknown||Some track distance in feet|
|+36||short||Default pit lane view distance|
Pit lane sections
Defined in exactly the same way as track sections.
By default, the game places a camera at the left side of every 16 track length units. The command definitions here can then move them further back, swap them to the right side, or just remove them.
Variable length from 14 bytes (Phoenix) to 60 (Spa-Francorchamps)
Terminated by 0xFF FF
Computer Car Behavior, etc
Always 28 bytes
|Unknown 1||byte||?||Possibly not used. Known values: 00|
|Unknown 2||byte||?||Possibly not used. Known values: 01|
|Unknown 3||byte||?||Possibly not used. Known values: 02|
|Unknown 4||byte||?||Possibly not used. Known values: 03|
|Unknown 5||byte||?||Possibly not used. 04 for slow tracks (US,MON,HUN,AUS), otherwise always 09|
|Unknown 6||byte||?||Possibly not used. Known values: 05|
|Unknown 7||byte||?||Possibly not used. Known values: 06|
|Unknown 8||byte||?||Possibly not used. Known values: 07|
|Unknown 9||byte||?||Possibly not used. Known values: 08|
|Unknown 10||byte||?||Possibly not used. Known values: 09|
|Unknown 11||byte||?||Possibly not used. Known values: 10|
|Unknown 12||byte||?||Possibly not used. 11 for slow tracks (US,MON,HUN,AUS), otherwise always 02|
|Unknown 13||byte||?||Possibly not used. Known values: 12|
|Unknown 14||byte||?||Possibly not used. Known values: 13|
|Unknown 15||byte||?||Possibly not used. Known values: 14|
|Unknown 16||byte||?||Possibly not used. Known values: 15|
|Formation Length||short||Cars will not steer left/right until this segment index at the start of the race||Known values: 20, 35, 50, 118, 200, 203|
|Lap time indication (ms)||int||Used in calculation of maximum number of runners non-race and hotseat duration. Divided by (104 * session minutes) for max runners non-race||Known values: 86000, 80000, etc|
|Lap Count||short||Lap count for 100% race|
|Strategy (lap for first pit stop)||short||Close to 33% or 50% race distance||Known values: 26, 27, 30, 37, 39, 43|
“Known values” are from tracks 01 (Phoenix) to 06 (Mexico City)
The final four (4) bytes of the track contain the checksum.
If the checksum is incorrect, F1GP will not load the track file.