Mario Kart 64
Loading...
Searching...
No Matches
main.h
Go to the documentation of this file.
1#ifndef MAIN_H
2#define MAIN_H
3
4// Message IDs
5#define MESG_SP_COMPLETE 100
6#define MESG_DP_COMPLETE 101
7#define MESG_VI_VBLANK 102
8#define MESG_START_GFX_SPTASK 103
9#define MESG_NMI_REQUEST 104
10
11#define MTX_HUD_POOL_SIZE 800
12
13#ifdef AVOID_UB
14#define MTX_HUD_POOL_SIZE_MAX MTX_HUD_POOL_SIZE
15#else
16#define MTX_HUD_POOL_SIZE_MAX MTX_HUD_POOL_SIZE - 50
17#endif
18
19#define MTX_OBJECT_POOL_SIZE 128
20
22// functions called by mtxShadow multiply by 8
23// 8 Kart AI Players * 4 real players in coop
24#define MTX_SHADOW_POOL_SIZE 8 * 4
25
27// functions called by mtxKart multiply by 8
28// 8 Kart AI Players * 4 real players in coop
29#define MTX_KART_POOL_SIZE 8 * 4
30
31#define MTX_EFFECT_POOL_SIZE 660
32
33// func_80095BD0 sets an OOB pool size max check (760)
34#ifdef AVOID_UB
35#define MTX_EFFECT_POOL_SIZE_MAX MTX_EFFECT_POOL_SIZE
36#else
37#define MTX_EFFECT_POOL_SIZE_MAX MTX_EFFECT_POOL_SIZE + 100
38#endif
39
40#define GFX_POOL_SIZE 7500
41
42struct GfxPool {
43 /* 0x00000 */ Mtx mtxScreen; // Matrix for skybox and startup logo
44 /* 0x00040 */ Mtx mtxPersp[4]; // Matrix for perspective screen modes
45 /* 0x00140 */ Mtx mtxOrtho; // Matrix for ortho hud screen modes
46 /* 0x00180 */ Mtx mtxUnk; // Matrix unused
47 /* 0x001C0 */ Mtx mtxLookAt[4]; // Matrix for lookat screen modes
48 /* 0x002C0 */ Mtx mtxHud[MTX_HUD_POOL_SIZE]; // Matrix hud elements and 2D related effects
49 /* 0x0CAC0 */ Mtx mtxObject[MTX_OBJECT_POOL_SIZE]; // Matrix course objects
50 /* 0x0EAC0 */ Mtx mtxShadow[MTX_SHADOW_POOL_SIZE]; // Matrix shadow characters
51 /* 0x0F2C0 */ Mtx mtxKart[MTX_KART_POOL_SIZE]; // Matrix kart characters
52 /* 0x0FAC0 */ Mtx mtxEffect[MTX_EFFECT_POOL_SIZE]; // Matrix misc effects
53 /* 0x19FC0 */ Mtx mtxArr[4]; // Matrix unused array
54 /* 0x1A0C0 */ Gfx gfxPool[GFX_POOL_SIZE];
55 /* 0x28B20 */ struct SPTask spTask;
56}; // size = 0x28B70
57
58typedef struct {
59 u16 triangle; // Index for gCollisionIndices which has indexes for gCollisionMesh
62
63void create_thread(OSThread*, OSId, void (*entry)(void*), void*, void*, OSPri);
64void main_func(void);
65void thread1_idle(void*);
66void setup_mesg_queues(void);
67void start_sptask(s32);
69void init_controllers(void);
71void read_controllers(void);
72void func_80000BEC(void);
73void dispatch_audio_sptask(struct SPTask*);
74void exec_display_list(struct SPTask*);
75void init_rcp(void);
78void rendering_init(void);
79void config_gfx_pool(void);
80void display_and_vsync(void);
82void init_segment_racing(void);
83void dma_copy(u8*, u8*, size_t);
84void setup_game_memory(void);
86void race_logic_loop(void);
87void game_state_handler(void);
88void interrupt_gfx_sptask(void);
89void receive_new_tasks(void);
90void set_vblank_handler(s32, struct VblankHandler*, OSMesgQueue*, OSMesg*);
91void start_gfx_sptask(void);
92void handle_vblank(void);
93void handle_dp_complete(void);
94void handle_sp_complete(void);
95void thread3_video(void*);
96void func_800025D4(void);
97void func_80002600(void);
98void func_8000262C(void);
99void func_80002658(void);
100void update_gamestate(void);
102void thread4_audio(void*);
103
104extern struct VblankHandler* gVblankHandler1;
105extern struct VblankHandler* gVblankHandler2;
106
107extern struct SPTask* gActiveSPTask;
108extern struct SPTask* sCurrentAudioSPTask;
109extern struct SPTask* sCurrentDisplaySPTask;
110extern struct SPTask* sNextAudioSPTask;
111extern struct SPTask* sNextDisplaySPTask;
112
113extern struct Controller gControllers[];
114extern struct Controller* gControllerOne;
115extern struct Controller* gControllerTwo;
116extern struct Controller* gControllerThree;
117extern struct Controller* gControllerFour;
118extern struct Controller* gControllerFive;
119extern struct Controller* gControllerSix;
120extern struct Controller* gControllerSeven;
121extern struct Controller* gControllerEight;
122
123extern Player gPlayers[];
124extern Player* gPlayerOne;
125extern Player* gPlayerTwo;
126extern Player* gPlayerThree;
127extern Player* gPlayerFour;
128extern Player* gPlayerFive;
129extern Player* gPlayerSix;
130extern Player* gPlayerSeven;
131extern Player* gPlayerEight;
132
133extern Player* gPlayerOneCopy;
134extern Player* gPlayerTwoCopy;
135
136extern struct GfxPool gGfxPools[];
137extern struct GfxPool* gGfxPool;
138
142extern OSMesgQueue sSoundMesgQueue;
143extern OSMesg sSoundMesgBuf[1];
144extern OSMesg gDmaMesgBuf[1], gGameMesgBuf;
145extern OSMesg gGfxMesgBuf[];
146extern OSMesg gIntrMesgBuf[16], gSPTaskMesgBuf[16];
147extern OSMesg gMainReceivedMesg;
148extern OSIoMesg gDmaIoMesg;
149extern OSMesgQueue gSIEventMesgQueue;
150extern OSMesg gSIEventMesgBuf[3];
151
152extern OSContStatus gControllerStatuses[];
153
154extern OSContPad gControllerPads[];
155extern u8 gControllerBits;
156
158extern u16 gNumActors;
160extern s32 gTickSpeed;
161extern f32 D_80150118;
162extern u16 wasSoftReset;
163extern u16 D_8015011E;
164
165extern s32 D_80150120;
166extern s32 gGotoMode;
167extern f32 gCameraZoom[];
168
169extern f32 gScreenAspect;
170extern f32 D_8015014C;
171extern f32 D_80150150;
172
173extern struct D_80150158 gD_80150158[];
174extern uintptr_t gSegmentTable[];
175extern Gfx* gDisplayListHead;
176extern struct SPTask* gGfxSPTask;
177extern s32 D_801502A0;
178extern s32 D_801502A4;
179extern u16* gPhysicalFramebuffers[];
180extern uintptr_t gPhysicalZBuffer;
181extern Mat4 D_801502C0;
182
183extern s32 padding[];
184
185extern u16 D_80152300[];
186extern u16 D_80152308;
187
188extern OSThread gIdleThread;
189extern u8 gIdleThreadStack[];
191extern u8 gVideoThreadStack[];
193extern u8 gGameLoopThreadStack[];
195extern u8 gAudioThreadStack[];
196
198extern u32 gGfxSPTaskStack[];
199extern OSMesg gPIMesgBuf[];
200extern OSMesgQueue gPIMesgQueue;
201void race_logic_loop(void);
202extern s32 gGamestate;
203#ifndef D_800DC510_AS_U16
204// Prevent overlapping writes in gcc
205// Whether D_800DC510 was intended to be a separate variable in main.c from the rest of the game is unknown
206#ifdef GCC
207extern u16 D_800DC510;
208#else
209extern s32 D_800DC510;
210#endif
211#endif
212
213extern u16 D_800DC514;
215extern u16 gDemoMode;
216extern u16 gEnableDebugMode;
217extern s32 gGamestateNext;
221
222extern s32 gModeSelection;
223extern s32 D_800DC540;
224extern s32 D_800DC544;
225extern s32 gCCSelection;
226extern s32 gGlobalTimer;
229extern s32 D_800DC568;
230extern s32 D_800DC56C[];
231extern s16 sNumVBlanks;
232extern f32 gVBlankTimer;
233extern f32 gCourseTimer;
234
235// end of definition of main.c variables
236
237#endif
f32 Mat4[4][4]
Definition common_structs.h:16
OSMesg gPIMesgBuf[]
Definition main.c:164
Player * gPlayerOne
Definition main.c:72
void init_segment_racing(void)
Definition main.c:491
OSMesgQueue gDmaMesgQueue
Definition main.c:93
void dispatch_audio_sptask(struct SPTask *)
Definition main.c:384
struct SPTask * sNextDisplaySPTask
Definition main.c:59
struct Controller * gControllerTwo
Definition main.c:63
void interrupt_gfx_sptask(void)
Definition main.c:914
Gfx * gDisplayListHead
Definition main.c:132
void func_80002600(void)
Definition main.c:1111
u8 gVideoThreadStack[]
Definition main.c:152
OSMesgQueue unused_gMsgQueue
Definition main.h:141
OSMesgQueue gGameVblankQueue
Definition main.h:141
s32 D_800DC544
Definition main.c:183
Player * gPlayerTwoCopy
Definition main.c:82
void thread4_audio(void *)
s32 D_80150120
Definition main.c:118
f32 D_80150150
Definition main.c:127
OSMesg gGfxMesgBuf[]
Definition main.c:97
void func_8000262C(void)
Definition main.c:1117
OSIoMesg gDmaIoMesg
Definition main.c:101
void receive_new_tasks(void)
Definition main.c:921
s32 padding[]
Definition main.c:143
f32 D_80150118
Definition main.c:113
void thread3_video(void *)
struct D_80150158 gD_80150158[]
Definition main.c:130
Player * gPlayerSix
Definition main.c:77
u16 wasSoftReset
Definition main.c:115
f32 gCourseTimer
Definition main.c:198
#define MTX_OBJECT_POOL_SIZE
Definition main.h:19
s16 sNumVBlanks
Definition main.c:195
OSMesg gIntrMesgBuf[16]
Definition main.c:99
void exec_display_list(struct SPTask *)
Definition main.c:389
u16 sRenderingFramebuffer
Definition main.c:191
void func_80002658(void)
Definition main.c:1123
#define MTX_EFFECT_POOL_SIZE
Definition main.h:31
#define MTX_KART_POOL_SIZE
Definition main.h:29
s32 D_800DC540
Definition main.c:182
struct SPTask * sNextAudioSPTask
Definition main.c:58
s32 gGlobalTimer
Definition main.c:185
OSMesgQueue gPIMesgQueue
Definition main.c:165
void handle_dp_complete(void)
Definition main.c:1007
s32 D_801502A0
Definition main.c:135
OSMesg gMainReceivedMesg
Definition main.c:100
void start_sptask(s32)
Definition main.c:257
struct Controller * gControllerThree
Definition main.c:64
void main_func(void)
Definition main.c:206
u8 gAudioThreadStack[]
Definition main.c:158
u16 * gPhysicalFramebuffers[]
Definition main.c:137
Mat4 D_801502C0
Definition main.c:141
void read_controllers(void)
Definition main.c:351
OSContStatus gControllerStatuses[]
Definition main.c:105
struct Controller * gControllerFour
Definition main.c:65
s32 D_800DC510
Definition main.c:169
f32 gScreenAspect
Definition main.c:125
u16 D_80152308
Definition main.c:146
s32 gGamestateNext
Definition main.c:174
OSMesg sSoundMesgBuf[1]
Definition main.c:95
u16 D_800DC514
Definition main.c:170
Player * gPlayerFour
Definition main.c:75
Player * gPlayerOneCopy
Definition main.c:81
void end_master_display_list(void)
Definition main.c:415
struct Controller gControllers[]
Definition main.c:61
struct VblankHandler sSoundVblankHandler
Definition main.c:92
void func_80000BEC(void)
Definition main.c:380
s32 gPlayerCountSelection1
Definition main.c:179
OSMesgQueue gSPTaskMesgQueue
Definition main.h:141
void handle_vblank(void)
Definition main.c:968
void game_init_clear_framebuffer(void)
Definition main.c:571
u8 gGfxSPTaskYieldBuffer[]
Definition main.c:162
void thread1_idle(void *)
Definition main.c:221
Player * gPlayerFive
Definition main.c:76
s32 gScreenModeSelection
Definition main.c:177
OSMesgQueue gGfxVblankQueue
Definition main.h:141
s32 gGotoMode
Definition main.c:119
u16 D_8015011E
Definition main.c:116
OSMesg gGameMesgBuf
Definition main.h:144
void func_800025D4(void)
Definition main.c:1105
void setup_game_memory(void)
Definition main.c:518
Player * gPlayerTwo
Definition main.c:73
uintptr_t gPhysicalZBuffer
Definition main.c:138
#define GFX_POOL_SIZE
Definition main.h:40
u16 gNumActors
Definition main.c:110
#define MTX_SHADOW_POOL_SIZE
Definition main.h:24
void * clear_framebuffer(s32)
Definition main.c:423
struct SPTask * gGfxSPTask
Definition main.c:134
Player gPlayers[]
Definition main.c:71
void config_gfx_pool(void)
Definition main.c:450
struct Controller * gControllerFive
Definition main.c:66
s32 gGamestate
Definition main.c:167
s32 D_801502A4
Definition main.c:136
struct Controller * gControllerSeven
Definition main.c:68
struct GfxPool * gGfxPool
Definition main.c:88
OSMesg gDmaMesgBuf[1]
Definition main.c:96
void init_segment_ending_sequences(void)
Definition main.c:483
OSThread gGameLoopThread
Definition main.c:155
u8 gIdleThreadStack[]
Definition main.c:150
void display_and_vsync(void)
Definition main.c:463
u16 gMatrixObjectCount
Definition main.c:111
s32 D_800DC568
Definition main.c:193
struct GfxPool gGfxPools[]
Definition main.c:87
void update_controller(s32)
Definition main.c:315
struct VblankHandler * gVblankHandler2
Definition main.c:53
OSMesgQueue sSoundMesgQueue
Definition main.c:94
Player * gPlayerSeven
Definition main.c:78
u8 gGameLoopThreadStack[]
Definition main.c:156
void rendering_init(void)
Definition main.c:437
OSThread gVideoThread
Definition main.c:151
struct SPTask * sCurrentAudioSPTask
Definition main.c:56
void create_gfx_task_structure(void)
Definition main.c:272
CollisionGrid gCollisionGrid[]
Definition main.c:109
s32 gTickSpeed
Definition main.c:112
OSMesgQueue gIntrMesgQueue
Definition main.h:141
void handle_sp_complete(void)
Definition main.c:1017
#define MTX_HUD_POOL_SIZE
Definition main.h:11
struct SPTask * sCurrentDisplaySPTask
Definition main.c:57
Player * gPlayerEight
Definition main.c:79
struct SPTask * gActiveSPTask
Definition main.c:55
OSContPad gControllerPads[]
Definition main.c:106
struct Controller * gControllerSix
Definition main.c:67
u16 D_80152300[]
Definition main.c:145
void update_gamestate(void)
Definition main.c:1134
s32 gCCSelection
Definition main.c:184
OSMesg gSIEventMesgBuf[3]
Definition main.c:103
u16 gDemoMode
Definition main.c:172
s32 D_800DC56C[]
Definition main.c:194
struct VblankHandler gGameVblankHandler
Definition main.c:91
u32 gGfxSPTaskStack[]
Definition main.c:163
void thread5_game_loop(void *)
u16 gEnableDebugMode
Definition main.c:173
void set_vblank_handler(s32, struct VblankHandler *, OSMesgQueue *, OSMesg *)
Definition main.c:947
s32 gActiveScreenMode
Definition main.c:176
void setup_mesg_queues(void)
Definition main.c:248
struct Controller * gControllerEight
Definition main.c:69
void game_state_handler(void)
Definition main.c:874
struct VblankHandler * gVblankHandler1
Definition main.c:52
u16 creditsRenderMode
Definition main.c:171
OSMesg gSPTaskMesgBuf[16]
Definition main.h:146
void init_controllers(void)
Definition main.c:304
Player * gPlayerThree
Definition main.c:74
OSMesgQueue gSIEventMesgQueue
Definition main.c:102
f32 gVBlankTimer
Definition main.c:197
OSThread gAudioThread
Definition main.c:157
void dma_copy(u8 *, u8 *, size_t)
Definition main.c:499
u16 sRenderedFramebuffer
Definition main.c:190
uintptr_t gSegmentTable[]
Definition main.c:131
struct Controller * gControllerOne
Definition main.c:62
void start_gfx_sptask(void)
Definition main.c:960
f32 gCameraZoom[]
Definition main.c:122
f32 D_8015014C
Definition main.c:126
OSThread gIdleThread
Definition main.c:149
void create_thread(OSThread *, OSId, void(*entry)(void *), void *, void *, OSPri)
Definition main.c:200
u8 gControllerBits
Definition main.c:107
s32 gModeSelection
Definition main.c:181
void init_rcp(void)
Definition main.c:404
void race_logic_loop(void)
Definition main.c:576
s32 OSId
Definition os_thread.h:22
s32 OSPri
Definition os_thread.h:21
Definition main.h:58
u16 triangle
Definition main.h:59
u16 numTriangles
Definition main.h:60
Definition common_structs.h:62
Definition common_structs.h:55
Definition main.h:42
Mtx mtxHud[MTX_HUD_POOL_SIZE]
Definition main.h:48
Mtx mtxLookAt[4]
Definition main.h:47
Mtx mtxKart[MTX_KART_POOL_SIZE]
Definition main.h:51
Mtx mtxObject[MTX_OBJECT_POOL_SIZE]
Definition main.h:49
Mtx mtxEffect[MTX_EFFECT_POOL_SIZE]
Definition main.h:52
Mtx mtxPersp[4]
Definition main.h:44
struct SPTask spTask
Definition main.h:55
Gfx gfxPool[GFX_POOL_SIZE]
Definition main.h:54
Mtx mtxOrtho
Definition main.h:45
Mtx mtxShadow[MTX_SHADOW_POOL_SIZE]
Definition main.h:50
Mtx mtxUnk
Definition main.h:46
Mtx mtxScreen
Definition main.h:43
Mtx mtxArr[4]
Definition main.h:53
Definition os_pi.h:53
Definition os_thread.h:50
Definition common_structs.h:249
Definition common_structs.h:43
Definition common_structs.h:50
signed int s32
Definition ultratypes.h:15
unsigned int u32
Definition ultratypes.h:16
signed short int s16
Definition ultratypes.h:13
float f32
Definition ultratypes.h:34
unsigned short int u16
Definition ultratypes.h:14
unsigned char u8
Definition ultratypes.h:12