Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/LevelSelect/MenuControl.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Menu Control Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.timer
13
private alias object.value1 : object.scrollDelayUp
14
private alias object.value2 : object.scrollDelayDown
15
private alias object.value3 : object.currentSelection
16
private alias object.value4 : object.soundTestCooldown
17
18
// States
19
private alias 0 : MENUCONTROL_INIT
20
private alias 1 : MENUCONTROL_FADEIN
21
private alias 2 : MENUCONTROL_SELECTING
22
private alias 3 : MENUCONTROL_LOADLEVEL
23
private alias 4 : MENUCONTROL_LOADSPECIAL
24
25
// The maximum number of selections available
26
private alias 27 : MAX_SELECTION_COUNT
27
28
// Aliases for some of the special options
29
private alias 64 : SETTING_PLAYER
30
private alias 65 : SETTING_SPINDASH
31
private alias 66 : SETTING_GNDSPDCAP
32
private alias 67 : SETTING_AIRSPDCAP
33
private alias 68 : SETTING_S1SPIKES
34
private alias 69 : SETTING_ITEMS
35
private alias 70 : SETTING_EMERALDS
36
37
private alias 71 : ENTRY_SOUNDTEST
38
39
// Player IDs
40
private alias 0 : MENUCONTROL_PLAYER_ST
41
private alias 1 : MENUCONTROL_PLAYER_S
42
private alias 2 : MENUCONTROL_PLAYER_T
43
private alias 3 : MENUCONTROL_PLAYER_K
44
45
// Origins Plus Player IDs
46
private alias 4 : MENUCONTROL_PLAYER_A
47
private alias 5 : MENUCONTROL_PLAYER_AT
48
49
// HexNo Aliases
50
private alias object.value0 : hexNo.number
51
private alias object.value1 : hexNo.highlighted
52
53
private alias 0 : HEXNO_HIGHLIGHT_FALSE
54
private alias 16 : HEXNO_HIGHLIGHT_TRUE
55
56
// Shield Type Aliases
57
private alias 0 : SHIELDTYPE_S1
58
private alias 1 : SHIELDTYPE_S2
59
private alias 2 : SHIELDTYPE_S3_S1
60
private alias 3 : SHIELDTYPE_S3_S2
61
62
// Player List Pos Aliases
63
public alias 0 : PLAYER_SONIC_A
64
public alias 1 : PLAYER_TAILS_A
65
public alias 2 : PLAYER_KNUCKLES_A
66
public alias 3 : PLAYER_SONIC_TAILS_A
67
public alias 4 : PLAYER_KNUCKLES_TAILS_A
68
public alias 5 : PLAYER_AMY_A
69
public alias 6 : PLAYER_AMY_TAILS_A
70
71
// Music loops
72
private alias 635050 : MUSIC_LOOP_GHZ // 635970 in older S1 versions, changed some time around 1.0.7
73
private alias 99380 : MUSIC_LOOP_MZ
74
private alias 100712 : MUSIC_LOOP_SYZ // This is 101364 in the normal stage...
75
private alias 84444 : MUSIC_LOOP_LZ
76
private alias 84364 : MUSIC_LOOP_SLZ
77
private alias 1 : MUSIC_LOOP_SBZ
78
private alias 84680 : MUSIC_LOOP_FINAL
79
private alias 39528 : MUSIC_LOOP_INV
80
81
// Music Event Aliases
82
private alias 25 : SLOT_MUSICEVENT_CHANGE
83
84
private alias 2 : MUSICEVENT_TRANSITION
85
86
87
// ========================
88
// Function Declarations
89
// ========================
90
91
reserve function MenuControl_HandleSecrets
92
reserve function MenuControl_PlaySong
93
94
95
// ========================
96
// Static Values
97
// ========================
98
99
private value MenuControl_DebugCheatCodePos = 0
100
private value MenuControl_EmeraldCheatCodePos = 0
101
102
103
// ========================
104
// Tables
105
// ========================
106
107
private table MenuControl_DebugModeCheatCode
108
1, 9, 9, 1, 0, 6, 2, 3
109
end table
110
111
private table MenuControl_EmeraldsCheatCode
112
4, 1, 2, 6
113
end table
114
115
// This table holds data for every stage with six values for every stage,
116
// -> First entry is menu table the stage option is on
117
// -> Second is what number this one is on the list, from top to bottom
118
// -> Third is the active stage list the stage is on
119
// -> Fourth is the stage's position in the stage list
120
// -> Fifth is the menu entry of what is on the opposite side of this selection, like how SBZ is to the right of GHZ and vice versa
121
// -> For "special" selections (like settings) this value is instead used to hold a special ID
122
// -> Sixth is the icon the entry uses (based on Sprite Frames in the BG Animation object)
123
private table MenuControl_EntryTable
124
0, 0, 1, 0, 15, 1 // 0 - GHZ 1
125
0, 1, 1, 1, 16, 1 // 1 - GHZ 2
126
0, 2, 1, 2, 17, 1 // 2 - GHZ 3
127
0, 4, 1, 3, 18, 2 // 3 - MZ 1
128
0, 5, 1, 4, 18, 2 // 4 - MZ 2
129
0, 6, 1, 5, 19, 2 // 5 - MZ 3
130
0, 8, 1, 6, 19, 3 // 6 - SYZ 1
131
0, 9, 1, 7, 20, 3 // 7 - SYZ 2
132
0, 10, 1, 8, 21, 3 // 8 - SYZ 3
133
0, 12, 1, 9, 23, 4 // 9 - LZ 1
134
0, 13, 1, 10, 24, 4 // 10 - LZ 2
135
0, 14, 1, 11, 25, 4 // 11 - LZ 3
136
0, 16, 1, 12, 26, 5 // 12 - SLZ 1
137
0, 17, 1, 13, 26, 5 // 13 - SLZ 2
138
0, 18, 1, 14, 27, 5 // 14 - SLZ 3
139
1, 0, 1, 15, 0, 6 // 15 - SBZ 1
140
1, 1, 1, 16, 1, 6 // 16 - SBZ 2
141
1, 2, 1, 17, 2, 6 // 17 - SBZ 3
142
1, 4, 1, 18, 3, 7 // 18 - Final Zone
143
1, 6, 2, 0, 5, 8 // 19 - Special Stage
144
1, 9, 0, 0, 64, 0 // 20 - Player Option
145
1, 10, 0, 0, 65, 0 // 21 - Spindash Setting
146
1, 11, 0, 0, 66, 0 // 22 - Ground Speed Cap Setting
147
1, 12, 0, 0, 67, 0 // 23 - Air Speed Cap Setting
148
1, 13, 0, 0, 68, 0 // 24 - S1 Spikes Setting
149
1, 14, 0, 0, 69, 0 // 25 - Items Setting
150
1, 15, 0, 0, 70, 0 // 26 - Max Emeralds Count
151
1, 18, 0, 0, 71, 0 // 27 - Sound Test
152
end table
153
154
155
// ========================
156
// Function Definitions
157
// ========================
158
159
private function MenuControl_HandleSecrets
160
if hexNo[+2].number < 8
161
SetTableValue(hexNo[+2].number, 117, MenuControl_EntryTable)
162
end if
163
164
GetTableValue(temp0, MenuControl_DebugCheatCodePos, MenuControl_DebugModeCheatCode)
165
if temp0 == hexNo[+2].number
166
MenuControl_DebugCheatCodePos++
167
if MenuControl_DebugCheatCodePos == 8
168
MenuControl_DebugCheatCodePos = 0
169
stage.debugMode = true
170
PlaySfx(SfxName[Ring L], false)
171
end if
172
else
173
MenuControl_DebugCheatCodePos = 0
174
end if
175
176
GetTableValue(temp0, MenuControl_EmeraldCheatCodePos, MenuControl_EmeraldsCheatCode)
177
if temp0 == hexNo[+2].number
178
MenuControl_EmeraldCheatCodePos++
179
if MenuControl_EmeraldCheatCodePos == 4
180
MenuControl_EmeraldCheatCodePos = 0
181
if options.superStates == true
182
// Give the player all seven emeralds
183
specialStage.emeralds = 0x7F
184
else
185
// Only give the player 6 emeralds, as the seventh one shouldn't really exist
186
specialStage.emeralds = 0x3F
187
specialStage.listPos = 6
188
end if
189
190
PlaySfx(SfxName[Emerald], false)
191
StopMusic()
192
end if
193
else
194
MenuControl_EmeraldCheatCodePos = 0
195
end if
196
end function
197
198
199
private function MenuControl_PlaySong
200
// Don't allow playing of songs in quick succession
201
if object.soundTestCooldown == 0
202
object.soundTestCooldown = 30
203
204
switch hexNo[+2].number
205
case 0
206
StopMusic()
207
break
208
209
case 1
210
SetMusicTrack("GreenHill.ogg", 0, MUSIC_LOOP_GHZ)
211
PlayMusic(0)
212
break
213
214
case 2
215
SetMusicTrack("Marble.ogg", 0, MUSIC_LOOP_MZ)
216
PlayMusic(0)
217
break
218
219
case 3
220
SetMusicTrack("SpringYard.ogg", 0, MUSIC_LOOP_SYZ)
221
PlayMusic(0)
222
break
223
224
case 4
225
SetMusicTrack("Labyrinth.ogg", 0, MUSIC_LOOP_LZ)
226
PlayMusic(0)
227
break
228
229
case 5
230
SetMusicTrack("Starlight.ogg", 0, MUSIC_LOOP_SLZ)
231
PlayMusic(0)
232
break
233
234
case 6
235
SetMusicTrack("ScrapBrain.ogg", 0, MUSIC_LOOP_SBZ)
236
PlayMusic(0)
237
break
238
239
case 7
240
SetMusicTrack("Invincibility.ogg", 0, MUSIC_LOOP_INV)
241
PlayMusic(0)
242
break
243
244
case 8
245
PlaySfx(SfxName[Life], false)
246
PauseMusic()
247
ResetObjectEntity(SLOT_MUSICEVENT_CHANGE, TypeName[Music Event], MUSICEVENT_TRANSITION, 0, 0)
248
object[SLOT_MUSICEVENT_CHANGE].priority = PRIORITY_ACTIVE
249
break
250
251
case 9
252
SetMusicTrack("SpecialStage.ogg", 0, true)
253
PlayMusic(0)
254
break
255
256
case 10
257
SetMusicTrack("Titlescreen.ogg", 0, false)
258
PlayMusic(0)
259
break
260
261
case 11
262
SetMusicTrack("Ending.ogg", 0, false)
263
PlayMusic(0)
264
break
265
266
case 12
267
SetMusicTrack("Boss.ogg", 0, true)
268
PlayMusic(0)
269
break
270
271
case 13
272
SetMusicTrack("Final.ogg", 0, MUSIC_LOOP_FINAL)
273
PlayMusic(0)
274
break
275
276
case 14
277
SetMusicTrack("ActComplete.ogg", 0, false)
278
PlayMusic(0)
279
break
280
281
case 15
282
SetMusicTrack("GameOver.ogg", 0, false)
283
PlayMusic(0)
284
break
285
286
case 16
287
SetMusicTrack("Continue.ogg", 0, false)
288
PlayMusic(0)
289
break
290
291
case 17
292
SetMusicTrack("Credits.ogg", 0, false)
293
PlayMusic(0)
294
break
295
296
case 18
297
SetMusicTrack("Drowning.ogg", 0, false)
298
PlayMusic(0)
299
break
300
301
end switch
302
end if
303
end function
304
305
306
// ========================
307
// Events
308
// ========================
309
310
event ObjectUpdate
311
// Set up the positions of the two HexNo objects
312
// (Not sure why this can't be in INIT like the ypos setup, but if you really wanna ig)
313
object[+1].xpos = screen.xcenter
314
object[+1].xpos += 118
315
object[+2].xpos = object[+1].xpos
316
317
switch object.state
318
case MENUCONTROL_INIT
319
object.timer = 320
320
321
SetScreenFade(0, 0, 0, object.timer)
322
323
// Setup the next two HexNo objects' positions
324
325
object[+1].ypos = 88
326
object[+1].priority = PRIORITY_ACTIVE
327
328
object[+2].ypos = 160
329
object[+2].priority = PRIORITY_ACTIVE
330
331
switch stage.playerListPos
332
case PLAYER_SONIC_A
333
hexNo[+1].number = MENUCONTROL_PLAYER_S
334
break
335
336
case PLAYER_TAILS_A
337
hexNo[+1].number = MENUCONTROL_PLAYER_T
338
break
339
340
case PLAYER_KNUCKLES_A
341
hexNo[+1].number = MENUCONTROL_PLAYER_K
342
break
343
344
case PLAYER_SONIC_TAILS_A
345
hexNo[+1].number = MENUCONTROL_PLAYER_ST
346
break
347
#platform: USE_ORIGINS
348
case PLAYER_AMY_A
349
hexNo[+1].number = MENUCONTROL_PLAYER_A
350
break
351
352
case PLAYER_AMY_TAILS_A
353
hexNo[+1].number = MENUCONTROL_PLAYER_AT
354
break
355
#endplatform
356
357
end switch
358
359
object.state++
360
break
361
362
case MENUCONTROL_FADEIN
363
if object.timer > 0
364
object.timer -= 16
365
else
366
object.state++
367
end if
368
369
SetScreenFade(0, 0, 0, object.timer)
370
break
371
372
case MENUCONTROL_SELECTING
373
if keyDown[0].down == true
374
object.scrollDelayUp = 0
375
object.scrollDelayDown++
376
377
if object.scrollDelayDown == 1
378
object.currentSelection++
379
end if
380
381
object.scrollDelayDown %= 12
382
else
383
384
if keyDown[0].up == true
385
object.scrollDelayDown = 0
386
387
object.scrollDelayUp++
388
if object.scrollDelayUp == 1
389
object.currentSelection--
390
end if
391
392
object.scrollDelayUp %= 12
393
else
394
object.scrollDelayUp = 0
395
object.scrollDelayDown = 0
396
end if
397
end if
398
399
// Loop back if max count reached
400
if object.currentSelection > MAX_SELECTION_COUNT
401
object.currentSelection = 0
402
end if
403
404
// Go back to mex if player if trying to go back from the first entry
405
if object.currentSelection < 0
406
object.currentSelection = MAX_SELECTION_COUNT
407
end if
408
409
// Get info about the current selection
410
temp0 = object.currentSelection
411
temp0 *= 6
412
temp0++
413
414
// Get what row the selection is in
415
GetTableValue(temp2, temp0, MenuControl_EntryTable)
416
temp0 += 3
417
418
// Get the selection's special ID (will return a normal value if it's a normal selection)
419
GetTableValue(temp1, temp0, MenuControl_EntryTable)
420
421
// Switch statement based on the entry's special ID
422
switch temp1
423
default
424
// Default - anything that isn't an option or sound test will end up here
425
checkResult = keyPress[0].left
426
checkResult |= keyPress[0].right
427
428
if checkResult == true
429
object.currentSelection = temp1
430
end if
431
432
hexNo[+1].highlighted = HEXNO_HIGHLIGHT_FALSE
433
hexNo[+2].highlighted = HEXNO_HIGHLIGHT_FALSE
434
435
if keyPress[0].buttonA == true
436
keyPress[0].start = true
437
end if
438
break
439
440
case SETTING_PLAYER
441
// Player option
442
hexNo[+1].highlighted = HEXNO_HIGHLIGHT_TRUE
443
hexNo[+2].highlighted = HEXNO_HIGHLIGHT_FALSE
444
445
if keyPress[0].left == true
446
hexNo[+1].number--
447
#platform: USE_ORIGINS
448
if hexNo[+1].number == MENUCONTROL_PLAYER_A
449
if game.hasPlusDLC == false
450
hexNo[+1].number--
451
end if
452
end if
453
454
if hexNo[+1].number < MENUCONTROL_PLAYER_ST
455
if game.hasPlusDLC == true
456
hexNo[+1].number = MENUCONTROL_PLAYER_AT
457
else
458
hexNo[+1].number = MENUCONTROL_PLAYER_K
459
end if
460
end if
461
#endplatform
462
end if
463
464
if keyPress[0].right == true
465
hexNo[+1].number++
466
#platform: USE_ORIGINS
467
if game.hasPlusDLC == false
468
if hexNo[+1].number == MENUCONTROL_PLAYER_A
469
hexNo[+1].number++
470
end if
471
472
if hexNo[+1].number == MENUCONTROL_PLAYER_AT
473
hexNo[+1].number++
474
end if
475
end if
476
477
if hexNo[+1].number > MENUCONTROL_PLAYER_AT
478
hexNo[+1].number = MENUCONTROL_PLAYER_ST
479
end if
480
#endplatform
481
end if
482
483
#platform: USE_STANDALONE
484
hexNo[+1].number &= MENUCONTROL_PLAYER_K
485
#endplatform
486
487
switch hexNo[+1].number
488
case MENUCONTROL_PLAYER_ST
489
#platform: USE_STANDALONE
490
stage.playerListPos = PLAYER_SONIC_TAILS_A
491
#endplatform
492
#platform: USE_ORIGINS
493
stage.playerListPos = PLAYER_SONIC_TAILS
494
#endplatform
495
break
496
497
case MENUCONTROL_PLAYER_S
498
#platform: USE_STANDALONE
499
stage.playerListPos = PLAYER_SONIC_A
500
#endplatform
501
#platform: USE_ORIGINS
502
stage.playerListPos = PLAYER_SONIC
503
#endplatform
504
stage.player2Enabled = false
505
break
506
507
case MENUCONTROL_PLAYER_T
508
#platform: USE_STANDALONE
509
stage.playerListPos = PLAYER_TAILS_A
510
#endplatform
511
#platform: USE_ORIGINS
512
stage.playerListPos = PLAYER_TAILS
513
#endplatform
514
stage.player2Enabled = false
515
break
516
517
case MENUCONTROL_PLAYER_K
518
#platform: USE_STANDALONE
519
stage.playerListPos = PLAYER_KNUCKLES_A
520
#endplatform
521
#platform: USE_ORIGINS
522
stage.playerListPos = PLAYER_KNUCKLES
523
#endplatform
524
stage.player2Enabled = false
525
break
526
527
#platform: USE_ORIGINS
528
case MENUCONTROL_PLAYER_A
529
stage.playerListPos = PLAYER_AMY
530
stage.player2Enabled = false
531
break
532
533
case MENUCONTROL_PLAYER_AT
534
stage.playerListPos = PLAYER_AMY_TAILS
535
stage.player2Enabled = true
536
break
537
#endplatform
538
539
end switch
540
break
541
542
case SETTING_SPINDASH
543
// Spindash setting
544
hexNo[+1].highlighted = HEXNO_HIGHLIGHT_FALSE
545
hexNo[+2].highlighted = HEXNO_HIGHLIGHT_FALSE
546
547
checkResult = keyPress[0].left
548
checkResult |= keyPress[0].right
549
550
if checkResult == true
551
// Toggle it
552
options.spindash ^= true
553
554
// Update the menu to match
555
if options.spindash == true
556
EditMenuEntry(MENU_2, "SPINDASH@@@@@*ON*", temp2, true)
557
else
558
EditMenuEntry(MENU_2, "SPINDASH@@@@*OFF*", temp2, true)
559
end if
560
end if
561
break
562
563
case SETTING_GNDSPDCAP
564
// Ground speed cap option
565
checkResult = keyPress[0].left
566
checkResult |= keyPress[0].right
567
568
if checkResult == true
569
// Toggle it
570
options.speedCap ^= true
571
572
// Update the menu text to match the new setting
573
if options.speedCap == true
574
EditMenuEntry(MENU_2, "GND SPD CAP@@*ON*", temp2, true)
575
else
576
EditMenuEntry(MENU_2, "GND SPD CAP *OFF*", temp2, true)
577
end if
578
end if
579
break
580
581
case SETTING_AIRSPDCAP
582
// Air speed cap option
583
checkResult = keyPress[0].left
584
checkResult |= keyPress[0].right
585
586
if checkResult == true
587
// Toggle it
588
options.airSpeedCap ^= true
589
590
// Change the menu text to match the new option setting
591
if options.airSpeedCap == true
592
EditMenuEntry(MENU_2, "AIR SPD CAP@@*ON*", temp2, true)
593
else
594
EditMenuEntry(MENU_2, "AIR SPD CAP *OFF*", temp2, true)
595
end if
596
end if
597
break
598
599
case SETTING_S1SPIKES
600
// Spike behavior
601
checkResult = keyPress[0].left
602
checkResult |= keyPress[0].right
603
604
if checkResult == true
605
// Toggle the option
606
options.spikeBehavior ^= true
607
608
// Update the menu text
609
if options.spikeBehavior == true
610
EditMenuEntry(MENU_2, "S1 SPIKES@@@@*ON*", temp2, true)
611
else
612
EditMenuEntry(MENU_2, "S1 SPIKES@@@*OFF*", temp2, true)
613
end if
614
end if
615
break
616
617
case SETTING_ITEMS
618
// Monitors option
619
checkResult = keyPress[0].left
620
checkResult |= keyPress[0].right
621
622
if checkResult == true
623
if keyPress[0].left == true
624
options.shieldType--
625
end if
626
627
if keyPress[0].right == true
628
options.shieldType++
629
end if
630
631
options.shieldType &= SHIELDTYPE_S3_S2
632
633
// Update the menu text to account for the new change
634
switch options.shieldType
635
case SHIELDTYPE_S1
636
EditMenuEntry(MENU_2, "ITEMS@@@@@@@@*S1*", temp2, true)
637
break
638
639
case SHIELDTYPE_S2
640
EditMenuEntry(MENU_2, "ITEMS@@@@@@@@*S2*", temp2, true)
641
break
642
643
case SHIELDTYPE_S3_S1
644
EditMenuEntry(MENU_2, "ITEMS@@@@@*S1+S3*", temp2, true)
645
break
646
647
case SHIELDTYPE_S3_S2
648
EditMenuEntry(MENU_2, "ITEMS@@@@@*S2+S3*", temp2, true)
649
break
650
end switch
651
end if
652
break
653
654
case SETTING_EMERALDS
655
// Max emeralds setting
656
hexNo[+1].highlighted = HEXNO_HIGHLIGHT_FALSE
657
hexNo[+2].highlighted = HEXNO_HIGHLIGHT_FALSE
658
659
checkResult = keyPress[0].left
660
checkResult |= keyPress[0].right
661
662
if checkResult == true
663
// Change the setting
664
options.superStates ^= true
665
666
// And update the menu to match
667
if options.superStates == true
668
EditMenuEntry(MENU_2, "MAX EMERALDS *07*", temp2, true)
669
else
670
EditMenuEntry(MENU_2, "MAX EMERALDS *06*", temp2, true)
671
end if
672
end if
673
break
674
675
case ENTRY_SOUNDTEST
676
// Sound test
677
if object.soundTestCooldown > 0
678
object.soundTestCooldown--
679
end if
680
681
hexNo[+1].highlighted = HEXNO_HIGHLIGHT_FALSE
682
hexNo[+2].highlighted = HEXNO_HIGHLIGHT_TRUE
683
684
685
if keyPress[0].buttonC == true
686
// Add 16 to the count
687
hexNo[+2].number += 16
688
end if
689
690
if keyPress[0].left == true
691
hexNo[+2].number--
692
end if
693
694
if keyPress[0].right == true
695
hexNo[+2].number++
696
end if
697
698
// There are only 32 entries
699
hexNo[+2].number &= 31
700
701
if keyPress[0].buttonA == true
702
CallFunction(MenuControl_PlaySong)
703
CallFunction(MenuControl_HandleSecrets)
704
end if
705
706
if keyPress[0].buttonB == true
707
CallFunction(MenuControl_PlaySong)
708
CallFunction(MenuControl_HandleSecrets)
709
end if
710
break
711
712
end switch
713
714
temp0 = object.currentSelection
715
temp0 *= 6
716
717
// Get what menu the current selection is on
718
GetTableValue(temp1, temp0, MenuControl_EntryTable)
719
temp0++
720
if temp1 == MENU_1
721
menu2.selection = -1
722
GetTableValue(menu1.selection, temp0, MenuControl_EntryTable)
723
else // MENU_2
724
menu1.selection = -1
725
GetTableValue(menu2.selection, temp0, MenuControl_EntryTable)
726
end if
727
728
temp0 += 4
729
730
// Get what picture the current selection should show
731
GetTableValue(BGAnimation_currentPreview, temp0, MenuControl_EntryTable)
732
733
// Check if the player wants to enter the level
734
if keyPress[0].start == true
735
// Special stage?
736
if object.currentSelection == 19
737
// Special fade for special stages
738
PlaySfx(SfxName[Warp], false)
739
object.state = MENUCONTROL_LOADSPECIAL
740
fadeColor = 0xD0
741
fadeColor <<= 16
742
temp0 = 0xFF
743
temp0 <<= 8
744
fadeColor += temp0
745
fadeColor += 0xE0
746
else
747
// Use the normal level loading routine
748
object.state = MENUCONTROL_LOADLEVEL
749
end if
750
end if
751
break
752
753
case MENUCONTROL_LOADLEVEL // Black fade for entering a normal stage
754
if object.timer < 0x100
755
music.volume -= 10
756
object.timer += 16
757
SetScreenFade(0, 0, 0, object.timer)
758
else
759
#platform: USE_ORIGINS
760
CallNativeFunction2(NotifyCallback, NOTIFY_LEVEL_SELECT_MENU, true)
761
CallNativeFunction2(NotifyCallback, NOTIFY_PLAYER_SET, stage.playerListPos)
762
#endplatform
763
764
StopMusic()
765
766
// Start getting info about the currently selected stage
767
temp0 = object.currentSelection
768
temp0 *= 6
769
temp0 += 2
770
771
// Get what stage list it's on
772
GetTableValue(temp1, temp0, MenuControl_EntryTable)
773
temp0++
774
775
// And then get the stage's list pos
776
GetTableValue(temp2, temp0, MenuControl_EntryTable)
777
778
stage.activeList = temp1
779
stage.listPos = temp2
780
781
LoadStage()
782
783
SetScreenFade(0x00, 0x00, 0x00, 0xFF)
784
end if
785
break
786
787
case MENUCONTROL_LOADSPECIAL
788
if object.timer < 768
789
music.volume -= 10
790
object.timer += 8
791
SetScreenFade(0xD0, 0xFF, 0xE0, object.timer)
792
else
793
StopMusic()
794
795
temp0 = object.currentSelection
796
temp0 *= 6
797
temp0 += 2
798
799
// Get what stage list it's on
800
GetTableValue(temp1, temp0, MenuControl_EntryTable)
801
temp0++
802
803
// And then get the stage's list position
804
GetTableValue(temp2, temp0, MenuControl_EntryTable)
805
806
stage.activeList = temp1
807
stage.listPos = temp2
808
809
LoadStage()
810
811
SetScreenFade(0xD0, 0xFF, 0xE0, 0xFF)
812
end if
813
break
814
815
end switch
816
end event
817
818
819
event ObjectDraw
820
temp0 = screen.xcenter
821
temp0 -= 10
822
DrawMenu(MENU_1, temp0, 16)
823
824
temp0 = screen.xcenter
825
temp0 += 142
826
DrawMenu(MENU_2, temp0, 16)
827
end event
828
829
830
event ObjectStartup
831
LoadSpriteSheet("LevelSelect/Text.gif")
832
833
foreach (TypeName[Menu Control], arrayPos0, ALL_ENTITIES)
834
// Set all Menu Control objects to be active
835
object[arrayPos0].priority = PRIORITY_ACTIVE
836
next
837
838
// Player is on stage select, so set the flag
839
options.stageSelectFlag = true
840
841
// (Initial verions of S1 used to reset stage.player2Enabled here, but that line was later removed)
842
843
// Setup the menu and its entries
844
845
// Left column
846
SetupMenu(MENU_1, 0, 3, 1)
847
AddMenuEntry(MENU_1, "GREEN HILL 1", true)
848
AddMenuEntry(MENU_1, "2", false)
849
AddMenuEntry(MENU_1, "3", false)
850
AddMenuEntry(MENU_1, " ", false)
851
AddMenuEntry(MENU_1, "MARBLE 1", true)
852
AddMenuEntry(MENU_1, "2", false)
853
AddMenuEntry(MENU_1, "3", false)
854
AddMenuEntry(MENU_1, " ", false)
855
AddMenuEntry(MENU_1, "SPRING YARD 1", true)
856
AddMenuEntry(MENU_1, "2", false)
857
AddMenuEntry(MENU_1, "3", false)
858
AddMenuEntry(MENU_1, " ", false)
859
AddMenuEntry(MENU_1, "LABYRINTH 1", true)
860
AddMenuEntry(MENU_1, "2", false)
861
AddMenuEntry(MENU_1, "3", false)
862
AddMenuEntry(MENU_1, " ", false)
863
AddMenuEntry(MENU_1, "STAR LIGHT 1", true)
864
AddMenuEntry(MENU_1, "2", false)
865
AddMenuEntry(MENU_1, "3", false)
866
AddMenuEntry(MENU_1, " ", false)
867
868
// Right column
869
SetupMenu(MENU_2, 0, 3, 1)
870
AddMenuEntry(MENU_2, "SCRAP BRAIN 1", true)
871
AddMenuEntry(MENU_2, "2", false)
872
AddMenuEntry(MENU_2, "3", false)
873
AddMenuEntry(MENU_2, " ", false)
874
AddMenuEntry(MENU_2, "FINAL ", true)
875
AddMenuEntry(MENU_2, " ", false)
876
AddMenuEntry(MENU_2, "SPECIAL STAGE ", true)
877
AddMenuEntry(MENU_2, " ", false)
878
AddMenuEntry(MENU_2, " ", false)
879
880
// (Neat note - In initial S1 versions, spaces were used as placeholder letters rather than @'s)
881
882
AddMenuEntry(MENU_2, "PLAYER@@@@@@@*@@*", true)
883
884
if options.spindash == true
885
AddMenuEntry(MENU_2, "SPINDASH@@@@@*ON*", true)
886
else
887
AddMenuEntry(MENU_2, "SPINDASH@@@@*OFF*", true)
888
end if
889
890
if options.speedCap == true
891
AddMenuEntry(MENU_2, "GND SPD CAP@@*ON*", true)
892
else
893
AddMenuEntry(MENU_2, "GND SPD CAP@*OFF*", true)
894
end if
895
896
if options.airSpeedCap == true
897
AddMenuEntry(MENU_2, "AIR SPD CAP@@*ON*", true)
898
else
899
AddMenuEntry(MENU_2, "AIR SPD CAP@*OFF*", true)
900
end if
901
902
if options.spikeBehavior == true
903
AddMenuEntry(MENU_2, "S1 SPIKES@@@@*ON*", true)
904
else
905
AddMenuEntry(MENU_2, "S1 SPIKES@@@*OFF*", true)
906
end if
907
908
switch options.shieldType
909
case SHIELDTYPE_S1
910
AddMenuEntry(MENU_2, "ITEMS@@@@@@@@*S1*", true)
911
break
912
913
case SHIELDTYPE_S2
914
AddMenuEntry(MENU_2, "ITEMS@@@@@@@@*S2*", true)
915
break
916
917
case SHIELDTYPE_S3_S1
918
AddMenuEntry(MENU_2, "ITEMS@@@@@*S1+S3*", true)
919
break
920
921
case SHIELDTYPE_S3_S2
922
AddMenuEntry(MENU_2, "ITEMS@@@@@*S2+S3*", true)
923
break
924
925
end switch
926
927
if options.superStates == false
928
AddMenuEntry(MENU_2, "MAX EMERALDS *06*", true)
929
else
930
AddMenuEntry(MENU_2, "MAX EMERALDS *07*", true)
931
end if
932
933
AddMenuEntry(MENU_2, " ", false)
934
AddMenuEntry(MENU_2, " ", false)
935
AddMenuEntry(MENU_2, "SOUND TEST *@@*", true)
936
937
menu1.selection = 0
938
menu2.selection = -1
939
940
// Not in the original, but origins compiler swaps the value of SPECIAL_STAGE to 2 (rather than 3 originally)
941
temp0 = 19
942
temp0 *= 6
943
temp0 += 2
944
SetTableValue(SPECIAL_STAGE, temp0, MenuControl_EntryTable)
945
end event
946
947
948
// ========================
949
// Editor Events
950
// ========================
951
952
event RSDKDraw
953
DrawSprite(0)
954
end event
955
956
957
event RSDKLoad
958
LoadSpriteSheet("Global/Display.gif")
959
SpriteFrame(-16, -16, 32, 32, 1, 143)
960
961
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
962
end event
963
964