Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Menu/LoadSaveMenu.txt
1319 views
1
//---------------Sonic CD Load Save Menu Script---------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.FadeValue
7
#alias Object.Value1 : Object.SelectedOption
8
#alias Object.Direction : Object.ShowDeleteButton
9
#alias Object[+4].Rotation : Object.SaveMode
10
#alias Object[+4].Value1 : DeleteConfirm.Highlight
11
12
// Menu Heading Aliases
13
#alias Object[33].State : MenuHeading.State
14
#alias Object[33].PropertyValue : MenuHeading.Header
15
16
// Menu Window Aliases
17
#alias Object[-1].State : MenuWindow.State
18
19
// Back Touch
20
#alias Object[1].Value4 : Object.BackTouchPress
21
22
// Save File State
23
#alias Object.Rotation : Object.SaveStatus // Meant to be used with [+ArrayPos0]
24
#alias Object.Rotation : Object.SaveOneStatus
25
#alias Object[+1].Rotation : Object.SaveTwoStatus
26
#alias Object[+2].Rotation : Object.SaveThreeStatus
27
#alias Object[+3].Rotation : Object.SaveFourStatus
28
29
// Save File Info
30
#alias Object.Value3 : Object.PlayerListPos
31
#alias Object.Value6 : Object.Lives
32
#alias Object.Value5 : Object.Score
33
#alias Object.Value2 : Object.StageListPos
34
#alias Object.Value4 : Object.TimeStones
35
#alias Object.PropertyValue : Object.SpecialListPos
36
#alias Object.Scale : Object.ScoreBonus
37
#alias Object.Value7 : Object.GoodFutureList
38
39
// Delete Button
40
#alias Object[+1].XPos : Delete.XPos
41
#alias Object[+1].YPos : Delete.YPos
42
43
// States
44
#alias 0 : STATE_INITIALIZE
45
#alias 1 : STATE_MAIN_SAVE_MENU
46
#alias 2 : STATE_SAVE_SELECTED
47
#alias 3 : STATE_LOAD_SAVE
48
#alias 4 : STATE_NEW_GAME_SELECTED
49
#alias 5 : STATE_FADEIN_CHARACTERSELECT
50
#alias 6 : STATE_CHARACTER_SELECT
51
#alias 7 : STATE_CHARACTER_SELECTED
52
#alias 8 : STATE_LOAD_NEW_GAME
53
#alias 9 : STATE_FADEOUT_CHARACTERSELECT
54
#alias 10 : STATE_RETURN_TO_SAVESEL
55
#alias 11 : STATE_EXIT
56
#alias 12 : STATE_TOGGLE_DELETE_MODE
57
#alias 13 : STATE_SAVE_SELECTED_DELETE
58
#alias 14 : STATE_SLIDE_DELETE_SAVE
59
#alias 15 : STATE_FADEIN_DELETECONFIRM
60
#alias 16 : STATE_DELETE_CONFIRM
61
#alias 17 : STATE_DELETECONFIRM_SELECTED
62
#alias 18 : STATE_FADEOUT_DELETECONFIRM
63
64
// Menu Heading States
65
#alias 1 : MENUHEADING_LEAVE_SCREEN
66
#alias 2 : MENUHEADING_ENTER_SCREEN
67
#alias 3 : MENUHEADING_BLANK // used by some external scripts
68
69
// Menu Heading Property Values
70
#alias 5 : MAINMENU_HEADER
71
72
// Menu Window States
73
#alias 3 : MENUWINDOW_SHRINK
74
75
// Menu Button States
76
#alias 1 : MENUBUTTON_BUTTONS_IN
77
78
// Soundtrack
79
#alias 0 : OST_JP
80
81
// Game Mode Aliases
82
#alias 1 : MODE_SAVEGAME
83
84
// Save Modes
85
#alias 0 : SAVEMODE_NORMAL
86
#alias 1 : SAVEMODE_NORMAL_SELECTED
87
#alias 2 : SAVEMODE_DELETE
88
#alias 3 : SAVEMODE_DELETE_SELECTED
89
90
// Buttons
91
#alias -1 : BUTTON_NONE // Touching nothing on mobile
92
#alias 0 : BUTTON_SAVE_ONE
93
#alias 1 : BUTTON_SAVE_TWO
94
#alias 2 : BUTTON_SAVE_THREE
95
#alias 3 : BUTTON_SAVE_FOUR
96
#alias 4 : BUTTON_DELETE
97
98
// Save Statuses
99
#alias 0 : SAVE_NORMAL
100
#alias 1 : SAVE_NORMAL_SELECTED
101
#alias 2 : SAVE_DELETE
102
#alias 3 : SAVE_DELETE_SELECTED
103
104
// Character Select Options
105
#alias -1 : PLAYER_NONE // Touching nothing on mobile
106
#alias 0 : PLAYER_SONIC_A
107
#alias 1 : PLAYER_TAILS_A
108
#alias 2 : PLAYER_BACK
109
110
// Delete Confirm Options
111
#alias -1 : DELETE_NONE // Touching nothing on mobile
112
#alias 0 : DELETE_YES
113
#alias 1 : DELETE_NO
114
#alias 2 : DELETE_BACK
115
116
// Presentation Stage
117
#alias 0 : STAGE_R_PPZ1A
118
119
// Special Stage
120
#alias 0 : STAGE_S_SS1
121
122
// Global SFX
123
#alias 9 : SFX_G_LAMPPOST
124
#alias 23 : SFX_G_MENUBUTTON
125
#alias 27 : SFX_G_SELECT
126
127
// Stage SFX
128
#alias 0 : SFX_S_EVENT
129
#alias 1 : SFX_S_BACKBUTTON
130
131
// Engine & Callbacks
132
#alias 2 : MESSAGE_LOSTFOCUS
133
134
// Languages
135
#alias 0 : LANG_ENGLISH
136
#alias 1 : LANG_FRENCH
137
#alias 2 : LANG_ITALIAN
138
#alias 3 : LANG_DEUTSCH
139
#alias 4 : LANG_SPANISH
140
#alias 5 : LANG_JAPANESE
141
142
// Function declarations
143
#function LoadSaveMenu_DrawSaveFiles
144
#function LoadSaveMenu_DrawDeleteNoSave
145
#function LoadSaveMenu_CheckTouchSave
146
#function LoadSaveMenu_SetShowDelete
147
148
149
function LoadSaveMenu_DrawSaveFiles
150
switch Object[+ArrayPos0].SaveStatus
151
case SAVE_DELETE
152
if Object[+ArrayPos0].StageListPos > 0
153
Object.Alpha = 64
154
DrawSpriteScreenFX(56, FX_INK, Object.XPos, Object.YPos)
155
Object.Alpha = 255
156
end if
157
// FallThrough
158
case SAVE_NORMAL
159
if ArrayPos0 == Object.SelectedOption
160
DrawSpriteScreenFX(9, FX_INK, Object.XPos, Object.YPos)
161
TempValue0 = Object[+ArrayPos0].StageListPos
162
if Object[+ArrayPos0].StageListPos > 0 // Is this save used?
163
TempValue0--
164
TempValue0 /= 10
165
if TempValue0 >= 8
166
TempValue0 = 8
167
TempValue1 = Object[+ArrayPos0].SpecialListPos
168
else
169
TempValue2 = TempValue0
170
TempValue2 *= 10
171
172
TempValue1 = Object[+ArrayPos0].StageListPos
173
TempValue1--
174
TempValue1 -= TempValue2
175
TempValue1 >>= 2
176
end if
177
TempValue0 += 21
178
TempValue1 += 67
179
DrawSpriteScreenFX(TempValue1, FX_INK, Object.XPos, Object.YPos)
180
else
181
TempValue0 += 20
182
end if
183
DrawSpriteScreenFX(TempValue0, FX_INK, Object.XPos, Object.YPos)
184
else
185
TempValue0 = Object[+ArrayPos0].StageListPos
186
if Object[+ArrayPos0].StageListPos > 0
187
TempValue0--
188
TempValue0 /= 10
189
if TempValue0 >= 8
190
TempValue0 = 8
191
TempValue1 = Object[+ArrayPos0].SpecialListPos
192
else
193
TempValue2 = TempValue0
194
TempValue2 *= 10
195
196
TempValue1 = Object[+ArrayPos0].StageListPos
197
TempValue1--
198
TempValue1 -= TempValue2
199
TempValue1 >>= 2
200
end if
201
TempValue0 += 11
202
TempValue1 += 59
203
DrawSpriteScreenFX(TempValue1, FX_INK, Object.XPos, Object.YPos)
204
else
205
TempValue0 += 10
206
end if
207
DrawSpriteScreenFX(TempValue0, FX_INK, Object.XPos, Object.YPos)
208
end if
209
break
210
211
case SAVE_DELETE_SELECTED
212
Object.Alpha = 64
213
DrawSpriteScreenFX(56, FX_INK, Object.XPos, Object.YPos)
214
Object.Alpha = 255
215
// FallThrough
216
case SAVE_NORMAL_SELECTED
217
TempValue0 = Object.FadeValue
218
TempValue0 &= 3
219
TempValue0 >>= 1
220
221
DrawSpriteScreenFX(9, FX_INK, Object.XPos, Object.YPos)
222
223
if TempValue0 == 0
224
TempValue0 = Object[+ArrayPos0].StageListPos // Is this save used?
225
if Object[+ArrayPos0].StageListPos > 0
226
TempValue0--
227
TempValue0 /= 10
228
if TempValue0 >= 8 // Is this a special stage?
229
TempValue0 = 8
230
231
TempValue1 = Object[+ArrayPos0].SpecialListPos
232
else
233
TempValue2 = TempValue0
234
TempValue2 *= 10
235
236
TempValue1 = Object[+ArrayPos0].StageListPos
237
TempValue1--
238
TempValue1 -= TempValue2
239
TempValue1 >>= 2
240
end if
241
TempValue0 += 21
242
243
TempValue1 += 67
244
DrawSpriteScreenFX(TempValue1, FX_INK, Object.XPos, Object.YPos)
245
else
246
TempValue0 += 20 // New Game
247
end if
248
DrawSpriteScreenFX(TempValue0, FX_INK, Object.XPos, Object.YPos)
249
end if
250
break
251
end switch
252
253
DrawSpriteScreenFX(8, FX_INK, Object.XPos, Object.YPos)
254
255
if Object[+ArrayPos0].StageListPos > 0 // Is this save used?
256
TempValue0 = Object[+ArrayPos0].PlayerListPos
257
TempValue0 <<= 1
258
TempValue0 += 4
259
260
TempValue1 = Object.AnimationTimer
261
TempValue1 >>= 5
262
TempValue0 += TempValue1
263
DrawSpriteScreenFX(TempValue0, FX_INK, Object.XPos, Object.YPos)
264
265
TempValue0 = 0
266
TempValue1 = 38
267
while TempValue0 < 7
268
TempValue2 = TempValue1
269
GetBit(CheckResult, Object[+ArrayPos0].TimeStones, TempValue0)
270
if CheckResult == false
271
TempValue2 += 7
272
end if
273
DrawSpriteScreenFX(TempValue2, FX_INK, Object.XPos, Object.YPos)
274
TempValue1++
275
TempValue0++
276
loop
277
else
278
DrawSpriteScreenFX(ArrayPos0, FX_INK, Object.XPos, Object.YPos)
279
end if
280
end function
281
282
283
function LoadSaveMenu_DrawDeleteNoSave
284
// Draw the Delete button
285
if Object.SaveMode >= SAVEMODE_DELETE
286
if Object.SelectedOption == BUTTON_DELETE
287
DrawSpriteScreenXY(55, Delete.XPos, Delete.YPos)
288
else
289
DrawSpriteScreenXY(54, Delete.XPos, Delete.YPos)
290
end if
291
else
292
if Object.SelectedOption == BUTTON_DELETE
293
DrawSpriteScreenXY(53, Delete.XPos, Delete.YPos)
294
else
295
DrawSpriteScreenXY(52, Delete.XPos, Delete.YPos)
296
end if
297
end if
298
299
// Slide the Delete button in or out
300
if Object.ShowDeleteButton == true
301
if Delete.YPos > 14
302
Delete.YPos -= 2
303
DrawRect(Delete.XPos, 32, 64, 18, 96, 96, 128, 255)
304
end if
305
else
306
if Delete.YPos < 32
307
Delete.YPos += 2
308
end if
309
DrawRect(Delete.XPos, 32, 64, 18, 96, 96, 128, 255)
310
end if
311
end function
312
313
314
// This function is shared by other scripts
315
function LoadSaveMenu_CheckTouchSave
316
TempValue0 *= 40
317
TempValue0 += Screen.CenterY
318
TempValue0 -= 87
319
TempValue1 = TempValue0
320
TempValue1 += 37
321
TempValue2 = Object.XPos
322
TempValue2 += 250
323
CheckTouchRect(Object.XPos, TempValue0, TempValue2, TempValue1)
324
end function
325
326
327
function LoadSaveMenu_SetShowDelete
328
Object.ShowDeleteButton = false
329
330
// Read save files
331
ArrayPos0 = 0
332
while ArrayPos0 < 4
333
if Object[+ArrayPos0].StageListPos > 0 // Is this save used?
334
Object.ShowDeleteButton = true
335
end if
336
ArrayPos0++
337
loop
338
end function
339
340
341
sub ObjectMain
342
switch Object.State
343
case STATE_INITIALIZE
344
#platform: Use_Origins
345
if Options.PhysicalControls == false
346
Object.SelectedOption = BUTTON_NONE
347
end if
348
#endplatform
349
350
#platform: Mobile
351
if Options.PhysicalControls == false
352
Object.SelectedOption = BUTTON_NONE
353
end if
354
#endplatform
355
356
Object.XPos = Screen.CenterX
357
Object.XPos -= 126
358
359
if Object.FadeValue == 0
360
CallFunction(LoadSaveMenu_SetShowDelete)
361
362
// Read save files
363
ArrayPos0 = 0
364
ArrayPos1 = 0
365
while ArrayPos0 < 4
366
Object[+ArrayPos0].PlayerListPos = SaveRAM[ArrayPos1]
367
ArrayPos1++
368
Object[+ArrayPos0].Lives = SaveRAM[ArrayPos1]
369
ArrayPos1++
370
Object[+ArrayPos0].Score = SaveRAM[ArrayPos1]
371
ArrayPos1++
372
Object[+ArrayPos0].StageListPos = SaveRAM[ArrayPos1]
373
ArrayPos1++
374
Object[+ArrayPos0].TimeStones = SaveRAM[ArrayPos1]
375
ArrayPos1++
376
Object[+ArrayPos0].SpecialListPos = SaveRAM[ArrayPos1]
377
ArrayPos1++
378
Object[+ArrayPos0].ScoreBonus = SaveRAM[ArrayPos1]
379
ArrayPos1++
380
Object[+ArrayPos0].GoodFutureList = SaveRAM[ArrayPos1]
381
ArrayPos1++
382
383
if Object[+ArrayPos0].StageListPos > 0 // Is this save used?
384
Object.ShowDeleteButton = true
385
end if
386
ArrayPos0++
387
loop
388
end if
389
390
Delete.XPos = Screen.CenterX
391
Delete.XPos -= 120
392
Delete.YPos = 32
393
394
if Object.FadeValue < 256
395
Object.Alpha = Object.FadeValue
396
Object.FadeValue += 6
397
else
398
Object.FadeValue = 0
399
Object.Alpha = 255
400
Object.State = STATE_MAIN_SAVE_MENU
401
end if
402
break
403
404
case STATE_MAIN_SAVE_MENU
405
// Flash a button when selected in delete mode
406
if Object.SaveMode == SAVE_DELETE_SELECTED
407
Object.AnimationTimer++
408
Object.AnimationTimer &= 63
409
else
410
Object.AnimationTimer = 0
411
end if
412
413
#platform: Standard
414
CheckResult = true
415
#endplatform
416
417
#platform: Mobile
418
CheckEqual(Options.PhysicalControls, true)
419
#endplatform
420
421
#platform: Use_Origins
422
CheckEqual(Options.PhysicalControls, true)
423
#endplatform
424
425
426
// 2011 Steam lacks Options.PhysicalControls, so we force it here first and the other platforms can override it
427
if CheckResult == true
428
if Object.ShowDeleteButton == false
429
if KeyPress[0].Up == true
430
Object.SelectedOption--
431
PlaySfx(SFX_G_MENUBUTTON, false)
432
if Object.SelectedOption < BUTTON_SAVE_ONE
433
Object.SelectedOption = BUTTON_SAVE_FOUR
434
end if
435
end if
436
if KeyPress[0].Down == true
437
Object.SelectedOption++
438
PlaySfx(SFX_G_MENUBUTTON, false)
439
if Object.SelectedOption > BUTTON_SAVE_FOUR
440
Object.SelectedOption = BUTTON_SAVE_ONE
441
end if
442
end if
443
else
444
if KeyPress[0].Up == true
445
Object.SelectedOption--
446
PlaySfx(SFX_G_MENUBUTTON, false)
447
if Object.SelectedOption < BUTTON_SAVE_ONE
448
Object.SelectedOption = BUTTON_DELETE
449
end if
450
end if
451
if KeyPress[0].Down == true
452
Object.SelectedOption++
453
PlaySfx(SFX_G_MENUBUTTON, false)
454
if Object.SelectedOption > BUTTON_DELETE
455
Object.SelectedOption = BUTTON_SAVE_ONE
456
end if
457
end if
458
end if
459
// Enable touch controls if the screen is touched
460
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
461
if CheckResult > -1
462
#platform: Mobile
463
Options.PhysicalControls = false
464
Object.SelectedOption = BUTTON_NONE
465
#endplatform
466
467
#platform: Use_Origins
468
Options.PhysicalControls = false
469
Object.SelectedOption = BUTTON_NONE
470
#endplatform
471
end if
472
else
473
// Touch Controls
474
475
// Check if the screen is touched (used to check if a touch was released)
476
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
477
TempValue3 = CheckResult
478
479
// Check if the delete button is touched
480
if Object.ShowDeleteButton == true
481
TempValue0 = Delete.XPos
482
TempValue0 -= 4
483
TempValue1 = TempValue0
484
TempValue1 += 72
485
CheckTouchRect(TempValue0, 0, TempValue1, 32)
486
else
487
CheckResult = -1
488
end if
489
490
if CheckResult > -1
491
Object.SelectedOption = BUTTON_DELETE
492
else
493
if TempValue3 < 0
494
if Object.SelectedOption == BUTTON_DELETE
495
KeyPress[0].Start = true
496
end if
497
else
498
if Object.SelectedOption == BUTTON_DELETE
499
Object.SelectedOption = BUTTON_NONE
500
end if
501
end if
502
end if
503
504
// Check if save file 1 is touched
505
TempValue0 = BUTTON_SAVE_ONE
506
CallFunction(LoadSaveMenu_CheckTouchSave)
507
if CheckResult > -1
508
Object.SelectedOption = BUTTON_SAVE_ONE
509
else
510
if TempValue3 < 0
511
if Object.SelectedOption == BUTTON_SAVE_ONE
512
KeyPress[0].Start = true
513
end if
514
else
515
if Object.SelectedOption == BUTTON_SAVE_ONE
516
Object.SelectedOption = BUTTON_NONE
517
end if
518
end if
519
end if
520
521
// Check if save file 2 is touched
522
TempValue0 = BUTTON_SAVE_TWO
523
CallFunction(LoadSaveMenu_CheckTouchSave)
524
if CheckResult > -1
525
Object.SelectedOption = BUTTON_SAVE_TWO
526
else
527
if TempValue3 < 0
528
if Object.SelectedOption == BUTTON_SAVE_TWO
529
KeyPress[0].Start = true
530
end if
531
else
532
if Object.SelectedOption == BUTTON_SAVE_TWO
533
Object.SelectedOption = BUTTON_NONE
534
end if
535
end if
536
end if
537
538
// Check if save file 3 is touched
539
TempValue0 = BUTTON_SAVE_THREE
540
CallFunction(LoadSaveMenu_CheckTouchSave)
541
if CheckResult > -1
542
Object.SelectedOption = BUTTON_SAVE_THREE
543
else
544
if TempValue3 < 0
545
if Object.SelectedOption == BUTTON_SAVE_THREE
546
KeyPress[0].Start = true
547
end if
548
else
549
if Object.SelectedOption == BUTTON_SAVE_THREE
550
Object.SelectedOption = BUTTON_NONE
551
end if
552
end if
553
end if
554
555
// Check if save file 4 is touched
556
TempValue0 = BUTTON_SAVE_FOUR
557
CallFunction(LoadSaveMenu_CheckTouchSave)
558
if CheckResult > -1
559
Object.SelectedOption = BUTTON_SAVE_FOUR
560
else
561
if TempValue3 < 0
562
if Object.SelectedOption == BUTTON_SAVE_FOUR
563
KeyPress[0].Start = true
564
end if
565
else
566
if Object.SelectedOption == BUTTON_SAVE_FOUR
567
Object.SelectedOption = BUTTON_NONE
568
end if
569
end if
570
end if
571
572
CallFunction(MenuHeading_CheckTouchBack)
573
574
// Enable physical controls if a button is pressed
575
if KeyPress[0].Up == true
576
Object.SelectedOption = BUTTON_SAVE_FOUR
577
#platform: Mobile
578
Options.PhysicalControls = true
579
#endplatform
580
581
#platform: Use_Origins
582
Options.PhysicalControls = true
583
#endplatform
584
end if
585
586
if KeyPress[0].Down == true
587
if Object.ShowDeleteButton == false
588
Object.SelectedOption = BUTTON_SAVE_ONE
589
else
590
Object.SelectedOption = BUTTON_DELETE
591
end if
592
#platform: Mobile
593
Options.PhysicalControls = true
594
#endplatform
595
596
#platform: Use_Origins
597
Options.PhysicalControls = true
598
#endplatform
599
end if
600
end if
601
602
CheckResult = false
603
604
if Object.SelectedOption > BUTTON_NONE // If a button was touched
605
if KeyPress[0].Start == true
606
CheckResult = true
607
end if
608
if KeyPress[0].ButtonA == true
609
CheckResult = true
610
end if
611
end if
612
613
if CheckResult == true
614
if Object.SelectedOption < BUTTON_DELETE // If a save file was selected
615
#platform: Use_Origins
616
// this object isn't used in the final version of Origins, but it looks like they had plans to use it at first?
617
if game.continueFlag != false
618
ArrayPos0 = Object.SelectedOption
619
if Object[+ArrayPos0].StageListPos == 0
620
break // break STATE_MAIN_SAVE_MENU
621
end if
622
end if
623
#endplatform
624
switch Object.SaveMode
625
case SAVEMODE_NORMAL
626
Object.ShowDeleteButton = false
627
ArrayPos0 = Object.SelectedOption
628
Object[+ArrayPos0].SaveStatus = SAVE_NORMAL_SELECTED
629
Object.State = STATE_SAVE_SELECTED
630
PlaySfx(SFX_G_SELECT, false)
631
if Object[+ArrayPos0].StageListPos > 0 // Is this save used?
632
StopMusic()
633
else
634
if Options.TailsUnlocked == 2 // I have no idea what this means, this will always be false
635
StopMusic()
636
end if
637
end if
638
break
639
640
case SAVEMODE_DELETE
641
ArrayPos0 = Object.SelectedOption
642
if Object[+ArrayPos0].StageListPos > 0 // Is this save used?
643
Object.ShowDeleteButton = false
644
Object.State = STATE_SAVE_SELECTED_DELETE
645
Object.SaveOneStatus = SAVE_NORMAL
646
Object.SaveTwoStatus = SAVE_NORMAL
647
Object.SaveThreeStatus = SAVE_NORMAL
648
Object.SaveFourStatus = SAVE_NORMAL
649
Object[+ArrayPos0].SaveStatus = SAVE_DELETE_SELECTED
650
651
Object.SaveMode = SAVEMODE_NORMAL
652
PlaySfx(SFX_G_LAMPPOST, false)
653
else
654
Object.SaveOneStatus = SAVE_NORMAL
655
Object.SaveTwoStatus = SAVE_NORMAL
656
Object.SaveThreeStatus = SAVE_NORMAL
657
Object.SaveFourStatus = SAVE_NORMAL
658
Object.SaveMode = SAVEMODE_NORMAL
659
#platform: Use_Origins
660
if Options.PhysicalControls == false
661
Object.SelectedOption = BUTTON_NONE
662
end if
663
#endplatform
664
665
#platform: Mobile
666
if Options.PhysicalControls == false
667
Object.SelectedOption = BUTTON_NONE
668
end if
669
#endplatform
670
end if
671
break
672
end switch
673
end if
674
675
if Object.SelectedOption == BUTTON_DELETE
676
PlaySfx(SFX_G_LAMPPOST, false)
677
Object.State = STATE_TOGGLE_DELETE_MODE
678
end if
679
end if
680
681
if KeyPress[0].ButtonB == true
682
Object.ShowDeleteButton = false
683
Object.FadeValue = 248
684
685
Object.State = STATE_EXIT
686
PlayStageSfx(SFX_S_BACKBUTTON, false)
687
end if
688
break
689
690
case STATE_SAVE_SELECTED
691
if Object.FadeValue < 30
692
Object.FadeValue++
693
else
694
Object.FadeValue = 0
695
ArrayPos0 = Object.SelectedOption
696
Object[+ArrayPos0].SaveStatus = SAVE_NORMAL
697
if Object[+ArrayPos0].StageListPos > 0 // Is this save used?
698
Object.State = STATE_LOAD_SAVE
699
else
700
if Options.TailsUnlocked < 2 // I have no idea what this means, this will always be true
701
Object.State = STATE_NEW_GAME_SELECTED
702
703
Object.YPos = 40
704
Object.YPos *= Object.SelectedOption
705
Object.YPos += Screen.CenterY
706
Object.YPos -= 87
707
else
708
Object.State = STATE_LOAD_NEW_GAME
709
end if
710
end if
711
end if
712
break
713
714
case STATE_LOAD_SAVE
715
if Object.FadeValue < 256
716
Object.FadeValue += 8
717
else
718
ArrayPos0 = Object.SelectedOption
719
720
Options.GameMode = MODE_SAVEGAME
721
Options.SaveSlot = Object.SelectedOption
722
723
Player.Lives = Object[+ArrayPos0].Lives
724
Player.Score = Object[+ArrayPos0].Score
725
Player.ScoreBonus = Object[+ArrayPos0].ScoreBonus
726
727
Good_Future_List = Object[+ArrayPos0].GoodFutureList
728
Good_Future_List &= 0xFFFF // 0b1111111111111111
729
Good_Future_Count = 0
730
Good_Future = false
731
732
MetalSonic_List = Object[+ArrayPos0].GoodFutureList
733
MetalSonic_List >>= 16
734
735
SpecialStage.TimeStones = Object[+ArrayPos0].TimeStones
736
SpecialStage.ListPos = Object[+ArrayPos0].SpecialListPos
737
738
LampPost.Check = 0
739
740
Stage.ActiveList = REGULAR_STAGE
741
Stage.ListPos = Object[+ArrayPos0].StageListPos
742
Stage.ListPos--
743
if Stage.ListPos < 0
744
Stage.ListPos = 0
745
Player.Lives = 3
746
Player.Score = 0
747
end if
748
749
if Stage.ListPos >= 80 // Check if the save is on a special stage
750
SpecialStage.NextZone = Stage.ListPos
751
SpecialStage.NextZone -= 80
752
Stage.ActiveList = SPECIAL_STAGE
753
754
#platform: Use_Origins
755
Stage.ActiveList = 3
756
#endplatform
757
758
Stage.ListPos = SpecialStage.ListPos
759
760
TempValue0 = SpecialStage.NextZone
761
TempValue0 %= 10
762
TempValue0 >>= 2
763
if TempValue0 == 1
764
TempValue1 = SpecialStage.NextZone
765
TempValue1 /= 10
766
TempValue1 <<= 1
767
GetBit(TempValue0, Good_Future_List, TempValue1)
768
Good_Future_Count += TempValue0
769
end if
770
else
771
TempValue0 = Stage.ListPos
772
TempValue0 %= 10
773
TempValue0 >>= 2
774
if TempValue0 == 1
775
TempValue1 = Stage.ListPos
776
TempValue1 /= 10
777
TempValue1 <<= 1
778
GetBit(TempValue0, Good_Future_List, TempValue1)
779
Good_Future_Count += TempValue0
780
end if
781
end if
782
Stage.PlayerListPos = Object[+ArrayPos0].PlayerListPos
783
784
#platform: Use_Origins
785
// normally saveSlot is just forced to 0 on the title screen, but it looks like they were planning to do a bit more than that initially? not like it matters anyways though, cause this object's unused in origins and all
786
game.callbackParam0 = Object.SelectedOption
787
EngineCallback(NOTIFY_SAVESLOT_SELECT)
788
#endplatform
789
790
LoadStage()
791
end if
792
SetScreenFade(0, 0, 0, Object.FadeValue)
793
break
794
795
case STATE_NEW_GAME_SELECTED
796
TempValue0 = Screen.CenterY
797
TempValue0 -= 87
798
if Object.YPos > TempValue0
799
Object.YPos -= 8
800
if Object.YPos < TempValue0
801
Object.YPos = TempValue0
802
end if
803
else
804
Object.State = STATE_FADEIN_CHARACTERSELECT
805
Object.Alpha = 0
806
807
#platform: Use_Origins
808
if Options.PhysicalControls == false
809
ArrayPos0 = Object.SelectedOption
810
Object[+ArrayPos0].PlayerListPos = PLAYER_NONE
811
end if
812
#endplatform
813
814
#platform: Mobile
815
if Options.PhysicalControls == false
816
ArrayPos0 = Object.SelectedOption
817
Object[+ArrayPos0].PlayerListPos = PLAYER_NONE
818
end if
819
#endplatform
820
821
end if
822
break
823
824
case STATE_FADEIN_CHARACTERSELECT
825
if Object.FadeValue < 256
826
Object.Alpha = Object.FadeValue
827
Object.FadeValue += 8
828
else
829
Object.FadeValue = 0
830
Object.Alpha = 255
831
Object.State = STATE_CHARACTER_SELECT
832
end if
833
break
834
835
case STATE_CHARACTER_SELECT
836
ArrayPos0 = Object.SelectedOption
837
838
#platform: Standard
839
CheckResult = true
840
#endplatform
841
842
#platform: Mobile
843
CheckEqual(Options.PhysicalControls, true)
844
#endplatform
845
846
#platform: Use_Origins
847
CheckEqual(Options.PhysicalControls, true)
848
#endplatform
849
850
// 2011 Steam lacks Options.PhysicalControls, so we force it here first and the other platforms can override it
851
if CheckResult == true
852
if KeyPress[0].Left == true
853
Object[+ArrayPos0].PlayerListPos--
854
PlaySfx(SFX_G_MENUBUTTON, false)
855
if Object[+ArrayPos0].PlayerListPos < PLAYER_SONIC_A
856
Object[+ArrayPos0].PlayerListPos = PLAYER_TAILS_A
857
end if
858
end if
859
if KeyPress[0].Right == true
860
Object[+ArrayPos0].PlayerListPos++
861
PlaySfx(SFX_G_MENUBUTTON, false)
862
if Object[+ArrayPos0].PlayerListPos > PLAYER_TAILS_A
863
Object[+ArrayPos0].PlayerListPos = PLAYER_SONIC_A
864
end if
865
end if
866
867
// Enable touch controls if the screen is touched
868
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
869
if CheckResult > -1
870
#platform: Mobile
871
Options.PhysicalControls = false
872
Object[+ArrayPos0].PlayerListPos = PLAYER_NONE
873
#endplatform
874
875
#platform: Use_Origins
876
Options.PhysicalControls = false
877
Object[+ArrayPos0].PlayerListPos = PLAYER_NONE
878
#endplatform
879
end if
880
else
881
// Touch Controls
882
883
if Engine.Message == MESSAGE_LOSTFOCUS
884
Object[+ArrayPos0].PlayerListPos = PLAYER_NONE
885
end if
886
887
// Check if Sonic is pressed
888
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
889
TempValue3 = CheckResult
890
891
TempValue0 = Screen.CenterX
892
TempValue0 -= 56
893
894
TempValue1 = Screen.CenterX
895
TempValue1 -= 8
896
CheckTouchRect(TempValue0, 126, TempValue1, 184)
897
if CheckResult > -1
898
Object[+ArrayPos0].PlayerListPos = PLAYER_SONIC_A
899
else
900
if TempValue3 < 0
901
if Object[+ArrayPos0].PlayerListPos == PLAYER_SONIC_A
902
KeyPress[0].Start = true
903
end if
904
else
905
if Object[+ArrayPos0].PlayerListPos == PLAYER_SONIC_A
906
Object[+ArrayPos0].PlayerListPos = PLAYER_NONE
907
end if
908
end if
909
end if
910
911
// Check if Tails is pressed
912
TempValue0 = Screen.CenterX
913
TempValue0 += 8
914
TempValue1 = Screen.CenterX
915
TempValue1 += 56
916
CheckTouchRect(TempValue0, 126, TempValue1, 184)
917
if CheckResult > -1
918
Object[+ArrayPos0].PlayerListPos = PLAYER_TAILS_A
919
else
920
if TempValue3 < 0
921
if Object[+ArrayPos0].PlayerListPos == PLAYER_TAILS_A
922
KeyPress[0].Start = true
923
end if
924
else
925
if Object[+ArrayPos0].PlayerListPos == PLAYER_TAILS_A
926
Object[+ArrayPos0].PlayerListPos = PLAYER_NONE
927
end if
928
end if
929
end if
930
931
// Check if the back button is pressed
932
TempValue0 = Screen.XSize
933
TempValue0 -= 76
934
CheckTouchRect(TempValue0, 192, Screen.XSize, Screen.YSize)
935
if CheckResult > -1
936
Object[+ArrayPos0].PlayerListPos = PLAYER_BACK
937
Object.BackTouchPress = true
938
else
939
Object.BackTouchPress = false
940
if TempValue3 < 0
941
if Object[+ArrayPos0].PlayerListPos == PLAYER_BACK
942
KeyPress[0].ButtonB = true
943
end if
944
else
945
if Object[+ArrayPos0].PlayerListPos == PLAYER_BACK
946
Object[+ArrayPos0].PlayerListPos = PLAYER_NONE
947
end if
948
end if
949
end if
950
951
// Enable physical controls if a button is pressed
952
if KeyPress[0].Left == true
953
Object[+ArrayPos0].PlayerListPos = PLAYER_TAILS_A
954
#platform: Mobile
955
Options.PhysicalControls = true
956
#endplatform
957
958
#platform: Use_Origins
959
Options.PhysicalControls = true
960
#endplatform
961
end if
962
963
if KeyPress[0].Right == true
964
Object[+ArrayPos0].PlayerListPos = PLAYER_SONIC_A
965
#platform: Mobile
966
Options.PhysicalControls = true
967
#endplatform
968
969
#platform: Use_Origins
970
Options.PhysicalControls = true
971
#endplatform
972
end if
973
end if
974
975
CheckResult = false
976
if KeyPress[0].Start == true
977
CheckResult = true
978
end if
979
if KeyPress[0].ButtonA == true
980
CheckResult = true
981
end if
982
if CheckResult == true
983
if Options.TailsUnlocked == true
984
PlaySfx(SFX_G_SELECT, false)
985
StopMusic()
986
Object.State = STATE_CHARACTER_SELECTED
987
else
988
if Object[+ArrayPos0].PlayerListPos == PLAYER_SONIC_A
989
PlaySfx(SFX_G_SELECT, false)
990
StopMusic()
991
Object.State = STATE_CHARACTER_SELECTED
992
else
993
#platform: Mobile
994
Object[+ArrayPos0].PlayerListPos = PLAYER_NONE
995
#endplatform
996
end if
997
end if
998
end if
999
1000
if KeyPress[0].ButtonB == true
1001
Object.State = STATE_FADEOUT_CHARACTERSELECT
1002
Object.FadeValue = 248
1003
PlayStageSfx(SFX_S_BACKBUTTON, false)
1004
end if
1005
break
1006
1007
case STATE_CHARACTER_SELECTED
1008
if Object.FadeValue < 30
1009
Object.FadeValue++
1010
else
1011
Object.FadeValue = 0
1012
Object.State = STATE_LOAD_NEW_GAME
1013
end if
1014
break
1015
1016
case STATE_LOAD_NEW_GAME
1017
if Object.FadeValue < 256
1018
Object.FadeValue += 8
1019
else
1020
ArrayPos0 = Object.SelectedOption
1021
ArrayPos1 = Object.SelectedOption
1022
ArrayPos1 <<= 3
1023
SaveRAM[ArrayPos1] = Object[+ArrayPos0].PlayerListPos // Character
1024
ArrayPos1++
1025
SaveRAM[ArrayPos1] = 3 // Lives
1026
ArrayPos1++
1027
SaveRAM[ArrayPos1] = 0 // Score
1028
ArrayPos1++
1029
SaveRAM[ArrayPos1] = 1 // Stage List Pos, gets down by one below this
1030
ArrayPos1++
1031
SaveRAM[ArrayPos1] = 0 // Time Stones
1032
ArrayPos1++
1033
SaveRAM[ArrayPos1] = 0 // Special Stage Pos
1034
ArrayPos1++
1035
SaveRAM[ArrayPos1] = 50000 // Score Bonus
1036
ArrayPos1++
1037
SaveRAM[ArrayPos1] = 0 // Destroyed Metal Sonic Projectors
1038
WriteSaveRAM()
1039
1040
Options.GameMode = MODE_SAVEGAME
1041
Options.SaveSlot = Object.SelectedOption
1042
1043
Player.Lives = 3
1044
Player.Score = 0
1045
Player.ScoreBonus = 50000
1046
1047
Good_Future_List = 0
1048
Good_Future_Count = 0
1049
Good_Future = false
1050
1051
Transporter_Destroyed = false
1052
MetalSonic_Destroyed = false
1053
MetalSonic_List = 0
1054
1055
SpecialStage.TimeStones = 0
1056
SpecialStage.ListPos = STAGE_S_SS1
1057
1058
LampPost.Check = 0
1059
Stage.ActiveList = REGULAR_STAGE
1060
1061
ArrayPos0 = Object.SelectedOption
1062
1063
Stage.ListPos = Object[+ArrayPos0].StageListPos
1064
Stage.ListPos--
1065
if Stage.ListPos < 0
1066
Stage.ListPos = STAGE_R_PPZ1A
1067
end if
1068
1069
Stage.PlayerListPos = Object[+ArrayPos0].PlayerListPos
1070
1071
#platform: Use_Origins
1072
// normally saveSlot is just forced to 0 on the title screen, but it looks like they were planning to do a bit more than that initially? not like it matters anyways though, cause this object's unused in origins and all
1073
game.callbackParam0 = Object.SelectedOption
1074
EngineCallback(NOTIFY_SAVESLOT_SELECT)
1075
#endplatform
1076
1077
LoadStage()
1078
1079
if Stage.PlayerListPos == PLAYER_SONIC_A // PLAYER_SONIC in origins plus - why did they update this object in plus even if it's unused in origins? wish i knew..
1080
LoadVideo("Opening")
1081
1082
// #platform: Mobile
1083
// if Options.Soundtrack == OST_JP
1084
// LoadVideo("Opening")
1085
// else
1086
// LoadVideo("OpeningUS")
1087
// end if
1088
// #endplatform
1089
1090
end if
1091
end if
1092
SetScreenFade(0, 0, 0, Object.FadeValue)
1093
break
1094
1095
case STATE_FADEOUT_CHARACTERSELECT
1096
if Object.FadeValue > 0
1097
Object.Alpha = Object.FadeValue
1098
Object.FadeValue -= 8
1099
else
1100
Object.Alpha = 0
1101
Object.State = STATE_RETURN_TO_SAVESEL
1102
end if
1103
break
1104
1105
case STATE_RETURN_TO_SAVESEL
1106
TempValue0 = Object.SelectedOption
1107
TempValue0 *= 40
1108
TempValue0 += Screen.CenterY
1109
TempValue0 -= 87
1110
if Object.YPos < TempValue0
1111
Object.YPos += 8
1112
if Object.YPos > TempValue0
1113
Object.YPos = TempValue0
1114
end if
1115
Object.Alpha = 0
1116
else
1117
1118
#platform: Use_Origins
1119
if Options.PhysicalControls == false
1120
Object.SelectedOption = BUTTON_NONE
1121
end if
1122
#endplatform
1123
1124
#platform: Mobile
1125
if Options.PhysicalControls == false
1126
Object.SelectedOption = BUTTON_NONE
1127
end if
1128
#endplatform
1129
1130
Object.State = STATE_MAIN_SAVE_MENU
1131
Object.Alpha = 255
1132
Object.SaveOneStatus = SAVE_NORMAL
1133
Object.SaveTwoStatus = SAVE_NORMAL
1134
Object.SaveThreeStatus = SAVE_NORMAL
1135
Object.SaveFourStatus = SAVE_NORMAL
1136
Object.SaveMode = SAVEMODE_NORMAL
1137
CallFunction(LoadSaveMenu_SetShowDelete)
1138
end if
1139
break
1140
1141
case STATE_EXIT
1142
if Object.FadeValue > 0
1143
Object.Alpha = Object.FadeValue
1144
Object.FadeValue -= 8
1145
else
1146
// Tell the other objects that you're leaving the menu
1147
Object.Type = TypeName[Blank Object]
1148
MenuWindow.State = MENUWINDOW_SHRINK // Reset the window
1149
//All of this is MenuButton Objects
1150
Object[34].State = MENUBUTTON_BUTTONS_IN
1151
Object[35].State = MENUBUTTON_BUTTONS_IN
1152
Object[36].State = MENUBUTTON_BUTTONS_IN
1153
Object[37].State = MENUBUTTON_BUTTONS_IN
1154
Object[38].State = MENUBUTTON_BUTTONS_IN
1155
Object[39].State = MENUBUTTON_BUTTONS_IN
1156
Object[40].State = MENUBUTTON_BUTTONS_IN
1157
Object[41].State = MENUBUTTON_BUTTONS_IN
1158
Object[42].State = MENUBUTTON_BUTTONS_IN
1159
1160
MenuHeading.State = MENUHEADING_LEAVE_SCREEN
1161
MenuHeading.Header = MAINMENU_HEADER
1162
end if
1163
break
1164
1165
case STATE_TOGGLE_DELETE_MODE
1166
if Object.FadeValue < 30
1167
Object.FadeValue++
1168
else
1169
Object.FadeValue = 0
1170
Object.State = STATE_MAIN_SAVE_MENU
1171
1172
#platform: Standard
1173
Object.SelectedOption = BUTTON_SAVE_ONE
1174
#endplatform
1175
1176
#platform: Use_Origins
1177
if Options.PhysicalControls == true
1178
Object.SelectedOption = BUTTON_SAVE_ONE
1179
else
1180
Object.SelectedOption = BUTTON_NONE
1181
end if
1182
#endplatform
1183
1184
#platform: Mobile
1185
if Options.PhysicalControls == true
1186
Object.SelectedOption = BUTTON_SAVE_ONE
1187
else
1188
Object.SelectedOption = BUTTON_NONE
1189
end if
1190
#endplatform
1191
1192
if Object.SaveMode >= SAVE_DELETE
1193
Object.SaveOneStatus = SAVE_NORMAL
1194
Object.SaveTwoStatus = SAVE_NORMAL
1195
Object.SaveThreeStatus = SAVE_NORMAL
1196
Object.SaveFourStatus = SAVE_NORMAL
1197
Object.SaveMode = SAVEMODE_NORMAL
1198
else
1199
Object.SaveOneStatus = SAVE_DELETE
1200
Object.SaveTwoStatus = SAVE_DELETE
1201
Object.SaveThreeStatus = SAVE_DELETE
1202
Object.SaveFourStatus = SAVE_DELETE
1203
Object.SaveMode = SAVEMODE_DELETE
1204
end if
1205
end if
1206
break
1207
1208
case STATE_SAVE_SELECTED_DELETE
1209
if Object.FadeValue < 30
1210
Object.FadeValue++
1211
else
1212
Object.FadeValue = 0
1213
ArrayPos0 = Object.SelectedOption
1214
Object[+ArrayPos0].SaveStatus = SAVE_DELETE
1215
1216
Object.State = STATE_SLIDE_DELETE_SAVE
1217
1218
Object.YPos = 40
1219
Object.YPos *= Object.SelectedOption
1220
Object.YPos += Screen.CenterY
1221
Object.YPos -= 87
1222
end if
1223
break
1224
1225
case STATE_SLIDE_DELETE_SAVE
1226
TempValue0 = Screen.CenterY
1227
TempValue0 -= 87
1228
if Object.YPos > TempValue0
1229
Object.YPos -= 8
1230
if Object.YPos < TempValue0
1231
Object.YPos = TempValue0
1232
end if
1233
else
1234
Object.State = STATE_FADEIN_DELETECONFIRM
1235
Object.Alpha = 0
1236
1237
#platform: Standard
1238
DeleteConfirm.Highlight = DELETE_YES
1239
#endplatform
1240
1241
#platform: Use_Origins
1242
if Options.PhysicalControls == true
1243
DeleteConfirm.Highlight = DELETE_YES
1244
else
1245
DeleteConfirm.Highlight = DELETE_NONE
1246
end if
1247
#endplatform
1248
1249
#platform: Mobile
1250
if Options.PhysicalControls == true
1251
DeleteConfirm.Highlight = DELETE_YES
1252
else
1253
DeleteConfirm.Highlight = DELETE_NONE
1254
end if
1255
#endplatform
1256
1257
end if
1258
break
1259
1260
case STATE_FADEIN_DELETECONFIRM
1261
if Object.FadeValue < 256
1262
Object.Alpha = Object.FadeValue
1263
Object.FadeValue += 8
1264
else
1265
Object.FadeValue = 0
1266
Object.Alpha = 255
1267
Object.State = STATE_DELETE_CONFIRM
1268
end if
1269
break
1270
1271
case STATE_DELETE_CONFIRM
1272
ArrayPos0 = Object.SelectedOption
1273
Object.AnimationTimer++
1274
Object.AnimationTimer &= 63
1275
1276
#platform: Standard
1277
CheckResult = true
1278
#endplatform
1279
1280
#platform: Mobile
1281
CheckEqual(Options.PhysicalControls, true)
1282
#endplatform
1283
1284
#platform: Use_Origins
1285
CheckEqual(Options.PhysicalControls, true)
1286
#endplatform
1287
1288
1289
// 2011 Steam lacks Options.PhysicalControls, so we force it here first and the other platforms can override it
1290
if CheckResult == true
1291
if KeyPress[0].Up == true
1292
DeleteConfirm.Highlight--
1293
PlaySfx(SFX_G_MENUBUTTON, false)
1294
if DeleteConfirm.Highlight < DELETE_YES
1295
DeleteConfirm.Highlight = DELETE_NO
1296
end if
1297
end if
1298
1299
if KeyPress[0].Down == true
1300
DeleteConfirm.Highlight++
1301
PlaySfx(SFX_G_MENUBUTTON, false)
1302
if DeleteConfirm.Highlight > DELETE_NO
1303
DeleteConfirm.Highlight = DELETE_YES
1304
end if
1305
end if
1306
1307
// Enable touch controls if the screen is touched
1308
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
1309
if CheckResult > -1
1310
1311
#platform: Mobile
1312
Options.PhysicalControls = false
1313
DeleteConfirm.Highlight = DELETE_NONE
1314
#endplatform
1315
1316
#platform: Use_Origins
1317
Options.PhysicalControls = false
1318
DeleteConfirm.Highlight = DELETE_NONE
1319
#endplatform
1320
end if
1321
else
1322
// Touch Controls
1323
1324
if Engine.Message == MESSAGE_LOSTFOCUS
1325
DeleteConfirm.Highlight = DELETE_NONE
1326
end if
1327
1328
// Check if YES is touched
1329
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
1330
TempValue3 = CheckResult
1331
TempValue0 = Screen.CenterX
1332
TempValue0 -= 34
1333
TempValue1 = Screen.CenterX
1334
TempValue1 += 34
1335
CheckTouchRect(TempValue0, 110, TempValue1, 135)
1336
if CheckResult > -1
1337
DeleteConfirm.Highlight = DELETE_YES
1338
else
1339
if TempValue3 < 0
1340
if DeleteConfirm.Highlight == DELETE_YES
1341
KeyPress[0].Start = true
1342
end if
1343
else
1344
if DeleteConfirm.Highlight == DELETE_YES
1345
DeleteConfirm.Highlight = DELETE_NONE
1346
end if
1347
end if
1348
end if
1349
1350
// Check if NO is touched
1351
CheckTouchRect(TempValue0, 144, TempValue1, 169)
1352
if CheckResult > -1
1353
DeleteConfirm.Highlight = DELETE_NO
1354
else
1355
if TempValue3 < 0
1356
if DeleteConfirm.Highlight == DELETE_NO
1357
KeyPress[0].Start = true
1358
end if
1359
else
1360
if DeleteConfirm.Highlight == DELETE_NO
1361
DeleteConfirm.Highlight = DELETE_NONE
1362
end if
1363
end if
1364
end if
1365
1366
// Check if the back button is touched
1367
TempValue0 = Screen.XSize
1368
TempValue0 -= 76
1369
CheckTouchRect(TempValue0, 192, Screen.XSize, Screen.YSize)
1370
if CheckResult > -1
1371
DeleteConfirm.Highlight = DELETE_BACK
1372
Object.BackTouchPress = true
1373
else
1374
Object.BackTouchPress = false
1375
if TempValue3 < 0
1376
if DeleteConfirm.Highlight == DELETE_BACK
1377
KeyPress[0].ButtonB = true
1378
end if
1379
else
1380
if DeleteConfirm.Highlight == DELETE_BACK
1381
DeleteConfirm.Highlight = DELETE_NONE
1382
end if
1383
end if
1384
end if
1385
1386
// Enable physical controls if a button is pressed
1387
if KeyPress[0].Up == true
1388
DeleteConfirm.Highlight = DELETE_NO
1389
#platform: Mobile
1390
Options.PhysicalControls = true
1391
#endplatform
1392
#platform: Use_Origins
1393
Options.PhysicalControls = true
1394
#endplatform
1395
end if
1396
1397
if KeyPress[0].Down == true
1398
DeleteConfirm.Highlight = DELETE_YES
1399
#platform: Mobile
1400
Options.PhysicalControls = true
1401
#endplatform
1402
#platform: Use_Origins
1403
Options.PhysicalControls = true
1404
#endplatform
1405
end if
1406
end if
1407
1408
CheckResult = false
1409
1410
if DeleteConfirm.Highlight > DELETE_NONE // If a button was touched
1411
if KeyPress[0].Start == true
1412
CheckResult = true
1413
end if
1414
if KeyPress[0].ButtonA == true
1415
CheckResult = true
1416
end if
1417
end if
1418
1419
if CheckResult == true
1420
if DeleteConfirm.Highlight == DELETE_YES
1421
PlayStageSfx(SFX_S_EVENT, false)
1422
else
1423
PlaySfx(SFX_G_SELECT, false)
1424
end if
1425
Object.AnimationTimer = 0
1426
1427
Object.State = STATE_DELETECONFIRM_SELECTED
1428
end if
1429
1430
if KeyPress[0].ButtonB == true
1431
ArrayPos0 = Object.SelectedOption
1432
Object[+ArrayPos0].SaveStatus = SAVE_NORMAL
1433
1434
Object.State = STATE_FADEOUT_DELETECONFIRM
1435
1436
Object.FadeValue = 248
1437
Object.AnimationTimer = 0
1438
1439
PlayStageSfx(SFX_S_BACKBUTTON, false)
1440
end if
1441
break
1442
1443
case STATE_DELETECONFIRM_SELECTED
1444
if Object.FadeValue < 30
1445
Object.FadeValue++
1446
else
1447
Object.State = STATE_FADEOUT_DELETECONFIRM
1448
Object.FadeValue = 248
1449
1450
ArrayPos0 = Object.SelectedOption
1451
Object[+ArrayPos0].SaveStatus = SAVE_NORMAL
1452
1453
if DeleteConfirm.Highlight == DELETE_YES
1454
// Delete this save in the menu
1455
Object[+ArrayPos0].PlayerListPos = 0
1456
Object[+ArrayPos0].Lives = 3
1457
Object[+ArrayPos0].Score = 0
1458
Object[+ArrayPos0].StageListPos = 0
1459
Object[+ArrayPos0].TimeStones = 0
1460
Object[+ArrayPos0].SpecialListPos = 0
1461
Object[+ArrayPos0].ScoreBonus = 50000
1462
Object[+ArrayPos0].GoodFutureList = 0
1463
1464
// Now delete it in SaveRAM
1465
ArrayPos1 = Object.SelectedOption
1466
ArrayPos1 <<= 3
1467
SaveRAM[ArrayPos1] = 0
1468
ArrayPos1++
1469
SaveRAM[ArrayPos1] = 3
1470
ArrayPos1++
1471
SaveRAM[ArrayPos1] = 0
1472
ArrayPos1++
1473
SaveRAM[ArrayPos1] = 0
1474
ArrayPos1++
1475
SaveRAM[ArrayPos1] = 0
1476
ArrayPos1++
1477
SaveRAM[ArrayPos1] = 0
1478
ArrayPos1++
1479
SaveRAM[ArrayPos1] = 0
1480
ArrayPos1++
1481
SaveRAM[ArrayPos1] = 0
1482
end if
1483
1484
WriteSaveRAM()
1485
end if
1486
break
1487
1488
case STATE_FADEOUT_DELETECONFIRM
1489
if Object.FadeValue > 0
1490
Object.Alpha = Object.FadeValue
1491
Object.FadeValue -= 8
1492
else
1493
Object.Alpha = 0
1494
Object.State = STATE_RETURN_TO_SAVESEL
1495
end if
1496
break
1497
end switch
1498
end sub
1499
1500
1501
sub ObjectDraw
1502
switch Object.State
1503
case STATE_INITIALIZE
1504
case STATE_MAIN_SAVE_MENU
1505
case STATE_SAVE_SELECTED
1506
case STATE_LOAD_SAVE
1507
case STATE_EXIT
1508
case STATE_SAVE_SELECTED_DELETE
1509
if Object.State != STATE_INITIALIZE
1510
CallFunction(LoadSaveMenu_DrawDeleteNoSave)
1511
end if
1512
1513
Object.YPos = Screen.CenterY
1514
Object.YPos -= 87
1515
ArrayPos0 = 0
1516
CallFunction(LoadSaveMenu_DrawSaveFiles)
1517
Object.YPos += 40
1518
ArrayPos0++
1519
CallFunction(LoadSaveMenu_DrawSaveFiles)
1520
Object.YPos += 40
1521
ArrayPos0++
1522
CallFunction(LoadSaveMenu_DrawSaveFiles)
1523
Object.YPos += 40
1524
ArrayPos0++
1525
CallFunction(LoadSaveMenu_DrawSaveFiles)
1526
break
1527
1528
case STATE_NEW_GAME_SELECTED
1529
case STATE_SLIDE_DELETE_SAVE
1530
CallFunction(LoadSaveMenu_DrawDeleteNoSave)
1531
ArrayPos0 = Object.SelectedOption
1532
CallFunction(LoadSaveMenu_DrawSaveFiles)
1533
break
1534
1535
case STATE_FADEIN_CHARACTERSELECT
1536
case STATE_CHARACTER_SELECT
1537
case STATE_LOAD_NEW_GAME
1538
case STATE_FADEOUT_CHARACTERSELECT
1539
case STATE_RETURN_TO_SAVESEL
1540
DrawSpriteScreenFX(30, FX_INK, Screen.CenterX, 84)
1541
TempValue0 = Screen.CenterX
1542
TempValue0 -= 32
1543
ArrayPos0 = Object.SelectedOption
1544
if Object[+ArrayPos0].PlayerListPos == PLAYER_SONIC_A
1545
DrawSpriteScreenFX(31, FX_INK, TempValue0, 136)
1546
DrawSpriteScreenFX(36, FX_INK, TempValue0, 164)
1547
DrawSpriteScreenFX(33, FX_INK, TempValue0, 136)
1548
else
1549
DrawSpriteScreenFX(31, FX_INK, TempValue0, 136)
1550
DrawSpriteScreenFX(34, FX_INK, TempValue0, 164)
1551
end if
1552
TempValue0 += 64
1553
if Object[+ArrayPos0].PlayerListPos == PLAYER_TAILS_A
1554
DrawSpriteScreenFX(32, FX_INK, TempValue0, 136)
1555
DrawSpriteScreenFX(37, FX_INK, TempValue0, 164)
1556
DrawSpriteScreenFX(33, FX_INK, TempValue0, 136)
1557
else
1558
DrawSpriteScreenFX(32, FX_INK, TempValue0, 136)
1559
DrawSpriteScreenFX(35, FX_INK, TempValue0, 164)
1560
end if
1561
Object.Alpha = 255
1562
CallFunction(LoadSaveMenu_DrawSaveFiles)
1563
break
1564
1565
case STATE_CHARACTER_SELECTED
1566
DrawSpriteScreenFX(30, FX_INK, Screen.CenterX, 84)
1567
TempValue0 = Screen.CenterX
1568
TempValue0 -= 32
1569
ArrayPos0 = Object.SelectedOption
1570
1571
// Flash the border for the selected character
1572
TempValue1 = Object.FadeValue
1573
TempValue1 &= 3
1574
TempValue1 >>= 1
1575
1576
if Object[+ArrayPos0].PlayerListPos == PLAYER_SONIC_A
1577
if TempValue1 == 0
1578
DrawSpriteScreenFX(31, FX_INK, TempValue0, 136)
1579
end if
1580
DrawSpriteScreenFX(36, FX_INK, TempValue0, 164)
1581
DrawSpriteScreenFX(33, FX_INK, TempValue0, 136)
1582
else
1583
DrawSpriteScreenFX(31, FX_INK, TempValue0, 136)
1584
DrawSpriteScreenFX(34, FX_INK, TempValue0, 164)
1585
end if
1586
TempValue0 += 64
1587
if Object[+ArrayPos0].PlayerListPos == PLAYER_TAILS_A
1588
if TempValue1 == 0
1589
DrawSpriteScreenFX(32, FX_INK, TempValue0, 136)
1590
end if
1591
DrawSpriteScreenFX(37, FX_INK, TempValue0, 164)
1592
DrawSpriteScreenFX(33, FX_INK, TempValue0, 136)
1593
else
1594
DrawSpriteScreenFX(32, FX_INK, TempValue0, 136)
1595
DrawSpriteScreenFX(35, FX_INK, TempValue0, 164)
1596
end if
1597
Object.Alpha = 255
1598
CallFunction(LoadSaveMenu_DrawSaveFiles)
1599
break
1600
1601
case STATE_TOGGLE_DELETE_MODE
1602
// Flash the delete button
1603
TempValue0 = Object.FadeValue
1604
TempValue0 &= 3
1605
TempValue0 >>= 1
1606
1607
if Object.SaveOneStatus == SAVE_DELETE
1608
if TempValue0 == 0
1609
DrawSpriteScreenXY(55, Delete.XPos, Delete.YPos)
1610
else
1611
DrawSpriteScreenXY(54, Delete.XPos, Delete.YPos)
1612
end if
1613
else
1614
if TempValue0 == 0
1615
DrawSpriteScreenXY(53, Delete.XPos, Delete.YPos)
1616
else
1617
DrawSpriteScreenXY(52, Delete.XPos, Delete.YPos)
1618
end if
1619
end if
1620
1621
Object.YPos = Screen.CenterY
1622
Object.YPos -= 87
1623
ArrayPos0 = 0
1624
CallFunction(LoadSaveMenu_DrawSaveFiles)
1625
Object.YPos += 40
1626
ArrayPos0++
1627
CallFunction(LoadSaveMenu_DrawSaveFiles)
1628
Object.YPos += 40
1629
ArrayPos0++
1630
CallFunction(LoadSaveMenu_DrawSaveFiles)
1631
Object.YPos += 40
1632
ArrayPos0++
1633
CallFunction(LoadSaveMenu_DrawSaveFiles)
1634
break
1635
1636
case STATE_FADEIN_DELETECONFIRM
1637
case STATE_DELETE_CONFIRM
1638
case STATE_FADEOUT_DELETECONFIRM
1639
DrawSpriteScreenFX(57, FX_INK, Screen.CenterX, 84)
1640
if DeleteConfirm.Highlight == DELETE_YES
1641
DrawSpriteScreenFX(76, FX_INK, Screen.CenterX, 112)
1642
else
1643
DrawSpriteScreenFX(75, FX_INK, Screen.CenterX, 112)
1644
end if
1645
if DeleteConfirm.Highlight == DELETE_NO
1646
DrawSpriteScreenFX(78, FX_INK, Screen.CenterX, 146)
1647
else
1648
DrawSpriteScreenFX(77, FX_INK, Screen.CenterX, 146)
1649
end if
1650
ArrayPos0 = Object.SelectedOption
1651
Object.Alpha = 255
1652
CallFunction(LoadSaveMenu_DrawSaveFiles)
1653
break
1654
1655
case STATE_DELETECONFIRM_SELECTED
1656
// Flash the selected button
1657
TempValue0 = Object.FadeValue
1658
TempValue0 &= 3
1659
TempValue0 >>= 1
1660
1661
DrawSpriteScreenFX(57, FX_INK, Screen.CenterX, 84)
1662
if DeleteConfirm.Highlight == DELETE_YES
1663
if TempValue0 == 0
1664
DrawSpriteScreenFX(76, FX_INK, Screen.CenterX, 112)
1665
else
1666
DrawSpriteScreenFX(75, FX_INK, Screen.CenterX, 112)
1667
end if
1668
else
1669
DrawSpriteScreenFX(75, FX_INK, Screen.CenterX, 112)
1670
end if
1671
if DeleteConfirm.Highlight == DELETE_NO
1672
if TempValue0 == 0
1673
DrawSpriteScreenFX(78, FX_INK, Screen.CenterX, 146)
1674
else
1675
DrawSpriteScreenFX(77, FX_INK, Screen.CenterX, 146)
1676
end if
1677
else
1678
DrawSpriteScreenFX(77, FX_INK, Screen.CenterX, 146)
1679
end if
1680
ArrayPos0 = Object.SelectedOption
1681
Object.Alpha = 255
1682
CallFunction(LoadSaveMenu_DrawSaveFiles)
1683
break
1684
end switch
1685
end sub
1686
1687
1688
sub ObjectStartup
1689
switch Engine.Language
1690
case LANG_ENGLISH
1691
LoadSpriteSheet("Menu/MenuGfx2_EN.gif")
1692
break
1693
case LANG_FRENCH
1694
LoadSpriteSheet("Menu/MenuGfx2_FR.gif")
1695
break
1696
case LANG_ITALIAN
1697
LoadSpriteSheet("Menu/MenuGfx2_IT.gif")
1698
break
1699
case LANG_DEUTSCH
1700
LoadSpriteSheet("Menu/MenuGfx2_DE.gif")
1701
break
1702
case LANG_SPANISH
1703
LoadSpriteSheet("Menu/MenuGfx2_ES.gif")
1704
break
1705
case LANG_JAPANESE
1706
LoadSpriteSheet("Menu/MenuGfx2_JP.gif")
1707
break
1708
end switch
1709
1710
SpriteFrame(4, 2, 32, 32, 389, 1) // #0 - Save 1 Gear
1711
SpriteFrame(4, 2, 32, 32, 422, 1) // #1 - Save 2 Gear
1712
SpriteFrame(4, 2, 32, 32, 455, 1) // #2 - Save 3 Gear
1713
SpriteFrame(4, 2, 32, 32, 446, 34) // #3 - Save 4 Gear
1714
SpriteFrame(3, 2, 40, 32, 259, 1) // #4 - Mini Sonic Gear
1715
SpriteFrame(3, 2, 64, 32, 259, 1) // #5 - Mini Sonic + Hey
1716
SpriteFrame(3, 2, 40, 32, 324, 1) // #6 - Mini Tails Gear
1717
SpriteFrame(3, 2, 64, 32, 324, 1) // #7 - Mini Tails + Hey
1718
SpriteFrame(45, 12, 13, 13, 488, 1) // #8 - Triangle Detail
1719
SpriteFrame(0, 0, 250, 37, 259, 421) // #9 - Select Border
1720
SpriteFrame(64, 12, 128, 16, 1, 1) // #10 - New Game
1721
SpriteFrame(64, 12, 144, 16, 259, 93) // #11 - Palmtree Panic
1722
SpriteFrame(64, 12, 144, 16, 259, 110) // #12 - Collision Chaos
1723
SpriteFrame(64, 12, 144, 16, 259, 127) // #13 - Tidal Tempest
1724
SpriteFrame(64, 12, 144, 16, 259, 144) // #14 - Quartz Quadrant
1725
SpriteFrame(64, 12, 144, 16, 259, 161) // #15 - Wacky Workbench
1726
SpriteFrame(64, 12, 144, 16, 259, 178) // #16 - Stardust Speedway
1727
SpriteFrame(64, 12, 144, 16, 259, 195) // #17 - Metallic Madness
1728
SpriteFrame(64, 12, 144, 16, 259, 212) // #18 - Final Fever
1729
SpriteFrame(64, 12, 144, 16, 259, 229) // #19 - Special Stage
1730
//Highlights
1731
SpriteFrame(64, 12, 128, 16, 130, 1) // #20 - New Game
1732
SpriteFrame(64, 12, 144, 16, 259, 268) // #21 - Palmtree Panic
1733
SpriteFrame(64, 12, 144, 16, 259, 285) // #22 - Collision Chaos
1734
SpriteFrame(64, 12, 144, 16, 259, 302) // #23 - Tidal Tempest
1735
SpriteFrame(64, 12, 144, 16, 259, 319) // #24 - Quartz Quadrant
1736
SpriteFrame(64, 12, 144, 16, 259, 336) // #25 - Wacky Workbench
1737
SpriteFrame(64, 12, 144, 16, 259, 353) // #26 - Stardust Speedway
1738
SpriteFrame(64, 12, 144, 16, 259, 370) // #27 - Metallic Madness
1739
SpriteFrame(64, 12, 144, 16, 259, 387) // #28 - Final Fever
1740
SpriteFrame(64, 12, 144, 16, 259, 404) // #29 - Special Stage
1741
1742
ReadSaveRAM()
1743
Options.Soundtrack = SaveRAM[38]
1744
if SaveRAM[36] == true
1745
Options.TailsUnlocked = true
1746
end if
1747
1748
SpriteFrame(-112, 0, 224, 16, 1, 477) // #30 - Player Select
1749
1750
SpriteFrame(-16, -20, 32, 40, 26, 357) // #31 - Sonic
1751
if Options.TailsUnlocked == true
1752
SpriteFrame(-16, -12, 32, 32, 59, 365) // #32 - Tails
1753
else
1754
SpriteFrame(-16, -12, 32, 32, 72, 332) // #32 - Locked Tails
1755
end if
1756
1757
SpriteFrame(-24, -24, 48, 48, 405, 88) // #33 - Character Border
1758
1759
SpriteFrame(-14, 0, 27, 8, 454, 88) // #34 - Sonic Name
1760
if Options.TailsUnlocked == true
1761
// Bug Details:
1762
// This works fine everywhere else, but in the Blit releases of the game, this sprite was
1763
// extended in the JP spritesheet to match the width of (unused) Japanese text sprites
1764
// This difference wasn't taken into account here, causing Tails' name to be cut off in-game
1765
SpriteFrame(-12, 0, 24, 8, 482, 88) // #35 - Tails Name
1766
else
1767
SpriteFrame(-12, 0, 24, 8, 92, 365) // #35 - Tails Name Locked
1768
end if
1769
1770
SpriteFrame(-14, 0, 27, 8, 454, 97) // #36 - Sonic Name Highlight
1771
if Options.TailsUnlocked == true
1772
// Bug Details: Same as above
1773
SpriteFrame(-12, 0, 24, 8, 482, 97) // #37 - Tails Name Highlight
1774
else
1775
SpriteFrame(-12, 0, 24, 8, 92, 374) // #37 - Tails Name Locked
1776
end if
1777
1778
SpriteFrame(224, 7, 8, 8, 404, 137) // #38 - Green Time Stone
1779
SpriteFrame(232, 7, 8, 8, 413, 137) // #39 - Orange Time Stone
1780
SpriteFrame(220, 15, 8, 8, 422, 137) // #40 - Yellow Time Stone
1781
SpriteFrame(228, 15, 8, 8, 431, 137) // #41 - Blue Time Stone
1782
SpriteFrame(236, 15, 8, 8, 440, 137) // #42 - Cyan Time Stone
1783
SpriteFrame(224, 23, 8, 8, 449, 137) // #43 - Purple Time Stone
1784
SpriteFrame(232, 23, 8, 8, 458, 137) // #44 - Red Time Stone
1785
1786
// (#45 - #51) - Time Stone Socket
1787
SpriteFrame(224, 7, 8, 8, 467, 137)
1788
SpriteFrame(232, 7, 8, 8, 467, 137)
1789
SpriteFrame(220, 15, 8, 8, 467, 137)
1790
SpriteFrame(228, 15, 8, 8, 467, 137)
1791
SpriteFrame(236, 15, 8, 8, 467, 137)
1792
SpriteFrame(224, 23, 8, 8, 467, 137)
1793
SpriteFrame(232, 23, 8, 8, 467, 137)
1794
1795
SpriteFrame(0, 0, 64, 18, 404, 196) // #52 - Delete
1796
SpriteFrame(0, 0, 64, 18, 404, 215) // #53 - Delete Highlight
1797
SpriteFrame(0, 0, 64, 18, 404, 234) // #54 - Cancel
1798
SpriteFrame(0, 0, 64, 18, 404, 253) // #55 - Cancel Highlight
1799
SpriteFrame(0, 0, 250, 37, 259, 459) // #56 - Orange Alpha
1800
SpriteFrame(-112, 0, 224, 16, 1, 443) // #57 - "Delete Save Game?"
1801
SpriteFrame(-112, 0, 224, 16, 1, 460) // #58 - Unused
1802
SpriteFrame(208, 12, 8, 16, 478, 183) // #59 - 1
1803
SpriteFrame(208, 12, 8, 16, 487, 183) // #60 - 2
1804
SpriteFrame(208, 12, 8, 16, 496, 183) // #61 - 3
1805
SpriteFrame(208, 12, 8, 16, 469, 200) // #62 - 4
1806
SpriteFrame(208, 12, 8, 16, 478, 200) // #63 - 5
1807
SpriteFrame(208, 12, 8, 16, 487, 200) // #64 - 6
1808
SpriteFrame(208, 12, 8, 16, 496, 200) // #65 - 7
1809
SpriteFrame(208, 12, 8, 16, 469, 217) // #66 - 8 (Unused)
1810
// Highlights
1811
SpriteFrame(208, 12, 8, 16, 478, 234) // #67 - 1
1812
SpriteFrame(208, 12, 8, 16, 487, 234) // #68 - 2
1813
SpriteFrame(208, 12, 8, 16, 496, 234) // #69 - 3
1814
SpriteFrame(208, 12, 8, 16, 469, 251) // #70 - 4
1815
SpriteFrame(208, 12, 8, 16, 478, 251) // #71 - 5
1816
SpriteFrame(208, 12, 8, 16, 487, 251) // #72 - 6
1817
SpriteFrame(208, 12, 8, 16, 496, 251) // #73 - 7
1818
SpriteFrame(208, 12, 8, 16, 469, 268) // #74 - 8 (Unused)
1819
1820
SpriteFrame(-32, 0, 64, 21, 404, 319) // #75 - Yes
1821
SpriteFrame(-32, 0, 64, 21, 404, 341) // #76 - Yes Highlight
1822
SpriteFrame(-32, 0, 64, 21, 404, 363) // #77 - No
1823
SpriteFrame(-32, 0, 64, 21, 404, 385) // #78 - No Highlight
1824
end sub
1825
1826
1827
// ========================
1828
// Editor Subs
1829
// ========================
1830
1831
sub RSDKDraw
1832
DrawSprite(0)
1833
end sub
1834
1835
1836
sub RSDKLoad
1837
LoadSpriteSheet("Global/Display.gif")
1838
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
1839
1840
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
1841
end sub
1842
1843