Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/Credits/CreditsControl.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Credits Control Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.timer
13
14
private alias 0 : CREDITSCONTROL_INIT // Initialization state
15
private alias 1 : CREDITSCONTROL_FADEIN // Fade in for when showing text
16
private alias 2 : CREDITSCONTROL_DISPLAY // Pausing to let the player read the credit text
17
private alias 3 : CREDITSCONTROL_FADEOUT // Fade out for when fading out of credits text
18
private alias 4 : CREDITSCONTROL_FADEIN2 // Speical fade in for when going to the angry Eggman screen
19
private alias 5 : CREDITSCONTROL_END_PAUSE // Pause for when on the angry Eggman screen
20
private alias 6 : CREDITSCONTROL_FADEOUT_FINAL // Fading out of the angry Eggman screen
21
22
// Priority Aliases
23
private alias 1 : PRIORITY_ACTIVE
24
25
// Presentation Stage Aliases
26
private alias 0 : STAGE_P_TITLE
27
28
// Regular Stage Aliases
29
private alias 0 : STAGE_R_GHZ1
30
private alias 4 : STAGE_R_MZ2
31
private alias 8 : STAGE_R_SYZ3
32
private alias 11 : STAGE_R_LZ3
33
private alias 14 : STAGE_R_SLZ3
34
private alias 15 : STAGE_R_SBZ1
35
private alias 16 : STAGE_R_SBZ2
36
37
38
// ========================
39
// Events
40
// ========================
41
42
event ObjectUpdate
43
switch object.state
44
case CREDITSCONTROL_INIT
45
// Start the fade effect
46
object.timer = 320
47
SetScreenFade(0, 0, 0, object.timer)
48
49
// Go to the fade-in state
50
object.state++
51
52
// Only start the music on the first screen
53
// (This object is refreshed between gameplay demos so this has to be in an if statement)
54
if credits.screen == 0
55
PlayMusic(0)
56
end if
57
break
58
59
case CREDITSCONTROL_FADEIN
60
if object.timer > 0
61
object.timer -= 8
62
else
63
object.alpha = 128
64
object.state++
65
end if
66
67
SetScreenFade(0, 0, 0, object.timer)
68
break
69
70
case CREDITSCONTROL_DISPLAY
71
object.timer++
72
73
// Pause for 136 frames
74
if object.timer == 136
75
object.timer = 0
76
object.state++
77
end if
78
break
79
80
case CREDITSCONTROL_FADEOUT
81
if object.timer < 256
82
object.timer += 8
83
SetScreenFade(0, 0, 0, object.timer)
84
else
85
// Start the demo
86
87
// Object gets cleared in a few frames anyway, but might as well
88
object.state = CREDITSCONTROL_INIT
89
90
// Increment the scredits.screen value
91
// Note that this makes 1 the first value, with 0 coming last
92
credits.screen++
93
credits.screen %= 9
94
95
// Move the camera to the curresponding position
96
// Another note: The text isn't actual text being drawn,
97
// instead each screen is built into the level tiles/chunks
98
// Because of this, moving to the next credits screen means moving the camera down
99
temp0 = credits.screen
100
temp0 <<= 8
101
screen.yoffset = temp0
102
103
// Turn on attract mode
104
options.attractMode = true
105
106
// Load the appropriate demo stage
107
switch credits.screen
108
case 0
109
// Final demo (check out note above, demos go 1-8 and then end at 0)
110
111
// Pay a visit to angry Eggman
112
object.state = CREDITSCONTROL_FADEIN2
113
114
// Determine whether the ending is good or not based on emerald count
115
// Of course, change between 6 and 7 emeralds depending on emerald count setting
116
if options.superStates == false
117
if specialStage.emeralds >= 0x3F // Six 1's in binary
118
screen.yoffset = 0xA00
119
else
120
screen.yoffset = 0x900
121
end if
122
else
123
if specialStage.emeralds >= 0x7F // Seven 1's in binary
124
screen.yoffset = 0xA00
125
else
126
screen.yoffset = 0x900
127
end if
128
end if
129
break
130
131
case 1
132
case 8
133
stage.activeList = REGULAR_STAGE
134
stage.listPos = STAGE_R_GHZ1
135
LoadStage()
136
break
137
138
case 2
139
stage.activeList = REGULAR_STAGE
140
stage.listPos = STAGE_R_MZ2
141
LoadStage()
142
break
143
144
case 3
145
stage.activeList = REGULAR_STAGE
146
stage.listPos = STAGE_R_SYZ3
147
LoadStage()
148
break
149
150
case 4
151
stage.activeList = REGULAR_STAGE
152
stage.listPos = STAGE_R_LZ3
153
LoadStage()
154
break
155
156
case 5
157
stage.activeList = REGULAR_STAGE
158
stage.listPos = STAGE_R_SLZ3
159
LoadStage()
160
break
161
162
case 6
163
stage.activeList = REGULAR_STAGE
164
stage.listPos = STAGE_R_SBZ1
165
LoadStage()
166
break
167
168
case 7
169
stage.activeList = REGULAR_STAGE
170
stage.listPos = STAGE_R_SBZ2
171
LoadStage()
172
break
173
174
end switch
175
176
// Set the screen to black
177
SetScreenFade(0, 0, 0, 255)
178
end if
179
break
180
181
case CREDITSCONTROL_FADEIN2
182
// Fade-in for when going to ending screen
183
if object.timer > 0
184
object.timer -= 8
185
else
186
object.alpha = 128
187
object.state++
188
end if
189
190
SetScreenFade(0, 0, 0, object.timer)
191
break
192
193
case CREDITSCONTROL_END_PAUSE
194
object.timer++
195
196
// Advance time is up
197
if object.timer == 1200
198
object.timer = 0
199
object.state++
200
end if
201
202
// Advance if the player wants to skip the cutscene, too
203
if keyPress[0].start == true
204
object.timer = 0
205
object.state = CREDITSCONTROL_FADEOUT_FINAL
206
end if
207
208
if keyPress[0].buttonA == true
209
object.timer = 0
210
object.state = CREDITSCONTROL_FADEOUT_FINAL
211
end if
212
213
if keyPress[0].buttonB == true
214
object.timer = 0
215
object.state = CREDITSCONTROL_FADEOUT_FINAL
216
end if
217
218
if keyPress[0].buttonC == true
219
object.timer = 0
220
object.state = CREDITSCONTROL_FADEOUT_FINAL
221
end if
222
223
#platform: MOBILE
224
if object.timer > 60
225
CheckTouchRect(0, 0, screen.xsize, screen.ysize)
226
227
if checkResult > -1
228
object.timer = 0
229
object.state = CREDITSCONTROL_FADEOUT_FINAL
230
end if
231
end if
232
#endplatform
233
break
234
235
case CREDITSCONTROL_FADEOUT_FINAL
236
// Final fade-out before going back
237
if object.timer < 256
238
object.timer += 8
239
SetScreenFade(0, 0, 0, object.timer)
240
else
241
// Go back to the menu now
242
243
stage.activeList = PRESENTATION_STAGE
244
stage.listPos = STAGE_P_TITLE
245
StopMusic()
246
247
options.attractMode = false
248
249
#platform: USE_STANDALONE
250
engine.state = 7
251
#endplatform
252
#platform: USE_ORIGINS
253
engine.state = 8
254
#endplatform
255
SetScreenFade(0, 0, 0, 255)
256
#platform: USE_ORIGINS
257
CallNativeFunction2(NotifyCallback, NOTIFY_STATS_MOVIE, true)
258
#endplatform
259
end if
260
break
261
262
end switch
263
264
// Center the text around the screen
265
temp0 = screen.xcenter
266
FlipSign(temp0)
267
temp0 += 256
268
screen.xoffset = temp0
269
end event
270
271
272
event ObjectStartup
273
SetMusicTrack("Credits.ogg", 0, false)
274
275
// Hide touch controls
276
options.touchControls = false
277
278
// Position the screen based on the current credits screen
279
// -> This scene is entirely refreshed between demo playbacks, so we can't look at where the camera was previously
280
temp0 = credits.screen
281
temp0 <<= 8
282
screen.yoffset = temp0
283
284
foreach (TypeName[Credits Control], arrayPos0, ALL_ENTITIES)
285
object[arrayPos0].priority = PRIORITY_ACTIVE
286
next
287
end event
288
289
290
// ========================
291
// Editor Events
292
// ========================
293
294
event RSDKDraw
295
DrawSprite(0)
296
end event
297
298
299
event RSDKLoad
300
LoadSpriteSheet("Global/Display.gif")
301
SpriteFrame(-16, -16, 32, 32, 1, 143)
302
303
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
304
end event
305
306