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/2PVSMenu2.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: 2P VS Menu 2 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 // Set, but never used
15
private alias object.value3 : object.selection
16
private alias object.value4 : object.selectionTimer
17
private alias object.value5 : object.charBox.x
18
private alias object.value6 : object.charBox.y
19
private alias object.value7 : object.sonicAlpha
20
private alias object.value8 : object.tailsAlpha
21
private alias object.value9 : object.knuxAlpha
22
23
// States
24
private alias 0 : 2PVSMENU2_SETUP
25
private alias 1 : 2PVSMENU2_SELECTING
26
private alias 2 : 2PVSMENU2_SELECTEDPLAYER
27
private alias 3 : 2PVSMENU2_SELECTEDBACK
28
private alias 4 : 2PVSMENU2_TOVSMENU3
29
private alias 5 : 2PVSMENU2_TOVSMENU1
30
31
// Selections
32
private alias 0 : 2PVSMENU2_SEL_NONE
33
private alias 1 : 2PVSMENU2_SEL_SONIC
34
private alias 2 : 2PVSMENU2_SEL_TAILS
35
private alias 3 : 2PVSMENU2_SEL_KNUX
36
private alias 4 : 2PVSMENU2_SEL_BACK
37
38
// 2PVSMenu1 Aliases
39
private alias object.value0 : 2PVSMenu1.timer
40
41
// 2PVSMenu1 States
42
private alias 1 : 2PVSMENU1_SELECTING
43
44
// 2PVSMenu3 Aliases
45
private alias object.value0 : 2PVSMenu3.timer
46
47
// 2PVSMenu3 States
48
private alias 1 : 2PVSMENU3_SELECTING
49
50
51
// ========================
52
// Function Declarations
53
// ========================
54
55
reserve function 2PVSMenu2_DrawSonicBox
56
reserve function 2PVSMenu2_DrawTailsBox
57
reserve function 2PVSMenu2_DrawKnuxBox
58
59
60
// ========================
61
// Function Definitions
62
// ========================
63
64
private function 2PVSMenu2_DrawSonicBox
65
temp0 = screen.xcenter
66
temp0 -= object.charBox.x
67
if object.selection == 2PVSMENU2_SEL_SONIC
68
if object.state == 2PVSMENU2_SELECTING
69
temp1 = 3
70
else
71
temp1 = object.selectionTimer
72
temp1 >>= 1
73
temp1 &= 1
74
temp1 += 2
75
end if
76
else
77
temp1 = 2
78
end if
79
object.alpha = object.sonicAlpha
80
DrawSpriteScreenFX(temp1, FX_INK, temp0, object.charBox.y)
81
DrawSpriteScreenFX(4, FX_INK, temp0, object.charBox.y)
82
end function
83
84
85
private function 2PVSMenu2_DrawTailsBox
86
if object.selection == 2PVSMENU2_SEL_TAILS
87
if object.state == 2PVSMENU2_SELECTING
88
temp1 = 3
89
else
90
temp1 = object.selectionTimer
91
temp1 >>= 1
92
temp1 &= 1
93
temp1 += 2
94
end if
95
else
96
temp1 = 2
97
end if
98
object.alpha = object.tailsAlpha
99
DrawSpriteScreenFX(temp1, FX_INK, screen.xcenter, object.charBox.y)
100
DrawSpriteScreenFX(5, FX_INK, screen.xcenter, object.charBox.y)
101
end function
102
103
104
private function 2PVSMenu2_DrawKnuxBox
105
temp0 = screen.xcenter
106
temp0 += object.charBox.x
107
if object.selection == 2PVSMENU2_SEL_KNUX
108
if object.state == 2PVSMENU2_SELECTING
109
temp1 = 3
110
else
111
temp1 = object.selectionTimer
112
temp1 >>= 1
113
temp1 &= 1
114
temp1 += 2
115
end if
116
else
117
temp1 = 2
118
end if
119
object.alpha = object.knuxAlpha
120
DrawSpriteScreenFX(temp1, FX_INK, temp0, object.charBox.y)
121
DrawSpriteScreenFX(6, FX_INK, temp0, object.charBox.y)
122
end function
123
124
125
// ========================
126
// Events
127
// ========================
128
129
event ObjectUpdate
130
switch object.state
131
case 2PVSMENU2_SETUP
132
LoadSpriteSheet("LevelSelect/Icons.gif")
133
object.iconSheet = object.spriteSheet
134
135
// Even if we're setting everything up for it, this 2PVS Menu in particular doesn't have any menus to draw so this goes unused
136
LoadSpriteSheet("LevelSelect/Text.gif")
137
object.textSheet = object.spriteSheet
138
139
if engine.deviceType == STANDARD
140
options.physicalControls = true
141
end if
142
143
if options.physicalControls == false
144
object.selection = 2PVSMENU2_SEL_NONE
145
else
146
object.selection = 2PVSMENU2_SEL_SONIC
147
end if
148
149
object.charBox.x = 80
150
object.charBox.y = 120
151
object.sonicAlpha = 0x100
152
object.tailsAlpha = 0x100
153
object.knuxAlpha = 0x100
154
object.inkEffect = INK_ALPHA
155
object.state++
156
break
157
158
case 2PVSMENU2_SELECTING
159
if options.physicalControls == false
160
CheckTouchRect(0, 0, screen.xsize, screen.ysize)
161
if checkResult > -1
162
temp0 = screen.xcenter
163
temp0 -= object.charBox.x
164
temp0 -= 32
165
166
temp1 = temp0
167
temp1 += 64
168
temp2 = object.charBox.y
169
temp2 -= 32
170
temp3 = temp2
171
temp3 += 64
172
object.selection = 2PVSMENU2_SEL_NONE
173
CheckTouchRect(temp0, temp2, temp1, temp3)
174
if checkResult > -1
175
object.selection = 2PVSMENU2_SEL_SONIC
176
end if
177
178
temp0 = screen.xcenter
179
temp0 -= 32
180
temp1 = temp0
181
temp1 += 64
182
CheckTouchRect(temp0, temp2, temp1, temp3)
183
if checkResult > -1
184
object.selection = 2PVSMENU2_SEL_TAILS
185
end if
186
187
temp0 = screen.xcenter
188
temp0 += object.charBox.x
189
temp0 -= 32
190
temp1 = temp0
191
temp1 += 64
192
CheckTouchRect(temp0, temp2, temp1, temp3)
193
if checkResult > -1
194
object.selection = 2PVSMENU2_SEL_KNUX
195
end if
196
197
temp0 = screen.xcenter
198
temp0 -= 24
199
temp1 = temp0
200
temp1 += 48
201
CheckTouchRect(temp0, 192, temp1, 224)
202
if checkResult > -1
203
object.selection = 2PVSMENU2_SEL_BACK
204
end if
205
else
206
switch object.selection
207
default
208
case 2PVSMENU2_SEL_NONE
209
break
210
211
case 2PVSMENU2_SEL_SONIC
212
case 2PVSMENU2_SEL_TAILS
213
case 2PVSMENU2_SEL_KNUX
214
object.state = 2PVSMENU2_SELECTEDPLAYER
215
object.selectionTimer = 0
216
PlaySfx(SfxName[Star Post], false)
217
break
218
219
case 2PVSMENU2_SEL_BACK
220
object.state = 2PVSMENU2_SELECTEDBACK
221
object.selectionTimer = 0
222
PlaySfx(SfxName[Menu Back], false)
223
break
224
225
end switch
226
end if
227
228
if object.state != 2PVSMENU2_SELECTEDPLAYER
229
if keyPress[0].left == true
230
options.physicalControls = true
231
object.selection = 2PVSMENU2_SEL_KNUX
232
end if
233
234
if keyPress[0].right == true
235
options.physicalControls = true
236
object.selection = 2PVSMENU2_SEL_SONIC
237
end if
238
239
if keyPress[0].up == true
240
options.physicalControls = true
241
object.selection = 2PVSMENU2_SEL_BACK
242
end if
243
244
if keyPress[0].down == true
245
options.physicalControls = true
246
object.selection = 2PVSMENU2_SEL_TAILS
247
end if
248
end if
249
else
250
if keyPress[0].left == true
251
object.selection--
252
if object.selection < 2PVSMENU2_SEL_SONIC
253
object.selection = 2PVSMENU2_SEL_KNUX
254
end if
255
256
PlaySfx(SfxName[Menu Move], false)
257
end if
258
259
if keyPress[0].right == true
260
object.selection++
261
if object.selection > 2PVSMENU2_SEL_KNUX
262
object.selection = 2PVSMENU2_SEL_SONIC
263
end if
264
265
PlaySfx(SfxName[Menu Move], false)
266
end if
267
268
if keyPress[0].up == true
269
if object.selection < 2PVSMENU2_SEL_BACK
270
object.selection = 2PVSMENU2_SEL_BACK
271
else
272
object.selection = 2PVSMENU2_SEL_TAILS
273
end if
274
275
PlaySfx(SfxName[Menu Move], false)
276
end if
277
278
if keyPress[0].down == true
279
if object.selection < 2PVSMENU2_SEL_BACK
280
object.selection = 2PVSMENU2_SEL_BACK
281
else
282
object.selection = 2PVSMENU2_SEL_TAILS
283
end if
284
285
PlaySfx(SfxName[Menu Move], false)
286
end if
287
288
if keyPress[0].start == true
289
if object.selection < 2PVSMENU2_SEL_BACK
290
object.state = 2PVSMENU2_SELECTEDPLAYER
291
object.selectionTimer = 0
292
PlaySfx(SfxName[Star Post], false)
293
else
294
object.state = 2PVSMENU2_SELECTEDBACK
295
object.selectionTimer = 0
296
PlaySfx(SfxName[Menu Back], false)
297
end if
298
end if
299
300
if keyPress[0].buttonA == true
301
object.state = 2PVSMENU2_SELECTEDPLAYER
302
object.selectionTimer = 0
303
PlaySfx(SfxName[Star Post], false)
304
end if
305
306
if keyPress[0].buttonB == true
307
object.state = 2PVSMENU2_SELECTEDBACK
308
object.selection = 2PVSMENU2_SEL_BACK
309
object.selectionTimer = 0
310
PlaySfx(SfxName[Menu Back], false)
311
end if
312
313
if object.state != 2PVSMENU2_SELECTEDPLAYER
314
CheckTouchRect(0, 0, screen.xsize, screen.ysize)
315
if checkResult > -1
316
options.physicalControls = false
317
object.selection = 2PVSMENU2_SEL_NONE
318
end if
319
end if
320
end if
321
break
322
323
case 2PVSMENU2_SELECTEDPLAYER
324
switch object.selection
325
default
326
case 2PVSMENU2_SEL_NONE
327
case 2PVSMENU2_SEL_BACK
328
break
329
330
case 2PVSMENU2_SEL_SONIC
331
object.tailsAlpha -= 8
332
object.knuxAlpha -= 8
333
break
334
335
case 2PVSMENU2_SEL_TAILS
336
object.sonicAlpha -= 8
337
object.knuxAlpha -= 8
338
break
339
340
case 2PVSMENU2_SEL_KNUX
341
object.sonicAlpha -= 8
342
object.tailsAlpha -= 8
343
break
344
345
end switch
346
347
if object.selectionTimer < 32
348
object.selectionTimer++
349
object.charBox.x = 32
350
object.charBox.x -= object.selectionTimer
351
object.charBox.x *= 80
352
object.charBox.x >>= 5
353
else
354
object.selectionTimer = 0
355
object.charBox.x = 0
356
object.timer = -256
357
object.state = 2PVSMENU2_TOVSMENU3
358
end if
359
break
360
361
case 2PVSMENU2_SELECTEDBACK
362
if object.selectionTimer < 32
363
object.selectionTimer++
364
else
365
object.selectionTimer = 0
366
object.state = 2PVSMENU2_TOVSMENU1
367
end if
368
break
369
370
case 2PVSMENU2_TOVSMENU3
371
if object.timer < 0x100
372
object.timer += 0x10
373
if object.timer > 0
374
SetScreenFade(0x00, 0x00, 0x00, object.timer)
375
end if
376
else
377
stage.playerListPos = object.selection
378
stage.playerListPos--
379
ResetObjectEntity(1, TypeName[2P VS Menu 3], 0, 0, 0)
380
object[1].priority = PRIORITY_ACTIVE
381
object[0].state = 2PVSMENU1_SELECTING
382
2PVSMenu3[0].timer = 384
383
SetScreenFade(0x00, 0x00, 0x00, 0xFF)
384
CallNativeFunction2(Connect2PVS, vs.gameLength, vs.itemMode)
385
end if
386
break
387
388
case 2PVSMENU2_TOVSMENU1
389
if object.timer < 0x100
390
object.timer += 0x10
391
SetScreenFade(0x00, 0x00, 0x00, object.timer)
392
else
393
ResetObjectEntity(1, TypeName[2P VS Menu 1], 0, 0, 0)
394
object[1].priority = PRIORITY_ACTIVE
395
object[0].state = 2PVSMENU3_SELECTING
396
2PVSMenu1[0].timer = 384
397
SetScreenFade(0x00, 0x00, 0x00, 0xFF)
398
end if
399
break
400
401
end switch
402
end event
403
404
405
event ObjectDraw
406
object.spriteSheet = object.iconSheet
407
408
// PLAYER SELECT
409
DrawSpriteScreenXY(0, screen.xcenter, 17)
410
DrawSpriteScreenXY(1, screen.xcenter, 17)
411
412
if object.state == 2PVSMENU2_SELECTEDBACK
413
temp0 = object.selectionTimer
414
temp0 >>= 1
415
temp0 &= 1
416
temp0 += 7
417
else
418
if options.physicalControls == false
419
if object.selection == 2PVSMENU2_SEL_BACK
420
temp0 = 1
421
else
422
temp0 = 0
423
end if
424
else
425
temp0 = 0
426
end if
427
428
temp0 += 7
429
end if
430
431
DrawSpriteScreenXY(temp0, screen.xcenter, 210)
432
switch object.selection
433
case 2PVSMENU2_SEL_NONE
434
case 2PVSMENU2_SEL_SONIC
435
CallFunction(2PVSMenu2_DrawTailsBox)
436
CallFunction(2PVSMenu2_DrawKnuxBox)
437
CallFunction(2PVSMenu2_DrawSonicBox)
438
break
439
440
case 2PVSMENU2_SEL_TAILS
441
CallFunction(2PVSMenu2_DrawKnuxBox)
442
CallFunction(2PVSMenu2_DrawSonicBox)
443
CallFunction(2PVSMenu2_DrawTailsBox)
444
break
445
446
case 2PVSMENU2_SEL_KNUX
447
CallFunction(2PVSMenu2_DrawTailsBox)
448
CallFunction(2PVSMenu2_DrawSonicBox)
449
CallFunction(2PVSMenu2_DrawKnuxBox)
450
break
451
452
case 2PVSMENU2_SEL_BACK
453
CallFunction(2PVSMenu2_DrawSonicBox)
454
CallFunction(2PVSMenu2_DrawTailsBox)
455
CallFunction(2PVSMenu2_DrawKnuxBox)
456
457
// Back Button Selection Box
458
if object.state != 2PVSMENU2_SELECTEDBACK
459
if options.physicalControls == true
460
DrawSpriteScreenXY(9, screen.xcenter, 210)
461
end if
462
end if
463
break
464
465
end switch
466
end event
467
468
469
event ObjectStartup
470
LoadSpriteSheet("LevelSelect/Icons.gif")
471
LoadSpriteSheet("LevelSelect/Text.gif") // Unused here
472
SpriteFrame(-104, 0, 96, 14, 1, 249) // PLAYER text - #0
473
SpriteFrame(8, 0, 96, 14, 1, 264) // SELECT text - #1
474
SpriteFrame(-32, -32, 64, 64, 98, 249) // Details Border - #2
475
SpriteFrame(-32, -32, 64, 64, 163, 249) // Details Border (Selected) - #3
476
SpriteFrame(-12, -20, 24, 40, 1, 279) // Sonic - #4
477
SpriteFrame(-16, -20, 32, 40, 54, 279) // Tails - #5
478
SpriteFrame(-14, -20, 27, 40, 26, 279) // Knuckles - #6
479
SpriteFrame(-20, -10, 40, 20, 1, 341) // Back - #7
480
SpriteFrame(-20, -10, 40, 20, 42, 341) // Back (Selected) - #8
481
SpriteFrame(-22, -12, 42, 22, 1, 362) // Selection Box - #9
482
483
foreach (TypeName[2P VS Menu 2], arrayPos0, ALL_ENTITIES)
484
object[arrayPos0].priority = PRIORITY_ACTIVE
485
next
486
end event
487
488
489
// ========================
490
// Editor Events
491
// ========================
492
493
event RSDKDraw
494
DrawSprite(0)
495
DrawSprite(1)
496
end event
497
498
499
event RSDKLoad
500
LoadSpriteSheet("LevelSelect/Icons.gif")
501
SpriteFrame(-104, 0, 96, 14, 1, 249) // PLAYER text - #0
502
SpriteFrame(8, 0, 96, 14, 1, 264) // SELECT text - #1
503
504
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
505
end event
506
507