Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Menu/DemoMenu.txt
1319 views
1
//------------------Sonic CD Demo Menu Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
//---This Object is normally only used by Lite Data files-----//
5
6
// Aliases
7
#alias Object.Value0 : Object.Fade
8
#alias Object.Value1 : Object.CurrentButton
9
#alias Object.Value2 : Object.CurrentRecord
10
#alias Object.Value3 : Object.BossUnlockRecord
11
12
// MenuHeading Aliases
13
#alias Object[33].State : MenuHeading.State
14
#alias Object[33].PropertyValue : MenuHeading.Header
15
16
// MenuWindow Alias
17
#alias Object[-1].State : MenuWindow.State
18
19
// States
20
#alias 0 : DEMOMENU_FADEIN
21
#alias 1 : DEMOMENU_CONTROLS
22
#alias 2 : DEMOMENU_LEVEL_SELECTED
23
#alias 3 : DEMOMENU_BACK
24
#alias 4 : DEMOMENU_LEVEL_LOAD
25
26
// Menu Heading States
27
#alias 1 : MENUHEADING_LEAVE_SCREEN
28
#alias 2 : MENUHEADING_ENTER_SCREEN
29
30
// MenuButton States
31
#alias 1 : MENUBUTTON_BUTTONS_IN
32
33
// MenuWindow States
34
#alias 3 : MENUWINDOW_SHRINK
35
36
// MenuHeading PropertyValues
37
#alias 5 : MAINMENU_HEADER
38
39
// Presentation Stages
40
#alias 0 : STAGE_R_PPZ1A
41
#alias 34 : STAGE_R_QQZ2A
42
#alias 38 : STAGE_R_QQZ3C
43
44
// Global SFX
45
#alias 23 : SFX_G_MENUBUTTON
46
#alias 27 : SFX_G_SELECT
47
48
// Stage SFX
49
#alias 1 : SFX_S_BACKBUTTON
50
51
// Game Mode Aliases
52
#alias 3 : MODE_TRIAL
53
54
//SaveRAM Values
55
// 48 : PPZ1DemoRecord
56
// 49 : QQZ2DemoRecord
57
58
// Function declarations
59
#function DemoMenu_StageTimeRecord
60
#function DemoMenu_StageTotalTimeRecord
61
#function DemoMenu_StagePortraitMovement
62
63
64
function DemoMenu_StageTimeRecord
65
TempValue4 = TempValue0
66
TempValue4 += 4
67
TempValue2 = TempValue1
68
TempValue2 /= 6000
69
TempValue3 = TempValue2
70
TempValue3 /= 10
71
TempValue3 += 11
72
DrawSpriteScreenFX(TempValue3, FX_INK, TempValue4, 136)
73
74
TempValue4 += 6
75
TempValue3 = TempValue2
76
TempValue3 %= 10
77
TempValue3 += 11
78
DrawSpriteScreenFX(TempValue3, FX_INK, TempValue4, 136)
79
80
TempValue4 += 11
81
TempValue2 = TempValue1
82
TempValue2 /= 100
83
TempValue2 %= 60
84
TempValue3 = TempValue2
85
TempValue3 /= 10
86
TempValue3 += 11
87
DrawSpriteScreenFX(TempValue3, FX_INK, TempValue4, 136)
88
89
TempValue4 += 6
90
TempValue3 = TempValue2
91
TempValue3 %= 10
92
TempValue3 += 11
93
DrawSpriteScreenFX(TempValue3, FX_INK, TempValue4, 136)
94
95
TempValue4 += 13
96
TempValue2 = TempValue1
97
TempValue2 %= 100
98
TempValue3 = TempValue2
99
TempValue3 /= 10
100
TempValue3 += 11
101
DrawSpriteScreenFX(TempValue3, FX_INK, TempValue4, 136)
102
103
TempValue4 += 6
104
TempValue3 = TempValue2
105
TempValue3 %= 10
106
TempValue3 += 11
107
DrawSpriteScreenFX(TempValue3, FX_INK, TempValue4, 136)
108
end function
109
110
111
function DemoMenu_StageTotalTimeRecord
112
TempValue4 = TempValue0
113
TempValue2 = TempValue1
114
TempValue2 /= 6000
115
TempValue3 = TempValue2
116
TempValue3 /= 10
117
TempValue3 += Object.Frame
118
DrawSpriteScreenFX(TempValue3, FX_INK, TempValue4, 155)
119
120
TempValue4 += 8
121
TempValue3 = TempValue2
122
TempValue3 %= 10
123
TempValue3 += Object.Frame
124
DrawSpriteScreenFX(TempValue3, FX_INK, TempValue4, 155)
125
126
TempValue4 += 15
127
TempValue2 = TempValue1
128
TempValue2 /= 100
129
TempValue2 %= 60
130
TempValue3 = TempValue2
131
TempValue3 /= 10
132
TempValue3 += Object.Frame
133
DrawSpriteScreenFX(TempValue3, FX_INK, TempValue4, 155)
134
135
TempValue4 += 8
136
TempValue3 = TempValue2
137
TempValue3 %= 10
138
TempValue3 += Object.Frame
139
DrawSpriteScreenFX(TempValue3, FX_INK, TempValue4, 155)
140
141
TempValue4 += 17
142
TempValue2 = TempValue1
143
TempValue2 %= 100
144
TempValue3 = TempValue2
145
TempValue3 /= 10
146
TempValue3 += Object.Frame
147
DrawSpriteScreenFX(TempValue3, FX_INK, TempValue4, 155)
148
149
TempValue4 += 8
150
TempValue3 = TempValue2
151
TempValue3 %= 10
152
TempValue3 += Object.Frame
153
DrawSpriteScreenFX(TempValue3, FX_INK, TempValue4, 155)
154
end function
155
156
157
function DemoMenu_StagePortraitMovement
158
Cos(TempValue4, Object.Rotation)
159
TempValue4 >>= 4
160
TempValue4 += TempValue2
161
Sin(TempValue5, Object.Rotation)
162
TempValue5 *= 3
163
TempValue5 >>= 6
164
TempValue5 += TempValue3
165
Object.Rotation += 128
166
Object.Rotation &= 511
167
EditFrame(10, 2, 2, 64, 58, TempValue4, TempValue5)
168
end function
169
170
171
sub ObjectMain
172
switch Object.State
173
case DEMOMENU_FADEIN
174
if Options.PhysicalControls == false
175
Object.CurrentButton = -1
176
else
177
Object.CurrentButton = 0
178
end if
179
180
if Object.Fade == 0
181
Object.BossUnlockRecord = 9000
182
Object.CurrentRecord = SaveRAM[48] // PPZ1 Demo Record
183
Object.CurrentRecord += SaveRAM[49] // QQZ2 Demo Record
184
if Object.CurrentRecord == 0
185
SaveRAM[48] = 60000
186
SaveRAM[49] = 60000
187
Object.CurrentRecord = 120000
188
end if
189
end if
190
191
if Object.Fade < 256
192
Object.Alpha = Object.Fade
193
Object.Fade += 6
194
else
195
Object.Fade = 0
196
Object.Alpha = 255
197
Object.State++
198
end if
199
break
200
201
case DEMOMENU_CONTROLS
202
if Options.PhysicalControls == true
203
204
if KeyPress[0].Left == true
205
Object.CurrentButton--
206
if Object.CurrentButton < 0
207
Object.CurrentButton = 2
208
end if
209
PlaySfx(SFX_G_MENUBUTTON, false)
210
end if
211
212
if KeyPress[0].Right == true
213
Object.CurrentButton++
214
if Object.CurrentButton > 2
215
Object.CurrentButton = 0
216
end if
217
PlaySfx(SFX_G_MENUBUTTON, false)
218
end if
219
220
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
221
if CheckResult > -1
222
Options.PhysicalControls = false
223
Object.CurrentButton = -1
224
end if
225
else
226
227
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
228
TempValue3 = CheckResult
229
TempValue0 = Screen.CenterX
230
TempValue0 -= 113
231
TempValue1 = Screen.CenterX
232
TempValue1 -= 45
233
CheckTouchRect(TempValue0, 67, TempValue1, 157)
234
if CheckResult > -1
235
Object.CurrentButton = 0
236
else
237
if TempValue3 < 0
238
if Object.CurrentButton == 0
239
KeyPress[0].Start = true
240
end if
241
else
242
if Object.CurrentButton == 0
243
Object.CurrentButton = -1
244
end if
245
end if
246
end if
247
248
TempValue0 = Screen.CenterX
249
TempValue0 -= 35
250
TempValue1 = Screen.CenterX
251
TempValue1 += 35
252
CheckTouchRect(TempValue0, 67, TempValue1, 157)
253
if CheckResult > -1
254
Object.CurrentButton = 1
255
else
256
if TempValue3 < 0
257
if Object.CurrentButton == 1
258
KeyPress[0].Start = true
259
end if
260
else
261
if Object.CurrentButton == 1
262
Object.CurrentButton = -1
263
end if
264
end if
265
end if
266
267
if Object.CurrentRecord <= Object.BossUnlockRecord
268
TempValue0 = Screen.CenterX
269
TempValue0 += 45
270
TempValue1 = Screen.CenterX
271
TempValue1 += 113
272
CheckTouchRect(TempValue0, 67, TempValue1, 157)
273
if CheckResult > -1
274
Object.CurrentButton = 2
275
else
276
if TempValue3 < 0
277
if Object.CurrentButton == 2
278
KeyPress[0].Start = true
279
end if
280
else
281
if Object.CurrentButton == 2
282
Object.CurrentButton = -1
283
end if
284
end if
285
end if
286
end if
287
CallFunction(MenuHeading_CheckTouchBack)
288
289
if KeyPress[0].Left == true
290
Object.CurrentButton = 1
291
Options.PhysicalControls = true
292
end if
293
294
if KeyPress[0].Right == true
295
Object.CurrentButton = 0
296
Options.PhysicalControls = true
297
end if
298
299
end if
300
301
CheckResult = false
302
if Object.CurrentButton > -1
303
if KeyPress[0].Start == true
304
if Object.CurrentButton == 2
305
if Object.CurrentRecord <= Object.BossUnlockRecord
306
CheckResult = true
307
end if
308
else
309
CheckResult = true
310
end if
311
end if
312
313
if KeyPress[0].ButtonA == true
314
if Object.CurrentButton == 2
315
if Object.CurrentRecord <= Object.BossUnlockRecord
316
CheckResult = true
317
end if
318
else
319
CheckResult = true
320
end if
321
end if
322
end if
323
324
if CheckResult == true
325
Object.State++
326
StopMusic()
327
PlaySfx(SFX_G_SELECT, false)
328
end if
329
330
if KeyPress[0].ButtonB == true
331
Object.Fade = 248
332
Object.State = DEMOMENU_BACK
333
PlayStageSfx(SFX_S_BACKBUTTON, false)
334
end if
335
break
336
337
case DEMOMENU_LEVEL_SELECTED
338
if Object.AnimationTimer < 30
339
Object.AnimationTimer++
340
else
341
Object.AnimationTimer = 0
342
Object.State = DEMOMENU_LEVEL_LOAD
343
end if
344
break
345
346
case DEMOMENU_BACK
347
if Object.Fade > 0
348
Object.Alpha = Object.Fade
349
Object.Fade -= 8
350
else
351
Object.Type = TypeName[Blank Object]
352
MenuWindow.State = MENUWINDOW_SHRINK
353
//All of this is MenuButton Objects
354
Object[34].State = MENUBUTTON_BUTTONS_IN
355
Object[35].State = MENUBUTTON_BUTTONS_IN
356
Object[36].State = MENUBUTTON_BUTTONS_IN
357
Object[37].State = MENUBUTTON_BUTTONS_IN
358
Object[38].State = MENUBUTTON_BUTTONS_IN
359
Object[39].State = MENUBUTTON_BUTTONS_IN
360
Object[40].State = MENUBUTTON_BUTTONS_IN
361
Object[41].State = MENUBUTTON_BUTTONS_IN
362
Object[42].State = MENUBUTTON_BUTTONS_IN
363
//End
364
MenuHeading.State = MENUHEADING_LEAVE_SCREEN
365
MenuHeading.Header = MAINMENU_HEADER
366
end if
367
break
368
369
case DEMOMENU_LEVEL_LOAD
370
if Object.Fade < 320
371
Object.Fade += 8
372
else
373
Options.GameMode = MODE_TRIAL
374
Player.Score = 0
375
Player.Lives = 3
376
Player.ScoreBonus = 50000
377
Transporter_Destroyed = false
378
MetalSonic_Destroyed = false
379
380
TimeAttack.Round = Object.CurrentButton
381
Stage.ActiveList = REGULAR_STAGE
382
switch Object.CurrentButton
383
case 0
384
Stage.ListPos = STAGE_R_PPZ1A
385
Good_Future = false
386
break
387
case 1
388
Stage.ListPos = STAGE_R_QQZ2A
389
Good_Future = false
390
break
391
case 2
392
Stage.ListPos = STAGE_R_QQZ3C
393
Good_Future = true
394
break
395
end switch
396
LoadStage()
397
end if
398
SetScreenFade(0, 0, 0, Object.Fade)
399
break
400
401
end switch
402
end sub
403
404
405
sub ObjectDraw
406
TempValue0 = Screen.CenterX
407
TempValue0 -= 113
408
DrawSpriteScreenFX(0, FX_INK, TempValue0, 57)
409
410
TempValue2 = 33
411
TempValue3 = 267
412
CallFunction(DemoMenu_StagePortraitMovement)
413
414
DrawSpriteScreenFX(10, FX_INK, TempValue0, 57)
415
DrawSpriteScreenFX(6, FX_INK, TempValue0, 134)
416
417
TempValue1 = SaveRAM[48] // PPZ1DemoRecord
418
CallFunction(DemoMenu_StageTimeRecord)
419
420
TempValue0 += 78
421
DrawSpriteScreenFX(1, FX_INK, TempValue0, 57)
422
423
TempValue2 = 33
424
TempValue3 = 396
425
CallFunction(DemoMenu_StagePortraitMovement)
426
427
DrawSpriteScreenFX(10, FX_INK, TempValue0, 57)
428
DrawSpriteScreenFX(6, FX_INK, TempValue0, 134)
429
430
TempValue1 = SaveRAM[49] // QQZ2DemoRecord
431
CallFunction(DemoMenu_StageTimeRecord)
432
433
TempValue0 += 78
434
DrawSpriteScreenFX(2, FX_INK, TempValue0, 57)
435
436
TempValue2 = 321
437
TempValue3 = 399
438
CallFunction(DemoMenu_StagePortraitMovement)
439
440
DrawSpriteScreenFX(10, FX_INK, TempValue0, 57)
441
442
Object.Rotation += 129
443
Object.Rotation &= 511
444
445
TempValue0 = Screen.CenterX
446
447
TempValue1 = Object.AnimationTimer
448
TempValue1 &= 3
449
TempValue1 >>= 1
450
TempValue1 += 7
451
452
switch Object.CurrentButton
453
case 0
454
TempValue0 -= 113
455
DrawSpriteScreenFX(TempValue1, FX_INK, TempValue0, 57)
456
break
457
458
case 1
459
TempValue0 -= 35
460
DrawSpriteScreenFX(TempValue1, FX_INK, TempValue0, 57)
461
break
462
463
case 2
464
TempValue0 += 43
465
DrawSpriteScreenFX(TempValue1, FX_INK, TempValue0, 57)
466
break
467
468
end switch
469
470
if Object.CurrentRecord > Object.BossUnlockRecord
471
TempValue0 = Screen.CenterX
472
TempValue0 += 97
473
DrawSpriteScreenFX(9, FX_INK, TempValue0, 128)
474
475
TempValue0 = Screen.CenterX
476
TempValue0 -= 113
477
DrawSpriteScreenFX(3, FX_INK, TempValue0, 155)
478
DrawSpriteScreenFX(4, FX_INK, TempValue0, 155)
479
480
TempValue0 += 44
481
Object.Frame = 21
482
TempValue1 = Object.CurrentRecord
483
CallFunction(DemoMenu_StageTotalTimeRecord)
484
485
TempValue0 += 114
486
DrawSpriteScreenFX(5, FX_INK, TempValue0, 154)
487
488
TempValue0 += 11
489
Object.Frame = 31
490
TempValue1 = Object.BossUnlockRecord
491
CallFunction(DemoMenu_StageTotalTimeRecord)
492
else
493
TempValue0 = Screen.CenterX
494
TempValue0 -= 113
495
DrawSpriteScreenFX(3, FX_INK, TempValue0, 155)
496
DrawSpriteScreenFX(4, FX_INK, TempValue0, 155)
497
498
TempValue0 += 44
499
500
Object.Frame = 21
501
TempValue1 = Object.CurrentRecord
502
CallFunction(DemoMenu_StageTotalTimeRecord)
503
end if
504
end sub
505
506
507
sub ObjectStartup
508
LoadSpriteSheet("Menu/MenuGfx1_EN.gif")
509
510
SpriteFrame(0, 0, 68, 90, 321, 1) //#0 - Palmtree Panic Border
511
SpriteFrame(0, 0, 68, 90, 321, 92) //#1 - Quartz Quadrant Border
512
SpriteFrame(0, 0, 68, 90, 321, 183) //#2 - Boss Border
513
SpriteFrame(0, 0, 36, 13, 219, 440) //#3 - Total
514
SpriteFrame(61, 0, 30, 5, 219, 434) //#4 - ´ ´´
515
SpriteFrame(0, 0, 66, 14, 211, 349) //#5 - Locked
516
SpriteFrame(17, 0, 22, 4, 169, 435) //#6 - Large ´ ´´
517
SpriteFrame(-1, -1, 70, 92, 321, 274) //#7 - Border
518
SpriteFrame(-1, -1, 0, 0, 325, 279) //#8 - Empty
519
SpriteFrame(0, -10, 8, 13, 258, 418) //#9 - Lock
520
SpriteFrame(2, 2, 64, 58, 1, 1) //#10 - Unknown
521
// Small Numbers
522
SpriteFrame(0, 0, 6, 8, 244, 400) //#11 - 0
523
SpriteFrame(0, 0, 6, 8, 251, 400) //#12 - 1
524
SpriteFrame(0, 0, 6, 8, 258, 400) //#13 - 2
525
SpriteFrame(0, 0, 6, 8, 265, 400) //#14 - 3
526
SpriteFrame(0, 0, 6, 8, 244, 409) //#15 - 4
527
SpriteFrame(0, 0, 6, 8, 251, 409) //#16 - 5
528
SpriteFrame(0, 0, 6, 8, 258, 409) //#17 - 6
529
SpriteFrame(0, 0, 6, 8, 265, 409) //#18 - 7
530
SpriteFrame(0, 0, 6, 8, 244, 418) //#19 - 8
531
SpriteFrame(0, 0, 6, 8, 251, 418) //#20 - 9
532
// White Numbers
533
SpriteFrame(0, 0, 8, 16, 154, 400) //#21 - 0
534
SpriteFrame(0, 0, 8, 16, 163, 400) //#22 - 1
535
SpriteFrame(0, 0, 8, 16, 172, 400) //#23 - 2
536
SpriteFrame(0, 0, 8, 16, 181, 400) //#24 - 3
537
SpriteFrame(0, 0, 8, 16, 190, 400) //#25 - 4
538
SpriteFrame(0, 0, 8, 16, 199, 400) //#26 - 5
539
SpriteFrame(0, 0, 8, 16, 208, 400) //#27 - 6
540
SpriteFrame(0, 0, 8, 16, 217, 400) //#28 - 7
541
SpriteFrame(0, 0, 8, 16, 226, 400) //#29 - 8
542
SpriteFrame(0, 0, 8, 16, 235, 400) //#30 - 9
543
// Red Numbers
544
SpriteFrame(0, 0, 8, 16, 154, 417) //#31 - 0
545
SpriteFrame(0, 0, 8, 16, 163, 417) //#32 - 1
546
SpriteFrame(0, 0, 8, 16, 172, 417) //#33 - 2
547
SpriteFrame(0, 0, 8, 16, 181, 417) //#34 - 3
548
SpriteFrame(0, 0, 8, 16, 190, 417) //#35 - 4
549
SpriteFrame(0, 0, 8, 16, 199, 417) //#36 - 5
550
SpriteFrame(0, 0, 8, 16, 208, 417) //#37 - 6
551
SpriteFrame(0, 0, 8, 16, 217, 417) //#38 - 7
552
SpriteFrame(0, 0, 8, 16, 226, 417) //#39 - 8
553
SpriteFrame(0, 0, 8, 16, 235, 417) //#40 - 9
554
end sub
555
556
557
// ========================
558
// Editor Subs
559
// ========================
560
561
sub RSDKDraw
562
DrawSprite(0)
563
end sub
564
565
566
sub RSDKLoad
567
LoadSpriteSheet("Global/Display.gif")
568
SpriteFrame(-17, -5, 34, 11, 1, 176) // "Demo"
569
570
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
571
end sub
572
573