Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/2PVS/2PVSMenu1.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: 2P VS Menu 1 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.iconSheet
14
private alias object.value2 : object.textSheet
15
private alias object.value3 : object.selection
16
private alias object.value4 : object.buttonOption
17
private alias object.value5 : object.selectionTimer
18
19
private alias object.value6 : object.prevGameLenSelected
20
private alias object.value7 : object.prevItemModeSelected
21
private alias object.value8 : object.nextGameLenSelected
22
private alias object.value9 : object.nextItemModeSelected
23
private alias object.value10 : object.okSelected
24
private alias object.value11 : object.backSelected
25
26
// States
27
private alias 0 : 2PVSMENU1_SETUP
28
private alias 1 : 2PVSMENU1_SELECTING
29
private alias 2 : 2PVSMENU1_SELECTEDOPTION
30
private alias 3 : 2PVSMENU1_TOVSMENU2
31
private alias 4 : 2PVSMENU1_EXITTOMENU
32
33
// Selections
34
private alias 0 : 2PVSMENU1_SEL_NONE
35
private alias 1 : 2PVSMENU1_SEL_GAMELEN
36
private alias 2 : 2PVSMENU1_SEL_ITEMMODE
37
private alias 3 : 2PVSMENU1_SEL_OKBACK
38
39
// Button Selections
40
private alias 0 : 2PVSMENU1_BTN_OK
41
private alias 1 : 2PVSMENU1_BTN_BACK
42
43
// 2PVSMenu2 Aliases
44
private alias object.value0 : 2PVSMenu2.timer
45
46
// 2PVSMenu2 States
47
private alias 1 : 2PVSMENU2_SELECTING
48
49
// Item Mode Aliases
50
private alias 0 : ITEMMODE_NOPREFERENCE
51
private alias 1 : ITEMMODE_RANDOM
52
private alias 2 : ITEMMODE_TELEPORTONLY
53
private alias 3 : ITEMMODE_FIXED
54
55
56
// ========================
57
// Function Declarations
58
// ========================
59
60
reserve function 2PVSMenu1_SetupMatchLenText
61
reserve function 2PVSMenu1_SetupItemsText
62
63
64
// ========================
65
// Function Definitions
66
// ========================
67
68
private function 2PVSMenu1_SetupMatchLenText
69
switch vs.gameLength
70
case 0
71
EditMenuEntry(MENU_1, "GAME: NO PREFERENCE", 0, true)
72
break
73
74
case 1
75
EditMenuEntry(MENU_1, "GAME: 1 MATCH ", 0, true)
76
break
77
78
case 2
79
EditMenuEntry(MENU_1, "GAME: 2 MATCHES", 0, true)
80
break
81
82
case 3
83
EditMenuEntry(MENU_1, "GAME: 3 MATCHES", 0, true)
84
break
85
86
case 4
87
EditMenuEntry(MENU_1, "GAME: 4 MATCHES", 0, true)
88
break
89
90
case 5
91
EditMenuEntry(MENU_1, "GAME: 5 MATCHES", 0, true)
92
break
93
94
case 6
95
EditMenuEntry(MENU_1, "GAME: 6 MATCHES", 0, true)
96
break
97
98
case 7
99
EditMenuEntry(MENU_1, "GAME: 7 MATCHES", 0, true)
100
break
101
102
case 8
103
EditMenuEntry(MENU_1, "GAME: 8 MATCHES", 0, true)
104
break
105
106
end switch
107
end function
108
109
110
private function 2PVSMenu1_SetupItemsText
111
switch vs.itemMode
112
case ITEMMODE_NOPREFERENCE
113
EditMenuEntry(MENU_1, "ITEMS: NO PREFERENCE", 8, true)
114
break
115
116
case ITEMMODE_RANDOM
117
EditMenuEntry(MENU_1, "ITEMS: RANDOM", 8, true)
118
break
119
120
case ITEMMODE_TELEPORTONLY
121
EditMenuEntry(MENU_1, "ITEMS: TELEPORT ONLY", 8, true)
122
break
123
124
case ITEMMODE_FIXED
125
EditMenuEntry(MENU_1, "ITEMS: FIXED", 8, true)
126
break
127
128
end switch
129
end function
130
131
132
// ========================
133
// Events
134
// ========================
135
136
event ObjectUpdate
137
switch object.state
138
case 2PVSMENU1_SETUP
139
SetupMenu(MENU_1, 0, 3, 2)
140
LoadSpriteSheet("LevelSelect/Icons.gif")
141
object.iconSheet = object.spriteSheet
142
LoadSpriteSheet("LevelSelect/Text.gif")
143
object.textSheet = object.spriteSheet
144
145
if engine.deviceType == STANDARD
146
options.physicalControls = true
147
end if
148
149
if options.physicalControls == false
150
menu1.selection = -1
151
object.selection = 2PVSMENU1_SEL_NONE
152
else
153
menu1.selection = 0
154
object.selection = 2PVSMENU1_SEL_GAMELEN
155
end if
156
157
#platform: USE_ORIGINS
158
// It's local multiplayer, you choose or you lose.
159
if vs.gameLength == 0
160
vs.gameLength = 1
161
end if
162
163
if vs.itemMode == ITEMMODE_NOPREFERENCE
164
vs.itemMode = ITEMMODE_RANDOM
165
end if
166
#endplatform
167
168
AddMenuEntry(MENU_1, "GAME: NO PREFERENCE", true)
169
CallFunction(2PVSMenu1_SetupMatchLenText)
170
AddMenuEntry(MENU_1, "@", true)
171
AddMenuEntry(MENU_1, "@", true)
172
AddMenuEntry(MENU_1, "@", true)
173
AddMenuEntry(MENU_1, "@", true)
174
AddMenuEntry(MENU_1, "@", true)
175
AddMenuEntry(MENU_1, "@", true)
176
AddMenuEntry(MENU_1, "@", true)
177
AddMenuEntry(MENU_1, "ITEMS: NO PREFERENCE", true)
178
179
CallFunction(2PVSMenu1_SetupItemsText)
180
181
object.state++
182
break
183
184
case 2PVSMENU1_SELECTING
185
if options.physicalControls == false
186
CheckTouchRect(0, 0, screen.xsize, screen.ysize)
187
if checkResult > -1
188
// Prev Game Length/Item Mode
189
temp0 = screen.xcenter
190
temp0 -= 152
191
temp1 = temp0
192
temp1 += 38
193
CheckTouchRect(temp0, 72, temp1, 104)
194
if checkResult > -1
195
object.prevGameLenSelected = true
196
else
197
object.prevGameLenSelected = false
198
end if
199
CheckTouchRect(temp0, 136, temp1, 168)
200
if checkResult > -1
201
object.prevItemModeSelected = true
202
else
203
object.prevItemModeSelected = false
204
end if
205
206
// Next Game Length/Item Mode
207
temp0 = screen.xcenter
208
temp0 += 116
209
temp1 = temp0
210
temp1 += 38
211
CheckTouchRect(temp0, 72, temp1, 104)
212
if checkResult > -1
213
object.nextGameLenSelected = true
214
else
215
object.nextGameLenSelected = false
216
end if
217
CheckTouchRect(temp0, 136, temp1, 168)
218
if checkResult > -1
219
object.nextItemModeSelected = true
220
else
221
object.nextItemModeSelected = false
222
end if
223
224
// OK button
225
temp0 = screen.xcenter
226
temp0 += 8
227
temp1 = temp0
228
temp1 += 64
229
CheckTouchRect(temp0, 192, temp1, 224)
230
if checkResult > -1
231
object.okSelected = true
232
else
233
object.okSelected = false
234
end if
235
236
// Back button
237
temp1 = screen.xcenter
238
temp1 -= 8
239
temp0 = temp1
240
temp0 -= 64
241
CheckTouchRect(temp0, 192, temp1, 224)
242
if checkResult > -1
243
object.backSelected = true
244
else
245
object.backSelected = false
246
end if
247
else
248
if object.prevGameLenSelected == true
249
object.prevGameLenSelected = false
250
vs.gameLength--
251
if vs.gameLength < 0
252
vs.gameLength = 8
253
end if
254
255
CallFunction(2PVSMenu1_SetupMatchLenText)
256
PlaySfx(SfxName[Menu Move], false)
257
end if
258
259
if object.prevItemModeSelected == true
260
object.prevItemModeSelected = false
261
vs.itemMode--
262
if vs.itemMode < ITEMMODE_NOPREFERENCE
263
vs.itemMode = ITEMMODE_FIXED
264
end if
265
266
CallFunction(2PVSMenu1_SetupItemsText)
267
PlaySfx(SfxName[Menu Move], false)
268
end if
269
270
if object.nextGameLenSelected == true
271
object.nextGameLenSelected = false
272
vs.gameLength++
273
if vs.gameLength > 8
274
vs.gameLength = 0
275
end if
276
277
CallFunction(2PVSMenu1_SetupMatchLenText)
278
PlaySfx(SfxName[Menu Move], false)
279
end if
280
281
if object.nextItemModeSelected == true
282
object.nextItemModeSelected = false
283
vs.itemMode++
284
if vs.itemMode > ITEMMODE_FIXED
285
vs.itemMode = ITEMMODE_NOPREFERENCE
286
end if
287
288
CallFunction(2PVSMenu1_SetupItemsText)
289
PlaySfx(SfxName[Menu Move], false)
290
end if
291
292
if object.okSelected == true
293
object.okSelected = false
294
object.state = 2PVSMENU1_SELECTEDOPTION
295
object.buttonOption = 2PVSMENU1_BTN_OK
296
PlaySfx(SfxName[Menu Select], false)
297
end if
298
299
if object.backSelected == true
300
object.backSelected = false
301
object.state = 2PVSMENU1_SELECTEDOPTION
302
object.buttonOption = 2PVSMENU1_BTN_BACK
303
PlaySfx(SfxName[Menu Back], false)
304
end if
305
end if
306
307
if object.state != 2PVSMENU1_SELECTEDOPTION
308
if keyPress[0].up == true
309
options.physicalControls = true
310
object.selection = 2PVSMENU1_SEL_OKBACK
311
end if
312
313
if keyPress[0].down == true
314
options.physicalControls = true
315
object.selection = 2PVSMENU1_SEL_GAMELEN
316
end if
317
end if
318
else
319
if keyPress[0].up == true
320
object.selection--
321
if object.selection < 2PVSMENU1_SEL_GAMELEN
322
object.selection = 2PVSMENU1_SEL_OKBACK
323
end if
324
325
PlaySfx(SfxName[Menu Move], false)
326
end if
327
328
if keyPress[0].down == true
329
object.selection++
330
if object.selection > 2PVSMENU1_SEL_OKBACK
331
object.selection = 2PVSMENU1_SEL_GAMELEN
332
end if
333
334
PlaySfx(SfxName[Menu Move], false)
335
end if
336
337
switch object.selection
338
default
339
case 2PVSMENU1_SEL_NONE
340
break
341
342
case 2PVSMENU1_SEL_GAMELEN
343
menu1.selection = 0
344
if keyPress[0].left == true
345
vs.gameLength--
346
// (Origins removes the No Preference setting)
347
#platform: USE_STANDALONE
348
if vs.gameLength < 0
349
#endplatform
350
#platform: USE_ORIGINS
351
if vs.gameLength < 1
352
#endplatform
353
vs.gameLength = 8
354
end if
355
356
CallFunction(2PVSMenu1_SetupMatchLenText)
357
PlaySfx(SfxName[Menu Move], false)
358
end if
359
360
if keyPress[0].right == true
361
vs.gameLength++
362
if vs.gameLength > 8
363
// (Origins removes the No Preference setting)
364
#platform: USE_STANDALONE
365
vs.gameLength = 0
366
#endplatform
367
#platform: USE_ORIGINS
368
vs.gameLength = 1
369
#endplatform
370
end if
371
372
CallFunction(2PVSMenu1_SetupMatchLenText)
373
PlaySfx(SfxName[Menu Move], false)
374
end if
375
376
if keyPress[0].buttonB == true
377
menu1.selection = -1
378
object.buttonOption = 2PVSMENU1_BTN_BACK
379
object.state = 2PVSMENU1_SELECTEDOPTION
380
PlaySfx(SfxName[Menu Back], false)
381
end if
382
break
383
384
case 2PVSMENU1_SEL_ITEMMODE
385
menu1.selection = 8
386
if keyPress[0].left == true
387
vs.itemMode--
388
#platform: USE_STANDALONE
389
if vs.itemMode < ITEMMODE_NOPREFERENCE
390
#endplatform
391
#platform: USE_ORIGINS
392
if vs.itemMode < ITEMMODE_RANDOM
393
#endplatform
394
vs.itemMode = ITEMMODE_FIXED
395
end if
396
397
CallFunction(2PVSMenu1_SetupItemsText)
398
PlaySfx(SfxName[Menu Move], false)
399
end if
400
401
if keyPress[0].right == true
402
vs.itemMode++
403
if vs.itemMode > ITEMMODE_FIXED
404
#platform: USE_STANDALONE
405
vs.itemMode = ITEMMODE_NOPREFERENCE
406
#endplatform
407
#platform: USE_ORIGINS
408
vs.itemMode = ITEMMODE_RANDOM
409
#endplatform
410
end if
411
412
CallFunction(2PVSMenu1_SetupItemsText)
413
PlaySfx(SfxName[Menu Move], false)
414
end if
415
416
if keyPress[0].buttonB == true
417
menu1.selection = -1
418
object.buttonOption = 2PVSMENU1_BTN_BACK
419
object.state = 2PVSMENU1_SELECTEDOPTION
420
PlaySfx(SfxName[Menu Back], false)
421
end if
422
break
423
424
case 2PVSMENU1_SEL_OKBACK
425
menu1.selection = -1
426
if keyPress[0].left == true
427
object.buttonOption ^= 1
428
PlaySfx(SfxName[Menu Move], false)
429
end if
430
431
if keyPress[0].right == true
432
object.buttonOption ^= 1
433
PlaySfx(SfxName[Menu Move], false)
434
end if
435
436
if keyPress[0].start == true
437
object.state = 2PVSMENU1_SELECTEDOPTION
438
PlaySfx(SfxName[Menu Select], false)
439
end if
440
441
if keyPress[0].buttonA == true
442
object.state = 2PVSMENU1_SELECTEDOPTION
443
PlaySfx(SfxName[Menu Select], false)
444
end if
445
446
if keyPress[0].buttonB == true
447
object.buttonOption = 2PVSMENU1_BTN_BACK
448
object.state = 2PVSMENU1_SELECTEDOPTION
449
PlaySfx(SfxName[Menu Back], false)
450
end if
451
break
452
453
end switch
454
455
if object.state != 2PVSMENU1_SELECTEDOPTION
456
CheckTouchRect(0, 0, screen.xsize, screen.ysize)
457
if checkResult > -1
458
options.physicalControls = false
459
object.selection = 2PVSMENU1_SEL_NONE
460
menu1.selection = -1
461
end if
462
end if
463
end if
464
break
465
466
case 2PVSMENU1_SELECTEDOPTION
467
if object.selectionTimer < 32
468
object.selectionTimer++
469
else
470
object.selectionTimer = 0
471
if object.buttonOption == 2PVSMENU1_BTN_OK
472
object.state = 2PVSMENU1_TOVSMENU2
473
else
474
object.state = 2PVSMENU1_EXITTOMENU
475
end if
476
end if
477
break
478
479
case 2PVSMENU1_TOVSMENU2 // Goes to 2P VS Menu 4 in Origins
480
if object.timer < 256
481
object.timer += 16
482
SetScreenFade(0x00, 0x00, 0x00, object.timer)
483
else
484
#platform: USE_STANDALONE
485
// In networking mode we have only a single, online multiplayer menu
486
ResetObjectEntity(1, TypeName[2P VS Menu 2], 0, 0, 0)
487
object[1].priority = PRIORITY_ACTIVE
488
#endplatform
489
#platform: USE_ORIGINS
490
// In local multiplayer mode we have two menus, one for each player present
491
ResetObjectEntity(1, TypeName[2P VS Menu 4], 1, 0, 88)
492
object[1].priority = PRIORITY_ACTIVE
493
ResetObjectEntity(2, TypeName[2P VS Menu 4], 2, 0, 168)
494
object[2].priority = PRIORITY_ACTIVE
495
#endplatform
496
object[0].state = 2PVSMENU2_SELECTING
497
2PVSMenu2[0].timer = 384
498
SetScreenFade(0x00, 0x00, 0x00, 0xFF)
499
end if
500
break
501
502
case 2PVSMENU1_EXITTOMENU
503
if object.timer < 256
504
music.volume -= 10
505
object.timer += 16
506
SetScreenFade(0x00, 0x00, 0x00, object.timer)
507
else
508
StopMusic()
509
options.vsMode = false
510
#platform: USE_STANDALONE
511
engine.state = 8
512
#endplatform
513
#platform: USE_ORIGINS
514
game.titleMode = true
515
stage.activeList = PRESENTATION_STAGE
516
stage.listPos = 0
517
LoadStage()
518
#endplatform
519
SetScreenFade(0x00, 0x00, 0x00, 0xFF)
520
end if
521
break
522
523
end switch
524
end event
525
526
527
event ObjectDraw
528
object.spriteSheet = object.iconSheet
529
DrawSpriteScreenXY(0, screen.xcenter, 17)
530
DrawSpriteScreenXY(1, screen.xcenter, 17)
531
532
if object.selection == 2PVSMENU1_SEL_GAMELEN
533
DrawSpriteScreenXY(3, screen.xcenter, 64)
534
else
535
DrawSpriteScreenXY(2, screen.xcenter, 64)
536
end if
537
538
if object.selection == 2PVSMENU1_SEL_ITEMMODE
539
DrawSpriteScreenXY(3, screen.xcenter, 128)
540
else
541
DrawSpriteScreenXY(2, screen.xcenter, 128)
542
end if
543
544
switch object.selection
545
case 2PVSMENU1_SEL_NONE
546
if object.prevGameLenSelected == true
547
DrawSpriteScreenXY(5, screen.xcenter, 88)
548
else
549
DrawSpriteScreenXY(4, screen.xcenter, 88)
550
end if
551
552
if object.nextGameLenSelected == true
553
DrawSpriteScreenXY(7, screen.xcenter, 88)
554
else
555
DrawSpriteScreenXY(6, screen.xcenter, 88)
556
end if
557
558
if object.prevItemModeSelected == true
559
DrawSpriteScreenXY(5, screen.xcenter, 152)
560
else
561
DrawSpriteScreenXY(4, screen.xcenter, 152)
562
end if
563
564
if object.nextItemModeSelected == true
565
DrawSpriteScreenXY(7, screen.xcenter, 152)
566
else
567
DrawSpriteScreenXY(6, screen.xcenter, 152)
568
end if
569
break
570
571
case 2PVSMENU1_SEL_GAMELEN
572
if keyDown[0].left == true
573
DrawSpriteScreenXY(5, screen.xcenter, 88)
574
else
575
DrawSpriteScreenXY(4, screen.xcenter, 88)
576
end if
577
578
if keyDown[0].right == true
579
DrawSpriteScreenXY(7, screen.xcenter, 88)
580
else
581
DrawSpriteScreenXY(6, screen.xcenter, 88)
582
end if
583
break
584
585
case 2PVSMENU1_SEL_ITEMMODE
586
if keyDown[0].left == true
587
DrawSpriteScreenXY(5, screen.xcenter, 152)
588
else
589
DrawSpriteScreenXY(4, screen.xcenter, 152)
590
end if
591
592
if keyDown[0].right == true
593
DrawSpriteScreenXY(7, screen.xcenter, 152)
594
else
595
DrawSpriteScreenXY(6, screen.xcenter, 152)
596
end if
597
break
598
599
end switch
600
601
temp0 = object.selectionTimer
602
temp0 >>= 1
603
temp0 &= 1
604
if temp0 == 0
605
if object.okSelected == true
606
DrawSpriteScreenXY(9, screen.xcenter, 210)
607
else
608
DrawSpriteScreenXY(8, screen.xcenter, 210)
609
end if
610
611
if object.backSelected == true
612
DrawSpriteScreenXY(11, screen.xcenter, 210)
613
else
614
DrawSpriteScreenXY(10, screen.xcenter, 210)
615
end if
616
else
617
if object.buttonOption == 2PVSMENU1_BTN_OK
618
DrawSpriteScreenXY(9, screen.xcenter, 210)
619
DrawSpriteScreenXY(10, screen.xcenter, 210)
620
else
621
DrawSpriteScreenXY(8, screen.xcenter, 210)
622
DrawSpriteScreenXY(11, screen.xcenter, 210)
623
end if
624
end if
625
626
if object.state < 2PVSMENU1_SELECTEDOPTION
627
if object.selection == 2PVSMENU1_SEL_OKBACK
628
if object.buttonOption == 2PVSMENU1_BTN_OK
629
DrawSpriteScreenXY(12, screen.xcenter, 210)
630
else
631
DrawSpriteScreenXY(13, screen.xcenter, 210)
632
end if
633
end if
634
end if
635
636
object.spriteSheet = object.textSheet
637
temp0 = screen.xcenter
638
temp0 -= 8
639
DrawMenu(MENU_1, screen.xcenter, 84)
640
end event
641
642
643
event ObjectStartup
644
LoadSpriteSheet("LevelSelect/Icons.gif")
645
LoadSpriteSheet("LevelSelect/Text.gif")
646
SpriteFrame(-56, 0, 32, 14, 185, 124) // VS text - #0
647
SpriteFrame(-8, 0, 64, 14, 185, 109) // MODE text - #1
648
SpriteFrame(-112, 0, 224, 48, 1, 151) // Details Border - #2
649
SpriteFrame(-112, 0, 224, 48, 1, 200) // Details Border (Selected) - #3
650
SpriteFrame(-142, -10, 20, 20, 138, 22) // Left - #4
651
SpriteFrame(-142, -10, 20, 20, 138, 64) // Left (Selected) - #5
652
SpriteFrame(122, -10, 20, 20, 159, 22) // Right - #6
653
SpriteFrame(122, -10, 20, 20, 159, 64) // Right (Selected) - #7
654
SpriteFrame(20, -10, 40, 20, 1, 320) // OK - #8
655
SpriteFrame(20, -10, 40, 20, 42, 320) // OK (Selected) - #9
656
SpriteFrame(-60, -10, 40, 20, 1, 341) // Back - #10
657
SpriteFrame(-60, -10, 40, 20, 42, 341) // Back (Selected) - #11
658
SpriteFrame(18, -12, 42, 22, 1, 362) // Selection Box (OK) - #12
659
SpriteFrame(-62, -12, 42, 22, 1, 362) // Selection Box (Back) - #13
660
661
foreach (TypeName[2P VS Menu 1], arrayPos0, ALL_ENTITIES)
662
object[arrayPos0].priority = PRIORITY_ACTIVE
663
next
664
end event
665
666
667
// ========================
668
// Editor Events
669
// ========================
670
671
event RSDKDraw
672
DrawSprite(0)
673
DrawSprite(1)
674
end event
675
676
677
event RSDKLoad
678
LoadSpriteSheet("LevelSelect/Icons.gif")
679
SpriteFrame(-56, 0, 32, 14, 185, 124) // VS text - #0
680
SpriteFrame(-8, 0, 64, 14, 185, 109) // MODE text - #1
681
682
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
683
end event
684
685