Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/src/game/game_init.h
7858 views
1
#ifndef GAME_INIT_H
2
#define GAME_INIT_H
3
4
#include <PR/ultratypes.h>
5
#include <PR/gbi.h>
6
#include <PR/os_cont.h>
7
#include <PR/os_message.h>
8
9
#include "types.h"
10
#include "memory.h"
11
12
#ifdef USE_SYSTEM_MALLOC
13
#define GFX_POOL_SIZE 1
14
#else
15
// Size of how large the master display list (gDisplayListHead) can be
16
#ifdef TARGET_N64
17
#define GFX_POOL_SIZE 6400
18
#else
19
#define GFX_POOL_SIZE 64000
20
#endif
21
#endif
22
23
struct GfxPool {
24
Gfx buffer[GFX_POOL_SIZE];
25
struct SPTask spTask;
26
};
27
28
struct DemoInput
29
{
30
u8 timer; // time until next input. if this value is 0, it means the demo is over
31
s8 rawStickX;
32
s8 rawStickY;
33
u8 buttonMask;
34
};
35
36
extern s8 get_mirror();
37
extern s16 get_palette();
38
39
extern struct Controller gControllers[3];
40
extern OSContStatus gControllerStatuses[4];
41
extern OSContPad gControllerPads[4];
42
extern OSMesgQueue gGameVblankQueue;
43
extern OSMesgQueue gGfxVblankQueue;
44
extern OSMesg gGameMesgBuf[1];
45
extern OSMesg gGfxMesgBuf[1];
46
extern struct VblankHandler gGameVblankHandler;
47
extern uintptr_t gPhysicalFrameBuffers[3];
48
extern uintptr_t gPhysicalZBuffer;
49
extern void *gMarioAnimsMemAlloc;
50
extern void *gDemoInputsMemAlloc;
51
extern struct SPTask *gGfxSPTask;
52
#ifdef USE_SYSTEM_MALLOC
53
extern struct AllocOnlyPool *gGfxAllocOnlyPool;
54
extern Gfx *gDisplayListHeadInChunk;
55
extern Gfx *gDisplayListEndInChunk;
56
#else
57
extern Gfx *gDisplayListHead;
58
extern u8 *gGfxPoolEnd;
59
#endif
60
extern struct GfxPool *gGfxPool;
61
extern u8 gControllerBits;
62
extern s8 gEepromProbe;
63
64
extern void (*gGoddardVblankCallback)(void);
65
extern struct Controller *gPlayer1Controller;
66
extern struct Controller *gPlayer2Controller;
67
extern struct Controller *gPlayer3Controller;
68
extern struct DemoInput *gCurrDemoInput;
69
extern u16 gDemoInputListID;
70
extern struct DemoInput gRecordedDemoInput;
71
72
// this area is the demo input + the header. when the demo is loaded in, there is a header the size
73
// of a single word next to the input list. this word is the current ID count.
74
extern struct DmaHandlerList gMarioAnimsBuf;
75
extern struct DmaHandlerList gDemoInputsBuf;
76
77
extern u8 gMarioAnims[];
78
extern u8 gDemoInputs[];
79
80
extern s8 gCanMirror;
81
extern s8 gReimportTextures;
82
extern s8 gBooDialogueWasSaid;
83
84
extern u16 sRenderingFrameBuffer;
85
extern u32 gGlobalTimer;
86
87
void setup_game_memory(void);
88
void thread5_game_loop(UNUSED void *arg);
89
void clear_frame_buffer(s32 color);
90
void clear_viewport(Vp *viewport, s32 color);
91
void make_viewport_clip_rect(Vp *viewport);
92
void init_rcp(void);
93
void end_master_display_list(void);
94
void render_init(void);
95
void select_gfx_pool(void);
96
void display_and_vsync(void);
97
98
#ifdef USE_SYSTEM_MALLOC
99
Gfx **alloc_next_dl(void);
100
#define gDisplayListHead (*(gDisplayListEndInChunk - gDisplayListHeadInChunk >= 2 ? &gDisplayListHeadInChunk : alloc_next_dl()))
101
#endif
102
103
#endif // GAME_INIT_H
104
105