Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Credits/CreditsSetup.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: CreditsSetup Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectCreditsSetup *CreditsSetup;
11
12
void CreditsSetup_Update(void) {}
13
14
void CreditsSetup_LateUpdate(void) {}
15
16
void CreditsSetup_StaticUpdate(void)
17
{
18
if (CreditsSetup->started) {
19
CreditsSetup->scrollPos += 0x1000;
20
21
EntityFXFade *fade = CreditsSetup->fxFade;
22
23
if (!CreditsSetup->skipped) {
24
// Check if we should play the next track
25
if (!RSDK.ChannelActive(0))
26
Music_PlayTrack(++CreditsSetup->creditsTrack);
27
28
if (ControllerInfo->keyStart.press || (CreditsSetup->creditsSize && CreditsSetup->creditsPos >= CreditsSetup->creditsSize)) {
29
CreditsSetup->skipped = true;
30
31
fade->state = FXFade_State_FadeOut;
32
fade->speedIn = 8;
33
fade->wait = 64;
34
fade->speedOut = 8;
35
fade->timer = 0;
36
fade->oneWay = false;
37
Music_FadeOut(0.0125);
38
}
39
}
40
else {
41
if (fade->state == FXFade_State_Wait && fade->wait == 1) {
42
EntityMenuParam *param = MenuParam_GetParam();
43
44
#if MANIA_USE_PLUS
45
if (param->creditsReturnToMenu) {
46
RSDK.SetScene("Presentation", "Menu");
47
}
48
else if (SaveGame_GetSaveRAM()->collectedEmeralds < 0b01111111) {
49
globals->gameMode == MODE_ENCORE ? RSDK.SetScene("Cutscenes", "Try Again Encore") : RSDK.SetScene("Cutscenes", "Try Again");
50
}
51
else if (globals->gameMode == MODE_ENCORE) {
52
RSDK.SetScene("Cutscenes", "Mirage Saloon Encore End");
53
}
54
else {
55
API.CheckDLC(DLC_PLUS) ? RSDK.SetScene("Presentation", "Game Summary") : RSDK.SetScene("Presentation", "Menu");
56
}
57
#else
58
if (param->creditsReturnToMenu)
59
RSDK.SetScene("Presentation", "Menu");
60
else if (SaveGame_GetSaveRAM()->collectedEmeralds < 0b01111111)
61
RSDK.SetScene("Cutscenes", "Try Again");
62
else
63
RSDK.SetScene("Presentation", "Menu");
64
#endif
65
66
RSDK.LoadScene();
67
}
68
}
69
70
int32 scrollSpeed = 0x10000;
71
if (ControllerInfo->keyA.down || ControllerInfo->keyB.down || ControllerInfo->keyC.down)
72
scrollSpeed = 0x80000;
73
74
foreach_all(UICreditsText, text)
75
{
76
text->drawGroup = Zone->playerDrawGroup[1];
77
text->position.y -= scrollSpeed;
78
}
79
80
CreditsSetup->creditsPos += scrollSpeed;
81
}
82
else {
83
foreach_all(Player, player) { destroyEntity(player); }
84
foreach_all(Camera, camera) { destroyEntity(camera); }
85
86
CreditsSetup->creditsSize = 0;
87
CreditsSetup->creditsPos = 0;
88
CreditsSetup_LoadCreditsStrings();
89
CreditsSetup->started = true;
90
}
91
}
92
93
void CreditsSetup_Draw(void) {}
94
95
void CreditsSetup_Create(void *data) {}
96
97
void CreditsSetup_StageLoad(void)
98
{
99
CreditsSetup->started = false;
100
101
foreach_all(FXFade, fxFade) { CreditsSetup->fxFade = fxFade; }
102
}
103
104
void CreditsSetup_LoadCreditsStrings(void)
105
{
106
String string;
107
String stringList;
108
109
INIT_STRING(stringList);
110
INIT_STRING(string);
111
RSDK.LoadStringList(&stringList, "Credits.txt", 8);
112
RSDK.InitString(&string, "", 0x80);
113
114
int32 offset = (ScreenInfo->size.y + 128) << 16;
115
for (int32 i = 0; RSDK.SplitStringList(&string, &stringList, i, 1); ++i) {
116
if (string.length <= 4) {
117
offset += 0x200000;
118
}
119
else {
120
int32 type = string.chars[1] - '0';
121
bool32 hasShape = string.chars[2] == 'U';
122
123
string.length -= 3;
124
for (int32 c = 0; c < string.length; ++c) string.chars[c] = string.chars[c + 3];
125
126
EntityUICreditsText *text = RSDK_GET_ENTITY(i + 0x100, UICreditsText);
127
RSDK.ResetEntity(text, UICreditsText->classID, 0);
128
text->hasShape = hasShape;
129
text->position.x = 0x1000000;
130
text->position.y = offset;
131
UICreditsText_SetText(type, text, &string);
132
133
SpriteFrame *frame = RSDK.GetFrame(UICreditsText->aniFrames, type, 0);
134
if (frame)
135
offset += (frame->height + 8) << 16;
136
if (type == 7)
137
offset -= 0x200000;
138
}
139
}
140
141
CreditsSetup->creditsSize = offset + (ScreenInfo->size.y << 15);
142
}
143
144
#if GAME_INCLUDE_EDITOR
145
void CreditsSetup_EditorDraw(void) {}
146
147
void CreditsSetup_EditorLoad(void) {}
148
#endif
149
150
void CreditsSetup_Serialize(void) {}
151
152