Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/MMZ/MMZSetup.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: MMZSetup Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectMMZSetup *MMZSetup;
11
12
void MMZSetup_Update(void) {}
13
14
void MMZSetup_LateUpdate(void) {}
15
16
void MMZSetup_StaticUpdate(void)
17
{
18
if (MMZSetup->paletteTimer == 4) {
19
RSDK.RotatePalette(0, 140, 142, true);
20
MMZSetup->paletteTimer = 0;
21
}
22
else {
23
MMZSetup->paletteTimer++;
24
}
25
26
if (Zone->actID == 1) {
27
if (!MMZSetup->panelAniTimer) {
28
if (++MMZSetup->panelAniFrame > 11)
29
MMZSetup->panelAniFrame = 0;
30
31
RSDK.DrawAniTiles(MMZSetup->aniTiles, 282, 0, 16 * MMZSetup->panelAniFrame, 16, 16);
32
}
33
34
if (++MMZSetup->panelAniTimer == (MMZSetup->panelAniDuration >> 1)) {
35
MMZSetup->panelAniTimer = 0;
36
37
if (--MMZSetup->panelAniDuration < 4)
38
MMZSetup->panelAniDuration = 4;
39
}
40
}
41
42
if (--MMZSetup->pistonAniDuration < 1) {
43
MMZSetup->pistonAniFrame += 32;
44
MMZSetup->pistonAniFrame %= 384;
45
46
MMZSetup->pistonAniDuration = MMZSetup->pistonAniDurationTable[MMZSetup->pistonAniFrame >> 5];
47
RSDK.DrawAniTiles(MMZSetup->aniTiles, 336, 96 + ((MMZSetup->pistonAniFrame >> 4) & 0xFFF0), MMZSetup->pistonAniFrame & 0xFF, 16, 32);
48
}
49
50
if (++MMZSetup->lightsAniDuration == 2) {
51
MMZSetup->lightsAniDuration = 0;
52
53
MMZSetup->spinLightsAniFrame += 16;
54
MMZSetup->spinLightsAniFrame %= 384;
55
RSDK.DrawAniTiles(MMZSetup->aniTiles, 338, 16 + ((MMZSetup->spinLightsAniFrame >> 4) & 0xFFF0), MMZSetup->spinLightsAniFrame & 0xFF, 16, 16);
56
57
MMZSetup->generatorAniFrame += 32;
58
MMZSetup->generatorAniFrame &= 0xFF;
59
RSDK.DrawAniTiles(MMZSetup->aniTiles, 330, 48, MMZSetup->generatorAniFrame, 16, 32);
60
RSDK.DrawAniTiles(MMZSetup->aniTiles, 332, 64, MMZSetup->generatorAniFrame, 32, 32);
61
}
62
}
63
64
void MMZSetup_Draw(void) {}
65
66
void MMZSetup_Create(void *data) {}
67
68
void MMZSetup_StageLoad(void)
69
{
70
MMZSetup->aniTiles = RSDK.LoadSpriteSheet("MMZ/AniTiles.gif", SCOPE_STAGE);
71
72
Animals->animalTypes[0] = ANIMAL_CUCKY;
73
Animals->animalTypes[1] = ANIMAL_POCKY;
74
75
if (Zone->actID) {
76
RSDK.GetTileLayer(0)->scrollPos = 384 << 16;
77
RSDK.GetTileLayer(1)->scrollPos = 384 << 16;
78
79
#if MANIA_USE_PLUS
80
for (int32 l = 3; l < 5; ++l) RSDK.GetTileLayer(l)->scrollInfo[0].scrollPos = (0x100 - ScreenInfo->center.x) << 16;
81
#endif
82
83
MMZSetup->panelAniDuration = 16;
84
if (!CutsceneRules_CheckStageReload() && CutsceneRules_CheckPlayerPos(TO_FIXED(44), TO_FIXED(1852), TO_FIXED(260), TO_FIXED(2092))) {
85
Zone->cameraBoundsB[0] = 2092;
86
Zone->cameraBoundsB[1] = 2092;
87
Zone->cameraBoundsB[2] = 2092;
88
Zone->cameraBoundsB[3] = 2092;
89
}
90
91
if (isMainGameMode() && globals->atlEnabled) {
92
if (!CutsceneRules_CheckStageReload())
93
Zone_ReloadStoredEntities(TO_FIXED(256), TO_FIXED(2092), true);
94
}
95
96
#if MANIA_USE_PLUS
97
if (isMainGameMode() && CutsceneRules_IsAct2())
98
Zone->stageFinishCallback = MMZSetup_StageFinish_EndAct2;
99
#endif
100
}
101
else {
102
if (isMainGameMode() && CutsceneRules_IsAct1()) {
103
Zone->shouldRecoverPlayers = true;
104
Zone->stageFinishCallback = MMZSetup_StageFinish_EndAct1;
105
}
106
107
Zone->cameraBoundsB[0] = 5120;
108
Zone->cameraBoundsB[1] = 5120;
109
Zone->cameraBoundsB[2] = 5120;
110
Zone->cameraBoundsB[3] = 5120;
111
}
112
113
#if MANIA_USE_PLUS
114
if (SceneInfo->filter & FILTER_ENCORE) {
115
RSDK.LoadPalette(0, "EncoreMMZ.act", 0b0000000011111111);
116
RSDK.LoadPalette(3, "EncoreMMZfp.act", 0b0000000011111111);
117
RSDK.LoadPalette(4, "EncoreMMZf.act", 0b0000000011111111);
118
}
119
#endif
120
}
121
122
void MMZSetup_StageFinish_EndAct1(void)
123
{
124
Zone_StoreEntities((Zone->cameraBoundsL[0] + ScreenInfo->center.x) << 16, Zone->cameraBoundsB[0] << 16);
125
RSDK.LoadScene();
126
}
127
128
#if MANIA_USE_PLUS
129
void MMZSetup_StageFinish_EndAct2(void) { CREATE_ENTITY(MMZ2Outro, NULL, 0, 0); }
130
#endif
131
132
#if GAME_INCLUDE_EDITOR
133
void MMZSetup_EditorDraw(void) {}
134
135
void MMZSetup_EditorLoad(void) {}
136
#endif
137
138
void MMZSetup_Serialize(void) {}
139
140