summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battle_script_commands.c2
-rw-r--r--src/battle_setup.c2
-rw-r--r--src/clock.c2
-rw-r--r--src/contest.c2761
-rw-r--r--src/credits.c2
-rw-r--r--src/data/heal_locations.h25
-rw-r--r--src/data/text/move_descriptions.h714
-rw-r--r--src/data/text/move_names.h3
-rw-r--r--src/field_player_avatar.c581
-rw-r--r--src/field_region_map.c2
-rw-r--r--src/field_special_scene.c2
-rw-r--r--src/field_specials.c4329
-rw-r--r--src/heal_location.c74
-rw-r--r--src/main_menu.c2
-rw-r--r--src/match_call.c4
-rw-r--r--src/menu.c3
-rw-r--r--src/overworld.c6
-rw-r--r--src/pokemon.c6
-rw-r--r--src/pokemon_storage_system.c523
-rw-r--r--src/pokemon_summary_screen.c7
-rw-r--r--src/region_map.c112
-rw-r--r--src/rotating_gate.c6
-rw-r--r--src/scrcmd.c2
-rw-r--r--src/tv.c4
-rw-r--r--src/wallclock.c4
25 files changed, 9013 insertions, 165 deletions
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index 5c0b78240..7f5a4fb48 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -7230,7 +7230,7 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr)
PREPARE_STAT_BUFFER(gBattleTextBuff1, statId)
- if ((statValue << 0x18) < 0) // stat decrease
+ if (statValue <= -1) // Stat decrease.
{
if (gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].mistTimer
&& !certain && gCurrentMove != MOVE_CURSE)
diff --git a/src/battle_setup.c b/src/battle_setup.c
index e478af936..2955a33fc 100644
--- a/src/battle_setup.c
+++ b/src/battle_setup.c
@@ -900,7 +900,7 @@ static void CB2_GiveStarter(void)
{
u16 starterMon;
- *GetVarPointer(VAR_FIRST_POKE) = gSpecialVar_Result;
+ *GetVarPointer(VAR_STARTER_MON) = gSpecialVar_Result;
starterMon = GetStarterPokemon(gSpecialVar_Result);
ScriptGiveMon(starterMon, 5, 0, 0, 0, 0);
ResetTasks();
diff --git a/src/clock.c b/src/clock.c
index ccbb0c24b..91eb5f16d 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -88,6 +88,6 @@ static void ReturnFromStartWallClock(void)
void StartWallClock(void)
{
- SetMainCallback2(Cb2_StartWallClock);
+ SetMainCallback2(CB2_StartWallClock);
gMain.savedCallback = ReturnFromStartWallClock;
}
diff --git a/src/contest.c b/src/contest.c
new file mode 100644
index 000000000..8513fc4a9
--- /dev/null
+++ b/src/contest.c
@@ -0,0 +1,2761 @@
+#include "global.h"
+#include "gpu_regs.h"
+#include "bg.h"
+#include "malloc.h"
+#include "constants/items.h"
+#include "constants/event_objects.h"
+#include "constants/moves.h"
+#include "constants/songs.h"
+#include "constants/species.h"
+#include "constants/flags.h"
+#include "battle.h"
+#include "battle_anim.h"
+#include "blend_palette.h"
+#include "contest.h"
+#include "data2.h"
+#include "decompress.h"
+#include "graphics.h"
+#include "link.h"
+#include "m4a.h"
+#include "main.h"
+#include "menu.h"
+#include "overworld.h"
+#include "palette.h"
+#include "random.h"
+#include "script.h"
+#include "sound.h"
+#include "sprite.h"
+#include "string_util.h"
+#include "task.h"
+#include "text.h"
+#include "tv.h"
+#include "scanline_effect.h"
+#include "util.h"
+#include "contest_link_80F57C4.h"
+#include "dma3.h"
+#include "battle_message.h"
+#include "event_scripts.h"
+#include "event_data.h"
+#include "strings.h"
+#include "contest_effect.h"
+#include "contest_link_80FC4F4.h"
+#include "script_pokemon_util_80F87D8.h"
+#include "international_string_util.h"
+#include "data2.h"
+#include "constants/rgb.h"
+
+extern void (*gFieldCallback)(void);
+
+void sub_80D782C(void);
+void sub_80D7C7C(u8 taskId);
+void sub_80D7CB4(u8 taskId);
+void sub_80D7DAC(u8 taskId);
+void sub_80D7DC8(u8 taskId);
+void sub_80D7DE8(u8 taskId);
+bool8 sub_80D7E44(u8 *);
+void sub_80D80C8(u8 taskId);
+void sub_80D8108(u8 taskId);
+void vblank_cb_battle(void);
+void sub_80D823C(void);
+void sub_80D833C(u8 taskId);
+void sub_80D8424(u8 taskId);
+void sub_80D8610(u8 taskId);
+void sub_80D8490(u8 taskId);
+void sub_80D880C(s8);
+void sub_80D883C(s8);
+void sub_80D8894(u8 taskId);
+void sub_80D892C(u8 taskId);
+void sub_80D895C(u8 taskId);
+void sub_80D8A04(u8 taskId);
+void sub_80D8A50(u8 taskId);
+void sub_80D8A88(u8 taskId);
+void sub_80D8B38(u8 taskId);
+void sub_80DA110(u8);
+void sub_80DA134(struct Sprite *);
+void sub_80DA164(struct Sprite *);
+void sub_80DA198(u8);
+void sub_80DA25C(u8);
+void sub_80DA28C(u8);
+void sub_80DA31C(u8);
+void sub_80DA348(u8);
+void sub_80DA38C(u8);
+void sub_80DA3CC(u8);
+void sub_80DA464(u8);
+void sub_80DA49C(u8);
+void sub_80DA4CC(u8);
+void sub_80DA51C(u8);
+void sub_80DA5B4(u8);
+void sub_80DA5E8(u8);
+void sub_80DA6B4(u8);
+void sub_80DA700(u8);
+void sub_80DA740(u8);
+void sub_80DA7A0(u8);
+void sub_80DA7EC(u8);
+void sub_80DA830(u8);
+void sub_80DA874(void);
+bool8 sub_80DA8A4(void);
+void sub_80DAF04(u8);
+void sub_80DAF1C(u8 a0, u8 a1);
+void sub_80DAF88(u8);
+void sub_80DAFA0(u8, u8);
+u8 sub_80DB0C4(void);
+u8 sub_80DB120(void);
+u8 sub_80DB174(u16, u32, u32, u32);
+void sub_80DB2BC(void);
+void prints_contest_move_description(u16);
+u16 sub_80DE84C(u16);
+void sub_80DB89C(void);
+u16 sub_80DB8B8(u8);
+void sub_80DB918(void);
+bool8 sub_80DBCA8(u8);
+void sub_80DBF68(void);
+void sub_80DBF90(void);
+void sub_80DC2BC(void);
+void sub_80DC490(bool8);
+void sub_80DC4F0(void);
+void sub_80DC594(void);
+void sub_80DC5E8(void);
+void sub_80DC7EC(void);
+void sub_80DCD48(void);
+void sub_80DCE58(u8);
+void sub_80DD04C(void);
+void sub_80DD590(void);
+void sub_80DDB0C(void);
+void sub_80DDBE8(void);
+bool8 sub_80DE1E8(u8);
+void sub_80DE224(void);
+void sub_80DE350(void);
+void sub_80DE424(u8);
+void sub_80DE69C(u8);
+void sub_80DEA20(void);
+void Contest_PrintTextToBg0WindowAt(u32, u8 *, s32, u8, u8);
+void Contest_StartTextPrinter(const u8 *, u8);
+void ContestBG_FillBoxWithIncrementingTile(u8, u16, u8, u8, u8, u8, u8, u8);
+bool32 Contest_RunTextPrinters(void);
+void Contest_SetBgCopyFlags(u32);
+void sub_80FC9F8(u8);
+bool8 AreMovesContestCombo(u16, u16);
+void sub_80DBD18(void);
+void sub_80DF250(void);
+void sub_80DF4F8(void);
+void sub_80DD080(u8);
+void sub_80DF080(u8);
+void sub_80DF750(void);
+void sub_80DE9DC(u8);
+void sub_80DCBE8(u8, u8);
+u8 sub_80DC9EC(u8);
+u16 sub_80DE834(u16);
+void sub_80DE864(u8);
+void sub_80DEAA8(u16);
+void sub_80DE9B0(u8);
+void sub_80DC674(u8);
+void sub_80DE12C(void);
+void sub_80DD45C(u8, u8);
+void sub_80DD720(u8);
+void sub_80DE008(bool8);
+void sub_80DC028(s16, s16, u8);
+bool8 sub_80DB5B8(u8, u8);
+bool8 sub_80DB798(u8);
+void sub_80DB884(void);
+void sub_80DC9B4(u8);
+void sub_80DDED0(s8, s8);
+void sub_80DDCDC(s8);
+void sub_80DDE0C(void);
+void sub_80DD940(void);
+void sub_80DB944(void);
+void sub_80DBA18(void);
+void sub_80DC3AC(void);
+bool8 sub_80DC3C4(void);
+void sub_80DF9D4(u8 *);
+void sub_80DF9E0(u8 *, s32);
+void ContestBG_FillBoxWithTile(u8, u16, u8, u8, u8, u8, u8);
+void Contest_PrintTextToBg0WindowStd(u8, const u8 *);
+
+EWRAM_DATA struct ContestPokemon gContestMons[4] = {0};
+EWRAM_DATA s16 gContestMonConditions[4] = {0};
+EWRAM_DATA s16 gUnknown_02039F08[4] = {0};
+EWRAM_DATA s16 gUnknown_02039F10[4] = {0};
+EWRAM_DATA s16 gUnknown_02039F18[4] = {0};
+EWRAM_DATA u8 gContestFinalStandings[4] = {0};
+EWRAM_DATA u8 gUnknown_02039F24 = 0;
+EWRAM_DATA u8 gContestPlayerMonIndex = 0;
+EWRAM_DATA u8 gUnknown_02039F26[4] = {0};
+EWRAM_DATA u8 gIsLinkContest = 0;
+// Bit 0: Is a link contest
+// Bit 1: Link contest uses wireless adapter
+EWRAM_DATA u8 gUnknown_02039F2B = 0;
+EWRAM_DATA u16 gSpecialVar_ContestCategory = 0;
+EWRAM_DATA u16 gSpecialVar_ContestRank = 0;
+EWRAM_DATA u8 gUnknown_02039F30 = 0;
+EWRAM_DATA u8 gUnknown_02039F31 = 0;
+EWRAM_DATA struct ContestResources * gContestResources = NULL;
+EWRAM_DATA u8 sContestBgCopyFlags = 0;
+EWRAM_DATA struct ContestWinner gUnknown_02039F3C = {0};
+
+u32 gContestRngValue;
+
+extern u16 gBattle_BG0_X;
+extern u16 gBattle_BG0_Y;
+extern u16 gBattle_BG1_X;
+extern s16 gBattle_BG1_Y;
+extern u16 gBattle_BG2_X;
+extern u16 gBattle_BG2_Y;
+extern u16 gBattle_BG3_X;
+extern u16 gBattle_BG3_Y;
+extern u16 gBattle_WIN0H;
+extern u16 gBattle_WIN0V;
+extern u16 gBattle_WIN1H;
+extern u16 gBattle_WIN1V;
+
+extern const u8 gContestMiscGfx[];
+extern const u8 gContestAudienceGfx[];
+extern const u8 gUnknown_08C16FA8[];
+extern const u8 gUnknown_08C16E90[];
+extern const u8 gUnknown_08C17170[];
+extern const u16 gUnknown_08587C30[];
+extern const struct BgTemplate gUnknown_08587F34[4];
+extern const struct WindowTemplate gUnknown_08587F44[];
+extern const u8 *const gUnknown_08587D90[];
+extern const u8 *const gUnknown_08587F08[];
+extern const u8 *const gUnknown_08587F1C[];
+extern const u8 gText_0827D55A[];
+extern const u8 gText_0827E793[];
+extern const u8 gText_0827E32E[];
+extern const u8 gText_0827E35B[];
+extern const u8 gText_0827E38D[];
+extern const u8 gText_0827E2FE[];
+extern const u8 gText_0827E6E3[];
+extern const u8 gText_0827E73C[];
+extern const u8 gText_0827E717[];
+extern const u8 gText_0827E76A[];
+extern const u8 gText_0827E7EA[];
+extern const u8 gText_0827E817[];
+extern const u8 gText_0827E58A[];
+extern const u8 gText_0827D56F[];
+extern const u8 gText_0827D597[];
+extern const struct ContestPokemon gContestOpponents[96];
+extern const u8 gUnknown_085898A4[96];
+extern const struct CompressedSpriteSheet gUnknown_08587C00;
+extern const u8 gContest2Pal[];
+extern const struct SpriteTemplate gSpriteTemplate_8587BE8;
+extern const struct CompressedSpriteSheet gUnknown_08587C08;
+extern const struct CompressedSpritePalette gUnknown_08587C10;
+extern const struct SpriteTemplate gSpriteTemplate_8587C18;
+extern const union AffineAnimCmd *const gUnknown_082FF6C0[];
+extern const union AffineAnimCmd *const gUnknown_082FF694[];
+extern const u8 *const gContestEffectDescriptionPointers[];
+
+void TaskDummy1(u8 taskId)
+{
+}
+
+void ResetLinkContestBoolean(void)
+{
+ gIsLinkContest = 0;
+}
+
+void sub_80D7678(void)
+{
+ u16 savedIme;
+
+ SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP);
+ SetGpuReg(REG_OFFSET_BLDCNT, 0);
+ SetGpuReg(REG_OFFSET_BLDALPHA, 0);
+ SetGpuReg(REG_OFFSET_BLDY, 0);
+ SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR);
+ SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR | WINOUT_WINOBJ_BG0 | WINOUT_WINOBJ_BG1 | WINOUT_WINOBJ_BG2 | WINOUT_WINOBJ_BG3 | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR);
+ SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON);
+
+ gBattle_BG0_X = 0;
+ gBattle_BG0_Y = 0;
+ gBattle_BG1_X = 0;
+ gBattle_BG1_Y = 0;
+ gBattle_BG2_X = 0;
+ gBattle_BG2_Y = 0;
+ gBattle_BG3_X = 0;
+ gBattle_BG3_Y = 0;
+ gBattle_WIN0H = 0;
+ gBattle_WIN0V = 0;
+ gBattle_WIN1H = 0;
+ gBattle_WIN1V = 0;
+}
+
+void LoadContestBgAfterMoveAnim(void)
+{
+ s32 i;
+
+ LZDecompressVram(gContestMiscGfx, (void *)VRAM);
+ LZDecompressVram(gContestAudienceGfx, (void *)(VRAM + 0x2000));
+ CopyToBgTilemapBuffer(3, gUnknown_08C16FA8, 0, 0);
+ CopyBgTilemapBufferToVram(3);
+ LoadCompressedPalette(gUnknown_08C16E90, 0, 0x200);
+ sub_80D782C();
+ for (i = 0; i < 4; i++)
+ {
+ u32 var = 5 + i;
+
+ LoadPalette(shared18000.unk18004[var], 16 * (5 + gUnknown_02039F26[i]), 16 * sizeof(u16));
+ }
+}
+
+void sub_80D779C(void)
+{
+ s32 i;
+
+ ResetBgsAndClearDma3BusyFlags(0);
+ InitBgsFromTemplates(0, gUnknown_08587F34, ARRAY_COUNT(gUnknown_08587F34));
+ SetBgAttribute(3, BG_CTRL_ATTR_PRIORITY, 1);
+ for (i = 0; i < 4; i++)
+ {
+ SetBgTilemapBuffer(i, gContestResources->field_24[i]);
+ }
+}
+
+void sub_80D77E4(void)
+{
+ InitWindows(gUnknown_08587F44);
+ DeactivateAllTextPrinters();
+ if (gIsLinkContest & 1)
+ {
+ gTextFlags.flag_0 = FALSE;
+ }
+ else
+ {
+ gTextFlags.flag_0 = TRUE;
+ }
+}
+
+void sub_80D782C(void)
+{
+ s32 i;
+
+ LoadPalette(gUnknown_08587C30, 0xf0, 0x20);
+ FillPalette(RGB_BLACK, 0, 2);
+ for (i = 10; i < 14; i++)
+ LoadPalette(gPlttBufferUnfaded + 241, 240 + i, 2);
+ FillPalette(RGB(31, 17, 31), 0xF3, 2);
+}
+
+void sub_80D787C(void)
+{
+ s32 i;
+
+ *gContestResources->field_0 = (struct Contest){};
+ for (i = 0; i < 4; i++)
+ {
+ gContestResources->field_0->unk19206[i] = 0xFF;
+ }
+ for (i = 0; i < 4; i++)
+ {
+ gContestResources->field_4[i] = (struct ContestantStatus){};
+ }
+ for (i = 0; i < 4; i++)
+ {
+ gContestResources->field_4[i].unkB_0 = 0;
+ gContestResources->field_4[i].effectStringId = CONTEST_STRING_NONE;
+ gContestResources->field_4[i].effectStringId2 = CONTEST_STRING_NONE;
+ }
+ *gContestResources->field_8 = (struct UnknownContestStruct7){};
+ *gContestResources->field_C = (struct ContestAIInfo){};
+ *gContestResources->field_10 = (struct UnknownContestStruct5){};
+ memset(gContestResources->field_14, 0, 4 * sizeof(struct UnknownContestStruct4));
+ if (!(gIsLinkContest & 1))
+ sub_80DCE58(0);
+ for (i = 0; i < 4; i++)
+ {
+ gContestResources->field_4[i].nextTurnOrder = 0xFF;
+ gContestResources->field_0->unk19218[i] = gUnknown_02039F26[i];
+ }
+ sub_80DD590();
+ *gContestResources->field_1c = (struct ContestResourcesField1C){};
+}
+
+void sub_80D7988(void)
+{
+ gContestResources = AllocZeroed(sizeof(struct ContestResources));
+ gContestResources->field_0 = AllocZeroed(sizeof(struct Contest));
+ gContestResources->field_4 = AllocZeroed(sizeof(struct ContestantStatus) * 4);
+ gContestResources->field_8 = AllocZeroed(sizeof(struct UnknownContestStruct7));
+ gContestResources->field_C = AllocZeroed(sizeof(struct ContestAIInfo));
+ gContestResources->field_10 = AllocZeroed(sizeof(struct UnknownContestStruct5) * 4);
+ gContestResources->field_14 = AllocZeroed(sizeof(struct UnknownContestStruct4) * 4);
+ gContestResources->field_18 = AllocZeroed(sizeof(struct ContestStruct_field_18));
+ gContestResources->field_1c = AllocZeroed(sizeof(struct ContestResourcesField1C));
+ gContestResources->field_20 = AllocZeroed(sizeof(struct ContestResourcesField20));
+ gContestResources->field_24[0] = AllocZeroed(0x1000);
+ gContestResources->field_24[1] = AllocZeroed(0x1000);
+ gContestResources->field_24[2] = AllocZeroed(0x1000);
+ gContestResources->field_24[3] = AllocZeroed(0x1000);
+ gContestResources->field_34 = AllocZeroed(0x800);
+ gContestResources->field_38 = AllocZeroed(0x800);
+ gContestResources->field_3c = AllocZeroed(0x2000);
+ gUnknown_0202305C = gContestResources->field_3c;
+ gUnknown_02023060 = gContestResources->field_24[1];
+}
+
+void sub_80D7A5C(void)
+{
+ FREE_AND_SET_NULL(gContestResources->field_0);
+ FREE_AND_SET_NULL(gContestResources->field_4);
+ FREE_AND_SET_NULL(gContestResources->field_8);
+ FREE_AND_SET_NULL(gContestResources->field_C);
+ FREE_AND_SET_NULL(gContestResources->field_10);
+ FREE_AND_SET_NULL(gContestResources->field_14);
+ FREE_AND_SET_NULL(gContestResources->field_18);
+ FREE_AND_SET_NULL(gContestResources->field_1c);
+ FREE_AND_SET_NULL(gContestResources->field_20);
+ FREE_AND_SET_NULL(gContestResources->field_24[0]);
+ FREE_AND_SET_NULL(gContestResources->field_24[1]);
+ FREE_AND_SET_NULL(gContestResources->field_24[2]);
+ FREE_AND_SET_NULL(gContestResources->field_24[3]);
+ FREE_AND_SET_NULL(gContestResources->field_34);
+ FREE_AND_SET_NULL(gContestResources->field_38);
+ FREE_AND_SET_NULL(gContestResources->field_3c);
+ FREE_AND_SET_NULL(gContestResources);
+ gUnknown_0202305C = NULL;
+ gUnknown_02023060 = NULL;
+}
+
+void sub_80D7B24(void)
+{
+ switch (gMain.state)
+ {
+ case 0:
+ sContestBgCopyFlags = 0;
+ sub_80D7988();
+ AllocateMonSpritesGfx();
+ FREE_AND_SET_NULL(gMonSpritesGfxPtr->firstDecompressed);
+ gMonSpritesGfxPtr->firstDecompressed = AllocZeroed(0x4000);
+ SetVBlankCallback(NULL);
+ sub_80D779C();
+ sub_80D77E4();
+ sub_80D7678();
+ ScanlineEffect_Clear();
+ ResetPaletteFade();
+ gPaletteFade.bufferTransferDisabled = TRUE;
+ ResetSpriteData();
+ ResetTasks();
+ FreeAllSpritePalettes();
+ gReservedSpritePaletteCount = 4;
+ //shared18000.unk18000 = 0;
+ gHeap[0x1a000] = 0;
+ ClearBattleMonForms();
+ sub_80D787C();
+ gMain.state++;
+ break;
+ case 1:
+ gMain.state++;
+ break;
+ case 2:
+ if (sub_80D7E44(&gContestResources->field_0->unk1925D))
+ {
+ gContestResources->field_0->unk1925D = 0;
+ gMain.state++;
+ }
+ break;
+ case 3:
+ sub_80DE224();
+ gBattle_BG1_X = 0;
+ gBattle_BG1_Y = 0;
+ BeginFastPaletteFade(2);
+ gPaletteFade.bufferTransferDisabled = FALSE;
+ SetVBlankCallback(vblank_cb_battle);
+ gContestResources->field_0->mainTaskId = CreateTask(sub_80D7C7C, 10);
+ SetMainCallback2(sub_80D823C);
+ if (gIsLinkContest & 2)
+ {
+ sub_800E0E8();
+ CreateWirelessStatusIndicatorSprite(8, 8);
+ }
+ break;
+ }
+}
+
+void sub_80D7C7C(u8 taskId)
+{
+ if (!gPaletteFade.active)
+ {
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].func = sub_80D7CB4;
+ }
+}
+
+void sub_80D7CB4(u8 taskId)
+{
+ if (gIsLinkContest & 1)
+ {
+ if (gIsLinkContest & 2)
+ {
+ switch (gTasks[taskId].data[0])
+ {
+ case 0:
+ sub_80DBF68();
+ gTasks[taskId].data[0]++;
+ // fallthrough
+ case 1:
+ if (sub_800A520())
+ {
+ sub_800ADF8();
+ gTasks[taskId].data[0]++;
+ }
+ return;
+ case 2:
+ if (sub_800A520() != TRUE)
+ return;
+ gTasks[taskId].data[0]++;
+ break;
+ }
+ }
+
+ if (!gPaletteFade.active)
+ {
+ gPaletteFade.bufferTransferDisabled = FALSE;
+ if (!(gIsLinkContest & 2))
+ sub_80DBF68();
+ CreateTask(sub_80D7DAC, 0);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].func = TaskDummy1;
+ }
+ }
+ else
+ {
+ gTasks[taskId].func = sub_80D80C8;
+ }
+}
+
+void sub_80D7DAC(u8 taskId)
+{
+ SetTaskFuncWithFollowupFunc(taskId, sub_80FC998, sub_80D7DC8);
+}
+
+void sub_80D7DC8(u8 taskId)
+{
+ gTasks[taskId].data[0] = 1;
+ gTasks[taskId].func = sub_80D7DE8;
+}
+
+void sub_80D7DE8(u8 taskId)
+{
+ gTasks[taskId].data[0]--;
+ if (gTasks[taskId].data[0] <= 0)
+ {
+ GetMultiplayerId(); // unused return value
+ DestroyTask(taskId);
+ gTasks[gContestResources->field_0->mainTaskId].func = sub_80D80C8;
+ gRngValue = gContestRngValue;
+ }
+}
+
+u8 sub_80D7E44(u8 *a)
+{
+ u16 sp0[16];
+ u16 sp20[16];
+
+ switch (*a)
+ {
+ case 0:
+ gPaletteFade.bufferTransferDisabled = TRUE;
+ RequestDma3Fill(0, (void *)VRAM, 0x8000, 1);
+ RequestDma3Fill(0, (void *)VRAM + 0x8000, 0x8000, 1);
+ RequestDma3Fill(0, (void *)VRAM + 0x10000, 0x8000, 1);
+ break;
+ case 1:
+ LZDecompressVram(gContestMiscGfx, (void *)VRAM);
+ break;
+ case 2:
+ LZDecompressVram(gContestAudienceGfx, (void *)(VRAM + 0x2000));
+ DmaCopyLarge32(3, (void *)(VRAM + 0x2000), shared15800, 0x2000, 0x1000);
+ break;
+ case 3:
+ CopyToBgTilemapBuffer(3, gUnknown_08C16FA8, 0, 0);
+ CopyBgTilemapBufferToVram(3);
+ break;
+ case 4:
+ CopyToBgTilemapBuffer(2, gUnknown_08C17170, 0, 0);
+ CopyBgTilemapBufferToVram(2);
+ DmaCopy32Defvars(3, gContestResources->field_24[2], shared18000.unk18A04, 0x800);
+ break;
+ case 5:
+ LoadCompressedPalette(gUnknown_08C16E90, 0, 0x200);
+ CpuCopy32(gPlttBufferUnfaded + 128, sp0, 16 * sizeof(u16));
+ CpuCopy32(gPlttBufferUnfaded + (5 + gContestPlayerMonIndex) * 16, sp20, 16 * sizeof(u16));
+ CpuCopy32(sp20, gPlttBufferUnfaded + 128, 16 * sizeof(u16));
+ CpuCopy32(sp0, gPlttBufferUnfaded + (5 + gContestPlayerMonIndex) * 16, 16 * sizeof(u16));
+ DmaCopy32Defvars(3, gPlttBufferUnfaded, shared18000.unk18004, 0x200);
+ sub_80D782C();
+ break;
+ case 6:
+ sub_80DD04C();
+ sub_80DBF90();
+ sub_80DB2BC();
+ gContestResources->field_0->unk19216 = sub_80DB120();
+ sub_80DC2BC();
+ sub_80DC4F0();
+ sub_80DC594();
+ sub_80DC5E8();
+ sub_80DC7EC();
+ gBattlerPositions[0] = 0;
+ gBattlerPositions[1] = 1;
+ gBattlerPositions[2] = 3;
+ gBattlerPositions[3] = 2;
+ gBattleTypeFlags = 0;
+ gBattlerAttacker = 2;
+ gBattlerTarget = 3;
+ gBattlerSpriteIds[gBattlerAttacker] = sub_80DB0C4();
+ sub_80DEA20();
+ CopyBgTilemapBufferToVram(3);
+ CopyBgTilemapBufferToVram(2);
+ CopyBgTilemapBufferToVram(1);
+ ShowBg(3);
+ ShowBg(2);
+ ShowBg(0);
+ ShowBg(1);
+ break;
+ default:
+ *a = 0;
+ return 1;
+ }
+
+ (*a)++;
+ return 0;
+}
+
+void sub_80D80C8(u8 taskId)
+{
+ gPaletteFade.bufferTransferDisabled = FALSE;
+ if (!gPaletteFade.active)
+ {
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].func = sub_80D8108;
+ }
+}
+
+
+void sub_80D8108(u8 taskId)
+{
+ switch (gTasks[taskId].data[0])
+ {
+ case 0:
+ if (gTasks[taskId].data[1]++ <= 60)
+ break;
+ gTasks[taskId].data[1] = 0;
+ PlaySE12WithPanning(SE_C_MAKU_U, 0);
+ gTasks[taskId].data[0]++;
+ break;
+ case 1:
+ if ((gBattle_BG1_Y += 7) <= 160)
+ break;
+ gTasks[taskId].data[0]++;
+ break;
+ case 2:
+ sub_80DE350();
+ gTasks[taskId].data[0]++;
+ break;
+ case 3:
+ {
+ u16 bg0Cnt = GetGpuReg(REG_OFFSET_BG0CNT);
+ u16 bg2Cnt = GetGpuReg(REG_OFFSET_BG2CNT);
+ ((struct BgCnt *)&bg0Cnt)->priority = 0;
+ ((struct BgCnt *)&bg2Cnt)->priority = 0;
+ SetGpuReg(REG_OFFSET_BG0CNT, bg0Cnt);
+ SetGpuReg(REG_OFFSET_BG2CNT, bg2Cnt);
+ sub_80DDB0C();
+ gTasks[taskId].data[0]++;
+ break;
+ }
+ case 4:
+ default:
+ if (gContestResources->field_0->unk1920A_6)
+ break;
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].func = sub_80D833C;
+ break;
+ }
+}
+
+void sub_80D823C(void)
+{
+ s32 i;
+
+ AnimateSprites();
+ RunTasks();
+ BuildOamBuffer();
+ UpdatePaletteFade();
+
+ for (i = 0; i < 4; i++)
+ {
+ if ((sContestBgCopyFlags >> i) & 1)
+ CopyBgTilemapBufferToVram(i);
+ }
+ sContestBgCopyFlags = 0;
+}
+
+void vblank_cb_battle(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);
+ SetGpuReg(REG_OFFSET_BG2HOFS, gBattle_BG2_X);
+ SetGpuReg(REG_OFFSET_BG2VOFS, gBattle_BG2_Y);
+ SetGpuReg(REG_OFFSET_BG3HOFS, gBattle_BG3_X);
+ SetGpuReg(REG_OFFSET_BG3VOFS, gBattle_BG3_Y);
+ SetGpuReg(REG_OFFSET_WIN0H, gBattle_WIN0H);
+ SetGpuReg(REG_OFFSET_WIN0V, gBattle_WIN0V);
+ SetGpuReg(REG_OFFSET_WIN1H, gBattle_WIN1H);
+ SetGpuReg(REG_OFFSET_WIN1V, gBattle_WIN1V);
+ TransferPlttBuffer();
+ LoadOam();
+ ProcessSpriteCopyRequests();
+ ScanlineEffect_InitHBlankDmaTransfer();
+}
+
+void sub_80D833C(u8 taskId)
+{
+ if (gTasks[taskId].data[0] == 0)
+ {
+ gBattle_BG0_Y = 0;
+ gBattle_BG2_Y = 0;
+ sub_80DCD48();
+ DmaCopy32Defvars(3, gPlttBufferUnfaded, shared18000.unk18204, 0x400);
+ ConvertIntToDecimalStringN(gStringVar1, gContestResources->field_0->turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1);
+ if (!sub_80DBCA8(gContestPlayerMonIndex))
+ StringCopy(gDisplayedStringBattle, gText_0827D507);
+ else
+ StringCopy(gDisplayedStringBattle, gText_0827D531);
+ sub_80DB89C();
+ StringExpandPlaceholders(gStringVar4, gDisplayedStringBattle);
+ Contest_StartTextPrinter(gStringVar4, 1);
+ gTasks[taskId].data[0]++;
+ }
+ else
+ {
+ if (!Contest_RunTextPrinters())
+ {
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].func = sub_80D8424;
+ }
+ }
+}
+
+void sub_80D8424(u8 taskId)
+{
+ if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys == B_BUTTON))
+ {
+ PlaySE(SE_SELECT);
+ if (!sub_80DBCA8(gContestPlayerMonIndex))
+ {
+ sub_80DC490(TRUE);
+ gTasks[taskId].func = sub_80D8490;
+ }
+ else
+ {
+ gTasks[taskId].func = sub_80D8894;
+ }
+ }
+}
+
+void sub_80D8490(u8 taskId)
+{
+ u8 i;
+ u8 sp8[32];
+
+ gBattle_BG0_Y = 0xA0;
+ gBattle_BG2_Y = 0xA0;
+
+ for (i = 0; i < 4; i++)
+ {
+ u16 move = gContestMons[gContestPlayerMonIndex].moves[i];
+ u8 *r5 = sp8;
+
+ if (gContestResources->field_4[gContestPlayerMonIndex].prevMove != MOVE_NONE
+ && sub_80DE1E8(gContestPlayerMonIndex)
+ && AreMovesContestCombo(gContestResources->field_4[gContestPlayerMonIndex].prevMove, move) != 0
+ && gContestResources->field_4[gContestPlayerMonIndex].hasJudgesAttention)
+ {
+ r5 = StringCopy(sp8, gText_ColorLightShadowDarkGrey);
+ }
+ else if (move != 0
+ && gContestResources->field_4[gContestPlayerMonIndex].prevMove == move
+ && gContestMoves[move].effect != CONTEST_EFFECT_REPETITION_NOT_BORING)
+ {
+ // Gray the text because it is a repeated move
+ r5 = StringCopy(sp8, gText_ColorBlue);
+ }
+ r5 = StringCopy(r5, gMoveNames[move]);
+
+ FillWindowPixelBuffer(i + 5, 0);
+ Contest_PrintTextToBg0WindowAt(i + 5, sp8, 5, 1, 7);
+ }
+
+ sub_80D880C(gContestResources->field_0->playerMoveChoice);
+ prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[gContestResources->field_0->playerMoveChoice]);
+ gTasks[taskId].func = sub_80D8610;
+}
+
+void sub_80D8610(u8 taskId)
+{
+ u8 numMoves = 0;
+ s32 i;
+
+ for (i = 0; i < 4; i++)
+ {
+ if (gContestMons[gContestPlayerMonIndex].moves[i] != MOVE_NONE)
+ numMoves++;
+ }
+
+ if (gMain.newKeys & A_BUTTON)
+ {
+ PlaySE(SE_SELECT);
+ gTasks[taskId].func = sub_80D8894;
+ }
+ else
+ {
+ switch (gMain.newAndRepeatedKeys)
+ {
+ case B_BUTTON:
+ PlaySE(SE_SELECT);
+ sub_80DC490(FALSE);
+ ConvertIntToDecimalStringN(gStringVar1, gContestResources->field_0->turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1);
+ if (!sub_80DBCA8(gContestPlayerMonIndex))
+ StringCopy(gDisplayedStringBattle, gText_0827D507);
+ else
+ StringCopy(gDisplayedStringBattle, gText_0827D531);
+ sub_80DB89C();
+ StringExpandPlaceholders(gStringVar4, gDisplayedStringBattle);
+ Contest_StartTextPrinter(gStringVar4, 0);
+ gBattle_BG0_Y = 0;
+ gBattle_BG2_Y = 0;
+ gTasks[taskId].func = sub_80D8424;
+ break;
+ case DPAD_LEFT:
+ case DPAD_RIGHT:
+ break;
+ case DPAD_UP:
+ sub_80D883C(gContestResources->field_0->playerMoveChoice);
+ if (gContestResources->field_0->playerMoveChoice == 0)
+ gContestResources->field_0->playerMoveChoice = numMoves - 1;
+ else
+ gContestResources->field_0->playerMoveChoice--;
+ sub_80D880C(gContestResources->field_0->playerMoveChoice);
+ prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[gContestResources->field_0->playerMoveChoice]);
+ if (numMoves > 1)
+ PlaySE(SE_SELECT);
+ break;
+ case DPAD_DOWN:
+ sub_80D883C(gContestResources->field_0->playerMoveChoice);
+ if (gContestResources->field_0->playerMoveChoice == numMoves - 1)
+ gContestResources->field_0->playerMoveChoice = 0;
+ else
+ gContestResources->field_0->playerMoveChoice++;
+ sub_80D880C(gContestResources->field_0->playerMoveChoice);
+ prints_contest_move_description(gContestMons[gContestPlayerMonIndex].moves[gContestResources->field_0->playerMoveChoice]);
+ if (numMoves > 1)
+ PlaySE(SE_SELECT);
+ break;
+ }
+ }
+}
+
+void sub_80D880C(s8 a0)
+{
+ ContestBG_FillBoxWithIncrementingTile(2, 55, 0, 31 + a0 * 2, 2, 2, 17, 1);
+}
+
+void sub_80D883C(s8 a0)
+{
+ ContestBG_FillBoxWithIncrementingTile(2, 11, 0, 31 + a0 * 2, 2, 1, 17, 1);
+ ContestBG_FillBoxWithIncrementingTile(2, 11, 0, 32 + a0 * 2, 2, 1, 17, 1);
+}
+
+void sub_80D8894(u8 taskId)
+{
+ if (gIsLinkContest & 1)
+ {
+ u16 var = sub_80DB8B8(gContestPlayerMonIndex);
+ u8 taskId2;
+
+ gContestResources->field_4[gContestPlayerMonIndex].currMove = var;
+ taskId2 = CreateTask(sub_80FC9F8, 0);
+ SetTaskFuncWithFollowupFunc(taskId2, sub_80FC9F8, sub_80D892C);
+ gTasks[taskId].func = TaskDummy1;
+ sub_80DBF68();
+ sub_80DC490(FALSE);
+ }
+ else
+ {
+ sub_80DB918();
+ gTasks[taskId].func = sub_80D895C;
+ }
+}
+
+void sub_80D892C(u8 taskId)
+{
+ DestroyTask(taskId);
+ gTasks[gContestResources->field_0->mainTaskId].func = sub_80D895C;
+}
+
+void sub_80D895C(u8 taskId)
+{
+ s32 i;
+
+ sub_80DB89C();
+ gBattle_BG0_Y = 0;
+ gBattle_BG2_Y = 0;
+ sub_80DC490(FALSE);
+
+ for (i = 0; i < 4; i++)
+ {
+ FillWindowPixelBuffer(5 + i, 0);
+ PutWindowTilemap(5 + i);
+ CopyWindowToVram(5 + i, 2);
+ }
+ Contest_SetBgCopyFlags(0);
+
+ DmaCopy32Defvars(3, gPlttBufferFaded, shared18000.unk18604, 0x400);
+ LoadPalette(shared18000.unk18204, 0, 0x400);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].func = sub_80D8A04;
+}
+
+void sub_80D8A04(u8 taskId)
+{
+ if (++gTasks[taskId].data[0] > 2)
+ {
+ gTasks[taskId].data[0] = 0;
+ if (++gTasks[taskId].data[1] == 2)
+ {
+ sub_80DDBE8();
+ sub_80DE69C(1);
+ gTasks[taskId].func = sub_80D8A50;
+ }
+ }
+}
+
+void sub_80D8A50(u8 taskId)
+{
+ if (!gContestResources->field_0->unk1920A_6 && !gContestResources->field_0->unk1920B_1)
+ gTasks[taskId].func = sub_80D8A88;
+}
+
+void sub_80D8A88(u8 taskId)
+{
+ if (++gTasks[taskId].data[0] > 19)
+ {
+ gContestResources->field_0->unk19214 = 0;
+ gContestResources->field_0->unk1921C = gRngValue;
+ if ((gIsLinkContest & 1) && sub_80DA8A4())
+ {
+ s32 i;
+
+ for (i = 0; i + gUnknown_02039F30 < 4; i++)
+ {
+ gContestResources->field_4[gUnknown_02039F30 + i].currMove = sub_80DB8B8(gUnknown_02039F30 + i);
+ }
+ }
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].func = sub_80D8B38;
+ }
+}
+
+void sub_80D8B38(u8 taskId)
+{
+ u8 spriteId;
+ s32 i;
+ u8 r6 = gContestResources->field_0->unk19215;
+ s8 r3;
+
+ switch (gTasks[taskId].data[0])
+ {
+ case 0:
+ sub_80DCD48();
+ for (i = 0; gContestResources->field_0->unk19214 != gContestResources->field_8->turnOrder[i]; i++)
+ ;
+ gContestResources->field_0->unk19215 = i;
+ r6 = gContestResources->field_0->unk19215;
+ if (gIsLinkContest & 1)
+ {
+ u8 taskId2;
+
+ gContestResources->field_0->unk1920B_2 = 1;
+ if (sub_80DA8A4())
+ sub_80DD080(gContestResources->field_0->unk19215);
+ taskId2 = CreateTask(sub_80FCC88, 0);
+ SetTaskFuncWithFollowupFunc(taskId2, sub_80FCC88, sub_80DA110);
+ sub_80DBF68();
+ gTasks[taskId].data[0] = 1;
+ }
+ else
+ {
+ sub_80DD080(gContestResources->field_0->unk19215);
+ gTasks[taskId].data[0] = 2;
+ }
+ return;
+ case 1:
+ if (!gContestResources->field_0->unk1920B_2)
+ gTasks[taskId].data[0] = 2;
+ return;
+ case 2:
+ sub_80DF080(r6);
+ sub_80DF750();
+ if (gContestResources->field_4[r6].numTurnsSkipped != 0
+ || gContestResources->field_4[r6].noMoreTurns)
+ {
+ gTasks[taskId].data[0] = 31;
+ }
+ else
+ {
+ sub_80DB89C();
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[0] = 3;
+ }
+ return;
+ case 3:
+ for (i = 0; i < 4; i++)
+ gBattleMonForms[i] = 0;
+ memset(gContestResources->field_18, 0, sizeof(*gContestResources->field_18));
+ sub_80DE9DC(gContestResources->field_0->unk19215);
+ spriteId = sub_80DB174(
+ gContestMons[gContestResources->field_0->unk19215].species,
+ gContestMons[gContestResources->field_0->unk19215].otId,
+ gContestMons[gContestResources->field_0->unk19215].personality,
+ gContestResources->field_0->unk19215);
+ gSprites[spriteId].pos2.x = 120;
+ gSprites[spriteId].callback = sub_80DA134;
+ gTasks[taskId].data[2] = spriteId;
+ gBattlerSpriteIds[gBattlerAttacker] = spriteId;
+ sub_80DCBE8(sub_80DC9EC(gContestResources->field_0->unk19215), FALSE);
+ gTasks[taskId].data[0] = 4;
+ return;
+ case 4:
+ spriteId = gTasks[taskId].data[2];
+ if (gSprites[spriteId].callback == SpriteCallbackDummy)
+ {
+ if (!gContestResources->field_14[r6].unk2_1)
+ gTasks[taskId].data[0] = 5;
+ }
+ return;
+ case 5:
+ if (gContestResources->field_4[r6].nervous)
+ {
+ gTasks[taskId].data[0] = 33;
+ }
+ else
+ {
+ sub_80DB89C();
+ StringCopy(gStringVar1, gContestMons[r6].nickname);
+ if (gContestResources->field_4[r6].currMove < MOVES_COUNT)
+ StringCopy(gStringVar2, gMoveNames[gContestResources->field_4[r6].currMove]);
+ else
+ StringCopy(gStringVar2, gUnknown_08587F1C[gContestResources->field_4[r6].moveCategory]);
+ StringExpandPlaceholders(gStringVar4, gText_0827D55A);
+ Contest_StartTextPrinter(gStringVar4, 1);
+ gTasks[taskId].data[0] = 6;
+ }
+ return;
+ case 6:
+ if (!Contest_RunTextPrinters())
+ {
+ gContestResources->field_0->unk1925E = 0;
+ gTasks[taskId].data[0] = 7;
+ }
+ return;
+ case 7:
+ {
+ u16 move = sub_80DE834(gContestResources->field_4[gContestResources->field_0->unk19215].currMove);
+
+ sub_80DE864(gContestResources->field_0->unk19215);
+ sub_80DE9DC(gContestResources->field_0->unk19215);
+ sub_80DEAA8(move);
+ DoMoveAnim(move);
+ gTasks[taskId].data[0] = 8;
+ }
+ return;
+ case 8:
+ gAnimScriptCallback();
+ if (!gAnimScriptActive)
+ {
+ sub_80DE9B0(r6);
+ if (gContestResources->field_0->unk1925E != 0)
+ {
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[0] = 9;
+ }
+ else
+ {
+ if (!gContestResources->field_4[r6].hasJudgesAttention)
+ sub_80DC674(r6);
+ sub_80DE12C();
+ gTasks[taskId].data[0] = 23;
+ }
+ }
+ return;
+ case 9:
+ if (gTasks[taskId].data[10]++ > 30)
+ {
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[0] = 7;
+ }
+ return;
+ case 23:
+ gTasks[taskId].data[1] = 0;
+ if (gContestResources->field_4[r6].effectStringId != CONTEST_STRING_NONE)
+ {
+ sub_80DD45C(r6, gContestResources->field_4[r6].effectStringId);
+ gContestResources->field_4[r6].effectStringId = CONTEST_STRING_NONE;
+ gTasks[taskId].data[0] = 24;
+ }
+ else
+ {
+ if (gContestResources->field_4[r6].effectStringId2 != CONTEST_STRING_NONE)
+ {
+ for (i = 0; i < 4; i++)
+ {
+ if (i != r6 && gContestResources->field_4[i].effectStringId != CONTEST_STRING_NONE)
+ break;
+ }
+ if (i == 4)
+ {
+ sub_80DD45C(r6, gContestResources->field_4[r6].effectStringId2);
+ gContestResources->field_4[r6].effectStringId2 = CONTEST_STRING_NONE;
+ gTasks[taskId].data[0] = 24;
+ }
+ else
+ {
+ gTasks[taskId].data[0] = 48;
+ }
+ }
+ else
+ {
+ gTasks[taskId].data[0] = 48;
+ }
+ }
+ return;
+ case 24:
+ if (!Contest_RunTextPrinters())
+ gTasks[taskId].data[0] = 23;
+ return;
+ case 48:
+ if (gContestResources->field_4[r6].turnOrderModAction == 1)
+ {
+ sub_80DD720(5);
+ }
+ else if (gContestResources->field_4[r6].turnOrderModAction == 2)
+ {
+ sub_80DD720(6);
+ }
+ else if (gContestResources->field_4[r6].turnOrderModAction == 3)
+ {
+ sub_80DD720(7);
+ }
+ else
+ {
+ gTasks[taskId].data[0] = 47;
+ return;
+ }
+ gTasks[taskId].data[0] = 49;
+ return;
+ case 49:
+ if (!gContestResources->field_0->unk1920A_4)
+ gTasks[taskId].data[0] = 47;
+ return;
+ case 47:
+ sub_80DE008(TRUE);
+ gTasks[taskId].data[0] = 12;
+ return;
+ case 12:
+ sub_80DC028(0, gContestResources->field_4[r6].appeal2, r6);
+ gTasks[taskId].data[0] = 13;
+ return;
+ case 13:
+ if (!gContestResources->field_14[gContestResources->field_0->unk19215].unk2_2)
+ gTasks[taskId].data[0] = 35;
+ return;
+ case 35:
+ if (gContestResources->field_4[r6].conditionMod == 1)
+ sub_80DD720(8);
+ gTasks[taskId].data[0] = 36;
+ return;
+ case 36:
+ if (!gContestResources->field_0->unk1920A_4)
+ gTasks[taskId].data[0] = 37;
+ return;
+ case 37:
+ if (sub_80DB5B8(r6, 1))
+ {
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[0] = 38;
+ }
+ else
+ {
+ gTasks[taskId].data[0] = 50;
+ }
+ return;
+ case 38:
+ if (++gTasks[taskId].data[10] > 20)
+ {
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[0] = 50;
+ }
+ return;
+ case 50:
+ if (sub_80DB798(r6))
+ PlaySE(SE_C_PASI);
+ gTasks[taskId].data[0] = 25;
+ return;
+ case 25:
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].data[0] = 26;
+ return;
+ case 26:
+ {
+ s32 r2 = 0;
+
+ r3 = 0;
+ for (i = gTasks[taskId].data[1]; i < 4; i++)
+ {
+ r3 = 0;
+ for (r2 = 0; r2 < 4; r2++)
+ {
+ if (r2 != r6 && gUnknown_02039F26[r2] == i
+ && gContestResources->field_4[r2].effectStringId != CONTEST_STRING_NONE)
+ {
+ r3 = 1;
+ break;
+ }
+ }
+ if (r3 != 0)
+ break;
+ }
+ if (r3)
+ {
+ gTasks[taskId].data[1] = gUnknown_02039F26[r2];
+ sub_80DD45C(r2, gContestResources->field_4[r2].effectStringId);
+ gContestResources->field_4[r2].effectStringId = CONTEST_STRING_NONE;
+ gTasks[taskId].data[0] = 27;
+ }
+ else
+ {
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[0] = 51;
+ sub_80DB884();
+ }
+ }
+ return;
+ case 27:
+ if (!Contest_RunTextPrinters())
+ gTasks[taskId].data[0] = 28;
+ return;
+ case 28:
+ for (i = 0; gTasks[taskId].data[1] != gUnknown_02039F26[i]; i++)
+ ;
+ sub_80DC028(gContestResources->field_4[i].appeal2 + gContestResources->field_4[i].jam, -gContestResources->field_4[i].jam, i);
+ gTasks[taskId].data[0] = 29;
+ return;
+ case 29:
+ for (i = 0; gTasks[taskId].data[1] != gUnknown_02039F26[i]; i++)
+ ;
+ if (!gContestResources->field_14[i].unk2_2)
+ gTasks[taskId].data[0] = 39;
+ return;
+ case 39:
+ for (i = 0; gTasks[taskId].data[1] != gUnknown_02039F26[i]; i++)
+ ;
+ if (sub_80DB5B8(i, 1))
+ {
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[0] = 40;
+ }
+ else
+ {
+ gTasks[taskId].data[0] = 30;
+ }
+ return;
+ case 40:
+ if (++gTasks[taskId].data[10] > 20)
+ {
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[0] = 30;
+ }
+ return;
+ case 30:
+ for (i = 0; i < 4; i++)
+ {
+ if (gUnknown_02039F26[i] == gTasks[taskId].data[1])
+ break;
+ }
+ if (sub_80DB798(i))
+ PlaySE(SE_C_PASI);
+ else
+ PlaySE(SE_C_SYU);
+ if (gContestResources->field_4[i].judgesAttentionWasRemoved)
+ {
+ sub_80DC674(i);
+ gContestResources->field_4[i].judgesAttentionWasRemoved = 0;
+ }
+ gTasks[taskId].data[1]++;
+ gTasks[taskId].data[0] = 26;
+ return;
+ case 51:
+ if (gTasks[taskId].data[10]++ > 9)
+ {
+ gTasks[taskId].data[10] = 0;
+ if (gContestResources->field_4[r6].numTurnsSkipped != 0
+ || gContestResources->field_4[r6].turnSkipped)
+ {
+ sub_80DB89C();
+ StringCopy(gStringVar1, gContestMons[r6].nickname);
+ StringExpandPlaceholders(gStringVar4, gText_0827E793);
+ Contest_StartTextPrinter(gStringVar4, 1);
+ }
+ gTasks[taskId].data[0] = 52;
+ }
+ return;
+ case 52:
+ if (!Contest_RunTextPrinters())
+ {
+ if (!gContestResources->field_4[r6].unk15_6)
+ gTasks[taskId].data[0] = 17;
+ else
+ gTasks[taskId].data[0] = 14;
+ }
+ return;
+ case 14:
+ r3 = gContestResources->field_4[r6].unk16;
+ if (gContestResources->field_4[r6].unk16 != 0)
+ {
+ sub_80DB89C();
+ if (r3 == 1)
+ Contest_StartTextPrinter(gText_0827E32E, 1);
+ else if (r3 == 2)
+ Contest_StartTextPrinter(gText_0827E35B, 1);
+ else
+ Contest_StartTextPrinter(gText_0827E38D, 1);
+ sub_80DD720(3);
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[0] = 45;
+ }
+ else
+ {
+ sub_80DB89C();
+ StringCopy(gStringVar1, gContestMons[r6].nickname);
+ StringExpandPlaceholders(gStringVar4, gText_0827E2FE);
+ Contest_StartTextPrinter(gStringVar4, 1);
+ sub_80DD720(2);
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[0] = 45;
+ }
+ return;
+ case 45:
+ if (!gContestResources->field_0->unk1920A_4)
+ {
+ sub_80DC9B4(gContestResources->field_0->unk19215);
+ gTasks[taskId].data[0] = 15;
+ }
+ return;
+ case 15:
+ if (!Contest_RunTextPrinters())
+ {
+ if (++gTasks[taskId].data[10] > 50)
+ {
+ if (!gContestResources->field_4[r6].hasJudgesAttention)
+ {
+ sub_80DC028(
+ gContestResources->field_4[r6].appeal2,
+ gContestResources->field_4[r6].unk17,
+ r6);
+ gContestResources->field_4[r6].appeal2 += gContestResources->field_4[r6].unk17;
+ }
+ gTasks[taskId].data[0] = 16;
+ }
+ }
+ return;
+ case 16:
+ if (!gContestResources->field_14[r6].unk2_2)
+ {
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[0] = 17;
+ }
+ return;
+ case 17:
+ if (gContestResources->field_4[r6].disappointedRepeat)
+ {
+ sub_80DB89C();
+ StringCopy(gStringVar1, gContestMons[r6].nickname);
+ StringExpandPlaceholders(gStringVar4, gText_0827E6E3);
+ Contest_StartTextPrinter(gStringVar4, 1);
+ gTasks[taskId].data[10] = 0;
+ sub_80DD720(0);
+ gTasks[taskId].data[0] = 46;
+ }
+ else
+ {
+ gTasks[taskId].data[0] = 41;
+ }
+ return;
+ case 46:
+ if (!gContestResources->field_0->unk1920A_4)
+ gTasks[taskId].data[0] = 19;
+ return;
+ case 19:
+ if (!Contest_RunTextPrinters())
+ {
+ sub_80DC028(gContestResources->field_4[r6].appeal2, -gContestResources->field_4[r6].unk18, r6);
+ gContestResources->field_4[r6].appeal2 -= gContestResources->field_4[r6].unk18;
+ gTasks[taskId].data[0] = 18;
+ }
+ return;
+ case 18:
+ sub_80DCD48();
+ if (!gContestResources->field_14[r6].unk2_2)
+ {
+ gTasks[taskId].data[10] = 0;
+ sub_80DB89C();
+ gTasks[taskId].data[0] = 41;
+ }
+ return;
+ case 41:
+ if (gContestResources->field_10->excitementFrozen && r6 != gContestResources->field_10->excitementFreezer)
+ {
+ gTasks[taskId].data[0] = 57;
+ }
+ else
+ {
+ r3 = gContestResources->field_10->bits_0;
+ if (gContestResources->field_4[r6].overrideCategoryExcitementMod)
+ {
+ r3 = 1;
+ StringCopy(gStringVar3, gMoveNames[gContestResources->field_4[r6].currMove]);
+ }
+ else
+ {
+ StringCopy(gStringVar3, gUnknown_08587F08[gContestMoves[gContestResources->field_4[r6].currMove].contestCategory]);
+ }
+ if (r3 > 0)
+ {
+ if (gContestResources->field_4[r6].disappointedRepeat)
+ r3 = 0;
+ }
+ sub_80DB89C();
+ StringCopy(gStringVar1, gContestMons[r6].nickname);
+ gContestResources->field_0->applauseLevel += r3;
+ if (gContestResources->field_0->applauseLevel < 0)
+ gContestResources->field_0->applauseLevel = 0;
+ if (r3 == 0)
+ {
+ gTasks[taskId].data[0] = 55;
+ }
+ else
+ {
+ if (r3 < 0)
+ StringExpandPlaceholders(gStringVar4, gText_0827E73C);
+ else if (r3 > 0 && gContestResources->field_0->applauseLevel <= 4)
+ StringExpandPlaceholders(gStringVar4, gText_0827E717);
+ else
+ StringExpandPlaceholders(gStringVar4, gText_0827E76A);
+ Contest_StartTextPrinter(gStringVar4, 1);
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[11] = 0;
+ if (r3 < 0)
+ gTasks[taskId].data[0] = 53;
+ else
+ gTasks[taskId].data[0] = 54;
+ }
+ }
+ return;
+ case 53:
+ switch (gTasks[taskId].data[10])
+ {
+ case 0:
+ sub_80DDED0(-1, 1);
+ PlayFanfare(MUS_ME_ZANNEN);
+ gTasks[taskId].data[10]++;
+ break;
+ case 1:
+ if (!gContestResources->field_0->unk1920B_0 && !Contest_RunTextPrinters())
+ {
+ sub_80DDCDC(-1);
+ gTasks[taskId].data[10]++;
+ }
+ break;
+ case 2:
+ if (!gContestResources->field_0->unk1920A_5)
+ {
+ if (gTasks[taskId].data[11]++ > 29)
+ {
+ gTasks[taskId].data[11] = 0;
+ sub_80DDED0(-1, -1);
+ gTasks[taskId].data[10]++;
+ }
+ }
+ break;
+ case 3:
+ if (!gPaletteFade.active)
+ {
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[11] = 0;
+ gTasks[taskId].data[0] = 43;
+ }
+ break;
+ }
+ return;
+ case 54:
+ switch (gTasks[taskId].data[10])
+ {
+ case 0:
+ if (!Contest_RunTextPrinters())
+ {
+ sub_80DDED0(1, 1);
+ gTasks[taskId].data[10]++;
+ }
+ break;
+ case 1:
+ if (!gContestResources->field_0->unk1920B_0)
+ {
+ sub_80DDE0C();
+ PlaySE(SE_W227B);
+ sub_80DDCDC(1);
+ gTasks[taskId].data[10]++;
+ }
+ break;
+ case 2:
+ if (!gContestResources->field_0->unk1920A_5)
+ {
+ if (gTasks[taskId].data[11]++ > 29)
+ {
+ gTasks[taskId].data[11] = 0;
+ sub_80DC028(gContestResources->field_4[r6].appeal2, gContestResources->field_10->unk2, r6);
+ gContestResources->field_4[r6].appeal2 += gContestResources->field_10->unk2;
+ gTasks[taskId].data[10]++;
+ }
+ }
+ break;
+ case 3:
+ if (!gContestResources->field_14[r6].unk2_2)
+ {
+ if (!gContestResources->field_0->unk1920A_7)
+ {
+ sub_80DDED0(1, -1);
+ gTasks[taskId].data[10]++;
+ }
+ }
+ break;
+ case 4:
+ if (!gPaletteFade.active)
+ {
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[11] = 0;
+ gTasks[taskId].data[0] = 43;
+ }
+ break;
+ }
+ return;
+ case 43:
+ if (!gContestResources->field_14[r6].unk2_2)
+ {
+ sub_80DB89C();
+ gTasks[taskId].data[0] = 55;
+ }
+ return;
+ case 57:
+ sub_80DB89C();
+ StringCopy(gStringVar3, gContestMons[gContestResources->field_10->excitementFreezer].nickname);
+ StringCopy(gStringVar1, gContestMons[r6].nickname);
+ StringCopy(gStringVar2, gMoveNames[gContestResources->field_4[r6].currMove]);
+ StringExpandPlaceholders(gStringVar4, gText_0827E7EA);
+ Contest_StartTextPrinter(gStringVar4, 1);
+ gTasks[taskId].data[0] = 58;
+ return;
+ case 58:
+ if (!Contest_RunTextPrinters())
+ {
+ sub_80DB89C();
+ StringExpandPlaceholders(gStringVar4, gText_0827E817);
+ Contest_StartTextPrinter(gStringVar4, 1);
+ gTasks[taskId].data[0] = 59;
+ }
+ return;
+ case 59:
+ if (!Contest_RunTextPrinters())
+ {
+ sub_80DB89C();
+ gTasks[taskId].data[0] = 55;
+ }
+ return;
+ case 33:
+ if (gContestResources->field_4[r6].hasJudgesAttention)
+ gContestResources->field_4[r6].hasJudgesAttention = 0;
+ sub_80DC9B4(r6);
+ StringCopy(gStringVar1, gContestMons[r6].nickname);
+ StringCopy(gStringVar2, gMoveNames[gContestResources->field_4[r6].currMove]);
+ StringExpandPlaceholders(gStringVar4, gText_0827E58A);
+ Contest_StartTextPrinter(gStringVar4, 1);
+ gTasks[taskId].data[0] = 34;
+ return;
+ case 34:
+ if (!Contest_RunTextPrinters())
+ gTasks[taskId].data[0] = 55;
+ return;
+ case 55:
+ sub_80DDBE8();
+ gTasks[taskId].data[0] = 56;
+ return;
+ case 56:
+ if (!gContestResources->field_0->unk1920A_6)
+ {
+ if (gContestResources->field_0->applauseLevel > 4)
+ {
+ gContestResources->field_0->applauseLevel = 0;
+ sub_80DD940();
+ }
+ gTasks[taskId].data[0] = 10;
+ }
+ return;
+ case 10:
+ spriteId = gTasks[taskId].data[2];
+ gSprites[spriteId].callback = sub_80DA164;
+ gTasks[taskId].data[0] = 11;
+ return;
+ case 11:
+ spriteId = gTasks[taskId].data[2];
+ if (gSprites[spriteId].invisible)
+ {
+ FreeSpriteOamMatrix(&gSprites[spriteId]);
+ DestroySprite(&gSprites[spriteId]);
+ gTasks[taskId].data[0] = 20;
+ }
+ return;
+ case 20:
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[0] = 21;
+ return;
+ case 31:
+ sub_80DB89C();
+ StringCopy(gStringVar1, gContestMons[r6].nickname);
+ StringExpandPlaceholders(gStringVar4, gText_0827D56F);
+ Contest_StartTextPrinter(gStringVar4, 1);
+ gTasks[taskId].data[0] = 32;
+ return;
+ case 32:
+ if (!Contest_RunTextPrinters())
+ gTasks[taskId].data[0] = 21;
+ return;
+ case 21:
+ if (++gTasks[taskId].data[10] > 29)
+ {
+ gTasks[taskId].data[10] = 0;
+ gTasks[taskId].data[0] = 22;
+ }
+ return;
+ case 22:
+ if (++gContestResources->field_0->unk19214 == 4)
+ {
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].data[2] = 0;
+ gTasks[taskId].func = sub_80DA198;
+ }
+ else
+ {
+ gTasks[taskId].data[0] = 0;
+ }
+ return;
+ }
+}
+
+void sub_80DA110(u8 taskId)
+{
+ sContest.unk1920B_2 = 0;
+ DestroyTask(taskId);
+}
+
+void sub_80DA134(struct Sprite *sprite)
+{
+ if (sprite->pos2.x != 0)
+ {
+ sprite->pos2.x -= 2;
+ }
+ else
+ {
+ if (++sprite->data[0] == 31)
+ {
+ sprite->data[0] = 0;
+ sprite->callback = SpriteCallbackDummy;
+ }
+ }
+}
+
+void sub_80DA164(struct Sprite *sprite)
+{
+ sprite->pos2.x -= 6;
+ if (sprite->pos1.x + sprite->pos2.x < -32)
+ {
+ sprite->callback = SpriteCallbackDummy;
+ sprite->invisible = TRUE;
+ }
+}
+
+void sub_80DA198(u8 taskId)
+{
+ switch (gTasks[taskId].data[0])
+ {
+ case 0:
+ if (gIsLinkContest & 1)
+ {
+ u8 taskId2;
+
+ sContest.unk1920B_2 = 1;
+ if (sub_80DA8A4())
+ {
+ sub_80DB944();
+ sub_80DBA18();
+ }
+ taskId2 = CreateTask(sub_80FCC88, 0);
+ SetTaskFuncWithFollowupFunc(taskId2, sub_80FCC88, sub_80DA110);
+ sub_80DBF68();
+ gTasks[taskId].data[0] = 1;
+ }
+ else
+ {
+ sub_80DB944();
+ sub_80DBA18();
+ gTasks[taskId].data[0] = 2;
+ }
+ break;
+ case 1:
+ if (!sContest.unk1920B_2)
+ gTasks[taskId].data[0] = 2;
+ break;
+ case 2:
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].func = sub_80DA25C;
+ break;
+ }
+}
+
+void sub_80DA25C(u8 taskId)
+{
+ sub_80DE008(FALSE);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].func = sub_80DA28C;
+}
+
+void sub_80DA28C(u8 taskId)
+{
+ switch (gTasks[taskId].data[0])
+ {
+ case 0:
+ if (++gTasks[taskId].data[1] > 20)
+ {
+ sub_80DE69C(2);
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].data[0]++;
+ }
+ break;
+ case 1:
+ if (!sContest.unk1920B_1)
+ {
+ if (++gTasks[taskId].data[1] > 20)
+ {
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].data[0]++;
+ }
+ }
+ break;
+ case 2:
+ sub_80DC3AC();
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].func = sub_80DA31C;
+ break;
+ }
+}
+
+void sub_80DA31C(u8 taskId)
+{
+ if (sub_80DC3C4())
+ gTasks[taskId].func = sub_80DA348;
+}
+
+void sub_80DA348(u8 taskId)
+{
+ DmaCopy32Defvars(3, shared18000.unk18204, gPlttBufferUnfaded, 0x400);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = 2;
+ gTasks[taskId].func = sub_80DA38C;
+}
+
+void sub_80DA38C(u8 taskId)
+{
+ if (++gTasks[taskId].data[0] > 2)
+ {
+ gTasks[taskId].data[0] = 0;
+ if (--gTasks[taskId].data[1] == 0)
+ gTasks[taskId].func = sub_80DA3CC;
+ }
+}
+
+void sub_80DA3CC(u8 taskId)
+{
+ if (gTasks[taskId].data[0] == 0)
+ {
+ u8 r4 = sContestantStatus[gContestPlayerMonIndex].attentionLevel;
+
+ sub_80DB89C();
+ StringCopy(gStringVar1, gContestMons[gContestPlayerMonIndex].nickname);
+ StringExpandPlaceholders(gStringVar4, gUnknown_08587D90[r4]);
+ Contest_StartTextPrinter(gStringVar4, 1);
+ gTasks[taskId].data[0]++;
+ }
+ else
+ {
+ if (!Contest_RunTextPrinters())
+ {
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].func = sub_80DA464;
+ sub_80DCD48();
+ }
+ }
+}
+
+void sub_80DA464(u8 taskId)
+{
+ if (gTasks[taskId].data[0]++ > 29)
+ {
+ gTasks[taskId].data[0] = 0;
+ sub_80DC3AC();
+ gTasks[taskId].func = sub_80DA49C;
+ }
+}
+
+void sub_80DA49C(u8 taskId)
+{
+ if (sub_80DC3C4())
+ {
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].func = sub_80DA4CC;
+ }
+}
+
+void sub_80DA4CC(u8 taskId)
+{
+ sub_80DE224();
+ gTasks[taskId].func = sub_80DE424;
+}
+
+void sub_80DA4F4(u8 taskId)
+{
+ sub_80DE350();
+ gTasks[taskId].func = sub_80DA51C;
+}
+
+void sub_80DA51C(u8 taskId)
+{
+ vu16 sp0 = GetGpuReg(REG_OFFSET_BG0CNT);
+ vu16 sp2 = GetGpuReg(REG_OFFSET_BG2CNT);
+ ((vBgCnt *)&sp0)->priority = 0;
+ ((vBgCnt *)&sp2)->priority = 0;
+ SetGpuReg(REG_OFFSET_BG0CNT, sp0);
+ SetGpuReg(REG_OFFSET_BG2CNT, sp2);
+ sContest.turnNumber++;
+ if (sContest.turnNumber == 5)
+ {
+ gTasks[taskId].func = sub_80DA5E8;
+ }
+ else
+ {
+ sub_80DDB0C();
+ gTasks[taskId].func = sub_80DA5B4;
+ }
+}
+
+void sub_80DA5B4(u8 taskId)
+{
+ if (!sContest.unk1920A_6)
+ gTasks[taskId].func = sub_80D833C;
+}
+
+void sub_80DA5E8(u8 taskId)
+{
+ s32 i;
+
+ gBattle_BG0_Y = 0;
+ gBattle_BG2_Y = 0;
+ for (i = 0; i < 4; i++)
+ gUnknown_02039F10[i] = sContestantStatus[i].unk4;
+ sub_80DBD18();
+ sub_80DB89C();
+ if (!(gIsLinkContest & 1))
+ BravoTrainerPokemonProfile_BeforeInterview1(sContestantStatus[gContestPlayerMonIndex].prevMove);
+ else
+ {
+ sub_80DF250();
+ sub_80DF4F8();
+ sub_80DF750();
+ }
+ gContestRngValue = gRngValue;
+ StringExpandPlaceholders(gStringVar4, gText_0827D597);
+ Contest_StartTextPrinter(gStringVar4, 1);
+ gTasks[taskId].data[2] = 0;
+ gTasks[taskId].func = sub_80DA6B4;
+}
+
+void sub_80DA6B4(u8 taskId)
+{
+ if (!Contest_RunTextPrinters())
+ {
+ sub_80DE224();
+ gBattle_BG1_X = 0;
+ gBattle_BG1_Y = 160;
+ PlaySE12WithPanning(SE_C_MAKU_D, 0);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].func = sub_80DA700;
+ }
+}
+
+void sub_80DA700(u8 taskId)
+{
+ gBattle_BG1_Y -= 7;
+ if (gBattle_BG1_Y < 0)
+ gBattle_BG1_Y = 0;
+ if (*(u16 *)&gBattle_BG1_Y == 0) // Why cast?
+ {
+ gTasks[taskId].func = sub_80DA740;
+ gTasks[taskId].data[0] = 0;
+ }
+}
+
+void sub_80DA740(u8 taskId)
+{
+ if (gTasks[taskId].data[0]++ >= 50)
+ {
+ gTasks[taskId].data[0] = 0;
+ if (gIsLinkContest & 1)
+ {
+ gTasks[taskId].func = sub_80DA7A0;
+ }
+ else
+ {
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0);
+ gTasks[taskId].func = sub_80DA830;
+ }
+ }
+}
+
+void sub_80DA7A0(u8 taskId)
+{
+ u8 taskId2 = CreateTask(sub_80FCACC, 0);
+
+ SetTaskFuncWithFollowupFunc(taskId2, sub_80FCACC, sub_80DA7EC);
+ gTasks[taskId].func = TaskDummy1;
+ sub_80DBF68();
+ sub_80DC490(FALSE);
+}
+
+void sub_80DA7EC(u8 taskId)
+{
+ DestroyTask(taskId);
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0);
+ gTasks[sContest.mainTaskId].func = sub_80DA830;
+}
+
+void sub_80DA830(u8 taskId)
+{
+ if (!gPaletteFade.active)
+ {
+ DestroyTask(taskId);
+ gFieldCallback = sub_80DA874;
+ FreeAllWindowBuffers();
+ sub_80D7A5C();
+ FreeMonSpritesGfx();
+ SetMainCallback2(CB2_ReturnToField);
+ }
+}
+
+void sub_80DA874(void)
+{
+ ScriptContext2_Disable();
+ EnableBothScriptContexts();
+}
+
+void sub_80DA884(void)
+{
+ if (!(gIsLinkContest & 1))
+ gContestPlayerMonIndex = 3;
+}
+
+bool8 sub_80DA8A4(void)
+{
+ if (gContestPlayerMonIndex == gUnknown_02039F2B)
+ return TRUE;
+ return FALSE;
+}
+
+
+void sub_80DA8C8(u8 partyIndex)
+{
+ u8 name[20];
+ u16 heldItem;
+ s16 cool;
+ s16 beauty;
+ s16 cute;
+ s16 smart;
+ s16 tough;
+
+ StringCopy(name, gSaveBlock2Ptr->playerName);
+ if (gIsLinkContest & 1)
+ {
+ sub_80DF9D4(name);
+ }
+ memcpy(gContestMons[gContestPlayerMonIndex].trainerName, name, 8);
+ if (gSaveBlock2Ptr->playerGender == MALE)
+ gContestMons[gContestPlayerMonIndex].trainerGfxId = EVENT_OBJ_GFX_LINK_BRENDAN;
+ else
+ gContestMons[gContestPlayerMonIndex].trainerGfxId = EVENT_OBJ_GFX_LINK_MAY;
+ gContestMons[gContestPlayerMonIndex].flags = 0;
+ gContestMons[gContestPlayerMonIndex].unk2C[0] = 0;
+ gContestMons[gContestPlayerMonIndex].species = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPECIES);
+ GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, name);
+ StringGetEnd10(name);
+ if (gIsLinkContest & 1)
+ {
+ sub_80DF9E0(name, GetMonData(&gPlayerParty[partyIndex], MON_DATA_LANGUAGE));
+ }
+ memcpy(gContestMons[gContestPlayerMonIndex].nickname, name, POKEMON_NAME_LENGTH + 1);
+ StringCopy(gContestMons[gContestPlayerMonIndex].nickname, name);
+ gContestMons[gContestPlayerMonIndex].cool = GetMonData(&gPlayerParty[partyIndex], MON_DATA_COOL);
+ gContestMons[gContestPlayerMonIndex].beauty = GetMonData(&gPlayerParty[partyIndex], MON_DATA_BEAUTY);
+ gContestMons[gContestPlayerMonIndex].cute = GetMonData(&gPlayerParty[partyIndex], MON_DATA_CUTE);
+ gContestMons[gContestPlayerMonIndex].smart = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SMART);
+ gContestMons[gContestPlayerMonIndex].tough = GetMonData(&gPlayerParty[partyIndex], MON_DATA_TOUGH);
+ gContestMons[gContestPlayerMonIndex].sheen = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SHEEN);
+ gContestMons[gContestPlayerMonIndex].moves[0] = GetMonData(&gPlayerParty[partyIndex], MON_DATA_MOVE1);
+ gContestMons[gContestPlayerMonIndex].moves[1] = GetMonData(&gPlayerParty[partyIndex], MON_DATA_MOVE2);
+ gContestMons[gContestPlayerMonIndex].moves[2] = GetMonData(&gPlayerParty[partyIndex], MON_DATA_MOVE3);
+ gContestMons[gContestPlayerMonIndex].moves[3] = GetMonData(&gPlayerParty[partyIndex], MON_DATA_MOVE4);
+ gContestMons[gContestPlayerMonIndex].personality = GetMonData(&gPlayerParty[partyIndex], MON_DATA_PERSONALITY);
+ gContestMons[gContestPlayerMonIndex].otId = GetMonData(&gPlayerParty[partyIndex], MON_DATA_OT_ID);
+
+ heldItem = GetMonData(&gPlayerParty[partyIndex], MON_DATA_HELD_ITEM);
+ cool = gContestMons[gContestPlayerMonIndex].cool;
+ beauty = gContestMons[gContestPlayerMonIndex].beauty;
+ cute = gContestMons[gContestPlayerMonIndex].cute;
+ smart = gContestMons[gContestPlayerMonIndex].smart;
+ tough = gContestMons[gContestPlayerMonIndex].tough;
+ if (heldItem == ITEM_RED_SCARF)
+ cool += 20;
+ else if (heldItem == ITEM_BLUE_SCARF)
+ beauty += 20;
+ else if (heldItem == ITEM_PINK_SCARF)
+ cute += 20;
+ else if (heldItem == ITEM_GREEN_SCARF)
+ smart += 20;
+ else if (heldItem == ITEM_YELLOW_SCARF)
+ tough += 20;
+ if (cool > 255)
+ cool = 255;
+ if (beauty > 255)
+ beauty = 255;
+ if (cute > 255)
+ cute = 255;
+ if (smart > 255)
+ smart = 255;
+ if (tough > 255)
+ tough = 255;
+ gContestMons[gContestPlayerMonIndex].cool = cool;
+ gContestMons[gContestPlayerMonIndex].beauty = beauty;
+ gContestMons[gContestPlayerMonIndex].cute = cute;
+ gContestMons[gContestPlayerMonIndex].smart = smart;
+ gContestMons[gContestPlayerMonIndex].tough = tough;
+}
+
+void sub_80DAB8C(u8 contestType, u8 rank)
+{
+ s32 i;
+ u8 opponentsCount = 0;
+ u8 opponents[100];
+ bool8 r7 = FALSE;
+ const u8 * r3;
+
+ sub_80DA884();
+
+ if (FlagGet(FLAG_SYS_GAME_CLEAR) && !(gIsLinkContest & 1))
+ r7 = TRUE;
+
+ // Find all suitable opponents
+ r3 = gUnknown_085898A4;
+ for (i = 0; i < ARRAY_COUNT(gContestOpponents); i++)
+ {
+ if (rank == gContestOpponents[i].whichRank)
+ {
+ if (r7 == TRUE)
+ {
+ if (r3[i] == 1)
+ continue;
+ }
+ else
+ {
+ if (r3[i] == 2)
+ continue;
+ }
+ if (contestType == CONTEST_CATEGORY_COOL && gContestOpponents[i].aiPool_Cool)
+ opponents[opponentsCount++] = i;
+ else if (contestType == CONTEST_CATEGORY_BEAUTY && gContestOpponents[i].aiPool_Beauty)
+ opponents[opponentsCount++] = i;
+ else if (contestType == CONTEST_CATEGORY_CUTE && gContestOpponents[i].aiPool_Cute)
+ opponents[opponentsCount++] = i;
+ else if (contestType == CONTEST_CATEGORY_SMART && gContestOpponents[i].aiPool_Smart)
+ opponents[opponentsCount++] = i;
+ else if (contestType == CONTEST_CATEGORY_TOUGH && gContestOpponents[i].aiPool_Tough)
+ opponents[opponentsCount++] = i;
+ }
+ }
+ opponents[opponentsCount] = 0xFF;
+
+ // Choose three random opponents from the list
+ for (i = 0; i < 3; i++)
+ {
+ u16 rnd = Random() % opponentsCount;
+ s32 j;
+
+ gContestMons[i] = gContestOpponents[opponents[rnd]];
+ for (j = rnd; opponents[j] != 0xFF; j++)
+ opponents[j] = opponents[j + 1];
+ opponentsCount--;
+ }
+
+ sub_80DA8C8(gUnknown_02039F24);
+}
+
+#ifdef NONMATCHING
+void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame)
+{
+ s32 i;
+ u8 opponentsCount = 0;
+ u8 opponents[100];
+ const u8 * r6;
+
+ if (gUnknown_02039F30 == 4)
+ return;
+
+ r6 = gUnknown_085898A4;
+ for (i = 0; i < ARRAY_COUNT(gContestOpponents); i++)
+ {
+ if (rank != gContestOpponents[i].whichRank)
+ continue;
+ if (isPostgame == TRUE)
+ {
+ if (r6[i] == 1)
+ continue;
+ }
+ else
+ {
+ if (r6[i] == 2)
+ continue;
+ }
+ if (contestType == CONTEST_CATEGORY_COOL && gContestOpponents[i].aiPool_Cool)
+ opponents[opponentsCount++] = i;
+ else if (contestType == CONTEST_CATEGORY_BEAUTY && gContestOpponents[i].aiPool_Beauty)
+ opponents[opponentsCount++] = i;
+ else if (contestType == CONTEST_CATEGORY_CUTE && gContestOpponents[i].aiPool_Cute)
+ opponents[opponentsCount++] = i;
+ else if (contestType == CONTEST_CATEGORY_SMART && gContestOpponents[i].aiPool_Smart)
+ opponents[opponentsCount++] = i;
+ else if (contestType == CONTEST_CATEGORY_TOUGH && gContestOpponents[i].aiPool_Tough)
+ opponents[opponentsCount++] = i;
+ }
+ opponents[opponentsCount] = 0xFF;
+ for (i = 0; i < 4 - gUnknown_02039F30; i++)
+ {
+ u16 rnd = sub_80F903C() % opponentsCount;
+ s32 j;
+
+ gContestMons[gUnknown_02039F30 + i] = gContestOpponents[opponents[rnd]];
+ sub_80DF9D4(gContestMons[gUnknown_02039F30 + i].trainerName);
+ sub_80DF9E0(gContestMons[gUnknown_02039F30 + i].nickname, GAME_LANGUAGE);
+ for (j = rnd; opponents[j] != 0xFF; j++)
+ opponents[j] = opponents[j + 1];
+ opponentsCount--;
+ }
+}
+#else
+NAKED void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame)
+{
+ asm_unified("\tpush {r4-r7,lr}\n"
+ "\tmov r7, r9\n"
+ "\tmov r6, r8\n"
+ "\tpush {r6,r7}\n"
+ "\tsub sp, 0x64\n"
+ "\tmov r8, r2\n"
+ "\tlsls r0, 24\n"
+ "\tlsrs r4, r0, 24\n"
+ "\tlsls r1, 24\n"
+ "\tlsrs r2, r1, 24\n"
+ "\tmovs r7, 0\n"
+ "\tldr r0, =gUnknown_02039F30\n"
+ "\tldrb r1, [r0]\n"
+ "\tmov r9, r0\n"
+ "\tcmp r1, 0x4\n"
+ "\tbne _080DACDE\n"
+ "\tb _080DADF6\n"
+ "_080DACDE:\n"
+ "\tmovs r5, 0\n"
+ "\tldr r3, =gContestOpponents\n"
+ "\tldr r6, =gUnknown_085898A4\n"
+ "_080DACE4:\n"
+ "\tldrb r0, [r3, 0x1C]\n"
+ "\tlsls r0, 30\n"
+ "\tlsrs r0, 30\n"
+ "\tcmp r2, r0\n"
+ "\tbne _080DAD56\n"
+ "\tmov r0, r8\n"
+ "\tcmp r0, 0x1\n"
+ "\tbne _080DAD08\n"
+ "\tldrb r0, [r6]\n"
+ "\tcmp r0, 0x1\n"
+ "\tbeq _080DAD56\n"
+ "\tb _080DAD0E\n"
+ "\t.pool\n"
+ "_080DAD08:\n"
+ "\tldrb r0, [r6]\n"
+ "\tcmp r0, 0x2\n"
+ "\tbeq _080DAD56\n"
+ "_080DAD0E:\n"
+ "\tcmp r4, 0\n"
+ "\tbne _080DAD1A\n"
+ "\tldrb r0, [r3, 0x1C]\n"
+ "\tlsls r0, 29\n"
+ "\tcmp r0, 0\n"
+ "\tblt _080DAD4A\n"
+ "_080DAD1A:\n"
+ "\tcmp r4, 0x1\n"
+ "\tbne _080DAD26\n"
+ "\tldrb r0, [r3, 0x1C]\n"
+ "\tlsls r0, 28\n"
+ "\tcmp r0, 0\n"
+ "\tblt _080DAD4A\n"
+ "_080DAD26:\n"
+ "\tcmp r4, 0x2\n"
+ "\tbne _080DAD32\n"
+ "\tldrb r0, [r3, 0x1C]\n"
+ "\tlsls r0, 27\n"
+ "\tcmp r0, 0\n"
+ "\tblt _080DAD4A\n"
+ "_080DAD32:\n"
+ "\tcmp r4, 0x3\n"
+ "\tbne _080DAD3E\n"
+ "\tldrb r0, [r3, 0x1C]\n"
+ "\tlsls r0, 26\n"
+ "\tcmp r0, 0\n"
+ "\tblt _080DAD4A\n"
+ "_080DAD3E:\n"
+ "\tcmp r4, 0x4\n"
+ "\tbne _080DAD56\n"
+ "\tldrb r0, [r3, 0x1C]\n"
+ "\tlsls r0, 25\n"
+ "\tcmp r0, 0\n"
+ "\tbge _080DAD56\n"
+ "_080DAD4A:\n"
+ "\tadds r0, r7, 0\n"
+ "\tadds r1, r0, 0x1\n"
+ "\tlsls r1, 24\n"
+ "\tlsrs r7, r1, 24\n"
+ "\tadd r0, sp\n"
+ "\tstrb r5, [r0]\n"
+ "_080DAD56:\n"
+ "\tadds r3, 0x40\n"
+ "\tadds r6, 0x1\n"
+ "\tadds r5, 0x1\n"
+ "\tcmp r5, 0x5F\n"
+ "\tbls _080DACE4\n"
+ "\tmov r3, sp\n"
+ "\tadds r1, r3, r7\n"
+ "\tmovs r0, 0xFF\n"
+ "\tstrb r0, [r1]\n"
+ "\tmovs r5, 0\n"
+ "\tmov r0, r9\n"
+ "\tldrb r1, [r0]\n"
+ "\tmovs r0, 0x4\n"
+ "\tsubs r0, r1\n"
+ "\tcmp r5, r0\n"
+ "\tbge _080DADF6\n"
+ "\tldr r3, =gContestMons\n"
+ "\tmov r8, r3\n"
+ "\tmov r6, r9\n"
+ "\tmovs r0, 0x2\n"
+ "\tadd r0, r8\n"
+ "\tmov r9, r0\n"
+ "_080DAD82:\n"
+ "\tbl sub_80F903C\n"
+ "\tlsls r0, 16\n"
+ "\tlsrs r0, 16\n"
+ "\tadds r1, r7, 0\n"
+ "\tbl __modsi3\n"
+ "\tadds r1, r0, 0\n"
+ "\tlsls r1, 16\n"
+ "\tlsrs r1, 16\n"
+ "\tldrb r0, [r6]\n"
+ "\tadds r0, r5\n"
+ "\tlsls r0, 6\n"
+ "\tadd r0, r8\n"
+ "\tldr r2, =gContestOpponents\n"
+ "\tmov r3, sp\n"
+ "\tadds r4, r3, r1\n"
+ "\tldrb r1, [r4]\n"
+ "\tlsls r1, 6\n"
+ "\tadds r1, r2\n"
+ "\tmovs r2, 0x40\n"
+ "\tbl memcpy\n"
+ "\tldrb r0, [r6]\n"
+ "\tadds r0, r5\n"
+ "\tlsls r0, 6\n"
+ "\tmov r1, r8\n"
+ "\tadds r1, 0xD\n"
+ "\tadds r0, r1\n"
+ "\tbl sub_80DF9D4\n"
+ "\tldrb r0, [r6]\n"
+ "\tadds r0, r5\n"
+ "\tlsls r0, 6\n"
+ "\tadd r0, r9\n"
+ "\tmovs r1, 0x2\n"
+ "\tbl sub_80DF9E0\n"
+ "\tldrb r0, [r4]\n"
+ "\tadds r3, r5, 0x1\n"
+ "\tsubs r1, r7, 0x1\n"
+ "\tcmp r0, 0xFF\n"
+ "\tbeq _080DADE6\n"
+ "\tadds r2, r4, 0\n"
+ "_080DADDA:\n"
+ "\tldrb r0, [r2, 0x1]\n"
+ "\tstrb r0, [r2]\n"
+ "\tadds r2, 0x1\n"
+ "\tldrb r0, [r2]\n"
+ "\tcmp r0, 0xFF\n"
+ "\tbne _080DADDA\n"
+ "_080DADE6:\n"
+ "\tlsls r0, r1, 24\n"
+ "\tlsrs r7, r0, 24\n"
+ "\tadds r5, r3, 0\n"
+ "\tldrb r1, [r6]\n"
+ "\tmovs r0, 0x4\n"
+ "\tsubs r0, r1\n"
+ "\tcmp r5, r0\n"
+ "\tblt _080DAD82\n"
+ "_080DADF6:\n"
+ "\tadd sp, 0x64\n"
+ "\tpop {r3,r4}\n"
+ "\tmov r8, r3\n"
+ "\tmov r9, r4\n"
+ "\tpop {r4-r7}\n"
+ "\tpop {r0}\n"
+ "\tbx r0\n"
+ "\t.pool");
+}
+#endif
+
+// GetContestAvailability?
+u8 sub_80DAE0C(struct Pokemon *pkmn)
+{
+ u8 ribbon;
+ u8 retVal;
+
+ if (GetMonData(pkmn, MON_DATA_IS_EGG))
+ return 3;
+ if (GetMonData(pkmn, MON_DATA_HP) == 0)
+ return 4;
+ switch (gSpecialVar_ContestCategory)
+ {
+ case CONTEST_CATEGORY_COOL:
+ ribbon = GetMonData(pkmn, MON_DATA_COOL_RIBBON);
+ break;
+ case CONTEST_CATEGORY_BEAUTY:
+ ribbon = GetMonData(pkmn, MON_DATA_BEAUTY_RIBBON);
+ break;
+ case CONTEST_CATEGORY_CUTE:
+ ribbon = GetMonData(pkmn, MON_DATA_CUTE_RIBBON);
+ break;
+ case CONTEST_CATEGORY_SMART:
+ ribbon = GetMonData(pkmn, MON_DATA_SMART_RIBBON);
+ break;
+ case CONTEST_CATEGORY_TOUGH:
+ ribbon = GetMonData(pkmn, MON_DATA_TOUGH_RIBBON);
+ break;
+ default:
+ return 0;
+ }
+
+ // Couldn't get this to match any other way.
+ // Returns 2, 1, or 0 respectively if ribbon's rank is above, equal, or below
+ // the current contest rank.
+ if (ribbon > gSpecialVar_ContestRank)
+ retVal = 2;
+ else if (ribbon >= gSpecialVar_ContestRank)
+ retVal = 1;
+ else
+ retVal = 0;
+ return retVal;
+}
+
+void sub_80DAEA4(void)
+{
+ s32 i;
+
+ for (i = 0; i < 4; i++)
+ {
+ FillWindowPixelBuffer(gUnknown_02039F26[i], 0);
+ sub_80DAF04(i);
+ sub_80DAF88(i);
+ }
+}
+
+u8 * sub_80DAED4(const u8 * src, u8 color)
+{
+ u8 * ptr = StringCopy(gDisplayedStringBattle, gText_ColorTransparent);
+ ptr[-1] = color;
+ ptr = StringCopy(ptr, src);
+
+ return ptr;
+}
+
+void sub_80DAF04(u8 a0)
+{
+ sub_80DAF1C(a0, a0 + 10);
+}
+
+void sub_80DAF1C(u8 a0, u8 a1)
+{
+ u8 buffer[32];
+ s32 offset;
+
+ StringCopy(buffer, gText_Slash);
+ StringAppend(buffer, gContestMons[a0].trainerName);
+ sub_80DAED4(buffer, a1);
+ offset = GetStringRightAlignXOffset(7, gDisplayedStringBattle, 0x60);
+ if (offset > 55)
+ offset = 55;
+ Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[a0], gDisplayedStringBattle, offset, 1, 7);
+}
+
+void sub_80DAF88(u8 a0)
+{
+ sub_80DAFA0(a0, a0 + 10);
+}
+
+void sub_80DAFA0(u8 a0, u8 a1)
+{
+ sub_80DAED4(gContestMons[a0].nickname, a1);
+ Contest_PrintTextToBg0WindowAt(gUnknown_02039F26[a0], gDisplayedStringBattle, 5, 1, 7);
+}
+
+u16 sub_80DAFE0(u8 who, u8 contestCategory)
+{
+ u8 statMain;
+ u8 statSub1;
+ u8 statSub2;
+
+ switch (contestCategory)
+ {
+ case CONTEST_CATEGORY_COOL:
+ statMain = gContestMons[who].cool;
+ statSub1 = gContestMons[who].tough;
+ statSub2 = gContestMons[who].beauty;
+ break;
+ case CONTEST_CATEGORY_BEAUTY:
+ statMain = gContestMons[who].beauty;
+ statSub1 = gContestMons[who].cool;
+ statSub2 = gContestMons[who].cute;
+ break;
+ case CONTEST_CATEGORY_CUTE:
+ statMain = gContestMons[who].cute;
+ statSub1 = gContestMons[who].beauty;
+ statSub2 = gContestMons[who].smart;
+ break;
+ case CONTEST_CATEGORY_SMART:
+ statMain = gContestMons[who].smart;
+ statSub1 = gContestMons[who].cute;
+ statSub2 = gContestMons[who].tough;
+ break;
+ case CONTEST_CATEGORY_TOUGH:
+ default:
+ statMain = gContestMons[who].tough;
+ statSub1 = gContestMons[who].smart;
+ statSub2 = gContestMons[who].cool;
+ break;
+ }
+ return statMain + (statSub1 + statSub2 + gContestMons[who].sheen) / 2;
+}
+
+void sub_80DB09C(u8 a0)
+{
+ s32 i;
+
+ for (i = 0; i < 4; i++)
+ gContestMonConditions[i] = sub_80DAFE0(i, a0);
+}
+
+u8 sub_80DB0C4(void)
+{
+ u8 spriteId;
+
+ LoadCompressedObjectPic(&gUnknown_08587C00);
+ LoadCompressedPalette(gContest2Pal, 0x110, 32);
+ spriteId = CreateSprite(&gSpriteTemplate_8587BE8, 112, 36, 30);
+ gSprites[spriteId].oam.paletteNum = 1;
+ gSprites[spriteId].callback = SpriteCallbackDummy;
+ return spriteId;
+}
+
+u8 sub_80DB120(void)
+{
+ u8 spriteId;
+
+ LoadCompressedObjectPic(&gUnknown_08587C08);
+ LoadCompressedObjectPalette(&gUnknown_08587C10);
+ spriteId = CreateSprite(&gSpriteTemplate_8587C18, 96, 10, 29);
+ gSprites[spriteId].invisible = TRUE;
+ gSprites[spriteId].data[0] = gSprites[spriteId].oam.tileNum;
+ return spriteId;
+}
+
+u8 sub_80DB174(u16 species, u32 otId, u32 personality, u32 index)
+{
+ u8 spriteId;
+ species = sub_80DE84C(species);
+
+ if (index == gContestPlayerMonIndex)
+ HandleLoadSpecialPokePic_2(gMonBackPicTable + species, gMonSpritesGfxPtr->sprites[0], species, personality);
+ else
+ HandleLoadSpecialPokePic_DontHandleDeoxys(gMonBackPicTable + species, gMonSpritesGfxPtr->sprites[0], species, personality);
+
+ LoadCompressedPalette(GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality), 0x120, 0x20);
+ SetMultiuseSpriteTemplateToPokemon(species, 0);
+
+ spriteId = CreateSprite(&gMultiuseSpriteTemplate, 0x70, sub_80A600C(2, species, 0), 30);
+ gSprites[spriteId].oam.paletteNum = 2;
+ gSprites[spriteId].oam.priority = 2;
+ gSprites[spriteId].subpriority = sub_80A82E4(2);
+ gSprites[spriteId].callback = SpriteCallbackDummy;
+ gSprites[spriteId].data[0] = gSprites[spriteId].oam.paletteNum;
+ gSprites[spriteId].data[2] = species;
+ if (IsSpeciesNotUnown(species))
+ gSprites[spriteId].affineAnims = gUnknown_082FF6C0;
+ else
+ gSprites[spriteId].affineAnims = gUnknown_082FF694;
+ StartSpriteAffineAnim(gSprites + spriteId, 0);
+
+ return spriteId;
+}
+
+bool8 IsSpeciesNotUnown(u16 species)
+{
+ if (species == SPECIES_UNOWN)
+ return FALSE;
+ else
+ return TRUE;
+}
+
+void sub_80DB2BC(void)
+{
+ CpuCopy16(gContestResources->field_24[0], gContestResources->field_24[0] + 0x500, 0x280);
+ CpuCopy16(gContestResources->field_24[2], gContestResources->field_24[2] + 0x500, 0x280);
+}
+
+u16 sub_80DB2EC(u16 a0, u8 a1)
+{
+ u16 var;
+
+ switch (gContestEffects[gContestMoves[a0].effect].effectType)
+ {
+ case 0:
+ case 1:
+ case 8:
+ var = 0x9082;
+ break;
+ case 2:
+ case 3:
+ var = 0x9088;
+ break;
+ default:
+ var = 0x9086;
+ break;
+ }
+ var += 0x9000 + (a1 << 12);
+ return var;
+}
+
+void prints_contest_move_description(u16 a)
+{
+ u8 category;
+ u16 categoryTile;
+ u8 numHearts;
+
+ category = gContestMoves[a].contestCategory;
+ if (category == CONTEST_CATEGORY_COOL)
+ categoryTile = 0x4040;
+ else if (category == CONTEST_CATEGORY_BEAUTY)
+ categoryTile = 0x4045;
+ else if (category == CONTEST_CATEGORY_CUTE)
+ categoryTile = 0x404A;
+ else if (category == CONTEST_CATEGORY_SMART)
+ categoryTile = 0x406A;
+ else
+ categoryTile = 0x408A;
+
+ ContestBG_FillBoxWithIncrementingTile(0, categoryTile, 0x0b, 0x1f, 0x05, 0x01, 0x11, 0x01);
+ ContestBG_FillBoxWithIncrementingTile(0, categoryTile + 0x10, 0x0b, 0x20, 0x05, 0x01, 0x11, 0x01);
+
+ if (gContestEffects[gContestMoves[a].effect].appeal == 0xFF)
+ numHearts = 0;
+ else
+ numHearts = gContestEffects[gContestMoves[a].effect].appeal / 10;
+ if (numHearts > 8)
+ numHearts = 8;
+ ContestBG_FillBoxWithTile(0, 0x5035, 0x15, 0x1f, 0x08, 0x01, 0x11);
+ ContestBG_FillBoxWithTile(0, 0x5012, 0x15, 0x1f, numHearts, 0x01, 0x11);
+
+ if (gContestEffects[gContestMoves[a].effect].jam == 0xFF)
+ numHearts = 0;
+ else
+ numHearts = gContestEffects[gContestMoves[a].effect].jam / 10;
+ if (numHearts > 8)
+ numHearts = 8;
+ ContestBG_FillBoxWithTile(0, 0x5036, 0x15, 0x20, 0x08, 0x01, 0x11);
+ ContestBG_FillBoxWithTile(0, 0x5014, 0x15, 0x20, numHearts, 0x01, 0x11);
+
+ FillWindowPixelBuffer(10, 0);
+ Contest_PrintTextToBg0WindowStd(10, gContestEffectDescriptionPointers[gContestMoves[a].effect]);
+ Contest_PrintTextToBg0WindowStd(9, gText_Slash);
+}
+
+void sub_80DB4E0(u16 move, u8 b)
+{
+ u8 r7 = gUnknown_02039F26[b] * 5 + 2;
+
+ if (!sub_80DBCA8(b) && move != MOVE_NONE)
+ {
+ u16 tile = sub_80DB2EC(move, b);
+
+ ContestBG_FillBoxWithIncrementingTile(0, tile, 20, r7, 2, 1, 17, 1);
+ ContestBG_FillBoxWithIncrementingTile(0, tile + 16, 20, r7 + 1, 2, 1, 17, 1);
+ }
+ else
+ {
+ ContestBG_FillBoxWithTile(0, 0, 20, r7, 2, 2, 17);
+ }
+}
+
+void sub_80DB584(void)
+{
+ s32 i;
+
+ for (i = 0; i < 4; i++)
+ sub_80DB4E0(gContestResources->field_4[i].currMove, i);
+}
+
+u16 sub_80DB5B0(void)
+{
+ return 0x2034;
+}
+
+bool8 sub_80DB5B8(u8 contestantIdx, bool8 resetMod)
+{
+ u8 r6;
+ s32 r4;
+
+ if (sContestantStatus[contestantIdx].conditionMod == 0)
+ return FALSE;
+ r6 = gUnknown_02039F26[contestantIdx] * 5 + 2;
+ r4 = sContestantStatus[contestantIdx].condition / 10;
+ if (sContestantStatus[contestantIdx].conditionMod == 1)
+ {
+ ContestBG_FillBoxWithTile(0, sub_80DB5B0(), 19, r6, 1, r4, 17);
+ if (resetMod)
+ {
+ PlaySE(SE_EXPMAX);
+ sContestantStatus[contestantIdx].conditionMod = 0;
+ }
+ }
+ else
+ {
+ ContestBG_FillBoxWithTile(0, 0, 19, r6 + r4, 1, 3 - r4, 17);
+ if (resetMod)
+ {
+ PlaySE(SE_FU_ZAKU2);
+ sContestantStatus[contestantIdx].conditionMod = 0;
+ }
+ }
+ return TRUE;
+}
+
+void sub_80DB69C(void)
+{
+ s32 i;
+ s32 r6;
+
+ for (i = 0; i < 4; i++)
+ {
+ u8 r4 = gUnknown_02039F26[i] * 5 + 2;
+ u16 r5 = sub_80DB5B0();
+
+ r6 = sContestantStatus[i].condition / 10;
+ ContestBG_FillBoxWithTile(0, r5, 19, r4, 1, r6, 17);
+ ContestBG_FillBoxWithTile(0, 0, 19, r4 + r6, 1, 3 - r6, 17);
+ }
+}
+
+u16 sub_80DB748(u8 status)
+{
+ u16 var = 0;
+
+ switch (status)
+ {
+ case 0:
+ var = 0x80;
+ break;
+ case 1:
+ var = 0x84;
+ break;
+ case 2:
+ var = 0x86;
+ break;
+ case 3:
+ var = 0x88;
+ break;
+ case 4:
+ var = 0x82;
+ break;
+ }
+ var += 0x9000;
+ return var;
+}
+
+bool8 sub_80DB798(u8 a)
+{
+ bool8 r9 = TRUE;
+ u16 r8 = 0;
+ u8 r7 = gUnknown_02039F26[a] * 5 + 2;
+
+ if (sContestantStatus[a].resistant != 0 || sContestantStatus[a].immune != 0 || sContestantStatus[a].jamSafetyCount != 0 || sContestantStatus[a].jamReduction != 0)
+ r8 = sub_80DB748(0);
+ else if (sContestantStatus[a].nervous)
+ r8 = sub_80DB748(1);
+ else if (sContestantStatus[a].numTurnsSkipped != 0 || sContestantStatus[a].noMoreTurns)
+ r8 = sub_80DB748(2);
+ else
+ r9 = FALSE;
+ if (r9)
+ {
+ ContestBG_FillBoxWithIncrementingTile(0, r8, 20, r7, 2, 1, 17, 1);
+ ContestBG_FillBoxWithIncrementingTile(0, r8 + 16, 20, r7 + 1, 2, 1, 17, 1);
+ }
+ else
+ {
+ ContestBG_FillBoxWithTile(0, 0, 20, r7, 2, 2, 17);
+ }
+ return r9;
+}
diff --git a/src/credits.c b/src/credits.c
index 168f3e8a3..a88e4b549 100644
--- a/src/credits.c
+++ b/src/credits.c
@@ -2285,7 +2285,7 @@ static void sub_81772B8(struct Sprite *sprite)
static void sub_8177388(void)
{
- u16 starter = SpeciesToNationalPokedexNum(GetStarterPokemon(VarGet(VAR_FIRST_POKE)));
+ u16 starter = SpeciesToNationalPokedexNum(GetStarterPokemon(VarGet(VAR_STARTER_MON)));
u16 page;
u16 dexNum;
u16 j;
diff --git a/src/data/heal_locations.h b/src/data/heal_locations.h
new file mode 100644
index 000000000..613bcebe8
--- /dev/null
+++ b/src/data/heal_locations.h
@@ -0,0 +1,25 @@
+static const struct HealLocation sHealLocations[] =
+{
+ {MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_2F), MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_2F), 4, 2},
+ {MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_2F), MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_2F), 4, 2},
+ {MAP_GROUP(PETALBURG_CITY), MAP_NUM(PETALBURG_CITY), 20, 17},
+ {MAP_GROUP(SLATEPORT_CITY), MAP_NUM(SLATEPORT_CITY), 19, 20},
+ {MAP_GROUP(MAUVILLE_CITY), MAP_NUM(MAUVILLE_CITY), 22, 6},
+ {MAP_GROUP(RUSTBORO_CITY), MAP_NUM(RUSTBORO_CITY), 16, 39},
+ {MAP_GROUP(FORTREE_CITY), MAP_NUM(FORTREE_CITY), 5, 7},
+ {MAP_GROUP(LILYCOVE_CITY), MAP_NUM(LILYCOVE_CITY), 24, 15},
+ {MAP_GROUP(MOSSDEEP_CITY), MAP_NUM(MOSSDEEP_CITY), 28, 17},
+ {MAP_GROUP(SOOTOPOLIS_CITY), MAP_NUM(SOOTOPOLIS_CITY), 43, 32},
+ {MAP_GROUP(EVER_GRANDE_CITY), MAP_NUM(EVER_GRANDE_CITY), 27, 49},
+ {MAP_GROUP(LITTLEROOT_TOWN), MAP_NUM(LITTLEROOT_TOWN), 5, 9},
+ {MAP_GROUP(LITTLEROOT_TOWN), MAP_NUM(LITTLEROOT_TOWN), 14, 9},
+ {MAP_GROUP(OLDALE_TOWN), MAP_NUM(OLDALE_TOWN), 6, 17},
+ {MAP_GROUP(DEWFORD_TOWN), MAP_NUM(DEWFORD_TOWN), 2, 11},
+ {MAP_GROUP(LAVARIDGE_TOWN), MAP_NUM(LAVARIDGE_TOWN), 9, 7},
+ {MAP_GROUP(FALLARBOR_TOWN), MAP_NUM(FALLARBOR_TOWN), 14, 8},
+ {MAP_GROUP(VERDANTURF_TOWN), MAP_NUM(VERDANTURF_TOWN), 16, 4},
+ {MAP_GROUP(PACIFIDLOG_TOWN), MAP_NUM(PACIFIDLOG_TOWN), 8, 16},
+ {MAP_GROUP(EVER_GRANDE_CITY), MAP_NUM(EVER_GRANDE_CITY), 18, 6},
+ {MAP_GROUP(SOUTHERN_ISLAND_EXTERIOR), MAP_NUM(SOUTHERN_ISLAND_EXTERIOR), 15, 20},
+ {MAP_GROUP(BATTLE_FRONTIER_OUTSIDE_EAST), MAP_NUM(BATTLE_FRONTIER_OUTSIDE_EAST), 3, 52},
+};
diff --git a/src/data/text/move_descriptions.h b/src/data/text/move_descriptions.h
new file mode 100644
index 000000000..f8830c593
--- /dev/null
+++ b/src/data/text/move_descriptions.h
@@ -0,0 +1,714 @@
+static const u8 sNullMoveDescription[] = _("");
+static const u8 sPoundMoveDescription[] = _("Pounds the foe with\nforelegs or tail.");
+static const u8 sKarateChopMoveDescription[] = _("A chopping attack with a\nhigh critical-hit ratio.");
+static const u8 sDoubleSlapMoveDescription[] = _("Repeatedly slaps the foe\n2 to 5 times.");
+static const u8 sCometPunchMoveDescription[] = _("Repeatedly punches the foe\n2 to 5 times.");
+static const u8 sMegaPunchMoveDescription[] = _("A strong punch thrown with\nincredible power.");
+static const u8 sPayDayMoveDescription[] = _("Throws coins at the foe.\nMoney is recovered after.");
+static const u8 sFirePunchMoveDescription[] = _("A fiery punch that may burn\nthe foe.");
+static const u8 sIcePunchMoveDescription[] = _("An icy punch that may\nfreeze the foe.");
+static const u8 sThunderPunchMoveDescription[] = _("An electrified punch that\nmay paralyze the foe.");
+static const u8 sScratchMoveDescription[] = _("Scratches the foe with\nsharp claws.");
+static const u8 sViceGripMoveDescription[] = _("Grips the foe with large and\npowerful pincers.");
+static const u8 sGuillotineMoveDescription[] = _("A powerful pincer attack\nthat may cause fainting.");
+static const u8 sRazorWindMoveDescription[] = _("A 2-turn move that strikes\nthe foe on the 2nd turn.");
+static const u8 sSwordsDanceMoveDescription[] = _("A fighting dance that\nsharply raises ATTACK.");
+static const u8 sCutMoveDescription[] = _("Cuts the foe with sharp\nscythes, claws, etc.");
+static const u8 sGustMoveDescription[] = _("Strikes the foe with a gust\nof wind whipped up by wings.");
+static const u8 sWingAttackMoveDescription[] = _("Strikes the foe with wings\nspread wide.");
+static const u8 sWhirlwindMoveDescription[] = _("Blows away the foe with\nwind and ends the battle.");
+static const u8 sFlyMoveDescription[] = _("Flies up on the first turn,\nthen strikes the next turn.");
+static const u8 sBindMoveDescription[] = _("Binds and squeezes the foe\nfor 2 to 5 turns.");
+static const u8 sSlamMoveDescription[] = _("Slams the foe with a long\ntail, vine, etc.");
+static const u8 sVineWhipMoveDescription[] = _("Strikes the foe with\nslender, whiplike vines.");
+static const u8 sStompMoveDescription[] = _("Stomps the enemy with a big\nfoot. May cause flinching.");
+static const u8 sDoubleKickMoveDescription[] = _("A double-kicking attack\nthat strikes the foe twice.");
+static const u8 sMegaKickMoveDescription[] = _("An extremely powerful kick\nwith intense force.");
+static const u8 sJumpKickMoveDescription[] = _("A strong jumping kick. May\nmiss and hurt the kicker.");
+static const u8 sRollingKickMoveDescription[] = _("A fast kick delivered from\na rapid spin.");
+static const u8 sSandAttackMoveDescription[] = _("Reduces the foe’s accuracy\nby hurling sand in its face.");
+static const u8 sHeadbuttMoveDescription[] = _("A ramming attack that may\ncause flinching.");
+static const u8 sHornAttackMoveDescription[] = _("Jabs the foe with sharp\nhorns.");
+static const u8 sFuryAttackMoveDescription[] = _("Jabs the foe 2 to 5 times\nwith sharp horns, etc.");
+static const u8 sHornDrillMoveDescription[] = _("A one-hit KO attack that\nuses a horn like a drill.");
+static const u8 sTackleMoveDescription[] = _("Charges the foe with a full-\nbody tackle.");
+static const u8 sBodySlamMoveDescription[] = _("A full-body slam that may\ncause paralysis.");
+static const u8 sWrapMoveDescription[] = _("Wraps and squeezes the foe\n2 to 5 times with vines, etc.");
+static const u8 sTakeDownMoveDescription[] = _("A reckless charge attack\nthat also hurts the user.");
+static const u8 sThrashMoveDescription[] = _("A rampage of 2 to 3 turns\nthat confuses the user.");
+static const u8 sDoubleEdgeMoveDescription[] = _("A life-risking tackle that\nalso hurts the user.");
+static const u8 sTailWhipMoveDescription[] = _("Wags the tail to lower the\nfoe’s DEFENSE.");
+static const u8 sPoisonStingMoveDescription[] = _("A toxic attack with barbs,\netc., that may poison.");
+static const u8 sTwineedleMoveDescription[] = _("Stingers on the forelegs\njab the foe twice.");
+static const u8 sPinMissileMoveDescription[] = _("Sharp pins are fired to\nstrike 2 to 5 times.");
+static const u8 sLeerMoveDescription[] = _("Frightens the foe with a\nleer to lower DEFENSE.");
+static const u8 sBiteMoveDescription[] = _("Bites with vicious fangs.\nMay cause flinching.");
+static const u8 sGrowlMoveDescription[] = _("Growls cutely to reduce the\nfoe’s ATTACK.");
+static const u8 sRoarMoveDescription[] = _("Makes the foe flee to end\nthe battle.");
+static const u8 sSingMoveDescription[] = _("A soothing song lulls the\nfoe into a deep slumber.");
+static const u8 sSupersonicMoveDescription[] = _("Emits bizarre sound waves\nthat may confuse the foe.");
+static const u8 sSonicBoomMoveDescription[] = _("Launches shock waves that\nalways inflict 20 HP damage.");
+static const u8 sDisableMoveDescription[] = _("Psychically disables one of\nthe foe’s moves.");
+static const u8 sAcidMoveDescription[] = _("Sprays a hide-melting acid.\nMay lower DEFENSE.");
+static const u8 sEmberMoveDescription[] = _("A weak fire attack that may\ninflict a burn.");
+static const u8 sFlamethrowerMoveDescription[] = _("A powerful fire attack that\nmay inflict a burn.");
+static const u8 sMistMoveDescription[] = _("Creates a mist that stops\nreduction of abilities.");
+static const u8 sWaterGunMoveDescription[] = _("Squirts water to attack\nthe foe.");
+static const u8 sHydroPumpMoveDescription[] = _("Blasts water at high power\nto strike the foe.");
+static const u8 sSurfMoveDescription[] = _("Creates a huge wave, then\ncrashes it down on the foe.");
+static const u8 sIceBeamMoveDescription[] = _("Blasts the foe with an icy\nbeam that may freeze it.");
+static const u8 sBlizzardMoveDescription[] = _("Hits the foe with an icy\nstorm that may freeze it.");
+static const u8 sPsybeamMoveDescription[] = _("Fires a peculiar ray that\nmay confuse the foe.");
+static const u8 sBubbleBeamMoveDescription[] = _("Forcefully sprays bubbles\nthat may lower SPEED.");
+static const u8 sAuroraBeamMoveDescription[] = _("Fires a rainbow-colored\nbeam that may lower ATTACK.");
+static const u8 sHyperBeamMoveDescription[] = _("Powerful, but leaves the\nuser immobile the next turn.");
+static const u8 sPeckMoveDescription[] = _("Attacks the foe with a\njabbing beak, etc.");
+static const u8 sDrillPeckMoveDescription[] = _("A corkscrewing attack with\nthe beak acting as a drill.");
+static const u8 sSubmissionMoveDescription[] = _("A reckless body slam that\nalso hurts the user.");
+static const u8 sLowKickMoveDescription[] = _("A kick that inflicts more\ndamage on heavier foes.");
+static const u8 sCounterMoveDescription[] = _("Retaliates any physical hit\nwith double the power.");
+static const u8 sSeismicTossMoveDescription[] = _("Inflicts damage identical\nto the user’s level.");
+static const u8 sStrengthMoveDescription[] = _("Builds enormous power,\nthen slams the foe.");
+static const u8 sAbsorbMoveDescription[] = _("An attack that absorbs\nhalf the damage inflicted.");
+static const u8 sMegaDrainMoveDescription[] = _("An attack that absorbs\nhalf the damage inflicted.");
+static const u8 sLeechSeedMoveDescription[] = _("Plants a seed on the foe to\nsteal HP on every turn.");
+static const u8 sGrowthMoveDescription[] = _("Forces the body to grow\nand heightens SP. ATK.");
+static const u8 sRazorLeafMoveDescription[] = _("Cuts the enemy with leaves.\nHigh critical-hit ratio.");
+static const u8 sSolarBeamMoveDescription[] = _("Absorbs light in one turn,\nthen attacks next turn.");
+static const u8 sPoisonPowderMoveDescription[] = _("Scatters a toxic powder\nthat may poison the foe.");
+static const u8 sStunSporeMoveDescription[] = _("Scatters a powder that may\nparalyze the foe.");
+static const u8 sSleepPowderMoveDescription[] = _("Scatters a powder that may\ncause the foe to sleep.");
+static const u8 sPetalDanceMoveDescription[] = _("A rampage of 2 to 3 turns\nthat confuses the user.");
+static const u8 sStringShotMoveDescription[] = _("Binds the foe with string\nto reduce its SPEED.");
+static const u8 sDragonRageMoveDescription[] = _("Launches shock waves that\nalways inflict 40 HP damage.");
+static const u8 sFireSpinMoveDescription[] = _("Traps the foe in a ring of\nfire for 2 to 5 turns.");
+static const u8 sThunderShockMoveDescription[] = _("An electrical attack that\nmay paralyze the foe.");
+static const u8 sThunderboltMoveDescription[] = _("A strong electrical attack\nthat may paralyze the foe.");
+static const u8 sThunderWaveMoveDescription[] = _("A weak jolt of electricity\nthat paralyzes the foe.");
+static const u8 sThunderMoveDescription[] = _("A lightning attack that may\ncause paralysis.");
+static const u8 sRockThrowMoveDescription[] = _("Throws small rocks to\nstrike the foe.");
+static const u8 sEarthquakeMoveDescription[] = _("A powerful quake, but has\nno effect on flying foes.");
+static const u8 sFissureMoveDescription[] = _("A one-hit KO move that\ndrops the foe in a fissure.");
+static const u8 sDigMoveDescription[] = _("Digs underground the first\nturn and strikes next turn.");
+static const u8 sToxicMoveDescription[] = _("Poisons the foe with an\nintensifying toxin.");
+static const u8 sConfusionMoveDescription[] = _("A psychic attack that may\ncause confusion.");
+static const u8 sPsychicMoveDescription[] = _("A powerful psychic attack\nthat may lower SP. DEF.");
+static const u8 sHypnosisMoveDescription[] = _("A hypnotizing move that\nmay induce sleep.");
+static const u8 sMeditateMoveDescription[] = _("Meditates in a peaceful\nfashion to raise ATTACK.");
+static const u8 sAgilityMoveDescription[] = _("Relaxes the body to sharply\nboost SPEED.");
+static const u8 sQuickAttackMoveDescription[] = _("An extremely fast attack\nthat always strikes first.");
+static const u8 sRageMoveDescription[] = _("Raises the user’s ATTACK\nevery time it is hit.");
+static const u8 sTeleportMoveDescription[] = _("A psychic move for fleeing\nfrom battle instantly.");
+static const u8 sNightShadeMoveDescription[] = _("Inflicts damage identical\nto the user’s level.");
+static const u8 sMimicMoveDescription[] = _("Copies a move used by the\nfoe during one battle.");
+static const u8 sScreechMoveDescription[] = _("Emits a screech to sharply\nreduce the foe’s DEFENSE.");
+static const u8 sDoubleTeamMoveDescription[] = _("Creates illusory copies to\nraise evasiveness.");
+static const u8 sRecoverMoveDescription[] = _("Recovers up to half the\nuser’s maximum HP.");
+static const u8 sHardenMoveDescription[] = _("Stiffens the body’s \nmuscles to raise DEFENSE.");
+static const u8 sMinimizeMoveDescription[] = _("Minimizes the user’s size\nto raise evasiveness.");
+static const u8 sSmokescreenMoveDescription[] = _("Lowers the foe’s accuracy\nusing smoke, ink, etc.");
+static const u8 sConfuseRayMoveDescription[] = _("A sinister ray that\nconfuses the foe.");
+static const u8 sWithdrawMoveDescription[] = _("Withdraws the body into its\nhard shell to raise DEFENSE.");
+static const u8 sDefenseCurlMoveDescription[] = _("Curls up to conceal weak\nspots and raise DEFENSE.");
+static const u8 sBarrierMoveDescription[] = _("Creates a barrier that\nsharply raises DEFENSE.");
+static const u8 sLightScreenMoveDescription[] = _("Creates a wall of light that\nlowers SP. ATK damage.");
+static const u8 sHazeMoveDescription[] = _("Creates a black haze that\neliminates all stat changes.");
+static const u8 sReflectMoveDescription[] = _("Creates a wall of light that\nweakens physical attacks.");
+static const u8 sFocusEnergyMoveDescription[] = _("Focuses power to raise the\ncritical-hit ratio.");
+static const u8 sBideMoveDescription[] = _("Endures attack for 2\nturns to retaliate double.");
+static const u8 sMetronomeMoveDescription[] = _("Waggles a finger to use any\nPOKéMON move at random.");
+static const u8 sMirrorMoveMoveDescription[] = _("Counters the foe’s attack\nwith the same move.");
+static const u8 sSelfDestructMoveDescription[] = _("Inflicts severe damage but\nmakes the user faint.");
+static const u8 sEggBombMoveDescription[] = _("An egg is forcibly hurled at\nthe foe.");
+static const u8 sLickMoveDescription[] = _("Licks with a long tongue to\ninjure. May also paralyze.");
+static const u8 sSmogMoveDescription[] = _("An exhaust-gas attack\nthat may also poison.");
+static const u8 sSludgeMoveDescription[] = _("Sludge is hurled to inflict\ndamage. May also poison.");
+static const u8 sBoneClubMoveDescription[] = _("Clubs the foe with a bone.\nMay cause flinching.");
+static const u8 sFireBlastMoveDescription[] = _("Incinerates everything it\nstrikes. May cause a burn.");
+static const u8 sWaterfallMoveDescription[] = _("Charges the foe with speed\nto climb waterfalls.");
+static const u8 sClampMoveDescription[] = _("Traps and squeezes the\nfoe for 2 to 5 turns.");
+static const u8 sSwiftMoveDescription[] = _("Sprays star-shaped rays\nthat never miss.");
+static const u8 sSkullBashMoveDescription[] = _("Tucks in the head, then\nattacks on the next turn.");
+static const u8 sSpikeCannonMoveDescription[] = _("Launches sharp spikes that\nstrike 2 to 5 times.");
+static const u8 sConstrictMoveDescription[] = _("Constricts to inflict pain.\nMay lower SPEED.");
+static const u8 sAmnesiaMoveDescription[] = _("Forgets about something\nand sharply raises SP. DEF.");
+static const u8 sKinesisMoveDescription[] = _("Distracts the foe.\nMay lower accuracy.");
+static const u8 sSoftBoiledMoveDescription[] = _("Recovers up to half the\nuser’s maximum HP.");
+static const u8 sHiJumpKickMoveDescription[] = _("A jumping knee kick. If it\nmisses, the user is hurt.");
+static const u8 sGlareMoveDescription[] = _("Intimidates and frightens\nthe foe into paralysis.");
+static const u8 sDreamEaterMoveDescription[] = _("Takes one half the damage\ninflicted on a sleeping foe.");
+static const u8 sPoisonGasMoveDescription[] = _("Envelops the foe in a toxic\ngas that may poison.");
+static const u8 sBarrageMoveDescription[] = _("Hurls round objects at the\nfoe 2 to 5 times.");
+static const u8 sLeechLifeMoveDescription[] = _("An attack that steals half\nthe damage inflicted.");
+static const u8 sLovelyKissMoveDescription[] = _("Demands a kiss with a scary\nface that induces sleep.");
+static const u8 sSkyAttackMoveDescription[] = _("Searches out weak spots,\nthen strikes the next turn.");
+static const u8 sTransformMoveDescription[] = _("Alters the user’s cells to\nbecome a copy of the foe.");
+static const u8 sBubbleMoveDescription[] = _("An attack using bubbles.\nMay lower the foe’s SPEED.");
+static const u8 sDizzyPunchMoveDescription[] = _("A rhythmic punch that may\nconfuse the foe.");
+static const u8 sSporeMoveDescription[] = _("Scatters a cloud of spores\nthat always induce sleep.");
+static const u8 sFlashMoveDescription[] = _("Looses a powerful blast of\nlight that cuts accuracy.");
+static const u8 sPsywaveMoveDescription[] = _("Attacks with a psychic\nwave of varying intensity.");
+static const u8 sSplashMoveDescription[] = _("It’s just a splash...\nHas no effect whatsoever.");
+static const u8 sAcidArmorMoveDescription[] = _("Liquifies the user’s body\nto sharply raise DEFENSE.");
+static const u8 sCrabhammerMoveDescription[] = _("Hammers with a pincer. Has a\nhigh critical-hit ratio.");
+static const u8 sExplosionMoveDescription[] = _("Inflicts severe damage but\nmakes the user faint.");
+static const u8 sFurySwipesMoveDescription[] = _("Rakes the foe with sharp\nclaws, etc., 2 to 5 times.");
+static const u8 sBonemerangMoveDescription[] = _("Throws a bone boomerang\nthat strikes twice.");
+static const u8 sRestMoveDescription[] = _("The user sleeps for 2 turns,\nrestoring HP and status.");
+static const u8 sRockSlideMoveDescription[] = _("Large boulders are hurled.\nMay cause flinching.");
+static const u8 sHyperFangMoveDescription[] = _("Attacks with sharp fangs.\nMay cause flinching.");
+static const u8 sSharpenMoveDescription[] = _("Reduces the polygon count\nand raises ATTACK.");
+static const u8 sConversionMoveDescription[] = _("Changes the user’s type\ninto a known move’s type.");
+static const u8 sTriAttackMoveDescription[] = _("Fires three types of beams\nat the same time.");
+static const u8 sSuperFangMoveDescription[] = _("Attacks with sharp fangs\nand cuts half the foe’s HP.");
+static const u8 sSlashMoveDescription[] = _("Slashes with claws, etc. Has\na high critical-hit ratio.");
+static const u8 sSubstituteMoveDescription[] = _("Creates a decoy using 1/4\nof the user’s maximum HP.");
+static const u8 sStruggleMoveDescription[] = _("Used only if all PP are gone.\nAlso hurts the user a little.");
+static const u8 sSketchMoveDescription[] = _("Copies the foe’s last move\npermanently.");
+static const u8 sTripleKickMoveDescription[] = _("Kicks the foe 3 times in a\nrow with rising intensity.");
+static const u8 sThiefMoveDescription[] = _("While attacking, it may\nsteal the foe’s held item.");
+static const u8 sSpiderWebMoveDescription[] = _("Ensnares the foe to stop it\nfrom fleeing or switching.");
+static const u8 sMindReaderMoveDescription[] = _("Senses the foe’s action to\nensure the next move’s hit.");
+static const u8 sNightmareMoveDescription[] = _("Inflicts 1/4 damage on a\nsleeping foe every turn.");
+static const u8 sFlameWheelMoveDescription[] = _("A fiery charge attack that\nmay inflict a burn.");
+static const u8 sSnoreMoveDescription[] = _("A loud attack that can be\nused only while asleep.");
+static const u8 sCurseMoveDescription[] = _("A move that functions\ndifferently for GHOSTS.");
+static const u8 sFlailMoveDescription[] = _("Inflicts more damage when\nthe user’s HP is down.");
+static const u8 sConversion2MoveDescription[] = _("Makes the user resistant\nto the last attack’s type.");
+static const u8 sAeroblastMoveDescription[] = _("Launches a vacuumed blast.\nHigh critical-hit ratio.");
+static const u8 sCottonSporeMoveDescription[] = _("Spores cling to the foe,\nsharply reducing SPEED.");
+static const u8 sReversalMoveDescription[] = _("Inflicts more damage when\nthe user’s HP is down.");
+static const u8 sSpiteMoveDescription[] = _("Spitefully cuts the PP\nof the foe’s last move.");
+static const u8 sPowderSnowMoveDescription[] = _("Blasts the foe with a snowy\ngust. May cause freezing.");
+static const u8 sProtectMoveDescription[] = _("Evades attack, but may fail\nif used in succession.");
+static const u8 sMachPunchMoveDescription[] = _("A punch is thrown at wicked\nspeed to strike first.");
+static const u8 sScaryFaceMoveDescription[] = _("Frightens with a scary face\nto sharply reduce SPEED.");
+static const u8 sFaintAttackMoveDescription[] = _("Draws the foe close, then\nstrikes without fail.");
+static const u8 sSweetKissMoveDescription[] = _("Demands a kiss with a cute\nlook. May cause confusion.");
+static const u8 sBellyDrumMoveDescription[] = _("Maximizes ATTACK while\nsacrificing HP.");
+static const u8 sSludgeBombMoveDescription[] = _("Sludge is hurled to inflict\ndamage. May also poison.");
+static const u8 sMudSlapMoveDescription[] = _("Hurls mud in the foe’s face\nto reduce its accuracy.");
+static const u8 sOctazookaMoveDescription[] = _("Fires a lump of ink to\ndamage and cut accuracy.");
+static const u8 sSpikesMoveDescription[] = _("Sets spikes that hurt a \nfoe switching in.");
+static const u8 sZapCannonMoveDescription[] = _("Powerful and sure to cause\nparalysis, but inaccurate.");
+static const u8 sForesightMoveDescription[] = _("Negates the foe’s efforts\nto heighten evasiveness.");
+static const u8 sDestinyBondMoveDescription[] = _("If the user faints, the foe\nis also made to faint.");
+static const u8 sPerishSongMoveDescription[] = _("Any POKéMON hearing this\nsong faints in 3 turns.");
+static const u8 sIcyWindMoveDescription[] = _("A chilling attack that\nlowers the foe’s SPEED.");
+static const u8 sDetectMoveDescription[] = _("Evades attack, but may fail\nif used in succession.");
+static const u8 sBoneRushMoveDescription[] = _("Strikes the foe with a bone\nin hand 2 to 5 times.");
+static const u8 sLockOnMoveDescription[] = _("Locks on to the foe to\nensure the next move hits.");
+static const u8 sOutrageMoveDescription[] = _("A rampage of 2 to 3 turns\nthat confuses the user.");
+static const u8 sSandstormMoveDescription[] = _("Causes a sandstorm that\nrages for several turns.");
+static const u8 sGigaDrainMoveDescription[] = _("An attack that steals half\nthe damage inflicted.");
+static const u8 sEndureMoveDescription[] = _("Endures any attack for\n1 turn, leaving at least 1HP.");
+static const u8 sCharmMoveDescription[] = _("Charms the foe and sharply\nreduces its ATTACK.");
+static const u8 sRolloutMoveDescription[] = _("An attack lasting 5 turns\nwith rising intensity.");
+static const u8 sFalseSwipeMoveDescription[] = _("An attack that leaves the\nfoe with at least 1 HP.");
+static const u8 sSwaggerMoveDescription[] = _("Confuses the foe, but also\nsharply raises ATTACK.");
+static const u8 sMilkDrinkMoveDescription[] = _("Recovers up to half the\nuser’s maximum HP.");
+static const u8 sSparkMoveDescription[] = _("An electrified tackle that\nmay paralyze the foe.");
+static const u8 sFuryCutterMoveDescription[] = _("An attack that intensifies\non each successive hit.");
+static const u8 sSteelWingMoveDescription[] = _("Strikes the foe with hard\nwings spread wide.");
+static const u8 sMeanLookMoveDescription[] = _("Fixes the foe with a mean\nlook that prevents escape.");
+static const u8 sAttractMoveDescription[] = _("Makes the opposite gender\nless likely to attack.");
+static const u8 sSleepTalkMoveDescription[] = _("Uses an available move\nrandomly while asleep.");
+static const u8 sHealBellMoveDescription[] = _("Chimes soothingly to heal\nall status abnormalities.");
+static const u8 sReturnMoveDescription[] = _("An attack that increases\nin power with friendship.");
+static const u8 sPresentMoveDescription[] = _("A gift in the form of a\nbomb. May restore HP.");
+static const u8 sFrustrationMoveDescription[] = _("An attack that is stronger\nif the TRAINER is disliked.");
+static const u8 sSafeguardMoveDescription[] = _("A mystical force prevents\nall status problems.");
+static const u8 sPainSplitMoveDescription[] = _("Adds the user and foe’s HP,\nthen shares them equally.");
+static const u8 sSacredFireMoveDescription[] = _("A mystical fire attack that\nmay inflict a burn.");
+static const u8 sMagnitudeMoveDescription[] = _("A ground-shaking attack\nof random intensity.");
+static const u8 sDynamicPunchMoveDescription[] = _("Powerful and sure to cause\nconfusion, but inaccurate.");
+static const u8 sMegahornMoveDescription[] = _("A brutal ramming attack\nusing out-thrust horns.");
+static const u8 sDragonBreathMoveDescription[] = _("Strikes the foe with an\nincredible blast of breath.");
+static const u8 sBatonPassMoveDescription[] = _("Switches out the user while\nkeeping effects in play.");
+static const u8 sEncoreMoveDescription[] = _("Makes the foe repeat its\nlast move over 2 to 6 turns.");
+static const u8 sPursuitMoveDescription[] = _("Inflicts bad damage if used\non a foe switching out.");
+static const u8 sRapidSpinMoveDescription[] = _("Spins the body at high\nspeed to strike the foe.");
+static const u8 sSweetScentMoveDescription[] = _("Allures the foe to reduce\nevasiveness.");
+static const u8 sIronTailMoveDescription[] = _("Attacks with a rock-hard\ntail. May lower DEFENSE.");
+static const u8 sMetalClawMoveDescription[] = _("A claw attack that may\nraise the user’s ATTACK.");
+static const u8 sVitalThrowMoveDescription[] = _("Makes the user’s move last,\nbut it never misses.");
+static const u8 sMorningSunMoveDescription[] = _("Restores HP. The amount\nvaries with the weather.");
+static const u8 sSynthesisMoveDescription[] = _("Restores HP. The amount\nvaries with the weather.");
+static const u8 sMoonlightMoveDescription[] = _("Restores HP. The amount\nvaries with the weather.");
+static const u8 sHiddenPowerMoveDescription[] = _("The effectiveness varies\nwith the user.");
+static const u8 sCrossChopMoveDescription[] = _("A double-chopping attack.\nHigh critical-hit ratio.");
+static const u8 sTwisterMoveDescription[] = _("Whips up a vicious twister\nto tear at the foe.");
+static const u8 sRainDanceMoveDescription[] = _("Boosts the power of WATER-\ntype moves for 5 turns.");
+static const u8 sSunnyDayMoveDescription[] = _("Boosts the power of FIRE-\ntype moves for 5 turns.");
+static const u8 sCrunchMoveDescription[] = _("Crunches with sharp fangs.\nMay lower SP. DEF.");
+static const u8 sMirrorCoatMoveDescription[] = _("Counters the foe’s special\nattack at double the power.");
+static const u8 sPsychUpMoveDescription[] = _("Copies the foe’s effect(s)\nand gives to the user.");
+static const u8 sExtremeSpeedMoveDescription[] = _("An extremely fast and\npowerful attack.");
+static const u8 sAncientPowerMoveDescription[] = _("An attack that may raise\nall stats.");
+static const u8 sShadowBallMoveDescription[] = _("Hurls a black blob that may\nlower the foe’s SP. DEF.");
+static const u8 sFutureSightMoveDescription[] = _("Heightens inner power to\nstrike 2 turns later.");
+static const u8 sRockSmashMoveDescription[] = _("A rock-crushing attack\nthat may lower DEFENSE.");
+static const u8 sWhirlpoolMoveDescription[] = _("Traps and hurts the foe in\na whirlpool for 2 to 5 turns.");
+static const u8 sBeatUpMoveDescription[] = _("Summons party POKéMON to\njoin in the attack.");
+static const u8 sFakeOutMoveDescription[] = _("A 1st-turn, 1st-strike move\nthat causes flinching.");
+static const u8 sUproarMoveDescription[] = _("Causes an uproar for 2 to 5\nturns and prevents sleep.");
+static const u8 sStockpileMoveDescription[] = _("Charges up power for up to\n3 turns.");
+static const u8 sSpitUpMoveDescription[] = _("Releases stockpiled power\n(the more the better).");
+static const u8 sSwallowMoveDescription[] = _("Absorbs stockpiled power\nand restores HP.");
+static const u8 sHeatWaveMoveDescription[] = _("Exhales a hot breath on the\nfoe. May inflict a burn.");
+static const u8 sHailMoveDescription[] = _("Summons a hailstorm that\nstrikes every turn.");
+static const u8 sTormentMoveDescription[] = _("Torments the foe and stops\nsuccessive use of a move.");
+static const u8 sFlatterMoveDescription[] = _("Confuses the foe, but\nraises its SP. ATK.");
+static const u8 sWillOWispMoveDescription[] = _("Inflicts a burn on the foe\nwith intense fire.");
+static const u8 sMementoMoveDescription[] = _("The user faints and lowers\nthe foe’s abilities.");
+static const u8 sFacadeMoveDescription[] = _("Boosts ATTACK when burned,\nparalyzed, or poisoned.");
+static const u8 sFocusPunchMoveDescription[] = _("A powerful loyalty attack.\nThe user flinches if hit.");
+static const u8 sSmellingSaltMoveDescription[] = _("Powerful against paralyzed\nfoes, but also heals them.");
+static const u8 sFollowMeMoveDescription[] = _("Draws attention to make\nfoes attack only the user.");
+static const u8 sNaturePowerMoveDescription[] = _("The type of attack varies\ndepending on the location.");
+static const u8 sChargeMoveDescription[] = _("Charges power to boost the\nelectric move used next.");
+static const u8 sTauntMoveDescription[] = _("Taunts the foe into only\nusing attack moves.");
+static const u8 sHelpingHandMoveDescription[] = _("Boosts the power of the\nrecipient’s moves.");
+static const u8 sTrickMoveDescription[] = _("Tricks the foe into trading\nheld items.");
+static const u8 sRolePlayMoveDescription[] = _("Mimics the target and\ncopies its special ability.");
+static const u8 sWishMoveDescription[] = _("A wish that restores HP.\nIt takes time to work.");
+static const u8 sAssistMoveDescription[] = _("Attacks randomly with one\nof the partner’s moves.");
+static const u8 sIngrainMoveDescription[] = _("Lays roots that restore HP.\nThe user can’t switch out.");
+static const u8 sSuperpowerMoveDescription[] = _("Boosts strength sharply,\nbut lowers abilities.");
+static const u8 sMagicCoatMoveDescription[] = _("Reflects special effects\nback to the attacker.");
+static const u8 sRecycleMoveDescription[] = _("Recycles a used item for\none more use.");
+static const u8 sRevengeMoveDescription[] = _("An attack that gains power\nif injured by the foe.");
+static const u8 sBrickBreakMoveDescription[] = _("Destroys barriers such as\nREFLECT and causes damage.");
+static const u8 sYawnMoveDescription[] = _("Lulls the foe into yawning,\nthen sleeping next turn.");
+static const u8 sKnockOffMoveDescription[] = _("Knocks down the foe’s held\nitem to prevent its use.");
+static const u8 sEndeavorMoveDescription[] = _("Gains power if the user’s HP\nis lower than the foe’s HP.");
+static const u8 sEruptionMoveDescription[] = _("The higher the user’s HP,\nthe more damage caused.");
+static const u8 sSkillSwapMoveDescription[] = _("The user swaps special\nabilities with the target.");
+static const u8 sImprisonMoveDescription[] = _("Prevents foes from using\nmoves known by the user.");
+static const u8 sRefreshMoveDescription[] = _("Heals poisoning, paralysis,\nor a burn.");
+static const u8 sGrudgeMoveDescription[] = _("If the user faints, deletes\nall PP of foe’s last move.");
+static const u8 sSnatchMoveDescription[] = _("Steals the effects of the\nmove the target uses next.");
+static const u8 sSecretPowerMoveDescription[] = _("An attack with effects\nthat vary by location.");
+static const u8 sDiveMoveDescription[] = _("Dives underwater the first\nturn and strikes next turn.");
+static const u8 sArmThrustMoveDescription[] = _("Straight-arm punches that\nstrike the foe 2 to 5 times.");
+static const u8 sCamouflageMoveDescription[] = _("Alters the POKéMON’s type\ndepending on the location.");
+static const u8 sTailGlowMoveDescription[] = _("Flashes a light that sharply\nraises SP. ATK.");
+static const u8 sLusterPurgeMoveDescription[] = _("Attacks with a burst of\nlight. May lower SP. DEF.");
+static const u8 sMistBallMoveDescription[] = _("Attacks with a flurry of\ndown. May lower SP. ATK.");
+static const u8 sFeatherDanceMoveDescription[] = _("Envelops the foe with down\nto sharply reduce ATTACK.");
+static const u8 sTeeterDanceMoveDescription[] = _("Confuses all POKéMON on\nthe scene.");
+static const u8 sBlazeKickMoveDescription[] = _("A kick with a high critical-\nhit ratio. May cause a burn.");
+static const u8 sMudSportMoveDescription[] = _("Covers the user in mud to\nraise electrical resistance.");
+static const u8 sIceBallMoveDescription[] = _("A 5-turn attack that gains\npower on successive hits.");
+static const u8 sNeedleArmMoveDescription[] = _("Attacks with thorny arms.\nMay cause flinching.");
+static const u8 sSlackOffMoveDescription[] = _("Slacks off and restores\nhalf the maximum HP.");
+static const u8 sHyperVoiceMoveDescription[] = _("A loud attack that uses\nsound waves to injure.");
+static const u8 sPoisonFangMoveDescription[] = _("A sharp-fanged attack.\nMay badly poison the foe.");
+static const u8 sCrushClawMoveDescription[] = _("Tears at the foe with sharp\nclaws. May lower DEFENSE.");
+static const u8 sBlastBurnMoveDescription[] = _("Powerful, but leaves the\nuser immobile the next turn.");
+static const u8 sHydroCannonMoveDescription[] = _("Powerful, but leaves the\nuser immobile the next turn.");
+static const u8 sMeteorMashMoveDescription[] = _("Fires a meteor-like punch.\nMay raise ATTACK.");
+static const u8 sAstonishMoveDescription[] = _("An attack that may shock\nthe foe into flinching.");
+static const u8 sWeatherBallMoveDescription[] = _("The move’s type and power\nchange with the weather.");
+static const u8 sAromatherapyMoveDescription[] = _("Heals all status problems\nwith a soothing scent.");
+static const u8 sFakeTearsMoveDescription[] = _("Feigns crying to sharply\nlower the foe’s SP. DEF.");
+static const u8 sAirCutterMoveDescription[] = _("Hacks with razorlike wind.\nHigh critical-hit ratio.");
+static const u8 sOverheatMoveDescription[] = _("Allows a full-power attack,\nbut sharply lowers SP. ATK.");
+static const u8 sOdorSleuthMoveDescription[] = _("Negates the foe’s efforts\nto heighten evasiveness.");
+static const u8 sRockTombMoveDescription[] = _("Stops the foe from moving\nwith rocks and cuts SPEED.");
+static const u8 sSilverWindMoveDescription[] = _("A powdery attack that may\nraise abilities.");
+static const u8 sMetalSoundMoveDescription[] = _("Emits a horrible screech\nthat sharply lowers SP. DEF.");
+static const u8 sGrassWhistleMoveDescription[] = _("Lulls the foe into sleep\nwith a pleasant melody.");
+static const u8 sTickleMoveDescription[] = _("Makes the foe laugh to\nlower ATTACK and DEFENSE.");
+static const u8 sCosmicPowerMoveDescription[] = _("Raises DEFENSE and SP. DEF\nwith a mystic power.");
+static const u8 sWaterSpoutMoveDescription[] = _("Inflicts more damage if the\nuser’s HP is high.");
+static const u8 sSignalBeamMoveDescription[] = _("A strange beam attack that\nmay confuse the foe.");
+static const u8 sShadowPunchMoveDescription[] = _("An unavoidable punch that\nis thrown from shadows.");
+static const u8 sExtrasensoryMoveDescription[] = _("Attacks with a peculiar\npower. May cause flinching.");
+static const u8 sSkyUppercutMoveDescription[] = _("An uppercut thrown as if\nleaping into the sky.");
+static const u8 sSandTombMoveDescription[] = _("Traps and hurts the foe in\nquicksand for 2 to 5 turns.");
+static const u8 sSheerColdMoveDescription[] = _("A chilling attack that\ncauses fainting if it hits.");
+static const u8 sMuddyWaterMoveDescription[] = _("Attacks with muddy water.\nMay lower accuracy.");
+static const u8 sBulletSeedMoveDescription[] = _("Shoots 2 to 5 seeds in a row\nto strike the foe.");
+static const u8 sAerialAceMoveDescription[] = _("An extremely speedy and\nunavoidable attack.");
+static const u8 sIcicleSpearMoveDescription[] = _("Attacks the foe by firing\n2 to 5 icicles in a row.");
+static const u8 sIronDefenseMoveDescription[] = _("Hardens the body’s surface\nto sharply raise DEFENSE.");
+static const u8 sBlockMoveDescription[] = _("Blocks the foe’s way to\nprevent escape.");
+static const u8 sHowlMoveDescription[] = _("Howls to raise the spirit\nand boosts ATTACK.");
+static const u8 sDragonClawMoveDescription[] = _("Slashes the foe with sharp\nclaws.");
+static const u8 sFrenzyPlantMoveDescription[] = _("Powerful, but leaves the\nuser immobile the next turn.");
+static const u8 sBulkUpMoveDescription[] = _("Bulks up the body to boost\nboth ATTACK and DEFENSE.");
+static const u8 sBounceMoveDescription[] = _("Bounces up, then down the\nnext turn. May paralyze.");
+static const u8 sMudShotMoveDescription[] = _("Hurls mud at the foe and\nreduces SPEED.");
+static const u8 sPoisonTailMoveDescription[] = _("Has a high critical-hit\nratio. May also poison.");
+static const u8 sCovetMoveDescription[] = _("Cutely begs to obtain an\nitem held by the foe.");
+static const u8 sVoltTackleMoveDescription[] = _("A life-risking tackle that\nslightly hurts the user.");
+static const u8 sMagicalLeafMoveDescription[] = _("Attacks with a strange leaf\nthat cannot be evaded.");
+static const u8 sWaterSportMoveDescription[] = _("The user becomes soaked to\nraise resistance to fire.");
+static const u8 sCalmMindMoveDescription[] = _("Raises SP. ATK and SP. DEF\nby focusing the mind.");
+static const u8 sLeafBladeMoveDescription[] = _("Slashes with a sharp leaf.\nHigh critical-hit ratio.");
+static const u8 sDragonDanceMoveDescription[] = _("A mystical dance that ups\nATTACK and SPEED.");
+static const u8 sRockBlastMoveDescription[] = _("Hurls boulders at the foe\n2 to 5 times in a row.");
+static const u8 sShockWaveMoveDescription[] = _("A fast and unavoidable\nelectric attack.");
+static const u8 sWaterPulseMoveDescription[] = _("Attacks with ultrasonic\nwaves. May confuse the foe.");
+static const u8 sDoomDesireMoveDescription[] = _("Summons strong sunlight to\nattack 2 turns later.");
+static const u8 sPsychoBoostMoveDescription[] = _("Allows a full-power attack,\nbut sharply lowers SP. ATK.");
+
+// MOVE_NONE is ignored in this table. Make sure to always subtract 1 before getting the right pointer.
+const u8 *const gMoveDescriptionPointers[MOVES_COUNT - 1] =
+{
+ [MOVE_POUND - 1] = sPoundMoveDescription,
+ [MOVE_KARATE_CHOP - 1] = sKarateChopMoveDescription,
+ [MOVE_DOUBLE_SLAP - 1] = sDoubleSlapMoveDescription,
+ [MOVE_COMET_PUNCH - 1] = sCometPunchMoveDescription,
+ [MOVE_MEGA_PUNCH - 1] = sMegaPunchMoveDescription,
+ [MOVE_PAY_DAY - 1] = sPayDayMoveDescription,
+ [MOVE_FIRE_PUNCH - 1] = sFirePunchMoveDescription,
+ [MOVE_ICE_PUNCH - 1] = sIcePunchMoveDescription,
+ [MOVE_THUNDER_PUNCH - 1] = sThunderPunchMoveDescription,
+ [MOVE_SCRATCH - 1] = sScratchMoveDescription,
+ [MOVE_VICE_GRIP - 1] = sViceGripMoveDescription,
+ [MOVE_GUILLOTINE - 1] = sGuillotineMoveDescription,
+ [MOVE_RAZOR_WIND - 1] = sRazorWindMoveDescription,
+ [MOVE_SWORDS_DANCE - 1] = sSwordsDanceMoveDescription,
+ [MOVE_CUT - 1] = sCutMoveDescription,
+ [MOVE_GUST - 1] = sGustMoveDescription,
+ [MOVE_WING_ATTACK - 1] = sWingAttackMoveDescription,
+ [MOVE_WHIRLWIND - 1] = sWhirlwindMoveDescription,
+ [MOVE_FLY - 1] = sFlyMoveDescription,
+ [MOVE_BIND - 1] = sBindMoveDescription,
+ [MOVE_SLAM - 1] = sSlamMoveDescription,
+ [MOVE_VINE_WHIP - 1] = sVineWhipMoveDescription,
+ [MOVE_STOMP - 1] = sStompMoveDescription,
+ [MOVE_DOUBLE_KICK - 1] = sDoubleKickMoveDescription,
+ [MOVE_MEGA_KICK - 1] = sMegaKickMoveDescription,
+ [MOVE_JUMP_KICK - 1] = sJumpKickMoveDescription,
+ [MOVE_ROLLING_KICK - 1] = sRollingKickMoveDescription,
+ [MOVE_SAND_ATTACK - 1] = sSandAttackMoveDescription,
+ [MOVE_HEADBUTT - 1] = sHeadbuttMoveDescription,
+ [MOVE_HORN_ATTACK - 1] = sHornAttackMoveDescription,
+ [MOVE_FURY_ATTACK - 1] = sFuryAttackMoveDescription,
+ [MOVE_HORN_DRILL - 1] = sHornDrillMoveDescription,
+ [MOVE_TACKLE - 1] = sTackleMoveDescription,
+ [MOVE_BODY_SLAM - 1] = sBodySlamMoveDescription,
+ [MOVE_WRAP - 1] = sWrapMoveDescription,
+ [MOVE_TAKE_DOWN - 1] = sTakeDownMoveDescription,
+ [MOVE_THRASH - 1] = sThrashMoveDescription,
+ [MOVE_DOUBLE_EDGE - 1] = sDoubleEdgeMoveDescription,
+ [MOVE_TAIL_WHIP - 1] = sTailWhipMoveDescription,
+ [MOVE_POISON_STING - 1] = sPoisonStingMoveDescription,
+ [MOVE_TWINEEDLE - 1] = sTwineedleMoveDescription,
+ [MOVE_PIN_MISSILE - 1] = sPinMissileMoveDescription,
+ [MOVE_LEER - 1] = sLeerMoveDescription,
+ [MOVE_BITE - 1] = sBiteMoveDescription,
+ [MOVE_GROWL - 1] = sGrowlMoveDescription,
+ [MOVE_ROAR - 1] = sRoarMoveDescription,
+ [MOVE_SING - 1] = sSingMoveDescription,
+ [MOVE_SUPERSONIC - 1] = sSupersonicMoveDescription,
+ [MOVE_SONIC_BOOM - 1] = sSonicBoomMoveDescription,
+ [MOVE_DISABLE - 1] = sDisableMoveDescription,
+ [MOVE_ACID - 1] = sAcidMoveDescription,
+ [MOVE_EMBER - 1] = sEmberMoveDescription,
+ [MOVE_FLAMETHROWER - 1] = sFlamethrowerMoveDescription,
+ [MOVE_MIST - 1] = sMistMoveDescription,
+ [MOVE_WATER_GUN - 1] = sWaterGunMoveDescription,
+ [MOVE_HYDRO_PUMP - 1] = sHydroPumpMoveDescription,
+ [MOVE_SURF - 1] = sSurfMoveDescription,
+ [MOVE_ICE_BEAM - 1] = sIceBeamMoveDescription,
+ [MOVE_BLIZZARD - 1] = sBlizzardMoveDescription,
+ [MOVE_PSYBEAM - 1] = sPsybeamMoveDescription,
+ [MOVE_BUBBLE_BEAM - 1] = sBubbleBeamMoveDescription,
+ [MOVE_AURORA_BEAM - 1] = sAuroraBeamMoveDescription,
+ [MOVE_HYPER_BEAM - 1] = sHyperBeamMoveDescription,
+ [MOVE_PECK - 1] = sPeckMoveDescription,
+ [MOVE_DRILL_PECK - 1] = sDrillPeckMoveDescription,
+ [MOVE_SUBMISSION - 1] = sSubmissionMoveDescription,
+ [MOVE_LOW_KICK - 1] = sLowKickMoveDescription,
+ [MOVE_COUNTER - 1] = sCounterMoveDescription,
+ [MOVE_SEISMIC_TOSS - 1] = sSeismicTossMoveDescription,
+ [MOVE_STRENGTH - 1] = sStrengthMoveDescription,
+ [MOVE_ABSORB - 1] = sAbsorbMoveDescription,
+ [MOVE_MEGA_DRAIN - 1] = sMegaDrainMoveDescription,
+ [MOVE_LEECH_SEED - 1] = sLeechSeedMoveDescription,
+ [MOVE_GROWTH - 1] = sGrowthMoveDescription,
+ [MOVE_RAZOR_LEAF - 1] = sRazorLeafMoveDescription,
+ [MOVE_SOLAR_BEAM - 1] = sSolarBeamMoveDescription,
+ [MOVE_POISON_POWDER - 1] = sPoisonPowderMoveDescription,
+ [MOVE_STUN_SPORE - 1] = sStunSporeMoveDescription,
+ [MOVE_SLEEP_POWDER - 1] = sSleepPowderMoveDescription,
+ [MOVE_PETAL_DANCE - 1] = sPetalDanceMoveDescription,
+ [MOVE_STRING_SHOT - 1] = sStringShotMoveDescription,
+ [MOVE_DRAGON_RAGE - 1] = sDragonRageMoveDescription,
+ [MOVE_FIRE_SPIN - 1] = sFireSpinMoveDescription,
+ [MOVE_THUNDER_SHOCK - 1] = sThunderShockMoveDescription,
+ [MOVE_THUNDERBOLT - 1] = sThunderboltMoveDescription,
+ [MOVE_THUNDER_WAVE - 1] = sThunderWaveMoveDescription,
+ [MOVE_THUNDER - 1] = sThunderMoveDescription,
+ [MOVE_ROCK_THROW - 1] = sRockThrowMoveDescription,
+ [MOVE_EARTHQUAKE - 1] = sEarthquakeMoveDescription,
+ [MOVE_FISSURE - 1] = sFissureMoveDescription,
+ [MOVE_DIG - 1] = sDigMoveDescription,
+ [MOVE_TOXIC - 1] = sToxicMoveDescription,
+ [MOVE_CONFUSION - 1] = sConfusionMoveDescription,
+ [MOVE_PSYCHIC - 1] = sPsychicMoveDescription,
+ [MOVE_HYPNOSIS - 1] = sHypnosisMoveDescription,
+ [MOVE_MEDITATE - 1] = sMeditateMoveDescription,
+ [MOVE_AGILITY - 1] = sAgilityMoveDescription,
+ [MOVE_QUICK_ATTACK - 1] = sQuickAttackMoveDescription,
+ [MOVE_RAGE - 1] = sRageMoveDescription,
+ [MOVE_TELEPORT - 1] = sTeleportMoveDescription,
+ [MOVE_NIGHT_SHADE - 1] = sNightShadeMoveDescription,
+ [MOVE_MIMIC - 1] = sMimicMoveDescription,
+ [MOVE_SCREECH - 1] = sScreechMoveDescription,
+ [MOVE_DOUBLE_TEAM - 1] = sDoubleTeamMoveDescription,
+ [MOVE_RECOVER - 1] = sRecoverMoveDescription,
+ [MOVE_HARDEN - 1] = sHardenMoveDescription,
+ [MOVE_MINIMIZE - 1] = sMinimizeMoveDescription,
+ [MOVE_SMOKESCREEN - 1] = sSmokescreenMoveDescription,
+ [MOVE_CONFUSE_RAY - 1] = sConfuseRayMoveDescription,
+ [MOVE_WITHDRAW - 1] = sWithdrawMoveDescription,
+ [MOVE_DEFENSE_CURL - 1] = sDefenseCurlMoveDescription,
+ [MOVE_BARRIER - 1] = sBarrierMoveDescription,
+ [MOVE_LIGHT_SCREEN - 1] = sLightScreenMoveDescription,
+ [MOVE_HAZE - 1] = sHazeMoveDescription,
+ [MOVE_REFLECT - 1] = sReflectMoveDescription,
+ [MOVE_FOCUS_ENERGY - 1] = sFocusEnergyMoveDescription,
+ [MOVE_BIDE - 1] = sBideMoveDescription,
+ [MOVE_METRONOME - 1] = sMetronomeMoveDescription,
+ [MOVE_MIRROR_MOVE - 1] = sMirrorMoveMoveDescription,
+ [MOVE_SELF_DESTRUCT - 1] = sSelfDestructMoveDescription,
+ [MOVE_EGG_BOMB - 1] = sEggBombMoveDescription,
+ [MOVE_LICK - 1] = sLickMoveDescription,
+ [MOVE_SMOG - 1] = sSmogMoveDescription,
+ [MOVE_SLUDGE - 1] = sSludgeMoveDescription,
+ [MOVE_BONE_CLUB - 1] = sBoneClubMoveDescription,
+ [MOVE_FIRE_BLAST - 1] = sFireBlastMoveDescription,
+ [MOVE_WATERFALL - 1] = sWaterfallMoveDescription,
+ [MOVE_CLAMP - 1] = sClampMoveDescription,
+ [MOVE_SWIFT - 1] = sSwiftMoveDescription,
+ [MOVE_SKULL_BASH - 1] = sSkullBashMoveDescription,
+ [MOVE_SPIKE_CANNON - 1] = sSpikeCannonMoveDescription,
+ [MOVE_CONSTRICT - 1] = sConstrictMoveDescription,
+ [MOVE_AMNESIA - 1] = sAmnesiaMoveDescription,
+ [MOVE_KINESIS - 1] = sKinesisMoveDescription,
+ [MOVE_SOFT_BOILED - 1] = sSoftBoiledMoveDescription,
+ [MOVE_HI_JUMP_KICK - 1] = sHiJumpKickMoveDescription,
+ [MOVE_GLARE - 1] = sGlareMoveDescription,
+ [MOVE_DREAM_EATER - 1] = sDreamEaterMoveDescription,
+ [MOVE_POISON_GAS - 1] = sPoisonGasMoveDescription,
+ [MOVE_BARRAGE - 1] = sBarrageMoveDescription,
+ [MOVE_LEECH_LIFE - 1] = sLeechLifeMoveDescription,
+ [MOVE_LOVELY_KISS - 1] = sLovelyKissMoveDescription,
+ [MOVE_SKY_ATTACK - 1] = sSkyAttackMoveDescription,
+ [MOVE_TRANSFORM - 1] = sTransformMoveDescription,
+ [MOVE_BUBBLE - 1] = sBubbleMoveDescription,
+ [MOVE_DIZZY_PUNCH - 1] = sDizzyPunchMoveDescription,
+ [MOVE_SPORE - 1] = sSporeMoveDescription,
+ [MOVE_FLASH - 1] = sFlashMoveDescription,
+ [MOVE_PSYWAVE - 1] = sPsywaveMoveDescription,
+ [MOVE_SPLASH - 1] = sSplashMoveDescription,
+ [MOVE_ACID_ARMOR - 1] = sAcidArmorMoveDescription,
+ [MOVE_CRABHAMMER - 1] = sCrabhammerMoveDescription,
+ [MOVE_EXPLOSION - 1] = sExplosionMoveDescription,
+ [MOVE_FURY_SWIPES - 1] = sFurySwipesMoveDescription,
+ [MOVE_BONEMERANG - 1] = sBonemerangMoveDescription,
+ [MOVE_REST - 1] = sRestMoveDescription,
+ [MOVE_ROCK_SLIDE - 1] = sRockSlideMoveDescription,
+ [MOVE_HYPER_FANG - 1] = sHyperFangMoveDescription,
+ [MOVE_SHARPEN - 1] = sSharpenMoveDescription,
+ [MOVE_CONVERSION - 1] = sConversionMoveDescription,
+ [MOVE_TRI_ATTACK - 1] = sTriAttackMoveDescription,
+ [MOVE_SUPER_FANG - 1] = sSuperFangMoveDescription,
+ [MOVE_SLASH - 1] = sSlashMoveDescription,
+ [MOVE_SUBSTITUTE - 1] = sSubstituteMoveDescription,
+ [MOVE_STRUGGLE - 1] = sStruggleMoveDescription,
+ [MOVE_SKETCH - 1] = sSketchMoveDescription,
+ [MOVE_TRIPLE_KICK - 1] = sTripleKickMoveDescription,
+ [MOVE_THIEF - 1] = sThiefMoveDescription,
+ [MOVE_SPIDER_WEB - 1] = sSpiderWebMoveDescription,
+ [MOVE_MIND_READER - 1] = sMindReaderMoveDescription,
+ [MOVE_NIGHTMARE - 1] = sNightmareMoveDescription,
+ [MOVE_FLAME_WHEEL - 1] = sFlameWheelMoveDescription,
+ [MOVE_SNORE - 1] = sSnoreMoveDescription,
+ [MOVE_CURSE - 1] = sCurseMoveDescription,
+ [MOVE_FLAIL - 1] = sFlailMoveDescription,
+ [MOVE_CONVERSION_2 - 1] = sConversion2MoveDescription,
+ [MOVE_AEROBLAST - 1] = sAeroblastMoveDescription,
+ [MOVE_COTTON_SPORE - 1] = sCottonSporeMoveDescription,
+ [MOVE_REVERSAL - 1] = sReversalMoveDescription,
+ [MOVE_SPITE - 1] = sSpiteMoveDescription,
+ [MOVE_POWDER_SNOW - 1] = sPowderSnowMoveDescription,
+ [MOVE_PROTECT - 1] = sProtectMoveDescription,
+ [MOVE_MACH_PUNCH - 1] = sMachPunchMoveDescription,
+ [MOVE_SCARY_FACE - 1] = sScaryFaceMoveDescription,
+ [MOVE_FAINT_ATTACK - 1] = sFaintAttackMoveDescription,
+ [MOVE_SWEET_KISS - 1] = sSweetKissMoveDescription,
+ [MOVE_BELLY_DRUM - 1] = sBellyDrumMoveDescription,
+ [MOVE_SLUDGE_BOMB - 1] = sSludgeBombMoveDescription,
+ [MOVE_MUD_SLAP - 1] = sMudSlapMoveDescription,
+ [MOVE_OCTAZOOKA - 1] = sOctazookaMoveDescription,
+ [MOVE_SPIKES - 1] = sSpikesMoveDescription,
+ [MOVE_ZAP_CANNON - 1] = sZapCannonMoveDescription,
+ [MOVE_FORESIGHT - 1] = sForesightMoveDescription,
+ [MOVE_DESTINY_BOND - 1] = sDestinyBondMoveDescription,
+ [MOVE_PERISH_SONG - 1] = sPerishSongMoveDescription,
+ [MOVE_ICY_WIND - 1] = sIcyWindMoveDescription,
+ [MOVE_DETECT - 1] = sDetectMoveDescription,
+ [MOVE_BONE_RUSH - 1] = sBoneRushMoveDescription,
+ [MOVE_LOCK_ON - 1] = sLockOnMoveDescription,
+ [MOVE_OUTRAGE - 1] = sOutrageMoveDescription,
+ [MOVE_SANDSTORM - 1] = sSandstormMoveDescription,
+ [MOVE_GIGA_DRAIN - 1] = sGigaDrainMoveDescription,
+ [MOVE_ENDURE - 1] = sEndureMoveDescription,
+ [MOVE_CHARM - 1] = sCharmMoveDescription,
+ [MOVE_ROLLOUT - 1] = sRolloutMoveDescription,
+ [MOVE_FALSE_SWIPE - 1] = sFalseSwipeMoveDescription,
+ [MOVE_SWAGGER - 1] = sSwaggerMoveDescription,
+ [MOVE_MILK_DRINK - 1] = sMilkDrinkMoveDescription,
+ [MOVE_SPARK - 1] = sSparkMoveDescription,
+ [MOVE_FURY_CUTTER - 1] = sFuryCutterMoveDescription,
+ [MOVE_STEEL_WING - 1] = sSteelWingMoveDescription,
+ [MOVE_MEAN_LOOK - 1] = sMeanLookMoveDescription,
+ [MOVE_ATTRACT - 1] = sAttractMoveDescription,
+ [MOVE_SLEEP_TALK - 1] = sSleepTalkMoveDescription,
+ [MOVE_HEAL_BELL - 1] = sHealBellMoveDescription,
+ [MOVE_RETURN - 1] = sReturnMoveDescription,
+ [MOVE_PRESENT - 1] = sPresentMoveDescription,
+ [MOVE_FRUSTRATION - 1] = sFrustrationMoveDescription,
+ [MOVE_SAFEGUARD - 1] = sSafeguardMoveDescription,
+ [MOVE_PAIN_SPLIT - 1] = sPainSplitMoveDescription,
+ [MOVE_SACRED_FIRE - 1] = sSacredFireMoveDescription,
+ [MOVE_MAGNITUDE - 1] = sMagnitudeMoveDescription,
+ [MOVE_DYNAMIC_PUNCH - 1] = sDynamicPunchMoveDescription,
+ [MOVE_MEGAHORN - 1] = sMegahornMoveDescription,
+ [MOVE_DRAGON_BREATH - 1] = sDragonBreathMoveDescription,
+ [MOVE_BATON_PASS - 1] = sBatonPassMoveDescription,
+ [MOVE_ENCORE - 1] = sEncoreMoveDescription,
+ [MOVE_PURSUIT - 1] = sPursuitMoveDescription,
+ [MOVE_RAPID_SPIN - 1] = sRapidSpinMoveDescription,
+ [MOVE_SWEET_SCENT - 1] = sSweetScentMoveDescription,
+ [MOVE_IRON_TAIL - 1] = sIronTailMoveDescription,
+ [MOVE_METAL_CLAW - 1] = sMetalClawMoveDescription,
+ [MOVE_VITAL_THROW - 1] = sVitalThrowMoveDescription,
+ [MOVE_MORNING_SUN - 1] = sMorningSunMoveDescription,
+ [MOVE_SYNTHESIS - 1] = sSynthesisMoveDescription,
+ [MOVE_MOONLIGHT - 1] = sMoonlightMoveDescription,
+ [MOVE_HIDDEN_POWER - 1] = sHiddenPowerMoveDescription,
+ [MOVE_CROSS_CHOP - 1] = sCrossChopMoveDescription,
+ [MOVE_TWISTER - 1] = sTwisterMoveDescription,
+ [MOVE_RAIN_DANCE - 1] = sRainDanceMoveDescription,
+ [MOVE_SUNNY_DAY - 1] = sSunnyDayMoveDescription,
+ [MOVE_CRUNCH - 1] = sCrunchMoveDescription,
+ [MOVE_MIRROR_COAT - 1] = sMirrorCoatMoveDescription,
+ [MOVE_PSYCH_UP - 1] = sPsychUpMoveDescription,
+ [MOVE_EXTREME_SPEED - 1] = sExtremeSpeedMoveDescription,
+ [MOVE_ANCIENT_POWER - 1] = sAncientPowerMoveDescription,
+ [MOVE_SHADOW_BALL - 1] = sShadowBallMoveDescription,
+ [MOVE_FUTURE_SIGHT - 1] = sFutureSightMoveDescription,
+ [MOVE_ROCK_SMASH - 1] = sRockSmashMoveDescription,
+ [MOVE_WHIRLPOOL - 1] = sWhirlpoolMoveDescription,
+ [MOVE_BEAT_UP - 1] = sBeatUpMoveDescription,
+ [MOVE_FAKE_OUT - 1] = sFakeOutMoveDescription,
+ [MOVE_UPROAR - 1] = sUproarMoveDescription,
+ [MOVE_STOCKPILE - 1] = sStockpileMoveDescription,
+ [MOVE_SPIT_UP - 1] = sSpitUpMoveDescription,
+ [MOVE_SWALLOW - 1] = sSwallowMoveDescription,
+ [MOVE_HEAT_WAVE - 1] = sHeatWaveMoveDescription,
+ [MOVE_HAIL - 1] = sHailMoveDescription,
+ [MOVE_TORMENT - 1] = sTormentMoveDescription,
+ [MOVE_FLATTER - 1] = sFlatterMoveDescription,
+ [MOVE_WILL_O_WISP - 1] = sWillOWispMoveDescription,
+ [MOVE_MEMENTO - 1] = sMementoMoveDescription,
+ [MOVE_FACADE - 1] = sFacadeMoveDescription,
+ [MOVE_FOCUS_PUNCH - 1] = sFocusPunchMoveDescription,
+ [MOVE_SMELLING_SALT - 1] = sSmellingSaltMoveDescription,
+ [MOVE_FOLLOW_ME - 1] = sFollowMeMoveDescription,
+ [MOVE_NATURE_POWER - 1] = sNaturePowerMoveDescription,
+ [MOVE_CHARGE - 1] = sChargeMoveDescription,
+ [MOVE_TAUNT - 1] = sTauntMoveDescription,
+ [MOVE_HELPING_HAND - 1] = sHelpingHandMoveDescription,
+ [MOVE_TRICK - 1] = sTrickMoveDescription,
+ [MOVE_ROLE_PLAY - 1] = sRolePlayMoveDescription,
+ [MOVE_WISH - 1] = sWishMoveDescription,
+ [MOVE_ASSIST - 1] = sAssistMoveDescription,
+ [MOVE_INGRAIN - 1] = sIngrainMoveDescription,
+ [MOVE_SUPERPOWER - 1] = sSuperpowerMoveDescription,
+ [MOVE_MAGIC_COAT - 1] = sMagicCoatMoveDescription,
+ [MOVE_RECYCLE - 1] = sRecycleMoveDescription,
+ [MOVE_REVENGE - 1] = sRevengeMoveDescription,
+ [MOVE_BRICK_BREAK - 1] = sBrickBreakMoveDescription,
+ [MOVE_YAWN - 1] = sYawnMoveDescription,
+ [MOVE_KNOCK_OFF - 1] = sKnockOffMoveDescription,
+ [MOVE_ENDEAVOR - 1] = sEndeavorMoveDescription,
+ [MOVE_ERUPTION - 1] = sEruptionMoveDescription,
+ [MOVE_SKILL_SWAP - 1] = sSkillSwapMoveDescription,
+ [MOVE_IMPRISON - 1] = sImprisonMoveDescription,
+ [MOVE_REFRESH - 1] = sRefreshMoveDescription,
+ [MOVE_GRUDGE - 1] = sGrudgeMoveDescription,
+ [MOVE_SNATCH - 1] = sSnatchMoveDescription,
+ [MOVE_SECRET_POWER - 1] = sSecretPowerMoveDescription,
+ [MOVE_DIVE - 1] = sDiveMoveDescription,
+ [MOVE_ARM_THRUST - 1] = sArmThrustMoveDescription,
+ [MOVE_CAMOUFLAGE - 1] = sCamouflageMoveDescription,
+ [MOVE_TAIL_GLOW - 1] = sTailGlowMoveDescription,
+ [MOVE_LUSTER_PURGE - 1] = sLusterPurgeMoveDescription,
+ [MOVE_MIST_BALL - 1] = sMistBallMoveDescription,
+ [MOVE_FEATHER_DANCE - 1] = sFeatherDanceMoveDescription,
+ [MOVE_TEETER_DANCE - 1] = sTeeterDanceMoveDescription,
+ [MOVE_BLAZE_KICK - 1] = sBlazeKickMoveDescription,
+ [MOVE_MUD_SPORT - 1] = sMudSportMoveDescription,
+ [MOVE_ICE_BALL - 1] = sIceBallMoveDescription,
+ [MOVE_NEEDLE_ARM - 1] = sNeedleArmMoveDescription,
+ [MOVE_SLACK_OFF - 1] = sSlackOffMoveDescription,
+ [MOVE_HYPER_VOICE - 1] = sHyperVoiceMoveDescription,
+ [MOVE_POISON_FANG - 1] = sPoisonFangMoveDescription,
+ [MOVE_CRUSH_CLAW - 1] = sCrushClawMoveDescription,
+ [MOVE_BLAST_BURN - 1] = sBlastBurnMoveDescription,
+ [MOVE_HYDRO_CANNON - 1] = sHydroCannonMoveDescription,
+ [MOVE_METEOR_MASH - 1] = sMeteorMashMoveDescription,
+ [MOVE_ASTONISH - 1] = sAstonishMoveDescription,
+ [MOVE_WEATHER_BALL - 1] = sWeatherBallMoveDescription,
+ [MOVE_AROMATHERAPY - 1] = sAromatherapyMoveDescription,
+ [MOVE_FAKE_TEARS - 1] = sFakeTearsMoveDescription,
+ [MOVE_AIR_CUTTER - 1] = sAirCutterMoveDescription,
+ [MOVE_OVERHEAT - 1] = sOverheatMoveDescription,
+ [MOVE_ODOR_SLEUTH - 1] = sOdorSleuthMoveDescription,
+ [MOVE_ROCK_TOMB - 1] = sRockTombMoveDescription,
+ [MOVE_SILVER_WIND - 1] = sSilverWindMoveDescription,
+ [MOVE_METAL_SOUND - 1] = sMetalSoundMoveDescription,
+ [MOVE_GRASS_WHISTLE - 1] = sGrassWhistleMoveDescription,
+ [MOVE_TICKLE - 1] = sTickleMoveDescription,
+ [MOVE_COSMIC_POWER - 1] = sCosmicPowerMoveDescription,
+ [MOVE_WATER_SPOUT - 1] = sWaterSpoutMoveDescription,
+ [MOVE_SIGNAL_BEAM - 1] = sSignalBeamMoveDescription,
+ [MOVE_SHADOW_PUNCH - 1] = sShadowPunchMoveDescription,
+ [MOVE_EXTRASENSORY - 1] = sExtrasensoryMoveDescription,
+ [MOVE_SKY_UPPERCUT - 1] = sSkyUppercutMoveDescription,
+ [MOVE_SAND_TOMB - 1] = sSandTombMoveDescription,
+ [MOVE_SHEER_COLD - 1] = sSheerColdMoveDescription,
+ [MOVE_MUDDY_WATER - 1] = sMuddyWaterMoveDescription,
+ [MOVE_BULLET_SEED - 1] = sBulletSeedMoveDescription,
+ [MOVE_AERIAL_ACE - 1] = sAerialAceMoveDescription,
+ [MOVE_ICICLE_SPEAR - 1] = sIcicleSpearMoveDescription,
+ [MOVE_IRON_DEFENSE - 1] = sIronDefenseMoveDescription,
+ [MOVE_BLOCK - 1] = sBlockMoveDescription,
+ [MOVE_HOWL - 1] = sHowlMoveDescription,
+ [MOVE_DRAGON_CLAW - 1] = sDragonClawMoveDescription,
+ [MOVE_FRENZY_PLANT - 1] = sFrenzyPlantMoveDescription,
+ [MOVE_BULK_UP - 1] = sBulkUpMoveDescription,
+ [MOVE_BOUNCE - 1] = sBounceMoveDescription,
+ [MOVE_MUD_SHOT - 1] = sMudShotMoveDescription,
+ [MOVE_POISON_TAIL - 1] = sPoisonTailMoveDescription,
+ [MOVE_COVET - 1] = sCovetMoveDescription,
+ [MOVE_VOLT_TACKLE - 1] = sVoltTackleMoveDescription,
+ [MOVE_MAGICAL_LEAF - 1] = sMagicalLeafMoveDescription,
+ [MOVE_WATER_SPORT - 1] = sWaterSportMoveDescription,
+ [MOVE_CALM_MIND - 1] = sCalmMindMoveDescription,
+ [MOVE_LEAF_BLADE - 1] = sLeafBladeMoveDescription,
+ [MOVE_DRAGON_DANCE - 1] = sDragonDanceMoveDescription,
+ [MOVE_ROCK_BLAST - 1] = sRockBlastMoveDescription,
+ [MOVE_SHOCK_WAVE - 1] = sShockWaveMoveDescription,
+ [MOVE_WATER_PULSE - 1] = sWaterPulseMoveDescription,
+ [MOVE_DOOM_DESIRE - 1] = sDoomDesireMoveDescription,
+ [MOVE_PSYCHO_BOOST - 1] = sPsychoBoostMoveDescription,
+};
diff --git a/src/data/text/move_names.h b/src/data/text/move_names.h
index 3df7c886b..9f540f1d6 100644
--- a/src/data/text/move_names.h
+++ b/src/data/text/move_names.h
@@ -1,4 +1,5 @@
-const u8 gMoveNames[][13] = {
+const u8 gMoveNames[MOVES_COUNT][MOVE_NAME_LENGTH + 1] =
+{
[MOVE_NONE] = _("-"),
[MOVE_POUND] = _("POUND"),
[MOVE_KARATE_CHOP] = _("KARATE CHOP"),
diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c
new file mode 100644
index 000000000..6ab721643
--- /dev/null
+++ b/src/field_player_avatar.c
@@ -0,0 +1,581 @@
+#include "global.h"
+#include "global.fieldmap.h"
+#include "sprite.h"
+#include "event_object_movement.h"
+#include "bike.h"
+#include "metatile_behavior.h"
+#include "metatile_behaviors.h"
+#include "constants/flags.h"
+#include "event_data.h"
+#include "fieldmap.h"
+#include "overworld.h"
+#include "rotating_gate.h"
+#include "constants/event_object_movement_constants.h"
+#include "field_player_avatar.h"
+
+extern void task_add_bump_boulder(u8, u8);
+static bool8 ShouldJumpLedge(s16, s16, u8);
+static bool8 sub_808B1BC(s16, s16, u8);
+static u8 sub_808B164(struct EventObject *, s16, s16, u8, u8);
+static u8 sub_808B238(s16, s16, u8);
+static void check_acro_bike_metatile(s16, s16, u8, u8 *);
+extern void PlayerNotOnBikeCollide(u8);
+extern void PlayerNotOnBikeCollideWithFarawayIslandMew(u8);
+extern void PlayerRun(u8);
+static void MovePlayerNotOnBike(u8, u16);
+static u8 CheckMovementInputNotOnBike(u8);
+extern void sub_808C5B0(void);
+extern void sub_808C4D8(void);
+static u8 CheckForPlayerAvatarCollision(u8);
+static u8 EventObjectCB2_NoMovement2();
+extern void sub_808C280(struct EventObject *);
+static bool8 TryInterruptEventObjectSpecialAnim(struct EventObject *, u8);
+void npc_clear_strange_bits(struct EventObject *);
+extern void DoPlayerAvatarTransition(void);
+static bool8 TryDoMetatileBehaviorForcedMovement();
+static void MovePlayerAvatarUsingKeypadInput(u8, u16, u16);
+static void PlayerAllowForcedMovementIfMovingSameDirection();
+static u8 sub_808B028(u8);
+static u8 GetForcedMovementByMetatileBehavior();
+static void PlayerNotOnBikeNotMoving(u8, u16);
+static void PlayerNotOnBikeTurningInPlace(u8, u16);
+static void PlayerNotOnBikeMoving(u8, u16);
+extern void sub_808C750(u8);
+
+static bool8 (*const gUnknown_084973FC[])(u8) =
+{
+ MetatileBehavior_IsTrickHouseSlipperyFloor,
+ MetatileBehavior_IsIce_2,
+ MetatileBehavior_IsWalkSouth,
+ MetatileBehavior_IsWalkNorth,
+ MetatileBehavior_IsWalkWest,
+ MetatileBehavior_IsWalkEast,
+ MetatileBehavior_IsSouthwardCurrent,
+ MetatileBehavior_IsNorthwardCurrent,
+ MetatileBehavior_IsWestwardCurrent,
+ MetatileBehavior_IsEastwardCurrent,
+ MetatileBehavior_IsSlideSouth,
+ MetatileBehavior_IsSlideNorth,
+ MetatileBehavior_IsSlideWest,
+ MetatileBehavior_IsSlideEast,
+ MetatileBehavior_IsWaterfall,
+ MetatileBehavior_IsSecretBaseJumpMat,
+ MetatileBehavior_IsSecretBaseSpinMat,
+ MetatileBehavior_IsMuddySlope,
+};
+
+static bool8 (*const gUnknown_08497444[])(void) =
+{
+ ForcedMovement_None,
+ ForcedMovement_Slip,
+ ForcedMovement_Slip,
+ ForcedMovement_WalkSouth,
+ ForcedMovement_WalkNorth,
+ ForcedMovement_WalkWest,
+ ForcedMovement_WalkEast,
+ ForcedMovement_PushedSouthByCurrent,
+ ForcedMovement_PushedNorthByCurrent,
+ ForcedMovement_PushedWestByCurrent,
+ ForcedMovement_PushedEastByCurrent,
+ ForcedMovement_SlideSouth,
+ ForcedMovement_SlideNorth,
+ ForcedMovement_SlideWest,
+ ForcedMovement_SlideEast,
+ ForcedMovement_PushedSouthByCurrent,
+ ForcedMovement_0xBB,
+ ForcedMovement_0xBC,
+ ForcedMovement_MuddySlope,
+};
+
+static void (*const gUnknown_08497490[])(u8, u16) =
+{
+ PlayerNotOnBikeNotMoving,
+ PlayerNotOnBikeTurningInPlace,
+ PlayerNotOnBikeMoving,
+};
+
+static bool8 (*const gUnknown_0849749C[])(u8) =
+{
+ MetatileBehavior_IsBumpySlope,
+ MetatileBehavior_IsIsolatedVerticalRail,
+ MetatileBehavior_IsIsolatedHorizontalRail,
+ MetatileBehavior_IsVerticalRail,
+ MetatileBehavior_IsHorizontalRail,
+};
+
+static const u8 gUnknown_084974B0[] = {9, 10, 11, 12, 13, 0, 0, 0};
+
+void MovementType_Player(struct Sprite *sprite)
+{
+ UpdateEventObjectCurrentMovement(&gEventObjects[sprite->data[0]], sprite, EventObjectCB2_NoMovement2);
+}
+
+static u8 EventObjectCB2_NoMovement2()
+{
+ return 0;
+}
+
+void player_step(u8 direction, u16 newKeys, u16 heldKeys)
+{
+ struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
+
+ sub_808C280(playerEventObj);
+ if (gPlayerAvatar.preventStep == FALSE)
+ {
+ Bike_TryAcroBikeHistoryUpdate(newKeys, heldKeys);
+ if (TryInterruptEventObjectSpecialAnim(playerEventObj, direction) == 0)
+ {
+ npc_clear_strange_bits(playerEventObj);
+ DoPlayerAvatarTransition();
+ if (TryDoMetatileBehaviorForcedMovement() == 0)
+ {
+ MovePlayerAvatarUsingKeypadInput(direction, newKeys, heldKeys);
+ PlayerAllowForcedMovementIfMovingSameDirection();
+ }
+ }
+ }
+}
+
+static bool8 TryInterruptEventObjectSpecialAnim(struct EventObject *playerEventObj, u8 direction)
+{
+ #ifdef NONMATCHING
+ u8 r5 = direction;
+ u8 r6 = direction;
+ #else
+ u8 r5 = direction;
+ register u8 r6 asm("r6") = direction;
+ #endif
+ //a very bad HACK
+
+ if (EventObjectIsMovementOverridden(playerEventObj)
+ && !EventObjectClearHeldMovementIfFinished(playerEventObj))
+ {
+ u8 heldMovementActionId = EventObjectGetHeldMovementActionId(playerEventObj);
+ if (heldMovementActionId > MOVEMENT_ACTION_WALK_FAST_RIGHT && heldMovementActionId < MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_DOWN)
+ {
+ if (direction == DIR_NONE)
+ {
+ return TRUE;
+ }
+
+ if (playerEventObj->movementDirection != r5)
+ {
+ EventObjectClearHeldMovement(playerEventObj);
+ return FALSE;
+ }
+
+ if (!sub_808B028(r6))
+ {
+ EventObjectClearHeldMovement(playerEventObj);
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+void npc_clear_strange_bits(struct EventObject *eventObj)
+{
+ eventObj->inanimate = 0;
+ eventObj->disableAnim = 0;
+ eventObj->facingDirectionLocked = 0;
+ gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_DASH;
+}
+
+static void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 heldKeys)
+{
+ if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE)
+ || (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE))
+ MovePlayerOnBike(direction, newKeys, heldKeys);
+ else
+ MovePlayerNotOnBike(direction, heldKeys);
+}
+
+static void PlayerAllowForcedMovementIfMovingSameDirection(void)
+{
+ if (gPlayerAvatar.runningState == MOVING)
+ gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_5;
+}
+
+static bool8 TryDoMetatileBehaviorForcedMovement()
+{
+ return gUnknown_08497444[GetForcedMovementByMetatileBehavior()]();
+}
+
+static u8 GetForcedMovementByMetatileBehavior(void)
+{
+ u8 i;
+
+ if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_5))
+ {
+ u8 metatileBehavior = gEventObjects[gPlayerAvatar.eventObjectId].currentMetatileBehavior;
+
+ for (i = 0; i < 18; i++)
+ {
+ if (gUnknown_084973FC[i](metatileBehavior))
+ return i + 1;
+ }
+ }
+ return 0;
+}
+
+bool8 ForcedMovement_None(void)
+{
+ if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_6)
+ {
+ struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
+
+ playerEventObj->facingDirectionLocked = 0;
+ playerEventObj->enableAnim = 1;
+ SetEventObjectDirection(playerEventObj, playerEventObj->facingDirection);
+ gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_6;
+ }
+ return FALSE;
+}
+
+static u8 DoForcedMovement(u8 direction, void (*b)(u8))
+{
+ struct PlayerAvatar *playerAvatar = &gPlayerAvatar;
+ u8 collisionType = CheckForPlayerAvatarCollision(direction);
+
+ playerAvatar->flags |= PLAYER_AVATAR_FLAG_6;
+ if (collisionType != 0)
+ {
+ ForcedMovement_None();
+ if (collisionType <= 4)
+ {
+ return 0;
+ }
+ else
+ {
+ if (collisionType == COLLISION_LEDGE_JUMP)
+ PlayerJumpLedge(direction);
+ playerAvatar->flags |= PLAYER_AVATAR_FLAG_6;
+ playerAvatar->runningState = MOVING;
+ return 1;
+ }
+ }
+ else
+ {
+ playerAvatar->runningState = MOVING;
+ b(direction);
+ return 1;
+ }
+}
+
+u8 DoForcedMovementInCurrentDirection(void (*a)(u8))
+{
+ struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
+
+ playerEventObj->disableAnim = 1;
+ return DoForcedMovement(playerEventObj->movementDirection, a);
+}
+
+bool8 ForcedMovement_Slip(void)
+{
+ return DoForcedMovementInCurrentDirection(PlayerGoSpeed2);
+}
+
+bool8 ForcedMovement_WalkSouth(void)
+{
+ return DoForcedMovement(DIR_SOUTH, PlayerGoSpeed1);
+}
+
+bool8 ForcedMovement_WalkNorth(void)
+{
+ return DoForcedMovement(DIR_NORTH, PlayerGoSpeed1);
+}
+
+bool8 ForcedMovement_WalkWest(void)
+{
+ return DoForcedMovement(DIR_WEST, PlayerGoSpeed1);
+}
+
+bool8 ForcedMovement_WalkEast(void)
+{
+ return DoForcedMovement(DIR_EAST, PlayerGoSpeed1);
+}
+
+bool8 ForcedMovement_PushedSouthByCurrent(void)
+{
+ return DoForcedMovement(DIR_SOUTH, PlayerGoSpeed3);
+}
+
+bool8 ForcedMovement_PushedNorthByCurrent(void)
+{
+ return DoForcedMovement(DIR_NORTH, PlayerGoSpeed3);
+}
+
+bool8 ForcedMovement_PushedWestByCurrent(void)
+{
+ return DoForcedMovement(DIR_WEST, PlayerGoSpeed3);
+}
+
+bool8 ForcedMovement_PushedEastByCurrent(void)
+{
+ return DoForcedMovement(DIR_EAST, PlayerGoSpeed3);
+}
+
+u8 ForcedMovement_Slide(u8 direction, void (*b)(u8))
+{
+ struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
+
+ playerEventObj->disableAnim = 1;
+ playerEventObj->facingDirectionLocked = 1;
+ return DoForcedMovement(direction, b);
+}
+
+bool8 ForcedMovement_SlideSouth(void)
+{
+ return ForcedMovement_Slide(DIR_SOUTH, PlayerGoSpeed2);
+}
+
+bool8 ForcedMovement_SlideNorth(void)
+{
+ return ForcedMovement_Slide(DIR_NORTH, PlayerGoSpeed2);
+}
+
+bool8 ForcedMovement_SlideWest(void)
+{
+ return ForcedMovement_Slide(DIR_WEST, PlayerGoSpeed2);
+}
+
+bool8 ForcedMovement_SlideEast(void)
+{
+ return ForcedMovement_Slide(DIR_EAST, PlayerGoSpeed2);
+}
+
+bool8 ForcedMovement_0xBB(void)
+{
+ sub_808C4D8();
+ return TRUE;
+}
+
+bool8 ForcedMovement_0xBC(void)
+{
+ sub_808C5B0();
+ return TRUE;
+}
+
+bool8 ForcedMovement_MuddySlope(void)
+{
+ struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
+
+ if (playerEventObj->movementDirection != DIR_NORTH || GetPlayerSpeed() <= 3)
+ {
+ Bike_UpdateBikeCounterSpeed(0);
+ playerEventObj->facingDirectionLocked = 1;
+ return DoForcedMovement(1, PlayerGoSpeed2);
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+static void MovePlayerNotOnBike(u8 direction, u16 heldKeys)
+{
+ gUnknown_08497490[CheckMovementInputNotOnBike(direction)](direction, heldKeys);
+}
+
+static u8 CheckMovementInputNotOnBike(u8 direction)
+{
+ if (direction == DIR_NONE)
+ {
+ gPlayerAvatar.runningState = NOT_MOVING;
+ return 0;
+ }
+ else if (direction != GetPlayerMovementDirection() && gPlayerAvatar.runningState != MOVING)
+ {
+ gPlayerAvatar.runningState = TURN_DIRECTION;
+ return 1;
+ }
+ else
+ {
+ gPlayerAvatar.runningState = MOVING;
+ return 2;
+ }
+}
+
+static void PlayerNotOnBikeNotMoving(u8 direction, u16 heldKeys)
+{
+ PlayerFaceDirection(GetPlayerFacingDirection());
+}
+
+static void PlayerNotOnBikeTurningInPlace(u8 direction, u16 heldKeys)
+{
+ PlayerTurnInPlace(direction);
+}
+
+static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys)
+{
+ u8 r0 = CheckForPlayerAvatarCollision(direction);
+
+ if (r0 != 0)
+ {
+ if (r0 == 6)
+ {
+ PlayerJumpLedge(direction);
+ return;
+ }
+ else if (r0 == 4 && IsPlayerCollidingWithFarawayIslandMew(direction) != 0)
+ {
+ PlayerNotOnBikeCollideWithFarawayIslandMew(direction);
+ return;
+ }
+ else
+ {
+ u8 r4 = r0 - 5;
+
+ if (r4 > 3)
+ {
+ PlayerNotOnBikeCollide(direction);
+ return;
+ }
+ else
+ {
+ return;
+ }
+ }
+ }
+
+ if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
+ {
+ // speed 2 is fast, same speed as running
+ PlayerGoSpeed2(direction);
+ return;
+ }
+
+ if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_4) && (heldKeys & B_BUTTON) && FlagGet(FLAG_SYS_B_DASH)
+ && IsRunningDisallowed(gEventObjects[gPlayerAvatar.eventObjectId].currentMetatileBehavior) == 0)
+ {
+ PlayerRun(direction);
+ gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_DASH;
+ return;
+ }
+ else
+ {
+ PlayerGoSpeed1(direction);
+ }
+}
+
+static u8 CheckForPlayerAvatarCollision(u8 direction)
+{
+ s16 x, y;
+ struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
+
+ x = playerEventObj->currentCoords.x;
+ y = playerEventObj->currentCoords.y;
+ MoveCoords(direction, &x, &y);
+ return CheckForEventObjectCollision(playerEventObj, x, y, direction, MapGridGetMetatileBehaviorAt(x, y));
+}
+
+static u8 sub_808B028(u8 direction)
+{
+ s16 x, y;
+ struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
+
+ x = playerEventObj->currentCoords.x;
+ y = playerEventObj->currentCoords.y;
+ MoveCoords(direction, &x, &y);
+ return sub_808B164(playerEventObj, x, y, direction, MapGridGetMetatileBehaviorAt(x, y));
+}
+
+u8 CheckForEventObjectCollision(struct EventObject *a, s16 x, s16 y, u8 direction, u8 e)
+{
+ u8 collision;
+
+ collision = GetCollisionAtCoords(a, x, y, direction);
+ if (collision == 3 && sub_808B1BC(x, y, direction))
+ return 5;
+ if (ShouldJumpLedge(x, y, direction))
+ {
+ IncrementGameStat(GAME_STAT_JUMPED_DOWN_LEDGES);
+ return COLLISION_LEDGE_JUMP;
+ }
+ if (collision == 4 && sub_808B238(x, y, direction))
+ return 7;
+
+ if (collision == 0)
+ {
+ if (CheckForRotatingGatePuzzleCollision(direction, x, y))
+ return 8;
+ check_acro_bike_metatile(x, y, e, &collision);
+ }
+ return collision;
+}
+
+static u8 sub_808B164(struct EventObject *a, s16 x, s16 y, u8 direction, u8 e)
+{
+ u8 collision = GetCollisionAtCoords(a, x, y, direction);
+
+ if (collision == 0)
+ {
+ if (CheckForRotatingGatePuzzleCollisionWithoutAnimation(direction, x, y) != 0)
+ return 8;
+ check_acro_bike_metatile(x, y, e, &collision);
+ }
+ return collision;
+}
+
+static bool8 sub_808B1BC(s16 x, s16 y, u8 direction)
+{
+ if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
+ && MapGridGetZCoordAt(x, y) == 3
+ && GetEventObjectIdByXYZ(x, y, 3) == 16)
+ {
+ sub_808C750(direction);
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+static bool8 ShouldJumpLedge(s16 x, s16 y, u8 z)
+{
+ if (GetLedgeJumpDirection(x, y, z) != 0)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+static u8 sub_808B238(s16 x, s16 y, u8 direction)
+{
+ if (FlagGet(FLAG_SYS_USE_STRENGTH))
+ {
+ u8 eventObjectId = GetEventObjectIdByXY(x, y);
+
+ if (eventObjectId != 16 && gEventObjects[eventObjectId].graphicsId == 0x57)
+ {
+ x = gEventObjects[eventObjectId].currentCoords.x;
+ y = gEventObjects[eventObjectId].currentCoords.y;
+ MoveCoords(direction, &x, &y);
+ if (GetCollisionAtCoords(&gEventObjects[eventObjectId], x, y, direction) == 0
+ && MetatileBehavior_IsNonAnimDoor(MapGridGetMetatileBehaviorAt(x, y)) == 0)
+ {
+ task_add_bump_boulder(eventObjectId, direction);
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+static void check_acro_bike_metatile(s16 unused1, s16 unused2, u8 c, u8 *d)
+{
+ u8 i;
+
+ for (i = 0; i < 5; i++)
+ {
+ if (gUnknown_0849749C[i](c))
+ {
+ *d = gUnknown_084974B0[i];
+ return;
+ }
+ }
+}
diff --git a/src/field_region_map.c b/src/field_region_map.c
index 34b6089df..f56548068 100644
--- a/src/field_region_map.c
+++ b/src/field_region_map.c
@@ -63,7 +63,7 @@ static const struct WindowTemplate gUnknown_085E5070[] = {
// .text
-void sub_817018C(MainCallback callback)
+void FieldInitRegionMap(MainCallback callback)
{
SetVBlankCallback(NULL);
sFieldRegionMapHandler = malloc(sizeof(*sFieldRegionMapHandler));
diff --git a/src/field_special_scene.c b/src/field_special_scene.c
index 39977808f..6f33b2c9b 100644
--- a/src/field_special_scene.c
+++ b/src/field_special_scene.c
@@ -272,7 +272,7 @@ bool8 sub_80FB59C(void)
void Task_HandlePorthole(u8 taskId)
{
s16 *data = gTasks[taskId].data;
- u16 *var = GetVarPointer(VAR_PORTHOLE);
+ u16 *var = GetVarPointer(VAR_PORTHOLE_STATE);
struct WarpData *location = &gSaveBlock1Ptr->location;
switch (data[0])
diff --git a/src/field_specials.c b/src/field_specials.c
new file mode 100644
index 000000000..897bcc8d7
--- /dev/null
+++ b/src/field_specials.c
@@ -0,0 +1,4329 @@
+#include "global.h"
+#include "main.h"
+#include "battle.h"
+#include "battle_tower.h"
+#include "cable_club.h"
+#include "data2.h"
+#include "decoration.h"
+#include "diploma.h"
+#include "event_data.h"
+#include "event_object_movement.h"
+#include "fieldmap.h"
+#include "field_camera.h"
+#include "field_effect.h"
+#include "field_message_box.h"
+#include "field_player_avatar.h"
+#include "field_region_map.h"
+#include "field_screen.h"
+#include "field_specials.h"
+#include "field_weather.h"
+#include "international_string_util.h"
+#include "item_icon.h"
+#include "link.h"
+#include "list_menu.h"
+#include "malloc.h"
+#include "match_call.h"
+#include "menu.h"
+#include "overworld.h"
+#include "party_menu.h"
+#include "pokeblock.h"
+#include "pokemon.h"
+#include "pokemon_storage_system.h"
+#include "random.h"
+#include "rayquaza_scene.h"
+#include "region_map.h"
+#include "rom_8011DC0.h"
+#include "rtc.h"
+#include "script.h"
+#include "script_menu.h"
+#include "sound.h"
+#include "starter_choose.h"
+#include "string_util.h"
+#include "strings.h"
+#include "task.h"
+#include "text.h"
+#include "tv.h"
+#include "wallclock.h"
+#include "window.h"
+#include "constants/event_objects.h"
+#include "constants/items.h"
+#include "constants/maps.h"
+#include "constants/songs.h"
+#include "constants/species.h"
+#include "constants/moves.h"
+#include "constants/vars.h"
+
+EWRAM_DATA bool8 gBikeCyclingChallenge = FALSE;
+EWRAM_DATA u8 gBikeCollisions = 0;
+EWRAM_DATA u32 gBikeCyclingTimer = 0;
+EWRAM_DATA u8 gUnknown_0203AB5C = 0;
+EWRAM_DATA u8 gUnknown_0203AB5D = 0;
+EWRAM_DATA u8 gUnknown_0203AB5E = 0;
+EWRAM_DATA u16 gUnknown_0203AB60 = 0;
+EWRAM_DATA u16 gUnknown_0203AB62 = 0;
+EWRAM_DATA struct ListMenuItem *gUnknown_0203AB64 = NULL;
+EWRAM_DATA u16 gUnknown_0203AB68 = 0;
+EWRAM_DATA u16 gUnknown_0203AB6A = 0;
+EWRAM_DATA u8 gUnknown_0203AB6C = 0;
+EWRAM_DATA u8 gUnknown_0203AB6D = 0;
+EWRAM_DATA u8 gUnknown_0203AB6E = 0;
+EWRAM_DATA u8 gUnknown_0203AB6F = 0;
+EWRAM_DATA u32 gUnknown_0203AB70 = 0;
+
+struct ListMenuTemplate gUnknown_030061D0;
+
+extern const u16 gEventObjectPalette8[];
+extern const u16 gEventObjectPalette17[];
+extern const u16 gEventObjectPalette33[];
+extern const u16 gEventObjectPalette34[];
+
+extern void LoadPalette(const void *src, u32 offset, u16 size); // incorrect signature, needed to match
+extern void BlendPalettes(u32, u8, u16);
+
+void UpdateMovedLilycoveFanClubMembers(void);
+void sub_813BF60(void);
+u16 GetNumMovedLilycoveFanClubMembers(void);
+
+static void RecordCyclingRoadResults(u32, u8);
+static void LoadLinkPartnerEventObjectSpritePalette(u8 graphicsId, u8 localEventId, u8 paletteNum);
+static void Task_PetalburgGym(u8);
+static void PetalburgGymFunc(u8, u16);
+static void Task_PCTurnOnEffect(u8);
+static void PCTurnOnEffect_0(struct Task *);
+static void PCTurnOnEffect_1(s16, s8, s8);
+static void PCTurnOffEffect(void);
+static void Task_LotteryCornerComputerEffect(u8);
+static void LotteryCornerComputerEffect(struct Task *);
+static void sub_81395BC(u8 taskId);
+static void sub_8139620(u8 taskId);
+static void sub_8139AF4(u8 taskId);
+static void sub_8139C2C(u16 a1, u8 a2);
+static void sub_8139C80(u8 taskId);
+static void sub_813A2DC(u8 taskId);
+static void sub_813AA60(u16 a0, u16 a1);
+static void sub_813ACE8(u8 a0, u16 a1);
+static void sub_813A42C(void);
+static void sub_813A4EC(u8 taskId);
+static void sub_813A694(u8 taskId);
+static void sub_813A46C(s32 itemIndex, bool8 onInit, struct ListMenu *list);
+static void sub_813AC44(u16 a0, u16 a1);
+static void sub_813AD34(u8 a0, u16 a1);
+static void sub_813A570(u8 taskId);
+static void sub_813A738(u8 taskId);
+static void sub_813A600(u8 taskId);
+static void sub_813A664(u8 taskId);
+static void sub_813ABD4(u16 a0);
+static void task_deoxys_sound(u8 taskId);
+static void sub_813B0B4(u8 a0);
+static void sub_813B160(u8 taskId);
+static void sub_813B57C(u8 taskId);
+static void sub_813B824(u8 taskId);
+static void _fwalk(u8 taskId);
+static u8 sub_813BF44(void);
+static void sub_813BD84(void);
+static u16 sub_813BB74(void);
+static void sub_813BE30(struct LinkBattleRecords *linkRecords, u8 a, u8 b);
+
+void Special_ShowDiploma(void)
+{
+ SetMainCallback2(CB2_ShowDiploma);
+ ScriptContext2_Enable();
+}
+
+void Special_ViewWallClock(void)
+{
+ gMain.savedCallback = CB2_ReturnToField;
+ SetMainCallback2(CB2_ViewWallClock);
+ ScriptContext2_Enable();
+}
+
+void ResetCyclingRoadChallengeData(void)
+{
+ gBikeCyclingChallenge = FALSE;
+ gBikeCollisions = 0;
+ gBikeCyclingTimer = 0;
+}
+
+void Special_BeginCyclingRoadChallenge(void)
+{
+ gBikeCyclingChallenge = TRUE;
+ gBikeCollisions = 0;
+ gBikeCyclingTimer = gMain.vblankCounter1;
+}
+
+u16 GetPlayerAvatarBike(void)
+{
+ if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE))
+ return 1;
+ if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE))
+ return 2;
+ return 0;
+}
+
+static void DetermineCyclingRoadResults(u32 numFrames, u8 numBikeCollisions)
+{
+ u8 result;
+
+ if (numBikeCollisions < 100)
+ {
+ ConvertIntToDecimalStringN(gStringVar1, numBikeCollisions, STR_CONV_MODE_LEFT_ALIGN, 2);
+ StringAppend(gStringVar1, gText_SpaceTimes);
+ }
+ else
+ {
+ StringCopy(gStringVar1, gText_99TimesPlus);
+ }
+
+ if (numFrames < 3600)
+ {
+ ConvertIntToDecimalStringN(gStringVar2, numFrames / 60, STR_CONV_MODE_RIGHT_ALIGN, 2);
+ gStringVar2[2] = CHAR_PERIOD;
+ ConvertIntToDecimalStringN(&gStringVar2[3], ((numFrames % 60) * 100) / 60, STR_CONV_MODE_LEADING_ZEROS, 2);
+ StringAppend(gStringVar2, gText_SpaceSeconds);
+ }
+ else
+ {
+ StringCopy(gStringVar2, gText_1MinutePlus);
+ }
+
+ result = 0;
+ if (numBikeCollisions == 0)
+ {
+ result = 5;
+ }
+ else if (numBikeCollisions < 4)
+ {
+ result = 4;
+ }
+ else if (numBikeCollisions < 10)
+ {
+ result = 3;
+ }
+ else if (numBikeCollisions < 20)
+ {
+ result = 2;
+ }
+ else if (numBikeCollisions < 100)
+ {
+ result = 1;
+ }
+
+ if (numFrames / 60 <= 10)
+ {
+ result += 5;
+ }
+ else if (numFrames / 60 <= 15)
+ {
+ result += 4;
+ }
+ else if (numFrames / 60 <= 20)
+ {
+ result += 3;
+ }
+ else if (numFrames / 60 <= 40)
+ {
+ result += 2;
+ }
+ else if (numFrames / 60 < 60)
+ {
+ result += 1;
+ }
+
+
+ gSpecialVar_Result = result;
+}
+
+void FinishCyclingRoadChallenge(void) {
+ const u32 numFrames = gMain.vblankCounter1 - gBikeCyclingTimer;
+
+ DetermineCyclingRoadResults(numFrames, gBikeCollisions);
+ RecordCyclingRoadResults(numFrames, gBikeCollisions);
+}
+
+static void RecordCyclingRoadResults(u32 numFrames, u8 numBikeCollisions) {
+ u16 low = VarGet(VAR_CYCLING_ROAD_RECORD_TIME_L);
+ u16 high = VarGet(VAR_CYCLING_ROAD_RECORD_TIME_H);
+ u32 framesRecord = low + (high << 16);
+
+ if (framesRecord > numFrames || framesRecord == 0)
+ {
+ VarSet(VAR_CYCLING_ROAD_RECORD_TIME_L, numFrames);
+ VarSet(VAR_CYCLING_ROAD_RECORD_TIME_H, numFrames >> 16);
+ VarSet(VAR_CYCLING_ROAD_RECORD_COLLISIONS, numBikeCollisions);
+ }
+}
+
+u16 GetRecordedCyclingRoadResults(void) {
+ u16 low = VarGet(VAR_CYCLING_ROAD_RECORD_TIME_L);
+ u16 high = VarGet(VAR_CYCLING_ROAD_RECORD_TIME_H);
+ u32 framesRecord = low + (high << 16);
+
+ if (framesRecord == 0)
+ {
+ return FALSE;
+ }
+
+ DetermineCyclingRoadResults(framesRecord, VarGet(VAR_CYCLING_ROAD_RECORD_COLLISIONS));
+ return TRUE;
+}
+
+void UpdateCyclingRoadState(void) {
+ if (gUnknown_020322DC.mapNum == MAP_NUM(ROUTE110_SEASIDE_CYCLING_ROAD_SOUTH_ENTRANCE) && gUnknown_020322DC.mapGroup == MAP_GROUP(ROUTE110_SEASIDE_CYCLING_ROAD_SOUTH_ENTRANCE))
+ {
+ return;
+ }
+
+ if (VarGet(VAR_CYCLING_CHALLENGE_STATE) == 2 || VarGet(VAR_CYCLING_CHALLENGE_STATE) == 3)
+ {
+ VarSet(VAR_CYCLING_CHALLENGE_STATE, 0);
+ Overworld_SetSavedMusic(MUS_DUMMY);
+ }
+}
+
+void SetSSTidalFlag(void)
+{
+ FlagSet(FLAG_SYS_CRUISE_MODE);
+ *GetVarPointer(VAR_CRUISE_STEP_COUNT) = 0;
+}
+
+void ResetSSTidalFlag(void)
+{
+ FlagClear(FLAG_SYS_CRUISE_MODE);
+}
+
+bool32 CountSSTidalStep(u16 delta)
+{
+ if (!FlagGet(FLAG_SYS_CRUISE_MODE) || (*GetVarPointer(VAR_CRUISE_STEP_COUNT) += delta) <= 0xcc)
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+u8 GetSSTidalLocation(s8 *mapGroup, s8 *mapNum, s16 *x, s16 *y)
+{
+ u16 *varCruiseStepCount = GetVarPointer(VAR_CRUISE_STEP_COUNT);
+ switch (*GetVarPointer(VAR_PORTHOLE_STATE))
+ {
+ case 1:
+ case 8:
+ return 1;
+ case 3:
+ case 9:
+ return 4;
+ case 4:
+ case 5:
+ return 2;
+ case 6:
+ case 10:
+ return 3;
+ case 2:
+ if (*varCruiseStepCount < 60)
+ {
+ *mapNum = MAP_NUM(ROUTE134);
+ *x = *varCruiseStepCount + 19;
+ }
+ else if (*varCruiseStepCount < 140)
+ {
+ *mapNum = MAP_NUM(ROUTE133);
+ *x = *varCruiseStepCount - 60;
+ }
+ else
+ {
+ *mapNum = MAP_NUM(ROUTE132);
+ *x = *varCruiseStepCount - 140;
+ }
+ break;
+ case 7:
+ if (*varCruiseStepCount < 66)
+ {
+ *mapNum = MAP_NUM(ROUTE132);
+ *x = 65 - *varCruiseStepCount;
+ }
+ else if (*varCruiseStepCount < 146) {
+ *mapNum = MAP_NUM(ROUTE133);
+ *x = 145 - *varCruiseStepCount;
+ }
+ else
+ {
+ *mapNum = MAP_NUM(ROUTE134);
+ *x = 224 - *varCruiseStepCount;
+ }
+ break;
+ }
+ *mapGroup = MAP_GROUP(ROUTE132);
+ *y = 20;
+ return 0;
+}
+
+bool32 is_tile_that_overrides_player_control(void)
+{
+ if (FlagGet(FLAG_0x088))
+ {
+ switch (gMapHeader.mapType)
+ {
+ case 1:
+ case 2:
+ case 3:
+ case 6:
+ if (++(*GetVarPointer(VAR_0x40F2)) < 0xFA)
+ {
+ return FALSE;
+ }
+ break;
+ default:
+ return FALSE;
+ }
+ }
+ else
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+bool32 sub_8138120(void)
+{
+ if (FlagGet(FLAG_0x08A))
+ {
+ switch (gMapHeader.mapType)
+ {
+ case 1:
+ case 2:
+ case 3:
+ case 6:
+ if (++(*GetVarPointer(VAR_0x40F3)) < 0xA)
+ {
+ return FALSE;
+ }
+ break;
+ default:
+ return FALSE;
+ }
+ }
+ else
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+bool32 sub_8138168(void)
+{
+ if (FlagGet(FLAG_0x072))
+ {
+ switch (gMapHeader.mapType)
+ {
+ case 1:
+ case 2:
+ case 3:
+ case 6:
+ if (++(*GetVarPointer(VAR_0x40F5)) < 0xA)
+ {
+ return FALSE;
+ }
+ break;
+ default:
+ return FALSE;
+ }
+ }
+ else
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+bool32 sub_81381B0(void)
+{
+ if (FlagGet(FLAG_0x080))
+ {
+ switch (gMapHeader.mapType)
+ {
+ case 1:
+ case 2:
+ case 3:
+ case 6:
+ if (++(*GetVarPointer(VAR_0x40F4)) < 0xFA)
+ {
+ return FALSE;
+ }
+ break;
+ default:
+ return FALSE;
+ }
+ }
+ else
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+bool32 sub_81381F8(void)
+{
+ if (FlagGet(FLAG_0x075))
+ {
+ switch (gMapHeader.mapType)
+ {
+ case 1:
+ case 2:
+ case 3:
+ case 6:
+ if (++(*GetVarPointer(VAR_0x40F6)) < 0xFA)
+ {
+ return FALSE;
+ }
+ break;
+ default:
+ return FALSE;
+ }
+ }
+ else
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+u8 GetLinkPartnerNames(void)
+{
+ u8 i;
+ u8 j = 0;
+ u8 myLinkPlayerNumber = GetMultiplayerId();
+ u8 nLinkPlayers = GetLinkPlayerCount();
+ for (i = 0; i < nLinkPlayers; i++)
+ {
+ if (myLinkPlayerNumber != i)
+ {
+ StringCopy(gTVStringVarPtrs[j], gLinkPlayers[i].name);
+ j++;
+ }
+ }
+ return nLinkPlayers;
+}
+
+void SpawnLinkPartnerEventObject(void)
+{
+ u8 j = 0;
+ s16 x = 0;
+ s16 y = 0;
+ u8 gUnknown_085B2B5C[] = {7, 9, 8, 10};
+ s8 gUnknown_085B2B60[][2] = {
+ { 0, 1},
+ { 1, 0},
+ { 0, -1},
+ {-1, 0}
+ };
+ u8 myLinkPlayerNumber;
+ u8 playerFacingDirection;
+ u8 linkSpriteId;
+ u8 i;
+
+ myLinkPlayerNumber = GetMultiplayerId();
+ playerFacingDirection = GetPlayerFacingDirection();
+ switch (playerFacingDirection)
+ {
+ case DIR_WEST:
+ j = 2;
+ x = gSaveBlock1Ptr->pos.x - 1;
+ y = gSaveBlock1Ptr->pos.y;
+ break;
+ case DIR_NORTH:
+ j = 1;
+ x = gSaveBlock1Ptr->pos.x;
+ y = gSaveBlock1Ptr->pos.y - 1;
+ break;
+ case DIR_EAST:
+ x = gSaveBlock1Ptr->pos.x + 1;
+ y = gSaveBlock1Ptr->pos.y;
+ break;
+ case DIR_SOUTH:
+ j = 3;
+ x = gSaveBlock1Ptr->pos.x;
+ y = gSaveBlock1Ptr->pos.y + 1;
+ }
+ for (i = 0; i < gSpecialVar_0x8004; i++)
+ {
+ if (myLinkPlayerNumber != i)
+ {
+ switch ((u8)gLinkPlayers[i].version)
+ {
+ case VERSION_RUBY:
+ case VERSION_SAPPHIRE:
+ if (gLinkPlayers[i].gender == 0)
+ linkSpriteId = EVENT_OBJ_GFX_LINK_RS_BRENDAN;
+ else
+ linkSpriteId = EVENT_OBJ_GFX_LINK_RS_MAY;
+ break;
+ case VERSION_EMERALD:
+ if (gLinkPlayers[i].gender == 0)
+ linkSpriteId = EVENT_OBJ_GFX_RIVAL_BRENDAN_NORMAL;
+ else
+ linkSpriteId = EVENT_OBJ_GFX_RIVAL_MAY_NORMAL;
+ break;
+ default:
+ if (gLinkPlayers[i].gender == 0)
+ linkSpriteId = EVENT_OBJ_GFX_RIVAL_BRENDAN_NORMAL;
+ else
+ linkSpriteId = EVENT_OBJ_GFX_RIVAL_MAY_NORMAL;
+ break;
+ }
+ SpawnSpecialEventObjectParameterized(linkSpriteId, gUnknown_085B2B5C[j], 0xf0 - i, gUnknown_085B2B60[j][0] + x + 7, gUnknown_085B2B60[j][1] + y + 7, 0);
+ LoadLinkPartnerEventObjectSpritePalette(linkSpriteId, 0xf0 - i, i);
+ j++;
+ if (j == 4)
+ {
+ j = 0;
+ }
+ }
+ }
+}
+
+static void LoadLinkPartnerEventObjectSpritePalette(u8 graphicsId, u8 localEventId, u8 paletteNum)
+{
+ paletteNum += 6;
+ if (graphicsId == EVENT_OBJ_GFX_LINK_RS_BRENDAN ||
+ graphicsId == EVENT_OBJ_GFX_LINK_RS_MAY ||
+ graphicsId == EVENT_OBJ_GFX_RIVAL_BRENDAN_NORMAL ||
+ graphicsId == EVENT_OBJ_GFX_RIVAL_MAY_NORMAL)
+ {
+ u8 obj = GetEventObjectIdByLocalIdAndMap(localEventId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
+ if (obj != NUM_EVENT_OBJECTS)
+ {
+ u8 spriteId = gEventObjects[obj].spriteId;
+ struct Sprite *sprite = &gSprites[spriteId];
+ sprite->oam.paletteNum = paletteNum;
+
+ switch (graphicsId)
+ {
+ case EVENT_OBJ_GFX_LINK_RS_BRENDAN:
+ LoadPalette(gEventObjectPalette33, 0x100 + paletteNum * 16, 0x20);
+ break;
+ case EVENT_OBJ_GFX_LINK_RS_MAY:
+ LoadPalette(gEventObjectPalette34, 0x100 + paletteNum * 16, 0x20);
+ break;
+ case EVENT_OBJ_GFX_RIVAL_BRENDAN_NORMAL:
+ LoadPalette(gEventObjectPalette8, 0x100 + paletteNum * 16, 0x20);
+ break;
+ case EVENT_OBJ_GFX_RIVAL_MAY_NORMAL:
+ LoadPalette(gEventObjectPalette17, 0x100 + paletteNum * 16, 0x20);
+ break;
+ }
+ }
+ }
+}
+
+static const struct UCoords8 gUnknown_085B2B68[] = {
+ { 7, 22},
+ {11, 19},
+ {10, 16},
+ {15, 16}
+};
+
+void MauvilleGymSpecial1(void)
+{
+ u8 i;
+ for (i = 0; i < ARRAY_COUNT(gUnknown_085B2B68); i++)
+ {
+ if (i == gSpecialVar_0x8004)
+ {
+ MapGridSetMetatileIdAt(gUnknown_085B2B68[i].x, gUnknown_085B2B68[i].y, 0x206);
+ }
+ else
+ {
+ MapGridSetMetatileIdAt(gUnknown_085B2B68[i].x, gUnknown_085B2B68[i].y, 0x205);
+ }
+ }
+}
+
+void MauvilleGymSpecial2(void)
+{
+ int x, y;
+ for (y = 12; y < 24; y++)
+ {
+ for (x = 7; x < 16; x++)
+ {
+ switch (MapGridGetMetatileIdAt(x, y))
+ {
+ case 0x220:
+ MapGridSetMetatileIdAt(x, y, 0x230);
+ break;
+ case 0x221:
+ MapGridSetMetatileIdAt(x, y, 0x231);
+ break;
+ case 0x228:
+ MapGridSetMetatileIdAt(x, y, 0x238);
+ break;
+ case 0x229:
+ MapGridSetMetatileIdAt(x, y, 0x239);
+ break;
+ case 0x230:
+ MapGridSetMetatileIdAt(x, y, 0x220);
+ break;
+ case 0x231:
+ MapGridSetMetatileIdAt(x, y, 0x221);
+ break;
+ case 0x238:
+ MapGridSetMetatileIdAt(x, y, 0xe28);
+ break;
+ case 0x239:
+ MapGridSetMetatileIdAt(x, y, 0xe29);
+ break;
+ case 0x222:
+ MapGridSetMetatileIdAt(x, y, 0x232);
+ break;
+ case 0x223:
+ MapGridSetMetatileIdAt(x, y, 0x233);
+ break;
+ case 0x22a:
+ MapGridSetMetatileIdAt(x, y, 0x23a);
+ break;
+ case 0x22b:
+ MapGridSetMetatileIdAt(x, y, 0x23b);
+ break;
+ case 0x232:
+ MapGridSetMetatileIdAt(x, y, 0x222);
+ break;
+ case 0x233:
+ MapGridSetMetatileIdAt(x, y, 0x223);
+ break;
+ case 0x23a:
+ MapGridSetMetatileIdAt(x, y, 0xe2a);
+ break;
+ case 0x23b:
+ MapGridSetMetatileIdAt(x, y, 0xe2b);
+ break;
+ case 0x240:
+ MapGridSetMetatileIdAt(x, y, 0xe42);
+ break;
+ case 0x248:
+ MapGridSetMetatileIdAt(x, y, 0x21a);
+ break;
+ case 0x241:
+ MapGridSetMetatileIdAt(x, y, 0xe43);
+ break;
+ case 0x249:
+ MapGridSetMetatileIdAt(x, y, 0x21a);
+ break;
+ case 0x242:
+ MapGridSetMetatileIdAt(x, y, 0xe40);
+ break;
+ case 0x21a:
+ if (MapGridGetMetatileIdAt(x, y - 1) == 0x240)
+ {
+ MapGridSetMetatileIdAt(x, y, 0xe48);
+ }
+ else
+ {
+ MapGridSetMetatileIdAt(x, y, 0xe49);
+ }
+ break;
+ case 0x243:
+ MapGridSetMetatileIdAt(x, y, 0xe41);
+ break;
+ case 0x251:
+ MapGridSetMetatileIdAt(x, y, 0xe50);
+ break;
+ case 0x250:
+ MapGridSetMetatileIdAt(x, y, 0x251);
+ break;
+ }
+ }
+ }
+}
+
+void MauvilleGymSpecial3(void)
+{
+ int i, x, y;
+ const struct UCoords8 *switchCoords = gUnknown_085B2B68;
+ for (i = ARRAY_COUNT(gUnknown_085B2B68) - 1; i >= 0; i--)
+ {
+ MapGridSetMetatileIdAt(switchCoords->x, switchCoords->y, 0x206);
+ switchCoords++;
+ }
+ for (y = 12; y < 24; y++)
+ {
+ for (x = 7; x < 16; x++)
+ {
+ switch (MapGridGetMetatileIdAt(x, y))
+ {
+ case 0x220:
+ MapGridSetMetatileIdAt(x, y, 0x230);
+ break;
+ case 0x221:
+ MapGridSetMetatileIdAt(x, y, 0x231);
+ break;
+ case 0x228:
+ MapGridSetMetatileIdAt(x, y, 0x238);
+ break;
+ case 0x229:
+ MapGridSetMetatileIdAt(x, y, 0x239);
+ break;
+ case 0x222:
+ MapGridSetMetatileIdAt(x, y, 0x232);
+ break;
+ case 0x223:
+ MapGridSetMetatileIdAt(x, y, 0x233);
+ break;
+ case 0x22a:
+ MapGridSetMetatileIdAt(x, y, 0x23a);
+ break;
+ case 0x22b:
+ MapGridSetMetatileIdAt(x, y, 0x23b);
+ break;
+ case 0x240:
+ MapGridSetMetatileIdAt(x, y, 0xe42);
+ break;
+ case 0x241:
+ MapGridSetMetatileIdAt(x, y, 0xe43);
+ break;
+ case 0x248:
+ case 0x249:
+ MapGridSetMetatileIdAt(x, y, 0x21a);
+ break;
+ case 0x250:
+ MapGridSetMetatileIdAt(x, y, 0x251);
+ break;
+ }
+ }
+ }
+}
+
+static const u8 gUnknown_085B2B78[] = {0, 1, 1, 1, 1};
+static const u16 gUnknown_085B2B7E[] = {0x218, 0x219, 0x21a, 0x21b, 0x21c};
+
+void PetalburgGymSpecial1(void)
+{
+ gUnknown_0203AB5C = 0;
+ gUnknown_0203AB5D = 0;
+ PlaySE(SE_KI_GASYAN);
+ CreateTask(Task_PetalburgGym, 8);
+}
+
+static void Task_PetalburgGym(u8 taskId)
+{
+ if (gUnknown_085B2B78[gUnknown_0203AB5D] == gUnknown_0203AB5C)
+ {
+ PetalburgGymFunc(gSpecialVar_0x8004, gUnknown_085B2B7E[gUnknown_0203AB5D]);
+ gUnknown_0203AB5C = 0;
+ if ((++gUnknown_0203AB5D) == 5)
+ {
+ DestroyTask(taskId);
+ EnableBothScriptContexts();
+ }
+ }
+ else
+ {
+ gUnknown_0203AB5C++;
+ }
+}
+
+static void PetalburgGymFunc(u8 a0, u16 a1)
+{
+ u16 x[4];
+ u16 y[4];
+ u8 i;
+ u8 nDoors = 0;
+ switch (a0)
+ {
+ case 1:
+ nDoors = 2;
+ x[0] = 1;
+ x[1] = 7;
+ y[0] = 0x68;
+ y[1] = 0x68;
+ break;
+ case 2:
+ nDoors = 2;
+ x[0] = 1;
+ x[1] = 7;
+ y[0] = 0x4e;
+ y[1] = 0x4e;
+ break;
+ case 3:
+ nDoors = 2;
+ x[0] = 1;
+ x[1] = 7;
+ y[0] = 0x5b;
+ y[1] = 0x5b;
+ break;
+ case 4:
+ nDoors = 1;
+ x[0] = 7;
+ y[0] = 0x27;
+ break;
+ case 5:
+ nDoors = 2;
+ x[0] = 1;
+ x[1] = 7;
+ y[0] = 0x34;
+ y[1] = 0x34;
+ break;
+ case 6:
+ nDoors = 1;
+ x[0] = 1;
+ y[0] = 0x41;
+ break;
+ case 7:
+ nDoors = 1;
+ x[0] = 7;
+ y[0] = 0xd;
+ break;
+ case 8:
+ nDoors = 1;
+ x[0] = 1;
+ y[0] = 0x1a;
+ break;
+ }
+ for (i = 0; i < nDoors; i++)
+ {
+ MapGridSetMetatileIdAt(x[i] + 7, y[i] + 7, a1 | 0xc00);
+ MapGridSetMetatileIdAt(x[i] + 7, y[i] + 8, (a1 + 8) | 0xc00);
+ }
+ DrawWholeMapView();
+}
+
+void PetalburgGymSpecial2(void)
+{
+ PetalburgGymFunc(gSpecialVar_0x8004, gUnknown_085B2B7E[4]);
+}
+
+void ShowFieldMessageStringVar4(void)
+{
+ ShowFieldMessage(gStringVar4);
+}
+
+void StorePlayerCoordsInVars(void)
+{
+ gSpecialVar_0x8004 = gSaveBlock1Ptr->pos.x;
+ gSpecialVar_0x8005 = gSaveBlock1Ptr->pos.y;
+}
+
+u8 GetPlayerTrainerIdOnesDigit(void)
+{
+ return (u16)((gSaveBlock2Ptr->playerTrainerId[1] << 8) | gSaveBlock2Ptr->playerTrainerId[0]) % 10;
+}
+
+void GetPlayerBigGuyGirlString(void)
+{
+ if (gSaveBlock2Ptr->playerGender == MALE)
+ {
+ StringCopy(gStringVar1, gText_BigGuy);
+ }
+ else
+ {
+ StringCopy(gStringVar1, gText_BigGirl);
+ }
+}
+
+void GetRivalSonDaughterString(void)
+{
+ if (gSaveBlock2Ptr->playerGender == MALE)
+ {
+ StringCopy(gStringVar1, gText_Daughter);
+ }
+ else
+ {
+ StringCopy(gStringVar1, gText_Son);
+ }
+}
+
+u8 GetBattleOutcome(void)
+{
+ return gBattleOutcome;
+}
+
+void CableCarWarp(void)
+{
+ if (gSpecialVar_0x8004 != 0)
+ {
+ Overworld_SetWarpDestination(MAP_GROUP(ROUTE112_CABLE_CAR_STATION), MAP_NUM(ROUTE112_CABLE_CAR_STATION), -1, 6, 4);
+ }
+ else
+ {
+ Overworld_SetWarpDestination(MAP_GROUP(MT_CHIMNEY_CABLE_CAR_STATION), MAP_NUM(MT_CHIMNEY_CABLE_CAR_STATION), -1, 6, 4);
+ }
+}
+
+void SetFlagInVar(void)
+{
+ FlagSet(gSpecialVar_0x8004);
+}
+
+u16 GetWeekCount(void)
+{
+ u16 weekCount = gLocalTime.days / 7;
+ if (weekCount > 9999)
+ {
+ weekCount = 9999;
+ }
+ return weekCount;
+}
+
+u8 GetLeadMonFriendshipScore(void)
+{
+ struct Pokemon *pokemon = &gPlayerParty[GetLeadMonIndex()];
+ if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) == 255)
+ {
+ return 6;
+ }
+ if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 200)
+ {
+ return 5;
+ }
+ if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 150)
+ {
+ return 4;
+ }
+ if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 100)
+ {
+ return 3;
+ }
+ if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 50)
+ {
+ return 2;
+ }
+ if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 1)
+ {
+ return 1;
+ }
+ return 0;
+}
+
+static void CB2_FieldShowRegionMap(void)
+{
+ FieldInitRegionMap(CB2_ReturnToFieldContinueScriptPlayMapMusic);
+}
+
+void FieldShowRegionMap(void)
+{
+ SetMainCallback2(CB2_FieldShowRegionMap);
+}
+
+void DoPCTurnOnEffect(void)
+{
+ if (FuncIsActiveTask(Task_PCTurnOnEffect) != TRUE)
+ {
+ u8 taskId = CreateTask(Task_PCTurnOnEffect, 8);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = taskId;
+ gTasks[taskId].data[2] = 0;
+ gTasks[taskId].data[3] = 0;
+ gTasks[taskId].data[4] = 0;
+ }
+}
+
+static void Task_PCTurnOnEffect(u8 taskId)
+{
+ struct Task *task = &gTasks[taskId];
+ if (task->data[0] == 0)
+ {
+ PCTurnOnEffect_0(task);
+ }
+}
+
+static void PCTurnOnEffect_0(struct Task *task)
+{
+ u8 playerDirection;
+ s8 dx = 0;
+ s8 dy = 0;
+ if (task->data[3] == 6)
+ {
+ task->data[3] = 0;
+ playerDirection = GetPlayerFacingDirection();
+ switch (playerDirection)
+ {
+ case DIR_NORTH:
+ dx = 0;
+ dy = -1;
+ break;
+ case DIR_WEST:
+ dx = -1;
+ dy = -1;
+ break;
+ case DIR_EAST:
+ dx = 1;
+ dy = -1;
+ break;
+ }
+ PCTurnOnEffect_1(task->data[4], dx, dy);
+ DrawWholeMapView();
+ task->data[4] ^= 1;
+ if ((++task->data[2]) == 5)
+ {
+ DestroyTask(task->data[1]);
+ }
+ }
+ task->data[3]++;
+}
+
+static void PCTurnOnEffect_1(s16 flag, s8 dx, s8 dy)
+{
+ u16 tileId = 0;
+ if (flag != 0)
+ {
+ if (gSpecialVar_0x8004 == 0)
+ {
+ tileId = 0x4;
+ }
+ else if (gSpecialVar_0x8004 == 1)
+ {
+ tileId = 0x25a;
+ }
+ else if (gSpecialVar_0x8004 == 2)
+ {
+ tileId = 0x259;
+ }
+ }
+ else
+ {
+ if (gSpecialVar_0x8004 == 0)
+ {
+ tileId = 0x5;
+ }
+ else if (gSpecialVar_0x8004 == 1)
+ {
+ tileId = 0x27f;
+ }
+ else if (gSpecialVar_0x8004 == 2)
+ {
+ tileId = 0x27e;
+ }
+ }
+ MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | 0xc00);
+}
+
+void DoPCTurnOffEffect(void)
+{
+ PCTurnOffEffect();
+}
+
+static void PCTurnOffEffect(void)
+{
+ s8 dx = 0;
+ s8 dy = 0;
+ u16 tileId = 0;
+ u8 playerDirection = GetPlayerFacingDirection();
+ switch (playerDirection)
+ {
+ case DIR_NORTH:
+ dx = 0;
+ dy = -1;
+ break;
+ case DIR_WEST:
+ dx = -1;
+ dy = -1;
+ break;
+ case DIR_EAST:
+ dx = 1;
+ dy = -1;
+ break;
+ }
+ if (gSpecialVar_0x8004 == 0)
+ {
+ tileId = 0x4;
+ }
+ else if (gSpecialVar_0x8004 == 1)
+ {
+ tileId = 0x25a;
+ }
+ else if (gSpecialVar_0x8004 == 2)
+ {
+ tileId = 0x259;
+ }
+ MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | 0xc00);
+ DrawWholeMapView();
+}
+
+void DoLotteryCornerComputerEffect(void)
+{
+ if (FuncIsActiveTask(Task_LotteryCornerComputerEffect) != TRUE)
+ {
+ u8 taskId = CreateTask(Task_LotteryCornerComputerEffect, 8);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = taskId;
+ gTasks[taskId].data[2] = 0;
+ gTasks[taskId].data[3] = 0;
+ gTasks[taskId].data[4] = 0;
+ }
+}
+
+static void Task_LotteryCornerComputerEffect(u8 taskId)
+{
+ struct Task *task = &gTasks[taskId];
+ if (task->data[0] == 0)
+ {
+ LotteryCornerComputerEffect(task);
+ }
+}
+
+static void LotteryCornerComputerEffect(struct Task *task)
+{
+ if (task->data[3] == 6)
+ {
+ task->data[3] = 0;
+ if (task->data[4] != 0)
+ {
+ MapGridSetMetatileIdAt(18, 8, 0xe9d);
+ MapGridSetMetatileIdAt(18, 9, 0xea5);
+ }
+ else
+ {
+ MapGridSetMetatileIdAt(18, 8, 0xe58);
+ MapGridSetMetatileIdAt(18, 9, 0xe60);
+ }
+ DrawWholeMapView();
+ task->data[4] ^= 1;
+ if ((++task->data[2]) == 5)
+ {
+ DestroyTask(task->data[1]);
+ }
+ }
+ task->data[3]++;
+}
+
+void EndLotteryCornerComputerEffect(void)
+{
+ MapGridSetMetatileIdAt(18, 8, 0xe9d);
+ MapGridSetMetatileIdAt(18, 9, 0xea5);
+ DrawWholeMapView();
+}
+
+void SetTrickHouseEndRoomFlag(void)
+{
+ u16 *specVar = &gSpecialVar_0x8004;
+ u16 flag = FLAG_0x1F5;
+ *specVar = flag;
+ FlagSet(flag);
+}
+
+void ResetTrickHouseEndRoomFlag(void)
+{
+ u16 *specVar = &gSpecialVar_0x8004;
+ u16 flag = FLAG_0x1F5;
+ *specVar = flag;
+ FlagClear(flag);
+}
+
+bool8 CheckLeadMonCool(void)
+{
+ if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_COOL) < 200)
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+bool8 CheckLeadMonBeauty(void)
+{
+ if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_BEAUTY) < 200)
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+bool8 CheckLeadMonCute(void)
+{
+ if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_CUTE) < 200)
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+bool8 CheckLeadMonSmart(void)
+{
+ if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SMART) < 200)
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+bool8 CheckLeadMonTough(void)
+{
+ if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_TOUGH) < 200)
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void IsGrassTypeInParty(void)
+{
+ u8 i;
+ u16 species;
+ struct Pokemon *pokemon;
+ for (i = 0; i < PARTY_SIZE; i++)
+ {
+ pokemon = &gPlayerParty[i];
+ if (GetMonData(pokemon, MON_DATA_SANITY_BIT2) && !GetMonData(pokemon, MON_DATA_IS_EGG))
+ {
+ species = GetMonData(pokemon, MON_DATA_SPECIES);
+ if (gBaseStats[species].type1 == TYPE_GRASS || gBaseStats[species].type2 == TYPE_GRASS)
+ {
+ gSpecialVar_Result = TRUE;
+ return;
+ }
+ }
+ }
+ gSpecialVar_Result = FALSE;
+}
+
+void SpawnScriptEventObject(void)
+{
+ u8 obj = SpawnSpecialEventObjectParameterized(EVENT_OBJ_GFX_BOY_1, 8, 0x7F, gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7, 3);
+ gEventObjects[obj].invisible = TRUE;
+ CameraObjectSetFollowedObjectId(gEventObjects[obj].spriteId);
+}
+
+void RemoveScriptEventObject(void)
+{
+ CameraObjectSetFollowedObjectId(GetPlayerAvatarObjectId());
+ RemoveEventObjectByLocalIdAndMap(0x7F, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
+}
+
+u8 GetPokeblockNameByMonNature(void)
+{
+ return CopyMonFavoritePokeblockName(GetNature(&gPlayerParty[GetLeadMonIndex()]), gStringVar1);
+}
+
+void GetSecretBaseNearbyMapName(void)
+{
+ GetMapName(gStringVar1, VarGet(VAR_SECRET_BASE_MAP), 0);
+}
+
+u16 GetBestBattleTowerStreak(void)
+{
+ return GetGameStat(GAME_STAT_BATTLE_TOWER_BEST_STREAK);
+}
+
+void BufferEReaderTrainerName(void)
+{
+ GetEreaderTrainerName(gStringVar1);
+}
+
+u16 GetSlotMachineId(void)
+{
+ static const u8 gUnknown_085B2B88[] = {12, 2, 4, 5, 1, 8, 7, 11, 3, 10, 9, 6};
+ static const u8 gUnknown_085B2B94[] = {0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5};
+ static const u8 gUnknown_085B2BA0[] = {3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5};
+
+ u32 v0 = gSaveBlock1Ptr->easyChatPairs[0].unk0_0 + gSaveBlock1Ptr->easyChatPairs[0].unk2 + gUnknown_085B2B88[gSpecialVar_0x8004];
+ if (GetPriceReduction(2))
+ {
+ return gUnknown_085B2BA0[v0 % 12];
+ }
+ return gUnknown_085B2B94[v0 % 12];
+}
+
+bool8 FoundAbandonedShipRoom1Key(void)
+{
+ u16 *specVar = &gSpecialVar_0x8004;
+ u16 flag = FLAG_HIDDEN_ITEM_1F;
+ *specVar = flag;
+ if (!FlagGet(flag))
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+bool8 FoundAbandonedShipRoom2Key(void)
+{
+ u16 *specVar = &gSpecialVar_0x8004;
+ u16 flag = FLAG_HIDDEN_ITEM_20;
+ *specVar = flag;
+ if (!FlagGet(flag))
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+bool8 FoundAbandonedShipRoom4Key(void)
+{
+ u16 *specVar = &gSpecialVar_0x8004;
+ u16 flag = FLAG_HIDDEN_ITEM_21;
+ *specVar = flag;
+ if (!FlagGet(flag))
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+bool8 FoundAbandonedShipRoom6Key(void)
+{
+ u16 *specVar = &gSpecialVar_0x8004;
+ u16 flag = FLAG_HIDDEN_ITEM_22;
+ *specVar = flag;
+ if (!FlagGet(flag))
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+bool8 LeadMonHasEffortRibbon(void)
+{
+ return GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_EFFORT_RIBBON, NULL);
+}
+
+void GiveLeadMonEffortRibbon(void)
+{
+ bool8 ribbonSet;
+ struct Pokemon *leadMon;
+ IncrementGameStat(GAME_STAT_RECEIVED_RIBBONS);
+ FlagSet(FLAG_SYS_RIBBON_GET);
+ ribbonSet = TRUE;
+ leadMon = &gPlayerParty[GetLeadMonIndex()];
+ SetMonData(leadMon, MON_DATA_EFFORT_RIBBON, &ribbonSet);
+ if (GetRibbonCount(leadMon) > 4)
+ {
+ sub_80EE4DC(leadMon, 0x47);
+ }
+}
+
+bool8 Special_AreLeadMonEVsMaxedOut(void)
+{
+ if (GetMonEVCount(&gPlayerParty[GetLeadMonIndex()]) >= 510)
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+u8 TryUpdateRusturfTunnelState(void)
+{
+ if (!FlagGet(FLAG_RUSTURF_TUNNEL_OPENED) && gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(RUSTURF_TUNNEL) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(RUSTURF_TUNNEL))
+ {
+ if (FlagGet(FLAG_HIDE_RUSTURF_TUNNEL_ROCK_1))
+ {
+ VarSet(VAR_RUSTURF_TUNNEL_STATE, 4);
+ return TRUE;
+ }
+ else if (FlagGet(FLAG_HIDE_RUSTURF_TUNNEL_ROCK_2))
+ {
+ VarSet(VAR_RUSTURF_TUNNEL_STATE, 5);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void SetShoalItemFlag(u16 v0)
+{
+ FlagSet(FLAG_SYS_SHOAL_ITEM);
+}
+
+void PutZigzagoonInPlayerParty(void)
+{
+ u16 monData;
+ CreateMon(&gPlayerParty[0], SPECIES_ZIGZAGOON, 7, 0x20, FALSE, 0, FALSE, 0);
+ monData = TRUE;
+ SetMonData(&gPlayerParty[0], MON_DATA_ALT_ABILITY, &monData);
+ monData = MOVE_TACKLE;
+ SetMonData(&gPlayerParty[0], MON_DATA_MOVE1, &monData);
+ monData = MOVE_NONE;
+ SetMonData(&gPlayerParty[0], MON_DATA_MOVE2, &monData);
+ SetMonData(&gPlayerParty[0], MON_DATA_MOVE3, &monData);
+ SetMonData(&gPlayerParty[0], MON_DATA_MOVE4, &monData);
+}
+
+bool8 IsStarterInParty(void)
+{
+ u8 i;
+ u16 starter = GetStarterPokemon(VarGet(VAR_STARTER_MON));
+ u8 partyCount = CalculatePlayerPartyCount();
+ for (i = 0; i < partyCount; i++)
+ {
+ if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) == starter)
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+bool8 ScriptCheckFreePokemonStorageSpace(void)
+{
+ return CheckFreePokemonStorageSpace();
+}
+
+bool8 IsPokerusInParty(void)
+{
+ if (!CheckPartyPokerus(gPlayerParty, 0x3f))
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void sub_8139560(void)
+{
+ u8 taskId = CreateTask(sub_81395BC, 9);
+ gTasks[taskId].data[0] = gSpecialVar_0x8005;
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].data[2] = gSpecialVar_0x8006;
+ gTasks[taskId].data[3] = gSpecialVar_0x8007;
+ gTasks[taskId].data[4] = gSpecialVar_0x8004;
+ SetCameraPanningCallback(NULL);
+ PlaySE(SE_W070);
+}
+
+static void sub_81395BC(u8 taskId)
+{
+ s16 *data = gTasks[taskId].data;
+
+ data[1]++;
+ if (data[1] % data[3] == 0)
+ {
+ data[1] = 0;
+ data[2]--;
+ data[0] = -data[0];
+ data[4] = -data[4];
+ SetCameraPanning(data[0], data[4]);
+ if (data[2] == 0)
+ {
+ sub_8139620(taskId);
+ InstallCameraPanAheadCallback();
+ }
+ }
+}
+
+static void sub_8139620(u8 taskId)
+{
+ DestroyTask(taskId);
+ EnableBothScriptContexts();
+}
+
+bool8 FoundBlackGlasses(void)
+{
+ return FlagGet(FLAG_HIDDEN_ITEM_BLACK_GLASSES);
+}
+
+void SetRoute119Weather(void)
+{
+ if (is_map_type_1_2_3_5_or_6(get_map_light_from_warp0()) != TRUE)
+ {
+ SetSav1Weather(20);
+ }
+}
+
+void SetRoute123Weather(void)
+{
+ if (is_map_type_1_2_3_5_or_6(get_map_light_from_warp0()) != TRUE)
+ {
+ SetSav1Weather(21);
+ }
+}
+
+u8 GetLeadMonIndex(void)
+{
+ u8 i;
+ u8 partyCount = CalculatePlayerPartyCount();
+ for (i = 0; i < partyCount; i++)
+ {
+ if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_EGG && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != 0)
+ {
+ return i;
+ }
+ }
+ return 0;
+}
+
+u16 ScriptGetPartyMonSpecies(void)
+{
+ return GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPECIES2, NULL);
+}
+
+void nullsub_54(void)
+{
+
+}
+
+u16 GetDaysUntilPacifidlogTMAvailable(void)
+{
+ u16 tmReceivedDay = VarGet(VAR_PACIFIDLOG_TM_RECEIVED_DAY);
+ if (gLocalTime.days - tmReceivedDay >= 7)
+ {
+ return 0;
+ }
+ else if (gLocalTime.days < 0)
+ {
+ return 8;
+ }
+ return 7 - (gLocalTime.days - tmReceivedDay);
+}
+
+u16 SetPacifidlogTMReceivedDay(void)
+{
+ VarSet(VAR_PACIFIDLOG_TM_RECEIVED_DAY, gLocalTime.days);
+ return gLocalTime.days;
+}
+
+bool8 MonOTNameMatchesPlayer(void)
+{
+ if (GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_LANGUAGE) != GAME_LANGUAGE)
+ {
+ return TRUE; // huh?
+ }
+
+ GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_OT_NAME, gStringVar1);
+ if (!StringCompare(gSaveBlock2Ptr->playerName, gStringVar1))
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void BufferLottoTicketNumber(void)
+{
+ if (gSpecialVar_Result >= 10000)
+ {
+ TV_PrintIntToStringVar(0, gSpecialVar_Result);
+ }
+ else if (gSpecialVar_Result >= 1000)
+ {
+ gStringVar1[0] = CHAR_0;
+ ConvertIntToDecimalStringN(gStringVar1 + 1, gSpecialVar_Result, 0, CountDigits(gSpecialVar_Result));
+ }
+ else if (gSpecialVar_Result >= 100)
+ {
+ gStringVar1[0] = CHAR_0;
+ gStringVar1[1] = CHAR_0;
+ ConvertIntToDecimalStringN(gStringVar1 + 2, gSpecialVar_Result, 0, CountDigits(gSpecialVar_Result));
+ }
+ else if (gSpecialVar_Result >= 10)
+ {
+ gStringVar1[0] = CHAR_0;
+ gStringVar1[1] = CHAR_0;
+ gStringVar1[2] = CHAR_0;
+ ConvertIntToDecimalStringN(gStringVar1 + 3, gSpecialVar_Result, 0, CountDigits(gSpecialVar_Result));
+ }
+ else
+ {
+ gStringVar1[0] = CHAR_0;
+ gStringVar1[1] = CHAR_0;
+ gStringVar1[2] = CHAR_0;
+ gStringVar1[3] = CHAR_0;
+ ConvertIntToDecimalStringN(gStringVar1 + 4, gSpecialVar_Result, 0, CountDigits(gSpecialVar_Result));
+ }
+}
+
+u16 sub_813986C(void)
+{
+ switch (gSpecialVar_Result)
+ {
+ case 0:
+ return mevent_081445C0(3);
+ case 1:
+ return mevent_081445C0(4);
+ case 2:
+ return mevent_081445C0(0);
+ case 3:
+ return mevent_081445C0(1);
+ case 4:
+ return mevent_081445C0(2);
+ default:
+ return 0;
+ }
+}
+
+bool8 sub_81398C0(void)
+{
+ if (gSpecialVar_0x8004 >= ITEM_TM01 && gSpecialVar_0x8004 <= ITEM_HM08)
+ {
+ StringCopy(gStringVar2, gMoveNames[ItemIdToBattleMoveId(gSpecialVar_0x8004)]);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+bool8 sub_813990C(void)
+{
+ u8 partyCount = CalculatePlayerPartyCount();
+ u8 i;
+
+ for (i = 0; i < partyCount; i++)
+ {
+ if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_BIT1) == 1)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+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)
+ return TRUE;
+ return FALSE;
+}
+
+void sub_8139980(void)
+{
+ SetCameraPanningCallback(NULL);
+ SetCameraPanning(8, 0);
+}
+
+const struct WindowTemplate gUnknown_085B2BAC = {
+ .priority = 0,
+ .tilemapLeft = 21,
+ .tilemapTop = 1,
+ .width = 8,
+ .height = 4,
+ .paletteNum = 15,
+ .baseBlock = 8,
+};
+
+const u8 *const gElevatorFloorsTable[] = {
+ gText_B4F,
+ gText_B3F,
+ gText_B2F,
+ gText_B1F,
+ gText_1F,
+ gText_2F,
+ gText_3F,
+ gText_4F,
+ gText_5F,
+ gText_6F,
+ gText_7F,
+ gText_8F,
+ gText_9F,
+ gText_10F,
+ gText_11F,
+ gText_Rooftop
+};
+
+const u16 gUnknown_085B2BF4[] = { 0x0329, 0x032a, 0x032b, 0x0331, 0x0332, 0x0333, 0x0339, 0x033a, 0x033b };
+const u16 gUnknown_085B2C06[] = { 0x0329, 0x032b, 0x032a, 0x0331, 0x0333, 0x0332, 0x0339, 0x033b, 0x033a };
+
+void SetDepartmentStoreFloorVar(void)
+{
+ u8 deptStoreFloor;
+ switch (gSaveBlock1Ptr->warp2.mapNum)
+ {
+ case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_1F):
+ deptStoreFloor = 4;
+ break;
+ case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_2F):
+ deptStoreFloor = 5;
+ break;
+ case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_3F):
+ deptStoreFloor = 6;
+ break;
+ case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_4F):
+ deptStoreFloor = 7;
+ break;
+ case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_5F):
+ deptStoreFloor = 8;
+ break;
+ case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_ROOFTOP):
+ deptStoreFloor = 15;
+ break;
+ default:
+ deptStoreFloor = 4;
+ break;
+ }
+ VarSet(VAR_DEPT_STORE_FLOOR, deptStoreFloor);
+}
+
+u16 sub_81399F4(void)
+{
+ gUnknown_0203AB60 = 0;
+ gUnknown_0203AB62 = 0;
+
+ if (gSaveBlock1Ptr->warp2.mapGroup == 13)
+ {
+ switch (gSaveBlock1Ptr->warp2.mapNum)
+ {
+ case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_5F):
+ gUnknown_0203AB60 = 0;
+ gUnknown_0203AB62 = 0;
+ break;
+ case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_4F):
+ gUnknown_0203AB60 = 0;
+ gUnknown_0203AB62 = 1;
+ break;
+ case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_3F):
+ gUnknown_0203AB60 = 0;
+ gUnknown_0203AB62 = 2;
+ break;
+ case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_2F):
+ gUnknown_0203AB60 = 0;
+ gUnknown_0203AB62 = 3;
+ break;
+ case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_1F):
+ gUnknown_0203AB60 = 0;
+ gUnknown_0203AB62 = 4;
+ break;
+ }
+ }
+
+ return gUnknown_0203AB62;
+}
+
+void ShakeScreenInElevator(void)
+{
+ static const u8 gUnknown_085B2C18[] = { 0x08, 0x10, 0x18, 0x20, 0x26, 0x2e, 0x34, 0x38, 0x39 };
+
+ s16 *data = gTasks[CreateTask(sub_8139AF4, 9)].data;
+ u16 floorDelta;
+
+ data[1] = 0;
+ data[2] = 0;
+ data[4] = 1;
+
+ if (gSpecialVar_0x8005 > gSpecialVar_0x8006)
+ {
+ floorDelta = gSpecialVar_0x8005 - gSpecialVar_0x8006;
+ data[6] = 1;
+ }
+ else
+ {
+ floorDelta = gSpecialVar_0x8006 - gSpecialVar_0x8005;
+ data[6] = 0;
+ }
+
+ if (floorDelta > 8)
+ floorDelta = 8;
+
+ data[5] = gUnknown_085B2C18[floorDelta];
+
+ SetCameraPanningCallback(NULL);
+ sub_8139C2C(floorDelta, data[6]);
+ PlaySE(SE_ELEBETA);
+}
+
+static void sub_8139AF4(u8 taskId)
+{
+ s16 *data = gTasks[taskId].data;
+ data[1]++;
+ if (data[1] % 3 == 0)
+ {
+ data[1] = 0;
+ data[2]++;
+ data[4] = -data[4];
+ SetCameraPanning(0, data[4]);
+ if (data[2] == data[5])
+ {
+ PlaySE(SE_PINPON);
+ DestroyTask(taskId);
+ EnableBothScriptContexts();
+ InstallCameraPanAheadCallback();
+ }
+ }
+}
+
+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);
+}
+
+void sub_8139C10(void)
+{
+ sub_8198070(gUnknown_0203AB5E, TRUE);
+ RemoveWindow(gUnknown_0203AB5E);
+}
+
+static void sub_8139C2C(u16 a1, u8 a2)
+{
+ static const u8 gUnknown_085B2C21[] = { 0x03, 0x06, 0x09, 0x0c, 0x0f, 0x12, 0x15, 0x18, 0x1b };
+
+ if (FuncIsActiveTask(sub_8139C80) != TRUE)
+ {
+ u8 taskId = CreateTask(sub_8139C80, 8);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].data[2] = a2;
+ gTasks[taskId].data[3] = gUnknown_085B2C21[a1];
+ }
+}
+
+// Annoyingly close but compiler wants to add all the parts of the index into the arrays
+// first and then shift by one, whereas we need each individual part to shift and then be added.
+#ifdef NONMATCHING
+static void sub_8139C80(u8 taskId)
+{
+ u8 x, y;
+ s16 *data = gTasks[taskId].data;
+
+ if (data[1] == 6)
+ {
+ data[0]++;
+ if (data[2] == 0)
+ {
+ for (y = 0; y < 3; y++)
+ {
+ for (x = 0; x < 3; x++)
+ {
+ MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2BF4[y * 3 + data[0] % 3] | 0xC00);
+ }
+ }
+ }
+ else
+ {
+ for (y = 0; y < 3; y++)
+ {
+ for (x = 0; x < 3; x++)
+ {
+ MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2C06[y * 3 + data[0] % 3] | 0xC00);
+ }
+ }
+ }
+ DrawWholeMapView();
+ data[1] = 0;
+ if (data[0] == data[3])
+ {
+ DestroyTask(taskId);
+ }
+ }
+ data[1]++;
+}
+#else
+NAKED
+static void sub_8139C80(u8 taskId)
+{
+ asm_unified("push {r4-r7,lr}\n\
+ mov r7, r10\n\
+ mov r6, r9\n\
+ mov r5, r8\n\
+ push {r5-r7}\n\
+ sub sp, 0x4\n\
+ lsls r0, 24\n\
+ lsrs r0, 24\n\
+ str r0, [sp]\n\
+ lsls r0, 2\n\
+ ldr r1, [sp]\n\
+ adds r0, r1\n\
+ lsls r0, 3\n\
+ ldr r1, =gTasks + 0x8\n\
+ adds r6, r0, r1\n\
+ movs r2, 0x2\n\
+ ldrsh r0, [r6, r2]\n\
+ cmp r0, 0x6\n\
+ bne _08139D7C\n\
+ ldrh r0, [r6]\n\
+ adds r0, 0x1\n\
+ strh r0, [r6]\n\
+ movs r1, 0x4\n\
+ ldrsh r0, [r6, r1]\n\
+ cmp r0, 0\n\
+ bne _08139D10\n\
+ movs r1, 0\n\
+ ldr r2, =gUnknown_085B2BF4\n\
+ mov r10, r2\n\
+_08139CBA:\n\
+ movs r5, 0\n\
+ adds r7, r1, 0x7\n\
+ lsls r0, r1, 1\n\
+ adds r2, r1, 0x1\n\
+ mov r8, r2\n\
+ adds r0, r1\n\
+ lsls r0, 1\n\
+ mov r9, r0\n\
+_08139CCA:\n\
+ adds r4, r5, 0\n\
+ adds r4, 0x8\n\
+ movs r1, 0\n\
+ ldrsh r0, [r6, r1]\n\
+ movs r1, 0x3\n\
+ bl __modsi3\n\
+ lsls r0, 16\n\
+ asrs r0, 15\n\
+ add r0, r9\n\
+ add r0, r10\n\
+ ldrh r0, [r0]\n\
+ movs r1, 0xC0\n\
+ lsls r1, 4\n\
+ adds r2, r1, 0\n\
+ orrs r2, r0\n\
+ adds r0, r4, 0\n\
+ adds r1, r7, 0\n\
+ bl MapGridSetMetatileIdAt\n\
+ adds r0, r5, 0x1\n\
+ lsls r0, 24\n\
+ lsrs r5, r0, 24\n\
+ cmp r5, 0x2\n\
+ bls _08139CCA\n\
+ mov r2, r8\n\
+ lsls r0, r2, 24\n\
+ lsrs r1, r0, 24\n\
+ cmp r1, 0x2\n\
+ bls _08139CBA\n\
+ b _08139D62\n\
+ .pool\n\
+_08139D10:\n\
+ movs r1, 0\n\
+ ldr r0, =gUnknown_085B2C06\n\
+ mov r10, r0\n\
+_08139D16:\n\
+ movs r5, 0\n\
+ adds r7, r1, 0x7\n\
+ lsls r0, r1, 1\n\
+ adds r2, r1, 0x1\n\
+ mov r8, r2\n\
+ adds r0, r1\n\
+ lsls r0, 1\n\
+ mov r9, r0\n\
+_08139D26:\n\
+ adds r4, r5, 0\n\
+ adds r4, 0x8\n\
+ movs r1, 0\n\
+ ldrsh r0, [r6, r1]\n\
+ movs r1, 0x3\n\
+ bl __modsi3\n\
+ lsls r0, 16\n\
+ asrs r0, 15\n\
+ add r0, r9\n\
+ add r0, r10\n\
+ ldrh r0, [r0]\n\
+ movs r1, 0xC0\n\
+ lsls r1, 4\n\
+ adds r2, r1, 0\n\
+ orrs r2, r0\n\
+ adds r0, r4, 0\n\
+ adds r1, r7, 0\n\
+ bl MapGridSetMetatileIdAt\n\
+ adds r0, r5, 0x1\n\
+ lsls r0, 24\n\
+ lsrs r5, r0, 24\n\
+ cmp r5, 0x2\n\
+ bls _08139D26\n\
+ mov r2, r8\n\
+ lsls r0, r2, 24\n\
+ lsrs r1, r0, 24\n\
+ cmp r1, 0x2\n\
+ bls _08139D16\n\
+_08139D62:\n\
+ bl DrawWholeMapView\n\
+ movs r0, 0\n\
+ strh r0, [r6, 0x2]\n\
+ movs r0, 0\n\
+ ldrsh r1, [r6, r0]\n\
+ movs r2, 0x6\n\
+ ldrsh r0, [r6, r2]\n\
+ cmp r1, r0\n\
+ bne _08139D7C\n\
+ ldr r0, [sp]\n\
+ bl DestroyTask\n\
+_08139D7C:\n\
+ ldrh r0, [r6, 0x2]\n\
+ adds r0, 0x1\n\
+ strh r0, [r6, 0x2]\n\
+ add sp, 0x4\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");
+}
+#endif // NAKED
+
+void sub_8139D98(void)
+{
+ u8 i;
+ u32 ivStorage[6];
+
+ ivStorage[0] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_HP_IV);
+ ivStorage[1] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_ATK_IV);
+ ivStorage[2] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_DEF_IV);
+ ivStorage[3] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPEED_IV);
+ ivStorage[4] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPATK_IV);
+ ivStorage[5] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPDEF_IV);
+
+ gSpecialVar_0x8005 = 0;
+
+ for (i = 0; i < ARRAY_COUNT(ivStorage); i++)
+ {
+ gSpecialVar_0x8005 += ivStorage[i];
+ }
+
+ gSpecialVar_0x8006 = 0;
+ gSpecialVar_0x8007 = ivStorage[0]; // HP IV
+
+ for (i = 1; i < 6; i++)
+ {
+ if (ivStorage[gSpecialVar_0x8006] < ivStorage[i])
+ {
+ gSpecialVar_0x8006 = i;
+ gSpecialVar_0x8007 = ivStorage[i];
+ }
+ else if (ivStorage[gSpecialVar_0x8006] == ivStorage[i])
+ {
+ u16 randomNumber = Random();
+ if ((randomNumber & 1) != 0)
+ {
+ gSpecialVar_0x8006 = i;
+ gSpecialVar_0x8007 = ivStorage[i];
+ }
+ }
+ }
+}
+
+bool32 warp0_in_pokecenter(void)
+{
+ static const u16 gUnknown_085B2C2A[] = { 0x0202, 0x0301, 0x0405, 0x0504, 0x0604, 0x0700, 0x0804, 0x090b, 0x0a05, 0x0b05, 0x0c02, 0x0d06, 0x0e03, 0x0f02, 0x100c, 0x100a, 0x1a35, 0x193c, 0xffff };
+
+ int i;
+ u16 map = (gUnknown_020322DC.mapGroup << 8) + gUnknown_020322DC.mapNum;
+
+ for (i = 0; gUnknown_085B2C2A[i] != 0xFFFF; i++)
+ {
+ if (gUnknown_085B2C2A[i] == map)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+bool32 sub_8139ED0(void)
+{
+ if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(TRAINER_HILL_ENTRANCE) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_HILL_ENTRANCE))
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void UpdateFrontierManiac(u16 a0)
+{
+ u16 *var = GetVarPointer(VAR_FRONTIER_MANIAC_FACILITY);
+ *var += a0;
+ *var %= 10;
+}
+
+void sub_8139F20(void)
+{
+ static const u8 *const gUnknown_085B2C50[][3] = {
+ { BattleFrontier_Lounge2_Text_260971, BattleFrontier_Lounge2_Text_260A1E, BattleFrontier_Lounge2_Text_260AE7 },
+ { BattleFrontier_Lounge2_Text_2619AC, BattleFrontier_Lounge2_Text_261A91, BattleFrontier_Lounge2_Text_261B0C },
+ { BattleFrontier_Lounge2_Text_261B95, BattleFrontier_Lounge2_Text_261B95, BattleFrontier_Lounge2_Text_261B95 },
+ { BattleFrontier_Lounge2_Text_261C1A, BattleFrontier_Lounge2_Text_261C1A, BattleFrontier_Lounge2_Text_261C1A },
+ { BattleFrontier_Lounge2_Text_260BC4, BattleFrontier_Lounge2_Text_260C6D, BattleFrontier_Lounge2_Text_260D3A },
+ { BattleFrontier_Lounge2_Text_260E1E, BattleFrontier_Lounge2_Text_260EC7, BattleFrontier_Lounge2_Text_260F74 },
+ { BattleFrontier_Lounge2_Text_2614E6, BattleFrontier_Lounge2_Text_261591, BattleFrontier_Lounge2_Text_26166F },
+ { BattleFrontier_Lounge2_Text_261282, BattleFrontier_Lounge2_Text_261329, BattleFrontier_Lounge2_Text_261403 },
+ { BattleFrontier_Lounge2_Text_261026, BattleFrontier_Lounge2_Text_2610CC, BattleFrontier_Lounge2_Text_261194 },
+ { BattleFrontier_Lounge2_Text_26174D, BattleFrontier_Lounge2_Text_2617F9, BattleFrontier_Lounge2_Text_2618C4 },
+ };
+
+ static const u8 gUnknown_085B2CC8[][2] = {
+ { 0x15, 0x38 },
+ { 0x15, 0x23 },
+ { 0xff, 0xff },
+ { 0xff, 0xff },
+ { 0x02, 0x04 },
+ { 0x07, 0x15 },
+ { 0x07, 0x15 },
+ { 0x0e, 0x1c },
+ { 0x0d, 0x70 },
+ { 0x07, 0x38 }
+ };
+
+ u8 i;
+ u16 unk = 0;
+ u16 var = VarGet(VAR_FRONTIER_MANIAC_FACILITY);
+ switch (var)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ if (gSaveBlock2Ptr->frontier.field_CE0[var][0] >= gSaveBlock2Ptr->frontier.field_CE0[var][1])
+ {
+ unk = gSaveBlock2Ptr->frontier.field_CE0[var][0];
+ }
+ else
+ {
+ unk = gSaveBlock2Ptr->frontier.field_CE0[var][1];
+ }
+ break;
+ case 4:
+ if (gSaveBlock2Ptr->frontier.field_D0C[0] >= gSaveBlock2Ptr->frontier.field_D0C[1])
+ {
+ unk = gSaveBlock2Ptr->frontier.field_D0C[0];
+ }
+ else
+ {
+ unk = gSaveBlock2Ptr->frontier.field_D0C[1];
+ }
+ break;
+ case 5:
+ if (gSaveBlock2Ptr->frontier.field_DE2[0] >= gSaveBlock2Ptr->frontier.field_DE2[1])
+ {
+ unk = gSaveBlock2Ptr->frontier.field_DE2[0];
+ }
+ else
+ {
+ unk = gSaveBlock2Ptr->frontier.field_DE2[1];
+ }
+ break;
+ case 6:
+ if (gSaveBlock2Ptr->frontier.field_DC8[0] >= gSaveBlock2Ptr->frontier.field_DC8[1])
+ {
+ unk = gSaveBlock2Ptr->frontier.field_DC8[0];
+ }
+ else
+ {
+ unk = gSaveBlock2Ptr->frontier.field_DC8[1];
+ }
+ break;
+ case 7:
+ if (gSaveBlock2Ptr->frontier.field_DDA[0] >= gSaveBlock2Ptr->frontier.field_DDA[1])
+ {
+ unk = gSaveBlock2Ptr->frontier.field_DDA[0];
+ }
+ else
+ {
+ unk = gSaveBlock2Ptr->frontier.field_DDA[1];
+ }
+ break;
+ case 8:
+ if (gSaveBlock2Ptr->frontier.field_E04[0] >= gSaveBlock2Ptr->frontier.field_E04[1])
+ {
+ unk = gSaveBlock2Ptr->frontier.field_E04[0];
+ }
+ else
+ {
+ unk = gSaveBlock2Ptr->frontier.field_E04[1];
+ }
+ break;
+ case 9:
+ if (gSaveBlock2Ptr->frontier.field_E1A[0] >= gSaveBlock2Ptr->frontier.field_E1A[1])
+ {
+ unk = gSaveBlock2Ptr->frontier.field_E1A[0];
+ }
+ else
+ {
+ unk = gSaveBlock2Ptr->frontier.field_E1A[1];
+ }
+ break;
+ }
+
+ for (i = 0; i < 2 && gUnknown_085B2CC8[var][i] < unk; i++);
+
+ ShowFieldMessage(gUnknown_085B2C50[var][i]);
+}
+
+void sub_813A080(void)
+{
+ static const u16 gUnknown_085B2CDC[] = {
+ 0x0007, 0x000e, 0x0015, 0x001c, 0x0023, 0x0031, 0x003f, 0x004d, 0x005b, 0x0000
+ };
+
+ u8 i;
+ u16 var = VarGet(VAR_0x40CE);
+ u8 chosenLevel = gSaveBlock2Ptr->frontier.chosenLvl;
+
+ if (var == 2 && !FlagGet(FLAG_0x152))
+ {
+ gSpecialVar_0x8005 = 5;
+ gSpecialVar_0x8006 = 4;
+ return;
+ }
+
+ for (i = 0; i < 9; i++)
+ {
+ if (gUnknown_085B2CDC[i] > gSaveBlock2Ptr->frontier.field_CE0[var][chosenLevel])
+ {
+ gSpecialVar_0x8005 = 4;
+ gSpecialVar_0x8006 = i + 5;
+ return;
+ }
+ }
+
+ gSpecialVar_0x8005 = 4;
+ gSpecialVar_0x8006 = 12;
+}
+
+void sub_813A128(void)
+{
+ u8 taskId = CreateTask(sub_813A2DC, 8);
+ struct Task *task = &gTasks[taskId];
+ task->data[11] = gSpecialVar_0x8004;
+
+ switch (gSpecialVar_0x8004)
+ {
+ case 0:
+ task->data[0] = 1;
+ task->data[1] = 1;
+ task->data[2] = 1;
+ task->data[3] = 1;
+ task->data[4] = 1;
+ task->data[5] = 1;
+ task->data[6] = 0;
+ task->data[15] = taskId;
+ break;
+ case 1:
+ task->data[0] = 5;
+ task->data[1] = 8;
+ task->data[2] = 1;
+ task->data[3] = 1;
+ task->data[4] = 9;
+ task->data[5] = 10;
+ task->data[6] = 0;
+ task->data[15] = taskId;
+ break;
+ case 2:
+ task->data[0] = 6;
+ task->data[1] = 12;
+ task->data[2] = 1;
+ task->data[3] = 1;
+ task->data[4] = 7;
+ task->data[5] = 12;
+ task->data[6] = 0;
+ task->data[15] = taskId;
+ break;
+ case 3:
+ task->data[0] = 6;
+ task->data[1] = 11;
+ task->data[2] = 14;
+ task->data[3] = 1;
+ task->data[4] = 15;
+ task->data[5] = 12;
+ task->data[6] = 0;
+ task->data[15] = taskId;
+ break;
+ case 4:
+ task->data[0] = 6;
+ task->data[1] = 6;
+ task->data[2] = 14;
+ task->data[3] = 1;
+ task->data[4] = 15;
+ task->data[5] = 12;
+ task->data[6] = 0;
+ task->data[15] = taskId;
+ break;
+ case 5:
+ task->data[0] = 6;
+ task->data[1] = 7;
+ task->data[2] = 14;
+ task->data[3] = 1;
+ task->data[4] = 15;
+ task->data[5] = 12;
+ task->data[6] = 0;
+ task->data[15] = taskId;
+ break;
+ case 6:
+ task->data[0] = 6;
+ task->data[1] = 10;
+ task->data[2] = 14;
+ task->data[3] = 1;
+ task->data[4] = 15;
+ task->data[5] = 12;
+ task->data[6] = 0;
+ task->data[15] = taskId;
+ break;
+ case 7:
+ task->data[0] = 6;
+ task->data[1] = 12;
+ task->data[2] = 15;
+ task->data[3] = 1;
+ task->data[4] = 14;
+ task->data[5] = 12;
+ task->data[6] = 0;
+ task->data[15] = taskId;
+ break;
+ case 8:
+ task->data[0] = 6;
+ task->data[1] = 10;
+ task->data[2] = 17;
+ task->data[3] = 1;
+ task->data[4] = 11;
+ task->data[5] = 12;
+ task->data[6] = 0;
+ task->data[15] = taskId;
+ break;
+ case 9:
+ case 10:
+ task->data[0] = 6;
+ task->data[1] = 11;
+ task->data[2] = 15;
+ task->data[3] = 1;
+ task->data[4] = 14;
+ task->data[5] = 12;
+ task->data[6] = 0;
+ task->data[15] = taskId;
+ break;
+ case 11:
+ task->data[0] = 6;
+ task->data[1] = 7;
+ task->data[2] = 19;
+ task->data[3] = 1;
+ task->data[4] = 10;
+ task->data[5] = 12;
+ task->data[6] = 0;
+ task->data[15] = taskId;
+ break;
+ case 12:
+ task->data[0] = 6;
+ task->data[1] = 7;
+ task->data[2] = 17;
+ task->data[3] = 1;
+ task->data[4] = 12;
+ task->data[5] = 12;
+ task->data[6] = 0;
+ task->data[15] = taskId;
+ break;
+ default:
+ gSpecialVar_Result = 0x7F;
+ DestroyTask(taskId);
+ break;
+ }
+}
+
+static const u8 *const gUnknown_085B2CF0[][16] = {
+ {
+ gText_Exit,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ gText_BlueFlute,
+ gText_YellowFlute,
+ gText_RedFlute,
+ gText_WhiteFlute,
+ gText_BlackFlute,
+ gText_PrettyChair,
+ gText_PrettyDesk,
+ gText_Exit,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ gText_0Pts,
+ gText_10Pts,
+ gText_20Pts,
+ gText_30Pts,
+ gText_40Pts,
+ gText_50Pts,
+ gText_60Pts,
+ gText_70Pts,
+ gText_80Pts,
+ gText_90Pts,
+ gText_100Pts,
+ gText_QuestionMark,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ gText_KissPoster16BP,
+ gText_KissCushion32BP,
+ gText_SmoochumDoll32BP,
+ gText_TogepiDoll48BP,
+ gText_MeowthDoll48BP,
+ gText_ClefairyDoll48BP,
+ gText_DittoDoll48BP,
+ gText_CyndaquilDoll80BP,
+ gText_ChikoritaDoll80BP,
+ gText_TotodileDoll80BP,
+ gText_Exit,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ gText_LaprasDoll128BP,
+ gText_SnorlaxDoll128BP,
+ gText_VenusaurDoll256BP,
+ gText_CharizardDoll256BP,
+ gText_BlastoiseDoll256BP,
+ gText_Exit,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ gText_Protein1BP,
+ gText_Calcium1BP,
+ gText_Iron1BP,
+ gText_Zinc1BP,
+ gText_Carbos1BP,
+ gText_HpUp1BP,
+ gText_Exit,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ gText_Leftovers48BP,
+ gText_WhiteHerb48BP,
+ gText_QuickClaw48BP,
+ gText_MentalHerb48BP,
+ gText_BrightPowder64BP,
+ gText_ChoiceBand64BP,
+ gText_KingsRock64BP,
+ gText_FocusBand64BP,
+ gText_ScopeLens64BP,
+ gText_Exit,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ gText_EnergyPowder50,
+ gText_EnergyRoot80,
+ gText_HealPowder50,
+ gText_RevivalHerb300,
+ gText_Protein1000,
+ gText_Iron1000,
+ gText_Carbos1000,
+ gText_Calcium1000,
+ gText_Zinc1000,
+ gText_HPUp1000,
+ gText_PPUp3000,
+ gText_Exit,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ gText_BattleTower2,
+ gText_BattleDome,
+ gText_BattlePalace,
+ gText_BattleArena,
+ gText_BattleFactory,
+ gText_BattlePike,
+ gText_BattlePyramid,
+ gText_RankingHall,
+ gText_ExchangeService,
+ gText_Exit,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ gText_Softboiled16BP,
+ gText_SeismicToss24BP,
+ gText_DreamEater24BP,
+ gText_MegaPunch24BP,
+ gText_MegaKick48BP,
+ gText_BodySlam48BP,
+ gText_RockSlide48BP,
+ gText_Counter48BP,
+ gText_ThunderWave48BP,
+ gText_SwordsDance48BP,
+ gText_Exit,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ gText_DefenseCurl16BP,
+ gText_Snore24BP,
+ gText_MudSlap24BP,
+ gText_Swift24BP,
+ gText_IcyWind24BP,
+ gText_Endure48BP,
+ gText_PsychUp48BP,
+ gText_IcePunch48BP,
+ gText_ThunderPunch48BP,
+ gText_FirePunch48BP,
+ gText_Exit,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ gText_SlateportCity,
+ gText_BattleFrontier,
+ gText_SouthernIsland,
+ gText_NavelRock,
+ gText_BirthIsland,
+ gText_FarawayIsland,
+ gText_Exit,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ gText_BattleTrainers,
+ gText_BattleBasics,
+ gText_PokemonNature,
+ gText_PokemonMoves,
+ gText_Underpowered,
+ gText_WhenInDanger,
+ gText_Exit,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ }
+};
+
+static void sub_813A2DC(u8 taskId)
+{
+ u32 unk1;
+ u8 i, windowId;
+ struct WindowTemplate template;
+ struct Task *task = &gTasks[taskId];
+
+ ScriptContext2_Enable();
+ gUnknown_0203AB68 = 0;
+ gUnknown_0203AB6C = 0x40;
+ sub_813AA60(task->data[11], 0);
+ sub_813ACE8(task->data[11], 0);
+ gUnknown_0203AB64 = AllocZeroed(task->data[1] * 8);
+ gUnknown_0203AB6A = 0;
+ sub_813A42C();
+
+ for (unk1 = 0, i = 0; i < task->data[1]; i++)
+ {
+ const u8 *text = gUnknown_085B2CF0[gSpecialVar_0x8004][i];
+ gUnknown_0203AB64[i].name = text;
+ gUnknown_0203AB64[i].id = i;
+ unk1 = display_text_and_get_width(text, unk1);
+ }
+
+ task->data[4] = convert_pixel_width_to_tile_width(unk1);
+
+ if (task->data[2] + task->data[4] > 0x1D)
+ {
+ int unk2 = 0x1D - task->data[4];
+ if (unk2 < 0)
+ {
+ task->data[2] = 0;
+ }
+ else
+ {
+ task->data[2] = unk2;
+ }
+ }
+
+ template = CreateWindowTemplate(0, task->data[2], task->data[3], task->data[4], task->data[5], 0xF, 0x64);
+ windowId = AddWindow(&template);
+ task->data[13] = windowId;
+ SetStandardWindowBorderStyle(windowId, 0);
+
+ gUnknown_030061D0.totalItems = task->data[1];
+ gUnknown_030061D0.maxShowed = task->data[0];
+ gUnknown_030061D0.windowId = task->data[13];
+
+ sub_813A694(taskId);
+ task->data[14] = ListMenuInit(&gUnknown_030061D0, task->data[7], task->data[8]);
+ schedule_bg_copy_tilemap_to_vram(0);
+ gTasks[taskId].func = sub_813A4EC;
+}
+
+static void sub_813A42C(void)
+{
+ gUnknown_030061D0.items = gUnknown_0203AB64;
+ gUnknown_030061D0.moveCursorFunc = sub_813A46C;
+ gUnknown_030061D0.itemPrintFunc = NULL;
+ gUnknown_030061D0.totalItems = 1;
+ gUnknown_030061D0.maxShowed = 1;
+ gUnknown_030061D0.windowId = 0;
+ gUnknown_030061D0.header_X = 0;
+ gUnknown_030061D0.item_X = 8;
+ gUnknown_030061D0.cursor_X = 0;
+ gUnknown_030061D0.upText_Y = 1;
+ gUnknown_030061D0.cursorPal = 2;
+ gUnknown_030061D0.fillValue = 1;
+ gUnknown_030061D0.cursorShadowPal = 3;
+ gUnknown_030061D0.lettersSpacing = 0;
+ gUnknown_030061D0.itemVerticalPadding = 0;
+ gUnknown_030061D0.scrollMultiple = 0;
+ gUnknown_030061D0.fontId = 1;
+ gUnknown_030061D0.cursorKind = 0;
+}
+
+static void sub_813A46C(s32 itemIndex, bool8 onInit, struct ListMenu *list)
+{
+ u8 taskId;
+ PlaySE(SE_SELECT);
+ taskId = FindTaskIdByFunc(sub_813A4EC);
+ if (taskId != 0xFF)
+ {
+ u16 misc;
+ struct Task *task = &gTasks[taskId];
+ ListMenuGetScrollAndRow(task->data[14], &misc, NULL);
+ gUnknown_0203AB68 = misc;
+ ListMenuGetCurrentItemArrayId(task->data[14], &misc);
+ sub_813AC44(task->data[11], gUnknown_0203AB6A);
+ sub_813AA60(task->data[11], misc);
+ sub_813AD34(task->data[11], misc);
+ gUnknown_0203AB6A = misc;
+ }
+}
+
+// stupid r5<->r6 swap
+#ifdef NONMATCHING
+static void sub_813A4EC(u8 taskId)
+{
+ struct Task *task = &gTasks[taskId];
+ s32 itemId = ListMenuHandleInputGetItemId(task->data[14]);
+
+ switch (itemId)
+ {
+ case LIST_NOTHING_CHOSEN:
+ break;
+ case LIST_B_PRESSED:
+ gSpecialVar_Result = 0x7F;
+ PlaySE(SE_SELECT);
+ sub_813A570(taskId);
+ break;
+ default:
+ gSpecialVar_Result = itemId;
+ PlaySE(SE_SELECT);
+ if (!task->data[6] || itemId == task->data[1] - 1)
+ {
+ sub_813A570(taskId);
+ }
+ else
+ {
+ sub_813A738(taskId);
+ task->func = sub_813A600;
+ EnableBothScriptContexts();
+ }
+ break;
+ }
+}
+#else
+NAKED
+static void sub_813A4EC(u8 taskId)
+{
+ asm_unified("push {r4-r6,lr}\n\
+ lsls r0, 24\n\
+ lsrs r5, r0, 24\n\
+ lsls r0, r5, 2\n\
+ adds r0, r5\n\
+ lsls r0, 3\n\
+ ldr r1, =gTasks\n\
+ adds r6, r0, r1\n\
+ ldrh r0, [r6, 0x24]\n\
+ lsls r0, 24\n\
+ lsrs r0, 24\n\
+ bl ListMenuHandleInputGetItemId\n\
+ adds r4, r0, 0\n\
+ movs r0, 0x2\n\
+ negs r0, r0\n\
+ cmp r4, r0\n\
+ beq _0813A51C\n\
+ adds r0, 0x1\n\
+ cmp r4, r0\n\
+ bne _0813A530\n\
+ b _0813A566\n\
+ .pool\n\
+_0813A51C:\n\
+ ldr r1, =gSpecialVar_Result\n\
+ movs r0, 0x7F\n\
+ strh r0, [r1]\n\
+ movs r0, 0x5\n\
+ bl PlaySE\n\
+ b _0813A54C\n\
+ .pool\n\
+_0813A530:\n\
+ ldr r0, =gSpecialVar_Result\n\
+ strh r4, [r0]\n\
+ movs r0, 0x5\n\
+ bl PlaySE\n\
+ movs r1, 0x14\n\
+ ldrsh r0, [r6, r1]\n\
+ cmp r0, 0\n\
+ beq _0813A54C\n\
+ movs r1, 0xA\n\
+ ldrsh r0, [r6, r1]\n\
+ subs r0, 0x1\n\
+ cmp r4, r0\n\
+ bne _0813A558\n\
+_0813A54C:\n\
+ adds r0, r5, 0\n\
+ bl sub_813A570\n\
+ b _0813A566\n\
+ .pool\n\
+_0813A558:\n\
+ adds r0, r5, 0\n\
+ bl sub_813A738\n\
+ ldr r0, =sub_813A600\n\
+ str r0, [r6]\n\
+ bl EnableBothScriptContexts\n\
+_0813A566:\n\
+ pop {r4-r6}\n\
+ pop {r0}\n\
+ bx r0\n\
+ .pool");
+}
+#endif // NONMATCHING
+
+static void sub_813A570(u8 taskId)
+{
+ u16 array;
+ struct Task *task = &gTasks[taskId];
+ ListMenuGetCurrentItemArrayId(task->data[14], &array);
+ sub_813AC44(task->data[11], array);
+ sub_813A738(taskId);
+ DestroyListMenuTask(task->data[14], NULL, NULL);
+ Free(gUnknown_0203AB64);
+ sub_8198070(task->data[13], 1);
+ FillWindowPixelBuffer(task->data[13], 0);
+ CopyWindowToVram(task->data[13], 2);
+ RemoveWindow(task->data[13]);
+ DestroyTask(taskId);
+ EnableBothScriptContexts();
+}
+
+static void sub_813A600(u8 taskId)
+{
+ switch (gTasks[taskId].data[6])
+ {
+ case 1:
+ default:
+ break;
+ case 2:
+ gTasks[taskId].data[6] = 1;
+ gTasks[taskId].func = sub_813A664;
+ break;
+ }
+}
+
+void sub_813A630(void)
+{
+ u8 taskId = FindTaskIdByFunc(sub_813A600);
+ if (taskId == 0xFF)
+ {
+ EnableBothScriptContexts();
+ }
+ else
+ {
+ gTasks[taskId].data[6]++;
+ }
+}
+
+static void sub_813A664(u8 taskId)
+{
+ ScriptContext2_Enable();
+ sub_813A694(taskId);
+ gTasks[taskId].func = sub_813A4EC;
+}
+
+static void sub_813A694(u8 taskId)
+{
+ static const struct ScrollArrowsTemplate gUnknown_085B3030 = {
+ .firstArrowType = 2,
+ .firstX = 0,
+ .firstY = 0,
+ .secondArrowType = 3,
+ .secondX = 0,
+ .secondY = 0,
+ .fullyUpThreshold = 0,
+ .fullyDownThreshold = 0,
+ .tileTag = 2000,
+ .palTag = 100,
+ .palNum = 0
+ };
+
+ struct Task *task = &gTasks[taskId];
+ struct ScrollArrowsTemplate template = gUnknown_085B3030;
+ if (task->data[0] != task->data[1])
+ {
+ template.firstX = (task->data[4] / 2) * 8 + 12 + (task->data[2] - 1) * 8;
+ template.firstY = 8;
+ template.secondX = (task->data[4] / 2) * 8 + 12 + (task->data[2] - 1) * 8;
+ template.secondY = task->data[5] * 8 + 10;
+ template.fullyUpThreshold = 0;
+ template.fullyDownThreshold = task->data[1] - task->data[0];
+ task->data[12] = AddScrollIndicatorArrowPair(&template, &gUnknown_0203AB68);
+ }
+}
+
+static void sub_813A738(u8 taskId)
+{
+ struct Task *task = &gTasks[taskId];
+ if (task->data[0] != task->data[1])
+ {
+ RemoveScrollIndicatorArrowPair(task->data[12]);
+ }
+}
+
+void nullsub_55(void)
+{
+
+}
+
+void sub_813A76C(void)
+{
+ u8 i;
+ for (i = 0; i < 2; i++)
+ {
+ if (gLinkPlayers[i].gender == MALE)
+ {
+ VarSet(VAR_OBJ_GFX_ID_F - i, EVENT_OBJ_GFX_BRENDAN_NORMAL);
+ }
+ else
+ {
+ VarSet(VAR_OBJ_GFX_ID_F - i, EVENT_OBJ_GFX_RIVAL_MAY_NORMAL);
+ }
+ }
+}
+
+void sub_813A7B8(void)
+{
+ static const u8 *const gUnknown_085B3040[] = {
+ BattleFrontier_Lounge5_Text_26468D,
+ BattleFrontier_Lounge5_Text_2646E5,
+ BattleFrontier_Lounge5_Text_264741,
+ BattleFrontier_Lounge5_Text_2647A4,
+ BattleFrontier_Lounge5_Text_2647FC,
+ BattleFrontier_Lounge5_Text_264858,
+ BattleFrontier_Lounge5_Text_2648BE,
+ BattleFrontier_Lounge5_Text_264916,
+ BattleFrontier_Lounge5_Text_264972,
+ BattleFrontier_Lounge5_Text_2649D5,
+ BattleFrontier_Lounge5_Text_264A3F,
+ BattleFrontier_Lounge5_Text_264A9B,
+ BattleFrontier_Lounge5_Text_264AF3,
+ BattleFrontier_Lounge5_Text_264B5D,
+ BattleFrontier_Lounge5_Text_2648BE,
+ BattleFrontier_Lounge5_Text_264BC3,
+ BattleFrontier_Lounge5_Text_264C36,
+ BattleFrontier_Lounge5_Text_2648BE,
+ BattleFrontier_Lounge5_Text_264C95,
+ BattleFrontier_Lounge5_Text_264D01,
+ BattleFrontier_Lounge5_Text_264D6B,
+ BattleFrontier_Lounge5_Text_264DD7,
+ BattleFrontier_Lounge5_Text_264E33,
+ BattleFrontier_Lounge5_Text_264E8F,
+ BattleFrontier_Lounge5_Text_2648BE,
+ };
+
+ u8 nature;
+
+ if (gSpecialVar_0x8004 >= PARTY_SIZE)
+ {
+ gSpecialVar_0x8004 = 0;
+ }
+
+ nature = GetNature(&gPlayerParty[gSpecialVar_0x8004]);
+ ShowFieldMessage(gUnknown_085B3040[nature]);
+}
+
+void UpdateFrontierGambler(u16 a0)
+{
+ u16 *var = GetVarPointer(VAR_FRONTIER_GAMBLER_FACILITY);
+ *var += a0;
+ *var %= 12;
+}
+
+void sub_813A820(void)
+{
+ static const u8 *const gUnknown_085B30A4[] = {
+ BattleFrontier_Lounge3_Text_262261,
+ BattleFrontier_Lounge3_Text_26230D,
+ BattleFrontier_Lounge3_Text_2623B9,
+ BattleFrontier_Lounge3_Text_262464,
+ BattleFrontier_Lounge3_Text_26250E,
+ BattleFrontier_Lounge3_Text_2625B8,
+ BattleFrontier_Lounge3_Text_26266A,
+ BattleFrontier_Lounge3_Text_26271C,
+ BattleFrontier_Lounge3_Text_2627C9,
+ BattleFrontier_Lounge3_Text_262876,
+ BattleFrontier_Lounge3_Text_26291A,
+ BattleFrontier_Lounge3_Text_2629BC,
+ };
+
+ u16 var = VarGet(VAR_FRONTIER_GAMBLER_FACILITY);
+ ShowFieldMessage(gUnknown_085B30A4[var]);
+ VarSet(VAR_FRONTIER_GAMBLER_SET_FACILITY_F, var);
+}
+
+void sub_813A854(void)
+{
+ static const u8 *const gUnknown_085B30D4[] = {
+ BattleFrontier_Lounge3_Text_262C04,
+ BattleFrontier_Lounge3_Text_262C90,
+ BattleFrontier_Lounge3_Text_262D1C,
+ BattleFrontier_Lounge3_Text_262DA7,
+ BattleFrontier_Lounge3_Text_262E34,
+ BattleFrontier_Lounge3_Text_262EC1,
+ BattleFrontier_Lounge3_Text_262F56,
+ BattleFrontier_Lounge3_Text_262FEB,
+ BattleFrontier_Lounge3_Text_263078,
+ BattleFrontier_Lounge3_Text_263105,
+ BattleFrontier_Lounge3_Text_26318C,
+ BattleFrontier_Lounge3_Text_263211,
+ };
+
+ ShowFieldMessage(gUnknown_085B30D4[VarGet(VAR_FRONTIER_GAMBLER_SET_FACILITY_F)]);
+}
+
+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 var2 = VarGet(VAR_FRONTIER_GAMBLER_SET_FACILITY_F);
+ u16 var3 = VarGet(VAR_FRONTIER_FACILITY);
+
+ if (VarGet(VAR_FRONTIER_GAMBLER_PLACED_BET_F) == 1)
+ {
+ if (gUnknown_085B3104[var2] == (var3 << 8) + var1)
+ {
+ if (a0 != 0)
+ {
+ VarSet(VAR_FRONTIER_GAMBLER_PLACED_BET_F, 2);
+ }
+ else
+ {
+ VarSet(VAR_FRONTIER_GAMBLER_PLACED_BET_F, 3);
+ }
+ }
+ }
+}
+
+void sub_813A8FC(void)
+{
+ u8 string[32];
+ u32 x;
+ StringCopy(ConvertIntToDecimalStringN(string, gSaveBlock2Ptr->frontier.frontierBattlePoints, STR_CONV_MODE_RIGHT_ALIGN, 4), gText_BP);
+ x = GetStringRightAlignXOffset(1, string, 48);
+ PrintTextOnWindow(gUnknown_0203AB6D, 1, string, x, 1, 0, NULL);
+}
+
+void sub_813A958(void)
+{
+ static const struct WindowTemplate gUnknown_085B311C = {
+ .priority = 0,
+ .tilemapLeft = 1,
+ .tilemapTop = 1,
+ .width = 6,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 8,
+ };
+
+ gUnknown_0203AB6D = AddWindow(&gUnknown_085B311C);
+ SetStandardWindowBorderStyle(gUnknown_0203AB6D, 0);
+ sub_813A8FC();
+ CopyWindowToVram(gUnknown_0203AB6D, 2);
+}
+
+void sub_813A988(void)
+{
+ sub_8198070(gUnknown_0203AB6D, TRUE);
+ RemoveWindow(gUnknown_0203AB6D);
+}
+
+void sub_813A9A4(void)
+{
+ if (gSaveBlock2Ptr->frontier.frontierBattlePoints < gSpecialVar_0x8004)
+ {
+ gSaveBlock2Ptr->frontier.frontierBattlePoints = 0;
+ }
+ else
+ {
+ gSaveBlock2Ptr->frontier.frontierBattlePoints -= gSpecialVar_0x8004;
+ }
+}
+
+void sub_813A9D0(void)
+{
+ if (gSaveBlock2Ptr->frontier.frontierBattlePoints + gSpecialVar_0x8004 > 0x270F)
+ {
+ gSaveBlock2Ptr->frontier.frontierBattlePoints = 0x270f;
+ }
+ else
+ {
+ gSaveBlock2Ptr->frontier.frontierBattlePoints = gSaveBlock2Ptr->frontier.frontierBattlePoints + gSpecialVar_0x8004;
+ }
+}
+
+u16 sub_813AA04(void)
+{
+ return gSaveBlock2Ptr->frontier.frontierBattlePoints;
+}
+
+void sub_813AA18(void)
+{
+ static const struct WindowTemplate gUnknown_085B3124 = {
+ .priority = 0,
+ .tilemapLeft = 2,
+ .tilemapTop = 9,
+ .width = 4,
+ .height = 4,
+ .paletteNum = 15,
+ .baseBlock = 20,
+ };
+
+ gUnknown_0203AB6E = AddWindow(&gUnknown_085B3124);
+ SetStandardWindowBorderStyle(gUnknown_0203AB6E, 0);
+ CopyWindowToVram(gUnknown_0203AB6E, 2);
+}
+
+void sub_813AA44(void)
+{
+ sub_8198070(gUnknown_0203AB6E, TRUE);
+ RemoveWindow(gUnknown_0203AB6E);
+}
+
+static void sub_813AA60(u16 a0, u16 a1)
+{
+ static const u16 gUnknown_085B312C[] = { 0x004b, 0x0067, 0x0057, 0x004f, 0x0054, 0x0055, 0x0056, 0x0050, 0x0051, 0x0052, 0xffff };
+ static const u16 gUnknown_085B3142[] = { 0x0071, 0x006f, 0x0072, 0x0073, 0x0074, 0xffff };
+ static const u16 gUnknown_085B314E[] = { 0x0040, 0x0043, 0x0041, 0x0046, 0x0042, 0x003f, 0xffff };
+ static const u16 gUnknown_085B315C[] = { 0x00c8, 0x00b4, 0x00b7, 0x00b9, 0x00b3, 0x00ba, 0x00bb, 0x00c4, 0x00c6, 0xffff };
+
+ static const u8 *const gUnknown_085B3170[] = {
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_2601AA,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_2601D0,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_260201,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_26022F,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_26025B,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_260287,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_2602B5,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_2602E0,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_26030F,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_26033E,
+ gText_Exit,
+ };
+
+ static const u8 *const gUnknown_085B319C[] = {
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_26036C,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_26036C,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_26036C,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_26036C,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_26036C,
+ gText_Exit
+ };
+
+ static const u8 *const gUnknown_085B31B4[] = {
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_260397,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_2603BE,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_2603E6,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_26040E,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_260436,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_26045C,
+ gText_Exit
+ };
+
+ static const u8 *const gUnknown_085B31D0[] = {
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_26047A,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_2604AC,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_2604D8,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_26050F,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_260542,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_260575,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_2605A8,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_2605E2,
+ BattleFrontier_BattlePointExchangeServiceCorner_Text_260613,
+ gText_Exit
+ };
+
+ if (a0 > 2 && a0 < 7)
+ {
+ FillWindowPixelRect(0, 0x11, 0, 0, 216, 32);
+ switch (a0)
+ {
+ case 3:
+ AddTextPrinterParameterized(0, 1, gUnknown_085B3170[a1], 0, NULL, 2, 1, 3);
+ if (gUnknown_085B312C[a1] == 0xFFFF)
+ {
+ sub_813ABD4(gUnknown_085B312C[a1]);
+ }
+ else
+ {
+ FreeSpriteTilesByTag(5500);
+ FreeSpritePaletteByTag(5500);
+ gUnknown_0203AB6C = AddDecorationIconObject(gUnknown_085B312C[a1], 33, 88, 0, 5500, 5500);
+ }
+ break;
+ case 4:
+ AddTextPrinterParameterized(0, 1, gUnknown_085B319C[a1], 0, NULL, 2, 1, 3);
+ if (gUnknown_085B3142[a1] == 0xFFFF)
+ {
+ sub_813ABD4(gUnknown_085B3142[a1]);
+ }
+ else
+ {
+ FreeSpriteTilesByTag(5500);
+ FreeSpritePaletteByTag(5500);
+ gUnknown_0203AB6C = AddDecorationIconObject(gUnknown_085B3142[a1], 33, 88, 0, 5500, 5500);
+ }
+ break;
+ case 5:
+ AddTextPrinterParameterized(0, 1, gUnknown_085B31B4[a1], 0, NULL, 2, 1, 3);
+ sub_813ABD4(gUnknown_085B314E[a1]);
+ break;
+ case 6:
+ AddTextPrinterParameterized(0, 1, gUnknown_085B31D0[a1], 0, NULL, 2, 1, 3);
+ sub_813ABD4(gUnknown_085B315C[a1]);
+ break;
+ }
+ }
+}
+
+static void sub_813ABD4(u16 a0)
+{
+ FreeSpriteTilesByTag(5500);
+ FreeSpritePaletteByTag(5500);
+ gUnknown_0203AB6C = AddItemIconSprite(5500, 5500, a0);
+
+ if (gUnknown_0203AB6C != MAX_SPRITES)
+ {
+ gSprites[gUnknown_0203AB6C].oam.priority = 0;
+ gSprites[gUnknown_0203AB6C].pos1.x = 36;
+ gSprites[gUnknown_0203AB6C].pos1.y = 92;
+ }
+}
+
+static void sub_813AC44(u16 a0, u16 unused)
+{
+ if (gUnknown_0203AB6C != MAX_SPRITES)
+ {
+ switch (a0)
+ {
+ case 3 ... 6:
+ DestroySpriteAndFreeResources(&gSprites[gUnknown_0203AB6C]);
+ break;
+ }
+ gUnknown_0203AB6C = MAX_SPRITES;
+ }
+}
+
+static const u16 gUnknown_085B31F8[] = { 0x0087, 0x0045, 0x008a, 0x0005, 0x0019, 0x0022, 0x009d, 0x0044, 0x0056, 0x000e };
+static const u16 gUnknown_085B320C[] = { 0x006f, 0x00ad, 0x00bd, 0x0081, 0x00c4, 0x00cb, 0x00f4, 0x0008, 0x0009, 0x0007 };
+
+void sub_813AC7C(void)
+{
+ if (gSpecialVar_0x8005 != 0)
+ {
+ StringCopy(gStringVar1, gMoveNames[gUnknown_085B320C[gSpecialVar_0x8004]]);
+ }
+ else
+ {
+ StringCopy(gStringVar1, gMoveNames[gUnknown_085B31F8[gSpecialVar_0x8004]]);
+ }
+}
+
+static void sub_813ACE8(u8 a0, u16 a1)
+{
+ static const struct WindowTemplate gUnknown_085B3220 = {
+ .priority = 0,
+ .tilemapLeft = 1,
+ .tilemapTop = 7,
+ .width = 12,
+ .height = 6,
+ .paletteNum = 15,
+ .baseBlock = 28,
+ };
+
+ if (a0 == 9 || a0 == 10)
+ {
+ if (gSpecialVar_0x8006 == 0)
+ {
+ gUnknown_0203AB5E = AddWindow(&gUnknown_085B3220);
+ SetStandardWindowBorderStyle(gUnknown_0203AB5E, 0);
+ }
+ sub_813AD34(a0, a1);
+ }
+}
+
+static void sub_813AD34(u8 a0, u16 a1)
+{
+ static const u8 *const gUnknown_085B3228[] = {
+ BattleFrontier_Lounge7_Text_265E30,
+ BattleFrontier_Lounge7_Text_265E5B,
+ BattleFrontier_Lounge7_Text_265E8A,
+ BattleFrontier_Lounge7_Text_265EC0,
+ BattleFrontier_Lounge7_Text_265EED,
+ BattleFrontier_Lounge7_Text_265F1C,
+ BattleFrontier_Lounge7_Text_265F47,
+ BattleFrontier_Lounge7_Text_265F77,
+ BattleFrontier_Lounge7_Text_265FAA,
+ BattleFrontier_Lounge7_Text_265FDD,
+ gText_Exit,
+ };
+
+ static const u8 *const gUnknown_085B3254[] = {
+ BattleFrontier_Lounge7_Text_26600A,
+ BattleFrontier_Lounge7_Text_26603E,
+ BattleFrontier_Lounge7_Text_266070,
+ BattleFrontier_Lounge7_Text_2660A6,
+ BattleFrontier_Lounge7_Text_2660D0,
+ BattleFrontier_Lounge7_Text_2660FF,
+ BattleFrontier_Lounge7_Text_26612D,
+ BattleFrontier_Lounge7_Text_26615F,
+ BattleFrontier_Lounge7_Text_266185,
+ BattleFrontier_Lounge7_Text_2661B5,
+ gText_Exit,
+ };
+
+ if (a0 == 9 || a0 == 10)
+ {
+ FillWindowPixelRect(gUnknown_0203AB5E, 0x11, 0, 0, 96, 48);
+ if (a0 == 10)
+ {
+ PrintTextOnWindow(gUnknown_0203AB5E, 1, gUnknown_085B3254[a1], 0, 1, 0, NULL);
+ }
+ else
+ {
+ PrintTextOnWindow(gUnknown_0203AB5E, 1, gUnknown_085B3228[a1], 0, 1, 0, NULL);
+ }
+ }
+}
+
+void sub_813ADB8(void)
+{
+ sub_8198070(gUnknown_0203AB5E, TRUE);
+ RemoveWindow(gUnknown_0203AB5E);
+}
+
+void sub_813ADD4(void)
+{
+ u16 scrollOffset, selectedRow;
+ u8 i;
+ u8 taskId = FindTaskIdByFunc(sub_813A600);
+ if (taskId != 0xFF)
+ {
+ 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);
+ }
+
+ PrintTextOnWindow(task->data[13], 1, gText_SelectorArrow, 0, selectedRow * 16, TEXT_SPEED_FF, NULL);
+ PutWindowTilemap(task->data[13]);
+ CopyWindowToVram(task->data[13], 3);
+ }
+}
+
+void sub_813AEB4(void)
+{
+ u8 i;
+ u16 temp1 = 0;
+ u16 temp2 = 0;
+ gSpecialVar_0x8005 = 0;
+
+ temp1 = VarGet(VAR_TEMP_E);
+ temp2 = VarGet(VAR_TEMP_D);
+
+ if (temp1 != 0)
+ {
+ i = 0;
+ do
+ {
+ if (gUnknown_0861500C[i] == gUnknown_085B320C[temp2])
+ {
+ gSpecialVar_0x8005 = i;
+ break;
+ }
+ i++;
+ } while (i < 30);
+ }
+ else
+ {
+ i = 0;
+ do
+ {
+ if (gUnknown_0861500C[i] == gUnknown_085B31F8[temp2])
+ {
+ gSpecialVar_0x8005 = i;
+ break;
+ }
+ i++;
+ } while (i < 30);
+ }
+}
+
+void sub_813AF48(void)
+{
+ u8 taskId = FindTaskIdByFunc(sub_813A600);
+ if (taskId != 0xFF)
+ {
+ struct Task *task = &gTasks[taskId];
+ DestroyListMenuTask(task->data[14], NULL, NULL);
+ Free(gUnknown_0203AB64);
+ sub_8198070(task->data[13], TRUE);
+ FillWindowPixelBuffer(task->data[13], 0);
+ ClearWindowTilemap(task->data[13]);
+ CopyWindowToVram(task->data[13], 2);
+ RemoveWindow(task->data[13]);
+ DestroyTask(taskId);
+ }
+}
+
+void sub_813AFC8(void)
+{
+ CreateTask(task_deoxys_sound, 8);
+}
+
+static const u16 gUnknown_085B3280[][16] = {
+ INCBIN_U16("graphics/misc/deoxys1.gbapal"),
+ INCBIN_U16("graphics/misc/deoxys2.gbapal"),
+ INCBIN_U16("graphics/misc/deoxys3.gbapal"),
+ INCBIN_U16("graphics/misc/deoxys4.gbapal"),
+ INCBIN_U16("graphics/misc/deoxys5.gbapal"),
+ INCBIN_U16("graphics/misc/deoxys6.gbapal"),
+ INCBIN_U16("graphics/misc/deoxys7.gbapal"),
+ INCBIN_U16("graphics/misc/deoxys8.gbapal"),
+ INCBIN_U16("graphics/misc/deoxys9.gbapal"),
+ INCBIN_U16("graphics/misc/deoxys10.gbapal"),
+ INCBIN_U16("graphics/misc/deoxys11.gbapal"),
+};
+
+static const u8 gUnknown_085B33E0[][2] = {
+ { 0x0f, 0x0c },
+ { 0x0b, 0x0e },
+ { 0x0f, 0x08 },
+ { 0x13, 0x0e },
+ { 0x0c, 0x0b },
+ { 0x12, 0x0b },
+ { 0x0f, 0x0e },
+ { 0x0b, 0x0e },
+ { 0x13, 0x0e },
+ { 0x0f, 0x0f },
+ { 0x0f, 0x0a },
+};
+
+static void task_deoxys_sound(u8 taskId)
+{
+ static const u8 gUnknown_085B33F6[] = { 0x04, 0x08, 0x08, 0x08, 0x04, 0x04, 0x04, 0x06, 0x03, 0x03 };
+
+ if (FlagGet(FLAG_0x8D4) == TRUE)
+ {
+ gSpecialVar_Result = 3;
+ EnableBothScriptContexts();
+ DestroyTask(taskId);
+ }
+ else
+ {
+ u16 temp1 = VarGet(VAR_0x4035);
+ u16 temp2 = VarGet(VAR_0x4034);
+
+ VarSet(VAR_0x4034, 0);
+ if (temp1 != 0 && gUnknown_085B33F6[temp1 - 1] < temp2)
+ {
+ sub_813B0B4(0);
+ VarSet(VAR_0x4035, 0);
+ gSpecialVar_Result = 0;
+ DestroyTask(taskId);
+ }
+ else if (temp1 == 10)
+ {
+ FlagSet(FLAG_0x8D4);
+ gSpecialVar_Result = 2;
+ EnableBothScriptContexts();
+ DestroyTask(taskId);
+ }
+ else
+ {
+ temp1++;
+ sub_813B0B4(temp1);
+ VarSet(VAR_0x4035, temp1);
+ gSpecialVar_Result = 1;
+ DestroyTask(taskId);
+ }
+ }
+}
+
+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);
+ }
+ else
+ {
+ PlaySE(SE_RG_DEOMOV);
+ }
+
+ CreateTask(sub_813B160, 8);
+
+ gFieldEffectArguments[0] = 1;
+ gFieldEffectArguments[1] = 58;
+ gFieldEffectArguments[2] = 26;
+ gFieldEffectArguments[3] = gUnknown_085B33E0[a0][0];
+ gFieldEffectArguments[4] = gUnknown_085B33E0[a0][1];
+
+ if (a0 == 0)
+ {
+ gFieldEffectArguments[5] = 60;
+ }
+ else
+ {
+ gFieldEffectArguments[5] = 5;
+ }
+
+ FieldEffectStart(FLDEFF_66);
+ Overworld_SetEventObjTemplateCoords(1, gUnknown_085B33E0[a0][0], gUnknown_085B33E0[a0][1]);
+}
+
+static void sub_813B160(u8 taskId)
+{
+ if (FieldEffectActiveListContains(FLDEFF_66) == FALSE)
+ {
+ EnableBothScriptContexts();
+ DestroyTask(taskId);
+ }
+}
+
+void increment_var_x4026_on_birth_island_modulo_100(void)
+{
+ u16 var = VarGet(VAR_0x4034);
+ if (gSaveBlock1Ptr->location.mapNum == MAP_NUM(BIRTH_ISLAND_EXTERIOR) && gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(BIRTH_ISLAND_EXTERIOR))
+ {
+ var++;
+ if (var > 99)
+ {
+ VarSet(VAR_0x4034, 0);
+ }
+ else
+ {
+ VarSet(VAR_0x4034, var);
+ }
+ }
+}
+
+void sub_813B1D0(void)
+{
+ LoadPalette(&gUnknown_085B3280[(u8)VarGet(VAR_0x4035)], 0x1A0, 8);
+ BlendPalettes(0x04000000, 16, 0);
+}
+
+void set_unknown_box_id(u8 id)
+{
+ gUnknown_0203AB6F = id;
+}
+
+u16 get_unknown_box_id(void)
+{
+ return gUnknown_0203AB6F;
+}
+
+bool32 sub_813B21C(void)
+{
+ if (FlagGet(FLAG_SYS_STORAGE_UNKNOWN_FLAG) == FALSE)
+ {
+ if (StorageGetCurrentBox() != VarGet(VAR_STORAGE_UNKNOWN))
+ {
+ FlagSet(FLAG_SYS_STORAGE_UNKNOWN_FLAG);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+bool8 sub_813B260(void)
+{
+ int box;
+ int i;
+ set_unknown_box_id(VarGet(VAR_STORAGE_UNKNOWN));
+ box = StorageGetCurrentBox();
+ do
+ {
+ for (i = 0; i < IN_BOX_COUNT; i++)
+ {
+ if (GetBoxMonData(GetBoxedMonPtr(box, i), MON_DATA_SPECIES, 0) == 0)
+ {
+ if (get_unknown_box_id() != box)
+ {
+ FlagClear(FLAG_SYS_STORAGE_UNKNOWN_FLAG);
+ }
+ VarSet(VAR_STORAGE_UNKNOWN, box);
+ return sub_813B21C();
+ }
+ }
+
+ if (++box == TOTAL_BOXES_COUNT)
+ {
+ box = 0;
+ }
+ } while (box != StorageGetCurrentBox());
+ return FALSE;
+}
+
+void sub_813B2E4(void)
+{
+ u16 randomValue = Random();
+ VarSet(VAR_0x4038, 0);
+
+ if (FlagGet(FLAG_0x1BE) == TRUE)
+ {
+ VarSet(VAR_0x4037, (randomValue & 7) + 1);
+ }
+ else if (FlagGet(FLAG_0x1BF) == TRUE)
+ {
+ VarSet(VAR_0x4037, (randomValue & 7) + 9);
+ }
+ else if ((randomValue & 1) == 0)
+ {
+ randomValue = Random();
+ VarSet(VAR_0x4037, (randomValue & 7) + 1);
+ }
+ else
+ {
+ randomValue = Random();
+ VarSet(VAR_0x4037, (randomValue & 7) + 9);
+ }
+}
+
+bool32 sub_813B374(void)
+{
+ static const u8 gUnknown_085B3400[] = { 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, 0x21, 0x21, 0x14, 0x14, 0x28, 0x28, 0x2a, 0x2a, 0x2c, 0x2c };
+
+ u16 var = VarGet(VAR_0x4037);
+
+ GetMapName(gStringVar1, gUnknown_085B3400[var - 1], 0);
+
+ if (var < 9)
+ {
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+}
+
+bool32 sub_813B3B0(void)
+{
+ static const u8 gUnknown_085B3410[] = { 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, 0x21, 0x21, 0x14, 0x14, 0x28, 0x28, 0x2a, 0x2a, 0x2c, 0x2c };
+
+ u16 var1 = VarGet(VAR_0x4038);
+ u16 var2 = VarGet(VAR_0x4037);
+
+ if (!var2)
+ {
+ return FALSE;
+ }
+
+ if (++var1 > 999)
+ {
+ VarSet(VAR_0x4038, 0);
+ if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(UNDERWATER_MARINE_CAVE))
+ {
+ switch (gSaveBlock1Ptr->location.mapNum)
+ {
+ case MAP_NUM(UNDERWATER_MARINE_CAVE):
+ case MAP_NUM(MARINE_CAVE_ENTRANCE):
+ case MAP_NUM(MARINE_CAVE_END):
+ case MAP_NUM(TERRA_CAVE_ENTRANCE):
+ case MAP_NUM(TERRA_CAVE_END):
+ VarSet(VAR_0x4039, 1);
+ return FALSE;
+ default:
+ break;
+ }
+ }
+
+ if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(UNDERWATER3))
+ {
+ switch (gSaveBlock1Ptr->location.mapNum)
+ {
+ case MAP_NUM(UNDERWATER3):
+ case MAP_NUM(UNDERWATER5):
+ case MAP_NUM(UNDERWATER6):
+ case MAP_NUM(UNDERWATER7):
+ VarSet(VAR_0x4039, 1);
+ return FALSE;
+ default:
+ break;
+ }
+ }
+
+ if (gSaveBlock1Ptr->location.mapNum == gUnknown_085B3410[var2 - 1] &&
+ gSaveBlock1Ptr->location.mapGroup == 0)
+ {
+ return TRUE;
+ }
+ else
+ {
+ VarSet(VAR_0x4037, 0);
+ return FALSE;
+ }
+ }
+ else
+ {
+ VarSet(VAR_0x4038, var1);
+ return FALSE;
+ }
+}
+
+void sub_813B484(void)
+{
+ sub_80AB104(2);
+}
+
+bool32 sub_813B490(void)
+{
+ static const u8 gUnknown_085B3420[][3] = {
+ { 0x02, 0x04, 0x01 },
+ { 0x04, 0x04, 0x01 },
+ { 0x05, 0x00, 0x01 },
+ { 0x06, 0x03, 0x01 },
+ { 0x08, 0x06, 0x01 },
+ { 0x09, 0x0d, 0x01 },
+ { 0x0a, 0x07, 0x01 },
+ { 0x0b, 0x07, 0x01 },
+ { 0x0c, 0x04, 0x01 },
+ { 0x0e, 0x05, 0x01 },
+ { 0x0f, 0x04, 0x01 },
+ { 0x1a, 0x37, 0x01 }
+ };
+
+ u8 i;
+ for (i = 0; i < 12; i++)
+ {
+ if (gSaveBlock1Ptr->location.mapGroup == gUnknown_085B3420[i][0])
+ {
+ if (gSaveBlock1Ptr->location.mapNum == gUnknown_085B3420[i][1])
+ {
+ return gUnknown_085B3420[i][2];
+ }
+ }
+ }
+ return TRUE;
+}
+
+bool32 sub_813B4E0(void)
+{
+ int index = GetRematchIdxByTrainerIdx(gSpecialVar_0x8004);
+ if (index >= 0)
+ {
+ if (FlagGet(FLAG_MATCH_CALL_REGISTERED + index) == TRUE)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+bool32 sub_813B514(void)
+{
+ if (!VarGet(VAR_0x403F))
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void sub_813B534(void)
+{
+ gUnknown_0203AB70 = gBattleTypeFlags;
+ gBattleTypeFlags = 0;
+ if (!gReceivedRemoteLinkPlayers)
+ {
+ CreateTask(sub_80B3AF8, 5);
+ }
+}
+
+void sub_813B568(void)
+{
+ CreateTask(sub_813B57C, 5);
+}
+
+static void sub_813B57C(u8 taskId)
+{
+ switch (gTasks[taskId].data[0])
+ {
+ case 0:
+ if (!FuncIsActiveTask(sub_80B3AF8))
+ {
+ gTasks[taskId].data[0]++;
+ }
+ break;
+ case 1:
+ if (sub_800A520() == TRUE)
+ {
+ if (GetMultiplayerId() == 0)
+ {
+ gTasks[taskId].data[0]++;
+ }
+ else
+ {
+ SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_0x8004, 2);
+ gTasks[taskId].data[0]++;
+ }
+ }
+ break;
+ case 2:
+ if ((GetBlockReceivedStatus() & 2) != 0)
+ {
+ if (GetMultiplayerId() == 0)
+ {
+ gSpecialVar_0x8005 = gBlockRecvBuffer[1][0];
+ ResetBlockReceivedFlag(1);
+ if (gSpecialVar_0x8004 == 1 && gSpecialVar_0x8005 == 1)
+ {
+ gSpecialVar_Result = 1;
+ }
+ else if (gSpecialVar_0x8004 == 0 && gSpecialVar_0x8005 == 1)
+ {
+ gSpecialVar_Result = 2;
+ }
+ else if (gSpecialVar_0x8004 == 1 && gSpecialVar_0x8005 == 0)
+ {
+ gSpecialVar_Result = 3;
+ }
+ else
+ {
+ gSpecialVar_Result = 0;
+ }
+ }
+ gTasks[taskId].data[0]++;
+ }
+ break;
+ case 3:
+ if (sub_800A520() == TRUE)
+ {
+ if (GetMultiplayerId() != 0)
+ {
+ gTasks[taskId].data[0]++;
+ }
+ else
+ {
+ SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_Result, 2);
+ gTasks[taskId].data[0]++;
+ }
+ }
+ break;
+ case 4:
+ if ((GetBlockReceivedStatus() & 1) != 0)
+ {
+ if (GetMultiplayerId() != 0)
+ {
+ gSpecialVar_Result = gBlockRecvBuffer[0][0];
+ ResetBlockReceivedFlag(0);
+ gTasks[taskId].data[0]++;
+ }
+ else
+ {
+ gTasks[taskId].data[0]++;
+ }
+ }
+ break;
+ case 5:
+ if (GetMultiplayerId() == 0)
+ {
+ if (gSpecialVar_Result == 2)
+ {
+ ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired);
+ }
+ }
+ else
+ {
+ if (gSpecialVar_Result == 3)
+ {
+ ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired);
+ }
+ }
+ gTasks[taskId].data[0]++;
+ break;
+ case 6:
+ if (!IsTextPrinterActive(0))
+ {
+ gTasks[taskId].data[0]++;
+ }
+ break;
+ case 7:
+ if (sub_800A520() == 1)
+ {
+ sub_800ADF8();
+ gTasks[taskId].data[0]++;
+ }
+ break;
+ case 8:
+ if (sub_800A520() == 1)
+ {
+ gTasks[taskId].data[0]++;
+ }
+ break;
+ case 9:
+ if (gWirelessCommType == 0)
+ {
+ sub_800AC34();
+ }
+ gBattleTypeFlags = gUnknown_0203AB70;
+ EnableBothScriptContexts();
+ DestroyTask(taskId);
+ break;
+ }
+}
+
+void sub_813B7D8(void)
+{
+ if (gSpecialVar_0x8004 == 0)
+ {
+ DoRayquazaScene(0, TRUE, CB2_ReturnToFieldContinueScriptPlayMapMusic);
+ }
+ else
+ {
+ DoRayquazaScene(1, FALSE, CB2_ReturnToFieldContinueScriptPlayMapMusic);
+ }
+}
+
+void sub_813B80C(void)
+{
+ CreateTask(sub_813B824, 8);
+ PlaySE(SE_W017);
+}
+
+static void sub_813B824(u8 taskId)
+{
+ s16 *data = gTasks[taskId].data;
+
+ data[1]++;
+ if (data[1] == gSpecialVar_0x8005)
+ {
+ data[0]++;
+ data[1] = 0;
+ PlaySE(SE_W017);
+ }
+
+ if (data[0] == gSpecialVar_0x8004 - 1)
+ {
+ DestroyTask(taskId);
+ }
+}
+
+void sub_813B880(void)
+{
+ u8 taskId = CreateTask(_fwalk, 8);
+ gTasks[taskId].data[0] = 4;
+ gTasks[taskId].data[1] = 4;
+ gTasks[taskId].data[2] = 4;
+ gTasks[taskId].data[3] = 0;
+}
+
+static void _fwalk(u8 taskId)
+{
+ u8 x, y;
+ s16 *data = gTasks[taskId].data;
+
+ data[data[3]]--;
+ if (data[data[3]] == 0)
+ {
+ for (y = 0; y < 4; y++)
+ {
+ for (x = 0; x < 3; x++)
+ {
+ MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + x + 6, gSaveBlock1Ptr->pos.y + y + 4, x + 0x201 + y * 8 + data[3] * 32);
+ }
+ }
+ DrawWholeMapView();
+ data[3]++;
+ if (data[3] == 3)
+ {
+ DestroyTask(taskId);
+ EnableBothScriptContexts();
+ }
+ }
+}
+
+void sub_813B968(void)
+{
+ gSpecialVar_Result = gSpecialVar_0x8004 / 7;
+ gSpecialVar_Result -= (gSpecialVar_Result / 20) * 20;
+}
+
+void sub_813B9A0(void)
+{
+ if (gSaveBlock1Ptr->lastHealLocation.mapGroup == MAP_GROUP(DEWFORD_TOWN) && gSaveBlock1Ptr->lastHealLocation.mapNum == MAP_NUM(DEWFORD_TOWN))
+ {
+ Overworld_SetHealLocationWarp(3);
+ }
+}
+
+bool32 sub_813B9C0(void)
+{
+ static const u16 gUnknown_085B3444[] = {
+ MAP_OLDALE_TOWN_POKEMON_CENTER_1F,
+ MAP_DEWFORD_TOWN_POKEMON_CENTER_1F,
+ MAP_LAVARIDGE_TOWN_POKEMON_CENTER_1F,
+ MAP_FALLARBOR_TOWN_POKEMON_CENTER_1F,
+ MAP_VERDANTURF_TOWN_POKEMON_CENTER_1F,
+ MAP_PACIFIDLOG_TOWN_POKEMON_CENTER_1F,
+ MAP_PETALBURG_CITY_POKEMON_CENTER_1F,
+ MAP_SLATEPORT_CITY_POKEMON_CENTER_1F,
+ MAP_MAUVILLE_CITY_POKEMON_CENTER_1F,
+ MAP_RUSTBORO_CITY_POKEMON_CENTER_1F,
+ MAP_FORTREE_CITY_POKEMON_CENTER_1F,
+ MAP_LILYCOVE_CITY_POKEMON_CENTER_1F,
+ MAP_MOSSDEEP_CITY_POKEMON_CENTER_1F,
+ MAP_SOOTOPOLIS_CITY_POKEMON_CENTER_1F,
+ MAP_EVER_GRANDE_CITY_POKEMON_CENTER_1F,
+ MAP_EVER_GRANDE_CITY_POKEMON_LEAGUE_1F,
+ MAP_BATTLE_FRONTIER_POKEMON_CENTER_1F,
+ MAP_SINGLE_BATTLE_COLOSSEUM,
+ MAP_TRADE_CENTER,
+ MAP_RECORD_CORNER,
+ MAP_DOUBLE_BATTLE_COLOSSEUM,
+ 0xffff
+ };
+
+ int i;
+ u16 map = (gSaveBlock1Ptr->location.mapGroup << 8) + gSaveBlock1Ptr->location.mapNum;
+
+ for (i = 0; gUnknown_085B3444[i] != 0xFFFF; i++)
+ {
+ if (gUnknown_085B3444[i] == map)
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void ResetFanClub(void)
+{
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] = 0;
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] = 0;
+}
+
+void sub_813BA30(void)
+{
+ if (sub_813BF44() != 0)
+ {
+ UpdateMovedLilycoveFanClubMembers();
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] = gSaveBlock2Ptr->playTimeHours;
+ }
+}
+
+void sub_813BA60(void)
+{
+ if (!((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> 7) & 1))
+ {
+ sub_813BF60();
+ sub_813BD84();
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] = gSaveBlock2Ptr->playTimeHours;
+ FlagClear(FLAG_HIDE_FANCLUB_OLD_LADY);
+ FlagClear(FLAG_HIDE_FANCLUB_BOY);
+ FlagClear(FLAG_HIDE_FANCLUB_LITTLE_BOY);
+ FlagClear(FLAG_HIDE_FANCLUB_LADY);
+ FlagClear(FLAG_0x2DA);
+ VarSet(VAR_LILYCOVE_FAN_CLUB_STATE, 1);
+ }
+}
+
+u8 sub_813BADC(u8 a0)
+{
+ static const u8 gUnknown_085B3470[] = { 0x02, 0x01, 0x02, 0x01 };
+
+ if (VarGet(VAR_LILYCOVE_FAN_CLUB_STATE) == 2)
+ {
+ if ((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] & 0x7F) + gUnknown_085B3470[a0] > 19)
+ {
+ if (GetNumMovedLilycoveFanClubMembers() < 3)
+ {
+ sub_813BB74();
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] &= 0xFF80;
+ }
+ else
+ {
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] = (gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] & 0xFF80) | 0x14;
+ }
+ }
+ else
+ {
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] += gUnknown_085B3470[a0];
+ }
+ }
+
+ return gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] & 0x7F;
+}
+
+static u16 sub_813BB74(void)
+{
+ static const u8 gUnknown_085B3474[] = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
+
+ u8 i;
+ u8 retVal = 0;
+
+ for (i = 0; i < 8; i++)
+ {
+ if (!((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> gUnknown_085B3474[i]) & 1))
+ {
+ retVal = i;
+ if ((Random() & 1) != 0)
+ {
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 1 << gUnknown_085B3474[retVal];
+ return retVal;
+ }
+ }
+ }
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 1 << gUnknown_085B3474[retVal];
+ return retVal;
+}
+
+static u16 sub_813BC00(void)
+{
+ static const u8 gUnknown_085B347C[] = { 0x08, 0x0d, 0x0e, 0x0b, 0x0a, 0x0c, 0x0f, 0x09 };
+
+ u8 i;
+ u8 retVal = 0;
+
+ if (GetNumMovedLilycoveFanClubMembers() == 1)
+ {
+ return 0;
+ }
+
+ for (i = 0; i < 8; i++)
+ {
+ if (((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> gUnknown_085B347C[i]) & 1) != 0)
+ {
+ retVal = i;
+ if ((Random() & 1) != 0)
+ {
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] ^= 1 << gUnknown_085B347C[retVal];
+ return retVal;
+ }
+ }
+ }
+
+ 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];
+ }
+
+ return retVal;
+}
+
+u16 GetNumMovedLilycoveFanClubMembers(void)
+{
+ u8 i;
+ u8 retVal = 0;
+
+ for (i = 0; i < 8; i++)
+ {
+ if (((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> (i + 8)) & 1) != 0)
+ {
+ retVal++;
+ }
+ }
+
+ return retVal;
+}
+
+void UpdateMovedLilycoveFanClubMembers(void)
+{
+ u8 i = 0;
+ if (gSaveBlock2Ptr->playTimeHours < 999)
+ {
+ while (TRUE)
+ {
+ if (GetNumMovedLilycoveFanClubMembers() < 5)
+ {
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] = gSaveBlock2Ptr->playTimeHours;
+ break;
+ }
+ else if (i == 8)
+ {
+ break;
+ }
+ else if (gSaveBlock2Ptr->playTimeHours - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] < 12)
+ {
+ return;
+ }
+ sub_813BC00();
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] += 12;
+ i++;
+ }
+ }
+}
+
+bool8 ShouldMoveLilycoveFanClubMember(void)
+{
+ return (gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> gSpecialVar_0x8004) & 1;
+}
+
+static void sub_813BD84(void)
+{
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 0x2000;
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 0x100;
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 0x400;
+}
+
+void BufferStreakTrainerText(void)
+{
+ u8 a = 0;
+ u8 b = 0;
+ switch (gSpecialVar_0x8004)
+ {
+ case 8:
+ break;
+ case 9:
+ break;
+ case 10:
+ a = 0;
+ b = 3;
+ break;
+ case 11:
+ a = 0;
+ b = 1;
+ break;
+ case 12:
+ a = 1;
+ b = 0;
+ break;
+ case 13:
+ a = 0;
+ b = 4;
+ break;
+ case 14:
+ a = 1;
+ b = 5;
+ break;
+ case 15:
+ break;
+ }
+ sub_813BE30(&gSaveBlock1Ptr->linkBattleRecords, a, b);
+}
+
+static void sub_813BE30(struct LinkBattleRecords *linkRecords, u8 a, u8 b)
+{
+ struct LinkBattleRecord *record = &linkRecords->entries[a];
+ if (record->name[0] == EOS)
+ {
+ switch (b)
+ {
+ case 0:
+ StringCopy(gStringVar1, gText_Wallace);
+ break;
+ case 1:
+ StringCopy(gStringVar1, gText_Steven);
+ break;
+ case 2:
+ StringCopy(gStringVar1, gText_Brawly);
+ break;
+ case 3:
+ StringCopy(gStringVar1, gText_Winona);
+ break;
+ case 4:
+ StringCopy(gStringVar1, gText_Phoebe);
+ break;
+ case 5:
+ StringCopy(gStringVar1, gText_Glacia);
+ break;
+ default:
+ StringCopy(gStringVar1, gText_Wallace);
+ break;
+ }
+ }
+ else
+ {
+ StringCopyN(gStringVar1, record->name, 7);
+ gStringVar1[7] = EOS;
+ ConvertInternationalString(gStringVar1, linkRecords->languages[a]);
+ }
+}
+
+void sub_813BF10(void)
+{
+ if (VarGet(VAR_LILYCOVE_FAN_CLUB_STATE) == 2)
+ {
+ sub_813BA30();
+ if (gBattleOutcome == 1)
+ {
+ sub_813BB74();
+ }
+ else
+ {
+ sub_813BC00();
+ }
+ }
+}
+
+static bool8 sub_813BF44(void)
+{
+ return (gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> 7) & 1;
+}
+
+void sub_813BF60(void)
+{
+ gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 0x80;
+}
+
+u8 sub_813BF7C(void)
+{
+ return sub_813BADC(gSpecialVar_0x8004);
+}
diff --git a/src/heal_location.c b/src/heal_location.c
index aa90fe1ae..b378e8e8c 100644
--- a/src/heal_location.c
+++ b/src/heal_location.c
@@ -1,83 +1,37 @@
-
-// Includes
#include "global.h"
-#include "constants/maps.h"
#include "heal_location.h"
+#include "constants/maps.h"
-#define HEAL_LOCATION(map, x, y) {MAP_GROUP(map), MAP_NUM(map), x, y}
-
-// Static type declarations
-
-// Static RAM declarations
-
-// Static ROM declarations
-
-// .rodata
-
-static const struct HealLocation sHealLocations[] = {
- HEAL_LOCATION(LITTLEROOT_TOWN_BRENDANS_HOUSE_2F, 4, 2),
- HEAL_LOCATION(LITTLEROOT_TOWN_MAYS_HOUSE_2F, 4, 2),
- HEAL_LOCATION(PETALBURG_CITY, 20, 17),
- HEAL_LOCATION(SLATEPORT_CITY, 19, 20),
- HEAL_LOCATION(MAUVILLE_CITY, 22, 6),
- HEAL_LOCATION(RUSTBORO_CITY, 16, 39),
- HEAL_LOCATION(FORTREE_CITY, 5, 7),
- HEAL_LOCATION(LILYCOVE_CITY, 24, 15),
- HEAL_LOCATION(MOSSDEEP_CITY, 28, 17),
- HEAL_LOCATION(SOOTOPOLIS_CITY, 43, 32),
- HEAL_LOCATION(EVER_GRANDE_CITY, 27, 49),
- HEAL_LOCATION(LITTLEROOT_TOWN, 5, 9),
- HEAL_LOCATION(LITTLEROOT_TOWN, 14, 9),
- HEAL_LOCATION(OLDALE_TOWN, 6, 17),
- HEAL_LOCATION(DEWFORD_TOWN, 2, 11),
- HEAL_LOCATION(LAVARIDGE_TOWN, 9, 7),
- HEAL_LOCATION(FALLARBOR_TOWN, 14, 8),
- HEAL_LOCATION(VERDANTURF_TOWN, 16, 4),
- HEAL_LOCATION(PACIFIDLOG_TOWN, 8, 16),
- HEAL_LOCATION(EVER_GRANDE_CITY, 18, 6),
- HEAL_LOCATION(SOUTHERN_ISLAND_EXTERIOR, 15, 20),
- HEAL_LOCATION(BATTLE_FRONTIER_OUTSIDE_EAST, 3, 52)
-};
-
-#define NUM_HEAL_LOCATIONS (ARRAY_COUNT(sHealLocations))
-
-// .text
+#include "data/heal_locations.h"
-static u32 GetHealLocationIndexFromMapGroupAndNum(u16 mapGroup, u16 mapNum)
+u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum)
{
u32 i;
- for (i = 0; i < NUM_HEAL_LOCATIONS; i++)
+ for (i = 0; i < ARRAY_COUNT(sHealLocations); i++)
{
if (sHealLocations[i].group == mapGroup && sHealLocations[i].map == mapNum)
- {
return i + 1;
- }
}
return 0;
}
-const struct HealLocation *GetHealLocationPointerFromMapGroupAndNum(u16 mapGroup, u16 mapNum)
+const struct HealLocation *GetHealLocationByMap(u16 mapGroup, u16 mapNum)
{
- u32 loc;
+ u32 index = GetHealLocationIndexByMap(mapGroup, mapNum);
- loc = GetHealLocationIndexFromMapGroupAndNum(mapGroup, mapNum);
- if (loc == 0)
- {
+ if (index == 0)
return NULL;
- }
- return &sHealLocations[loc - 1];
+ else
+ return &sHealLocations[index - 1];
}
-const struct HealLocation *GetHealLocationPointer(u32 loc)
+const struct HealLocation *GetHealLocation(u32 index)
{
- if (loc == 0)
- {
+ if (index == 0)
return NULL;
- }
- if (loc > NUM_HEAL_LOCATIONS)
- {
+ else if (index > ARRAY_COUNT(sHealLocations))
return NULL;
- }
- return &sHealLocations[loc - 1];
+ else
+ return &sHealLocations[index - 1];
}
diff --git a/src/main_menu.c b/src/main_menu.c
index 87673c9b2..3afe1abe5 100644
--- a/src/main_menu.c
+++ b/src/main_menu.c
@@ -1965,7 +1965,7 @@ void sub_80323CC(u8 a, u8 b, u16 c, u16 d, u8 e, u8 f)
{
struct WindowTemplate sp;
- sp = sub_8198A50(0, a + 1, b + 1, 5, 4, f, d);
+ sp = CreateWindowTemplate(0, a + 1, b + 1, 5, 4, f, d);
CreateYesNoMenu(&sp, c, e, 0);
}
diff --git a/src/match_call.c b/src/match_call.c
index aa6945161..99eb6d65a 100644
--- a/src/match_call.c
+++ b/src/match_call.c
@@ -360,7 +360,7 @@ MATCHCALLDEF(sMomMatchCallHeader, 0, 0, FLAG_0x0D8, gMomMatchCallDesc, gMomMatch
static const match_call_text_data_t sStevenTextScripts[] = {
{ gText_Steven_Pokenav_2B5B95, 0xffff, 0xffff },
- { gText_Steven_Pokenav_2B5C53, FLAG_0x0C7, 0xffff },
+ { gText_Steven_Pokenav_2B5C53, FLAG_RUSTURF_TUNNEL_OPENED, 0xffff },
{ gText_Steven_Pokenav_2B5CC9, FLAG_0x0D4, 0xffff },
{ gText_Steven_Pokenav_2B5DB4, FLAG_0x070, 0xffff },
{ gText_Steven_Pokenav_2B5E26, FLAG_0x4F6, 0xffff },
@@ -415,7 +415,7 @@ MATCHCALLDEF(sBrendanMatchCallHeader, 4, FEMALE, FLAG_0x0FD, gMayBrendanMatchCal
static const match_call_text_data_t sWallyTextScripts[] = {
{ gText_Wally_Pokenav_2B4DE2, 0xFFFF, 0xFFFF },
- { gText_Wally_Pokenav_2B4E57, FLAG_0x0C7, 0xFFFF },
+ { gText_Wally_Pokenav_2B4E57, FLAG_RUSTURF_TUNNEL_OPENED, 0xFFFF },
{ gText_Wally_Pokenav_2B4EA5, FLAG_0x4F3, 0xFFFF },
{ gText_Wally_Pokenav_2B4F41, FLAG_0x097, 0xFFFF },
{ gText_Wally_Pokenav_2B4FF3, FLAG_0x06F, 0xFFFF },
diff --git a/src/menu.c b/src/menu.c
index 96dda3075..f4ffec023 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -120,7 +120,6 @@ extern void DrawWindowBorder(u8, u8, u8, u8, u8, u8);
extern void sub_81980A8(u8, u8, u8, u8, u8, u8);
extern u8 MoveMenuCursor(s8);
extern u8 sub_8199134(s8, s8);
-extern void sub_8199F74(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 letterSpacing, u8 lineSpacing);
extern void sub_8198C78(void);
extern void task_free_buf_after_copying_tile_data_to_vram(u8 taskId);
@@ -1143,7 +1142,7 @@ void SetWindowTemplateFields(struct WindowTemplate *template, u8 bg, u8 left, u8
template->baseBlock = baseBlock;
}
-struct WindowTemplate sub_8198A50(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock)
+struct WindowTemplate CreateWindowTemplate(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock)
{
struct WindowTemplate template;
SetWindowTemplateFields(&template, bg, left, top, width, height, paletteNum, baseBlock);
diff --git a/src/overworld.c b/src/overworld.c
index 772f8a057..d85af9e4d 100644
--- a/src/overworld.c
+++ b/src/overworld.c
@@ -689,7 +689,7 @@ void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused)
void sub_8084CCC(u8 a1)
{
- const struct HealLocation *warp = GetHealLocationPointer(a1);
+ const struct HealLocation *warp = GetHealLocation(a1);
if (warp)
Overworld_SetWarpDestination(warp->group, warp->map, -1, warp->x, warp->y);
@@ -702,7 +702,7 @@ void Overworld_SetWarpDestToLastHealLoc(void)
void Overworld_SetHealLocationWarp(u8 healLocationId)
{
- const struct HealLocation *healLocation = GetHealLocationPointer(healLocationId);
+ const struct HealLocation *healLocation = GetHealLocation(healLocationId);
if (healLocation != NULL)
SetWarpData(&gSaveBlock1Ptr->lastHealLocation, healLocation->group, healLocation->map, -1, healLocation->x, healLocation->y);
@@ -761,7 +761,7 @@ void sub_8084F2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
void sub_8084F6C(u8 a1)
{
- const struct HealLocation *warp = GetHealLocationPointer(a1);
+ const struct HealLocation *warp = GetHealLocation(a1);
if (warp)
SetWarpData(&gSaveBlock1Ptr->warp1, warp->group, warp->map, -1, warp->x, warp->y);
}
diff --git a/src/pokemon.c b/src/pokemon.c
index cd7e45758..7c010cd39 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -2089,7 +2089,7 @@ void GiveBoxMonInitialMoveset(struct BoxPokemon *boxMon)
s32 level = GetLevelFromBoxMonExp(boxMon);
s32 i;
- for (i = 0; gLevelUpLearnsets[species][i] != (u16)-1; i++)
+ for (i = 0; gLevelUpLearnsets[species][i] != LEVEL_UP_END; i++)
{
u16 moveLevel;
u16 move;
@@ -2101,7 +2101,7 @@ void GiveBoxMonInitialMoveset(struct BoxPokemon *boxMon)
move = (gLevelUpLearnsets[species][i] & 0x1FF);
- if (GiveMoveToBoxMon(boxMon, move) == (u16)-1)
+ if (GiveMoveToBoxMon(boxMon, move) == 0xFFFF)
DeleteFirstMoveAndGiveMoveToBoxMon(boxMon, move);
}
}
@@ -2123,7 +2123,7 @@ u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove)
while ((gLevelUpLearnsets[species][sLearningMoveTableID] & 0xFE00) != (level << 9))
{
sLearningMoveTableID++;
- if (gLevelUpLearnsets[species][sLearningMoveTableID] == 0xFFFF)
+ if (gLevelUpLearnsets[species][sLearningMoveTableID] == LEVEL_UP_END)
return 0;
}
}
diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c
index 7f8c24ab7..7c622c223 100644
--- a/src/pokemon_storage_system.c
+++ b/src/pokemon_storage_system.c
@@ -7,17 +7,49 @@
#include "text.h"
#include "strings.h"
#include "window.h"
+#include "menu.h"
+#include "bg.h"
+#include "main.h"
+#include "palette.h"
+#include "overworld.h"
+#include "field_screen.h"
+#include "field_weather.h"
+#include "script.h"
+#include "international_string_util.h"
+#include "walda_phrase.h"
+#include "sound.h"
+#include "gpu_regs.h"
+#include "constants/songs.h"
IWRAM_DATA u8 gUnknown_03000F78[0x188];
-struct OptionAndDescription
-{
- const u8 *optionTxt;
- const u8 *descriptionTxt;
-};
+extern const u8 gText_PartyFull[];
+extern const u8 gText_Box[];
+extern const u8 gText_JustOnePkmn[];
+
+extern u8 gUnknown_02039D00;
+
+// This file's functions.
+void StorageSystemCreatePrimaryMenu(u8 whichMenu, s16 *windowIdPtr);
+void sub_80C7D74(u8);
+u8 sub_80CAEA0(void);
+void SetBoxWallpaper(u8 boxId, u8 wallpaperId);
+void SetCurrentBox(u8 boxId);
+void ClearMonInBox(u8 boxId, u8 boxPos);
+void ResetWaldaWallpaper(void);
+void sub_80C7958(u8 curBox);
+void sub_80C7B14(void);
+void sub_80C7BB4(void);
+void sub_80CA028(void);
+void sub_80C7B80(void);
+void sub_80D2AA4(void);
+void sub_80C7BE4(void);
+void sub_80CAA14(void);
+void sub_80C7CF4(struct Sprite *sprite);
+struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority);
// const rom data
-const struct OptionAndDescription gUnknown_085716C0[] =
+const struct PSS_MenuStringPtrs gUnknown_085716C0[] =
{
{gText_WithdrawPokemon, gText_WithdrawMonDescription},
{gText_DepositPokemon, gText_DepositMonDescription},
@@ -74,6 +106,10 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_8571730[] =
const u8 gUnknown_08571734[] = {4, 0xF, 0xE};
const u8 gUnknown_08571737[] = _("/30");
+const u16 gBoxSelectionPopupPalette[] = INCBIN_U16("graphics/unknown/unknown_57173C.gbapal");
+const u8 gBoxSelectionPopupCenterTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_center.4bpp");
+const u8 gBoxSelectionPopupSidesTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp");
+
// code
u8 CountMonsInBox(u8 boxId)
{
@@ -166,24 +202,473 @@ static u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n)
return str;
}
-/* can't match
-static void sub_80C7128(u16 *dst, u16 dstToAdd, u16 dstToMul, const u16 *src, u16 srcToAdd, u16 srcToMul, u32 size, u16 count, u16 srcBy)
+static void sub_80C7128(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, u16 src_left, u16 src_top, u16 dest_width, u16 dest_height, u16 src_width)
+{
+ u16 i;
+
+ dest_width *= 2;
+ dest += dest_top * 0x20 + dest_left;
+ src += src_top * src_width + src_left;
+ for (i = 0; i < dest_height; i++)
+ {
+ CpuCopy16(src, dest, dest_width);
+ dest += 0x20;
+ src += src_width;
+ }
+}
+
+#define MAX_DMA_BLOCK_SIZE 0x1000
+#define Dma3FillLarge_(value, dest, size, bit) \
+{ \
+ void *_dest = dest; \
+ u32 _size = size; \
+ while (1) \
+ { \
+ if (_size <= MAX_DMA_BLOCK_SIZE) \
+ { \
+ DmaFill##bit(3, value, _dest, _size); \
+ break; \
+ } \
+ DmaFill##bit(3, value, _dest, MAX_DMA_BLOCK_SIZE); \
+ _dest += MAX_DMA_BLOCK_SIZE; \
+ _size -= MAX_DMA_BLOCK_SIZE; \
+ } \
+}
+
+#define Dma3FillLarge16_(value, dest, size) Dma3FillLarge_(value, dest, size, 16)
+#define Dma3FillLarge32_(value, dest, size) Dma3FillLarge_(value, dest, size, 32)
+
+void sub_80C71A4(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height)
+{
+ u16 i;
+
+ dest += dest_top * 0x20 + dest_left;
+ width *= 2;
+ for (i = 0; i < height; dest += 0x20, i++)
+ Dma3FillLarge16_(0, dest, width);
+}
+
+void Task_PokemonStorageSystem(u8 taskId)
+{
+ struct Task *task = gTasks + taskId;
+ switch (task->data[0])
+ {
+ case 0:
+ StorageSystemCreatePrimaryMenu(task->data[1], &task->data[15]);
+ sub_81973A4();
+ NewMenuHelpers_DrawDialogueFrame(0, 0);
+ FillWindowPixelBuffer(0, 0x11);
+ AddTextPrinterParameterized(0, 1, gUnknown_085716C0[task->data[1]].desc, TEXT_SPEED_FF, NULL, 2, 1, 3);
+ CopyWindowToVram(0, 3);
+ CopyWindowToVram(task->data[15], 3);
+ task->data[0]++;
+ break;
+ case 1:
+ if (IsWeatherNotFadingIn())
+ {
+ task->data[0]++;
+ }
+ break;
+ case 2:
+ task->data[2] = ProcessMenuInput();
+ switch(task->data[2])
+ {
+ case -2:
+ task->data[3] = task->data[1];
+ if (gMain.newKeys & DPAD_UP && --task->data[3] < 0)
+ task->data[3] = 4;
+
+ if (gMain.newKeys & DPAD_DOWN && ++task->data[3] > 4)
+ task->data[3] = 0;
+ if (task->data[1] != task->data[3])
+ {
+ task->data[1] = task->data[3];
+ FillWindowPixelBuffer(0, 0x11);
+ AddTextPrinterParameterized(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3);
+ }
+ break;
+ case -1:
+ case 4:
+ sub_819746C(task->data[15], TRUE);
+ ScriptContext2_Disable();
+ EnableBothScriptContexts();
+ RemoveWindow(task->data[15]);
+ DestroyTask(taskId);
+ break;
+ default:
+ if (task->data[2] == 0 && CountPartyMons() == PARTY_SIZE)
+ {
+ FillWindowPixelBuffer(0, 0x11);
+ AddTextPrinterParameterized(0, 1, gText_PartyFull, 0, NULL, 2, 1, 3);
+ task->data[0] = 3;
+ }
+ else if (task->data[2] == 1 && CountPartyMons() == 1)
+ {
+ FillWindowPixelBuffer(0, 0x11);
+ AddTextPrinterParameterized(0, 1, gText_JustOnePkmn, 0, NULL, 2, 1, 3);
+ task->data[0] = 3;
+ }
+ else
+ {
+ FadeScreen(1, 0);
+ task->data[0] = 4;
+ }
+ break;
+ }
+ break;
+ case 3:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ {
+ FillWindowPixelBuffer(0, 0x11);
+ AddTextPrinterParameterized(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3);
+ task->data[0] = 2;
+ }
+ else if (gMain.newKeys & DPAD_UP)
+ {
+ if (--task->data[1] < 0)
+ task->data[1] = 4;
+ MoveMenuCursor(-1);
+ task->data[1] = GetMenuCursorPos();
+ FillWindowPixelBuffer(0, 0x11);
+ AddTextPrinterParameterized(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3);
+ task->data[0] = 2;
+ }
+ else if (gMain.newKeys & DPAD_DOWN)
+ {
+ if (++task->data[1] > 3)
+ task->data[1] = 0;
+ MoveMenuCursor(1);
+ task->data[1] = GetMenuCursorPos();
+ FillWindowPixelBuffer(0, 0x11);
+ AddTextPrinterParameterized(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3);
+ task->data[0] = 2;
+ }
+ break;
+ case 4:
+ if (!gPaletteFade.active)
+ {
+ overworld_free_bg_tilemaps();
+ sub_80C7D74(task->data[2]);
+ RemoveWindow(task->data[15]);
+ DestroyTask(taskId);
+ }
+ break;
+ }
+}
+
+void ShowPokemonStorageSystem(void)
+{
+ u8 taskId = CreateTask(Task_PokemonStorageSystem, 80);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = 0;
+ ScriptContext2_Enable();
+}
+
+void mapldr_0808C6D8(void)
+{
+ u8 taskId;
+ MainCallback vblankCb = gMain.vblankCallback;
+
+ SetVBlankCallback(NULL);
+ taskId = CreateTask(Task_PokemonStorageSystem, 80);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = gUnknown_02039D00;
+ Task_PokemonStorageSystem(taskId);
+ SetVBlankCallback(vblankCb);
+ pal_fill_black();
+}
+
+void StorageSystemCreatePrimaryMenu(u8 whichMenu, s16 *windowIdPtr)
+{
+ s16 windowId;
+ struct WindowTemplate winTemplate = gUnknown_085716E8;
+ winTemplate.width = GetMaxWidthInMenuTable((void *)gUnknown_085716C0, ARRAY_COUNT(gUnknown_085716C0));
+ windowId = AddWindow(&winTemplate);
+
+ NewMenuHelpers_DrawStdWindowFrame(windowId, FALSE);
+ PrintMenuTable(windowId, ARRAY_COUNT(gUnknown_085716C0), (void *)gUnknown_085716C0);
+ InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, ARRAY_COUNT(gUnknown_085716C0), whichMenu);
+ *windowIdPtr = windowId;
+}
+
+void sub_80C7678(void)
+{
+ gUnknown_02039D00 = sub_80CAEA0();
+ gFieldCallback = mapldr_0808C6D8;
+ SetMainCallback2(CB2_ReturnToField);
+}
+
+s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx, u8 mode)
+{
+ s16 i;
+ s16 direction;
+ if (mode == 0 || mode == 1)
+ {
+ direction = 1;
+ }
+ else
+ {
+ direction = -1;
+ }
+ if (mode == 1 || mode == 3)
+ {
+ for (i = startIdx + direction; i >= 0 && i <= stopIdx; i += direction)
+ {
+ if (GetBoxMonData(box + i, MON_DATA_SPECIES) != 0)
+ return i;
+ }
+ }
+ else
+ {
+ for (i = startIdx + direction; i >= 0 && i <= stopIdx; i += direction)
+ {
+ if (GetBoxMonData(box + i, MON_DATA_SPECIES) != 0 && !GetBoxMonData(box + i, MON_DATA_IS_EGG))
+ return i;
+ }
+ }
+ return -1;
+}
+
+void ResetPokemonStorageSystem(void)
+{
+ u16 boxId;
+ u16 boxMon;
+
+ SetCurrentBox(0);
+ for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++)
+ {
+ for (boxMon = 0; boxMon < IN_BOX_COUNT; boxMon++)
+ ClearMonInBox(boxId, boxMon);
+ }
+ for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++)
+ {
+ u8 *dest = StringCopy(GetBoxNamePtr(boxId), gText_Box);
+ ConvertIntToDecimalStringN(dest, boxId + 1, STR_CONV_MODE_LEFT_ALIGN, 2);
+ }
+ for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++)
+ {
+ SetBoxWallpaper(boxId, boxId % 4);
+ }
+ ResetWaldaWallpaper();
+}
+
+void sub_80C77E8(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3, bool32 loadPal)
+{
+ struct SpritePalette palette =
+ {
+ gBoxSelectionPopupPalette, palTag
+ };
+ struct SpriteSheet sheets[] =
+ {
+ {gBoxSelectionPopupCenterTiles, 0x800, tileTag},
+ {gBoxSelectionPopupSidesTiles, 0x180, tileTag + 1},
+ {}
+ };
+
+ if (loadPal)
+ LoadSpritePalette(&palette);
+
+ LoadSpriteSheets(sheets);
+ gUnknown_02039D04 = a0;
+ a0->unk_0240 = tileTag;
+ a0->unk_0242 = palTag;
+ a0->unk_0246 = a3;
+ a0->unk_023c = loadPal;
+}
+
+void sub_80C7890(void)
+{
+ if (gUnknown_02039D04->unk_023c)
+ FreeSpritePaletteByTag(gUnknown_02039D04->unk_0242);
+ FreeSpriteTilesByTag(gUnknown_02039D04->unk_0240);
+ FreeSpriteTilesByTag(gUnknown_02039D04->unk_0240 + 1);
+}
+
+void sub_80C78D4(u8 curBox)
+{
+ sub_80C7958(curBox);
+}
+
+void sub_80C78E4(void)
+{
+ sub_80C7B14();
+}
+
+u8 sub_80C78F0(void)
+{
+ if (gMain.newKeys & B_BUTTON)
+ {
+ PlaySE(SE_SELECT);
+ return 201;
+ }
+ if (gMain.newKeys & A_BUTTON)
+ {
+ PlaySE(SE_SELECT);
+ return gUnknown_02039D04->curBox;
+ }
+ if (gMain.newKeys & DPAD_LEFT)
+ {
+ PlaySE(SE_SELECT);
+ sub_80C7BB4();
+ }
+ else if (gMain.newKeys & DPAD_RIGHT)
+ {
+ PlaySE(SE_SELECT);
+ sub_80C7B80();
+ }
+ return 200;
+}
+
+void sub_80C7958(u8 curBox)
{
u16 i;
+ u8 spriteId;
+ struct SpriteTemplate template;
+ struct OamData oamData = {};
+ oamData.size = 3;
+ oamData.paletteNum = 1;
+ template = (struct SpriteTemplate){
+ 0, 0, &oamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
+ };
+
+ gUnknown_02039D04->curBox = curBox;
+ template.tileTag = gUnknown_02039D04->unk_0240;
+ template.paletteTag = gUnknown_02039D04->unk_0242;
+
+ spriteId = CreateSprite(&template, 0xA0, 0x60, 0);
+ gUnknown_02039D04->unk_0000 = gSprites + spriteId;
+
+ oamData.shape = ST_OAM_V_RECTANGLE;
+ oamData.size = 1;
+ template.tileTag = gUnknown_02039D04->unk_0240 + 1;
+ template.anims = sSpriteAnimTable_8571710;
+ for (i = 0; i < 4; i++)
+ {
+ u16 r5;
+ spriteId = CreateSprite(&template, 0x7c, 0x50, gUnknown_02039D04->unk_0246);
+ gUnknown_02039D04->unk_0004[i] = gSprites + spriteId;
+ r5 = 0;
+ if (i & 2)
+ {
+ gUnknown_02039D04->unk_0004[i]->pos1.x = 0xc4;
+ r5 = 2;
+ }
+ if (i & 1)
+ {
+ gUnknown_02039D04->unk_0004[i]->pos1.y = 0x70;
+ gUnknown_02039D04->unk_0004[i]->oam.size = 0;
+ r5++;
+ }
+ StartSpriteAnim(gUnknown_02039D04->unk_0004[i], r5);
+ }
+ for (i = 0; i < 2; i++)
+ {
+ gUnknown_02039D04->unk_0020[i] = sub_80CD2E8(72 * i + 0x7c, 0x58, i, 0, gUnknown_02039D04->unk_0246);
+ if (gUnknown_02039D04->unk_0020[i])
+ {
+ gUnknown_02039D04->unk_0020[i]->data[0] = (i == 0 ? -1 : 1);
+ gUnknown_02039D04->unk_0020[i]->callback = sub_80C7CF4;
+ }
+ }
+ sub_80C7BE4();
+}
+
+void sub_80C7B14(void)
+{
+ u16 i;
+ if (gUnknown_02039D04->unk_0000)
+ {
+ DestroySprite(gUnknown_02039D04->unk_0000);
+ gUnknown_02039D04->unk_0000 = NULL;
+ }
+ for (i = 0; i < 4; i++)
+ {
+ if (gUnknown_02039D04->unk_0004[i])
+ {
+ DestroySprite(gUnknown_02039D04->unk_0004[i]);
+ gUnknown_02039D04->unk_0004[i] = NULL;
+ }
+ }
+ for (i = 0; i < 2; i++)
+ {
+ if (gUnknown_02039D04->unk_0020[i])
+ DestroySprite(gUnknown_02039D04->unk_0020[i]);
+ }
+}
- size <<= 0x11;
- dst += (dstToMul * 32) + dstToAdd;
- src += (srcToMul * srcBy) + srcToAdd;
+void sub_80C7B80(void)
+{
+ if (++gUnknown_02039D04->curBox >= TOTAL_BOXES_COUNT)
+ gUnknown_02039D04->curBox = 0;
+ sub_80C7BE4();
+}
+
+void sub_80C7BB4(void)
+{
+ gUnknown_02039D04->curBox = (gUnknown_02039D04->curBox == 0 ? TOTAL_BOXES_COUNT - 1 : gUnknown_02039D04->curBox - 1);
+ sub_80C7BE4();
+}
- i = 0;
- if (i < count)
+void sub_80C7BE4(void)
+{
+ u8 text[16];
+ struct WindowTemplate winTemplate;
+ u8 windowId;
+ u8 *boxName = GetBoxNamePtr(gUnknown_02039D04->curBox);
+ u8 nPokemonInBox = CountMonsInBox(gUnknown_02039D04->curBox);
+ u32 winTileData;
+ s32 center;
+
+ memset(&winTemplate, 0, sizeof(winTemplate));
+ winTemplate.width = 8;
+ winTemplate.height = 4;
+
+ windowId = AddWindow(&winTemplate);
+ FillWindowPixelBuffer(windowId, 0x44);
+
+ center = GetStringCenterAlignXOffset(1, boxName, 0x40);
+ box_print(windowId, 1, center, 1, gUnknown_08571734, TEXT_SPEED_FF, boxName);
+
+ ConvertIntToDecimalStringN(text, nPokemonInBox, 1, 2);
+ StringAppend(text, gUnknown_08571737);
+ center = GetStringCenterAlignXOffset(1, text, 0x40);
+ box_print(windowId, 1, center, 0x11, gUnknown_08571734, TEXT_SPEED_FF, text);
+
+ winTileData = GetWindowAttribute(windowId, WINDOW_TILE_DATA);
+ CpuCopy32((void *)winTileData, (void *)OBJ_VRAM0 + 0x100 + (GetSpriteTileStartByTag(gUnknown_02039D04->unk_0240) * 32), 0x400);
+
+ RemoveWindow(windowId);
+}
+
+void sub_80C7CF4(struct Sprite *sprite)
+{
+ if (++sprite->data[1] > 3)
{
- size >>= 1;
- for (i = 0; i < count; i++)
+ sprite->data[1] = 0;
+ sprite->pos2.x += sprite->data[0];
+ if (++sprite->data[2] > 5)
{
- CpuSet(src, dst, size >> 0x10);
- dst += 0x20;
- src += srcBy;
+ sprite->data[2] = 0;
+ sprite->pos2.x = 0;
}
}
-}*/
+}
+
+void sub_80C7D28(void)
+{
+ LoadOam();
+ ProcessSpriteCopyRequests();
+ sub_80D2AA4();
+ TransferPlttBuffer();
+ SetGpuReg(REG_OFFSET_BG2HOFS, gUnknown_02039D08->bg2_X);
+}
+
+void c2_Box(void)
+{
+ RunTasks();
+ do_scheduled_bg_tilemap_copies_to_vram();
+ sub_80CA028();
+ sub_80CAA14();
+ AnimateSprites();
+ BuildOamBuffer();
+}
diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c
index 32d2bde4f..38b1fea4f 100644
--- a/src/pokemon_summary_screen.c
+++ b/src/pokemon_summary_screen.c
@@ -29,6 +29,7 @@
#include "daycare.h"
#include "data2.h"
#include "contest.h"
+#include "contest_effect.h"
extern struct UnkSummaryStruct* gUnknown_0203CF1C;
extern struct BgTemplate gUnknown_0861CBB4;
@@ -41,7 +42,6 @@ extern struct UnkStruct_61CC04 gUnknown_0861CC10;
extern struct UnkStruct_61CC04 gUnknown_0861CBEC;
extern struct UnkStruct_61CC04 gUnknown_0861CBF8;
extern u16 gSummaryScreenWindow_Tilemap[];
-extern struct ContestMove gContestMoves[];
extern struct ContestEffect gContestEffects[];
extern struct WindowTemplate gUnknown_0861CC24;
extern u8 gUnknown_0861CD2C[][3];
@@ -57,7 +57,6 @@ extern u8 gUnknown_0861CE7B[];
extern struct WindowTemplate gUnknown_0861CCEC;
extern struct WindowTemplate gUnknown_0861CD14;
extern const u8 *const gContestEffectDescriptionPointers[];
-extern const u8 *const gMoveDescriptionPointers[];
void sub_81C488C(u8 a);
extern u8 sub_81221EC();
@@ -342,6 +341,10 @@ struct UnkSummaryStruct
u8 unk_filler4[6];
};
+// const rom data
+#include "data/text/move_descriptions.h"
+
+// code
void sub_81BF8EC(u8 a, void *b, u8 c, u8 d, void *e)
{
u8 byte;
diff --git a/src/region_map.c b/src/region_map.c
index 5176d4996..3214ae185 100644
--- a/src/region_map.c
+++ b/src/region_map.c
@@ -22,6 +22,8 @@
#include "field_effect.h"
#include "region_map.h"
#include "constants/region_map_sections.h"
+#include "heal_location.h"
+#include "constants/heal_locations.h"
#define MAP_WIDTH 28
#define MAP_HEIGHT 15
@@ -52,7 +54,7 @@ static EWRAM_DATA struct {
/*0x88c*/ u8 unk_88c[0x1c0];
/*0xa4c*/ u8 unk_a4c[0x26];
/*0xa72*/ bool8 unk_a72;
-} *gUnknown_0203A148 = NULL; // a74
+} *sFlyMap = NULL; // a74
static bool32 gUnknown_03001180;
static bool32 gUnknown_03001184;
@@ -242,23 +244,23 @@ static const u16 Unknown_085A1D48[] = INCBIN_U16("graphics/pokenav/fly_target_ic
static const u8 sUnknown_085A1D68[] = INCBIN_U8("graphics/pokenav/fly_target_icons.4bpp.lz");
-static const u8 sUnknown_085A1E3C[][3] = {
- {MAP_GROUP(LITTLEROOT_TOWN), MAP_NUM(LITTLEROOT_TOWN), 1},
- {MAP_GROUP(OLDALE_TOWN), MAP_NUM(OLDALE_TOWN), 14},
- {MAP_GROUP(DEWFORD_TOWN), MAP_NUM(DEWFORD_TOWN), 15},
- {MAP_GROUP(LAVARIDGE_TOWN), MAP_NUM(LAVARIDGE_TOWN), 16},
- {MAP_GROUP(FALLARBOR_TOWN), MAP_NUM(FALLARBOR_TOWN), 17},
- {MAP_GROUP(VERDANTURF_TOWN), MAP_NUM(VERDANTURF_TOWN), 18},
- {MAP_GROUP(PACIFIDLOG_TOWN), MAP_NUM(PACIFIDLOG_TOWN), 19},
- {MAP_GROUP(PETALBURG_CITY), MAP_NUM(PETALBURG_CITY), 3},
- {MAP_GROUP(SLATEPORT_CITY), MAP_NUM(SLATEPORT_CITY), 4},
- {MAP_GROUP(MAUVILLE_CITY), MAP_NUM(MAUVILLE_CITY), 5},
- {MAP_GROUP(RUSTBORO_CITY), MAP_NUM(RUSTBORO_CITY), 6},
- {MAP_GROUP(FORTREE_CITY), MAP_NUM(FORTREE_CITY), 7},
- {MAP_GROUP(LILYCOVE_CITY), MAP_NUM(LILYCOVE_CITY), 8},
- {MAP_GROUP(MOSSDEEP_CITY), MAP_NUM(MOSSDEEP_CITY), 9},
- {MAP_GROUP(SOOTOPOLIS_CITY), MAP_NUM(SOOTOPOLIS_CITY), 10},
- {MAP_GROUP(EVER_GRANDE_CITY), MAP_NUM(EVER_GRANDE_CITY), 11},
+static const u8 sMapHealLocations[][3] = {
+ {MAP_GROUP(LITTLEROOT_TOWN), MAP_NUM(LITTLEROOT_TOWN), HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F},
+ {MAP_GROUP(OLDALE_TOWN), MAP_NUM(OLDALE_TOWN), HEAL_LOCATION_OLDALE_TOWN},
+ {MAP_GROUP(DEWFORD_TOWN), MAP_NUM(DEWFORD_TOWN), HEAL_LOCATION_DEWFORD_TOWN},
+ {MAP_GROUP(LAVARIDGE_TOWN), MAP_NUM(LAVARIDGE_TOWN), HEAL_LOCATION_LAVARIDGE_TOWN},
+ {MAP_GROUP(FALLARBOR_TOWN), MAP_NUM(FALLARBOR_TOWN), HEAL_LOCATION_FALLARBOR_TOWN},
+ {MAP_GROUP(VERDANTURF_TOWN), MAP_NUM(VERDANTURF_TOWN), HEAL_LOCATION_VERDANTURF_TOWN},
+ {MAP_GROUP(PACIFIDLOG_TOWN), MAP_NUM(PACIFIDLOG_TOWN), HEAL_LOCATION_PACIFIDLOG_TOWN},
+ {MAP_GROUP(PETALBURG_CITY), MAP_NUM(PETALBURG_CITY), HEAL_LOCATION_PETALBURG_CITY},
+ {MAP_GROUP(SLATEPORT_CITY), MAP_NUM(SLATEPORT_CITY), HEAL_LOCATION_SLATEPORT_CITY},
+ {MAP_GROUP(MAUVILLE_CITY), MAP_NUM(MAUVILLE_CITY), HEAL_LOCATION_MAUVILLE_CITY},
+ {MAP_GROUP(RUSTBORO_CITY), MAP_NUM(RUSTBORO_CITY), HEAL_LOCATION_RUSTBORO_CITY},
+ {MAP_GROUP(FORTREE_CITY), MAP_NUM(FORTREE_CITY), HEAL_LOCATION_FORTREE_CITY},
+ {MAP_GROUP(LILYCOVE_CITY), MAP_NUM(LILYCOVE_CITY), HEAL_LOCATION_LILYCOVE_CITY},
+ {MAP_GROUP(MOSSDEEP_CITY), MAP_NUM(MOSSDEEP_CITY), HEAL_LOCATION_MOSSDEEP_CITY},
+ {MAP_GROUP(SOOTOPOLIS_CITY), MAP_NUM(SOOTOPOLIS_CITY), HEAL_LOCATION_SOOTOPOLIS_CITY},
+ {MAP_GROUP(EVER_GRANDE_CITY), MAP_NUM(EVER_GRANDE_CITY), HEAL_LOCATION_EVER_GRANDE_CITY_1},
{MAP_GROUP(ROUTE101), MAP_NUM(ROUTE101), 0},
{MAP_GROUP(ROUTE102), MAP_NUM(ROUTE102), 0},
{MAP_GROUP(ROUTE103), MAP_NUM(ROUTE103), 0},
@@ -1578,8 +1580,8 @@ void MCB2_FlyMap(void)
SetGpuReg(REG_OFFSET_BG2HOFS, 0);
SetGpuReg(REG_OFFSET_BG3HOFS, 0);
SetGpuReg(REG_OFFSET_BG3VOFS, 0);
- gUnknown_0203A148 = malloc(sizeof(*gUnknown_0203A148));
- if (gUnknown_0203A148 == NULL)
+ sFlyMap = malloc(sizeof(*sFlyMap));
+ if (sFlyMap == NULL)
{
SetMainCallback2(CB2_ReturnToFieldWithOpenMenu);
}
@@ -1608,11 +1610,11 @@ void MCB2_FlyMap(void)
gMain.state++;
break;
case 4:
- InitRegionMap(&gUnknown_0203A148->regionMap, FALSE);
+ InitRegionMap(&sFlyMap->regionMap, FALSE);
CreateRegionMapCursor(0, 0);
CreateRegionMapPlayerIcon(1, 1);
- gUnknown_0203A148->mapSecId = gUnknown_0203A148->regionMap.mapSecId;
- StringFill(gUnknown_0203A148->unk_a4c, CHAR_SPACE, 16);
+ sFlyMap->mapSecId = sFlyMap->regionMap.mapSecId;
+ StringFill(sFlyMap->unk_a4c, CHAR_SPACE, 16);
gUnknown_03001180 = TRUE;
sub_8124904();
gMain.state++;
@@ -1664,7 +1666,7 @@ static void sub_81248C0(void)
static void sub_81248D4(void)
{
- gUnknown_0203A148->unk_000();
+ sFlyMap->unk_000();
AnimateSprites();
BuildOamBuffer();
do_scheduled_bg_tilemap_copies_to_vram();
@@ -1672,8 +1674,8 @@ static void sub_81248D4(void)
static void sub_81248F4(void callback(void))
{
- gUnknown_0203A148->unk_000 = callback;
- gUnknown_0203A148->unk_004 = 0;
+ sFlyMap->unk_000 = callback;
+ sFlyMap->unk_004 = 0;
}
static void sub_8124904(void)
@@ -1682,21 +1684,21 @@ static void sub_8124904(void)
bool32 flag;
const u8 *name;
- if (gUnknown_0203A148->regionMap.iconDrawType > MAPSECTYPE_NONE && gUnknown_0203A148->regionMap.iconDrawType <= MAPSECTYPE_BATTLE_FRONTIER)
+ if (sFlyMap->regionMap.iconDrawType > MAPSECTYPE_NONE && sFlyMap->regionMap.iconDrawType <= MAPSECTYPE_BATTLE_FRONTIER)
{
flag = FALSE;
for (i = 0; i < 1; i++)
{
- if (gUnknown_0203A148->regionMap.mapSecId == gUnknown_085A1EDC[i].mapSecId)
+ if (sFlyMap->regionMap.mapSecId == gUnknown_085A1EDC[i].mapSecId)
{
if (FlagGet(gUnknown_085A1EDC[i].flag))
{
- StringLength(gUnknown_085A1EDC[i].name[gUnknown_0203A148->regionMap.posWithinMapSec]);
+ StringLength(gUnknown_085A1EDC[i].name[sFlyMap->regionMap.posWithinMapSec]);
flag = TRUE;
sub_8198070(0, FALSE);
SetWindowBorderStyle(1, FALSE, 0x65, 0x0d);
- PrintTextOnWindow(1, 1, gUnknown_0203A148->regionMap.mapSecName, 0, 1, 0, NULL);
- name = gUnknown_085A1EDC[i].name[gUnknown_0203A148->regionMap.posWithinMapSec];
+ PrintTextOnWindow(1, 1, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL);
+ name = gUnknown_085A1EDC[i].name[sFlyMap->regionMap.posWithinMapSec];
PrintTextOnWindow(1, 1, name, GetStringRightAlignXOffset(1, name, 0x60), 0x11, 0, NULL);
schedule_bg_copy_tilemap_to_vram(0);
gUnknown_03001180 = TRUE;
@@ -1715,7 +1717,7 @@ static void sub_8124904(void)
{
FillWindowPixelBuffer(0, 0x11);
}
- PrintTextOnWindow(0, 1, gUnknown_0203A148->regionMap.mapSecName, 0, 1, 0, NULL);
+ PrintTextOnWindow(0, 1, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL);
schedule_bg_copy_tilemap_to_vram(0);
gUnknown_03001180 = FALSE;
}
@@ -1739,8 +1741,8 @@ static void sub_8124A70(void)
{
struct SpriteSheet sheet;
- LZ77UnCompWram(sUnknown_085A1D68, gUnknown_0203A148->unk_88c);
- sheet.data = gUnknown_0203A148->unk_88c;
+ LZ77UnCompWram(sUnknown_085A1D68, sFlyMap->unk_88c);
+ sheet.data = sFlyMap->unk_88c;
sheet.size = 0x1c0;
sheet.tag = 2;
LoadSpriteSheet(&sheet);
@@ -1829,7 +1831,7 @@ static void sub_8124BE4(void)
static void sub_8124CBC(struct Sprite *sprite)
{
- if (gUnknown_0203A148->regionMap.mapSecId == sprite->data[0])
+ if (sFlyMap->regionMap.mapSecId == sprite->data[0])
{
if (++sprite->data[1] > 16)
{
@@ -1846,11 +1848,11 @@ static void sub_8124CBC(struct Sprite *sprite)
static void sub_8124D14(void)
{
- switch (gUnknown_0203A148->unk_004)
+ switch (sFlyMap->unk_004)
{
case 0:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0);
- gUnknown_0203A148->unk_004++;
+ sFlyMap->unk_004++;
break;
case 1:
if (!UpdatePaletteFade())
@@ -1863,7 +1865,7 @@ static void sub_8124D14(void)
static void sub_8124D64(void)
{
- if (gUnknown_0203A148->unk_004 == 0)
+ if (sFlyMap->unk_004 == 0)
{
switch (sub_81230AC())
{
@@ -1875,16 +1877,16 @@ static void sub_8124D64(void)
sub_8124904();
break;
case INPUT_EVENT_A_BUTTON:
- if (gUnknown_0203A148->regionMap.iconDrawType == MAPSECTYPE_CITY_CANFLY || gUnknown_0203A148->regionMap.iconDrawType == MAPSECTYPE_BATTLE_FRONTIER)
+ if (sFlyMap->regionMap.iconDrawType == MAPSECTYPE_CITY_CANFLY || sFlyMap->regionMap.iconDrawType == MAPSECTYPE_BATTLE_FRONTIER)
{
m4aSongNumStart(SE_SELECT);
- gUnknown_0203A148->unk_a72 = TRUE;
+ sFlyMap->unk_a72 = TRUE;
sub_81248F4(sub_8124E0C);
}
break;
case INPUT_EVENT_B_BUTTON:
m4aSongNumStart(SE_SELECT);
- gUnknown_0203A148->unk_a72 = FALSE;
+ sFlyMap->unk_a72 = FALSE;
sub_81248F4(sub_8124E0C);
break;
}
@@ -1893,40 +1895,40 @@ static void sub_8124D64(void)
static void sub_8124E0C(void)
{
- switch (gUnknown_0203A148->unk_004)
+ switch (sFlyMap->unk_004)
{
case 0:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0);
- gUnknown_0203A148->unk_004++;
+ sFlyMap->unk_004++;
break;
case 1:
if (!UpdatePaletteFade())
{
FreeRegionMapIconResources();
- if (gUnknown_0203A148->unk_a72)
+ if (sFlyMap->unk_a72)
{
- switch (gUnknown_0203A148->regionMap.mapSecId)
+ switch (sFlyMap->regionMap.mapSecId)
{
case MAPSEC_SOUTHERN_ISLAND:
- sub_8084CCC(0x15);
+ sub_8084CCC(HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR);
break;
case MAPSEC_BATTLE_FRONTIER:
- sub_8084CCC(0x16);
+ sub_8084CCC(HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST);
break;
case MAPSEC_LITTLEROOT_TOWN:
- sub_8084CCC(gSaveBlock2Ptr->playerGender == MALE ? 0x0C : 0x0D);
+ sub_8084CCC(gSaveBlock2Ptr->playerGender == MALE ? HEAL_LOCATION_LITTLEROOT_TOWN_1 : HEAL_LOCATION_LITTLEROOT_TOWN_2);
break;
case MAPSEC_EVER_GRANDE_CITY:
- sub_8084CCC(FlagGet(FLAG_LANDMARK_POKEMON_LEAGUE) && gUnknown_0203A148->regionMap.posWithinMapSec == 0 ? 0x14 : 0x0B);
+ sub_8084CCC(FlagGet(FLAG_LANDMARK_POKEMON_LEAGUE) && sFlyMap->regionMap.posWithinMapSec == 0 ? HEAL_LOCATION_EVER_GRANDE_CITY_2 : HEAL_LOCATION_EVER_GRANDE_CITY_1);
break;
default:
- if (sUnknown_085A1E3C[gUnknown_0203A148->regionMap.mapSecId][2] != 0)
+ if (sMapHealLocations[sFlyMap->regionMap.mapSecId][2] != 0)
{
- sub_8084CCC(sUnknown_085A1E3C[gUnknown_0203A148->regionMap.mapSecId][2]);
+ sub_8084CCC(sMapHealLocations[sFlyMap->regionMap.mapSecId][2]);
}
else
{
- warp1_set_2(sUnknown_085A1E3C[gUnknown_0203A148->regionMap.mapSecId][0], sUnknown_085A1E3C[gUnknown_0203A148->regionMap.mapSecId][1], -1);
+ warp1_set_2(sMapHealLocations[sFlyMap->regionMap.mapSecId][0], sMapHealLocations[sFlyMap->regionMap.mapSecId][1], -1);
}
break;
}
@@ -1936,10 +1938,10 @@ static void sub_8124E0C(void)
{
SetMainCallback2(sub_81B58A8);
}
- if (gUnknown_0203A148 != NULL)
+ if (sFlyMap != NULL)
{
- free(gUnknown_0203A148);
- gUnknown_0203A148 = NULL;
+ free(sFlyMap);
+ sFlyMap = NULL;
}
FreeAllWindowBuffers();
}
diff --git a/src/rotating_gate.c b/src/rotating_gate.c
index 1f5ef165f..fcced6c8c 100644
--- a/src/rotating_gate.c
+++ b/src/rotating_gate.c
@@ -189,12 +189,6 @@ struct RotatingGatePuzzle
u8 orientation;
};
-struct Coords8
-{
- s8 deltaX;
- s8 deltaY;
-};
-
// .rodata
// Fortree
static const struct RotatingGatePuzzle sRotatingGate_FortreePuzzleConfig[] =
diff --git a/src/scrcmd.c b/src/scrcmd.c
index a15ad666c..01d04704a 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -1515,7 +1515,7 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx)
xText = (xWindow - xText - 1) * 8 + 3;
yText = (yText - yWindow - 1) * 8;
- winTemplate = sub_8198A50(0, xWindow, yWindow + 1, width, height, 0xF, 0x1);
+ winTemplate = CreateWindowTemplate(0, xWindow, yWindow + 1, width, height, 0xF, 0x1);
gUnknown_03000F30 = AddWindow(&winTemplate);
LoadUserWindowBorderGfx(gUnknown_03000F30, 0x214, 0xE0);
NewMenuHelpers_DrawStdWindowFrame(gUnknown_03000F30, 0);
diff --git a/src/tv.c b/src/tv.c
index 2e915697e..d09e72abc 100644
--- a/src/tv.c
+++ b/src/tv.c
@@ -1448,8 +1448,8 @@ void ContestLiveUpdates_BeforeInterview_5(u8 a0, u8 a1)
sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
if (sCurTVShowSlot != -1)
{
- show->contestLiveUpdates.winningSpecies = gUnknown_02039E00[a1].unk_00;
- StringCopy(show->contestLiveUpdates.winningTrainerName, gUnknown_02039E00[a1].unk_0d);
+ show->contestLiveUpdates.winningSpecies = gContestMons[a1].species;
+ StringCopy(show->contestLiveUpdates.winningTrainerName, gContestMons[a1].trainerName);
StripExtCtrlCodes(show->contestLiveUpdates.winningTrainerName);
show->contestLiveUpdates.appealFlags2 = a0;
if (a1 + 1 > gUnknown_02039F30)
diff --git a/src/wallclock.c b/src/wallclock.c
index 9b96d416c..3d95d75ac 100644
--- a/src/wallclock.c
+++ b/src/wallclock.c
@@ -602,7 +602,7 @@ static void WallClockInit(void)
ShowBg(3);
}
-void Cb2_StartWallClock(void)
+void CB2_StartWallClock(void)
{
u8 taskId;
u8 spriteId;
@@ -644,7 +644,7 @@ void Cb2_StartWallClock(void)
schedule_bg_copy_tilemap_to_vram(2);
}
-void Cb2_ViewWallClock(void)
+void CB2_ViewWallClock(void)
{
u8 taskId;
u8 spriteId;