Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/TitleCards/R9_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
33
// Time Period Aliases
34
#alias 0 : TIME_PRESENT
35
#alias 1 : TIME_PAST
36
#alias 2 : TIME_GOOD_FUTURE
37
#alias 3 : TIME_BAD_FUTURE
38
39
40
// ControlMode Aliases
41
#alias -1 : CONTROLMODE_NONE
42
#alias 0 : CONTROLMODE_NORMAL
43
44
// Priority
45
#alias 1 : PRIORITY_ACTIVE
46
47
48
sub ObjectPlayerInteraction
49
Player.Timer = 0
50
end sub
51
52
53
sub ObjectDraw
54
switch Object.State
55
case TITLECARD_FADEIN
56
Player.ControlMode = CONTROLMODE_NONE
57
Player.Up = false
58
Player.Down = false
59
Player.Left = false
60
Player.Right = false
61
Player.JumpPress = false
62
Player.JumpHold = false
63
64
// Check if the player comes from warping, if not, blank speed
65
if Warp.XPos < 1
66
Player.Speed = 0
67
end if
68
69
if Object.Timer > 0
70
if Object.Timer == 256
71
PlayMusic(0)
72
if Warp.XPos > 0
73
// Restore values post-warp
74
Player.XPos = Warp.XPos
75
Player.YPos = Warp.YPos
76
77
Player.XVelocity = Warp.XVelocity
78
Player.YVelocity = Warp.YVelocity
79
Player.Speed = Warp.XVelocity
80
81
Player.State = Warp.State
82
83
Stage.MilliSeconds = Rec_Milliseconds
84
Stage.Seconds = Rec_Seconds
85
Stage.Minutes = Rec_Minutes
86
87
Player.InvincibleTimer = 8000
88
end if
89
Warp.Timer = 0
90
Warp.Frame = 0
91
end if
92
93
SetScreenFade(Object.FadeR, Object.FadeG, Object.FadeB, Object.Timer)
94
Object.Timer -= 8
95
else
96
Fade_Colour = 0
97
98
// the title card animation doesn't play out if you come from a warp or restarted from a checkpoint
99
CheckEqual(Warp.XPos, 0)
100
TempValue0 = CheckResult
101
CheckLower(LampPost.Check, 32)
102
TempValue0 &= CheckResult
103
if TempValue0 == true
104
Object.State = TITLECARD_SLIDEIN
105
Object.Timer = 0
106
else
107
Player.ControlMode = CONTROLMODE_NORMAL
108
Stage.TimeEnabled = true
109
110
ResetObjectEntity(20, TypeName[Blank Object], 0, 0, 0)
111
Warp.XPos = 0
112
end if
113
end if
114
break
115
116
case TITLECARD_SLIDEIN
117
TempValue0 = 144
118
TempValue0 += Object.CharPos
119
120
if Object.TextPos > TempValue0
121
// Slide the text to the left
122
Object.TextPos -= 8
123
else
124
if Object.BarPos == 0
125
Object.State = TITLECARD_DISPLAY
126
end if
127
end if
128
129
if Object.BarPos < 0
130
// Move the Bar down
131
Object.BarPos += 8
132
end if
133
break
134
135
case TITLECARD_DISPLAY
136
// Hold for a moment to let the Player see what a nice Title Card this is
137
138
if Object.Timer == 90
139
// Time's up, start sliding out!
140
Object.State = TITLECARD_SLIDEOUT
141
else
142
Object.Timer++
143
end if
144
break
145
146
case TITLECARD_SLIDEOUT
147
if Object.TextPos < 408
148
149
// Move the text to the right, and...
150
Object.TextPos += 16
151
152
// ...move the bar upwards as well
153
Object.BarPos -= 16
154
155
else
156
// Free Sonic's control, and enable the stage timer.
157
Player.ControlMode = CONTROLMODE_NORMAL
158
Stage.TimeEnabled = true
159
160
// The Title Card's job is done, despawn it
161
ResetObjectEntity(20, TypeName[Blank Object], 0, 0, 0)
162
Warp.XPos = 0
163
end if
164
break
165
166
end switch
167
168
// Before drawing, make sure this object hasn't been blanked already
169
// (Under certain circumstances, this can otherwise cause major graphical issues!!)
170
if Object.Type > TypeName[Blank Object]
171
TempValue0 = 136
172
TempValue0 += Object.CharPos
173
174
// Draw the Red Bar
175
DrawSpriteScreenXY(0, TempValue0, Object.BarPos)
176
177
// And then, draw the act number
178
DrawSpriteScreenXY(Stage.ActNo, Object.TextPos, 80)
179
180
// And then draw the Zone text, the Sonic CD bar, and the weird three lines
181
DrawSpriteScreenXY(4, Object.TextPos, 80)
182
DrawSpriteScreenXY(5, Object.TextPos, 80)
183
DrawSpriteScreenXY(6, Object.TextPos, 80)
184
DrawSpriteScreenXY(7, Object.TextPos, 80)
185
186
#platform: Use_Decomp // Creates a black rectangle that fills the empty space on wider resolutions
187
Tempvalue0 = Object.TextPos
188
TempValue0 += 220
189
DrawRect(TempValue0, 163, Screen.XSize, 9, 0, 0, 0, 255)
190
#endplatform
191
192
// And then Draw the Round Name
193
// (Letters start at Sprite Frame 8)
194
TempValue0 = 8
195
while TempValue0 < Object.TextSize
196
DrawSpriteScreenXY(TempValue0, Object.TextPos, 80)
197
TempValue0++
198
loop
199
end if
200
201
end sub
202
203
204
sub ObjectStartup
205
206
// Load the Display sheet for the current Player
207
if Stage.PlayerListPos == PLAYER_SONIC_A
208
LoadSpriteSheet("Global/Display.gif")
209
else
210
LoadSpriteSheet("Global/Display_t.gif")
211
end if
212
213
// Set the music for the Stage
214
if Options.Soundtrack == OST_JP
215
SetMusicTrack("JP/FinalBoss.ogg", 0, 1)
216
else
217
SetMusicTrack("US/FinalBoss.ogg", 1, 1)
218
end if
219
220
Flower_TypeNo = TypeName[Flower]
221
Object[20].Type = TypeName[Title Card]
222
223
// Different Fade-In times depending on if this is a new level load or if the Player is warping in
224
if Warp.XPos > 0
225
// If the Player is warping in, have a shorter fade-in time
226
Object[20].Timer = 256
227
else
228
Object[20].Timer = 384
229
end if
230
231
// In the Final Fever Zone, set a Roof to be active
232
if Stage.ActNo == 3
233
Player.RoofBarrier = true
234
end if
235
236
// Make the Title Card always active, and have it draw above everything
237
Object[20].Priority = PRIORITY_ACTIVE
238
Object[20].DrawOrder = 6
239
240
// Set initial Bar & Text Positions
241
Object[20].BarPos = -216
242
Object[20].TextPos = 336
243
244
245
Object[20].CharPos = Screen.CenterX
246
Object[20].CharPos -= 160
247
248
if Object[20].CharPos > 3
249
Object[20].CharPos -= 4
250
end if
251
252
Object[20].CharPos &= 248
253
254
Object[20].TextPos += Object[20].CharPos
255
Object[20].TextPos += Object[20].CharPos
256
257
// "Final Fever" is 10 letters long
258
Object[20].TextSize = 10
259
260
// Bump the value by 8 to correspond with the order of the Sprite Frames
261
Object[20].TextSize += 8
262
263
// Preserve the color used from the last fade. Fade_Colour is stored as RRGGBB, in hex
264
265
Object[20].FadeR = Fade_Colour
266
Object[20].FadeR >>= 16
267
268
Object[20].FadeG = Fade_Colour
269
Object[20].FadeG &= 0x00FF00
270
Object[20].FadeG >>= 8
271
272
Object[20].FadeB = Fade_Colour
273
Object[20].FadeB &= 0x0000FF
274
275
// 0 - Red Bar Frame
276
SpriteFrame(0, 0, 32, 200, 223, 1)
277
278
// 1-3 - Act Bubbles
279
SpriteFrame(96, 96, 48, 48, 41, 1)
280
SpriteFrame(96, 96, 48, 48, 90, 1)
281
SpriteFrame(96, 96, 48, 48, 139, 1)
282
283
// 4 - "Zone" text
284
SpriteFrame(64, 97, 48, 16, 41, 67)
285
286
// This script has only been included in updated mobile versions, so we don't need to do any of the usual compatability shenanigans here :)
287
// 5 - Main part of the "SONIC THE HEGDEHOG CD" bar
288
SpriteFrame(72, 81, 160, 16, 49, 50)
289
290
// 6 - Continuation of the Sonic CD bar
291
SpriteFrame(16, 81, 160, 16, 41, 50)
292
293
// 7 - Set of three lines
294
SpriteFrame(100, 32, 24, 48, 188, 1)
295
296
// 8-17 - Individual letters spelling out Final Fever
297
SpriteFrame(0, 0, 16, 55, 198, 133) // #8 - F
298
SpriteFrame(17, 32, 6, 23, 169, 108) // #9 - I
299
SpriteFrame(24, 32, 11, 23, 187, 84) // #10 - N
300
SpriteFrame(36, 32, 11, 23, 43, 84) // #11 - A
301
SpriteFrame(48, 32, 9, 23, 159, 84) // #12 - L
302
303
SpriteFrame(0, 56, 16, 55, 198, 133) // #13 - F
304
SpriteFrame(17, 56, 9, 23, 88, 84) // #14 - E
305
SpriteFrame(27, 56, 11, 23, 104, 108) // #15 - V
306
SpriteFrame(39, 56, 9, 23, 88, 84) // #16 - E
307
SpriteFrame(49, 56, 12, 23, 57, 108) // #17 - R
308
309
// This script doesn't have the Origins Mission/Boss Rush code since this file doesn't even exist in that version
310
// (It's likely that it's there in the original source though, given R2 and SS have it too, but we can't really verify that since they didn't include any R91C folder in Origins...)
311
end sub
312
313
314
// ========================
315
// Editor Subs
316
// ========================
317
318
sub RSDKDraw
319
Object.TextSize = 10
320
Object.TextSize += 8
321
322
TempValue0 = 136
323
TempValue0 += Object.CharPos
324
TempValue0 <<= 16
325
326
TempValue1 = 0x500000
327
TempValue1 += Object.YPos
328
329
DrawSpriteXY(0, Object.XPos, Object.YPos)
330
DrawSpriteXY(Stage.ActNo, Object.XPos, TempValue1)
331
DrawSpriteXY(4, Object.XPos, TempValue1)
332
DrawSpriteXY(5, Object.XPos, TempValue1)
333
DrawSpriteXY(6, Object.XPos, TempValue1)
334
DrawSpriteXY(7, Object.XPos, TempValue1)
335
336
TempValue0 = 8
337
while TempValue0 < Object.TextSize
338
DrawSpriteXY(TempValue0, Object.XPos, TempValue1)
339
TempValue0++
340
loop
341
end sub
342
343
344
sub RSDKLoad
345
LoadSpriteSheet("Global/Display.gif")
346
// 0 - Red Bar Frame
347
SpriteFrame(0, 0, 32, 200, 223, 1)
348
349
// 1-3 - Act Bubbles
350
SpriteFrame(96, 96, 48, 48, 41, 1)
351
SpriteFrame(96, 96, 48, 48, 90, 1)
352
SpriteFrame(96, 96, 48, 48, 139, 1)
353
354
// 4 - "Zone" text
355
SpriteFrame(64, 97, 48, 16, 41, 67)
356
357
// 5 - Main part of the "SONIC THE HEGDEHOG CD" bar
358
SpriteFrame(64, 81, 160, 16, 41, 50)
359
360
// 6 - Continuation of the Sonic CD bar
361
SpriteFrame(16, 81, 160, 16, 41, 50)
362
363
// 7 - Set of three lines
364
SpriteFrame(100, 32, 24, 48, 188, 1)
365
366
// 8-17 - Individual letters spelling out Final Fever
367
SpriteFrame(0, 0, 16, 55, 198, 133) // #8 - F
368
SpriteFrame(17, 32, 6, 23, 169, 108) // #9 - I
369
SpriteFrame(24, 32, 11, 23, 187, 84) // #10 - N
370
SpriteFrame(36, 32, 11, 23, 43, 84) // #11 - A
371
SpriteFrame(48, 32, 9, 23, 159, 84) // #12 - L
372
373
SpriteFrame(0, 56, 16, 55, 198, 133) // #13 - F
374
SpriteFrame(17, 56, 9, 23, 88, 84) // #14 - E
375
SpriteFrame(27, 56, 11, 23, 104, 108) // #15 - V
376
SpriteFrame(39, 56, 9, 23, 88, 84) // #16 - E
377
SpriteFrame(49, 56, 12, 23, 57, 108) // #17 - R
378
379
380
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
381
end sub
382
383