Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/GameVariables.h
338 views
1
#ifndef GAME_VARIABLES_H
2
#define GAME_VARIABLES_H
3
4
// =========================
5
// GAME ENUMS
6
// =========================
7
8
typedef enum {
9
#if !MANIA_USE_PLUS
10
MODE_NOSAVE,
11
#endif
12
MODE_MANIA, // officially called "MODE_SAVEGAME" in pre-plus, but it's easier to re-use names lol
13
#if MANIA_USE_PLUS
14
MODE_ENCORE,
15
#endif
16
MODE_TIMEATTACK,
17
MODE_COMPETITION,
18
} GameModes;
19
20
typedef enum {
21
ID_NONE = 0 << 0,
22
ID_SONIC = 1 << 0,
23
ID_TAILS = 1 << 1,
24
ID_KNUCKLES = 1 << 2,
25
#if MANIA_USE_PLUS
26
ID_MIGHTY = 1 << 3,
27
ID_RAY = 1 << 4,
28
#endif
29
ID_TAILS_ASSIST = ID_TAILS << 8,
30
ID_KNUCKLES_ASSIST = ID_KNUCKLES << 8, // custom-added, can be used to check if "& knux" is active
31
ID_DEFAULT_PLAYER = ID_SONIC | ID_TAILS_ASSIST,
32
} PlayerIDs;
33
34
#define GET_CHARACTER_ID(playerNum) (((globals->playerID >> (8 * ((playerNum)-1))) & 0xFF))
35
#define CHECK_CHARACTER_ID(characterID, playerNum) (((globals->playerID >> (8 * ((playerNum)-1))) & 0xFF) == (characterID))
36
37
#if MANIA_USE_PLUS
38
#define GET_STOCK_ID(stockNum) (((globals->stock >> (8 * ((stockNum)-1))) & 0xFF))
39
#define CHECK_STOCK_ID(characterID, stockNum) (((globals->stock >> (8 * ((stockNum)-1))) & 0xFF) == (characterID))
40
#endif
41
42
typedef enum { ITEMS_FIXED, ITEMS_RANDOM, ITEMS_TELEPORT } ItemModes;
43
44
typedef enum {
45
MEDAL_DEBUGMODE = 1 << 0,
46
MEDAL_ANDKNUCKLES = 1 << 1,
47
MEDAL_PEELOUT = 1 << 2,
48
MEDAL_INSTASHIELD = 1 << 3,
49
MEDAL_NODROPDASH = 1 << 4,
50
#if MANIA_USE_PLUS
51
MEDAL_NOTIMEOVER = 1 << 5,
52
#endif
53
} MedalMods;
54
55
typedef enum { MEDIA_DEMO } CategoryIDS;
56
57
typedef enum { FORCE_SPLIT } ScreenSplit;
58
59
typedef enum { NO_SAVE_SLOT = 255 } SaveSlots;
60
61
typedef enum { WIDE_SCR_XSIZE = 424, WIDE_SCR_XCENTER = 212 } ScreenSizes;
62
63
#if RETRO_REV02
64
typedef enum {
65
// General Filters
66
FILTER_NONE = 0 << 0,
67
FILTER_SLOT1 = 1 << 0,
68
FILTER_SLOT2 = 1 << 1,
69
FILTER_SLOT3 = 1 << 2,
70
FILTER_SLOT4 = 1 << 3,
71
FILTER_SLOT5 = 1 << 4,
72
FILTER_SLOT6 = 1 << 5,
73
FILTER_SLOT7 = 1 << 6,
74
FILTER_SLOT8 = 1 << 7,
75
FILTER_ANY = FILTER_SLOT1 | FILTER_SLOT2 | FILTER_SLOT3 | FILTER_SLOT4 | FILTER_SLOT5 | FILTER_SLOT6 | FILTER_SLOT7 | FILTER_SLOT8,
76
} SceneFilters;
77
#endif
78
79
#if MANIA_USE_PLUS
80
typedef enum {
81
// Mania-Specific filter uses
82
FILTER_BOTH = FILTER_SLOT1,
83
FILTER_MANIA = FILTER_SLOT2,
84
FILTER_ENCORE = FILTER_SLOT3,
85
} ManiaFilters;
86
87
typedef enum { DLC_PLUS } GameDLC;
88
#endif
89
90
typedef enum {
91
PLANEFILTER_NONE,
92
PLANEFILTER_AL, // - Plane A, Low Layer
93
PLANEFILTER_BL, // - Plane B, Low Layer
94
PLANEFILTER_AH, // - Plane A, High Layer
95
PLANEFILTER_BH, // - Plane B, High Layer
96
} PlaneFilterTypes;
97
98
typedef enum {
99
SLOT_PLAYER1 = 0,
100
SLOT_PLAYER2 = 1,
101
#if MANIA_USE_PLUS
102
SLOT_PLAYER3 = 2,
103
SLOT_PLAYER4 = 3,
104
SLOT_POWERUP1 = 4,
105
SLOT_PLAYER5 = 4, // Used in TMZ2Outro
106
SLOT_POWERUP2 = 5,
107
SLOT_PLAYER6 = 5, // Used in TMZ2Outro
108
SLOT_POWERUP3 = 6,
109
SLOT_POWERUP4 = 7,
110
SLOT_POWERUP1_2 = 8,
111
SLOT_POWERUP2_2 = 9,
112
SLOT_POWERUP3_2 = 10,
113
SLOT_POWERUP4_2 = 11,
114
#else
115
SLOT_POWERUP1 = 2,
116
SLOT_POWERUP2 = 3,
117
SLOT_POWERUP1_2 = 4,
118
SLOT_POWERUP2_2 = 5,
119
#endif
120
SLOT_BSS_SETUP = 8,
121
SLOT_PBL_SETUP = 8,
122
SLOT_UFO_SETUP = 8,
123
SLOT_MUSIC = 9,
124
SLOT_BSS_HUD = 10,
125
SLOT_UFO_CAMERA = 10,
126
SLOT_PBL_CAMERA = 10,
127
SLOT_BSS_MESSAGE = 11,
128
SLOT_UFO_HUD = 11,
129
SLOT_ZONE = MANIA_USE_PLUS ? 12 : 8,
130
// 13 = ???
131
// 14 = ???
132
SLOT_CUTSCENESEQ = 15,
133
SLOT_PAUSEMENU = 16,
134
SLOT_GAMEOVER = 16,
135
SLOT_ACTCLEAR = 16,
136
SLOT_PAUSEMENU_UICONTROL = 17,
137
SLOT_PAUSEMENU_BUTTON1 = 18,
138
SLOT_PAUSEMENU_BUTTON2 = 19,
139
SLOT_PAUSEMENU_BUTTON3 = 20,
140
SLOT_DIALOG = 21,
141
SLOT_DIALOG_UICONTROL = 22,
142
SLOT_DIALOG_BUTTONS = 23,
143
SLOT_DIALOG_BUTTON2 = 24,
144
SLOT_DIALOG_BUTTON3 = 25,
145
#if MANIA_USE_PLUS
146
SLOT_POPOVER = 26,
147
SLOT_POPOVER_UICONTROL = 27,
148
SLOT_POPOVER_BUTTONS = 28,
149
SLOT_POPOVER_BUTTON2 = 29,
150
SLOT_POPOVER_BUTTON3 = 30,
151
SLOT_POPOVER_BUTTON4 = 31,
152
#endif
153
SLOT_BIGBUBBLE_P1 = 32,
154
SLOT_BIGBUBBLE_P2 = 33,
155
#if MANIA_USE_PLUS
156
SLOT_BIGBUBBLE_P3 = 34,
157
SLOT_BIGBUBBLE_P4 = 36,
158
#endif
159
SLOT_BSS_HORIZON = 32,
160
SLOT_UFO_SPEEDLINES = 34,
161
SLOT_UFO_PLASMA = 36,
162
#if MANIA_USE_PLUS
163
SLOT_REPLAYRECORDER_PLAYBACK = 36,
164
SLOT_REPLAYRECORDER_RECORD = 37,
165
SLOT_MUSICSTACK_START = 40,
166
//[41-47] are part of the music stack
167
SLOT_MUSICSTACK_END = 48,
168
#endif
169
SLOT_CAMERA1 = 60,
170
SLOT_CAMERA2 = 61,
171
SLOT_CAMERA3 = 62,
172
SLOT_CAMERA4 = 63,
173
} ReservedEntities;
174
175
typedef enum {
176
PRESENCE_GENERIC,
177
PRESENCE_MENU,
178
PRESENCE_MANIA,
179
#if MANIA_USE_PLUS
180
PRESENCE_ENCORE,
181
#endif
182
PRESENCE_TA,
183
PRESENCE_COMP,
184
PRESENCE_TITLE,
185
} PresenceTypes;
186
187
#if MANIA_USE_PLUS
188
typedef enum {
189
SECRET_RICKYMODE = 1 << 0,
190
SECRET_SUPERDASH = 1 << 1,
191
} GameCheats;
192
#endif
193
194
// =========================
195
// GLOBAL VARIABLES
196
// =========================
197
198
typedef struct {
199
int32 gameMode;
200
int32 playerID; // active character IDs (usually leader & sidekick)
201
int32 specialCleared;
202
int32 specialRingID;
203
int32 blueSpheresID;
204
int32 blueSpheresInit;
205
int32 atlEnabled;
206
int32 atlEntityCount;
207
int32 atlEntitySlot[0x20];
208
int32 atlEntityData[0x4000];
209
int32 saveLoaded;
210
int32 saveRAM[0x4000];
211
int32 saveSlotID;
212
int32 noSaveSlot[0x400];
213
int32 menuParam[0x4000];
214
int32 itemMode;
215
int32 suppressTitlecard;
216
int32 suppressAutoMusic;
217
int32 competitionSession[0x4000];
218
int32 medalMods;
219
int32 parallaxOffset[0x100];
220
int32 enableIntro;
221
int32 optionsLoaded;
222
int32 optionsRAM[0x80];
223
int32 presenceID;
224
int32 medallionDebug;
225
int32 noSave;
226
int32 notifiedAutosave;
227
int32 recallEntities;
228
int32 restartRings;
229
int32 restart1UP;
230
int32 restartPowerups;
231
int32 restartPos[8];
232
int32 restartSlot[4];
233
int32 restartDir[4];
234
int32 restartMinutes;
235
int32 restartSeconds;
236
int32 restartMilliseconds;
237
int32 tempMinutes;
238
int32 tempSeconds;
239
int32 tempMilliseconds;
240
int32 restartScore;
241
int32 restartScore1UP;
242
int32 restartLives[4];
243
#if GAME_VERSION != VER_100
244
int32 restartMusicID;
245
#endif
246
int32 restartFlags;
247
int32 tempFlags;
248
int32 continues;
249
int32 initCoolBonus;
250
int32 coolBonus[4];
251
#if MANIA_USE_PLUS
252
int32 replayWriteBuffer[0x40000];
253
int32 replayReadBuffer[0x40000];
254
int32 replayTempWBuffer[0x40000];
255
int32 replayTempRBuffer[0x40000];
256
int32 replayTableID;
257
int32 replayTableLoaded;
258
int32 taTableID;
259
int32 taTableLoaded;
260
int32 stock; // order of buddies (not including the leader/sidekick)
261
int32 characterFlags; // characters in the "party"
262
int32 vapeMode;
263
int32 secrets;
264
int32 superSecret;
265
int32 superMusicEnabled;
266
int32 lastHasPlus;
267
int32 hasPlusInitial;
268
#endif
269
} GlobalVariables;
270
271
extern GlobalVariables *globals;
272
273
// =========================
274
// GAME HELPERS
275
// =========================
276
277
#if MANIA_USE_PLUS
278
#define isMainGameMode() (globals->gameMode == MODE_MANIA || globals->gameMode == MODE_ENCORE)
279
#else
280
#define isMainGameMode() (globals->gameMode == MODE_NOSAVE || globals->gameMode == MODE_MANIA)
281
#endif
282
283
// used mainly for cutscenes
284
#define MANIA_GET_PLAYER(p1, p2, cam) \
285
EntityPlayer *p1 = RSDK_GET_ENTITY(SLOT_PLAYER1, Player); \
286
EntityPlayer *p2 = RSDK_GET_ENTITY(SLOT_PLAYER2, Player); \
287
EntityCamera *cam = RSDK_GET_ENTITY(SLOT_CAMERA1, Camera);
288
289
// "Base" Classes
290
#define MANIA_PLATFORM_BASE \
291
RSDK_ENTITY \
292
StateMachine(state); \
293
StateMachine(stateCollide); \
294
int32 type; \
295
Vector2 amplitude; \
296
int32 speed; \
297
bool32 hasTension; \
298
int8 frameID; \
299
uint8 collision; \
300
Vector2 tileOrigin; \
301
Vector2 centerPos; \
302
Vector2 drawPos; \
303
Vector2 collisionOffset; \
304
int32 stood; \
305
int32 timer; \
306
int32 stoodAngle; \
307
uint8 stoodPlayers; \
308
uint8 pushPlayersL; \
309
uint8 pushPlayersR; \
310
Hitbox hitbox; \
311
Animator animator; \
312
int32 childCount;
313
314
#define MANIA_BUTTON_BASE \
315
RSDK_ENTITY \
316
int32 type; \
317
bool32 walkOnto; \
318
uint8 tag; \
319
bool32 down; \
320
bool32 toggled; \
321
bool32 currentlyActive; \
322
bool32 activated; \
323
bool32 wasActivated; \
324
int32 pressPos;
325
326
#define MANIA_UI_ITEM_BASE \
327
RSDK_ENTITY \
328
StateMachine(state); \
329
void (*processButtonCB)(void); \
330
bool32 (*touchCB)(void); \
331
void (*actionCB)(void); \
332
void (*selectedCB)(void); \
333
void (*failCB)(void); \
334
void (*buttonEnterCB)(void); \
335
void (*buttonLeaveCB)(void); \
336
bool32 (*checkButtonEnterCB)(void); \
337
bool32 (*checkSelectedCB)(void); \
338
int32 timer; \
339
Vector2 startPos; \
340
Entity *parent; \
341
Vector2 touchPosSizeS; \
342
Vector2 touchPosOffsetS; \
343
bool32 touchPressed; \
344
Vector2 touchPosSizeM[4]; /*size of the touchPos: in 16-bit shifted format*/ \
345
Vector2 touchPosOffsetM[4]; /*offset of the touchPos: 0,0 is entity pos, negative is left/up, positive is right/down*/ \
346
void (*touchPosCallbacks[4])(void); \
347
int32 touchPosCount; \
348
int32 touchPosID; \
349
bool32 isSelected; \
350
bool32 disabled;
351
352
#define MANIA_CUTSCENE_BASE \
353
RSDK_ENTITY \
354
Vector2 size; \
355
bool32 activated; \
356
Animator animator; /* unused, afaik */ \
357
Hitbox hitbox;
358
359
#endif //! GAME_VARIABLES_H
360
361