Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R8/FadeScreen.txt
1319 views
1
//----------------Sonic CD Fade Screen Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
#alias Object.Value1 : Object.Timer
8
9
// Player Aliases
10
#alias Object[0].Value0 : Player.Rings
11
12
// States
13
#alias 0 : FADESCREEN_SETUP
14
#alias 1 : FADESCREEN_AMY
15
#alias 2 : FADESCREEN_FINALFEVER
16
#alias 3 : FADESCREEN_BLANK
17
#alias 4 : FADESCREEN_BOSSRUSH // Origins Exclusive
18
19
// Property Values
20
#alias 0 : CUTSCENE_ENDING
21
#alias 1 : CUTSCENE_FINALFEVER
22
23
// Game Mode Aliases
24
#alias 1 : MODE_SAVEGAME
25
#alias 2 : MODE_TIMEATTACK
26
27
// Presentation Stages
28
#alias 0 : STAGE_P_TITLE
29
#alias 2 : STAGE_P_TATTACK
30
#alias 7 : STAGE_P_STAFFCREDITS
31
#alias 8 : STAGE_P_TAILSUNLOCK
32
33
// Soundstrack
34
#alias 0 : OST_JP
35
36
// Players
37
#alias 0 : PLAYER_SONIC_A
38
#alias 1 : PLAYER_TAILS_A
39
40
// Engine States
41
#alias 1 : ENGINE_MAINGAME
42
#alias 8 : ENGINE_WAIT
43
44
// Callbacks
45
#alias 4 : CALLBACK_FINISHGAME_NOTIFY
46
47
sub ObjectMain
48
switch Object.State
49
case FADESCREEN_SETUP
50
if Object.Timer < 480
51
Object.Timer += 4
52
Music.Volume--
53
else
54
Object.Timer = 224
55
if Object.PropertyValue == CUTSCENE_ENDING
56
Object.State++
57
else
58
Object.State += 2
59
end if
60
end if
61
62
if Object.PropertyValue == CUTSCENE_FINALFEVER
63
SetScreenFade(0, 0, 0, Object.Timer)
64
else
65
SetScreenFade(224, 224, 224, Object.Timer)
66
end if
67
break
68
69
case FADESCREEN_AMY
70
if Object.Timer > 0
71
Music.Volume--
72
Object.Timer -= 16
73
else
74
StopMusic()
75
76
#platform: Use_Origins
77
EngineCallback(NOTIFY_BOSS_END)
78
TempValue0 = false
79
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
80
TempValue0 = true
81
else
82
// Check if the player is replaying the stage from My Data & Rankings
83
if game.oneStageFlag != false
84
TempValue0 = true
85
EngineCallback(NOTIFY_ACT_FINISH)
86
game.callbackResult = -1 // Reset any callback result
87
game.callbackParam0 = 1 // 0 - Normal Retry, anything else - Show current and best time
88
game.callbackParam1 = Stage.ListPos // Get current stage
89
game.callbackParam2 = 0 // Unknown
90
EngineCallback(NOTIFY_STAGE_RETRY)
91
end if
92
end if
93
#endplatform
94
#platform: Use_Standalone
95
TempValue0 = false
96
#endplatform
97
if TempValue0 != false
98
Object.State = FADESCREEN_BOSSRUSH
99
else
100
if Options.GameMode == MODE_TIMEATTACK
101
TimeAttack.Result = Stage.Seconds
102
TimeAttack.Result *= 100
103
TempValue0 = Stage.Minutes
104
TempValue0 *= 6000
105
TimeAttack.Result += TempValue0
106
TimeAttack.Result += Stage.MilliSeconds
107
108
TempValue0 = Stage.ListPos
109
TempValue0 %= 10
110
TempValue0 >>= 2
111
TempValue1 = Stage.ListPos
112
TempValue1 /= 10
113
TempValue1 *= 3
114
TempValue0 += TempValue1
115
TempValue0++
116
TempValue1 = Stage.Seconds
117
TempValue1 *= 100
118
TempValue2 = Stage.Minutes
119
TempValue2 *= 6000
120
TempValue1 += TempValue2
121
TempValue1 += Stage.MilliSeconds
122
SetLeaderboard(TempValue0, TempValue1)
123
Stage.ListPos = STAGE_P_TATTACK
124
else
125
EngineCallback(CALLBACK_FINISHGAME_NOTIFY)
126
if Player.Score > 0
127
if Options.GameMode == MODE_SAVEGAME
128
if Stage.DebugMode == false
129
SetLeaderboard(0, Player.Score)
130
end if
131
end if
132
end if
133
#platform: Use_Origins
134
game.callbackParam0 = StageStatsUsabilityParam1 // Enemies destroyed by any means
135
game.callbackParam1 = StageStatsUsabilityParam2 // Enemies destroyed by rolling
136
game.callbackParam2 = 0
137
EngineCallback(NOTIFY_STATS_ENEMY)
138
139
game.callbackParam0 = Player.Rings
140
EngineCallback(NOTIFY_STATS_RING)
141
142
game.callbackParam0 = StageStatsUsabilityParam5 // Lamp Post related
143
EngineCallback(NOTIFY_STATS_PARAM_1)
144
145
game.callbackParam0 = 0 // Unknown
146
game.callbackParam1 = StageStatsUsabilityParam4 // Unknown
147
game.callbackParam2 = 0 // Unknown
148
EngineCallback(NOTIFY_STATS_CHARA_ACTION)
149
150
EngineCallback(NOTIFY_ACT_FINISH)
151
152
StageStatsUsabilityParam1 = 0
153
StageStatsUsabilityParam2 = 0
154
StageStatsUsabilityParam3 = 0
155
StageStatsUsabilityParam4 = 0
156
StatsUsabilityParam1 = 0
157
StatsUsabilityParam2 = 0
158
StatsUsabilityParam3 = 0
159
StatsUsabilityParam4 = 0
160
161
if SpecialStage.TimeStones > 126 // 0b1111110, each '1' bit represents an obtained time stone
162
EngineCallback(NOTIFY_GOOD_ENDING)
163
else
164
if Good_Future_List > 0x3FFE // 0b11111111111110, each '1' bit represents a zone with the robot transporters destroyed
165
EngineCallback(NOTIFY_GOOD_ENDING)
166
end if
167
end if
168
#endplatform
169
170
#platform: Use_Standalone
171
if Stage.PlayerListPos == PLAYER_SONIC_A
172
#endplatform
173
if SpecialStage.TimeStones > 126 // 0b1111110, each '1' bit represents an obtained time stone
174
LoadVideo("Good_Ending")
175
else
176
if Good_Future_List > 0x3FFE // 0b11111111111110, each '1' bit represents a zone with the robot transporters destroyed
177
LoadVideo("Good_Ending")
178
else
179
LoadVideo("Bad_Ending")
180
end if
181
end if
182
#platform: Use_Standalone
183
end if
184
#endplatform
185
186
// Because of the way mobile cd worked (using the phone's native video player)
187
// it needed to reproduce separated videos depending of the soundtrack option
188
// for the sake of clarity and simplicity, the mobile code got commented out
189
//#platform: Use_Standalone
190
// if Stage.PlayerListPos == PLAYER_SONIC_A
191
//#endplatform
192
// if SpecialStage.TimeStones > 126 // 0b1111110, each '1' bit represents an obtained time stone
193
// if Options.Soundtrack == OST_JP
194
// LoadVideo("Good_Ending")
195
// else
196
// LoadVideo("Good_EndingUS")
197
// end if
198
// else
199
// if Good_Future_List > 0x3FFE // 0b11111111111110, each '1' bit represents a zone with the robot transporters destroyed
200
// if Options.Soundtrack == OST_JP
201
// LoadVideo("Good_Ending")
202
// else
203
// LoadVideo("Good_EndingUS")
204
// end if
205
// else
206
// if Options.Soundtrack == OST_JP
207
// LoadVideo("Bad_Ending")
208
// else
209
// LoadVideo("Bad_EndingUS")
210
// end if
211
// end if
212
// end if
213
//#platform: Use_Standalone
214
// end if
215
//#endplatform
216
217
if SaveRAM[36] == false // Is Tails unlocked?
218
#platform: Use_Origins
219
if game.playMode == BOOT_PLAYMODE_CLASSIC
220
Stage.ListPos = STAGE_P_TITLE
221
Engine.State = ENGINE_WAIT
222
else
223
SaveRAM[36] = true
224
WriteSaveRAM()
225
Stage.ListPos = STAGE_P_TAILSUNLOCK
226
end if
227
#endplatform
228
229
#platform: Use_Standalone
230
SaveRAM[36] = true
231
WriteSaveRAM()
232
Stage.ListPos = STAGE_P_TAILSUNLOCK
233
#endplatform
234
else
235
Stage.ListPos = STAGE_P_TITLE
236
#platform: Use_Origins
237
Engine.State = ENGINE_WAIT
238
#endplatform
239
end if
240
241
#platform: Use_Decomp
242
// We don't really want to softlock the game, do we?
243
if Engine.State == ENGINE_WAIT
244
Engine.State = ENGINE_MAINGAME
245
end if
246
#endplatform
247
248
#platform: Use_Origins
249
// Unlock ending on the Museum
250
game.callbackParam0 = true
251
EngineCallback(NOTIFY_STATS_MOVIE)
252
#endplatform
253
254
#platform: Use_Standalone
255
// Originally the game checked if the player was using Sonic or Tails
256
// This got removed in Origins, but since it covers this whole thing, this workaround should do
257
if Stage.PlayerListPos == PLAYER_TAILS_A
258
Stage.ListPos = STAGE_P_STAFFCREDITS
259
end if
260
#endplatform
261
end if
262
Stage.ActiveList = PRESENTATION_STAGE
263
LoadStage()
264
end if
265
266
end if
267
SetScreenFade(Object.Timer, Object.Timer, Object.Timer, 255)
268
break
269
270
case FADESCREEN_FINALFEVER
271
if Object.Timer > 0
272
Music.Volume--
273
Object.Timer -= 16
274
else
275
StopMusic()
276
Stage.ListPos += 2 // Would load Final Fever (if it was there), assuming you're in R83C
277
LoadStage()
278
end if
279
break
280
281
case FADESCREEN_BLANK
282
break
283
284
case FADESCREEN_BOSSRUSH
285
SetScreenFade(255, 255, 255, 255)
286
break
287
end switch
288
end sub
289
290
291
// ========================
292
// Editor Subs
293
// ========================
294
295
sub RSDKDraw
296
DrawSprite(0)
297
end sub
298
299
300
sub RSDKLoad
301
LoadSpriteSheet("Global/Display.gif")
302
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
303
304
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
305
end sub
306
307