Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/LRZ/LRZ1Setup.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: LRZ1Setup Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectLRZ1Setup *LRZ1Setup;
11
12
void LRZ1Setup_Update(void) {}
13
14
void LRZ1Setup_LateUpdate(void) {}
15
16
void LRZ1Setup_StaticUpdate(void)
17
{
18
LRZ1Setup->palTimer += 24;
19
if (LRZ1Setup->palTimer >= 256) {
20
LRZ1Setup->palTimer -= 256;
21
22
RSDK.RotatePalette(1, 208, 211, true);
23
RSDK.RotatePalette(2, 208, 211, true);
24
RSDK.RotatePalette(3, 208, 211, true);
25
RSDK.RotatePalette(4, 208, 211, true);
26
}
27
28
if (LRZ1Setup->fadeTimer <= 0) {
29
int32 blend = RSDK.Cos1024(2 * (Zone->timer & 0x1FF)) >> 3;
30
RSDK.SetLimitedFade(5, 1, blend >= 0 ? 4 : 3, abs(blend), 208, 211);
31
RSDK.RotatePalette(3, 208, 211, true);
32
RSDK.RotatePalette(4, 208, 211, true);
33
34
RSDK.SetLimitedFade(6, 2, blend >= 0 ? 4 : 3, abs(blend), 208, 211);
35
RSDK.RotatePalette(3, 208, 211, false);
36
RSDK.RotatePalette(4, 208, 211, false);
37
38
RSDK.SetLimitedFade(0, 5, 6, LRZ1Setup->palTimer, 208, 211);
39
}
40
else {
41
if (LRZ1Setup->fadeTimer == 1)
42
RSDK.CopyPalette(0, 208, 1, 208, 5);
43
44
RSDK.SetLimitedFade(0, 1, 7, LRZ1Setup->fadeTimer, 208, 212);
45
46
if (LRZ1Setup->fadeTimer < 256)
47
LRZ1Setup->fadeTimer += 2;
48
}
49
50
RSDK.SetLimitedFade(0, 1, 2, (RSDK.Sin256(2 * Zone->timer) >> 1) + 128, 140, 141);
51
RSDK.SetLimitedFade(0, 1, 2, (RSDK.Sin256(2 * Zone->timer + 128) >> 1) + 128, 142, 143);
52
RSDK.SetLimitedFade(0, 1, 2, (RSDK.Sin256(Zone->timer) >> 1) + 128, 156, 158);
53
54
foreach_active(Player, player)
55
{
56
if (player->onGround) {
57
Hitbox *hitbox = Player_GetHitbox(player);
58
59
int32 tileInfo = 0;
60
uint8 behaviour = LRZ1_TFLAGS_NORMAL;
61
LRZ2Setup_GetTileInfo(player->position.x, (hitbox->bottom << 16) + player->position.y, player->moveLayerPosition.x,
62
player->moveLayerPosition.y, player->collisionPlane, &tileInfo, &behaviour);
63
64
if (behaviour == LRZ1_TFLAGS_LAVA && player->shield != SHIELD_FIRE && !LRZ1Setup->fadeTimer) {
65
Player_HurtFlip(player);
66
}
67
}
68
}
69
70
#if MANIA_USE_PLUS
71
if (!(Zone->timer & 3)) {
72
++LRZ1Setup->background1->deformationOffset;
73
++LRZ1Setup->background2->deformationOffset;
74
}
75
76
if (!(Zone->timer & 1)) {
77
++LRZ1Setup->fgLow->deformationOffset;
78
++LRZ1Setup->fgHigh->deformationOffset;
79
}
80
#endif
81
}
82
83
void LRZ1Setup_Draw(void) {}
84
85
void LRZ1Setup_Create(void *data) {}
86
87
void LRZ1Setup_StageLoad(void)
88
{
89
LRZ1Setup->fadeTimer = 0;
90
91
LRZ1Setup->background1 = RSDK.GetTileLayer(RSDK.GetTileLayerID("Background 1"));
92
LRZ1Setup->background2 = RSDK.GetTileLayer(RSDK.GetTileLayerID("Background 2"));
93
94
#if MANIA_USE_PLUS
95
LRZ1Setup->fgLow = RSDK.GetTileLayer(Zone->fgLayer[0]);
96
LRZ1Setup->fgHigh = RSDK.GetTileLayer(Zone->fgLayer[1]);
97
#endif
98
99
// Slows the vScroll of the BG when the lava lake is visible to give a nicer effect :]
100
RSDK.SetDrawGroupProperties(0, false, LRZ1Setup_DrawHook_ApplyBGSmoothing);
101
102
Animals->animalTypes[0] = ANIMAL_FLICKY;
103
#if MANIA_USE_PLUS
104
Animals->animalTypes[1] = ANIMAL_CUCKY;
105
#else
106
Animals->animalTypes[1] = ANIMAL_RICKY;
107
#endif
108
109
if (isMainGameMode() && CutsceneRules_IsAct1())
110
Zone->stageFinishCallback = LRZ1Setup_StageFinish_EndAct1;
111
112
#if MANIA_USE_PLUS
113
if (SceneInfo->filter & FILTER_ENCORE) {
114
RSDK.LoadPalette(0, "EncoreLRZ1.act", 0b0000000011111111);
115
116
for (int32 i = 0; i < 0x400; ++i) LRZ1Setup->fgLow->deformationData[i] = LRZ1Setup->deformFG[i & 0x1F];
117
for (int32 i = 0; i < 0x400; ++i) LRZ1Setup->fgHigh->deformationData[i] = LRZ1Setup->deformFG[i & 0x1F];
118
for (int32 i = 0; i < 0x400; ++i) LRZ1Setup->background1->deformationData[i] = LRZ1Setup->deformBG[i & 0x1F];
119
for (int32 i = 0; i < 0x400; ++i) LRZ1Setup->background2->deformationData[i] = LRZ1Setup->deformBG[i & 0x1F];
120
}
121
122
if (!isMainGameMode() || !globals->enableIntro || CutsceneRules_CheckStageReload()) {
123
Zone->cameraBoundsL[0] = 2732;
124
Zone->cameraBoundsL[1] = 2732;
125
Zone->cameraBoundsL[2] = 2732;
126
Zone->cameraBoundsL[3] = 2732;
127
foreach_all(LRZ1Intro, intro) { destroyEntity(intro); }
128
}
129
#else
130
Zone->cameraBoundsL[0] = 648;
131
Zone->cameraBoundsL[1] = 648;
132
Zone->cameraBoundsL[2] = 648;
133
Zone->cameraBoundsL[3] = 648;
134
#endif
135
}
136
137
void LRZ1Setup_StageFinish_EndAct1(void) { CREATE_ENTITY(LRZ1Outro, NULL, 0, 0); }
138
139
void LRZ1Setup_DrawHook_ApplyBGSmoothing(void)
140
{
141
int32 scroll = MIN(0x800000 - 8 * ScreenInfo->position.y * ScreenInfo->position.y, 0);
142
143
LRZ1Setup->background1->scrollPos = scroll;
144
LRZ1Setup->background2->scrollPos = scroll;
145
}
146
147
#if GAME_INCLUDE_EDITOR
148
void LRZ1Setup_EditorDraw(void) {}
149
150
void LRZ1Setup_EditorLoad(void) {}
151
#endif
152
153
void LRZ1Setup_Serialize(void) {}
154
155