forked from pret/pokeemerald
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbattle_factory_screen.c
4314 lines (3980 loc) · 147 KB
/
battle_factory_screen.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 "battle.h"
#include "battle_factory_screen.h"
#include "battle_factory.h"
#include "sprite.h"
#include "event_data.h"
#include "overworld.h"
#include "random.h"
#include "battle_tower.h"
#include "text.h"
#include "palette.h"
#include "task.h"
#include "main.h"
#include "malloc.h"
#include "bg.h"
#include "gpu_regs.h"
#include "string_util.h"
#include "international_string_util.h"
#include "window.h"
#include "data.h"
#include "decompress.h"
#include "pokemon_summary_screen.h"
#include "sound.h"
#include "pokedex.h"
#include "util.h"
#include "trainer_pokemon_sprites.h"
#include "starter_choose.h"
#include "strings.h"
#include "graphics.h"
#include "constants/battle_frontier.h"
#include "constants/battle_tent.h"
#include "constants/songs.h"
#include "constants/rgb.h"
// Select_ refers to the first Pokémon selection screen where you choose your initial 3 rental Pokémon.
// Swap_ refers to the subsequent selection screens where you can swap a Pokémon with one from the beaten trainer
// Note that, generally, "Action" will refer to the immediate actions that can be taken on each screen,
// i.e. selecting a Pokémon or selecting the Cancel button
// The "Options menu" will refer to the popup menu that shows when some actions have been selected
#define SWAP_PLAYER_SCREEN 0 // The screen where the player selects which of their Pokémon to swap away
#define SWAP_ENEMY_SCREEN 1 // The screen where the player selects which new Pokémon from the defeated party to swap for
#define SELECTABLE_MONS_COUNT 6
#define PALNUM_FADE_TEXT 14
#define PALNUM_TEXT 15
enum {
PALTAG_BALL_GRAY = 100,
PALTAG_BALL_SELECTED,
PALTAG_INTERFACE,
PALTAG_MON_PIC_BG,
};
enum {
GFXTAG_BALL = 100,
GFXTAG_ARROW,
GFXTAG_MENU_HIGHLIGHT_LEFT,
GFXTAG_MENU_HIGHLIGHT_RIGHT,
GFXTAG_ACTION_BOX_LEFT,
GFXTAG_ACTION_BOX_RIGHT,
GFXTAG_ACTION_HIGHLIGHT_LEFT,
GFXTAG_ACTION_HIGHLIGHT_MIDDLE,
GFXTAG_ACTION_HIGHLIGHT_RIGHT,
GFXTAG_MON_PIC_BG_ANIM,
};
// Tasks in this file universally use data[0] as a state for switches
#define tState data[0]
// States for both Select/Swap versions of Task_FadeSpeciesName
enum {
FADESTATE_INIT,
FADESTATE_RUN,
FADESTATE_DELAY
};
// Return states for the Select Actions
enum {
SELECT_SUMMARY,
SELECT_CONTINUE_CHOOSING,
SELECT_CONFIRM_MONS,
SELECT_INVALID_MON,
};
struct FactorySelectableMon
{
u16 monId;
u16 ballSpriteId;
u8 selectedId; // 0 - not selected, 1 - first Pokémon, 2 - second Pokémon, 3 - third Pokémon
struct Pokemon monData;
};
struct FactoryMonPic
{
u8 monSpriteId;
u8 bgSpriteId;
};
struct FactorySelectScreen
{
u8 menuCursorPos;
u8 menuCursor1SpriteId;
u8 menuCursor2SpriteId;
u8 cursorPos;
u8 cursorSpriteId;
u8 selectingMonsState;
bool8 fromSummaryScreen;
u8 yesNoCursorPos;
u8 unused;
struct FactorySelectableMon mons[SELECTABLE_MONS_COUNT];
struct FactoryMonPic monPics[FRONTIER_PARTY_SIZE]; // Array so all chosen mons can be shown at once
bool8 monPicAnimating;
u8 fadeSpeciesNameTaskId;
bool8 fadeSpeciesNameActive;
u16 speciesNameColorBackup;
bool8 fadeSpeciesNameFadeOut;
u8 fadeSpeciesNameCoeffDelay;
u8 fadeSpeciesNameCoeff;
u8 faceSpeciesNameDelay;
};
struct SwapScreenAction
{
u8 id;
void (*func)(u8 taskId);
};
struct FactorySwapScreen
{
u8 menuCursorPos;
u8 menuCursor1SpriteId;
u8 menuCursor2SpriteId;
u8 cursorPos;
u8 cursorSpriteId;
u8 ballSpriteIds[FRONTIER_PARTY_SIZE];
u8 pkmnForSwapButtonSpriteIds[2][3]; // For this and sprite ID array below, [0][i] is the button background, [1][i] is the button highlight
u8 cancelButtonSpriteIds[2][2];
u8 playerMonId;
u8 enemyMonId;
bool8 inEnemyScreen;
bool8 fromSummaryScreen;
u8 yesNoCursorPos;
u8 actionsCount;
const struct SwapScreenAction *actionsData;
u8 unused[4];
bool8 monSwapped;
u8 fadeSpeciesNameTaskId;
bool8 fadeSpeciesNameActive;
u16 speciesNameColorBackup;
bool8 fadeSpeciesNameFadeOut;
u8 fadeSpeciesNameCoeffDelay;
u8 fadeSpeciesNameCoeff;
u8 faceSpeciesNameDelay;
struct FactoryMonPic monPic;
bool8 monPicAnimating;
};
static void SpriteCB_Pokeball(struct Sprite *);
static void SpriteCB_OpenMonPic(struct Sprite *);
static void OpenMonPic(u8 *, bool8 *, bool8);
static void HideMonPic(struct FactoryMonPic, bool8 *);
static void CloseMonPic(struct FactoryMonPic, bool8 *, bool8);
static void Task_OpenMonPic(u8);
static void Task_CloseMonPic(u8);
// Select screen
static void CB2_InitSelectScreen(void);
static void Select_SetWinRegs(s16, s16, s16, s16);
static void Select_InitMonsData(void);
static void Select_InitAllSprites(void);
static void Select_ReshowMonSprite(void);
static void Select_PrintSelectMonString(void);
static void Select_PrintMonSpecies(void);
static void Select_PrintMonCategory(void);
static void Select_PrintRentalPkmnString(void);
static void Select_CopyMonsToPlayerParty(void);
static void Select_ShowChosenMons(void);
static void Select_ShowYesNoOptions(void);
static void Select_HideChosenMons(void);
static void Select_ShowMenuOptions(void);
static void Select_PrintMenuOptions(void);
static void Select_PrintYesNoOptions(void);
static void Select_Task_FadeSpeciesName(u8);
static void Select_Task_OpenChosenMonPics(u8);
static void Select_Task_HandleChooseMons(u8);
static void Select_Task_HandleMenu(u8);
static void CreateFrontierFactorySelectableMons(u8);
static void CreateSlateportTentSelectableMons(u8);
static void Select_SetBallSpritePaletteNum(u8);
static void Select_ErasePopupMenu(u8);
static u8 Select_RunMenuOptionFunc(void);
static u8 Select_DeclineChosenMons(void);
static u8 Select_OptionSummary(void);
static u8 Select_OptionOthers(void);
static u8 Select_OptionRentDeselect(void);
static bool32 Select_AreSpeciesValid(u16);
// Swap screen
static void CB2_InitSwapScreen(void);
static void Swap_DestroyAllSprites(void);
static void Swap_ShowYesNoOptions(void);
static void Swap_HideActionButtonHighlights(void);
static void Swap_EraseSpeciesWindow(void);
static void Swap_UpdateYesNoCursorPosition(s8);
static void Swap_UpdateMenuCursorPosition(s8);
static void Swap_ErasePopupMenu(u8);
static void Swap_Task_ScreenInfoTransitionIn(u8);
static void Swap_Task_HandleChooseMons(u8);
static void Swap_Task_ScreenInfoTransitionOut(u8);
static void Swap_PrintOnInfoWindow(const u8 *);
static void Swap_ShowMenuOptions(void);
static void Swap_PrintMenuOptions(void);
static void Swap_PrintYesNoOptions(void);
static void Swap_PrintMonSpecies(void);
static void Swap_PrintMonSpeciesAtFade(void);
static void Swap_PrintMonSpeciesForTransition(void);
static void Swap_PrintMonCategory(void);
static void Swap_InitAllSprites(void);
static void Swap_PrintPkmnSwap(void);
static void Swap_EraseSpeciesAtFadeWindow(void);
static void Swap_EraseActionFadeWindow(void);
static void Swap_ShowSummaryMonSprite(void);
static void Swap_UpdateActionCursorPosition(s8);
static void Swap_UpdateBallCursorPosition(s8);
static void Swap_RunMenuOptionFunc(u8);
static void Swap_OptionSwap(u8);
static void Swap_OptionSummary(u8);
static void Swap_OptionRechoose(u8);
static void Swap_RunActionFunc(u8);
static void Swap_TaskCantHaveSameMons(u8);
static void Swap_CreateMonSprite(void);
static void Swap_PrintActionStrings(void);
static void Swap_PrintActionStrings2(void);
static void Swap_PrintOneActionString(u8);
static void Swap_InitActions(u8);
static void Swap_HighlightActionButton(u8);
static bool8 Swap_AlreadyHasSameSpecies(u8);
static void Swap_ActionMon(u8);
static void Swap_ActionCancel(u8);
static void Swap_ActionPkmnForSwap(u8);
static EWRAM_DATA u8 *sSelectMenuTilesetBuffer = NULL;
static EWRAM_DATA u8 *sSelectMonPicBgTilesetBuffer = NULL;
static EWRAM_DATA u8 *sSelectMenuTilemapBuffer = NULL;
static EWRAM_DATA u8 *sSelectMonPicBgTilemapBuffer = NULL;
static EWRAM_DATA struct Pokemon *sFactorySelectMons = NULL;
static EWRAM_DATA u8 *sSwapMenuTilesetBuffer = NULL;
static EWRAM_DATA u8 *sSwapMonPicBgTilesetBuffer = NULL;
static EWRAM_DATA u8 *sSwapMenuTilemapBuffer = NULL;
static EWRAM_DATA u8 *sSwapMonPicBgTilemapBuffer = NULL;
static struct FactorySelectScreen *sFactorySelectScreen;
static void (*sSwap_CurrentOptionFunc)(u8 taskId);
static struct FactorySwapScreen *sFactorySwapScreen;
COMMON_DATA u8 (*gFactorySelect_CurrentOptionFunc)(void) = NULL;
static const u16 sPokeballGray_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/pokeball_gray.gbapal");
static const u16 sPokeballSelected_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/pokeball_selected.gbapal");
static const u16 sInterface_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/interface.gbapal"); // Arrow, menu/action highlights, action box, etc
static const u8 sPokeball_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/pokeball.4bpp"); // Unused, gPokeballSelection_Gfx used instead
static const u8 sArrow_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/arrow.4bpp");
static const u8 sMenuHighlightLeft_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/menu_highlight_left.4bpp");
static const u8 sMenuHighlightRight_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/menu_highlight_right.4bpp");
static const u8 sActionBoxLeft_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_box_left.4bpp");
static const u8 sActionBoxRight_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_box_right.4bpp");
static const u8 sActionHighlightLeft_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_highlight_left.4bpp");
static const u8 sActionHighlightMiddle_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_highlight_middle.4bpp");
static const u8 sActionHighlightRight_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_highlight_right.4bpp");
static const u8 sMonPicBgAnim_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg_anim.4bpp");
static const u8 sMonPicBg_Tilemap[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg.bin");
static const u16 sMonPicBg_Gfx[] = INCBIN_U16("graphics/battle_frontier/factory_screen/mon_pic_bg.4bpp");
static const u16 sMonPicBg_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/mon_pic_bg.gbapal");
static const struct SpriteSheet sSelect_SpriteSheets[] =
{
{sArrow_Gfx, sizeof(sArrow_Gfx), GFXTAG_ARROW},
{sMenuHighlightLeft_Gfx, sizeof(sMenuHighlightLeft_Gfx), GFXTAG_MENU_HIGHLIGHT_LEFT},
{sMenuHighlightRight_Gfx, sizeof(sMenuHighlightRight_Gfx), GFXTAG_MENU_HIGHLIGHT_RIGHT},
{sMonPicBgAnim_Gfx, sizeof(sMonPicBgAnim_Gfx), GFXTAG_MON_PIC_BG_ANIM},
{},
};
static const struct CompressedSpriteSheet sSelect_BallGfx[] =
{
{gPokeballSelection_Gfx, 0x800, GFXTAG_BALL},
{},
};
static const struct SpritePalette sSelect_SpritePalettes[] =
{
{sPokeballGray_Pal, PALTAG_BALL_GRAY},
{sPokeballSelected_Pal, PALTAG_BALL_SELECTED},
{sInterface_Pal, PALTAG_INTERFACE},
{sMonPicBg_Pal, PALTAG_MON_PIC_BG},
{},
};
u8 static (* const sSelect_MenuOptionFuncs[])(void) =
{
Select_OptionSummary,
Select_OptionRentDeselect,
Select_OptionOthers
};
static const struct BgTemplate sSelect_BgTemplates[] =
{
{
.bg = 0,
.charBaseIndex = 0,
.mapBaseIndex = 24,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 1,
.charBaseIndex = 1,
.mapBaseIndex = 25,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
},
{
.bg = 3,
.charBaseIndex = 2,
.mapBaseIndex = 27,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0
},
};
enum {
SELECT_WIN_TITLE,
SELECT_WIN_SPECIES,
SELECT_WIN_INFO,
SELECT_WIN_OPTIONS,
SELECT_WIN_YES_NO,
SELECT_WIN_MON_CATEGORY,
};
static const struct WindowTemplate sSelect_WindowTemplates[] =
{
[SELECT_WIN_TITLE] = {
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 2,
.width = 12,
.height = 2,
.paletteNum = PALNUM_TEXT,
.baseBlock = 0x0001,
},
[SELECT_WIN_SPECIES] = {
.bg = 0,
.tilemapLeft = 19,
.tilemapTop = 2,
.width = 11,
.height = 2,
.paletteNum = PALNUM_FADE_TEXT,
.baseBlock = 0x0019,
},
[SELECT_WIN_INFO] = {
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 15,
.width = 20,
.height = 3,
.paletteNum = PALNUM_TEXT,
.baseBlock = 0x002f,
},
[SELECT_WIN_OPTIONS] = {
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 14,
.width = 8,
.height = 6,
.paletteNum = PALNUM_TEXT,
.baseBlock = 0x006b,
},
[SELECT_WIN_YES_NO] = {
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 14,
.width = 8,
.height = 4,
.paletteNum = PALNUM_TEXT,
.baseBlock = 0x009b,
},
[SELECT_WIN_MON_CATEGORY] = {
.bg = 0,
.tilemapLeft = 15,
.tilemapTop = 0,
.width = 15,
.height = 2,
.paletteNum = PALNUM_TEXT,
.baseBlock = 0x00bb,
},
DUMMY_WIN_TEMPLATE,
};
static const u16 sSelectText_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/text.gbapal");
static const u8 sMenuOptionTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_TRANSPARENT};
static const u8 sSpeciesNameTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_RED, TEXT_COLOR_TRANSPARENT};
static const struct OamData sOam_Select_Pokeball =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
.mosaic = FALSE,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(32x32),
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(32x32),
.tileNum = 0,
.priority = 3,
.paletteNum = 0,
.affineParam = 0,
};
static const struct OamData sOam_Select_Arrow =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
.mosaic = FALSE,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(16x16),
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(16x16),
.tileNum = 0,
.priority = 3,
.paletteNum = 0,
.affineParam = 0,
};
static const struct OamData sOam_Select_MenuHighlight =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
.mosaic = FALSE,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(32x16),
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(32x16),
.tileNum = 0,
.priority = 2,
.paletteNum = 0,
.affineParam = 0,
};
static const struct OamData sOam_Select_MonPicBgAnim =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_DOUBLE,
.objMode = ST_OAM_OBJ_BLEND,
.mosaic = FALSE,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(64x64),
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(64x64),
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 1,
};
static const union AnimCmd sAnim_Select_Interface[] =
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_END,
};
static const union AnimCmd sAnim_Select_MonPicBgAnim[] =
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_END,
};
static const union AnimCmd sAnim_Select_Pokeball_Still[] =
{
ANIMCMD_FRAME(0, 30),
ANIMCMD_END,
};
static const union AnimCmd sAnim_Select_Pokeball_Moving[] =
{
ANIMCMD_FRAME(16, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(32, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(16, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(32, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(0, 32),
ANIMCMD_FRAME(16, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_FRAME(32, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_FRAME(16, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_FRAME(32, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_END,
};
static const union AnimCmd * const sAnims_Select_Interface[] =
{
sAnim_Select_Interface,
};
static const union AnimCmd * const sAnims_Select_MonPicBgAnim[] =
{
sAnim_Select_MonPicBgAnim,
};
static const union AnimCmd * const sAnims_Select_Pokeball[] =
{
sAnim_Select_Pokeball_Still,
sAnim_Select_Pokeball_Moving,
};
static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Opening[] =
{
AFFINEANIMCMD_FRAME(5, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(16, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(32, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(64, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(128, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(256, 5, 0, 0),
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Closing[] =
{
AFFINEANIMCMD_FRAME(128, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(64, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(32, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(16, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(5, 5, 0, 0),
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Open[] =
{
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd * const sAffineAnims_Select_MonPicBgAnim[] =
{
sAffineAnim_Select_MonPicBg_Opening,
sAffineAnim_Select_MonPicBg_Closing,
sAffineAnim_Select_MonPicBg_Open,
};
static const struct SpriteTemplate sSpriteTemplate_Select_Pokeball =
{
.tileTag = GFXTAG_BALL,
.paletteTag = PALTAG_BALL_GRAY,
.oam = &sOam_Select_Pokeball,
.anims = sAnims_Select_Pokeball,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_Pokeball
};
static const struct SpriteTemplate sSpriteTemplate_Select_Arrow =
{
.tileTag = GFXTAG_ARROW,
.paletteTag = PALTAG_INTERFACE,
.oam = &sOam_Select_Arrow,
.anims = sAnims_Select_Interface,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct SpriteTemplate sSpriteTemplate_Select_MenuHighlightLeft =
{
.tileTag = GFXTAG_MENU_HIGHLIGHT_LEFT,
.paletteTag = PALTAG_INTERFACE,
.oam = &sOam_Select_MenuHighlight,
.anims = sAnims_Select_Interface,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct SpriteTemplate sSpriteTemplate_Select_MenuHighlightRight =
{
.tileTag = GFXTAG_MENU_HIGHLIGHT_RIGHT,
.paletteTag = PALTAG_INTERFACE,
.oam = &sOam_Select_MenuHighlight,
.anims = sAnims_Select_Interface,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct SpriteTemplate sSpriteTemplate_Select_MonPicBgAnim =
{
.tileTag = GFXTAG_MON_PIC_BG_ANIM,
.paletteTag = PALTAG_MON_PIC_BG,
.oam = &sOam_Select_MonPicBgAnim,
.anims = sAnims_Select_MonPicBgAnim,
.images = NULL,
.affineAnims = sAffineAnims_Select_MonPicBgAnim,
.callback = SpriteCallbackDummy
};
static const struct SpriteSheet sSwap_SpriteSheets[] =
{
{sArrow_Gfx, sizeof(sArrow_Gfx), GFXTAG_ARROW},
{sMenuHighlightLeft_Gfx, sizeof(sMenuHighlightLeft_Gfx), GFXTAG_MENU_HIGHLIGHT_LEFT},
{sMenuHighlightRight_Gfx, sizeof(sMenuHighlightRight_Gfx), GFXTAG_MENU_HIGHLIGHT_RIGHT},
{sActionBoxLeft_Gfx, sizeof(sActionBoxLeft_Gfx), GFXTAG_ACTION_BOX_LEFT},
{sActionBoxRight_Gfx, sizeof(sActionBoxRight_Gfx), GFXTAG_ACTION_BOX_RIGHT},
#ifdef BUGFIX
{sActionHighlightLeft_Gfx, sizeof(sActionHighlightLeft_Gfx), GFXTAG_ACTION_HIGHLIGHT_LEFT},
#else
{sActionHighlightLeft_Gfx, 8 * TILE_SIZE_4BPP, /* Incorrect size */ GFXTAG_ACTION_HIGHLIGHT_LEFT},
#endif
{sActionHighlightMiddle_Gfx, sizeof(sActionHighlightMiddle_Gfx), GFXTAG_ACTION_HIGHLIGHT_MIDDLE},
{sActionHighlightRight_Gfx, sizeof(sActionHighlightRight_Gfx), GFXTAG_ACTION_HIGHLIGHT_RIGHT},
{sMonPicBgAnim_Gfx, sizeof(sMonPicBgAnim_Gfx), GFXTAG_MON_PIC_BG_ANIM},
{},
};
static const struct CompressedSpriteSheet sSwap_BallGfx[] =
{
{gPokeballSelection_Gfx, 0x800, GFXTAG_BALL},
{},
};
static const struct SpritePalette sSwap_SpritePalettes[] =
{
{sPokeballGray_Pal, PALTAG_BALL_GRAY},
{sPokeballSelected_Pal, PALTAG_BALL_SELECTED},
{sInterface_Pal, PALTAG_INTERFACE},
{sMonPicBg_Pal, PALTAG_MON_PIC_BG},
{},
};
static const struct OamData sOam_Swap_Pokeball =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
.mosaic = FALSE,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(32x32),
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(32x32),
.tileNum = 0,
.priority = 3,
.paletteNum = 0,
.affineParam = 0,
};
static const struct OamData sOam_Swap_Arrow =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
.mosaic = FALSE,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(16x16),
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(16x16),
.tileNum = 0,
.priority = 3,
.paletteNum = 0,
.affineParam = 0,
};
static const struct OamData sOam_Swap_MenuHighlight =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
.mosaic = FALSE,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(32x16),
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(32x16),
.tileNum = 0,
.priority = 2,
.paletteNum = 0,
.affineParam = 0,
};
static const struct OamData sOam_Swap_MonPicBgAnim =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_DOUBLE,
.objMode = ST_OAM_OBJ_BLEND,
.mosaic = FALSE,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(64x64),
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(64x64),
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 1,
};
static const union AnimCmd sAnim_Swap_Interface[] =
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_END,
};
static const union AnimCmd sAnim_Swap_MonPicBgAnim[] =
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_END,
};
static const union AnimCmd sAnim_Swap_Pokeball_Still[] =
{
ANIMCMD_FRAME(0, 30),
ANIMCMD_END,
};
static const union AnimCmd sAnim_Swap_Pokeball_Moving[] =
{
ANIMCMD_FRAME(16, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(32, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(16, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(32, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(0, 32),
ANIMCMD_FRAME(16, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_FRAME(32, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_FRAME(16, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_FRAME(32, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_END,
};
static const union AnimCmd * const sAnims_Swap_Interface[] =
{
sAnim_Swap_Interface,
};
static const union AnimCmd * const sAnims_Swap_MonPicBgAnim[] =
{
sAnim_Swap_MonPicBgAnim,
};
static const union AnimCmd * const sAnims_Swap_Pokeball[] =
{
sAnim_Swap_Pokeball_Still,
sAnim_Swap_Pokeball_Moving,
};
static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Opening[] =
{
AFFINEANIMCMD_FRAME(5, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(16, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(32, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(64, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(128, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(256, 5, 0, 0),
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Closing[] =
{
AFFINEANIMCMD_FRAME(128, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(64, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(32, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(16, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(5, 5, 0, 0),
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Open[] =
{
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd * const sAffineAnims_Swap_MonPicBgAnim[] =
{
sAffineAnim_Swap_MonPicBg_Opening,
sAffineAnim_Swap_MonPicBg_Closing,
sAffineAnim_Swap_MonPicBg_Open,
};
static const struct SpriteTemplate sSpriteTemplate_Swap_Pokeball =
{
.tileTag = GFXTAG_BALL,
.paletteTag = PALTAG_BALL_GRAY,
.oam = &sOam_Swap_Pokeball,
.anims = sAnims_Swap_Pokeball,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_Pokeball
};
static const struct SpriteTemplate sSpriteTemplate_Swap_Arrow =
{
.tileTag = GFXTAG_ARROW,
.paletteTag = PALTAG_INTERFACE,
.oam = &sOam_Swap_Arrow,
.anims = sAnims_Swap_Interface,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct SpriteTemplate sSpriteTemplate_Swap_MenuHighlightLeft =
{
.tileTag = GFXTAG_MENU_HIGHLIGHT_LEFT,
.paletteTag = PALTAG_INTERFACE,
.oam = &sOam_Swap_MenuHighlight,
.anims = sAnims_Swap_Interface,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct SpriteTemplate sSpriteTemplate_Swap_MenuHighlightRight =
{
.tileTag = GFXTAG_MENU_HIGHLIGHT_RIGHT,
.paletteTag = PALTAG_INTERFACE,
.oam = &sOam_Swap_MenuHighlight,
.anims = sAnims_Swap_Interface,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct SpriteTemplate sSpriteTemplate_Swap_MonPicBgAnim =
{
.tileTag = GFXTAG_MON_PIC_BG_ANIM,
.paletteTag = PALTAG_MON_PIC_BG,
.oam = &sOam_Swap_MonPicBgAnim,
.anims = sAnims_Swap_MonPicBgAnim,
.images = NULL,
.affineAnims = sAffineAnims_Swap_MonPicBgAnim,
.callback = SpriteCallbackDummy
};
void static (* const sSwap_MenuOptionFuncs[])(u8 taskId) =
{
Swap_OptionSummary,
Swap_OptionSwap,
Swap_OptionRechoose,
};
static const struct BgTemplate sSwap_BgTemplates[4] =
{
{
.bg = 0,
.charBaseIndex = 0,
.mapBaseIndex = 24,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0
},
{
.bg = 1,
.charBaseIndex = 1,
.mapBaseIndex = 25,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
},
{
.bg = 2,
.charBaseIndex = 2,
.mapBaseIndex = 26,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 3,
.charBaseIndex = 2,
.mapBaseIndex = 27,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0
},
};
enum {
SWAP_WIN_TITLE,
SWAP_WIN_SPECIES,
SWAP_WIN_INFO,
SWAP_WIN_OPTIONS,
SWAP_WIN_YES_NO,
SWAP_WIN_ACTION_FADE, // Used for action text fading out during screen transition
SWAP_WIN_UNUSED,
SWAP_WIN_SPECIES_AT_FADE, // Used to print species name stopped at current fade level
SWAP_WIN_MON_CATEGORY,
};
static const struct WindowTemplate sSwap_WindowTemplates[] =
{
[SWAP_WIN_TITLE] = {
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 2,
.width = 12,
.height = 2,
.paletteNum = PALNUM_TEXT,
.baseBlock = 0x0001,
},
[SWAP_WIN_SPECIES] = {
.bg = 2,
.tilemapLeft = 19,
.tilemapTop = 2,
.width = 11,
.height = 2,
.paletteNum = PALNUM_FADE_TEXT,
.baseBlock = 0x0019,
},
[SWAP_WIN_INFO] = {
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 15,
.width = 20,
.height = 3,
.paletteNum = PALNUM_TEXT,
.baseBlock = 0x002f,
},
[SWAP_WIN_OPTIONS] = {
.bg = 0,
.tilemapLeft = 21,
.tilemapTop = 14,
.width = 9,
.height = 6,
.paletteNum = PALNUM_TEXT,
.baseBlock = 0x006b,
},
[SWAP_WIN_YES_NO] = {
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 14,
.width = 8,
.height = 4,
.paletteNum = PALNUM_TEXT,
.baseBlock = 0x00a1,
},
[SWAP_WIN_ACTION_FADE] = {
.bg = 2,
.tilemapLeft = 21,
.tilemapTop = 15,
.width = 9,
.height = 5,