Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/src/game/area.h
7858 views
1
#ifndef AREA_H
2
#define AREA_H
3
4
#include <PR/ultratypes.h>
5
6
#include "types.h"
7
#include "camera.h"
8
#include "engine/graph_node.h"
9
10
struct WarpNode
11
{
12
/*00*/ u8 id;
13
/*01*/ u8 destLevel;
14
/*02*/ u8 destArea;
15
/*03*/ u8 destNode;
16
};
17
18
struct ObjectWarpNode
19
{
20
/*0x00*/ struct WarpNode node;
21
/*0x04*/ struct Object *object;
22
/*0x08*/ struct ObjectWarpNode *next;
23
};
24
25
// From Surface 0x1B to 0x1E
26
#define INSTANT_WARP_INDEX_START 0x00 // Equal and greater than Surface 0x1B
27
#define INSTANT_WARP_INDEX_STOP 0x04 // Less than Surface 0x1F
28
29
struct InstantWarp
30
{
31
/*0x00*/ u8 id; // 0 = 0x1B / 1 = 0x1C / 2 = 0x1D / 3 = 0x1E
32
/*0x01*/ u8 area;
33
/*0x02*/ Vec3s displacement;
34
};
35
36
struct SpawnInfo
37
{
38
/*0x00*/ Vec3s startPos;
39
/*0x06*/ Vec3s startAngle;
40
/*0x0C*/ s8 areaIndex;
41
/*0x0D*/ s8 activeAreaIndex;
42
/*0x10*/ u32 behaviorArg;
43
/*0x14*/ void *behaviorScript;
44
/*0x18*/ struct GraphNode *unk18;
45
/*0x1C*/ struct SpawnInfo *next;
46
};
47
48
struct UnusedArea28
49
{
50
/*0x00*/ s16 unk00;
51
/*0x02*/ s16 unk02;
52
/*0x04*/ s16 unk04;
53
/*0x06*/ s16 unk06;
54
/*0x08*/ s16 unk08;
55
};
56
57
struct Whirlpool
58
{
59
/*0x00*/ Vec3s pos;
60
/*0x03*/ s16 strength;
61
};
62
63
struct Area
64
{
65
/*0x00*/ s8 index;
66
/*0x01*/ s8 flags; // Only has 1 flag: 0x01 = Is this the active area?
67
/*0x02*/ u16 terrainType; // default terrain of the level (set from level script cmd 0x31)
68
/*0x04*/ struct GraphNodeRoot *unk04; // geometry layout data
69
/*0x08*/ s16 *terrainData; // collision data (set from level script cmd 0x2E)
70
/*0x0C*/ s8 *surfaceRooms; // (set from level script cmd 0x2F)
71
/*0x10*/ s16 *macroObjects; // Macro Objects Ptr (set from level script cmd 0x39)
72
/*0x14*/ struct ObjectWarpNode *warpNodes;
73
/*0x18*/ struct WarpNode *paintingWarpNodes;
74
/*0x1C*/ struct InstantWarp *instantWarps;
75
/*0x20*/ struct SpawnInfo *objectSpawnInfos;
76
/*0x24*/ struct Camera *camera;
77
/*0x28*/ struct UnusedArea28 *unused28; // Filled by level script 0x3A, but is unused.
78
/*0x2C*/ struct Whirlpool *whirlpools[2];
79
/*0x34*/ u8 dialog[2]; // Level start dialog number (set by level script cmd 0x30)
80
/*0x36*/ u16 musicParam;
81
/*0x38*/ u16 musicParam2;
82
};
83
84
// All the transition data to be used in screen_transition.c
85
struct WarpTransitionData
86
{
87
/*0x00*/ u8 red;
88
/*0x01*/ u8 green;
89
/*0x02*/ u8 blue;
90
91
/*0x04*/ s16 startTexRadius;
92
/*0x06*/ s16 endTexRadius;
93
/*0x08*/ s16 startTexX;
94
/*0x0A*/ s16 startTexY;
95
/*0x0C*/ s16 endTexX;
96
/*0x0E*/ s16 endTexY;
97
98
/*0x10*/ s16 texTimer; // always 0, does seems to affect transition when disabled
99
};
100
101
#define WARP_TRANSITION_FADE_FROM_COLOR 0x00
102
#define WARP_TRANSITION_FADE_INTO_COLOR 0x01
103
#define WARP_TRANSITION_FADE_FROM_STAR 0x08
104
#define WARP_TRANSITION_FADE_INTO_STAR 0x09
105
#define WARP_TRANSITION_FADE_FROM_CIRCLE 0x0A
106
#define WARP_TRANSITION_FADE_INTO_CIRCLE 0x0B
107
#define WARP_TRANSITION_FADE_FROM_MARIO 0x10
108
#define WARP_TRANSITION_FADE_INTO_MARIO 0x11
109
#define WARP_TRANSITION_FADE_FROM_BOWSER 0x12
110
#define WARP_TRANSITION_FADE_INTO_BOWSER 0x13
111
112
struct WarpTransition
113
{
114
/*0x00*/ u8 isActive; // Is the transition active. (either TRUE or FALSE)
115
/*0x01*/ u8 type; // Determines the type of transition to use (circle, star, etc.)
116
/*0x02*/ u8 time; // Amount of time to complete the transition (in frames)
117
/*0x03*/ u8 pauseRendering; // Should the game stop rendering. (either TRUE or FALSE)
118
/*0x04*/ struct WarpTransitionData data;
119
};
120
121
enum MenuOption {
122
MENU_OPT_NONE,
123
MENU_OPT_1,
124
MENU_OPT_2,
125
MENU_OPT_3,
126
MENU_OPT_4,
127
MENU_OPT_DEFAULT = MENU_OPT_1,
128
129
// Course Pause Menu
130
MENU_OPT_CONTINUE = MENU_OPT_1,
131
MENU_OPT_EXIT_COURSE = MENU_OPT_2,
132
MENU_OPT_CAMERA_ANGLE_R = MENU_OPT_3,
133
MENU_OPT_QUIT = MENU_OPT_4,
134
135
// Save Menu
136
MENU_OPT_SAVE_AND_CONTINUE = MENU_OPT_1,
137
MENU_OPT_SAVE_AND_QUIT = MENU_OPT_2,
138
MENU_OPT_CONTINUE_DONT_SAVE = MENU_OPT_3
139
};
140
141
extern struct GraphNode **gLoadedGraphNodes;
142
extern struct SpawnInfo gPlayerSpawnInfos[];
143
extern struct GraphNode *D_8033A160[];
144
extern struct Area gAreaData[];
145
extern struct WarpTransition gWarpTransition;
146
extern s16 gCurrCourseNum;
147
extern s16 gCurrActNum;
148
extern s16 gCurrAreaIndex;
149
extern s16 gSavedCourseNum;
150
extern s16 gMenuOptSelectIndex;
151
extern s16 gSaveOptSelectIndex;
152
153
extern struct SpawnInfo *gMarioSpawnInfo;
154
155
extern struct Area *gAreas;
156
extern struct Area *gCurrentArea;
157
158
extern s16 gCurrSaveFileNum;
159
extern s16 gCurrLevelNum;
160
161
162
void override_viewport_and_clip(Vp *a, Vp *b, u8 c, u8 d, u8 e);
163
void print_intro_text(s8 in_game);
164
u32 get_mario_spawn_type(struct Object *o);
165
struct ObjectWarpNode *area_get_warp_node(u8 id);
166
void clear_areas(void);
167
void clear_area_graph_nodes(void);
168
void load_area(s32 index);
169
void unload_area(void);
170
void load_mario_area(void);
171
void unload_mario_area(void);
172
void change_area(s32 index);
173
void area_update_objects(void);
174
void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue);
175
void play_transition_after_delay(s16 transType, s16 time, u8 red, u8 green, u8 blue, s16 delay);
176
void render_game(void);
177
178
#endif // AREA_H
179