Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Title/Start.txt
1319 views
1
//---------------------Sonic CD Start Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Fade
7
#alias Object.Value1 : Object.StageSelectCheatPos
8
#alias Object.Value2 : Object.SoundTestCheatPos
9
#alias Object.Value3 : Object.DemoTimer
10
11
// States
12
#alias 0 : START_SETUP
13
#alias 1 : START_GOTO_MENU
14
#alias 2 : START_GOTO_STAGESELECT // Unused
15
#alias 3 : START_GOTO_SOUNDTEST // Unused
16
#alias 4 : START_GOTO_DEMO
17
18
// Cheat Input Aliases
19
#alias 0 : CHEATINPUT_NONE
20
#alias 1 : CHEATINPUT_UP
21
#alias 2 : CHEATINPUT_DOWN
22
#alias 3 : CHEATINPUT_LEFT
23
#alias 4 : CHEATINPUT_RIGHT
24
#alias 5 : CHEATINPUT_BUTTONA
25
#alias 6 : CHEATINPUT_BUTTONB
26
#alias 7 : CHEATINPUT_BUTTONC
27
28
// DemoNumber Aliases
29
#alias 0 : DEMO_R11A
30
#alias 1 : DEMO_SS1
31
#alias 2 : DEMO_R43C
32
#alias 3 : DEMO_SS6
33
#alias 4 : DEMO_R82A
34
#alias 5 : DEMO_MAX
35
36
// Select Aliases
37
#alias 0 : SELECT_INIT
38
39
// Global SFX
40
#alias 1 : SFX_G_RING
41
#alias 27 : SFX_G_SELECT
42
43
// Callbacks & Engine States
44
#alias 1 : CALLBACK_PRESS_START
45
#alias 7 : CALLBACK_EXIT_SELECTED
46
#alias 16 : CALLBACK_MOREGAMES
47
48
// Game Mode Aliases
49
#alias 0 : MODE_NOSAVE
50
51
// Language Aliases
52
#alias 0 : LANG_ENGLISH
53
#alias 1 : LANG_FRENCH
54
#alias 2 : LANG_ITALIAN
55
#alias 3 : LANG_DEUTSCH
56
#alias 4 : LANG_SPANISH
57
#alias 5 : LANG_JAPANESE
58
59
// Presentation Stages
60
#alias 1 : STAGE_P_MENU
61
#alias 3 : STAGE_P_STAGESELECT
62
#alias 4 : STAGE_P_SOUNDTEST
63
64
// Regular Stages
65
#alias 0 : STAGE_R_R11A
66
#alias 28 : STAGE_R_R43C
67
#alias 64 : STAGE_R_R82A
68
69
// Special Stages
70
#alias 0 : STAGE_S_SS1
71
#alias 5 : STAGE_S_SS6
72
73
// Device Type
74
#alias 0 : RETRO_STANDARD
75
76
// Entirely functional, yet unused
77
// Perhaps it was removed because it would devalue unlocking things in Time Attack?
78
// No way to say for sure
79
#function TouchStart_HandleCheatCodes
80
81
82
function TouchStart_HandleCheatCodes
83
TempValue0 = CHEATINPUT_NONE
84
85
if KeyPress[0].Up == true
86
TempValue0 = CHEATINPUT_UP
87
end if
88
89
if KeyPress[0].Down == true
90
TempValue0 = CHEATINPUT_DOWN
91
end if
92
93
if KeyPress[0].Left == true
94
TempValue0 = CHEATINPUT_LEFT
95
end if
96
97
if KeyPress[0].Right == true
98
TempValue0 = CHEATINPUT_RIGHT
99
end if
100
101
if KeyPress[0].ButtonA == true
102
TempValue0 = CHEATINPUT_BUTTONA
103
end if
104
105
if KeyPress[0].ButtonB == true
106
TempValue0 = CHEATINPUT_BUTTONB
107
end if
108
109
if KeyPress[0].ButtonC == true
110
TempValue0 = CHEATINPUT_BUTTONC
111
end if
112
113
// Up, Down, Down, Left, Right, B
114
switch Object.StageSelectCheatPos
115
case 0
116
if TempValue0 == CHEATINPUT_UP
117
Object.StageSelectCheatPos++
118
else
119
if TempValue0 != CHEATINPUT_NONE
120
Object.StageSelectCheatPos = 0
121
end if
122
end if
123
break
124
125
case 1
126
if TempValue0 == CHEATINPUT_DOWN
127
Object.StageSelectCheatPos++
128
else
129
if TempValue0 != CHEATINPUT_NONE
130
Object.StageSelectCheatPos = 0
131
end if
132
end if
133
break
134
135
case 2
136
if TempValue0 == CHEATINPUT_DOWN
137
Object.StageSelectCheatPos++
138
else
139
if TempValue0 != CHEATINPUT_NONE
140
Object.StageSelectCheatPos = 0
141
end if
142
end if
143
break
144
145
case 3
146
if TempValue0 == CHEATINPUT_LEFT
147
Object.StageSelectCheatPos++
148
else
149
if TempValue0 != CHEATINPUT_NONE
150
Object.StageSelectCheatPos = 0
151
end if
152
end if
153
break
154
155
case 4
156
if TempValue0 == CHEATINPUT_RIGHT
157
Object.StageSelectCheatPos++
158
else
159
if TempValue0 != CHEATINPUT_NONE
160
Object.StageSelectCheatPos = 0
161
end if
162
end if
163
break
164
165
case 5
166
if TempValue0 == CHEATINPUT_BUTTONB
167
Object.StageSelectCheatPos = 0
168
169
// Go to the Stage Select
170
Object.State = START_GOTO_STAGESELECT
171
StopMusic()
172
173
// Just a cool lil' jingle :)
174
PlaySfx(SFX_G_RING, false)
175
else
176
if TempValue0 != CHEATINPUT_NONE
177
Object.StageSelectCheatPos = 0
178
end if
179
end if
180
break
181
end switch
182
183
// Down, Down, Down, Left, Right, A
184
switch Object.SoundTestCheatPos
185
case 0
186
if TempValue0 == CHEATINPUT_DOWN
187
Object.SoundTestCheatPos++
188
else
189
if TempValue0 != CHEATINPUT_NONE
190
Object.SoundTestCheatPos = 0
191
end if
192
end if
193
break
194
195
case 1
196
if TempValue0 == CHEATINPUT_DOWN
197
Object.SoundTestCheatPos++
198
else
199
if TempValue0 != CHEATINPUT_NONE
200
Object.SoundTestCheatPos = 0
201
end if
202
end if
203
break
204
205
case 2
206
if TempValue0 == CHEATINPUT_DOWN
207
Object.SoundTestCheatPos++
208
else
209
if TempValue0 != CHEATINPUT_NONE
210
Object.SoundTestCheatPos = 0
211
end if
212
end if
213
break
214
215
case 3
216
if TempValue0 == CHEATINPUT_LEFT
217
Object.SoundTestCheatPos++
218
else
219
if TempValue0 != CHEATINPUT_NONE
220
Object.SoundTestCheatPos = 0
221
end if
222
end if
223
break
224
225
case 4
226
if TempValue0 == CHEATINPUT_RIGHT
227
Object.SoundTestCheatPos++
228
else
229
if TempValue0 != CHEATINPUT_NONE
230
Object.SoundTestCheatPos = 0
231
end if
232
end if
233
break
234
235
case 5
236
if TempValue0 == CHEATINPUT_BUTTONA
237
Object.SoundTestCheatPos = 0
238
239
// Go to the Sound Test
240
Object.State = START_GOTO_SOUNDTEST
241
StopMusic()
242
243
PlaySfx(SFX_G_RING, false)
244
else
245
if TempValue0 != CHEATINPUT_NONE
246
Object.SoundTestCheatPos = 0
247
end if
248
end if
249
break
250
end switch
251
end function
252
253
254
sub ObjectMain
255
#platform: Use_Origins
256
Menu.ExitFlag = true
257
#endplatform
258
259
switch Object.State
260
case START_SETUP
261
CheckTouchRect(0, 0, Screen.XSize, 240)
262
263
#platform: Use_Origins
264
// On Origins, you can back out if you really want to
265
if KeyPress[0].ButtonB == true
266
EngineCallback(NOTIFY_BACK_TO_MAINMENU)
267
end if
268
269
if KeyPress[0].Start == true
270
CheckResult = false
271
end if
272
273
if KeyPress[0].ButtonA == true
274
CheckResult = false
275
end if
276
277
if input.pressButton == true
278
CheckResult = false
279
end if
280
#endplatform
281
282
#platform: Use_Standalone
283
if KeyPress[0].Start == true
284
CheckResult = false
285
end if
286
#endplatform
287
288
if CheckResult > -1 // Check if you used the touch input, or if what's above is true
289
// The Player's (reportedly) interacted with the game in some form, so start the Select sequence
290
Object.State = START_GOTO_MENU // Select Menu
291
292
#platform: Use_Origins
293
Object[+1].Type = TypeName[Select]
294
Object[+1].iXPos = Screen.CenterX
295
Object[+1].iYPos = 200
296
Object[+1].State = SELECT_INIT
297
#endplatform
298
299
#platform: Use_Standalone
300
StopMusic()
301
PlaySfx(SFX_G_SELECT, false)
302
303
#endplatform
304
305
#platform: Use_Haptics
306
HapticEffect(31, 0, 0, 0)
307
#endplatform
308
else
309
Object.DemoTimer++
310
311
if Object.DemoTimer == 1550
312
Object.State = START_GOTO_DEMO
313
end if
314
end if
315
316
// I mean, if you want to I guess?
317
if Engine.PlatformID == RETRO_WP7
318
if KeyPress[0].ButtonB == true
319
EngineCallback(CALLBACK_EXIT_SELECTED)
320
end if
321
end if
322
break
323
324
case START_GOTO_MENU
325
// In Origins, this state does nothing and all the stuff in handled by the Select object instead
326
#platform: Use_Standalone
327
Object.Fade += 4
328
if Object.Fade == 384
329
Stage.ListPos = STAGE_P_MENU
330
LoadStage()
331
end if
332
333
SetScreenFade(0, 0, 0, Object.Fade)
334
#endplatform
335
break
336
337
case START_GOTO_STAGESELECT // This state is unused
338
Object.Fade += 4
339
340
if Object.Fade == 384
341
Options.GameMode = MODE_NOSAVE
342
Stage.ListPos = STAGE_P_STAGESELECT
343
LoadStage()
344
end if
345
346
SetScreenFade(0, 0, 0, Object.Fade)
347
break
348
349
case START_GOTO_SOUNDTEST // This state is also unused
350
Object.Fade += 4
351
352
if Object.Fade == 384
353
Options.GameMode = MODE_NOSAVE
354
Stage.ListPos = STAGE_P_SOUNDTEST
355
LoadStage()
356
end if
357
358
SetScreenFade(0, 0, 0, Object.Fade)
359
break
360
361
case START_GOTO_DEMO
362
Object.Fade += 4
363
364
if Object.Fade == 384
365
Engine.HapticsEnabled = false
366
367
Fade_Colour = 0x000000
368
369
// Reset loads of stuff
370
Player.Score = 0
371
Player.Lives = 3
372
Player.ScoreBonus = 50000
373
Transporter_Destroyed = false
374
MetalSonic_Destroyed = false
375
Good_Future = false
376
Options.GameMode = MODE_NOSAVE
377
Options.AttractMode = true
378
379
if Engine.PlatformID == RETRO_ANDROID
380
if Engine.TrialMode == true
381
Options.DemoNumber = 0
382
end if
383
end if
384
385
switch Options.DemoNumber
386
case DEMO_R11A
387
// R11A - Palmtree Panic Act 1, Present
388
Stage.ActiveList = REGULAR_STAGE
389
Stage.ListPos = STAGE_R_R11A
390
break
391
392
case DEMO_SS1
393
// SS1 - Special Stage 1
394
Stage.ActiveList = SPECIAL_STAGE
395
#platform: Use_Origins
396
Stage.ActiveList = 3
397
#endplatform
398
Stage.ListPos = STAGE_S_SS1
399
break
400
401
case DEMO_R43C
402
// R43C - Tidal Tempest 3, Good Future
403
Stage.ActiveList = REGULAR_STAGE
404
Stage.ListPos = STAGE_R_R43C
405
break
406
407
case DEMO_SS6
408
// SS6 - Special Stage 6
409
Stage.ActiveList = SPECIAL_STAGE
410
#platform: Use_Origins
411
Stage.ActiveList = 3
412
#endplatform
413
Stage.ListPos = STAGE_S_SS6
414
break
415
416
case DEMO_R82A
417
// R82A - Metallic Madness 2 Present
418
Stage.ActiveList = REGULAR_STAGE
419
Stage.ListPos = STAGE_R_R82A
420
break
421
end switch
422
423
// Cycle through the same 6 demos
424
Options.DemoNumber++
425
Options.DemoNumber %= 5
426
427
#platform: Use_Origins
428
// Sonic Team REALLY hates the concept of Amy being in attract demos
429
// The Sonic object already sets the player to him, so this is pretty redundant
430
if Stage.PlayerListPos == PLAYER_AMY
431
Stage.PlayerListPos = PLAYER_SONIC
432
end if
433
#endplatform
434
435
LoadStage()
436
end if
437
438
SetScreenFade(0, 0, 0, Object.Fade)
439
break
440
441
end switch
442
443
end sub
444
445
446
sub ObjectDraw
447
#platform: Use_Origins
448
// Don't display the following if the Select menu is open
449
if Object.State != START_GOTO_MENU
450
Object.AnimationTimer++
451
if Object.AnimationTimer > 59
452
Object.AnimationTimer = 0
453
end if
454
455
// If in the upper half of a second, then
456
if Object.AnimationTimer > 29
457
if Engine.DeviceType == RETRO_STANDARD
458
// On standard Platforms, display the "Press Button" text
459
DrawSprite(2)
460
else
461
// On mobile Platforms, display the corresponding language text for
462
// telling the player to tap the screen
463
DrawSprite(1)
464
end if
465
end if
466
end if
467
468
// Get the cordinates for the bottom right of the screen
469
TempValue0 = Screen.XSize
470
TempValue0 -= 22
471
472
TempValue1 = Screen.YSize
473
TempValue1 -= 12
474
475
// Draw the Sega copyright sprite there
476
DrawSpriteScreenXY(3, TempValue0, TempValue1)
477
#endplatform
478
479
#platform: Use_Standalone
480
Object.AnimationTimer++
481
if Object.AnimationTimer > 59
482
Object.AnimationTimer = 0
483
end if
484
#endplatform
485
486
#platform: Use_Standalone
487
#platform: Standard
488
if Object.AnimationTimer > 29
489
DrawSprite(0)
490
end if
491
#endplatform
492
#endplatform
493
494
#platform: Use_Standalone
495
#platform: Mobile
496
if Object.AnimationTimer > 29
497
DrawSprite(1)
498
end if
499
#endplatform
500
#endplatform
501
end sub
502
503
504
sub ObjectStartup
505
#platform: Use_Origins
506
game.callbackParam0 = false
507
EngineCallback(NOTIFY_LEVEL_SELECT_MENU)
508
#endplatform
509
LoadSpriteSheet("Title/Title.gif")
510
511
// The following Sprites differ between languages
512
513
// They follow the order of
514
// 0 - Press to Start
515
// 1 - Touch to Start!
516
517
// But of course in the language they correspond to
518
519
switch Engine.Language
520
case LANG_ENGLISH
521
case LANG_JAPANESE
522
SpriteFrame(-43, 0, 87, 11, 106, 103) // Press Start
523
SpriteFrame(-56, 0, 117, 11, 106, 91) // Touch to Start!
524
break
525
526
case LANG_FRENCH
527
SpriteFrame(-60, 0, 120, 11, 391, 387) // Appui sur Start
528
SpriteFrame(-94, 0, 189, 11, 322, 399) // Touche pour Commencer !
529
break
530
531
case LANG_ITALIAN
532
SpriteFrame(-44, 0, 88, 11, 270, 411) // Premi Start
533
SpriteFrame(-76, 0, 152, 11, 359, 411) // Tocca Per Iniziare!
534
break
535
536
case LANG_DEUTSCH
537
SpriteFrame(-52, -2, 106, 13, 405, 373) // Start Drücken
538
SpriteFrame(-87, 0, 175, 11, 336, 423) // Zum Starten Antippen!
539
break
540
541
case LANG_SPANISH
542
SpriteFrame(-43, 0, 87, 11, 274, 435) // Pulsa Start
543
SpriteFrame(-74, 0, 149, 11, 362, 435) // ¡Toca para Empezar!
544
break
545
end switch
546
547
SpriteFrame(-48, 0, 97, 11, 414, 361) // Press Button (Same sprite regardless of language)
548
SpriteFrame(-88, -8, 88, 8, 423, 311) // Sega Copyright text
549
end sub
550
551
552
// ========================
553
// Editor Subs
554
// ========================
555
556
sub RSDKDraw
557
DrawSprite(0)
558
end sub
559
560
561
sub RSDKLoad
562
LoadSpriteSheet("Title/Title.gif")
563
SpriteFrame(-43, 0, 87, 11, 106, 103) // LANG_ENGLISH "Press Start"
564
565
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
566
end sub
567
568