summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDiegoisawesome <Diegoisawesome@users.noreply.github.com>2018-08-29 14:13:39 -0500
committerGitHub <noreply@github.com>2018-08-29 14:13:39 -0500
commit8e5c72766c2efd2d3d4e490232fcd5f6c265fe06 (patch)
treeac0ff8a6501ac194c9123a2c4273630c3d8b33c5 /src
parentaca96b07f063f2d4d6543f5dd6f415a0a4c427db (diff)
parent3dea8fa2658cb1055fb835983e8a738cf543e232 (diff)
Merge pull request #300 from DizzyEggg/decompile_battle_frontier_1
Decompile battle_dome
Diffstat (limited to 'src')
-rw-r--r--src/battle_controller_opponent.c18
-rw-r--r--src/battle_controller_player.c2
-rw-r--r--src/battle_dome.c6488
-rw-r--r--src/battle_frontier_1.c118
-rw-r--r--src/battle_main.c4
-rw-r--r--src/battle_message.c2
-rw-r--r--src/battle_pyramid_bag.c (renamed from src/battle_pyramid.c)0
-rw-r--r--src/battle_script_commands.c4
-rw-r--r--src/battle_setup.c5
-rw-r--r--src/battle_tent.c276
-rw-r--r--src/battle_tower.c85
-rw-r--r--src/bg.c2
-rw-r--r--src/credits.c9
-rw-r--r--src/egg_hatch.c2
-rw-r--r--src/evolution_scene.c2
-rw-r--r--src/field_effect.c12
-rwxr-xr-xsrc/field_message_box.c10
-rw-r--r--src/field_specials.c57
-rw-r--r--src/fieldmap.c2
-rw-r--r--src/hall_of_fame.c28
-rw-r--r--src/item.c16
-rw-r--r--src/link.c2
-rw-r--r--src/main_menu.c16
-rw-r--r--src/match_call.c2
-rw-r--r--src/menu.c2
-rw-r--r--src/new_game.c4
-rw-r--r--src/overworld.c4
-rw-r--r--src/pokedex.c128
-rw-r--r--src/pokemon.c16
-rw-r--r--src/record_mixing.c4
-rw-r--r--src/recorded_battle.c6
-rw-r--r--src/rom_8011DC0.c5
-rw-r--r--src/starter_choose.c15
-rw-r--r--src/trainer_pokemon_sprites.c (renamed from src/battle_dome_cards.c)216
-rw-r--r--src/unk_text_util_2.c1
35 files changed, 7241 insertions, 322 deletions
diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c
index 1eaa9da18..6148587f8 100644
--- a/src/battle_controller_opponent.c
+++ b/src/battle_controller_opponent.c
@@ -1606,22 +1606,22 @@ static void OpponentHandleChoosePokemon(void)
{
s32 chosenMonId;
- if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) == 6)
+ if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) == PARTY_SIZE)
{
chosenMonId = GetMostSuitableMonToSwitchInto();
- if (chosenMonId == 6)
+ if (chosenMonId == PARTY_SIZE)
{
- s32 bank1, bank2, firstId, lastId;
+ s32 battler1, battler2, firstId, lastId;
if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
{
- bank2 = bank1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
+ battler2 = battler1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
}
else
{
- bank1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
- bank2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
+ battler1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
+ battler2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
}
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
@@ -1639,8 +1639,8 @@ static void OpponentHandleChoosePokemon(void)
for (chosenMonId = firstId; chosenMonId < lastId; chosenMonId++)
{
if (GetMonData(&gEnemyParty[chosenMonId], MON_DATA_HP) != 0
- && chosenMonId != gBattlerPartyIndexes[bank1]
- && chosenMonId != gBattlerPartyIndexes[bank2])
+ && chosenMonId != gBattlerPartyIndexes[battler1]
+ && chosenMonId != gBattlerPartyIndexes[battler2])
{
break;
}
@@ -1650,7 +1650,7 @@ static void OpponentHandleChoosePokemon(void)
else
{
chosenMonId = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler);
- *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6;
+ *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
}
diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c
index 6ab19e368..ffe8936a0 100644
--- a/src/battle_controller_player.c
+++ b/src/battle_controller_player.c
@@ -31,13 +31,13 @@
#include "item_use.h"
#include "recorded_battle.h"
#include "party_menu.h"
+#include "battle_dome.h"
extern u8 gUnknown_0203CEE8;
extern u8 gUnknown_0203CEE9;
extern u8 gUnknown_0203CF00[];
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;
-extern s32 gUnknown_0203CD70;
extern struct UnusedControllerStruct gUnknown_02022D0C;
extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern struct SpriteTemplate gMultiuseSpriteTemplate;
diff --git a/src/battle_dome.c b/src/battle_dome.c
new file mode 100644
index 000000000..0183811cd
--- /dev/null
+++ b/src/battle_dome.c
@@ -0,0 +1,6488 @@
+#include "global.h"
+#include "battle_dome.h"
+#include "battle.h"
+#include "battle_setup.h"
+#include "battle_tower.h"
+#include "battle_message.h"
+#include "event_data.h"
+#include "overworld.h"
+#include "util.h"
+#include "malloc.h"
+#include "string_util.h"
+#include "random.h"
+#include "task.h"
+#include "main.h"
+#include "gpu_regs.h"
+#include "text.h"
+#include "bg.h"
+#include "window.h"
+#include "palette.h"
+#include "decompress.h"
+#include "menu.h"
+#include "sound.h"
+#include "pokemon_icon.h"
+#include "data2.h"
+#include "international_string_util.h"
+#include "trainer_pokemon_sprites.h"
+#include "scanline_effect.h"
+#include "constants/species.h"
+#include "constants/moves.h"
+#include "constants/trainers.h"
+#include "constants/abilities.h"
+#include "constants/songs.h"
+#include "constants/battle_frontier.h"
+#include "constants/rgb.h"
+
+#define DOME_ROUND1 0
+#define DOME_ROUND2 1
+#define DOME_QUARTERFINAL 1 // Different name for the same round.
+#define DOME_SEMIFINAL 2
+#define DOME_FINAL 3
+#define DOME_ROUNDS_COUNT 4
+
+struct BattleDomeStruct
+{
+ u8 arr[DOME_TOURNAMENT_TRAINERS_COUNT];
+ u8 unk_10;
+ u8 unk_11[3];
+};
+
+struct UnkStruct_860DD10
+{
+ u8 x;
+ u8 y;
+ u16 src;
+};
+
+extern void sub_81B8558(void);
+extern u32 sub_81A39C4(void);
+extern u16 sub_8162548(u8, u8);
+extern u16 RandomizeFacilityTrainerMonId(u16);
+extern u8 GetFacilityEnemyMonLevel(void);
+extern u16 sub_81A5060(u8 monId, u8 moveSlotId);
+extern u8 sub_81A50F0(u8, u8);
+extern u8 sub_81A50B0(u8);
+extern void sub_8162614(u16, u8);
+extern void sub_81A4C30(void);
+extern bool8 sub_81A3610(void);
+extern u16 sub_81A4FF0(u8);
+extern u8 GetFrontierTrainerFrontSpriteId(u16);
+extern u8 GetFrontierOpponentClass(u16);
+extern void sub_80F94E8(void);
+
+extern u8 gUnknown_0203CEF8[];
+extern u16 gBattle_BG0_X;
+extern u16 gBattle_BG0_Y;
+extern u16 gBattle_BG1_X;
+extern u16 gBattle_BG1_Y;
+extern u16 gBattle_BG2_X;
+extern u16 gBattle_BG2_Y;
+extern u16 gBattle_BG3_X;
+extern u16 gBattle_BG3_Y;
+
+extern const u16 gBattleFrontierHeldItems[];
+extern const struct FacilityMon gBattleFrontierMons[];
+extern const struct BattleFrontierTrainer gBattleFrontierTrainers[];
+extern const struct SpriteTemplate gUnknown_0860CFA8;
+
+// gfx
+extern const u8 gUnknown_08D83D50[];
+extern const u8 gUnknown_08D84970[];
+extern const u8 gUnknown_08D84F00[];
+extern const u8 gUnknown_08D85444[];
+extern const u8 gUnknown_08D85358[];
+extern const u8 gUnknown_08D85600[];
+extern const u8 gUnknown_08D854C8[];
+extern const u8 gUnknown_08D82F10[];
+extern const u8 gUnknown_08D834FC[];
+extern const u8 gUnknown_08D83B2C[];
+extern const u8 gUnknown_08D83C3C[];
+extern const u8 gUnknown_08D83900[];
+extern const u8 gBattleFrontierGfx_DomeOptions[];
+
+// text
+extern const u8 gTrainerClassNames[][0xD];
+
+extern const u8 gBattleDomeOpponentPotential1[];
+extern const u8 gBattleDomeOpponentPotential2[];
+extern const u8 gBattleDomeOpponentPotential3[];
+extern const u8 gBattleDomeOpponentPotential4[];
+extern const u8 gBattleDomeOpponentPotential5[];
+extern const u8 gBattleDomeOpponentPotential6[];
+extern const u8 gBattleDomeOpponentPotential7[];
+extern const u8 gBattleDomeOpponentPotential8[];
+extern const u8 gBattleDomeOpponentPotential9[];
+extern const u8 gBattleDomeOpponentPotential10[];
+extern const u8 gBattleDomeOpponentPotential11[];
+extern const u8 gBattleDomeOpponentPotential12[];
+extern const u8 gBattleDomeOpponentPotential13[];
+extern const u8 gBattleDomeOpponentPotential14[];
+extern const u8 gBattleDomeOpponentPotential15[];
+extern const u8 gBattleDomeOpponentPotential16[];
+extern const u8 gBattleDomeOpponentPotential17[];
+extern const u8 gBattleDomeOpponentStyle1[];
+extern const u8 gBattleDomeOpponentStyle2[];
+extern const u8 gBattleDomeOpponentStyle3[];
+extern const u8 gBattleDomeOpponentStyle4[];
+extern const u8 gBattleDomeOpponentStyle5[];
+extern const u8 gBattleDomeOpponentStyle6[];
+extern const u8 gBattleDomeOpponentStyle7[];
+extern const u8 gBattleDomeOpponentStyle8[];
+extern const u8 gBattleDomeOpponentStyle9[];
+extern const u8 gBattleDomeOpponentStyle10[];
+extern const u8 gBattleDomeOpponentStyle11[];
+extern const u8 gBattleDomeOpponentStyle12[];
+extern const u8 gBattleDomeOpponentStyle13[];
+extern const u8 gBattleDomeOpponentStyle14[];
+extern const u8 gBattleDomeOpponentStyle15[];
+extern const u8 gBattleDomeOpponentStyle16[];
+extern const u8 gBattleDomeOpponentStyle17[];
+extern const u8 gBattleDomeOpponentStyle18[];
+extern const u8 gBattleDomeOpponentStyle19[];
+extern const u8 gBattleDomeOpponentStyle20[];
+extern const u8 gBattleDomeOpponentStyle21[];
+extern const u8 gBattleDomeOpponentStyle22[];
+extern const u8 gBattleDomeOpponentStyle23[];
+extern const u8 gBattleDomeOpponentStyle24[];
+extern const u8 gBattleDomeOpponentStyle25[];
+extern const u8 gBattleDomeOpponentStyle26[];
+extern const u8 gBattleDomeOpponentStyle27[];
+extern const u8 gBattleDomeOpponentStyle28[];
+extern const u8 gBattleDomeOpponentStyleUnused1[];
+extern const u8 gBattleDomeOpponentStyleUnused2[];
+extern const u8 gBattleDomeOpponentStyleUnused3[];
+extern const u8 gBattleDomeOpponentStyleUnused4[];
+extern const u8 gBattleDomeOpponentStats1[];
+extern const u8 gBattleDomeOpponentStats2[];
+extern const u8 gBattleDomeOpponentStats3[];
+extern const u8 gBattleDomeOpponentStats4[];
+extern const u8 gBattleDomeOpponentStats5[];
+extern const u8 gBattleDomeOpponentStats6[];
+extern const u8 gBattleDomeOpponentStats7[];
+extern const u8 gBattleDomeOpponentStats8[];
+extern const u8 gBattleDomeOpponentStats9[];
+extern const u8 gBattleDomeOpponentStats10[];
+extern const u8 gBattleDomeOpponentStats11[];
+extern const u8 gBattleDomeOpponentStats12[];
+extern const u8 gBattleDomeOpponentStats13[];
+extern const u8 gBattleDomeOpponentStats14[];
+extern const u8 gBattleDomeOpponentStats15[];
+extern const u8 gBattleDomeOpponentStats16[];
+extern const u8 gBattleDomeOpponentStats17[];
+extern const u8 gBattleDomeOpponentStats18[];
+extern const u8 gBattleDomeOpponentStats19[];
+extern const u8 gBattleDomeOpponentStats20[];
+extern const u8 gBattleDomeOpponentStats21[];
+extern const u8 gBattleDomeOpponentStats22[];
+extern const u8 gBattleDomeOpponentStats23[];
+extern const u8 gBattleDomeOpponentStats24[];
+extern const u8 gBattleDomeOpponentStats25[];
+extern const u8 gBattleDomeOpponentStats26[];
+extern const u8 gBattleDomeOpponentStats27[];
+extern const u8 gBattleDomeOpponentStats28[];
+extern const u8 gBattleDomeOpponentStats29[];
+extern const u8 gBattleDomeOpponentStats30[];
+extern const u8 gBattleDomeOpponentStats31[];
+extern const u8 gBattleDomeOpponentStats32[];
+extern const u8 gBattleDomeOpponentStats33[];
+extern const u8 gBattleDomeOpponentStats34[];
+extern const u8 gBattleDomeOpponentStats35[];
+extern const u8 gBattleDomeOpponentStats36[];
+extern const u8 gBattleDomeOpponentStats37[];
+extern const u8 gBattleDomeOpponentStats38[];
+extern const u8 gBattleDomeOpponentStats39[];
+extern const u8 gBattleDomeOpponentStats40[];
+extern const u8 gBattleDomeOpponentStats41[];
+extern const u8 gBattleDomeOpponentStats42[];
+extern const u8 gBattleDomeOpponentStats43[];
+extern const u8 gBattleDomeMatchNumber1[];
+extern const u8 gBattleDomeMatchNumber2[];
+extern const u8 gBattleDomeMatchNumber3[];
+extern const u8 gBattleDomeMatchNumber4[];
+extern const u8 gBattleDomeMatchNumber5[];
+extern const u8 gBattleDomeMatchNumber6[];
+extern const u8 gBattleDomeMatchNumber7[];
+extern const u8 gBattleDomeMatchNumber8[];
+extern const u8 gBattleDomeMatchNumber9[];
+extern const u8 gBattleDomeMatchNumber10[];
+extern const u8 gBattleDomeMatchNumber11[];
+extern const u8 gBattleDomeMatchNumber12[];
+extern const u8 gBattleDomeMatchNumber13[];
+extern const u8 gBattleDomeMatchNumber14[];
+extern const u8 gBattleDomeMatchNumber15[];
+extern const u8 gBattleDomeWinStrings1[];
+extern const u8 gBattleDomeWinStrings2[];
+extern const u8 gBattleDomeWinStrings3[];
+extern const u8 gBattleDomeWinStrings4[];
+extern const u8 gBattleDomeWinStrings5[];
+extern const u8 gBattleDomeWinStrings6[];
+extern const u8 gBattleDomeWinStrings7[];
+
+// This file's functions.
+static u8 GetDomeTrainerMonIvs(u16 trainerId);
+static void SwapDomeTrainers(s32 id1, s32 id2, u16 *statsArray);
+static void CalcDomeMonStats(u16 species, s32 level, s32 ivs, u8 evBits, u8 nature, s32 *stats);
+static void CreateDomeTrainerMons(u16 tournamentTrainerId);
+static s32 sub_818FCBC(u16 tournamentTrainerId, bool8 arg1);
+static s32 sub_818FDB8(u16 tournamentTrainerId, bool8 arg1);
+static s32 GetTypeEffectivenessPoints(s32 move, s32 species, s32 arg2);
+static s32 sub_818FEB4(s32 *arr, bool8 arg1);
+static void sub_8190400(u8 taskId);
+static void sub_8190CD4(u8 taskId);
+static u8 sub_819221C(u8 taskId);
+static void sub_8194D48(void);
+static s32 TrainerIdToTournamentId(u16 trainerId);
+static u16 TrainerIdOfPlayerOpponent(void);
+static void sub_8194220(u8 taskId);
+static void sub_8194950(u8 taskId);
+static void CB2_BattleDome(void);
+static void VblankCb0_BattleDome(void);
+static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo);
+static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId);
+static s32 sub_8192F08(u8, u8*);
+static u8 GetDomeBrainTrainerPicId(void);
+static u8 GetDomeBrainTrainerClass(void);
+static void CopyDomeBrainTrainerName(u8 *dst);
+static void CopyDomeTrainerName(u8 *dst, u16 trainerId);
+static void HblankCb_BattleDome(void);
+static void VblankCb1_BattleDome(void);
+static u8 sub_8193BDC(u8 taskId);
+static void DecideRoundWinners(u8 roundId);
+static u8 sub_81953E8(u8 tournamentId, u8);
+static void sub_81948EC(u8, u8);
+static void sub_8190B40(struct Sprite *sprite);
+static void sub_8190C6C(struct Sprite *sprite);
+static void sub_818E9CC(void);
+static void sub_818EA84(void);
+static void sub_818ED28(void);
+static void sub_818F9B0(void);
+static void sub_818F9E0(void);
+static void sub_818FA20(void);
+static void ShowDomeOpponentInfo(void);
+static void sub_81938A4(void);
+static void sub_81938E0(void);
+static void sub_8190298(void);
+static void sub_81902E4(void);
+static void sub_8193D40(void);
+static void sub_8193D7C(void);
+static void sub_81902F8(void);
+static void sub_819033C(void);
+static void sub_8194D68(void);
+static void sub_8194E44(void);
+static void sub_8194EB4(void);
+static void sub_8194EC0(void);
+static void sub_8194EF8(void);
+static void sub_8194F58(void);
+static void InitDomeTrainers(void);
+
+// EWRAM variables.
+EWRAM_DATA u32 gUnknown_0203CD70 = 0;
+static EWRAM_DATA u32 gUnknown_0203CD74 = 0;
+static EWRAM_DATA struct BattleDomeStruct *sBattleDomeStruct = {0};
+static EWRAM_DATA u8 *sTilemapBuffer = NULL;
+
+// Const rom data.
+static const u8 sMovePointsForDomeTrainers[MOVES_COUNT][DOME_TOURNAMENT_TRAINERS_COUNT] =
+{
+ [MOVE_NONE] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ [MOVE_POUND] = {0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0},
+ [MOVE_KARATE_CHOP] = {0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0},
+ [MOVE_DOUBLE_SLAP] = {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
+ [MOVE_COMET_PUNCH] = {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
+ [MOVE_MEGA_PUNCH] = {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
+ [MOVE_PAY_DAY] = {0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1},
+ [MOVE_FIRE_PUNCH] = {0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1},
+ [MOVE_ICE_PUNCH] = {0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1},
+ [MOVE_THUNDER_PUNCH] = {0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1},
+ [MOVE_SCRATCH] = {0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0},
+ [MOVE_VICE_GRIP] = {0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0},
+ [MOVE_GUILLOTINE] = {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0},
+ [MOVE_RAZOR_WIND] = {0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0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0,
+ 0, 0, 0, 0, 253, 0, 0, 0, 0, 0, 253, 254, 0, 0, 0, 0,
+ 0, 254, 0, 0, 0, 0, 0, 254, 0, 0, 0, 0, 0, 254, 0, 0,
+ 0, 0, 0, 254, 0, 0, 0, 0, 0,
+};
+
+static const u8 gUnknown_0860CBF1[][5][4]=
+{
+ {{0x07, 0x01, 0x08, 0x10}, {0x07, 0x01, 0x08, 0x10}, {0x07, 0x01, 0x08, 0x10}, {0x07, 0x01, 0x08, 0x10}, {0x07, 0x01, 0x08, 0x10}},
+ {{0x00, 0x02, 0x09, 0x10}, {0x00, 0x02, 0x09, 0x10}, {0x00, 0x02, 0x09, 0x10}, {0x00, 0x02, 0x09, 0x10}, {0x00, 0x02, 0x09, 0x10}},
+ {{0x01, 0x03, 0x0a, 0x11}, {0x01, 0x03, 0x0a, 0x11}, {0x01, 0x03, 0x0a, 0x11}, {0x01, 0x03, 0x0a, 0x11}, {0x01, 0x03, 0x0a, 0x11}},
+ {{0x02, 0x04, 0x0b, 0x11}, {0x02, 0x04, 0x0b, 0x11}, {0x02, 0x04, 0x0b, 0x11}, {0x02, 0x04, 0x0b, 0x11}, {0x02, 0x04, 0x0b, 0x11}},
+ {{0x03, 0x05, 0x0c, 0x12}, {0x03, 0x05, 0x0c, 0x12}, {0x03, 0x05, 0x0c, 0x12}, {0x03, 0x05, 0x0c, 0x12}, {0x03, 0x05, 0x0c, 0x12}},
+ {{0x04, 0x06, 0x0d, 0x12}, {0x04, 0x06, 0x0d, 0x12}, {0x04, 0x06, 0x0d, 0x12}, {0x04, 0x06, 0x0d, 0x12}, {0x04, 0x06, 0x0d, 0x12}},
+ {{0x05, 0x07, 0x0e, 0x13}, {0x05, 0x07, 0x0e, 0x13}, {0x05, 0x07, 0x0e, 0x13}, {0x05, 0x07, 0x0e, 0x13}, {0x05, 0x07, 0x0e, 0x13}},
+ {{0x06, 0x00, 0x0f, 0x13}, {0x06, 0x00, 0x0f, 0x13}, {0x06, 0x00, 0x0f, 0x13}, {0x06, 0x00, 0x0f, 0x13}, {0x06, 0x00, 0x0f, 0x13}},
+ {{0x1f, 0x09, 0x14, 0x1f}, {0x1f, 0x09, 0x14, 0x1f}, {0x1f, 0x09, 0x14, 0x1f}, {0x1f, 0x09, 0x14, 0x1f}, {0x1f, 0x09, 0x14, 0x1f}},
+ {{0x08, 0x0a, 0x14, 0x01}, {0x08, 0x0a, 0x14, 0x01}, {0x08, 0x0a, 0x14, 0x01}, {0x08, 0x0a, 0x14, 0x01}, {0x08, 0x0a, 0x14, 0x01}},
+ {{0x09, 0x0b, 0x15, 0x02}, {0x09, 0x0b, 0x15, 0x02}, {0x09, 0x0b, 0x15, 0x02}, {0x09, 0x0b, 0x15, 0x02}, {0x09, 0x0b, 0x15, 0x02}},
+ {{0x0a, 0x0c, 0x15, 0x03}, {0x0a, 0x0c, 0x15, 0x03}, {0x0a, 0x0c, 0x15, 0x03}, {0x0a, 0x0c, 0x15, 0x03}, {0x0a, 0x0c, 0x15, 0x03}},
+ {{0x0b, 0x0d, 0x16, 0x04}, {0x0b, 0x0d, 0x16, 0x04}, {0x0b, 0x0d, 0x16, 0x04}, {0x0b, 0x0d, 0x16, 0x04}, {0x0b, 0x0d, 0x16, 0x04}},
+ {{0x0c, 0x0e, 0x16, 0x05}, {0x0c, 0x0e, 0x16, 0x05}, {0x0c, 0x0e, 0x16, 0x05}, {0x0c, 0x0e, 0x16, 0x05}, {0x0c, 0x0e, 0x16, 0x05}},
+ {{0x0d, 0x0f, 0x17, 0x06}, {0x0d, 0x0f, 0x17, 0x06}, {0x0d, 0x0f, 0x17, 0x06}, {0x0d, 0x0f, 0x17, 0x06}, {0x0d, 0x0f, 0x17, 0x06}},
+ {{0x0e, 0x1f, 0x17, 0x07}, {0x0e, 0x1f, 0x17, 0x07}, {0x0e, 0x1f, 0x17, 0x07}, {0x0e, 0x1f, 0x17, 0x07}, {0x0e, 0x1f, 0x17, 0x07}},
+ {{0x13, 0x11, 0x00, 0x14}, {0x13, 0x11, 0x00, 0x18}, {0x13, 0x11, 0x00, 0x18}, {0x13, 0x11, 0x00, 0x18}, {0x13, 0x11, 0x00, 0x18}},
+ {{0x10, 0x12, 0x02, 0x15}, {0x10, 0x12, 0x02, 0x18}, {0x10, 0x12, 0x02, 0x18}, {0x10, 0x12, 0x02, 0x18}, {0x10, 0x12, 0x02, 0x18}},
+ {{0x11, 0x13, 0x04, 0x16}, {0x11, 0x13, 0x04, 0x19}, {0x11, 0x13, 0x04, 0x19}, {0x11, 0x13, 0x04, 0x19}, {0x11, 0x13, 0x04, 0x19}},
+ {{0x12, 0x10, 0x06, 0x17}, {0x12, 0x10, 0x06, 0x19}, {0x12, 0x10, 0x06, 0x19}, {0x12, 0x10, 0x06, 0x19}, {0x12, 0x10, 0x06, 0x19}},
+ {{0x17, 0x15, 0x10, 0x08}, {0x17, 0x15, 0x1a, 0x08}, {0x17, 0x15, 0x1a, 0x08}, {0x17, 0x15, 0x1a, 0x08}, {0x17, 0x15, 0x1a, 0x08}},
+ {{0x14, 0x16, 0x11, 0x0a}, {0x14, 0x16, 0x1a, 0x0a}, {0x14, 0x16, 0x1a, 0x0a}, {0x14, 0x16, 0x1a, 0x0a}, {0x14, 0x16, 0x1a, 0x0a}},
+ {{0x15, 0x17, 0x12, 0x0c}, {0x15, 0x17, 0x1b, 0x0c}, {0x15, 0x17, 0x1b, 0x0c}, {0x15, 0x17, 0x1b, 0x0c}, {0x15, 0x17, 0x1b, 0x0c}},
+ {{0x16, 0x14, 0x13, 0x0e}, {0x16, 0x14, 0x1b, 0x0e}, {0x16, 0x14, 0x1b, 0x0e}, {0x16, 0x14, 0x1b, 0x0e}, {0x16, 0x14, 0x1b, 0x0e}},
+ {{0xff, 0xff, 0xff, 0xff}, {0x19, 0x19, 0x10, 0x1a}, {0x19, 0x19, 0x10, 0x1c}, {0x19, 0x19, 0x10, 0x1c}, {0x19, 0x19, 0x10, 0x1c}},
+ {{0xff, 0xff, 0xff, 0xff}, {0x18, 0x18, 0x12, 0x1b}, {0x18, 0x18, 0x12, 0x1c}, {0x18, 0x18, 0x12, 0x1c}, {0x18, 0x18, 0x12, 0x1c}},
+ {{0xff, 0xff, 0xff, 0xff}, {0x1b, 0x1b, 0x18, 0x14}, {0x1b, 0x1b, 0x1d, 0x14}, {0x1b, 0x1b, 0x1d, 0x14}, {0x1b, 0x1b, 0x1d, 0x14}},
+ {{0xff, 0xff, 0xff, 0xff}, {0x1a, 0x1a, 0x19, 0x16}, {0x1a, 0x1a, 0x1d, 0x16}, {0x1a, 0x1a, 0x1d, 0x16}, {0x1a, 0x1a, 0x1d, 0x16}},
+ {{0xff, 0xff, 0xff, 0xff}, {0xff, 0xff, 0xff, 0xff}, {0xff, 0xff, 0x18, 0x1d}, {0xff, 0xff, 0x18, 0x1e}, {0xff, 0xff, 0x18, 0x1e}},
+ {{0xff, 0xff, 0xff, 0xff}, {0xff, 0xff, 0xff, 0xff}, {0xff, 0xff, 0x1c, 0x1a}, {0xff, 0xff, 0x1e, 0x1a}, {0xff, 0xff, 0x1e, 0x1a}},
+ {{0xff, 0xff, 0xff, 0xff}, {0xff, 0xff, 0xff, 0xff}, {0xff, 0xff, 0xff, 0xff}, {0xff, 0xff, 0x1c, 0x1d}, {0xff, 0xff, 0x1c, 0x1d}},
+ {{0x0f, 0x08, 0x08, 0x00}, {0x0f, 0x08, 0x08, 0x00}, {0x0f, 0x08, 0x08, 0x00}, {0x0f, 0x08, 0x08, 0x00}, {0x0f, 0x08, 0x08, 0x00}},
+};
+
+static const struct BgTemplate gUnknown_0860CE74[4] =
+{
+ {
+ .bg = 0,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 28,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 0,
+ .baseTile = 0
+ },
+ {
+ .bg = 1,
+ .charBaseIndex = 1,
+ .mapBaseIndex = 29,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 1,
+ .baseTile = 0
+ },
+ {
+ .bg = 2,
+ .charBaseIndex = 2,
+ .mapBaseIndex = 30,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 2,
+ .baseTile = 0
+ },
+ {
+ .bg = 3,
+ .charBaseIndex = 2,
+ .mapBaseIndex = 31,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 2,
+ .baseTile = 0
+ },
+};
+
+static const struct BgTemplate gUnknown_0860CE84[4] =
+{
+ {
+ .bg = 0,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 20,
+ .screenSize = 3,
+ .paletteMode = 0,
+ .priority = 0,
+ .baseTile = 0
+ },
+ {
+ .bg = 1,
+ .charBaseIndex = 1,
+ .mapBaseIndex = 24,
+ .screenSize = 3,
+ .paletteMode = 0,
+ .priority = 0,
+ .baseTile = 0
+ },
+ {
+ .bg = 2,
+ .charBaseIndex = 2,
+ .mapBaseIndex = 28,
+ .screenSize = 3,
+ .paletteMode = 0,
+ .priority = 1,
+ .baseTile = 0
+ },
+ {
+ .bg = 3,
+ .charBaseIndex = 2,
+ .mapBaseIndex = 7,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 1,
+ .baseTile = 0
+ },
+};
+
+static const struct WindowTemplate gUnknown_0860CE94[] =
+{
+ {
+ .priority = 0,
+ .tilemapLeft = 0,
+ .tilemapTop = 3,
+ .width = 8,
+ .height = 16,
+ .paletteNum = 15,
+ .baseBlock = 16,
+ },
+ {
+ .priority = 0,
+ .tilemapLeft = 22,
+ .tilemapTop = 3,
+ .width = 8,
+ .height = 16,
+ .paletteNum = 15,
+ .baseBlock = 144,
+ },
+ {
+ .priority = 0,
+ .tilemapLeft = 8,
+ .tilemapTop = 1,
+ .width = 14,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 272,
+ },
+ DUMMY_WIN_TEMPLATE,
+};
+
+static const struct WindowTemplate gUnknown_0860CEB4[] =
+{
+ {
+ .priority = 0,
+ .tilemapLeft = 2,
+ .tilemapTop = 2,
+ .width = 26,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 1,
+ },
+ {
+ .priority = 0,
+ .tilemapLeft = 16,
+ .tilemapTop = 5,
+ .width = 8,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 53,
+ },
+ {
+ .priority = 0,
+ .tilemapLeft = 19,
+ .tilemapTop = 7,
+ .width = 9,
+ .height = 3,
+ .paletteNum = 15,
+ .baseBlock = 69,
+ },
+ {
+ .priority = 0,
+ .tilemapLeft = 16,
+ .tilemapTop = 10,
+ .width = 8,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 96,
+ },
+ {
+ .priority = 0,
+ .tilemapLeft = 2,
+ .tilemapTop = 12,
+ .width = 26,
+ .height = 7,
+ .paletteNum = 15,
+ .baseBlock = 112,
+ },
+ {
+ .priority = 0,
+ .tilemapLeft = 5,
+ .tilemapTop = 2,
+ .width = 23,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 294,
+ },
+ {
+ .priority = 0,
+ .tilemapLeft = 2,
+ .tilemapTop = 5,
+ .width = 8,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 340,
+ },
+ {
+ .priority = 0,
+ .tilemapLeft = 20,
+ .tilemapTop = 5,
+ .width = 8,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 356,
+ },
+ {
+ .priority = 0,
+ .tilemapLeft = 2,
+ .tilemapTop = 16,
+ .width = 26,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 372,
+ },
+ {
+ .priority = 1,
+ .tilemapLeft = 2,
+ .tilemapTop = 2,
+ .width = 26,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 1,
+ },
+ {
+ .priority = 1,
+ .tilemapLeft = 16,
+ .tilemapTop = 5,
+ .width = 8,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 53,
+ },
+ {
+ .priority = 1,
+ .tilemapLeft = 19,
+ .tilemapTop = 7,
+ .width = 9,
+ .height = 3,
+ .paletteNum = 15,
+ .baseBlock = 69,
+ },
+ {
+ .priority = 1,
+ .tilemapLeft = 16,
+ .tilemapTop = 10,
+ .width = 8,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 96,
+ },
+ {
+ .priority = 1,
+ .tilemapLeft = 2,
+ .tilemapTop = 12,
+ .width = 26,
+ .height = 7,
+ .paletteNum = 15,
+ .baseBlock = 112,
+ },
+ {
+ .priority = 1,
+ .tilemapLeft = 5,
+ .tilemapTop = 2,
+ .width = 23,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 294,
+ },
+ {
+ .priority = 1,
+ .tilemapLeft = 2,
+ .tilemapTop = 5,
+ .width = 8,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 340,
+ },
+ {
+ .priority = 1,
+ .tilemapLeft = 20,
+ .tilemapTop = 5,
+ .width = 8,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 356,
+ },
+ {
+ .priority = 1,
+ .tilemapLeft = 2,
+ .tilemapTop = 16,
+ .width = 26,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 372,
+ },
+ // UB: No DUMMY_WIN_TEMPLATE at the array's end.
+};
+
+static const struct ScanlineEffectParams gUnknown_0860CF44 =
+{
+ .dmaDest = (void *)REG_ADDR_BG3CNT,
+ .dmaControl = 0xa2600001,
+ .initState = 1,
+};
+
+static const struct CompressedSpriteSheet gUnknown_0860CF50[] =
+{
+ {gBattleFrontierGfx_DomeOptions, 0x0600, 0x0000},
+ {},
+};
+
+static const struct CompressedSpritePalette gUnknown_0860CF60[] =
+{
+ {gUnknown_08D85444, 0x0000},
+ {},
+};
+
+static const struct OamData gUnknown_0860CF70 =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 0,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 1,
+ .tileNum = 0,
+ .priority = 0,
+ .paletteNum = 0,
+ .affineParam = 0,
+};
+
+static const struct OamData gUnknown_0860CF78 =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 1,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 2,
+ .tileNum = 0,
+ .priority = 0,
+ .paletteNum = 1,
+ .affineParam = 0,
+};
+
+static const struct OamData gUnknown_0860CF80 =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 1,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 0,
+ .tileNum = 0,
+ .priority = 0,
+ .paletteNum = 2,
+ .affineParam = 0,
+};
+
+static const struct OamData gUnknown_0860CF88 =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 2,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 0,
+ .tileNum = 0,
+ .priority = 0,
+ .paletteNum = 2,
+ .affineParam = 0,
+};
+
+static const union AnimCmd gUnknown_0860CF90[] =
+{
+ ANIMCMD_FRAME(20, 1),
+ ANIMCMD_END,
+};
+static const union AnimCmd gUnknown_0860CF98[] =
+{
+ ANIMCMD_FRAME(24, 1),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd * const gUnknown_0860CFA0[] =
+{
+ gUnknown_0860CF90,
+ gUnknown_0860CF98,
+};
+
+static const struct SpriteTemplate gUnknown_0860CFA8 =
+{
+ .tileTag = 0x0000,
+ .paletteTag = 0xffff,
+ .oam = &gUnknown_0860CF70,
+ .anims = gUnknown_0860CFA0,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy
+};
+
+static const union AnimCmd gUnknown_0860CFC0[] =
+{
+ ANIMCMD_FRAME(8, 1),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd gUnknown_0860CFC8[] =
+{
+ ANIMCMD_FRAME(0, 1),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd * const gUnknown_0860CFD0[] =
+{
+ gUnknown_0860CFC0,
+ gUnknown_0860CFC8,
+};
+
+static const struct SpriteTemplate gUnknown_0860CFD8 =
+{
+ .tileTag = 0x0000,
+ .paletteTag = 0xffff,
+ .oam = &gUnknown_0860CF78,
+ .anims = gUnknown_0860CFD0,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy
+};
+
+static const union AnimCmd gUnknown_0860CFF0[] =
+{
+ ANIMCMD_FRAME(40, 1),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd gUnknown_0860CFF8[] =
+{
+ ANIMCMD_FRAME(32, 1),
+ ANIMCMD_END,
+ };
+
+static const union AnimCmd * const gUnknown_0860D000[] =
+{
+ gUnknown_0860CFF0,
+ gUnknown_0860CFF8,
+};
+
+static const struct SpriteTemplate gUnknown_0860D008 =
+{
+ .tileTag = 0x0000,
+ .paletteTag = 0xffff,
+ .oam = &gUnknown_0860CF78,
+ .anims = gUnknown_0860D000,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy
+};
+
+static const union AnimCmd gUnknown_0860D020[] =
+{
+ ANIMCMD_FRAME(18, 1),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd gUnknown_0860D028[] =
+{
+ ANIMCMD_FRAME(18, 129, .vFlip = TRUE),
+ ANIMCMD_END,
+ };
+
+static const union AnimCmd gUnknown_0860D030[] =
+{
+ ANIMCMD_FRAME(16, 65, .hFlip = TRUE),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd gUnknown_0860D038[] =
+{
+ ANIMCMD_FRAME(16, 1),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd * const gUnknown_0860D040[] =
+{
+ gUnknown_0860D020,
+ gUnknown_0860D028,
+};
+
+static const union AnimCmd * const gUnknown_0860D048[] =
+{
+ gUnknown_0860D030,
+ gUnknown_0860D038,
+};
+
+static const struct SpriteTemplate gUnknown_0860D050 =
+{
+ .tileTag = 0x0000,
+ .paletteTag = 0xffff,
+ .oam = &gUnknown_0860CF88,
+ .anims = gUnknown_0860D048,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_8190B40
+};
+
+static const struct SpriteTemplate gUnknown_0860D068 =
+{
+ .tileTag = 0x0000,
+ .paletteTag = 0xffff,
+ .oam = &gUnknown_0860CF80,
+ .anims = gUnknown_0860D040,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_8190C6C
+};
+
+static const u8 gUnknown_0860D080[DOME_TOURNAMENT_TRAINERS_COUNT] =
+{
+ 0x00, 0x08, 0x0c, 0x04, 0x07, 0x0f, 0x0b, 0x03, 0x02, 0x0a, 0x0e, 0x06, 0x05, 0x0d, 0x09, 0x01
+};
+
+static void (* const gUnknown_0860D090[])(void) =
+{
+ sub_818E9CC,
+ sub_818EA84,
+ sub_818ED28,
+ sub_818F9B0,
+ sub_818F9E0,
+ sub_818FA20,
+ ShowDomeOpponentInfo,
+ sub_81938A4,
+ sub_81938E0,
+ sub_8190298,
+ sub_81902E4,
+ sub_8193D40,
+ sub_8193D7C,
+ sub_81902F8,
+ sub_819033C,
+ sub_8194D48,
+ sub_8194D68,
+ sub_8194E44,
+ sub_8194EB4,
+ sub_8194EC0,
+ sub_8194EF8,
+ sub_8194F58,
+ InitDomeTrainers,
+};
+
+static const u32 gUnknown_0860D0EC[][2] =
+{
+ {0x00000004, 0x00000008},
+ {0x00100000, 0x00200000},
+};
+
+static const u32 gUnknown_0860D0FC[][2] =
+{
+ {0xfffffffb, 0xfffffff7},
+ {0xffefffff, 0xffdfffff},
+};
+
+static const u8 sIdToOpponentId[DOME_TOURNAMENT_TRAINERS_COUNT][DOME_ROUNDS_COUNT] =
+{
+ [0] = {8, 0, 4, 8},
+ [1] = {9, 12, 8, 0},
+ [2] = {10, 8, 12, 0},
+ [3] = {11, 4, 0, 8},
+ [4] = {12, 0, 4, 8},
+ [5] = {13, 12, 8, 0},
+ [6] = {14, 8, 12, 0},
+ [7] = {15, 4, 0, 8},
+ [8] = {0, 0, 4, 8},
+ [9] = {1, 12, 8, 0},
+ [10] = {2, 8, 12, 0},
+ [11] = {3, 4, 0, 8},
+ [12] = {4, 0, 4, 8},
+ [13] = {5, 12, 8, 0},
+ [14] = {6, 8, 12, 0},
+ [15] = {7, 4, 0, 8},
+};
+
+static const u8 gUnknown_0860D14C[] = {0x00, 0x08, 0x04, 0x0c, 0x07, 0x0f, 0x03, 0x0b, 0x02, 0x0a, 0x06, 0x0e, 0x05, 0x0d, 0x01, 0x09};
+
+static const u8 gUnknown_0860D15C[][4] =
+{
+ {0x00, 0x08, 0x0c, 0x0e},
+ {0x00, 0x08, 0x0c, 0x0e},
+ {0x01, 0x08, 0x0c, 0x0e},
+ {0x01, 0x08, 0x0c, 0x0e},
+ {0x02, 0x09, 0x0c, 0x0e},
+ {0x02, 0x09, 0x0c, 0x0e},
+ {0x03, 0x09, 0x0c, 0x0e},
+ {0x03, 0x09, 0x0c, 0x0e},
+ {0x04, 0x0a, 0x0d, 0x0e},
+ {0x04, 0x0a, 0x0d, 0x0e},
+ {0x05, 0x0a, 0x0d, 0x0e},
+ {0x05, 0x0a, 0x0d, 0x0e},
+ {0x06, 0x0b, 0x0d, 0x0e},
+ {0x06, 0x0b, 0x0d, 0x0e},
+ {0x07, 0x0b, 0x0d, 0x0e},
+ {0x07, 0x0b, 0x0d, 0x0e},
+};
+
+static const u8 gUnknown_0860D19C[] = {0x17, 0x1b, 0x1d, 0x1e};
+
+static const u8 gUnknown_0860D1A0[][4] =
+{
+ {0x10, 0x18, 0x1c, 0x1e},
+ {0x11, 0x18, 0x1c, 0x1e},
+ {0x12, 0x19, 0x1c, 0x1e},
+ {0x13, 0x19, 0x1c, 0x1e},
+ {0x14, 0x1a, 0x1d, 0x1e},
+ {0x15, 0x1a, 0x1d, 0x1e},
+ {0x16, 0x1b, 0x1d, 0x1e},
+ {0x17, 0x1b, 0x1d, 0x1e},
+};
+
+static const u8 gUnknown_0860D1C0[] = {0x00, 0x0f, 0x08, 0x07, 0x03, 0x0c, 0x0b, 0x04, 0x01, 0x0e, 0x09, 0x06, 0x02, 0x0d, 0x0a, 0x05};
+
+static const u8 *const gBattleDomePotentialPointers[] =
+{
+ gBattleDomeOpponentPotential1,
+ gBattleDomeOpponentPotential2,
+ gBattleDomeOpponentPotential3,
+ gBattleDomeOpponentPotential4,
+ gBattleDomeOpponentPotential5,
+ gBattleDomeOpponentPotential6,
+ gBattleDomeOpponentPotential7,
+ gBattleDomeOpponentPotential8,
+ gBattleDomeOpponentPotential9,
+ gBattleDomeOpponentPotential10,
+ gBattleDomeOpponentPotential11,
+ gBattleDomeOpponentPotential12,
+ gBattleDomeOpponentPotential13,
+ gBattleDomeOpponentPotential14,
+ gBattleDomeOpponentPotential15,
+ gBattleDomeOpponentPotential16,
+ gBattleDomeOpponentPotential17,
+};
+
+static const u8 *const gBattleDomeOpponentStylePointers[] =
+{
+ gBattleDomeOpponentStyle1,
+ gBattleDomeOpponentStyle2,
+ gBattleDomeOpponentStyle3,
+ gBattleDomeOpponentStyle4,
+ gBattleDomeOpponentStyle5,
+ gBattleDomeOpponentStyle6,
+ gBattleDomeOpponentStyle7,
+ gBattleDomeOpponentStyle8,
+ gBattleDomeOpponentStyle9,
+ gBattleDomeOpponentStyle10,
+ gBattleDomeOpponentStyle11,
+ gBattleDomeOpponentStyle12,
+ gBattleDomeOpponentStyle13,
+ gBattleDomeOpponentStyle14,
+ gBattleDomeOpponentStyle15,
+ gBattleDomeOpponentStyle16,
+ gBattleDomeOpponentStyle17,
+ gBattleDomeOpponentStyle18,
+ gBattleDomeOpponentStyle19,
+ gBattleDomeOpponentStyle20,
+ gBattleDomeOpponentStyle21,
+ gBattleDomeOpponentStyle22,
+ gBattleDomeOpponentStyle23,
+ gBattleDomeOpponentStyle24,
+ gBattleDomeOpponentStyle25,
+ gBattleDomeOpponentStyle26,
+ gBattleDomeOpponentStyle27,
+ gBattleDomeOpponentStyle28,
+ gBattleDomeOpponentStyleUnused1,
+ gBattleDomeOpponentStyleUnused2,
+ gBattleDomeOpponentStyleUnused3,
+ gBattleDomeOpponentStyleUnused4,
+};
+
+static const u8 *const gBattleDomeOpponentStatsPointers[] =
+{
+ gBattleDomeOpponentStats1,
+ gBattleDomeOpponentStats2,
+ gBattleDomeOpponentStats3,
+ gBattleDomeOpponentStats4,
+ gBattleDomeOpponentStats5,
+ gBattleDomeOpponentStats6,
+ gBattleDomeOpponentStats7,
+ gBattleDomeOpponentStats8,
+ gBattleDomeOpponentStats9,
+ gBattleDomeOpponentStats10,
+ gBattleDomeOpponentStats11,
+ gBattleDomeOpponentStats12,
+ gBattleDomeOpponentStats13,
+ gBattleDomeOpponentStats14,
+ gBattleDomeOpponentStats15,
+ gBattleDomeOpponentStats16,
+ gBattleDomeOpponentStats17,
+ gBattleDomeOpponentStats18,
+ gBattleDomeOpponentStats19,
+ gBattleDomeOpponentStats20,
+ gBattleDomeOpponentStats21,
+ gBattleDomeOpponentStats22,
+ gBattleDomeOpponentStats23,
+ gBattleDomeOpponentStats24,
+ gBattleDomeOpponentStats25,
+ gBattleDomeOpponentStats26,
+ gBattleDomeOpponentStats27,
+ gBattleDomeOpponentStats28,
+ gBattleDomeOpponentStats29,
+ gBattleDomeOpponentStats30,
+ gBattleDomeOpponentStats31,
+ gBattleDomeOpponentStats32,
+ gBattleDomeOpponentStats33,
+ gBattleDomeOpponentStats34,
+ gBattleDomeOpponentStats35,
+ gBattleDomeOpponentStats36,
+ gBattleDomeOpponentStats37,
+ gBattleDomeOpponentStats38,
+ gBattleDomeOpponentStats39,
+ gBattleDomeOpponentStats40,
+ gBattleDomeOpponentStats41,
+ gBattleDomeOpponentStats42,
+ gBattleDomeOpponentStats43,
+};
+
+static const u8 sInfoTrainerMonX[] = {0x68, 0x88, 0x68};
+static const u8 sInfoTrainerMonY[] = {0x26, 0x3e, 0x4e};
+static const u8 gUnknown_0860D346[] = {0x00, 0x04, 0x00};
+
+static const u8 gUnknown_0860D349[] = {0x00, 0x05, 0x09, 0x0c, 0x0e, 0x00, 0x00};
+
+static const u8 *const gBattleDomeMatchNumberPointers[] =
+{
+ gBattleDomeMatchNumber1,
+ gBattleDomeMatchNumber2,
+ gBattleDomeMatchNumber3,
+ gBattleDomeMatchNumber4,
+ gBattleDomeMatchNumber5,
+ gBattleDomeMatchNumber6,
+ gBattleDomeMatchNumber7,
+ gBattleDomeMatchNumber8,
+ gBattleDomeMatchNumber9,
+ gBattleDomeMatchNumber10,
+ gBattleDomeMatchNumber11,
+ gBattleDomeMatchNumber12,
+ gBattleDomeMatchNumber13,
+ gBattleDomeMatchNumber14,
+ gBattleDomeMatchNumber15,
+};
+
+static const u8 *const gBattleDomeWinStringsPointers[] =
+{
+ gBattleDomeWinStrings1,
+ gBattleDomeWinStrings2,
+ gBattleDomeWinStrings3,
+ gBattleDomeWinStrings4,
+ gBattleDomeWinStrings5,
+ gBattleDomeWinStrings6,
+ gBattleDomeWinStrings7,
+};
+
+static const u8 sFirstTrainerMonX[] = {0x60, 0x60, 0x60};
+static const u8 sFirstTrainerMonY[] = {0x38, 0x50, 0x68};
+static const u8 sSecondTrainerMonX[] = {0x90, 0x90, 0x90};
+static const u8 sSecondTrainerMonY[] = {0x38, 0x50, 0x68};
+
+static const u8 gUnknown_0860D3B4[] = {0x00, 0x08, 0x0c, 0x04, 0x07, 0x0f, 0x0b, 0x03, 0x02, 0x0a, 0x0e, 0x06, 0x05, 0x0d, 0x09, 0x01};
+
+static const u8 gUnknown_0860D3C4[][3] =
+{
+ {0x00, 0x02, 0x00},
+ {0x02, 0x02, 0x00},
+ {0x04, 0x02, 0x00},
+ {0x06, 0x02, 0x00},
+ {0x08, 0x02, 0x00},
+ {0x0a, 0x02, 0x00},
+ {0x0c, 0x02, 0x00},
+ {0x0e, 0x02, 0x00},
+ {0x00, 0x04, 0x01},
+ {0x04, 0x04, 0x01},
+ {0x08, 0x04, 0x01},
+ {0x0c, 0x04, 0x01},
+ {0x00, 0x08, 0x02},
+ {0x08, 0x08, 0x02},
+ {0x00, 0x10, 0x03},
+};
+
+static const u8 gUnknown_0860D3F1[][2] =
+{
+ {0x00, 0x00},
+ {0x01, 0x70},
+ {0x01, 0x00},
+ {0x00, 0x70},
+ {0x00, 0x30},
+ {0x01, 0x40},
+ {0x01, 0x30},
+ {0x00, 0x40},
+ {0x00, 0x10},
+ {0x01, 0x60},
+ {0x01, 0x10},
+ {0x00, 0x60},
+ {0x00, 0x20},
+ {0x01, 0x50},
+ {0x01, 0x20},
+ {0x00, 0x50},
+};
+
+static const u8 gUnknown_0860D411[][2] =
+{
+ {0x44, 0x21},
+ {0x44, 0x31},
+ {0x44, 0x41},
+ {0x44, 0x51},
+ {0x44, 0x61},
+ {0x44, 0x71},
+ {0x44, 0x81},
+ {0x44, 0x91},
+ {0xac, 0x21},
+ {0xac, 0x31},
+ {0xac, 0x41},
+ {0xac, 0x51},
+ {0xac, 0x61},
+ {0xac, 0x71},
+ {0xac, 0x81},
+ {0xac, 0x91},
+ {0x57, 0x29},
+ {0x57, 0x49},
+ {0x57, 0x69},
+ {0x57, 0x89},
+ {0x99, 0x29},
+ {0x99, 0x49},
+ {0x99, 0x69},
+ {0x99, 0x89},
+ {0x5f, 0x39},
+ {0x5f, 0x79},
+ {0x91, 0x39},
+ {0x91, 0x79},
+ {0x67, 0x59},
+ {0x89, 0x59},
+ {0x78, 0x59},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d450[] =
+{
+ {.src = 0x6021, .y = 0x04, .x = 0x09},
+ {.src = 0x6023, .y = 0x04, .x = 0x0a},
+ {.src = 0x6047, .y = 0x05, .x = 0x0a},
+ {.src = 0x6043, .y = 0x05, .x = 0x0b},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d460[] =
+{
+ {.src = 0x6021, .y = 0x04, .x = 0x09},
+ {.src = 0x6023, .y = 0x04, .x = 0x0a},
+ {.src = 0x6047, .y = 0x05, .x = 0x0a},
+ {.src = 0x6023, .y = 0x05, .x = 0x0b},
+ {.src = 0x6027, .y = 0x06, .x = 0x0b},
+ {.src = 0x6047, .y = 0x07, .x = 0x0b},
+ {.src = 0x6043, .y = 0x07, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d47c[] =
+{
+ {.src = 0x6021, .y = 0x04, .x = 0x09},
+ {.src = 0x6023, .y = 0x04, .x = 0x0a},
+ {.src = 0x6047, .y = 0x05, .x = 0x0a},
+ {.src = 0x6023, .y = 0x05, .x = 0x0b},
+ {.src = 0x6027, .y = 0x06, .x = 0x0b},
+ {.src = 0x6047, .y = 0x07, .x = 0x0b},
+ {.src = 0x6023, .y = 0x07, .x = 0x0c},
+ {.src = 0x6027, .y = 0x08, .x = 0x0c},
+ {.src = 0x6027, .y = 0x09, .x = 0x0c},
+ {.src = 0x6027, .y = 0x0a, .x = 0x0c},
+ {.src = 0x603b, .y = 0x0b, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d4a8[] =
+{
+ {.src = 0x6021, .y = 0x04, .x = 0x09},
+ {.src = 0x6023, .y = 0x04, .x = 0x0a},
+ {.src = 0x6047, .y = 0x05, .x = 0x0a},
+ {.src = 0x6023, .y = 0x05, .x = 0x0b},
+ {.src = 0x6027, .y = 0x06, .x = 0x0b},
+ {.src = 0x6047, .y = 0x07, .x = 0x0b},
+ {.src = 0x6023, .y = 0x07, .x = 0x0c},
+ {.src = 0x6027, .y = 0x08, .x = 0x0c},
+ {.src = 0x6027, .y = 0x09, .x = 0x0c},
+ {.src = 0x6027, .y = 0x0a, .x = 0x0c},
+ {.src = 0x603b, .y = 0x0b, .x = 0x0c},
+ {.src = 0x602c, .y = 0x0b, .x = 0x0d},
+ {.src = 0x602d, .y = 0x0b, .x = 0x0e},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d4dc[] =
+{
+ {.src = 0x6021, .y = 0x06, .x = 0x09},
+ {.src = 0x6021, .y = 0x06, .x = 0x0a},
+ {.src = 0x6027, .y = 0x05, .x = 0x0a},
+ {.src = 0x6043, .y = 0x05, .x = 0x0b},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d4ec[] =
+{
+ {.src = 0x6021, .y = 0x06, .x = 0x09},
+ {.src = 0x6021, .y = 0x06, .x = 0x0a},
+ {.src = 0x6027, .y = 0x05, .x = 0x0a},
+ {.src = 0x6023, .y = 0x05, .x = 0x0b},
+ {.src = 0x6027, .y = 0x06, .x = 0x0b},
+ {.src = 0x6047, .y = 0x07, .x = 0x0b},
+ {.src = 0x6043, .y = 0x07, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d508[] =
+{
+ {.src = 0x6021, .y = 0x06, .x = 0x09},
+ {.src = 0x6021, .y = 0x06, .x = 0x0a},
+ {.src = 0x6027, .y = 0x05, .x = 0x0a},
+ {.src = 0x6023, .y = 0x05, .x = 0x0b},
+ {.src = 0x6027, .y = 0x06, .x = 0x0b},
+ {.src = 0x6047, .y = 0x07, .x = 0x0b},
+ {.src = 0x6023, .y = 0x07, .x = 0x0c},
+ {.src = 0x6027, .y = 0x08, .x = 0x0c},
+ {.src = 0x6027, .y = 0x09, .x = 0x0c},
+ {.src = 0x6027, .y = 0x0a, .x = 0x0c},
+ {.src = 0x603b, .y = 0x0b, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d534[] =
+{
+ {.src = 0x6021, .y = 0x06, .x = 0x09},
+ {.src = 0x6021, .y = 0x06, .x = 0x0a},
+ {.src = 0x6027, .y = 0x05, .x = 0x0a},
+ {.src = 0x6023, .y = 0x05, .x = 0x0b},
+ {.src = 0x6027, .y = 0x06, .x = 0x0b},
+ {.src = 0x6047, .y = 0x07, .x = 0x0b},
+ {.src = 0x6023, .y = 0x07, .x = 0x0c},
+ {.src = 0x6027, .y = 0x08, .x = 0x0c},
+ {.src = 0x6027, .y = 0x09, .x = 0x0c},
+ {.src = 0x6027, .y = 0x0a, .x = 0x0c},
+ {.src = 0x603b, .y = 0x0b, .x = 0x0c},
+ {.src = 0x602c, .y = 0x0b, .x = 0x0d},
+ {.src = 0x602d, .y = 0x0b, .x = 0x0e},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d568[] =
+{
+ {.src = 0x6021, .y = 0x08, .x = 0x09},
+ {.src = 0x6023, .y = 0x08, .x = 0x0a},
+ {.src = 0x6047, .y = 0x09, .x = 0x0a},
+ {.src = 0x6021, .y = 0x09, .x = 0x0b},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d578[] =
+{
+ {.src = 0x6021, .y = 0x08, .x = 0x09},
+ {.src = 0x6023, .y = 0x08, .x = 0x0a},
+ {.src = 0x6047, .y = 0x09, .x = 0x0a},
+ {.src = 0x6021, .y = 0x09, .x = 0x0b},
+ {.src = 0x6027, .y = 0x08, .x = 0x0b},
+ {.src = 0x6027, .y = 0x07, .x = 0x0b},
+ {.src = 0x6043, .y = 0x07, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d594[] =
+{
+ {.src = 0x6021, .y = 0x08, .x = 0x09},
+ {.src = 0x6023, .y = 0x08, .x = 0x0a},
+ {.src = 0x6047, .y = 0x09, .x = 0x0a},
+ {.src = 0x6021, .y = 0x09, .x = 0x0b},
+ {.src = 0x6027, .y = 0x08, .x = 0x0b},
+ {.src = 0x6027, .y = 0x07, .x = 0x0b},
+ {.src = 0x6023, .y = 0x07, .x = 0x0c},
+ {.src = 0x6027, .y = 0x08, .x = 0x0c},
+ {.src = 0x6027, .y = 0x09, .x = 0x0c},
+ {.src = 0x6027, .y = 0x0a, .x = 0x0c},
+ {.src = 0x603b, .y = 0x0b, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d5c0[] =
+{
+ {.src = 0x6021, .y = 0x08, .x = 0x09},
+ {.src = 0x6023, .y = 0x08, .x = 0x0a},
+ {.src = 0x6047, .y = 0x09, .x = 0x0a},
+ {.src = 0x6021, .y = 0x09, .x = 0x0b},
+ {.src = 0x6027, .y = 0x08, .x = 0x0b},
+ {.src = 0x6027, .y = 0x07, .x = 0x0b},
+ {.src = 0x6023, .y = 0x07, .x = 0x0c},
+ {.src = 0x6027, .y = 0x08, .x = 0x0c},
+ {.src = 0x6027, .y = 0x09, .x = 0x0c},
+ {.src = 0x6027, .y = 0x0a, .x = 0x0c},
+ {.src = 0x603b, .y = 0x0b, .x = 0x0c},
+ {.src = 0x602c, .y = 0x0b, .x = 0x0d},
+ {.src = 0x602d, .y = 0x0b, .x = 0x0e},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d5f4[] =
+{
+ {.src = 0x6021, .y = 0x0a, .x = 0x09},
+ {.src = 0x6021, .y = 0x0a, .x = 0x0a},
+ {.src = 0x6027, .y = 0x09, .x = 0x0a},
+ {.src = 0x6021, .y = 0x09, .x = 0x0b},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d604[] =
+{
+ {.src = 0x6021, .y = 0x0a, .x = 0x09},
+ {.src = 0x6021, .y = 0x0a, .x = 0x0a},
+ {.src = 0x6027, .y = 0x09, .x = 0x0a},
+ {.src = 0x6021, .y = 0x09, .x = 0x0b},
+ {.src = 0x6027, .y = 0x08, .x = 0x0b},
+ {.src = 0x6027, .y = 0x07, .x = 0x0b},
+ {.src = 0x6043, .y = 0x07, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d620[] =
+{
+ {.src = 0x6021, .y = 0x0a, .x = 0x09},
+ {.src = 0x6021, .y = 0x0a, .x = 0x0a},
+ {.src = 0x6027, .y = 0x09, .x = 0x0a},
+ {.src = 0x6021, .y = 0x09, .x = 0x0b},
+ {.src = 0x6027, .y = 0x08, .x = 0x0b},
+ {.src = 0x6027, .y = 0x07, .x = 0x0b},
+ {.src = 0x6023, .y = 0x07, .x = 0x0c},
+ {.src = 0x6027, .y = 0x08, .x = 0x0c},
+ {.src = 0x6027, .y = 0x09, .x = 0x0c},
+ {.src = 0x6027, .y = 0x0a, .x = 0x0c},
+ {.src = 0x603b, .y = 0x0b, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d64c[] =
+{
+ {.src = 0x6021, .y = 0x0a, .x = 0x09},
+ {.src = 0x6021, .y = 0x0a, .x = 0x0a},
+ {.src = 0x6027, .y = 0x09, .x = 0x0a},
+ {.src = 0x6021, .y = 0x09, .x = 0x0b},
+ {.src = 0x6027, .y = 0x08, .x = 0x0b},
+ {.src = 0x6027, .y = 0x07, .x = 0x0b},
+ {.src = 0x6023, .y = 0x07, .x = 0x0c},
+ {.src = 0x6027, .y = 0x08, .x = 0x0c},
+ {.src = 0x6027, .y = 0x09, .x = 0x0c},
+ {.src = 0x6027, .y = 0x0a, .x = 0x0c},
+ {.src = 0x603b, .y = 0x0b, .x = 0x0c},
+ {.src = 0x602c, .y = 0x0b, .x = 0x0d},
+ {.src = 0x602d, .y = 0x0b, .x = 0x0e},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d680[] =
+{
+ {.src = 0x6021, .y = 0x0c, .x = 0x09},
+ {.src = 0x6023, .y = 0x0c, .x = 0x0a},
+ {.src = 0x6047, .y = 0x0d, .x = 0x0a},
+ {.src = 0x6043, .y = 0x0d, .x = 0x0b},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d690[] =
+{
+ {.src = 0x6021, .y = 0x0c, .x = 0x09},
+ {.src = 0x6023, .y = 0x0c, .x = 0x0a},
+ {.src = 0x6047, .y = 0x0d, .x = 0x0a},
+ {.src = 0x6023, .y = 0x0d, .x = 0x0b},
+ {.src = 0x6027, .y = 0x0e, .x = 0x0b},
+ {.src = 0x6047, .y = 0x0f, .x = 0x0b},
+ {.src = 0x6021, .y = 0x0f, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d6ac[] =
+{
+ {.src = 0x6021, .y = 0x0c, .x = 0x09},
+ {.src = 0x6023, .y = 0x0c, .x = 0x0a},
+ {.src = 0x6047, .y = 0x0d, .x = 0x0a},
+ {.src = 0x6023, .y = 0x0d, .x = 0x0b},
+ {.src = 0x6027, .y = 0x0e, .x = 0x0b},
+ {.src = 0x6047, .y = 0x0f, .x = 0x0b},
+ {.src = 0x6021, .y = 0x0f, .x = 0x0c},
+ {.src = 0x6033, .y = 0x0e, .x = 0x0c},
+ {.src = 0x6032, .y = 0x0d, .x = 0x0c},
+ {.src = 0x6031, .y = 0x0c, .x = 0x0c},
+ {.src = 0x6030, .y = 0x0b, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d6d8[] =
+{
+ {.src = 0x6021, .y = 0x0c, .x = 0x09},
+ {.src = 0x6023, .y = 0x0c, .x = 0x0a},
+ {.src = 0x6047, .y = 0x0d, .x = 0x0a},
+ {.src = 0x6023, .y = 0x0d, .x = 0x0b},
+ {.src = 0x6027, .y = 0x0e, .x = 0x0b},
+ {.src = 0x6047, .y = 0x0f, .x = 0x0b},
+ {.src = 0x6021, .y = 0x0f, .x = 0x0c},
+ {.src = 0x6033, .y = 0x0e, .x = 0x0c},
+ {.src = 0x6032, .y = 0x0d, .x = 0x0c},
+ {.src = 0x6031, .y = 0x0c, .x = 0x0c},
+ {.src = 0x6030, .y = 0x0b, .x = 0x0c},
+ {.src = 0x602c, .y = 0x0b, .x = 0x0d},
+ {.src = 0x602d, .y = 0x0b, .x = 0x0e},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d70c[] =
+{
+ {.src = 0x6021, .y = 0x0e, .x = 0x09},
+ {.src = 0x6021, .y = 0x0e, .x = 0x0a},
+ {.src = 0x6027, .y = 0x0d, .x = 0x0a},
+ {.src = 0x6043, .y = 0x0d, .x = 0x0b},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d71c[] =
+{
+ {.src = 0x6021, .y = 0x0e, .x = 0x09},
+ {.src = 0x6021, .y = 0x0e, .x = 0x0a},
+ {.src = 0x6027, .y = 0x0d, .x = 0x0a},
+ {.src = 0x6023, .y = 0x0d, .x = 0x0b},
+ {.src = 0x6027, .y = 0x0e, .x = 0x0b},
+ {.src = 0x6047, .y = 0x0f, .x = 0x0b},
+ {.src = 0x6021, .y = 0x0f, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d738[] =
+{
+ {.src = 0x6021, .y = 0x0e, .x = 0x09},
+ {.src = 0x6021, .y = 0x0e, .x = 0x0a},
+ {.src = 0x6027, .y = 0x0d, .x = 0x0a},
+ {.src = 0x6023, .y = 0x0d, .x = 0x0b},
+ {.src = 0x6027, .y = 0x0e, .x = 0x0b},
+ {.src = 0x6047, .y = 0x0f, .x = 0x0b},
+ {.src = 0x6021, .y = 0x0f, .x = 0x0c},
+ {.src = 0x6033, .y = 0x0e, .x = 0x0c},
+ {.src = 0x6032, .y = 0x0d, .x = 0x0c},
+ {.src = 0x6031, .y = 0x0c, .x = 0x0c},
+ {.src = 0x6030, .y = 0x0b, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d764[] =
+{
+ {.src = 0x6021, .y = 0x0e, .x = 0x09},
+ {.src = 0x6021, .y = 0x0e, .x = 0x0a},
+ {.src = 0x6027, .y = 0x0d, .x = 0x0a},
+ {.src = 0x6023, .y = 0x0d, .x = 0x0b},
+ {.src = 0x6027, .y = 0x0e, .x = 0x0b},
+ {.src = 0x6047, .y = 0x0f, .x = 0x0b},
+ {.src = 0x6021, .y = 0x0f, .x = 0x0c},
+ {.src = 0x6033, .y = 0x0e, .x = 0x0c},
+ {.src = 0x6032, .y = 0x0d, .x = 0x0c},
+ {.src = 0x6031, .y = 0x0c, .x = 0x0c},
+ {.src = 0x6030, .y = 0x0b, .x = 0x0c},
+ {.src = 0x602c, .y = 0x0b, .x = 0x0d},
+ {.src = 0x602d, .y = 0x0b, .x = 0x0e},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d798[] =
+{
+ {.src = 0x6021, .y = 0x10, .x = 0x09},
+ {.src = 0x6023, .y = 0x10, .x = 0x0a},
+ {.src = 0x6047, .y = 0x11, .x = 0x0a},
+ {.src = 0x6021, .y = 0x11, .x = 0x0b},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d7a8[] =
+{
+ {.src = 0x6021, .y = 0x10, .x = 0x09},
+ {.src = 0x6023, .y = 0x10, .x = 0x0a},
+ {.src = 0x6047, .y = 0x11, .x = 0x0a},
+ {.src = 0x6021, .y = 0x11, .x = 0x0b},
+ {.src = 0x6027, .y = 0x10, .x = 0x0b},
+ {.src = 0x6027, .y = 0x0f, .x = 0x0b},
+ {.src = 0x6021, .y = 0x0f, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d7c4[] =
+{
+ {.src = 0x6021, .y = 0x10, .x = 0x09},
+ {.src = 0x6023, .y = 0x10, .x = 0x0a},
+ {.src = 0x6047, .y = 0x11, .x = 0x0a},
+ {.src = 0x6021, .y = 0x11, .x = 0x0b},
+ {.src = 0x6027, .y = 0x10, .x = 0x0b},
+ {.src = 0x6027, .y = 0x0f, .x = 0x0b},
+ {.src = 0x6021, .y = 0x0f, .x = 0x0c},
+ {.src = 0x6033, .y = 0x0e, .x = 0x0c},
+ {.src = 0x6032, .y = 0x0d, .x = 0x0c},
+ {.src = 0x6031, .y = 0x0c, .x = 0x0c},
+ {.src = 0x6030, .y = 0x0b, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d7f0[] =
+{
+ {.src = 0x6021, .y = 0x10, .x = 0x09},
+ {.src = 0x6023, .y = 0x10, .x = 0x0a},
+ {.src = 0x6047, .y = 0x11, .x = 0x0a},
+ {.src = 0x6021, .y = 0x11, .x = 0x0b},
+ {.src = 0x6027, .y = 0x10, .x = 0x0b},
+ {.src = 0x6027, .y = 0x0f, .x = 0x0b},
+ {.src = 0x6021, .y = 0x0f, .x = 0x0c},
+ {.src = 0x6033, .y = 0x0e, .x = 0x0c},
+ {.src = 0x6032, .y = 0x0d, .x = 0x0c},
+ {.src = 0x6031, .y = 0x0c, .x = 0x0c},
+ {.src = 0x6030, .y = 0x0b, .x = 0x0c},
+ {.src = 0x602c, .y = 0x0b, .x = 0x0d},
+ {.src = 0x602d, .y = 0x0b, .x = 0x0e},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d824[] =
+{
+ {.src = 0x602b, .y = 0x12, .x = 0x09},
+ {.src = 0x602b, .y = 0x12, .x = 0x0a},
+ {.src = 0x6027, .y = 0x11, .x = 0x0a},
+ {.src = 0x6021, .y = 0x11, .x = 0x0b},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d834[] =
+{
+ {.src = 0x602b, .y = 0x12, .x = 0x09},
+ {.src = 0x602b, .y = 0x12, .x = 0x0a},
+ {.src = 0x6027, .y = 0x11, .x = 0x0a},
+ {.src = 0x6021, .y = 0x11, .x = 0x0b},
+ {.src = 0x6027, .y = 0x10, .x = 0x0b},
+ {.src = 0x6027, .y = 0x0f, .x = 0x0b},
+ {.src = 0x6021, .y = 0x0f, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d850[] =
+{
+ {.src = 0x602b, .y = 0x12, .x = 0x09},
+ {.src = 0x602b, .y = 0x12, .x = 0x0a},
+ {.src = 0x6027, .y = 0x11, .x = 0x0a},
+ {.src = 0x6021, .y = 0x11, .x = 0x0b},
+ {.src = 0x6027, .y = 0x10, .x = 0x0b},
+ {.src = 0x6027, .y = 0x0f, .x = 0x0b},
+ {.src = 0x6021, .y = 0x0f, .x = 0x0c},
+ {.src = 0x6033, .y = 0x0e, .x = 0x0c},
+ {.src = 0x6032, .y = 0x0d, .x = 0x0c},
+ {.src = 0x6031, .y = 0x0c, .x = 0x0c},
+ {.src = 0x6030, .y = 0x0b, .x = 0x0c},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d87c[] =
+{
+ {.src = 0x602b, .y = 0x12, .x = 0x09},
+ {.src = 0x602b, .y = 0x12, .x = 0x0a},
+ {.src = 0x6027, .y = 0x11, .x = 0x0a},
+ {.src = 0x6021, .y = 0x11, .x = 0x0b},
+ {.src = 0x6027, .y = 0x10, .x = 0x0b},
+ {.src = 0x6027, .y = 0x0f, .x = 0x0b},
+ {.src = 0x6021, .y = 0x0f, .x = 0x0c},
+ {.src = 0x6033, .y = 0x0e, .x = 0x0c},
+ {.src = 0x6032, .y = 0x0d, .x = 0x0c},
+ {.src = 0x6031, .y = 0x0c, .x = 0x0c},
+ {.src = 0x6030, .y = 0x0b, .x = 0x0c},
+ {.src = 0x602c, .y = 0x0b, .x = 0x0d},
+ {.src = 0x602d, .y = 0x0b, .x = 0x0e},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d8b0[] =
+{
+ {.src = 0x6021, .y = 0x04, .x = 0x14},
+ {.src = 0x6025, .y = 0x04, .x = 0x13},
+ {.src = 0x6049, .y = 0x05, .x = 0x13},
+ {.src = 0x6045, .y = 0x05, .x = 0x12},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d8c0[] =
+{
+ {.src = 0x6021, .y = 0x04, .x = 0x14},
+ {.src = 0x6025, .y = 0x04, .x = 0x13},
+ {.src = 0x6049, .y = 0x05, .x = 0x13},
+ {.src = 0x6025, .y = 0x05, .x = 0x12},
+ {.src = 0x6029, .y = 0x06, .x = 0x12},
+ {.src = 0x6049, .y = 0x07, .x = 0x12},
+ {.src = 0x6045, .y = 0x07, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d8dc[] =
+{
+ {.src = 0x6021, .y = 0x04, .x = 0x14},
+ {.src = 0x6025, .y = 0x04, .x = 0x13},
+ {.src = 0x6049, .y = 0x05, .x = 0x13},
+ {.src = 0x6025, .y = 0x05, .x = 0x12},
+ {.src = 0x6029, .y = 0x06, .x = 0x12},
+ {.src = 0x6049, .y = 0x07, .x = 0x12},
+ {.src = 0x6025, .y = 0x07, .x = 0x11},
+ {.src = 0x6029, .y = 0x08, .x = 0x11},
+ {.src = 0x6029, .y = 0x09, .x = 0x11},
+ {.src = 0x6029, .y = 0x0a, .x = 0x11},
+ {.src = 0x603c, .y = 0x0b, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d908[] =
+{
+ {.src = 0x6021, .y = 0x04, .x = 0x14},
+ {.src = 0x6025, .y = 0x04, .x = 0x13},
+ {.src = 0x6049, .y = 0x05, .x = 0x13},
+ {.src = 0x6025, .y = 0x05, .x = 0x12},
+ {.src = 0x6029, .y = 0x06, .x = 0x12},
+ {.src = 0x6049, .y = 0x07, .x = 0x12},
+ {.src = 0x6025, .y = 0x07, .x = 0x11},
+ {.src = 0x6029, .y = 0x08, .x = 0x11},
+ {.src = 0x6029, .y = 0x09, .x = 0x11},
+ {.src = 0x6029, .y = 0x0a, .x = 0x11},
+ {.src = 0x603c, .y = 0x0b, .x = 0x11},
+ {.src = 0x602f, .y = 0x0b, .x = 0x10},
+ {.src = 0x602e, .y = 0x0b, .x = 0x0f},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d93c[] =
+{
+ {.src = 0x6021, .y = 0x06, .x = 0x14},
+ {.src = 0x6021, .y = 0x06, .x = 0x13},
+ {.src = 0x6029, .y = 0x05, .x = 0x13},
+ {.src = 0x6045, .y = 0x05, .x = 0x12},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d94c[] =
+{
+ {.src = 0x6021, .y = 0x06, .x = 0x14},
+ {.src = 0x6021, .y = 0x06, .x = 0x13},
+ {.src = 0x6029, .y = 0x05, .x = 0x13},
+ {.src = 0x6025, .y = 0x05, .x = 0x12},
+ {.src = 0x6029, .y = 0x06, .x = 0x12},
+ {.src = 0x6049, .y = 0x07, .x = 0x12},
+ {.src = 0x6045, .y = 0x07, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d968[] =
+{
+ {.src = 0x6021, .y = 0x06, .x = 0x14},
+ {.src = 0x6021, .y = 0x06, .x = 0x13},
+ {.src = 0x6029, .y = 0x05, .x = 0x13},
+ {.src = 0x6025, .y = 0x05, .x = 0x12},
+ {.src = 0x6029, .y = 0x06, .x = 0x12},
+ {.src = 0x6049, .y = 0x07, .x = 0x12},
+ {.src = 0x6025, .y = 0x07, .x = 0x11},
+ {.src = 0x6029, .y = 0x08, .x = 0x11},
+ {.src = 0x6029, .y = 0x09, .x = 0x11},
+ {.src = 0x6029, .y = 0x0a, .x = 0x11},
+ {.src = 0x603c, .y = 0x0b, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d994[] =
+{
+ {.src = 0x6021, .y = 0x06, .x = 0x14},
+ {.src = 0x6021, .y = 0x06, .x = 0x13},
+ {.src = 0x6029, .y = 0x05, .x = 0x13},
+ {.src = 0x6025, .y = 0x05, .x = 0x12},
+ {.src = 0x6029, .y = 0x06, .x = 0x12},
+ {.src = 0x6049, .y = 0x07, .x = 0x12},
+ {.src = 0x6025, .y = 0x07, .x = 0x11},
+ {.src = 0x6029, .y = 0x08, .x = 0x11},
+ {.src = 0x6029, .y = 0x09, .x = 0x11},
+ {.src = 0x6029, .y = 0x0a, .x = 0x11},
+ {.src = 0x603c, .y = 0x0b, .x = 0x11},
+ {.src = 0x602f, .y = 0x0b, .x = 0x10},
+ {.src = 0x602e, .y = 0x0b, .x = 0x0f},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d9c8[] =
+{
+ {.src = 0x6021, .y = 0x08, .x = 0x14},
+ {.src = 0x6025, .y = 0x08, .x = 0x13},
+ {.src = 0x6049, .y = 0x09, .x = 0x13},
+ {.src = 0x6021, .y = 0x09, .x = 0x12},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d9d8[] =
+{
+ {.src = 0x6021, .y = 0x08, .x = 0x14},
+ {.src = 0x6025, .y = 0x08, .x = 0x13},
+ {.src = 0x6049, .y = 0x09, .x = 0x13},
+ {.src = 0x6021, .y = 0x09, .x = 0x12},
+ {.src = 0x6029, .y = 0x08, .x = 0x12},
+ {.src = 0x6029, .y = 0x07, .x = 0x12},
+ {.src = 0x6045, .y = 0x07, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860d9f4[] =
+{
+ {.src = 0x6021, .y = 0x08, .x = 0x14},
+ {.src = 0x6025, .y = 0x08, .x = 0x13},
+ {.src = 0x6049, .y = 0x09, .x = 0x13},
+ {.src = 0x6021, .y = 0x09, .x = 0x12},
+ {.src = 0x6029, .y = 0x08, .x = 0x12},
+ {.src = 0x6029, .y = 0x07, .x = 0x12},
+ {.src = 0x6025, .y = 0x07, .x = 0x11},
+ {.src = 0x6029, .y = 0x08, .x = 0x11},
+ {.src = 0x6029, .y = 0x09, .x = 0x11},
+ {.src = 0x6029, .y = 0x0a, .x = 0x11},
+ {.src = 0x603c, .y = 0x0b, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860da20[] =
+{
+ {.src = 0x6021, .y = 0x08, .x = 0x14},
+ {.src = 0x6025, .y = 0x08, .x = 0x13},
+ {.src = 0x6049, .y = 0x09, .x = 0x13},
+ {.src = 0x6021, .y = 0x09, .x = 0x12},
+ {.src = 0x6029, .y = 0x08, .x = 0x12},
+ {.src = 0x6029, .y = 0x07, .x = 0x12},
+ {.src = 0x6025, .y = 0x07, .x = 0x11},
+ {.src = 0x6029, .y = 0x08, .x = 0x11},
+ {.src = 0x6029, .y = 0x09, .x = 0x11},
+ {.src = 0x6029, .y = 0x0a, .x = 0x11},
+ {.src = 0x603c, .y = 0x0b, .x = 0x11},
+ {.src = 0x602f, .y = 0x0b, .x = 0x10},
+ {.src = 0x602e, .y = 0x0b, .x = 0x0f},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860da54[] =
+{
+ {.src = 0x6021, .y = 0x0a, .x = 0x14},
+ {.src = 0x6021, .y = 0x0a, .x = 0x13},
+ {.src = 0x6029, .y = 0x09, .x = 0x13},
+ {.src = 0x6021, .y = 0x09, .x = 0x12},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860da64[] =
+{
+ {.src = 0x6021, .y = 0x0a, .x = 0x14},
+ {.src = 0x6021, .y = 0x0a, .x = 0x13},
+ {.src = 0x6029, .y = 0x09, .x = 0x13},
+ {.src = 0x6021, .y = 0x09, .x = 0x12},
+ {.src = 0x6029, .y = 0x08, .x = 0x12},
+ {.src = 0x6029, .y = 0x07, .x = 0x12},
+ {.src = 0x6045, .y = 0x07, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860da80[] =
+{
+ {.src = 0x6021, .y = 0x0a, .x = 0x14},
+ {.src = 0x6021, .y = 0x0a, .x = 0x13},
+ {.src = 0x6029, .y = 0x09, .x = 0x13},
+ {.src = 0x6021, .y = 0x09, .x = 0x12},
+ {.src = 0x6029, .y = 0x08, .x = 0x12},
+ {.src = 0x6029, .y = 0x07, .x = 0x12},
+ {.src = 0x6025, .y = 0x07, .x = 0x11},
+ {.src = 0x6029, .y = 0x08, .x = 0x11},
+ {.src = 0x6029, .y = 0x09, .x = 0x11},
+ {.src = 0x6029, .y = 0x0a, .x = 0x11},
+ {.src = 0x603c, .y = 0x0b, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860daac[] =
+{
+ {.src = 0x6021, .y = 0x0a, .x = 0x14},
+ {.src = 0x6021, .y = 0x0a, .x = 0x13},
+ {.src = 0x6029, .y = 0x09, .x = 0x13},
+ {.src = 0x6021, .y = 0x09, .x = 0x12},
+ {.src = 0x6029, .y = 0x08, .x = 0x12},
+ {.src = 0x6029, .y = 0x07, .x = 0x12},
+ {.src = 0x6025, .y = 0x07, .x = 0x11},
+ {.src = 0x6029, .y = 0x08, .x = 0x11},
+ {.src = 0x6029, .y = 0x09, .x = 0x11},
+ {.src = 0x6029, .y = 0x0a, .x = 0x11},
+ {.src = 0x603c, .y = 0x0b, .x = 0x11},
+ {.src = 0x602f, .y = 0x0b, .x = 0x10},
+ {.src = 0x602e, .y = 0x0b, .x = 0x0f},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860dae0[] =
+{
+ {.src = 0x6021, .y = 0x0c, .x = 0x14},
+ {.src = 0x6025, .y = 0x0c, .x = 0x13},
+ {.src = 0x6049, .y = 0x0d, .x = 0x13},
+ {.src = 0x6045, .y = 0x0d, .x = 0x12},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860daf0[] =
+{
+ {.src = 0x6021, .y = 0x0c, .x = 0x14},
+ {.src = 0x6025, .y = 0x0c, .x = 0x13},
+ {.src = 0x6049, .y = 0x0d, .x = 0x13},
+ {.src = 0x6025, .y = 0x0d, .x = 0x12},
+ {.src = 0x6029, .y = 0x0e, .x = 0x12},
+ {.src = 0x6049, .y = 0x0f, .x = 0x12},
+ {.src = 0x6021, .y = 0x0f, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860db0c[] =
+{
+ {.src = 0x6021, .y = 0x0c, .x = 0x14},
+ {.src = 0x6025, .y = 0x0c, .x = 0x13},
+ {.src = 0x6049, .y = 0x0d, .x = 0x13},
+ {.src = 0x6025, .y = 0x0d, .x = 0x12},
+ {.src = 0x6029, .y = 0x0e, .x = 0x12},
+ {.src = 0x6049, .y = 0x0f, .x = 0x12},
+ {.src = 0x6021, .y = 0x0f, .x = 0x11},
+ {.src = 0x6038, .y = 0x0e, .x = 0x11},
+ {.src = 0x6037, .y = 0x0d, .x = 0x11},
+ {.src = 0x6036, .y = 0x0c, .x = 0x11},
+ {.src = 0x6035, .y = 0x0b, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860db38[] =
+{
+ {.src = 0x6021, .y = 0x0c, .x = 0x14},
+ {.src = 0x6025, .y = 0x0c, .x = 0x13},
+ {.src = 0x6049, .y = 0x0d, .x = 0x13},
+ {.src = 0x6025, .y = 0x0d, .x = 0x12},
+ {.src = 0x6029, .y = 0x0e, .x = 0x12},
+ {.src = 0x6049, .y = 0x0f, .x = 0x12},
+ {.src = 0x6021, .y = 0x0f, .x = 0x11},
+ {.src = 0x6038, .y = 0x0e, .x = 0x11},
+ {.src = 0x6037, .y = 0x0d, .x = 0x11},
+ {.src = 0x6036, .y = 0x0c, .x = 0x11},
+ {.src = 0x6035, .y = 0x0b, .x = 0x11},
+ {.src = 0x602f, .y = 0x0b, .x = 0x10},
+ {.src = 0x602e, .y = 0x0b, .x = 0x0f},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860db6c[] =
+{
+ {.src = 0x6021, .y = 0x0e, .x = 0x14},
+ {.src = 0x6021, .y = 0x0e, .x = 0x13},
+ {.src = 0x6029, .y = 0x0d, .x = 0x13},
+ {.src = 0x6045, .y = 0x0d, .x = 0x12},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860db7c[] =
+{
+ {.src = 0x6021, .y = 0x0e, .x = 0x14},
+ {.src = 0x6021, .y = 0x0e, .x = 0x13},
+ {.src = 0x6029, .y = 0x0d, .x = 0x13},
+ {.src = 0x6025, .y = 0x0d, .x = 0x12},
+ {.src = 0x6029, .y = 0x0e, .x = 0x12},
+ {.src = 0x6049, .y = 0x0f, .x = 0x12},
+ {.src = 0x6021, .y = 0x0f, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860db98[] =
+{
+ {.src = 0x6021, .y = 0x0e, .x = 0x14},
+ {.src = 0x6021, .y = 0x0e, .x = 0x13},
+ {.src = 0x6029, .y = 0x0d, .x = 0x13},
+ {.src = 0x6025, .y = 0x0d, .x = 0x12},
+ {.src = 0x6029, .y = 0x0e, .x = 0x12},
+ {.src = 0x6049, .y = 0x0f, .x = 0x12},
+ {.src = 0x6021, .y = 0x0f, .x = 0x11},
+ {.src = 0x6038, .y = 0x0e, .x = 0x11},
+ {.src = 0x6037, .y = 0x0d, .x = 0x11},
+ {.src = 0x6036, .y = 0x0c, .x = 0x11},
+ {.src = 0x6035, .y = 0x0b, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860dbc4[] =
+{
+ {.src = 0x6021, .y = 0x0e, .x = 0x14},
+ {.src = 0x6021, .y = 0x0e, .x = 0x13},
+ {.src = 0x6029, .y = 0x0d, .x = 0x13},
+ {.src = 0x6025, .y = 0x0d, .x = 0x12},
+ {.src = 0x6029, .y = 0x0e, .x = 0x12},
+ {.src = 0x6049, .y = 0x0f, .x = 0x12},
+ {.src = 0x6021, .y = 0x0f, .x = 0x11},
+ {.src = 0x6038, .y = 0x0e, .x = 0x11},
+ {.src = 0x6037, .y = 0x0d, .x = 0x11},
+ {.src = 0x6036, .y = 0x0c, .x = 0x11},
+ {.src = 0x6035, .y = 0x0b, .x = 0x11},
+ {.src = 0x602f, .y = 0x0b, .x = 0x10},
+ {.src = 0x602e, .y = 0x0b, .x = 0x0f},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860dbf8[] =
+{
+ {.src = 0x6021, .y = 0x10, .x = 0x14},
+ {.src = 0x6025, .y = 0x10, .x = 0x13},
+ {.src = 0x6049, .y = 0x11, .x = 0x13},
+ {.src = 0x6021, .y = 0x11, .x = 0x12},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860dc08[] =
+{
+ {.src = 0x6021, .y = 0x10, .x = 0x14},
+ {.src = 0x6025, .y = 0x10, .x = 0x13},
+ {.src = 0x6049, .y = 0x11, .x = 0x13},
+ {.src = 0x6021, .y = 0x11, .x = 0x12},
+ {.src = 0x6029, .y = 0x10, .x = 0x12},
+ {.src = 0x6029, .y = 0x0f, .x = 0x12},
+ {.src = 0x6021, .y = 0x0f, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860dc24[] =
+{
+ {.src = 0x6021, .y = 0x10, .x = 0x14},
+ {.src = 0x6025, .y = 0x10, .x = 0x13},
+ {.src = 0x6049, .y = 0x11, .x = 0x13},
+ {.src = 0x6021, .y = 0x11, .x = 0x12},
+ {.src = 0x6029, .y = 0x10, .x = 0x12},
+ {.src = 0x6029, .y = 0x0f, .x = 0x12},
+ {.src = 0x6021, .y = 0x0f, .x = 0x11},
+ {.src = 0x6038, .y = 0x0e, .x = 0x11},
+ {.src = 0x6037, .y = 0x0d, .x = 0x11},
+ {.src = 0x6036, .y = 0x0c, .x = 0x11},
+ {.src = 0x6035, .y = 0x0b, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860dc50[] =
+{
+ {.src = 0x6021, .y = 0x10, .x = 0x14},
+ {.src = 0x6025, .y = 0x10, .x = 0x13},
+ {.src = 0x6049, .y = 0x11, .x = 0x13},
+ {.src = 0x6021, .y = 0x11, .x = 0x12},
+ {.src = 0x6029, .y = 0x10, .x = 0x12},
+ {.src = 0x6029, .y = 0x0f, .x = 0x12},
+ {.src = 0x6021, .y = 0x0f, .x = 0x11},
+ {.src = 0x6038, .y = 0x0e, .x = 0x11},
+ {.src = 0x6037, .y = 0x0d, .x = 0x11},
+ {.src = 0x6036, .y = 0x0c, .x = 0x11},
+ {.src = 0x6035, .y = 0x0b, .x = 0x11},
+ {.src = 0x602f, .y = 0x0b, .x = 0x10},
+ {.src = 0x602e, .y = 0x0b, .x = 0x0f},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860dc84[] =
+{
+ {.src = 0x602b, .y = 0x12, .x = 0x14},
+ {.src = 0x602b, .y = 0x12, .x = 0x13},
+ {.src = 0x6029, .y = 0x11, .x = 0x13},
+ {.src = 0x6021, .y = 0x11, .x = 0x12},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860dc94[] =
+{
+ {.src = 0x602b, .y = 0x12, .x = 0x14},
+ {.src = 0x602b, .y = 0x12, .x = 0x13},
+ {.src = 0x6029, .y = 0x11, .x = 0x13},
+ {.src = 0x6021, .y = 0x11, .x = 0x12},
+ {.src = 0x6029, .y = 0x10, .x = 0x12},
+ {.src = 0x6029, .y = 0x0f, .x = 0x12},
+ {.src = 0x6021, .y = 0x0f, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860dcb0[] =
+{
+ {.src = 0x602b, .y = 0x12, .x = 0x14},
+ {.src = 0x602b, .y = 0x12, .x = 0x13},
+ {.src = 0x6029, .y = 0x11, .x = 0x13},
+ {.src = 0x6021, .y = 0x11, .x = 0x12},
+ {.src = 0x6029, .y = 0x10, .x = 0x12},
+ {.src = 0x6029, .y = 0x0f, .x = 0x12},
+ {.src = 0x6021, .y = 0x0f, .x = 0x11},
+ {.src = 0x6038, .y = 0x0e, .x = 0x11},
+ {.src = 0x6037, .y = 0x0d, .x = 0x11},
+ {.src = 0x6036, .y = 0x0c, .x = 0x11},
+ {.src = 0x6035, .y = 0x0b, .x = 0x11},
+};
+
+static const struct UnkStruct_860DD10 gUnknown_0860dcdc[] =
+{
+ {.src = 0x602b, .y = 0x12, .x = 0x14},
+ {.src = 0x602b, .y = 0x12, .x = 0x13},
+ {.src = 0x6029, .y = 0x11, .x = 0x13},
+ {.src = 0x6021, .y = 0x11, .x = 0x12},
+ {.src = 0x6029, .y = 0x10, .x = 0x12},
+ {.src = 0x6029, .y = 0x0f, .x = 0x12},
+ {.src = 0x6021, .y = 0x0f, .x = 0x11},
+ {.src = 0x6038, .y = 0x0e, .x = 0x11},
+ {.src = 0x6037, .y = 0x0d, .x = 0x11},
+ {.src = 0x6036, .y = 0x0c, .x = 0x11},
+ {.src = 0x6035, .y = 0x0b, .x = 0x11},
+ {.src = 0x602f, .y = 0x0b, .x = 0x10},
+ {.src = 0x602e, .y = 0x0b, .x = 0x0f},
+};
+
+static const struct UnkStruct_860DD10 * const gUnknown_0860DD10[DOME_TOURNAMENT_TRAINERS_COUNT][4] =
+{
+ {gUnknown_0860d450, gUnknown_0860d460, gUnknown_0860d47c, gUnknown_0860d4a8},
+ {gUnknown_0860dc84, gUnknown_0860dc94, gUnknown_0860dcb0, gUnknown_0860dcdc},
+ {gUnknown_0860d8b0, gUnknown_0860d8c0, gUnknown_0860d8dc, gUnknown_0860d908},
+ {gUnknown_0860d824, gUnknown_0860d834, gUnknown_0860d850, gUnknown_0860d87c},
+ {gUnknown_0860d5f4, gUnknown_0860d604, gUnknown_0860d620, gUnknown_0860d64c},
+ {gUnknown_0860dae0, gUnknown_0860daf0, gUnknown_0860db0c, gUnknown_0860db38},
+ {gUnknown_0860da54, gUnknown_0860da64, gUnknown_0860da80, gUnknown_0860daac},
+ {gUnknown_0860d680, gUnknown_0860d690, gUnknown_0860d6ac, gUnknown_0860d6d8},
+ {gUnknown_0860d4dc, gUnknown_0860d4ec, gUnknown_0860d508, gUnknown_0860d534},
+ {gUnknown_0860dbf8, gUnknown_0860dc08, gUnknown_0860dc24, gUnknown_0860dc50},
+ {gUnknown_0860d93c, gUnknown_0860d94c, gUnknown_0860d968, gUnknown_0860d994},
+ {gUnknown_0860d798, gUnknown_0860d7a8, gUnknown_0860d7c4, gUnknown_0860d7f0},
+ {gUnknown_0860d568, gUnknown_0860d578, gUnknown_0860d594, gUnknown_0860d5c0},
+ {gUnknown_0860db6c, gUnknown_0860db7c, gUnknown_0860db98, gUnknown_0860dbc4},
+ {gUnknown_0860d9c8, gUnknown_0860d9d8, gUnknown_0860d9f4, gUnknown_0860da20},
+ {gUnknown_0860d70c, gUnknown_0860d71c, gUnknown_0860d738, gUnknown_0860d764},
+};
+
+static const u8 gUnknown_0860DE10[DOME_TOURNAMENT_TRAINERS_COUNT][4] =
+{
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+ {0x04, 0x07, 0x0b, 0x0d},
+};
+
+// code
+void CallBattleDomeFunction(void)
+{
+ gUnknown_0860D090[gSpecialVar_0x8004]();
+}
+
+static void sub_818E9CC(void)
+{
+ u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
+ u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
+
+ gSaveBlock2Ptr->frontier.field_CA8 = 0;
+ gSaveBlock2Ptr->frontier.field_CB2 = 0;
+ gSaveBlock2Ptr->frontier.field_CA9_a = 0;
+ gSaveBlock2Ptr->frontier.field_CA9_b = 0;
+ if (!(gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860D0EC[battleMode][lvlMode]))
+ gSaveBlock2Ptr->frontier.field_D0C[battleMode][lvlMode] = 0;
+
+ saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
+ gTrainerBattleOpponent_A = 0;
+}
+
+static void sub_818EA84(void)
+{
+ u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
+ u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
+
+ switch (gSpecialVar_0x8005)
+ {
+ case 0:
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D0C[battleMode][lvlMode];
+ break;
+ case 1:
+ gSpecialVar_Result = ((gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860D0EC[battleMode][lvlMode]) != 0);
+ break;
+ case 2:
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_0;
+ break;
+ case 3:
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_1;
+ break;
+ case 4:
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_2;
+ break;
+ case 5:
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_3;
+ break;
+ case 6:
+ if (VarGet(VAR_FRONTIER_BATTLE_MODE) == FRONTIER_MODE_DOUBLES)
+ {
+ if (lvlMode)
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_5;
+ else
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_4;
+ }
+ else
+ {
+ if (lvlMode)
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_1;
+ else
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_0;
+ }
+ break;
+ case 7:
+ if (VarGet(VAR_FRONTIER_BATTLE_MODE) == FRONTIER_MODE_DOUBLES)
+ {
+ if (lvlMode)
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_7;
+ else
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_6;
+ }
+ else
+ {
+ if (lvlMode)
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_3;
+ else
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_2;
+ }
+ break;
+ case 8:
+ sub_81B8558();
+ gUnknown_0203CEF8[0] = gSaveBlock2Ptr->frontier.field_CB0;
+ gUnknown_0203CEF8[1] = gSaveBlock2Ptr->frontier.field_CB0 >> 8;
+ break;
+ case 9:
+ gSpecialVar_Result = (gSaveBlock2Ptr->frontier.field_D0A * 2) - 3 + gSaveBlock2Ptr->frontier.field_D0B;
+ break;
+ }
+}
+
+static void sub_818ED28(void)
+{
+ u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
+ u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
+
+ switch (gSpecialVar_0x8005)
+ {
+ case 0:
+ gSaveBlock2Ptr->frontier.field_D0C[battleMode][lvlMode] = gSpecialVar_0x8006;
+ break;
+ case 1:
+ if (gSpecialVar_0x8006)
+ gSaveBlock2Ptr->frontier.field_CDC |= gUnknown_0860D0EC[battleMode][lvlMode];
+ else
+ gSaveBlock2Ptr->frontier.field_CDC &= gUnknown_0860D0FC[battleMode][lvlMode];
+ break;
+ case 2:
+ gSaveBlock2Ptr->frontier.field_D08_0 = gSpecialVar_0x8006;
+ break;
+ case 3:
+ gSaveBlock2Ptr->frontier.field_D08_1 = gSpecialVar_0x8006;
+ break;
+ case 4:
+ gSaveBlock2Ptr->frontier.field_D08_2 = gSpecialVar_0x8006;
+ break;
+ case 5:
+ gSaveBlock2Ptr->frontier.field_D08_3 = gSpecialVar_0x8006;
+ break;
+ case 6:
+ if (VarGet(VAR_FRONTIER_BATTLE_MODE) == FRONTIER_MODE_DOUBLES)
+ {
+ if (lvlMode)
+ gSaveBlock2Ptr->frontier.field_D08_5 = gSpecialVar_0x8006;
+ else
+ gSaveBlock2Ptr->frontier.field_D08_4 = gSpecialVar_0x8006;
+ }
+ else
+ {
+ if (lvlMode)
+ gSaveBlock2Ptr->frontier.field_D08_1 = gSpecialVar_0x8006;
+ else
+ gSaveBlock2Ptr->frontier.field_D08_0 = gSpecialVar_0x8006;
+ }
+ break;
+ case 7:
+ if (VarGet(VAR_FRONTIER_BATTLE_MODE) == FRONTIER_MODE_DOUBLES)
+ {
+ if (lvlMode)
+ gSaveBlock2Ptr->frontier.field_D08_7 = gSpecialVar_0x8006;
+ else
+ gSaveBlock2Ptr->frontier.field_D08_6 = gSpecialVar_0x8006;
+ }
+ else
+ {
+ if (lvlMode)
+ gSaveBlock2Ptr->frontier.field_D08_3 = gSpecialVar_0x8006;
+ else
+ gSaveBlock2Ptr->frontier.field_D08_2 = gSpecialVar_0x8006;
+ }
+ break;
+ case 8:
+ gSaveBlock2Ptr->frontier.field_CB0 = T1_READ_16(gUnknown_0203CEF8);
+ break;
+ }
+}
+
+static void InitDomeTrainers(void)
+{
+ s32 i, j, k;
+ s32 monLevel;
+ s32 species[3];
+ s32 monTypesBits, monTypesCount;
+ s32 trainerId;
+ s32 monTournamentId;
+ u16 *statSums;
+ s32 *statValues;
+ u8 ivs = 0;
+
+ species[0] = 0;
+ species[1] = 0;
+ species[2] = 0;
+ statSums = AllocZeroed(sizeof(u16) * DOME_TOURNAMENT_TRAINERS_COUNT);
+ statValues = AllocZeroed(sizeof(s32) * 6);
+
+ gSaveBlock2Ptr->frontier.field_D0A = gSaveBlock2Ptr->frontier.lvlMode + 1;
+ gSaveBlock2Ptr->frontier.field_D0B = VarGet(VAR_FRONTIER_BATTLE_MODE) + 1;
+ gSaveBlock2Ptr->frontier.domeTrainers[0].trainerId = TRAINER_PLAYER;
+ gSaveBlock2Ptr->frontier.domeTrainers[0].isEliminated = 0;
+ gSaveBlock2Ptr->frontier.domeTrainers[0].eliminatedAt = 0;
+ gSaveBlock2Ptr->frontier.domeTrainers[0].unk3 = 0;
+
+ for (i = 0; i < 3; i++)
+ {
+ gSaveBlock2Ptr->frontier.domeMonId[0][i] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.field_CAA[i] - 1], MON_DATA_SPECIES, NULL);
+ for (j = 0; j < 4; j++)
+ gSaveBlock2Ptr->frontier.field_EFC[i].moves[j] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.field_CAA[i] - 1], MON_DATA_MOVE1 + j, NULL);
+ for (j = 0; j < 6; j++)
+ gSaveBlock2Ptr->frontier.field_EFC[i].evs[j] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.field_CAA[i] - 1], MON_DATA_HP_EV + j, NULL);
+
+ gSaveBlock2Ptr->frontier.field_EFC[i].nature = GetNature(&gPlayerParty[gSaveBlock2Ptr->frontier.field_CAA[i] - 1]);
+ }
+
+ for (i = 1; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ if (i > 5)
+ {
+ do
+ {
+ trainerId = sub_8162548(sub_81A39C4(), 0);
+ for (j = 1; j < i; j++)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[j].trainerId == trainerId)
+ break;
+ }
+ } while (j != i);
+ gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId = trainerId;
+ }
+ else
+ {
+ do
+ {
+ trainerId = sub_8162548(sub_81A39C4() + 1, 0);
+ for (j = 1; j < i; j++)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[j].trainerId == trainerId)
+ break;
+ }
+ } while (j != i);
+ gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId = trainerId;
+ }
+
+ for (j = 0; j < 3; j++)
+ {
+ // Make sure the mon is valid.
+ do
+ {
+ monTournamentId = RandomizeFacilityTrainerMonId(trainerId);
+ for (k = 0; k < j; k++)
+ {
+ s32 checkingMonId = gSaveBlock2Ptr->frontier.domeMonId[i][k];
+ if (checkingMonId == monTournamentId
+ || species[0] == gFacilityTrainerMons[monTournamentId].species
+ || species[1] == gFacilityTrainerMons[monTournamentId].species
+ || gFacilityTrainerMons[checkingMonId].itemTableId == gFacilityTrainerMons[monTournamentId].itemTableId)
+ break;
+ }
+ } while (k != j);
+
+ gSaveBlock2Ptr->frontier.domeMonId[i][j] = monTournamentId;
+ species[j] = gFacilityTrainerMons[monTournamentId].species;
+ }
+
+ gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated = 0;
+ gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt = 0;
+ gSaveBlock2Ptr->frontier.domeTrainers[i].unk3 = 0;
+ }
+
+ monTypesBits = 0;
+ statSums[0] = 0;
+ for (i = 0; i < 3; i++)
+ {
+ trainerId = gSaveBlock2Ptr->frontier.field_CAA[i] - 1; // Great variable choice, gamefreak.
+ statSums[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_ATK, NULL);
+ statSums[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_DEF, NULL);
+ statSums[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_SPATK, NULL);
+ statSums[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_SPDEF, NULL);
+ statSums[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_SPEED, NULL);
+ statSums[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_MAX_HP, NULL);
+ monTypesBits |= gBitTable[gBaseStats[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].type1];
+ monTypesBits |= gBitTable[gBaseStats[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].type2];
+ }
+
+ for (monTypesCount = 0, j = 0; j < 32; j++)
+ {
+ if (monTypesBits & 1)
+ monTypesCount++;
+ monTypesBits >>= 1;
+ }
+
+ monLevel = GetFacilityEnemyMonLevel();
+ statSums[0] += (monTypesCount * monLevel) / 20;
+
+ for (i = 1; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ monTypesBits = 0;
+ statSums[i] = 0;
+ ivs = GetDomeTrainerMonIvs(gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId);
+ for (j = 0; j < 3; j++)
+ {
+ CalcDomeMonStats(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].species,
+ monLevel, ivs,
+ gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].evSpread,
+ gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].nature,
+ statValues);
+
+ statSums[i] += statValues[STAT_ATK];
+ statSums[i] += statValues[STAT_DEF];
+ statSums[i] += statValues[STAT_SPATK];
+ statSums[i] += statValues[STAT_SPDEF];
+ statSums[i] += statValues[STAT_SPEED];
+ statSums[i] += statValues[STAT_HP];
+ monTypesBits |= gBitTable[gBaseStats[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].species].type1];
+ monTypesBits |= gBitTable[gBaseStats[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].species].type2];
+ }
+
+ for (monTypesCount = 0, j = 0; j < 32; j++)
+ {
+ if (monTypesBits & 1)
+ monTypesCount++;
+ monTypesBits >>= 1;
+ }
+ statSums[i] += (monTypesCount * monLevel) / 20;
+ }
+
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT - 1; i++)
+ {
+ for (j = i + 1; j < DOME_TOURNAMENT_TRAINERS_COUNT; j++)
+ {
+ if (statSums[i] < statSums[j])
+ {
+ SwapDomeTrainers(i, j, statSums);
+ }
+ else
+ {
+ if (statSums[i] == statSums[j])
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[j].trainerId == TRAINER_PLAYER)
+ SwapDomeTrainers(i, j, statSums);
+ else if (gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId > gSaveBlock2Ptr->frontier.domeTrainers[j].trainerId)
+ SwapDomeTrainers(i, j, statSums);
+ }
+ }
+ }
+ }
+
+ if (sub_81A3610())
+ {
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId == TRAINER_PLAYER)
+ break;
+ }
+
+ if (gUnknown_0860D3F1[i][0] != 0)
+ {
+ j = 0;
+ gSaveBlock2Ptr->frontier.domeTrainers[j].trainerId = TRAINER_FRONTIER_BRAIN;
+ }
+ else
+ {
+ j = 1;
+ gSaveBlock2Ptr->frontier.domeTrainers[j].trainerId = TRAINER_FRONTIER_BRAIN;
+ }
+
+ for (i = 0; i < 3; i++)
+ gSaveBlock2Ptr->frontier.domeMonId[j][i] = sub_81A4FF0(i);
+ }
+
+ Free(statSums);
+ Free(statValues);
+}
+
+#define CALC_STAT(base, statIndex) \
+{ \
+ u8 baseStat = gBaseStats[species].base; \
+ stats[statIndex] = (((2 * baseStat + ivs + evs[statIndex] / 4) * level) / 100) + 5; \
+ stats[statIndex] = (u8) ModifyStatByNature(nature, stats[statIndex], statIndex); \
+}
+
+static void CalcDomeMonStats(u16 species, s32 level, s32 ivs, u8 evBits, u8 nature, s32 *stats)
+{
+ s32 i, count;
+ u8 bits;
+ u16 resultingEvs;
+ s32 evs[6];
+
+ count = 0, bits = evBits;
+ for (i = 0; i < 6; bits >>= 1, i++)
+ {
+ if (bits & 1)
+ count++;
+ }
+
+ resultingEvs = MAX_TOTAL_EVS / count;
+ for (i = 0; i < 6; bits <<= 1, i++)
+ {
+ evs[i] = 0;
+ if (evBits & bits)
+ evs[i] = resultingEvs;
+ }
+
+ if (species == SPECIES_SHEDINJA)
+ {
+ stats[STAT_HP] = 1;
+ }
+ else
+ {
+ s32 n = 2 * gBaseStats[species].baseHP;
+ stats[STAT_HP] = (((n + ivs + evs[STAT_HP] / 4) * level) / 100) + level + 10;
+ }
+
+ CALC_STAT(baseAttack, STAT_ATK);
+ CALC_STAT(baseDefense, STAT_DEF);
+ CALC_STAT(baseSpeed, STAT_SPEED);
+ CALC_STAT(baseSpAttack, STAT_SPATK);
+ CALC_STAT(baseSpDefense, STAT_SPDEF);
+}
+
+#define SWAP_16(x, y) \
+{ \
+ temp = x; \
+ x = y; \
+ y = temp; \
+}
+
+static void SwapDomeTrainers(s32 id1, s32 id2, u16 *statsArray)
+{
+ s32 i;
+ u16 temp;
+
+ SWAP_16(statsArray[id1], statsArray[id2]);
+ SWAP_16(gSaveBlock2Ptr->frontier.domeTrainers[id1].trainerId, gSaveBlock2Ptr->frontier.domeTrainers[id2].trainerId);
+
+ for (i = 0; i < 3; i++)
+ SWAP_16(gSaveBlock2Ptr->frontier.domeMonId[id1][i], gSaveBlock2Ptr->frontier.domeMonId[id2][i]);
+}
+
+static void sub_818F9B0(void)
+{
+ StringCopy(gStringVar1, gRoundsStringTable[gSaveBlock2Ptr->frontier.field_CB2]);
+}
+
+static void sub_818F9E0(void)
+{
+ StringCopy(gStringVar1, gRoundsStringTable[gSaveBlock2Ptr->frontier.field_CB2]);
+ CopyDomeTrainerName(gStringVar2, gTrainerBattleOpponent_A);
+}
+
+static void sub_818FA20(void)
+{
+ gUnknown_0203CD70 = 0;
+ gUnknown_0203CD74 = GetMonData(&gPlayerParty[0], MON_DATA_MAX_HP, NULL);
+ gUnknown_0203CD74 += GetMonData(&gPlayerParty[1], MON_DATA_MAX_HP, NULL);
+ CalculatePlayerPartyCount();
+ CreateDomeTrainerMons(TrainerIdToTournamentId(gTrainerBattleOpponent_A));
+}
+
+static void CreateDomeMon(u8 monPartyId, u16 tournamentTrainerId, u8 tournamentMonId, u32 otId)
+{
+ s32 i;
+ u8 happiness = 0xFF;
+ u8 fixedIv = GetDomeTrainerMonIvs(tournamentTrainerId); // BUG: Should be using trainerId instead of tournamentTrainerId. As a result, all Pokemon have ivs of 3.
+ u8 level = GetFacilityEnemyMonLevel();
+ CreateMonWithEVSpreadPersonalityOTID(&gEnemyParty[monPartyId],
+ gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].species,
+ level,
+ gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].nature,
+ fixedIv,
+ gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].evSpread, otId);
+
+ happiness = 0xFF;
+ for (i = 0; i < 4; i++)
+ {
+ SetMonMoveSlot(&gEnemyParty[monPartyId],
+ gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].moves[i], i);
+ if (gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].moves[i] == MOVE_FRUSTRATION)
+ happiness = 0;
+ }
+
+ SetMonData(&gEnemyParty[monPartyId], MON_DATA_FRIENDSHIP, &happiness);
+ SetMonData(&gEnemyParty[monPartyId], MON_DATA_HELD_ITEM,
+ &gBattleFrontierHeldItems[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].itemTableId]);
+}
+
+static void CreateDomeTrainerMons(u16 tournamentTrainerId)
+{
+ u8 monsCount = 0;
+ u32 otId = 0;
+ s32 i, bits;
+
+ ZeroEnemyPartyMons();
+ bits = GetTrainerMonCountInBits(tournamentTrainerId);
+ otId = Random32();
+ if (Random() % 10 > 5)
+ {
+ for (i = 0; i < 3; i++)
+ {
+ if (bits & 1)
+ {
+ CreateDomeMon(monsCount, tournamentTrainerId, i, otId);
+ monsCount++;
+ }
+ bits >>= 1;
+ }
+ }
+ else
+ {
+ for (i = 2; i >= 0; i--)
+ {
+ if (bits & 4)
+ {
+ CreateDomeMon(monsCount, tournamentTrainerId, i, otId);
+ monsCount++;
+ }
+ bits <<= 1;
+ }
+ }
+}
+
+s32 GetTrainerMonCountInBits(u16 tournamentTrainerId)
+{
+ s32 bits;
+ if (Random() & 1)
+ {
+ bits = sub_818FCBC(tournamentTrainerId, FALSE);
+ if (bits == 0)
+ bits = sub_818FDB8(tournamentTrainerId, TRUE);
+ }
+ else
+ {
+ bits = sub_818FDB8(tournamentTrainerId, FALSE);
+ if (bits == 0)
+ bits = sub_818FCBC(tournamentTrainerId, TRUE);
+ }
+
+ return bits;
+}
+
+static s32 sub_818FCBC(u16 tournamentTrainerId, bool8 arg1)
+{
+ s32 i, moveId, playerMonId;
+ s32 array[3];
+
+ for (i = 0; i < 3; i++)
+ {
+ array[i] = 0;
+ for (moveId = 0; moveId < 4; moveId++)
+ {
+ for (playerMonId = 0; playerMonId < 3; playerMonId++)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentTrainerId].trainerId == TRAINER_FRONTIER_BRAIN)
+ {
+ array[i] += GetTypeEffectivenessPoints(sub_81A5060(i, moveId),
+ GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), 0);
+ }
+ else
+ {
+ array[i] += GetTypeEffectivenessPoints(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][i]].moves[moveId],
+ GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), 0);
+ }
+ }
+ }
+ }
+ return sub_818FEB4(array, arg1);
+}
+
+static s32 sub_818FDB8(u16 tournamentTrainerId, bool8 arg1)
+{
+ s32 i, moveId, playerMonId;
+ s32 array[3];
+
+ for (i = 0; i < 3; i++)
+ {
+ array[i] = 0;
+ for (moveId = 0; moveId < 4; moveId++)
+ {
+ for (playerMonId = 0; playerMonId < 3; playerMonId++)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentTrainerId].trainerId == TRAINER_FRONTIER_BRAIN)
+ {
+ array[i] += GetTypeEffectivenessPoints(sub_81A5060(i, moveId),
+ GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), 1);
+ }
+ else
+ {
+ array[i] += GetTypeEffectivenessPoints(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][i]].moves[moveId],
+ GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), 1);
+ }
+ }
+ }
+ }
+ return sub_818FEB4(array, arg1);
+}
+
+static s32 sub_818FEB4(s32 *arr, bool8 arg1)
+{
+ s32 i, j;
+ s32 bits = 0;
+ s32 array[3];
+
+ for (i = 0; i < 3; i++)
+ array[i] = i;
+
+ if (arr[0] == arr[1] && arr[0] == arr[2])
+ {
+ if (arg1)
+ {
+ i = 0;
+ while (i != 2)
+ {
+ u32 rand = Random() & 3;
+ if (rand != 3 && !(bits & gBitTable[rand]))
+ {
+ bits |= gBitTable[rand];
+ i++;
+ }
+ }
+ }
+ }
+ else
+ {
+ for (i = 0; i < 2; i++)
+ {
+ for (j = i + 1; j < 3; j++)
+ {
+ s32 temp;
+
+ if (arr[i] < arr[j])
+ {
+ temp = arr[i];
+ arr[i] = arr[j];
+ arr[j] = temp;
+
+ temp = array[i];
+ array[i] = array[j];
+ array[j] = temp;
+ }
+
+ if (arr[i] == arr[j] && (Random() & 1))
+ {
+ temp = arr[i];
+ arr[i] = arr[j];
+ arr[j] = temp;
+
+ temp = array[i];
+ array[i] = array[j];
+ array[j] = temp;
+ }
+ }
+ }
+
+ for (i = 0; i < 2; i++)
+ {
+ bits |= gBitTable[array[i]];
+ }
+ }
+
+ return bits;
+}
+
+#define TYPE_x0 0
+#define TYPE_x0_25 5
+#define TYPE_x0_50 10
+#define TYPE_x1 20
+#define TYPE_x2 40
+#define TYPE_x4 80
+
+// Functionally equivalent, while loop is impossible to match.
+#ifdef NONMATCHING
+static s32 GetTypeEffectivenessPoints(s32 move, s32 targetSpecies, s32 arg2)
+{
+ s32 defType1, defType2, defAbility, moveType;
+ s32 i = 0;
+ s32 typePower = TYPE_x1;
+
+ if (move == MOVE_NONE || move == 0xFFFF || gBattleMoves[move].power == 0)
+ return 0;
+
+ defType1 = gBaseStats[targetSpecies].type1;
+ defType2 = gBaseStats[targetSpecies].type2;
+ defAbility = gBaseStats[targetSpecies].ability1;
+ moveType = gBattleMoves[move].type;
+
+ if (defAbility == ABILITY_LEVITATE && moveType == TYPE_GROUND)
+ {
+ if (arg2 == 1)
+ typePower = 8;
+ }
+ else
+ {
+ while (gTypeEffectiveness[i + 0] != TYPE_ENDTABLE)
+ {
+ if (gTypeEffectiveness[i + 0] == TYPE_FORESIGHT)
+ {
+ i += 3;
+ }
+ else
+ {
+ u8 val = gTypeEffectiveness[i + 0];
+ if (val == moveType)
+ {
+ // BUG: * 2 is not necessary and makes the condition always false if the ability is wonder guard.
+ if (gTypeEffectiveness[i + 1] == defType1 && (defAbility != ABILITY_WONDER_GUARD || gTypeEffectiveness[i + 2] == TYPE_MUL_SUPER_EFFECTIVE * 2))
+ typePower = (gTypeEffectiveness[i + 2] * typePower) / 10;
+ if (gTypeEffectiveness[i + 1] == defType2 && defType1 != defType2 && (defAbility != ABILITY_WONDER_GUARD || gTypeEffectiveness[i + 2] == TYPE_MUL_SUPER_EFFECTIVE * 2))
+ typePower = (gTypeEffectiveness[i + 2] * typePower) / 10;
+ }
+ i += 3;
+ }
+ }
+ }
+
+ switch (arg2)
+ {
+ case 0:
+ switch (typePower)
+ {
+ case 10:
+ case 5:
+ case 0:
+ default:
+ typePower = 0;
+ break;
+ case 20:
+ typePower = 2;
+ break;
+ case 40:
+ typePower = 4;
+ break;
+ case 80:
+ typePower = 8;
+ break;
+ }
+ break;
+ case 1:
+ switch (typePower)
+ {
+ default:
+ case 20:
+ typePower = 0;
+ break;
+ case 5:
+ typePower = 4;
+ break;
+ case 0:
+ typePower = 8;
+ break;
+ case 10:
+ typePower = 2;
+ break;
+ case 40:
+ typePower = -2;
+ break;
+ case 80:
+ typePower = -4;
+ break;
+ }
+ break;
+ case 2:
+ switch (typePower)
+ {
+ case TYPE_x0:
+ typePower = -16;
+ break;
+ case TYPE_x0_25:
+ typePower = -8;
+ break;
+ case TYPE_x0_50:
+ default:
+ typePower = 0;
+ break;
+ case TYPE_x1:
+ typePower = 4;
+ break;
+ case TYPE_x2:
+ typePower = 12;
+ break;
+ case TYPE_x4:
+ typePower = 20;
+ break;
+ }
+ break;
+ }
+
+ return typePower;
+}
+#else
+NAKED
+static s32 GetTypeEffectivenessPoints(s32 move, s32 species, s32 arg2)
+{
+ asm_unified("\n\
+ push {r4-r7,lr}\n\
+ mov r7, r10\n\
+ mov r6, r9\n\
+ mov r5, r8\n\
+ push {r5-r7}\n\
+ sub sp, 0x8\n\
+ adds r3, r0, 0\n\
+ adds r4, r1, 0\n\
+ str r2, [sp]\n\
+ movs r6, 0\n\
+ movs r2, 0x14\n\
+ cmp r3, 0\n\
+ beq _0818FFF0\n\
+ ldr r0, =0x0000ffff\n\
+ cmp r3, r0\n\
+ beq _0818FFF0\n\
+ ldr r0, =gBattleMoves\n\
+ lsls r1, r3, 1\n\
+ adds r1, r3\n\
+ lsls r1, 2\n\
+ adds r3, r1, r0\n\
+ ldrb r0, [r3, 0x1]\n\
+ cmp r0, 0\n\
+ bne _0818FFFC\n\
+_0818FFF0:\n\
+ movs r0, 0\n\
+ b _08190156\n\
+ .pool\n\
+_0818FFFC:\n\
+ ldr r1, =gBaseStats\n\
+ lsls r0, r4, 3\n\
+ subs r0, r4\n\
+ lsls r0, 2\n\
+ adds r0, r1\n\
+ ldrb r1, [r0, 0x6]\n\
+ mov r10, r1\n\
+ ldrb r1, [r0, 0x7]\n\
+ mov r9, r1\n\
+ ldrb r0, [r0, 0x16]\n\
+ mov r8, r0\n\
+ ldrb r3, [r3, 0x2]\n\
+ str r3, [sp, 0x4]\n\
+ cmp r0, 0x1A\n\
+ bne _0819002C\n\
+ cmp r3, 0x4\n\
+ bne _0819002C\n\
+ ldr r0, [sp]\n\
+ cmp r0, 0x1\n\
+ bne _081900AA\n\
+ movs r2, 0x8\n\
+ b _081900A4\n\
+ .pool\n\
+_0819002C:\n\
+ ldr r0, =gTypeEffectiveness\n\
+ adds r1, r6, r0\n\
+ ldrb r0, [r1]\n\
+ ldr r7, =gTypeEffectiveness\n\
+ cmp r0, 0xFF\n\
+ beq _081900A4\n\
+ adds r4, r1, 0\n\
+_0819003A:\n\
+ ldrb r0, [r4]\n\
+ cmp r0, 0xFE\n\
+ beq _08190096\n\
+ ldrb r0, [r4]\n\
+ ldr r1, [sp, 0x4]\n\
+ cmp r0, r1\n\
+ bne _08190096\n\
+ ldrb r0, [r4, 0x1]\n\
+ adds r5, r6, 0x1\n\
+ cmp r0, r10\n\
+ bne _0819006C\n\
+ adds r1, r6, 0x2\n\
+ mov r0, r8\n\
+ cmp r0, 0x19\n\
+ bne _0819005E\n\
+ ldrb r0, [r4, 0x2]\n\
+ cmp r0, 0x28\n\
+ bne _0819006C\n\
+_0819005E:\n\
+ adds r0, r1, r7\n\
+ ldrb r0, [r0]\n\
+ muls r0, r2\n\
+ movs r1, 0xA\n\
+ bl __divsi3\n\
+ adds r2, r0, 0\n\
+_0819006C:\n\
+ adds r0, r5, r7\n\
+ ldrb r0, [r0]\n\
+ cmp r0, r9\n\
+ bne _08190096\n\
+ cmp r10, r9\n\
+ beq _08190096\n\
+ adds r1, r6, 0x2\n\
+ mov r0, r8\n\
+ cmp r0, 0x19\n\
+ bne _08190088\n\
+ adds r0, r1, r7\n\
+ ldrb r0, [r0]\n\
+ cmp r0, 0x28\n\
+ bne _08190096\n\
+_08190088:\n\
+ adds r0, r1, r7\n\
+ ldrb r0, [r0]\n\
+ muls r0, r2\n\
+ movs r1, 0xA\n\
+ bl __divsi3\n\
+ adds r2, r0, 0\n\
+_08190096:\n\
+ adds r4, 0x3\n\
+ adds r6, 0x3\n\
+ ldr r1, =gTypeEffectiveness\n\
+ adds r0, r6, r1\n\
+ ldrb r0, [r0]\n\
+ cmp r0, 0xFF\n\
+ bne _0819003A\n\
+_081900A4:\n\
+ ldr r0, [sp]\n\
+ cmp r0, 0x1\n\
+ beq _081900E0\n\
+_081900AA:\n\
+ ldr r1, [sp]\n\
+ cmp r1, 0x1\n\
+ bgt _081900BC\n\
+ cmp r1, 0\n\
+ beq _081900C4\n\
+ b _08190154\n\
+ .pool\n\
+_081900BC:\n\
+ ldr r0, [sp]\n\
+ cmp r0, 0x2\n\
+ beq _08190114\n\
+ b _08190154\n\
+_081900C4:\n\
+ cmp r2, 0xA\n\
+ beq _08190146\n\
+ cmp r2, 0xA\n\
+ ble _08190146\n\
+ cmp r2, 0x28\n\
+ beq _0819014A\n\
+ cmp r2, 0x28\n\
+ bgt _081900DA\n\
+ cmp r2, 0x14\n\
+ beq _08190104\n\
+ b _08190146\n\
+_081900DA:\n\
+ cmp r2, 0x50\n\
+ bne _08190146\n\
+ b _08190100\n\
+_081900E0:\n\
+ cmp r2, 0xA\n\
+ beq _08190104\n\
+ cmp r2, 0xA\n\
+ bgt _081900F2\n\
+ cmp r2, 0\n\
+ beq _08190100\n\
+ cmp r2, 0x5\n\
+ beq _0819014A\n\
+ b _08190146\n\
+_081900F2:\n\
+ cmp r2, 0x28\n\
+ beq _08190108\n\
+ cmp r2, 0x28\n\
+ ble _08190146\n\
+ cmp r2, 0x50\n\
+ beq _0819010E\n\
+ b _08190146\n\
+_08190100:\n\
+ movs r2, 0x8\n\
+ b _08190154\n\
+_08190104:\n\
+ movs r2, 0x2\n\
+ b _08190154\n\
+_08190108:\n\
+ movs r2, 0x2\n\
+ negs r2, r2\n\
+ b _08190154\n\
+_0819010E:\n\
+ movs r2, 0x4\n\
+ negs r2, r2\n\
+ b _08190154\n\
+_08190114:\n\
+ cmp r2, 0xA\n\
+ beq _08190146\n\
+ cmp r2, 0xA\n\
+ bgt _08190126\n\
+ cmp r2, 0\n\
+ beq _0819013A\n\
+ cmp r2, 0x5\n\
+ beq _08190140\n\
+ b _08190146\n\
+_08190126:\n\
+ cmp r2, 0x28\n\
+ beq _0819014E\n\
+ cmp r2, 0x28\n\
+ bgt _08190134\n\
+ cmp r2, 0x14\n\
+ beq _0819014A\n\
+ b _08190146\n\
+_08190134:\n\
+ cmp r2, 0x50\n\
+ beq _08190152\n\
+ b _08190146\n\
+_0819013A:\n\
+ movs r2, 0x10\n\
+ negs r2, r2\n\
+ b _08190154\n\
+_08190140:\n\
+ movs r2, 0x8\n\
+ negs r2, r2\n\
+ b _08190154\n\
+_08190146:\n\
+ movs r2, 0\n\
+ b _08190154\n\
+_0819014A:\n\
+ movs r2, 0x4\n\
+ b _08190154\n\
+_0819014E:\n\
+ movs r2, 0xC\n\
+ b _08190154\n\
+_08190152:\n\
+ movs r2, 0x14\n\
+_08190154:\n\
+ adds r0, r2, 0\n\
+_08190156:\n\
+ add sp, 0x8\n\
+ pop {r3-r5}\n\
+ mov r8, r3\n\
+ mov r9, r4\n\
+ mov r10, r5\n\
+ pop {r4-r7}\n\
+ pop {r1}\n\
+ bx r1\n\
+ ");
+}
+#endif // NONMATCHING
+
+static u8 GetDomeTrainerMonIvs(u16 trainerId)
+{
+ u8 fixedIv;
+ if (trainerId <= 99)
+ fixedIv = 3;
+ else if (trainerId <= 119)
+ fixedIv = 6;
+ else if (trainerId <= 139)
+ fixedIv = 9;
+ else if (trainerId <= 159)
+ fixedIv = 12;
+ else if (trainerId <= 179)
+ fixedIv = 15;
+ else if (trainerId <= 199)
+ fixedIv = 18;
+ else if (trainerId <= 219)
+ fixedIv = 21;
+ else
+ fixedIv = 31;
+
+ return fixedIv;
+}
+
+static s32 TournamentIdOfOpponent(s32 roundId, s32 trainerId)
+{
+ s32 i, j, val;
+
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId == trainerId)
+ break;
+ }
+
+ if (roundId != DOME_ROUND1)
+ {
+ if (roundId == DOME_FINAL)
+ val = sIdToOpponentId[i][roundId] + 8;
+ else
+ val = sIdToOpponentId[i][roundId] + 4;
+
+ for (j = sIdToOpponentId[i][roundId]; j < val; j++)
+ {
+ if (gUnknown_0860D14C[j] != i && !gSaveBlock2Ptr->frontier.domeTrainers[gUnknown_0860D14C[j]].isEliminated)
+ break;
+ }
+
+ if (j != val)
+ return gUnknown_0860D14C[j];
+ else
+ return 0xFF;
+ }
+ else
+ {
+ if (!gSaveBlock2Ptr->frontier.domeTrainers[sIdToOpponentId[i][roundId]].isEliminated)
+ return sIdToOpponentId[i][roundId];
+ else
+ return 0xFF;
+ }
+}
+
+static void sub_8190298(void)
+{
+ gTrainerBattleOpponent_A = TrainerIdOfPlayerOpponent();
+}
+
+static u16 TrainerIdOfPlayerOpponent(void)
+{
+ return gSaveBlock2Ptr->frontier.domeTrainers[TournamentIdOfOpponent(gSaveBlock2Ptr->frontier.field_CB2, TRAINER_PLAYER)].trainerId;
+}
+
+static void sub_81902E4(void)
+{
+ sub_8162614(gTrainerBattleOpponent_A, 0);
+}
+
+static void sub_81902F8(void)
+{
+ gSaveBlock2Ptr->frontier.field_CA8 = gSpecialVar_0x8005;
+ VarSet(VAR_TEMP_0, 0);
+ gSaveBlock2Ptr->frontier.field_CA9_a = 1;
+ sub_81A4C30();
+}
+
+static void sub_819033C(void)
+{
+ u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
+ u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
+
+ if (gSaveBlock2Ptr->frontier.field_D0C[battleMode][lvlMode] < 999)
+ gSaveBlock2Ptr->frontier.field_D0C[battleMode][lvlMode]++;
+ if (gSaveBlock2Ptr->frontier.field_D1C[battleMode][lvlMode] < 999)
+ gSaveBlock2Ptr->frontier.field_D1C[battleMode][lvlMode]++;
+
+ if (gSaveBlock2Ptr->frontier.field_D0C[battleMode][lvlMode] > gSaveBlock2Ptr->frontier.field_D14[battleMode][lvlMode])
+ gSaveBlock2Ptr->frontier.field_D14[battleMode][lvlMode] = gSaveBlock2Ptr->frontier.field_D0C[battleMode][lvlMode];
+}
+
+static void ShowDomeOpponentInfo(void)
+{
+ u8 taskId = CreateTask(sub_8190400, 0);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = TrainerIdToTournamentId(TrainerIdOfPlayerOpponent());
+ gTasks[taskId].data[2] = 0;
+ gTasks[taskId].data[3] = 0;
+
+ SetMainCallback2(CB2_BattleDome);
+}
+
+static void sub_8190400(u8 taskId)
+{
+ s32 i;
+ s32 r5 = gTasks[taskId].data[1];
+ s32 r9 = gTasks[taskId].data[2];
+ s32 r7 = gTasks[taskId].data[3];
+
+ switch (gTasks[taskId].data[0])
+ {
+ case 0:
+ SetHBlankCallback(NULL);
+ SetVBlankCallback(NULL);
+ EnableInterrupts(INTR_FLAG_VBLANK);
+ CpuFill32(0, (void *)VRAM, VRAM_SIZE);
+ ResetBgsAndClearDma3BusyFlags(0);
+ InitBgsFromTemplates(0, gUnknown_0860CE84, ARRAY_COUNT(gUnknown_0860CE84));
+ InitWindows(gUnknown_0860CEB4);
+ DeactivateAllTextPrinters();
+ gBattle_BG0_X = 0;
+ gBattle_BG0_Y = 0;
+ gBattle_BG1_X = 0;
+ gBattle_BG1_Y = 0;
+ gBattle_BG3_X = 0;
+ gBattle_BG3_Y = 0;
+ if (r9 == 2)
+ gBattle_BG2_X = 0, gBattle_BG2_Y = 0;
+ else
+ gBattle_BG2_X = 0, gBattle_BG2_Y = 160;
+
+ gTasks[taskId].data[0]++;
+ break;
+ case 1:
+ SetGpuReg(REG_OFFSET_BLDCNT, 0);
+ SetGpuReg(REG_OFFSET_BLDALPHA, 0);
+ SetGpuReg(REG_OFFSET_BLDY, 0);
+ SetGpuReg(REG_OFFSET_MOSAIC, 0);
+ SetGpuReg(REG_OFFSET_WIN0H, 0);
+ SetGpuReg(REG_OFFSET_WIN0V, 0);
+ SetGpuReg(REG_OFFSET_WIN1H, 0);
+ SetGpuReg(REG_OFFSET_WIN1V, 0);
+ SetGpuReg(REG_OFFSET_WININ, 0);
+ SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
+ ResetPaletteFade();
+ ResetSpriteData();
+ FreeAllSpritePalettes();
+ gReservedSpritePaletteCount = 4;
+ gTasks[taskId].data[0]++;
+ break;
+ case 2:
+ DecompressAndLoadBgGfxUsingHeap(2, gUnknown_08D83D50, 0x2000, 0, 0);
+ DecompressAndLoadBgGfxUsingHeap(2, gUnknown_08D84970, 0x2000, 0, 1);
+ DecompressAndLoadBgGfxUsingHeap(3, gUnknown_08D84F00, 0x800, 0, 1);
+ LoadCompressedObjectPic(gUnknown_0860CF50);
+ LoadCompressedPalette(gUnknown_08D85358, 0, 0x200);
+ LoadCompressedPalette(gUnknown_08D85444, 0x100, 0x200);
+ LoadCompressedPalette(gUnknown_08D85600, 0xF0, 0x20);
+ if (r9 == 2)
+ LoadCompressedPalette(gUnknown_08D854C8, 0x50, 0x20);
+ CpuFill32(0, gPlttBufferFaded, 0x400);
+ ShowBg(0);
+ ShowBg(1);
+ ShowBg(2);
+ ShowBg(3);
+ gTasks[taskId].data[0]++;
+ break;
+ case 3:
+ SetVBlankCallback(VblankCb0_BattleDome);
+ sBattleDomeStruct = AllocZeroed(sizeof(*sBattleDomeStruct));
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ sBattleDomeStruct->arr[i] |= 0xFF;
+ LoadMonIconPalettes();
+ i = CreateTask(sub_8190CD4, 0);
+ gTasks[i].data[0] = 0;
+ gTasks[i].data[2] = 0;
+ gTasks[i].data[3] = r9;
+ gTasks[i].data[4] = r7;
+ if (r9 == 2)
+ {
+ DisplayMatchInfoOnCard(0, r5);
+ sBattleDomeStruct->unk_10 = 1;
+ }
+ else
+ {
+ DisplayTrainerInfoOnCard(0, r5);
+ }
+ SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_1D_MAP);
+ if (r9 != 0)
+ {
+ r7 = CreateSprite(&gUnknown_0860D068, 120, 4, 0);
+ StartSpriteAnim(&gSprites[r7], 0);
+ gSprites[r7].data[0] = i;
+
+ r7 = CreateSprite(&gUnknown_0860D068, 120, 156, 0);
+ StartSpriteAnim(&gSprites[r7], 1);
+ gSprites[r7].data[0] = i;
+
+ r7 = CreateSprite(&gUnknown_0860D050, 6, 80, 0);
+ StartSpriteAnim(&gSprites[r7], 0);
+ gSprites[r7].data[0] = i;
+ gSprites[r7].data[1] = 0;
+ if (r9 == 1)
+ gSprites[r7].invisible = 1;
+
+ r7 = CreateSprite(&gUnknown_0860D050, 234, 80, 0);
+ StartSpriteAnim(&gSprites[r7], 1);
+ gSprites[r7].data[0] = i;
+ gSprites[r7].data[1] = 1;
+ }
+ DestroyTask(taskId);
+ break;
+ }
+}
+
+// Note: Card scrolling up means the current card goes down and another one appears from top.
+// The same is true for scrolling left.
+// That means that the sprite needs to move with the moving card in the opposite scrolling direction.
+
+static void SpriteCb_TrainerIconCardScrollUp(struct Sprite *sprite)
+{
+ sprite->pos1.y += 4;
+ if (sprite->data[0] != 0)
+ {
+ if (sprite->pos1.y >= -32)
+ sprite->invisible = 0;
+ if (++sprite->data[1] == 40)
+ sprite->callback = SpriteCallbackDummy;
+ }
+ else
+ {
+ if (sprite->pos1.y >= 192)
+ {
+ sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ FreeAndDestroyTrainerPicSprite(sprite->data[3]);
+ }
+ }
+}
+
+static void SpriteCb_TrainerIconCardScrollDown(struct Sprite *sprite)
+{
+ sprite->pos1.y -= 4;
+ if (sprite->data[0] != 0)
+ {
+ if (sprite->pos1.y <= 192)
+ sprite->invisible = 0;
+ if (++sprite->data[1] == 40)
+ sprite->callback = SpriteCallbackDummy;
+ }
+ else
+ {
+ if (sprite->pos1.y <= -32)
+ {
+ sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ FreeAndDestroyTrainerPicSprite(sprite->data[3]);
+ }
+ }
+}
+
+static void SpriteCb_TrainerIconCardScrollLeft(struct Sprite *sprite)
+{
+ sprite->pos1.x += 4;
+ if (sprite->data[0] != 0)
+ {
+ if (sprite->pos1.x >= -32)
+ sprite->invisible = 0;
+ if (++sprite->data[1] == 64)
+ sprite->callback = SpriteCallbackDummy;
+ }
+ else
+ {
+ if (sprite->pos1.x >= 272)
+ {
+ sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ FreeAndDestroyTrainerPicSprite(sprite->data[3]);
+ }
+ }
+}
+
+static void SpriteCb_TrainerIconCardScrollRight(struct Sprite *sprite)
+{
+ sprite->pos1.x -= 4;
+ if (sprite->data[0] != 0)
+ {
+ if (sprite->pos1.x <= 272)
+ sprite->invisible = 0;
+ if (++sprite->data[1] == 64)
+ sprite->callback = SpriteCallbackDummy;
+ }
+ else
+ {
+ if (sprite->pos1.x <= -32)
+ {
+ sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ FreeAndDestroyTrainerPicSprite(sprite->data[3]);
+ }
+ }
+}
+
+#define sMonIconStill data[3]
+
+static void SpriteCb_MonIcon(struct Sprite *sprite)
+{
+ if (!sprite->sMonIconStill)
+ UpdateMonIconFrame(sprite);
+}
+
+static void SpriteCb_MonIconCardScrollUp(struct Sprite *sprite)
+{
+ if (!sprite->sMonIconStill)
+ UpdateMonIconFrame(sprite);
+ sprite->pos1.y += 4;
+ if (sprite->data[0] != 0)
+ {
+ if (sprite->pos1.y >= -16)
+ sprite->invisible = 0;
+ if (++sprite->data[1] == 40)
+ sprite->callback = SpriteCb_MonIcon;
+ }
+ else
+ {
+ if (sprite->pos1.y >= 176)
+ {
+ sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ sub_80D2EF8(sprite);
+ }
+ }
+}
+
+static void SpriteCb_MonIconCardScrollDown(struct Sprite *sprite)
+{
+ if (!sprite->sMonIconStill)
+ UpdateMonIconFrame(sprite);
+ sprite->pos1.y -= 4;
+ if (sprite->data[0] != 0)
+ {
+ if (sprite->pos1.y <= 176)
+ sprite->invisible = 0;
+ if (++sprite->data[1] == 40)
+ sprite->callback = SpriteCb_MonIcon;
+ }
+ else
+ {
+ if (sprite->pos1.y <= -16)
+ {
+ sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ sub_80D2EF8(sprite);
+ }
+ }
+}
+
+static void SpriteCb_MonIconCardScrollLeft(struct Sprite *sprite)
+{
+ if (!sprite->sMonIconStill)
+ UpdateMonIconFrame(sprite);
+ sprite->pos1.x += 4;
+ if (sprite->data[0] != 0)
+ {
+ if (sprite->pos1.x >= -16)
+ sprite->invisible = 0;
+ if (++sprite->data[1] == 64)
+ sprite->callback = SpriteCb_MonIcon;
+ }
+ else
+ {
+ if (sprite->pos1.x >= 256)
+ {
+ sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ sub_80D2EF8(sprite);
+ }
+ }
+}
+
+static void SpriteCb_MonIconCardScrollRight(struct Sprite *sprite)
+{
+ if (!sprite->sMonIconStill)
+ UpdateMonIconFrame(sprite);
+ sprite->pos1.x -= 4;
+ if (sprite->data[0] != 0)
+ {
+ if (sprite->pos1.x <= 256)
+ sprite->invisible = 0;
+ if (++sprite->data[1] == 64)
+ sprite->callback = SpriteCb_MonIcon;
+ }
+ else
+ {
+ if (sprite->pos1.x <= -16)
+ {
+ sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ sub_80D2EF8(sprite);
+ }
+ }
+}
+
+static void sub_8190B40(struct Sprite *sprite)
+{
+ s32 taskId1 = sprite->data[0];
+ s32 arrId = gTasks[gTasks[taskId1].data[4]].data[1];
+ s32 tournmanetTrainerId = gUnknown_0860D080[arrId];
+ s32 r12 = gSaveBlock2Ptr->frontier.field_CB2;
+
+ if (gTasks[taskId1].data[3] == 1)
+ {
+ if (sprite->data[1])
+ {
+ if ((gSaveBlock2Ptr->frontier.domeTrainers[tournmanetTrainerId].isEliminated
+ && sBattleDomeStruct->unk_10 - 1 < gSaveBlock2Ptr->frontier.domeTrainers[tournmanetTrainerId].eliminatedAt))
+ {
+ sprite->invisible = 0;
+ }
+ else if (!gSaveBlock2Ptr->frontier.domeTrainers[tournmanetTrainerId].isEliminated
+ && sBattleDomeStruct->unk_10 - 1 < r12)
+ {
+ sprite->invisible = 0;
+ }
+ else
+ {
+ if (gTasks[taskId1].data[0] == 2)
+ sprite->invisible = 1;
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->unk_10 != 0)
+ {
+ sprite->invisible = 0;
+ }
+ else
+ {
+ if (gTasks[taskId1].data[0] == 2)
+ sprite->invisible = 1;
+ }
+ }
+ }
+ else
+ {
+ if (sprite->data[1])
+ {
+ if (sBattleDomeStruct->unk_10 > 1)
+ {
+ if (gTasks[taskId1].data[0] == 2)
+ sprite->invisible = 1;
+ }
+ else
+ {
+ sprite->invisible = 0;
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->unk_10 != 0)
+ {
+ sprite->invisible = 0;
+ }
+ else
+ {
+ if (gTasks[taskId1].data[0] == 2)
+ sprite->invisible = 1;
+ }
+ }
+ }
+}
+
+static void sub_8190C6C(struct Sprite *sprite)
+{
+ s32 taskId1 = sprite->data[0];
+
+ if (gTasks[taskId1].data[3] == 1)
+ {
+ if (sBattleDomeStruct->unk_10 != 0)
+ {
+ if (gTasks[taskId1].data[0] == 2)
+ sprite->invisible = 1;
+ }
+ else
+ {
+ sprite->invisible = 0;
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->unk_10 != 1)
+ {
+ if (gTasks[taskId1].data[0] == 2)
+ sprite->invisible = 1;
+ }
+ else
+ {
+ sprite->invisible = 0;
+ }
+ }
+}
+
+static void sub_8190CD4(u8 taskId)
+{
+ s32 i;
+ s32 windowId = 0;
+ s32 r9 = gTasks[taskId].data[3];
+ s32 taskId2 = gTasks[taskId].data[4];
+ s32 trainerTournamentId = 0;
+ s32 matchNo = 0;
+
+ switch (gTasks[taskId].data[0])
+ {
+ case 0:
+ if (!gPaletteFade.active)
+ {
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK);
+ gTasks[taskId].data[0] = 1;
+ }
+ break;
+ case 1:
+ if (!gPaletteFade.active)
+ gTasks[taskId].data[0] = 2;
+ break;
+ case 2:
+ i = sub_819221C(taskId);
+ switch (i)
+ {
+ case 9:
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
+ gTasks[taskId].data[0] = 8;
+ break;
+ case 1 ... 8:
+ gTasks[taskId].data[5] = i;
+ if (gTasks[taskId].data[2] != 0)
+ windowId = 9;
+ else
+ windowId = 0;
+
+ for (i = windowId; i < windowId + 9; i++)
+ {
+ CopyWindowToVram(i, 2);
+ FillWindowPixelBuffer(i, 0);
+ }
+ gTasks[taskId].data[0] = 3;
+ break;
+ case 0:
+ break;
+ }
+ break;
+ case 3:
+ i = gTasks[taskId].data[5];
+ switch (i)
+ {
+ case 1:
+ case 5:
+ if (gTasks[taskId].data[2])
+ {
+ gBattle_BG0_X = 0;
+ gBattle_BG0_Y = 0;
+ gBattle_BG1_X = 0;
+ gBattle_BG1_Y = 160;
+ }
+ else
+ {
+ gBattle_BG0_X = 0;
+ gBattle_BG0_Y = 160;
+ gBattle_BG1_X = 0;
+ gBattle_BG1_Y = 0;
+ }
+
+ if (i == 1)
+ {
+ if (sBattleDomeStruct->unk_10 == 0)
+ {
+ gBattle_BG2_X = 0;
+ gBattle_BG2_Y = 320;
+ trainerTournamentId = gUnknown_0860D080[gTasks[taskId2].data[1]];
+ DisplayTrainerInfoOnCard(gTasks[taskId].data[2] | 0x10, trainerTournamentId);
+ }
+ else
+ {
+ gBattle_BG2_X = 256;
+ gBattle_BG2_Y = 0;
+ trainerTournamentId = gUnknown_0860D080[gTasks[taskId2].data[1]];
+ DisplayTrainerInfoOnCard(gTasks[taskId].data[2] | 0x10, trainerTournamentId);
+ sBattleDomeStruct->unk_10 = 0;
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->unk_10 == 0)
+ {
+ matchNo = gTasks[taskId2].data[1] - 16;
+ sub_8192F08(matchNo, sBattleDomeStruct->unk_11);
+ gBattle_BG2_X = 0;
+ gBattle_BG2_Y = 320;
+ trainerTournamentId = sBattleDomeStruct->unk_11[0];
+ DisplayTrainerInfoOnCard(gTasks[taskId].data[2] | 0x10, trainerTournamentId);
+ }
+ else if (sBattleDomeStruct->unk_10 == 2)
+ {
+ matchNo = gTasks[taskId2].data[1] - 16;
+ sub_8192F08(matchNo, sBattleDomeStruct->unk_11);
+ gBattle_BG2_X = 0;
+ gBattle_BG2_Y = 320;
+ trainerTournamentId = sBattleDomeStruct->unk_11[1];
+ DisplayTrainerInfoOnCard(gTasks[taskId].data[2] | 0x10, trainerTournamentId);
+ }
+ else
+ {
+ gBattle_BG2_X = 256;
+ gBattle_BG2_Y = 160;
+ matchNo = gTasks[taskId2].data[1] - 16;
+ DisplayMatchInfoOnCard(gTasks[taskId].data[2] | 0x10, matchNo);
+ }
+ }
+
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++)
+ {
+ if (i < 2)
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollUp;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ gSprites[sBattleDomeStruct->arr[i]].data[3] = sBattleDomeStruct->arr[i];
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollUp;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ }
+ }
+ }
+ for (i = DOME_TOURNAMENT_TRAINERS_COUNT / 2; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ if (i < 10)
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollUp;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ gSprites[sBattleDomeStruct->arr[i]].data[3] = sBattleDomeStruct->arr[i];
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollUp;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ }
+ }
+ }
+
+ gTasks[taskId].data[0] = 4;
+ gTasks[taskId].data[5] = 0;
+ break;
+ case 2:
+ case 6:
+ if (gTasks[taskId].data[2])
+ {
+ gBattle_BG0_X = 0;
+ gBattle_BG0_Y = 0;
+ gBattle_BG1_X = 0;
+ gBattle_BG1_Y = -160;
+ }
+ else
+ {
+ gBattle_BG0_X = 0;
+ gBattle_BG0_Y = -160;
+ gBattle_BG1_X = 0;
+ gBattle_BG1_Y = 0;
+ }
+
+ if (i == 2)
+ {
+ if (sBattleDomeStruct->unk_10 == 0)
+ {
+ gBattle_BG2_X = 0;
+ gBattle_BG2_Y = 160;
+ trainerTournamentId = gUnknown_0860D080[gTasks[taskId2].data[1]];
+ DisplayTrainerInfoOnCard(gTasks[taskId].data[2] | 4, trainerTournamentId);
+ }
+ else
+ {
+ gBattle_BG2_X = 0;
+ gBattle_BG2_Y = 0;
+ trainerTournamentId = gUnknown_0860D080[gTasks[taskId2].data[1]];
+ DisplayTrainerInfoOnCard(gTasks[taskId].data[2] | 4, trainerTournamentId);
+ sBattleDomeStruct->unk_10 = 0;
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->unk_10 == 0)
+ {
+ matchNo = gTasks[taskId2].data[1] - 16;
+ sub_8192F08(matchNo, sBattleDomeStruct->unk_11);
+ gBattle_BG2_X = 0;
+ gBattle_BG2_Y = 160;
+ trainerTournamentId = sBattleDomeStruct->unk_11[0];
+ DisplayTrainerInfoOnCard(gTasks[taskId].data[2] | 4, trainerTournamentId);
+ }
+ else if (sBattleDomeStruct->unk_10 == 2)
+ {
+ matchNo = gTasks[taskId2].data[1] - 16;
+ sub_8192F08(matchNo, sBattleDomeStruct->unk_11);
+ gBattle_BG2_X = 0;
+ gBattle_BG2_Y = 160;
+ trainerTournamentId = sBattleDomeStruct->unk_11[1];
+ DisplayTrainerInfoOnCard(gTasks[taskId].data[2] | 4, trainerTournamentId);
+ }
+ else
+ {
+ gBattle_BG2_X = 256;
+ gBattle_BG2_Y = 0;
+ matchNo = gTasks[taskId2].data[1] - 16;
+ DisplayMatchInfoOnCard(gTasks[taskId].data[2] | 4, matchNo);
+ }
+ }
+
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++)
+ {
+ if (i < 2)
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollDown;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ gSprites[sBattleDomeStruct->arr[i]].data[3] = sBattleDomeStruct->arr[i];
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollDown;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ }
+ }
+ }
+ for (i = DOME_TOURNAMENT_TRAINERS_COUNT / 2; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ if (i < 10)
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollDown;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ gSprites[sBattleDomeStruct->arr[i]].data[3] = sBattleDomeStruct->arr[i];
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollDown;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ }
+ }
+ }
+
+ gTasks[taskId].data[0] = 5;
+ gTasks[taskId].data[5] = 0;
+ break;
+ case 3:
+ if (gTasks[taskId].data[2])
+ {
+ gBattle_BG0_X = 0;
+ gBattle_BG0_Y = 0;
+ gBattle_BG1_X = 256;
+ gBattle_BG1_Y = 0;
+ }
+ else
+ {
+ gBattle_BG0_X = 256;
+ gBattle_BG0_Y = 0;
+ gBattle_BG1_X = 0;
+ gBattle_BG1_Y = 0;
+ }
+
+ if (sBattleDomeStruct->unk_10 == 0)
+ {
+ gBattle_BG2_X = 256;
+ gBattle_BG2_Y = 160;
+ trainerTournamentId = gUnknown_0860D080[gTasks[taskId2].data[1]];
+ DisplayTrainerInfoOnCard(gTasks[taskId].data[2] | 8, trainerTournamentId);
+ }
+ else
+ {
+ gBattle_BG2_X = 256;
+ gBattle_BG2_Y = 0;
+ matchNo = gUnknown_0860D15C[gTasks[taskId2].data[1]][sBattleDomeStruct->unk_10 - 1];
+ DisplayMatchInfoOnCard(gTasks[taskId].data[2] | 8, matchNo);
+ }
+
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++)
+ {
+ if (i < 2)
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ gSprites[sBattleDomeStruct->arr[i]].data[3] = sBattleDomeStruct->arr[i];
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ }
+ }
+ }
+ for (i = DOME_TOURNAMENT_TRAINERS_COUNT / 2; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ if (i < 10)
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ gSprites[sBattleDomeStruct->arr[i]].data[3] = sBattleDomeStruct->arr[i];
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ }
+ }
+ }
+
+ gTasks[taskId].data[0] = 6;
+ gTasks[taskId].data[5] = 0;
+ break;
+ case 7:
+ if (gTasks[taskId].data[2])
+ {
+ gBattle_BG0_X = 0;
+ gBattle_BG0_Y = 0;
+ gBattle_BG1_X = 256;
+ gBattle_BG1_Y = 0;
+ }
+ else
+ {
+ gBattle_BG0_X = 256;
+ gBattle_BG0_Y = 0;
+ gBattle_BG1_X = 0;
+ gBattle_BG1_Y = 0;
+ }
+
+ if (sBattleDomeStruct->unk_10 == 0)
+ {
+ gBattle_BG2_X = 256;
+ gBattle_BG2_Y = 160;
+ trainerTournamentId = sBattleDomeStruct->unk_11[0];
+ DisplayTrainerInfoOnCard(gTasks[taskId].data[2] | 8, trainerTournamentId);
+ }
+ else
+ {
+ gBattle_BG2_X = 0;
+ gBattle_BG2_Y = 160;
+ matchNo = gTasks[taskId2].data[1] - 16;
+ DisplayMatchInfoOnCard(gTasks[taskId].data[2] | 8, matchNo);
+ }
+
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++)
+ {
+ if (i < 2)
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ gSprites[sBattleDomeStruct->arr[i]].data[3] = sBattleDomeStruct->arr[i];
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ }
+ }
+ }
+ for (i = DOME_TOURNAMENT_TRAINERS_COUNT / 2; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ if (i < 10)
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ gSprites[sBattleDomeStruct->arr[i]].data[3] = sBattleDomeStruct->arr[i];
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ }
+ }
+ }
+
+ gTasks[taskId].data[0] = 6;
+ gTasks[taskId].data[5] = 0;
+ break;
+ case 4:
+ if (gTasks[taskId].data[2])
+ {
+ gBattle_BG0_X = 0;
+ gBattle_BG0_Y = 0;
+ gBattle_BG1_X = -256;
+ gBattle_BG1_Y = 0;
+ }
+ else
+ {
+ gBattle_BG0_X = -256;
+ gBattle_BG0_Y = 0;
+ gBattle_BG1_X = 0;
+ gBattle_BG1_Y = 0;
+ }
+
+ if (sBattleDomeStruct->unk_10 == 1)
+ {
+ gBattle_BG2_X = 0;
+ gBattle_BG2_Y = 160;
+ }
+ else
+ {
+ gBattle_BG2_X = 0;
+ gBattle_BG2_Y = 0;
+ }
+ matchNo = gUnknown_0860D15C[gTasks[taskId2].data[1]][sBattleDomeStruct->unk_10 - 1];
+ DisplayMatchInfoOnCard(gTasks[taskId].data[2] | 2, matchNo);
+
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++)
+ {
+ if (i < 2)
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ gSprites[sBattleDomeStruct->arr[i]].data[3] = sBattleDomeStruct->arr[i];
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ }
+ }
+ }
+ for (i = DOME_TOURNAMENT_TRAINERS_COUNT / 2; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ if (i < 10)
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ gSprites[sBattleDomeStruct->arr[i]].data[3] = sBattleDomeStruct->arr[i];
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ }
+ }
+ }
+
+ gTasks[taskId].data[0] = 7;
+ gTasks[taskId].data[5] = 0;
+ break;
+ case 8:
+ if (gTasks[taskId].data[2])
+ {
+ gBattle_BG0_X = 0;
+ gBattle_BG0_Y = 0;
+ gBattle_BG1_X = -256;
+ gBattle_BG1_Y = 0;
+ }
+ else
+ {
+ gBattle_BG0_X = -256;
+ gBattle_BG0_Y = 0;
+ gBattle_BG1_X = 0;
+ gBattle_BG1_Y = 0;
+ }
+
+ if (sBattleDomeStruct->unk_10 == 2)
+ {
+ gBattle_BG2_X = 256;
+ gBattle_BG2_Y = 160;
+ trainerTournamentId = sBattleDomeStruct->unk_11[1];
+ DisplayTrainerInfoOnCard(gTasks[taskId].data[2] | 2, trainerTournamentId);
+ }
+ else
+ {
+ gBattle_BG2_X = 0;
+ gBattle_BG2_Y = 160;
+ matchNo = gTasks[taskId2].data[1] - 16;
+ DisplayMatchInfoOnCard(gTasks[taskId].data[2] | 2, matchNo);
+ }
+
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++)
+ {
+ if (i < 2)
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ gSprites[sBattleDomeStruct->arr[i]].data[3] = sBattleDomeStruct->arr[i];
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ }
+ }
+ }
+ for (i = DOME_TOURNAMENT_TRAINERS_COUNT / 2; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ if (i < 10)
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ gSprites[sBattleDomeStruct->arr[i]].data[3] = sBattleDomeStruct->arr[i];
+ }
+ }
+ else
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ {
+ gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight;
+ gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
+ gSprites[sBattleDomeStruct->arr[i]].data[1] = 0;
+ gSprites[sBattleDomeStruct->arr[i]].data[2] = i;
+ }
+ }
+ }
+
+ gTasks[taskId].data[0] = 7;
+ gTasks[taskId].data[5] = 0;
+ break;
+ }
+ break;
+ case 4:
+ if (++gTasks[taskId].data[5] != 41)
+ {
+ gBattle_BG0_Y -= 4;
+ gBattle_BG1_Y -= 4;
+ gBattle_BG2_Y -= 4;
+ }
+ else
+ {
+ gTasks[taskId].data[0] = 2;
+ }
+ break;
+ case 5:
+ if (++gTasks[taskId].data[5] != 41)
+ {
+ gBattle_BG0_Y += 4;
+ gBattle_BG1_Y += 4;
+ gBattle_BG2_Y += 4;
+ }
+ else
+ {
+ gTasks[taskId].data[0] = 2;
+ }
+ break;
+ case 6:
+ if (++gTasks[taskId].data[5] != 65)
+ {
+ gBattle_BG0_X -= 4;
+ gBattle_BG1_X -= 4;
+ gBattle_BG2_X -= 4;
+ }
+ else
+ {
+ gTasks[taskId].data[0] = 2;
+ }
+ break;
+ case 7:
+ if (++gTasks[taskId].data[5] != 65)
+ {
+ gBattle_BG0_X += 4;
+ gBattle_BG1_X += 4;
+ gBattle_BG2_X += 4;
+ }
+ else
+ {
+ gTasks[taskId].data[0] = 2;
+ }
+ break;
+ case 8:
+ if (!gPaletteFade.active)
+ {
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++)
+ {
+ if (i < 2)
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ FreeAndDestroyTrainerPicSprite(sBattleDomeStruct->arr[i]);
+ }
+ else
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ sub_80D2EF8(&gSprites[sBattleDomeStruct->arr[i]]);
+ }
+ }
+ for (i = DOME_TOURNAMENT_TRAINERS_COUNT / 2; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ if (i < 10)
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ FreeAndDestroyTrainerPicSprite(sBattleDomeStruct->arr[i]);
+ }
+ else
+ {
+ if (sBattleDomeStruct->arr[i] != 0xFF)
+ sub_80D2EF8(&gSprites[sBattleDomeStruct->arr[i]]);
+ }
+ }
+
+ FreeMonIconPalettes();
+ FREE_AND_SET_NULL(sBattleDomeStruct);
+ FreeAllWindowBuffers();
+ if (r9 == 0)
+ {
+ SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
+ }
+ else
+ {
+ i = CreateTask(sub_8194220, 0);
+ gTasks[i].data[0] = 0;
+ gTasks[i].data[1] = 0;
+ gTasks[i].data[2] = 3;
+ gTasks[i].data[3] = gTasks[taskId].data[4];
+ gTasks[i].data[4] = gTasks[taskId2].data[6];
+ }
+ DestroyTask(taskId);
+ }
+ break;
+ }
+}
+
+static u8 sub_819221C(u8 taskId)
+{
+ u8 retVal = 0;
+ s32 taskId2 = gTasks[taskId].data[4];
+ s32 r5 = gTasks[taskId2].data[1];
+ u8 r10 = gUnknown_0860D080[r5];
+ u16 roundId = gSaveBlock2Ptr->frontier.field_CB2;
+
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ retVal = 9;
+
+ if (gTasks[taskId].data[3] == 0)
+ return retVal;
+
+ if (gTasks[taskId].data[3] == 1)
+ {
+ if (gMain.newKeys & DPAD_UP && sBattleDomeStruct->unk_10 == 0)
+ {
+ if (r5 == 0)
+ r5 = 15;
+ else
+ r5--;
+ retVal = 1;
+ }
+ else if (gMain.newKeys & DPAD_DOWN && sBattleDomeStruct->unk_10 == 0)
+ {
+ if (r5 == 15)
+ r5 = 0;
+ else
+ r5++;
+ retVal = 2;
+ }
+ else if (gMain.newKeys & DPAD_LEFT && sBattleDomeStruct->unk_10 != 0)
+ {
+ sBattleDomeStruct->unk_10--;
+ retVal = 3;
+ }
+ else if (gMain.newKeys & DPAD_RIGHT)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[r10].isEliminated && sBattleDomeStruct->unk_10 - 1 < gSaveBlock2Ptr->frontier.domeTrainers[r10].eliminatedAt)
+ {
+ sBattleDomeStruct->unk_10++;
+ retVal = 4;
+ }
+ if (!gSaveBlock2Ptr->frontier.domeTrainers[r10].isEliminated && sBattleDomeStruct->unk_10 - 1 < roundId)
+ {
+ sBattleDomeStruct->unk_10++;
+ retVal = 4;
+ }
+ }
+
+ if (retVal == 9)
+ {
+ if (sBattleDomeStruct->unk_10 != 0)
+ gTasks[taskId2].data[1] = gUnknown_0860D1A0[r5 / 2][sBattleDomeStruct->unk_10 - 1];
+ else
+ gTasks[taskId2].data[1] = r5;
+ }
+ }
+ else
+ {
+ if (gMain.newKeys & DPAD_UP && sBattleDomeStruct->unk_10 == 1)
+ {
+ if (r5 == 16)
+ r5 = gUnknown_0860D19C[roundId];
+ else
+ r5--;
+ retVal = 5;
+ }
+ else if (gMain.newKeys & DPAD_DOWN && sBattleDomeStruct->unk_10 == 1)
+ {
+ if (r5 == gUnknown_0860D19C[roundId])
+ r5 = 16;
+ else
+ r5++;
+ retVal = 6;
+ }
+ else if (gMain.newKeys & DPAD_LEFT && sBattleDomeStruct->unk_10 != 0)
+ {
+ retVal = 7;
+ sBattleDomeStruct->unk_10--;
+ }
+ else if (gMain.newKeys & DPAD_RIGHT && (sBattleDomeStruct->unk_10 == 0 || sBattleDomeStruct->unk_10 == 1))
+ {
+ retVal = 8;
+ sBattleDomeStruct->unk_10++;
+ }
+
+ if (retVal == 9)
+ {
+ if (sBattleDomeStruct->unk_10 == 0)
+ gTasks[taskId2].data[1] = gUnknown_0860D1C0[sBattleDomeStruct->unk_11[0]];
+ else if (sBattleDomeStruct->unk_10 == 2)
+ gTasks[taskId2].data[1] = gUnknown_0860D1C0[sBattleDomeStruct->unk_11[1]];
+ else
+ gTasks[taskId2].data[1] = r5;
+ }
+ }
+
+ if (retVal != 0 && retVal != 9)
+ {
+ PlaySE(SE_SELECT);
+ gTasks[taskId2].data[1] = r5;
+ gTasks[taskId].data[2] ^= 1;
+ }
+
+ return retVal;
+}
+
+static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId)
+{
+ struct TextSubPrinter textPrinter;
+ s32 i, j, k;
+ s32 trainerId = 0;
+ u8 nature = 0;
+ s32 arrId = 0;
+ s32 windowId = 0;
+ s32 x = 0, y = 0;
+ u8 palSlot = 0;
+ s16 *allocatedArray = AllocZeroed(sizeof(s16) * 18);
+ trainerId = gSaveBlock2Ptr->frontier.domeTrainers[trainerTournamentId].trainerId;
+
+ if (flags & 1)
+ arrId = 8, windowId = 9, palSlot = 2;
+ if (flags & 2)
+ x = 256;
+ if (flags & 4)
+ y = 160;
+ if (flags & 8)
+ x = -256;
+ if (flags & 0x10)
+ y = -160;
+
+ if (trainerId == TRAINER_PLAYER)
+ sBattleDomeStruct->arr[arrId] = CreateTrainerPicSprite(PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender), TRUE, x + 48, y + 64, palSlot + 12, 0xFFFF);
+ else if (trainerId == TRAINER_FRONTIER_BRAIN)
+ sBattleDomeStruct->arr[arrId] = CreateTrainerPicSprite(GetDomeBrainTrainerPicId(), TRUE, x + 48, y + 64, palSlot + 12, 0xFFFF);
+ else
+ sBattleDomeStruct->arr[arrId] = CreateTrainerPicSprite(GetFrontierTrainerFrontSpriteId(trainerId), TRUE, x + 48, y + 64, palSlot + 12, 0xFFFF);
+
+ if (flags & 0x1E)
+ gSprites[sBattleDomeStruct->arr[arrId]].invisible = 1;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (trainerId == TRAINER_PLAYER)
+ {
+ sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i],
+ SpriteCb_MonIcon,
+ x | sInfoTrainerMonX[i],
+ y + sInfoTrainerMonY[i],
+ 0, 0, TRUE);
+ gSprites[sBattleDomeStruct->arr[2 + i + arrId]].oam.priority = 0;
+ }
+ else if (trainerId == TRAINER_FRONTIER_BRAIN)
+ {
+ sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i],
+ SpriteCb_MonIcon,
+ x | sInfoTrainerMonX[i],
+ y + sInfoTrainerMonY[i],
+ 0, 0, TRUE);
+ gSprites[sBattleDomeStruct->arr[2 + i + arrId]].oam.priority = 0;
+ }
+ else
+ {
+ sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]].species,
+ SpriteCb_MonIcon,
+ x | sInfoTrainerMonX[i],
+ y + sInfoTrainerMonY[i],
+ 0, 0, TRUE);
+ gSprites[sBattleDomeStruct->arr[2 + i + arrId]].oam.priority = 0;
+ }
+
+ if (flags & 0x1E)
+ gSprites[sBattleDomeStruct->arr[2 + i + arrId]].invisible = 1;
+ }
+ textPrinter.fontId = 2;
+ textPrinter.x = 0;
+ textPrinter.y = 0;
+ textPrinter.currentX = textPrinter.x;
+ textPrinter.currentY = textPrinter.y;
+ textPrinter.letterSpacing = 2;
+ textPrinter.lineSpacing = 0;
+ textPrinter.fontColor_l = 0;
+ textPrinter.fgColor = 14;
+ textPrinter.bgColor = 0;
+ textPrinter.shadowColor = 13;
+
+ i = 0;
+ if (trainerId == TRAINER_PLAYER)
+ j = gFacilityClassToTrainerClass[FACILITY_CLASS_PKMN_TRAINER_BRENDAN];
+ else if (trainerId == TRAINER_FRONTIER_BRAIN)
+ j = GetDomeBrainTrainerClass();
+ else
+ j = GetFrontierOpponentClass(trainerId);
+
+ for (;gTrainerClassNames[j][i] != EOS; i++)
+ gStringVar1[i] = gTrainerClassNames[j][i];
+ gStringVar1[i] = CHAR_SPACE;
+ gStringVar1[i + 1] = EOS;
+
+ if (trainerId == TRAINER_PLAYER)
+ {
+ StringAppend(gStringVar1, gSaveBlock2Ptr->playerName);
+ }
+ else if (trainerId == TRAINER_FRONTIER_BRAIN)
+ {
+ CopyDomeBrainTrainerName(gStringVar2);
+ StringAppend(gStringVar1, gStringVar2);
+ }
+ else
+ {
+ CopyDomeTrainerName(gStringVar2, trainerId);
+ StringAppend(gStringVar1, gStringVar2);
+ }
+
+ textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, gStringVar1, 0xD0, textPrinter.letterSpacing);
+ textPrinter.current_text_offset = gStringVar1;
+ textPrinter.windowId = windowId;
+ PutWindowTilemap(windowId);
+ CopyWindowToVram(windowId, 3);
+ AddTextPrinter(&textPrinter, 0, NULL);
+ textPrinter.letterSpacing = 0;
+
+ for (i = 0; i < 3; i++)
+ {
+ textPrinter.currentY = gUnknown_0860D346[i];
+ if (trainerId == TRAINER_PLAYER)
+ textPrinter.current_text_offset = gSpeciesNames[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]];
+ else if (trainerId == TRAINER_FRONTIER_BRAIN)
+ textPrinter.current_text_offset = gSpeciesNames[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]];
+ else
+ textPrinter.current_text_offset = gSpeciesNames[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]].species];
+
+ textPrinter.windowId = 1 + i + windowId;
+ if (i == 1)
+ textPrinter.currentX = 7;
+ else
+ textPrinter.currentX = 0;
+
+ PutWindowTilemap(1 + i + windowId);
+ CopyWindowToVram(1 + i + windowId, 3);
+ AddTextPrinter(&textPrinter, 0, NULL);
+ }
+
+ PutWindowTilemap(windowId + 4);
+ CopyWindowToVram(windowId + 4, 3);
+ if (trainerId == TRAINER_FRONTIER_BRAIN)
+ textPrinter.current_text_offset = gBattleDomePotentialPointers[16];
+ else
+ textPrinter.current_text_offset = gBattleDomePotentialPointers[trainerTournamentId];
+
+ textPrinter.fontId = 1;
+ textPrinter.windowId = windowId + 4;
+ textPrinter.currentX = 0;
+ textPrinter.y = 4;
+ textPrinter.currentY = 4;
+ AddTextPrinter(&textPrinter, 0, NULL);
+
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ for (k = 0; k < DOME_TOURNAMENT_TRAINERS_COUNT; k++)
+ {
+ if (trainerId == TRAINER_FRONTIER_BRAIN)
+ allocatedArray[k] += sMovePointsForDomeTrainers[sub_81A5060(i, j)][k];
+ else if (trainerId == TRAINER_PLAYER)
+ allocatedArray[k] += sMovePointsForDomeTrainers[gSaveBlock2Ptr->frontier.field_EFC[i].moves[j]][k];
+ else
+ allocatedArray[k] += sMovePointsForDomeTrainers[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]].moves[j]][k];
+ }
+ }
+ }
+
+ for (i = 0; i < ARRAY_COUNT(gUnknown_0860C988); i++)
+ {
+ s32 r4 = 0;
+
+ for (k = 0, j = 0; j < DOME_TOURNAMENT_TRAINERS_COUNT; j++)
+ {
+ if (gUnknown_0860C988[i][j] != 0)
+ {
+ r4++;
+ if (allocatedArray[j] != 0 && allocatedArray[j] >= gUnknown_0860C988[i][j])
+ k++;
+ }
+ }
+ if (r4 == k)
+ break;
+ }
+
+ textPrinter.current_text_offset = gBattleDomeOpponentStylePointers[i];
+ textPrinter.y = 20;
+ textPrinter.currentY = 20;
+ AddTextPrinter(&textPrinter, 0, NULL);
+
+ for (i = 0; i < 18; i++)
+ allocatedArray[i] = 0;
+
+ if (trainerId == TRAINER_FRONTIER_BRAIN || trainerId == TRAINER_PLAYER)
+ {
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 6; j++)
+ {
+ if (trainerId == TRAINER_FRONTIER_BRAIN)
+ allocatedArray[j] = sub_81A50F0(i, j);
+ else
+ allocatedArray[j] = gSaveBlock2Ptr->frontier.field_EFC[i].evs[j];
+ }
+ allocatedArray[6] += allocatedArray[0];
+ for (j = 0; j < 5; j++)
+ {
+ if (trainerId == TRAINER_FRONTIER_BRAIN)
+ nature = sub_81A50B0(i);
+ else
+ nature = gSaveBlock2Ptr->frontier.field_EFC[i].nature;
+
+ if (gNatureStatTable[nature][j] > 0)
+ {
+ allocatedArray[j + 7] += (allocatedArray[j + 1] * 110) / 100;
+ }
+ else if (gNatureStatTable[nature][j] < 0)
+ {
+ allocatedArray[j + 7] += (allocatedArray[j + 1] * 90) / 100;
+ allocatedArray[j + 13]++;
+ }
+ else
+ {
+ allocatedArray[j + 7] += allocatedArray[j + 1];
+ }
+ }
+ }
+ for (j = 0, i = 0; i < 6; i++)
+ j += allocatedArray[6 + i];
+ for (i = 0; i < 6; i++)
+ allocatedArray[i] = (allocatedArray[6 + i] * 100) / j;
+ }
+ else
+ {
+ for (i = 0; i < 3; i++)
+ {
+ s32 evBits = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]].evSpread;
+ for (k = 0, j = 0; j < 6; j++)
+ {
+ allocatedArray[j] = 0;
+ if (evBits & 1)
+ k++;
+ evBits >>= 1;
+ }
+ k = MAX_TOTAL_EVS / k;
+ evBits = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]].evSpread;
+ for (j = 0; j < 6; j++)
+ {
+ if (evBits & 1)
+ allocatedArray[j] = k;
+ evBits >>= 1;
+ }
+
+ allocatedArray[6] += allocatedArray[0];
+ for (j = 0; j < 5; j++)
+ {
+ nature = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[trainerTournamentId][i]].nature;
+ if (gNatureStatTable[nature][j] > 0)
+ {
+ allocatedArray[j + 7] += (allocatedArray[j + 1] * 110) / 100;
+ }
+ else if (gNatureStatTable[nature][j] < 0)
+ {
+ allocatedArray[j + 7] += (allocatedArray[j + 1] * 90) / 100;
+ allocatedArray[j + 13]++;
+ }
+ else
+ {
+ allocatedArray[j + 7] += allocatedArray[j + 1];
+ }
+ }
+ }
+ for (j = 0, i = 0; i < 6; i++)
+ j += allocatedArray[i + 6];
+ for (i = 0; i < 6; i++)
+ allocatedArray[i] = (allocatedArray[6 + i] * 100) / j;
+ }
+
+ for (i = 0, j = 0, k = 0; k < 6; k++)
+ {
+ if (allocatedArray[k] > 29)
+ {
+ if (i == 2)
+ {
+ if (allocatedArray[6] < allocatedArray[k])
+ {
+ if (allocatedArray[7] < allocatedArray[k])
+ {
+ if (allocatedArray[6] < allocatedArray[7])
+ {
+ allocatedArray[6] = allocatedArray[7];
+ allocatedArray[7] = k;
+ }
+ else
+ {
+ allocatedArray[7] = k;
+ }
+ }
+ else
+ {
+ allocatedArray[6] = allocatedArray[7];
+ allocatedArray[7] = k;
+ }
+ }
+ else
+ {
+ if (allocatedArray[7] < allocatedArray[k])
+ allocatedArray[7] = k;
+ }
+ }
+ else
+ {
+ allocatedArray[i + 6] = k;
+ i++;
+ }
+ }
+ if (allocatedArray[k] == 0)
+ {
+ if (j == 2)
+ {
+ if (allocatedArray[k + 12] >= 2
+ || ((allocatedArray[k + 12] == 1 && allocatedArray[12 + allocatedArray[8]] == 0 && allocatedArray[12 + allocatedArray[9]] == 0)
+ )
+ )
+ {
+ allocatedArray[8] = allocatedArray[9];
+ allocatedArray[9] = k;
+ }
+ else if (allocatedArray[k + 12] == 1 && allocatedArray[12 + allocatedArray[8]] == 0)
+ {
+ allocatedArray[8] = allocatedArray[9];
+ allocatedArray[9] = k;
+ }
+ else if (allocatedArray[k + 12] == 1 && allocatedArray[12 + allocatedArray[9]] == 0)
+ {
+ allocatedArray[9] = k;
+ }
+ }
+ else
+ {
+ allocatedArray[j + 8] = k;
+ j++;
+ }
+ }
+ }
+
+ if (i == 2)
+ i = gUnknown_0860D349[allocatedArray[6]] + (allocatedArray[7] - (allocatedArray[6] + 1));
+ else if (i == 1)
+ i = allocatedArray[6] + 15;
+ else if (j == 2)
+ i = gUnknown_0860D349[allocatedArray[8]] + (allocatedArray[9] - (allocatedArray[8] + 1)) + 21;
+ else if (j == 1)
+ i = allocatedArray[8] + 36;
+ else
+ i = 42;
+
+ textPrinter.current_text_offset = gBattleDomeOpponentStatsPointers[i];
+ textPrinter.y = 36;
+ textPrinter.currentY = 36;
+ AddTextPrinter(&textPrinter, 0, NULL);
+ Free(allocatedArray);
+}
+
+static s32 sub_8192F08(u8 arg0, u8 *arg1)
+{
+ s32 i;
+ u8 tournamentId;
+ s32 retVal = 0;
+ s32 count = 0;
+
+ for (i = gUnknown_0860D3C4[arg0][0]; i < gUnknown_0860D3C4[arg0][0] + gUnknown_0860D3C4[arg0][1]; i++)
+ {
+ tournamentId = gUnknown_0860D3B4[i];
+ if (!gSaveBlock2Ptr->frontier.domeTrainers[tournamentId].isEliminated)
+ {
+ arg1[count] = tournamentId;
+ if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentId].trainerId == TRAINER_PLAYER)
+ StringCopy(gStringVar1, gSaveBlock2Ptr->playerName);
+ else if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentId].trainerId == TRAINER_FRONTIER_BRAIN)
+ CopyDomeBrainTrainerName(gStringVar1);
+ else
+ CopyDomeTrainerName(gStringVar1, gSaveBlock2Ptr->frontier.domeTrainers[tournamentId].trainerId);
+ count++;
+ }
+ }
+
+ if (count == 2)
+ return 0;
+
+ for (i = gUnknown_0860D3C4[arg0][0]; i < gUnknown_0860D3C4[arg0][0] + gUnknown_0860D3C4[arg0][1]; i++)
+ {
+ tournamentId = gUnknown_0860D3B4[i];
+ if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentId].isEliminated
+ && gSaveBlock2Ptr->frontier.domeTrainers[tournamentId].eliminatedAt >= gUnknown_0860D3C4[arg0][2])
+ {
+ arg1[count] = tournamentId;
+ count++;
+ if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentId].eliminatedAt == gUnknown_0860D3C4[arg0][2])
+ {
+ StringCopy(gStringVar2, gMoveNames[gSaveBlock2Ptr->frontier.field_EC0[tournamentId]]);
+ retVal = gSaveBlock2Ptr->frontier.domeTrainers[tournamentId].unk3 * 2;
+ if (gSaveBlock2Ptr->frontier.field_EC0[tournamentId] == 0 && gSaveBlock2Ptr->frontier.domeTrainers[tournamentId].unk3 == 0)
+ retVal = 4;
+ }
+ else
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentId].trainerId == TRAINER_PLAYER)
+ StringCopy(gStringVar1, gSaveBlock2Ptr->playerName);
+ else if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentId].trainerId == TRAINER_FRONTIER_BRAIN)
+ CopyDomeBrainTrainerName(gStringVar1);
+ else
+ CopyDomeTrainerName(gStringVar1, gSaveBlock2Ptr->frontier.domeTrainers[tournamentId].trainerId);
+ }
+ }
+
+ if (count == 2)
+ break;
+ }
+
+ if (arg0 == 14)
+ return retVal + 2;
+ else
+ return retVal + 1;
+}
+
+static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo)
+{
+ struct TextSubPrinter textPrinter;
+ s32 tournamentIds[2];
+ s32 trainerIds[2];
+ bool32 lost[2];
+ s32 i;
+ s32 winStringId = 0;
+ s32 arrId = 0;
+ s32 windowId = 0;
+ s32 x = 0, y = 0;
+ u8 palSlot = 0;
+
+ if (flags & 1)
+ arrId = 8, windowId = 9, palSlot = 2;
+ if (flags & 2)
+ x = 256;
+ if (flags & 4)
+ y = 160;
+ if (flags & 8)
+ x = -256;
+ if (flags & 0x10)
+ y = -160;
+
+ // Copy trainers information to handy arrays.
+ winStringId = sub_8192F08(matchNo, sBattleDomeStruct->unk_11);
+ for (i = 0; i < 2; i++)
+ {
+ tournamentIds[i] = sBattleDomeStruct->unk_11[i];
+ trainerIds[i] = gSaveBlock2Ptr->frontier.domeTrainers[tournamentIds[i]].trainerId;
+ if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentIds[i]].eliminatedAt <= gUnknown_0860D3C4[matchNo][2]
+ && gSaveBlock2Ptr->frontier.domeTrainers[tournamentIds[i]].isEliminated)
+ lost[i] = TRUE;
+ else
+ lost[i] = FALSE;
+ }
+
+ // Draw first trainer sprite.
+ if (trainerIds[0] == TRAINER_PLAYER)
+ sBattleDomeStruct->arr[arrId] = CreateTrainerPicSprite(PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender), TRUE, x + 48, y + 88, palSlot + 12, 0xFFFF);
+ else if (trainerIds[0] == TRAINER_FRONTIER_BRAIN)
+ sBattleDomeStruct->arr[arrId] = CreateTrainerPicSprite(GetDomeBrainTrainerPicId(), TRUE, x + 48, y + 88, palSlot + 12, 0xFFFF);
+ else
+ sBattleDomeStruct->arr[arrId] = CreateTrainerPicSprite(GetFrontierTrainerFrontSpriteId(trainerIds[0]), TRUE, x + 48, y + 88, palSlot + 12, 0xFFFF);
+
+ if (flags & 0x1E)
+ gSprites[sBattleDomeStruct->arr[arrId]].invisible = 1;
+ if (lost[0])
+ gSprites[sBattleDomeStruct->arr[arrId]].oam.paletteNum = 3;
+
+ // Draw second trainer sprite.
+ if (trainerIds[1] == TRAINER_PLAYER)
+ sBattleDomeStruct->arr[1 + arrId] = CreateTrainerPicSprite(PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender), TRUE, x + 192, y + 88, palSlot + 13, 0xFFFF);
+ else if (trainerIds[1] == TRAINER_FRONTIER_BRAIN)
+ sBattleDomeStruct->arr[1 + arrId] = CreateTrainerPicSprite(GetDomeBrainTrainerPicId(), TRUE, x + 192, y + 88, palSlot + 13, 0xFFFF);
+ else
+ sBattleDomeStruct->arr[1 + arrId] = CreateTrainerPicSprite(GetFrontierTrainerFrontSpriteId(trainerIds[1]), TRUE, x + 192, y + 88, palSlot + 13, 0xFFFF);
+
+ if (flags & 0x1E)
+ gSprites[sBattleDomeStruct->arr[1 + arrId]].invisible = 1;
+ if (lost[1])
+ gSprites[sBattleDomeStruct->arr[1 + arrId]].oam.paletteNum = 3;
+
+ // Draw first trainer's pokemon icons.
+ for (i = 0; i < 3; i++)
+ {
+ if (trainerIds[0] == TRAINER_PLAYER)
+ {
+ sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[0]][i],
+ SpriteCb_MonIcon,
+ x | sFirstTrainerMonX[i],
+ y + sFirstTrainerMonY[i],
+ 0, 0, TRUE);
+ gSprites[sBattleDomeStruct->arr[2 + i + arrId]].oam.priority = 0;
+ }
+ else if (trainerIds[0] == TRAINER_FRONTIER_BRAIN)
+ {
+ sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[0]][i],
+ SpriteCb_MonIcon,
+ x | sFirstTrainerMonX[i],
+ y + sFirstTrainerMonY[i],
+ 0, 0, TRUE);
+ gSprites[sBattleDomeStruct->arr[2 + i + arrId]].oam.priority = 0;
+ }
+ else
+ {
+ sBattleDomeStruct->arr[2 + i + arrId] = CreateMonIcon(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[0]][i]].species,
+ SpriteCb_MonIcon,
+ x | sFirstTrainerMonX[i],
+ y + sFirstTrainerMonY[i],
+ 0, 0, TRUE);
+ gSprites[sBattleDomeStruct->arr[2 + i + arrId]].oam.priority = 0;
+ }
+
+ if (flags & 0x1E)
+ gSprites[sBattleDomeStruct->arr[2 + i + arrId]].invisible = 1;
+ if (lost[0])
+ {
+ gSprites[sBattleDomeStruct->arr[2 + i + arrId]].oam.paletteNum = 3;
+ gSprites[sBattleDomeStruct->arr[2 + i + arrId]].sMonIconStill = TRUE;
+ }
+ }
+
+ // Draw second trainer's pokemon icons.
+ for (i = 0; i < 3; i++)
+ {
+ if (trainerIds[1] == TRAINER_PLAYER)
+ {
+ sBattleDomeStruct->arr[5 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[1]][i],
+ SpriteCb_MonIcon,
+ x | sSecondTrainerMonX[i],
+ y + sSecondTrainerMonY[i],
+ 0, 0, TRUE);
+ gSprites[sBattleDomeStruct->arr[5 + i + arrId]].oam.priority = 0;
+ }
+ else if (trainerIds[1] == TRAINER_FRONTIER_BRAIN)
+ {
+ sBattleDomeStruct->arr[5 + i + arrId] = CreateMonIcon(gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[1]][i],
+ SpriteCb_MonIcon,
+ x | sSecondTrainerMonX[i],
+ y + sSecondTrainerMonY[i],
+ 0, 0, TRUE);
+ gSprites[sBattleDomeStruct->arr[5 + i + arrId]].oam.priority = 0;
+ }
+ else
+ {
+ sBattleDomeStruct->arr[5 + i + arrId] = CreateMonIcon(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentIds[1]][i]].species,
+ SpriteCb_MonIcon,
+ x | sSecondTrainerMonX[i],
+ y + sSecondTrainerMonY[i],
+ 0, 0, TRUE);
+ gSprites[sBattleDomeStruct->arr[5 + i + arrId]].oam.priority = 0;
+ }
+
+ if (flags & 0x1E)
+ gSprites[sBattleDomeStruct->arr[5 + i + arrId]].invisible = 1;
+ if (lost[1])
+ {
+ gSprites[sBattleDomeStruct->arr[5 + i + arrId]].oam.paletteNum = 3;
+ gSprites[sBattleDomeStruct->arr[5 + i + arrId]].sMonIconStill = TRUE;
+ }
+ }
+
+ // Print the win string (or 'Let the battle begin!' one).
+ textPrinter.x = 0;
+ textPrinter.y = 2;
+ textPrinter.currentX = textPrinter.x;
+ textPrinter.currentY = textPrinter.y;
+ textPrinter.letterSpacing = 0;
+ textPrinter.lineSpacing = 0;
+ textPrinter.fontColor_l = 0;
+ textPrinter.fgColor = 14;
+ textPrinter.bgColor = 0;
+ textPrinter.shadowColor = 13;
+ StringExpandPlaceholders(gStringVar4, gBattleDomeWinStringsPointers[winStringId]);
+ textPrinter.current_text_offset = gStringVar4;
+ textPrinter.windowId = windowId + 8;
+ textPrinter.fontId = 1;
+ PutWindowTilemap(windowId + 8);
+ CopyWindowToVram(windowId + 8, 3);
+ textPrinter.currentX = 0;
+ textPrinter.currentY = textPrinter.y = 0;
+ AddTextPrinter(&textPrinter, 0, NULL);
+
+ // Print first trainer's name.
+ if (trainerIds[0] == TRAINER_PLAYER)
+ StringCopy(gStringVar1, gSaveBlock2Ptr->playerName);
+ else if (trainerIds[0] == TRAINER_FRONTIER_BRAIN)
+ CopyDomeBrainTrainerName(gStringVar1);
+ else
+ CopyDomeTrainerName(gStringVar1, trainerIds[0]);
+
+ textPrinter.fontId = 2;
+ textPrinter.letterSpacing = 2;
+ textPrinter.current_text_offset = gStringVar1;
+ textPrinter.windowId = windowId + 6;
+ textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.current_text_offset, 0x40, textPrinter.letterSpacing);
+ textPrinter.currentY = textPrinter.y = 2;
+ PutWindowTilemap(windowId + 6);
+ CopyWindowToVram(windowId + 6, 3);
+ AddTextPrinter(&textPrinter, 0, NULL);
+
+ // Print second trainer's name.
+ if (trainerIds[1] == TRAINER_PLAYER)
+ StringCopy(gStringVar1, gSaveBlock2Ptr->playerName);
+ else if (trainerIds[1] == TRAINER_FRONTIER_BRAIN)
+ CopyDomeBrainTrainerName(gStringVar1);
+ else
+ CopyDomeTrainerName(gStringVar1, trainerIds[1]);
+
+ textPrinter.current_text_offset = gStringVar1;
+ textPrinter.windowId = windowId + 7;
+ textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.current_text_offset, 0x40, textPrinter.letterSpacing);
+ textPrinter.currentY = textPrinter.y = 2;
+ PutWindowTilemap(windowId + 7);
+ CopyWindowToVram(windowId + 7, 3);
+ AddTextPrinter(&textPrinter, 0, NULL);
+
+ // Print match number.
+ textPrinter.letterSpacing = 0;
+ textPrinter.current_text_offset = gBattleDomeMatchNumberPointers[matchNo];
+ textPrinter.windowId = windowId + 5;
+ textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.current_text_offset, 0xA0, textPrinter.letterSpacing);
+ textPrinter.currentY = textPrinter.y = 2;
+ PutWindowTilemap(windowId + 5);
+ CopyWindowToVram(windowId + 5, 3);
+ AddTextPrinter(&textPrinter, 0, NULL);
+}
+
+static void sub_81938A4(void)
+{
+ u8 taskId = CreateTask(sub_8194220, 0);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].data[2] = 2;
+ gTasks[taskId].data[4] = 0;
+ SetMainCallback2(CB2_BattleDome);
+}
+
+static void sub_81938E0(void)
+{
+ u8 taskId;
+
+ sub_8194D48();
+ gSaveBlock2Ptr->frontier.lvlMode = gSaveBlock2Ptr->frontier.field_D0A - 1;
+ gSaveBlock2Ptr->frontier.field_CB2 = 3;
+ taskId = CreateTask(sub_8194220, 0);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].data[2] = 2;
+ gTasks[taskId].data[4] = 1;
+ SetMainCallback2(CB2_BattleDome);
+}
+
+static void sub_819395C(u8 taskId)
+{
+ u8 newTaskId = 0;
+ s32 spriteId = gTasks[taskId].data[1];
+
+ switch (gTasks[taskId].data[0])
+ {
+ case 0:
+ if (!gPaletteFade.active)
+ {
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK);
+ gTasks[taskId].data[0] = 1;
+ StartSpriteAnim(&gSprites[spriteId], 1);
+ }
+ break;
+ case 1:
+ if (!gPaletteFade.active)
+ gTasks[taskId].data[0] = 2;
+ break;
+ case 2:
+ switch (sub_8193BDC(taskId))
+ {
+ case 0:
+ default:
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
+ gTasks[taskId].data[0] = 7;
+ break;
+ case 1:
+ break;
+ case 2:
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
+ gTasks[taskId].data[0] = 3;
+ break;
+ case 3:
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
+ gTasks[taskId].data[0] = 5;
+ break;
+ }
+ break;
+ case 3:
+ if (!gPaletteFade.active)
+ {
+ FreeAllWindowBuffers();
+ ScanlineEffect_Stop();
+ FREE_AND_SET_NULL(sTilemapBuffer);
+ newTaskId = CreateTask(sub_8190400, 0);
+ gTasks[newTaskId].data[0] = 0;
+ gTasks[newTaskId].data[1] = gUnknown_0860D080[spriteId];
+ gTasks[newTaskId].data[2] = 1;
+ gTasks[newTaskId].data[3] = taskId;
+
+ gTasks[taskId].data[0] = 4;
+ sBattleDomeStruct->unk_10 = 0;
+ }
+ break;
+ case 4:
+ break;
+ case 5:
+ if (!gPaletteFade.active)
+ {
+ FreeAllWindowBuffers();
+ ScanlineEffect_Stop();
+ FREE_AND_SET_NULL(sTilemapBuffer);
+ newTaskId = CreateTask(sub_8190400, 0);
+ gTasks[newTaskId].data[0] = 0;
+ gTasks[newTaskId].data[1] = spriteId - 16;
+ gTasks[newTaskId].data[2] = 2;
+ gTasks[newTaskId].data[3] = taskId;
+
+ gTasks[taskId].data[0] = 6;
+ }
+ break;
+ case 6:
+ break;
+ case 7:
+ if (!gPaletteFade.active)
+ {
+ FreeAllWindowBuffers();
+ ScanlineEffect_Stop();
+ FREE_AND_SET_NULL(sTilemapBuffer);
+ SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
+ DestroyTask(gTasks[taskId].data[7]);
+ DestroyTask(taskId);
+ }
+ break;
+ }
+}
+
+static u8 sub_8193BDC(u8 taskId)
+{
+ u8 retVal = 1;
+ s32 arrId = 4;
+ s32 spriteId = gTasks[taskId].data[1];
+ s32 roundId = gSaveBlock2Ptr->frontier.field_CB2;
+
+ if (gMain.newKeys == B_BUTTON || (gMain.newKeys & A_BUTTON && spriteId == 31))
+ {
+ PlaySE(SE_SELECT);
+ retVal = 0;
+ }
+ else if (gMain.newKeys & A_BUTTON)
+ {
+ if (spriteId < 16)
+ {
+ PlaySE(SE_SELECT);
+ retVal = 2;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ retVal = 3;
+ }
+ }
+ else
+ {
+ if (gMain.newKeys == DPAD_UP && gUnknown_0860CBF1[spriteId][roundId][0] != 0xFF)
+ arrId = 0;
+ else if (gMain.newKeys == DPAD_DOWN && gUnknown_0860CBF1[spriteId][roundId][1] != 0xFF)
+ arrId = 1;
+ else if (gMain.newKeys == DPAD_LEFT && gUnknown_0860CBF1[spriteId][roundId][2] != 0xFF)
+ arrId = 2;
+ else if (gMain.newKeys == DPAD_RIGHT && gUnknown_0860CBF1[spriteId][roundId][3] != 0xFF)
+ arrId = 3;
+ }
+
+ if (arrId != 4)
+ {
+ PlaySE(SE_SELECT);
+ StartSpriteAnim(&gSprites[spriteId], 0);
+ spriteId = gUnknown_0860CBF1[spriteId][roundId][arrId];
+ StartSpriteAnim(&gSprites[spriteId], 1);
+ gTasks[taskId].data[1] = spriteId;
+ }
+
+ return retVal;
+}
+
+static void sub_8193D40(void)
+{
+ u8 taskId = CreateTask(sub_8194220, 0);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = 1;
+ gTasks[taskId].data[2] = 2;
+ gTasks[taskId].data[4] = 0;
+ SetMainCallback2(CB2_BattleDome);
+}
+
+static void sub_8193D7C(void)
+{
+ s32 i;
+
+ if (gSpecialVar_0x8005 == 1)
+ {
+ gSaveBlock2Ptr->frontier.domeTrainers[TrainerIdToTournamentId(gTrainerBattleOpponent_A)].isEliminated = 1;
+ gSaveBlock2Ptr->frontier.domeTrainers[TrainerIdToTournamentId(gTrainerBattleOpponent_A)].eliminatedAt = gSaveBlock2Ptr->frontier.field_CB2;
+ gSaveBlock2Ptr->frontier.field_EC0[TrainerIdToTournamentId(gTrainerBattleOpponent_A)] = gBattleResults.lastUsedMovePlayer;
+ if (gSaveBlock2Ptr->frontier.field_CB2 < DOME_FINAL)
+ DecideRoundWinners(gSaveBlock2Ptr->frontier.field_CB2);
+ }
+ else
+ {
+ gSaveBlock2Ptr->frontier.domeTrainers[TrainerIdToTournamentId(TRAINER_PLAYER)].isEliminated = 1;
+ gSaveBlock2Ptr->frontier.domeTrainers[TrainerIdToTournamentId(TRAINER_PLAYER)].eliminatedAt = gSaveBlock2Ptr->frontier.field_CB2;
+ gSaveBlock2Ptr->frontier.field_EC0[TrainerIdToTournamentId(TRAINER_PLAYER)] = gBattleResults.lastUsedMoveOpponent;
+ if (gBattleOutcome == B_OUTCOME_FORFEITED || gSpecialVar_0x8005 == 9)
+ gSaveBlock2Ptr->frontier.domeTrainers[TrainerIdToTournamentId(TRAINER_PLAYER)].unk3 = 1;
+ for (i = gSaveBlock2Ptr->frontier.field_CB2; i < DOME_ROUNDS_COUNT; i++)
+ DecideRoundWinners(i);
+ }
+}
+
+static u16 GetWinningMove(s32 winnerTournamentId, s32 loserTournamentId, u8 roundId)
+{
+ s32 i, j, k;
+ s32 moveScores[4 * 3];
+ u16 moveIds[4 * 3];
+ u16 bestScore = 0;
+ u16 bestId = 0;
+ s32 movePower = 0;
+ GetFacilityEnemyMonLevel(); // Unused return variable.
+
+ // Calc move points of all 4 moves for all 3 pokemon hitting all 3 target mons.
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ moveScores[i * 4 + j] = 0;
+ if (gSaveBlock2Ptr->frontier.domeTrainers[winnerTournamentId].trainerId == TRAINER_FRONTIER_BRAIN)
+ moveIds[i * 4 + j] = sub_81A5060(i, j);
+ else
+ moveIds[i * 4 + j] = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[winnerTournamentId][i]].moves[j];
+
+ movePower = gBattleMoves[moveIds[i * 4 + j]].power;
+ if (movePower == 0)
+ movePower = 40;
+ else if (movePower == 1)
+ movePower = 60;
+ else if (moveIds[i * 4 + j] == MOVE_SELF_DESTRUCT || moveIds[i * 4 + j] == MOVE_EXPLOSION)
+ movePower /= 2;
+
+ for (k = 0; k < 3; k++)
+ {
+ u32 var = 0;
+ u32 targetSpecies = 0;
+ u32 targetAbility = 0;
+ do
+ {
+ var = Random32();
+ } while (gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[loserTournamentId][k]].nature != GetNatureFromPersonality(var));
+
+ targetSpecies = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[loserTournamentId][k]].species;
+ if (var & 1)
+ targetAbility = gBaseStats[targetSpecies].ability2;
+ else
+ targetAbility = gBaseStats[targetSpecies].ability1;
+
+ var = AI_TypeCalc(moveIds[i * 4 + j], targetSpecies, targetAbility);
+ if (var & MOVE_RESULT_NOT_VERY_EFFECTIVE && var & MOVE_RESULT_SUPER_EFFECTIVE)
+ moveScores[i * 4 + j] += movePower;
+ else if (var & MOVE_RESULT_NO_EFFECT)
+ moveScores[i * 4 + j] += 0;
+ else if (var & MOVE_RESULT_SUPER_EFFECTIVE)
+ moveScores[i * 4 + j] += movePower * 2;
+ else if (var & MOVE_RESULT_NOT_VERY_EFFECTIVE)
+ moveScores[i * 4 + j] += movePower / 2;
+ else
+ moveScores[i * 4 + j] += movePower;
+ }
+
+ if (bestScore < moveScores[i * 4 + j])
+ {
+ bestId = i * 4 + j;
+ bestScore = moveScores[i * 4 + j];
+ }
+ else if (bestScore == moveScores[i * 4 + j])
+ {
+ if (moveIds[bestId] < moveIds[i * 4 + j]) // Why not use (Random() & 1) instead of promoting moves with a higher id?
+ bestId = i * 4 + j;
+ }
+ }
+ }
+
+ j = bestId;
+ goto LABEL;
+ while (j != 0)
+ {
+ for (j = 0, k = 0; k < 4 * 3; k++)
+ {
+ if (bestScore < moveScores[k])
+ {
+ j = k;
+ bestScore = moveScores[k];
+ }
+ else if (bestScore == moveScores[k] && moveIds[j] < moveIds[k])
+ {
+ j = k;
+ }
+ }
+ if (i == roundId - 1)
+ break;
+ LABEL:
+ {
+ for (i = 0; i < roundId - 1; i++)
+ {
+ if (gSaveBlock2Ptr->frontier.field_EC0[sub_81953E8(winnerTournamentId, i)] == moveIds[j])
+ break;
+ }
+ if (i == roundId - 1)
+ break;
+
+ moveScores[j] = 0;
+ bestScore = 0;
+ j = 0;
+ for (k = 0; k < 4 * 3; k++)
+ j += moveScores[k];
+ }
+ }
+
+ if (moveScores[j] == 0)
+ j = bestId;
+
+ return moveIds[j];
+}
+
+static void sub_8194220(u8 taskId)
+{
+ s32 i;
+ struct TextSubPrinter textPrinter;
+ s32 r10 = gTasks[taskId].data[1];
+ s32 r4 = gTasks[taskId].data[2];
+
+ switch (gTasks[taskId].data[0])
+ {
+ case 0:
+ SetHBlankCallback(NULL);
+ SetVBlankCallback(NULL);
+ EnableInterrupts(INTR_FLAG_HBLANK | INTR_FLAG_VBLANK);
+ CpuFill32(0, (void *)VRAM, VRAM_SIZE);
+ ResetBgsAndClearDma3BusyFlags(0);
+ InitBgsFromTemplates(0, gUnknown_0860CE74, ARRAY_COUNT(gUnknown_0860CE74));
+ InitWindows(gUnknown_0860CE94);
+ DeactivateAllTextPrinters();
+ gBattle_BG0_X = 0;
+ gBattle_BG0_Y = 0;
+ gBattle_BG1_X = 0;
+ gBattle_BG1_Y = 0;
+ ChangeBgX(2, 0, 0);
+ ChangeBgY(2, 0, 0);
+ ChangeBgX(3, 0, 0);
+ ChangeBgY(3, 0xB00, 0);
+ gTasks[taskId].data[0]++;
+ break;
+ case 1:
+ SetGpuReg(REG_OFFSET_BLDCNT, 0);
+ SetGpuReg(REG_OFFSET_BLDALPHA, 0);
+ SetGpuReg(REG_OFFSET_BLDY, 0);
+ SetGpuReg(REG_OFFSET_MOSAIC, 0);
+ SetGpuReg(REG_OFFSET_WIN0H, 0x5860);
+ SetGpuReg(REG_OFFSET_WIN0V, 0x9F);
+ SetGpuReg(REG_OFFSET_WIN1H, 0x9098);
+ SetGpuReg(REG_OFFSET_WIN1V, 0x9F);
+ SetGpuReg(REG_OFFSET_WININ, 0);
+ SetGpuReg(REG_OFFSET_WINOUT, 0x3F);
+ ResetPaletteFade();
+ ResetSpriteData();
+ FreeAllSpritePalettes();
+ gTasks[taskId].data[0]++;
+ break;
+ case 2:
+ sTilemapBuffer = AllocZeroed(0x800);
+ LZDecompressWram(gUnknown_08D83900, sTilemapBuffer);
+ SetBgTilemapBuffer(1, sTilemapBuffer);
+ CopyBgTilemapBufferToVram(1);
+ DecompressAndLoadBgGfxUsingHeap(1, gUnknown_08D82F10, 0x2000, 0, 0);
+ DecompressAndLoadBgGfxUsingHeap(2, gUnknown_08D834FC, 0x2000, 0, 0);
+ DecompressAndLoadBgGfxUsingHeap(2, gUnknown_08D83B2C, 0x2000, 0, 1);
+ DecompressAndLoadBgGfxUsingHeap(3, gUnknown_08D83C3C, 0x2000, 0, 1);
+ LoadCompressedPalette(gUnknown_08D85358, 0, 0x200);
+ LoadCompressedPalette(gUnknown_08D85444, 0x100, 0x200);
+ LoadCompressedPalette(gUnknown_08D85600, 0xF0, 0x20);
+ CpuFill32(0, gPlttBufferFaded, 0x400);
+ ShowBg(0);
+ ShowBg(1);
+ ShowBg(2);
+ ShowBg(3);
+ gTasks[taskId].data[0]++;
+ break;
+ case 3:
+ LoadCompressedObjectPic(gUnknown_0860CF50);
+ if (r10 == 0)
+ {
+ for (i = 0; i < (unsigned) 31; i++)
+ CreateSprite(&gUnknown_0860CFA8, gUnknown_0860D411[i][0], gUnknown_0860D411[i][1], 0);
+ if (gTasks[taskId].data[4])
+ CreateSprite(&gUnknown_0860D008, 218, 12, 0);
+ else
+ CreateSprite(&gUnknown_0860CFD8, 218, 12, 0);
+ }
+
+ SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJ_1D_MAP);
+ gTasks[taskId].data[0]++;
+ break;
+ case 4:
+ textPrinter.fontId = 2;
+ textPrinter.current_text_offset = gText_BattleTourney;
+ textPrinter.windowId = 2;
+ textPrinter.x = 0;
+ textPrinter.y = 0;
+ textPrinter.letterSpacing = 2;
+ textPrinter.lineSpacing = 0;
+ textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.current_text_offset, 0x70, textPrinter.letterSpacing);
+ textPrinter.currentY = 1;
+ textPrinter.fontColor_l = 0;
+ textPrinter.fgColor = 14;
+ textPrinter.bgColor = 0;
+ textPrinter.shadowColor = 13;
+ AddTextPrinter(&textPrinter, 0, NULL);
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ s32 var, var2;
+
+ CopyDomeTrainerName(gDisplayedStringBattle, gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId);
+ if (r10 == 1)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt != 0)
+ {
+ var2 = gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt - 1;
+ sub_81948EC(i, var2);
+ }
+ }
+ else if (gSaveBlock2Ptr->frontier.field_CB2 != DOME_ROUND2)
+ {
+ sub_81948EC(i, gSaveBlock2Ptr->frontier.field_CB2 - 2);
+ }
+ }
+ else if (r10 == 0)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt != 0)
+ {
+ var2 = gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt - 1;
+ sub_81948EC(i, var2);
+ }
+ }
+ else if (gSaveBlock2Ptr->frontier.field_CB2 != DOME_ROUND1)
+ {
+ if (gTasks[taskId].data[4])
+ var2 = gSaveBlock2Ptr->frontier.field_CB2;
+ else
+ var2 = gSaveBlock2Ptr->frontier.field_CB2 - 1;
+ sub_81948EC(i, var2);
+ }
+ }
+
+ if (gTasks[taskId].data[4])
+ var = gSaveBlock2Ptr->frontier.field_CB2;
+ else
+ var = gSaveBlock2Ptr->frontier.field_CB2 - 1;
+
+ if ( ((r10 == 1 && gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt < gSaveBlock2Ptr->frontier.field_CB2 - 1)
+ || (r10 == 0 && gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt <= var))
+ && gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId == TRAINER_PLAYER)
+ {
+ textPrinter.fgColor = 3;
+ textPrinter.shadowColor = 4;
+ }
+ else
+ {
+ textPrinter.fgColor = 11;
+ textPrinter.shadowColor = 13;
+ }
+ }
+ else
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId == TRAINER_PLAYER)
+ {
+ textPrinter.fgColor = 3;
+ textPrinter.shadowColor = 4;
+ }
+ else
+ {
+ textPrinter.fgColor = 14;
+ textPrinter.shadowColor = 13;
+ }
+ }
+
+ if (gUnknown_0860D3F1[i][0] == 0)
+ textPrinter.currentX = GetStringWidthDifference(textPrinter.fontId, gDisplayedStringBattle, 0x3D, textPrinter.letterSpacing);
+ else
+ textPrinter.currentX = 3;
+ textPrinter.current_text_offset = gDisplayedStringBattle;
+ textPrinter.windowId = gUnknown_0860D3F1[i][0];
+ textPrinter.currentY = gUnknown_0860D3F1[i][1];
+ AddTextPrinter(&textPrinter, 0, NULL);
+ }
+ gTasks[taskId].data[0]++;
+ break;
+ case 5:
+ PutWindowTilemap(0);
+ PutWindowTilemap(1);
+ PutWindowTilemap(2);
+ CopyWindowToVram(0, 3);
+ CopyWindowToVram(1, 3);
+ CopyWindowToVram(2, 3);
+ SetHBlankCallback(HblankCb_BattleDome);
+ SetVBlankCallback(VblankCb1_BattleDome);
+ if (r4 == 2)
+ {
+ if (r10 == 0)
+ {
+ i = CreateTask(sub_819395C, 0);
+ gTasks[i].data[0] = r10;
+ gTasks[i].data[1] = r10;
+ gTasks[i].data[6] = gTasks[taskId].data[4];
+ }
+ else
+ {
+ i = CreateTask(sub_8194950, 0);
+ gTasks[i].data[0] = 0;
+ }
+ }
+ else
+ {
+ i = gTasks[taskId].data[3];
+ gTasks[i].data[0] = 0;
+ }
+ ScanlineEffect_Clear();
+ for (i = 0; i < 91; i++)
+ {
+ gScanlineEffectRegBuffers[0][i] = 0x1F0A;
+ gScanlineEffectRegBuffers[1][i] = 0x1F0A;
+ }
+ for (i = 91; i < 160; i++)
+ {
+ asm(""::"r"(i));
+ gScanlineEffectRegBuffers[0][i] = 0x1F09;
+ gScanlineEffectRegBuffers[1][i] = 0x1F09;
+ }
+ ScanlineEffect_SetParams(gUnknown_0860CF44);
+ DestroyTask(taskId);
+ break;
+ }
+}
+
+static void sub_81948EC(u8 tournamentId, u8 arg1)
+{
+ s32 i;
+ const struct UnkStruct_860DD10 *structPtr = gUnknown_0860DD10[tournamentId][arg1];
+
+ for (i = 0; i < gUnknown_0860DE10[tournamentId][arg1]; i++)
+ CopyToBgTilemapBufferRect_ChangePalette(1, &structPtr[i].src, structPtr[i].x, structPtr[i].y, 1, 1, 0x11);
+
+ CopyBgTilemapBufferToVram(1);
+}
+
+static void sub_8194950(u8 taskId)
+{
+ s32 i;
+ struct TextSubPrinter textPrinter;
+
+ switch (gTasks[taskId].data[0])
+ {
+ case 0:
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK);
+ gTasks[taskId].data[0] = 1;
+ break;
+ case 1:
+ if (!gPaletteFade.active)
+ {
+ gTasks[taskId].data[0] = 2;
+ gTasks[taskId].data[3] = 64;
+ textPrinter.fontId = 2;
+ textPrinter.x = 0;
+ textPrinter.y = 0;
+ textPrinter.letterSpacing = 2;
+ textPrinter.lineSpacing = 0;
+ textPrinter.fontColor_l = 0;
+ textPrinter.fgColor = 11;
+ textPrinter.bgColor = 0;
+ textPrinter.shadowColor = 13;
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ CopyDomeTrainerName(gDisplayedStringBattle, gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId);
+ if (gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt == gSaveBlock2Ptr->frontier.field_CB2 - 1
+ && gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated)
+ {
+ if (gUnknown_0860D3F1[i][0] == 0)
+ textPrinter.currentX = GetStringWidthDifference(textPrinter.fontId, gDisplayedStringBattle, 0x3D, textPrinter.letterSpacing);
+ else
+ textPrinter.currentX = 3;
+
+ textPrinter.current_text_offset = gDisplayedStringBattle;
+ textPrinter.windowId = gUnknown_0860D3F1[i][0];
+ textPrinter.currentY = gUnknown_0860D3F1[i][1];
+ AddTextPrinter(&textPrinter, 0, NULL);
+ }
+ if (!gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated)
+ {
+ s32 var = gSaveBlock2Ptr->frontier.field_CB2 - 1;
+ sub_81948EC(i, var);
+ }
+ }
+ }
+ break;
+ case 2:
+ if (--gTasks[taskId].data[3] == 0)
+ gTasks[taskId].data[0] = 3;
+ break;
+ case 3:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ {
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
+ gTasks[taskId].data[0] = 4;
+ }
+ break;
+ case 4:
+ if (!gPaletteFade.active)
+ {
+ SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
+ DestroyTask(taskId);
+ }
+ break;
+ }
+}
+
+static void CB2_BattleDome(void)
+{
+ AnimateSprites();
+ BuildOamBuffer();
+ RunTextPrinters();
+ UpdatePaletteFade();
+ RunTasks();
+}
+
+static void VblankCb0_BattleDome(void)
+{
+ ChangeBgX(3, 0x80, 1);
+ ChangeBgY(3, 0x80, 2);
+ SetGpuReg(REG_OFFSET_BG0HOFS, gBattle_BG0_X);
+ SetGpuReg(REG_OFFSET_BG0VOFS, gBattle_BG0_Y);
+ SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X);
+ SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y);
+ SetGpuReg(REG_OFFSET_BG2HOFS, gBattle_BG2_X);
+ SetGpuReg(REG_OFFSET_BG2VOFS, gBattle_BG2_Y);
+ LoadOam();
+ ProcessSpriteCopyRequests();
+ TransferPlttBuffer();
+}
+
+#define SET_WIN0H_WIN1H(win0H, win1H) \
+{ \
+ *(vu32*)(REG_ADDR_WIN0H) = ((win0H << 16) | (win1H)); \
+}
+
+static void HblankCb_BattleDome(void)
+{
+ register u32 vCount asm("r0") = REG_VCOUNT;
+ register u32 vCount_ asm("r1") = vCount;
+ if (vCount > 41)
+ {
+ if (vCount < 50)
+ {
+ REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
+ SET_WIN0H_WIN1H(WINHV_COORDS(152, 155), WINHV_COORDS(85, 88));
+ return;
+ }
+ else if (vCount > 57)
+ {
+ if (vCount < 75)
+ {
+ REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
+ SET_WIN0H_WIN1H(WINHV_COORDS(144, 152), WINHV_COORDS(88, 96));
+ return;
+ }
+ else if (vCount < 82)
+ {
+ REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
+ SET_WIN0H_WIN1H(WINHV_COORDS(152, 155), WINHV_COORDS(85, 88));
+ return;
+ }
+ else if (vCount > 94)
+ {
+ if (vCount < 103)
+ {
+ REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
+ SET_WIN0H_WIN1H(WINHV_COORDS(152, 155), WINHV_COORDS(85, 88));
+ return;
+ }
+ else if (vCount < 119)
+ {
+ REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
+ SET_WIN0H_WIN1H(WINHV_COORDS(144, 152), WINHV_COORDS(88, 96));
+ return;
+ }
+ else if (vCount > 126)
+ {
+ if (vCount_ < 135)
+ {
+ REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
+ SET_WIN0H_WIN1H(WINHV_COORDS(152, 155), WINHV_COORDS(85, 88));
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ | WININ_WIN1_BG_ALL | WININ_WIN1_CLR | WININ_WIN1_OBJ;
+ SET_WIN0H_WIN1H(0, 0);
+}
+
+static void VblankCb1_BattleDome(void)
+{
+ SetGpuReg(REG_OFFSET_BG0HOFS, gBattle_BG0_X);
+ SetGpuReg(REG_OFFSET_BG0VOFS, gBattle_BG0_Y);
+ SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X);
+ SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y);
+ ChangeBgY(2, 0x80, 2);
+ ChangeBgY(3, 0x80, 1);
+ LoadOam();
+ ProcessSpriteCopyRequests();
+ TransferPlttBuffer();
+ ScanlineEffect_InitHBlankDmaTransfer();
+}
+
+static void sub_8194D48(void)
+{
+ gFacilityTrainerMons = gBattleFrontierMons;
+ gFacilityTrainers = gBattleFrontierTrainers;
+}
+
+static void sub_8194D68(void)
+{
+ s32 i, moveSlot;
+
+ for (i = 0; i < 2; i++)
+ {
+ s32 playerMonId = gSaveBlock2Ptr->frontier.field_CAA[gUnknown_0203CEF8[i] - 1] - 1;
+ s32 count;
+
+ for (moveSlot = 0; moveSlot < 4; moveSlot++)
+ {
+ count = 0;
+ while (count < 4)
+ {
+ if (GetMonData(&gSaveBlock1Ptr->playerParty[playerMonId], MON_DATA_MOVE1 + count, NULL) == GetMonData(&gPlayerParty[i], MON_DATA_MOVE1 + moveSlot, NULL))
+ break;
+ count++;
+ }
+ if (count == 4)
+ SetMonMoveSlot(&gPlayerParty[i], MOVE_SKETCH, moveSlot);
+ }
+
+ gSaveBlock1Ptr->playerParty[playerMonId] = gPlayerParty[i];
+ }
+}
+
+static void sub_8194E44(void)
+{
+ s32 i;
+
+ for (i = 0; i < 2; i++)
+ {
+ s32 playerMonId = gSaveBlock2Ptr->frontier.field_CAA[gUnknown_0203CEF8[i] - 1] - 1;
+ u16 item = GetMonData(&gSaveBlock1Ptr->playerParty[playerMonId], MON_DATA_HELD_ITEM, NULL);
+ SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &item);
+ }
+}
+
+static void sub_8194EB4(void)
+{
+ sub_80F94E8();
+}
+
+static void sub_8194EC0(void)
+{
+ if (TrainerIdToTournamentId(gTrainerBattleOpponent_A) > TrainerIdToTournamentId(TRAINER_PLAYER))
+ gSpecialVar_Result = 1;
+ else
+ gSpecialVar_Result = 2;
+}
+
+static void sub_8194EF8(void)
+{
+ s32 i;
+
+ sub_8194D48();
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ if (!gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated)
+ break;
+ }
+ CopyDomeTrainerName(gStringVar1, gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId);
+}
+
+static void sub_8194F58(void)
+{
+ s32 i, j, k;
+ s32 monLevel;
+ s32 species[3];
+ s32 monTypesBits;
+ s32 trainerId;
+ s32 monTournamentId;
+ u8 lvlMode;
+ u16 *statSums;
+ s32 *statValues;
+ u8 ivs = 0;
+
+ species[0] = 0;
+ species[1] = 0;
+ species[2] = 0;
+ if ((gSaveBlock2Ptr->frontier.field_D0A != -gSaveBlock2Ptr->frontier.field_D0B) && gSaveBlock2Ptr->frontier.field_CA8 != 1)
+ return;
+
+ statSums = AllocZeroed(sizeof(u16) * DOME_TOURNAMENT_TRAINERS_COUNT);
+ statValues = AllocZeroed(sizeof(s32) * 6);
+ lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
+ gSaveBlock2Ptr->frontier.lvlMode = 0;
+ // This one, I'd like to call a 'C fakematching'.
+ {
+ u8 one;
+ gSaveBlock2Ptr->frontier.field_D0A = (one = 1);
+ gSaveBlock2Ptr->frontier.field_D0B = one;
+ }
+
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ do
+ {
+ if (i < 5)
+ trainerId = Random() % 10;
+ else if (i < 15)
+ trainerId = Random() % 20 + 10;
+ else
+ trainerId = Random() % 10 + 30;
+
+ for (j = 0; j < i; j++)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[j].trainerId == trainerId)
+ break;
+ }
+ } while (j != i);
+
+ gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId = trainerId;
+ for (j = 0; j < 3; j++)
+ {
+ // Make sure the mon is valid.
+ do
+ {
+ monTournamentId = RandomizeFacilityTrainerMonId(trainerId);
+ for (k = 0; k < j; k++)
+ {
+ s32 checkingMonId = gSaveBlock2Ptr->frontier.domeMonId[i][k];
+ if (checkingMonId == monTournamentId
+ || species[0] == gFacilityTrainerMons[monTournamentId].species
+ || species[1] == gFacilityTrainerMons[monTournamentId].species
+ || gFacilityTrainerMons[checkingMonId].itemTableId == gFacilityTrainerMons[monTournamentId].itemTableId)
+ break;
+ }
+ } while (k != j);
+
+ gSaveBlock2Ptr->frontier.domeMonId[i][j] = monTournamentId;
+ species[j] = gFacilityTrainerMons[monTournamentId].species;
+ }
+ gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated = 0;
+ gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt = 0;
+ gSaveBlock2Ptr->frontier.domeTrainers[i].unk3 = 0;
+ }
+
+ monLevel = 50;
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ monTypesBits = 0;
+ statSums[i] = 0;
+ ivs = GetDomeTrainerMonIvs(gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId);
+ for (j = 0; j < 3; j++)
+ {
+ CalcDomeMonStats(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].species,
+ monLevel, ivs,
+ gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].evSpread,
+ gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].nature,
+ statValues);
+
+ statSums[i] += statValues[STAT_ATK];
+ statSums[i] += statValues[STAT_DEF];
+ statSums[i] += statValues[STAT_SPATK];
+ statSums[i] += statValues[STAT_SPDEF];
+ statSums[i] += statValues[STAT_SPEED];
+ statSums[i] += statValues[STAT_HP];
+ monTypesBits |= gBitTable[gBaseStats[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].species].type1];
+ monTypesBits |= gBitTable[gBaseStats[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[i][j]].species].type2];
+ }
+
+ // Because GF hates temporary vars, trainerId acts like monTypesCount here.
+ for (trainerId = 0, j = 0; j < 32; j++)
+ {
+ if (monTypesBits & 1)
+ trainerId++;
+ monTypesBits >>= 1;
+ }
+ statSums[i] += (trainerId * monLevel) / 20;
+ }
+
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT - 1; i++)
+ {
+ for (j = i + 1; j < DOME_TOURNAMENT_TRAINERS_COUNT; j++)
+ {
+ if (statSums[i] < statSums[j])
+ {
+ SwapDomeTrainers(i, j, statSums);
+ }
+ else if (statSums[i] == statSums[j])
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId > gSaveBlock2Ptr->frontier.domeTrainers[j].trainerId)
+ SwapDomeTrainers(i, j, statSums);
+ }
+ }
+ }
+
+ Free(statSums);
+ Free(statValues);
+
+ for (i = 0; i < 4; i++)
+ DecideRoundWinners(i);
+
+ gSaveBlock2Ptr->frontier.lvlMode = lvlMode;
+}
+
+static s32 TrainerIdToTournamentId(u16 trainerId)
+{
+ s32 i;
+
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId == trainerId)
+ break;
+ }
+
+ return i;
+}
+
+// The same as the above one, but has global scope.
+s32 TrainerIdToDomeTournamentId(u16 trainerId)
+{
+ s32 i;
+
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId == trainerId)
+ break;
+ }
+
+ return i;
+}
+
+static u8 sub_81953E8(u8 tournamentId, u8 arg1)
+{
+ u8 arr[2];
+ sub_8192F08(gUnknown_0860D1A0[gUnknown_0860D1C0[tournamentId] / 2][arg1] - 16, arr);
+ if (tournamentId == arr[0])
+ return arr[1];
+ else
+ return arr[0];
+}
+
+static void DecideRoundWinners(u8 roundId)
+{
+ s32 i;
+ s32 moveSlot, monId1, monId2;
+ s32 tournamentId1, tournamentId2;
+ s32 species;
+ s32 points1 = 0, points2 = 0;
+
+ for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
+ {
+ if (gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated || gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId == TRAINER_PLAYER)
+ continue;
+
+ tournamentId1 = i;
+ tournamentId2 = TournamentIdOfOpponent(roundId, gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].trainerId);
+ // Frontier Brain always wins, check tournamentId1.
+ if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].trainerId == TRAINER_FRONTIER_BRAIN && tournamentId2 != 0xFF)
+ {
+ gSaveBlock2Ptr->frontier.domeTrainers[tournamentId2].isEliminated = 1;
+ gSaveBlock2Ptr->frontier.domeTrainers[tournamentId2].eliminatedAt = roundId;
+ gSaveBlock2Ptr->frontier.field_EC0[tournamentId2] = GetWinningMove(tournamentId1, tournamentId2, roundId);
+ }
+ // Frontier Brain always wins, check tournamentId2.
+ else if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentId2].trainerId == TRAINER_FRONTIER_BRAIN && tournamentId1 != 0xFF)
+ {
+ gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].isEliminated = 1;
+ gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].eliminatedAt = roundId;
+ gSaveBlock2Ptr->frontier.field_EC0[tournamentId1] = GetWinningMove(tournamentId2, tournamentId1, roundId);
+ }
+ // Decide which one of two trainers wins!
+ else if (tournamentId2 != 0xFF)
+ {
+ // BUG: points1 and points2 are not cleared at the beginning of the loop resulting in not fair results.
+
+ // Calculate points for both trainers.
+ for (monId1 = 0; monId1 < 3; monId1++)
+ {
+ for (moveSlot = 0; moveSlot < 4; moveSlot++)
+ {
+ for (monId2 = 0; monId2 < 3; monId2++)
+ {
+ points1 += GetTypeEffectivenessPoints(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentId1][monId1]].moves[moveSlot],
+ gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentId2][monId2]].species, 2);
+ }
+ }
+ species = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentId1][monId1]].species;
+ points1 += ( gBaseStats[species].baseHP
+ + gBaseStats[species].baseAttack
+ + gBaseStats[species].baseDefense
+ + gBaseStats[species].baseSpeed
+ + gBaseStats[species].baseSpAttack
+ + gBaseStats[species].baseSpDefense) / 10;
+ }
+ // Random part of the formula.
+ points1 += (Random() & 0x1F);
+ // Favor trainers with higher id;
+ points1 += tournamentId1;
+
+ for (monId1 = 0; monId1 < 3; monId1++)
+ {
+ for (moveSlot = 0; moveSlot < 4; moveSlot++)
+ {
+ for (monId2 = 0; monId2 < 3; monId2++)
+ {
+ points2 += GetTypeEffectivenessPoints(gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentId2][monId1]].moves[moveSlot],
+ gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentId1][monId2]].species, 2);
+ }
+ }
+ species = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentId2][monId1]].species;
+ points2 += ( gBaseStats[species].baseHP
+ + gBaseStats[species].baseAttack
+ + gBaseStats[species].baseDefense
+ + gBaseStats[species].baseSpeed
+ + gBaseStats[species].baseSpAttack
+ + gBaseStats[species].baseSpDefense) / 10;
+ }
+ // Random part of the formula.
+ points2 += (Random() & 0x1F);
+ // Favor trainers with higher id;
+ points2 += tournamentId2;
+
+ if (points1 > points2)
+ {
+ gSaveBlock2Ptr->frontier.domeTrainers[tournamentId2].isEliminated = 1;
+ gSaveBlock2Ptr->frontier.domeTrainers[tournamentId2].eliminatedAt = roundId;
+ gSaveBlock2Ptr->frontier.field_EC0[tournamentId2] = GetWinningMove(tournamentId1, tournamentId2, roundId);
+ }
+ else if (points1 < points2)
+ {
+ gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].isEliminated = 1;
+ gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].eliminatedAt = roundId;
+ gSaveBlock2Ptr->frontier.field_EC0[tournamentId1] = GetWinningMove(tournamentId2, tournamentId1, roundId);
+ }
+ // Points are the same, so we favor the one with the higher id.
+ else if (tournamentId1 > tournamentId2)
+ {
+ gSaveBlock2Ptr->frontier.domeTrainers[tournamentId2].isEliminated = 1;
+ gSaveBlock2Ptr->frontier.domeTrainers[tournamentId2].eliminatedAt = roundId;
+ gSaveBlock2Ptr->frontier.field_EC0[tournamentId2] = GetWinningMove(tournamentId1, tournamentId2, roundId);
+ }
+ else
+ {
+ gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].isEliminated = 1;
+ gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].eliminatedAt = roundId;
+ gSaveBlock2Ptr->frontier.field_EC0[tournamentId1] = GetWinningMove(tournamentId2, tournamentId1, roundId);
+ }
+ }
+ }
+}
+
+static void CopyDomeTrainerName(u8 *dst, u16 trainerId)
+{
+ s32 i = 0;
+ GetFacilityEnemyMonLevel(); // Unused return value.
+
+ if (trainerId == TRAINER_FRONTIER_BRAIN)
+ {
+ CopyDomeBrainTrainerName(dst);
+ }
+ else
+ {
+ if (trainerId == TRAINER_PLAYER)
+ {
+ for (i = 0; i < OT_NAME_LENGTH; i++)
+ dst[i] = gSaveBlock2Ptr->playerName[i];
+ }
+ else if (trainerId < 300)
+ {
+ for (i = 0; i < 7; i++)
+ dst[i] = gFacilityTrainers[trainerId].trainerName[i];
+ }
+ dst[i] = EOS;
+ }
+}
+
+static u8 GetDomeBrainTrainerPicId(void)
+{
+ return gTrainers[TRAINER_TUCKER].trainerPic;
+}
+
+static u8 GetDomeBrainTrainerClass(void)
+{
+ return gTrainers[TRAINER_TUCKER].trainerClass;
+}
+
+static void CopyDomeBrainTrainerName(u8 *dst)
+{
+ s32 i;
+
+ for (i = 0; i < 7; i++)
+ dst[i] = gTrainers[TRAINER_TUCKER].trainerName[i];
+ dst[i] = EOS;
+}
diff --git a/src/battle_frontier_1.c b/src/battle_frontier_1.c
new file mode 100644
index 000000000..ee8a42954
--- /dev/null
+++ b/src/battle_frontier_1.c
@@ -0,0 +1,118 @@
+#include "global.h"
+#include "event_data.h"
+#include "battle_setup.h"
+#include "overworld.h"
+#include "random.h"
+#include "battle_tower.h"
+
+extern void sub_8162614(u16, u8);
+
+extern void (* const gUnknown_0860DE50[])(void);
+extern const u32 gUnknown_0860DE98[][2];
+extern const u32 gUnknown_0860DEA8[][2];
+
+// code
+void sub_8195960(void)
+{
+ gUnknown_0860DE50[gSpecialVar_0x8004]();
+}
+
+void sub_8195980(void)
+{
+ u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
+ u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
+
+ gSaveBlock2Ptr->frontier.field_CA8 = 0;
+ gSaveBlock2Ptr->frontier.field_CB2 = 0;
+ gSaveBlock2Ptr->frontier.field_CA9_a = 0;
+ gSaveBlock2Ptr->frontier.field_CA9_b = 0;
+ if (!(gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860DE98[battleMode][lvlMode]))
+ gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode] = 0;
+
+ saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
+ gTrainerBattleOpponent_A = 0;
+}
+
+void sub_8195A38(void)
+{
+ u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
+ u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
+
+ switch (gSpecialVar_0x8005)
+ {
+ case 0:
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_DC4[1];
+ break;
+ case 1:
+ gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode];
+ break;
+ case 2:
+ gSpecialVar_Result = ((gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860DE98[battleMode][lvlMode]) != 0);
+ break;
+ }
+}
+
+void sub_8195AE4(void)
+{
+ u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
+ u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
+
+ switch (gSpecialVar_0x8005)
+ {
+ case 0:
+ gSaveBlock2Ptr->frontier.field_DC4[1] = gSpecialVar_0x8006;
+ break;
+ case 1:
+ gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode] = gSpecialVar_0x8006;
+ break;
+ case 2:
+ if (gSpecialVar_0x8006)
+ gSaveBlock2Ptr->frontier.field_CDC |= gUnknown_0860DE98[battleMode][lvlMode];
+ else
+ gSaveBlock2Ptr->frontier.field_CDC &= gUnknown_0860DEA8[battleMode][lvlMode];
+ break;
+ }
+}
+
+void sub_8195BB0(void)
+{
+ u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
+ u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
+
+ if (gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode] < 50)
+ gSpecialVar_Result = Random() % 3;
+ else if (gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode] < 99)
+ gSpecialVar_Result = 3;
+ else
+ gSpecialVar_Result = 4;
+}
+
+void sub_8195C20(void)
+{
+ gTrainerBattleOpponent_A = 5 *(Random() % 255) / 64u;
+ sub_8162614(gTrainerBattleOpponent_A, 0);
+}
+
+void sub_8195C50(void)
+{
+ if (gTrainerBattleOpponent_A < 300)
+ ConvertBattleFrontierTrainerSpeechToString(gFacilityTrainers[gTrainerBattleOpponent_A].speechBefore);
+}
+
+/*
+void sub_8195C7C(void)
+{
+ u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
+ u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
+
+ if (gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode] < 9999)
+ {
+ u16 wat = 0;
+ gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode]++;
+ if (lvlMode < gSaveBlock2Ptr->frontier.field_DD0[battleMode][lvlMode])
+ wat = 1;
+ if (gSaveBlock2Ptr->frontier.field_DC8[battleMode][wat] != 0)
+ gSaveBlock2Ptr->frontier.field_DD0[battleMode][lvlMode] = gSaveBlock2Ptr->frontier.field_DC8[battleMode][lvlMode];
+ }
+}
+*/
diff --git a/src/battle_main.c b/src/battle_main.c
index 86937f85f..9f9511c38 100644
--- a/src/battle_main.c
+++ b/src/battle_main.c
@@ -3929,7 +3929,7 @@ static void TryDoEventsBeforeFirstTurn(void)
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
{
StopCryAndClearCrySongs();
- BattleScriptExecute(BattleScript_82DB8BE);
+ BattleScriptExecute(BattleScript_ArenaTurnBeginning);
}
}
@@ -4019,7 +4019,7 @@ void BattleTurnPassed(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
BattleScriptExecute(BattleScript_82DB881);
else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->field_DA == 0)
- BattleScriptExecute(BattleScript_82DB8BE);
+ BattleScriptExecute(BattleScript_ArenaTurnBeginning);
}
u8 IsRunningFromBattleImpossible(void)
diff --git a/src/battle_message.c b/src/battle_message.c
index 13502d6f2..78b9ac53b 100644
--- a/src/battle_message.c
+++ b/src/battle_message.c
@@ -1248,7 +1248,7 @@ static const u8 sText_Round2[] = _("Round 2");
static const u8 sText_Semifinal[] = _("Semifinal");
static const u8 sText_Final[] = _("Final");
-const u8 * const gRoundsStringTable[] =
+const u8 *const gRoundsStringTable[] =
{
sText_Round1,
sText_Round2,
diff --git a/src/battle_pyramid.c b/src/battle_pyramid_bag.c
index f9cc48a9a..f9cc48a9a 100644
--- a/src/battle_pyramid.c
+++ b/src/battle_pyramid_bag.c
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index b13727a12..12a66df80 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -6750,10 +6750,10 @@ static void atk76_various(void)
}
}
break;
- case 21:
+ case VARIOUS_VOLUME_DOWN:
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x55);
break;
- case 22:
+ case VARIOUS_VOLUME_UP:
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
break;
case 23:
diff --git a/src/battle_setup.c b/src/battle_setup.c
index 2955a33fc..17ab20ccd 100644
--- a/src/battle_setup.c
+++ b/src/battle_setup.c
@@ -33,6 +33,7 @@
#include "field_weather.h"
#include "gym_leader_rematch.h"
#include "constants/map_types.h"
+#include "constants/battle_frontier.h"
enum
{
@@ -863,7 +864,7 @@ u8 sub_80B100C(s32 arg0)
return sUnknown_0854FEA7[Random() % ARRAY_COUNT(sUnknown_0854FEA7)];
}
- if (VarGet(VAR_0x40CE) != 3)
+ if (VarGet(VAR_FRONTIER_BATTLE_MODE) != FRONTIER_MODE_LINK_MULTIS)
return sUnknown_0854FE98[Random() % ARRAY_COUNT(sUnknown_0854FE98)];
}
else
@@ -880,7 +881,7 @@ u8 sub_80B100C(s32 arg0)
return sUnknown_0854FEA7[Random() % ARRAY_COUNT(sUnknown_0854FEA7)];
}
- if (VarGet(VAR_0x40CE) != 3)
+ if (VarGet(VAR_FRONTIER_BATTLE_MODE) != FRONTIER_MODE_LINK_MULTIS)
return sUnknown_0854FE98[Random() % ARRAY_COUNT(sUnknown_0854FE98)];
}
diff --git a/src/battle_tent.c b/src/battle_tent.c
index 68d7c5e83..516f3fc4d 100644
--- a/src/battle_tent.c
+++ b/src/battle_tent.c
@@ -11,7 +11,11 @@
#include "constants/items.h"
#include "constants/region_map_sections.h"
-// this file's functions
+extern const struct BattleFrontierTrainer gSlateportBattleTentTrainers[];
+extern const struct FacilityMon gSlateportBattleTentMons[];
+extern const u16 gBattleFrontierHeldItems[];
+
+// This file's functions.
void sub_81B99D4(void);
void sub_81B9A28(void);
void sub_81B9A44(void);
@@ -51,7 +55,7 @@ void (*const gUnknown_086160B4[])(void) =
sub_81B9B28
};
-const u16 gUnknown_086160D4[] = {ITEM_NEST_BALL, ITEM_NONE};
+static const u16 sVerdanturfTentRewards[] = {ITEM_NEST_BALL};
void (*const gUnknown_086160D8[])(void) =
{
@@ -64,7 +68,7 @@ void (*const gUnknown_086160D8[])(void) =
sub_81B9CF0
};
-const u16 gUnknown_086160F4[] = {ITEM_HYPER_POTION, ITEM_NONE};
+static const u16 sFallarborTentRewards[] = {ITEM_HYPER_POTION};
void (*const gUnknown_086160F8[])(void) =
{
@@ -80,7 +84,7 @@ void (*const gUnknown_086160F8[])(void) =
sub_81B9EC0
};
-const u16 gUnknown_08616120[] = {ITEM_FULL_HEAL, ITEM_NONE};
+static const u16 sSlateportTentRewards[] = {ITEM_FULL_HEAL};
// code
void sub_81B99B4(void)
@@ -115,7 +119,7 @@ void sub_81B9A60(void)
void sub_81B9A90(void)
{
if (gTrainerBattleOpponent_A < 300)
- ConvertBattleFrontierTrainerSpeechToString(gUnknown_0203BC88[gTrainerBattleOpponent_A].speechBefore);
+ ConvertBattleFrontierTrainerSpeechToString(gFacilityTrainers[gTrainerBattleOpponent_A].speechBefore);
}
void sub_81B9ABC(void)
@@ -128,7 +132,7 @@ void sub_81B9ABC(void)
void sub_81B9B00(void)
{
- gSaveBlock2Ptr->frontier.field_E6A = gUnknown_086160D4[Random() % 1];
+ gSaveBlock2Ptr->frontier.field_E6A = sVerdanturfTentRewards[Random() % ARRAY_COUNT(sVerdanturfTentRewards)];
}
void sub_81B9B28(void)
@@ -178,7 +182,7 @@ void sub_81B9C2C(void)
void sub_81B9C70(void)
{
- gSaveBlock2Ptr->frontier.field_E6C = gUnknown_086160F4[Random() % 1];
+ gSaveBlock2Ptr->frontier.field_E6C = sFallarborTentRewards[Random() % ARRAY_COUNT(sFallarborTentRewards)];
}
void sub_81B9C98(void)
@@ -233,7 +237,7 @@ void sub_81B9DB4(void)
void sub_81B9DF8(void)
{
- gSaveBlock2Ptr->frontier.field_E6E = gUnknown_08616120[Random() % 1];
+ gSaveBlock2Ptr->frontier.field_E6E = sSlateportTentRewards[Random() % ARRAY_COUNT(sSlateportTentRewards)];
}
void sub_81B9E20(void)
@@ -266,3 +270,259 @@ bool8 sub_81B9E94(void)
return (gMapHeader.regionMapSectionId == MAPSEC_SLATEPORT_CITY
&& ((gMapHeader.mapLayoutId == 385) | (gMapHeader.mapLayoutId == 386)));
}
+
+// This function was written very...oddly.
+#ifdef NONMATCHING
+void sub_81B9EC0(void)
+{
+ s32 i, j;
+ u16 currMonId = 0, currSpecies = 0;
+ u16 species[PARTY_SIZE];
+ u16 monIds[PARTY_SIZE];
+ u16 heldItems[PARTY_SIZE];
+ s32 zero = 0;
+
+ gFacilityTrainers = gSlateportBattleTentTrainers;
+ for (i = 0; i < PARTY_SIZE; i++)
+ {
+ species[i] = 0;
+ monIds[i] = 0;
+ heldItems[i] = 0;
+ }
+ gFacilityTrainerMons = gSlateportBattleTentMons;
+ currSpecies = 0;
+ for (i = 0; i != PARTY_SIZE;)
+ {
+ // Cannot have two pokemon of the same species.
+ currMonId = Random() % 70;
+ for (j = zero; j < i + zero; j++)
+ {
+ if (monIds[j] == currMonId)
+ break;
+ if (species[j] == gFacilityTrainerMons[currMonId].species)
+ {
+ if (currSpecies == 0)
+ currSpecies = gFacilityTrainerMons[currMonId].species;
+ else
+ break;
+ }
+ }
+ if (j != i + zero)
+ continue;
+
+ // Cannot have two same held items.
+ for (j = zero; j < i + zero; j++)
+ {
+ if (heldItems[j] == 0)
+ continue;
+ if (heldItems[j] == gBattleFrontierHeldItems[gFacilityTrainerMons[currMonId].itemTableId])
+ {
+ if (gFacilityTrainerMons[currMonId].species == currSpecies)
+ currSpecies = 0;
+ else
+ break;
+ }
+ }
+ if (j != i + zero)
+ continue;
+
+ gSaveBlock2Ptr->frontier.field_E70[i].monId = currMonId;
+ species[i] = gFacilityTrainerMons[currMonId].species;
+ heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[currMonId].itemTableId];
+ monIds[i] = currMonId;
+ i++;
+ }
+}
+#else
+NAKED
+void sub_81B9EC0(void)
+{
+ asm_unified("\n\
+ push {r4-r7,lr}\n\
+ mov r7, r10\n\
+ mov r6, r9\n\
+ mov r5, r8\n\
+ push {r5-r7}\n\
+ sub sp, 0x3C\n\
+ ldr r1, =gFacilityTrainers\n\
+ ldr r0, =gSlateportBattleTentTrainers\n\
+ str r0, [r1]\n\
+ add r0, sp, 0xC\n\
+ mov r9, r0\n\
+ mov r1, sp\n\
+ adds r1, 0x18\n\
+ str r1, [sp, 0x2C]\n\
+ ldr r5, =gFacilityTrainerMons\n\
+ ldr r4, =gSlateportBattleTentMons\n\
+ movs r2, 0\n\
+ adds r3, r1, 0\n\
+ mov r1, r9\n\
+ mov r0, sp\n\
+ movs r6, 0x5\n\
+ mov r8, r6\n\
+_081B9EEC:\n\
+ strh r2, [r0]\n\
+ strh r2, [r1]\n\
+ strh r2, [r3]\n\
+ adds r3, 0x2\n\
+ adds r1, 0x2\n\
+ adds r0, 0x2\n\
+ movs r7, 0x1\n\
+ negs r7, r7\n\
+ add r8, r7\n\
+ mov r6, r8\n\
+ cmp r6, 0\n\
+ bge _081B9EEC\n\
+ str r4, [r5]\n\
+ movs r7, 0\n\
+ mov r10, r7\n\
+ movs r0, 0\n\
+ mov r8, r0\n\
+ ldr r1, [sp, 0x2C]\n\
+ str r1, [sp, 0x30]\n\
+ mov r2, sp\n\
+ str r2, [sp, 0x34]\n\
+ lsls r6, r0, 1\n\
+ str r6, [sp, 0x24]\n\
+ add r6, r9\n\
+ str r6, [sp, 0x28]\n\
+_081B9F1E:\n\
+ bl Random\n\
+ lsls r0, 16\n\
+ lsrs r0, 16\n\
+ movs r1, 0x46\n\
+ bl __umodsi3\n\
+ lsls r0, 16\n\
+ lsrs r5, r0, 16\n\
+ movs r2, 0\n\
+ mov r7, r8\n\
+ adds r6, r2, r7\n\
+ cmp r2, r6\n\
+ bge _081B9F7C\n\
+ ldr r1, [sp, 0x28]\n\
+ ldrh r0, [r1]\n\
+ cmp r0, r5\n\
+ beq _081B9F7C\n\
+ ldr r0, =gFacilityTrainerMons\n\
+ ldr r1, [r0]\n\
+ lsls r0, r5, 4\n\
+ adds r4, r0, r1\n\
+ ldrh r7, [r4]\n\
+ mov r12, r7\n\
+ lsls r3, r2, 1\n\
+ ldr r1, [sp, 0x24]\n\
+ add r1, sp\n\
+ str r6, [sp, 0x38]\n\
+_081B9F56:\n\
+ ldrh r0, [r1]\n\
+ cmp r0, r12\n\
+ bne _081B9F66\n\
+ mov r0, r10\n\
+ cmp r0, 0\n\
+ bne _081B9F7C\n\
+ ldrh r7, [r4]\n\
+ mov r10, r7\n\
+_081B9F66:\n\
+ adds r3, 0x2\n\
+ adds r1, 0x2\n\
+ adds r2, 0x1\n\
+ ldr r0, [sp, 0x38]\n\
+ cmp r2, r0\n\
+ bge _081B9F7C\n\
+ mov r7, r9\n\
+ adds r0, r7, r3\n\
+ ldrh r0, [r0]\n\
+ cmp r0, r5\n\
+ bne _081B9F56\n\
+_081B9F7C:\n\
+ cmp r2, r6\n\
+ bne _081BA01C\n\
+ movs r2, 0\n\
+ cmp r2, r6\n\
+ bge _081B9FD4\n\
+ ldr r0, =gBattleFrontierHeldItems\n\
+ mov r12, r0\n\
+ ldr r7, =gFacilityTrainerMons\n\
+ ldr r1, [sp, 0x24]\n\
+ ldr r0, [sp, 0x2C]\n\
+ adds r4, r1, r0\n\
+_081B9F92:\n\
+ ldrh r3, [r4]\n\
+ cmp r3, 0\n\
+ beq _081B9FCC\n\
+ ldr r1, [r7]\n\
+ lsls r0, r5, 4\n\
+ adds r1, r0, r1\n\
+ ldrb r0, [r1, 0xA]\n\
+ lsls r0, 1\n\
+ add r0, r12\n\
+ ldrh r0, [r0]\n\
+ cmp r3, r0\n\
+ bne _081B9FCC\n\
+ ldrh r0, [r1]\n\
+ cmp r0, r10\n\
+ bne _081B9FD4\n\
+ movs r1, 0\n\
+ mov r10, r1\n\
+ b _081B9FD4\n\
+ .pool\n\
+_081B9FCC:\n\
+ adds r4, 0x2\n\
+ adds r2, 0x1\n\
+ cmp r2, r6\n\
+ blt _081B9F92\n\
+_081B9FD4:\n\
+ cmp r2, r6\n\
+ bne _081BA01C\n\
+ ldr r0, =gSaveBlock2Ptr\n\
+ ldr r1, [r0]\n\
+ mov r2, r8\n\
+ lsls r3, r2, 1\n\
+ adds r0, r3, r2\n\
+ lsls r0, 2\n\
+ adds r1, r0\n\
+ movs r6, 0xE7\n\
+ lsls r6, 4\n\
+ adds r1, r6\n\
+ strh r5, [r1]\n\
+ ldr r0, =gFacilityTrainerMons\n\
+ ldr r0, [r0]\n\
+ lsls r1, r5, 4\n\
+ adds r1, r0\n\
+ ldrh r0, [r1]\n\
+ ldr r7, [sp, 0x34]\n\
+ strh r0, [r7]\n\
+ ldr r2, =gBattleFrontierHeldItems\n\
+ ldrb r0, [r1, 0xA]\n\
+ lsls r0, 1\n\
+ adds r0, r2\n\
+ ldrh r0, [r0]\n\
+ ldr r1, [sp, 0x30]\n\
+ strh r0, [r1]\n\
+ add r3, r9\n\
+ strh r5, [r3]\n\
+ adds r1, 0x2\n\
+ str r1, [sp, 0x30]\n\
+ adds r2, r7, 0\n\
+ adds r2, 0x2\n\
+ str r2, [sp, 0x34]\n\
+ movs r6, 0x1\n\
+ add r8, r6\n\
+_081BA01C:\n\
+ mov r7, r8\n\
+ cmp r7, 0x6\n\
+ beq _081BA024\n\
+ b _081B9F1E\n\
+_081BA024:\n\
+ add sp, 0x3C\n\
+ pop {r3-r5}\n\
+ mov r8, r3\n\
+ mov r9, r4\n\
+ mov r10, r5\n\
+ pop {r4-r7}\n\
+ pop {r0}\n\
+ bx r0\n\
+ .pool\n\
+ ");
+}
+#endif // NONMATCHING
diff --git a/src/battle_tower.c b/src/battle_tower.c
new file mode 100644
index 000000000..e70d4af91
--- /dev/null
+++ b/src/battle_tower.c
@@ -0,0 +1,85 @@
+#include "global.h"
+#include "event_data.h"
+#include "battle_setup.h"
+#include "overworld.h"
+#include "random.h"
+#include "battle_tower.h"
+
+extern void sub_81A3ACC(void);
+
+extern const u32 gUnknown_085DF9AC[][2];
+extern const u32 gUnknown_085DF9CC[][2];
+extern void (* const gUnknown_085DF96C[])(void);
+
+// This file's functions.
+void sub_8164ED8(void);
+u16 sub_8164FCC(u8, u8);
+
+// code
+void sub_8161F74(void)
+{
+ gUnknown_085DF96C[gSpecialVar_0x8004]();
+}
+
+void sub_8161F94(void)
+{
+ u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
+ u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
+
+ gSaveBlock2Ptr->frontier.field_CA8 = 1;
+ gSaveBlock2Ptr->frontier.field_CB2 = 0;
+ gSaveBlock2Ptr->frontier.field_CA9_a = 0;
+ gSaveBlock2Ptr->frontier.field_CA9_b = 0;
+ sub_81A3ACC();
+ if (!(gSaveBlock2Ptr->frontier.field_CDC & gUnknown_085DF9AC[battleMode][lvlMode]))
+ gSaveBlock2Ptr->frontier.field_CE0[battleMode][lvlMode] = 0;
+
+ sub_8164ED8();
+ saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
+ gTrainerBattleOpponent_A = 0;
+}
+
+void sub_8162054(void)
+{
+ u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
+ u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
+
+ switch (gSpecialVar_0x8005)
+ {
+ case 0:
+ break;
+ case 1:
+ gSpecialVar_Result = sub_8164FCC(lvlMode, battleMode);
+ break;
+ case 2:
+ gSpecialVar_Result = ((gSaveBlock2Ptr->frontier.field_CDC & gUnknown_085DF9AC[battleMode][lvlMode]) != 0);
+ break;
+ case 3:
+ gSaveBlock2Ptr->frontier.field_D07 = gSaveBlock2Ptr->frontier.lvlMode;
+ break;
+ }
+}
+
+void sub_81620F4(void)
+{
+ u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
+ u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
+
+ switch (gSpecialVar_0x8005)
+ {
+ case 0:
+ break;
+ case 1:
+ gSaveBlock2Ptr->frontier.field_CE0[battleMode][lvlMode] = gSpecialVar_0x8006;
+ break;
+ case 2:
+ if (gSpecialVar_0x8006)
+ gSaveBlock2Ptr->frontier.field_CDC |= gUnknown_085DF9AC[battleMode][lvlMode];
+ else
+ gSaveBlock2Ptr->frontier.field_CDC &= gUnknown_085DF9CC[battleMode][lvlMode];
+ break;
+ case 3:
+ gSaveBlock2Ptr->frontier.field_D07 = gSaveBlock2Ptr->frontier.lvlMode;
+ break;
+ }
+}
diff --git a/src/bg.c b/src/bg.c
index 2f4cdc856..7c55410b1 100644
--- a/src/bg.c
+++ b/src/bg.c
@@ -1001,7 +1001,7 @@ void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 wi
}
}
-void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, void *src, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette)
+void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, const void *src, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette)
{
CopyRectToBgTilemapBufferRect(bg, src, 0, 0, rectWidth, rectHeight, destX, destY, rectWidth, rectHeight, palette, 0, 0);
}
diff --git a/src/credits.c b/src/credits.c
index a88e4b549..c054958ce 100644
--- a/src/credits.c
+++ b/src/credits.c
@@ -12,7 +12,7 @@
#include "gpu_regs.h"
#include "m4a.h"
#include "constants/rgb.h"
-#include "battle_dome_cards.h"
+#include "trainer_pokemon_sprites.h"
#include "starter_choose.h"
#include "decompress.h"
#include "intro_credits_graphics.h"
@@ -1197,7 +1197,6 @@ void sub_8175620(void)
u8 taskIdA;
s16 taskIdC;
u8 taskIdB;
- u16 savedIme;
sub_8175CE4();
SetVBlankCallback(NULL);
@@ -1333,7 +1332,7 @@ static void sub_81758E4(u8 taskIdA)
u16 *temp;
ResetSpriteData();
- dp13_810BB8C();
+ ResetAllPicSprites();
FreeAllSpritePalettes();
gReservedSpritePaletteCount = 8;
LZ77UnCompVram(&gBirchHelpGfx, (void *)VRAM);
@@ -2164,7 +2163,7 @@ static void sub_8177050(struct Sprite *sprite)
{
if (gUnknown_0203BD28)
{
- sub_818D820(sprite->data[6]);
+ FreeAndDestroyMonPicSprite(sprite->data[6]);
return;
}
@@ -2242,7 +2241,7 @@ static void sub_8177050(struct Sprite *sprite)
case 10:
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
- sub_818D820(sprite->data[6]);
+ FreeAndDestroyMonPicSprite(sprite->data[6]);
break;
}
}
diff --git a/src/egg_hatch.c b/src/egg_hatch.c
index ab0cd92a2..1c626cc86 100644
--- a/src/egg_hatch.c
+++ b/src/egg_hatch.c
@@ -512,7 +512,7 @@ static void CB2_EggHatch_0(void)
gMain.state++;
break;
case 2:
- copy_decompressed_tile_data_to_vram_autofree(0, gBattleTextboxTiles, 0, 0, 0);
+ DecompressAndLoadBgGfxUsingHeap(0, gBattleTextboxTiles, 0, 0, 0);
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);
LoadCompressedPalette(gBattleTextboxPalette, 0, 0x20);
gMain.state++;
diff --git a/src/evolution_scene.c b/src/evolution_scene.c
index 7960d6cba..ae15e79fe 100644
--- a/src/evolution_scene.c
+++ b/src/evolution_scene.c
@@ -1484,7 +1484,7 @@ static void InitMovingBackgroundTask(bool8 isLink)
LoadPalette(sUnknown_085B51E4, 0xA0, 0x20);
- copy_decompressed_tile_data_to_vram_autofree(1, sUnknown_085B4134, FALSE, 0, 0);
+ DecompressAndLoadBgGfxUsingHeap(1, sUnknown_085B4134, FALSE, 0, 0);
CopyToBgTilemapBuffer(1, sUnknown_085B482C, 0, 0);
CopyToBgTilemapBuffer(outerBgId, sUnknown_085B4D10, 0, 0);
CopyBgTilemapBufferToVram(1);
diff --git a/src/field_effect.c b/src/field_effect.c
index f047c78a3..13de58aa4 100644
--- a/src/field_effect.c
+++ b/src/field_effect.c
@@ -1,8 +1,6 @@
-
-// Includes
#include "global.h"
#include "field_effect.h"
-#include "battle_dome_cards.h"
+#include "trainer_pokemon_sprites.h"
#include "decompress.h"
#include "field_camera.h"
#include "field_effect_helpers.h"
@@ -557,7 +555,7 @@ u8 AddNewGameBirchObject(s16 x, s16 y, u8 subpriority)
#ifdef NONMATCHING
u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y)
{
- u16 spriteId = sub_818D7D8(species, 0, 0x8000, 1, x, y, 0, gMonPaletteTable[species].tag);
+ u16 spriteId = CreateMonPicSprite_HandleDeoxys(species, 0, 0x8000, 1, x, y, 0, gMonPaletteTable[species].tag);
PreservePaletteInWeather(IndexOfSpritePaletteTag(gMonPaletteTable[species].tag) + 0x10);
if (spriteId == 0xFFFF)
return 0x40;
@@ -590,7 +588,7 @@ u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y)
movs r1, 0\n\
adds r2, r3, 0\n\
movs r3, 0x1\n\
- bl sub_818D7D8\n\
+ bl CreateMonPicSprite_HandleDeoxys\n\
lsls r0, 16\n\
lsrs r5, r0, 16\n\
ldrh r0, [r4, 0x4]\n\
@@ -619,7 +617,7 @@ _080B5FDE:\n\
u8 CreateMonSprite_FieldMove(u16 species, u32 d, u32 g, s16 x, s16 y, u8 subpriority)
{
const struct CompressedSpritePalette *spritePalette = GetMonSpritePalStructFromOtIdPersonality(species, d, g);
- u16 spriteId = sub_818D7D8(species, d, g, 1, x, y, 0, spritePalette->tag);
+ u16 spriteId = CreateMonPicSprite_HandleDeoxys(species, d, g, 1, x, y, 0, spritePalette->tag);
PreservePaletteInWeather(IndexOfSpritePaletteTag(spritePalette->tag) + 0x10);
if (spriteId == 0xFFFF)
return 0x40;
@@ -634,7 +632,7 @@ void FreeResourcesAndDestroySprite(struct Sprite *sprite, u8 spriteId)
{
FreeOamMatrix(sprite->oam.matrixNum);
}
- sub_818D820(spriteId);
+ FreeAndDestroyMonPicSprite(spriteId);
}
#ifdef NONMATCHING
diff --git a/src/field_message_box.c b/src/field_message_box.c
index 8ca291e33..7ed87e837 100755
--- a/src/field_message_box.c
+++ b/src/field_message_box.c
@@ -4,7 +4,9 @@
#include "string_util.h"
#include "task.h"
#include "text.h"
-#include "battle_frontier_1.h"
+
+extern bool32 sub_8196094(void);
+extern void sub_8196080(u8*);
EWRAM_DATA u8 gUnknown_020375BC = 0;
@@ -23,7 +25,7 @@ void sub_8098128(void)
void sub_8098154(u8 taskId)
{
struct Task *task = &gTasks[taskId];
-
+
switch (task->data[0])
{
case 0:
@@ -61,12 +63,12 @@ bool8 ShowFieldMessage(u8 *str)
return FALSE;
textbox_fdecode_auto_and_task_add(str, 1);
gUnknown_020375BC = 2;
- return TRUE;
+ return TRUE;
}
void sub_8098214(u8 taskId)
{
- if (sub_8196094() == 0)
+ if (!sub_8196094())
{
gUnknown_020375BC = 0;
DestroyTask(taskId);
diff --git a/src/field_specials.c b/src/field_specials.c
index 897bcc8d7..84852e6b5 100644
--- a/src/field_specials.c
+++ b/src/field_specials.c
@@ -52,6 +52,7 @@
#include "constants/species.h"
#include "constants/moves.h"
#include "constants/vars.h"
+#include "constants/battle_frontier.h"
EWRAM_DATA bool8 gBikeCyclingChallenge = FALSE;
EWRAM_DATA u8 gBikeCollisions = 0;
@@ -1645,7 +1646,7 @@ bool8 sub_81398C0(void)
StringCopy(gStringVar2, gMoveNames[ItemIdToBattleMoveId(gSpecialVar_0x8004)]);
return TRUE;
}
-
+
return FALSE;
}
@@ -1667,7 +1668,7 @@ bool8 InMultiBattleRoom(void)
{
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(BATTLE_FRONTIER_BATTLE_TOWER_MULTI_BATTLE_ROOM)
&& gSaveBlock1Ptr->location.mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_TOWER_MULTI_BATTLE_ROOM) &&
- VarGet(VAR_0x40CE) == 2)
+ VarGet(VAR_FRONTIER_BATTLE_MODE) == FRONTIER_MODE_MULTIS)
return TRUE;
return FALSE;
}
@@ -1799,7 +1800,7 @@ void ShakeScreenInElevator(void)
if (floorDelta > 8)
floorDelta = 8;
-
+
data[5] = gUnknown_085B2C18[floorDelta];
SetCameraPanningCallback(NULL);
@@ -1830,16 +1831,16 @@ static void sub_8139AF4(u8 taskId)
void sub_8139B60(void)
{
int xPos;
-
+
gUnknown_0203AB5E = AddWindow(&gUnknown_085B2BAC);
SetStandardWindowBorderStyle(gUnknown_0203AB5E, 0);
-
+
xPos = GetStringCenterAlignXOffset(1, gText_ElevatorNowOn, 64);
PrintTextOnWindow(gUnknown_0203AB5E, 1, gText_ElevatorNowOn, xPos, 1, TEXT_SPEED_FF, NULL);
-
+
xPos = GetStringCenterAlignXOffset(1, gElevatorFloorsTable[gSpecialVar_0x8005], 64);
PrintTextOnWindow(gUnknown_0203AB5E, 1, gElevatorFloorsTable[gSpecialVar_0x8005], xPos, 17, TEXT_SPEED_FF, NULL);
-
+
PutWindowTilemap(gUnknown_0203AB5E);
CopyWindowToVram(gUnknown_0203AB5E, 3);
}
@@ -2167,13 +2168,13 @@ void sub_8139F20(void)
}
break;
case 4:
- if (gSaveBlock2Ptr->frontier.field_D0C[0] >= gSaveBlock2Ptr->frontier.field_D0C[1])
+ if (gSaveBlock2Ptr->frontier.field_D0C[0][0] >= gSaveBlock2Ptr->frontier.field_D0C[0][1])
{
- unk = gSaveBlock2Ptr->frontier.field_D0C[0];
+ unk = gSaveBlock2Ptr->frontier.field_D0C[0][0];
}
else
{
- unk = gSaveBlock2Ptr->frontier.field_D0C[1];
+ unk = gSaveBlock2Ptr->frontier.field_D0C[0][1];
}
break;
case 5:
@@ -2187,13 +2188,13 @@ void sub_8139F20(void)
}
break;
case 6:
- if (gSaveBlock2Ptr->frontier.field_DC8[0] >= gSaveBlock2Ptr->frontier.field_DC8[1])
+ if (gSaveBlock2Ptr->frontier.field_DC8[0][0] >= gSaveBlock2Ptr->frontier.field_DC8[0][1])
{
- unk = gSaveBlock2Ptr->frontier.field_DC8[0];
+ unk = gSaveBlock2Ptr->frontier.field_DC8[0][0];
}
else
{
- unk = gSaveBlock2Ptr->frontier.field_DC8[1];
+ unk = gSaveBlock2Ptr->frontier.field_DC8[0][1];
}
break;
case 7:
@@ -2240,10 +2241,10 @@ void sub_813A080(void)
};
u8 i;
- u16 var = VarGet(VAR_0x40CE);
- u8 chosenLevel = gSaveBlock2Ptr->frontier.chosenLvl;
+ u16 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
+ u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
- if (var == 2 && !FlagGet(FLAG_0x152))
+ if (battleMode == 2 && !FlagGet(FLAG_0x152))
{
gSpecialVar_0x8005 = 5;
gSpecialVar_0x8006 = 4;
@@ -2252,7 +2253,7 @@ void sub_813A080(void)
for (i = 0; i < 9; i++)
{
- if (gUnknown_085B2CDC[i] > gSaveBlock2Ptr->frontier.field_CE0[var][chosenLevel])
+ if (gUnknown_085B2CDC[i] > gSaveBlock2Ptr->frontier.field_CE0[battleMode][lvlMode])
{
gSpecialVar_0x8005 = 4;
gSpecialVar_0x8006 = i + 5;
@@ -2662,8 +2663,8 @@ static void sub_813A2DC(u8 taskId)
}
task->data[4] = convert_pixel_width_to_tile_width(unk1);
-
- if (task->data[2] + task->data[4] > 0x1D)
+
+ if (task->data[2] + task->data[4] > 0x1D)
{
int unk2 = 0x1D - task->data[4];
if (unk2 < 0)
@@ -3036,13 +3037,13 @@ void sub_813A878(u8 a0)
{
static const u16 gUnknown_085B3104[] = {0x0000, 0x0001, 0x0002, 0x0100, 0x0101, 0x0400, 0x0401, 0x0200, 0x0201, 0x0300, 0x0500, 0x0600};
- u16 var1 = VarGet(VAR_0x40CE);
+ u16 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
u16 var2 = VarGet(VAR_FRONTIER_GAMBLER_SET_FACILITY_F);
- u16 var3 = VarGet(VAR_FRONTIER_FACILITY);
+ u16 frontierFacilityId = VarGet(VAR_FRONTIER_FACILITY);
if (VarGet(VAR_FRONTIER_GAMBLER_PLACED_BET_F) == 1)
{
- if (gUnknown_085B3104[var2] == (var3 << 8) + var1)
+ if (gUnknown_085B3104[var2] == (frontierFacilityId << 8) + battleMode)
{
if (a0 != 0)
{
@@ -3363,7 +3364,7 @@ void sub_813ADD4(void)
struct Task *task = &gTasks[taskId];
ListMenuGetScrollAndRow(task->data[14], &scrollOffset, &selectedRow);
SetStandardWindowBorderStyle(task->data[13], 0);
-
+
for (i = 0; i < 6; i++)
{
sub_8199F74(task->data[13], 1, gUnknown_085B2CF0[gSpecialVar_0x8004][scrollOffset + i], 10, i * 16, TEXT_SPEED_FF, NULL, 0, 0);
@@ -3381,7 +3382,7 @@ void sub_813AEB4(void)
u16 temp1 = 0;
u16 temp2 = 0;
gSpecialVar_0x8005 = 0;
-
+
temp1 = VarGet(VAR_TEMP_E);
temp2 = VarGet(VAR_TEMP_D);
@@ -3509,7 +3510,7 @@ static void sub_813B0B4(u8 a0)
u8 eventObjectId;
LoadPalette(&gUnknown_085B3280[a0], 0x1A0, 8);
TryGetEventObjectIdByLocalIdAndMap(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &eventObjectId);
-
+
if (a0 == 0)
{
PlaySE(SE_W109);
@@ -3656,7 +3657,7 @@ bool32 sub_813B374(void)
u16 var = VarGet(VAR_0x4037);
GetMapName(gStringVar1, gUnknown_085B3400[var - 1], 0);
-
+
if (var < 9)
{
return FALSE;
@@ -3697,7 +3698,7 @@ bool32 sub_813B3B0(void)
break;
}
}
-
+
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(UNDERWATER3))
{
switch (gSaveBlock1Ptr->location.mapNum)
@@ -4159,7 +4160,7 @@ static u16 sub_813BC00(void)
}
}
}
-
+
if (((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> gUnknown_085B347C[retVal]) & 1))
{
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] ^= 1 << gUnknown_085B347C[retVal];
diff --git a/src/fieldmap.c b/src/fieldmap.c
index f57c4b48f..8d1988686 100644
--- a/src/fieldmap.c
+++ b/src/fieldmap.c
@@ -951,7 +951,7 @@ void copy_tileset_patterns_to_vram2(struct Tileset const *tileset, u16 numTiles,
if (!tileset->isCompressed)
LoadBgTiles(2, tileset->tiles, numTiles * 32, offset);
else
- copy_decompressed_tile_data_to_vram_autofree(2, tileset->tiles, numTiles * 32, offset, 0);
+ DecompressAndLoadBgGfxUsingHeap(2, tileset->tiles, numTiles * 32, offset, 0);
}
}
diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c
index f5c4ba491..33c85d448 100644
--- a/src/hall_of_fame.c
+++ b/src/hall_of_fame.c
@@ -5,6 +5,7 @@
#include "sprite.h"
#include "pokemon.h"
#include "text.h"
+#include "text_window.h"
#include "malloc.h"
#include "gpu_regs.h"
#include "main.h"
@@ -26,6 +27,7 @@
#include "event_data.h"
#include "overworld.h"
#include "menu.h"
+#include "trainer_pokemon_sprites.h"
struct HallofFameMon
{
@@ -81,18 +83,10 @@ extern const u8 gText_MainMenuTime[];
extern const u8 gContestConfetti_Gfx[];
extern const u8 gContestConfetti_Pal[];
-extern void NewMenuHelpers_DrawDialogueFrame(u8, u8);
extern void sub_8175620(void);
extern u8 TrySavingData(u8);
-extern u8 sub_818D3E4(u16 species, u32 trainerId, u32 personality, u8 flags, s16 x, s16 y, u8, u16);
extern void sub_8197434(u8, u8);
extern u16 sub_818D97C(u8 playerGender, u8);
-extern u16 sub_818D8AC(u16, u8, s16, s16, u8, u16);
-extern const void* stdpal_get(u8);
-extern void LoadWindowGfx(u8, u8, u16, u8);
-extern u16 sub_818D820(u16);
-extern u16 sub_818D8F0(u16);
-extern u16 sub_818D7D8(u16 species, u32 trainerId, u32 personality, u8 arg3, s16 sp0, s16 sp1, u8 sp2, u16 sp3);
extern void sub_8198204(u8 *dst, const u8 *src, u8, u8, u8);
extern bool8 sub_80F9C30(void);
extern void sub_8198314(void);
@@ -102,8 +96,6 @@ extern void sub_80F9BF4(u16, u16, u8);
extern void sub_81980F0(u8, u8, u8, u8, u16);
extern void sub_80F9BCC(u16, u16, u8);
extern bool8 sub_80F9C1C(void);
-extern u16 SpeciesToPokedexNum(u16 species);
-extern void dp13_810BB8C(void);
extern void sub_81971D0(void);
extern void sub_8197200(void);
extern void sub_8152254(void);
@@ -611,7 +603,7 @@ static void Task_Hof_DisplayMon(u8 taskId)
if (currMon->species == SPECIES_EGG)
field6 += 10;
- spriteId = sub_818D3E4(currMon->species, currMon->tid, currMon->personality, 1, xPos, yPos, currMonId, 0xFFFF);
+ spriteId = CreatePicSprite2(currMon->species, currMon->tid, currMon->personality, 1, xPos, yPos, currMonId, 0xFFFF);
gSprites[spriteId].tDestinationX = field4;
gSprites[spriteId].tDestinationY = field6;
gSprites[spriteId].data[0] = 0;
@@ -723,7 +715,7 @@ static void sub_8173EE4(u8 taskId)
ShowBg(0);
ShowBg(1);
ShowBg(3);
- gTasks[taskId].tPlayerSpriteID = sub_818D8AC(sub_818D97C(gSaveBlock2Ptr->playerGender, 1), 1, 120, 72, 6, 0xFFFF);
+ gTasks[taskId].tPlayerSpriteID = CreateTrainerPicSprite(PlayerGenderToFrontTrainerPicId_Debug(gSaveBlock2Ptr->playerGender, TRUE), 1, 120, 72, 6, 0xFFFF);
AddWindow(&sHof_WindowTemplate);
LoadWindowGfx(1, gSaveBlock2Ptr->optionsWindowFrameType, 0x21D, 0xD0);
LoadPalette(stdpal_get(1), 0xE0, 0x20);
@@ -780,11 +772,11 @@ static void Task_Hof_HandleExit(u8 taskId)
if (spriteId != 0xFF)
{
FreeOamMatrix(gSprites[spriteId].oam.matrixNum);
- sub_818D820(spriteId);
+ FreeAndDestroyMonPicSprite(spriteId);
}
}
- sub_818D8F0(gTasks[taskId].tPlayerSpriteID);
+ FreeAndDestroyTrainerPicSprite(gTasks[taskId].tPlayerSpriteID);
HideBg(0);
HideBg(1);
HideBg(3);
@@ -956,7 +948,7 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId)
if (currMon->species == SPECIES_EGG)
posY += 10;
- spriteId = sub_818D7D8(currMon->species, currMon->tid, currMon->personality, 1, posX, posY, i, 0xFFFF);
+ spriteId = CreateMonPicSprite_HandleDeoxys(currMon->species, currMon->tid, currMon->personality, 1, posX, posY, i, 0xFFFF);
gSprites[spriteId].oam.priority = 1;
gTasks[taskId].tMonSpriteId(i) = spriteId;
}
@@ -1026,7 +1018,7 @@ static void Task_HofPC_HandleInput(u8 taskId)
u8 spriteId = gTasks[taskId].tMonSpriteId(i);
if (spriteId != 0xFF)
{
- sub_818D820(spriteId);
+ FreeAndDestroyMonPicSprite(spriteId);
gTasks[taskId].tMonSpriteId(i) = 0xFF;
}
}
@@ -1087,7 +1079,7 @@ static void Task_HofPC_HandleExit(u8 taskId)
u16 spriteId = gTasks[taskId].tMonSpriteId(i);
if (spriteId != 0xFF)
{
- sub_818D820(spriteId);
+ FreeAndDestroyMonPicSprite(spriteId);
gTasks[taskId].tMonSpriteId(i) = 0xFF;
}
}
@@ -1305,7 +1297,7 @@ static void sub_8174F70(void)
ResetTasks();
ResetSpriteData();
reset_temp_tile_data_buffers();
- dp13_810BB8C();
+ ResetAllPicSprites();
FreeAllSpritePalettes();
gReservedSpritePaletteCount = 8;
LoadCompressedObjectPic(&sHallOfFame_ConfettiSpriteSheet);
diff --git a/src/item.c b/src/item.c
index c94f29910..22894bbff 100644
--- a/src/item.c
+++ b/src/item.c
@@ -845,8 +845,8 @@ u16 CountTotalItemQuantityInBag(u16 itemId)
static bool8 CheckPyramidBagHasItem(u16 itemId, u16 count)
{
u8 i;
- u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.chosenLvl];
- u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.chosenLvl];
+ u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode];
+ u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
for (i = 0; i < PYRAMID_BAG_ITEMS_COUNT; i++)
{
@@ -867,8 +867,8 @@ static bool8 CheckPyramidBagHasItem(u16 itemId, u16 count)
static bool8 CheckPyramidBagHasSpace(u16 itemId, u16 count)
{
u8 i;
- u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.chosenLvl];
- u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.chosenLvl];
+ u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode];
+ u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
for (i = 0; i < PYRAMID_BAG_ITEMS_COUNT; i++)
{
@@ -890,8 +890,8 @@ bool8 AddPyramidBagItem(u16 itemId, u16 count)
{
u16 i;
- u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.chosenLvl];
- u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.chosenLvl];
+ u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode];
+ u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
u16 *newItems = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(u16));
u8 *newQuantities = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(u8));
@@ -963,8 +963,8 @@ bool8 RemovePyramidBagItem(u16 itemId, u16 count)
{
u16 i;
- u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.chosenLvl];
- u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.chosenLvl];
+ u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode];
+ u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
i = gUnknown_0203CF30[3] + gUnknown_0203CF30[4];
if (items[i] == itemId && quantities[i] >= count)
diff --git a/src/link.c b/src/link.c
index b729f86eb..457e44a01 100644
--- a/src/link.c
+++ b/src/link.c
@@ -1679,7 +1679,7 @@ void CB2_LinkError(void)
static void sub_800B080(void)
{
LoadBgTiles(0, g2BlankTilesGfx, 0x20, 0);
- copy_decompressed_tile_data_to_vram_autofree(1, gWirelessLinkDisplayGfx, FALSE, 0, 0);
+ DecompressAndLoadBgGfxUsingHeap(1, gWirelessLinkDisplayGfx, FALSE, 0, 0);
CopyToBgTilemapBuffer(1, gWirelessLinkDisplayTilemap, 0, 0);
CopyBgTilemapBufferToVram(1);
LoadPalette(gWirelessLinkDisplayPal, 0, 0x20);
diff --git a/src/main_menu.c b/src/main_menu.c
index 052035e34..e28faf986 100644
--- a/src/main_menu.c
+++ b/src/main_menu.c
@@ -1,7 +1,5 @@
-
-// Includes
#include "global.h"
-#include "battle_dome_cards.h"
+#include "trainer_pokemon_sprites.h"
#include "bg.h"
#include "constants/flags.h"
#include "constants/rgb.h"
@@ -1018,7 +1016,7 @@ void task_new_game_prof_birch_speech_1(u8 taskId)
ScanlineEffect_Stop();
ResetSpriteData();
FreeAllSpritePalettes();
- dp13_810BB8C();
+ ResetAllPicSprites();
AddBirchSpeechObjects(taskId);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0);
gTasks[taskId].data[4] = 0;
@@ -1336,7 +1334,7 @@ void task_new_game_prof_birch_speech_17(u8 taskId)
if (!gPaletteFade.active)
{
FreeAllWindowBuffers();
- sub_818D820(gTasks[taskId].data[9]);
+ FreeAndDestroyMonPicSprite(gTasks[taskId].data[9]);
set_default_player_name(Random() % 20);
DestroyTask(taskId);
DoNamingScreen(0, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, new_game_prof_birch_speech_part2_start);
@@ -1515,8 +1513,8 @@ void task_new_game_prof_birch_speech_part2_12(u8 taskId)
if (!gPaletteFade.active)
{
FreeAllWindowBuffers();
- sub_818D820(gTasks[taskId].data[9]);
- dp13_810BB8C();
+ FreeAndDestroyMonPicSprite(gTasks[taskId].data[9]);
+ ResetAllPicSprites();
SetMainCallback2(CB2_NewGame);
DestroyTask(taskId);
}
@@ -1558,7 +1556,7 @@ void new_game_prof_birch_speech_part2_start(void)
ScanlineEffect_Stop();
ResetSpriteData();
FreeAllSpritePalettes();
- dp13_810BB8C();
+ ResetAllPicSprites();
AddBirchSpeechObjects(taskId);
if (gSaveBlock2Ptr->playerGender != MALE)
{
@@ -1613,7 +1611,7 @@ void sub_80318D8(struct Sprite *sprite)
u8 sub_80318F4(u8 a, u8 b)
{
- return sub_818D3E4(SPECIES_LOTAD, 8, 0, 1, a, b, 14, -1);
+ return CreatePicSprite2(SPECIES_LOTAD, 8, 0, 1, a, b, 14, -1);
}
void AddBirchSpeechObjects(u8 taskId)
diff --git a/src/match_call.c b/src/match_call.c
index 99eb6d65a..2879881bf 100644
--- a/src/match_call.c
+++ b/src/match_call.c
@@ -5,9 +5,9 @@
#include "event_data.h"
#include "string_util.h"
#include "battle.h"
-#include "battle_frontier_1.h"
#include "gym_leader_rematch.h"
+extern void sub_8197080(u8 *dest);
extern const u8 gTrainerClassNames[][13];
// Static type declarations
diff --git a/src/menu.c b/src/menu.c
index eda9513ba..8a4b4fce5 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1801,7 +1801,7 @@ void *decompress_and_copy_tile_data_to_vram(u8 bgId, const void *src, int size,
return NULL;
}
-void copy_decompressed_tile_data_to_vram_autofree(u8 bgId, const void *src, int size, u16 offset, u8 mode)
+void DecompressAndLoadBgGfxUsingHeap(u8 bgId, const void *src, int size, u16 offset, u8 mode)
{
int sizeOut;
void *ptr = malloc_and_decompress(src, &sizeOut);
diff --git a/src/new_game.c b/src/new_game.c
index 8b8436d10..da5e91229 100644
--- a/src/new_game.c
+++ b/src/new_game.c
@@ -23,6 +23,8 @@
#include "overworld.h"
#include "mail.h"
#include "battle_records.h"
+#include "item.h"
+#include "pokedex.h"
extern u8 gDifferentSaveFile;
extern u16 gSaveFileStatus;
@@ -33,13 +35,11 @@ extern u16 GetGeneratedTrainerIdLower(void);
extern void ClearContestWinnerPicsInContestHall(void);
extern void sub_80BB358(void);
extern void ResetBagScrollPositions(void);
-extern void ResetPokedex(void);
extern void ResetGabbyAndTy(void);
extern void ResetSecretBases(void);
extern void ResetLinkContestBoolean(void);
extern void sub_8052DA8(void);
extern void ResetPokemonStorageSystem(void);
-extern void ClearBag(void);
extern void NewGameInitPCItems(void);
extern void ClearDecorationInventories(void);
extern void ResetFanClub(void);
diff --git a/src/overworld.c b/src/overworld.c
index d85af9e4d..1cf830cf7 100644
--- a/src/overworld.c
+++ b/src/overworld.c
@@ -151,7 +151,7 @@ extern void TransferTilesetAnimsBuffer(void);
extern bool32 sub_81D5F48(void);
extern u8 GetCurrentTrainerHillMapId(void);
extern bool8 warp0_in_pokecenter(void);
-extern void dp13_810BB8C(void);
+extern void ResetAllPicSprites(void);
extern void FieldEffectActiveListClear(void);
extern void SetUpFieldTasks(void);
extern void sub_81BE6B8(void);
@@ -2149,7 +2149,7 @@ static void sub_8086988(u32 a1)
ResetSpriteData();
ResetPaletteFade();
ScanlineEffect_Clear();
- dp13_810BB8C();
+ ResetAllPicSprites();
ResetCameraUpdateInfo();
InstallCameraPanAheadCallback();
if (!a1)
diff --git a/src/pokedex.c b/src/pokedex.c
index 0d73a9fe1..2cb3c153f 100644
--- a/src/pokedex.c
+++ b/src/pokedex.c
@@ -11,7 +11,7 @@
#include "main.h"
#include "sound.h"
#include "task.h"
-#include "battle_dome_cards.h"
+#include "trainer_pokemon_sprites.h"
#include "scanline_effect.h"
#include "malloc.h"
#include "gpu_regs.h"
@@ -821,7 +821,7 @@ const u8 sText_TenDashes[] = _("----------");
void ResetPokedex(void)
{
u16 i;
-
+
gUnknown_02039B50 = 0;
gUnknown_02039B52 = 64;
gUnknown_030060B0 = 0;
@@ -910,7 +910,7 @@ void sub_80BB534(void)
{
u8 *addr;
u32 size;
-
+
switch (gMain.state)
{
case 0:
@@ -929,7 +929,7 @@ void sub_80BB534(void)
ResetPaletteFade();
FreeAllSpritePalettes();
gReservedSpritePaletteCount = 8;
- dp13_810BB8C();
+ ResetAllPicSprites();
gMain.state++;
break;
case 2:
@@ -984,7 +984,7 @@ void sub_80BB78C(u8 taskId)
void sub_80BB7D4(u8 taskId)
{
SetGpuReg(REG_OFFSET_BG0VOFS, gUnknown_02039B4C->menuY);
-
+
if (gUnknown_02039B4C->menuY)
{
gUnknown_02039B4C->menuY -= 8;
@@ -1377,7 +1377,7 @@ bool8 sub_80BC514(u8 a)
SetBgTilemapBuffer(2, AllocZeroed(0x800));
SetBgTilemapBuffer(1, AllocZeroed(0x800));
SetBgTilemapBuffer(0, AllocZeroed(0x800));
- copy_decompressed_tile_data_to_vram_autofree(3, gPokedexMenu_Gfx, 0x2000, 0, 0);
+ DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0);
CopyToBgTilemapBuffer(1, gUnknown_08DC2C5C, 0, 0);
CopyToBgTilemapBuffer(3, gUnknown_08DC2DAC, 0, 0);
if (a == 0)
@@ -1467,7 +1467,7 @@ void sub_80BC844(u8 a)
void sub_80BC890(void)
{
void* tilemapBuffer;
-
+
FreeAllWindowBuffers();
tilemapBuffer = GetBgTilemapBuffer(0);
if (tilemapBuffer)
@@ -1487,7 +1487,7 @@ void sub_80BC8D4(u8 dexMode, u8 sortMode)
{
u16 vars[3]; //I have no idea why three regular variables are stored in an array, but whatever.
s16 i;
-
+
gUnknown_02039B4C->pokemonListCount = 0;
switch (dexMode)
@@ -1633,7 +1633,7 @@ void sub_80BC8D4(u8 dexMode, u8 sortMode)
void sub_80BCE2C(u8 windowId, u8 fontId, const u8* str, u8 left, u8 top)
{
u8 color[3];
-
+
color[0] = 0;
color[1] = 15;
color[2] = 3;
@@ -1731,7 +1731,7 @@ void sub_80BD154(u16 a, u8 left, u8 top, u16 unused)
{
u8 text[6];
u16 r6;
-
+
memcpy(text, gUnknown_0855D2B8, 6);
r6 = gUnknown_02039B4C->unk0[a].dexNum;
if (gUnknown_02039B4C->dexMode == DEX_MODE_HOENN)
@@ -1753,7 +1753,7 @@ void sub_80BD1F4(u16 a, u8 x, u8 y, u16 unused)
u8 sub_80BD23C(u16 num, u8 left, u8 top)
{
const u8* str;
-
+
num = NationalPokedexNumToSpecies(num);
if (num)
str = gSpeciesNames[num];
@@ -1773,7 +1773,7 @@ void sub_80BD2B4(u16 a, u16 b)
u8 i;
u16 unk;
u8 spriteId;
-
+
gPaletteFade.bufferTransferDisabled = TRUE;
for (i = 0; i < 4; i++)
@@ -1803,13 +1803,13 @@ void sub_80BD2B4(u16 a, u16 b)
gSprites[spriteId].callback = sub_80BE4E0;
gSprites[spriteId].data[5] = 32;
}
-
+
sub_80BCE84(0, a, b);
SetGpuReg(REG_OFFSET_BG2VOFS, gUnknown_02039B4C->unk62D);
gUnknown_02039B4C->unk630 = 0;
gUnknown_02039B4C->unk632 = 0;
-
+
gPaletteFade.bufferTransferDisabled = FALSE;
}
@@ -1897,7 +1897,7 @@ u16 sub_80BD69C(u16 a, u16 b)
u8 i;
u16 r6;
u8 r10 = 0;
-
+
if ((gMain.heldKeys & DPAD_UP) && (a > 0))
{
r10 = 1;
@@ -1917,7 +1917,7 @@ u16 sub_80BD69C(u16 a, u16 b)
else if ((gMain.newKeys & DPAD_LEFT) && (a > 0))
{
r6 = a;
-
+
for (i = 0; i < 7; i++)
a = sub_80C0E0C(1, a, 0, gUnknown_02039B4C->pokemonListCount - 1);
gUnknown_02039B4C->unk62C += 16 * (a - r6);
@@ -1935,13 +1935,13 @@ u16 sub_80BD69C(u16 a, u16 b)
sub_80BD2B4(a, 0xE);
PlaySE(SE_Z_PAGE);
}
-
+
if (r10 == 0)
{
gUnknown_02039B4C->unk638 = 0;
return a;
}
-
+
r5 = gUnknown_0855D28C[gUnknown_02039B4C->unk638 / 4];
r3 = gUnknown_0855D291[gUnknown_02039B4C->unk638 / 4];
gUnknown_02039B4C->unk62E = r3;
@@ -2030,7 +2030,7 @@ u8 sub_80BDA40(void)
{
if (gUnknown_02039B4C->unk61E[i] != 0xFFFF)
{
- sub_818D820(gUnknown_02039B4C->unk61E[i]);
+ FreeAndDestroyMonPicSprite(gUnknown_02039B4C->unk61E[i]);
gUnknown_02039B4C->unk61E[i] |= 0xFFFF;
}
}
@@ -2109,7 +2109,7 @@ void sub_80BDB7C(u8 a)
if (a == 0)
{
u32 _a;
-
+
if (!IsNationalPokedexEnabled())
{
CreateSprite(&gUnknown_0855D1F4, 32, 40, 1);
@@ -2160,22 +2160,22 @@ void sub_80BDB7C(u8 a)
else
{
u16 r6;
-
+
CreateSprite(&gUnknown_0855D1F4, 32, 40, 1);
spriteId = CreateSprite(&gUnknown_0855D1F4, 32, 76, 1);
StartSpriteAnim(&gSprites[spriteId], 1);
CreateSprite(&gUnknown_0855D20C, 17, 45, 1);
-
+
spriteId = CreateSprite(&gUnknown_0855D20C, 17, 55, 1);
StartSpriteAnim(&gSprites[spriteId], 1);
CreateSprite(&gUnknown_0855D20C, 17, 81, 1);
-
+
spriteId = CreateSprite(&gUnknown_0855D20C, 17, 91, 1);
StartSpriteAnim(&gSprites[spriteId], 1);
-
+
r6 = GetHoennPokedexCount(0);
_a = 0;
@@ -2197,9 +2197,9 @@ void sub_80BDB7C(u8 a)
spriteId = CreateSprite(&gUnknown_0855D23C, 56, 45, 1);
r5 = (r6 % 100) % 10;
StartSpriteAnim(&gSprites[spriteId], r5);
-
+
_a = 0;
-
+
spriteId = CreateSprite(&gUnknown_0855D23C, 40, 55, 1);
r5 = gUnknown_02039B4C->unk61A / 100;
StartSpriteAnim(&gSprites[spriteId], r5);
@@ -2207,21 +2207,21 @@ void sub_80BDB7C(u8 a)
_a = 1;
else
gSprites[spriteId].invisible = TRUE;
-
+
spriteId = CreateSprite(&gUnknown_0855D23C, 48, 55, 1);
r5 = (gUnknown_02039B4C->unk61A % 100) / 10;
if (r5 != 0 || _a != 0)
StartSpriteAnim(&gSprites[spriteId], r5);
else
gSprites[spriteId].invisible = TRUE;
-
+
spriteId = CreateSprite(&gUnknown_0855D23C, 56, 55, 1);
r5 = (gUnknown_02039B4C->unk61A % 100) % 10;
StartSpriteAnim(&gSprites[spriteId], r5);
-
+
r6 = GetHoennPokedexCount(1);
_a = 0;
-
+
spriteId = CreateSprite(&gUnknown_0855D23C, 40, 81, 1);
r5 = r6 / 100;
StartSpriteAnim(&gSprites[spriteId], r5);
@@ -2229,20 +2229,20 @@ void sub_80BDB7C(u8 a)
_a = 1;
else
gSprites[spriteId].invisible = TRUE;
-
+
spriteId = CreateSprite(&gUnknown_0855D23C, 48, 81, 1);
r5 = (r6 % 100) / 10;
if (r5 != 0 || _a != 0)
StartSpriteAnim(&gSprites[spriteId], r5);
else
gSprites[spriteId].invisible = TRUE;
-
+
spriteId = CreateSprite(&gUnknown_0855D23C, 56, 81, 1);
r5 = (r6 % 100) % 10;
StartSpriteAnim(&gSprites[spriteId], r5);
-
+
_a = 0;
-
+
spriteId = CreateSprite(&gUnknown_0855D23C, 40, 91, 1);
r5 = gUnknown_02039B4C->unk61C / 100;
StartSpriteAnim(&gSprites[spriteId], r5);
@@ -2250,14 +2250,14 @@ void sub_80BDB7C(u8 a)
_a = 1;
else
gSprites[spriteId].invisible = TRUE;
-
+
spriteId = CreateSprite(&gUnknown_0855D23C, 48, 91, 1);
r5 = (gUnknown_02039B4C->unk61C % 100) / 10;
if (r5 != 0 || _a != 0)
StartSpriteAnim(&gSprites[spriteId], r5);
else
gSprites[spriteId].invisible = TRUE;
-
+
spriteId = CreateSprite(&gUnknown_0855D23C, 56, 91, 1);
r5 = (gUnknown_02039B4C->unk61C % 100) % 10;
StartSpriteAnim(&gSprites[spriteId], r5);
@@ -2313,7 +2313,7 @@ void sub_80BE4E0(struct Sprite *sprite)
if (gUnknown_02039B4C->unk64A != 0 && gUnknown_02039B4C->unk64A != 3)
{
- sub_818D820(gUnknown_02039B4C->unk61E[data1]);
+ FreeAndDestroyMonPicSprite(gUnknown_02039B4C->unk61E[data1]);
gUnknown_02039B4C->unk61E[data1] = 0xFFFF;
}
else
@@ -2339,7 +2339,7 @@ void sub_80BE4E0(struct Sprite *sprite)
if ((sprite->data[5] <= -64 || sprite->data[5] >= 64) && sprite->data[0] != 0)
{
- sub_818D820(gUnknown_02039B4C->unk61E[data1]);
+ FreeAndDestroyMonPicSprite(gUnknown_02039B4C->unk61E[data1]);
gUnknown_02039B4C->unk61E[data1] = 0xFFFF;
}
}
@@ -2449,14 +2449,14 @@ void sub_80BE8DC(const u8* str, u8 left, u8 top)
color[0] = 0;
color[1] = 15;
color[2] = 3;
-
+
AddTextPrinterParameterized2(0, 1, left, top, 0, 0, color, -1, str);
}
u8 sub_80BE91C(struct PokedexListItem* item, u8 b)
{
u8 taskId;
-
+
gUnknown_02039B54 = item;
taskId = CreateTask(sub_80BEA24, 0);
gTasks[taskId].data[0] = 0;
@@ -2473,7 +2473,7 @@ u8 sub_80BE91C(struct PokedexListItem* item, u8 b)
SetBgTilemapBuffer(0, AllocZeroed(0x800));
InitWindows(gUnknown_0856E640);
DeactivateAllTextPrinters();
-
+
return taskId;
}
@@ -2518,7 +2518,7 @@ void sub_80BEA24(u8 taskId)
}
break;
case 1:
- copy_decompressed_tile_data_to_vram_autofree(3, gPokedexMenu_Gfx, 0x2000, 0, 0);
+ DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0);
CopyToBgTilemapBuffer(3, gUnknown_08DC3080, 0, 0);
FillWindowPixelBuffer(0, 0);
PutWindowTilemap(0);
@@ -2703,7 +2703,7 @@ void sub_80BEFD0(u8 taskId)
{
if (!gPaletteFade.active)
{
- sub_818D820(gTasks[taskId].data[4]);
+ FreeAndDestroyMonPicSprite(gTasks[taskId].data[4]);
switch (gUnknown_02039B4C->unk64E)
{
case 1:
@@ -2724,7 +2724,7 @@ void sub_80BF038(u8 taskId)
{
if (!gPaletteFade.active)
{
- sub_818D820(gTasks[taskId].data[4]);
+ FreeAndDestroyMonPicSprite(gTasks[taskId].data[4]);
gTasks[taskId].func = sub_80BEA24;
}
}
@@ -2733,7 +2733,7 @@ void sub_80BF070(u8 taskId)
{
if (!gPaletteFade.active)
{
- sub_818D820(gTasks[taskId].data[4]);
+ FreeAndDestroyMonPicSprite(gTasks[taskId].data[4]);
sub_80BEDB0();
DestroyTask(taskId);
}
@@ -2813,7 +2813,7 @@ void sub_80BF250(u8 taskId)
}
break;
case 1:
- copy_decompressed_tile_data_to_vram_autofree(3, &gPokedexMenu_Gfx, 0x2000, 0, 0);
+ DecompressAndLoadBgGfxUsingHeap(3, &gPokedexMenu_Gfx, 0x2000, 0, 0);
CopyToBgTilemapBuffer(3, &gUnknown_08DC3198, 0, 0);
FillWindowPixelBuffer(0, 0);
PutWindowTilemap(0);
@@ -2960,7 +2960,7 @@ void sub_80BF790(u8 taskId)
if (!gPaletteFade.active)
{
sub_8145914();
- sub_818D820(gTasks[taskId].data[4]);
+ FreeAndDestroyMonPicSprite(gTasks[taskId].data[4]);
switch (gUnknown_02039B4C->unk64E)
{
default:
@@ -3007,7 +3007,7 @@ void sub_80BF82C(u8 taskId)
}
break;
case 1:
- copy_decompressed_tile_data_to_vram_autofree(3, gPokedexMenu_Gfx, 0x2000, 0, 0);
+ DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0);
CopyToBgTilemapBuffer(3, gUnknown_08DC2E6C, 0, 0);
FillWindowPixelBuffer(0, 0);
PutWindowTilemap(0);
@@ -3109,8 +3109,8 @@ void sub_80BFC78(u8 taskId)
{
if (!gPaletteFade.active)
{
- sub_818D820(gTasks[taskId].data[4]);
- sub_818D8F0(gTasks[taskId].data[5]);
+ FreeAndDestroyMonPicSprite(gTasks[taskId].data[4]);
+ FreeAndDestroyTrainerPicSprite(gTasks[taskId].data[5]);
switch (gUnknown_02039B4C->unk64E)
{
default:
@@ -3334,7 +3334,7 @@ void sub_80BFE38(u8 taskId)
{
u8 spriteId;
u16 dexNum = gTasks[taskId].data[1];
-
+
switch (gTasks[taskId].data[0])
{
case 0:
@@ -3354,7 +3354,7 @@ void sub_80BFE38(u8 taskId)
}
break;
case 1:
- copy_decompressed_tile_data_to_vram_autofree(3, gPokedexMenu_Gfx, 0x2000, 0, 0);
+ DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0);
CopyToBgTilemapBuffer(3, gUnknown_08DC3080, 0, 0);
FillWindowPixelBuffer(0, 0);
PutWindowTilemap(0);
@@ -3440,7 +3440,7 @@ void blockset_load_palette_to_gpu(u8 taskId)
buffer = GetBgTilemapBuffer(3);
if (buffer)
Free(buffer);
-
+
species = NationalPokedexNumToSpecies(gTasks[taskId].data[1]);
otId = ((u16)gTasks[taskId].data[13] << 16) | (u16)gTasks[taskId].data[12];
personality = ((u16)gTasks[taskId].data[15] << 16) | (u16)gTasks[taskId].data[14];
@@ -3472,7 +3472,7 @@ void sub_80C020C(u32 num, u32 value, u32 c, u32 d)
const u8 *text;
const u8 *text2;
const u8 *text3;
-
+
if (d)
sub_80BE8DC(gText_PokedexRegistration, GetStringCenterAlignXOffset(1, gText_PokedexRegistration, 0xF0), 0);
if (value == 0)
@@ -4064,7 +4064,7 @@ void sub_80C0A88(u8 windowId, const u8 *str, u8 left, u8 top)
color[0] = 0;
color[1] = 15;
color[2] = 3;
-
+
AddTextPrinterParameterized2(windowId, 1, left, top, 0, 0, color, -1, str);
}
@@ -4107,7 +4107,7 @@ void sub_80C0BF0(u8 windowId, const u8* str, u8 left, u8 top)
u8 str2[11];
u8 i;
u8 count;
-
+
for (i = 0; i < 11; i++)
str2[i] = CHAR_SPACE;
for (count = 0; str[count] != CHAR_SPACE && count < 11; count++)
@@ -4232,12 +4232,12 @@ u32 sub_80C0E68(u16 a)
u16 sub_80C0E9C(u16 num, s16 x, s16 y, u16 paletteSlot)
{
num = NationalPokedexNumToSpecies(num);
- return sub_818D7D8(num, 8, sub_80C0E68(num), TRUE, x, y, paletteSlot, 0xFFFF);
+ return CreateMonPicSprite_HandleDeoxys(num, 8, sub_80C0E68(num), TRUE, x, y, paletteSlot, 0xFFFF);
}
u16 sub_80C0EF8(u16 species, s16 x, s16 y, s8 paletteSlot)
{
- return sub_818D8AC(species, TRUE, x, y, paletteSlot, 0xFFFF);
+ return CreateTrainerPicSprite(species, TRUE, x, y, paletteSlot, 0xFFFF);
}
int sub_80C0F30(u8 dexMode, u8 sortMode, u8 abcGroup, u8 bodyColor, u8 type1, u8 type2)
@@ -4364,7 +4364,7 @@ u8 sub_80C1258(void)
void sub_80C1270(const u8 *str, u32 left, u32 top)
{
u8 color[3];
-
+
color[0] = 0;
color[1] = 15;
color[2] = 2;
@@ -4397,8 +4397,8 @@ void sub_80C12E0(u8 taskId)
InitWindows(gUnknown_0856F008);
DeactivateAllTextPrinters();
PutWindowTilemap(0);
- copy_decompressed_tile_data_to_vram_autofree(3, gPokedexSearchMenu_Gfx, 0x2000, 0, 0);
-
+ DecompressAndLoadBgGfxUsingHeap(3, gPokedexSearchMenu_Gfx, 0x2000, 0, 0);
+
if (!IsNationalPokedexEnabled())
CopyToBgTilemapBuffer(3, gPokedexSearch2_Tilemap, 0, 0);
else
@@ -4450,7 +4450,7 @@ void sub_80C12E0(u8 taskId)
void sub_80C152C(void)
{
void* tilemapBuffer;
-
+
FreeAllWindowBuffers();
tilemapBuffer = GetBgTilemapBuffer(0);
if (tilemapBuffer)
@@ -4992,12 +4992,12 @@ void sub_80C2064(u8 a, u8 b)
void sub_80C20F8(u8 taskId)
{
u16 var;
-
+
sub_80C12B0(0x28, 0x10, 0x60, 0x50);
var = gTasks[taskId].data[6] + gTasks[taskId].data[7];
sub_80C1270(gUnknown_0856EE5C[var].text2, 0x2D, 0x11);
-
+
var = gTasks[taskId].data[8] + gTasks[taskId].data[9];
sub_80C1270(gUnknown_0856EEB4[var].text2, 0x2D, 0x21);
diff --git a/src/pokemon.c b/src/pokemon.c
index 3aa88e991..9022f69ea 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -13,6 +13,7 @@
#include "constants/hold_effects.h"
#include "constants/battle_move_effects.h"
#include "constants/songs.h"
+#include "constants/battle_frontier.h"
#include "string_util.h"
#include "text.h"
#include "link.h"
@@ -80,8 +81,7 @@ extern void set_unknown_box_id(u8);
extern void sub_803FA70(u8 battlerId);
extern u8 sav1_map_get_name(void);
extern const u8 *sub_81A1650(u8, u8 language);
-extern u8 BattleFrontierGetOpponentLvl(u8);
-extern u16 FacilityClassToPicIndex(u16);
+extern u8 GetFrontierEnemyMonLevel(u8);
extern bool8 InBattlePyramid(void);
extern bool8 InBattlePike(void);
extern bool8 sub_806F104(void);
@@ -955,7 +955,7 @@ const u16 gHoennToNationalOrder[] = // Assigns Hoenn Dex Pokémon (Using Nationa
NATIONAL_DEX_BLAZIKEN, // HOENN_DEX_BLAZIKEN
NATIONAL_DEX_MUDKIP, // HOENN_DEX_MUDKIP
NATIONAL_DEX_MARSHTOMP, // HOENN_DEX_MARSHTOMP
- NATIONAL_DEX_SWAMPERT, // HOENN_DEX_SWAMPERT
+ NATIONAL_DEX_SWAMPERT, // HOENN_DEX_SWAMPERT
NATIONAL_DEX_POOCHYENA, // HOENN_DEX_POOCHYENA
NATIONAL_DEX_MIGHTYENA, // HOENN_DEX_MIGHTYENA
NATIONAL_DEX_ZIGZAGOON, // HOENN_DEX_ZIGZAGOON
@@ -2819,8 +2819,8 @@ void sub_8068338(struct Pokemon *mon, struct UnknownPokemonStruct *src, bool8 lv
u8 language;
u8 value;
- if (gSaveBlock2Ptr->frontier.chosenLvl != 0)
- level = BattleFrontierGetOpponentLvl(gSaveBlock2Ptr->frontier.chosenLvl);
+ if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50)
+ level = GetFrontierEnemyMonLevel(gSaveBlock2Ptr->frontier.lvlMode);
else if (lvl50)
level = 50;
else
@@ -2884,7 +2884,7 @@ void sub_8068528(struct Pokemon *mon, const struct UnknownPokemonStruct2 *src, u
CreateMon(mon,
src->mons[monId].species,
- BattleFrontierGetOpponentLvl(src->field_0_1 - 1),
+ GetFrontierEnemyMonLevel(src->field_0_1 - 1),
0x1F,
TRUE,
personality,
@@ -7118,9 +7118,9 @@ u16 FacilityClassToPicIndex(u16 facilityClass)
u16 PlayerGenderToFrontTrainerPicId(u8 playerGender)
{
if (playerGender != MALE)
- return FacilityClassToPicIndex(FACILITY_CLASS_PKMN_TRAINER_BRENDAN);
- else
return FacilityClassToPicIndex(FACILITY_CLASS_PKMN_TRAINER_MAY);
+ else
+ return FacilityClassToPicIndex(FACILITY_CLASS_PKMN_TRAINER_BRENDAN);
}
void HandleSetPokedexFlag(u16 nationalNum, u8 caseId, u32 personality)
diff --git a/src/record_mixing.c b/src/record_mixing.c
index 8b21e214f..552c32d38 100644
--- a/src/record_mixing.c
+++ b/src/record_mixing.c
@@ -1635,8 +1635,8 @@ void sub_80E8260(struct UnkRecordMixingStruct2 *dst)
dst->field_0[0][i].field_4 = gSaveBlock2Ptr->frontier.field_CF0[i];
dst->field_0[1][i].field_4 = gSaveBlock2Ptr->frontier.field_CF4[i];
dst->field_0[2][i].field_4 = gSaveBlock2Ptr->frontier.field_CF8[i];
- dst->field_0[3][i].field_4 = gSaveBlock2Ptr->frontier.field_D14[i];
- dst->field_0[4][i].field_4 = gSaveBlock2Ptr->frontier.field_DD0[i];
+ dst->field_0[3][i].field_4 = gSaveBlock2Ptr->frontier.field_D14[0][i];
+ dst->field_0[4][i].field_4 = gSaveBlock2Ptr->frontier.field_DD0[0][i];
dst->field_0[5][i].field_4 = gSaveBlock2Ptr->frontier.field_DDE[i];
dst->field_0[6][i].field_4 = gSaveBlock2Ptr->frontier.field_DEA[i];
dst->field_0[7][i].field_4 = gSaveBlock2Ptr->frontier.field_E08[i];
diff --git a/src/recorded_battle.c b/src/recorded_battle.c
index 45b07ca7a..e19f3047f 100644
--- a/src/recorded_battle.c
+++ b/src/recorded_battle.c
@@ -1293,7 +1293,7 @@ static bool32 AllocTryCopyRecordedBattleSaveData(struct RecordedBattleSave *dst)
static void CB2_RecordedBattleEnd(void)
{
- gSaveBlock2Ptr->frontier.chosenLvl = sUnknown_0203C7AD;
+ gSaveBlock2Ptr->frontier.lvlMode = sUnknown_0203C7AD;
gBattleOutcome = 0;
gBattleTypeFlags = 0;
gTrainerBattleOpponent_A = 0;
@@ -1353,7 +1353,7 @@ static void SetRecordedBattleVarsFromSave(struct RecordedBattleSave *src)
gTrainerBattleOpponent_B = src->opponentB;
gPartnerTrainerId = src->partnerId;
gUnknown_0203C7B4 = src->field_4FA;
- sUnknown_0203C7AD = gSaveBlock2Ptr->frontier.chosenLvl;
+ sUnknown_0203C7AD = gSaveBlock2Ptr->frontier.lvlMode;
sFrontierFacility = src->field_4FD;
sUnknown_0203C7AF = src->field_4FE;
sBattleStyle = src->battleStyle;
@@ -1375,7 +1375,7 @@ static void SetRecordedBattleVarsFromSave(struct RecordedBattleSave *src)
sUnknown_0203CCDC[i] = src->field_50E[i];
}
- gSaveBlock2Ptr->frontier.chosenLvl = src->field_4FC;
+ gSaveBlock2Ptr->frontier.lvlMode = src->field_4FC;
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
diff --git a/src/rom_8011DC0.c b/src/rom_8011DC0.c
index 55e3fe32b..993dc0f4f 100644
--- a/src/rom_8011DC0.c
+++ b/src/rom_8011DC0.c
@@ -18,6 +18,7 @@
#include "constants/maps.h"
#include "constants/species.h"
#include "constants/rgb.h"
+#include "constants/battle_frontier.h"
#include "trade.h"
#include "trainer_card.h"
#include "overworld.h"
@@ -468,7 +469,7 @@ void sub_8012780(u8 taskId)
switch (data->state)
{
case 0:
- if (gSpecialVar_0x8004 == 20 && gSaveBlock2Ptr->frontier.chosenLvl == 1)
+ if (gSpecialVar_0x8004 == 20 && gSaveBlock2Ptr->frontier.lvlMode == FRONTIER_LVL_OPEN)
gSpecialVar_0x8004++;
gUnknown_02022C2C = gUnknown_082F00C4[gSpecialVar_0x8004];
gUnknown_02022C2D = gUnknown_082F00C4[gSpecialVar_0x8004] >> 8;
@@ -1050,7 +1051,7 @@ void sub_80134E8(u8 taskId)
switch (data->state)
{
case 0:
- if (gSpecialVar_0x8004 == 20 && gSaveBlock2Ptr->frontier.chosenLvl == 1)
+ if (gSpecialVar_0x8004 == 20 && gSaveBlock2Ptr->frontier.lvlMode == FRONTIER_LVL_OPEN)
gSpecialVar_0x8004++;
gUnknown_02022C2C = gUnknown_082F0530[gSpecialVar_0x8004];
sub_8010F84(gUnknown_02022C2C, 0, 0);
diff --git a/src/starter_choose.c b/src/starter_choose.c
index 36e2b121a..c1e7eea40 100644
--- a/src/starter_choose.c
+++ b/src/starter_choose.c
@@ -20,6 +20,7 @@
#include "international_string_util.h"
#include "trig.h"
#include "scanline_effect.h"
+#include "trainer_pokemon_sprites.h"
#define STARTER_MON_COUNT 3
@@ -48,12 +49,6 @@ extern const u8 gStarterChoose_LabelCoords[][2];
extern const u8 gUnknown_085B1E0C[];
extern const u8 gUnknown_085B1E28[][2];
-extern void clear_scheduled_bg_copies_to_vram(void);
-extern void dp13_810BB8C(void);
-extern void do_scheduled_bg_tilemap_copies_to_vram(void);
-extern u16 sub_818D820(u16);
-extern u8 sub_818D3E4(u16 species, u32 trainerId, u32 personality, u8 flags, s16 x, s16 y, u8, u16);
-
// this file's functions
static void MainCallback2_StarterChoose(void);
static void sub_8134604(void);
@@ -132,7 +127,7 @@ void CB2_ChooseStarter(void)
ResetSpriteData();
ResetPaletteFade();
FreeAllSpritePalettes();
- dp13_810BB8C();
+ ResetAllPicSprites();
LoadPalette(GetOverworldTextboxPalettePtr(), 0xE0, 0x20);
LoadPalette(gBirchBagGrassPal, 0, 0x40);
@@ -263,7 +258,7 @@ static void Task_StarterChoose5(u8 taskId)
case 0: // YES
// Return the starter choice and exit.
gSpecialVar_Result = gTasks[taskId].tStarterSelection;
- dp13_810BB8C();
+ ResetAllPicSprites();
SetMainCallback2(gMain.savedCallback);
break;
case 1: // NO
@@ -271,7 +266,7 @@ static void Task_StarterChoose5(u8 taskId)
PlaySE(SE_SELECT);
spriteId = gTasks[taskId].tPkmnSpriteId;
FreeOamMatrix(gSprites[spriteId].oam.matrixNum);
- sub_818D820(spriteId);
+ FreeAndDestroyMonPicSprite(spriteId);
spriteId = gTasks[taskId].tCircleSpriteId;
FreeOamMatrix(gSprites[spriteId].oam.matrixNum);
@@ -349,7 +344,7 @@ static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y)
{
u8 spriteId;
- spriteId = sub_818D3E4(species, 8, 0, 1, x, y, 0xE, 0xFFFF);
+ spriteId = CreatePicSprite2(species, 8, 0, 1, x, y, 0xE, 0xFFFF);
gSprites[spriteId].oam.priority = 0;
return spriteId;
}
diff --git a/src/battle_dome_cards.c b/src/trainer_pokemon_sprites.c
index 5e659a2e8..085e66214 100644
--- a/src/battle_dome_cards.c
+++ b/src/trainer_pokemon_sprites.c
@@ -1,5 +1,3 @@
-
-// Includes
#include "global.h"
#include "sprite.h"
#include "window.h"
@@ -7,7 +5,10 @@
#include "constants/species.h"
#include "palette.h"
#include "decompress.h"
-#include "battle_dome_cards.h"
+#include "trainer_pokemon_sprites.h"
+#include "data2.h"
+#include "pokemon.h"
+#include "constants/trainers.h"
extern const struct CompressedSpriteSheet gMonFrontPicTable[NUM_SPECIES];
extern const struct CompressedSpriteSheet gMonBackPicTable[NUM_SPECIES];
@@ -19,11 +20,10 @@ extern const union AffineAnimCmd *const gUnknown_082FF694[];
extern const union AnimCmd *const gPlayerMonSpriteAnimsTable[];
extern const union AnimCmd *const *const gMonAnimationsSpriteAnimsPtrTable[NUM_SPECIES];
extern const union AnimCmd *const *const gUnknown_0830536C[];
-extern const u8 gFacilityClassToPicIndex[];
// Static type declarations
-struct BattleDomeCard
+struct PicData
{
u8 *frames;
struct SpriteFrameImage *images;
@@ -33,15 +33,16 @@ struct BattleDomeCard
};
// Static RAM declarations
+#define PICS_COUNT 8
-static EWRAM_DATA struct SpriteTemplate gUnknown_0203CCEC = {};
-static EWRAM_DATA struct BattleDomeCard gUnknown_0203CD04[8] = {};
+static EWRAM_DATA struct SpriteTemplate sCreatingSpriteTemplate = {};
+static EWRAM_DATA struct PicData sSpritePics[PICS_COUNT] = {};
// Static ROM declarations
// .rodata
-static const struct BattleDomeCard gUnknown_0860B058 = {};
+static const struct PicData sDummyPicData = {};
static const struct OamData gUnknown_0860B064 =
{
.size = 3
@@ -53,80 +54,67 @@ static const struct OamData gUnknown_0860B06C =
// .text
-static void nullsub_122(struct Sprite *sprite)
+static void DummyPicSpriteCallback(struct Sprite *sprite)
{
}
-bool16 dp13_810BB8C(void)
+bool16 ResetAllPicSprites(void)
{
int i;
- for (i = 0; i < 8; i ++)
- {
- gUnknown_0203CD04[i] = gUnknown_0860B058;
- }
+ for (i = 0; i < PICS_COUNT; i ++)
+ sSpritePics[i] = sDummyPicData;
+
return FALSE;
}
-static bool16 load_pokemon_image_TODO(u16 species, u32 personality, bool8 isFrontPic, u8 *dest, bool8 isTrainer, bool8 ignoreDeoxys)
+static bool16 DecompressPic(u16 species, u32 personality, bool8 isFrontPic, u8 *dest, bool8 isTrainer, bool8 ignoreDeoxys)
{
if (!isTrainer)
{
if (isFrontPic)
{
if (!ignoreDeoxys)
- {
LoadSpecialPokePic(&gMonFrontPicTable[species], dest, species, personality, isFrontPic);
- }
else
- {
LoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], dest, species, personality, isFrontPic);
- }
}
else
{
if (!ignoreDeoxys)
- {
LoadSpecialPokePic(&gMonBackPicTable[species], dest, species, personality, isFrontPic);
- }
else
- {
LoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species], dest, species, personality, isFrontPic);
- }
}
}
else
{
if (isFrontPic)
- {
DecompressPicFromTable(&gTrainerFrontPicTable[species], dest, species);
- }
else
- {
DecompressPicFromTable(&gTrainerBackPicTable[species], dest, species);
- }
}
return FALSE;
}
-static bool16 sub_818D09C(u16 species, u32 personality, bool8 isFrontPic, u8 *dest, bool8 isTrainer)
+static bool16 DecompressPic_HandleDeoxys(u16 species, u32 personality, bool8 isFrontPic, u8 *dest, bool8 isTrainer)
{
- return load_pokemon_image_TODO(species, personality, isFrontPic, dest, isTrainer, FALSE);
+ return DecompressPic(species, personality, isFrontPic, dest, isTrainer, FALSE);
}
-static void sub_818D0C4(u16 species, u32 otId, u32 personality, u8 paletteSlot, u16 paletteTag, bool8 isTrainer)
+static void LoadPicPaletteByTagOrSlot(u16 species, u32 otId, u32 personality, u8 paletteSlot, u16 paletteTag, bool8 isTrainer)
{
if (!isTrainer)
{
if (paletteTag == 0xFFFF)
{
- gUnknown_0203CCEC.paletteTag |= 0xFFFF;
+ sCreatingSpriteTemplate.paletteTag |= 0xFFFF;
LoadCompressedPalette(GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality), 0x100 + paletteSlot * 0x10, 0x20);
}
else
{
- gUnknown_0203CCEC.paletteTag = paletteTag;
+ sCreatingSpriteTemplate.paletteTag = paletteTag;
LoadCompressedObjectPalette(GetMonSpritePalStructFromOtIdPersonality(species, otId, personality));
}
}
@@ -134,42 +122,34 @@ static void sub_818D0C4(u16 species, u32 otId, u32 personality, u8 paletteSlot,
{
if (paletteTag == 0xFFFF)
{
- gUnknown_0203CCEC.paletteTag |= 0xFFFF;
+ sCreatingSpriteTemplate.paletteTag |= 0xFFFF;
LoadCompressedPalette(gTrainerFrontPicPaletteTable[species].data, 0x100 + paletteSlot * 0x10, 0x20);
}
else
{
- gUnknown_0203CCEC.paletteTag = paletteTag;
+ sCreatingSpriteTemplate.paletteTag = paletteTag;
LoadCompressedObjectPalette(&gTrainerFrontPicPaletteTable[species]);
}
}
}
-static void sub_818D180(u16 species, u32 otId, u32 personality, u8 paletteSlot, bool8 isTrainer)
+static void LoadPicPaletteBySlot(u16 species, u32 otId, u32 personality, u8 paletteSlot, bool8 isTrainer)
{
if (!isTrainer)
- {
LoadCompressedPalette(GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality), paletteSlot * 0x10, 0x20);
- }
else
- {
LoadCompressedPalette(gTrainerFrontPicPaletteTable[species].data, paletteSlot * 0x10, 0x20);
- }
}
-static void uns_builder_assign_animtable1(bool8 isTrainer)
+static void AssignSpriteAnimsTable(bool8 isTrainer)
{
if (!isTrainer)
- {
- gUnknown_0203CCEC.anims = gPlayerMonSpriteAnimsTable;
- }
+ sCreatingSpriteTemplate.anims = gPlayerMonSpriteAnimsTable;
else
- {
- gUnknown_0203CCEC.anims = gUnknown_0830536C[0];
- }
+ sCreatingSpriteTemplate.anims = gUnknown_0830536C[0];
}
-static u16 oamt_spawn_poke_or_trainer_picture(u16 species, u32 otId, u32 personality, bool8 isFrontPic, s16 x, s16 y, u8 paletteSlot, u16 paletteTag, bool8 isTrainer, bool8 ignoreDeoxys)
+static u16 CreatePicSprite(u16 species, u32 otId, u32 personality, bool8 isFrontPic, s16 x, s16 y, u8 paletteSlot, u16 paletteTag, bool8 isTrainer, bool8 ignoreDeoxys)
{
u8 i;
u8 *framePics;
@@ -177,14 +157,14 @@ static u16 oamt_spawn_poke_or_trainer_picture(u16 species, u32 otId, u32 persona
int j;
u8 spriteId;
- for (i = 0; i < 8; i ++)
+ for (i = 0; i < PICS_COUNT; i ++)
{
- if (!gUnknown_0203CD04[i].active)
+ if (!sSpritePics[i].active)
{
break;
}
}
- if (i == 8)
+ if (i == PICS_COUNT)
{
return 0xFFFF;
}
@@ -199,7 +179,7 @@ static u16 oamt_spawn_poke_or_trainer_picture(u16 species, u32 otId, u32 persona
Free(framePics);
return 0xFFFF;
}
- if (load_pokemon_image_TODO(species, personality, isFrontPic, framePics, isTrainer, ignoreDeoxys))
+ if (DecompressPic(species, personality, isFrontPic, framePics, isTrainer, ignoreDeoxys))
{
// debug trap?
return 0xFFFF;
@@ -209,32 +189,32 @@ static u16 oamt_spawn_poke_or_trainer_picture(u16 species, u32 otId, u32 persona
images[j].data = framePics + 0x800 * j;
images[j].size = 0x800;
}
- gUnknown_0203CCEC.tileTag = 0xFFFF;
- gUnknown_0203CCEC.oam = &gUnknown_0860B064;
- uns_builder_assign_animtable1(isTrainer);
- gUnknown_0203CCEC.images = images;
- gUnknown_0203CCEC.affineAnims = gDummySpriteAffineAnimTable;
- gUnknown_0203CCEC.callback = nullsub_122;
- sub_818D0C4(species, otId, personality, paletteSlot, paletteTag, isTrainer);
- spriteId = CreateSprite(&gUnknown_0203CCEC, x, y, 0);
+ sCreatingSpriteTemplate.tileTag = 0xFFFF;
+ sCreatingSpriteTemplate.oam = &gUnknown_0860B064;
+ AssignSpriteAnimsTable(isTrainer);
+ sCreatingSpriteTemplate.images = images;
+ sCreatingSpriteTemplate.affineAnims = gDummySpriteAffineAnimTable;
+ sCreatingSpriteTemplate.callback = DummyPicSpriteCallback;
+ LoadPicPaletteByTagOrSlot(species, otId, personality, paletteSlot, paletteTag, isTrainer);
+ spriteId = CreateSprite(&sCreatingSpriteTemplate, x, y, 0);
if (paletteTag == 0xFFFF)
{
gSprites[spriteId].oam.paletteNum = paletteSlot;
}
- gUnknown_0203CD04[i].frames = framePics;
- gUnknown_0203CD04[i].images = images;
- gUnknown_0203CD04[i].paletteTag = paletteTag;
- gUnknown_0203CD04[i].spriteId = spriteId;
- gUnknown_0203CD04[i].active = TRUE;
+ sSpritePics[i].frames = framePics;
+ sSpritePics[i].images = images;
+ sSpritePics[i].paletteTag = paletteTag;
+ sSpritePics[i].spriteId = spriteId;
+ sSpritePics[i].active = TRUE;
return spriteId;
}
-static u16 sub_818D384(u16 species, u32 otId, u32 personality, bool8 isFrontPic, s16 x, s16 y, u8 paletteSlot, u16 paletteTag, bool8 isTrainer)
+static u16 CreatePicSprite_HandleDeoxys(u16 species, u32 otId, u32 personality, bool8 isFrontPic, s16 x, s16 y, u8 paletteSlot, u16 paletteTag, bool8 isTrainer)
{
- return oamt_spawn_poke_or_trainer_picture(species, otId, personality, isFrontPic, x, y, paletteSlot, paletteTag, isTrainer, FALSE);
+ return CreatePicSprite(species, otId, personality, isFrontPic, x, y, paletteSlot, paletteTag, isTrainer, FALSE);
}
-u16 sub_818D3E4(u16 species, u32 otId, u32 personality, u8 flags, s16 x, s16 y, u8 paletteSlot, u16 paletteTag)
+u16 CreatePicSprite2(u16 species, u32 otId, u32 personality, u8 flags, s16 x, s16 y, u8 paletteSlot, u16 paletteTag)
{
u8 *framePics;
struct SpriteFrameImage *images;
@@ -243,14 +223,14 @@ u16 sub_818D3E4(u16 species, u32 otId, u32 personality, u8 flags, s16 x, s16 y,
u8 spriteId;
u8 flags2;
- for (i = 0; i < 8; i ++)
+ for (i = 0; i < PICS_COUNT; i ++)
{
- if (!gUnknown_0203CD04[i].active)
+ if (!sSpritePics[i].active)
{
break;
}
}
- if (i == 8)
+ if (i == PICS_COUNT)
{
return 0xFFFF;
}
@@ -274,7 +254,7 @@ u16 sub_818D3E4(u16 species, u32 otId, u32 personality, u8 flags, s16 x, s16 y,
Free(framePics);
return 0xFFFF;
}
- if (load_pokemon_image_TODO(species, personality, flags, framePics, FALSE, FALSE))
+ if (DecompressPic(species, personality, flags, framePics, FALSE, FALSE))
{
// debug trap?
return 0xFFFF;
@@ -284,76 +264,76 @@ u16 sub_818D3E4(u16 species, u32 otId, u32 personality, u8 flags, s16 x, s16 y,
images[j].data = framePics + 0x800 * j;
images[j].size = 0x800;
}
- gUnknown_0203CCEC.tileTag = 0xFFFF;
- gUnknown_0203CCEC.anims = gMonAnimationsSpriteAnimsPtrTable[species];
- gUnknown_0203CCEC.images = images;
+ sCreatingSpriteTemplate.tileTag = 0xFFFF;
+ sCreatingSpriteTemplate.anims = gMonAnimationsSpriteAnimsPtrTable[species];
+ sCreatingSpriteTemplate.images = images;
if (flags2 == 0x01)
{
- gUnknown_0203CCEC.affineAnims = gUnknown_082FF694;
- gUnknown_0203CCEC.oam = &gUnknown_0860B06C;
+ sCreatingSpriteTemplate.affineAnims = gUnknown_082FF694;
+ sCreatingSpriteTemplate.oam = &gUnknown_0860B06C;
}
else if (flags2 == 0x00)
{
- gUnknown_0203CCEC.affineAnims = gUnknown_082FF618;
- gUnknown_0203CCEC.oam = &gUnknown_0860B06C;
+ sCreatingSpriteTemplate.affineAnims = gUnknown_082FF618;
+ sCreatingSpriteTemplate.oam = &gUnknown_0860B06C;
}
else
{
- gUnknown_0203CCEC.oam = &gUnknown_0860B064;
- gUnknown_0203CCEC.affineAnims = gDummySpriteAffineAnimTable;
+ sCreatingSpriteTemplate.oam = &gUnknown_0860B064;
+ sCreatingSpriteTemplate.affineAnims = gDummySpriteAffineAnimTable;
}
- gUnknown_0203CCEC.callback = nullsub_122;
- sub_818D0C4(species, otId, personality, paletteSlot, paletteTag, FALSE);
- spriteId = CreateSprite(&gUnknown_0203CCEC, x, y, 0);
+ sCreatingSpriteTemplate.callback = DummyPicSpriteCallback;
+ LoadPicPaletteByTagOrSlot(species, otId, personality, paletteSlot, paletteTag, FALSE);
+ spriteId = CreateSprite(&sCreatingSpriteTemplate, x, y, 0);
if (paletteTag == 0xFFFF)
{
gSprites[spriteId].oam.paletteNum = paletteSlot;
}
- gUnknown_0203CD04[i].frames = framePics;
- gUnknown_0203CD04[i].images = images;
- gUnknown_0203CD04[i].paletteTag = paletteTag;
- gUnknown_0203CD04[i].spriteId = spriteId;
- gUnknown_0203CD04[i].active = TRUE;
+ sSpritePics[i].frames = framePics;
+ sSpritePics[i].images = images;
+ sSpritePics[i].paletteTag = paletteTag;
+ sSpritePics[i].spriteId = spriteId;
+ sSpritePics[i].active = TRUE;
return spriteId;
}
-static u16 sub_818D5B0(u16 spriteId)
+static u16 FreeAndDestroyPicSpriteInternal(u16 spriteId)
{
u8 i;
u8 *framePics;
struct SpriteFrameImage *images;
- for (i = 0; i < 8; i ++)
+ for (i = 0; i < PICS_COUNT; i ++)
{
- if (gUnknown_0203CD04[i].spriteId == spriteId)
+ if (sSpritePics[i].spriteId == spriteId)
{
break;
}
}
- if (i == 8)
+ if (i == PICS_COUNT)
{
return 0xFFFF;
}
- framePics = gUnknown_0203CD04[i].frames;
- images = gUnknown_0203CD04[i].images;
- if (gUnknown_0203CD04[i].paletteTag != 0xFFFF)
+ framePics = sSpritePics[i].frames;
+ images = sSpritePics[i].images;
+ if (sSpritePics[i].paletteTag != 0xFFFF)
{
FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(gSprites[spriteId].oam.paletteNum));
}
DestroySprite(&gSprites[spriteId]);
Free(framePics);
Free(images);
- gUnknown_0203CD04[i] = gUnknown_0860B058;
+ sSpritePics[i] = sDummyPicData;
return 0;
}
static u16 sub_818D65C(u16 species, u32 otId, u32 personality, bool8 isFrontPic, u8 paletteSlot, u8 windowId, bool8 isTrainer)
{
- if (sub_818D09C(species, personality, isFrontPic, (u8 *)GetWindowAttribute(windowId, WINDOW_TILE_DATA), FALSE))
+ if (DecompressPic_HandleDeoxys(species, personality, isFrontPic, (u8 *)GetWindowAttribute(windowId, WINDOW_TILE_DATA), FALSE))
{
return 0xFFFF;
}
- sub_818D180(species, otId, personality, paletteSlot, isTrainer);
+ LoadPicPaletteBySlot(species, otId, personality, paletteSlot, isTrainer);
return 0;
}
@@ -362,29 +342,29 @@ static u16 sub_818D6CC(u16 species, u32 otId, u32 personality, bool8 isFrontPic,
u8 *framePics;
framePics = Alloc(4 * 0x800);
- if (framePics && !sub_818D09C(species, personality, isFrontPic, framePics, isTrainer))
+ if (framePics && !DecompressPic_HandleDeoxys(species, personality, isFrontPic, framePics, isTrainer))
{
BlitBitmapRectToWindow(windowId, framePics, 0, 0, 0x40, 0x40, destX, destY, 0x40, 0x40);
- sub_818D180(species, otId, personality, paletteSlot, isTrainer);
+ LoadPicPaletteBySlot(species, otId, personality, paletteSlot, isTrainer);
Free(framePics);
return 0;
}
return 0xFFFF;
}
-static u16 sub_818D778(u16 species, u32 otId, u32 personality, bool8 isFrontPic, s16 x, s16 y, u8 paletteSlot, u16 paletteTag, bool8 ignoreDeoxys)
+static u16 CreateMonPicSprite(u16 species, u32 otId, u32 personality, bool8 isFrontPic, s16 x, s16 y, u8 paletteSlot, u16 paletteTag, bool8 ignoreDeoxys)
{
- return oamt_spawn_poke_or_trainer_picture(species, otId, personality, isFrontPic, x, y, paletteSlot, paletteTag, FALSE, ignoreDeoxys);
+ return CreatePicSprite(species, otId, personality, isFrontPic, x, y, paletteSlot, paletteTag, FALSE, ignoreDeoxys);
}
-u16 sub_818D7D8(u16 species, u32 otId, u32 personality, bool8 isFrontPic, s16 x, s16 y, u8 paletteSlot, u16 paletteTag)
+u16 CreateMonPicSprite_HandleDeoxys(u16 species, u32 otId, u32 personality, bool8 isFrontPic, s16 x, s16 y, u8 paletteSlot, u16 paletteTag)
{
- return sub_818D778(species, otId, personality, isFrontPic, x, y, paletteSlot, paletteTag, FALSE);
+ return CreateMonPicSprite(species, otId, personality, isFrontPic, x, y, paletteSlot, paletteTag, FALSE);
}
-u16 sub_818D820(u16 spriteId)
+u16 FreeAndDestroyMonPicSprite(u16 spriteId)
{
- return sub_818D5B0(spriteId);
+ return FreeAndDestroyPicSpriteInternal(spriteId);
}
u16 sub_818D834(u16 species, u32 otId, u32 personality, bool8 isFrontPic, u8 paletteSlot, u8 windowId)
@@ -397,14 +377,14 @@ u16 sub_818D864(u16 species, u32 otId, u32 personality, bool8 isFrontPic, u16 de
return sub_818D6CC(species, otId, personality, isFrontPic, destX, destY, paletteSlot, windowId, FALSE);
}
-u16 sub_818D8AC(u16 species, bool8 isFrontPic, s16 x, s16 y, u8 paletteSlot, u16 paletteTag)
+u16 CreateTrainerPicSprite(u16 species, bool8 isFrontPic, s16 x, s16 y, u8 paletteSlot, u16 paletteTag)
{
- return sub_818D384(species, 0, 0, isFrontPic, x, y, paletteSlot, paletteTag, TRUE);
+ return CreatePicSprite_HandleDeoxys(species, 0, 0, isFrontPic, x, y, paletteSlot, paletteTag, TRUE);
}
-u16 sub_818D8F0(u16 spriteId)
+u16 FreeAndDestroyTrainerPicSprite(u16 spriteId)
{
- return sub_818D5B0(spriteId);
+ return FreeAndDestroyPicSpriteInternal(spriteId);
}
u16 sub_818D904(u16 species, bool8 isFrontPic, u8 paletteSlot, u8 windowId)
@@ -417,17 +397,17 @@ u16 sub_818D938(u16 species, bool8 isFrontPic, u16 destX, u16 destY, u8 paletteS
return sub_818D6CC(species, 0, 0, isFrontPic, destX, destY, paletteSlot, windowId, TRUE);
}
-u8 sub_818D97C(u8 a0, u8 a1)
+u16 PlayerGenderToFrontTrainerPicId_Debug(u8 gender, bool8 getClass)
{
- if (a1 == 1)
+ if (getClass == TRUE)
{
- switch (a0)
+ switch (gender)
{
- default:
- return gFacilityClassToPicIndex[0x3F];
- case 0:
- return gFacilityClassToPicIndex[0x3C];
+ default:
+ return gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_MAY];
+ case MALE:
+ return gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_BRENDAN];
}
}
- return a0;
+ return gender;
}
diff --git a/src/unk_text_util_2.c b/src/unk_text_util_2.c
index ca8246128..4821ed776 100644
--- a/src/unk_text_util_2.c
+++ b/src/unk_text_util_2.c
@@ -4,6 +4,7 @@
#include "text.h"
#include "sound.h"
+ALIGNED(4)
static const u8 sUnknown_08616124[] = {1, 2, 4};
static const u16 sFont6BrailleGlyphs[] = INCBIN_U16("data/graphics/fonts/font6.fwjpnfont");