Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Credits/CreditsControl.txt
1319 views
1
//--------------Sonic CD Credits Control 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
// Value1 is unused...
8
#alias Object.Value2 : Object.Scroll
9
#alias Object.Value3 : Object.EndCredits
10
11
// Text Font Aliases
12
#alias Object.Value1 : Object.TargetLine
13
14
// States
15
#alias 0 : CREDITSCONTROL_INIT
16
#alias 1 : CREDITSCONTROL_FADEIN
17
#alias 2 : CREDITSCONTROL_MAIN
18
#alias 3 : CREDITSCONTROL_FADEOUT
19
20
// Soundtrack
21
#alias 0 : OST_JP
22
23
// Presentation Stage
24
#alias 1 : STAGE_P_MENU
25
26
// Priority
27
#alias 1 : PRIORITY_ACTIVE
28
29
// Engine States
30
#alias 8 : ENGINE_WAIT
31
32
// Text Info type
33
#alias 0 : TEXTINFO_TEXTDATA
34
#alias 1 : TEXTINFO_TEXTSIZE
35
#alias 2 : TEXTINFO_ROWCOUNT
36
37
38
sub ObjectMain
39
switch Object.State
40
case CREDITSCONTROL_INIT
41
42
// Object.Scroll should be 0 at this point, so this is
43
// essentially resetting the Camera Y Offset to be 0
44
Screen.YOffset = Object.Scroll
45
46
// Center the camera to be around 256 pixels in, to make sure the text is centered
47
TempValue0 = 256
48
TempValue0 -= Screen.CenterX
49
50
Screen.XOffset = TempValue0
51
52
// This Object is what draws the backgound, so it needs to draw low
53
Object.DrawOrder = 0
54
55
if Object.Timer < 8
56
// Hold for a moment...
57
58
Object.Timer++
59
else
60
// Start fading in
61
62
Object.Timer = 254
63
PlayMusic(0)
64
Object.State++
65
end if
66
67
// Set the screen to be black for now
68
SetScreenFade(0, 0, 0, 255)
69
break
70
71
case CREDITSCONTROL_FADEIN
72
if Object.Timer > 0
73
SetScreenFade(0, 0, 0, Object.Timer)
74
75
Object.Timer -= 8
76
else
77
Object.State++
78
end if
79
break
80
81
case CREDITSCONTROL_MAIN
82
Object.Scroll++
83
84
// Speed up the credits if the player wants
85
if KeyDown[0].ButtonA == true
86
Object.Scroll++
87
end if
88
89
if KeyDown[0].ButtonC == true
90
Object.Scroll++
91
end if
92
93
TempValue0 = Object.Scroll
94
TempValue0 >>= 1
95
96
Screen.YOffset = TempValue0
97
98
// If at the end of the Credits, then fade out
99
if Object.Scroll > Object.EndCredits
100
Object.State = CREDITSCONTROL_FADEOUT
101
Object.Timer = 0
102
end if
103
104
// And then, let the Player just skip the Credits if they want to
105
106
if KeyPress[0].Start == true
107
Object.State = CREDITSCONTROL_FADEOUT
108
Object.Timer = 0
109
end if
110
111
if KeyPress[0].ButtonB == true
112
Object.State = CREDITSCONTROL_FADEOUT
113
Object.Timer = 0
114
end if
115
116
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
117
if CheckResult > -1
118
Object.State = CREDITSCONTROL_FADEOUT
119
Object.Timer = 0
120
end if
121
break
122
123
case CREDITSCONTROL_FADEOUT
124
if Object.Timer < 320
125
Object.Timer += 8
126
Music.Volume -= 2
127
else
128
StopMusic()
129
130
// Go back to the menu now
131
#platform: Use_Origins // Call Origins movie
132
Engine.State = ENGINE_WAIT
133
134
// Unlock ending on the Museum
135
game.callbackParam0 = true
136
EngineCallback(NOTIFY_STATS_MOVIE)
137
#endplatform
138
139
#platform: Use_Standalone
140
Stage.ActiveList = PRESENTATION_STAGE
141
Stage.ListPos = STAGE_P_MENU
142
LoadStage()
143
#endplatform
144
end if
145
146
// Have a maximum fade value of 255, since that's all that a byte can hold
147
TempValue0 = Object.Timer
148
if TempValue0 > 255
149
TempValue0 = 255
150
end if
151
152
SetScreenFade(0, 0, 0, TempValue0)
153
break
154
155
end switch
156
157
end sub
158
159
160
sub ObjectDraw
161
162
// The scene doesn't have a background or anything, so draw a Black Rectangle here to avoid frame smear
163
DrawRect(0, 0, Screen.XSize, Screen.YSize, 0, 0, 0, 255)
164
165
end sub
166
167
168
sub ObjectStartup
169
// There's no exact "credits" song for either region, per se, so
170
// these tracks are used instead
171
if Options.Soundtrack == OST_JP
172
SetMusicTrack("JP/TimeAttack.ogg", 0, 100512)
173
else
174
SetMusicTrack("US/DAGarden.ogg", 0, 117382)
175
end if
176
177
// Note: On Standard Platforms (ie PC 2012 & consoles) "Data/Game/Credits_Console.txt" is used instead
178
// (Though, Origins does indeed use the "Mobile" file, and mobile versions of couse do too)
179
LoadTextFile(MENU_1, "Data/Game/Credits_Mobile.txt", false)
180
181
// In this scene, we control the camera manually
182
Screen.CameraEnabled = false
183
184
// Place the Credits Control object into the scene
185
Object[0].Type = TypeName[Credits Control]
186
187
// Make sure that it's always active, since it's the master control in this scene
188
Object[0].Priority = PRIORITY_ACTIVE
189
190
// Get the row count of how many entries there are in the credits file
191
GetTextInfo(TempValue1, MENU_1, TEXTINFO_ROWCOUNT, 0, 0)
192
193
// Find the first unoccupied object slot in the stage
194
ArrayPos0 = 32
195
while Object[ArrayPos0].Type != TypeName[Blank Object]
196
ArrayPos0++
197
loop
198
199
// Create all the Credits text
200
// - TempValue0 is the current line being read from the file
201
// - TempValue2 is the X Position to spawn the text at (stays constant)
202
// - TempValue3 is the Y Position to spawn the text at
203
204
// Starting values:
205
206
// Starting line should be 0 (ofc)
207
TempValue0 = 0
208
209
// X Position should be 256 pixels to the right
210
TempValue2 = 0x1000000
211
212
// Starting Y Position should be 256 pixels as well
213
TempValue3 = 0x1000000
214
215
// Now, let's enter the loop!
216
while TempValue0 < TempValue1
217
218
// Get what type of entry it is
219
// [Reading the number inside the brackets]
220
GetTextInfo(TempValue4, MENU_1, TEXTINFO_TEXTDATA, TempValue0, 1)
221
222
// Get the length of the entry
223
GetTextInfo(TempValue5, MENU_1, TEXTINFO_TEXTSIZE, TempValue0, 0)
224
225
if TempValue5 == 0
226
// This is a blank line, so don't put any text on the current line and instead create a new line 22 pixels tall
227
TempValue3 += 0x160000
228
else
229
if TempValue4 == 48 // '0' character
230
ResetObjectEntity(ArrayPos0, TypeName[Text Font 1], 0, TempValue2, TempValue3)
231
Object[ArrayPos0].TargetLine = TempValue0
232
ArrayPos0++
233
234
// 22 pixels difference
235
TempValue3 += 0x160000
236
else
237
if TempValue4 == 49 // '1' character
238
ResetObjectEntity(ArrayPos0, TypeName[Text Font 2], 0, TempValue2, TempValue3)
239
Object[ArrayPos0].TargetLine = TempValue0
240
ArrayPos0++
241
242
// 14 pixels difference
243
TempValue3 += 0xE0000
244
else
245
if TempValue4 == 50 // '2' character
246
ResetObjectEntity(ArrayPos0, TypeName[Text Font 3], 0, TempValue2, TempValue3)
247
Object[ArrayPos0].TargetLine = TempValue0
248
ArrayPos0++
249
250
// 14 pixels difference
251
TempValue3 += 0xE0000
252
end if
253
end if
254
end if
255
end if
256
257
TempValue0++
258
loop
259
260
TempValue3 -= 0xE0000 // 14 pixels
261
Object[0].EndCredits = TempValue3
262
Object[0].EndCredits >>= 15
263
264
end sub
265
266
267
// ========================
268
// Editor Subs
269
// ========================
270
271
sub RSDKDraw
272
DrawSprite(0)
273
end sub
274
275
276
sub RSDKLoad
277
LoadSpriteSheet("Global/Display.gif")
278
SpriteFrame(-16, -16, 32, 32, 1, 143) // "Script" Icon
279
280
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
281
end sub
282
283