Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/TitleCards/R4_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
125
// Now, this part got changed in an update
126
127
else
128
// -> Updated version - both the text AND the bar have to be on screen for the title card to progress
129
130
if Object.BarPos == 0
131
Object.State = TITLECARD_DISPLAY
132
end if
133
end if
134
135
if Object.BarPos < 0
136
// Move the Bar down
137
Object.BarPos += 8
138
139
// There used to be code here in older versions, but not anymore...
140
// -> Initial version - only the bar needed to be in the proper position for the title card to continue
141
// This had text get incorrectly often
142
143
end if
144
break
145
146
case TITLECARD_DISPLAY
147
// Hold for a moment to let the Player see what a nice Title Card this is
148
149
if Object.Timer == 90
150
// Time's up, start sliding out!
151
Object.State = TITLECARD_SLIDEOUT
152
else
153
Object.Timer++
154
end if
155
break
156
157
case TITLECARD_SLIDEOUT
158
if Object.TextPos < 408
159
160
// Move the text to the right, and...
161
Object.TextPos += 16
162
163
// ...move the bar upwards as well
164
Object.BarPos -= 16
165
166
else
167
// Free Sonic's control, and enable the stage timer.
168
Player.ControlMode = CONTROLMODE_NORMAL
169
Stage.TimeEnabled = true
170
171
// The Title Card's job is done, despawn it
172
ResetObjectEntity(20, TypeName[Blank Object], 0, 0, 0)
173
Warp.XPos = 0
174
end if
175
break
176
177
end switch
178
179
// Before drawing, make sure this object hasn't been blanked already
180
// (Under certain circumstances, this can otherwise cause major graphical issues!!)
181
if Object.Type > TypeName[Blank Object]
182
TempValue0 = 136
183
TempValue0 += Object.CharPos
184
185
// Draw the Red Bar
186
DrawSpriteScreenXY(0, TempValue0, Object.BarPos)
187
188
// And then, draw the act number
189
DrawSpriteScreenXY(Stage.ActNo, Object.TextPos, 80)
190
191
// And then draw the Zone text, the Sonic CD bar, and the weird three lines
192
DrawSpriteScreenXY(4, Object.TextPos, 80)
193
DrawSpriteScreenXY(5, Object.TextPos, 80)
194
DrawSpriteScreenXY(6, Object.TextPos, 80)
195
DrawSpriteScreenXY(7, Object.TextPos, 80)
196
197
#platform: Use_Decomp // Creates a black rectangle that fills the empty space on wider resolutions
198
Tempvalue0 = Object.TextPos
199
TempValue0 += 220
200
DrawRect(TempValue0, 163, Screen.XSize, 9, 0, 0, 0, 255)
201
#endplatform
202
203
// And then Draw the Round Name
204
// (Letters start at Sprite Frame 8)
205
TempValue0 = 8
206
while TempValue0 < Object.TextSize
207
DrawSpriteScreenXY(TempValue0, Object.TextPos, 80)
208
TempValue0++
209
loop
210
end if
211
212
end sub
213
214
215
sub ObjectStartup
216
// Load the Display sheet for the current Player
217
if Stage.PlayerListPos == PLAYER_SONIC_A // PLAYER_SONIC in origins
218
LoadSpriteSheet("Global/Display.gif")
219
end if
220
if Stage.PlayerListPos == PLAYER_TAILS_A // PLAYER_TAILS in origins
221
LoadSpriteSheet("Global/Display_t.gif")
222
end if
223
#platform: Use_Origins
224
if Stage.PlayerListPos == PLAYER_KNUCKLES
225
LoadSpriteSheet("Global/Display_k.gif")
226
end if
227
if Stage.PlayerListPos == PLAYER_AMY
228
LoadSpriteSheet("Global/Display_a.gif")
229
end if
230
#endplatform
231
232
// Set the music for the Stage
233
if Options.Soundtrack == OST_JP
234
switch HUD.CurrentTimePeriod
235
case TIME_PRESENT
236
SetMusicTrack("JP/R4A.ogg", 0, 1)
237
break
238
case TIME_PAST
239
SetMusicTrack("R4B.ogg", 0, 1)
240
break
241
case TIME_GOOD_FUTURE
242
SetMusicTrack("JP/R4C.ogg", 0, 1)
243
break
244
case TIME_BAD_FUTURE
245
SetMusicTrack("JP/R4D.ogg", 0, 1)
246
break
247
end switch
248
else
249
switch HUD.CurrentTimePeriod
250
case TIME_PRESENT
251
SetMusicTrack("US/R4A.ogg", 0, 415148)
252
break
253
case TIME_PAST
254
SetMusicTrack("R4B.ogg", 0, 1)
255
break
256
case TIME_GOOD_FUTURE
257
SetMusicTrack("US/R4C.ogg", 0, 1)
258
break
259
case TIME_BAD_FUTURE
260
SetMusicTrack("US/R4D.ogg", 0, 145616)
261
break
262
end switch
263
end if
264
265
Flower_TypeNo = TypeName[Flower]
266
Object[20].Type = TypeName[Title Card]
267
268
// Different Fade-In times depending on if this is a new level load or if the Player is warping in
269
if Warp.XPos > 0
270
// If the Player is warping in, have a shorter fade-in time
271
Object[20].Timer = 256
272
else
273
Object[20].Timer = 384
274
end if
275
276
// In the first act of Tidal Tempest, set a Roof to be active
277
if Stage.ActNo == 1
278
Player.RoofBarrier = true
279
end if
280
281
// Make the Title Card always active, and have it draw above everything
282
Object[20].Priority = PRIORITY_ACTIVE
283
Object[20].DrawOrder = 6
284
285
// Set initial Bar & Text Positions
286
Object[20].BarPos = -216
287
Object[20].TextPos = 336
288
289
290
Object[20].CharPos = Screen.CenterX
291
Object[20].CharPos -= 160
292
293
if Object[20].CharPos > 3
294
Object[20].CharPos -= 4
295
end if
296
297
Object[20].CharPos &= 248
298
299
Object[20].TextPos += Object[20].CharPos
300
Object[20].TextPos += Object[20].CharPos
301
302
// "Tidal Tempest" is 12 letters long
303
Object[20].TextSize = 12
304
305
// Bump the value by 8 to correspond with the order of the Sprite Frames
306
Object[20].TextSize += 8
307
308
// Preserve the color used from the last fade. Fade_Colour is stored as RRGGBB, in hex
309
310
Object[20].FadeR = Fade_Colour
311
Object[20].FadeR >>= 16
312
313
Object[20].FadeG = Fade_Colour
314
Object[20].FadeG &= 0x00FF00
315
Object[20].FadeG >>= 8
316
317
Object[20].FadeB = Fade_Colour
318
Object[20].FadeB &= 0x0000FF
319
320
// 0 - Red Bar Frame
321
SpriteFrame(0, 0, 32, 200, 223, 1)
322
323
// 1-3 - Act Bubbles
324
SpriteFrame(96, 96, 48, 48, 41, 1)
325
SpriteFrame(96, 96, 48, 48, 90, 1)
326
SpriteFrame(96, 96, 48, 48, 139, 1)
327
328
// 4 - "Zone" text
329
SpriteFrame(64, 97, 48, 16, 41, 67)
330
331
// 5 - Main part of the "SONIC THE HEGDEHOG CD" bar
332
333
// Workaround for steam datafile to show this sprite correctly
334
#platform: Use_Origins
335
SpriteFrame(72, 81, 160, 16, 49, 50) // #5 - Sonic The Hedgehog CD
336
#endplatform
337
338
#platform: Use_Standalone
339
#platform: Standard
340
SpriteFrame(64, 81, 160, 16, 41, 50)// #5 - Sonic The Hedgehog CD
341
#endplatform
342
#endplatform
343
344
#platform: Use_Standalone
345
#platform: Mobile
346
SpriteFrame(72, 81, 160, 16, 49, 50)// #5 - Sonic The Hedgehog CD
347
#endplatform
348
#endplatform
349
350
// 6 - Continuation of the Sonic CD bar
351
SpriteFrame(16, 81, 160, 16, 41, 50)
352
353
// 7 - Set of three lines
354
SpriteFrame(100, 32, 24, 48, 188, 1)
355
356
// 8-19 - Individual letters spelling out Tidal Tempest
357
SpriteFrame(0, 0, 16, 56, 83, 132) // #8 - T
358
SpriteFrame(12, 33, 6, 23, 169, 108) // #9 - I
359
SpriteFrame(19, 33, 11, 23, 76, 84) // #10 - D
360
SpriteFrame(31, 33, 11, 23, 43, 84) // #11 - A
361
SpriteFrame(43, 33, 9, 23, 159, 84) // #12 - L
362
363
SpriteFrame(0, 56, 16, 56, 83, 132) // #13 - T
364
SpriteFrame(16, 57, 9, 23, 88, 84) // #14 - E
365
SpriteFrame(26, 57, 17, 23, 169, 84) // #15 - M
366
SpriteFrame(44, 57, 10, 23, 211, 84) // #16 - P
367
SpriteFrame(54, 57, 9, 23, 88, 84) // #17 - E
368
SpriteFrame(63, 57, 10, 23, 70, 108) // #18 - S
369
SpriteFrame(73, 57, 10, 23, 81, 108) // #19 - T
370
371
372
#platform: Use_Origins
373
if game.playMode == BOOT_PLAYMODE_MISSION
374
TempValue0 = true
375
else
376
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
377
TempValue0 = true
378
else
379
TempValue0 = false
380
end if
381
end if
382
383
if TempValue0 != false
384
PlayMusic(0)
385
386
game.missionCondition = 0
387
game.missionEnd = false
388
389
Player.ControlMode = CONTROLMODE_NORMAL
390
Stage.TimeEnabled = true
391
392
ResetObjectEntity(20, TypeName[Blank Object], 0, 0, 0)
393
Warp.XPos = 0
394
end if
395
#endplatform
396
end sub
397
398
399
// ========================
400
// Editor Subs
401
// ========================
402
403
sub RSDKDraw
404
Object.TextSize = 12
405
Object.TextSize += 8
406
407
TempValue0 = 136
408
TempValue0 += Object.CharPos
409
TempValue0 <<= 16
410
411
TempValue1 = 0x500000
412
TempValue1 += Object.YPos
413
414
DrawSpriteXY(0, Object.XPos, Object.YPos)
415
DrawSpriteXY(Stage.ActNo, Object.XPos, TempValue1)
416
DrawSpriteXY(4, Object.XPos, TempValue1)
417
DrawSpriteXY(5, Object.XPos, TempValue1)
418
DrawSpriteXY(6, Object.XPos, TempValue1)
419
DrawSpriteXY(7, Object.XPos, TempValue1)
420
421
TempValue0 = 8
422
while TempValue0 < Object.TextSize
423
DrawSpriteXY(TempValue0, Object.XPos, TempValue1)
424
TempValue0++
425
loop
426
end sub
427
428
429
sub RSDKLoad
430
LoadSpriteSheet("Global/Display.gif")
431
// 0 - Red Bar Frame
432
SpriteFrame(0, 0, 32, 200, 223, 1)
433
434
// 1-3 - Act Bubbles
435
SpriteFrame(96, 96, 48, 48, 41, 1)
436
SpriteFrame(96, 96, 48, 48, 90, 1)
437
SpriteFrame(96, 96, 48, 48, 139, 1)
438
439
// 4 - "Zone" text
440
SpriteFrame(64, 97, 48, 16, 41, 67)
441
442
// 5 - Main part of the "SONIC THE HEGDEHOG CD" bar
443
SpriteFrame(64, 81, 160, 16, 41, 50)
444
445
// 6 - Continuation of the Sonic CD bar
446
SpriteFrame(16, 81, 160, 16, 41, 50)
447
448
// 7 - Set of three lines
449
SpriteFrame(100, 32, 24, 48, 188, 1)
450
451
// 8-19 - Individual letters spelling out Tidal Tempest
452
SpriteFrame(0, 0, 16, 56, 83, 132) // #8 - T
453
SpriteFrame(12, 33, 6, 23, 169, 108) // #9 - I
454
SpriteFrame(19, 33, 11, 23, 76, 84) // #10 - D
455
SpriteFrame(31, 33, 11, 23, 43, 84) // #11 - A
456
SpriteFrame(43, 33, 9, 23, 159, 84) // #12 - L
457
458
SpriteFrame(0, 56, 16, 56, 83, 132) // #13 - T
459
SpriteFrame(16, 57, 9, 23, 88, 84) // #14 - E
460
SpriteFrame(26, 57, 17, 23, 169, 84) // #15 - M
461
SpriteFrame(44, 57, 10, 23, 211, 84) // #16 - P
462
SpriteFrame(54, 57, 9, 23, 88, 84) // #17 - E
463
SpriteFrame(63, 57, 10, 23, 70, 108) // #18 - S
464
SpriteFrame(73, 57, 10, 23, 81, 108) // #19 - T
465
466
467
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
468
end sub
469
470