coastline 0.0.4
Loading...
Searching...
No Matches
render.h
Go to the documentation of this file.
1#ifndef COASTLINE_RENDER_H
2#define COASTLINE_RENDER_H
3
8
9#include <PR/gbi.h>
10#include <PR/ultratypes.h>
11
13#include "common/ptr32.h"
14#include "common/screendraw.h"
15#include "common/vecmath.h"
16
17#if TGR_BOSS_RALLY
18#include "common/gbicommand.h"
19#endif
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
41
50
59
63typedef struct {
64#if TGR_BOSS_RALLY
65 union {
67 unsigned textureEntry;
68 };
69#else
71#endif
73 union {
76 } source;
83 u8 unreconstructed18[0x20 - 0x18];
84#if TGR_BOSS_RALLY
85 u32 textureFlags;
86#else
87 union {
88 struct {
89 unsigned mirrorS : 1;
90 unsigned mirrorT : 1;
91 unsigned clampS : 1;
92 unsigned clampT : 1;
93 unsigned format : 4;
94 unsigned : 3;
95 unsigned animated : 1;
96 unsigned : 2;
97 unsigned size : 18;
98 };
100 };
101#endif /* TGR_BOSS_RALLY */
103
104#if TGR_BOSS_RALLY
106#define MODEL_TEXTURE_ANIMATED(texture) (((texture)->textureFlags >> 20) & 1u)
108#define MODEL_TEXTURE_FORMAT(texture) (((texture)->textureFlags >> 24) & 0xfu)
110#define MODEL_TEXTURE_SIZE(texture) ((texture)->textureFlags & 0x3ffffu)
111#else
113#define MODEL_TEXTURE_ANIMATED(texture) ((texture)->animated)
115#define MODEL_TEXTURE_FORMAT(texture) ((texture)->format)
117#define MODEL_TEXTURE_SIZE(texture) ((texture)->size)
118#endif
119
120/* The formats of a texture of a model. */
121#define TEXTURE_FORMAT_CI4 1
122#define TEXTURE_FORMAT_I8 4
123
125#define TEXTURE_FORMAT_SNOW_STILL 0xB
126
128#define TEXTURE_CI4_PALETTE 15
129
131#define CLIP_RATIOS 6
132
134typedef struct {
140#if TGR_BOSS_RALLY
141 s32 dashboardTextureEntries[16];
142 s32 dashboardGearTextureEntry;
143#endif
145
156#if TGR_BOSS_RALLY
157extern f32 (*g_pProjectionMtx)[4];
158#else
159extern Mtx *g_pProjectionMtx;
160#endif
161
172extern f32 g_afMvpMatrix[4][4];
173
174#if TGR_BOSS_RALLY
181extern f32 g_afCameraRollMatrix[4][4];
182#endif
183
194extern f32 g_afPerspectiveMatrix[4][4];
195
206extern f32 g_afScratchMatrix[4][4];
207
219
231
243
255
267
278
289extern s32 g_dwNumViewports;
290
301#if TGR_BOSS_RALLY
303#else
305#endif
306
318
330
342
353extern f32 g_afViewProjMatrix[4][4];
354
365extern u16 g_wPerspNorm;
366
377extern f32 gFrustumFar;
378
390
401extern f32 g_ViewLookAtMtx[4][4];
402
413#if TGR_BOSS_RALLY
414extern f32 g_mtxIdentity[4][4];
415#else
416extern Mtx g_mtxIdentity;
417#endif
418
430
442
454
466
477extern s32 g_bSmoothShading;
478
490
502
514
525extern f32 g_afLightDirection[3];
526
537extern u32 g_adwLightRampColors[4];
538
549extern s32 g_adwVehicleVisible[];
550
561#if TGR_BOSS_RALLY
563#else
565#endif
566
577extern u8 g_bDirLightR;
578
589extern u8 g_bDirLightG;
590
601extern u8 g_bDirLightB;
602
613extern u8 g_bAmbientLightR;
614
625extern u8 g_bAmbientLightG;
626
637extern u8 g_bAmbientLightB;
638
639#if !TGR_BOSS_RALLY
649#endif /* !TGR_BOSS_RALLY */
650
662
674
686extern s32 g_dwStatUnused0;
687
696extern s32 g_dwStatUnused1;
697
706extern s32 g_dwStatUnused2;
707
716extern s32 g_dwStatUnused3;
718
728
738
750
762
775
787
798extern u8 g_abLightRampR[4];
799
810extern u8 g_abLightRampG[4];
811
822extern u8 g_abLightRampB[4];
823
825#define VIEWPORTS 32
826
836extern Vp g_aViewports[VIEWPORTS];
838
850
851#if !TGR_BOSS_RALLY
863#endif /* !TGR_BOSS_RALLY */
864
875extern s32 g_bGbiClipping;
876
888
900
914
927void DrawTexturedTile(s32 index, ModelTexture *textures);
928
942
956
968
980void SetupFog(void);
981
990void StubEmpty(void);
991
992#if TGR_REGION == TGR_REGION_JP || TGR_REGION == TGR_REGION_EU
1000
1008void BlankDisplay(void);
1009
1018#endif /* TGR_REGION == TGR_REGION_JP || TGR_REGION == TGR_REGION_EU */
1019
1020#if TGR_REGION == TGR_REGION_US || TGR_REGION == TGR_REGION_ASIA
1022#define BLANK_SCREEN() osViBlack(TRUE)
1023#else
1025#define BLANK_SCREEN() BlankDisplay()
1026#endif
1027
1039
1052
1053#ifdef __cplusplus
1054}
1055#endif
1056
1057#endif /* COASTLINE_RENDER_H */
s32 g_dwStatTrianglesDrawn
The triangles submitted during the current frame.
f32 g_fCameraFovRadians
The field of view of the cameras, in radians.
s32 g_dwViewportIndex
The viewport set last.
u32 g_dwTextureFilterMode
The texture filter of the other modes.
void StubEmpty(void)
Do nothing.
CameraFrame * g_pActiveCamera
The camera of the view being drawn.
f32 g_afMvpMatrix[4][4]
A matrix the renderer builds before converting it.
s32 g_dwVehicleCullingDisabled
Whether the car of the camera is drawn from its cockpit and mirror cameras too.
u32 g_dwAmbientLightColor
The packed colour of the ambient light.
void SetupFog(void)
Set the colour and the range of the fog for the weather and the track, and add them to the display li...
f32 g_afPerspectiveMatrix[4][4]
The perspective of the current view.
s32 g_dwViewportScaleZ
The depth scale of the viewport SetViewport() last set.
s32 g_adwVehicleVisible[]
Whether each vehicle is in the view being drawn.
s32 g_dwFogFactorOffset
The offset and the scale that turn the depth of a point into its fog, from 0 to 255,...
u8 g_bDirLightR
The colour of the light of the sun, in parts.
u32 g_dwDisplayBlanked
Whether BlankDisplay() blanked the screen and UnblankDisplay() has not yet shown it.
void DrawTexturedTile(s32 index, ModelTexture *textures)
Load a texture of a model into the texture memory and set up the tiles to draw it.
s32 g_dwNumViewports
The views on the screen, one for each player.
s32 g_dwCurrentSplitScreenIndex
The view being drawn.
void StreamAnimatedTrackTextures(void)
Select current animated track textures and their snow variants.
s32 g_dwClipRatioIndex
The display list of g_aClipRatioDisplayLists a frame starts with.
f32 ComputeFogFactorAtPoint(Vec3f *point)
How thick the fog is at a point of the world, in the view being drawn.
void ClearFramebuffersHighRes(void)
Black out the screen and clear both frame buffers in the high resolution.
f32 g_afViewProjMatrix[4][4]
The view and projection of the view being drawn.
s32 g_bTrackTextureLod
Whether the level of detail of the textures of the track is on.
f32 g_afLightDirection[3]
The direction of the light of the sun.
void UnblankDisplay(void)
Show the screen again.
s32 g_dwViewportMirrored
Whether the current view is mirrored.
void NormalizeLightMatrix(f32 m[4][4])
Scale a whole matrix down by the largest magnitude of its first three rows, plus 0....
u8 g_bAmbientLightG
The green channel of the ambient light.
u32 g_dwTextureRenderTile
The tile DrawTexturedTile() sets up to draw with.
f32 GetMaxAbsValue12(f32 m[4][4])
The largest absolute value of the first three rows of a matrix.
Mtx * g_pProjectionMtx
The projection of the current view.
s32 g_dwVehicleLodBias
The least detailed level the vehicles are drawn at, from 0.
s32 g_dwViewportTransZ
The depth offset of the viewport SetViewport() last set.
s32 g_dwFogMinDistance
The depths the fog starts and ends at, from 0 at the near plane to 1000 at the far.
f32 g_afScratchMatrix[4][4]
A matrix the renderer fills as an operand.
u32 g_dwTextureTmemAddress
The address in the texture memory DrawTexturedTile() loads to.
u8 g_bAmbientLightB
The blue channel of the ambient light.
u8 g_abLightRampB[4]
The blue channel of each placed-model light-ramp colour.
u16 g_wPerspNorm
The normalisation of the perspective of the projection.
void ClearRenderStats(void)
Clear the counts of the vertices, triangles, and polygons drawn in a frame.
s32 g_dwTrackMirrored
Whether the track is drawn mirrored.
Gfx g_aClipRatioDisplayLists[CLIP_RATIOS][5]
The display lists that set each clipping ratio, from 1.
s32 g_dwStatPolygonsDrawn
The polygons submitted during the current frame.
u8 g_bDirLightG
The green channel of the directional light.
void SetupWeatherLights(void)
Set the direction and the colours of the lights, and the light ramps, for the weather.
f32 gFrustumFar
The distance of the far plane of the cameras.
s32 g_dwStatVerticesDrawn
The vertices, triangles, and polygons drawn this frame.
u8 g_abLightRampG[4]
The green channel of each placed-model light-ramp colour.
Lights1 g_DefaultLights
The lights the vehicles and the track start from.
s32 g_dwStatVehicleTriangles
The triangles of the vehicles drawn this frame.
u32 g_adwLightRampColors[4]
The colours of the light of the placed models lit by their light ramp, by its index.
u8 g_bAmbientLightR
The colour of the ambient light, in parts.
void BlankDisplay(void)
Blank the screen.
s32 g_dwFogMaxDistance
The fog end depth, from 0 at the near plane to 1000 at the far plane.
s32 g_bSmoothShading
Whether the track is drawn with smooth shading.
f32 g_fFrustumFovAngle
The angle SetupFrustumCorners() was last given.
u8 g_bDirLightB
The blue channel of the directional light.
f32 g_fCameraProjectionScale
The distance the far planes of the cameras are taken from; the stages of the menus see a fifth of it.
ViewportRect g_aViewportRects[]
The rectangles of the views.
s32 g_dwFogFactorScale
The scale that maps depth to a fog value from 0 to 255.
void ClearFramebuffersLowRes(void)
Blank the screen and clear both frame buffers in the low resolution.
#define VIEWPORTS
The viewports.
Definition render.h:825
u8 g_abLightRampR[4]
The light ramps of the placed models, in parts, by the index of the ramp.
#define CLIP_RATIOS
The clipping ratios from 1 to 6, each a display list that sets it.
Definition render.h:131
f32 g_ViewLookAtMtx[4][4]
The view of the current view, before its perspective.
u32 g_dwDirLightColor
The colour of the light of the sun and of the ambient light.
s32 g_bGbiClipping
Whether the microcode clips the triangles.
Mtx g_mtxIdentity
The identity matrix used for display-list transforms.
The next command of the display list the game builds.
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 frame of reference: three axes and a position, the rows of a 4 by 4 matrix whose last column Finish...
Definition render.h:30
Vec3f forward
Definition render.h:31
Vec3f position
Definition render.h:37
f32 upW
Definition render.h:36
f32 fov
Definition render.h:39
f32 positionW
Definition render.h:38
f32 forwardW
Definition render.h:32
Vec3f up
Definition render.h:35
Vec3f side
Definition render.h:33
f32 sideW
Definition render.h:34
A command of a display list of the game.
Definition gbicommand.h:30
An ambient light and one directional light.
Definition gbi.h:445
A texture of a model and its palette.
Definition render.h:63
unsigned size
Definition render.h:97
u8 unreconstructed18[0x20 - 0x18]
Definition render.h:83
u16 height
Definition render.h:78
u8 * image
Definition render.h:70
s16 tileT1
Definition render.h:81
s16 tileT0
Definition render.h:79
s16 tileS1
Definition render.h:82
u32 paletteRomIndex
Definition render.h:74
unsigned format
Definition render.h:93
unsigned clampS
Definition render.h:91
u16 width
Definition render.h:77
unsigned clampT
Definition render.h:92
unsigned mirrorS
Definition render.h:89
s16 tileS0
Definition render.h:80
TextureAnimation * animation
Definition render.h:75
u8 formatByte
Definition render.h:99
unsigned animated
Definition render.h:95
u16 * palette
Definition render.h:72
unsigned mirrorT
Definition render.h:90
A frame of an animated texture, with its ROM offsets and the time the next frame starts.
Definition render.h:45
u32 paletteRom
Definition render.h:47
u32 time
Definition render.h:48
u32 imageRom
Definition render.h:46
The frames of an animated texture.
Definition render.h:52
TextureAnimationFrame frames[]
Definition render.h:57
u32 startTime
Definition render.h:56
u8 unreconstructed0[0x2 - 0x0]
Definition render.h:53
u16 frameCount
Definition render.h:54
u8 unreconstructed4[0x8 - 0x4]
Definition render.h:55
A point or direction in space.
Definition vecmath.h:17
The rectangle of the screen a view fills.
Definition render.h:134
s32 width
Definition render.h:137
s32 height
Definition render.h:138
s32 y
Definition render.h:136
s32 vehicleIndex
Definition render.h:139
s32 x
Definition render.h:135
Integer and floating-point types of libultra.
unsigned int u32
Definition ultratypes.h:20
short s16
Definition ultratypes.h:24
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
A 4 by 4 matrix in s15.16 fixed point, with the integer halves before the fractions.
Definition gbi.h:16
A viewport, aligned for the RSP.
Definition gbi.h:422
The vector and matrix arithmetic of the game, its arctangent and power, the triangle and segment test...