coastline 0.0.4
Loading...
Searching...
No Matches
track.h
Go to the documentation of this file.
1#ifndef COASTLINE_TRACK_H
2#define COASTLINE_TRACK_H
3
13
14#include <PR/gbi.h>
15#include <PR/ultratypes.h>
16
17#include "common/ptr32.h"
18#include "common/render.h"
19#include "common/vecmath.h"
20
21#if TGR_BOSS_RALLY
22#include "common/gbicommand.h"
23#endif
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
36
55
57#define TRACK_SECTION_ALTERNATE 0x0001
58
60#define TRACK_SECTION_VISITED 0x8000
61
63typedef struct {
64 union {
65 f32 matrix[4][4];
66 struct {
69 } rows[4];
70 };
72#if TGR_BOSS_RALLY
74#else
76#endif
84
86#define TRACK_INSTANCE_LIGHT_RAMP 0x0003
87
89#define TRACK_INSTANCE_TWO_SIDED 0x0004
90
92#define TRACK_INSTANCE_TRANSLUCENT 0x0008
93
95#define TRACK_INSTANCE_SHELTER 0x0010
96
101#define TRACK_INSTANCE_CLEAR_SKY 0x0020
102
104#define TRACK_INSTANCE_FLAT 0x0080
105
107#define TRACK_INSTANCE_NIGHT_LIT 0x0100
108
110#define TRACK_INSTANCE_NO_SHADOW 0x0200
111
113#define TRACK_INSTANCE_RAMPED 0x0400
114
116#define TRACK_INSTANCE_DARK_OR_WET 0x0800
117
119#define TRACK_INSTANCE_UNROTATED 0x2000
120
122#define TRACK_INSTANCE_ARCADE 0x4000
123
125#define TRACK_INSTANCE_MODE_FLAGS \
126 (TRACK_INSTANCE_TWO_SIDED | TRACK_INSTANCE_CLEAR_SKY | TRACK_INSTANCE_FLAT | \
127 TRACK_INSTANCE_RAMPED)
128
130#define TRACK_SURFACE_START 2
131
133#define TRACK_SURFACE_PAVED 3
134
136#define TRACK_SURFACE_SLOW 4
137
139typedef struct {
143
145typedef struct {
149
151#define TRACK_SPECIALS 16
152
154enum {
163};
164
166typedef struct {
167 union {
172 union {
175 } param;
178
180#define TRACK_GATES 10
181
183typedef struct {
186} TrackGate;
187
189typedef struct {
193#if TGR_PLATFORM == TGR_PLATFORM_N64
194 union {
197 };
198#else
199 TGR_PTR(TrackSurface) surfaces;
200#endif
202#if TGR_PLATFORM == TGR_PLATFORM_N64
203 union {
206 };
207#else
208 TGR_PTR(Vec3f) vertices;
209#endif
212 TGR_PTR(u16)
214 TGR_PTR(u16)
224#if TGR_BOSS_RALLY
226#else
228#endif
230 TGR_PTR(TGR_PTR(const char))
234 TGR_PTR(u16)
236 TGR_PTR(u16)
247 TGR_PTR(u16)
249 TGR_PTR(u16)
257 u8 unreconstructed228[0x230 - 0x228];
259
271
272#if TGR_PLATFORM == TGR_PLATFORM_N64
282#endif
283
284#if !TGR_BOSS_RALLY
294#else
296#define g_aTrackGates g_LoadedTrack.gates
297#endif
298
310
322
334
336#define RAY_INSTANCES 32
337
361 Vec3f *outNormal,
362 Vec3f *origin,
363 u16 *groundInstances,
364 s32 *groundInstanceCount,
365 u16 *nearbyInstances,
366 s32 *nearbyCount,
367 f32 *groundDistance,
368 s32 *groundSurface);
369
370#if TGR_BOSS_RALLY && defined(__cplusplus)
371extern "C" {
372#endif
373
389
403
419
433#if TGR_BOSS_RALLY && defined(__cplusplus)
434}
435#endif
436
449
451#define TRACK_HEADER_SIZE 0x230
452
453/* The limits of a track. */
454#if TGR_BOSS_RALLY
456#define TRACK_MAX_SIZE 4000000
457#else
458#define TRACK_MAX_SIZE 0x171400
459#endif
460#define TRACK_MAX_INSTANCES 0x800
461
463#define TRACK_SECTION_HEADER_SIZE 0x20
465#define TRACK_SECTION_DATA_SIZE 0x800
466
476
486
496
506
516
517#if !TGR_BOSS_RALLY
527#endif /* !TGR_BOSS_RALLY */
528
540
552
557extern u16 g_awTrackDebugWords[5];
558
571
584
596
608
609#ifdef __cplusplus
610}
611#endif
612
613#endif /* COASTLINE_TRACK_H */
The state the renderer shares between the parts of a frame.
The graphics binary interface types the gu routines fill in for the RSP microcode.
Pointers of 32 bits in the data the game reads from files and in its display lists.
#define TGR_PTR(T)
A pointer of 32 bits to T.
Definition ptr32.h:152
A command of a display list of the game.
Definition gbicommand.h:30
A texture of a model and its palette.
Definition render.h:63
A gate of a lap: a line across the route, seen from above.
Definition track.h:183
f32 seconds
Definition track.h:185
Vec2f ends[2]
Definition track.h:184
The triangles of a cell of the grid of the track: where they start in the list, and how many.
Definition track.h:145
u16 start
Definition track.h:146
u16 count
Definition track.h:147
The header of the loaded track.
Definition track.h:189
Vec3f * vertices
Definition track.h:204
Vec3f startPosition
Definition track.h:222
f32(* vertexRows)[3]
Definition track.h:205
s32 textureCount
Definition track.h:210
s32 instanceCount
Definition track.h:233
f32 minX
Definition track.h:216
f32 minZ
Definition track.h:220
f32 startHeading
Definition track.h:223
u16 * gridTriangles
Definition track.h:213
f32 maxZ
Definition track.h:221
u16 * gridCellStarts
Definition track.h:215
u8 fogColor[3]
Definition track.h:244
u16 * gridInstances
Definition track.h:235
s32 headerSize
Definition track.h:191
u8 unreconstructed228[0x230 - 0x228]
Definition track.h:257
TrackGate gates[TRACK_GATES]
Definition track.h:253
s32 surfaceCount
Definition track.h:192
TrackInstance * instances
Definition track.h:232
u8 * reservedSkyData[2]
Definition track.h:229
s32 sectionCount
Definition track.h:243
s32 vertexCount
Definition track.h:201
s32 gateCount
Definition track.h:254
u16 * triangleNearbyInstances
Definition track.h:250
f32 maxY
Definition track.h:219
f32 minY
Definition track.h:218
Vec3f * cameraPoints
Definition track.h:245
f32 maxX
Definition track.h:217
TrackSurface * surfaces
Definition track.h:195
u8 * surfaceBytes
Definition track.h:196
u8 * triangleFlags
Definition track.h:252
u16 * nearbyInstances
Definition track.h:248
u32 size
Definition track.h:190
TrackSection ** sections
Definition track.h:242
u16 * gridInstanceStarts
Definition track.h:237
TrackSection * rootSection
Definition track.h:239
u8 * reservedRouteData
Definition track.h:241
TrackSpecial specials[TRACK_SPECIALS]
Definition track.h:255
Gfx * skyDisplayList
Definition track.h:227
const char ** instanceNames
Definition track.h:231
s32 cameraPointCount
Definition track.h:246
ModelTexture * textures
Definition track.h:211
s32 specialCount
Definition track.h:256
A model placed on the track.
Definition track.h:63
Vec3f vector
Definition track.h:67
u16 polygonCount
Definition track.h:82
u16 groups
Definition track.h:77
u16 vertexCount
Definition track.h:80
f32 matrix[4][4]
Definition track.h:65
u16 flags
Definition track.h:79
f32 invScale
Definition track.h:71
Gfx * displayList
Definition track.h:75
u16 triangleCount
Definition track.h:81
u16 hidesGroups
Definition track.h:78
f32 w
Definition track.h:68
A point of the route, across the track.
Definition track.h:30
Vec3f position
Definition track.h:32
Vec3f right
Definition track.h:33
Vec3f left
Definition track.h:31
f32 distance
Definition track.h:34
A section of the route.
Definition track.h:38
u16 flags
Definition track.h:51
struct TrackSection * child
Definition track.h:39
struct TrackSection * parent
Definition track.h:42
u8 gridMaxX
Definition track.h:48
u8 gridMinY
Definition track.h:47
TrackPoint points[]
Definition track.h:53
struct TrackSection * reverseNext
Definition track.h:44
struct TrackSection * next
Definition track.h:41
u8 gridMaxY
Definition track.h:49
TrackPoint previousPoint
Definition track.h:52
u8 gridMinX
Definition track.h:46
u16 pointCount
Definition track.h:50
A special object of a track.
Definition track.h:166
f32 spinAngle
Definition track.h:173
s32 instance
Definition track.h:168
union TrackSpecial::@012065046060276125162265276330377072350010376373 target
u8 type
Definition track.h:176
Vec3f * path
Definition track.h:170
s32 pathLength
Definition track.h:174
A triangle of the track: its corners and what it belongs to.
Definition track.h:139
u16 vertices[3]
Definition track.h:140
u16 instance
Definition track.h:141
A point or direction in a plane.
Definition vecmath.h:24
A point or direction in space.
Definition vecmath.h:17
u16 NextGridCellInstance(TrackGridCursor *cursor)
Take the next placed model of a cell of the grid.
u16 GetInstanceGridCellCount(TrackGridCursor *cursor)
The placed models left in a cell.
s32 g_nOpaqueVisibleInstanceCount
The opaque models at the start of the list.
#define TRACK_SECTION_HEADER_SIZE
The bytes of the header of each of the two sections of the route of the loaded track.
Definition track.h:463
u16 NextGridCellTriangle(TrackGridCursor *cursor)
Take the next triangle of a cell of the grid.
TrackSection * g_pRootTrackSection
The starting route section, at its address within the loaded track.
u32 LookupTrackGridCell(f32 x, f32 y)
The triangles of the cell of the grid of the track under a point.
TrackHeader g_LoadedTrack
The loaded track.
u32 g_dwTrackTextureRomOffset
Where the textures of the loaded track are on the cartridge, after its compressed geometry.
#define TRACK_SPECIALS
The special objects a track header lists.
Definition track.h:151
s32 g_dwStreamDmaPrevSegment
The segment of textures last streamed, or -1.
u32 g_dwCurrentTrackRomOffset
Where the loaded track is on the cartridge.
#define TRACK_SECTION_DATA_SIZE
The bytes of the data of each of the two sections of the route of the loaded track.
Definition track.h:465
u16 g_awTrackDebugWords[5]
Two words of the loaded track, 0x3960 and 0x3968 bytes into it, that the loading prints.
u8 g_abTrackSection1Data[TRACK_SECTION_DATA_SIZE]
The data of the first route section of the loaded track.
TrackGate g_aTrackGates[TRACK_GATES]
The first gate of the loaded track, addressed separately by the original code.
u32 LookupInstanceCellAtPoint(f32 x, f32 y)
The placed models of the cell of the grid of the track under a point.
u32 LookupInstanceGridCell(s32 column, s32 row)
The placed models of a cell of the grid of the track.
u8 g_abTrackSection2Data[TRACK_SECTION_DATA_SIZE]
The data of the second route section of the loaded track.
s32 g_dwStreamedSnowMode
The snow mode the textures were last streamed for, or -1.
u16 g_awVisibleInstanceList[]
The placed models drawn this frame, by index.
u8 g_abTrackSection1Header[TRACK_SECTION_HEADER_SIZE]
The header of the first route section of the loaded track.
u32 FindTrackGridCellByIndex(s32 column, s32 row)
The triangles of a cell of the grid of the track by its column and row.
u8 g_abTrackSection2Header[TRACK_SECTION_HEADER_SIZE]
The header of the second route section of the loaded track.
u16 GetTrackGridCellCount(TrackGridCursor *cursor)
The triangles left in a cell.
s32 CastRayAgainstTrack(Vec3f *outPoint, Vec3f *outNormal, Vec3f *origin, u16 *groundInstances, s32 *groundInstanceCount, u16 *nearbyInstances, s32 *nearbyCount, f32 *groundDistance, s32 *groundSurface)
Drop a vertical line through a point onto the track.
@ TRACK_SPECIAL_SPIN_Z
Definition track.h:155
@ TRACK_SPECIAL_AIRPLANE_PATH_RIGHT
Definition track.h:160
@ TRACK_SPECIAL_SPIN_X
Definition track.h:156
@ TRACK_SPECIAL_AIRPLANE_TRIGGER
Definition track.h:161
@ TRACK_SPECIAL_AIRPLANE_PATH_LEFT
Definition track.h:159
@ TRACK_SPECIAL_SPIN_Y
Definition track.h:157
@ TRACK_SPECIAL_AIRPLANE
Definition track.h:158
@ TRACK_SPECIAL_WATERFALL
Definition track.h:162
s32 g_nDebugHiddenInstanceIndex
The placed model left undrawn while debugging.
#define TRACK_GATES
The gates a track can have.
Definition track.h:180
void LoadTrackGeometryFromRom(s32 track)
Decompress a track and its sections from the cartridge into g_LoadedTrack, and prepare it.
Integer and floating-point types of libultra.
unsigned int u32
Definition ultratypes.h:20
float f32
Definition ultratypes.h:38
unsigned short u16
Definition ultratypes.h:19
int s32
Definition ultratypes.h:25
unsigned char u8
Definition ultratypes.h:18
A display list command for the Fast3D microcode.
Definition gbi.h:132
The vector and matrix arithmetic of the game, its arctangent and power, the triangle and segment test...