Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/TitleCards/R2_TitleCard.txt
1319 views
1
//-----------------Sonic CD Title Card Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.BarPos
7
#alias Object.Value1 : Object.TextPos
8
#alias Object.Value2 : Object.TextSize
9
#alias Object.Value3 : Object.Timer
10
#alias Object.Value4 : Object.FadeR
11
#alias Object.Value5 : Object.FadeG
12
#alias Object.Value6 : Object.FadeB
13
#alias Object.Value7 : Object.CharPos
14
15
// Player Aliases
16
#alias Object[0].Value4 : Player.InvincibleTimer
17
18
// HUD Alias
19
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
20
21
// States
22
#alias 0 : TITLECARD_FADEIN
23
#alias 1 : TITLECARD_SLIDEIN
24
#alias 2 : TITLECARD_DISPLAY
25
#alias 3 : TITLECARD_SLIDEOUT
26
27
// Soundtrack
28
#alias 0 : OST_JP
29
30
// Players
31
#alias 0 : PLAYER_SONIC_A
32
#alias 1 : PLAYER_TAILS_A
33
34
// Time Period Aliases
35
#alias 0 : TIME_PRESENT
36
#alias 1 : TIME_PAST
37
#alias 2 : TIME_GOOD_FUTURE
38
#alias 3 : TIME_BAD_FUTURE
39
40
41
// ControlMode Aliases
42
#alias -1 : CONTROLMODE_NONE
43
#alias 0 : CONTROLMODE_NORMAL
44
45
// Priority
46
#alias 1 : PRIORITY_ACTIVE
47
48
49
sub ObjectPlayerInteraction
50
Player.Timer = 0
51
end sub
52
53
54
sub ObjectDraw
55
switch Object.State
56
case TITLECARD_FADEIN
57
Player.ControlMode = CONTROLMODE_NONE
58
Player.Up = false
59
Player.Down = false
60
Player.Left = false
61
Player.Right = false
62
Player.JumpPress = false
63
Player.JumpHold = false
64
65
// Check if the player comes from warping, if not, blank speed
66
if Warp.XPos < 1
67
Player.Speed = 0
68
end if
69
70
if Object.Timer > 0
71
if Object.Timer == 256
72
PlayMusic(0)
73
if Warp.XPos > 0
74
// Restore values post-warp
75
Player.XPos = Warp.XPos
76
Player.YPos = Warp.YPos
77
78
Player.XVelocity = Warp.XVelocity
79
Player.YVelocity = Warp.YVelocity
80
Player.Speed = Warp.XVelocity
81
82
Player.State = Warp.State
83
84
Stage.MilliSeconds = Rec_Milliseconds
85
Stage.Seconds = Rec_Seconds
86
Stage.Minutes = Rec_Minutes
87
88
Player.InvincibleTimer = 8000
89
end if
90
Warp.Timer = 0
91
Warp.Frame = 0
92
end if
93
94
SetScreenFade(Object.FadeR, Object.FadeG, Object.FadeB, Object.Timer)
95
Object.Timer -= 8
96
else
97
Fade_Colour = 0
98
99
// the title card animation doesn't play out if you come from a warp or restarted from a checkpoint
100
CheckEqual(Warp.XPos, 0)
101
TempValue0 = CheckResult
102
CheckLower(LampPost.Check, 32)
103
TempValue0 &= CheckResult
104
if TempValue0 == true
105
Object.State = TITLECARD_SLIDEIN
106
Object.Timer = 0
107
else
108
Player.ControlMode = CONTROLMODE_NORMAL
109
Stage.TimeEnabled = true
110
111
ResetObjectEntity(20, TypeName[Blank Object], 0, 0, 0)
112
Warp.XPos = 0
113
end if
114
end if
115
break
116
117
case TITLECARD_SLIDEIN
118
TempValue0 = 144
119
TempValue0 += Object.CharPos
120
121
if Object.TextPos > TempValue0
122
// Slide the text to the left
123
Object.TextPos -= 8
124
else
125
if Object.BarPos == 0
126
Object.State = TITLECARD_DISPLAY
127
end if
128
end if
129
130
if Object.BarPos < 0
131
// Move the Bar down
132
Object.BarPos += 8
133
end if
134
break
135
136
case TITLECARD_DISPLAY
137
// Hold for a moment to let the Player see what a nice Title Card this is
138
139
if Object.Timer == 90
140
// Time's up, start sliding out!
141
Object.State = TITLECARD_SLIDEOUT
142
else
143
Object.Timer++
144
end if
145
break
146
147
case TITLECARD_SLIDEOUT
148
if Object.TextPos < 408
149
150
// Move the text to the right, and...
151
Object.TextPos += 16
152
153
// ...move the bar upwards as well
154
Object.BarPos -= 16
155
156
else
157
// Free Sonic's control, and enable the stage timer.
158
Player.ControlMode = CONTROLMODE_NORMAL
159
Stage.TimeEnabled = true
160
161
// The Title Card's job is done, despawn it
162
ResetObjectEntity(20, TypeName[Blank Object], 0, 0, 0)
163
Warp.XPos = 0
164
end if
165
break
166
167
end switch
168
169
// Before drawing, make sure this object hasn't been blanked already
170
// (Under certain circumstances, this can otherwise cause major graphical issues!!)
171
if Object.Type > TypeName[Blank Object]
172
TempValue0 = 136
173
TempValue0 += Object.CharPos
174
175
// Draw the Red Bar
176
DrawSpriteScreenXY(0, TempValue0, Object.BarPos)
177
178
// And then, draw the act number
179
DrawSpriteScreenXY(Stage.ActNo, Object.TextPos, 80)
180
181
// And then draw the Zone text, the Sonic CD bar, and the weird three lines
182
DrawSpriteScreenXY(4, Object.TextPos, 80)
183
DrawSpriteScreenXY(5, Object.TextPos, 80)
184
DrawSpriteScreenXY(6, Object.TextPos, 80)
185
DrawSpriteScreenXY(7, Object.TextPos, 80)
186
187
#platform: Use_Decomp // Creates a black rectangle that fills the empty space on wider resolutions
188
Tempvalue0 = Object.TextPos
189
TempValue0 += 220
190
DrawRect(TempValue0, 163, Screen.XSize, 9, 0, 0, 0, 255)
191
#endplatform
192
193
// And then Draw the Round Name
194
// (Letters start at Sprite Frame 8)
195
TempValue0 = 8
196
while TempValue0 < Object.TextSize
197
DrawSpriteScreenXY(TempValue0, Object.TextPos, 80)
198
TempValue0++
199
loop
200
end if
201
202
end sub
203
204
205
sub ObjectStartup
206
// Load the Display sheet for the current Player
207
if Stage.PlayerListPos == PLAYER_SONIC_A // PLAYER_SONIC in origins
208
LoadSpriteSheet("Global/Display.gif")
209
end if
210
if Stage.PlayerListPos == PLAYER_TAILS_A // PLAYER_TAILS in origins
211
LoadSpriteSheet("Global/Display_t.gif")
212
end if
213
#platform: Use_Origins
214
if Stage.PlayerListPos == PLAYER_KNUCKLES
215
LoadSpriteSheet("Global/Display_k.gif")
216
end if
217
if Stage.PlayerListPos == PLAYER_AMY
218
LoadSpriteSheet("Global/Display_a.gif")
219
end if
220
#endplatform
221
222
SetMusicTrack("JP/DAGarden.ogg", 0, true)
223
224
Flower_TypeNo = TypeName[Flower]
225
Object[20].Type = TypeName[Title Card]
226
227
// Different Fade-In times depending on if this is a new level load or if the Player is warping in
228
if Warp.XPos > 0
229
// If the Player is warping in, have a shorter fade-in time
230
Object[20].Timer = 256
231
else
232
Object[20].Timer = 384
233
end if
234
235
// In the... Desert Dazzle boss Zone, set a Roof to be active...?
236
if Stage.ActNo == 3
237
Player.RoofBarrier = true
238
end if
239
240
// Make the Title Card always active, and have it draw above everything
241
Object[20].Priority = PRIORITY_ACTIVE
242
Object[20].DrawOrder = 6
243
244
// Set initial Bar & Text Positions
245
Object[20].BarPos = -216
246
Object[20].TextPos = 336
247
248
249
Object[20].CharPos = Screen.CenterX
250
Object[20].CharPos -= 160
251
252
if Object[20].CharPos > 3
253
Object[20].CharPos -= 4
254
end if
255
256
Object[20].CharPos &= 248
257
258
Object[20].TextPos += Object[20].CharPos
259
Object[20].TextPos += Object[20].CharPos
260
261
// "Desert Dazzle" is 12 letters long
262
Object[20].TextSize = 12
263
264
// Bump the value by 8 to correspond with the order of the Sprite Frames
265
Object[20].TextSize += 8
266
267
// Preserve the color used from the last fade. Fade_Colour is stored as RRGGBB, in hex
268
269
Object[20].FadeR = Fade_Colour
270
Object[20].FadeR >>= 16
271
272
Object[20].FadeG = Fade_Colour
273
Object[20].FadeG &= 0x00FF00
274
Object[20].FadeG >>= 8
275
276
Object[20].FadeB = Fade_Colour
277
Object[20].FadeB &= 0x0000FF
278
279
// 0 - Red Bar Frame
280
SpriteFrame(0, 0, 32, 200, 223, 1)
281
282
// 1-3 - Act Bubbles
283
SpriteFrame(96, 96, 48, 48, 41, 1)
284
SpriteFrame(96, 96, 48, 48, 90, 1)
285
SpriteFrame(96, 96, 48, 48, 139, 1)
286
287
// 4 - "Zone" text
288
SpriteFrame(64, 97, 48, 16, 41, 67)
289
290
// 5 - Main part of the "SONIC THE HEGDEHOG CD" bar
291
292
// Workaround for steam datafile to show this sprite correctly
293
#platform: Use_Origins
294
SpriteFrame(72, 81, 160, 16, 49, 50) // #5 - Sonic The Hedgehog CD
295
#endplatform
296
297
#platform: Use_Standalone
298
#platform: Standard
299
SpriteFrame(64, 81, 160, 16, 41, 50)// #5 - Sonic The Hedgehog CD
300
#endplatform
301
#endplatform
302
303
#platform: Use_Standalone
304
#platform: Mobile
305
SpriteFrame(72, 81, 160, 16, 49, 50)// #5 - Sonic The Hedgehog CD
306
#endplatform
307
#endplatform
308
309
// 6 - Continuation of the Sonic CD bar
310
SpriteFrame(16, 81, 160, 16, 41, 50)
311
312
// 7 - Set of three lines
313
SpriteFrame(100, 32, 24, 48, 188, 1)
314
315
// 8-19 - Individual letters spelling out Desert Dazzle
316
SpriteFrame(0, 0, 17, 55, 180, 133) // #8 - D
317
SpriteFrame(18, 32, 9, 23, 88, 84) // #9 - E
318
SpriteFrame(28, 32, 10, 23, 70, 108) // #10 - S
319
SpriteFrame(39, 32, 9, 23, 88, 84) // #11 - E
320
SpriteFrame(49, 32, 12, 23, 57, 108) // #12 - R
321
SpriteFrame(62, 32, 10, 23, 81, 108) // #13 - T
322
323
SpriteFrame(0, 56, 17, 55, 180, 133) // #14 - D
324
SpriteFrame(18, 56, 11, 23, 43, 84) // #15 - A
325
SpriteFrame(30, 56, 10, 23, 158, 108) // #16 - Z
326
SpriteFrame(41, 56, 10, 23, 158, 108) // #17 - Z
327
SpriteFrame(52, 56, 9, 23, 159, 84) // #18 - L
328
SpriteFrame(62, 56, 9, 23, 88, 84) // #19 - E
329
330
#platform: Use_Origins
331
// They copy pasted this through all the title cards. This script isn't even used and yet it's Mission-ready LOL
332
333
if game.playMode == BOOT_PLAYMODE_MISSION
334
TempValue0 = true
335
else
336
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
337
TempValue0 = true
338
else
339
TempValue0 = false
340
end if
341
end if
342
343
if TempValue0 != false
344
PlayMusic(0)
345
346
game.missionCondition = 0
347
game.missionEnd = false
348
349
Player.ControlMode = CONTROLMODE_NORMAL
350
Stage.TimeEnabled = true
351
352
ResetObjectEntity(20, TypeName[Blank Object], 0, 0, 0)
353
Warp.XPos = 0
354
end if
355
#endplatform
356
end sub
357
358
359
// ========================
360
// Editor Subs
361
// ========================
362
363
sub RSDKDraw
364
Object.TextSize = 12
365
Object.TextSize += 8
366
367
TempValue0 = 136
368
TempValue0 += Object.CharPos
369
TempValue0 <<= 16
370
371
TempValue1 = 0x500000
372
TempValue1 += Object.YPos
373
374
DrawSpriteXY(0, Object.XPos, Object.YPos)
375
DrawSpriteXY(Stage.ActNo, Object.XPos, TempValue1)
376
DrawSpriteXY(4, Object.XPos, TempValue1)
377
DrawSpriteXY(5, Object.XPos, TempValue1)
378
DrawSpriteXY(6, Object.XPos, TempValue1)
379
DrawSpriteXY(7, Object.XPos, TempValue1)
380
381
TempValue0 = 8
382
while TempValue0 < Object.TextSize
383
DrawSpriteXY(TempValue0, Object.XPos, TempValue1)
384
TempValue0++
385
loop
386
end sub
387
388
389
sub RSDKLoad
390
LoadSpriteSheet("Global/Display.gif")
391
// 0 - Red Bar Frame
392
SpriteFrame(0, 0, 32, 200, 223, 1)
393
394
// 1-3 - Act Bubbles
395
SpriteFrame(96, 96, 48, 48, 41, 1)
396
SpriteFrame(96, 96, 48, 48, 90, 1)
397
SpriteFrame(96, 96, 48, 48, 139, 1)
398
399
// 4 - "Zone" text
400
SpriteFrame(64, 97, 48, 16, 41, 67)
401
402
// 5 - Main part of the "SONIC THE HEGDEHOG CD" bar
403
SpriteFrame(64, 81, 160, 16, 41, 50)
404
405
// 6 - Continuation of the Sonic CD bar
406
SpriteFrame(16, 81, 160, 16, 41, 50)
407
408
// 7 - Set of three lines
409
SpriteFrame(100, 32, 24, 48, 188, 1)
410
411
// 8-19 - Individual letters spelling out Desert Dazzle
412
SpriteFrame(0, 0, 17, 55, 180, 133) // #8 - D
413
SpriteFrame(18, 32, 9, 23, 88, 84) // #9 - E
414
SpriteFrame(28, 32, 10, 23, 70, 108) // #10 - S
415
SpriteFrame(39, 32, 9, 23, 88, 84) // #11 - E
416
SpriteFrame(49, 32, 12, 23, 57, 108) // #12 - R
417
SpriteFrame(62, 32, 10, 23, 81, 108) // #13 - T
418
419
SpriteFrame(0, 56, 17, 55, 180, 133) // #14 - D
420
SpriteFrame(18, 56, 11, 23, 43, 84) // #15 - A
421
SpriteFrame(30, 56, 10, 23, 158, 108) // #16 - Z
422
SpriteFrame(41, 56, 10, 23, 158, 108) // #17 - Z
423
SpriteFrame(52, 56, 9, 23, 159, 84) // #18 - L
424
SpriteFrame(62, 56, 9, 23, 88, 84) // #19 - E
425
426
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
427
end sub
428
429