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.
|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||Unknown Long 1|
|$1004||Unknown Long 2|
|$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
These are still not fully decomposed, but contain an identifier, a number of offsets, and varying amounts of data at these offsets. Most likely, the data represents points, lines, polygons, etc, to create a 3D object.
The 3D objects in GP2 are built up in a similar fashion, and comparing those values to the ones in F1GP, more info will be discovered.
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|
|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, then it represents the index of a track-side object|
|Unknown 2||short||Possibly related to drawing order|
|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 etc
Contains the default computer car setup, and other known and unknown data.
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|
|Brake Balance?||Possibly, based on GP2 info|
Remaining values currently unknown, but may contain Track Grip, Acceleration, Air Resistance, Race and Qualifying Aggression values.
Pit lane sections
Defined in exactly the same way as track sections.
Unknown structure 1
Variable length from 14 (Phoenix) to 60 (Spa-Francorchamps)
Terminated by 0xFF FF
Unknown structure 2
Always 28 bytes
|Unknown 1||byte||?||Known values: 00|
|Unknown 2||byte||?||Known values: 01|
|Unknown 3||byte||?||Known values: 02|
|Unknown 4||byte||?||Known values: 03|
|Unknown 5||byte||?||04 for slow tracks (US,MON,HUN,AUS), otherwise always 09|
|Unknown 6||byte||?||Known values: 05|
|Unknown 7||byte||?||Known values: 06|
|Unknown 8||byte||?||Known values: 07|
|Unknown 9||byte||?||Known values: 08|
|Unknown 10||byte||?||Known values: 09|
|Unknown 11||byte||?||Known values: 10|
|Unknown 12||byte||?||11 for slow tracks (US,MON,HUN,AUS), otherwise always 02|
|Unknown 13||byte||?||Known values: 12|
|Unknown 14||byte||?||Known values: 13|
|Unknown 15||byte||?||Known values: 14|
|Unknown 16||byte||?||Known values: 15|
|Unknown 17||byte||?||Known values: 20, 35, 50, 118, 200, 203|
|Unknown 18||byte||?||Known values: 00|
|Unknown 19||byte||?||Known values: 32, 56, 128, 240|
|Unknown 20||byte||?||Known values: 56, 68, 72, 79|
|Unknown 11||byte||?||Known values: 01|
|Unknown 22||byte||?||Known values: 00|
|Lap Count||byte||Lap count for 100% race|
|Unknown 23||byte||?||Known values: 00|
|Unknown 24||byte||Player strategy related, close to 33% or 50% race distance||Known values: 26, 27, 30, 37, 39, 43|
|Unknown 25||byte||?||Known values: 00|
|Unknown 26||byte||?||Known values: 00, 204|
|Unknown 27||byte||?||Known values: 00, 12, 16, 32, 64|
Note that bytes are specified here, but it's quite possible that the values represent short or other data types.
"Known values" are from tracks 01 (Phoenix) to 06 (Mexico City)
The final four (4) bytes of the track contain the checksum.