Mario Kart 64
Loading...
Searching...
No Matches
main.h File Reference

Go to the source code of this file.

Data Structures

struct  GfxPool
 
struct  CollisionGrid
 

Macros

#define MESG_SP_COMPLETE   100
 
#define MESG_DP_COMPLETE   101
 
#define MESG_VI_VBLANK   102
 
#define MESG_START_GFX_SPTASK   103
 
#define MESG_NMI_REQUEST   104
 
#define MTX_HUD_POOL_SIZE   800
 
#define MTX_HUD_POOL_SIZE_MAX   MTX_HUD_POOL_SIZE - 50
 
#define MTX_OBJECT_POOL_SIZE   128
 
#define MTX_SHADOW_POOL_SIZE   8 * 4
 
#define MTX_KART_POOL_SIZE   8 * 4
 
#define MTX_EFFECT_POOL_SIZE   660
 
#define MTX_EFFECT_POOL_SIZE_MAX   MTX_EFFECT_POOL_SIZE + 100
 
#define GFX_POOL_SIZE   7500
 

Functions

void create_thread (OSThread *, OSId, void(*entry)(void *), void *, void *, OSPri)
 
void main_func (void)
 
void thread1_idle (void *)
 
void setup_mesg_queues (void)
 
void start_sptask (s32)
 
void create_gfx_task_structure (void)
 
void init_controllers (void)
 
void update_controller (s32)
 
void read_controllers (void)
 
void func_80000BEC (void)
 
void dispatch_audio_sptask (struct SPTask *)
 
void exec_display_list (struct SPTask *)
 
void init_rcp (void)
 
void end_master_display_list (void)
 
void * clear_framebuffer (s32)
 
void rendering_init (void)
 
void config_gfx_pool (void)
 
void display_and_vsync (void)
 
void init_segment_ending_sequences (void)
 
void init_segment_racing (void)
 
void dma_copy (u8 *, u8 *, size_t)
 
void setup_game_memory (void)
 
void game_init_clear_framebuffer (void)
 
void race_logic_loop (void)
 
void game_state_handler (void)
 
void interrupt_gfx_sptask (void)
 
void receive_new_tasks (void)
 
void set_vblank_handler (s32, struct VblankHandler *, OSMesgQueue *, OSMesg *)
 
void start_gfx_sptask (void)
 
void handle_vblank (void)
 
void handle_dp_complete (void)
 
void handle_sp_complete (void)
 
void thread3_video (void *)
 
void func_800025D4 (void)
 
void func_80002600 (void)
 
void func_8000262C (void)
 
void func_80002658 (void)
 
void update_gamestate (void)
 
void thread5_game_loop (void *)
 
void thread4_audio (void *)
 

Variables

struct VblankHandlergVblankHandler1
 
struct VblankHandlergVblankHandler2
 
struct SPTaskgActiveSPTask
 
struct SPTasksCurrentAudioSPTask
 
struct SPTasksCurrentDisplaySPTask
 
struct SPTasksNextAudioSPTask
 
struct SPTasksNextDisplaySPTask
 
struct Controller gControllers []
 
struct ControllergControllerOne
 
struct ControllergControllerTwo
 
struct ControllergControllerThree
 
struct ControllergControllerFour
 
struct ControllergControllerFive
 
struct ControllergControllerSix
 
struct ControllergControllerSeven
 
struct ControllergControllerEight
 
Player gPlayers []
 
PlayergPlayerOne
 
PlayergPlayerTwo
 
PlayergPlayerThree
 
PlayergPlayerFour
 
PlayergPlayerFive
 
PlayergPlayerSix
 
PlayergPlayerSeven
 
PlayergPlayerEight
 
PlayergPlayerOneCopy
 
PlayergPlayerTwoCopy
 
struct GfxPool gGfxPools []
 
struct GfxPoolgGfxPool
 
struct VblankHandler gGameVblankHandler
 
struct VblankHandler sSoundVblankHandler
 
OSMesgQueue gDmaMesgQueue
 
OSMesgQueue gGameVblankQueue
 
OSMesgQueue gGfxVblankQueue
 
OSMesgQueue unused_gMsgQueue
 
OSMesgQueue gIntrMesgQueue
 
OSMesgQueue gSPTaskMesgQueue
 
OSMesgQueue sSoundMesgQueue
 
OSMesg sSoundMesgBuf [1]
 
OSMesg gDmaMesgBuf [1]
 
OSMesg gGameMesgBuf
 
OSMesg gGfxMesgBuf []
 
OSMesg gIntrMesgBuf [16]
 
OSMesg gSPTaskMesgBuf [16]
 
OSMesg gMainReceivedMesg
 
OSIoMesg gDmaIoMesg
 
OSMesgQueue gSIEventMesgQueue
 
OSMesg gSIEventMesgBuf [3]
 
OSContStatus gControllerStatuses []
 
OSContPad gControllerPads []
 
u8 gControllerBits
 
CollisionGrid gCollisionGrid []
 
u16 gNumActors
 
u16 gMatrixObjectCount
 
s32 gTickSpeed
 
f32 D_80150118
 
u16 wasSoftReset
 
u16 D_8015011E
 
s32 D_80150120
 
s32 gGotoMode
 
f32 gCameraZoom []
 
f32 gScreenAspect
 
f32 D_8015014C
 
f32 D_80150150
 
struct D_80150158 gD_80150158 []
 
uintptr_t gSegmentTable []
 
Gfx * gDisplayListHead
 
struct SPTaskgGfxSPTask
 
s32 D_801502A0
 
s32 D_801502A4
 
u16gPhysicalFramebuffers []
 
uintptr_t gPhysicalZBuffer
 
Mat4 D_801502C0
 
s32 padding []
 
u16 D_80152300 []
 
u16 D_80152308
 
OSThread gIdleThread
 
u8 gIdleThreadStack []
 
OSThread gVideoThread
 
u8 gVideoThreadStack []
 
OSThread gGameLoopThread
 
u8 gGameLoopThreadStack []
 
OSThread gAudioThread
 
u8 gAudioThreadStack []
 
u8 gGfxSPTaskYieldBuffer []
 
u32 gGfxSPTaskStack []
 
OSMesg gPIMesgBuf []
 
OSMesgQueue gPIMesgQueue
 
s32 gGamestate
 
s32 D_800DC510
 
u16 D_800DC514
 
u16 creditsRenderMode
 
u16 gDemoMode
 
u16 gEnableDebugMode
 
s32 gGamestateNext
 
s32 gActiveScreenMode
 
s32 gScreenModeSelection
 
s32 gPlayerCountSelection1
 
s32 gModeSelection
 
s32 D_800DC540
 
s32 D_800DC544
 
s32 gCCSelection
 
s32 gGlobalTimer
 
u16 sRenderedFramebuffer
 
u16 sRenderingFramebuffer
 
s32 D_800DC568
 
s32 D_800DC56C []
 
s16 sNumVBlanks
 
f32 gVBlankTimer
 
f32 gCourseTimer
 

Macro Definition Documentation

◆ GFX_POOL_SIZE

#define GFX_POOL_SIZE   7500

◆ MESG_DP_COMPLETE

#define MESG_DP_COMPLETE   101

◆ MESG_NMI_REQUEST

#define MESG_NMI_REQUEST   104

◆ MESG_SP_COMPLETE

#define MESG_SP_COMPLETE   100

◆ MESG_START_GFX_SPTASK

#define MESG_START_GFX_SPTASK   103

◆ MESG_VI_VBLANK

#define MESG_VI_VBLANK   102

◆ MTX_EFFECT_POOL_SIZE

#define MTX_EFFECT_POOL_SIZE   660

◆ MTX_EFFECT_POOL_SIZE_MAX

#define MTX_EFFECT_POOL_SIZE_MAX   MTX_EFFECT_POOL_SIZE + 100

◆ MTX_HUD_POOL_SIZE

#define MTX_HUD_POOL_SIZE   800

◆ MTX_HUD_POOL_SIZE_MAX

#define MTX_HUD_POOL_SIZE_MAX   MTX_HUD_POOL_SIZE - 50

◆ MTX_KART_POOL_SIZE

#define MTX_KART_POOL_SIZE   8 * 4
Todo
Verify with proper documentation

◆ MTX_OBJECT_POOL_SIZE

#define MTX_OBJECT_POOL_SIZE   128

◆ MTX_SHADOW_POOL_SIZE

#define MTX_SHADOW_POOL_SIZE   8 * 4
Todo
Verify with proper documentation

Function Documentation

◆ clear_framebuffer()

void * clear_framebuffer ( s32 color)
Todo
Why did void* work for matching
Here is the caller graph for this function:

◆ config_gfx_pool()

void config_gfx_pool ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_gfx_task_structure()

void create_gfx_task_structure ( void )

Initializes the Fast3D OSTask structure. Loads F3DEX or F3DLX based on the number of players

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_thread()

void create_thread ( OSThread * thread,
OSId id,
void(* entry )(void *),
void * arg,
void * sp,
OSPri pri )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dispatch_audio_sptask()

void dispatch_audio_sptask ( struct SPTask * spTask)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ display_and_vsync()

void display_and_vsync ( void )

Send current master display list for rendering. Tell the VI which colour framebuffer to display. Yields to the VI framerate twice, locking the game at 30 FPS. Selects the next framebuffer to be rendered and displayed.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dma_copy()

void dma_copy ( u8 * dest,
u8 * romAddr,
size_t size )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ end_master_display_list()

void end_master_display_list ( void )

End the master display list and initialize the graphics task structure for the next frame to be rendered.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exec_display_list()

void exec_display_list ( struct SPTask * spTask)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ func_80000BEC()

void func_80000BEC ( void )
Here is the caller graph for this function:

◆ func_800025D4()

void func_800025D4 ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ func_80002600()

void func_80002600 ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ func_8000262C()

void func_8000262C ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ func_80002658()

void func_80002658 ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ game_init_clear_framebuffer()

void game_init_clear_framebuffer ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ game_state_handler()

void game_state_handler ( void )

mk64's game loop depends on a series of states. It runs a wide branching series of code based on these states. State 1) Clear framebuffer State 2) Run menus State 3) Process race related logic State 4) Ending sequence State 5) Credits

Note that the state doesn't flip-flop at random but is permanent until the state changes (ie. Exit menus and start a race).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_dp_complete()

void handle_dp_complete ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_sp_complete()

void handle_sp_complete ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_vblank()

void handle_vblank ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_controllers()

void init_controllers ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_rcp()

void init_rcp ( void )

Set default RCP (Reality Co-Processor) settings.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_segment_ending_sequences()

void init_segment_ending_sequences ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_segment_racing()

void init_segment_racing ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ interrupt_gfx_sptask()

void interrupt_gfx_sptask ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main_func()

void main_func ( void )
Here is the call graph for this function:

◆ race_logic_loop()

void race_logic_loop ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_controllers()

void read_controllers ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ receive_new_tasks()

void receive_new_tasks ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rendering_init()

void rendering_init ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_vblank_handler()

void set_vblank_handler ( s32 index,
struct VblankHandler * handler,
OSMesgQueue * queue,
OSMesg * msg )
Here is the caller graph for this function:

◆ setup_game_memory()

void setup_game_memory ( void )

Setup main segments and framebuffers.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_mesg_queues()

void setup_mesg_queues ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_gfx_sptask()

void start_gfx_sptask ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_sptask()

void start_sptask ( s32 taskType)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ thread1_idle()

void thread1_idle ( void * arg)

Initialize hardware, start main thread, then idle.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ thread3_video()

void thread3_video ( void * )

◆ thread4_audio()

void thread4_audio ( void * )

◆ thread5_game_loop()

void thread5_game_loop ( void * )

◆ update_controller()

void update_controller ( s32 index)
Here is the caller graph for this function:

◆ update_gamestate()

void update_gamestate ( void )

Sets courseId to NULL if

Bug
Reloading this segment makes random_u16() deterministic for player spawn order. In laymens terms, random_u16() outputs the same value every time.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ creditsRenderMode

u16 creditsRenderMode
extern

◆ D_800DC510

s32 D_800DC510
extern

◆ D_800DC514

u16 D_800DC514
extern

◆ D_800DC540

s32 D_800DC540
extern

◆ D_800DC544

s32 D_800DC544
extern

◆ D_800DC568

s32 D_800DC568
extern

◆ D_800DC56C

s32 D_800DC56C[]
extern

◆ D_80150118

f32 D_80150118
extern

◆ D_8015011E

u16 D_8015011E
extern

◆ D_80150120

s32 D_80150120
extern

◆ D_8015014C

f32 D_8015014C
extern

◆ D_80150150

f32 D_80150150
extern

◆ D_801502A0

s32 D_801502A0
extern

◆ D_801502A4

s32 D_801502A4
extern

◆ D_801502C0

Mat4 D_801502C0
extern

◆ D_80152300

u16 D_80152300[]
extern

◆ D_80152308

u16 D_80152308
extern

◆ gActiveScreenMode

s32 gActiveScreenMode
extern

◆ gActiveSPTask

struct SPTask* gActiveSPTask
extern

◆ gAudioThread

OSThread gAudioThread
extern

◆ gAudioThreadStack

u8 gAudioThreadStack[]
extern

◆ gCameraZoom

f32 gCameraZoom[]
extern

◆ gCCSelection

s32 gCCSelection
extern

◆ gCollisionGrid

CollisionGrid gCollisionGrid[]
extern

◆ gControllerBits

u8 gControllerBits
extern

◆ gControllerEight

struct Controller* gControllerEight
extern

◆ gControllerFive

struct Controller* gControllerFive
extern

◆ gControllerFour

struct Controller* gControllerFour
extern

◆ gControllerOne

struct Controller* gControllerOne
extern

◆ gControllerPads

OSContPad gControllerPads[]
extern

◆ gControllers

struct Controller gControllers[]
extern

◆ gControllerSeven

struct Controller* gControllerSeven
extern

◆ gControllerSix

struct Controller* gControllerSix
extern

◆ gControllerStatuses

OSContStatus gControllerStatuses[]
extern

◆ gControllerThree

struct Controller* gControllerThree
extern

◆ gControllerTwo

struct Controller* gControllerTwo
extern

◆ gCourseTimer

f32 gCourseTimer
extern

◆ gD_80150158

struct D_80150158 gD_80150158[]
extern

◆ gDemoMode

u16 gDemoMode
extern

◆ gDisplayListHead

Gfx* gDisplayListHead
extern

◆ gDmaIoMesg

OSIoMesg gDmaIoMesg
extern

◆ gDmaMesgBuf

OSMesg gDmaMesgBuf[1]
extern

◆ gDmaMesgQueue

OSMesgQueue gDmaMesgQueue
extern

◆ gEnableDebugMode

u16 gEnableDebugMode
extern

◆ gGameLoopThread

OSThread gGameLoopThread
extern

◆ gGameLoopThreadStack

u8 gGameLoopThreadStack[]
extern

◆ gGameMesgBuf

OSMesg gGameMesgBuf

◆ gGamestate

s32 gGamestate
extern

◆ gGamestateNext

s32 gGamestateNext
extern

◆ gGameVblankHandler

struct VblankHandler gGameVblankHandler
extern

◆ gGameVblankQueue

OSMesgQueue gGameVblankQueue

◆ gGfxMesgBuf

OSMesg gGfxMesgBuf[]
extern

◆ gGfxPool

struct GfxPool* gGfxPool
extern

◆ gGfxPools

struct GfxPool gGfxPools[]
extern

◆ gGfxSPTask

struct SPTask* gGfxSPTask
extern

◆ gGfxSPTaskStack

u32 gGfxSPTaskStack[]
extern

◆ gGfxSPTaskYieldBuffer

u8 gGfxSPTaskYieldBuffer[]
extern

◆ gGfxVblankQueue

OSMesgQueue gGfxVblankQueue

◆ gGlobalTimer

s32 gGlobalTimer
extern

◆ gGotoMode

s32 gGotoMode
extern

◆ gIdleThread

OSThread gIdleThread
extern

◆ gIdleThreadStack

u8 gIdleThreadStack[]
extern

◆ gIntrMesgBuf

OSMesg gIntrMesgBuf[16]
extern

◆ gIntrMesgQueue

OSMesgQueue gIntrMesgQueue

◆ gMainReceivedMesg

OSMesg gMainReceivedMesg
extern

◆ gMatrixObjectCount

u16 gMatrixObjectCount
extern

◆ gModeSelection

s32 gModeSelection
extern

◆ gNumActors

u16 gNumActors
extern

◆ gPhysicalFramebuffers

u16* gPhysicalFramebuffers[]
extern

◆ gPhysicalZBuffer

uintptr_t gPhysicalZBuffer
extern

◆ gPIMesgBuf

OSMesg gPIMesgBuf[]
extern

◆ gPIMesgQueue

OSMesgQueue gPIMesgQueue
extern

◆ gPlayerCountSelection1

s32 gPlayerCountSelection1
extern

◆ gPlayerEight

Player* gPlayerEight
extern

◆ gPlayerFive

Player* gPlayerFive
extern

◆ gPlayerFour

Player* gPlayerFour
extern

◆ gPlayerOne

Player* gPlayerOne
extern

◆ gPlayerOneCopy

Player* gPlayerOneCopy
extern

◆ gPlayers

Player gPlayers[]
extern

◆ gPlayerSeven

Player* gPlayerSeven
extern

◆ gPlayerSix

Player* gPlayerSix
extern

◆ gPlayerThree

Player* gPlayerThree
extern

◆ gPlayerTwo

Player* gPlayerTwo
extern

◆ gPlayerTwoCopy

Player* gPlayerTwoCopy
extern

◆ gScreenAspect

f32 gScreenAspect
extern

◆ gScreenModeSelection

s32 gScreenModeSelection
extern

◆ gSegmentTable

uintptr_t gSegmentTable[]
extern

◆ gSIEventMesgBuf

OSMesg gSIEventMesgBuf[3]
extern

◆ gSIEventMesgQueue

OSMesgQueue gSIEventMesgQueue
extern

◆ gSPTaskMesgBuf

OSMesg gSPTaskMesgBuf[16]

◆ gSPTaskMesgQueue

OSMesgQueue gSPTaskMesgQueue

◆ gTickSpeed

s32 gTickSpeed
extern

◆ gVblankHandler1

struct VblankHandler* gVblankHandler1
extern

◆ gVblankHandler2

struct VblankHandler* gVblankHandler2
extern

◆ gVBlankTimer

f32 gVBlankTimer
extern

◆ gVideoThread

OSThread gVideoThread
extern

◆ gVideoThreadStack

u8 gVideoThreadStack[]
extern

◆ padding

s32 padding[]
extern

◆ sCurrentAudioSPTask

struct SPTask* sCurrentAudioSPTask
extern

◆ sCurrentDisplaySPTask

struct SPTask* sCurrentDisplaySPTask
extern

◆ sNextAudioSPTask

struct SPTask* sNextAudioSPTask
extern

◆ sNextDisplaySPTask

struct SPTask* sNextDisplaySPTask
extern

◆ sNumVBlanks

s16 sNumVBlanks
extern

◆ sRenderedFramebuffer

u16 sRenderedFramebuffer
extern

◆ sRenderingFramebuffer

u16 sRenderingFramebuffer
extern

◆ sSoundMesgBuf

OSMesg sSoundMesgBuf[1]
extern

◆ sSoundMesgQueue

OSMesgQueue sSoundMesgQueue
extern

◆ sSoundVblankHandler

struct VblankHandler sSoundVblankHandler
extern

◆ unused_gMsgQueue

OSMesgQueue unused_gMsgQueue

◆ wasSoftReset

u16 wasSoftReset
extern