forked from pret/pokeemerald
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain_menu.c
2305 lines (2130 loc) · 80.8 KB
/
main_menu.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "global.h"
#include "trainer_pokemon_sprites.h"
#include "bg.h"
#include "constants/rgb.h"
#include "constants/songs.h"
#include "constants/trainers.h"
#include "data.h"
#include "decompress.h"
#include "event_data.h"
#include "field_effect.h"
#include "gpu_regs.h"
#include "graphics.h"
#include "international_string_util.h"
#include "link.h"
#include "main.h"
#include "menu.h"
#include "list_menu.h"
#include "mystery_event_menu.h"
#include "naming_screen.h"
#include "option_menu.h"
#include "overworld.h"
#include "palette.h"
#include "pokeball.h"
#include "pokedex.h"
#include "pokemon.h"
#include "random.h"
#include "rtc.h"
#include "save.h"
#include "scanline_effect.h"
#include "sound.h"
#include "sprite.h"
#include "strings.h"
#include "string_util.h"
#include "task.h"
#include "text.h"
#include "text_window.h"
#include "title_screen.h"
#include "window.h"
#include "mystery_gift_menu.h"
/*
* Main menu state machine
* -----------------------
*
* Entry point: CB2_InitMainMenu
*
* Note: States advance sequentially unless otherwise stated.
*
* CB2_InitMainMenu / CB2_ReinitMainMenu
* - Both of these states call InitMainMenu, which does all the work.
* - In the Reinit case, the init code will check if the user came from
* the options screen. If they did, then the options menu item is
* pre-selected.
*
* Task_MainMenuCheckSaveFile
* - Determines how many menu options to show based on whether
* the save file is Ok, empty, corrupted, etc.
* - If there was an error loading the save file, advance to
* Task_WaitForSaveFileErrorWindow.
* - If there were no errors, advance to Task_MainMenuCheckBattery.
* - Note that the check to enable Mystery Events would normally happen
* here, but this version of Emerald has them disabled.
*
* Task_WaitForSaveFileErrorWindow
* - Wait for the text to finish printing and then for the A button
* to be pressed.
*
* Task_MainMenuCheckBattery
* - If the battery is OK, advance to Task_DisplayMainMenu.
* - If the battery is dry, advance to Task_WaitForBatteryDryErrorWindow.
*
* Task_WaitForBatteryDryErrorWindow
* - Wait for the text to finish printing and then for the A button
* to be pressed.
*
* Task_DisplayMainWindow
* - Display the buttons to the user. If the menu is in HAS_MYSTERY_EVENTS
* mode, there are too many buttons for one screen and a scrollbar is added,
* and the scrollbar task is spawned (Task_ScrollIndicatorArrowPairOnMainMenu).
*
* Task_HighlightSelectedMainMenuItem
* - Update the UI to match the currently selected item.
*
* Task_HandleMainMenuInput
* - If A is pressed, advance to Task_HandleMainMenuAPressed.
* - If B is pressed, return to the title screen via CB2_InitTitleScreen.
* - If Up or Down is pressed, handle scrolling if there is a scroll bar, change
* the selection, then go back to Task_HighlightSelectedMainMenuItem.
*
* Task_HandleMainMenuAPressed
* - If the user selected New Game, advance to Task_NewGameBirchSpeech_Init.
* - If the user selected Continue, advance to CB2_ContinueSavedGame.
* - If the user selected the Options menu, advance to CB2_InitOptionMenu.
* - If the user selected Mystery Gift, advance to CB2_InitMysteryGift. However,
* if the wireless adapter was removed, instead advance to
* Task_DisplayMainMenuInvalidActionError.
* - Code to start a Mystery Event is present here, but is unreachable in this
* version.
*
* Task_HandleMainMenuBPressed
* - Clean up the main menu and go back to CB2_InitTitleScreen.
*
* Task_DisplayMainMenuInvalidActionError
* - Print one of three different error messages, wait for the text to stop
* printing, and then wait for A or B to be pressed.
* - Then advance to Task_HandleMainMenuBPressed.
*
* Task_NewGameBirchSpeech_Init
* - Load the sprites for the intro speech, start playing music
* Task_NewGameBirchSpeech_WaitToShowBirch
* - Spawn Task_NewGameBirchSpeech_FadeInTarget1OutTarget2
* - Spawn Task_NewGameBirchSpeech_FadePlatformOut
* - Both of these tasks destroy themselves when done.
* Task_NewGameBirchSpeech_WaitForSpriteFadeInWelcome
* Task_NewGameBirchSpeech_ThisIsAPokemon
* - When the text is done printing, spawns Task_NewGameBirchSpeechSub_InitPokeball
* Task_NewGameBirchSpeech_MainSpeech
* Task_NewGameBirchSpeech_AndYouAre
* Task_NewGameBirchSpeech_StartBirchLotadPlatformFade
* Task_NewGameBirchSpeech_StartBirchLotadPlatformFade
* Task_NewGameBirchSpeech_SlidePlatformAway
* Task_NewGameBirchSpeech_StartPlayerFadeIn
* Task_NewGameBirchSpeech_WaitForPlayerFadeIn
* Task_NewGameBirchSpeech_BoyOrGirl
* Task_NewGameBirchSpeech_WaitToShowGenderMenu
* Task_NewGameBirchSpeech_ChooseGender
* - Animates by advancing to Task_NewGameBirchSpeech_SlideOutOldGenderSprite
* whenever the player's selection changes.
* - Advances to Task_NewGameBirchSpeech_WhatsYourName when done.
*
* Task_NewGameBirchSpeech_SlideOutOldGenderSprite
* Task_NewGameBirchSpeech_SlideInNewGenderSprite
* - Returns back to Task_NewGameBirchSpeech_ChooseGender.
*
* Task_NewGameBirchSpeech_WhatsYourName
* Task_NewGameBirchSpeech_WaitForWhatsYourNameToPrint
* Task_NewGameBirchSpeech_WaitPressBeforeNameChoice
* Task_NewGameBirchSpeech_StartNamingScreen
* C2_NamingScreen
* - Returns to CB2_NewGameBirchSpeech_ReturnFromNamingScreen when done
* CB2_NewGameBirchSpeech_ReturnFromNamingScreen
* Task_NewGameBirchSpeech_ReturnFromNamingScreenShowTextbox
* Task_NewGameBirchSpeech_SoItsPlayerName
* Task_NewGameBirchSpeech_CreateNameYesNo
* Task_NewGameBirchSpeech_ProcessNameYesNoMenu
* - If confirmed, advance to Task_NewGameBirchSpeech_SlidePlatformAway2.
* - Otherwise, return to Task_NewGameBirchSpeech_BoyOrGirl.
*
* Task_NewGameBirchSpeech_SlidePlatformAway2
* Task_NewGameBirchSpeech_ReshowBirchLotad
* Task_NewGameBirchSpeech_WaitForSpriteFadeInAndTextPrinter
* Task_NewGameBirchSpeech_AreYouReady
* Task_NewGameBirchSpeech_ShrinkPlayer
* Task_NewGameBirchSpeech_WaitForPlayerShrink
* Task_NewGameBirchSpeech_FadePlayerToWhite
* Task_NewGameBirchSpeech_Cleanup
* - Advances to CB2_NewGame.
*
* Task_NewGameBirchSpeechSub_InitPokeball
* - Advances to Task_NewGameBirchSpeechSub_WaitForLotad
* Task_NewGameBirchSpeechSub_WaitForLotad
* - Destroys itself when done.
*/
#define OPTION_MENU_FLAG (1 << 15)
// Static type declarations
// Static RAM declarations
static EWRAM_DATA bool8 sStartedPokeBallTask = 0;
static EWRAM_DATA u16 sCurrItemAndOptionMenuCheck = 0;
static u8 sBirchSpeechMainTaskId;
// Static ROM declarations
static u32 InitMainMenu(bool8);
static void Task_MainMenuCheckSaveFile(u8);
static void Task_MainMenuCheckBattery(u8);
static void Task_WaitForSaveFileErrorWindow(u8);
static void CreateMainMenuErrorWindow(const u8 *);
static void ClearMainMenuWindowTilemap(const struct WindowTemplate *);
static void Task_DisplayMainMenu(u8);
static void Task_WaitForBatteryDryErrorWindow(u8);
static void MainMenu_FormatSavegameText(void);
static void HighlightSelectedMainMenuItem(u8, u8, s16);
static void Task_HandleMainMenuInput(u8);
static void Task_HandleMainMenuAPressed(u8);
static void Task_HandleMainMenuBPressed(u8);
static void Task_NewGameBirchSpeech_Init(u8);
static void Task_DisplayMainMenuInvalidActionError(u8);
static void AddBirchSpeechObjects(u8);
static void Task_NewGameBirchSpeech_WaitToShowBirch(u8);
static void NewGameBirchSpeech_StartFadeInTarget1OutTarget2(u8, u8);
static void NewGameBirchSpeech_StartFadePlatformOut(u8, u8);
static void Task_NewGameBirchSpeech_WaitForSpriteFadeInWelcome(u8);
static void NewGameBirchSpeech_ShowDialogueWindow(u8, u8);
static void NewGameBirchSpeech_ClearWindow(u8);
static void Task_NewGameBirchSpeech_ThisIsAPokemon(u8);
static void Task_NewGameBirchSpeech_MainSpeech(u8);
static void NewGameBirchSpeech_WaitForThisIsPokemonText(struct TextPrinterTemplate *, u16);
static void Task_NewGameBirchSpeech_AndYouAre(u8);
static void Task_NewGameBirchSpeechSub_WaitForLotad(u8);
static void Task_NewGameBirchSpeech_StartBirchLotadPlatformFade(u8);
static void NewGameBirchSpeech_StartFadeOutTarget1InTarget2(u8, u8);
static void NewGameBirchSpeech_StartFadePlatformIn(u8, u8);
static void Task_NewGameBirchSpeech_SlidePlatformAway(u8);
static void Task_NewGameBirchSpeech_StartPlayerFadeIn(u8);
static void Task_NewGameBirchSpeech_WaitForPlayerFadeIn(u8);
static void Task_NewGameBirchSpeech_BoyOrGirl(u8);
static void LoadMainMenuWindowFrameTiles(u8, u16);
static void DrawMainMenuWindowBorder(const struct WindowTemplate *, u16);
static void Task_HighlightSelectedMainMenuItem(u8);
static void Task_NewGameBirchSpeech_WaitToShowGenderMenu(u8);
static void Task_NewGameBirchSpeech_ChooseGender(u8);
static void NewGameBirchSpeech_ShowGenderMenu(void);
static s8 NewGameBirchSpeech_ProcessGenderMenuInput(void);
static void NewGameBirchSpeech_ClearGenderWindow(u8, u8);
static void Task_NewGameBirchSpeech_WhatsYourName(u8);
static void Task_NewGameBirchSpeech_SlideOutOldGenderSprite(u8);
static void Task_NewGameBirchSpeech_SlideInNewGenderSprite(u8);
static void Task_NewGameBirchSpeech_WaitForWhatsYourNameToPrint(u8);
static void Task_NewGameBirchSpeech_WaitPressBeforeNameChoice(u8);
static void Task_NewGameBirchSpeech_StartNamingScreen(u8);
static void CB2_NewGameBirchSpeech_ReturnFromNamingScreen(void);
static void NewGameBirchSpeech_SetDefaultPlayerName(u8);
static void Task_NewGameBirchSpeech_CreateNameYesNo(u8);
static void Task_NewGameBirchSpeech_ProcessNameYesNoMenu(u8);
void CreateYesNoMenuParameterized(u8, u8, u16, u16, u8, u8);
static void Task_NewGameBirchSpeech_SlidePlatformAway2(u8);
static void Task_NewGameBirchSpeech_ReshowBirchLotad(u8);
static void Task_NewGameBirchSpeech_WaitForSpriteFadeInAndTextPrinter(u8);
static void Task_NewGameBirchSpeech_AreYouReady(u8);
static void Task_NewGameBirchSpeech_ShrinkPlayer(u8);
static void SpriteCB_MovePlayerDownWhileShrinking(struct Sprite *);
static void Task_NewGameBirchSpeech_WaitForPlayerShrink(u8);
static void Task_NewGameBirchSpeech_FadePlayerToWhite(u8);
static void Task_NewGameBirchSpeech_Cleanup(u8);
static void SpriteCB_Null();
static void Task_NewGameBirchSpeech_ReturnFromNamingScreenShowTextbox(u8);
static void MainMenu_FormatSavegamePlayer(void);
static void MainMenu_FormatSavegamePokedex(void);
static void MainMenu_FormatSavegameTime(void);
static void MainMenu_FormatSavegameBadges(void);
static void NewGameBirchSpeech_CreateDialogueWindowBorder(u8, u8, u8, u8, u8, u8);
// .rodata
static const u16 sBirchSpeechBgPals[][16] = {
INCBIN_U16("graphics/birch_speech/bg0.gbapal"),
INCBIN_U16("graphics/birch_speech/bg1.gbapal")
};
static const u32 sBirchSpeechShadowGfx[] = INCBIN_U32("graphics/birch_speech/shadow.4bpp.lz");
static const u32 sBirchSpeechBgMap[] = INCBIN_U32("graphics/birch_speech/map.bin.lz");
static const u16 sBirchSpeechBgGradientPal[] = INCBIN_U16("graphics/birch_speech/bg2.gbapal");
#define MENU_LEFT 2
#define MENU_TOP_WIN0 1
#define MENU_TOP_WIN1 5
#define MENU_TOP_WIN2 1
#define MENU_TOP_WIN3 9
#define MENU_TOP_WIN4 13
#define MENU_TOP_WIN5 17
#define MENU_TOP_WIN6 21
#define MENU_WIDTH 26
#define MENU_HEIGHT_WIN0 2
#define MENU_HEIGHT_WIN1 2
#define MENU_HEIGHT_WIN2 6
#define MENU_HEIGHT_WIN3 2
#define MENU_HEIGHT_WIN4 2
#define MENU_HEIGHT_WIN5 2
#define MENU_HEIGHT_WIN6 2
#define MENU_LEFT_ERROR 2
#define MENU_TOP_ERROR 15
#define MENU_WIDTH_ERROR 26
#define MENU_HEIGHT_ERROR 4
#define MENU_SHADOW_PADDING 1
#define MENU_WIN_HCOORDS WIN_RANGE(((MENU_LEFT - 1) * 8) + MENU_SHADOW_PADDING, (MENU_LEFT + MENU_WIDTH + 1) * 8 - MENU_SHADOW_PADDING)
#define MENU_WIN_VCOORDS(n) WIN_RANGE(((MENU_TOP_WIN##n - 1) * 8) + MENU_SHADOW_PADDING, (MENU_TOP_WIN##n + MENU_HEIGHT_WIN##n + 1) * 8 - MENU_SHADOW_PADDING)
#define MENU_SCROLL_SHIFT WIN_RANGE(32, 32)
static const struct WindowTemplate sWindowTemplates_MainMenu[] =
{
// No saved game
// NEW GAME
{
.bg = 0,
.tilemapLeft = MENU_LEFT,
.tilemapTop = MENU_TOP_WIN0,
.width = MENU_WIDTH,
.height = MENU_HEIGHT_WIN0,
.paletteNum = 15,
.baseBlock = 1
},
// OPTIONS
{
.bg = 0,
.tilemapLeft = MENU_LEFT,
.tilemapTop = MENU_TOP_WIN1,
.width = MENU_WIDTH,
.height = MENU_HEIGHT_WIN1,
.paletteNum = 15,
.baseBlock = 0x35
},
// Has saved game
// CONTINUE
{
.bg = 0,
.tilemapLeft = MENU_LEFT,
.tilemapTop = MENU_TOP_WIN2,
.width = MENU_WIDTH,
.height = MENU_HEIGHT_WIN2,
.paletteNum = 15,
.baseBlock = 1
},
// NEW GAME
{
.bg = 0,
.tilemapLeft = MENU_LEFT,
.tilemapTop = MENU_TOP_WIN3,
.width = MENU_WIDTH,
.height = MENU_HEIGHT_WIN3,
.paletteNum = 15,
.baseBlock = 0x9D
},
// OPTION / MYSTERY GIFT
{
.bg = 0,
.tilemapLeft = MENU_LEFT,
.tilemapTop = MENU_TOP_WIN4,
.width = MENU_WIDTH,
.height = MENU_HEIGHT_WIN4,
.paletteNum = 15,
.baseBlock = 0xD1
},
// OPTION / MYSTERY EVENTS
{
.bg = 0,
.tilemapLeft = MENU_LEFT,
.tilemapTop = MENU_TOP_WIN5,
.width = MENU_WIDTH,
.height = MENU_HEIGHT_WIN5,
.paletteNum = 15,
.baseBlock = 0x105
},
// OPTION
{
.bg = 0,
.tilemapLeft = MENU_LEFT,
.tilemapTop = MENU_TOP_WIN6,
.width = MENU_WIDTH,
.height = MENU_HEIGHT_WIN6,
.paletteNum = 15,
.baseBlock = 0x139
},
// Error message window
{
.bg = 0,
.tilemapLeft = MENU_LEFT_ERROR,
.tilemapTop = MENU_TOP_ERROR,
.width = MENU_WIDTH_ERROR,
.height = MENU_HEIGHT_ERROR,
.paletteNum = 15,
.baseBlock = 0x16D
},
DUMMY_WIN_TEMPLATE
};
static const struct WindowTemplate sNewGameBirchSpeechTextWindows[] =
{
{
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 15,
.width = 27,
.height = 4,
.paletteNum = 15,
.baseBlock = 1
},
{
.bg = 0,
.tilemapLeft = 3,
.tilemapTop = 5,
.width = 6,
.height = 4,
.paletteNum = 15,
.baseBlock = 0x6D
},
{
.bg = 0,
.tilemapLeft = 3,
.tilemapTop = 2,
.width = 9,
.height = 10,
.paletteNum = 15,
.baseBlock = 0x85
},
DUMMY_WIN_TEMPLATE
};
static const u16 sMainMenuBgPal[] = INCBIN_U16("graphics/interface/main_menu_bg.gbapal");
static const u16 sMainMenuTextPal[] = INCBIN_U16("graphics/interface/main_menu_text.gbapal");
static const u8 sTextColor_Headers[] = {TEXT_DYNAMIC_COLOR_1, TEXT_DYNAMIC_COLOR_2, TEXT_DYNAMIC_COLOR_3};
static const u8 sTextColor_MenuInfo[] = {TEXT_DYNAMIC_COLOR_1, TEXT_COLOR_WHITE, TEXT_DYNAMIC_COLOR_3};
static const struct BgTemplate sMainMenuBgTemplates[] = {
{
.bg = 0,
.charBaseIndex = 2,
.mapBaseIndex = 30,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 1,
.charBaseIndex = 0,
.mapBaseIndex = 7,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
}
};
static const struct BgTemplate sBirchBgTemplate = {
.bg = 0,
.charBaseIndex = 3,
.mapBaseIndex = 30,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
};
static const struct ScrollArrowsTemplate sScrollArrowsTemplate_MainMenu = {2, 0x78, 8, 3, 0x78, 0x98, 3, 4, 1, 1, 0};
static const union AffineAnimCmd sSpriteAffineAnim_PlayerShrink[] = {
AFFINEANIMCMD_FRAME(-2, -2, 0, 0x30),
AFFINEANIMCMD_END
};
static const union AffineAnimCmd *const sSpriteAffineAnimTable_PlayerShrink[] =
{
sSpriteAffineAnim_PlayerShrink
};
static const struct MenuAction sMenuActions_Gender[] = {
{gText_BirchBoy, {NULL}},
{gText_BirchGirl, {NULL}}
};
static const u8 *const sMalePresetNames[] = {
gText_DefaultNameStu,
gText_DefaultNameMilton,
gText_DefaultNameTom,
gText_DefaultNameKenny,
gText_DefaultNameReid,
gText_DefaultNameJude,
gText_DefaultNameJaxson,
gText_DefaultNameEaston,
gText_DefaultNameWalker,
gText_DefaultNameTeru,
gText_DefaultNameJohnny,
gText_DefaultNameBrett,
gText_DefaultNameSeth,
gText_DefaultNameTerry,
gText_DefaultNameCasey,
gText_DefaultNameDarren,
gText_DefaultNameLandon,
gText_DefaultNameCollin,
gText_DefaultNameStanley,
gText_DefaultNameQuincy
};
static const u8 *const sFemalePresetNames[] = {
gText_DefaultNameKimmy,
gText_DefaultNameTiara,
gText_DefaultNameBella,
gText_DefaultNameJayla,
gText_DefaultNameAllie,
gText_DefaultNameLianna,
gText_DefaultNameSara,
gText_DefaultNameMonica,
gText_DefaultNameCamila,
gText_DefaultNameAubree,
gText_DefaultNameRuthie,
gText_DefaultNameHazel,
gText_DefaultNameNadine,
gText_DefaultNameTanja,
gText_DefaultNameYasmin,
gText_DefaultNameNicola,
gText_DefaultNameLillie,
gText_DefaultNameTerra,
gText_DefaultNameLucy,
gText_DefaultNameHalie
};
// The number of male vs. female names is assumed to be the same.
// If they aren't, the smaller of the two sizes will be used and any extra names will be ignored.
#define NUM_PRESET_NAMES min(ARRAY_COUNT(sMalePresetNames), ARRAY_COUNT(sFemalePresetNames))
enum
{
HAS_NO_SAVED_GAME, //NEW GAME, OPTION
HAS_SAVED_GAME, //CONTINUE, NEW GAME, OPTION
HAS_MYSTERY_GIFT, //CONTINUE, NEW GAME, MYSTERY GIFT, OPTION
HAS_MYSTERY_EVENTS, //CONTINUE, NEW GAME, MYSTERY GIFT, MYSTERY EVENTS, OPTION
};
enum
{
ACTION_NEW_GAME,
ACTION_CONTINUE,
ACTION_OPTION,
ACTION_MYSTERY_GIFT,
ACTION_MYSTERY_EVENTS,
ACTION_EREADER,
ACTION_INVALID
};
#define MAIN_MENU_BORDER_TILE 0x1D5
static void CB2_MainMenu(void)
{
RunTasks();
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
}
static void VBlankCB_MainMenu(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
void CB2_InitMainMenu(void)
{
InitMainMenu(FALSE);
}
void CB2_ReinitMainMenu(void)
{
InitMainMenu(TRUE);
}
static u32 InitMainMenu(bool8 returningFromOptionsMenu)
{
SetVBlankCallback(NULL);
SetGpuReg(REG_OFFSET_DISPCNT, 0);
SetGpuReg(REG_OFFSET_BG2CNT, 0);
SetGpuReg(REG_OFFSET_BG1CNT, 0);
SetGpuReg(REG_OFFSET_BG0CNT, 0);
SetGpuReg(REG_OFFSET_BG2HOFS, 0);
SetGpuReg(REG_OFFSET_BG2VOFS, 0);
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
SetGpuReg(REG_OFFSET_BG1VOFS, 0);
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
DmaFill16(3, 0, (void *)VRAM, VRAM_SIZE);
DmaFill32(3, 0, (void *)OAM, OAM_SIZE);
DmaFill16(3, 0, (void *)(PLTT + 2), PLTT_SIZE - 2);
ResetPaletteFade();
LoadPalette(sMainMenuBgPal, BG_PLTT_ID(0), PLTT_SIZE_4BPP);
LoadPalette(sMainMenuTextPal, BG_PLTT_ID(15), PLTT_SIZE_4BPP);
ScanlineEffect_Stop();
ResetTasks();
ResetSpriteData();
FreeAllSpritePalettes();
if (returningFromOptionsMenu)
BeginNormalPaletteFade(PALETTES_ALL, 0, 0x10, 0, RGB_BLACK); // fade to black
else
BeginNormalPaletteFade(PALETTES_ALL, 0, 0x10, 0, RGB_WHITEALPHA); // fade to white
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sMainMenuBgTemplates, ARRAY_COUNT(sMainMenuBgTemplates));
ChangeBgX(0, 0, BG_COORD_SET);
ChangeBgY(0, 0, BG_COORD_SET);
ChangeBgX(1, 0, BG_COORD_SET);
ChangeBgY(1, 0, BG_COORD_SET);
InitWindows(sWindowTemplates_MainMenu);
DeactivateAllTextPrinters();
LoadMainMenuWindowFrameTiles(0, MAIN_MENU_BORDER_TILE);
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_WININ, 0);
SetGpuReg(REG_OFFSET_WINOUT, 0);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0);
EnableInterrupts(1);
SetVBlankCallback(VBlankCB_MainMenu);
SetMainCallback2(CB2_MainMenu);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
ShowBg(0);
HideBg(1);
CreateTask(Task_MainMenuCheckSaveFile, 0);
return 0;
}
#define tMenuType data[0]
#define tCurrItem data[1]
#define tItemCount data[12]
#define tScrollArrowTaskId data[13]
#define tIsScrolled data[14]
#define tWirelessAdapterConnected data[15]
#define tArrowTaskIsScrolled data[15] // For scroll indicator arrow task
static void Task_MainMenuCheckSaveFile(u8 taskId)
{
s16 *data = gTasks[taskId].data;
if (!gPaletteFade.active)
{
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG0 | WININ_WIN0_OBJ);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_DARKEN | BLDCNT_TGT1_BG0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 7);
if (IsWirelessAdapterConnected())
tWirelessAdapterConnected = TRUE;
switch (gSaveFileStatus)
{
case SAVE_STATUS_OK:
tMenuType = HAS_SAVED_GAME;
if (IsMysteryGiftEnabled())
tMenuType++;
gTasks[taskId].func = Task_MainMenuCheckBattery;
break;
case SAVE_STATUS_CORRUPT:
CreateMainMenuErrorWindow(gText_SaveFileErased);
tMenuType = HAS_NO_SAVED_GAME;
gTasks[taskId].func = Task_WaitForSaveFileErrorWindow;
break;
case SAVE_STATUS_ERROR:
CreateMainMenuErrorWindow(gText_SaveFileCorrupted);
gTasks[taskId].func = Task_WaitForSaveFileErrorWindow;
tMenuType = HAS_SAVED_GAME;
if (IsMysteryGiftEnabled() == TRUE)
tMenuType++;
break;
case SAVE_STATUS_EMPTY:
default:
tMenuType = HAS_NO_SAVED_GAME;
gTasks[taskId].func = Task_MainMenuCheckBattery;
break;
case SAVE_STATUS_NO_FLASH:
CreateMainMenuErrorWindow(gJPText_No1MSubCircuit);
gTasks[taskId].tMenuType = HAS_NO_SAVED_GAME;
gTasks[taskId].func = Task_WaitForSaveFileErrorWindow;
break;
}
if (sCurrItemAndOptionMenuCheck & OPTION_MENU_FLAG) // are we returning from the options menu?
{
switch (tMenuType) // if so, highlight the OPTIONS item
{
case HAS_NO_SAVED_GAME:
case HAS_SAVED_GAME:
sCurrItemAndOptionMenuCheck = tMenuType + 1;
break;
case HAS_MYSTERY_GIFT:
sCurrItemAndOptionMenuCheck = 3;
break;
case HAS_MYSTERY_EVENTS:
sCurrItemAndOptionMenuCheck = 4;
break;
}
}
sCurrItemAndOptionMenuCheck &= ~OPTION_MENU_FLAG; // turn off the "returning from options menu" flag
tCurrItem = sCurrItemAndOptionMenuCheck;
tItemCount = tMenuType + 2;
}
}
static void Task_WaitForSaveFileErrorWindow(u8 taskId)
{
RunTextPrinters();
if (!IsTextPrinterActive(7) && (JOY_NEW(A_BUTTON)))
{
ClearWindowTilemap(7);
ClearMainMenuWindowTilemap(&sWindowTemplates_MainMenu[7]);
gTasks[taskId].func = Task_MainMenuCheckBattery;
}
}
static void Task_MainMenuCheckBattery(u8 taskId)
{
if (!gPaletteFade.active)
{
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG0 | WININ_WIN0_OBJ);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_DARKEN | BLDCNT_TGT1_BG0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 7);
if (!(RtcGetErrorStatus() & RTC_ERR_FLAG_MASK))
{
gTasks[taskId].func = Task_DisplayMainMenu;
}
else
{
CreateMainMenuErrorWindow(gText_BatteryRunDry);
gTasks[taskId].func = Task_WaitForBatteryDryErrorWindow;
}
}
}
static void Task_WaitForBatteryDryErrorWindow(u8 taskId)
{
RunTextPrinters();
if (!IsTextPrinterActive(7) && (JOY_NEW(A_BUTTON)))
{
ClearWindowTilemap(7);
ClearMainMenuWindowTilemap(&sWindowTemplates_MainMenu[7]);
gTasks[taskId].func = Task_DisplayMainMenu;
}
}
static void Task_DisplayMainMenu(u8 taskId)
{
s16 *data = gTasks[taskId].data;
u16 palette;
if (!gPaletteFade.active)
{
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG0 | WININ_WIN0_OBJ);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_DARKEN | BLDCNT_TGT1_BG0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 7);
palette = RGB_BLACK;
LoadPalette(&palette, BG_PLTT_ID(15) + 14, PLTT_SIZEOF(1));
palette = RGB_WHITE;
LoadPalette(&palette, BG_PLTT_ID(15) + 10, PLTT_SIZEOF(1));
palette = RGB(12, 12, 12);
LoadPalette(&palette, BG_PLTT_ID(15) + 11, PLTT_SIZEOF(1));
palette = RGB(26, 26, 25);
LoadPalette(&palette, BG_PLTT_ID(15) + 12, PLTT_SIZEOF(1));
// Note: If there is no save file, the save block is zeroed out,
// so the default gender is MALE.
if (gSaveBlock2Ptr->playerGender == MALE)
{
palette = RGB(4, 16, 31);
LoadPalette(&palette, BG_PLTT_ID(15) + 1, PLTT_SIZEOF(1));
}
else
{
palette = RGB(31, 3, 21);
LoadPalette(&palette, BG_PLTT_ID(15) + 1, PLTT_SIZEOF(1));
}
switch (gTasks[taskId].tMenuType)
{
case HAS_NO_SAVED_GAME:
default:
FillWindowPixelBuffer(0, PIXEL_FILL(0xA));
FillWindowPixelBuffer(1, PIXEL_FILL(0xA));
AddTextPrinterParameterized3(0, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuNewGame);
AddTextPrinterParameterized3(1, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuOption);
PutWindowTilemap(0);
PutWindowTilemap(1);
CopyWindowToVram(0, COPYWIN_GFX);
CopyWindowToVram(1, COPYWIN_GFX);
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[0], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[1], MAIN_MENU_BORDER_TILE);
break;
case HAS_SAVED_GAME:
FillWindowPixelBuffer(2, PIXEL_FILL(0xA));
FillWindowPixelBuffer(3, PIXEL_FILL(0xA));
FillWindowPixelBuffer(4, PIXEL_FILL(0xA));
AddTextPrinterParameterized3(2, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuContinue);
AddTextPrinterParameterized3(3, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuNewGame);
AddTextPrinterParameterized3(4, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuOption);
MainMenu_FormatSavegameText();
PutWindowTilemap(2);
PutWindowTilemap(3);
PutWindowTilemap(4);
CopyWindowToVram(2, COPYWIN_GFX);
CopyWindowToVram(3, COPYWIN_GFX);
CopyWindowToVram(4, COPYWIN_GFX);
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[2], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[3], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[4], MAIN_MENU_BORDER_TILE);
break;
case HAS_MYSTERY_GIFT:
FillWindowPixelBuffer(2, PIXEL_FILL(0xA));
FillWindowPixelBuffer(3, PIXEL_FILL(0xA));
FillWindowPixelBuffer(4, PIXEL_FILL(0xA));
FillWindowPixelBuffer(5, PIXEL_FILL(0xA));
AddTextPrinterParameterized3(2, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuContinue);
AddTextPrinterParameterized3(3, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuNewGame);
AddTextPrinterParameterized3(4, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuMysteryGift);
AddTextPrinterParameterized3(5, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuOption);
MainMenu_FormatSavegameText();
PutWindowTilemap(2);
PutWindowTilemap(3);
PutWindowTilemap(4);
PutWindowTilemap(5);
CopyWindowToVram(2, COPYWIN_GFX);
CopyWindowToVram(3, COPYWIN_GFX);
CopyWindowToVram(4, COPYWIN_GFX);
CopyWindowToVram(5, COPYWIN_GFX);
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[2], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[3], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[4], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[5], MAIN_MENU_BORDER_TILE);
break;
case HAS_MYSTERY_EVENTS:
FillWindowPixelBuffer(2, PIXEL_FILL(0xA));
FillWindowPixelBuffer(3, PIXEL_FILL(0xA));
FillWindowPixelBuffer(4, PIXEL_FILL(0xA));
FillWindowPixelBuffer(5, PIXEL_FILL(0xA));
FillWindowPixelBuffer(6, PIXEL_FILL(0xA));
AddTextPrinterParameterized3(2, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuContinue);
AddTextPrinterParameterized3(3, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuNewGame);
AddTextPrinterParameterized3(4, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuMysteryGift2);
AddTextPrinterParameterized3(5, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuMysteryEvents);
AddTextPrinterParameterized3(6, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuOption);
MainMenu_FormatSavegameText();
PutWindowTilemap(2);
PutWindowTilemap(3);
PutWindowTilemap(4);
PutWindowTilemap(5);
PutWindowTilemap(6);
CopyWindowToVram(2, COPYWIN_GFX);
CopyWindowToVram(3, COPYWIN_GFX);
CopyWindowToVram(4, COPYWIN_GFX);
CopyWindowToVram(5, COPYWIN_GFX);
CopyWindowToVram(6, COPYWIN_GFX);
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[2], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[3], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[4], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[5], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[6], MAIN_MENU_BORDER_TILE);
tScrollArrowTaskId = AddScrollIndicatorArrowPair(&sScrollArrowsTemplate_MainMenu, &sCurrItemAndOptionMenuCheck);
gTasks[tScrollArrowTaskId].func = Task_ScrollIndicatorArrowPairOnMainMenu;
if (sCurrItemAndOptionMenuCheck == 4)
{
ChangeBgY(0, 0x2000, BG_COORD_ADD);
ChangeBgY(1, 0x2000, BG_COORD_ADD);
tIsScrolled = TRUE;
gTasks[tScrollArrowTaskId].tArrowTaskIsScrolled = TRUE;
}
break;
}
gTasks[taskId].func = Task_HighlightSelectedMainMenuItem;
}
}
static void Task_HighlightSelectedMainMenuItem(u8 taskId)
{
HighlightSelectedMainMenuItem(gTasks[taskId].tMenuType, gTasks[taskId].tCurrItem, gTasks[taskId].tIsScrolled);
gTasks[taskId].func = Task_HandleMainMenuInput;
}
static bool8 HandleMainMenuInput(u8 taskId)
{
s16 *data = gTasks[taskId].data;
if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
IsWirelessAdapterConnected(); // why bother calling this here? debug? Task_HandleMainMenuAPressed will check too
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
gTasks[taskId].func = Task_HandleMainMenuAPressed;
}
else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_WHITEALPHA);
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(0, DISPLAY_WIDTH));
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(0, DISPLAY_HEIGHT));
gTasks[taskId].func = Task_HandleMainMenuBPressed;
}
else if ((JOY_NEW(DPAD_UP)) && tCurrItem > 0)
{
if (tMenuType == HAS_MYSTERY_EVENTS && tIsScrolled == TRUE && tCurrItem == 1)
{
ChangeBgY(0, 0x2000, BG_COORD_SUB);
ChangeBgY(1, 0x2000, BG_COORD_SUB);
gTasks[tScrollArrowTaskId].tArrowTaskIsScrolled = tIsScrolled = FALSE;
}
tCurrItem--;
sCurrItemAndOptionMenuCheck = tCurrItem;
return TRUE;
}
else if ((JOY_NEW(DPAD_DOWN)) && tCurrItem < tItemCount - 1)
{
if (tMenuType == HAS_MYSTERY_EVENTS && tCurrItem == 3 && tIsScrolled == FALSE)
{
ChangeBgY(0, 0x2000, BG_COORD_ADD);
ChangeBgY(1, 0x2000, BG_COORD_ADD);
gTasks[tScrollArrowTaskId].tArrowTaskIsScrolled = tIsScrolled = TRUE;
}
tCurrItem++;
sCurrItemAndOptionMenuCheck = tCurrItem;
return TRUE;
}
return FALSE;
}
static void Task_HandleMainMenuInput(u8 taskId)
{
if (HandleMainMenuInput(taskId))
gTasks[taskId].func = Task_HighlightSelectedMainMenuItem;
}
static void Task_HandleMainMenuAPressed(u8 taskId)
{
bool8 wirelessAdapterConnected;
u8 action;
if (!gPaletteFade.active)
{
if (gTasks[taskId].tMenuType == HAS_MYSTERY_EVENTS)
RemoveScrollIndicatorArrowPair(gTasks[taskId].tScrollArrowTaskId);
ClearStdWindowAndFrame(0, TRUE);
ClearStdWindowAndFrame(1, TRUE);
ClearStdWindowAndFrame(2, TRUE);
ClearStdWindowAndFrame(3, TRUE);
ClearStdWindowAndFrame(4, TRUE);
ClearStdWindowAndFrame(5, TRUE);
ClearStdWindowAndFrame(6, TRUE);
ClearStdWindowAndFrame(7, TRUE);
wirelessAdapterConnected = IsWirelessAdapterConnected();
switch (gTasks[taskId].tMenuType)
{
case HAS_NO_SAVED_GAME:
default:
switch (gTasks[taskId].tCurrItem)
{
case 0:
default:
action = ACTION_NEW_GAME;
break;
case 1:
action = ACTION_OPTION;
break;
}
break;
case HAS_SAVED_GAME:
switch (gTasks[taskId].tCurrItem)
{
case 0:
default:
action = ACTION_CONTINUE;
break;
case 1:
action = ACTION_NEW_GAME;
break;
case 2:
action = ACTION_OPTION;
break;
}
break;
case HAS_MYSTERY_GIFT:
switch (gTasks[taskId].tCurrItem)
{
case 0:
default:
action = ACTION_CONTINUE;
break;
case 1:
action = ACTION_NEW_GAME;
break;
case 2:
action = ACTION_MYSTERY_GIFT;
if (!wirelessAdapterConnected)
{
action = ACTION_INVALID;
gTasks[taskId].tMenuType = HAS_NO_SAVED_GAME;
}
break;