Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/TAttack/MenuControl.txt
1319 views
1
//----------------Sonic CD Menu Control Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer // Also used for fading
7
#alias Object.Value2 : Object.SelectedButton // Only used for Mobile
8
#alias Object.Value3 : Object.SavedRound // This is used AFTER you play in time attack
9
#alias Object.Value4 : Object.SMYPos // Also used for the XPos of the zone portrait
10
#alias Object.Value5 : Object.SMCurrentButton
11
#alias Object.Value6 : Object.BeatedRecord
12
#alias Object.Value7 : Object.SSUnlocked
13
#alias Object.Scale : Object.OffSet
14
15
// Large Icon / Special Large Icon Aliases
16
#alias Object[40].State : LargeIcon.State
17
#alias Object[40].XPos : LargeIcon.XPos
18
#alias Object[40].PropertyValue : LargeIcon.Portrait
19
20
// Time Stuff
21
#alias Object.Value1 : Object.Minutes
22
#alias Object.Value2 : Object.Seconds
23
#alias Object.Value3 : Object.Milliseconds
24
#alias Object.Value4 : Object.ZoneLocked
25
26
// States
27
// *SM = Sub Menu
28
#alias 0 : MENUCONTROL_SETUP
29
#alias 1 : MENUCONTROL_FADEIN
30
#alias 2 : MENUCONTROL_CONTROLS
31
#alias 3 : MENUCONTROL_BLANK
32
#alias 4 : MENUCONTROL_RETURN_TO_MENU
33
#alias 5 : MENUCONTROL_ENTER_SM
34
#alias 6 : MENUCONTROL_CALL_RECORD_MENU
35
#alias 7 : MENUCONTROL_SM_CONTROLS
36
#alias 8 : MENUCONTROL_SM_SCROLL_DOWN
37
#alias 9 : MENUCONTROL_SM_SCROLL_UP
38
#alias 10 : MENUCONTROL_SM_CONFIRMED
39
#alias 11 : MENUCONTROL_SM_LOAD_LEVEL
40
#alias 12 : MENUCONTROL_SM_LEVEL_RETURN
41
#alias 13 : MENUCONTROL_SM_COMFIRMED_LEAVE
42
#alias 14 : MENUCONTROL_SM_EXIT
43
#alias 15 : MENUCONTROL_SM_RECORD_BEATED
44
#alias 16 : MENUCONTROL_SCROLL_DOWN
45
#alias 17 : MENUCONTROL_SCROLLING_1
46
#alias 18 : MENUCONTROL_SCROLL_UP
47
#alias 19 : MENUCONTROL_SCROLLING_2
48
49
// Large Icon State
50
#alias 1 : LARGEICON_ENTER_SCREEN
51
#alias 2 : LARGEICON_LEAVE_SCREEN
52
53
// Round Icon States
54
#alias 1 : ROUNDICON_SELECTED_ZONE
55
56
// Presentation Stages
57
#alias 0 : STAGE_P_TITLE
58
#alias 1 : STAGE_P_MENU
59
60
// Players
61
#alias 0 : PLAYER_SONIC_A
62
63
// Soundtrack
64
#alias 0 : OST_JP
65
66
// Global SFX
67
#alias 21 : SFX_G_ACHIEVEMENT
68
#alias 23 : SFX_G_MENUBUTTON
69
#alias 27 : SFX_G_SELECT
70
71
// Stage SFX
72
#alias 0 : SFX_S_BACKBUTTON
73
74
// Engine & Callbacks
75
#alias 2 : CALLBACK_TATTACK_NOTIFY_ENTER
76
#alias 3 : CALLBACK_TATTACK_NOTIFY_EXIT
77
78
// Engine Messages
79
#alias 2 : MESSAGE_LOSTFOCUS
80
81
// Device Type
82
#alias 1 : RETRO_MOBILE
83
84
// Game Mode Aliases
85
#alias 2 : MODE_TIMEATTACK
86
87
// SaveRAM[39] is how many zones are unlocked for Time Attack
88
89
// Function declarations
90
#function MenuControl_IconTransitions
91
#function MenuControl_DefaultRecord
92
#function MenuControl_ZoneUnlockCheck
93
#function MenuControl_TotalRegularRecord
94
#function MenuControl_TotalSpecialRecord
95
96
97
function MenuControl_IconTransitions
98
ArrayPos0 = 32
99
100
//Top Half
101
TempValue2 = Screen.CenterX
102
TempValue2 <<= 16
103
104
TempValue0 = -210
105
TempValue1 = -46
106
while ArrayPos0 < 36
107
// Horizontal Movement
108
Object[ArrayPos0].XPos = TempValue0
109
Object[ArrayPos0].XPos *= Object.OffSet
110
Object[ArrayPos0].XPos >>= 1
111
Object[ArrayPos0].XPos += TempValue2
112
// Vertical Movement
113
Object[ArrayPos0].YPos = TempValue1
114
Object[ArrayPos0].YPos *= Object.OffSet
115
Object[ArrayPos0].YPos += 0x640000
116
TempValue0 += 140
117
ArrayPos0++
118
loop
119
120
//Bottom Half
121
TempValue0 = -210
122
TempValue1 = 46
123
while ArrayPos0 < 40
124
// Horizontal Movement
125
Object[ArrayPos0].XPos = TempValue0
126
Object[ArrayPos0].XPos *= Object.OffSet
127
Object[ArrayPos0].XPos >>= 1
128
Object[ArrayPos0].XPos += TempValue2
129
// Vertical Movement
130
Object[ArrayPos0].YPos = TempValue1
131
Object[ArrayPos0].YPos *= Object.OffSet
132
Object[ArrayPos0].YPos += 0x640000
133
TempValue0 += 140
134
ArrayPos0++
135
loop
136
end function
137
138
139
function MenuControl_DefaultRecord
140
ArrayPos0 = 48 //Act 1 Time Attack Result
141
TempValue0 = 0
142
TempValue1 = 0
143
// Checks in all Time Attack levels if there is a record saved
144
while TempValue0 < 21
145
TempValue1 += SaveRAM[ArrayPos0]
146
ArrayPos0 += 6
147
TempValue0++
148
loop
149
150
// if there are no records, set the default times (5 Minutes per round)
151
if TempValue1 == 0
152
ArrayPos0 = 48
153
TempValue0 = 0
154
while TempValue0 < 21
155
SaveRAM[ArrayPos0] = 30000
156
ArrayPos0++
157
SaveRAM[ArrayPos0] = 30000
158
ArrayPos0++
159
SaveRAM[ArrayPos0] = 30000
160
ArrayPos0++
161
SaveRAM[ArrayPos0] = 30000
162
ArrayPos0++
163
SaveRAM[ArrayPos0] = 30000
164
ArrayPos0++
165
SaveRAM[ArrayPos0] = 30000
166
ArrayPos0++
167
TempValue0++
168
loop
169
end if
170
end function
171
172
173
function MenuControl_ZoneUnlockCheck
174
#platform: Use_Origins
175
TempValue0 = TimeAttackUnlockCount // Origins seems to save this somewhere, probably in HE2
176
#endplatform
177
178
#platform: Use_Standalone
179
TempValue0 = -1
180
ArrayPos0 = 3 // Save 0 Stage.ListPos
181
while ArrayPos0 < 40
182
TempValue1 = SaveRAM[ArrayPos0]
183
// In this order, check if your save is post PPZ 3, post MMZ 2 or if it's on a special stage
184
if TempValue1 > 10
185
if TempValue1 > 67
186
if TempValue1 < 80
187
TempValue1 = 7
188
else
189
TempValue1 -= 80
190
TempValue1 /= 10
191
end if
192
else
193
TempValue1 /= 10
194
end if
195
else
196
TempValue1 = 0
197
end if
198
if TempValue1 > TempValue0
199
TempValue0 = TempValue1 // Sets the amount of unlocked zones
200
end if
201
ArrayPos0 += 8 // Jump to next save
202
loop
203
#endplatform
204
205
if TempValue0 > SaveRAM[39]
206
SaveRAM[39] = TempValue0 // Set the new value if there are new unlocked zones
207
else
208
TempValue0 = SaveRAM[39] // Otherwise just use the saved value
209
end if
210
211
// Unlocks the playable zones
212
ArrayPos0 = 32
213
while TempValue0 > 0
214
Object[ArrayPos0].ZoneLocked = false
215
ArrayPos0++ // Skips the locking of this zone
216
TempValue0--
217
loop
218
219
// Locks the rest of zones
220
while ArrayPos0 < 39
221
Object[ArrayPos0].ZoneLocked = true
222
ArrayPos0++
223
loop
224
end function
225
226
227
function MenuControl_TotalRegularRecord
228
229
// Get the times of all zones
230
ArrayPos0 = 32
231
ArrayPos1 = 48
232
TempValue1 = 0
233
while ArrayPos0 < 39
234
TempValue0 = SaveRAM[ArrayPos1]
235
ArrayPos1 += 6
236
TempValue0 += SaveRAM[ArrayPos1]
237
ArrayPos1 += 6
238
TempValue0 += SaveRAM[ArrayPos1]
239
ArrayPos1 += 6
240
TempValue1 += TempValue0
241
Object[ArrayPos0].Minutes = TempValue0
242
Object[ArrayPos0].Minutes /= 6000
243
244
Object[ArrayPos0].Seconds = TempValue0
245
Object[ArrayPos0].Seconds /= 100
246
Object[ArrayPos0].Seconds %= 60
247
248
Object[ArrayPos0].MilliSeconds = TempValue0
249
Object[ArrayPos0].MilliSeconds %= 100
250
ArrayPos0++
251
loop
252
253
// Calculate the total time
254
Object[ArrayPos0].Minutes = TempValue1
255
Object[ArrayPos0].Minutes /= 6000
256
257
Object[ArrayPos0].Seconds = TempValue1
258
Object[ArrayPos0].Seconds /= 100
259
Object[ArrayPos0].Seconds %= 60
260
261
Object[ArrayPos0].MilliSeconds = TempValue1
262
Object[ArrayPos0].MilliSeconds %= 100
263
264
if Object[ArrayPos0].Minutes < 25
265
SetAchievement(10, 100)
266
end if
267
268
if Object[ArrayPos0].Minutes < 30
269
Object.SSUnlocked = true
270
end if
271
272
end function
273
274
275
function MenuControl_TotalSpecialRecord
276
277
// Get the times of all zones
278
ArrayPos0 = 32
279
ArrayPos1 = 49
280
TempValue1 = 0
281
while ArrayPos0 < 39
282
TempValue0 = SaveRAM[ArrayPos1]
283
ArrayPos1 += 18
284
TempValue1 += TempValue0
285
Object[ArrayPos0].Minutes = TempValue0
286
Object[ArrayPos0].Minutes /= 6000
287
288
Object[ArrayPos0].Seconds = TempValue0
289
Object[ArrayPos0].Seconds /= 100
290
Object[ArrayPos0].Seconds %= 60
291
292
Object[ArrayPos0].MilliSeconds = TempValue0
293
Object[ArrayPos0].MilliSeconds %= 100
294
ArrayPos0++
295
loop
296
297
// Calculate the total time
298
Object[ArrayPos0].Minutes = TempValue1
299
Object[ArrayPos0].Minutes /= 6000
300
301
Object[ArrayPos0].Seconds = TempValue1
302
Object[ArrayPos0].Seconds /= 100
303
Object[ArrayPos0].Seconds %= 60
304
305
Object[ArrayPos0].MilliSeconds = TempValue1
306
Object[ArrayPos0].MilliSeconds %= 100
307
308
Object.SSUnlocked = true
309
310
end function
311
312
313
sub ObjectMain
314
switch Object.State
315
case MENUCONTROL_SETUP
316
#platform: Use_Origins
317
game.callbackParam0 = false
318
EngineCallback(NOTIFY_TIMEATTACK_MODE)
319
#endplatform
320
// Makes sure nothing gets carried away from the saves
321
Stage.DebugMode = false
322
Stage.PlayerListPos = PLAYER_SONIC_A // PLAYER_SONIC in origins
323
LampPost.Check = 0
324
Good_Future = false
325
Good_Future_Count = 0
326
Good_Future_List = 0
327
SpecialStage.TimeStones = 0
328
ReadSaveRAM()
329
330
Object.State = MENUCONTROL_FADEIN
331
Object.Timer = 384
332
Object.OffSet = 0x40000
333
SetScreenFade(0, 0, 0, 255)
334
335
#platform: Use_Origins
336
if Engine.DeviceType == RETRO_MOBILE
337
Object.SavedRound = -1
338
Object.SelectedButton = -1
339
Object.SMCurrentButton = -1
340
end if
341
#endplatform
342
343
#platform: Mobile
344
Object.SavedRound = -1
345
Object.SelectedButton = -1
346
Object.SMCurrentButton = -1
347
#endplatform
348
349
CallFunction(MenuControl_ZoneUnlockCheck)
350
if TimeAttack.Round > -1 // Check if you come from playing time attack
351
Object.State = MENUCONTROL_SM_LEVEL_RETURN
352
353
LargeIcon.Portrait = TimeAttack.Round
354
Object.SavedRound = TimeAttack.Round
355
356
LargeIcon.XPos = Screen.CenterX
357
LargeIcon.XPos -= 72
358
LargeIcon.XPos <<= 16
359
360
Object.SMYPos = TimeAttack.Zone
361
Object.SMYPos *= 192
362
Object.SMYPos += 192
363
364
if TimeAttack.Result > 0
365
ArrayPos0 = TimeAttack.Round
366
ArrayPos0 *= 18
367
368
TempValue0 = TimeAttack.Zone
369
TempValue0 *= 6
370
371
ArrayPos0 += TempValue0
372
ArrayPos0 += 48
373
ArrayPos0 += TimeAttack.MenuSection
374
if TimeAttack.Result < SaveRAM[ArrayPos0]
375
// 1st Record Beated
376
ArrayPos1 = ArrayPos0
377
ArrayPos1 += 4
378
ArrayPos0 += 2
379
SaveRAM[ArrayPos1] = SaveRAM[ArrayPos0]
380
ArrayPos1 -= 2
381
ArrayPos0 -= 2
382
SaveRAM[ArrayPos1] = SaveRAM[ArrayPos0]
383
SaveRAM[ArrayPos0] = TimeAttack.Result
384
Object.BeatedRecord = 1
385
else
386
ArrayPos0 += 2
387
if TimeAttack.Result < SaveRAM[ArrayPos0]
388
// 2st Record Beated
389
ArrayPos1 = ArrayPos0
390
ArrayPos1 += 2
391
SaveRAM[ArrayPos1] = SaveRAM[ArrayPos0]
392
SaveRAM[ArrayPos0] = TimeAttack.Result
393
Object.BeatedRecord = 2
394
else
395
ArrayPos0 += 2
396
if TimeAttack.Result < SaveRAM[ArrayPos0]
397
// 3st Record Beated
398
SaveRAM[ArrayPos0] = TimeAttack.Result
399
Object.BeatedRecord = 3
400
end if
401
end if
402
end if
403
end if
404
Object.OffSet = 0x50000
405
else
406
TimeAttack.MenuSection = 0
407
end if
408
409
CallFunction(MenuControl_DefaultRecord)
410
411
if TimeAttack.MenuSection == 0
412
CallFunction(MenuControl_TotalRegularRecord)
413
else
414
CallFunction(MenuControl_TotalSpecialRecord)
415
Object[40].Type = TypeName[S Large Icon]
416
Object[41].Type = TypeName[S Records]
417
ArrayPos0 = 32
418
while ArrayPos0 < 40
419
Object[ArrayPos0].Type = TypeName[Special Icon]
420
ArrayPos0++
421
loop
422
end if
423
WriteSaveRAM()
424
425
CallFunction(MenuControl_IconTransitions)
426
EngineCallback(CALLBACK_TATTACK_NOTIFY_ENTER)
427
PlayMusic(0)
428
break
429
430
case MENUCONTROL_FADEIN
431
if Object.Timer > 0
432
Object.Timer -= 8
433
Object.OffSet -= 0x1000
434
else
435
Object.State = MENUCONTROL_CONTROLS
436
end if
437
SetScreenFade(0, 0, 0, Object.Timer)
438
CallFunction(MenuControl_IconTransitions)
439
break
440
441
case MENUCONTROL_CONTROLS
442
#platform: Standard
443
CheckResult = true
444
#endplatform
445
446
#platform: Mobile
447
CheckEqual(Options.PhysicalControls, true)
448
#endplatform
449
450
451
if CheckResult == true
452
ArrayPos0 = 32
453
ArrayPos0 += Object.SavedRound
454
CheckResult = false
455
if Object[ArrayPos0].State != ROUNDICON_SELECTED_ZONE
456
if KeyPress[0].Left == true
457
Object.SavedRound--
458
if Object.SavedRound < 0
459
Object.SavedRound = 7
460
end if
461
PlaySfx(SFX_G_MENUBUTTON, false)
462
end if
463
464
if KeyPress[0].Right == true
465
Object.SavedRound++
466
if Object.SavedRound > 7
467
Object.SavedRound = 0
468
end if
469
PlaySfx(SFX_G_MENUBUTTON, false)
470
end if
471
472
if KeyPress[0].Up == true
473
Object.SavedRound -= 4
474
if Object.SavedRound < 0
475
Object.SavedRound += 8
476
if Object.SSUnlocked == true
477
Object.State = MENUCONTROL_SCROLL_UP
478
end if
479
end if
480
PlaySfx(SFX_G_MENUBUTTON, false)
481
end if
482
483
if KeyPress[0].Down == true
484
Object.SavedRound += 4
485
if Object.SavedRound > 7
486
Object.SavedRound -= 8
487
if Object.SSUnlocked == true
488
Object.State = MENUCONTROL_SCROLL_DOWN
489
end if
490
end if
491
PlaySfx(SFX_G_MENUBUTTON, false)
492
end if
493
494
if KeyPress[0].Start == true
495
CheckResult = true
496
end if
497
498
if KeyPress[0].ButtonA == true
499
CheckResult = true
500
end if
501
end if
502
503
if CheckResult == true
504
ArrayPos0 = 32
505
ArrayPos0 += Object.SavedRound
506
if Object[ArrayPos0].ZoneLocked == 0
507
Object[ArrayPos0].State = ROUNDICON_SELECTED_ZONE
508
Object.SMCurrentButton = 0
509
switch Object.SavedRound
510
case -1
511
break
512
case 0
513
PlaySfx(SFX_G_SELECT, false)
514
break
515
case 1
516
PlaySfx(SFX_G_SELECT, false)
517
break
518
case 2
519
PlaySfx(SFX_G_SELECT, false)
520
break
521
case 3
522
PlaySfx(SFX_G_SELECT, false)
523
break
524
case 4
525
PlaySfx(SFX_G_SELECT, false)
526
break
527
case 5
528
PlaySfx(SFX_G_SELECT, false)
529
break
530
case 6
531
PlaySfx(SFX_G_SELECT, false)
532
break
533
case 7
534
PlaySfx(SFX_G_SELECT, false)
535
Object.State++
536
StopMusic()
537
break
538
end switch
539
end if
540
end if
541
end if
542
543
#platform: Mobile
544
if Options.PhysicalControls == true
545
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
546
if CheckResult > -1
547
Options.PhysicalControls = false
548
Object.SavedRound = -1
549
end if
550
else
551
if Engine.Message == MESSAGE_LOSTFOCUS
552
Object.SelectedButton = -1
553
end if
554
555
if Object.SSUnlocked == true
556
TempValue0 = Screen.XSize
557
TempValue0 -= 72
558
CheckTouchRect(TempValue0, 192, Screen.XSize, Screen.YSize)
559
if CheckResult > -1
560
Object.SelectedButton = 8
561
else
562
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
563
if CheckResult < 0
564
if Object.SelectedButton == 8
565
PlaySfx(SFX_G_MENUBUTTON, false)
566
Object.State = MENUCONTROL_SCROLL_DOWN
567
Object.SelectedButton = -1
568
end if
569
else
570
if Object.SelectedButton == 8
571
Object.SelectedButton = -1
572
end if
573
end if
574
end if
575
end if
576
577
if Object.SelectedButton > -1
578
Object.SavedRound = Object.SelectedButton
579
else
580
Object.SavedRound = -1
581
end if
582
583
if KeyPress[0].Left == true
584
Object.SavedRound = 7
585
Object.SelectedButton = -1
586
587
Options.PhysicalControls = true
588
end if
589
590
if KeyPress[0].Right == true
591
Object.SavedRound = 0
592
Object.SelectedButton = -1
593
594
Options.PhysicalControls = true
595
end if
596
597
if KeyPress[0].Up == true
598
Object.SavedRound = 7
599
Object.SelectedButton = -1
600
601
Options.PhysicalControls = true
602
end if
603
604
if KeyPress[0].Down == true
605
Object.SavedRound = 0
606
Object.SelectedButton = -1
607
608
Options.PhysicalControls = true
609
end if
610
end if
611
#endplatform
612
613
if KeyPress[0].ButtonB == true
614
Object.SavedRound = 7
615
ArrayPos0 = 32
616
ArrayPos0 += Object.SavedRound
617
//Telling to RoundIcon that we want to leave
618
Object[ArrayPos0].State = ROUNDICON_SELECTED_ZONE
619
Object.State++
620
621
StopMusic()
622
PlaySfx(SFX_G_SELECT, false)
623
end if
624
break
625
626
case MENUCONTROL_BLANK
627
break
628
629
case MENUCONTROL_RETURN_TO_MENU
630
if Object.Timer < 384
631
Object.Timer += 8
632
Object.OffSet += 0x1000
633
else
634
#platform: Use_Origins
635
Stage.ListPos = STAGE_P_TITLE
636
StopMusic()
637
#endplatform
638
639
#platform: Use_Standalone
640
Stage.ListPos = STAGE_P_MENU
641
#endplatform
642
643
LoadStage()
644
end if
645
SetScreenFade(0, 0, 0, Object.Timer)
646
647
CallFunction(MenuControl_IconTransitions)
648
EngineCallback(CALLBACK_TATTACK_NOTIFY_EXIT)
649
break
650
651
case MENUCONTROL_ENTER_SM
652
if Object.Timer < 256
653
Object.Timer += 8
654
Object.OffSet += 0x2000
655
else
656
if TimeAttack.MenuSection == 0
657
Object[40].Type = TypeName[Large Icon]
658
Object[41].Type = TypeName[Records]
659
else
660
Object[40].Type = TypeName[S Large Icon]
661
Object[41].Type = TypeName[S Records]
662
end if
663
LargeIcon.Portrait = Object.SavedRound
664
LargeIcon.State = LARGEICON_ENTER_SCREEN
665
666
Object[41].DrawOrder = 2
667
Object[42].DrawOrder = 2
668
Object[43].DrawOrder = 2
669
670
Object.Timer = 0
671
Object.SMYPos = 0
672
673
Object.State++
674
end if
675
CallFunction(MenuControl_IconTransitions)
676
break
677
case MENUCONTROL_CALL_RECORD_MENU
678
if Object.SMYPos < 192
679
Object.SMYPos += 8
680
else
681
Object.State++
682
end if
683
684
#platform: Standard
685
Object.SMCurrentButton = 0
686
#endplatform
687
688
#platform: Mobile
689
if Options.PhysicalControls == true
690
Object.SMCurrentButton = 0
691
else
692
Object.SMCurrentButton = -1
693
end if
694
#endplatform
695
break
696
697
case MENUCONTROL_SM_CONTROLS
698
#platform: Standard
699
CheckResult = true
700
#endplatform
701
702
#platform: Mobile
703
CheckEqual(Options.PhysicalControls, true)
704
#endplatform
705
706
if CheckResult == true
707
if TimeAttack.MenuSection == 0
708
if KeyPress[0].Up == true
709
Object.State = MENUCONTROL_SM_SCROLL_UP
710
end if
711
712
if KeyPress[0].Down == true
713
Object.State = MENUCONTROL_SM_SCROLL_DOWN
714
end if
715
716
if KeyPress[0].Left == true
717
Object.SMCurrentButton--
718
if Object.SMCurrentButton < 0
719
Object.SMCurrentButton = 2
720
end if
721
end if
722
723
if KeyPress[0].Right == true
724
Object.SMCurrentButton++
725
if Object.SMCurrentButton > 2
726
Object.SMCurrentButton = 0
727
end if
728
end if
729
else
730
if KeyPress[0].Left == true
731
Object.SMCurrentButton -= 2
732
if Object.SMCurrentButton < 0
733
Object.SMCurrentButton = 2
734
end if
735
end if
736
737
if KeyPress[0].Right == true
738
Object.SMCurrentButton += 2
739
if Object.SMCurrentButton > 2
740
Object.SMCurrentButton = 0
741
end if
742
end if
743
end if
744
745
CheckResult = false
746
if KeyPress[0].Start == true
747
CheckResult = true
748
end if
749
750
if KeyPress[0].ButtonA == true
751
CheckResult = true
752
end if
753
754
if KeyPress[0].ButtonB == true
755
PlayStageSfx(SFX_S_BACKBUTTON, false)
756
LargeIcon.State = LARGEICON_LEAVE_SCREEN
757
Object.State = MENUCONTROL_SM_COMFIRMED_LEAVE
758
759
Object[41].DrawOrder = 8
760
Object[42].DrawOrder = 8
761
Object[43].DrawOrder = 8
762
763
ArrayPos0 = Object.SMYPos
764
ArrayPos0 /= 192
765
ArrayPos0 += 40
766
Object[ArrayPos0].DrawOrder = 2
767
end if
768
769
if CheckResult == true
770
switch Object.SMCurrentButton
771
case 0
772
PlayStageSfx(SFX_S_BACKBUTTON, false)
773
LargeIcon.State = LARGEICON_LEAVE_SCREEN
774
Object.State = MENUCONTROL_SM_COMFIRMED_LEAVE
775
776
Object[41].DrawOrder = 8
777
Object[42].DrawOrder = 8
778
Object[43].DrawOrder = 8
779
780
ArrayPos0 = Object.SMYPos
781
ArrayPos0 /= 192
782
ArrayPos0 += 40
783
Object[ArrayPos0].DrawOrder = 2
784
break
785
786
case 1
787
PlaySfx(SFX_G_MENUBUTTON, false)
788
Object.State = MENUCONTROL_SM_SCROLL_UP
789
break
790
791
case 2
792
PlaySfx(SFX_G_SELECT, false)
793
Object.State = MENUCONTROL_SM_CONFIRMED
794
StopMusic()
795
break
796
797
end switch
798
end if
799
end if
800
801
#platform: Mobile
802
if Options.PhysicalControls == true
803
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
804
if CheckResult > -1
805
Options.PhysicalControls = false
806
Object.SMCurrentButton = -1
807
end if
808
else
809
if Engine.Message == MESSAGE_LOSTFOCUS
810
Object.SMCurrentButton = -1
811
end if
812
813
TempValue0 = Screen.CenterX
814
TempValue0 -= 140
815
TempValue1 = TempValue0
816
TempValue1 += 66
817
CheckTouchRect(TempValue0, 0, TempValue1, 40)
818
if CheckResult > -1
819
Object.SMCurrentButton = 0
820
else
821
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
822
if CheckResult < 0
823
if Object.SMCurrentButton == 0
824
PlayStageSfx(SFX_S_BACKBUTTON, false)
825
LargeIcon.State = LARGEICON_LEAVE_SCREEN
826
Object.State = MENUCONTROL_SM_COMFIRMED_LEAVE
827
828
Object[41].DrawOrder = 8
829
Object[42].DrawOrder = 8
830
Object[43].DrawOrder = 8
831
832
ArrayPos0 = Object.SMYPos
833
ArrayPos0 /= 192
834
ArrayPos0 += 40
835
Object[ArrayPos0].DrawOrder = 2
836
end if
837
else
838
if Object.SMCurrentButton == 0
839
Object.SMCurrentButton = -1
840
end if
841
end if
842
end if
843
844
if KeyPress[0].ButtonB == true
845
PlayStageSfx(SFX_S_BACKBUTTON, false)
846
LargeIcon.State = LARGEICON_LEAVE_SCREEN
847
Object.State = MENUCONTROL_SM_COMFIRMED_LEAVE
848
849
Object[41].DrawOrder = 8
850
Object[42].DrawOrder = 8
851
Object[43].DrawOrder = 8
852
853
ArrayPos0 = Object.SMYPos
854
ArrayPos0 /= 192
855
ArrayPos0 += 40
856
Object[ArrayPos0].DrawOrder = 2
857
end if
858
859
TempValue0 += 159
860
TempValue1 += 159
861
if TimeAttack.MenuSection == 0
862
CheckTouchRect(TempValue0, 0, TempValue1, 40)
863
if CheckResult > -1
864
Object.SMCurrentButton = 1
865
else
866
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
867
if CheckResult < 0
868
if Object.SMCurrentButton == 1
869
PlaySfx(SFX_G_MENUBUTTON, false)
870
Object.State = MENUCONTROL_SM_SCROLL_DOWN
871
end if
872
else
873
if Object.SMCurrentButton == 1
874
Object.SMCurrentButton = -1
875
end if
876
end if
877
end if
878
end if
879
880
TempValue0 += 68
881
TempValue1 += 68
882
CheckTouchRect(TempValue0, 0, TempValue1, 40)
883
if CheckResult > -1
884
Object.SMCurrentButton = 2
885
else
886
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
887
if CheckResult < 0
888
if Object.SMCurrentButton == 2
889
PlaySfx(SFX_G_SELECT, false)
890
Object.State = MENUCONTROL_SM_CONFIRMED
891
StopMusic()
892
end if
893
else
894
if Object.SMCurrentButton == 2
895
Object.SMCurrentButton = -1
896
end if
897
end if
898
end if
899
900
if KeyPress[0].Left == true
901
Object.SMCurrentButton = 2
902
Options.PhysicalControls = true
903
end if
904
905
if KeyPress[0].Right == true
906
Object.SMCurrentButton = 0
907
Options.PhysicalControls = true
908
end if
909
end if
910
#endplatform
911
break
912
913
case MENUCONTROL_SM_SCROLL_UP
914
if Object.Timer < 192
915
Object.Timer += 8
916
Object.SMYPos += 8
917
if Object.SMYPos > 767
918
Object.SMYPos -= 576
919
end if
920
else
921
Object.Timer = 0
922
Object.State = MENUCONTROL_SM_CONTROLS
923
#platform: Mobile
924
if Options.PhysicalControls == false
925
Object.SMCurrentButton = -1
926
end if
927
#endplatform
928
end if
929
930
break
931
932
case MENUCONTROL_SM_SCROLL_DOWN
933
if Object.Timer < 192
934
Object.Timer += 8
935
Object.SMYPos -= 8
936
if Object.SMYPos < 192
937
Object.SMYPos += 576
938
end if
939
else
940
Object.Timer = 0
941
Object.State = MENUCONTROL_SM_CONTROLS
942
#platform: Mobile
943
if Options.PhysicalControls == false
944
Object.SMCurrentButton = -1
945
end if
946
#endplatform
947
end if
948
break
949
950
case MENUCONTROL_SM_CONFIRMED
951
if Object.Timer < 30
952
Object.Timer++
953
else
954
Object.Timer = 0
955
Object.State++
956
end if
957
break
958
959
case MENUCONTROL_SM_LOAD_LEVEL
960
if Object.Timer < 320
961
Object.Timer += 8
962
else
963
if TimeAttack.MenuSection == 0
964
Stage.ActiveList = REGULAR_STAGE
965
Stage.ListPos = LargeIcon.Portrait
966
TimeAttack.Round = LargeIcon.Portrait
967
Stage.ListPos *= 10
968
969
TempValue0 = Object.SMYPos
970
TempValue0 -= 192
971
TempValue0 /= 192
972
973
TimeAttack.Zone = TempValue0
974
TempValue0 <<= 2
975
Stage.ListPos += TempValue0
976
if TempValue0 == 8
977
Stage.ListPos++
978
end if
979
else
980
Stage.ActiveList = SPECIAL_STAGE
981
#platform: Use_Origins
982
Stage.ActiveList = 3
983
#endplatform
984
Stage.ListPos = LargeIcon.Portrait
985
TimeAttack.Round = LargeIcon.Portrait
986
TimeAttack.Zone = 0
987
end if
988
989
#platform: Use_Origins
990
game.callbackParam0 = true
991
EngineCallback(NOTIFY_TIMEATTACK_MODE)
992
#endplatform
993
994
Player.Lives = 1
995
Player.Score = 0
996
Options.GameMode = MODE_TIMEATTACK
997
998
LoadStage()
999
end if
1000
SetScreenFade(0, 0, 0, Object.Timer)
1001
break
1002
1003
case MENUCONTROL_SM_LEVEL_RETURN
1004
if Object.Timer > 0
1005
Object.Timer -= 8
1006
else
1007
TimeAttack.Round = -1
1008
if Object.BeatedRecord > 0
1009
PlaySfx(SFX_G_ACHIEVEMENT, false)
1010
Object.State = MENUCONTROL_SM_RECORD_BEATED
1011
Object[0].DrawOrder = 4
1012
else
1013
Object.State = MENUCONTROL_SM_CONTROLS
1014
end if
1015
end if
1016
SetScreenFade(0, 0, 0, Object.Timer)
1017
break
1018
1019
case MENUCONTROL_SM_COMFIRMED_LEAVE
1020
if Object.Timer < 30
1021
Object.Timer++
1022
else
1023
Object.OffSet = 0x50000
1024
Object.Timer = 0
1025
Object.State++
1026
end if
1027
1028
if Object.SMYPos > 0
1029
Object.SMYPos -= 8
1030
end if
1031
break
1032
1033
case MENUCONTROL_SM_EXIT
1034
if Object.Timer < 256
1035
Object.Timer += 8
1036
Object.OffSet -= 0x2000
1037
else
1038
Object.Timer = 0
1039
Object.State = MENUCONTROL_CONTROLS
1040
end if
1041
CallFunction(MenuControl_IconTransitions)
1042
break
1043
1044
case MENUCONTROL_SM_RECORD_BEATED
1045
if Object.Timer < 120
1046
Object.Timer++
1047
else
1048
Object.Timer = 0
1049
Object.State = MENUCONTROL_SM_CONTROLS
1050
1051
Object.BeatedRecord = 0
1052
Object[0].DrawOrder = 1
1053
end if
1054
break
1055
1056
case MENUCONTROL_SCROLL_DOWN
1057
if Object.Timer < 20
1058
Object.Timer++
1059
1060
ArrayPos0 = 32
1061
while ArrayPos0 < 40
1062
Object[ArrayPos0].YPos -= 0xC0000
1063
ArrayPos0++
1064
loop
1065
else
1066
Object.Timer = 0
1067
1068
ArrayPos0 = 32
1069
if TimeAttack.MenuSection == 0
1070
while ArrayPos0 < 40
1071
Object[ArrayPos0].YPos += 0x1E00000
1072
Object[ArrayPos0].Type = TypeName[Special Icon]
1073
ArrayPos0++
1074
loop
1075
TimeAttack.MenuSection = 1
1076
CallFunction(MenuControl_TotalSpecialRecord)
1077
else
1078
while ArrayPos0 < 40
1079
Object[ArrayPos0].YPos += 0x1E00000
1080
Object[ArrayPos0].Type = TypeName[Round Icon]
1081
ArrayPos0++
1082
loop
1083
TimeAttack.MenuSection = 0
1084
CallFunction(MenuControl_TotalRegularRecord)
1085
end if
1086
Object.State++
1087
end if
1088
break
1089
1090
case MENUCONTROL_SCROLLING_1 // Follow-up to MENUCONTROL_SCROLL_DOWN
1091
if Object.Timer < 20
1092
Object.Timer++
1093
1094
ArrayPos0 = 32
1095
while ArrayPos0 < 40
1096
Object[ArrayPos0].YPos -= 0xC0000
1097
ArrayPos0++
1098
loop
1099
else
1100
Object.Timer = 0
1101
Object.State = MENUCONTROL_CONTROLS
1102
end if
1103
break
1104
1105
case MENUCONTROL_SCROLL_UP
1106
if Object.Timer < 20
1107
Object.Timer++
1108
1109
ArrayPos0 = 32
1110
while ArrayPos0 < 40
1111
Object[ArrayPos0].YPos += 0xC0000
1112
ArrayPos0++
1113
loop
1114
else
1115
Object.Timer = 0
1116
1117
ArrayPos0 = 32
1118
if TimeAttack.MenuSection == 0
1119
while ArrayPos0 < 40
1120
Object[ArrayPos0].YPos -= 0x1E00000
1121
Object[ArrayPos0].Type = TypeName[Special Icon]
1122
ArrayPos0++
1123
loop
1124
TimeAttack.MenuSection = 1
1125
CallFunction(MenuControl_TotalSpecialRecord)
1126
else
1127
while ArrayPos0 < 40
1128
Object[ArrayPos0].YPos -= 0x1E00000
1129
Object[ArrayPos0].Type = TypeName[Round Icon]
1130
ArrayPos0++
1131
loop
1132
TimeAttack.MenuSection = 0
1133
CallFunction(MenuControl_TotalRegularRecord)
1134
end if
1135
Object.State++
1136
end if
1137
break
1138
1139
case MENUCONTROL_SCROLLING_2 // Follow-up to MENUCONTROL_SCROLL_UP
1140
if Object.Timer < 20
1141
Object.Timer++
1142
1143
ArrayPos0 = 32
1144
while ArrayPos0 < 40
1145
Object[ArrayPos0].YPos += 0xC0000
1146
ArrayPos0++
1147
loop
1148
else
1149
Object.Timer = 0
1150
Object.State = MENUCONTROL_CONTROLS
1151
end if
1152
break
1153
1154
end switch
1155
end sub
1156
1157
1158
sub ObjectDraw
1159
switch Object.State
1160
case MENUCONTROL_SM_COMFIRMED_LEAVE
1161
TempValue0 = Screen.CenterX
1162
TempValue0 += 16
1163
DrawRect(TempValue0, 31, Screen.CenterX, 9, 0, 0, 0, 255)
1164
DrawRect(TempValue0, 40, Screen.CenterX, 135, 224, 0, 0, 255)
1165
DrawRect(TempValue0, 175, Screen.CenterX, 38, 0, 0, 96, 255)
1166
break
1167
1168
case MENUCONTROL_SM_RECORD_BEATED
1169
TempValue0 = Object.Timer
1170
TempValue0 >>= 2
1171
TempValue0 &= 1
1172
if TempValue0 == 0
1173
TempValue0 = Screen.CenterX
1174
TempValue0 += 16
1175
TempValue1 = Object.BeatedRecord
1176
TempValue1 *= 24
1177
TempValue1 += 105
1178
DrawRect(TempValue0, TempValue1, 34, 24, 8, 0, 104, 255)
1179
end if
1180
break
1181
1182
end switch
1183
end sub
1184
1185
1186
sub ObjectStartup
1187
#platform: Use_Origins
1188
game.callbackParam0 = true
1189
EngineCallback(NOTIFY_LEVEL_SELECT_MENU)
1190
1191
game.callbackParam0 = 0
1192
EngineCallback(NOTIFY_PLAYER_SET)
1193
#endplatform
1194
1195
if Options.Soundtrack == OST_JP
1196
SetMusicTrack("JP/TimeAttack.ogg", 0, 100512)
1197
else
1198
SetMusicTrack("US/DAGarden.ogg", 0, 117382)
1199
end if
1200
1201
Object[0].Type = TypeName[Menu Control]
1202
Object[0].DrawOrder = 1
1203
1204
#platform: Use_Origins
1205
if Engine.DeviceType == RETRO_MOBILE
1206
Options.PhysicalControls = true
1207
end if
1208
#endplatform
1209
1210
#platform: Mobile
1211
Options.PhysicalControls = false
1212
#endplatform
1213
end sub
1214
1215
1216
// ========================
1217
// Editor Subs
1218
// ========================
1219
1220
sub RSDKDraw
1221
DrawSprite(0)
1222
end sub
1223
1224
1225
sub RSDKLoad
1226
LoadSpriteSheet("Global/Display.gif")
1227
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
1228
1229
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
1230
end sub
1231
1232