summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battle_anim.c4
-rw-r--r--src/battle_anim_80A9C70.c4
-rwxr-xr-xsrc/battle_anim_8170478.c12
-rw-r--r--src/battle_arena.c2
-rw-r--r--src/battle_bg.c2
-rw-r--r--src/battle_dome.c4
-rw-r--r--src/battle_factory_screen.c6
-rw-r--r--src/battle_gfx_sfx_util.c44
-rw-r--r--src/battle_interface.c2
-rw-r--r--src/battle_pike.c2
-rw-r--r--src/battle_pyramid_bag.c4
-rw-r--r--src/battle_tower.c2
-rw-r--r--src/berry_tag_screen.c4
-rw-r--r--src/bg.c84
-rw-r--r--src/blit.c10
-rwxr-xr-xsrc/cable_car.c6
-rw-r--r--src/contest.c6
-rw-r--r--src/credits.c12
-rw-r--r--src/daycare.c4
-rw-r--r--src/decompress.c12
-rw-r--r--src/decoration.c6
-rw-r--r--src/dma3_manager.c46
-rw-r--r--src/egg_hatch.c15
-rw-r--r--src/evolution_graphics.c2
-rw-r--r--src/field_effect.c4
-rw-r--r--src/field_player_avatar.c2
-rw-r--r--src/field_poison.c2
-rw-r--r--src/field_specials.c4
-rw-r--r--src/hall_of_fame.c8
-rw-r--r--src/intro.c26
-rw-r--r--src/intro_credits_graphics.c12
-rw-r--r--src/item_icon.c4
-rwxr-xr-xsrc/item_menu.c8
-rw-r--r--src/item_menu_icons.c2
-rw-r--r--src/link_rfu.c2
-rw-r--r--src/list_menu.c6
-rw-r--r--src/load_save.c1
-rw-r--r--src/main_menu.c2
-rw-r--r--src/menu.c38
-rw-r--r--src/menu_helpers.c4
-rw-r--r--src/mon_markings.c1
-rw-r--r--src/money.c4
-rw-r--r--src/overworld.c2
-rwxr-xr-xsrc/party_menu.c354
-rw-r--r--src/player_pc.c4
-rw-r--r--src/pokeball.c12
-rw-r--r--src/pokeblock.c4
-rw-r--r--src/pokeblock_feed.c10
-rw-r--r--src/pokedex.c4
-rw-r--r--src/pokemon.c26
-rw-r--r--src/pokemon_icon.c17
-rw-r--r--src/pokemon_size_record.c2
-rw-r--r--src/pokemon_storage_system.c10184
-rw-r--r--src/pokemon_summary_screen.c24
-rw-r--r--src/post_battle_event_funcs.c4
-rw-r--r--src/rayquaza_scene.c46
-rw-r--r--src/rom_8034C54.c2
-rw-r--r--src/save.c1
-rw-r--r--src/scrcmd.c2
-rw-r--r--src/script_menu.c12
-rwxr-xr-xsrc/script_pokemon_util_80F87D8.c2
-rw-r--r--src/smokescreen.c4
-rw-r--r--src/start_menu.c4
-rw-r--r--src/starter_choose.c4
-rw-r--r--src/text.c7
-rw-r--r--src/title_screen.c6
-rw-r--r--src/trainer_pokemon_sprites.c4
-rw-r--r--src/tv.c2
-rw-r--r--src/unk_transition.c2
-rw-r--r--src/walda_phrase.c11
-rw-r--r--src/wallclock.c2
-rw-r--r--src/wild_encounter.c12
-rw-r--r--src/window.c66
73 files changed, 10587 insertions, 674 deletions
diff --git a/src/battle_anim.c b/src/battle_anim.c
index 1e1219800..2d211c411 100644
--- a/src/battle_anim.c
+++ b/src/battle_anim.c
@@ -1605,8 +1605,8 @@ static void ScriptCmd_loadspritegfx(void)
sBattleAnimScriptPtr++;
index = T1_READ_16(sBattleAnimScriptPtr);
- LoadCompressedObjectPicUsingHeap(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(index)]);
- LoadCompressedObjectPaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(index)]);
+ LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(index)]);
+ LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(index)]);
sBattleAnimScriptPtr += 2;
AddSpriteIndex(GET_TRUE_SPRITE_INDEX(index));
gAnimFramesToWait = 1;
diff --git a/src/battle_anim_80A9C70.c b/src/battle_anim_80A9C70.c
index 2eea276a1..001f99d7f 100644
--- a/src/battle_anim_80A9C70.c
+++ b/src/battle_anim_80A9C70.c
@@ -71,8 +71,8 @@ u8 sub_80A9C70(u8 battlerId, bool8 b)
u8 spriteId2;
u8 i;
- LoadCompressedObjectPicUsingHeap(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_CIRCLE_IMPACT)]);
- LoadCompressedObjectPaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_CIRCLE_IMPACT)]);
+ LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_CIRCLE_IMPACT)]);
+ LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_CIRCLE_IMPACT)]);
gTasks[taskId].data[0] = battlerId;
if (b)
{
diff --git a/src/battle_anim_8170478.c b/src/battle_anim_8170478.c
index 32214b58d..502c4cdbb 100755
--- a/src/battle_anim_8170478.c
+++ b/src/battle_anim_8170478.c
@@ -1376,8 +1376,8 @@ static void sub_8171D60(u8 ballId)
if (GetSpriteTileStartByTag(gBallOpenParticleSpritesheets[ballId].tag) == 0xFFFF)
{
- LoadCompressedObjectPicUsingHeap(&gBallOpenParticleSpritesheets[ballId]);
- LoadCompressedObjectPaletteUsingHeap(&gBallOpenParticlePalettes[ballId]);
+ LoadCompressedSpriteSheetUsingHeap(&gBallOpenParticleSpritesheets[ballId]);
+ LoadCompressedSpritePaletteUsingHeap(&gBallOpenParticlePalettes[ballId]);
}
}
@@ -2032,8 +2032,8 @@ void sub_8172EF0(u8 battler, struct Pokemon *mon)
{
if (GetSpriteTileStartByTag(0x27F9) == 0xFFFF)
{
- LoadCompressedObjectPicUsingHeap(&gBattleAnimPicTable[233]);
- LoadCompressedObjectPaletteUsingHeap(&gBattleAnimPaletteTable[233]);
+ LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[233]);
+ LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[233]);
}
taskId1 = CreateTask(sub_8172FEC, 10);
@@ -2173,8 +2173,8 @@ void sub_81732B0(u8 taskId)
{
u8 paletteIndex;
- LoadCompressedObjectPicUsingHeap(&gBattleAnimPicTable[269]);
- LoadCompressedObjectPaletteUsingHeap(&gBattleAnimPaletteTable[269]);
+ LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[269]);
+ LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[269]);
paletteIndex = IndexOfSpritePaletteTag(0x281D); // unused
DestroyAnimVisualTask(taskId);
}
diff --git a/src/battle_arena.c b/src/battle_arena.c
index cd2c976da..14f86c882 100644
--- a/src/battle_arena.c
+++ b/src/battle_arena.c
@@ -499,7 +499,7 @@ u8 BattleArena_ShowJudgmentWindow(u8 *state)
case 0:
BeginNormalPaletteFade(0x7FFFFF1C, 4, 0, 8, 0);
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR);
- LoadCompressedObjectPic(gUnknown_08611F74);
+ LoadCompressedSpriteSheet(gUnknown_08611F74);
LoadCompressedPalette(gUnknown_08D855E8, 0x1F0, 0x20);
gBattle_WIN0H = 0xFF;
gBattle_WIN0V = 0x70;
diff --git a/src/battle_bg.c b/src/battle_bg.c
index bb66a41fd..7ba59e6be 100644
--- a/src/battle_bg.c
+++ b/src/battle_bg.c
@@ -1103,7 +1103,7 @@ void DrawBattleEntryBackground(void)
SetGpuReg(REG_OFFSET_WINOUT, 0x36);
gBattle_BG1_Y = 0xFF5C;
gBattle_BG2_Y = 0xFF5C;
- LoadCompressedObjectPicUsingHeap(&gUnknown_0831AA00);
+ LoadCompressedSpriteSheetUsingHeap(&gUnknown_0831AA00);
}
else if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER))
{
diff --git a/src/battle_dome.c b/src/battle_dome.c
index 514b57c97..159d7e790 100644
--- a/src/battle_dome.c
+++ b/src/battle_dome.c
@@ -3536,7 +3536,7 @@ static void sub_8190400(u8 taskId)
DecompressAndLoadBgGfxUsingHeap(2, gUnknown_08D83D50, 0x2000, 0, 0);
DecompressAndLoadBgGfxUsingHeap(2, gUnknown_08D84970, 0x2000, 0, 1);
DecompressAndLoadBgGfxUsingHeap(3, gUnknown_08D84F00, 0x800, 0, 1);
- LoadCompressedObjectPic(gUnknown_0860CF50);
+ LoadCompressedSpriteSheet(gUnknown_0860CF50);
LoadCompressedPalette(gUnknown_08D85358, 0, 0x200);
LoadCompressedPalette(gUnknown_08D85444, 0x100, 0x200);
LoadCompressedPalette(gUnknown_08D85600, 0xF0, 0x20);
@@ -5707,7 +5707,7 @@ static void sub_8194220(u8 taskId)
gTasks[taskId].data[0]++;
break;
case 3:
- LoadCompressedObjectPic(gUnknown_0860CF50);
+ LoadCompressedSpriteSheet(gUnknown_0860CF50);
if (r10 == 0)
{
for (i = 0; i < (unsigned) 31; i++)
diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c
index 60b233daf..0bcdc0d66 100644
--- a/src/battle_factory_screen.c
+++ b/src/battle_factory_screen.c
@@ -131,8 +131,6 @@ struct FactorySwapMonsStruct
bool8 unk30;
};
-extern u8 gUnknown_0203CF20;
-
extern const u16 gBattleFrontierHeldItems[];
extern const struct FacilityMon gBattleFrontierMons[];
extern const struct FacilityMon gSlateportBattleTentMons[];
@@ -1167,7 +1165,7 @@ static void CB2_InitSelectScreen(void)
case 4:
LoadSpritePalettes(gUnknown_086103F4);
LoadSpriteSheets(gUnknown_086103BC);
- LoadCompressedObjectPic(gUnknown_086103E4);
+ LoadCompressedSpriteSheet(gUnknown_086103E4);
ShowBg(0);
ShowBg(1);
SetVBlankCallback(Select_VblankCb);
@@ -3171,7 +3169,7 @@ static void CB2_InitSwapScreen(void)
case 4:
LoadSpritePalettes(gUnknown_086106B0);
LoadSpriteSheets(gUnknown_08610650);
- LoadCompressedObjectPic(gUnknown_086106A0);
+ LoadCompressedSpriteSheet(gUnknown_086106A0);
SetVBlankCallback(Swap_VblankCb);
gMain.state++;
break;
diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c
index f53a6281d..a5d2566df 100644
--- a/src/battle_gfx_sfx_util.c
+++ b/src/battle_gfx_sfx_util.c
@@ -643,7 +643,7 @@ void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId)
DecompressPicFromTable_2(&gTrainerFrontPicTable[frontPicId],
gMonSpritesGfxPtr->sprites[position],
SPECIES_NONE);
- LoadCompressedObjectPalette(&gTrainerFrontPicPaletteTable[frontPicId]);
+ LoadCompressedSpritePalette(&gTrainerFrontPicPaletteTable[frontPicId]);
}
void DecompressTrainerBackPic(u16 backPicId, u8 battlerId)
@@ -675,20 +675,20 @@ void BattleLoadAllHealthBoxesGfxAtOnce(void)
LoadSpritePalette(&sSpritePalettes_HealthBoxHealthBar[1]);
if (!IsDoubleBattle())
{
- LoadCompressedObjectPic(&sSpriteSheet_SinglesPlayerHealthbox);
- LoadCompressedObjectPic(&sSpriteSheet_SinglesOpponentHealthbox);
+ LoadCompressedSpriteSheet(&sSpriteSheet_SinglesPlayerHealthbox);
+ LoadCompressedSpriteSheet(&sSpriteSheet_SinglesOpponentHealthbox);
numberOfBattlers = 2;
}
else
{
- LoadCompressedObjectPic(&sSpriteSheets_DoublesPlayerHealthbox[0]);
- LoadCompressedObjectPic(&sSpriteSheets_DoublesPlayerHealthbox[1]);
- LoadCompressedObjectPic(&sSpriteSheets_DoublesOpponentHealthbox[0]);
- LoadCompressedObjectPic(&sSpriteSheets_DoublesOpponentHealthbox[1]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_DoublesPlayerHealthbox[0]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_DoublesPlayerHealthbox[1]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_DoublesOpponentHealthbox[0]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_DoublesOpponentHealthbox[1]);
numberOfBattlers = 4;
}
for (i = 0; i < numberOfBattlers; i++)
- LoadCompressedObjectPic(&sSpriteSheets_HealthBar[gBattlerPositions[i]]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[gBattlerPositions[i]]);
}
bool8 BattleLoadAllHealthBoxesGfx(u8 state)
@@ -707,37 +707,37 @@ bool8 BattleLoadAllHealthBoxesGfx(u8 state)
if (state == 2)
{
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
- LoadCompressedObjectPic(&sSpriteSheet_SafariHealthbox);
+ LoadCompressedSpriteSheet(&sSpriteSheet_SafariHealthbox);
else
- LoadCompressedObjectPic(&sSpriteSheet_SinglesPlayerHealthbox);
+ LoadCompressedSpriteSheet(&sSpriteSheet_SinglesPlayerHealthbox);
}
else if (state == 3)
- LoadCompressedObjectPic(&sSpriteSheet_SinglesOpponentHealthbox);
+ LoadCompressedSpriteSheet(&sSpriteSheet_SinglesOpponentHealthbox);
else if (state == 4)
- LoadCompressedObjectPic(&sSpriteSheets_HealthBar[gBattlerPositions[0]]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[gBattlerPositions[0]]);
else if (state == 5)
- LoadCompressedObjectPic(&sSpriteSheets_HealthBar[gBattlerPositions[1]]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[gBattlerPositions[1]]);
else
retVal = TRUE;
}
else
{
if (state == 2)
- LoadCompressedObjectPic(&sSpriteSheets_DoublesPlayerHealthbox[0]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_DoublesPlayerHealthbox[0]);
else if (state == 3)
- LoadCompressedObjectPic(&sSpriteSheets_DoublesPlayerHealthbox[1]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_DoublesPlayerHealthbox[1]);
else if (state == 4)
- LoadCompressedObjectPic(&sSpriteSheets_DoublesOpponentHealthbox[0]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_DoublesOpponentHealthbox[0]);
else if (state == 5)
- LoadCompressedObjectPic(&sSpriteSheets_DoublesOpponentHealthbox[1]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_DoublesOpponentHealthbox[1]);
else if (state == 6)
- LoadCompressedObjectPic(&sSpriteSheets_HealthBar[gBattlerPositions[0]]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[gBattlerPositions[0]]);
else if (state == 7)
- LoadCompressedObjectPic(&sSpriteSheets_HealthBar[gBattlerPositions[1]]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[gBattlerPositions[1]]);
else if (state == 8)
- LoadCompressedObjectPic(&sSpriteSheets_HealthBar[gBattlerPositions[2]]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[gBattlerPositions[2]]);
else if (state == 9)
- LoadCompressedObjectPic(&sSpriteSheets_HealthBar[gBattlerPositions[3]]);
+ LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[gBattlerPositions[3]]);
else
retVal = TRUE;
}
@@ -1116,7 +1116,7 @@ void LoadAndCreateEnemyShadowSprites(void)
{
u8 battlerId;
- LoadCompressedObjectPic(&gSpriteSheet_EnemyShadow);
+ LoadCompressedSpriteSheet(&gSpriteSheet_EnemyShadow);
battlerId = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBattlerSpriteCoord(battlerId, 0), GetBattlerSpriteCoord(battlerId, 1) + 29, 0xC8);
diff --git a/src/battle_interface.c b/src/battle_interface.c
index 9fd8e116a..4a8422091 100644
--- a/src/battle_interface.c
+++ b/src/battle_interface.c
@@ -1523,7 +1523,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
bar_data0 = 5;
}
- LoadCompressedObjectPicUsingHeap(&sStatusSummaryBarSpriteSheet);
+ LoadCompressedSpriteSheetUsingHeap(&sStatusSummaryBarSpriteSheet);
LoadSpriteSheet(&sStatusSummaryBallsSpriteSheet);
LoadSpritePalette(&sStatusSummaryBarSpritePal);
LoadSpritePalette(&sStatusSummaryBallsSpritePal);
diff --git a/src/battle_pike.c b/src/battle_pike.c
index 893796790..303146f6a 100644
--- a/src/battle_pike.c
+++ b/src/battle_pike.c
@@ -1611,7 +1611,7 @@ static void sub_81A8830(void)
static bool8 CanEncounterWildMon(u8 enemyMonLevel)
{
- if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3))
+ if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG))
{
u8 monAbility = GetMonAbility(&gPlayerParty[0]);
if (monAbility == ABILITY_KEEN_EYE || monAbility == ABILITY_INTIMIDATE)
diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c
index 8a6348522..12f631155 100644
--- a/src/battle_pyramid_bag.c
+++ b/src/battle_pyramid_bag.c
@@ -547,7 +547,7 @@ static bool8 sub_81C5238(void)
gPyramidBagResources->state++;
break;
case 3:
- LoadCompressedObjectPic(&gUnknown_0861F3CC);
+ LoadCompressedSpriteSheet(&gUnknown_0861F3CC);
gPyramidBagResources->state++;
break;
case 4:
@@ -964,7 +964,7 @@ static void HandleMenuActionInput(u8 taskId)
{
if (sub_81221EC() != TRUE)
{
- s8 id = GetMenuCursorPos();
+ s8 id = Menu_GetCursorPos();
if (gMain.newKeys & DPAD_UP)
{
if (id > 0 && IsValidMenuAction(id - 2))
diff --git a/src/battle_tower.c b/src/battle_tower.c
index 4a9e0dbc4..e60783fa2 100644
--- a/src/battle_tower.c
+++ b/src/battle_tower.c
@@ -2147,7 +2147,7 @@ static void FillFactoryTentTrainerParty(u16 trainerId, u8 firstMonId)
void FrontierSpeechToString(const u16 *words)
{
ConvertEasyChatWordsToString(gStringVar4, words, 3, 2);
- if (GetStringWidth(1, gStringVar4, -1) > 204)
+ if (GetStringWidth(1, gStringVar4, -1) > 204u)
{
s32 i = 0;
diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c
index 22f99a426..6e968fc0a 100644
--- a/src/berry_tag_screen.c
+++ b/src/berry_tag_screen.c
@@ -349,11 +349,11 @@ static bool8 LoadBerryTagGfx(void)
sBerryTag->gfxState++;
break;
case 5:
- LoadCompressedObjectPic(&gUnknown_0857FDEC);
+ LoadCompressedSpriteSheet(&gUnknown_0857FDEC);
sBerryTag->gfxState++;
break;
default:
- LoadCompressedObjectPalette(&gUnknown_0857FDF4);
+ LoadCompressedSpritePalette(&gUnknown_0857FDF4);
return TRUE; // done
}
diff --git a/src/bg.c b/src/bg.c
index a41075ad7..21624e4a0 100644
--- a/src/bg.c
+++ b/src/bg.c
@@ -33,8 +33,8 @@ struct BgConfig2
u32 unk_3:18;
void* tilemap;
- u32 bg_x;
- u32 bg_y;
+ s32 bg_x;
+ s32 bg_y;
};
static IWRAM_DATA struct BgControl sGpuBgConfigs;
@@ -524,12 +524,12 @@ u16 GetBgAttribute(u8 bg, u8 attributeId)
case 8:
switch (GetBgType(bg))
{
- case 0:
- return GetBgMetricTextMode(bg, 0) * 0x800;
- case 1:
- return GetBgMetricAffineMode(bg, 0) * 0x100;
- default:
- return 0;
+ case 0:
+ return GetBgMetricTextMode(bg, 0) * 0x800;
+ case 1:
+ return GetBgMetricAffineMode(bg, 0) * 0x100;
+ default:
+ return 0;
}
case 9:
return GetBgType(bg);
@@ -540,7 +540,7 @@ u16 GetBgAttribute(u8 bg, u8 attributeId)
}
}
-u32 ChangeBgX(u8 bg, u32 value, u8 op)
+s32 ChangeBgX(u8 bg, s32 value, u8 op)
{
u8 mode;
u16 temp1;
@@ -610,7 +610,7 @@ u32 ChangeBgX(u8 bg, u32 value, u8 op)
return sGpuBgConfigs2[bg].bg_x;
}
-u32 GetBgX(u8 bg)
+s32 GetBgX(u8 bg)
{
if (IsInvalidBg32(bg) != FALSE)
return -1;
@@ -620,7 +620,7 @@ u32 GetBgX(u8 bg)
return sGpuBgConfigs2[bg].bg_x;
}
-u32 ChangeBgY(u8 bg, u32 value, u8 op)
+s32 ChangeBgY(u8 bg, s32 value, u8 op)
{
u8 mode;
u16 temp1;
@@ -690,7 +690,7 @@ u32 ChangeBgY(u8 bg, u32 value, u8 op)
return sGpuBgConfigs2[bg].bg_y;
}
-u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
+s32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
{
u8 mode;
u16 temp1;
@@ -761,7 +761,7 @@ u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
return sGpuBgConfigs2[bg].bg_y;
}
-u32 GetBgY(u8 bg)
+s32 GetBgY(u8 bg)
{
if (IsInvalidBg32(bg) != FALSE)
return -1;
@@ -778,14 +778,10 @@ void SetBgAffine(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX, s16 dis
u8 Unused_AdjustBgMosaic(u8 a1, u8 a2)
{
- u16 result;
- s16 test1;
- s16 test2;
-
- result = GetGpuReg(REG_OFFSET_MOSAIC);
+ u16 result = GetGpuReg(REG_OFFSET_MOSAIC);
+ s16 test1 = result & 0xF;
+ s16 test2 = (result >> 4) & 0xF;
- test1 = result & 0xF;
- test2 = (result >> 4) & 0xF;
result &= 0xFF00;
switch (a2)
@@ -1039,47 +1035,43 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt
u16 mode2;
u16 attribute;
u16 mode3;
+ u16 x16, y16;
- u16 x16;
- u16 y16;
-
- if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE)
+ if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg))
{
attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
mode = GetBgMetricTextMode(bg, 0x1) * 0x20;
mode2 = GetBgMetricTextMode(bg, 0x2) * 0x20;
switch (GetBgType(bg))
{
- case 0:
- for (y16 = y; y16 < (y + height); y16++)
+ case 0:
+ for (y16 = y; y16 < (y + height); y16++)
+ {
+ for (x16 = x; x16 < (x + width); x16++)
{
- for (x16 = x; x16 < (x + width); x16++)
- {
- CopyTileMapEntry(&firstTileNum, &((u16*)sGpuBgConfigs2[bg].tilemap)[(u16)GetTileMapIndexFromCoords(x16, y16, attribute, mode, mode2)], paletteSlot, 0, 0);
- firstTileNum = (firstTileNum & 0xFC00) + ((firstTileNum + tileNumDelta) & 0x3FF);
- }
+ CopyTileMapEntry(&firstTileNum, &((u16*)sGpuBgConfigs2[bg].tilemap)[(u16)GetTileMapIndexFromCoords(x16, y16, attribute, mode, mode2)], paletteSlot, 0, 0);
+ firstTileNum = (firstTileNum & 0xFC00) + ((firstTileNum + tileNumDelta) & 0x3FF);
}
- break;
- case 1:
- mode3 = GetBgMetricAffineMode(bg, 0x1);
- for (y16 = y; y16 < (y + height); y16++)
+ }
+ break;
+ case 1:
+ mode3 = GetBgMetricAffineMode(bg, 0x1);
+ for (y16 = y; y16 < (y + height); y16++)
+ {
+ for (x16 = x; x16 < (x + width); x16++)
{
- for (x16 = x; x16 < (x + width); x16++)
- {
- ((u8*)sGpuBgConfigs2[bg].tilemap)[(y16 * mode3) + x16] = firstTileNum;
- firstTileNum = (firstTileNum & 0xFC00) + ((firstTileNum + tileNumDelta) & 0x3FF);
- }
+ ((u8*)sGpuBgConfigs2[bg].tilemap)[(y16 * mode3) + x16] = firstTileNum;
+ firstTileNum = (firstTileNum & 0xFC00) + ((firstTileNum + tileNumDelta) & 0x3FF);
}
- break;
+ }
+ break;
}
}
}
u16 GetBgMetricTextMode(u8 bg, u8 whichMetric)
{
- u8 attribute;
-
- attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
+ u8 attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
switch (whichMetric)
{
@@ -1125,9 +1117,7 @@ u16 GetBgMetricTextMode(u8 bg, u8 whichMetric)
u32 GetBgMetricAffineMode(u8 bg, u8 whichMetric)
{
- u8 attribute;
-
- attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
+ u8 attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
switch (whichMetric)
{
diff --git a/src/blit.c b/src/blit.c
index b4d5f7de5..26a63fe9b 100644
--- a/src/blit.c
+++ b/src/blit.c
@@ -1,12 +1,12 @@
#include "global.h"
#include "blit.h"
-void BlitBitmapRect4BitWithoutColorKey(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height)
+void BlitBitmapRect4BitWithoutColorKey(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height)
{
BlitBitmapRect4Bit(src, dst, srcX, srcY, dstX, dstY, width, height, 0xFF);
}
-void BlitBitmapRect4Bit(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height, u8 colorKey)
+void BlitBitmapRect4Bit(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height, u8 colorKey)
{
s32 xEnd;
s32 yEnd;
@@ -14,7 +14,7 @@ void BlitBitmapRect4Bit(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 sr
s32 multiplierDstY;
s32 loopSrcY, loopDstY;
s32 loopSrcX, loopDstX;
- u8 *pixelsSrc;
+ const u8 *pixelsSrc;
u8 *pixelsDst;
s32 toOrr;
s32 toAnd;
@@ -103,7 +103,7 @@ void FillBitmapRect4Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 hei
}
}
-void BlitBitmapRect4BitTo8Bit(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height, u8 colorKey, u8 paletteOffset)
+void BlitBitmapRect4BitTo8Bit(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height, u8 colorKey, u8 paletteOffset)
{
s32 palOffsetBits;
s32 xEnd;
@@ -112,7 +112,7 @@ void BlitBitmapRect4BitTo8Bit(struct Bitmap *src, struct Bitmap *dst, u16 srcX,
s32 multiplierDstY;
s32 loopSrcY, loopDstY;
s32 loopSrcX, loopDstX;
- u8 *pixelsSrc;
+ const u8 *pixelsSrc;
u8 *pixelsDst;
s32 colorKeyBits;
diff --git a/src/cable_car.c b/src/cable_car.c
index 00606c905..207a0c22d 100755
--- a/src/cable_car.c
+++ b/src/cable_car.c
@@ -259,7 +259,7 @@ static void CableCarMainCallback_Setup(void)
break;
case 2:
for (i = 0; i < 3; i++)
- LoadCompressedObjectPic(&gUnknown_085CDB54[i]);
+ LoadCompressedSpriteSheet(&gUnknown_085CDB54[i]);
LoadSpritePalettes(gUnknown_085CDB74);
sCableCar->mtChimneyTilemap = malloc_and_decompress(gCableCarMtChimneyTilemap, &sizeOut);
@@ -351,7 +351,7 @@ static void CableCarMainCallback_Run(void)
static void CleanupCableCar(void)
{
u8 i = 0;
-
+
HideBg(0);
HideBg(1);
HideBg(2);
@@ -361,7 +361,7 @@ static void CleanupCableCar(void)
sub_80AB130(WEATHER_NONE);
for (i = 0; i < 20; i++)
gWeatherPtr->sprites.s2.ashSprites[i] = NULL;
-
+
ResetTasks();
ResetSpriteData();
ResetPaletteFade();
diff --git a/src/contest.c b/src/contest.c
index 3d74109cb..34662b490 100644
--- a/src/contest.c
+++ b/src/contest.c
@@ -2484,7 +2484,7 @@ u8 sub_80DB0C4(void)
{
u8 spriteId;
- LoadCompressedObjectPic(&gUnknown_08587C00);
+ LoadCompressedSpriteSheet(&gUnknown_08587C00);
LoadCompressedPalette(gContest2Pal, 0x110, 32);
spriteId = CreateSprite(&gSpriteTemplate_8587BE8, 112, 36, 30);
gSprites[spriteId].oam.paletteNum = 1;
@@ -2496,8 +2496,8 @@ u8 sub_80DB120(void)
{
u8 spriteId;
- LoadCompressedObjectPic(&gUnknown_08587C08);
- LoadCompressedObjectPalette(&gUnknown_08587C10);
+ LoadCompressedSpriteSheet(&gUnknown_08587C08);
+ LoadCompressedSpritePalette(&gUnknown_08587C10);
spriteId = CreateSprite(&gSpriteTemplate_8587C18, 96, 10, 29);
gSprites[spriteId].invisible = TRUE;
gSprites[spriteId].data[0] = gSprites[spriteId].oam.tileNum;
diff --git a/src/credits.c b/src/credits.c
index 67ab97481..42bdbf454 100644
--- a/src/credits.c
+++ b/src/credits.c
@@ -1964,9 +1964,9 @@ static bool8 sub_8176AB0(u8 data, u8 taskIdA)
case 2:
if (gSaveBlock2Ptr->playerGender == MALE)
{
- LoadCompressedObjectPic(gUnknown_085F5334);
- LoadCompressedObjectPic(gUnknown_085F53BC);
- LoadCompressedObjectPic(gUnknown_085F5354);
+ LoadCompressedSpriteSheet(gUnknown_085F5334);
+ LoadCompressedSpriteSheet(gUnknown_085F53BC);
+ LoadCompressedSpriteSheet(gUnknown_085F5354);
LoadSpritePalettes(gUnknown_085F5384);
spriteId = intro_create_brendan_sprite(120, 46);
@@ -1981,9 +1981,9 @@ static bool8 sub_8176AB0(u8 data, u8 taskIdA)
}
else
{
- LoadCompressedObjectPic(gUnknown_085F5344);
- LoadCompressedObjectPic(gUnknown_085F53AC);
- LoadCompressedObjectPic(gUnknown_085F5354);
+ LoadCompressedSpriteSheet(gUnknown_085F5344);
+ LoadCompressedSpriteSheet(gUnknown_085F53AC);
+ LoadCompressedSpriteSheet(gUnknown_085F5354);
LoadSpritePalettes(gUnknown_085F5384);
spriteId = intro_create_may_sprite(120, 46);
diff --git a/src/daycare.c b/src/daycare.c
index 131540f6e..ef93fd2d8 100644
--- a/src/daycare.c
+++ b/src/daycare.c
@@ -901,7 +901,7 @@ static bool8 _DoEggActions_CheckHatch(struct DayCare *daycare)
for (i = 0; i < DAYCARE_MON_COUNT; i++)
{
- if (GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SANITY_BIT2))
+ if (GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SANITY_HAS_SPECIES))
daycare->mons[i].steps++, validEggs++;
}
@@ -922,7 +922,7 @@ static bool8 _DoEggActions_CheckHatch(struct DayCare *daycare)
{
if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
continue;
- if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_BIT1))
+ if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_IS_BAD_EGG))
continue;
steps = GetMonData(&gPlayerParty[i], MON_DATA_FRIENDSHIP);
diff --git a/src/decompress.c b/src/decompress.c
index 24d23209f..ed2f7a0bb 100644
--- a/src/decompress.c
+++ b/src/decompress.c
@@ -22,7 +22,7 @@ void LZDecompressVram(const u32 *src, void *dest)
LZ77UnCompVram(src, dest);
}
-u16 LoadCompressedObjectPic(const struct CompressedSpriteSheet *src)
+u16 LoadCompressedSpriteSheet(const struct CompressedSpriteSheet *src)
{
struct SpriteSheet dest;
@@ -33,7 +33,7 @@ u16 LoadCompressedObjectPic(const struct CompressedSpriteSheet *src)
return LoadSpriteSheet(&dest);
}
-void LoadCompressedObjectPicOverrideBuffer(const struct CompressedSpriteSheet *src, void *buffer)
+void LoadCompressedSpriteSheetOverrideBuffer(const struct CompressedSpriteSheet *src, void *buffer)
{
struct SpriteSheet dest;
@@ -44,7 +44,7 @@ void LoadCompressedObjectPicOverrideBuffer(const struct CompressedSpriteSheet *s
LoadSpriteSheet(&dest);
}
-void LoadCompressedObjectPalette(const struct CompressedSpritePalette *src)
+void LoadCompressedSpritePalette(const struct CompressedSpritePalette *src)
{
struct SpritePalette dest;
@@ -54,7 +54,7 @@ void LoadCompressedObjectPalette(const struct CompressedSpritePalette *src)
LoadSpritePalette(&dest);
}
-void LoadCompressedObjectPaletteOverrideBuffer(const struct CompressedSpritePalette *a, void *buffer)
+void LoadCompressedSpritePaletteOverrideBuffer(const struct CompressedSpritePalette *a, void *buffer)
{
struct SpritePalette dest;
@@ -465,7 +465,7 @@ u32 GetDecompressedDataSize(const u32 *ptr)
return (ptr8[3] << 16) | (ptr8[2] << 8) | (ptr8[1]);
}
-bool8 LoadCompressedObjectPicUsingHeap(const struct CompressedSpriteSheet* src)
+bool8 LoadCompressedSpriteSheetUsingHeap(const struct CompressedSpriteSheet* src)
{
struct SpriteSheet dest;
void* buffer;
@@ -482,7 +482,7 @@ bool8 LoadCompressedObjectPicUsingHeap(const struct CompressedSpriteSheet* src)
return FALSE;
}
-bool8 LoadCompressedObjectPaletteUsingHeap(const struct CompressedSpritePalette *src)
+bool8 LoadCompressedSpritePaletteUsingHeap(const struct CompressedSpritePalette *src)
{
struct SpritePalette dest;
void* buffer;
diff --git a/src/decoration.c b/src/decoration.c
index dd691721a..addca6954 100644
--- a/src/decoration.c
+++ b/src/decoration.c
@@ -519,7 +519,7 @@ void sub_8126B80(u8 taskId)
if (!gPaletteFade.active)
{
- menuPos = GetMenuCursorPos();
+ menuPos = Menu_GetCursorPos();
switch (Menu_ProcessInput())
{
default:
@@ -527,7 +527,7 @@ void sub_8126B80(u8 taskId)
sSecretBasePCMenuActions[sSecretBasePCMenuCursorPos].func.void_u8(taskId);
break;
case -2:
- sSecretBasePCMenuCursorPos = GetMenuCursorPos();
+ sSecretBasePCMenuCursorPos = Menu_GetCursorPos();
if ((s8)menuPos != sSecretBasePCMenuCursorPos)
{
sub_8126C08();
@@ -2065,7 +2065,7 @@ u8 AddDecorationIconObjectFromIconTable(u16 tilesTag, u16 paletteTag, u8 decor)
LoadSpriteSheet(&sheet);
palette.data = GetDecorationIconPicOrPalette(decor, 1);
palette.tag = paletteTag;
- LoadCompressedObjectPalette(&palette);
+ LoadCompressedSpritePalette(&palette);
template = malloc(sizeof(struct SpriteTemplate));
*template = gItemIconSpriteTemplate;
template->tileTag = tilesTag;
diff --git a/src/dma3_manager.c b/src/dma3_manager.c
index 28df9d932..51fa7072d 100644
--- a/src/dma3_manager.c
+++ b/src/dma3_manager.c
@@ -1,9 +1,6 @@
#include "global.h"
#include "dma3.h"
-// Maximum amount of data we will transfer in one operation
-#define MAX_DMA_BLOCK_SIZE 0x1000
-
#define MAX_DMA_REQUESTS 128
#define DMA_REQUEST_COPY32 1
@@ -40,49 +37,6 @@ void ClearDma3Requests(void)
gDma3ManagerLocked = FALSE;
}
-#define Dma3CopyLarge_(src, dest, size, bit) \
-{ \
- const void *_src = src; \
- void *_dest = dest; \
- u32 _size = size; \
- while (1) \
- { \
- if (_size <= MAX_DMA_BLOCK_SIZE) \
- { \
- DmaCopy##bit(3, _src, _dest, _size); \
- break; \
- } \
- DmaCopy##bit(3, _src, _dest, MAX_DMA_BLOCK_SIZE); \
- _src += MAX_DMA_BLOCK_SIZE; \
- _dest += MAX_DMA_BLOCK_SIZE; \
- _size -= MAX_DMA_BLOCK_SIZE; \
- } \
-}
-
-#define Dma3CopyLarge16_(src, dest, size) Dma3CopyLarge_(src, dest, size, 16)
-#define Dma3CopyLarge32_(src, dest, size) Dma3CopyLarge_(src, dest, size, 32)
-
-#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 ProcessDma3Requests(void)
{
u16 bytesTransferred;
diff --git a/src/egg_hatch.c b/src/egg_hatch.c
index ed25a2c68..360dd2466 100644
--- a/src/egg_hatch.c
+++ b/src/egg_hatch.c
@@ -30,6 +30,7 @@
#include "field_weather.h"
#include "international_string_util.h"
#include "naming_screen.h"
+#include "pokemon_storage_system.h"
#include "field_screen_effect.h"
#include "battle.h" // to get rid of later
@@ -60,10 +61,6 @@ extern const u32 gUnknown_08331F60[]; // tilemap gameboy circle
extern const u8 gText_HatchedFromEgg[];
extern const u8 gText_NickHatchPrompt[];
-extern void PlayRainSoundEffect(void);
-extern u16 sub_80D22D0(void);
-extern u8 CountPartyAliveNonEggMonsExcept(u8);
-
static void Task_EggHatch(u8 taskID);
static void CB2_EggHatch_0(void);
static void CB2_EggHatch_1(void);
@@ -442,7 +439,7 @@ static u8 EggHatchCreateMonSprite(u8 a0, u8 switchID, u8 pokeID, u16* speciesLoc
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species],
gMonSpritesGfxPtr->sprites[(a0 * 2) + 1],
species, pid);
- LoadCompressedObjectPalette(GetMonSpritePalStruct(mon));
+ LoadCompressedSpritePalette(GetMonSpritePalStruct(mon));
*speciesLoc = species;
}
break;
@@ -876,7 +873,7 @@ u8 GetEggStepsToSubtract(void)
u8 count, i;
for (count = CalculatePlayerPartyCount(), i = 0; i < count; i++)
{
- if (!GetMonData(&gPlayerParty[i], MON_DATA_SANITY_BIT3))
+ if (!GetMonData(&gPlayerParty[i], MON_DATA_SANITY_IS_EGG))
{
u8 ability = GetMonAbility(&gPlayerParty[i]);
if (ability == ABILITY_MAGMA_ARMOR || ability == ABILITY_FLAME_BODY)
@@ -888,7 +885,7 @@ u8 GetEggStepsToSubtract(void)
u16 sub_80722E0(void)
{
- u16 value = sub_80D22D0();
- value += CountPartyAliveNonEggMonsExcept(6);
- return value;
+ u16 aliveNonEggMonsCount = CountStorageNonEggMons();
+ aliveNonEggMonsCount += CountPartyAliveNonEggMonsExcept(6);
+ return aliveNonEggMonsCount;
}
diff --git a/src/evolution_graphics.c b/src/evolution_graphics.c
index 022599dfb..bfd46978c 100644
--- a/src/evolution_graphics.c
+++ b/src/evolution_graphics.c
@@ -251,7 +251,7 @@ static void CreatePostEvoSparkleSet2(u8 arg0)
void LoadEvoSparkleSpriteAndPal(void)
{
- LoadCompressedObjectPicUsingHeap(&sEvoSparkleSpriteSheets[0]);
+ LoadCompressedSpriteSheetUsingHeap(&sEvoSparkleSpriteSheets[0]);
LoadSpritePalettes(sEvoSparkleSpritePals);
}
diff --git a/src/field_effect.c b/src/field_effect.c
index 1442c611a..e1850d001 100644
--- a/src/field_effect.c
+++ b/src/field_effect.c
@@ -733,8 +733,8 @@ bool8 FieldEffectActiveListContains(u8 id)
u8 CreateTrainerSprite(u8 trainerSpriteID, s16 x, s16 y, u8 subpriority, u8 *buffer)
{
struct SpriteTemplate spriteTemplate;
- LoadCompressedObjectPaletteOverrideBuffer(&gTrainerFrontPicPaletteTable[trainerSpriteID], buffer);
- LoadCompressedObjectPicOverrideBuffer(&gTrainerFrontPicTable[trainerSpriteID], buffer);
+ LoadCompressedSpritePaletteOverrideBuffer(&gTrainerFrontPicPaletteTable[trainerSpriteID], buffer);
+ LoadCompressedSpriteSheetOverrideBuffer(&gTrainerFrontPicTable[trainerSpriteID], buffer);
spriteTemplate.tileTag = gTrainerFrontPicTable[trainerSpriteID].tag;
spriteTemplate.paletteTag = gTrainerFrontPicPaletteTable[trainerSpriteID].tag;
spriteTemplate.oam = &gNewGameBirchOamAttributes;
diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c
index a5aa23e32..7a6e16dd3 100644
--- a/src/field_player_avatar.c
+++ b/src/field_player_avatar.c
@@ -1845,7 +1845,7 @@ static bool8 Fishing6(struct Task *task)
}
else
{
- if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3))
+ if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG))
{
u8 ability = GetMonAbility(&gPlayerParty[0]);
if (ability == ABILITY_SUCTION_CUPS || ability == ABILITY_STICKY_HOLD)
diff --git a/src/field_poison.c b/src/field_poison.c
index 7aaab902f..fac17dea9 100644
--- a/src/field_poison.c
+++ b/src/field_poison.c
@@ -122,7 +122,7 @@ s32 DoPoisonFieldEffect(void)
u32 numFainted = 0;
for (i = 0; i < PARTY_SIZE; i++)
{
- if (GetMonData(pokemon, MON_DATA_SANITY_BIT2) && pokemon_ailments_get_primary(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN)
+ if (GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES) && pokemon_ailments_get_primary(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN)
{
hp = GetMonData(pokemon, MON_DATA_HP);
if (hp == 0 || --hp == 0)
diff --git a/src/field_specials.c b/src/field_specials.c
index 3f945fcfb..64ff46ce2 100644
--- a/src/field_specials.c
+++ b/src/field_specials.c
@@ -1266,7 +1266,7 @@ void IsGrassTypeInParty(void)
for (i = 0; i < PARTY_SIZE; i++)
{
pokemon = &gPlayerParty[i];
- if (GetMonData(pokemon, MON_DATA_SANITY_BIT2) && !GetMonData(pokemon, MON_DATA_IS_EGG))
+ if (GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES) && !GetMonData(pokemon, MON_DATA_IS_EGG))
{
species = GetMonData(pokemon, MON_DATA_SPECIES);
if (gBaseStats[species].type1 == TYPE_GRASS || gBaseStats[species].type2 == TYPE_GRASS)
@@ -1658,7 +1658,7 @@ bool8 sub_813990C(void)
for (i = 0; i < partyCount; i++)
{
- if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_BIT1) == 1)
+ if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_IS_BAD_EGG) == 1)
return TRUE;
}
diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c
index f7792e935..fc60d2b08 100644
--- a/src/hall_of_fame.c
+++ b/src/hall_of_fame.c
@@ -1283,8 +1283,8 @@ static void sub_8174F70(void)
ResetAllPicSprites();
FreeAllSpritePalettes();
gReservedSpritePaletteCount = 8;
- LoadCompressedObjectPic(sHallOfFame_ConfettiSpriteSheet);
- LoadCompressedObjectPalette(sHallOfFame_ConfettiSpritePalette);
+ LoadCompressedSpriteSheet(sHallOfFame_ConfettiSpriteSheet);
+ LoadCompressedSpritePalette(sHallOfFame_ConfettiSpritePalette);
}
static void sub_8174FAC(void)
@@ -1475,8 +1475,8 @@ static void sub_8175364(u8 taskId)
gSpecialVar_0x8004 = var;
gSpecialVar_0x8005 = 0xFFFF;
}
- LoadCompressedObjectPic(sHallOfFame_ConfettiSpriteSheet);
- LoadCompressedObjectPalette(sHallOfFame_ConfettiSpritePalette);
+ LoadCompressedSpriteSheet(sHallOfFame_ConfettiSpriteSheet);
+ LoadCompressedSpritePalette(sHallOfFame_ConfettiSpritePalette);
data[0]++;
break;
case 1:
diff --git a/src/intro.c b/src/intro.c
index 94692e6ec..18a899fb0 100644
--- a/src/intro.c
+++ b/src/intro.c
@@ -1044,10 +1044,10 @@ static void Task_IntroLoadPart1Graphics(u8 taskId)
SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(20) | BGCNT_16COLOR | BGCNT_TXT256x512);
SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(18) | BGCNT_16COLOR | BGCNT_TXT256x512);
SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(16) | BGCNT_16COLOR | BGCNT_TXT256x512);
- LoadCompressedObjectPic(gUnknown_085E4FDC);
- LoadCompressedObjectPic(gUnknown_085E4FEC);
+ LoadCompressedSpriteSheet(gUnknown_085E4FDC);
+ LoadCompressedSpriteSheet(gUnknown_085E4FEC);
LoadSpritePalettes(gUnknown_085E4FFC);
- LoadCompressedObjectPic(gUnknown_085E4A74);
+ LoadCompressedSpriteSheet(gUnknown_085E4A74);
LoadSpritePalettes(gUnknown_085E4A84);
CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x1F0, 0x20);
CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x1E1, 0x1E);
@@ -1204,16 +1204,16 @@ static void Task_IntroStartBikeRide(u8 taskId)
u8 spriteId;
if (gUnknown_0203BCC8 == 0)
- LoadCompressedObjectPic(gIntro2BrendanSpriteSheet);
+ LoadCompressedSpriteSheet(gIntro2BrendanSpriteSheet);
else
- LoadCompressedObjectPic(gIntro2MaySpriteSheet);
+ LoadCompressedSpriteSheet(gIntro2MaySpriteSheet);
- LoadCompressedObjectPic(gIntro2BicycleSpriteSheet);
- LoadCompressedObjectPic(gIntro2FlygonSpriteSheet);
+ LoadCompressedSpriteSheet(gIntro2BicycleSpriteSheet);
+ LoadCompressedSpriteSheet(gIntro2FlygonSpriteSheet);
for (spriteId = 0; spriteId < 3; spriteId++)
{
- LoadCompressedObjectPic(&gUnknown_085E4AE8[spriteId]);
+ LoadCompressedSpriteSheet(&gUnknown_085E4AE8[spriteId]);
}
LoadSpritePalettes(gUnknown_085F530C);
@@ -1542,8 +1542,8 @@ static void Task_IntroLoadPart1Graphics3(u8 taskId)
LZDecompressVram(gIntro3GroudonTilemap, (void *)(VRAM + 0xC000));
LZDecompressVram(gIntro3LegendBgGfx, (void *)(VRAM + 0x4000));
LZDecompressVram(gIntro3GroudonBgTilemap, (void *)(VRAM + 0xE000));
- LoadCompressedObjectPicUsingHeap(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_ROCKS)]);
- LoadCompressedObjectPaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_ROCKS)]);
+ LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_ROCKS)]);
+ LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_ROCKS)]);
CpuCopy16(gIntro3BgPal, gPlttBufferUnfaded, sizeof(gIntro3BgPal));
gTasks[taskId].func = Task_IntroLoadPart1Graphics4;
}
@@ -1764,7 +1764,7 @@ static void Task_IntroLoadPart1Graphics9(u8 taskId)
LZDecompressVram(gIntro3KyogreGfx, (void *)VRAM);
LZDecompressVram(gIntro3KyogreTilemap, (void *)(VRAM + 0xC000));
LZDecompressVram(gIntro3KyogreBgTilemap, (void *)(VRAM + 0xE000));
- LoadCompressedObjectPic(gUnknown_085E4C88);
+ LoadCompressedSpriteSheet(gUnknown_085E4C88);
LoadSpritePalette(gUnknown_085E4C98);
BeginNormalPaletteFade(0xFFFFFFFE, 0, 0x10, 0, RGB_WHITEALPHA);
gTasks[taskId].func = Task_IntroFadeIn0;
@@ -2092,7 +2092,7 @@ static void Task_IntroFadeIn5(u8 taskId)
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[6] = 1;
gTasks[taskId].data[7] = 0;
- LoadCompressedObjectPicUsingHeap(gUnknown_085E4BF4);
+ LoadCompressedSpriteSheetUsingHeap(gUnknown_085E4BF4);
LoadSpritePalettes(gUnknown_085E4C04);
}
@@ -2169,7 +2169,7 @@ static void Task_IntroFadeIn7(u8 taskId)
{
u8 newTaskId;
- LoadCompressedObjectPic(gUnknown_085E5048);
+ LoadCompressedSpriteSheet(gUnknown_085E5048);
LoadSpritePalettes(gUnknown_085E5058);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0
| DISPCNT_OBJ_1D_MAP
diff --git a/src/intro_credits_graphics.c b/src/intro_credits_graphics.c
index 20a360901..d85e58938 100644
--- a/src/intro_credits_graphics.c
+++ b/src/intro_credits_graphics.c
@@ -341,7 +341,7 @@ void load_intro_part2_graphics(u8 a)
LZ77UnCompVram(gUnknown_085F0DBC, (void *)(VRAM));
LZ77UnCompVram(gUnknown_085F1398, (void *)(VRAM + 0x3000));
LoadPalette(&gUnknown_085F0CFC, 0, 96);
- LoadCompressedObjectPic(gUnknown_085F5064);
+ LoadCompressedSpriteSheet(gUnknown_085F5064);
LoadPalette(&gUnknown_085F1668, 256, 32);
sub_817B76C();
break;
@@ -349,7 +349,7 @@ void load_intro_part2_graphics(u8 a)
LZ77UnCompVram(gUnknown_085F1824, (void *)(VRAM));
LZ77UnCompVram(gUnknown_085F1EAC, (void *)(VRAM + 0x3000));
LoadPalette(&gUnknown_085F17E4, 0, 32);
- LoadCompressedObjectPic(gUnknown_085F50EC);
+ LoadCompressedSpriteSheet(gUnknown_085F50EC);
LoadPalette(&gUnknown_085F21B0, 256, 32);
sub_817B788();
break;
@@ -447,7 +447,7 @@ void sub_817B1C8(u8 a)
LZ77UnCompVram(gUnknown_085F0DBC, (void *)(VRAM));
LZ77UnCompVram(gUnknown_085F1398, (void *)(VRAM + 0x3000));
LoadPalette(&gUnknown_085F0CFC, 0, 96);
- LoadCompressedObjectPic(gUnknown_085F5064);
+ LoadCompressedSpriteSheet(gUnknown_085F5064);
LZ77UnCompVram(gUnknown_085F16A8, (void *)(VRAM + 0x10000));
LoadPalette(&gUnknown_085F1668, 256, 32);
sub_817B76C();
@@ -457,7 +457,7 @@ void sub_817B1C8(u8 a)
LZ77UnCompVram(gUnknown_085F0DBC, (void *)(VRAM));
LZ77UnCompVram(gUnknown_085F1398, (void *)(VRAM + 0x3000));
LoadPalette(&gUnknown_085F0D5C, 0, 96);
- LoadCompressedObjectPic(gUnknown_085F5064);
+ LoadCompressedSpriteSheet(gUnknown_085F5064);
LZ77UnCompVram(gUnknown_085F16A8, (void *)(VRAM + 0x10000));
LoadPalette(&gUnknown_085F1688, 256, 32);
sub_817B76C();
@@ -468,7 +468,7 @@ void sub_817B1C8(u8 a)
LZ77UnCompVram(gUnknown_085F1824, (void *)(VRAM));
LZ77UnCompVram(gUnknown_085F1EAC, (void *)(VRAM + 0x3000));
LoadPalette(&gUnknown_085F1804, 0, 32);
- LoadCompressedObjectPic(gUnknown_085F50EC);
+ LoadCompressedSpriteSheet(gUnknown_085F50EC);
LoadPalette(&gUnknown_085F1804, 256, 32);
sub_817B788();
break;
@@ -477,7 +477,7 @@ void sub_817B1C8(u8 a)
LZ77UnCompVram(gUnknown_085F235C, (void *)(VRAM));
LZ77UnCompVram(gUnknown_085F2568, (void *)(VRAM + 0x3000));
LoadPalette(&gUnknown_085F231C, 0, 64);
- LoadCompressedObjectPic(gUnknown_085F5180);
+ LoadCompressedSpriteSheet(gUnknown_085F5180);
LoadPalette(&gUnknown_085F2548, 256, 32);
sub_817B7A4();
break;
diff --git a/src/item_icon.c b/src/item_icon.c
index d037782bd..e9379dbba 100644
--- a/src/item_icon.c
+++ b/src/item_icon.c
@@ -107,7 +107,7 @@ u8 AddItemIconSprite(u16 tilesTag, u16 paletteTag, u16 itemId)
spritePalette.data = GetItemIconPicOrPalette(itemId, 1);
spritePalette.tag = paletteTag;
- LoadCompressedObjectPalette(&spritePalette);
+ LoadCompressedSpritePalette(&spritePalette);
spriteTemplate = Alloc(sizeof(*spriteTemplate));
CpuCopy16(&gItemIconSpriteTemplate, spriteTemplate, sizeof(*spriteTemplate));
@@ -144,7 +144,7 @@ u8 AddCustomItemIconSprite(struct SpriteTemplate *customSpriteTemplate, u16 tile
spritePalette.data = GetItemIconPicOrPalette(itemId, 1);
spritePalette.tag = paletteTag;
- LoadCompressedObjectPalette(&spritePalette);
+ LoadCompressedSpritePalette(&spritePalette);
spriteTemplate = Alloc(sizeof(*spriteTemplate));
CpuCopy16(customSpriteTemplate, spriteTemplate, sizeof(*spriteTemplate));
diff --git a/src/item_menu.c b/src/item_menu.c
index 32c42ac31..a220f02ef 100755
--- a/src/item_menu.c
+++ b/src/item_menu.c
@@ -713,13 +713,13 @@ bool8 load_bag_menu_graphics(void)
break;
case 3:
if (IsWallysBag() == TRUE || gSaveBlock2Ptr->playerGender == MALE)
- LoadCompressedObjectPic(&gUnknown_0857FB34);
+ LoadCompressedSpriteSheet(&gUnknown_0857FB34);
else
- LoadCompressedObjectPic(&gUnknown_0857FB3C);
+ LoadCompressedSpriteSheet(&gUnknown_0857FB3C);
gUnknown_0203CE54->unk834++;
break;
case 4:
- LoadCompressedObjectPalette(&gUnknown_0857FB44);
+ LoadCompressedSpritePalette(&gUnknown_0857FB44);
gUnknown_0203CE54->unk834++;
break;
default:
@@ -1564,7 +1564,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId)
{
if (sub_81221EC() != TRUE)
{
- s8 cursorPos = GetMenuCursorPos();
+ s8 cursorPos = Menu_GetCursorPos();
if (gMain.newKeys & DPAD_UP)
{
if (cursorPos > 0 && sub_81ACDFC(cursorPos - 2))
diff --git a/src/item_menu_icons.c b/src/item_menu_icons.c
index 894574ec9..669195b33 100644
--- a/src/item_menu_icons.c
+++ b/src/item_menu_icons.c
@@ -583,7 +583,7 @@ static void sub_80D5070(u8 berryId)
pal.data = gBerryPicTable[berryId].pal;
pal.tag = 0x7544;
- LoadCompressedObjectPalette(&pal);
+ LoadCompressedSpritePalette(&pal);
LZDecompressWram(gBerryPicTable[berryId].tiles, &gDecompressionBuffer[0x1000]);
sub_80D5018(&gDecompressionBuffer[0x1000], &gDecompressionBuffer[0]);
}
diff --git a/src/link_rfu.c b/src/link_rfu.c
index 2c6e22475..5f4beadee 100644
--- a/src/link_rfu.c
+++ b/src/link_rfu.c
@@ -2244,7 +2244,7 @@ void sub_800E0E8(void)
{
if (GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag) == 0xFFFF)
{
- LoadCompressedObjectPic(&sWirelessStatusIndicatorSpriteSheet);
+ LoadCompressedSpriteSheet(&sWirelessStatusIndicatorSpriteSheet);
}
LoadSpritePalette(&sWirelessStatusIndicatorSpritePalette);
gWirelessStatusIndicatorSpriteId = 0xFF;
diff --git a/src/list_menu.c b/src/list_menu.c
index caf4b798d..2476fae26 100644
--- a/src/list_menu.c
+++ b/src/list_menu.c
@@ -1074,7 +1074,7 @@ u8 AddScrollIndicatorArrowPair(const struct ScrollArrowsTemplate *arrowInfo, u16
spriteSheet.data = sRedArrowOtherGfx;
spriteSheet.size = 0x100;
spriteSheet.tag = arrowInfo->tileTag;
- LoadCompressedObjectPic(&spriteSheet);
+ LoadCompressedSpriteSheet(&spriteSheet);
if (arrowInfo->palTag == SPRITE_INVALID_TAG)
{
@@ -1320,7 +1320,7 @@ static u8 ListMenuAddRedOutlineCursorObject(struct CursorStruct *cursor)
spriteSheet.data = sSelectorOutlineGfx;
spriteSheet.size = 0x100;
spriteSheet.tag = cursor->tileTag;
- LoadCompressedObjectPic(&spriteSheet);
+ LoadCompressedSpriteSheet(&spriteSheet);
if (cursor->palTag == SPRITE_INVALID_TAG)
{
@@ -1405,7 +1405,7 @@ static u8 ListMenuAddRedArrowCursorObject(struct CursorStruct *cursor)
spriteSheet.data = sRedArrowGfx;
spriteSheet.size = 0x80;
spriteSheet.tag = cursor->tileTag;
- LoadCompressedObjectPic(&spriteSheet);
+ LoadCompressedSpriteSheet(&spriteSheet);
if (cursor->palTag == SPRITE_INVALID_TAG)
{
diff --git a/src/load_save.c b/src/load_save.c
index 8ecf89959..963626428 100644
--- a/src/load_save.c
+++ b/src/load_save.c
@@ -3,6 +3,7 @@
#include "load_save.h"
#include "main.h"
#include "pokemon.h"
+#include "pokemon_storage_system.h"
#include "random.h"
#include "alloc.h"
#include "item.h"
diff --git a/src/main_menu.c b/src/main_menu.c
index e11f783eb..4cd5c8e14 100644
--- a/src/main_menu.c
+++ b/src/main_menu.c
@@ -1394,7 +1394,7 @@ static void Task_NewGameBirchSpeech_ChooseGender(u8 taskId)
gTasks[taskId].func = Task_NewGameBirchSpeech_WhatsYourName;
break;
}
- gender2 = GetMenuCursorPos();
+ gender2 = Menu_GetCursorPos();
if (gender2 != gTasks[taskId].tPlayerGender)
{
gTasks[taskId].tPlayerGender = gender2;
diff --git a/src/menu.c b/src/menu.c
index 61096138a..e0e5eb4eb 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -132,7 +132,7 @@ extern void sub_8197BB4(u8, u8, u8, u8, u8, u8);
extern void sub_8197E30(u8, u8, u8, u8, u8, u8);
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 Menu_MoveCursor(s8);
extern u8 sub_8199134(s8, s8);
extern void sub_8198C78(void);
extern void task_free_buf_after_copying_tile_data_to_vram(u8 taskId);
@@ -910,7 +910,7 @@ u8 sub_8198348(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numC
else
gUnknown_0203CD90.cursorPos = pos;
- MoveMenuCursor(0);
+ Menu_MoveCursor(0);
return gUnknown_0203CD90.cursorPos;
}
@@ -935,7 +935,7 @@ void RedrawMenuCursor(u8 oldPos, u8 newPos)
AddTextPrinterParameterized(gUnknown_0203CD90.windowId, gUnknown_0203CD90.fontId, gText_SelectorArrow3, gUnknown_0203CD90.left, gUnknown_0203CD90.optionHeight * newPos + gUnknown_0203CD90.top, 0, 0);
}
-u8 MoveMenuCursor(s8 cursorDelta)
+u8 Menu_MoveCursor(s8 cursorDelta)
{
u8 oldPos = gUnknown_0203CD90.cursorPos;
int newPos = gUnknown_0203CD90.cursorPos + cursorDelta;
@@ -951,7 +951,7 @@ u8 MoveMenuCursor(s8 cursorDelta)
return gUnknown_0203CD90.cursorPos;
}
-u8 MoveMenuCursorNoWrapAround(s8 cursorDelta)
+u8 Menu_MoveCursorNoWrapAround(s8 cursorDelta)
{
u8 oldPos = gUnknown_0203CD90.cursorPos;
int newPos = gUnknown_0203CD90.cursorPos + cursorDelta;
@@ -967,7 +967,7 @@ u8 MoveMenuCursorNoWrapAround(s8 cursorDelta)
return gUnknown_0203CD90.cursorPos;
}
-u8 GetMenuCursorPos(void)
+u8 Menu_GetCursorPos(void)
{
return gUnknown_0203CD90.cursorPos;
}
@@ -987,13 +987,13 @@ s8 Menu_ProcessInput(void)
else if (gMain.newKeys & DPAD_UP)
{
PlaySE(SE_SELECT);
- MoveMenuCursor(-1);
+ Menu_MoveCursor(-1);
return MENU_NOTHING_CHOSEN;
}
else if (gMain.newKeys & DPAD_DOWN)
{
PlaySE(SE_SELECT);
- MoveMenuCursor(1);
+ Menu_MoveCursor(1);
return MENU_NOTHING_CHOSEN;
}
@@ -1016,13 +1016,13 @@ s8 Menu_ProcessInputNoWrap(void)
}
else if (gMain.newKeys & DPAD_UP)
{
- if (oldPos != MoveMenuCursorNoWrapAround(-1))
+ if (oldPos != Menu_MoveCursorNoWrapAround(-1))
PlaySE(SE_SELECT);
return MENU_NOTHING_CHOSEN;
}
else if (gMain.newKeys & DPAD_DOWN)
{
- if (oldPos != MoveMenuCursorNoWrapAround(1))
+ if (oldPos != Menu_MoveCursorNoWrapAround(1))
PlaySE(SE_SELECT);
return MENU_NOTHING_CHOSEN;
}
@@ -1045,13 +1045,13 @@ s8 ProcessMenuInput_other(void)
else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP)
{
PlaySE(SE_SELECT);
- MoveMenuCursor(-1);
+ Menu_MoveCursor(-1);
return MENU_NOTHING_CHOSEN;
}
else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN)
{
PlaySE(SE_SELECT);
- MoveMenuCursor(1);
+ Menu_MoveCursor(1);
return MENU_NOTHING_CHOSEN;
}
@@ -1074,13 +1074,13 @@ s8 Menu_ProcessInputNoWrapAround_other(void)
}
else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP)
{
- if (oldPos != MoveMenuCursorNoWrapAround(-1))
+ if (oldPos != Menu_MoveCursorNoWrapAround(-1))
PlaySE(SE_SELECT);
return MENU_NOTHING_CHOSEN;
}
else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN)
{
- if (oldPos != MoveMenuCursorNoWrapAround(1))
+ if (oldPos != Menu_MoveCursorNoWrapAround(1))
PlaySE(SE_SELECT);
return MENU_NOTHING_CHOSEN;
}
@@ -1588,7 +1588,7 @@ u8 InitMenuInUpperLeftCorner(u8 windowId, u8 itemCount, u8 initialCursorPos, boo
else
gUnknown_0203CD90.cursorPos = pos;
- return MoveMenuCursor(0);
+ return Menu_MoveCursor(0);
}
u8 InitMenuInUpperLeftCornerPlaySoundWhenAPressed(u8 windowId, u8 itemCount, u8 initialCursorPos)
@@ -1797,9 +1797,9 @@ bool8 free_temp_tile_data_buffers_if_possible(void)
}
}
-void *decompress_and_copy_tile_data_to_vram(u8 bgId, const void *src, int size, u16 offset, u8 mode)
+void *decompress_and_copy_tile_data_to_vram(u8 bgId, const void *src, u32 size, u16 offset, u8 mode)
{
- int sizeOut;
+ u32 sizeOut;
if (gUnknown_0203CDA8 < ARRAY_COUNT(gUnknown_0203CDAC))
{
void *ptr = malloc_and_decompress(src, &sizeOut);
@@ -1815,9 +1815,9 @@ void *decompress_and_copy_tile_data_to_vram(u8 bgId, const void *src, int size,
return NULL;
}
-void DecompressAndLoadBgGfxUsingHeap(u8 bgId, const void *src, int size, u16 offset, u8 mode)
+void DecompressAndLoadBgGfxUsingHeap(u8 bgId, const void *src, u32 size, u16 offset, u8 mode)
{
- int sizeOut;
+ u32 sizeOut;
void *ptr = malloc_and_decompress(src, &sizeOut);
if (!size)
size = sizeOut;
@@ -1838,7 +1838,7 @@ void task_free_buf_after_copying_tile_data_to_vram(u8 taskId)
}
}
-void *malloc_and_decompress(const void *src, int *size)
+void *malloc_and_decompress(const void *src, u32 *size)
{
void *ptr;
u8 *sizeAsBytes = (u8 *)size;
diff --git a/src/menu_helpers.c b/src/menu_helpers.c
index a3c0be36a..0adc6228e 100644
--- a/src/menu_helpers.c
+++ b/src/menu_helpers.c
@@ -394,8 +394,8 @@ void sub_8122298(u16 *arg0, u16 *arg1, u8 arg2, u8 arg3, u8 arg4)
void LoadListMenuArrowsGfx(void)
{
- LoadCompressedObjectPic(&gUnknown_0859F514);
- LoadCompressedObjectPalette(&gUnknown_0859F51C);
+ LoadCompressedSpriteSheet(&gUnknown_0859F514);
+ LoadCompressedSpritePalette(&gUnknown_0859F51C);
}
void sub_8122344(u8 *spriteIds, u8 count)
diff --git a/src/mon_markings.c b/src/mon_markings.c
index 30015dbef..48f0f5ecb 100644
--- a/src/mon_markings.c
+++ b/src/mon_markings.c
@@ -390,7 +390,6 @@ void sub_811FAF8(void)
}
}
-
bool8 sub_811FBA4(void)
{
u16 i;
diff --git a/src/money.c b/src/money.c
index a347f818d..faf830637 100644
--- a/src/money.c
+++ b/src/money.c
@@ -186,8 +186,8 @@ void HideMoneyBox(void)
void AddMoneyLabelObject(u16 x, u16 y)
{
- LoadCompressedObjectPic(&sSpriteSheet_MoneyLabel);
- LoadCompressedObjectPalette(&sSpritePalette_MoneyLabel);
+ LoadCompressedSpriteSheet(&sSpriteSheet_MoneyLabel);
+ LoadCompressedSpritePalette(&sSpritePalette_MoneyLabel);
sMoneyLabelSpriteId = CreateSprite(&sSpriteTemplate_MoneyLabel, x, y, 0);
}
diff --git a/src/overworld.c b/src/overworld.c
index 6998c9d98..27bd0425a 100644
--- a/src/overworld.c
+++ b/src/overworld.c
@@ -1340,7 +1340,7 @@ void UpdateAmbientCry(s16 *state, u16 *delayCounter)
monsCount = CalculatePlayerPartyCount();
for (i = 0; i < monsCount; i++)
{
- if (!GetMonData(&gPlayerParty[i], MON_DATA_SANITY_BIT3)
+ if (!GetMonData(&gPlayerParty[i], MON_DATA_SANITY_IS_EGG)
&& GetMonAbility(&gPlayerParty[0]) == ABILITY_SWARM)
{
divBy = 2;
diff --git a/src/party_menu.c b/src/party_menu.c
index f9977fb89..6e12dcbf3 100755
--- a/src/party_menu.c
+++ b/src/party_menu.c
@@ -458,7 +458,7 @@ void sub_81B97DC(struct Pokemon*, u8, u8);
void InitPartyMenu(u8 a, u8 b, u8 c, u8 d, u8 e, TaskFunc task, MainCallback callback)
{
u16 i;
-
+
reset_brm();
gUnknown_0203CEC4 = Alloc(sizeof(struct Struct203CEC4));
if (gUnknown_0203CEC4 == NULL)
@@ -476,25 +476,25 @@ void InitPartyMenu(u8 a, u8 b, u8 c, u8 d, u8 e, TaskFunc task, MainCallback cal
gUnknown_0203CEC4->unk8_1 = 0;
gUnknown_0203CEC4->unk8_2 = 0xFF;
gUnknown_0203CEC4->unk9_0 = 0xFF;
-
+
if (a == 4)
gUnknown_0203CEC4->unk8_0 = TRUE;
else
gUnknown_0203CEC4->unk8_0 = FALSE;
-
+
if (b != 0xFF)
gUnknown_0203CEC8.mode = b;
-
+
for (i = 0; i <= 15; i++)
gUnknown_0203CEC4->data[i] = 0;
for (i = 0; i < 3; i++)
gUnknown_0203CEC4->unkC[i] |= 0xFF;
-
+
if (d == 0)
gUnknown_0203CEC8.unk9 = 0;
else if (gUnknown_0203CEC8.unk9 > 5 || GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_SPECIES) == SPECIES_NONE)
gUnknown_0203CEC8.unk9 = 0; // wut why is this else if?
-
+
gTextFlags.autoScroll = 0;
CalculatePlayerPartyCount();
SetMainCallback2(PartyMenuInitCallback);
@@ -698,7 +698,7 @@ bool8 AllocPartyMenuBg(void)
bool8 AllocPartyMiscGfx(void)
{
int sizeout;
-
+
switch (gUnknown_0203CEC4->data[0])
{
case 0:
@@ -767,9 +767,9 @@ void FreePartyPointers(void)
void PartyMenuInitHelperStructs(u8 a)
{
u8 i;
-
+
gUnknown_0203CEDC = Alloc(sizeof(struct Struct203CEDC[PARTY_SIZE]));
-
+
for (i = 0; i < PARTY_SIZE; i++)
{
gUnknown_0203CEDC[i].unk0 = &gUnknown_086156C4[1];
@@ -822,7 +822,7 @@ void RenderPartyMenuBox(u8 slot)
DisplayPartyPokemonSelectHeldItemRelated(slot);
else if (!sub_81B0BFC(slot))
DisplayPartyPokemonData(slot);
-
+
if (gUnknown_0203CEC8.unk8_0 == 5)
sub_81B0FCC(slot, 0);
else if (gUnknown_0203CEC8.unk9 == slot)
@@ -857,7 +857,7 @@ void DisplayPartyPokemonData(u8 slot)
void DisplayPartyPokemonSelectData(u8 slot, u8 stringID)
{
struct Pokemon *mon = &gPlayerParty[slot];
-
+
gUnknown_0203CEDC[slot].unk0->unk0(gUnknown_0203CEDC[slot].windowId, 0, 0, 0, 0, 1);
DisplayPartyPokemonNickname(mon, &gUnknown_0203CEDC[slot], 0);
if (!GetMonData(mon, MON_DATA_IS_EGG))
@@ -873,7 +873,7 @@ void DisplayPartyPokemonSelectForBattle(u8 slot)
u8 i;
struct Pokemon *mon = &gPlayerParty[slot];
u8 *ptr = gSelectedOrderFromParty;
-
+
if (!GetBattleEntryEligibility(mon))
{
DisplayPartyPokemonSelectData(slot, 7);
@@ -937,7 +937,7 @@ bool8 sub_81B0BFC(u8 slot)
{
struct Pokemon *currentPokemon = &gPlayerParty[slot];
u16 item = gSpecialVar_ItemId;
-
+
if (gUnknown_0203CEC8.unkB == 12)
{
gSpecialVar_Result = FALSE;
@@ -947,7 +947,7 @@ bool8 sub_81B0BFC(u8 slot)
{
if (gUnknown_0203CEC8.unkB != 3)
return FALSE;
-
+
switch (CheckIfItemIsTMHMOrEvolutionStone(item))
{
default:
@@ -986,7 +986,7 @@ void sub_81B0CEC(u8 slot)
{
struct Struct203CEDC *structPtr = &gUnknown_0203CEDC[slot];
u8 actualSlot = slot - 3;
-
+
if (gUnknown_02022FF8[actualSlot].species == SPECIES_NONE)
{
sub_81B2720(structPtr->windowId);
@@ -1022,12 +1022,12 @@ u8* GetPartyMiscGraphicsTile(u16 tileId)
void party_menu_add_per_mon_objects_internal(u8 slot)
{
u8 actualSlot;
-
+
if (gUnknown_0203CEC8.unk8_0 == 5 && slot > 2)
{
u8 status;
actualSlot = slot - 3;
-
+
if (gUnknown_02022FF8[actualSlot].species != SPECIES_NONE)
{
party_menu_link_mon_icon_anim(gUnknown_02022FF8[actualSlot].species, gUnknown_02022FF8[actualSlot].personality, &gUnknown_0203CEDC[slot], 0, 0);
@@ -1082,7 +1082,7 @@ void sub_81B0F28(void)
void sub_81B0FCC(u8 slot, u8 b)
{
u8 spriteId;
-
+
switch (slot)
{
default:
@@ -1141,7 +1141,7 @@ u8 GetPartyBoxPalBitfield(u8 slot, u8 b)
}
if (gUnknown_0203CEC8.unkB == 10 && slot == gUnknown_0203CEC8.unk9 )
returnVar |= 32;
-
+
return returnVar;
}
@@ -1149,10 +1149,10 @@ bool8 PartyBoxPal_ParnterOrDisqualifiedInArena(u8 slot)
{
if (gUnknown_0203CEC8.mode == 2 && (slot == 1 || slot == 4 || slot == 5))
return TRUE;
-
+
if (slot < 3 && (gBattleTypeFlags & BATTLE_TYPE_ARENA) && gMain.inBattle && (gBattleStruct->arenaLostPlayerMons >> sub_81B8F38(slot) & 1))
return TRUE;
-
+
return FALSE;
}
@@ -1173,11 +1173,11 @@ bool8 IsMultiBattle(void)
void sub_81B1288(struct Pokemon *partySlot, struct Pokemon *pokemon)
{
struct Pokemon *temp = Alloc(sizeof(struct Pokemon));
-
+
*temp = *partySlot;
*partySlot = *pokemon;
*pokemon = *temp;
-
+
Free(temp);
}
@@ -1193,12 +1193,12 @@ void c3_0811FAB4(u8 taskId)
{
if (gUnknown_0203CEC8.unk8_0 == 1)
sub_81B9080();
-
+
if (gUnknown_0203CEC4->exitCallback != NULL)
SetMainCallback2(gUnknown_0203CEC4->exitCallback);
else
SetMainCallback2(gUnknown_0203CEC8.exitCallback);
-
+
ResetSpriteData();
FreePartyPointers();
DestroyTask(taskId);
@@ -1220,7 +1220,7 @@ void sub_81B1370(u8 taskId)
if (!gPaletteFade.active && sub_81221EC() != TRUE)
{
s8 *ptr = sub_81B13EC();
-
+
switch (PartyMenuButtonHandler(ptr))
{
case 1:
@@ -1268,7 +1268,7 @@ void sub_81B140C(u8 taskId, s8 *ptr)
{
if (gUnknown_0203CEC8.unk8_0 == 1)
gUnknown_0203CEC4->exitCallback = sub_81B9140;
-
+
sub_81B302C(&gUnknown_0203CEC4->unkC[1]);
gUnknown_03006328(taskId, sub_81B6794);
}
@@ -1360,20 +1360,20 @@ void sub_81B15D0(u8 taskId, s8 *ptr)
}
break;
}
-}
+}
bool8 sub_81B1660(u8 taskId)
{
const u8* stringPtr = NULL;
-
+
if (gUnknown_0203CEC8.unk8_0 == 2)
stringPtr = gText_CancelParticipation;
else if (gUnknown_0203CEC8.unk8_0 == 4)
stringPtr = sub_81B88BC();
-
+
if (stringPtr == NULL)
return FALSE;
-
+
sub_81B302C(&gUnknown_0203CEC4->unkC[1]);
StringExpandPlaceholders(gStringVar4, stringPtr);
sub_81B1B5C(gStringVar4, 1);
@@ -1411,7 +1411,7 @@ void sub_81B1708(u8 taskId)
u16 PartyMenuButtonHandler(s8 *ptr)
{
s8 movementDir;
-
+
switch (gMain.newAndRepeatedKeys)
{
case DPAD_UP:
@@ -1440,19 +1440,19 @@ u16 PartyMenuButtonHandler(s8 *ptr)
break;
}
}
-
+
if (gMain.newKeys & START_BUTTON)
return 8;
-
+
if (movementDir)
{
UpdateCurrentPartySelection(ptr, movementDir);
return 0;
}
-
+
if ((gMain.newKeys & A_BUTTON) && *ptr == 7)
return 2;
-
+
return gMain.newKeys & (A_BUTTON | B_BUTTON);
}
@@ -1460,12 +1460,12 @@ u16 PartyMenuButtonHandler(s8 *ptr)
void UpdateCurrentPartySelection(s8 *ptr, s8 movementDir)
{
s8 slot = *ptr;
-
+
if (gUnknown_0203CEC8.mode == 0)
SetNewPartySelectTarget1(ptr, movementDir);
else
SetNewPartySelectTarget2(ptr, movementDir);
-
+
if (*ptr != slot)
{
PlaySE(SE_SELECT);
@@ -1525,7 +1525,7 @@ _081B184C:\n\
void SetNewPartySelectTarget1(s8 *ptr, s8 b)
{
u8 r0r2;
-
+
switch (b)
{
case -1:
@@ -1737,7 +1737,7 @@ void SetNewPartySelectTarget2(s8 *ptr, s8 b)
u8 unk;
s8 unk2 = b;
u8 unk3;
-
+
switch (b)
{
case -1:
@@ -1829,7 +1829,7 @@ void SetNewPartySelectTarget2(s8 *ptr, s8 b)
gUnknown_0203CEC4->unk8_1 = *ptr;
*ptr = 0;
}
- else
+ else
{
unk3 = *ptr - 4;
if (unk3 <= 1)
@@ -2077,7 +2077,7 @@ u8* GetMonNickname(struct Pokemon *mon, u8 *dest)
u8 sub_81B1B5C(const u8* str, u8 b)
{
u8 taskId;
-
+
sub_81B3300(str);
taskId = CreateTask(sub_81B1B8C, 1);
gTasks[taskId].data[0] = b;
@@ -2168,7 +2168,7 @@ void sub_81B1D68(u16 item, u16 item2, u8 c)
void sub_81B1DB8(struct Pokemon *mon, u16 item)
{
u8 itemBytes[2];
-
+
if (ItemIsMail(item) == TRUE)
{
if (GiveMailToMon(mon, item) == 0xFF)
@@ -2182,12 +2182,12 @@ void sub_81B1DB8(struct Pokemon *mon, u16 item)
u8 sub_81B1E00(struct Pokemon* mon)
{
u16 item = GetMonData(mon, MON_DATA_HELD_ITEM);
-
+
if (item == ITEM_NONE)
return 0;
if (AddBagItem(item, 1) == FALSE)
return 1;
-
+
item = ITEM_NONE;
SetMonData(mon, MON_DATA_HELD_ITEM, &item);
return 2;
@@ -2201,7 +2201,7 @@ void pokemon_item_not_removed(u16 itemUnused)
void sub_81B1E60(u8 taskId)
{
s16 *data = gTasks[taskId].data;
-
+
data[0] += data[2];
data[3]--;
SetMonData(&gPlayerParty[data[4]], MON_DATA_HP, &data[0]);
@@ -2219,7 +2219,7 @@ void sub_81B1F18(u8 taskId, u8 slot, s8 c, s16 HPDifference, TaskFunc func)
{
struct Pokemon *mon = &gPlayerParty[slot];
s16 *data = gTasks[taskId].data;
-
+
data[0] = GetMonData(mon, MON_DATA_HP);
data[1] = GetMonData(mon, MON_DATA_MAX_HP);
data[2] = c;
@@ -2232,7 +2232,7 @@ void sub_81B1F18(u8 taskId, u8 slot, s8 c, s16 HPDifference, TaskFunc func)
void sub_81B1FA8(u8 taskId, u8 b, u32 hp)
{
s16 *data = gTasks[taskId].data;
-
+
switch (b) // only case 0 is used
{
case 0:
@@ -2275,7 +2275,7 @@ u8 pokemon_ailments_get_primary(u32 status)
u8 sub_81B205C(struct Pokemon *mon)
{
u8 ailment;
-
+
if (GetMonData(mon, MON_DATA_HP) == 0)
return AILMENT_FNT;
ailment = pokemon_ailments_get_primary(GetMonData(mon, MON_DATA_STATUS));
@@ -2289,11 +2289,11 @@ u8 sub_81B205C(struct Pokemon *mon)
void sub_81B209C(void)
{
u16 *ptr;
-
+
if (gUnknown_0203CEC8.unk8_0 == 11)
{
u8 i;
-
+
ptr = &gUnknown_0203CEC8.unkE;
gUnknown_0203CEC8.unkE = 0;
if (gSpecialVar_0x8005 == 0)
@@ -2384,7 +2384,7 @@ void sub_81B227C(u8 taskId)
u8 CanPartyPokemonLearnTMTutor(struct Pokemon *mon, u16 item, u8 tutor)
{
u16 move;
-
+
if (GetMonData(mon, MON_DATA_IS_EGG))
return CANNOT_LEARN_MOVE_IS_EGG;
if (item >= ITEM_TM01_FOCUS_PUNCH)
@@ -2403,7 +2403,7 @@ u8 CanPartyPokemonLearnTMTutor(struct Pokemon *mon, u16 item, u8 tutor)
{
move = sub_81B2360(tutor);
}
-
+
if (pokemon_has_move(mon, move) == TRUE)
return ALREADY_KNOWS_MOVE;
return CAN_LEARN_MOVE;
@@ -2424,7 +2424,7 @@ bool8 sub_81B2370(u16 species, u8 tutor)
void sub_81B239C(u8 a)
{
u8 i;
-
+
switch (a)
{
case 0:
@@ -2454,7 +2454,7 @@ void sub_81B2428(bool8 a)
u8 windowId;
u8 offset;
u8 mainOffset;
-
+
if (gUnknown_0203CEC8.unk8_0 != 5)
{
if (a == TRUE)
@@ -2499,7 +2499,7 @@ void BlitBitmapToPartyWindow(u8 windowId, u8 *b, u8 c, u8 x, u8 y, u8 width, u8
{
u8 *pixels = AllocZeroed(height * width * 32);
u8 i, j;
-
+
if (pixels != NULL)
{
for (i = 0; i < height; i++)
@@ -2546,7 +2546,7 @@ void sub_81B2720(u8 windowId)
void UpdateSelectedPartyBox(struct Struct203CEDC *ptr, u8 bitfield)
{
u8 palNum = GetWindowAttribute(ptr->windowId, WINDOW_PALETTE_NUM) * 16;
-
+
if (bitfield & 0x40)
{
LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AF1[0]), gUnknown_08615AC0[0] + palNum, 2);
@@ -2674,7 +2674,7 @@ void DisplayPartyPokemonBarDetail(u8 windowId, const u8 *str, u8 color, u8 *alig
void DisplayPartyPokemonNickname(struct Pokemon *mon, struct Struct203CEDC *ptr, u8 c)
{
u8 nickname[POKEMON_NAME_LENGTH + 1];
-
+
if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE)
{
if (c == 1)
@@ -2710,7 +2710,7 @@ void DisplayPartyPokemonLevel(u8 level, struct Struct203CEDC *ptr)
void DisplayPartyPokemonGenderNidoranCheck(struct Pokemon *mon, struct Struct203CEDC *ptr, u8 c)
{
u8 nickname[POKEMON_NAME_LENGTH + 1];
-
+
if (c == 1)
ptr->unk0->unk0(ptr->windowId, ptr->unk0->unk4[8] >> 3, (ptr->unk0->unk4[9] >> 3) + 1, ptr->unk0->unk4[10] >> 3, ptr->unk0->unk4[11] >> 3, 0);
GetMonNickname(mon, nickname);
@@ -2720,7 +2720,7 @@ void DisplayPartyPokemonGenderNidoranCheck(struct Pokemon *mon, struct Struct203
void DisplayPartyPokemonGender(u8 gender, u16 species, u8 *nickname, struct Struct203CEDC *ptr)
{
u8 palNum = GetWindowAttribute(ptr->windowId, WINDOW_PALETTE_NUM) * 16;
-
+
if (species == SPECIES_NONE)
return;
if ((species == SPECIES_NIDORAN_M || species == SPECIES_NIDORAN_F) && StringCompare(nickname, gSpeciesNames[species]) == 0)
@@ -2754,10 +2754,10 @@ void DisplayPartyPokemonHPCheck(struct Pokemon *mon, struct Struct203CEDC *ptr,
void DisplayPartyPokemonHP(u16 hp, struct Struct203CEDC *ptr)
{
u8 *strOut = ConvertIntToDecimalStringN(gStringVar1, hp, 1, 3);
-
+
strOut[0] = CHAR_SLASH;
strOut[1] = EOS;
-
+
DisplayPartyPokemonBarDetail(ptr->windowId, gStringVar1, 0, &ptr->unk0->unk4[12]);
}
@@ -2790,7 +2790,7 @@ void DisplayPartyPokemonHPBar(u16 hp, u16 maxhp, struct Struct203CEDC *ptr)
{
u8 palNum = GetWindowAttribute(ptr->windowId, WINDOW_PALETTE_NUM) * 16;
u8 hpFraction;
-
+
switch (GetHPBarLevel(hp, maxhp))
{
case HP_BAR_GREEN:
@@ -2807,7 +2807,7 @@ void DisplayPartyPokemonHPBar(u16 hp, u16 maxhp, struct Struct203CEDC *ptr)
LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ACB[1]), gUnknown_08615AB8[1] + palNum, 2);
break;
}
-
+
hpFraction = GetScaledHPFraction(hp, maxhp, ptr->unk0->unk4[22]);
FillWindowPixelRect(ptr->windowId, gUnknown_08615AB8[1], ptr->unk0->unk4[20], ptr->unk0->unk4[21], hpFraction, 1);
FillWindowPixelRect(ptr->windowId, gUnknown_08615AB8[0], ptr->unk0->unk4[20], ptr->unk0->unk4[21] + 1, hpFraction, 2);
@@ -2915,10 +2915,10 @@ void sub_81B302C(u8 *ptr)
void display_pokemon_menu_message(u32 stringID)
{
u8 *windowPtr = &gUnknown_0203CEC4->unkC[1];
-
+
if (*windowPtr != 0xFF)
sub_81B302C(windowPtr);
-
+
if (stringID != 0x7F)
{
switch (stringID)
@@ -2962,10 +2962,10 @@ bool8 sub_81B314C(void)
struct Pokemon *party = gPlayerParty;
u8 i;
u8 j = 0;
-
+
if (gUnknown_0203CEC8.unkB == 1)
return TRUE;
-
+
for (i = 0; i < 6; i++)
{
if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE && (GetMonData(&party[i], MON_DATA_HP) != 0 || GetMonData(&party[i], MON_DATA_IS_EGG)))
@@ -2982,7 +2982,7 @@ u8 sub_81B31B0(u8 a)
u8 cursorDimension;
u8 fontAttribute;
u8 i;
-
+
switch (a)
{
case 0:
@@ -2998,23 +2998,23 @@ u8 sub_81B31B0(u8 a)
window = gUnknown_08615960;
break;
}
-
+
gUnknown_0203CEC4->unkC[0] = AddWindow(&window);
SetWindowBorderStyle(gUnknown_0203CEC4->unkC[0], FALSE, 0x4F, 13);
if (a == 3)
return gUnknown_0203CEC4->unkC[0];
cursorDimension = GetMenuCursorDimensionByFont(1, 0);
fontAttribute = GetFontAttribute(1, 2);
-
+
for (i = 0; i < gUnknown_0203CEC4->unk17; i++)
{
u8 unk = (gUnknown_0203CEC4->unkF[i] > 18) ? 4 : 3;
AddTextPrinterParameterized4(gUnknown_0203CEC4->unkC[0], 1, cursorDimension, (i * 16) + 1, fontAttribute, 0, gUnknown_086157FC[unk], 0, gUnknown_08615C08[gUnknown_0203CEC4->unkF[i]].textPtr);
}
-
+
InitMenuInUpperLeftCorner(gUnknown_0203CEC4->unkC[0], gUnknown_0203CEC4->unk17, 0, 1);
schedule_bg_copy_tilemap_to_vram(2);
-
+
return gUnknown_0203CEC4->unkC[0];
}
@@ -3046,7 +3046,7 @@ void sub_81B3394(void)
void sub_81B33B4(struct Pokemon *mons, u8 a, u8 b)
{
u8 i;
-
+
if (b == 0)
{
sub_81B3414(mons, a);
@@ -3062,7 +3062,7 @@ void sub_81B33B4(struct Pokemon *mons, u8 a, u8 b)
void sub_81B3414(struct Pokemon *mons, u8 a)
{
u8 i, j;
-
+
gUnknown_0203CEC4->unk17 = 0;
AppendToList(gUnknown_0203CEC4->unkF, &gUnknown_0203CEC4->unk17, 0);
for (i = 0; i < MAX_MON_MOVES; i++)
@@ -3091,7 +3091,7 @@ void sub_81B3414(struct Pokemon *mons, u8 a)
u8 sub_81B353C(struct Pokemon *mon)
{
u32 returnVar;
-
+
switch (gUnknown_0203CEC8.unk8_0)
{
case 0:
@@ -3143,7 +3143,7 @@ bool8 sub_81B3608(u8 taskId)
{
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
u16 item;
-
+
GetMonNickname(mon, gStringVar1);
sub_81B302C(&gUnknown_0203CEC4->unkC[1]);
if (gUnknown_0203CEC8.unk8_0 != 12)
@@ -3187,7 +3187,7 @@ void sub_81B3730(u8 taskId)
{
s16 *data;
s8 input;
-
+
if (gPaletteFade.active == FALSE && sub_81221EC() != TRUE)
{
data = gTasks[taskId].data;
@@ -3195,7 +3195,7 @@ void sub_81B3730(u8 taskId)
input = Menu_ProcessInputNoWrapAround_other();
else
input = ProcessMenuInput_other();
- data[0] = GetMenuCursorPos();
+ data[0] = Menu_GetCursorPos();
if (input != MENU_NOTHING_CHOSEN)
{
if (input == MENU_B_PRESSED)
@@ -3256,7 +3256,7 @@ void sub_81B3938(u8 taskId)
{
s16 *data = gTasks[taskId].data;
u8 windowIds[2];
-
+
if (gUnknown_0203CEC8.unkA == gUnknown_0203CEC8.unk9)
{
sub_81B407C(taskId);
@@ -3300,7 +3300,7 @@ void sub_81B3938(u8 taskId)
#ifdef NONMATCHING
bool8 sub_81B3AD8(s16 a, s16 b, u8 *c, u8 *d, u8 *e)
{
-
+
if ((a + b) < 0 || a > 31)
{
return FALSE;
@@ -3391,7 +3391,7 @@ _081B3B34:\n\
void sub_81B3B40(const void *rectSrc, s16 a, s16 b, s16 c, s16 d, s16 e)
{
u8 f, g, h;
-
+
if (sub_81B3AD8(a, c, &f, &g, &h))
{
FillBgTilemapBufferRect_Palette0(0, 0, g, b, h, d);
@@ -3411,7 +3411,7 @@ void sub_81B3C0C(struct Struct203CEDC *ptr, s16 a)
void sub_81B3C60(u8 taskId)
{
s16 *data = gTasks[taskId].data;
-
+
if (data[10] != 0)
sub_81B3C0C(&gUnknown_0203CEDC[gUnknown_0203CEC8.unk9], data[10]);
if (data[11] != 0)
@@ -3421,7 +3421,7 @@ void sub_81B3C60(u8 taskId)
void sub_81B3CC0(u8 taskId)
{
s16 *data = gTasks[taskId].data;
-
+
if (data[10] != 0)
sub_81B3B40(gUnknown_0203CEF0, data[0] + data[8], data[1], data[2], data[3], data[10]);
if (data[11] != 0)
@@ -3433,7 +3433,7 @@ void sub_81B3D48(u8 taskId)
{
s16 *data = gTasks[taskId].data;
u16 tilemapRelatedMaybe[2];
-
+
sub_81B3CC0(taskId);
sub_81B3C60(taskId);
data[8] += data[10];
@@ -3460,7 +3460,7 @@ void sub_81B3D48(u8 taskId)
void sub_81B3E60(u8 taskId)
{
s16 *data = gTasks[taskId].data;
-
+
sub_81B3CC0(taskId);
sub_81B3C60(taskId);
if (data[10] == 0 && data[11] == 0)
@@ -3487,7 +3487,7 @@ void oamt_swap_pos(u8 *spriteIdPtr1, u8 *spriteIdPtr2)
{
u8 spriteIdBuffer = *spriteIdPtr1;
u16 xBuffer1, yBuffer1, xBuffer2, yBuffer2;
-
+
*spriteIdPtr1 = *spriteIdPtr2;
*spriteIdPtr2 = spriteIdBuffer;
xBuffer1 = gSprites[*spriteIdPtr1].pos1.x;
@@ -3501,7 +3501,7 @@ void oamt_swap_pos(u8 *spriteIdPtr1, u8 *spriteIdPtr2)
gSprites[*spriteIdPtr2].pos1.x = xBuffer1;
gSprites[*spriteIdPtr2].pos1.y = yBuffer1;
gSprites[*spriteIdPtr2].pos2.x = xBuffer2;
- gSprites[*spriteIdPtr2].pos2.y = yBuffer2;
+ gSprites[*spriteIdPtr2].pos2.y = yBuffer2;
}
void swap_pokemon_and_oams(void)
@@ -3509,7 +3509,7 @@ void swap_pokemon_and_oams(void)
struct Struct203CEDC *structPtrs[2];
struct Pokemon *mon1, *mon2;
struct Pokemon *monBuffer;
-
+
structPtrs[0] = &gUnknown_0203CEDC[gUnknown_0203CEC8.unk9];
structPtrs[1] = &gUnknown_0203CEDC[gUnknown_0203CEC8.unkA];
mon1 = &gPlayerParty[gUnknown_0203CEC8.unk9];
@@ -3604,7 +3604,7 @@ void c2_8123744(void)
void sub_81B42D0(u8 taskId)
{
u16 item;
-
+
if (!gPaletteFade.active)
{
item = gSpecialVar_ItemId;
@@ -3678,7 +3678,7 @@ void sub_81B44FC(u8 taskId)
void sub_81B452C(void)
{
u8 mail = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_MAIL);
-
+
sub_811A20C(4, gSaveBlock1Ptr->mail[mail].words, sub_81B4578, 3);
}
@@ -3686,7 +3686,7 @@ void sub_81B4578(void)
{
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
u16 item = GetMonData(mon, MON_DATA_HELD_ITEM);
-
+
if (gSpecialVar_Result == FALSE)
{
TakeMailFromMon(mon);
@@ -3716,7 +3716,7 @@ void sub_81B4624(u8 taskId)
void sub_81B469C(u8 taskId)
{
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
-
+
if (sub_81B1BD4() != TRUE)
{
sub_81B5C94(mon, &gUnknown_0203CEDC[gUnknown_0203CEC8.unk9]);
@@ -3735,7 +3735,7 @@ void sub_81B4724(u8 taskId)
{
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
u16 item = GetMonData(mon, MON_DATA_HELD_ITEM);
-
+
PlaySE(SE_SELECT);
sub_81B302C(&gUnknown_0203CEC4->unkC[0]);
sub_81B302C(&gUnknown_0203CEC4->unkC[1]);
@@ -3762,7 +3762,7 @@ void sub_81B47E0(u8 taskId)
{
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
u16 item = GetMonData(mon, MON_DATA_HELD_ITEM);
-
+
PlaySE(SE_SELECT);
sub_81B302C(&gUnknown_0203CEC4->unkC[0]);
sub_81B302C(&gUnknown_0203CEC4->unkC[1]);
@@ -3794,7 +3794,7 @@ void sub_81B48A8(u8 taskId)
void sub_81B48DC(u8 taskId)
{
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
-
+
switch (Menu_ProcessInputNoWrapClearOnChoose())
{
case 0:
@@ -3815,7 +3815,7 @@ void sub_81B4988(u8 taskId)
{
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
u16 itemClear;
-
+
if (sub_81B1BD4() != TRUE)
{
itemClear = ITEM_NONE;
@@ -3911,7 +3911,7 @@ void sub_81B4C60(u8 taskId)
void sub_81B4C94(u8 taskId)
{
u16 item;
-
+
switch (Menu_ProcessInputNoWrapClearOnChoose())
{
case 0:
@@ -3940,7 +3940,7 @@ void sub_81B4C94(u8 taskId)
void sub_81B4D78(u8 taskId)
{
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
-
+
PlaySE(SE_SELECT);
sub_81B302C(&gUnknown_0203CEC4->unkC[0]);
sub_81B302C(&gUnknown_0203CEC4->unkC[1]);
@@ -3980,7 +3980,7 @@ void sub_81B4E8C(u8 taskId)
{
u8 unk;
u8 i;
-
+
sub_81B302C(&gUnknown_0203CEC4->unkC[0]);
sub_81B302C(&gUnknown_0203CEC4->unkC[1]);
unk = sub_81B8830();
@@ -4016,7 +4016,7 @@ void sub_81B4FA8(u8 taskId)
{
u8 unk;
u8 i, j;
-
+
PlaySE(SE_SELECT);
sub_81B302C(&gUnknown_0203CEC4->unkC[0]);
sub_81B302C(&gUnknown_0203CEC4->unkC[1]);
@@ -4052,7 +4052,7 @@ void sub_81B50C8(u8 taskId)
u16 species2 = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_SPECIES2);
u16 species = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_SPECIES);
u8 obedience = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_OBEDIENCE);
-
+
switch (sub_807A8D0(*(u32 *)sub_800F7DC() /* dirty cast, probably needs to be changed */, species2, species, obedience))
{
case 1:
@@ -4080,7 +4080,7 @@ void brm_trade_1(u8 taskId)
u16 species = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_SPECIES);
u8 obedience = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_OBEDIENCE);
u32 stringId = sub_807A7E0(*(u32 *)sub_800F7DC() /* dirty cast, probably needs to be changed */, *(u32 *)&gUnknown_02022C38 /* dirty cast, probably needs to be changed */, species2, gUnknown_02022C3C, gUnknown_02022C3E, species, obedience);
-
+
if (stringId != 0)
{
StringExpandPlaceholders(gStringVar4, gUnknown_08615E0C[stringId - 1]);
@@ -4153,10 +4153,10 @@ void sub_81B5430(u8 taskId)
void sub_81B5470(u8 taskId)
{
- u8 fieldMove = gUnknown_0203CEC4->unkF[GetMenuCursorPos()] - 19;
+ u8 fieldMove = gUnknown_0203CEC4->unkF[Menu_GetCursorPos()] - 19;
struct MapHeader const *mapHeader;
u8 fieldMove2;
-
+
PlaySE(SE_SELECT);
if (gUnknown_08615D9C[fieldMove].fieldMoveFunc != NULL)
{
@@ -4345,7 +4345,7 @@ void hm2_waterfall(void)
bool8 hm_prepare_waterfall(void)
{
s16 x, y;
-
+
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
if (MetatileBehavior_IsWaterfall(MapGridGetMetatileBehaviorAt(x, y)) == TRUE && IsPlayerSurfingNorth() == TRUE)
{
@@ -4378,7 +4378,7 @@ void party_menu_icon_anim(struct Pokemon *mon, struct Struct203CEDC *ptr, u32 a)
{
u32 bit = 1;
u16 species2;
-
+
if (IsMultiBattle() == TRUE && gMain.inBattle)
bit = (gUnknown_08616020[a] ^ bit) ? 1 : 0;
species2 = GetMonData(mon, MON_DATA_SPECIES2);
@@ -4423,7 +4423,7 @@ void sub_81B5B38(u8 spriteId, struct Pokemon *mon)
}
void AnimateSelectedPartyIcon(u8 spriteId, u8 a)
-{
+{
gSprites[spriteId].data[0] = 0;
if (a == 0)
{
@@ -4450,7 +4450,7 @@ void AnimateSelectedPartyIcon(u8 spriteId, u8 a)
void UpdatePartyMonIconFrameAndBounce(struct Sprite *sprite)
{
u8 unk = UpdateMonIconFrame(sprite);
-
+
if (unk != 0)
{
if (unk & 1)
@@ -4515,7 +4515,7 @@ void sub_81B5D4C(u8 *a, u8 *b, u8 c)
{
u16 i;
u16 item;
-
+
switch (c)
{
case 0:
@@ -4541,7 +4541,7 @@ void sub_81B5DF0(u8 spriteId, u8 isMail)
{
u8 subpriority = gSprites[spriteId].subpriority;
u8 newSpriteId = CreateSprite(&gSpriteTemplate_8615EC0, 250, 170, subpriority - 1);
-
+
gSprites[newSpriteId].pos2.x = 4;
gSprites[newSpriteId].pos2.y = 10;
gSprites[newSpriteId].callback = sub_81B5E74;
@@ -4553,7 +4553,7 @@ void sub_81B5DF0(u8 spriteId, u8 isMail)
void sub_81B5E74(struct Sprite *sprite)
{
u8 otherSpriteId = sprite->data[7];
-
+
if (gSprites[otherSpriteId].invisible)
{
sprite->invisible = TRUE;
@@ -4584,7 +4584,7 @@ void party_menu_link_mon_pokeball_object(u16 species, struct Struct203CEDC *ptr)
u8 sub_81B5F34(u8 x, u8 y)
{
u8 spriteId = CreateSprite(&gSpriteTemplate_8615F08, x, y, 8);
-
+
gSprites[spriteId].oam.priority = 2;
return spriteId;
}
@@ -4619,9 +4619,9 @@ void sub_81B5FBC(u8 spriteId, u8 spriteId2, u8 a)
void LoadPartyMenuPokeballGfx(void)
{
- LoadCompressedObjectPic(&gUnknown_08615EF8);
- LoadCompressedObjectPic(&gUnknown_08615F70);
- LoadCompressedObjectPalette(&gUnknown_08615F00);
+ LoadCompressedSpriteSheet(&gUnknown_08615EF8);
+ LoadCompressedSpriteSheet(&gUnknown_08615F70);
+ LoadCompressedSpritePalette(&gUnknown_08615F00);
}
void party_menu_status_condition_object(struct Pokemon *mon, struct Struct203CEDC *ptr)
@@ -4665,8 +4665,8 @@ void party_menu_update_status_condition_object(u8 status, struct Struct203CEDC *
void LoadPartyMenuAilmentGfx(void)
{
- LoadCompressedObjectPic(&gUnknown_08615FF8);
- LoadCompressedObjectPalette(&gUnknown_08616000);
+ LoadCompressedSpriteSheet(&gUnknown_08615FF8);
+ LoadCompressedSpritePalette(&gUnknown_08616000);
}
void sub_81B617C(void)
@@ -4677,7 +4677,7 @@ void sub_81B617C(void)
u8 i;
u8 msgIDMaybe;
register TaskFunc task asm("r0");
-
+
if (gMain.inBattle)
{
inBattle = TRUE;
@@ -4731,7 +4731,7 @@ void sub_81B6280(u8 taskId)
bool8 IsHPRecoveryItem(u16 item)
{
const u8 *effect;
-
+
if (item == ITEM_ENIGMA_BERRY)
effect = gSaveBlock1Ptr->enigmaBerry.itemEffect;
else
@@ -4821,7 +4821,7 @@ bool8 IsBlueYellowRedFlute(u16 item)
}
bool8 ExecuteTableBasedItemEffect__(u8 partyMonIndex, u16 item, u8 monMoveIndex)
-{
+{
if (gMain.inBattle)
return ExecuteTableBasedItemEffect(&gPlayerParty[partyMonIndex], item, sub_81B8F38(partyMonIndex), monMoveIndex);
else
@@ -4834,7 +4834,7 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task)
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
u16 item = gSpecialVar_ItemId;
bool8 canHeal;
-
+
if (UsingHPEVItemOnShedinja(mon, item))
{
canHeal = IsHPRecoveryItem(item);
@@ -4921,7 +4921,7 @@ void sub_81B67C8(u8 taskId, TaskFunc task)
bool8 cannotUseEffect = ExecuteTableBasedItemEffect__(gUnknown_0203CEC8.unk9, item, 0);
u16 newFriendship = GetMonData(mon, MON_DATA_FRIENDSHIP);
u16 newRelevantEV = sub_81B691C(mon, effectType);
-
+
if (cannotUseEffect || (friendship == newFriendship && relevantEV == newRelevantEV))
{
gUnknown_0203CEE8 = 0;
@@ -5008,7 +5008,7 @@ void sub_81B6A10(u8 slot)
u8 fontId = 1;
u8 windowId = sub_81B31B0(3);
u16 move;
-
+
for (i = 0; i < MAX_MON_MOVES; i++)
{
move = GetMonData(&gPlayerParty[slot], MON_DATA_MOVE1 + i);
@@ -5023,7 +5023,7 @@ void sub_81B6A10(u8 slot)
void ether_effect_related_3(u8 taskId)
{
s8 input = Menu_ProcessInput();
-
+
if (input != MENU_NOTHING_CHOSEN)
{
if (input == MENU_B_PRESSED)
@@ -5043,7 +5043,7 @@ void dp05_ether(u8 taskId, TaskFunc unused)
{
const u8 *effect;
u16 item = gSpecialVar_ItemId;
-
+
if (item == ITEM_ENIGMA_BERRY)
effect = gSaveBlock1Ptr->enigmaBerry.itemEffect;
else
@@ -5065,7 +5065,7 @@ void dp05_ether(u8 taskId, TaskFunc unused)
void ether_effect_related_2(u8 taskId)
{
sub_81B302C(&gUnknown_0203CEC4->unkC[0]);
- gUnknown_0203CEC8.unkE = GetMenuCursorPos();
+ gUnknown_0203CEC8.unkE = Menu_GetCursorPos();
ether_effect_related(taskId);
}
@@ -5084,7 +5084,7 @@ void ether_effect_related(u8 taskId)
u16 item = gSpecialVar_ItemId;
struct Struct203CEC8 *ptr = &gUnknown_0203CEC8;
struct Pokemon *mon;
-
+
if (ExecuteTableBasedItemEffect__(ptr->unk9, item, *moveslot))
{
gUnknown_0203CEE8 = 0;
@@ -5125,7 +5125,7 @@ u16 ItemIdToBattleMoveId(u16 item)
bool8 sub_81B6D14(u16 move)
{
u8 i;
-
+
for (i = 0; i < NUM_HIDDEN_MACHINES; i++)
{
if (gUnknown_08616040[i + NUM_TECHNICAL_MACHINES] == move)
@@ -5137,7 +5137,7 @@ bool8 sub_81B6D14(u16 move)
bool8 pokemon_has_move(struct Pokemon *mon, u16 move)
{
u8 i;
-
+
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (GetMonData(mon, MON_DATA_MOVE1 + i) == move)
@@ -5166,7 +5166,7 @@ void sub_81B6DC4(u8 taskId, TaskFunc unused)
struct Pokemon *mon;
s16 *move;
u16 item;
-
+
PlaySE(SE_SELECT);
mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
move = &gUnknown_0203CEC8.unkE;
@@ -5200,7 +5200,7 @@ void sub_81B6EB4(u8 taskId)
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
s16 *move = &gUnknown_0203CEC8.unkE;
u16 item = gSpecialVar_ItemId;
-
+
if (move[1] == 0)
{
AdjustFriendship(mon, 4);
@@ -5231,7 +5231,7 @@ void sub_81B6F98(u8 taskId)
if (gUnknown_0203CEC8.unk10 == 1)
sub_81B77AC(taskId);
else
- {
+ {
if (gUnknown_0203CEC8.unk10 == 2)
gSpecialVar_Result = TRUE;
sub_81B12C0(taskId);
@@ -5298,7 +5298,7 @@ void sub_81B7154(u8 taskId)
{
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
u16 move = GetMonData(mon, MON_DATA_MOVE1 + sub_81C1B94());
-
+
GetMonNickname(mon, gStringVar1);
StringCopy(gStringVar2, gMoveNames[move]);
sub_81B6D74(gText_12PoofForgotMove);
@@ -5309,7 +5309,7 @@ void sub_81B71D4(u8 taskId)
{
struct Pokemon *mon;
u16 move;
-
+
if (sub_81B1BD4() != TRUE)
{
mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
@@ -5341,7 +5341,7 @@ void sub_81B7294(u8 taskId)
void sub_81B72C8(u8 taskId)
{
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
-
+
switch (Menu_ProcessInputNoWrapClearOnChoose())
{
case 0:
@@ -5384,7 +5384,7 @@ void dp05_rare_candy(u8 taskId, TaskFunc task)
s16 *arrayPtr = ptr->data;
u16 *itemPtr = &gSpecialVar_ItemId;
bool8 cannotUseEffect;
-
+
if (GetMonData(mon, MON_DATA_LEVEL) != MAX_LEVEL)
{
sub_81B79A0(mon, arrayPtr);
@@ -5454,7 +5454,7 @@ void sub_81B7634(u8 taskId)
void sub_81B767C(u8 taskId)
{
s16 *arrayPtr = gUnknown_0203CEC4->data;
-
+
arrayPtr[12] = sub_81B3364();
sub_81D3640(arrayPtr[12], arrayPtr, &arrayPtr[6], 1, 2, 3);
CopyWindowToVram(arrayPtr[12], 2);
@@ -5464,7 +5464,7 @@ void sub_81B767C(u8 taskId)
void sub_81B76C8(u8 taskIdUnused)
{
s16 *arrayPtr = gUnknown_0203CEC4->data;
-
+
sub_81D3784(arrayPtr[12], &arrayPtr[6], 1, 2, 3);
CopyWindowToVram(arrayPtr[12], 2);
schedule_bg_copy_tilemap_to_vram(2);
@@ -5473,7 +5473,7 @@ void sub_81B76C8(u8 taskIdUnused)
void sub_81B7704(u8 taskId)
{
u16 result;
-
+
if (WaitFanfare(0) && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)))
{
sub_81B3394();
@@ -5500,7 +5500,7 @@ void sub_81B7704(u8 taskId)
void sub_81B77AC(u8 taskId)
{
u16 result = MonTryLearningNewMove(&gPlayerParty[gUnknown_0203CEC8.unk9], 0);
-
+
switch (result)
{
case 0:
@@ -5521,7 +5521,7 @@ void sub_81B7810(u8 taskId)
{
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
u16 targetSpecies = GetEvolutionTargetSpecies(mon, 0, 0);
-
+
if (targetSpecies != SPECIES_NONE)
{
FreePartyPointers();
@@ -5580,7 +5580,7 @@ void sub_81B7A28(u8 taskId)
{
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
u16 hp;
-
+
if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE)
{
hp = GetMonData(mon, MON_DATA_HP);
@@ -5945,7 +5945,7 @@ void sub_81B7E4C(u8 taskId)
{
struct Pokemon *mon;
s16 *move;
-
+
if (!gPaletteFade.active)
{
mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
@@ -6022,7 +6022,7 @@ void sub_81B8044(u8 taskId)
void sub_81B8088(u8 taskId)
{
u16 item;
-
+
if (!gPaletteFade.active)
{
item = gUnknown_0203CEC8.unkC;
@@ -6036,7 +6036,7 @@ void sub_81B8088(u8 taskId)
void sub_81B8104(u8 taskId)
{
s8 slot = gUnknown_0203CEC8.unk9;
-
+
if (sub_81B1BD4() != TRUE)
{
sub_81B5C94(&gPlayerParty[slot], &gUnknown_0203CEDC[slot]);
@@ -6047,7 +6047,7 @@ void sub_81B8104(u8 taskId)
void sub_81B814C(void)
{
u8 mail;
-
+
sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.unk9], gUnknown_0203CEC8.unkC);
mail = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_MAIL);
sub_811A20C(4, gSaveBlock1Ptr->mail[mail].words, sub_81B81A8, 3);
@@ -6057,7 +6057,7 @@ void sub_81B81A8(void)
{
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
u16 item = GetMonData(mon, MON_DATA_HELD_ITEM);
-
+
if (gSpecialVar_Result == FALSE)
{
TakeMailFromMon(mon);
@@ -6096,7 +6096,7 @@ void sub_81B82A0(u8 taskId)
void sub_81B82D4(u8 taskId)
{
u16 item;
-
+
switch (Menu_ProcessInputNoWrapClearOnChoose())
{
case 0:
@@ -6161,7 +6161,7 @@ void sub_81B8474(u8 taskId)
{
struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9];
struct MailStruct *mail;
-
+
gUnknown_0203CEE8 = 0;
mail = &gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos];
if (GetMonData(mon, MON_DATA_HELD_ITEM) != ITEM_NONE)
@@ -6203,10 +6203,10 @@ bool8 GetBattleEntryEligibility(struct Pokemon *mon)
{
u16 i = 0;
u16 species;
-
- if (GetMonData(mon, MON_DATA_IS_EGG) || GetMonData(mon, MON_DATA_LEVEL) > sub_81B8888() ||
- (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(BATTLE_FRONTIER_BATTLE_PYRAMID_LOBBY) &&
- gSaveBlock1Ptr->location.mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PYRAMID_LOBBY) &&
+
+ if (GetMonData(mon, MON_DATA_IS_EGG) || GetMonData(mon, MON_DATA_LEVEL) > sub_81B8888() ||
+ (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(BATTLE_FRONTIER_BATTLE_PYRAMID_LOBBY) &&
+ gSaveBlock1Ptr->location.mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PYRAMID_LOBBY) &&
GetMonData(mon, MON_DATA_HELD_ITEM) != ITEM_NONE))
return FALSE;
switch (VarGet(VAR_FRONTIER_FACILITY)) // oddly the specific cases are beyond 6, turns out case 9 is apparently related to link battles
@@ -6237,7 +6237,7 @@ u8 sub_81B865C(void)
u16 species;
u16 item;
u8 facilityNum;
-
+
if (gSelectedOrderFromParty[unk - 1] == 0)
{
if (unk == 1)
@@ -6407,7 +6407,7 @@ _081B8758:\n\
bool8 sub_81B8770(u8 slot)
{
u8 i;
-
+
for (i = 0; i < 4; i++)
{
if (gSelectedOrderFromParty[i] == slot)
@@ -6419,7 +6419,7 @@ bool8 sub_81B8770(u8 slot)
void sub_81B879C(u8 taskId)
{
u8 msgID = sub_81B865C();
-
+
if (msgID != 0xFF)
{
PlaySE(SE_HAZURE);
@@ -6487,7 +6487,7 @@ u8 sub_81B8888(void)
const u8* sub_81B88BC(void)
{
u8 facilityNum = VarGet(VAR_FRONTIER_FACILITY);
-
+
if (!(facilityNum != 8 && facilityNum != 9))
return gText_CancelBattle;
if (facilityNum == FRONTIER_FACILITY_DOME && gSpecialVar_0x8005 == 2)
@@ -6551,7 +6551,7 @@ bool8 sub_81B8A7C(void)
u8 newSlot;
u8 i;
u8 neededToMatch;
-
+
if (IsMultiBattle() == TRUE && (slot == 1 || slot == 4 || slot == 5))
{
StringCopy(gStringVar1, GetTrainerPartnerName());
@@ -6613,7 +6613,7 @@ void sub_81B8C88(u8 *ptr, bool8 multiplayerFlag)
{
u8 partyIndexes[6];
int i, j;
-
+
if (IsMultiBattle() == TRUE)
{
if (multiplayerFlag)
@@ -6672,7 +6672,7 @@ void sub_81B8D88(u8 *ptr, bool8 multiplayerFlag, u8 battlerPosition)
int i, j;
u8 leftBattler;
u8 rightBattler;
-
+
if (GetBattlerSide(battlerPosition) == B_SIDE_PLAYER)
{
leftBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
@@ -6737,7 +6737,7 @@ void sub_81B8E80(u8 battlerPosition, u8 unk, u8 arrayIndex)
int i, j;
u8 *battleStructRelated;
u8 possiblePartyIndexBuffer;
-
+
if (IsMultiBattle())
{
battleStructRelated = gBattleStruct->field_60[battlerPosition];
@@ -6771,7 +6771,7 @@ u8 sub_81B8F38(u8 slot)
{
u8 modResult = slot & 1;
u8 retVal;
-
+
slot /= 2;
if (modResult != 0)
retVal = gUnknown_0203CF00[slot] & 0xF;
@@ -6783,7 +6783,7 @@ u8 sub_81B8F38(u8 slot)
void sub_81B8F6C(u8 slot, u8 setVal)
{
bool32 modResult = slot & 1;
-
+
slot /= 2;
if (modResult != 0)
gUnknown_0203CF00[slot] = (gUnknown_0203CF00[slot] & 0xF0) | setVal;
@@ -6801,7 +6801,7 @@ void sub_81B8FB0(u8 slot, u8 slot2)
u8 pokemon_order_func(u8 slot)
{
u8 i, j;
-
+
for (j = i = 0; i < 3; j++, i++)
{
if ((gUnknown_0203CF00[i] >> 4) != slot)
@@ -6822,7 +6822,7 @@ void pokemon_change_order(void)
{
struct Pokemon *partyBuffer = Alloc(sizeof(gPlayerParty));
u8 i;
-
+
memcpy(partyBuffer, gPlayerParty, sizeof(gPlayerParty));
for (i = 0; i < PARTY_SIZE; i++)
memcpy(&gPlayerParty[pokemon_order_func(i)], &partyBuffer[i], sizeof(struct Pokemon));
@@ -6833,7 +6833,7 @@ void sub_81B9080(void)
{
struct Pokemon *partyBuffer = Alloc(sizeof(gPlayerParty));
u8 i;
-
+
memcpy(partyBuffer, gPlayerParty, sizeof(gPlayerParty));
for (i = 0; i < PARTY_SIZE; i++)
memcpy(&gPlayerParty[sub_81B8F38(i)], &partyBuffer[i], sizeof(struct Pokemon));
@@ -6845,7 +6845,7 @@ void sub_81B90D0(void)
u8 i;
struct Pokemon *mon;
u8 leadVal;
-
+
for (i = 1; i < PARTY_SIZE; i++)
{
mon = &gPlayerParty[sub_81B8F38(i)];
@@ -6881,7 +6881,7 @@ void sub_81B91B4(u8 taskId)
{
s16 *data = gTasks[taskId].data;
u8 i;
-
+
if (!gPaletteFade.active)
{
data[0] -= 8;
@@ -6902,7 +6902,7 @@ void sub_81B91B4(u8 taskId)
void sub_81B9240(u8 taskId)
{
s16 *data = gTasks[taskId].data;
-
+
if (++data[0] == 0x100)
sub_81B12C0(taskId);
}
@@ -6917,7 +6917,7 @@ void sub_81B9294(u8 taskId)
{
s16 *data = gTasks[taskId].data;
u8 i;
-
+
for (i = 3; i < PARTY_SIZE; i++)
{
if (gUnknown_02022FF8[i - 3].species != SPECIES_NONE)
@@ -7043,7 +7043,7 @@ void sub_81B9588(void)
void sub_81B95E0(void)
{
u8 i;
-
+
gSpecialVar_Result = FALSE;
for (i = 0; i < 3; i++)
{
@@ -7081,7 +7081,7 @@ void sub_81B968C(void)
void sub_81B96D0(void)
{
u8 i;
-
+
gSpecialVar_Result = 0;
for (i = 0; i < MAX_MON_MOVES; i++)
{
@@ -7094,7 +7094,7 @@ void sub_81B9718(void)
{
struct Pokemon *mon = &gPlayerParty[gSpecialVar_0x8004];
u16 move = GetMonData(mon, MON_DATA_MOVE1 + gSpecialVar_0x8005);
-
+
GetMonNickname(mon, gStringVar1);
StringCopy(gStringVar2, gMoveNames[move]);
}
@@ -7102,7 +7102,7 @@ void sub_81B9718(void)
void sub_81B9770(void)
{
u16 i;
-
+
SetMonMoveSlot(&gPlayerParty[gSpecialVar_0x8004], MOVE_NONE, gSpecialVar_0x8005);
RemoveMonPPBonus(&gPlayerParty[gSpecialVar_0x8004], gSpecialVar_0x8005);
for (i = gSpecialVar_0x8005; i < MAX_MON_MOVES - 1; i++)
@@ -7142,7 +7142,7 @@ void sub_81B9918(void)
{
u16 move;
u32 i, j;
-
+
gSpecialVar_Result = FALSE;
move = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_MOVE1 + gSpecialVar_0x8005);
if (move == MOVE_SURF)
@@ -7158,7 +7158,7 @@ void sub_81B9918(void)
}
}
}
- if (sub_80D23A8(move) != TRUE)
+ if (AnyStorageMonWithMove(move) != TRUE)
gSpecialVar_Result = TRUE;
}
}
diff --git a/src/player_pc.c b/src/player_pc.c
index c41dfa380..b7380cee3 100644
--- a/src/player_pc.c
+++ b/src/player_pc.c
@@ -461,9 +461,9 @@ static void ItemStorageMenuProcessInput(u8 taskId)
s8 r2;
s8 inputOptionId;
- r5 = GetMenuCursorPos();
+ r5 = Menu_GetCursorPos();
inputOptionId = Menu_ProcessInput();
- r2 = GetMenuCursorPos();
+ r2 = Menu_GetCursorPos();
switch(inputOptionId)
{
case -2:
diff --git a/src/pokeball.c b/src/pokeball.c
index aa29b020f..baa165649 100644
--- a/src/pokeball.c
+++ b/src/pokeball.c
@@ -999,8 +999,8 @@ void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 battlerId, u8 x, u8 y,
{
u8 spriteId;
- LoadCompressedObjectPicUsingHeap(&gBallSpriteSheets[0]);
- LoadCompressedObjectPaletteUsingHeap(&gBallSpritePalettes[0]);
+ LoadCompressedSpriteSheetUsingHeap(&gBallSpriteSheets[0]);
+ LoadCompressedSpritePaletteUsingHeap(&gBallSpritePalettes[0]);
spriteId = CreateSprite(&gBallSpriteTemplates[0], x, y, subpriortiy);
gSprites[spriteId].data[0] = monSpriteId;
@@ -1101,8 +1101,8 @@ u8 sub_807671C(u8 a, u8 b, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 g, u32
{
u8 spriteId;
- LoadCompressedObjectPicUsingHeap(&gBallSpriteSheets[0]);
- LoadCompressedObjectPaletteUsingHeap(&gBallSpritePalettes[0]);
+ LoadCompressedSpriteSheetUsingHeap(&gBallSpriteSheets[0]);
+ LoadCompressedSpritePaletteUsingHeap(&gBallSpritePalettes[0]);
spriteId = CreateSprite(&gBallSpriteTemplates[0], x, y, subPriority);
gSprites[spriteId].data[0] = a;
gSprites[spriteId].data[1] = g;
@@ -1245,8 +1245,8 @@ void LoadBallGfx(u8 ballId)
if (GetSpriteTileStartByTag(gBallSpriteSheets[ballId].tag) == 0xFFFF)
{
- LoadCompressedObjectPicUsingHeap(&gBallSpriteSheets[ballId]);
- LoadCompressedObjectPaletteUsingHeap(&gBallSpritePalettes[ballId]);
+ LoadCompressedSpriteSheetUsingHeap(&gBallSpriteSheets[ballId]);
+ LoadCompressedSpritePaletteUsingHeap(&gBallSpritePalettes[ballId]);
}
switch (ballId)
{
diff --git a/src/pokeblock.c b/src/pokeblock.c
index 1418588b8..67f185ff6 100644
--- a/src/pokeblock.c
+++ b/src/pokeblock.c
@@ -640,11 +640,11 @@ static bool8 LoadPokeblockMenuGfx(void)
sPokeblockMenu->gfxState++;
break;
case 3:
- LoadCompressedObjectPic(&gPokeblockCase_SpriteSheet);
+ LoadCompressedSpriteSheet(&gPokeblockCase_SpriteSheet);
sPokeblockMenu->gfxState++;
break;
case 4:
- LoadCompressedObjectPalette(&gPokeblockCase_SpritePal);
+ LoadCompressedSpritePalette(&gPokeblockCase_SpritePal);
sPokeblockMenu->gfxState++;
break;
case 5:
diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c
index 2271d7adf..b1f182b66 100644
--- a/src/pokeblock_feed.c
+++ b/src/pokeblock_feed.c
@@ -656,25 +656,25 @@ static bool8 LoadMonAndSceneGfx(struct Pokemon *mon)
trainerId = GetMonData(mon, MON_DATA_OT_ID);
palette = GetMonSpritePalStructFromOtIdPersonality(species, trainerId, personality);
- LoadCompressedObjectPalette(palette);
+ LoadCompressedSpritePalette(palette);
SetMultiuseSpriteTemplateToPokemon(palette->tag, 1);
sPokeblockFeed->loadGfxState++;
break;
case 2:
- LoadCompressedObjectPic(&gPokeblockCase_SpriteSheet);
+ LoadCompressedSpriteSheet(&gPokeblockCase_SpriteSheet);
sPokeblockFeed->loadGfxState++;
break;
case 3:
- LoadCompressedObjectPalette(&gPokeblockCase_SpritePal);
+ LoadCompressedSpritePalette(&gPokeblockCase_SpritePal);
sPokeblockFeed->loadGfxState++;
break;
case 4:
- LoadCompressedObjectPic(&sPokeblock_SpriteSheet);
+ LoadCompressedSpriteSheet(&sPokeblock_SpriteSheet);
sPokeblockFeed->loadGfxState++;
break;
case 5:
SetPokeblockSpritePal(gSpecialVar_ItemId);
- LoadCompressedObjectPalette(&sPokeblockSpritePal);
+ LoadCompressedSpritePalette(&sPokeblockSpritePal);
sPokeblockFeed->loadGfxState++;
break;
case 6:
diff --git a/src/pokedex.c b/src/pokedex.c
index ef8905bb6..755a46821 100644
--- a/src/pokedex.c
+++ b/src/pokedex.c
@@ -1803,7 +1803,7 @@ bool8 sub_80BC514(u8 a)
ResetSpriteData();
FreeAllSpritePalettes();
gReservedSpritePaletteCount = 8;
- LoadCompressedObjectPic(&sInterfaceSpriteSheet[0]);
+ LoadCompressedSpriteSheet(&sInterfaceSpriteSheet[0]);
LoadSpritePalettes(sInterfaceSpritePalette);
CreateInterfaceSprites(a);
gMain.state++;
@@ -4815,7 +4815,7 @@ void sub_80C12E0(u8 taskId)
}
break;
case 1:
- LoadCompressedObjectPic(sInterfaceSpriteSheet);
+ LoadCompressedSpriteSheet(sInterfaceSpriteSheet);
LoadSpritePalettes(sInterfaceSpritePalette);
sub_80C2594(taskId);
for (i = 0; i < 16; i++)
diff --git a/src/pokemon.c b/src/pokemon.c
index 640d70776..6700ef553 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -4091,13 +4091,13 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data)
case MON_DATA_LANGUAGE:
retVal = boxMon->language;
break;
- case MON_DATA_SANITY_BIT1:
+ case MON_DATA_SANITY_IS_BAD_EGG:
retVal = boxMon->isBadEgg;
break;
- case MON_DATA_SANITY_BIT2:
+ case MON_DATA_SANITY_HAS_SPECIES:
retVal = boxMon->hasSpecies;
break;
- case MON_DATA_SANITY_BIT3:
+ case MON_DATA_SANITY_IS_EGG:
retVal = boxMon->isEgg;
break;
case MON_DATA_OT_NAME:
@@ -4298,7 +4298,7 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data)
u16 *moves = (u16 *)data;
s32 i = 0;
- while (moves[i] != 355)
+ while (moves[i] != MOVES_COUNT)
{
u16 move = moves[i];
if (substruct1->moves[0] == move
@@ -4460,13 +4460,13 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg)
case MON_DATA_LANGUAGE:
SET8(boxMon->language);
break;
- case MON_DATA_SANITY_BIT1:
+ case MON_DATA_SANITY_IS_BAD_EGG:
SET8(boxMon->isBadEgg);
break;
- case MON_DATA_SANITY_BIT2:
+ case MON_DATA_SANITY_HAS_SPECIES:
SET8(boxMon->hasSpecies);
break;
- case MON_DATA_SANITY_BIT3:
+ case MON_DATA_SANITY_IS_EGG:
SET8(boxMon->isEgg);
break;
case MON_DATA_OT_NAME:
@@ -4722,7 +4722,7 @@ u8 SendMonToPC(struct Pokemon* mon)
do
{
- for (boxPos = 0; boxPos < 30; boxPos++)
+ for (boxPos = 0; boxPos < IN_BOX_COUNT; boxPos++)
{
struct BoxPokemon* checkingMon = GetBoxedMonPtr(boxNo, boxPos);
if (GetBoxMonData(checkingMon, MON_DATA_SPECIES, NULL) == SPECIES_NONE)
@@ -4739,7 +4739,7 @@ u8 SendMonToPC(struct Pokemon* mon)
}
boxNo++;
- if (boxNo == 14)
+ if (boxNo == TOTAL_BOXES_COUNT)
boxNo = 0;
} while (boxNo != StorageGetCurrentBox());
@@ -4889,9 +4889,9 @@ bool8 IsPokemonStorageFull(void)
{
s32 i, j;
- for (i = 0; i < 14; i++)
- for (j = 0; j < 30; j++)
- if (GetBoxMonDataFromAnyBox(i, j, MON_DATA_SPECIES) == SPECIES_NONE)
+ for (i = 0; i < TOTAL_BOXES_COUNT; i++)
+ for (j = 0; j < IN_BOX_COUNT; j++)
+ if (GetBoxMonDataAt(i, j, MON_DATA_SPECIES) == SPECIES_NONE)
return FALSE;
return TRUE;
@@ -6847,7 +6847,7 @@ void SetWildMonHeldItem(void)
u16 species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, 0);
u16 var1 = 45;
u16 var2 = 95;
- if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3, 0)
+ if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG, 0)
&& GetMonAbility(&gPlayerParty[0]) == ABILITY_COMPOUND_EYES)
{
var1 = 20;
diff --git a/src/pokemon_icon.c b/src/pokemon_icon.c
index c24c8a898..36a7da0ee 100644
--- a/src/pokemon_icon.c
+++ b/src/pokemon_icon.c
@@ -1076,7 +1076,7 @@ u8 sub_80D2D78(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8
return spriteId;
}
-u16 mon_icon_convert_unown_species_id(u16 species, u32 personality)
+u16 GetIconSpecies(u16 species, u32 personality)
{
u16 result;
@@ -1104,7 +1104,8 @@ u16 GetUnownLetterByPersonality(u32 personality)
{
if (!personality)
return 0;
- return (((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 0x3)) % 0x1C;
+ else
+ return (((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 0x3)) % 0x1C;
}
u16 sub_80D2E84(u16 species)
@@ -1121,19 +1122,17 @@ u16 sub_80D2E84(u16 species)
}
else
{
- if(species > (SPECIES_UNOWN_B - 1))
- species = 260;
- return mon_icon_convert_unown_species_id(species, 0);
+ if (species > (SPECIES_UNOWN_B - 1))
+ species = SPECIES_OLD_UNOWN_J; // That's an oddly specific species.
+ return GetIconSpecies(species, 0);
}
}
const u8 *GetMonIconPtr(u16 species, u32 personality, bool32 extra)
{
- return GetMonIconTiles(mon_icon_convert_unown_species_id(species, personality), extra);
+ return GetMonIconTiles(GetIconSpecies(species, personality), extra);
}
-
-
void sub_80D2EF8(struct Sprite *sprite)
{
sub_80D328C(sprite);
@@ -1220,7 +1219,7 @@ void sub_80D304C(u16 offset)
}
}
-u8 sub_80D3080(u16 species)
+u8 GetValidMonIconPalIndex(u16 species)
{
if (species > SPECIES_EGG)
species = 260;
diff --git a/src/pokemon_size_record.c b/src/pokemon_size_record.c
index 2d9a2f08f..b0e14d2b1 100644
--- a/src/pokemon_size_record.c
+++ b/src/pokemon_size_record.c
@@ -210,7 +210,7 @@ void GiveGiftRibbonToParty(u8 index, u8 ribbonId)
{
struct Pokemon *mon = &gPlayerParty[i];
- if (GetMonData(mon, MON_DATA_SPECIES) != 0 && GetMonData(mon, MON_DATA_SANITY_BIT3) == 0)
+ if (GetMonData(mon, MON_DATA_SPECIES) != 0 && GetMonData(mon, MON_DATA_SANITY_IS_EGG) == 0)
{
SetMonData(mon, array[index], &data);
gotRibbon = TRUE;
diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c
index ad56b1678..a988e4104 100644
--- a/src/pokemon_storage_system.c
+++ b/src/pokemon_storage_system.c
@@ -1,55 +1,728 @@
#include "global.h"
+#include "alloc.h"
#include "bg.h"
+#include "data2.h"
+#include "decompress.h"
+#include "dma3.h"
+#include "dynamic_placeholder_text_util.h"
#include "event_data.h"
#include "field_screen_effect.h"
#include "field_weather.h"
#include "gpu_regs.h"
+#include "graphics.h"
#include "international_string_util.h"
+#include "item.h"
+#include "item_icon.h"
+#include "item_menu.h"
+#include "mail.h"
#include "main.h"
#include "menu.h"
+#include "mon_markings.h"
+#include "naming_screen.h"
#include "overworld.h"
#include "palette.h"
+#include "pc_screen_effect.h"
#include "pokemon.h"
+#include "pokemon_icon.h"
+#include "pokemon_summary_screen.h"
#include "pokemon_storage_system.h"
#include "script.h"
#include "sound.h"
#include "string_util.h"
#include "strings.h"
#include "text.h"
+#include "text_window.h"
+#include "trig.h"
#include "walda_phrase.h"
#include "window.h"
+#include "constants/maps.h"
+#include "constants/moves.h"
+#include "constants/rgb.h"
#include "constants/songs.h"
#include "constants/species.h"
-IWRAM_DATA u8 gUnknown_03000F78[0x188];
+struct WallpaperTable
+{
+ const u32 *tiles;
+ const u32 *tileMap;
+ const u16 *palettes;
+};
+
+struct PokemonStorageSystemFunc
+{
+ u8 (*func)(void);
+ s8 unk4;
+};
+
+struct StorageAction
+{
+ const u8 *text;
+ u8 format;
+};
+
+struct StorageMenu
+{
+ const u8 *text;
+ int textId;
+};
+
+struct PSS_MenuStringPtrs
+{
+ const u8 *text;
+ const u8 *desc;
+};
+
+struct UnkStruct_2000028
+{
+ const u8 *unk_00;
+ u8 *unk_04;
+ u16 unk_08;
+ u16 unk_0a;
+ u16 newField;
+ void (*unk_0c)(struct UnkStruct_2000028 *data);
+};
+
+struct UnkStruct_2000020
+{
+ struct UnkStruct_2000028 *unk_00;
+ u8 unk_04;
+ u8 unk_05;
+};
+
+struct UnkPSSStruct_2002370
+{
+ struct Sprite *unk_0000;
+ struct Sprite *unk_0004[4];
+ u32 unk_0014[3];
+ struct Sprite *unk_0020[2];
+ u8 filler_0028[0x214];
+ u32 unk_023c;
+ u16 unk_0240;
+ u16 unk_0242;
+ u8 curBox;
+ u8 unk_0245;
+ u8 unk_0246;
+};
-extern const u8 gText_PartyFull[];
-extern const u8 gText_Box[];
-extern const u8 gText_JustOnePkmn[];
+struct UnkStorageStruct
+{
+ struct Sprite *sprite;
+ u8 *tiles;
+ u16 palIndex;
+ u8 unk8;
+ u8 unk9;
+ u8 unk10;
+};
+
+struct PokemonStorageSystemData
+{
+ u8 state;
+ u8 boxOption;
+ u8 screenChangeType;
+ bool8 isReshowingPSS;
+ u8 taskId;
+ struct UnkStruct_2000020 unk_0020;
+ struct UnkStruct_2000028 unk_0028[8];
+ u16 field_B0[528 / 2];
+ u16 field_2C0;
+ u16 field_2C2;
+ u8 field_2C4;
+ u8 field_2C5;
+ u8 showPartyMenuState;
+ u8 unk_02C7;
+ u8 unk_02C8;
+ bool8 unk_02C9;
+ s16 newCurrBoxId;
+ u16 bg2_X;
+ s16 field_2CE;
+ u16 field_2D0;
+ u8 field_2D2;
+ u8 field_2D3;
+ u8 field_2D4;
+ u16 field_2D6;
+ s16 field_2D8;
+ u16 field_2DA;
+ u16 field_2DC;
+ u16 field_2DE;
+ u16 field_2E0;
+ u8 filler[22];
+ u8 field_2F8[1024];
+ u8 field_6F8;
+ u8 field_6F9;
+ u8 field_6FA;
+ s8 field_6FB;
+ u16 field_6FC[16];
+ u16 field_71C;
+ u16 field_71E;
+ struct Sprite *field_720[2];
+ struct Sprite *field_728[2];
+ struct Sprite *field_730[2];
+ u32 field_738;
+ u8 field_73C[80];
+ u16 field_78C;
+ s16 wallpaperSetId;
+ s16 wallpaperId;
+ u16 field_792[360];
+ u8 wallpaperChangeState;
+ u8 field_A63;
+ u8 field_A64;
+ s8 field_A65;
+ u8 *wallpaperTiles;
+ struct Sprite *movingMonSprite;
+ struct Sprite *partySprites[PARTY_SIZE];
+ struct Sprite *boxMonsSprites[IN_BOX_COUNT];
+ struct Sprite **field_B00;
+ struct Sprite **field_B04;
+ u16 field_B08[40];
+ u16 field_B58[40];
+ u16 boxSpecies[IN_BOX_COUNT];
+ u32 boxPersonalities[IN_BOX_COUNT];
+ u8 field_C5C;
+ u8 field_C5D;
+ u8 field_C5E;
+ u16 field_C60;
+ s16 field_C62;
+ s16 field_C64;
+ u16 field_C66;
+ u8 field_C68;
+ s8 field_C69;
+ u8 field_C6A;
+ u8 field_C6B;
+ struct WindowTemplate menuWindow;
+ struct StorageMenu menuItems[7];
+ u8 menuItemsCount;
+ u8 menuWidth;
+ u8 field_CAE;
+ u16 field_CB0;
+ struct Sprite *field_CB4;
+ struct Sprite *field_CB8;
+ s32 field_CBC;
+ s32 field_CC0;
+ u32 field_CC4;
+ u32 field_CC8;
+ s16 field_CCC;
+ s16 field_CCE;
+ u16 field_CD0;
+ s8 field_CD2;
+ s8 field_CD3;
+ u8 field_CD4;
+ u8 field_CD5;
+ u8 field_CD6;
+ u8 field_CD7;
+ u8 field_CD8[2];
+ const u32 *cursorMonPalette;
+ u32 cursorMonPersonality;
+ u16 cursorMonSpecies;
+ u16 cursorMonItem;
+ u16 field_CE8;
+ bool8 setMosaic;
+ u8 cursorMonMarkings;
+ u8 cursorMonLevel;
+ bool8 cursorMonIsEgg;
+ u8 cursorMonNick[POKEMON_NAME_LENGTH + 1];
+ u8 cursorMonNickText[36];
+ u8 cursorMonSpeciesName[36];
+ u8 cursorMonGenderLvlText[36];
+ u8 cursorMonItemName[36];
+ bool8 (*monPlaceChangeFunc)(void);
+ u8 monPlaceChangeState;
+ u8 field_D91;
+ struct Sprite *field_D94;
+ struct Sprite *field_D98[2];
+ u16 *field_DA0;
+ struct PokemonMarkMenu field_DA4;
+ struct UnkPSSStruct_2002370 field_1E5C;
+ struct Pokemon movingMon;
+ struct Pokemon field_2108;
+ s8 field_216C;
+ u8 field_216D;
+ s8 field_216E;
+ s8 field_216F;
+ s8 field_2170;
+ s8 field_2171;
+ u16 field_2172;
+ u16 field_2174;
+ u16 field_2176[8];
+ u8 field_2186;
+ u8 field_2187;
+ u8 field_2188;
+ union
+ {
+ struct Pokemon *mon;
+ struct BoxPokemon *box;
+ } field_218C;
+ u8 field_2190[40];
+ u8 field_21B8[40];
+ u8 field_21E0[POKEMON_NAME_LENGTH + 1];
+ u8 itemName[20];
+ u8 inBoxMovingMode;
+ u16 field_2200;
+ struct UnkStorageStruct field_2204[3];
+ u16 movingItem;
+ u16 field_2236;
+ u8 field_2238;
+ u16 field_223A;
+ u16 *field_223C;
+ struct Sprite *cursorMonSprite;
+ u16 field_2244[0x40];
+ u8 field_22C4[0x800];
+ u8 field_2AC4[0x1800];
+ u8 field_42C4[0x800];
+ u8 field_4AC4[0x1000];
+ u8 field_5AC4[0x800];
+};
-extern u8 gUnknown_02039D00;
+struct UnkSubStruct_2039D84
+{
+ s16 field_0;
+ s16 field_2;
+ u16 field_4;
+ u16 field_6;
+ s16 field_8;
+ s16 field_A;
+};
+
+struct UnkStruct_2039D84
+{
+ struct UnkSubStruct_2039D84 field_0[2];
+ const void *field_18;
+ const void *field_1C;
+ u16 field_20;
+ u16 field_22;
+ u16 field_24;
+ u16 field_26;
+ u16 field_28;
+ u8 field_2A;
+ u8 field_2B;
+ u8 field_2C;
+ u8 field_2D;
+};
+
+enum
+{
+ BOX_OPTION_WITHDRAW,
+ BOX_OPTION_DEPOSIT,
+ BOX_OPTION_MOVE_MONS,
+ BOX_OPTION_MOVE_ITEMS,
+ BOX_OPTION_EXIT,
+};
+
+enum
+{
+ PC_TEXT_EXIT_BOX,
+ PC_TEXT_WHAT_YOU_DO,
+ PC_TEXT_PICK_A_THEME,
+ PC_TEXT_PICK_A_WALLPAPER,
+ PC_TEXT_IS_SELECTED,
+ PC_TEXT_JUMP_TO_WHICH_BOX,
+ PC_TEXT_DEPOSIT_IN_WHICH_BOX,
+ PC_TEXT_WAS_DEPOSITED,
+ PC_TEXT_BOX_IS_FULL,
+ PC_TEXT_RELEASE_POKE,
+ PC_TEXT_WAS_RELEASED,
+ PC_TEXT_BYE_BYE,
+ PC_TEXT_MARK_POKE,
+ PC_TEXT_LAST_POKE,
+ PC_TEXT_PARTY_FULL,
+ PC_TEXT_HOLDING_POKE,
+ PC_TEXT_WHICH_ONE_WILL_TAKE,
+ PC_TEXT_CANT_RELEASE_EGG,
+ PC_TEXT_CONTINUE_BOX,
+ PC_TEXT_CAME_BACK,
+ PC_TEXT_WORRIED,
+ PC_TEXT_SURPRISE,
+ PC_TEXT_PLEASE_REMOVE_MAIL,
+ PC_TEXT_IS_SELECTED2,
+ PC_TEXT_GIVE_TO_MON,
+ PC_TEXT_PLACED_IN_BAG,
+ PC_TEXT_BAG_FULL,
+ PC_TEXT_PUT_IN_BAG,
+ PC_TEXT_ITEM_IS_HELD,
+ PC_TEXT_CHANGED_TO_ITEM,
+ PC_TEXT_CANT_STORE_MAIL,
+};
+
+enum
+{
+ PC_TEXT_FMT_NORMAL,
+ PC_TEXT_FMT_MON_NAME_1,
+ PC_TEXT_FMT_MON_NAME_2,
+ PC_TEXT_FMT_MON_NAME_3,
+ PC_TEXT_FMT_MON_NAME_4,
+ PC_TEXT_FMT_MON_NAME_5,
+ PC_TEXT_FMT_MON_NAME_6,
+ PC_TEXT_FMT_ITEM_NAME,
+};
+
+enum
+{
+ SCREEN_CHANGE_EXIT_BOX,
+ SCREEN_CHANGE_SUMMARY_SCREEN,
+ SCREEN_CHANGE_NAME_BOX,
+ SCREEN_CHANGE_ITEM_FROM_BAG,
+};
+
+enum
+{
+ MODE_PARTY,
+ MODE_BOX,
+ MODE_2,
+};
+
+enum
+{
+ WALLPAPER_FOREST,
+ WALLPAPER_CITY,
+ WALLPAPER_DESERT,
+ WALLPAPER_SAVANNA,
+ WALLPAPER_CRAG,
+ WALLPAPER_VOLCANO,
+ WALLPAPER_SNOW,
+ WALLPAPER_CAVE,
+ WALLPAPER_BEACH,
+ WALLPAPER_SEAFLOOR,
+ WALLPAPER_RIVER,
+ WALLPAPER_SKY,
+ WALLPAPER_POLKADOT,
+ WALLPAPER_POKECENTER,
+ WALLPAPER_MACHINE,
+ WALLPAPER_PLAIN,
+ WALLPAPER_FRIENDS, // The one received as a gift from Walda's parents.
+ WALLPAPER_COUNT
+};
+
+enum
+{
+ FRIENDS_ZIGZAGOON,
+ FRIENDS_SCREEN,
+ FRIENDS_HORIZONTAL,
+ FRIENDS_DIAGONAL,
+ FRIENDS_BLOCK,
+ FRIENDS_RIBBON,
+ FRIENDS_POKECENTER2,
+ FRIENDS_FRAME,
+ FRIENDS_BLANK,
+ FRIENDS_CIRCLES,
+ FRIENDS_AZUMARILL,
+ FRIENDS_PIKACHU,
+ FRIENDS_LEGENDARY,
+ FRIENDS_DUSCLOPS,
+ FRIENDS_LUDICOLO,
+ FRIENDS_WHISCASH,
+ FRIENDS_WALLPAPERS_COUNT
+};
+
+enum
+{
+ CURSOR_AREA_IN_BOX,
+ CURSOR_AREA_IN_PARTY,
+ CURSOR_AREA_BOX,
+ CURSOR_AREA_BUTTONS, // Party Pokemon and Close Box
+};
+
+#define TAG_PAL_WAVEFORM 0xDACA
+#define TAG_PAL_DAC8 0xDAC8
+#define TAG_PAL_DAC6 0xDAC6
+#define TAG_PAL_DACE 0xDACE
+#define TAG_PAL_DAC7 0xDAC7
+#define TAG_PAL_DAC9 0xDAC9
+#define TAG_PAL_DAC0 0xDAC0
+#define TAG_PAL_DACB 0xDACB
+
+#define TAG_TILE_WAVEFORM 0x5
+#define TAG_TILE_10 0x10
+#define TAG_TILE_2 0x2
+#define TAG_TILE_D 0xD
+#define TAG_TILE_A 0xA
+#define TAG_TILE_3 0x3
+#define TAG_TILE_4 0x4
+#define TAG_TILE_12 0x12
+#define TAG_TILE_7 0x7
+#define TAG_TILE_0 0x0
+#define TAG_TILE_1 0x1
+
+// IWRAM bss
+IWRAM_DATA static u32 gUnknown_03000F78[98];
+
+// EWRAM DATA
+EWRAM_DATA static u8 sPreviousBoxOption = 0;
+EWRAM_DATA static struct UnkPSSStruct_2002370 *gUnknown_02039D04 = NULL;
+EWRAM_DATA static struct PokemonStorageSystemData *sPSSData = NULL;
+EWRAM_DATA static bool8 sInPartyMenu = 0;
+EWRAM_DATA static u8 sCurrentBoxOption = 0;
+EWRAM_DATA static u8 gUnknown_02039D0E = 0;
+EWRAM_DATA static u8 sWhichToReshow = 0;
+EWRAM_DATA static u8 gUnknown_02039D10 = 0;
+EWRAM_DATA static u16 gUnknown_02039D12 = 0;
+EWRAM_DATA static struct Pokemon gUnknown_02039D14 = {0};
+EWRAM_DATA static s8 sBoxCursorArea = 0;
+EWRAM_DATA static s8 sBoxCursorPosition = 0;
+EWRAM_DATA static bool8 sIsMonBeingMoved = 0;
+EWRAM_DATA static u8 sMovingMonOrigBoxId = 0;
+EWRAM_DATA static u8 sMovingMonOrigBoxPos = 0;
+EWRAM_DATA static bool8 sCanOnlyMove = 0;
+
+extern void sub_80F9BCC(u16, u16, u8);
+extern void sub_80F9BF4(u16, u16, u8);
+extern bool8 sub_80F9C1C(void);
+extern bool8 sub_80F9C30(void);
+extern void sub_80C6D80(u8 *arg0, void *arg1, u8 arg2, u8 arg3, s32 arg4);
+
+extern const struct CompressedSpriteSheet gMonFrontPicTable[];
// 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 PSS_MenuStringPtrs gUnknown_085716C0[] =
+static void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr);
+static void Cb2_EnterPSS(u8 boxOption);
+static u8 GetCurrentBoxOption(void);
+static u8 HandleInput(void);
+static u8 sub_80CDC2C(void);
+static u8 sub_80CB9BC(void);
+static void LoadWallpaperGfx(u8 boxId, s8 direction);
+static void sub_80CCCFC(u8 boxId, s8 direction);
+static void sub_80CD0B8(s8 direction);
+static void SetCurrentBox(u8 boxId);
+static void sub_80CC32C(u8 boxId);
+static void sub_80C7958(u8 curBox);
+static void sub_80CCAE0(void *arg0);
+static void sub_80C7B14(void);
+static void sub_80C7BB4(void);
+static void ScrollBackground(void);
+static void sub_80C7B80(void);
+static void sub_80C7BE4(void);
+static void sub_80CAA14(void);
+static void sub_80CFDC4(void);
+static void sub_80CE790(void);
+static void sub_80CE8E4(void);
+static void GiveChosenBagItem(void);
+static void SetUpHidePartyMenu(void);
+static void DestroyAllPartyMonIcons(void);
+static void sub_80D11CC(void);
+static void LoadPSSMenuGfx(void);
+static void LoadWaveformSpritePalette(void);
+static void sub_80CDC18(void);
+static void sub_80CD36C(void);
+static void sub_80CD3EC(void);
+static void sub_80CAC1C(void);
+static void sub_80CEBDC(void);
+static void SetScrollingBackground(void);
+static void sub_80CABE0(void);
+static void sub_80CAEAC(void);
+static void sub_80D0C60(void);
+static void sub_80CFEA8(void);
+static void sub_80CDC0C(void);
+static void sub_80CAF04(void);
+static void sub_80CA0D8(void);
+static void AddMenu(void);
+static void sub_80CE250(void);
+static void InitCanRelaseMonVars(void);
+static void sub_80D01B8(void);
+static void ReleaseMon(void);
+static void RefreshCursorMonData(void);
+static void LoadCursorMonSprite(void);
+static void sub_80CA154(void);
+static void sub_80CA1C4(void);
+static void sub_80CC064(void);
+static void sub_80CE324(void);
+static void ClearBottomWindow(void);
+static void sub_80CA704(void);
+static void sub_80D013C(void);
+static void sub_80CE00C(void);
+static void sub_80D1194(void);
+static void PrintCursorMonInfo(void);
+static void sub_80CA65C(void);
+static void AddWallpaperSetsMenu(void);
+static void sub_80CD02C(void);
+static void InitMenu(void);
+static void sub_80CD158(void);
+static void sub_80CFC14(void);
+static void sub_80CEB40(void);
+static void sub_80CCEE0(void);
+static void sub_80D1818(void);
+static void sub_80D19B4(u32 arg0);
+static void sub_80CAA74(void);
+static void PrintItemDescription(void);
+static void sub_80CE760(void);
+static void sub_80CDBA0(void);
+static void sub_80CE7E8(void);
+static void sub_80CFECC(void);
+static void sub_80CA9EC(void);
+static void FreePSSData(void);
+static void AddBoxMenu(void);
+static void sub_80CCF9C(void);
+static void MoveMon(void);
+static void PlaceMon(void);
+static void sub_80CAB20(void);
+static void sub_80CE22C(void);
+static void sub_80CDA68(void);
+static void sub_80CB950(void);
+static void sub_80CA9C0(void);
+static void SetUpDoShowPartyMenu(void);
+static void BoxSetMosaic(void);
+static void sub_80C7CF4(struct Sprite *sprite);
+static void sub_80CC100(struct Sprite *sprite);
+static void sub_80CB278(struct Sprite *sprite);
+static void sub_80CD210(struct Sprite *sprite);
+static bool32 WaitForWallpaperGfxLoad(void);
+static bool8 InitPSSWindows(void);
+static bool8 sub_80CC0A0(void);
+static bool8 sub_80CE2A8(void);
+static bool8 sub_80D0164(void);
+static bool8 sub_80CC35C(void);
+static bool8 sub_80D01E4(void);
+static bool8 sub_80CDED4(void);
+static bool8 sub_80CDF08(void);
+static bool8 sub_80D184C(void);
+static bool8 sub_80D18E4(void);
+static bool8 DoShowPartyMenu(void);
+static bool8 sub_80D1218(void);
+static bool8 ScrollToBox(void);
+static bool8 sub_80CD554(void);
+static bool8 HidePartyMenu(void);
+static bool8 IsActiveItemMoving(void);
+static bool8 sub_80D0580(u8 arg0);
+static bool8 sub_80D0BC0(void);
+static bool8 sub_80CA2B8(void);
+static bool8 DoWallpaperGfxChange(void);
+static bool8 DoMonPlaceChange(void);
+static bool8 sub_80D00A8(void);
+static bool8 CanMovePartyMon(void);
+static bool8 CanShiftMon(void);
+static bool8 IsCursorOnCloseBox(void);
+static bool8 IsCursorOnBox(void);
+static bool8 IsCursorInBox(void);
+static bool8 IsMonBeingMoved(void);
+static bool8 TryStorePartyMonInBox(u8 boxId);
+static void Cb_InitPSS(u8 taskId);
+static void Cb_PlaceMon(u8 taskId);
+static void Cb_ChangeScreen(u8 taskId);
+static void Cb_ShowPSS(u8 taskId);
+static void Cb_OnBPressed(u8 taskId);
+static void Cb_HandleBoxOptions(u8 taskId);
+static void Cb_OnSelectedMon(u8 taskId);
+static void Cb_OnCloseBoxPressed(u8 taskId);
+static void Cb_HidePartyPokemon(u8 taskId);
+static void Cb_DepositMenu(u8 taskId);
+static void Cb_MoveMon(u8 taskId);
+static void Cb_GiveMovingItemToMon(u8 taskId);
+static void Cb_SwitchSelectedItem(u8 taskId);
+static void Cb_TakeItemForMoving(u8 taskId);
+static void Cb_WithdrawMon(u8 taskId);
+static void Cb_ShiftMon(u8 taskId);
+static void Cb_ShowPartyPokemon(u8 taskId);
+static void Cb_ShowItemInfo(u8 taskId);
+static void Cb_GiveItemFromBag(u8 taskId);
+static void Cb_ItemToBag(u8 taskId);
+static void Cb_TakeItemForMoving(u8 taskId);
+static void Cb_ShowMarkMenu(u8 taskId);
+static void Cb_ShowMonSummary(u8 taskId);
+static void Cb_ReleaseMon(u8 taskId);
+static void Cb_ReshowPSS(u8 taskId);
+static void Cb_MainPSS(u8 taskId);
+static void Cb_JumpBox(u8 taskId);
+static void Cb_HandleWallpapers(u8 taskId);
+static void Cb_NameBox(u8 taskId);
+static void Cb_PrintCantStoreMail(u8 taskId);
+static void Cb_HandleMovingMonFromParty(u8 taskId);
+static void SetUpScrollToBox(u8 boxId);
+static void sub_80CFE54(u8 animNum);
+static void SetMovingMonPriority(u8 priority);
+static void InitMonPlaceChange(u8 arg0);
+static void SetMonMarkings(u8 markings);
+static void ShowYesNoWindow(s8 cursorPos);
+static void sub_80CDBF8(u8 cursorBoxPosition);
+static void sub_80D01D0(u8 arg0);
+static void sub_80CD1A8(bool8 arg0);
+static void sub_80CA984(bool8 arg0);
+static void CreatePartyMonsSprites(bool8 arg0);
+static void PrintStorageActionText(u8 id);
+static s16 sub_80D00AC(void);
+static s8 RunCanReleaseMon(void);
+static u8 GetBoxCursorPosition(void);
+static void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos);
+static void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos);
+static void Item_TakeMons(u8 cursorArea, u8 cursorPos);
+static void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos);
+static struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority);
+static void SetWallpaperForCurrentBox(u8 wallpaperId);
+static void AddWallpapersMenu(u8 wallpaperSet);
+static u16 GetMovingItem(void);
+static void LoadCursorMonGfx(u16 species, u32 pid);
+static void sub_80CA2D0(struct Sprite *sprite);
+static void sub_80CCF64(struct Sprite *sprite);
+static void sub_80CBA3C(struct Sprite *sprite);
+static void sub_80CCF30(struct Sprite *sprite);
+static void sub_80CBAF0(s16 yDelta);
+static void sub_80CAAA8(u8 arg0, bool8 isPartyMon);
+static const u8 *GetMovingItemName(void);
+static void SetMenuText(u8 textId);
+static void sub_80D0D8C(u8 cursorArea, u8 cursorPos);
+static void sub_80D0E50(u8 cursorArea, u8 cursorPos);
+static void sub_80D0F38(u16 item);
+static struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 oamPriority, u8 subpriority);
+static void DestroyBoxMonIcon(struct Sprite *sprite);
+static void SetBoxSpeciesAndPersonalities(u8 boxId);
+static void sub_80CB9D0(struct Sprite *sprite, u16 partyId);
+static void sub_80CC370(u8 taskId);
+static void sub_80CCB50(u8 boxId);
+static s8 sub_80CC644(u8 boxId);
+static void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2);
+static s16 sub_80CD00C(const u8 *string);
+static bool8 MonPlaceChange_Shift(void);
+static bool8 MonPlaceChange_Move(void);
+static bool8 MonPlaceChange_Place(void);
+static bool8 sub_80CDEC4(void);
+static bool8 sub_80CDEB4(void);
+static void sub_80CD444(u8 cursorArea, u8 cursorPosition, u16 *x, u16 *y);
+static void SetShiftedMonData(u8 boxId, u8 position);
+static void SetMovedMonData(u8 boxId, u8 position);
+static void SetPlacedMonData(u8 boxId, u8 position);
+static void PurgeMonOrBoxMon(u8 boxId, u8 position);
+static void SetCursorMonData(void *pokemon, u8 mode);
+static bool32 AtLeastThreeUsableMons(void);
+static u8 InBoxInput_Normal(void);
+static u8 InBoxInput_MovingMultiple(void);
+static u8 InBoxInput_GrabbingMultiple(void);
+static s8 sub_80CFF98(u8 arg0);
+static u8 sub_80CFA5C(void);
+static u8 sub_80D0BA4(void);
+static bool8 sub_80CFA84(void);
+static bool8 sub_80CFB44(void);
+static bool8 sub_80D024C(void);
+static bool8 sub_80D0344(void);
+static bool8 sub_80D03B0(void);
+static bool8 sub_80D0420(void);
+static bool8 sub_80D04A0(void);
+static bool8 sub_80D04C8(void);
+static void sub_80D07B0(u8 arg0, u8 arg1);
+static void sub_80D0834(u8 arg0, u8 arg1);
+static void sub_80D0B5C(void);
+static void sub_80D062C(void);
+static void sub_80D0884(u16 arg0, u16 arg1, u16 arg2);
+static void sub_80D08CC(void);
+static void sub_80D09A4(void);
+static void sub_80D0A1C(void);
+static void sub_80D0AAC(void);
+static u8 sub_80D0894(void);
+static void sub_80D0778(u8 arg0, u8 arg1, u8 arg2);
+static void sub_80D0708(u8 arg0, u8 arg1, u8 arg2);
+static void sub_80D06D0(u8 arg0, u8 arg1, u8 arg2);
+static void sub_80D0740(u8 arg0, u8 arg1, u8 arg2);
+static void sub_80D27AC(u8 id, u16 arg1, u16 arg2, u16 arg3, u16 arg4);
+static void sub_80D27F4(u8 id, u8 arg1, s8 arg2);
+static void sub_80D2644(u8 id, u8 bg, const void *arg2, u16 arg3, u16 arg4);
+static void sub_80D2770(u8 id, u16 arg1, u16 arg2);
+static void sub_80D259C(u8 count);
+static void sub_80D25F0(void);
+static void sub_80D2918(u8 id);
+static void sub_80D2960(u8 id);
+static void sub_80D29F8(u8 id);
+static void sub_80D2A90(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2);
+static void sub_80D2AA4(void);
+static void sub_80D2B88(struct UnkStruct_2000028 *unkStruct);
+static void sub_80D2C1C(struct UnkStruct_2000028 *unkStruct);
+
+// static const rom data
+static const struct PSS_MenuStringPtrs gUnknown_085716C0[] =
{
{gText_WithdrawPokemon, gText_WithdrawMonDescription},
{gText_DepositPokemon, gText_DepositMonDescription},
@@ -58,7 +731,16 @@ const struct PSS_MenuStringPtrs gUnknown_085716C0[] =
{gText_SeeYa, gText_SeeYaDescription}
};
-const struct WindowTemplate gUnknown_085716E8 = {0, 1, 1, 0x11, 0xA, 0xF, 1};
+static const struct WindowTemplate gUnknown_085716E8 =
+{
+ .bg = 0,
+ .tilemapLeft = 1,
+ .tilemapTop = 1,
+ .width = 17,
+ .height = 10,
+ .paletteNum = 15,
+ .baseBlock = 0x1,
+};
static const union AnimCmd sSpriteAnim_85716F0[] =
{
@@ -84,7 +766,7 @@ static const union AnimCmd sSpriteAnim_8571708[] =
ANIMCMD_END
};
-const union AnimCmd *const sSpriteAnimTable_8571710[] =
+static const union AnimCmd *const sSpriteAnimTable_8571710[] =
{
sSpriteAnim_85716F0,
sSpriteAnim_85716F8,
@@ -103,12 +785,765 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_8571730[] =
sSpriteAffineAnim_8571720
};
-const u8 gUnknown_08571734[] = {4, 0xF, 0xE};
-const u8 gUnknown_08571737[] = _("/30");
+static const u8 gUnknown_08571734[] = {4, 0xF, 0xE};
+static const u8 gUnknown_08571737[] = _("/30");
+
+static const u16 gBoxSelectionPopupPalette[] = INCBIN_U16("graphics/unknown/unknown_57173C.gbapal");
+static const u8 gBoxSelectionPopupCenterTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_center.4bpp");
+static const u8 gBoxSelectionPopupSidesTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp");
+static const u32 gPokemonStorageScrollingBGTileset[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.4bpp.lz");
+static const u32 gPokemonStorageScrollingBGTilemap[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.bin.lz");
+static const u32 gUnknown_08572280[] = INCBIN_U32("graphics/unknown/unknown_572280.gbapal");
+static const u32 gUnknown_085722A0[] = INCBIN_U32("graphics/unknown/unknown_5722A0.bin.lz");
+
+static const u16 gUnknown_0857239C[] =
+{
+ 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0x0108, 0x0111, 0x0112, 0x0113, 0x0114, 0x0115, 0x0116, 0x0117, 0x0118,
+ 0x2101, 0x2102, 0x2103, 0x2104, 0x2105, 0x2106, 0x2107, 0x2108, 0x2111, 0x2112, 0x2113, 0x2114, 0x2115, 0x2116, 0x2117, 0x2118,
+};
+
+static const u16 gUnknown_085723DC[] = INCBIN_U16("graphics/unknown/unknown_5723DC.gbapal"); // Left-most part and Close Box.
+static const u16 gUnknown_085723FC[] = INCBIN_U16("graphics/unknown/unknown_5723FC.gbapal");
+static const u16 gUnknown_0857241C[] = INCBIN_U16("graphics/unknown/unknown_57241C.gbapal");
+static const u16 gUnknown_0857243C[] = INCBIN_U16("graphics/unknown/unknown_57243C.gbapal");
+
+static const u16 gUnknown_0857245C[] =
+{
+ 0x014c, 0x014d, 0x014e, 0x014f, 0x0170, 0x0171, 0x0172, 0x0173, 0x0174, 0x015c, 0x015d, 0x015e, 0x015f, 0x0180, 0x0181, 0x0182,
+ 0x0183, 0x0184, 0x0175, 0x0176, 0x0177, 0x0178, 0x0179, 0x017a, 0x017b, 0x017c, 0x017d, 0x0185, 0x0186, 0x0187, 0x0188, 0x0189,
+ 0x018a, 0x018b, 0x018c, 0x018d
+};
+static const u16 gUnknown_085724A4[] =
+{
+ 0x1140, 0x1141, 0x1141, 0x1142, 0x1150, 0x1151, 0x1151, 0x1152, 0x1160, 0x1161, 0x1161, 0x1162,
+};
+static const u16 gUnknown_085724BC[] =
+{
+ 0x1143, 0x1144, 0x1144, 0x1145, 0x1153, 0x1154, 0x1154, 0x1155, 0x1163, 0x1164, 0x1164, 0x1165,
+};
+
+static const u16 gWaveformPalette[] = INCBIN_U16("graphics/pokemon_storage/waveform.gbapal");
+static const u32 gWaveformTiles[] = INCBIN_U32("graphics/pokemon_storage/waveform.4bpp");
+static const u32 gUnknown_085726B4[] = INCBIN_U32("graphics/unused/unknown_5726B4.gbapal");
+static const u32 gUnknown_085726F4[] = INCBIN_U32("graphics/unknown/unknown_5726F4.gbapal");
+
+static const struct WindowTemplate gUnknown_08572714[] =
+{
+ { // 0
+ .bg = 1,
+ .tilemapLeft = 0,
+ .tilemapTop = 11,
+ .width = 9,
+ .height = 7,
+ .paletteNum = 3,
+ .baseBlock = 0xC0,
+ },
+ { // 1
+ .bg = 0,
+ .tilemapLeft = 11,
+ .tilemapTop = 17,
+ .width = 18,
+ .height = 2,
+ .paletteNum = 15,
+ .baseBlock = 0x14,
+ },
+ { // 2
+ .bg = 0,
+ .tilemapLeft = 0,
+ .tilemapTop = 13,
+ .width = 21,
+ .height = 7,
+ .paletteNum = 15,
+ .baseBlock = 0x14,
+ },
+ DUMMY_WIN_TEMPLATE
+};
+
+static const struct BgTemplate gUnknown_08572734[] =
+{
+ {
+ .bg = 0,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 29,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 0,
+ .baseTile = 0
+ },
+ {
+ .bg = 1,
+ .charBaseIndex = 1,
+ .mapBaseIndex = 30,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 1,
+ .baseTile = 0x100
+ },
+ {
+ .bg = 2,
+ .charBaseIndex = 2,
+ .mapBaseIndex = 27,
+ .screenSize = 1,
+ .paletteMode = 0,
+ .priority = 2,
+ .baseTile = 0
+ },
+ {
+ .bg = 3,
+ .charBaseIndex = 3,
+ .mapBaseIndex = 31,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 3,
+ .baseTile = 0
+ },
+};
+
+static const struct SpritePalette gWaveformSpritePalette =
+{
+ gWaveformPalette, TAG_PAL_WAVEFORM
+};
+
+static const struct SpriteSheet gWaveformSpriteSheet =
+{
+ gWaveformTiles, sizeof(gWaveformTiles), TAG_TILE_WAVEFORM
+};
+
+static const struct OamData sOamData_857286C;
+static const struct SpriteTemplate sSpriteTemplate_CursorMon =
+{
+ .tileTag = TAG_TILE_2,
+ .paletteTag = TAG_PAL_DAC6,
+ .oam = &sOamData_857286C,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+static const struct StorageAction gPCStorageActionTexts[] =
+{
+ [PC_TEXT_EXIT_BOX] = {gText_ExitFromBox, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_WHAT_YOU_DO] = {gText_WhatDoYouWantToDo, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_PICK_A_THEME] = {gText_PleasePickATheme, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_PICK_A_WALLPAPER] = {gText_PickTheWallpaper, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_IS_SELECTED] = {gText_PkmnIsSelected, PC_TEXT_FMT_MON_NAME_1},
+ [PC_TEXT_JUMP_TO_WHICH_BOX] = {gText_JumpToWhichBox, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_DEPOSIT_IN_WHICH_BOX] = {gText_DepositInWhichBox, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_WAS_DEPOSITED] = {gText_PkmnWasDeposited, PC_TEXT_FMT_MON_NAME_1},
+ [PC_TEXT_BOX_IS_FULL] = {gText_BoxIsFull2, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_RELEASE_POKE] = {gText_ReleaseThisPokemon, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_WAS_RELEASED] = {gText_PkmnWasReleased, PC_TEXT_FMT_MON_NAME_4},
+ [PC_TEXT_BYE_BYE] = {gText_ByeByePkmn, PC_TEXT_FMT_MON_NAME_6},
+ [PC_TEXT_MARK_POKE] = {gText_MarkYourPkmn, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_LAST_POKE] = {gText_ThatsYourLastPkmn, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_PARTY_FULL] = {gText_YourPartysFull, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_HOLDING_POKE] = {gText_YoureHoldingAPkmn, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_WHICH_ONE_WILL_TAKE] = {gText_WhichOneWillYouTake, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_CANT_RELEASE_EGG] = {gText_YouCantReleaseAnEgg, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_CONTINUE_BOX] = {gText_ContinueBoxOperations, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_CAME_BACK] = {gText_PkmnCameBack, PC_TEXT_FMT_MON_NAME_1},
+ [PC_TEXT_WORRIED] = {gText_WasItWorriedAboutYou, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_SURPRISE] = {gText_FourEllipsesExclamation, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_PLEASE_REMOVE_MAIL] = {gText_PleaseRemoveTheMail, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_IS_SELECTED2] = {gText_PkmnIsSelected, PC_TEXT_FMT_ITEM_NAME},
+ [PC_TEXT_GIVE_TO_MON] = {gText_GiveToAPkmn, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_PLACED_IN_BAG] = {gText_PlacedItemInBag, PC_TEXT_FMT_ITEM_NAME},
+ [PC_TEXT_BAG_FULL] = {gText_BagIsFull2, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_PUT_IN_BAG] = {gText_PutItemInBag, PC_TEXT_FMT_NORMAL},
+ [PC_TEXT_ITEM_IS_HELD] = {gText_ItemIsNowHeld, PC_TEXT_FMT_ITEM_NAME},
+ [PC_TEXT_CHANGED_TO_ITEM] = {gText_ChangedToNewItem, PC_TEXT_FMT_ITEM_NAME},
+ [PC_TEXT_CANT_STORE_MAIL] = {gText_MailCantBeStored, PC_TEXT_FMT_NORMAL},
+};
+
+static const struct WindowTemplate sYesNoWindowTemplate =
+{
+ .bg = 0,
+ .tilemapLeft = 24,
+ .tilemapTop = 11,
+ .width = 5,
+ .height = 4,
+ .paletteNum = 15,
+ .baseBlock = 0x5C,
+};
+
+static const struct OamData sOamData_857286C =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 0,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 3,
+ .tileNum = 0,
+ .priority = 0,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const struct OamData sOamData_8572874 =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 1,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 0,
+ .tileNum = 0,
+ .priority = 0,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const union AnimCmd sSpriteAnim_857287C[] =
+{
+ ANIMCMD_FRAME(0, 5),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_8572884[] =
+{
+ ANIMCMD_FRAME(2, 8),
+ ANIMCMD_FRAME(4, 8),
+ ANIMCMD_FRAME(6, 8),
+ ANIMCMD_JUMP(0)
+};
+
+static const union AnimCmd sSpriteAnim_8572894[] =
+{
+ ANIMCMD_FRAME(8, 5),
+ ANIMCMD_END
+};
+
+static const union AnimCmd sSpriteAnim_857289C[] =
+{
+ ANIMCMD_FRAME(10, 8),
+ ANIMCMD_FRAME(4, 8),
+ ANIMCMD_FRAME(12, 8),
+ ANIMCMD_JUMP(0)
+};
+
+static const union AnimCmd *const sSpriteAnimTable_85728AC[] =
+{
+ sSpriteAnim_857287C,
+ sSpriteAnim_8572884,
+ sSpriteAnim_8572894,
+ sSpriteAnim_857289C
+};
+
+static const struct SpriteTemplate sSpriteTemplate_Waveform =
+{
+ .tileTag = TAG_TILE_WAVEFORM,
+ .paletteTag = TAG_PAL_WAVEFORM,
+ .oam = &sOamData_8572874,
+ .anims = sSpriteAnimTable_85728AC,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+static const struct OamData sOamData_85728EC;
+static const struct SpriteTemplate gUnknown_085728D4 =
+{
+ .tileTag = TAG_TILE_12,
+ .paletteTag = TAG_PAL_DAC0,
+ .oam = &sOamData_85728EC,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+};
+
+static const struct OamData sOamData_85728EC =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 0,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 2,
+ .tileNum = 0,
+ .priority = 0,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const union AffineAnimCmd gSpriteAffineAnim_85728F4[] =
+{
+ AFFINEANIMCMD_FRAME(-2, -2, 0, 120),
+ AFFINEANIMCMD_END
+};
+
+static const union AffineAnimCmd gSpriteAffineAnim_8572904[] =
+{
+ AFFINEANIMCMD_FRAME(16, 16, 0, 0),
+ AFFINEANIMCMD_FRAME(16, 16, 0, 15),
+ AFFINEANIMCMD_END
+};
+
+static const union AffineAnimCmd *const gSpriteAffineAnimTable_857291C[] =
+{
+ gSpriteAffineAnim_85728F4,
+ gSpriteAffineAnim_8572904
+};
+
+static const u16 gWallpaperPalettes_Forest[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/forest_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/forest_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Forest[] = INCBIN_U32("graphics/pokemon_storage/forest.4bpp.lz");
+static const u32 gWallpaperTilemap_Forest[] = INCBIN_U32("graphics/pokemon_storage/forest.bin.lz");
+
+static const u16 gWallpaperPalettes_City[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/city_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/city_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_City[] = INCBIN_U32("graphics/pokemon_storage/city.4bpp.lz");
+static const u32 gWallpaperTilemap_City[] = INCBIN_U32("graphics/pokemon_storage/city.bin.lz");
+
+static const u16 gWallpaperPalettes_Desert[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/desert_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/desert_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Desert[] = INCBIN_U32("graphics/pokemon_storage/desert.4bpp.lz");
+static const u32 gWallpaperTilemap_Desert[] = INCBIN_U32("graphics/pokemon_storage/desert.bin.lz");
+
+static const u16 gWallpaperPalettes_Savanna[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/savanna_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/savanna_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Savanna[] = INCBIN_U32("graphics/pokemon_storage/savanna.4bpp.lz");
+static const u32 gWallpaperTilemap_Savanna[] = INCBIN_U32("graphics/pokemon_storage/savanna.bin.lz");
+
+static const u16 gWallpaperPalettes_Crag[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/crag_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/crag_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Crag[] = INCBIN_U32("graphics/pokemon_storage/crag.4bpp.lz");
+static const u32 gWallpaperTilemap_Crag[] = INCBIN_U32("graphics/pokemon_storage/crag.bin.lz");
+
+static const u16 gWallpaperPalettes_Volcano[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/volcano_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/volcano_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Volcano[] = INCBIN_U32("graphics/pokemon_storage/volcano.4bpp.lz");
+static const u32 gWallpaperTilemap_Volcano[] = INCBIN_U32("graphics/pokemon_storage/volcano.bin.lz");
+
+static const u16 gWallpaperPalettes_Snow[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/snow_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/snow_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Snow[] = INCBIN_U32("graphics/pokemon_storage/snow.4bpp.lz");
+static const u32 gWallpaperTilemap_Snow[] = INCBIN_U32("graphics/pokemon_storage/snow.bin.lz");
+
+static const u16 gWallpaperPalettes_Cave[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/cave_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/cave_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Cave[] = INCBIN_U32("graphics/pokemon_storage/cave.4bpp.lz");
+static const u32 gWallpaperTilemap_Cave[] = INCBIN_U32("graphics/pokemon_storage/cave.bin.lz");
+
+static const u16 gWallpaperPalettes_Beach[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/beach_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/beach_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Beach[] = INCBIN_U32("graphics/pokemon_storage/beach.4bpp.lz");
+static const u32 gWallpaperTilemap_Beach[] = INCBIN_U32("graphics/pokemon_storage/beach.bin.lz");
+
+static const u16 gWallpaperPalettes_Seafloor[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/seafloor_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/seafloor_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Seafloor[] = INCBIN_U32("graphics/pokemon_storage/seafloor.4bpp.lz");
+static const u32 gWallpaperTilemap_Seafloor[] = INCBIN_U32("graphics/pokemon_storage/seafloor.bin.lz");
+
+static const u16 gWallpaperPalettes_River[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/river_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/river_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_River[] = INCBIN_U32("graphics/pokemon_storage/river.4bpp.lz");
+static const u32 gWallpaperTilemap_River[] = INCBIN_U32("graphics/pokemon_storage/river.bin.lz");
+static const u16 gWallpaperPalettes_Sky[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/sky_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/sky_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Sky[] = INCBIN_U32("graphics/pokemon_storage/sky.4bpp.lz");
+static const u32 gWallpaperTilemap_Sky[] = INCBIN_U32("graphics/pokemon_storage/sky.bin.lz");
+
+static const u16 gWallpaperPalettes_PolkaDot[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/polkadot_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/polkadot_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_PolkaDot[] = INCBIN_U32("graphics/pokemon_storage/polkadot.4bpp.lz");
+static const u32 gWallpaperTilemap_PolkaDot[] = INCBIN_U32("graphics/pokemon_storage/polkadot.bin.lz");
+
+static const u16 gWallpaperPalettes_Pokecenter[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/pokecenter_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/pokecenter_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Pokecenter[] = INCBIN_U32("graphics/pokemon_storage/pokecenter.4bpp.lz");
+static const u32 gWallpaperTilemap_Pokecenter[] = INCBIN_U32("graphics/pokemon_storage/pokecenter.bin.lz");
+
+static const u16 gWallpaperPalettes_Machine[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/machine_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/machine_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Machine[] = INCBIN_U32("graphics/pokemon_storage/machine.4bpp.lz");
+static const u32 gWallpaperTilemap_Machine[] = INCBIN_U32("graphics/pokemon_storage/machine.bin.lz");
+
+static const u16 gWallpaperPalettes_Plain[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/plain_frame.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/plain_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Plain[] = INCBIN_U32("graphics/pokemon_storage/plain.4bpp.lz");
+static const u32 gWallpaperTilemap_Plain[] = INCBIN_U32("graphics/pokemon_storage/plain.bin.lz");
+
+// 12×18 tilemap
+static const u32 gUnknown_085773C4[] = INCBIN_U32("graphics/unused/tilemap_5773C4.bin");
+
+static const u16 gUnknown_08577574[][2] =
+{
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF},
+ {0x1CE7, 0x7FFF}
+};
+
+#define WALLPAPER_ENTRY(name) {gWallpaperTiles_##name, gWallpaperTilemap_##name, gWallpaperPalettes_##name[0]}
+
+static const struct WallpaperTable gWallpaperTable[] =
+{
+ [WALLPAPER_FOREST] = WALLPAPER_ENTRY(Forest),
+ [WALLPAPER_CITY] = WALLPAPER_ENTRY(City),
+ [WALLPAPER_DESERT] = WALLPAPER_ENTRY(Desert),
+ [WALLPAPER_SAVANNA] = WALLPAPER_ENTRY(Savanna),
+ [WALLPAPER_CRAG] = WALLPAPER_ENTRY(Crag),
+ [WALLPAPER_VOLCANO] = WALLPAPER_ENTRY(Volcano),
+ [WALLPAPER_SNOW] = WALLPAPER_ENTRY(Snow),
+ [WALLPAPER_CAVE] = WALLPAPER_ENTRY(Cave),
+ [WALLPAPER_BEACH] = WALLPAPER_ENTRY(Beach),
+ [WALLPAPER_SEAFLOOR] = WALLPAPER_ENTRY(Seafloor),
+ [WALLPAPER_RIVER] = WALLPAPER_ENTRY(River),
+ [WALLPAPER_SKY] = WALLPAPER_ENTRY(Sky),
+ [WALLPAPER_POLKADOT] = WALLPAPER_ENTRY(PolkaDot),
+ [WALLPAPER_POKECENTER] = WALLPAPER_ENTRY(Pokecenter),
+ [WALLPAPER_MACHINE] = WALLPAPER_ENTRY(Machine),
+ [WALLPAPER_PLAIN] = WALLPAPER_ENTRY(Plain),
+};
+
+static const u8 gPCGfx_Arrow[] = INCBIN_U8("graphics/pokemon_storage/arrow.4bpp");
+
+static const u16 gWallpaperPalettes_Zigzagoon[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/zigzagoon_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Zigzagoon[] = INCBIN_U32("graphics/pokemon_storage/zigzagoon.4bpp.lz");
+static const u32 gWallpaperTilemap_Zigzagoon[] = INCBIN_U32("graphics/pokemon_storage/zigzagoon.bin.lz");
+
+static const u16 gWallpaperPalettes_Screen[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/screen_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Screen[] = INCBIN_U32("graphics/pokemon_storage/screen.4bpp.lz");
+static const u32 gWallpaperTilemap_Screen[] = INCBIN_U32("graphics/pokemon_storage/screen.bin.lz");
+
+static const u16 gWallpaperPalettes_Diagonal[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/diagonal_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Diagonal[] = INCBIN_U32("graphics/pokemon_storage/diagonal.4bpp.lz");
+static const u32 gWallpaperTilemap_Diagonal[] = INCBIN_U32("graphics/pokemon_storage/diagonal.bin.lz");
+
+static const u16 gWallpaperPalettes_Block[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/block_bg.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/block_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Block[] = INCBIN_U32("graphics/pokemon_storage/block.4bpp.lz");
+static const u32 gWallpaperTilemap_Block[] = INCBIN_U32("graphics/pokemon_storage/block.bin.lz");
+
+static const u16 gWallpaperPalettes_Pokecenter2[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/pokecenter2_bg.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/pokecenter2_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Pokecenter2[] = INCBIN_U32("graphics/pokemon_storage/pokecenter2.4bpp.lz");
+static const u32 gWallpaperTilemap_Pokecenter2[] = INCBIN_U32("graphics/pokemon_storage/pokecenter2.bin.lz");
+
+static const u16 gWallpaperPalettes_Frame[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/frame_bg.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/frame_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Frame[] = INCBIN_U32("graphics/pokemon_storage/frame.4bpp.lz");
+static const u32 gWallpaperTilemap_Frame[] = INCBIN_U32("graphics/pokemon_storage/frame.bin.lz");
+
+static const u16 gWallpaperPalettes_Blank[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/zigzagoon_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Blank[] = INCBIN_U32("graphics/pokemon_storage/blank.4bpp.lz");
+static const u32 gWallpaperTilemap_Blank[] = INCBIN_U32("graphics/pokemon_storage/blank.bin.lz");
+
+static const u16 gWallpaperPalettes_Circles[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/circles_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Circles[] = INCBIN_U32("graphics/pokemon_storage/circles.4bpp.lz");
+static const u32 gWallpaperTilemap_Circles[] = INCBIN_U32("graphics/pokemon_storage/circles.bin.lz");
+
+static const u16 gWallpaperPalettes_Azumarill[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/azumarill_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Azumarill[] = INCBIN_U32("graphics/pokemon_storage/azumarill.4bpp.lz");
+static const u32 gWallpaperTilemap_Azumarill[] = INCBIN_U32("graphics/pokemon_storage/azumarill.bin.lz");
+
+static const u16 gWallpaperPalettes_Pikachu[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/pikachu_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Pikachu[] = INCBIN_U32("graphics/pokemon_storage/pikachu.4bpp.lz");
+static const u32 gWallpaperTilemap_Pikachu[] = INCBIN_U32("graphics/pokemon_storage/pikachu.bin.lz");
+
+static const u16 gWallpaperPalettes_Legendary[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/legendary_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Legendary[] = INCBIN_U32("graphics/pokemon_storage/legendary.4bpp.lz");
+static const u32 gWallpaperTilemap_Legendary[] = INCBIN_U32("graphics/pokemon_storage/legendary.bin.lz");
+
+static const u16 gWallpaperPalettes_Dusclops[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/dusclops_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Dusclops[] = INCBIN_U32("graphics/pokemon_storage/dusclops.4bpp.lz");
+static const u32 gWallpaperTilemap_Dusclops[] = INCBIN_U32("graphics/pokemon_storage/dusclops.bin.lz");
+
+static const u16 gWallpaperPalettes_Ludicolo[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/ludicolo_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Ludicolo[] = INCBIN_U32("graphics/pokemon_storage/ludicolo.4bpp.lz");
+static const u32 gWallpaperTilemap_Ludicolo[] = INCBIN_U32("graphics/pokemon_storage/ludicolo.bin.lz");
+
+static const u16 gWallpaperPalettes_Whiscash[][16] =
+{
+ INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"),
+ INCBIN_U16("graphics/pokemon_storage/whiscash_bg.gbapal"),
+};
+static const u32 gWallpaperTiles_Whiscash[] = INCBIN_U32("graphics/pokemon_storage/whiscash.4bpp.lz");
+static const u32 gWallpaperTilemap_Whiscash[] = INCBIN_U32("graphics/pokemon_storage/whiscash.bin.lz");
+
+static const u32 gWallpaperIcon_Aqua[] = INCBIN_U32("graphics/pokemon_storage/aqua_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Heart[] = INCBIN_U32("graphics/pokemon_storage/heart_icon.4bpp.lz");
+static const u32 gWallpaperIcon_FiveStar[] = INCBIN_U32("graphics/pokemon_storage/five_star_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Brick[] = INCBIN_U32("graphics/pokemon_storage/brick_icon.4bpp.lz");
+static const u32 gWallpaperIcon_FourStar[] = INCBIN_U32("graphics/pokemon_storage/four_star_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Asterisk[] = INCBIN_U32("graphics/pokemon_storage/asterisk_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Dot[] = INCBIN_U32("graphics/pokemon_storage/dot_icon.4bpp.lz");
+static const u32 gWallpaperIcon_LineCircle[] = INCBIN_U32("graphics/pokemon_storage/line_circle_icon.4bpp.lz");
+static const u32 gWallpaperIcon_PokeBall[] = INCBIN_U32("graphics/pokemon_storage/pokeball_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Maze[] = INCBIN_U32("graphics/pokemon_storage/maze_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Footprint[] = INCBIN_U32("graphics/pokemon_storage/footprint_icon.4bpp.lz");
+static const u32 gWallpaperIcon_BigAsterisk[] = INCBIN_U32("graphics/pokemon_storage/big_asterisk_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Circle[] = INCBIN_U32("graphics/pokemon_storage/circle_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Koffing[] = INCBIN_U32("graphics/pokemon_storage/koffing_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Ribbon[] = INCBIN_U32("graphics/pokemon_storage/ribbon_icon.4bpp.lz");
+static const u32 gWallpaperIcon_FourCircles[] = INCBIN_U32("graphics/pokemon_storage/four_circles_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Lotad[] = INCBIN_U32("graphics/pokemon_storage/lotad_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Crystal[] = INCBIN_U32("graphics/pokemon_storage/crystal_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Pichu[] = INCBIN_U32("graphics/pokemon_storage/pichu_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Diglett[] = INCBIN_U32("graphics/pokemon_storage/diglett_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Luvdisc[] = INCBIN_U32("graphics/pokemon_storage/luvdisc_icon.4bpp.lz");
+static const u32 gWallpaperIcon_StarInCircle[] = INCBIN_U32("graphics/pokemon_storage/star_in_circle_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Spinda[] = INCBIN_U32("graphics/pokemon_storage/spinda_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Latis[] = INCBIN_U32("graphics/pokemon_storage/latis_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Minun[] = INCBIN_U32("graphics/pokemon_storage/minun_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Togepi[] = INCBIN_U32("graphics/pokemon_storage/togepi_icon.4bpp.lz");
+static const u32 gWallpaperIcon_Magma[] = INCBIN_U32("graphics/pokemon_storage/magma_icon.4bpp.lz");
+
+static const struct WallpaperTable gFriendsWallpaperTable[] =
+{
+ WALLPAPER_ENTRY(Zigzagoon),
+ WALLPAPER_ENTRY(Screen),
+ WALLPAPER_ENTRY(Horizontal),
+ WALLPAPER_ENTRY(Diagonal),
+ WALLPAPER_ENTRY(Block),
+ WALLPAPER_ENTRY(Ribbon),
+ WALLPAPER_ENTRY(Pokecenter2),
+ WALLPAPER_ENTRY(Frame),
+ WALLPAPER_ENTRY(Blank),
+ WALLPAPER_ENTRY(Circles),
+ WALLPAPER_ENTRY(Azumarill),
+ WALLPAPER_ENTRY(Pikachu),
+ WALLPAPER_ENTRY(Legendary),
+ WALLPAPER_ENTRY(Dusclops),
+ WALLPAPER_ENTRY(Ludicolo),
+ WALLPAPER_ENTRY(Whiscash),
+};
+
+static const u32 *const gFriendsIcons[] =
+{
+ gWallpaperIcon_Aqua,
+ gWallpaperIcon_Heart,
+ gWallpaperIcon_FiveStar,
+ gWallpaperIcon_Brick,
+ gWallpaperIcon_FourStar,
+ gWallpaperIcon_Asterisk,
+ gWallpaperIcon_Dot,
+ gWallpaperIcon_Cross,
+ gWallpaperIcon_LineCircle,
+ gWallpaperIcon_PokeBall,
+ gWallpaperIcon_Maze,
+ gWallpaperIcon_Footprint,
+ gWallpaperIcon_BigAsterisk,
+ gWallpaperIcon_Circle,
+ gWallpaperIcon_Koffing,
+ gWallpaperIcon_Ribbon,
+ gWallpaperIcon_Bolt,
+ gWallpaperIcon_FourCircles,
+ gWallpaperIcon_Lotad,
+ gWallpaperIcon_Crystal,
+ gWallpaperIcon_Pichu,
+ gWallpaperIcon_Diglett,
+ gWallpaperIcon_Luvdisc,
+ gWallpaperIcon_StarInCircle,
+ gWallpaperIcon_Spinda,
+ gWallpaperIcon_Latis,
+ gWallpaperIcon_Plusle,
+ gWallpaperIcon_Minun,
+ gWallpaperIcon_Togepi,
+ gWallpaperIcon_Magma,
+};
+
+// Unknown Unused data.
+static const u16 gUnknown_0857B07C = 0x23BA;
-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");
+static const struct SpriteSheet gUnknown_0857B080 = {gPCGfx_Arrow, 0x80, 6};
+
+static const struct OamData gOamData_83BB298 =
+{
+ .shape = ST_OAM_H_RECTANGLE,
+ .size = 2,
+ .priority = 2
+};
+
+static const union AnimCmd gSpriteAnim_83BB2A0[] =
+{
+ ANIMCMD_FRAME(0, 5),
+ ANIMCMD_END
+};
+
+static const union AnimCmd gSpriteAnim_83BB2A8[] =
+{
+ ANIMCMD_FRAME(8, 5),
+ ANIMCMD_END
+};
+
+static const union AnimCmd *const gSpriteAnimTable_83BB2B0[] =
+{
+ gSpriteAnim_83BB2A0,
+ gSpriteAnim_83BB2A8
+};
+
+static const struct SpriteTemplate gSpriteTemplate_857B0A8 =
+{
+ TAG_TILE_3,
+ TAG_PAL_DAC9,
+ &gOamData_83BB298,
+ gSpriteAnimTable_83BB2B0,
+ NULL,
+ gDummySpriteAffineAnimTable,
+ SpriteCallbackDummy
+};
+
+static const struct OamData gOamData_83BB2D0 =
+{
+ .shape = ST_OAM_V_RECTANGLE,
+ .priority = 2
+};
+
+static const union AnimCmd gSpriteAnim_83BB2D8[] =
+{
+ ANIMCMD_FRAME(0, 5),
+ ANIMCMD_END
+};
+
+static const union AnimCmd gSpriteAnim_83BB2E0[] =
+{
+ ANIMCMD_FRAME(2, 5),
+ ANIMCMD_END
+};
+
+static const union AnimCmd *const gSpriteAnimTable_83BB2E8[] =
+{
+ gSpriteAnim_83BB2D8,
+ gSpriteAnim_83BB2E0
+};
+
+static const struct SpriteTemplate gUnknown_0857B0E0 =
+{
+ 6,
+ TAG_PAL_WAVEFORM,
+ &gOamData_83BB2D0,
+ gSpriteAnimTable_83BB2E8,
+ NULL,
+ gDummySpriteAffineAnimTable,
+ sub_80CD210
+};
+
+static const u16 gHandCursorPalette[] = INCBIN_U16("graphics/pokemon_storage/hand_cursor.gbapal");
+static const u8 gHandCursorTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor.4bpp");
+static const u8 gHandCursorShadowTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor_shadow.4bpp");
// code
u8 CountMonsInBox(u8 boxId)
@@ -117,7 +1552,7 @@ u8 CountMonsInBox(u8 boxId)
for (i = 0, count = 0; i < IN_BOX_COUNT; i++)
{
- if (GetBoxMonDataFromAnyBox(boxId, i, MON_DATA_SPECIES) != SPECIES_NONE)
+ if (GetBoxMonDataAt(boxId, i, MON_DATA_SPECIES) != SPECIES_NONE)
count++;
}
@@ -130,7 +1565,7 @@ s16 GetFirstFreeBoxSpot(u8 boxId)
for (i = 0; i < IN_BOX_COUNT; i++)
{
- if (GetBoxMonDataFromAnyBox(boxId, i, MON_DATA_SPECIES) == SPECIES_NONE)
+ if (GetBoxMonDataAt(boxId, i, MON_DATA_SPECIES) == SPECIES_NONE)
return i;
}
@@ -191,7 +1626,7 @@ u8 CountPartyMons(void)
return count;
}
-static u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n)
+u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n)
{
u8 *str;
@@ -217,28 +1652,7 @@ static void sub_80C7128(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src,
}
}
-#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)
+static void sub_80C71A4(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height)
{
u16 i;
@@ -248,13 +1662,14 @@ void sub_80C71A4(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height)
Dma3FillLarge16_(0, dest, width);
}
-void Task_PokemonStorageSystem(u8 taskId)
+static void Task_PokemonStorageSystemPC(u8 taskId)
{
- struct Task *task = gTasks + taskId;
+ struct Task *task = &gTasks[taskId];
+
switch (task->data[0])
{
case 0:
- StorageSystemCreatePrimaryMenu(task->data[1], &task->data[15]);
+ CreatePCMenu(task->data[1], &task->data[15]);
sub_81973A4();
NewMenuHelpers_DrawDialogueFrame(0, 0);
FillWindowPixelBuffer(0, 0x11);
@@ -327,8 +1742,8 @@ void Task_PokemonStorageSystem(u8 taskId)
{
if (--task->data[1] < 0)
task->data[1] = 4;
- MoveMenuCursor(-1);
- task->data[1] = GetMenuCursorPos();
+ Menu_MoveCursor(-1);
+ task->data[1] = Menu_GetCursorPos();
FillWindowPixelBuffer(0, 0x11);
AddTextPrinterParameterized2(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3);
task->data[0] = 2;
@@ -337,8 +1752,8 @@ void Task_PokemonStorageSystem(u8 taskId)
{
if (++task->data[1] > 3)
task->data[1] = 0;
- MoveMenuCursor(1);
- task->data[1] = GetMenuCursorPos();
+ Menu_MoveCursor(1);
+ task->data[1] = Menu_GetCursorPos();
FillWindowPixelBuffer(0, 0x11);
AddTextPrinterParameterized2(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3);
task->data[0] = 2;
@@ -348,7 +1763,7 @@ void Task_PokemonStorageSystem(u8 taskId)
if (!gPaletteFade.active)
{
overworld_free_bg_tilemaps();
- sub_80C7D74(task->data[2]);
+ Cb2_EnterPSS(task->data[2]);
RemoveWindow(task->data[15]);
DestroyTask(taskId);
}
@@ -356,29 +1771,29 @@ void Task_PokemonStorageSystem(u8 taskId)
}
}
-void ShowPokemonStorageSystem(void)
+void ShowPokemonStorageSystemPC(void)
{
- u8 taskId = CreateTask(Task_PokemonStorageSystem, 80);
+ u8 taskId = CreateTask(Task_PokemonStorageSystemPC, 80);
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[1] = 0;
ScriptContext2_Enable();
}
-void mapldr_0808C6D8(void)
+static void FieldCb_ReturnToPcMenu(void)
{
u8 taskId;
MainCallback vblankCb = gMain.vblankCallback;
SetVBlankCallback(NULL);
- taskId = CreateTask(Task_PokemonStorageSystem, 80);
+ taskId = CreateTask(Task_PokemonStorageSystemPC, 80);
gTasks[taskId].data[0] = 0;
- gTasks[taskId].data[1] = gUnknown_02039D00;
- Task_PokemonStorageSystem(taskId);
+ gTasks[taskId].data[1] = sPreviousBoxOption;
+ Task_PokemonStorageSystemPC(taskId);
SetVBlankCallback(vblankCb);
pal_fill_black();
}
-void StorageSystemCreatePrimaryMenu(u8 whichMenu, s16 *windowIdPtr)
+static void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr)
{
s16 windowId;
struct WindowTemplate winTemplate = gUnknown_085716E8;
@@ -391,14 +1806,14 @@ void StorageSystemCreatePrimaryMenu(u8 whichMenu, s16 *windowIdPtr)
*windowIdPtr = windowId;
}
-void sub_80C7678(void)
+static void Cb2_ExitPSS(void)
{
- gUnknown_02039D00 = sub_80CAEA0();
- gFieldCallback = mapldr_0808C6D8;
+ sPreviousBoxOption = GetCurrentBoxOption();
+ gFieldCallback = FieldCb_ReturnToPcMenu;
SetMainCallback2(CB2_ReturnToField);
}
-s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx, u8 mode)
+static s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx, u8 mode)
{
s16 i;
s16 direction;
@@ -431,14 +1846,13 @@ s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx
void ResetPokemonStorageSystem(void)
{
- u16 boxId;
- u16 boxMon;
+ u16 boxId, boxPosition;
SetCurrentBox(0);
for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++)
{
- for (boxMon = 0; boxMon < IN_BOX_COUNT; boxMon++)
- ClearMonInBox(boxId, boxMon);
+ for (boxPosition = 0; boxPosition < IN_BOX_COUNT; boxPosition++)
+ ZeroBoxMonAt(boxId, boxPosition);
}
for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++)
{
@@ -452,7 +1866,7 @@ void ResetPokemonStorageSystem(void)
ResetWaldaWallpaper();
}
-void sub_80C77E8(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3, bool32 loadPal)
+static void sub_80C77E8(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3, bool32 loadPal)
{
struct SpritePalette palette =
{
@@ -476,7 +1890,7 @@ void sub_80C77E8(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3
a0->unk_023c = loadPal;
}
-void sub_80C7890(void)
+static void sub_80C7890(void)
{
if (gUnknown_02039D04->unk_023c)
FreeSpritePaletteByTag(gUnknown_02039D04->unk_0242);
@@ -484,17 +1898,17 @@ void sub_80C7890(void)
FreeSpriteTilesByTag(gUnknown_02039D04->unk_0240 + 1);
}
-void sub_80C78D4(u8 curBox)
+static void sub_80C78D4(u8 curBox)
{
sub_80C7958(curBox);
}
-void sub_80C78E4(void)
+static void sub_80C78E4(void)
{
sub_80C7B14();
}
-u8 sub_80C78F0(void)
+static u8 HandleBoxChooseSelectionInput(void)
{
if (gMain.newKeys & B_BUTTON)
{
@@ -519,7 +1933,7 @@ u8 sub_80C78F0(void)
return 200;
}
-void sub_80C7958(u8 curBox)
+static void sub_80C7958(u8 curBox)
{
u16 i;
u8 spriteId;
@@ -535,7 +1949,7 @@ void sub_80C7958(u8 curBox)
template.tileTag = gUnknown_02039D04->unk_0240;
template.paletteTag = gUnknown_02039D04->unk_0242;
- spriteId = CreateSprite(&template, 0xA0, 0x60, 0);
+ spriteId = CreateSprite(&template, 160, 96, 0);
gUnknown_02039D04->unk_0000 = gSprites + spriteId;
oamData.shape = ST_OAM_V_RECTANGLE;
@@ -545,17 +1959,17 @@ void sub_80C7958(u8 curBox)
for (i = 0; i < 4; i++)
{
u16 r5;
- spriteId = CreateSprite(&template, 0x7c, 0x50, gUnknown_02039D04->unk_0246);
+ spriteId = CreateSprite(&template, 124, 80, gUnknown_02039D04->unk_0246);
gUnknown_02039D04->unk_0004[i] = gSprites + spriteId;
r5 = 0;
if (i & 2)
{
- gUnknown_02039D04->unk_0004[i]->pos1.x = 0xc4;
+ gUnknown_02039D04->unk_0004[i]->pos1.x = 196;
r5 = 2;
}
if (i & 1)
{
- gUnknown_02039D04->unk_0004[i]->pos1.y = 0x70;
+ gUnknown_02039D04->unk_0004[i]->pos1.y = 112;
gUnknown_02039D04->unk_0004[i]->oam.size = 0;
r5++;
}
@@ -573,7 +1987,7 @@ void sub_80C7958(u8 curBox)
sub_80C7BE4();
}
-void sub_80C7B14(void)
+static void sub_80C7B14(void)
{
u16 i;
if (gUnknown_02039D04->unk_0000)
@@ -596,20 +2010,20 @@ void sub_80C7B14(void)
}
}
-void sub_80C7B80(void)
+static void sub_80C7B80(void)
{
if (++gUnknown_02039D04->curBox >= TOTAL_BOXES_COUNT)
gUnknown_02039D04->curBox = 0;
sub_80C7BE4();
}
-void sub_80C7BB4(void)
+static void sub_80C7BB4(void)
{
gUnknown_02039D04->curBox = (gUnknown_02039D04->curBox == 0 ? TOTAL_BOXES_COUNT - 1 : gUnknown_02039D04->curBox - 1);
sub_80C7BE4();
}
-void sub_80C7BE4(void)
+static void sub_80C7BE4(void)
{
u8 text[16];
struct WindowTemplate winTemplate;
@@ -626,13 +2040,13 @@ void sub_80C7BE4(void)
windowId = AddWindow(&winTemplate);
FillWindowPixelBuffer(windowId, 0x44);
- center = GetStringCenterAlignXOffset(1, boxName, 0x40);
+ center = GetStringCenterAlignXOffset(1, boxName, 64);
AddTextPrinterParameterized3(windowId, 1, center, 1, gUnknown_08571734, TEXT_SPEED_FF, boxName);
ConvertIntToDecimalStringN(text, nPokemonInBox, 1, 2);
StringAppend(text, gUnknown_08571737);
- center = GetStringCenterAlignXOffset(1, text, 0x40);
- AddTextPrinterParameterized3(windowId, 1, center, 0x11, gUnknown_08571734, TEXT_SPEED_FF, text);
+ center = GetStringCenterAlignXOffset(1, text, 64);
+ AddTextPrinterParameterized3(windowId, 1, center, 17, 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);
@@ -640,7 +2054,7 @@ void sub_80C7BE4(void)
RemoveWindow(windowId);
}
-void sub_80C7CF4(struct Sprite *sprite)
+static void sub_80C7CF4(struct Sprite *sprite)
{
if (++sprite->data[1] > 3)
{
@@ -654,21 +2068,8587 @@ void sub_80C7CF4(struct Sprite *sprite)
}
}
-void sub_80C7D28(void)
+static void VblankCb_PSS(void)
{
LoadOam();
ProcessSpriteCopyRequests();
sub_80D2AA4();
TransferPlttBuffer();
- SetGpuReg(REG_OFFSET_BG2HOFS, gUnknown_02039D08->bg2_X);
+ SetGpuReg(REG_OFFSET_BG2HOFS, sPSSData->bg2_X);
}
-void c2_Box(void)
+static void Cb2_PSS(void)
{
RunTasks();
do_scheduled_bg_tilemap_copies_to_vram();
- sub_80CA028();
+ ScrollBackground();
sub_80CAA14();
AnimateSprites();
BuildOamBuffer();
}
+
+static void Cb2_EnterPSS(u8 boxOption)
+{
+ ResetTasks();
+ sCurrentBoxOption = boxOption;
+ sPSSData = Alloc(sizeof(*sPSSData));
+ if (sPSSData == NULL)
+ {
+ SetMainCallback2(Cb2_ExitPSS);
+ }
+ else
+ {
+ sPSSData->boxOption = boxOption;
+ sPSSData->isReshowingPSS = FALSE;
+ gUnknown_02039D12 = 0;
+ sPSSData->state = 0;
+ sPSSData->taskId = CreateTask(Cb_InitPSS, 3);
+ gUnknown_02039D10 = StorageGetCurrentBox();
+ SetMainCallback2(Cb2_PSS);
+ }
+}
+
+static void Cb2_ReturnToPSS(void)
+{
+ ResetTasks();
+ sPSSData = Alloc(sizeof(*sPSSData));
+ if (sPSSData == NULL)
+ {
+ SetMainCallback2(Cb2_ExitPSS);
+ }
+ else
+ {
+ sPSSData->boxOption = sCurrentBoxOption;
+ sPSSData->isReshowingPSS = TRUE;
+ sPSSData->state = 0;
+ sPSSData->taskId = CreateTask(Cb_InitPSS, 3);
+ SetMainCallback2(Cb2_PSS);
+ }
+}
+
+static void ResetAllBgCoords(void)
+{
+ SetGpuReg(REG_OFFSET_BG0HOFS, 0);
+ SetGpuReg(REG_OFFSET_BG0VOFS, 0);
+ SetGpuReg(REG_OFFSET_BG1HOFS, 0);
+ SetGpuReg(REG_OFFSET_BG1VOFS, 0);
+ SetGpuReg(REG_OFFSET_BG2HOFS, 0);
+ SetGpuReg(REG_OFFSET_BG2VOFS, 0);
+ SetGpuReg(REG_OFFSET_BG3HOFS, 0);
+ SetGpuReg(REG_OFFSET_BG3VOFS, 0);
+}
+
+static void sub_80C7E98(void)
+{
+ ResetPaletteFade();
+ ResetSpriteData();
+ FreeSpriteTileRanges();
+ FreeAllSpritePalettes();
+ ClearDma3Requests();
+ gReservedSpriteTileCount = 0x280;
+ sub_80D2A90(&sPSSData->unk_0020, sPSSData->unk_0028, 8);
+ gKeyRepeatStartDelay = 20;
+ clear_scheduled_bg_copies_to_vram();
+ sub_80D259C(3);
+ sub_80D2644(0, 1, gUnknown_0857239C, 8, 4);
+ sub_80D2770(0, 1, 0);
+ sPSSData->unk_02C7 = 0;
+}
+
+static void sub_80C7F1C(void)
+{
+ sub_80CDC0C();
+ sInPartyMenu = (sPSSData->boxOption == BOX_OPTION_DEPOSIT);
+ gUnknown_02039D0E = 0;
+}
+
+static void sub_80C7F4C(void)
+{
+ if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS)
+ {
+ SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL);
+ SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(7, 11));
+ }
+ SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_1D_MAP);
+}
+
+static void SetPSSCallback(TaskFunc newFunc)
+{
+ gTasks[sPSSData->taskId].func = newFunc;
+ sPSSData->state = 0;
+}
+
+static void Cb_InitPSS(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ SetVBlankCallback(NULL);
+ SetGpuReg(REG_OFFSET_DISPCNT, 0);
+ sub_80C7E98();
+ if (sPSSData->isReshowingPSS)
+ {
+ switch (sWhichToReshow)
+ {
+ case 1:
+ sub_80CE790();
+ break;
+ case 0:
+ sub_80CE8E4();
+ break;
+ case 2:
+ GiveChosenBagItem();
+ break;
+ }
+ }
+ LoadPSSMenuGfx();
+ LoadWaveformSpritePalette();
+ break;
+ case 1:
+ if (!InitPSSWindows())
+ {
+ SetPSSCallback(Cb_ChangeScreen);
+ return;
+ }
+ break;
+ case 2:
+ PutWindowTilemap(0);
+ ClearWindowTilemap(1);
+ CpuFill32(0, (void *)VRAM, 0x200);
+ LoadUserWindowBorderGfx(1, 0xB, 0xE0);
+ break;
+ case 3:
+ ResetAllBgCoords();
+ if (!sPSSData->isReshowingPSS)
+ sub_80C7F1C();
+ break;
+ case 4:
+ sub_80CAF04();
+ if (!sPSSData->isReshowingPSS)
+ sub_80CD36C();
+ else
+ sub_80CD3EC();
+ break;
+ case 5:
+ if (!sub_80D0164())
+ {
+ SetPSSCallback(Cb_ChangeScreen);
+ return;
+ }
+ else
+ {
+ SetScrollingBackground();
+ sub_80CAC1C();
+ }
+ break;
+ case 6:
+ sub_80CA0D8();
+ break;
+ case 7:
+ sub_80CA704();
+ break;
+ case 8:
+ sub_80CC32C(StorageGetCurrentBox());
+ break;
+ case 9:
+ if (sub_80CC35C())
+ return;
+
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ {
+ sPSSData->field_DA4.baseTileTag = TAG_TILE_D;
+ sPSSData->field_DA4.basePaletteTag = TAG_PAL_DACE;
+ sub_811F90C(&sPSSData->field_DA4);
+ sub_811FA90();
+ }
+ else
+ {
+ sub_80D0C60();
+ sub_80CAEAC();
+ }
+ break;
+ case 10:
+ sub_80C7F4C();
+ if (!sPSSData->isReshowingPSS)
+ {
+ BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK);
+ SetPSSCallback(Cb_ShowPSS);
+ }
+ else
+ {
+ BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK);
+ SetPSSCallback(Cb_ReshowPSS);
+ }
+ SetVBlankCallback(VblankCb_PSS);
+ return;
+ default:
+ return;
+ }
+
+ sPSSData->state++;
+}
+
+static void Cb_ShowPSS(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ PlaySE(SE_PC_LOGIN);
+ sub_80F9BCC(0x14, 0, 1);
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!sub_80F9C1C())
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ }
+}
+
+static void Cb_ReshowPSS(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ BeginNormalPaletteFade(0xFFFFFFFF, -1, 0x10, 0, RGB_BLACK);
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!UpdatePaletteFade())
+ {
+ if (sWhichToReshow == 2 && gSpecialVar_ItemId != 0)
+ {
+ PrintStorageActionText(PC_TEXT_ITEM_IS_HELD);
+ sPSSData->state++;
+ }
+ else
+ {
+ SetPSSCallback(Cb_MainPSS);
+ }
+ }
+ break;
+ case 2:
+ if (!IsDma3ManagerBusyWithBgCopy() && gMain.newKeys & (A_BUTTON | B_BUTTON))
+ {
+ ClearBottomWindow();
+ sPSSData->state++;
+ }
+ break;
+ case 3:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ }
+}
+
+static void Cb_MainPSS(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ switch (HandleInput())
+ {
+ case 1:
+ PlaySE(SE_SELECT);
+ sPSSData->state = 1;
+ break;
+ case 5:
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_MONS && sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ {
+ PrintStorageActionText(PC_TEXT_WHICH_ONE_WILL_TAKE);
+ sPSSData->state = 3;
+ }
+ else
+ {
+ sub_80CDC0C();
+ SetPSSCallback(Cb_ShowPartyPokemon);
+ }
+ break;
+ case 6:
+ if (sPSSData->boxOption == BOX_OPTION_MOVE_MONS)
+ {
+ if (IsMonBeingMoved() && ItemIsMail(sPSSData->cursorMonItem))
+ sPSSData->state = 5;
+ else
+ SetPSSCallback(Cb_HidePartyPokemon);
+ }
+ else if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS)
+ {
+ SetPSSCallback(Cb_HidePartyPokemon);
+ }
+ break;
+ case 4:
+ SetPSSCallback(Cb_OnCloseBoxPressed);
+ break;
+ case 19:
+ SetPSSCallback(Cb_OnBPressed);
+ break;
+ case 7:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_HandleBoxOptions);
+ break;
+ case 8:
+ SetPSSCallback(Cb_OnSelectedMon);
+ break;
+ case 9:
+ PlaySE(SE_SELECT);
+ sPSSData->newCurrBoxId = StorageGetCurrentBox() + 1;
+ if (sPSSData->newCurrBoxId >= TOTAL_BOXES_COUNT)
+ sPSSData->newCurrBoxId = 0;
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ {
+ SetUpScrollToBox(sPSSData->newCurrBoxId);
+ sPSSData->state = 2;
+ }
+ else
+ {
+ sub_80CFEA8();
+ sPSSData->state = 10;
+ }
+ break;
+ case 10:
+ PlaySE(SE_SELECT);
+ sPSSData->newCurrBoxId = StorageGetCurrentBox() - 1;
+ if (sPSSData->newCurrBoxId < 0)
+ sPSSData->newCurrBoxId = TOTAL_BOXES_COUNT - 1;
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ {
+ SetUpScrollToBox(sPSSData->newCurrBoxId);
+ sPSSData->state = 2;
+ }
+ else
+ {
+ sub_80CFEA8();
+ sPSSData->state = 10;
+ }
+ break;
+ case 11:
+ if (!CanMovePartyMon())
+ {
+ if (ItemIsMail(sPSSData->cursorMonItem))
+ {
+ sPSSData->state = 5;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_DepositMenu);
+ }
+ }
+ else
+ {
+ sPSSData->state = 4;
+ }
+ break;
+ case 13:
+ if (CanMovePartyMon())
+ {
+ sPSSData->state = 4;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_MoveMon);
+ }
+ break;
+ case 14:
+ if (!CanShiftMon())
+ {
+ sPSSData->state = 4;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_ShiftMon);
+ }
+ break;
+ case 12:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_WithdrawMon);
+ break;
+ case 15:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_PlaceMon);
+ break;
+ case 16:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_TakeItemForMoving);
+ break;
+ case 17:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_GiveMovingItemToMon);
+ break;
+ case 18:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_SwitchSelectedItem);
+ break;
+ case 20:
+ PlaySE(SE_SELECT);
+ sub_80D01D0(0);
+ sPSSData->state = 7;
+ break;
+ case 22:
+ sub_80D01D0(1);
+ sPSSData->state = 8;
+ break;
+ case 21:
+ PlaySE(SE_SELECT);
+ sub_80D01D0(2);
+ sPSSData->state = 9;
+ break;
+ case 23:
+ sub_80D01D0(3);
+ sPSSData->state = 7;
+ break;
+ case 25:
+ PlaySE(SE_SELECT);
+ sub_80D01D0(4);
+ sPSSData->state = 9;
+ break;
+ case 26:
+ PlaySE(SE_SELECT);
+ sub_80D01D0(5);
+ sPSSData->state = 7;
+ break;
+ case 24:
+ PlaySE(SE_HAZURE);
+ break;
+ }
+ break;
+ case 1:
+ if (!sub_80CD554())
+ {
+ if (IsCursorOnCloseBox())
+ sub_80CA9C0();
+ else
+ sub_80CA9EC();
+
+ if (sPSSData->setMosaic)
+ BoxSetMosaic();
+ sPSSData->state = 0;
+ }
+ break;
+ case 2:
+ if (!ScrollToBox())
+ {
+ SetCurrentBox(sPSSData->newCurrBoxId);
+ if (!sInPartyMenu && !IsMonBeingMoved())
+ {
+ sub_80CE00C();
+ BoxSetMosaic();
+ }
+
+ if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS)
+ {
+ sub_80CFECC();
+ sPSSData->state = 11;
+ }
+ else
+ {
+ sPSSData->state = 0;
+ }
+ }
+ break;
+ case 3:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ sPSSData->state = 0;
+ }
+ break;
+ case 4:
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_LAST_POKE);
+ sPSSData->state = 6;
+ break;
+ case 5:
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL);
+ sPSSData->state = 6;
+ break;
+ case 6:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ case 7:
+ if (!sub_80D01E4())
+ sPSSData->state = 0;
+ break;
+ case 8:
+ if (!sub_80D01E4())
+ SetPSSCallback(Cb_MoveMon);
+ break;
+ case 9:
+ if (!sub_80D01E4())
+ {
+ if (sPSSData->setMosaic)
+ BoxSetMosaic();
+ sPSSData->state = 0;
+ }
+ break;
+ case 10:
+ if (!sub_80D1218())
+ {
+ SetUpScrollToBox(sPSSData->newCurrBoxId);
+ sPSSData->state = 2;
+ }
+ break;
+ case 11:
+ if (!sub_80D1218())
+ sPSSData->state = 0;
+ break;
+ }
+}
+
+static void Cb_ShowPartyPokemon(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ SetUpDoShowPartyMenu();
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!DoShowPartyMenu())
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ }
+}
+
+static void Cb_HidePartyPokemon(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ PlaySE(SE_SELECT);
+ SetUpHidePartyMenu();
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!HidePartyMenu())
+ {
+ sub_80CDBF8(sub_80CDC2C());
+ sPSSData->state++;
+ }
+ break;
+ case 2:
+ if (!sub_80CD554())
+ {
+ if (sPSSData->setMosaic)
+ BoxSetMosaic();
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ }
+}
+
+static void Cb_OnSelectedMon(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ if (!sub_80CA2B8())
+ {
+ PlaySE(SE_SELECT);
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ PrintStorageActionText(PC_TEXT_IS_SELECTED);
+ else if (IsActiveItemMoving() || sPSSData->cursorMonItem != 0)
+ PrintStorageActionText(PC_TEXT_IS_SELECTED2);
+ else
+ PrintStorageActionText(PC_TEXT_GIVE_TO_MON);
+
+ AddMenu();
+ sPSSData->state = 1;
+ }
+ break;
+ case 1: // debug?
+ if (!sub_80D00A8())
+ sPSSData->state = 2;
+ break;
+ case 2:
+ switch (sub_80D00AC())
+ {
+ case -1:
+ case 0:
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ case 3:
+ if (CanMovePartyMon())
+ {
+ sPSSData->state = 3;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MoveMon);
+ }
+ break;
+ case 5:
+ PlaySE(SE_SELECT);
+ ClearBottomWindow();
+ SetPSSCallback(Cb_PlaceMon);
+ break;
+ case 4:
+ if (!CanShiftMon())
+ {
+ sPSSData->state = 3;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ ClearBottomWindow();
+ SetPSSCallback(Cb_ShiftMon);
+ }
+ break;
+ case 2:
+ PlaySE(SE_SELECT);
+ ClearBottomWindow();
+ SetPSSCallback(Cb_WithdrawMon);
+ break;
+ case 1:
+ if (CanMovePartyMon())
+ {
+ sPSSData->state = 3;
+ }
+ else if (ItemIsMail(sPSSData->cursorMonItem))
+ {
+ sPSSData->state = 4;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ ClearBottomWindow();
+ SetPSSCallback(Cb_DepositMenu);
+ }
+ break;
+ case 7:
+ if (CanMovePartyMon())
+ {
+ sPSSData->state = 3;
+ }
+ else if (sPSSData->cursorMonIsEgg)
+ {
+ sPSSData->state = 5; // Cannot release an Egg.
+ }
+ else if (ItemIsMail(sPSSData->cursorMonItem))
+ {
+ sPSSData->state = 4;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_ReleaseMon);
+ }
+ break;
+ case 6:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_ShowMonSummary);
+ break;
+ case 8:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_ShowMarkMenu);
+ break;
+ case 12:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_TakeItemForMoving);
+ break;
+ case 13:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_GiveMovingItemToMon);
+ break;
+ case 16:
+ SetPSSCallback(Cb_ItemToBag);
+ break;
+ case 15:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_SwitchSelectedItem);
+ break;
+ case 14:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_GiveItemFromBag);
+ break;
+ case 17:
+ SetPSSCallback(Cb_ShowItemInfo);
+ break;
+ }
+ break;
+ case 3:
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_LAST_POKE);
+ sPSSData->state = 6;
+ break;
+ case 5:
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_CANT_RELEASE_EGG);
+ sPSSData->state = 6;
+ break;
+ case 4:
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL);
+ sPSSData->state = 6;
+ break;
+ case 6:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ }
+}
+
+static void Cb_MoveMon(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ InitMonPlaceChange(0);
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!DoMonPlaceChange())
+ {
+ if (sInPartyMenu)
+ SetPSSCallback(Cb_HandleMovingMonFromParty);
+ else
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ }
+}
+
+static void Cb_PlaceMon(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ InitMonPlaceChange(1);
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!DoMonPlaceChange())
+ {
+ if (sInPartyMenu)
+ SetPSSCallback(Cb_HandleMovingMonFromParty);
+ else
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ }
+}
+
+static void Cb_ShiftMon(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ InitMonPlaceChange(2);
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!DoMonPlaceChange())
+ {
+ BoxSetMosaic();
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ }
+}
+
+static void Cb_WithdrawMon(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ if (CalculatePlayerPartyCount() == PARTY_SIZE)
+ {
+ PrintStorageActionText(PC_TEXT_PARTY_FULL);
+ sPSSData->state = 1;
+ }
+ else
+ {
+ sub_80CDC18();
+ InitMonPlaceChange(0);
+ sPSSData->state = 2;
+ }
+ break;
+ case 1:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ case 2:
+ if (!DoMonPlaceChange())
+ {
+ SetMovingMonPriority(1);
+ SetUpDoShowPartyMenu();
+ sPSSData->state++;
+ }
+ break;
+ case 3:
+ if (!DoShowPartyMenu())
+ {
+ InitMonPlaceChange(1);
+ sPSSData->state++;
+ }
+ break;
+ case 4:
+ if (!DoMonPlaceChange())
+ {
+ sub_80CAB20();
+ sPSSData->state++;
+ }
+ break;
+ case 5:
+ SetPSSCallback(Cb_HidePartyPokemon);
+ break;
+ }
+}
+
+static void Cb_DepositMenu(u8 taskId)
+{
+ u8 boxId;
+
+ switch (sPSSData->state)
+ {
+ case 0:
+ PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX);
+ sub_80C77E8(&sPSSData->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE);
+ sub_80C78D4(gUnknown_02039D0E);
+ sPSSData->state++;
+ break;
+ case 1:
+ boxId = HandleBoxChooseSelectionInput();
+ if (boxId == 200)
+ {
+ // no box chosen yet
+ }
+ else if (boxId == 201)
+ {
+ ClearBottomWindow();
+ sub_80C78E4();
+ sub_80C7890();
+ SetPSSCallback(Cb_MainPSS);
+ }
+ else
+ {
+ if (TryStorePartyMonInBox(boxId))
+ {
+ gUnknown_02039D0E = boxId;
+ ClearBottomWindow();
+ sub_80C78E4();
+ sub_80C7890();
+ sPSSData->state = 2;
+ }
+ else
+ {
+ PrintStorageActionText(PC_TEXT_BOX_IS_FULL);
+ sPSSData->state = 4;
+ }
+ }
+ break;
+ case 2:
+ CompactPartySlots();
+ sub_80CB950();
+ sPSSData->state++;
+ break;
+ case 3:
+ if (!sub_80CB9BC())
+ {
+ sub_80CE22C();
+ BoxSetMosaic();
+ sub_80CAB20();
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ case 4:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX);
+ sPSSData->state = 1;
+ }
+ break;
+ }
+}
+
+static void Cb_ReleaseMon(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ PrintStorageActionText(PC_TEXT_RELEASE_POKE);
+ ShowYesNoWindow(1);
+ sPSSData->state++;
+ // fallthrough
+ case 1:
+ switch (Menu_ProcessInputNoWrapClearOnChoose())
+ {
+ case MENU_B_PRESSED:
+ case 1:
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ case 0:
+ ClearBottomWindow();
+ InitCanRelaseMonVars();
+ sub_80CE250();
+ sPSSData->state++;
+ break;
+ }
+ break;
+ case 2:
+ RunCanReleaseMon();
+ if (!sub_80CE2A8())
+ {
+ while (1)
+ {
+ s8 r0 = RunCanReleaseMon();
+ if (r0 == 1)
+ {
+ sPSSData->state++;
+ break;
+ }
+ else if (r0 == 0)
+ {
+ sPSSData->state = 8; // Can't release the mon.
+ break;
+ }
+ }
+ }
+ break;
+ case 3:
+ ReleaseMon();
+ RefreshCursorMonData();
+ PrintStorageActionText(PC_TEXT_WAS_RELEASED);
+ sPSSData->state++;
+ break;
+ case 4:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ PrintStorageActionText(PC_TEXT_BYE_BYE);
+ sPSSData->state++;
+ }
+ break;
+ case 5:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ if (sInPartyMenu)
+ {
+ CompactPartySlots();
+ sub_80CB950();
+ sPSSData->state++;
+ }
+ else
+ {
+ sPSSData->state = 7;
+ }
+ }
+ break;
+ case 6:
+ if (!sub_80CB9BC())
+ {
+ sub_80CE00C();
+ BoxSetMosaic();
+ sub_80CAB20();
+ sPSSData->state++;
+ }
+ break;
+ case 7:
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ case 8:
+ PrintStorageActionText(PC_TEXT_WAS_RELEASED);
+ sPSSData->state++;
+ break;
+ case 9:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ PrintStorageActionText(PC_TEXT_SURPRISE);
+ sPSSData->state++;
+ }
+ break;
+ case 10:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ sub_80CC064();
+ sPSSData->state++;
+ }
+ break;
+ case 11:
+ if (!sub_80CC0A0())
+ {
+ sub_80CE324();
+ PrintStorageActionText(PC_TEXT_CAME_BACK);
+ sPSSData->state++;
+ }
+ break;
+ case 12:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ PrintStorageActionText(PC_TEXT_WORRIED);
+ sPSSData->state++;
+ }
+ break;
+ case 13:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ }
+}
+
+static void Cb_ShowMarkMenu(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ PrintStorageActionText(PC_TEXT_MARK_POKE);
+ sPSSData->field_DA4.markings = sPSSData->cursorMonMarkings;
+ sub_811FAA4(sPSSData->cursorMonMarkings, 0xb0, 0x10);
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!sub_811FBA4())
+ {
+ sub_811FAF8();
+ ClearBottomWindow();
+ SetMonMarkings(sPSSData->field_DA4.markings);
+ RefreshCursorMonData();
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ }
+}
+
+static void Cb_TakeItemForMoving(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ if (!ItemIsMail(sPSSData->cursorMonItem))
+ {
+ ClearBottomWindow();
+ sPSSData->state++;
+ }
+ else
+ {
+ SetPSSCallback(Cb_PrintCantStoreMail);
+ }
+ break;
+ case 1:
+ sub_80CFE54(2);
+ Item_FromMonToMoving((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition());
+ sPSSData->state++;
+ break;
+ case 2:
+ if (!sub_80D1218())
+ {
+ sub_80CFE54(3);
+ ClearBottomWindow();
+ sub_80CE00C();
+ PrintCursorMonInfo();
+ sPSSData->state++;
+ }
+ break;
+ case 3:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ }
+}
+
+static void Cb_GiveMovingItemToMon(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ ClearBottomWindow();
+ sPSSData->state++;
+ break;
+ case 1:
+ sub_80CFE54(2);
+ Item_GiveMovingToMon((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition());
+ sPSSData->state++;
+ break;
+ case 2:
+ if (!sub_80D1218())
+ {
+ sub_80CFE54(0);
+ sub_80CE00C();
+ PrintCursorMonInfo();
+ PrintStorageActionText(PC_TEXT_ITEM_IS_HELD);
+ sPSSData->state++;
+ }
+ break;
+ case 3:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ sPSSData->state++;
+ }
+ break;
+ case 4:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ }
+}
+
+static void Cb_ItemToBag(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ if (!AddBagItem(sPSSData->cursorMonItem, 1))
+ {
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_BAG_FULL);
+ sPSSData->state = 3;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ Item_TakeMons((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition());
+ sPSSData->state = 1;
+ }
+ break;
+ case 1:
+ if (!sub_80D1218())
+ {
+ PrintStorageActionText(PC_TEXT_PLACED_IN_BAG);
+ sPSSData->state = 2;
+ }
+ break;
+ case 2:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ sub_80CE00C();
+ PrintCursorMonInfo();
+ sPSSData->state = 4;
+ }
+ break;
+ case 4:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ case 3:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ }
+}
+
+static void Cb_SwitchSelectedItem(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ if (!ItemIsMail(sPSSData->cursorMonItem))
+ {
+ ClearBottomWindow();
+ sPSSData->state++;
+ }
+ else
+ {
+ SetPSSCallback(Cb_PrintCantStoreMail);
+ }
+ break;
+ case 1:
+ sub_80CFE54(2);
+ Item_SwitchMonsWithMoving((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition());
+ sPSSData->state++;
+ break;
+ case 2:
+ if (!sub_80D1218())
+ {
+ sub_80CFE54(3);
+ sub_80CE00C();
+ PrintCursorMonInfo();
+ PrintStorageActionText(PC_TEXT_CHANGED_TO_ITEM);
+ sPSSData->state++;
+ }
+ break;
+ case 3:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ sPSSData->state++;
+ }
+ break;
+ case 4:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ }
+}
+
+static void Cb_ShowItemInfo(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ ClearBottomWindow();
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ {
+ PlaySE(SE_WIN_OPEN);
+ PrintItemDescription();
+ sub_80D1818();
+ sPSSData->state++;
+ }
+ break;
+ case 2:
+ if (!sub_80D184C())
+ sPSSData->state++;
+ break;
+ case 3:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ sPSSData->state++;
+ break;
+ case 4:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ PlaySE(SE_WIN_OPEN);
+ sPSSData->state++;
+ }
+ break;
+ case 5:
+ if (!sub_80D18E4())
+ sPSSData->state++;
+ break;
+ case 6:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ }
+}
+
+static void Cb_CloseBoxWhileHoldingItem(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ PlaySE(SE_SELECT);
+ PrintStorageActionText(PC_TEXT_PUT_IN_BAG);
+ ShowYesNoWindow(0);
+ sPSSData->state = 1;
+ break;
+ case 1:
+ switch (Menu_ProcessInputNoWrapClearOnChoose())
+ {
+ case MENU_B_PRESSED:
+ case 1:
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ case 0:
+ if (AddBagItem(sPSSData->movingItem, 1) == TRUE)
+ {
+ ClearBottomWindow();
+ sPSSData->state = 3;
+ }
+ else
+ {
+ PrintStorageActionText(PC_TEXT_BAG_FULL);
+ sPSSData->state = 2;
+ }
+ break;
+ }
+ break;
+ case 2:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ sPSSData->state = 5;
+ }
+ break;
+ case 3:
+ sub_80D1194();
+ sPSSData->state = 4;
+ break;
+ case 4:
+ if (!sub_80D1218())
+ {
+ sub_80CFE54(0);
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ case 5:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ }
+}
+
+static void Cb_HandleMovingMonFromParty(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ CompactPartySlots();
+ sub_80CB950();
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!sub_80CB9BC())
+ {
+ sub_80CAB20();
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ }
+}
+
+static void Cb_PrintCantStoreMail(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ PrintStorageActionText(PC_TEXT_CANT_STORE_MAIL);
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ sPSSData->state++;
+ break;
+ case 2:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ sPSSData->state++;
+ }
+ break;
+ case 3:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ }
+}
+
+static void Cb_HandleBoxOptions(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ PrintStorageActionText(PC_TEXT_WHAT_YOU_DO);
+ AddMenu();
+ sPSSData->state++;
+ break;
+ case 1:
+ if (sub_80D00A8())
+ return;
+ sPSSData->state++;
+ case 2:
+ switch (sub_80D00AC())
+ {
+ case -1:
+ case 0:
+ sub_80CD1A8(TRUE);
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ case 11:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(Cb_NameBox);
+ break;
+ case 10:
+ PlaySE(SE_SELECT);
+ ClearBottomWindow();
+ SetPSSCallback(Cb_HandleWallpapers);
+ break;
+ case 9:
+ PlaySE(SE_SELECT);
+ ClearBottomWindow();
+ SetPSSCallback(Cb_JumpBox);
+ break;
+ }
+ break;
+ }
+}
+
+static void Cb_HandleWallpapers(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ AddWallpaperSetsMenu();
+ PrintStorageActionText(PC_TEXT_PICK_A_THEME);
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!sub_80D00A8())
+ sPSSData->state++;
+ break;
+ case 2:
+ sPSSData->wallpaperSetId = sub_80D00AC();
+ switch (sPSSData->wallpaperSetId)
+ {
+ case -1:
+ sub_80CD1A8(TRUE);
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ case 18 ... 21:
+ PlaySE(SE_SELECT);
+ sub_80D013C();
+ sPSSData->wallpaperSetId -= 18;
+ sPSSData->state++;
+ break;
+ // New wallpaper from Walda.
+ case 22:
+ PlaySE(SE_SELECT);
+ sPSSData->wallpaperId = 16;
+ sub_80D013C();
+ ClearBottomWindow();
+ sPSSData->state = 6;
+ break;
+ }
+ break;
+ case 3:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ {
+ AddWallpapersMenu(sPSSData->wallpaperSetId);
+ PrintStorageActionText(PC_TEXT_PICK_A_WALLPAPER);
+ sPSSData->state++;
+ }
+ break;
+ case 4:
+ sPSSData->wallpaperId = sub_80D00AC();
+ switch (sPSSData->wallpaperId)
+ {
+ case -2:
+ break;
+ case -1:
+ ClearBottomWindow();
+ sPSSData->state = 0;
+ break;
+ default:
+ PlaySE(SE_SELECT);
+ ClearBottomWindow();
+ sPSSData->wallpaperId -= 23;
+ SetWallpaperForCurrentBox(sPSSData->wallpaperId);
+ sPSSData->state++;
+ break;
+ }
+ break;
+ case 5:
+ if (!DoWallpaperGfxChange())
+ {
+ sub_80CD1A8(TRUE);
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ case 6:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ {
+ SetWallpaperForCurrentBox(sPSSData->wallpaperId);
+ sPSSData->state = 5;
+ }
+ break;
+ }
+}
+
+static void Cb_JumpBox(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ PrintStorageActionText(PC_TEXT_JUMP_TO_WHICH_BOX);
+ sub_80C77E8(&sPSSData->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE);
+ sub_80C78D4(StorageGetCurrentBox());
+ sPSSData->state++;
+ break;
+ case 1:
+ sPSSData->newCurrBoxId = HandleBoxChooseSelectionInput();
+ switch (sPSSData->newCurrBoxId)
+ {
+ case 200:
+ break;
+ default:
+ ClearBottomWindow();
+ sub_80C78E4();
+ sub_80C7890();
+ if (sPSSData->newCurrBoxId == 201 || sPSSData->newCurrBoxId == StorageGetCurrentBox())
+ {
+ sub_80CD1A8(TRUE);
+ SetPSSCallback(Cb_MainPSS);
+ }
+ else
+ {
+ sPSSData->state++;
+ }
+ break;
+ }
+ break;
+ case 2:
+ SetUpScrollToBox(sPSSData->newCurrBoxId);
+ sPSSData->state++;
+ break;
+ case 3:
+ if (!ScrollToBox())
+ {
+ SetCurrentBox(sPSSData->newCurrBoxId);
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ }
+}
+
+static void Cb_NameBox(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ sub_80CE760();
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!UpdatePaletteFade())
+ {
+ sWhichToReshow = 1;
+ sPSSData->screenChangeType = SCREEN_CHANGE_NAME_BOX;
+ SetPSSCallback(Cb_ChangeScreen);
+ }
+ break;
+ }
+}
+
+static void Cb_ShowMonSummary(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ sub_80CE7E8();
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!UpdatePaletteFade())
+ {
+ sWhichToReshow = 0;
+ sPSSData->screenChangeType = SCREEN_CHANGE_SUMMARY_SCREEN;
+ SetPSSCallback(Cb_ChangeScreen);
+ }
+ break;
+ }
+}
+
+static void Cb_GiveItemFromBag(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
+ sPSSData->state++;
+ break;
+ case 1:
+ if (!UpdatePaletteFade())
+ {
+ sWhichToReshow = 2;
+ sPSSData->screenChangeType = SCREEN_CHANGE_ITEM_FROM_BAG;
+ SetPSSCallback(Cb_ChangeScreen);
+ }
+ break;
+ }
+}
+
+static void Cb_OnCloseBoxPressed(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ if (IsMonBeingMoved())
+ {
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_HOLDING_POKE);
+ sPSSData->state = 1;
+ }
+ else if (IsActiveItemMoving())
+ {
+ SetPSSCallback(Cb_CloseBoxWhileHoldingItem);
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ PrintStorageActionText(PC_TEXT_EXIT_BOX);
+ ShowYesNoWindow(0);
+ sPSSData->state = 2;
+ }
+ break;
+ case 1:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ case 2:
+ switch (Menu_ProcessInputNoWrapClearOnChoose())
+ {
+ case MENU_B_PRESSED:
+ case 1:
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ case 0:
+ PlaySE(SE_PC_OFF);
+ ClearBottomWindow();
+ sPSSData->state++;
+ break;
+ }
+ break;
+ case 3:
+ sub_80F9BF4(0x14, 0, 1);
+ sPSSData->state++;
+ break;
+ case 4:
+ if (!sub_80F9C30())
+ {
+ sub_80CABE0();
+ gPlayerPartyCount = CalculatePlayerPartyCount();
+ sPSSData->screenChangeType = SCREEN_CHANGE_EXIT_BOX;
+ SetPSSCallback(Cb_ChangeScreen);
+ }
+ break;
+ }
+}
+
+static void Cb_OnBPressed(u8 taskId)
+{
+ switch (sPSSData->state)
+ {
+ case 0:
+ if (IsMonBeingMoved())
+ {
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_HOLDING_POKE);
+ sPSSData->state = 1;
+ }
+ else if (IsActiveItemMoving())
+ {
+ SetPSSCallback(Cb_CloseBoxWhileHoldingItem);
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ PrintStorageActionText(PC_TEXT_CONTINUE_BOX);
+ ShowYesNoWindow(0);
+ sPSSData->state = 2;
+ }
+ break;
+ case 1:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MainPSS);
+ }
+ break;
+ case 2:
+ switch (Menu_ProcessInputNoWrapClearOnChoose())
+ {
+ case 0:
+ ClearBottomWindow();
+ SetPSSCallback(Cb_MainPSS);
+ break;
+ case 1:
+ case MENU_B_PRESSED:
+ PlaySE(SE_PC_OFF);
+ ClearBottomWindow();
+ sPSSData->state++;
+ break;
+ }
+ break;
+ case 3:
+ sub_80F9BF4(0x14, 0, 0);
+ sPSSData->state++;
+ break;
+ case 4:
+ if (!sub_80F9C30())
+ {
+ sub_80CABE0();
+ gPlayerPartyCount = CalculatePlayerPartyCount();
+ sPSSData->screenChangeType = SCREEN_CHANGE_EXIT_BOX;
+ SetPSSCallback(Cb_ChangeScreen);
+ }
+ break;
+ }
+}
+
+static void Cb_ChangeScreen(u8 taskId)
+{
+ struct BoxPokemon *boxMons;
+ u8 mode, monIndex, maxMonIndex;
+ u8 screenChangeType = sPSSData->screenChangeType;
+
+ if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS && IsActiveItemMoving() == TRUE)
+ gUnknown_02039D12 = GetMovingItem();
+ else
+ gUnknown_02039D12 = 0;
+
+ switch (screenChangeType)
+ {
+ case SCREEN_CHANGE_EXIT_BOX:
+ default:
+ FreePSSData();
+ SetMainCallback2(Cb2_ExitPSS);
+ break;
+ case SCREEN_CHANGE_SUMMARY_SCREEN:
+ boxMons = sPSSData->field_218C.box;
+ monIndex = sPSSData->field_2187;
+ maxMonIndex = sPSSData->field_2186;
+ mode = sPSSData->field_2188;
+ FreePSSData();
+ if (mode == PSS_MODE_NORMAL && boxMons == &gUnknown_02039D14.box)
+ ShowPokemonSummaryScreenSet40EF(mode, boxMons, monIndex, maxMonIndex, Cb2_ReturnToPSS);
+ else
+ ShowPokemonSummaryScreen(mode, boxMons, monIndex, maxMonIndex, Cb2_ReturnToPSS);
+ break;
+ case SCREEN_CHANGE_NAME_BOX:
+ FreePSSData();
+ DoNamingScreen(NAMING_SCREEN_BOX, GetBoxNamePtr(StorageGetCurrentBox()), 0, 0, 0, Cb2_ReturnToPSS);
+ break;
+ case SCREEN_CHANGE_ITEM_FROM_BAG:
+ FreePSSData();
+ GoToBagMenu(11, 0, Cb2_ReturnToPSS);
+ break;
+ }
+
+ DestroyTask(taskId);
+}
+
+static void GiveChosenBagItem(void)
+{
+ u16 item = gSpecialVar_ItemId;
+
+ if (item != 0)
+ {
+ u8 id = GetBoxCursorPosition();
+
+ if (sInPartyMenu)
+ SetMonData(&gPlayerParty[id], MON_DATA_HELD_ITEM, &item);
+ else
+ SetCurrentBoxMonData(id, MON_DATA_HELD_ITEM, &item);
+
+ RemoveBagItem(item, 1);
+ }
+}
+
+static void FreePSSData(void)
+{
+ sub_80D25F0();
+ sub_80D01B8();
+ FREE_AND_SET_NULL(sPSSData);
+ FreeAllWindowBuffers();
+}
+
+static void SetScrollingBackground(void)
+{
+ SetGpuReg(REG_OFFSET_BG3CNT, BGCNT_PRIORITY(3) | BGCNT_CHARBASE(3) | BGCNT_16COLOR | BGCNT_SCREENBASE(31));
+ DecompressAndLoadBgGfxUsingHeap(3, gPokemonStorageScrollingBGTileset, 0, 0, 0);
+ LZ77UnCompVram(gPokemonStorageScrollingBGTilemap, (void *)VRAM + 0xF800);
+}
+
+static void ScrollBackground(void)
+{
+ ChangeBgX(3, 128, 1);
+ ChangeBgY(3, 128, 2);
+}
+
+static void LoadPSSMenuGfx(void)
+{
+ InitBgsFromTemplates(0, gUnknown_08572734, ARRAY_COUNT(gUnknown_08572734));
+ DecompressAndLoadBgGfxUsingHeap(1, gPSSMenu_Gfx, 0, 0, 0);
+ LZ77UnCompWram(gUnknown_085722A0, sPSSData->field_5AC4);
+ SetBgTilemapBuffer(1, sPSSData->field_5AC4);
+ ShowBg(1);
+ schedule_bg_copy_tilemap_to_vram(1);
+}
+
+static bool8 InitPSSWindows(void)
+{
+ if (!InitWindows(gUnknown_08572714))
+ {
+ return FALSE;
+ }
+ else
+ {
+ DeactivateAllTextPrinters();
+ return TRUE;
+ }
+}
+
+static void LoadWaveformSpritePalette(void)
+{
+ LoadSpritePalette(&gWaveformSpritePalette);
+}
+
+static void sub_80CA0D8(void)
+{
+ LoadPalette(gUnknown_085723DC, 0, 0x20);
+ LoadPalette(gUnknown_085723FC, 0x20, 0x20);
+ LoadPalette(gUnknown_085726F4, 0xF0, 0x20);
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ LoadPalette(gUnknown_0857241C, 0x30, 0x20);
+ else
+ LoadPalette(gUnknown_0857243C, 0x30, 0x20);
+
+ SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_16COLOR | BGCNT_SCREENBASE(30));
+ LoadCursorMonSprite();
+ sub_80CA154();
+ sub_80CA1C4();
+ RefreshCursorMonData();
+}
+
+static void sub_80CA154(void)
+{
+ sPSSData->field_D94 = sub_811FFB4(TAG_TILE_10, TAG_PAL_DAC8, NULL);
+ sPSSData->field_D94->oam.priority = 1;
+ sPSSData->field_D94->subpriority = 1;
+ sPSSData->field_D94->pos1.x = 40;
+ sPSSData->field_D94->pos1.y = 150;
+ sPSSData->field_DA0 = (void*) OBJ_VRAM0 + 32 * GetSpriteTileStartByTag(TAG_TILE_10);
+}
+
+static void sub_80CA1C4(void)
+{
+ u16 i;
+ struct SpriteSheet sheet = gWaveformSpriteSheet;
+
+ LoadSpriteSheet(&sheet);
+ for (i = 0; i < 2; i++)
+ {
+ u8 spriteId = CreateSprite(&sSpriteTemplate_Waveform, i * 63 + 8, 9, 2);
+ sPSSData->field_D98[i] = &gSprites[spriteId];
+ }
+}
+
+static void RefreshCursorMonData(void)
+{
+ LoadCursorMonGfx(sPSSData->cursorMonSpecies, sPSSData->cursorMonPersonality);
+ PrintCursorMonInfo();
+ sub_80CA65C();
+ schedule_bg_copy_tilemap_to_vram(0);
+}
+
+static void BoxSetMosaic(void)
+{
+ RefreshCursorMonData();
+ if (sPSSData->cursorMonSprite)
+ {
+ sPSSData->cursorMonSprite->oam.mosaic = TRUE;
+ sPSSData->cursorMonSprite->data[0] = 10;
+ sPSSData->cursorMonSprite->data[1] = 1;
+ sPSSData->cursorMonSprite->callback = sub_80CA2D0;
+ SetGpuReg(REG_OFFSET_MOSAIC, (sPSSData->cursorMonSprite->data[0] << 12) | (sPSSData->cursorMonSprite->data[0] << 8));
+ }
+}
+
+static u8 sub_80CA2B8(void)
+{
+ return sPSSData->cursorMonSprite->oam.mosaic;
+}
+
+static void sub_80CA2D0(struct Sprite *sprite)
+{
+ sprite->data[0] -= sprite->data[1];
+ if (sprite->data[0] < 0)
+ sprite->data[0] = 0;
+ SetGpuReg(REG_OFFSET_MOSAIC, (sprite->data[0] << 12) | (sprite->data[0] << 8));
+ if (sprite->data[0] == 0)
+ {
+ sprite->oam.mosaic = FALSE;
+ sprite->callback = SpriteCallbackDummy;
+ }
+}
+
+static void LoadCursorMonSprite(void)
+{
+ u16 i;
+ u16 tileStart;
+ u8 palSlot;
+ u8 spriteId;
+ struct SpriteSheet sheet = {sPSSData->field_22C4, 0x800, TAG_TILE_2};
+ struct SpritePalette palette = {sPSSData->field_2244, TAG_PAL_DAC6};
+ struct SpriteTemplate template = sSpriteTemplate_CursorMon;
+
+ for (i = 0; i < 0x800; i++)
+ sPSSData->field_22C4[i] = 0;
+ for (i = 0; i < 0x10; i++)
+ sPSSData->field_2244[i] = 0;
+
+ sPSSData->cursorMonSprite = NULL;
+
+ do
+ {
+ tileStart = LoadSpriteSheet(&sheet);
+ if (tileStart == 0)
+ break;
+
+ palSlot = LoadSpritePalette(&palette);
+ if (palSlot == 0xFF)
+ break;
+
+ spriteId = CreateSprite(&template, 40, 48, 0);
+ if (spriteId == MAX_SPRITES)
+ break;
+
+ sPSSData->cursorMonSprite = &gSprites[spriteId];
+ sPSSData->field_223A = palSlot * 16 + 0x100;
+ sPSSData->field_223C = (void*) OBJ_VRAM0 + tileStart * 32;
+ } while (0);
+
+ if (sPSSData->cursorMonSprite == NULL)
+ {
+ FreeSpriteTilesByTag(TAG_TILE_2);
+ FreeSpritePaletteByTag(TAG_PAL_DAC6);
+ }
+}
+
+static void LoadCursorMonGfx(u16 species, u32 pid)
+{
+ if (sPSSData->cursorMonSprite == NULL)
+ return;
+
+ if (species != SPECIES_NONE)
+ {
+ LoadSpecialPokePic(&gMonFrontPicTable[species], sPSSData->field_22C4, species, pid, TRUE);
+ LZ77UnCompWram(sPSSData->cursorMonPalette, sPSSData->field_2244);
+ CpuCopy32(sPSSData->field_22C4, sPSSData->field_223C, 0x800);
+ LoadPalette(sPSSData->field_2244, sPSSData->field_223A, 0x20);
+ sPSSData->cursorMonSprite->invisible = FALSE;
+ }
+ else
+ {
+ sPSSData->cursorMonSprite->invisible = TRUE;
+ }
+}
+
+static void PrintCursorMonInfo(void)
+{
+ FillWindowPixelBuffer(0, 0x11);
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ {
+ AddTextPrinterParameterized(0, 1, sPSSData->cursorMonNickText, 6, 0, TEXT_SPEED_FF, NULL);
+ AddTextPrinterParameterized(0, 2, sPSSData->cursorMonSpeciesName, 6, 15, TEXT_SPEED_FF, NULL);
+ AddTextPrinterParameterized(0, 2, sPSSData->cursorMonGenderLvlText, 10, 29, TEXT_SPEED_FF, NULL);
+ AddTextPrinterParameterized(0, 0, sPSSData->cursorMonItemName, 6, 43, TEXT_SPEED_FF, NULL);
+ }
+ else
+ {
+ AddTextPrinterParameterized(0, 0, sPSSData->cursorMonItemName, 6, 0, TEXT_SPEED_FF, NULL);
+ AddTextPrinterParameterized(0, 1, sPSSData->cursorMonNickText, 6, 13, TEXT_SPEED_FF, NULL);
+ AddTextPrinterParameterized(0, 2, sPSSData->cursorMonSpeciesName, 6, 28, TEXT_SPEED_FF, NULL);
+ AddTextPrinterParameterized(0, 2, sPSSData->cursorMonGenderLvlText, 10, 42, TEXT_SPEED_FF, NULL);
+ }
+
+ CopyWindowToVram(0, 2);
+ if (sPSSData->cursorMonSpecies != SPECIES_NONE)
+ {
+ sub_8120084(sPSSData->cursorMonMarkings, sPSSData->field_DA0);
+ sPSSData->field_D94->invisible = FALSE;
+ }
+ else
+ {
+ sPSSData->field_D94->invisible = TRUE;
+ }
+}
+
+static void sub_80CA65C(void)
+{
+ u16 i;
+
+ if (sPSSData->cursorMonSpecies != SPECIES_NONE)
+ {
+ sub_80D27AC(0, 0, 0, 8, 2);
+ for (i = 0; i < 2; i++)
+ StartSpriteAnimIfDifferent(sPSSData->field_D98[i], i * 2 + 1);
+ }
+ else
+ {
+ sub_80D27AC(0, 0, 2, 8, 2);
+ for (i = 0; i < 2; i++)
+ StartSpriteAnim(sPSSData->field_D98[i], i * 2);
+ }
+
+ sub_80D2918(0);
+ schedule_bg_copy_tilemap_to_vram(1);
+}
+
+static void sub_80CA704(void)
+{
+ LZ77UnCompWram(gUnknown_08DD36C8, sPSSData->field_B0);
+ LoadPalette(gPSSMenu_Pal, 0x10, 0x20);
+ sub_80D2644(1, 1, sPSSData->field_B0, 12, 22);
+ sub_80D2644(2, 1, gUnknown_0857245C, 9, 4);
+ sub_80D2770(1, 10, 0);
+ sub_80D2770(2, 21, 0);
+ sub_80CAA74();
+ if (sInPartyMenu)
+ {
+ sub_80CA984(TRUE);
+ CreatePartyMonsSprites(TRUE);
+ sub_80D2918(2);
+ sub_80D2918(1);
+ }
+ else
+ {
+ sub_80D27AC(1, 0, 20, 12, 2);
+ sub_80CA984(TRUE);
+ sub_80D2918(1);
+ sub_80D2918(2);
+ }
+
+ schedule_bg_copy_tilemap_to_vram(1);
+ sPSSData->unk_02C7 = 0;
+}
+
+static void SetUpShowPartyMenu(void)
+{
+ sPSSData->field_2C0 = 20;
+ sPSSData->field_2C2 = 2;
+ sPSSData->field_2C5 = 0;
+ CreatePartyMonsSprites(FALSE);
+}
+
+static bool8 ShowPartyMenu(void)
+{
+ if (sPSSData->field_2C5 == 20)
+ return FALSE;
+
+ sPSSData->field_2C0--;
+ sPSSData->field_2C2++;
+ sub_80D27F4(1, 3, 1);
+ sub_80D2918(1);
+ schedule_bg_copy_tilemap_to_vram(1);
+ sub_80CBAF0(8);
+ if (++sPSSData->field_2C5 == 20)
+ {
+ sInPartyMenu = TRUE;
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+}
+
+static void SetUpHidePartyMenu(void)
+{
+ sPSSData->field_2C0 = 0;
+ sPSSData->field_2C2 = 22;
+ sPSSData->field_2C5 = 0;
+ if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS)
+ sub_80D11CC();
+}
+
+static bool8 HidePartyMenu(void)
+{
+ if (sPSSData->field_2C5 != 20)
+ {
+ sPSSData->field_2C0++;
+ sPSSData->field_2C2--;
+ sub_80D27F4(1, 3, -1);
+ sub_80D2918(1);
+ FillBgTilemapBufferRect_Palette0(1, 0x100, 10, sPSSData->field_2C2, 12, 1);
+ sub_80CBAF0(-8);
+ if (++sPSSData->field_2C5 != 20)
+ {
+ schedule_bg_copy_tilemap_to_vram(1);
+ return TRUE;
+ }
+ else
+ {
+ sInPartyMenu = FALSE;
+ DestroyAllPartyMonIcons();
+ CompactPartySlots();
+ sub_80D27AC(2, 0, 0, 9, 2);
+ sub_80D2918(2);
+ schedule_bg_copy_tilemap_to_vram(1);
+ return FALSE;
+ }
+ }
+
+ return FALSE;
+}
+
+static void sub_80CA984(bool8 arg0)
+{
+ if (arg0)
+ sub_80D27AC(2, 0, 0, 9, 2);
+ else
+ sub_80D27AC(2, 0, 2, 9, 2);
+
+ sub_80D2918(2);
+ schedule_bg_copy_tilemap_to_vram(1);
+}
+
+static void sub_80CA9C0(void)
+{
+ sPSSData->unk_02C7 = 1;
+ sPSSData->unk_02C8 = 30;
+ sPSSData->unk_02C9 = TRUE;
+}
+
+static void sub_80CA9EC(void)
+{
+ if (sPSSData->unk_02C7)
+ {
+ sPSSData->unk_02C7 = 0;
+ sub_80CA984(TRUE);
+ }
+}
+
+static void sub_80CAA14(void)
+{
+ if (sPSSData->unk_02C7 && ++sPSSData->unk_02C8 > 30)
+ {
+ sPSSData->unk_02C8 = 0;
+ sPSSData->unk_02C9 = (sPSSData->unk_02C9 == FALSE);
+ sub_80CA984(sPSSData->unk_02C9);
+ }
+}
+
+static void sub_80CAA74(void)
+{
+ u8 i;
+
+ for (i = 1; i < PARTY_SIZE; i++)
+ {
+ s32 species = GetMonData(gPlayerParty + i, MON_DATA_SPECIES);
+ sub_80CAAA8(i, (species != SPECIES_NONE));
+ }
+}
+
+static void sub_80CAAA8(u8 arg0, bool8 isPartyMon)
+{
+ u16 i, j, index;
+ const u16 *data;
+
+ if (isPartyMon)
+ data = gUnknown_085724A4;
+ else
+ data = gUnknown_085724BC;
+
+ index = 3 * (3 * (arg0 - 1) + 1);
+ index *= 4;
+ index += 7;
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ sPSSData->field_B0[index + j] = data[j];
+ }
+ data += 4;
+ index += 12;
+ }
+}
+
+static void sub_80CAB20(void)
+{
+ sub_80CAA74();
+ sub_80D27AC(1, 0, 0, 12, 22);
+ sub_80D2918(1);
+ schedule_bg_copy_tilemap_to_vram(1);
+}
+
+static void SetUpDoShowPartyMenu(void)
+{
+ sPSSData->showPartyMenuState = 0;
+ PlaySE(SE_WIN_OPEN);
+ SetUpShowPartyMenu();
+}
+
+static bool8 DoShowPartyMenu(void)
+{
+ switch (sPSSData->showPartyMenuState)
+ {
+ case 0:
+ if (!ShowPartyMenu())
+ {
+ sub_80CDBA0();
+ sPSSData->showPartyMenuState++;
+ }
+ break;
+ case 1:
+ if (!sub_80CD554())
+ {
+ if (sPSSData->setMosaic)
+ BoxSetMosaic();
+ sPSSData->showPartyMenuState++;
+ }
+ break;
+ case 2:
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void sub_80CABE0(void)
+{
+ if (gUnknown_02039D10 != StorageGetCurrentBox())
+ {
+ FlagClear(FLAG_SYS_STORAGE_UNKNOWN_FLAG);
+ VarSet(VAR_STORAGE_UNKNOWN, StorageGetCurrentBox());
+ }
+}
+
+static void sub_80CAC1C(void)
+{
+ SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(29));
+ LoadUserWindowBorderGfx(1, 2, 208);
+ FillBgTilemapBufferRect(0, 0, 0, 0, 32, 20, 17);
+ CopyBgTilemapBufferToVram(0);
+}
+
+static void PrintStorageActionText(u8 id)
+{
+ u8 *txtPtr;
+
+ DynamicPlaceholderTextUtil_Reset();
+ switch (gPCStorageActionTexts[id].format)
+ {
+ case PC_TEXT_FMT_NORMAL:
+ break;
+ case PC_TEXT_FMT_MON_NAME_1:
+ case PC_TEXT_FMT_MON_NAME_2:
+ case PC_TEXT_FMT_MON_NAME_3:
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPSSData->cursorMonNick);
+ break;
+ case PC_TEXT_FMT_MON_NAME_4:
+ case PC_TEXT_FMT_MON_NAME_5:
+ case PC_TEXT_FMT_MON_NAME_6:
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPSSData->field_21E0);
+ break;
+ case PC_TEXT_FMT_ITEM_NAME:
+ if (IsActiveItemMoving())
+ txtPtr = StringCopy(sPSSData->itemName, GetMovingItemName());
+ else
+ txtPtr = StringCopy(sPSSData->itemName, sPSSData->cursorMonItemName);
+
+ while (*(txtPtr - 1) == CHAR_SPACE)
+ txtPtr--;
+
+ *txtPtr = EOS;
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPSSData->itemName);
+ break;
+ }
+
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(sPSSData->field_2190, gPCStorageActionTexts[id].text);
+ FillWindowPixelBuffer(1, 0x11);
+ AddTextPrinterParameterized(1, 1, sPSSData->field_2190, 0, 1, TEXT_SPEED_FF, NULL);
+ sub_8098858(1, 2, 14);
+ PutWindowTilemap(1);
+ CopyWindowToVram(1, 2);
+ schedule_bg_copy_tilemap_to_vram(0);
+}
+
+static void ShowYesNoWindow(s8 cursorPos)
+{
+ CreateYesNoMenu(&sYesNoWindowTemplate, 11, 14, 0);
+ Menu_MoveCursorNoWrapAround(cursorPos);
+}
+
+static void ClearBottomWindow(void)
+{
+ sub_8198070(1, FALSE);
+ schedule_bg_copy_tilemap_to_vram(0);
+}
+
+static void AddWallpaperSetsMenu(void)
+{
+ InitMenu();
+ SetMenuText(18);
+ SetMenuText(19);
+ SetMenuText(20);
+ SetMenuText(21);
+ if (IsWaldaWallpaperUnlocked())
+ SetMenuText(22);
+ AddMenu();
+}
+
+static void AddWallpapersMenu(u8 wallpaperSet)
+{
+ InitMenu();
+ switch (wallpaperSet)
+ {
+ case 0:
+ SetMenuText(23);
+ SetMenuText(24);
+ SetMenuText(25);
+ SetMenuText(26);
+ break;
+ case 1:
+ SetMenuText(27);
+ SetMenuText(28);
+ SetMenuText(29);
+ SetMenuText(30);
+ break;
+ case 2:
+ SetMenuText(31);
+ SetMenuText(32);
+ SetMenuText(33);
+ SetMenuText(34);
+ break;
+ case 3:
+ SetMenuText(35);
+ SetMenuText(36);
+ SetMenuText(37);
+ SetMenuText(38);
+ break;
+ }
+ AddMenu();
+}
+
+static u8 GetCurrentBoxOption(void)
+{
+ return sCurrentBoxOption;
+}
+
+static void sub_80CAEAC(void)
+{
+ if (!IsCursorOnBox())
+ {
+ if (sInPartyMenu)
+ sub_80D0D8C(CURSOR_AREA_IN_PARTY, GetBoxCursorPosition());
+ else
+ sub_80D0D8C(CURSOR_AREA_IN_BOX, GetBoxCursorPosition());
+ }
+
+ if (gUnknown_02039D12 != 0)
+ {
+ sub_80D0F38(gUnknown_02039D12);
+ sub_80CFE54(3);
+ }
+}
+
+static void sub_80CAF04(void)
+{
+ u16 i;
+
+ LoadMonIconPalettes();
+ for (i = 0; i < 40; i++)
+ sPSSData->field_B08[i] = 0;
+ for (i = 0; i < 40; i++)
+ sPSSData->field_B58[i] = 0;
+ for (i = 0; i < PARTY_SIZE; i++)
+ sPSSData->partySprites[i] = NULL;
+ for (i = 0; i < IN_BOX_COUNT; i++)
+ sPSSData->boxMonsSprites[i] = NULL;
+
+ sPSSData->movingMonSprite = NULL;
+ sPSSData->field_78C = 0;
+}
+
+static u8 sub_80CAFAC(void)
+{
+ return (IsCursorInBox() ? 2 : 1);
+}
+
+static void CreateMovingMonIcon(void)
+{
+ u32 personality = GetMonData(&sPSSData->movingMon, MON_DATA_PERSONALITY);
+ u16 species = GetMonData(&sPSSData->movingMon, MON_DATA_SPECIES2);
+ u8 priority = sub_80CAFAC();
+
+ sPSSData->movingMonSprite = CreateMonIconSprite(species, personality, 0, 0, priority, 7);
+ sPSSData->movingMonSprite->callback = sub_80CC100;
+}
+
+static void sub_80CB028(u8 boxId)
+{
+ u8 boxPosition;
+ u16 i, j, count;
+ u16 species;
+ u32 personality;
+
+ count = 0;
+ boxPosition = 0;
+ for (i = 0; i < IN_BOX_COLUMNS; i++)
+ {
+ for (j = 0; j < IN_BOX_ROWS; j++)
+ {
+ species = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2);
+ if (species != SPECIES_NONE)
+ {
+ personality = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY);
+ sPSSData->boxMonsSprites[count] = CreateMonIconSprite(species, personality, 8 * (3 * j) + 100, 8 * (3 * i) + 44, 2, 19 - j);
+ }
+ else
+ {
+ sPSSData->boxMonsSprites[count] = NULL;
+ }
+ boxPosition++;
+ count++;
+ }
+ }
+
+ if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS)
+ {
+ for (boxPosition = 0; boxPosition < IN_BOX_COUNT; boxPosition++)
+ {
+ if (GetBoxMonDataAt(boxId, boxPosition, MON_DATA_HELD_ITEM) == 0)
+ sPSSData->boxMonsSprites[boxPosition]->oam.objMode = 1;
+ }
+ }
+}
+
+static void sub_80CB140(u8 boxPosition)
+{
+ u16 species = GetCurrentBoxMonData(boxPosition, MON_DATA_SPECIES2);
+
+ if (species != SPECIES_NONE)
+ {
+ s16 x = 8 * (3 * (boxPosition % IN_BOX_ROWS)) + 100;
+ s16 y = 8 * (3 * (boxPosition / IN_BOX_ROWS)) + 44;
+ u32 personality = GetCurrentBoxMonData(boxPosition, MON_DATA_PERSONALITY);
+
+ sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(species, personality, x, y, 2, 19 - (boxPosition % IN_BOX_ROWS));
+ if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS)
+ sPSSData->boxMonsSprites[boxPosition]->oam.objMode = 1;
+ }
+}
+
+static void sub_80CB1F0(s16 arg0)
+{
+ u16 i;
+
+ for (i = 0; i < IN_BOX_COUNT; i++)
+ {
+ if (sPSSData->boxMonsSprites[i] != NULL)
+ {
+ sPSSData->boxMonsSprites[i]->data[2] = arg0;
+ sPSSData->boxMonsSprites[i]->data[4] = 1;
+ sPSSData->boxMonsSprites[i]->callback = sub_80CB278;
+ }
+ }
+}
+
+static void sub_80CB234(struct Sprite *sprite)
+{
+ if (sprite->data[1] != 0)
+ {
+ sprite->data[1]--;
+ sprite->pos1.x += sprite->data[2];
+ }
+ else
+ {
+ sPSSData->field_C66--;
+ sprite->pos1.x = sprite->data[3];
+ sprite->callback = SpriteCallbackDummy;
+ }
+}
+
+static void sub_80CB278(struct Sprite *sprite)
+{
+ if (sprite->data[4] != 0)
+ {
+ sprite->data[4]--;
+ }
+ else
+ {
+ sprite->pos1.x += sprite->data[2];
+ sprite->data[5] = sprite->pos1.x + sprite->pos2.x;
+ if (sprite->data[5] <= 68 || sprite->data[5] >= 252)
+ sprite->callback = SpriteCallbackDummy;
+ }
+}
+
+static void DestroyAllIconsInRow(u8 row)
+{
+ u16 column;
+ u8 boxPosition = row;
+
+ for (column = 0; column < IN_BOX_COLUMNS; column++)
+ {
+ if (sPSSData->boxMonsSprites[boxPosition] != NULL)
+ {
+ DestroyBoxMonIcon(sPSSData->boxMonsSprites[boxPosition]);
+ sPSSData->boxMonsSprites[boxPosition] = NULL;
+ }
+ boxPosition += IN_BOX_ROWS;
+ }
+}
+
+static u8 sub_80CB2F8(u8 row, u16 times, s16 xDelta)
+{
+ s32 i;
+ u16 y = 44;
+ s16 xDest = 8 * (3 * row) + 100;
+ u16 x = xDest - ((times + 1) * xDelta);
+ u8 subpriority = 19 - row;
+ u8 count = 0;
+ u8 boxPosition = row;
+
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ {
+ for (i = 0; i < IN_BOX_COLUMNS; i++)
+ {
+ if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE)
+ {
+ sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(sPSSData->boxSpecies[boxPosition],
+ sPSSData->boxPersonalities[boxPosition],
+ x, y, 2, subpriority);
+ if (sPSSData->boxMonsSprites[boxPosition] != NULL)
+ {
+ sPSSData->boxMonsSprites[boxPosition]->data[1] = times;
+ sPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta;
+ sPSSData->boxMonsSprites[boxPosition]->data[3] = xDest;
+ sPSSData->boxMonsSprites[boxPosition]->callback = sub_80CB234;
+ count++;
+ }
+ }
+ boxPosition += IN_BOX_ROWS;
+ y += 24;
+ }
+ }
+ else
+ {
+ for (i = 0; i < IN_BOX_COLUMNS; i++)
+ {
+ if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE)
+ {
+ sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(sPSSData->boxSpecies[boxPosition],
+ sPSSData->boxPersonalities[boxPosition],
+ x, y, 2, subpriority);
+ if (sPSSData->boxMonsSprites[boxPosition] != NULL)
+ {
+ sPSSData->boxMonsSprites[boxPosition]->data[1] = times;
+ sPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta;
+ sPSSData->boxMonsSprites[boxPosition]->data[3] = xDest;
+ sPSSData->boxMonsSprites[boxPosition]->callback = sub_80CB234;
+ if (GetBoxMonDataAt(sPSSData->field_C5C, boxPosition, MON_DATA_HELD_ITEM) == 0)
+ sPSSData->boxMonsSprites[boxPosition]->oam.objMode = 1;
+ count++;
+ }
+ }
+ boxPosition += IN_BOX_ROWS;
+ y += 24;
+ }
+ }
+
+ return count;
+}
+
+static void sub_80CB4CC(u8 boxId, s8 direction)
+{
+ sPSSData->field_C6A = 0;
+ sPSSData->field_C6B = boxId;
+ sPSSData->field_C69 = direction;
+ sPSSData->field_C60 = 32;
+ sPSSData->field_C64 = -(6 * direction);
+ sPSSData->field_C66 = 0;
+ SetBoxSpeciesAndPersonalities(boxId);
+ if (direction > 0)
+ sPSSData->field_C68 = 0;
+ else
+ sPSSData->field_C68 = IN_BOX_ROWS - 1;
+
+ sPSSData->field_C62 = (24 * sPSSData->field_C68) + 100;
+ sub_80CB1F0(sPSSData->field_C64);
+}
+
+static bool8 sub_80CB584(void)
+{
+ if (sPSSData->field_C60 != 0)
+ sPSSData->field_C60--;
+
+ switch (sPSSData->field_C6A)
+ {
+ case 0:
+ sPSSData->field_C62 += sPSSData->field_C64;
+ if (sPSSData->field_C62 <= 64 || sPSSData->field_C62 >= 252)
+ {
+ DestroyAllIconsInRow(sPSSData->field_C68);
+ sPSSData->field_C62 += sPSSData->field_C69 * 24;
+ sPSSData->field_C6A++;
+ }
+ break;
+ case 1:
+ sPSSData->field_C62 += sPSSData->field_C64;
+ sPSSData->field_C66 += sub_80CB2F8(sPSSData->field_C68, sPSSData->field_C60, sPSSData->field_C64);
+ if ((sPSSData->field_C69 > 0 && sPSSData->field_C68 == IN_BOX_ROWS - 1)
+ || (sPSSData->field_C69 < 0 && sPSSData->field_C68 == 0))
+ {
+ sPSSData->field_C6A++;
+ }
+ else
+ {
+ sPSSData->field_C68 += sPSSData->field_C69;
+ sPSSData->field_C6A = 0;
+ }
+ break;
+ case 2:
+ if (sPSSData->field_C66 == 0)
+ {
+ sPSSData->field_C60++;
+ return FALSE;
+ }
+ break;
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void SetBoxSpeciesAndPersonalities(u8 boxId)
+{
+ s32 i, j, boxPosition;
+
+ boxPosition = 0;
+ for (i = 0; i < IN_BOX_COLUMNS; i++)
+ {
+ for (j = 0; j < IN_BOX_ROWS; j++)
+ {
+ sPSSData->boxSpecies[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2);
+ if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE)
+ sPSSData->boxPersonalities[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY);
+ boxPosition++;
+ }
+ }
+
+ sPSSData->field_C5C = boxId;
+}
+
+static void DestroyBoxMonIconAtPosition(u8 boxPosition)
+{
+ if (sPSSData->boxMonsSprites[boxPosition] != NULL)
+ {
+ DestroyBoxMonIcon(sPSSData->boxMonsSprites[boxPosition]);
+ sPSSData->boxMonsSprites[boxPosition] = NULL;
+ }
+}
+
+static void SetBoxMonIconObjMode(u8 boxPosition, u8 objMode)
+{
+ if (sPSSData->boxMonsSprites[boxPosition] != NULL)
+ {
+ sPSSData->boxMonsSprites[boxPosition]->oam.objMode = objMode;
+ }
+}
+
+static void CreatePartyMonsSprites(bool8 arg0)
+{
+ u16 i, count;
+ u16 species = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES2);
+ u32 personality = GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY);
+
+ sPSSData->partySprites[0] = CreateMonIconSprite(species, personality, 104, 64, 1, 12);
+ count = 1;
+ for (i = 1; i < PARTY_SIZE; i++)
+ {
+ species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2);
+ if (species != SPECIES_NONE)
+ {
+ personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY);
+ sPSSData->partySprites[i] = CreateMonIconSprite(species, personality, 152, 8 * (3 * (i - 1)) + 16, 1, 12);
+ count++;
+ }
+ else
+ {
+ sPSSData->partySprites[i] = NULL;
+ }
+ }
+
+ if (!arg0)
+ {
+ for (i = 0; i < count; i++)
+ {
+ sPSSData->partySprites[i]->pos1.y -= 160;
+ sPSSData->partySprites[i]->invisible = TRUE;
+ }
+ }
+
+ if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS)
+ {
+ for (i = 0; i < PARTY_SIZE; i++)
+ {
+ if (sPSSData->partySprites[i] != NULL && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == 0)
+ sPSSData->partySprites[i]->oam.objMode = 1;
+ }
+ }
+}
+
+static void sub_80CB950(void)
+{
+ u16 i, count;
+
+ sPSSData->field_C5E = 0;
+ for (i = 0, count = 0; i < PARTY_SIZE; i++)
+ {
+ if (sPSSData->partySprites[i] != NULL)
+ {
+ if (i != count)
+ {
+ sub_80CB9D0(sPSSData->partySprites[i], count);
+ sPSSData->partySprites[i] = NULL;
+ sPSSData->field_C5E++;
+ }
+ count++;
+ }
+ }
+}
+
+static u8 sub_80CB9BC(void)
+{
+ return sPSSData->field_C5E;
+}
+
+static void sub_80CB9D0(struct Sprite *sprite, u16 partyId)
+{
+ s16 x, y;
+
+ sprite->data[1] = partyId;
+ if (partyId == 0)
+ x = 104, y = 64;
+ else
+ x = 152, y = 8 * (3 * (partyId - 1)) + 16;
+
+ sprite->data[2] = (u16)(sprite->pos1.x) * 8;
+ sprite->data[3] = (u16)(sprite->pos1.y) * 8;
+ sprite->data[4] = ((x * 8) - sprite->data[2]) / 8;
+ sprite->data[5] = ((y * 8) - sprite->data[3]) / 8;
+ sprite->data[6] = 8;
+ sprite->callback = sub_80CBA3C;
+}
+
+static void sub_80CBA3C(struct Sprite *sprite)
+{
+ if (sprite->data[6] != 0)
+ {
+ s16 x = sprite->data[2] += sprite->data[4];
+ s16 y = sprite->data[3] += sprite->data[5];
+ sprite->pos1.x = x / 8u;
+ sprite->pos1.y = y / 8u;
+ sprite->data[6]--;
+ }
+ else
+ {
+ if (sprite->data[1] == 0)
+ {
+ sprite->pos1.x = 104;
+ sprite->pos1.y = 64;
+ }
+ else
+ {
+ sprite->pos1.x = 152;
+ sprite->pos1.y = 8 * (3 * (sprite->data[1] - 1)) + 16;
+ }
+ sprite->callback = SpriteCallbackDummy;
+ sPSSData->partySprites[sprite->data[1]] = sprite;
+ sPSSData->field_C5E--;
+ }
+}
+
+static void DestroyMovingMonIcon(void)
+{
+ if (sPSSData->movingMonSprite != NULL)
+ {
+ DestroyBoxMonIcon(sPSSData->movingMonSprite);
+ sPSSData->movingMonSprite = NULL;
+ }
+}
+
+static void sub_80CBAF0(s16 yDelta)
+{
+ u16 i, posY;
+
+ for (i = 0; i < PARTY_SIZE; i++)
+ {
+ if (sPSSData->partySprites[i] != NULL)
+ {
+ sPSSData->partySprites[i]->pos1.y += yDelta;
+ posY = sPSSData->partySprites[i]->pos1.y + sPSSData->partySprites[i]->pos2.y + sPSSData->partySprites[i]->centerToCornerVecY;
+ posY += 16;
+ if (posY > 192)
+ sPSSData->partySprites[i]->invisible = TRUE;
+ else
+ sPSSData->partySprites[i]->invisible = FALSE;
+ }
+ }
+}
+
+static void DestroyPartyMonIcon(u8 partyId)
+{
+ if (sPSSData->partySprites[partyId] != NULL)
+ {
+ DestroyBoxMonIcon(sPSSData->partySprites[partyId]);
+ sPSSData->partySprites[partyId] = NULL;
+ }
+}
+
+static void DestroyAllPartyMonIcons(void)
+{
+ u16 i;
+
+ for (i = 0; i < PARTY_SIZE; i++)
+ {
+ if (sPSSData->partySprites[i] != NULL)
+ {
+ DestroyBoxMonIcon(sPSSData->partySprites[i]);
+ sPSSData->partySprites[i] = NULL;
+ }
+ }
+}
+
+static void SetPartyMonIconObjMode(u8 partyId, u8 objMode)
+{
+ if (sPSSData->partySprites[partyId] != NULL)
+ {
+ sPSSData->partySprites[partyId]->oam.objMode = objMode;
+ }
+}
+
+static void sub_80CBC14(u8 mode, u8 id)
+{
+ if (mode == MODE_PARTY)
+ {
+ sPSSData->movingMonSprite = sPSSData->partySprites[id];
+ sPSSData->partySprites[id] = NULL;
+ }
+ else if (mode == MODE_BOX)
+ {
+ sPSSData->movingMonSprite = sPSSData->boxMonsSprites[id];
+ sPSSData->boxMonsSprites[id] = NULL;
+ }
+ else
+ {
+ return;
+ }
+
+ sPSSData->movingMonSprite->callback = sub_80CC100;
+ sPSSData->movingMonSprite->oam.priority = sub_80CAFAC();
+ sPSSData->movingMonSprite->subpriority = 7;
+}
+
+static void sub_80CBCAC(u8 boxId, u8 position)
+{
+ if (boxId == TOTAL_BOXES_COUNT) // party mon
+ {
+ sPSSData->partySprites[position] = sPSSData->movingMonSprite;
+ sPSSData->partySprites[position]->oam.priority = 1;
+ sPSSData->partySprites[position]->subpriority = 12;
+ }
+ else
+ {
+ sPSSData->boxMonsSprites[position] = sPSSData->movingMonSprite;
+ sPSSData->boxMonsSprites[position]->oam.priority = 2;
+ sPSSData->boxMonsSprites[position]->subpriority = 19 - (position % IN_BOX_ROWS);
+ }
+ sPSSData->movingMonSprite->callback = SpriteCallbackDummy;
+ sPSSData->movingMonSprite = NULL;
+}
+
+static void sub_80CBD5C(u8 boxId, u8 position)
+{
+ if (boxId == TOTAL_BOXES_COUNT) // party mon
+ sPSSData->field_B00 = &sPSSData->partySprites[position];
+ else
+ sPSSData->field_B00 = &sPSSData->boxMonsSprites[position];
+
+ sPSSData->movingMonSprite->callback = SpriteCallbackDummy;
+ sPSSData->field_C5D = 0;
+}
+
+static bool8 sub_80CBDC4(void)
+{
+ if (sPSSData->field_C5D == 16)
+ return FALSE;
+
+ sPSSData->field_C5D++;
+ if (sPSSData->field_C5D & 1)
+ {
+ (*sPSSData->field_B00)->pos1.y--;
+ sPSSData->movingMonSprite->pos1.y++;
+ }
+
+ (*sPSSData->field_B00)->pos2.x = gSineTable[sPSSData->field_C5D * 8] / 16;
+ sPSSData->movingMonSprite->pos2.x = -(gSineTable[sPSSData->field_C5D * 8] / 16);
+ if (sPSSData->field_C5D == 8)
+ {
+ sPSSData->movingMonSprite->oam.priority = (*sPSSData->field_B00)->oam.priority;
+ sPSSData->movingMonSprite->subpriority = (*sPSSData->field_B00)->subpriority;
+ (*sPSSData->field_B00)->oam.priority = sub_80CAFAC();
+ (*sPSSData->field_B00)->subpriority = 7;
+ }
+
+ if (sPSSData->field_C5D == 16)
+ {
+ struct Sprite *sprite = sPSSData->movingMonSprite;
+ sPSSData->movingMonSprite = (*sPSSData->field_B00);
+ *sPSSData->field_B00 = sprite;
+
+ sPSSData->movingMonSprite->callback = sub_80CC100;
+ (*sPSSData->field_B00)->callback = SpriteCallbackDummy;
+ }
+
+ return TRUE;
+}
+
+static void sub_80CBF14(u8 mode, u8 position)
+{
+ switch (mode)
+ {
+ case MODE_PARTY:
+ sPSSData->field_B04 = &sPSSData->partySprites[position];
+ break;
+ case MODE_BOX:
+ sPSSData->field_B04 = &sPSSData->boxMonsSprites[position];
+ break;
+ case MODE_2:
+ sPSSData->field_B04 = &sPSSData->movingMonSprite;
+ break;
+ default:
+ return;
+ }
+
+ if (*sPSSData->field_B04 != NULL)
+ {
+ InitSpriteAffineAnim(*sPSSData->field_B04);
+ (*sPSSData->field_B04)->oam.affineMode = 1;
+ (*sPSSData->field_B04)->affineAnims = gSpriteAffineAnimTable_857291C;
+ StartSpriteAffineAnim(*sPSSData->field_B04, 0);
+ }
+}
+
+static bool8 sub_80CBFD8(void)
+{
+ if (*sPSSData->field_B04 == NULL || (*sPSSData->field_B04)->invisible)
+ return FALSE;
+
+ if ((*sPSSData->field_B04)->affineAnimEnded)
+ (*sPSSData->field_B04)->invisible = TRUE;
+
+ return TRUE;
+}
+
+static void sub_80CC020(void)
+{
+ if (*sPSSData->field_B04 != NULL)
+ {
+ FreeOamMatrix((*sPSSData->field_B04)->oam.matrixNum);
+ DestroyBoxMonIcon(*sPSSData->field_B04);
+ *sPSSData->field_B04 = NULL;
+ }
+}
+
+static void sub_80CC064(void)
+{
+ if (*sPSSData->field_B04 != NULL)
+ {
+ (*sPSSData->field_B04)->invisible = FALSE;
+ StartSpriteAffineAnim(*sPSSData->field_B04, 1);
+ }
+}
+
+static bool8 sub_80CC0A0(void)
+{
+ if (sPSSData->field_B04 == NULL)
+ return FALSE;
+
+ if ((*sPSSData->field_B04)->affineAnimEnded)
+ sPSSData->field_B04 = NULL;
+
+ return TRUE;
+}
+
+static void SetMovingMonPriority(u8 priority)
+{
+ sPSSData->movingMonSprite->oam.priority = priority;
+}
+
+static void sub_80CC100(struct Sprite *sprite)
+{
+ sprite->pos1.x = sPSSData->field_CB4->pos1.x;
+ sprite->pos1.y = sPSSData->field_CB4->pos1.y + sPSSData->field_CB4->pos2.y + 4;
+}
+
+static u16 sub_80CC124(u16 species)
+{
+ u16 i, var;
+
+ for (i = 0; i < 40; i++)
+ {
+ if (sPSSData->field_B58[i] == species)
+ break;
+ }
+
+ if (i == 40)
+ {
+ for (i = 0; i < 40; i++)
+ {
+ if (sPSSData->field_B58[i] == 0)
+ break;
+ }
+ if (i == 40)
+ return 0xFFFF;
+ }
+
+ sPSSData->field_B58[i] = species;
+ sPSSData->field_B08[i]++;
+ var = 16 * i;
+ CpuCopy32(GetMonIconTiles(species, TRUE), (void*)(OBJ_VRAM0) + var * 32, 0x200);
+
+ return var;
+}
+
+static void sub_80CC1E0(u16 species)
+{
+ u16 i;
+
+ for (i = 0; i < 40; i++)
+ {
+ if (sPSSData->field_B58[i] == species)
+ {
+ if (--sPSSData->field_B08[i] == 0)
+ sPSSData->field_B58[i] = 0;
+ break;
+ }
+ }
+}
+
+static struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 oamPriority, u8 subpriority)
+{
+ u16 tileNum;
+ u8 spriteId;
+ struct SpriteTemplate tempalte = gUnknown_085728D4;
+
+ species = GetIconSpecies(species, personality);
+ tempalte.paletteTag = 0xDAC0 + gMonIconPaletteIndices[species];
+ tileNum = sub_80CC124(species);
+ if (tileNum == 0xFFFF)
+ return NULL;
+
+ spriteId = CreateSprite(&tempalte, x, y, subpriority);
+ if (spriteId == MAX_SPRITES)
+ {
+ sub_80CC1E0(species);
+ return NULL;
+ }
+
+ gSprites[spriteId].oam.tileNum = tileNum;
+ gSprites[spriteId].oam.priority = oamPriority;
+ gSprites[spriteId].data[0] = species;
+ return &gSprites[spriteId];
+}
+
+static void DestroyBoxMonIcon(struct Sprite *sprite)
+{
+ sub_80CC1E0(sprite->data[0]);
+ DestroySprite(sprite);
+}
+
+static void sub_80CC32C(u8 boxId)
+{
+ u8 taskId = CreateTask(sub_80CC370, 2);
+
+ gTasks[taskId].data[2] = boxId;
+}
+
+static bool8 sub_80CC35C(void)
+{
+ return FuncIsActiveTask(sub_80CC370);
+}
+
+static void sub_80CC370(u8 taskId)
+{
+ struct Task *task = &gTasks[taskId];
+
+ switch (task->data[0])
+ {
+ case 0:
+ sPSSData->field_2D2 = 0;
+ sPSSData->bg2_X = 0;
+ task->data[1] = RequestDma3Fill(0, sPSSData->field_4AC4, 0x1000, 1);
+ break;
+ case 1:
+ if (CheckForSpaceForDma3Request(task->data[1]) == -1)
+ return;
+
+ SetBgTilemapBuffer(2, sPSSData->field_4AC4);
+ ShowBg(2);
+ break;
+ case 2:
+ LoadWallpaperGfx(task->data[2], 0);
+ break;
+ case 3:
+ if (!WaitForWallpaperGfxLoad())
+ return;
+
+ sub_80CCB50(task->data[2]);
+ sub_80CD02C();
+ sub_80CB028(task->data[2]);
+ SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(27) | BGCNT_TXT512x256);
+ break;
+ case 4:
+ DestroyTask(taskId);
+ break;
+ default:
+ task->data[0] = 0;
+ return;
+ }
+
+ task->data[0]++;
+}
+
+static void SetUpScrollToBox(u8 boxId)
+{
+ s8 direction = sub_80CC644(boxId);
+
+ sPSSData->field_2CE = (direction > 0) ? 6 : -6;
+ sPSSData->field_2D3 = (direction > 0) ? 1 : 2;
+ sPSSData->field_2D0 = 32;
+ sPSSData->field_2D4 = boxId;
+ sPSSData->field_2D6 = (direction <= 0) ? 5 : 0;
+ sPSSData->field_2D8 = direction;
+ sPSSData->field_2DA = (direction > 0) ? 264 : 56;
+ sPSSData->field_2DC = (direction <= 0) ? 5 : 0;
+ sPSSData->field_2DE = 0;
+ sPSSData->field_2E0 = 2;
+ sPSSData->field_A64 = boxId;
+ sPSSData->field_A65 = direction;
+ sPSSData->field_A63 = 0;
+}
+
+static bool8 ScrollToBox(void)
+{
+ bool8 var;
+
+ switch (sPSSData->field_A63)
+ {
+ case 0:
+ LoadWallpaperGfx(sPSSData->field_A64, sPSSData->field_A65);
+ sPSSData->field_A63++;
+ case 1:
+ if (!WaitForWallpaperGfxLoad())
+ return TRUE;
+
+ sub_80CB4CC(sPSSData->field_A64, sPSSData->field_A65);
+ sub_80CCCFC(sPSSData->field_A64, sPSSData->field_A65);
+ sub_80CD0B8(sPSSData->field_A65);
+ break;
+ case 2:
+ var = sub_80CB584();
+ if (sPSSData->field_2D0 != 0)
+ {
+ sPSSData->bg2_X += sPSSData->field_2CE;
+ if (--sPSSData->field_2D0 != 0)
+ return TRUE;
+ sub_80CCEE0();
+ sub_80CD158();
+ }
+ return var;
+ }
+
+ sPSSData->field_A63++;
+ return TRUE;
+}
+
+static s8 sub_80CC644(u8 boxId)
+{
+ u8 i;
+ u8 currentBox = StorageGetCurrentBox();
+
+ for (i = 0; currentBox != boxId; i++)
+ {
+ currentBox++;
+ if (currentBox >= TOTAL_BOXES_COUNT)
+ currentBox = 0;
+ }
+
+ return (i < TOTAL_BOXES_COUNT / 2) ? 1 : -1;
+}
+
+static void SetWallpaperForCurrentBox(u8 wallpaperId)
+{
+ u8 boxId = StorageGetCurrentBox();
+ SetBoxWallpaper(boxId, wallpaperId);
+ sPSSData->wallpaperChangeState = 0;
+}
+
+static bool8 DoWallpaperGfxChange(void)
+{
+ switch (sPSSData->wallpaperChangeState)
+ {
+ case 0:
+ BeginNormalPaletteFade(sPSSData->field_738, 1, 0, 16, RGB_WHITEALPHA);
+ sPSSData->wallpaperChangeState++;
+ break;
+ case 1:
+ if (!UpdatePaletteFade())
+ {
+ u8 curBox = StorageGetCurrentBox();
+ LoadWallpaperGfx(curBox, 0);
+ sPSSData->wallpaperChangeState++;
+ }
+ break;
+ case 2:
+ if (WaitForWallpaperGfxLoad() == TRUE)
+ {
+ sub_80CCF9C();
+ BeginNormalPaletteFade(sPSSData->field_738, 1, 16, 0, RGB_WHITEALPHA);
+ sPSSData->wallpaperChangeState++;
+ }
+ break;
+ case 3:
+ if (!UpdatePaletteFade())
+ sPSSData->wallpaperChangeState++;
+ break;
+ case 4:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void LoadWallpaperGfx(u8 boxId, s8 direction)
+{
+ u8 wallpaperId;
+ const struct WallpaperTable *wallpaperGfx;
+ void *iconGfx;
+ u32 size1, size2;
+
+ sPSSData->field_6F9 = 0;
+ sPSSData->field_6FA = boxId;
+ sPSSData->field_6FB = direction;
+ if (sPSSData->field_6FB != 0)
+ {
+ sPSSData->field_2D2 = (sPSSData->field_2D2 == 0);
+ sub_80CCAE0(sPSSData->field_4AC4);
+ }
+
+ wallpaperId = GetBoxWallpaper(sPSSData->field_6FA);
+ if (wallpaperId != WALLPAPER_FRIENDS)
+ {
+ wallpaperGfx = &gWallpaperTable[wallpaperId];
+ LZ77UnCompWram(wallpaperGfx->tileMap, sPSSData->field_792);
+ sub_80CCA3C(sPSSData->field_792, sPSSData->field_6FB, sPSSData->field_2D2);
+
+ if (sPSSData->field_6FB != 0)
+ LoadPalette(wallpaperGfx->palettes, (sPSSData->field_2D2 * 32) + 0x40, 0x40);
+ else
+ CpuCopy16(wallpaperGfx->palettes, &gPlttBufferUnfaded[(sPSSData->field_2D2 * 32) + 0x40], 0x40);
+
+ sPSSData->wallpaperTiles = malloc_and_decompress(wallpaperGfx->tiles, &size1);
+ LoadBgTiles(2, sPSSData->wallpaperTiles, size1, sPSSData->field_2D2 << 8);
+ }
+ else
+ {
+ wallpaperGfx = &gFriendsWallpaperTable[GetWaldaWallpaperPatternId()];
+ LZ77UnCompWram(wallpaperGfx->tileMap, sPSSData->field_792);
+ sub_80CCA3C(sPSSData->field_792, sPSSData->field_6FB, sPSSData->field_2D2);
+
+ CpuCopy16(wallpaperGfx->palettes, sPSSData->field_792, 0x40);
+ CpuCopy16(GetWaldaWallpaperColorsPtr(), &sPSSData->field_792[1], 4);
+ CpuCopy16(GetWaldaWallpaperColorsPtr(), &sPSSData->field_792[17], 4);
+
+ if (sPSSData->field_6FB != 0)
+ LoadPalette(sPSSData->field_792, (sPSSData->field_2D2 * 32) + 0x40, 0x40);
+ else
+ CpuCopy16(sPSSData->field_792, &gPlttBufferUnfaded[(sPSSData->field_2D2 * 32) + 0x40], 0x40);
+
+ sPSSData->wallpaperTiles = malloc_and_decompress(wallpaperGfx->tiles, &size1);
+ iconGfx = malloc_and_decompress(gFriendsIcons[GetWaldaWallpaperIconId()], &size2);
+ CpuCopy32(iconGfx, sPSSData->wallpaperTiles + 0x800, size2);
+ Free(iconGfx);
+ LoadBgTiles(2, sPSSData->wallpaperTiles, size1, sPSSData->field_2D2 << 8);
+ }
+
+ CopyBgTilemapBufferToVram(2);
+}
+
+static bool32 WaitForWallpaperGfxLoad(void)
+{
+ if (IsDma3ManagerBusyWithBgCopy())
+ return FALSE;
+
+ if (sPSSData->wallpaperTiles != NULL)
+ {
+ Free(sPSSData->wallpaperTiles);
+ sPSSData->wallpaperTiles = NULL;
+ }
+ return TRUE;
+}
+
+static void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2)
+{
+ s16 var = (arg2 * 2) + 3;
+ s16 x = ((sPSSData->bg2_X / 8 + 10) + (direction * 24)) & 0x3F;
+
+ CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, arg2 << 8, var);
+
+ if (direction == 0)
+ return;
+ else if (direction > 0)
+ x *= 1, x += 0x14; // x * 1 is needed to match, but can be safely removed as it makes no functional difference
+ else
+ x -= 4;
+
+ FillBgTilemapBufferRect(2, 0, x, 2, 4, 0x12, 0x11);
+}
+
+static void sub_80CCAE0(void *arg0)
+{
+ u16 i;
+ u16 *dest = arg0;
+ s16 r3 = ((sPSSData->bg2_X / 8) + 30) & 0x3F;
+
+ if (r3 <= 31)
+ dest += r3 + 0x260;
+ else
+ dest += r3 + 0x640;
+
+ for (i = 0; i < 0x2C; i++)
+ {
+ *dest++ = 0;
+ r3 = (r3 + 1) & 0x3F;
+ if (r3 == 0)
+ dest -= 0x420;
+ if (r3 == 0x20)
+ dest += 0x3e0;
+ }
+}
+
+static void sub_80CCB50(u8 boxId)
+{
+ u8 tagIndex;
+ s16 r6;
+ u16 i;
+
+ struct SpriteSheet spriteSheet = {sPSSData->field_2F8, 0x200, TAG_TILE_3};
+ struct SpritePalette palettes[] = {
+ {sPSSData->field_6FC, TAG_PAL_DAC9},
+ {}
+ };
+
+ u16 wallpaperId = GetBoxWallpaper(boxId);
+
+ sPSSData->field_6FC[14] = gUnknown_08577574[wallpaperId][0];
+ sPSSData->field_6FC[15] = gUnknown_08577574[wallpaperId][1];
+ LoadSpritePalettes(palettes);
+ sPSSData->field_738 = 0x3f0;
+
+ tagIndex = IndexOfSpritePaletteTag(TAG_PAL_DAC9);
+ sPSSData->field_71C = 0x10e + 16 * tagIndex;
+ sPSSData->field_738 |= 0x10000 << tagIndex;
+
+ tagIndex = IndexOfSpritePaletteTag(TAG_PAL_DAC9);
+ sPSSData->field_71E = 0x10e + 16 * tagIndex;
+ sPSSData->field_738 |= 0x10000 << tagIndex;
+
+ StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8);
+ sub_80C6D80(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, 2);
+ LoadSpriteSheet(&spriteSheet);
+ r6 = sub_80CD00C(GetBoxNamePtr(boxId));
+
+ for (i = 0; i < 2; i++)
+ {
+ u8 spriteId = CreateSprite(&gSpriteTemplate_857B0A8, r6 + i * 32, 28, 24);
+ sPSSData->field_720[i] = &gSprites[spriteId];
+ StartSpriteAnim(sPSSData->field_720[i], i);
+ }
+ sPSSData->field_6F8 = 0;
+}
+
+static void sub_80CCCFC(u8 boxId, s8 direction)
+{
+ u16 r8;
+ s16 x, x2;
+ u16 i;
+ struct SpriteSheet spriteSheet = {sPSSData->field_2F8, 0x200, TAG_TILE_3};
+ struct SpriteTemplate template = gSpriteTemplate_857B0A8;
+
+ sPSSData->field_6F8 = (sPSSData->field_6F8 == 0);
+ if (sPSSData->field_6F8 == 0)
+ {
+ spriteSheet.tag = TAG_TILE_3;
+ r8 = sPSSData->field_71C;
+ }
+ else
+ {
+ spriteSheet.tag = TAG_TILE_4;
+ r8 = sPSSData->field_71C;
+ template.tileTag = TAG_TILE_4;
+ template.paletteTag = TAG_PAL_DAC9;
+ }
+
+ StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8);
+ sub_80C6D80(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, 2);
+ LoadSpriteSheet(&spriteSheet);
+ LoadPalette(gUnknown_08577574[GetBoxWallpaper(boxId)], r8, 4);
+ x = sub_80CD00C(GetBoxNamePtr(boxId));
+ x2 = x;
+ x2 += direction * 192;
+
+ for (i = 0; i < 2; i++)
+ {
+ u8 spriteId = CreateSprite(&template, i * 32 + x2, 28, 24);
+
+ sPSSData->field_728[i] = &gSprites[spriteId];
+ sPSSData->field_728[i]->data[0] = (-direction) * 6;
+ sPSSData->field_728[i]->data[1] = i * 32 + x;
+ sPSSData->field_728[i]->data[2] = 0;
+ sPSSData->field_728[i]->callback = sub_80CCF30;
+ StartSpriteAnim(sPSSData->field_728[i], i);
+
+ sPSSData->field_720[i]->data[0] = (-direction) * 6;
+ sPSSData->field_720[i]->data[1] = 1;
+ sPSSData->field_720[i]->callback = sub_80CCF64;
+ }
+}
+
+static void sub_80CCEE0(void)
+{
+ if (sPSSData->field_6F8 == 0)
+ FreeSpriteTilesByTag(TAG_TILE_4);
+ else
+ FreeSpriteTilesByTag(TAG_TILE_3);
+
+ sPSSData->field_720[0] = sPSSData->field_728[0];
+ sPSSData->field_720[1] = sPSSData->field_728[1];
+}
+
+static void sub_80CCF30(struct Sprite *sprite)
+{
+ if (sprite->data[2] != 0)
+ sprite->data[2]--;
+ else if ((sprite->pos1.x += sprite->data[0]) == sprite->data[1])
+ sprite->callback = SpriteCallbackDummy;
+}
+
+static void sub_80CCF64(struct Sprite *sprite)
+{
+ if (sprite->data[1] != 0)
+ {
+ sprite->data[1]--;
+ }
+ else
+ {
+ sprite->pos1.x += sprite->data[0];
+ sprite->data[2] = sprite->pos1.x + sprite->pos2.x;
+ if (sprite->data[2] < 0x40 || sprite->data[2] > 0x100)
+ DestroySprite(sprite);
+ }
+}
+
+static void sub_80CCF9C(void)
+{
+ u8 boxId = StorageGetCurrentBox();
+ u8 wallpaperId = GetBoxWallpaper(boxId);
+ if (sPSSData->field_6F8 == 0)
+ CpuCopy16(gUnknown_08577574[wallpaperId], gPlttBufferUnfaded + sPSSData->field_71C, 4);
+ else
+ CpuCopy16(gUnknown_08577574[wallpaperId], gPlttBufferUnfaded + sPSSData->field_71E, 4);
+}
+
+static s16 sub_80CD00C(const u8 *string)
+{
+ return 0xB0 - GetStringWidth(1, string, 0) / 2;
+}
+
+static void sub_80CD02C(void)
+{
+ u16 i;
+
+ LoadSpriteSheet(&gUnknown_0857B080);
+ for (i = 0; i < 2; i++)
+ {
+ u8 spriteId = CreateSprite(&gUnknown_0857B0E0, 0x5c + i * 0x88, 28, 22);
+ if (spriteId != MAX_SPRITES)
+ {
+ struct Sprite *sprite = &gSprites[spriteId];
+ StartSpriteAnim(sprite, i);
+ sprite->data[3] = (i == 0) ? -1 : 1;
+ sPSSData->field_730[i] = sprite;
+ }
+ }
+ if (IsCursorOnBox())
+ sub_80CD1A8(TRUE);
+}
+
+static void sub_80CD0B8(s8 direction)
+{
+ u16 i;
+
+ for (i = 0; i < 2; i++)
+ {
+ sPSSData->field_730[i]->pos2.x = 0;
+ sPSSData->field_730[i]->data[0] = 2;
+ }
+ if (direction < 0)
+ {
+ sPSSData->field_730[0]->data[1] = 29;
+ sPSSData->field_730[1]->data[1] = 5;
+ sPSSData->field_730[0]->data[2] = 0x48;
+ sPSSData->field_730[1]->data[2] = 0x48;
+ }
+ else
+ {
+ sPSSData->field_730[0]->data[1] = 5;
+ sPSSData->field_730[1]->data[1] = 29;
+ sPSSData->field_730[0]->data[2] = 0xF8;
+ sPSSData->field_730[1]->data[2] = 0xF8;
+ }
+ sPSSData->field_730[0]->data[7] = 0;
+ sPSSData->field_730[1]->data[7] = 1;
+}
+
+static void sub_80CD158(void)
+{
+ u16 i;
+
+ for (i = 0; i < 2; i++)
+ {
+ sPSSData->field_730[i]->pos1.x = 0x88 * i + 0x5c;
+ sPSSData->field_730[i]->pos2.x = 0;
+ sPSSData->field_730[i]->invisible = FALSE;
+ }
+ sub_80CD1A8(TRUE);
+}
+
+static void sub_80CD1A8(bool8 a0)
+{
+ u16 i;
+
+ if (a0)
+ {
+ for (i = 0; i < 2; i++)
+ {
+ sPSSData->field_730[i]->data[0] = 1;
+ sPSSData->field_730[i]->data[1] = 0;
+ sPSSData->field_730[i]->data[2] = 0;
+ sPSSData->field_730[i]->data[4] = 0;
+ }
+ }
+ else
+ {
+ for (i = 0; i < 2; i++)
+ {
+ sPSSData->field_730[i]->data[0] = 0;
+ }
+ }
+}
+
+static void sub_80CD210(struct Sprite *sprite)
+{
+ switch (sprite->data[0])
+ {
+ case 0:
+ sprite->pos2.x = 0;
+ break;
+ case 1:
+ if (++sprite->data[1] > 3)
+ {
+ sprite->data[1] = 0;
+ sprite->pos2.x += sprite->data[3];
+ if (++sprite->data[2] > 5)
+ {
+ sprite->data[2] = 0;
+ sprite->pos2.x = 0;
+ }
+ }
+ break;
+ case 2:
+ sprite->data[0] = 3;
+ break;
+ case 3:
+ sprite->pos1.x -= sPSSData->field_2CE;
+ if (sprite->pos1.x < 73 || sprite->pos1.x > 247)
+ sprite->invisible = TRUE;
+ if (--sprite->data[1] == 0)
+ {
+ sprite->pos1.x = sprite->data[2];
+ sprite->invisible = FALSE;
+ sprite->data[0] = 4;
+ }
+ break;
+ case 4:
+ sprite->pos1.x -= sPSSData->field_2CE;
+ break;
+ }
+}
+
+static struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority)
+{
+ u8 spriteId = CreateSprite(&gUnknown_0857B0E0, x, y, subpriority);
+ if (spriteId == MAX_SPRITES)
+ return NULL;
+
+ animId %= 2;
+ StartSpriteAnim(&gSprites[spriteId], animId);
+ gSprites[spriteId].oam.priority = priority;
+ gSprites[spriteId].callback = SpriteCallbackDummy;
+ return &gSprites[spriteId];
+}
+
+static void sub_80CD36C(void)
+{
+ if (sPSSData->boxOption != BOX_OPTION_DEPOSIT)
+ sBoxCursorArea = CURSOR_AREA_IN_BOX;
+ else
+ sBoxCursorArea = CURSOR_AREA_IN_PARTY;
+
+ sBoxCursorPosition = 0;
+ sIsMonBeingMoved = FALSE;
+ sMovingMonOrigBoxId = 0;
+ sMovingMonOrigBoxPos = 0;
+ sCanOnlyMove = FALSE;
+ sub_80CDC0C();
+ sub_80CFC14();
+ sPSSData->field_CD6 = 1;
+ sPSSData->inBoxMovingMode = 0;
+ sub_80CEB40();
+}
+
+static void sub_80CD3EC(void)
+{
+ sub_80CFC14();
+ sub_80CEBDC();
+ sPSSData->field_CD6 = 1;
+ sPSSData->inBoxMovingMode = 0;
+ if (sIsMonBeingMoved)
+ {
+ sPSSData->movingMon = gUnknown_02039D14;
+ CreateMovingMonIcon();
+ }
+}
+
+static void sub_80CD444(u8 cursorArea, u8 cursorPosition, u16 *x, u16 *y)
+{
+ switch (cursorArea)
+ {
+ case CURSOR_AREA_IN_BOX:
+ *x = (cursorPosition % IN_BOX_ROWS) * 24 + 100;
+ *y = (cursorPosition / IN_BOX_ROWS) * 24 + 32;
+ break;
+ case CURSOR_AREA_IN_PARTY:
+ if (cursorPosition == 0)
+ {
+ *x = 0x68;
+ *y = 0x34;
+ }
+ else if (cursorPosition == PARTY_SIZE)
+ {
+ *x = 0x98;
+ *y = 0x84;
+ }
+ else
+ {
+ *x = 0x98;
+ *y = (cursorPosition - 1) * 24 + 4;
+ }
+ break;
+ case CURSOR_AREA_BOX:
+ *x = 0xa2;
+ *y = 0x0c;
+ break;
+ case CURSOR_AREA_BUTTONS:
+ *y = sIsMonBeingMoved ? 8 : 14;
+ *x = cursorPosition * 0x58 + 0x78;
+ break;
+ case 4:
+ *x = 0xa0;
+ *y = 0x60;
+ break;
+ }
+}
+
+static u16 sub_80CD504(void)
+{
+ switch (sBoxCursorArea)
+ {
+ case CURSOR_AREA_IN_PARTY:
+ return GetMonData(&gPlayerParty[sBoxCursorPosition], MON_DATA_SPECIES);
+ case CURSOR_AREA_IN_BOX:
+ return GetCurrentBoxMonData(sBoxCursorPosition, MON_DATA_SPECIES);
+ default:
+ return SPECIES_NONE;
+ }
+}
+
+static bool8 sub_80CD554(void)
+{
+ s16 tmp;
+
+ if (sPSSData->field_CD0 == 0)
+ {
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ return FALSE;
+ else
+ return sub_80D1218();
+ }
+ else if (--sPSSData->field_CD0 != 0)
+ {
+ sPSSData->field_CBC += sPSSData->field_CC4;
+ sPSSData->field_CC0 += sPSSData->field_CC8;
+ sPSSData->field_CB4->pos1.x = sPSSData->field_CBC >> 8;
+ sPSSData->field_CB4->pos1.y = sPSSData->field_CC0 >> 8;
+ if (sPSSData->field_CB4->pos1.x > 0x100)
+ {
+ tmp = sPSSData->field_CB4->pos1.x - 0x100;
+ sPSSData->field_CB4->pos1.x = tmp + 0x40;
+ }
+ if (sPSSData->field_CB4->pos1.x < 0x40)
+ {
+ tmp = 0x40 - sPSSData->field_CB4->pos1.x;
+ sPSSData->field_CB4->pos1.x = 0x100 - tmp;
+ }
+ if (sPSSData->field_CB4->pos1.y > 0xb0)
+ {
+ tmp = sPSSData->field_CB4->pos1.y - 0xb0;
+ sPSSData->field_CB4->pos1.y = tmp - 0x10;
+ }
+ if (sPSSData->field_CB4->pos1.y < -0x10)
+ {
+ tmp = -0x10 - sPSSData->field_CB4->pos1.y;
+ sPSSData->field_CB4->pos1.y = 0xb0 - tmp;
+ }
+ if (sPSSData->field_CD7 && --sPSSData->field_CD7 == 0)
+ sPSSData->field_CB4->vFlip = (sPSSData->field_CB4->vFlip == FALSE);
+ }
+ else
+ {
+ sPSSData->field_CB4->pos1.x = sPSSData->field_CCC;
+ sPSSData->field_CB4->pos1.y = sPSSData->field_CCE;
+ sub_80CDA68();
+ }
+
+ return TRUE;
+}
+
+static void sub_80CD6AC(u8 newCurosrArea, u8 newCursorPosition)
+{
+ u16 x, y;
+
+ sub_80CD444(newCurosrArea, newCursorPosition, &x, &y);
+ sPSSData->field_CD4 = newCurosrArea;
+ sPSSData->field_CD5 = newCursorPosition;
+ sPSSData->field_CCC = x;
+ sPSSData->field_CCE = y;
+}
+
+static void sub_80CD70C(void)
+{
+ int r7, r0;
+
+ if (sPSSData->field_CD2 != 0 || sPSSData->field_CD3 != 0)
+ sPSSData->field_CD0 = 12;
+ else
+ sPSSData->field_CD0 = 6;
+
+ if (sPSSData->field_CD7)
+ sPSSData->field_CD7 = sPSSData->field_CD0 >> 1;
+
+ switch (sPSSData->field_CD2)
+ {
+ default:
+ r7 = sPSSData->field_CCE - sPSSData->field_CB4->pos1.y;
+ break;
+ case -1:
+ r7 = sPSSData->field_CCE - 0xc0 - sPSSData->field_CB4->pos1.y;
+ break;
+ case 1:
+ r7 = sPSSData->field_CCE + 0xc0 - sPSSData->field_CB4->pos1.y;
+ break;
+ }
+
+ switch (sPSSData->field_CD3)
+ {
+ default:
+ r0 = sPSSData->field_CCC - sPSSData->field_CB4->pos1.x;
+ break;
+ case -1:
+ r0 = sPSSData->field_CCC - 0xc0 - sPSSData->field_CB4->pos1.x;
+ break;
+ case 1:
+ r0 = sPSSData->field_CCC + 0xc0 - sPSSData->field_CB4->pos1.x;
+ break;
+ }
+
+ r7 <<= 8;
+ r0 <<= 8;
+ sPSSData->field_CC4 = r0 / sPSSData->field_CD0;
+ sPSSData->field_CC8 = r7 / sPSSData->field_CD0;
+ sPSSData->field_CBC = sPSSData->field_CB4->pos1.x << 8;
+ sPSSData->field_CC0 = sPSSData->field_CB4->pos1.y << 8;
+}
+
+static void sub_80CD894(u8 newCurosrArea, u8 newCursorPosition)
+{
+ sub_80CD6AC(newCurosrArea, newCursorPosition);
+ sub_80CD70C();
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ {
+ if (sPSSData->inBoxMovingMode == 0 && !sIsMonBeingMoved)
+ StartSpriteAnim(sPSSData->field_CB4, 1);
+ }
+ else
+ {
+ if (!IsActiveItemMoving())
+ StartSpriteAnim(sPSSData->field_CB4, 1);
+ }
+
+ if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS)
+ {
+ if (sBoxCursorArea == CURSOR_AREA_IN_BOX)
+ sub_80D0E50(CURSOR_AREA_IN_BOX, sBoxCursorPosition);
+ else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY)
+ sub_80D0E50(CURSOR_AREA_IN_PARTY, sBoxCursorPosition);
+
+ if (newCurosrArea == CURSOR_AREA_IN_BOX)
+ sub_80D0D8C(newCurosrArea, newCursorPosition);
+ else if (newCurosrArea == CURSOR_AREA_IN_PARTY)
+ sub_80D0D8C(newCurosrArea, newCursorPosition);
+ }
+
+ if (newCurosrArea == CURSOR_AREA_IN_PARTY && sBoxCursorArea != CURSOR_AREA_IN_PARTY)
+ {
+ sPSSData->field_CD6 = newCurosrArea;
+ sPSSData->field_CB8->invisible = TRUE;
+ }
+
+ switch (newCurosrArea)
+ {
+ case CURSOR_AREA_IN_PARTY:
+ case CURSOR_AREA_BOX:
+ case CURSOR_AREA_BUTTONS:
+ sPSSData->field_CB4->oam.priority = 1;
+ sPSSData->field_CB8->invisible = TRUE;
+ sPSSData->field_CB8->oam.priority = 1;
+ break;
+ case CURSOR_AREA_IN_BOX:
+ if (sPSSData->inBoxMovingMode != 0)
+ {
+ sPSSData->field_CB4->oam.priority = 0;
+ sPSSData->field_CB8->invisible = TRUE;
+ }
+ else
+ {
+ sPSSData->field_CB4->oam.priority = 2;
+ if (sBoxCursorArea == CURSOR_AREA_IN_BOX && sIsMonBeingMoved)
+ SetMovingMonPriority(2);
+ }
+ break;
+ }
+}
+
+static void sub_80CDA68(void)
+{
+ sBoxCursorArea = sPSSData->field_CD4;
+ sBoxCursorPosition = sPSSData->field_CD5;
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ {
+ if (sPSSData->inBoxMovingMode == 0 && !sIsMonBeingMoved)
+ StartSpriteAnim(sPSSData->field_CB4, 0);
+ }
+ else
+ {
+ if (!IsActiveItemMoving())
+ StartSpriteAnim(sPSSData->field_CB4, 0);
+ }
+
+ sub_80CEB40();
+ switch (sBoxCursorArea)
+ {
+ case CURSOR_AREA_BUTTONS:
+ SetMovingMonPriority(1);
+ break;
+ case CURSOR_AREA_BOX:
+ sub_80CD1A8(TRUE);
+ break;
+ case CURSOR_AREA_IN_PARTY:
+ sPSSData->field_CB8->subpriority = 13;
+ SetMovingMonPriority(1);
+ break;
+ case CURSOR_AREA_IN_BOX:
+ if (sPSSData->inBoxMovingMode == 0)
+ {
+ sPSSData->field_CB4->oam.priority = 1;
+ sPSSData->field_CB8->oam.priority = 2;
+ sPSSData->field_CB8->subpriority = 21;
+ sPSSData->field_CB8->invisible = FALSE;
+ SetMovingMonPriority(2);
+ }
+ break;
+ }
+}
+
+static void sub_80CDBA0(void)
+{
+ u8 partyCount;
+
+ if (!sIsMonBeingMoved)
+ {
+ partyCount = 0;
+ }
+ else
+ {
+ partyCount = CalculatePlayerPartyCount();
+ if (partyCount >= PARTY_SIZE)
+ partyCount = PARTY_SIZE - 1;
+ }
+ if (sPSSData->field_CB4->vFlip)
+ sPSSData->field_CD7 = 1;
+ sub_80CD894(CURSOR_AREA_IN_PARTY, partyCount);
+}
+
+static void sub_80CDBF8(u8 cursorBoxPosition)
+{
+ sub_80CD894(CURSOR_AREA_IN_BOX, cursorBoxPosition);
+}
+
+EWRAM_DATA static u8 gUnknown_02039D7E = 0;
+
+static void sub_80CDC0C(void)
+{
+ gUnknown_02039D7E = 0;
+}
+
+static void sub_80CDC18(void)
+{
+ gUnknown_02039D7E = sBoxCursorPosition;
+}
+
+static u8 sub_80CDC2C(void)
+{
+ return gUnknown_02039D7E;
+}
+
+static void InitMonPlaceChange(u8 a0)
+{
+ static bool8 (*const placeChangeFuncs[])(void) =
+ {
+ MonPlaceChange_Move,
+ MonPlaceChange_Place,
+ MonPlaceChange_Shift,
+ };
+
+ sPSSData->monPlaceChangeFunc = placeChangeFuncs[a0];
+ sPSSData->monPlaceChangeState = 0;
+}
+
+static void sub_80CDC64(bool8 arg0)
+{
+ if (!arg0)
+ sPSSData->monPlaceChangeFunc = sub_80CDEB4;
+ else
+ sPSSData->monPlaceChangeFunc = sub_80CDEC4;
+
+ sPSSData->monPlaceChangeState = 0;
+}
+
+static bool8 DoMonPlaceChange(void)
+{
+ return sPSSData->monPlaceChangeFunc();
+}
+
+static bool8 MonPlaceChange_Move(void)
+{
+ switch (sPSSData->monPlaceChangeState)
+ {
+ case 0:
+ if (sIsMonBeingMoved)
+ return FALSE;
+ StartSpriteAnim(sPSSData->field_CB4, 2);
+ sPSSData->monPlaceChangeState++;
+ break;
+ case 1:
+ if (!sub_80CDED4())
+ {
+ StartSpriteAnim(sPSSData->field_CB4, 3);
+ MoveMon();
+ sPSSData->monPlaceChangeState++;
+ }
+ break;
+ case 2:
+ if (!sub_80CDF08())
+ sPSSData->monPlaceChangeState++;
+ break;
+ case 3:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static bool8 MonPlaceChange_Place(void)
+{
+ switch (sPSSData->monPlaceChangeState)
+ {
+ case 0:
+ if (!sub_80CDED4())
+ {
+ StartSpriteAnim(sPSSData->field_CB4, 2);
+ PlaceMon();
+ sPSSData->monPlaceChangeState++;
+ }
+ break;
+ case 1:
+ if (!sub_80CDF08())
+ {
+ StartSpriteAnim(sPSSData->field_CB4, 0);
+ sPSSData->monPlaceChangeState++;
+ }
+ break;
+ case 2:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static bool8 MonPlaceChange_Shift(void)
+{
+ switch (sPSSData->monPlaceChangeState)
+ {
+ case 0:
+ switch (sBoxCursorArea)
+ {
+ case CURSOR_AREA_IN_PARTY:
+ sPSSData->field_D91 = TOTAL_BOXES_COUNT;
+ break;
+ case CURSOR_AREA_IN_BOX:
+ sPSSData->field_D91 = StorageGetCurrentBox();
+ break;
+ default:
+ return FALSE;
+ }
+ StartSpriteAnim(sPSSData->field_CB4, 2);
+ sub_80CBD5C(sPSSData->field_D91, sBoxCursorPosition);
+ sPSSData->monPlaceChangeState++;
+ break;
+ case 1:
+ if (!sub_80CBDC4())
+ {
+ StartSpriteAnim(sPSSData->field_CB4, 3);
+ SetShiftedMonData(sPSSData->field_D91, sBoxCursorPosition);
+ sPSSData->monPlaceChangeState++;
+ }
+ break;
+ case 2:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static bool8 sub_80CDEB4(void)
+{
+ return sub_80CDED4();
+}
+
+static bool8 sub_80CDEC4(void)
+{
+ return sub_80CDF08();
+}
+
+static bool8 sub_80CDED4(void)
+{
+ switch (sPSSData->field_CB4->pos2.y)
+ {
+ default:
+ sPSSData->field_CB4->pos2.y++;
+ break;
+ case 0:
+ sPSSData->field_CB4->pos2.y++;
+ break;
+ case 8:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static bool8 sub_80CDF08(void)
+{
+ switch (sPSSData->field_CB4->pos2.y)
+ {
+ case 0:
+ return FALSE;
+ default:
+ sPSSData->field_CB4->pos2.y--;
+ break;
+ }
+
+ return TRUE;
+}
+
+static void MoveMon(void)
+{
+ switch (sBoxCursorArea)
+ {
+ case CURSOR_AREA_IN_PARTY:
+ SetMovedMonData(TOTAL_BOXES_COUNT, sBoxCursorPosition);
+ sub_80CBC14(MODE_PARTY, sBoxCursorPosition);
+ break;
+ case CURSOR_AREA_IN_BOX:
+ if (sPSSData->inBoxMovingMode == 0)
+ {
+ SetMovedMonData(StorageGetCurrentBox(), sBoxCursorPosition);
+ sub_80CBC14(MODE_BOX, sBoxCursorPosition);
+ }
+ break;
+ default:
+ return;
+ }
+
+ sIsMonBeingMoved = TRUE;
+}
+
+static void PlaceMon(void)
+{
+ u8 boxId;
+
+ switch (sBoxCursorArea)
+ {
+ case CURSOR_AREA_IN_PARTY:
+ SetPlacedMonData(TOTAL_BOXES_COUNT, sBoxCursorPosition);
+ sub_80CBCAC(TOTAL_BOXES_COUNT, sBoxCursorPosition);
+ break;
+ case CURSOR_AREA_IN_BOX:
+ boxId = StorageGetCurrentBox();
+ SetPlacedMonData(boxId, sBoxCursorPosition);
+ sub_80CBCAC(boxId, sBoxCursorPosition);
+ break;
+ default:
+ return;
+ }
+
+ sIsMonBeingMoved = FALSE;
+}
+
+static void sub_80CE00C(void)
+{
+ sub_80CEB40();
+}
+
+static void SetMovedMonData(u8 boxId, u8 position)
+{
+ if (boxId == TOTAL_BOXES_COUNT)
+ sPSSData->movingMon = gPlayerParty[sBoxCursorPosition];
+ else
+ BoxMonAtToMon(boxId, position, &sPSSData->movingMon);
+
+ PurgeMonOrBoxMon(boxId, position);
+ sMovingMonOrigBoxId = boxId;
+ sMovingMonOrigBoxPos = position;
+}
+
+static void SetPlacedMonData(u8 boxId, u8 position)
+{
+ if (boxId == TOTAL_BOXES_COUNT)
+ {
+ gPlayerParty[position] = sPSSData->movingMon;
+ }
+ else
+ {
+ BoxMonRestorePP(&sPSSData->movingMon.box);
+ SetBoxMonAt(boxId, position, &sPSSData->movingMon.box);
+ }
+}
+
+static void PurgeMonOrBoxMon(u8 boxId, u8 position)
+{
+ if (boxId == TOTAL_BOXES_COUNT)
+ ZeroMonData(&gPlayerParty[position]);
+ else
+ ZeroBoxMonAt(boxId, position);
+}
+
+static void SetShiftedMonData(u8 boxId, u8 position)
+{
+ if (boxId == TOTAL_BOXES_COUNT)
+ sPSSData->field_2108 = gPlayerParty[position];
+ else
+ BoxMonAtToMon(boxId, position, &sPSSData->field_2108);
+
+ SetPlacedMonData(boxId, position);
+ sPSSData->movingMon = sPSSData->field_2108;
+ SetCursorMonData(&sPSSData->movingMon, MODE_PARTY);
+ sMovingMonOrigBoxId = boxId;
+ sMovingMonOrigBoxPos = position;
+}
+
+static bool8 TryStorePartyMonInBox(u8 boxId)
+{
+ s16 boxPosition = GetFirstFreeBoxSpot(boxId);
+ if (boxPosition == -1)
+ return FALSE;
+
+ if (sIsMonBeingMoved)
+ {
+ SetPlacedMonData(boxId, boxPosition);
+ DestroyMovingMonIcon();
+ sIsMonBeingMoved = FALSE;
+ }
+ else
+ {
+ SetMovedMonData(TOTAL_BOXES_COUNT, sBoxCursorPosition);
+ SetPlacedMonData(boxId, boxPosition);
+ DestroyPartyMonIcon(sBoxCursorPosition);
+ }
+
+ if (boxId == StorageGetCurrentBox())
+ sub_80CB140(boxPosition);
+
+ StartSpriteAnim(sPSSData->field_CB4, 1);
+ return TRUE;
+}
+
+static void sub_80CE22C(void)
+{
+ StartSpriteAnim(sPSSData->field_CB4, 0);
+ sub_80CEB40();
+}
+
+static void sub_80CE250(void)
+{
+ u8 mode;
+
+ if (sIsMonBeingMoved)
+ mode = MODE_2;
+ else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY)
+ mode = MODE_PARTY;
+ else
+ mode = MODE_BOX;
+
+ sub_80CBF14(mode, sBoxCursorPosition);
+ StringCopy(sPSSData->field_21E0, sPSSData->cursorMonNick);
+}
+
+static bool8 sub_80CE2A8(void)
+{
+ if (!sub_80CBFD8())
+ {
+ StartSpriteAnim(sPSSData->field_CB4, 0);
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+}
+
+static void ReleaseMon(void)
+{
+ u8 boxId;
+
+ sub_80CC020();
+ if (sIsMonBeingMoved)
+ {
+ sIsMonBeingMoved = FALSE;
+ }
+ else
+ {
+ if (sBoxCursorArea == CURSOR_AREA_IN_PARTY)
+ boxId = TOTAL_BOXES_COUNT;
+ else
+ boxId = StorageGetCurrentBox();
+
+ PurgeMonOrBoxMon(boxId, sBoxCursorPosition);
+ }
+ sub_80CEB40();
+}
+
+static void sub_80CE324(void)
+{
+ if (sIsMonBeingMoved)
+ StartSpriteAnim(sPSSData->field_CB4, 3);
+}
+
+struct
+{
+ s8 mapGroup;
+ s8 mapNum;
+ u16 move;
+} static const gUnknown_0857B9A4[] =
+{
+ {MAP_GROUPS_COUNT, 0, MOVE_SURF},
+ {MAP_GROUPS_COUNT, 0, MOVE_DIVE},
+ {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MOVE_STRENGTH},
+ {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MOVE_ROCK_SMASH},
+ {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MOVE_STRENGTH},
+ {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MOVE_ROCK_SMASH},
+};
+
+static void sub_80CE350(u16 *moves)
+{
+ s32 i;
+
+ for (i = 0; i < ARRAY_COUNT(gUnknown_0857B9A4); i++)
+ {
+ if (gUnknown_0857B9A4[i].mapGroup == MAP_GROUPS_COUNT
+ || (gUnknown_0857B9A4[i].mapGroup == gSaveBlock1Ptr->location.mapGroup && gUnknown_0857B9A4[i].mapNum == gSaveBlock1Ptr->location.mapNum))
+ {
+ *moves = gUnknown_0857B9A4[i].move;
+ moves++;
+ }
+ }
+
+ *moves = MOVES_COUNT;
+}
+
+static void InitCanRelaseMonVars(void)
+{
+ if (!AtLeastThreeUsableMons())
+ {
+ sPSSData->field_216D = 1;
+ sPSSData->field_216C = 0;
+ return;
+ }
+
+ if (sIsMonBeingMoved)
+ {
+ sPSSData->field_2108 = sPSSData->movingMon;
+ sPSSData->field_2170 = -1;
+ sPSSData->field_2171 = -1;
+ }
+ else
+ {
+ if (sBoxCursorArea == CURSOR_AREA_IN_PARTY)
+ {
+ sPSSData->field_2108 = gPlayerParty[sBoxCursorPosition];
+ sPSSData->field_2170 = TOTAL_BOXES_COUNT;
+ }
+ else
+ {
+ BoxMonAtToMon(StorageGetCurrentBox(), sBoxCursorPosition, &sPSSData->field_2108);
+ sPSSData->field_2170 = StorageGetCurrentBox();
+ }
+ sPSSData->field_2171 = sBoxCursorPosition;
+ }
+
+ sub_80CE350(sPSSData->field_2176);
+ sPSSData->field_2174 = GetMonData(&sPSSData->field_2108, MON_DATA_KNOWN_MOVES, sPSSData->field_2176);
+ if (sPSSData->field_2174 != 0)
+ {
+ sPSSData->field_216D = 0;
+ }
+ else
+ {
+ sPSSData->field_216D = 1;
+ sPSSData->field_216C = 1;
+ }
+
+ sPSSData->field_2172 = 0;
+}
+
+static bool32 AtLeastThreeUsableMons(void)
+{
+ s32 i, j, count;
+
+ count = (sIsMonBeingMoved != FALSE);
+ for (j = 0; j < PARTY_SIZE; j++)
+ {
+ if (GetMonData(&gPlayerParty[j], MON_DATA_SANITY_HAS_SPECIES))
+ count++;
+ }
+
+ if (count >= 3)
+ return TRUE;
+
+ for (i = 0; i < TOTAL_BOXES_COUNT; i++)
+ {
+ for (j = 0; j < IN_BOX_COUNT; j++)
+ {
+ if (CheckBoxMonSanityAt(i, j))
+ {
+ if (++count >= 3)
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+static s8 RunCanReleaseMon(void)
+{
+ u16 i;
+ u16 knownMoves;
+
+ if (sPSSData->field_216D)
+ return sPSSData->field_216C;
+
+ switch (sPSSData->field_2172)
+ {
+ case 0:
+ for (i = 0; i < PARTY_SIZE; i++)
+ {
+ if (sPSSData->field_2170 != TOTAL_BOXES_COUNT || sPSSData->field_2171 != i)
+ {
+ knownMoves = GetMonData(gPlayerParty + i, MON_DATA_KNOWN_MOVES, sPSSData->field_2176);
+ sPSSData->field_2174 &= ~(knownMoves);
+ }
+ }
+ if (sPSSData->field_2174 == 0)
+ {
+ sPSSData->field_216D = 1;
+ sPSSData->field_216C = 1;
+ }
+ else
+ {
+ sPSSData->field_216E = 0;
+ sPSSData->field_216F = 0;
+ sPSSData->field_2172++;
+ }
+ break;
+ case 1:
+ for (i = 0; i < IN_BOX_COUNT; i++)
+ {
+ knownMoves = GetAndCopyBoxMonDataAt(sPSSData->field_216E, sPSSData->field_216F, MON_DATA_KNOWN_MOVES, sPSSData->field_2176);
+ if (knownMoves != 0
+ && !(sPSSData->field_2170 == sPSSData->field_216E && sPSSData->field_2171 == sPSSData->field_216F))
+ {
+ sPSSData->field_2174 &= ~(knownMoves);
+ if (sPSSData->field_2174 == 0)
+ {
+ sPSSData->field_216D = 1;
+ sPSSData->field_216C = 1;
+ break;
+ }
+ }
+ if (++sPSSData->field_216F >= IN_BOX_COUNT)
+ {
+ sPSSData->field_216F = 0;
+ if (++sPSSData->field_216E >= TOTAL_BOXES_COUNT)
+ {
+ sPSSData->field_216D = 1;
+ sPSSData->field_216C = 0;
+ }
+ }
+ }
+ break;
+ }
+
+ return -1;
+}
+
+static void sub_80CE760(void)
+{
+ if (sIsMonBeingMoved)
+ gUnknown_02039D14 = sPSSData->movingMon;
+}
+
+static void sub_80CE790(void)
+{
+ if (sIsMonBeingMoved)
+ {
+ if (sMovingMonOrigBoxId == TOTAL_BOXES_COUNT)
+ sPSSData->movingMon = gUnknown_02039D14;
+ else
+ sPSSData->movingMon.box = gUnknown_02039D14.box;
+ }
+}
+
+static void sub_80CE7E8(void)
+{
+ if (sIsMonBeingMoved)
+ {
+ sub_80CE760();
+ sPSSData->field_218C.mon = &gUnknown_02039D14;
+ sPSSData->field_2187 = 0;
+ sPSSData->field_2186 = 0;
+ sPSSData->field_2188 = 0;
+ }
+ else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY)
+ {
+ sPSSData->field_218C.mon = gPlayerParty;
+ sPSSData->field_2187 = sBoxCursorPosition;
+ sPSSData->field_2186 = CountPartyMons() - 1;
+ sPSSData->field_2188 = 0;
+ }
+ else
+ {
+ sPSSData->field_218C.box = GetBoxedMonPtr(StorageGetCurrentBox(), 0);
+ sPSSData->field_2187 = sBoxCursorPosition;
+ sPSSData->field_2186 = IN_BOX_COUNT - 1;
+ sPSSData->field_2188 = 2;
+ }
+}
+
+static void sub_80CE8E4(void)
+{
+ if (sIsMonBeingMoved)
+ sub_80CE790();
+ else
+ sBoxCursorPosition = gUnknown_0203CF20;
+}
+
+s16 CompactPartySlots(void)
+{
+ s16 retVal = -1;
+ u16 i, last;
+
+ for (i = 0, last = 0; i < PARTY_SIZE; i++)
+ {
+ u16 species = GetMonData(gPlayerParty + i, MON_DATA_SPECIES);
+ if (species != SPECIES_NONE)
+ {
+ if (i != last)
+ gPlayerParty[last] = gPlayerParty[i];
+ last++;
+ }
+ else if (retVal == -1)
+ {
+ retVal = i;
+ }
+ }
+ for (; last < PARTY_SIZE; last++)
+ ZeroMonData(gPlayerParty + last);
+
+ return retVal;
+}
+
+static void SetMonMarkings(u8 markings)
+{
+ sPSSData->cursorMonMarkings = markings;
+ if (sIsMonBeingMoved)
+ {
+ SetMonData(&sPSSData->movingMon, MON_DATA_MARKINGS, &markings);
+ }
+ else
+ {
+ if (sBoxCursorArea == CURSOR_AREA_IN_PARTY)
+ SetMonData(gPlayerParty + sBoxCursorPosition, MON_DATA_MARKINGS, &markings);
+ if (sBoxCursorArea == CURSOR_AREA_IN_BOX)
+ SetCurrentBoxMonData(sBoxCursorPosition, MON_DATA_MARKINGS, &markings);
+ }
+}
+
+static bool8 CanMovePartyMon(void)
+{
+ if (sBoxCursorArea == CURSOR_AREA_IN_PARTY && !sIsMonBeingMoved && CountPartyAliveNonEggMonsExcept(sBoxCursorPosition) == 0)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+static bool8 CanShiftMon(void)
+{
+ if (sIsMonBeingMoved)
+ {
+ if (sBoxCursorArea == CURSOR_AREA_IN_PARTY && CountPartyAliveNonEggMonsExcept(sBoxCursorPosition) == 0)
+ {
+ if (sPSSData->cursorMonIsEgg || GetMonData(&sPSSData->movingMon, MON_DATA_HP) == 0)
+ return FALSE;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static bool8 IsMonBeingMoved(void)
+{
+ return sIsMonBeingMoved;
+}
+
+static bool8 IsCursorOnBox(void)
+{
+ return (sBoxCursorArea == CURSOR_AREA_BOX);
+}
+
+static bool8 IsCursorOnCloseBox(void)
+{
+ return (sBoxCursorArea == CURSOR_AREA_BUTTONS && sBoxCursorPosition == 1);
+}
+
+static bool8 IsCursorInBox(void)
+{
+ return (sBoxCursorArea == CURSOR_AREA_IN_BOX);
+}
+
+static void sub_80CEB40(void)
+{
+ sPSSData->setMosaic = (sIsMonBeingMoved == FALSE);
+ if (!sIsMonBeingMoved)
+ {
+ switch (sBoxCursorArea)
+ {
+ case CURSOR_AREA_IN_PARTY:
+ if (sBoxCursorPosition < PARTY_SIZE)
+ {
+ SetCursorMonData(&gPlayerParty[sBoxCursorPosition], MODE_PARTY);
+ break;
+ }
+ // fallthrough
+ case CURSOR_AREA_BUTTONS:
+ case CURSOR_AREA_BOX:
+ SetCursorMonData(NULL, MODE_2);
+ break;
+ case CURSOR_AREA_IN_BOX:
+ SetCursorMonData(GetBoxedMonPtr(StorageGetCurrentBox(), sBoxCursorPosition), MODE_BOX);
+ break;
+ }
+ }
+}
+
+static void sub_80CEBDC(void)
+{
+ if (sIsMonBeingMoved)
+ SetCursorMonData(&gUnknown_02039D14, MODE_PARTY);
+ else
+ sub_80CEB40();
+}
+
+static void SetCursorMonData(void *pokemon, u8 mode)
+{
+ u8 *txtPtr;
+ u16 gender;
+ bool8 sanityIsBagEgg;
+
+ sPSSData->cursorMonItem = 0;
+ gender = MON_MALE;
+ sanityIsBagEgg = FALSE;
+ if (mode == MODE_PARTY)
+ {
+ struct Pokemon *mon = (struct Pokemon *)pokemon;
+
+ sPSSData->cursorMonSpecies = GetMonData(mon, MON_DATA_SPECIES2);
+ if (sPSSData->cursorMonSpecies != SPECIES_NONE)
+ {
+ sanityIsBagEgg = GetMonData(mon, MON_DATA_SANITY_IS_BAD_EGG);
+ if (sanityIsBagEgg)
+ sPSSData->cursorMonIsEgg = TRUE;
+ else
+ sPSSData->cursorMonIsEgg = GetMonData(mon, MON_DATA_IS_EGG);
+
+ GetMonData(mon, MON_DATA_NICKNAME, sPSSData->cursorMonNick);
+ StringGetEnd10(sPSSData->cursorMonNick);
+ sPSSData->cursorMonLevel = GetMonData(mon, MON_DATA_LEVEL);
+ sPSSData->cursorMonMarkings = GetMonData(mon, MON_DATA_MARKINGS);
+ sPSSData->cursorMonPersonality = GetMonData(mon, MON_DATA_PERSONALITY);
+ sPSSData->cursorMonPalette = GetMonFrontSpritePal(mon);
+ gender = GetMonGender(mon);
+ sPSSData->cursorMonItem = GetMonData(mon, MON_DATA_HELD_ITEM);
+ }
+ }
+ else if (mode == MODE_BOX)
+ {
+ struct BoxPokemon *boxMon = (struct BoxPokemon *)pokemon;
+
+ sPSSData->cursorMonSpecies = GetBoxMonData(pokemon, MON_DATA_SPECIES2);
+ if (sPSSData->cursorMonSpecies != SPECIES_NONE)
+ {
+ u32 otId = GetBoxMonData(boxMon, MON_DATA_OT_ID);
+ sanityIsBagEgg = GetBoxMonData(boxMon, MON_DATA_SANITY_IS_BAD_EGG);
+ if (sanityIsBagEgg)
+ sPSSData->cursorMonIsEgg = TRUE;
+ else
+ sPSSData->cursorMonIsEgg = GetBoxMonData(boxMon, MON_DATA_IS_EGG);
+
+
+ GetBoxMonData(boxMon, MON_DATA_NICKNAME, sPSSData->cursorMonNick);
+ StringGetEnd10(sPSSData->cursorMonNick);
+ sPSSData->cursorMonLevel = GetLevelFromBoxMonExp(boxMon);
+ sPSSData->cursorMonMarkings = GetBoxMonData(boxMon, MON_DATA_MARKINGS);
+ sPSSData->cursorMonPersonality = GetBoxMonData(boxMon, MON_DATA_PERSONALITY);
+ sPSSData->cursorMonPalette = GetFrontSpritePalFromSpeciesAndPersonality(sPSSData->cursorMonSpecies, otId, sPSSData->cursorMonPersonality);
+ gender = GetGenderFromSpeciesAndPersonality(sPSSData->cursorMonSpecies, sPSSData->cursorMonPersonality);
+ sPSSData->cursorMonItem = GetBoxMonData(boxMon, MON_DATA_HELD_ITEM);
+ }
+ }
+ else
+ {
+ sPSSData->cursorMonSpecies = SPECIES_NONE;
+ sPSSData->cursorMonItem = 0;
+ }
+
+ if (sPSSData->cursorMonSpecies == SPECIES_NONE)
+ {
+ StringFill(sPSSData->cursorMonNick, CHAR_SPACE, 5);
+ StringFill(sPSSData->cursorMonNickText, CHAR_SPACE, 8);
+ StringFill(sPSSData->cursorMonSpeciesName, CHAR_SPACE, 8);
+ StringFill(sPSSData->cursorMonGenderLvlText, CHAR_SPACE, 8);
+ StringFill(sPSSData->cursorMonItemName, CHAR_SPACE, 8);
+ }
+ else if (sPSSData->cursorMonIsEgg)
+ {
+ if (sanityIsBagEgg)
+ StringCopyPadded(sPSSData->cursorMonNickText, sPSSData->cursorMonNick, CHAR_SPACE, 5);
+ else
+ StringCopyPadded(sPSSData->cursorMonNickText, gText_EggNickname, CHAR_SPACE, 8);
+
+ StringFill(sPSSData->cursorMonSpeciesName, CHAR_SPACE, 8);
+ StringFill(sPSSData->cursorMonGenderLvlText, CHAR_SPACE, 8);
+ StringFill(sPSSData->cursorMonItemName, CHAR_SPACE, 8);
+ }
+ else
+ {
+ if (sPSSData->cursorMonSpecies == SPECIES_NIDORAN_F || sPSSData->cursorMonSpecies == SPECIES_NIDORAN_M)
+ gender = MON_GENDERLESS;
+
+ StringCopyPadded(sPSSData->cursorMonNickText, sPSSData->cursorMonNick, CHAR_SPACE, 5);
+
+ txtPtr = sPSSData->cursorMonSpeciesName;
+ *(txtPtr)++ = CHAR_SLASH;
+ StringCopyPadded(txtPtr, gSpeciesNames[sPSSData->cursorMonSpecies], CHAR_SPACE, 5);
+
+ txtPtr = sPSSData->cursorMonGenderLvlText;
+ *(txtPtr)++ = EXT_CTRL_CODE_BEGIN;
+ *(txtPtr)++ = 4;
+ switch (gender)
+ {
+ case MON_MALE:
+ *(txtPtr)++ = 4;
+ *(txtPtr)++ = 1;
+ *(txtPtr)++ = 5;
+ *(txtPtr)++ = CHAR_MALE;
+ break;
+ case MON_FEMALE:
+ *(txtPtr)++ = 6;
+ *(txtPtr)++ = 1;
+ *(txtPtr)++ = 7;
+ *(txtPtr)++ = CHAR_FEMALE;
+ break;
+ default:
+ *(txtPtr)++ = 2;
+ *(txtPtr)++ = 1;
+ *(txtPtr)++ = 3;
+ *(txtPtr)++ = 0x77;
+ break;
+ }
+
+ *(txtPtr++) = EXT_CTRL_CODE_BEGIN;
+ *(txtPtr++) = 4;
+ *(txtPtr++) = 2;
+ *(txtPtr++) = 1;
+ *(txtPtr++) = 3;
+ *(txtPtr++) = 0;
+ *(txtPtr++) = CHAR_SPECIAL_F9;
+ *(txtPtr++) = 5;
+
+ txtPtr = ConvertIntToDecimalStringN(txtPtr, sPSSData->cursorMonLevel, STR_CONV_MODE_LEFT_ALIGN, 3);
+ txtPtr[0] = CHAR_SPACE;
+ txtPtr[1] = EOS;
+
+ if (sPSSData->cursorMonItem != 0)
+ StringCopyPadded(sPSSData->cursorMonItemName, ItemId_GetName(sPSSData->cursorMonItem), CHAR_SPACE, 8);
+ else
+ StringFill(sPSSData->cursorMonItemName, CHAR_SPACE, 8);
+ }
+}
+
+static u8 HandleInput_InBox(void)
+{
+ switch (sPSSData->inBoxMovingMode)
+ {
+ case 0:
+ default:
+ return InBoxInput_Normal();
+ case 1:
+ return InBoxInput_GrabbingMultiple();
+ case 2:
+ return InBoxInput_MovingMultiple();
+ }
+}
+
+// This group of four functions handling input simply CANNOT be matched.
+// GF must have written them in a really weird way, a way not a sane person could dream to reproduce.
+#ifdef NONMATCHING
+static u8 InBoxInput_Normal(void)
+{
+ u8 retVal;
+ s8 cursorArea = sBoxCursorArea;
+ s8 cursorPosition = sBoxCursorPosition;
+
+ sPSSData->field_CD2 = 0;
+ sPSSData->field_CD3 = 0;
+ sPSSData->field_CD7 = 0;
+ retVal = 0;
+ if (!(gMain.newAndRepeatedKeys & DPAD_UP))
+ {
+ if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ {
+ retVal = TRUE;
+ cursorPosition += IN_BOX_ROWS;
+ if (cursorPosition >= IN_BOX_COUNT)
+ {
+ cursorArea = CURSOR_AREA_BUTTONS;
+ cursorPosition -= IN_BOX_COUNT;
+ cursorPosition /= 3;
+ sPSSData->field_CD2 = 1;
+ sPSSData->field_CD7 = 1;
+ }
+ }
+ else if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ {
+ retVal = TRUE;
+ if (sBoxCursorPosition % IN_BOX_ROWS != 0)
+ {
+ cursorPosition--;
+ }
+ else
+ {
+ sPSSData->field_CD3 = -1;
+ cursorPosition += (IN_BOX_ROWS - 1);
+ }
+ }
+ else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ {
+ retVal = TRUE;
+ if ((sBoxCursorPosition + 1) % IN_BOX_ROWS != 0)
+ {
+ cursorPosition++;
+ }
+ else
+ {
+ sPSSData->field_CD3 = 1;
+ cursorPosition -= (IN_BOX_ROWS - 1);
+ }
+ }
+ else if (gMain.newKeys & START_BUTTON)
+ {
+ retVal = TRUE;
+ cursorArea = CURSOR_AREA_BOX;
+ cursorPosition = 0;
+ }
+ else
+ {
+ if ((gMain.newKeys & A_BUTTON) && sub_80CFA5C())
+ {
+ if (!sCanOnlyMove)
+ return 8;
+
+ if (sPSSData->boxOption == BOX_OPTION_MOVE_MONS || sIsMonBeingMoved == TRUE)
+ {
+ switch (sub_80CFF98(0))
+ {
+ case 1:
+ return 11;
+ case 2:
+ return 12;
+ case 3:
+ return 13;
+ case 4:
+ return 14;
+ case 5:
+ return 15;
+ case 12:
+ return 16;
+ case 13:
+ return 17;
+ case 15:
+ return 18;
+ }
+ }
+ else
+ {
+ sPSSData->inBoxMovingMode = 1;
+ return 20;
+ }
+ }
+
+ if (gMain.newKeys & B_BUTTON)
+ return 19;
+
+ if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
+ {
+ if (gMain.heldKeys & L_BUTTON)
+ return 10;
+ if (gMain.heldKeys & R_BUTTON)
+ return 9;
+ }
+
+ if (gMain.newKeys & SELECT_BUTTON)
+ {
+ sub_80CFDC4();
+ return 0;
+ }
+ retVal = FALSE;
+ }
+ }
+ else
+ {
+ retVal = TRUE;
+ if (sBoxCursorPosition >= IN_BOX_ROWS)
+ {
+ cursorPosition -= IN_BOX_ROWS;
+ }
+ else
+ {
+ cursorArea = CURSOR_AREA_BOX;
+ cursorPosition = 0;
+ }
+ }
+
+ if (retVal)
+ sub_80CD894(cursorArea, cursorPosition);
+
+ return retVal;
+}
+#else
+NAKED
+static u8 InBoxInput_Normal(void)
+{
+ asm_unified("\n\
+ push {r4-r7,lr}\n\
+ mov r7, r10\n\
+ mov r6, r9\n\
+ mov r5, r8\n\
+ push {r5-r7}\n\
+ ldr r0, =sBoxCursorArea\n\
+ ldrb r0, [r0]\n\
+ mov r8, r0\n\
+ ldr r2, =sBoxCursorPosition\n\
+ ldrb r4, [r2]\n\
+ ldr r5, =sPSSData\n\
+ ldr r0, [r5]\n\
+ ldr r1, =0x00000cd2\n\
+ mov r10, r1\n\
+ add r0, r10\n\
+ movs r1, 0\n\
+ strb r1, [r0]\n\
+ ldr r0, [r5]\n\
+ ldr r7, =0x00000cd3\n\
+ adds r0, r7\n\
+ strb r1, [r0]\n\
+ ldr r0, [r5]\n\
+ ldr r3, =0x00000cd7\n\
+ mov r9, r3\n\
+ add r0, r9\n\
+ strb r1, [r0]\n\
+ ldr r6, =gMain\n\
+ ldrh r1, [r6, 0x30]\n\
+ movs r0, 0x40\n\
+ ands r0, r1\n\
+ adds r3, r2, 0\n\
+ cmp r0, 0\n\
+ beq _080CF14C\n\
+ b _080CF33C\n\
+_080CF14C:\n\
+ movs r0, 0x80\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF1A8\n\
+ movs r6, 0x1\n\
+ lsls r0, r4, 24\n\
+ movs r1, 0xC0\n\
+ lsls r1, 19\n\
+ adds r0, r1\n\
+ lsrs r4, r0, 24\n\
+ asrs r0, 24\n\
+ cmp r0, 0x1D\n\
+ bgt _080CF168\n\
+ b _080CF358\n\
+_080CF168:\n\
+ movs r2, 0x3\n\
+ mov r8, r2\n\
+ subs r0, 0x1E\n\
+ lsls r0, 24\n\
+ asrs r0, 24\n\
+ movs r1, 0x3\n\
+ bl __divsi3\n\
+ lsls r0, 24\n\
+ lsrs r4, r0, 24\n\
+ ldr r0, [r5]\n\
+ add r0, r10\n\
+ strb r6, [r0]\n\
+ ldr r0, [r5]\n\
+ add r0, r9\n\
+ strb r6, [r0]\n\
+ b _080CF358\n\
+ .pool\n\
+_080CF1A8:\n\
+ movs r0, 0x20\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF1DE\n\
+ movs r6, 0x1\n\
+ movs r0, 0\n\
+ ldrsb r0, [r3, r0]\n\
+ movs r1, 0x6\n\
+ bl __modsi3\n\
+ lsls r0, 24\n\
+ cmp r0, 0\n\
+ beq _080CF1CA\n\
+ lsls r0, r4, 24\n\
+ movs r3, 0xFF\n\
+ lsls r3, 24\n\
+ b _080CF34C\n\
+_080CF1CA:\n\
+ ldr r0, [r5]\n\
+ adds r0, r7\n\
+ movs r1, 0xFF\n\
+ strb r1, [r0]\n\
+ lsls r0, r4, 24\n\
+ movs r1, 0xA0\n\
+ lsls r1, 19\n\
+ adds r0, r1\n\
+ lsrs r4, r0, 24\n\
+ b _080CF358\n\
+_080CF1DE:\n\
+ movs r0, 0x10\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF212\n\
+ movs r6, 0x1\n\
+ movs r0, 0\n\
+ ldrsb r0, [r3, r0]\n\
+ adds r0, 0x1\n\
+ movs r1, 0x6\n\
+ bl __modsi3\n\
+ cmp r0, 0\n\
+ beq _080CF204\n\
+ lsls r0, r4, 24\n\
+ movs r2, 0x80\n\
+ lsls r2, 17\n\
+ adds r0, r2\n\
+ lsrs r4, r0, 24\n\
+ b _080CF358\n\
+_080CF204:\n\
+ ldr r0, [r5]\n\
+ adds r0, r7\n\
+ strb r6, [r0]\n\
+ lsls r0, r4, 24\n\
+ movs r3, 0xFB\n\
+ lsls r3, 24\n\
+ b _080CF34C\n\
+_080CF212:\n\
+ ldrh r1, [r6, 0x2E]\n\
+ movs r0, 0x8\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF220\n\
+ movs r6, 0x1\n\
+ b _080CF352\n\
+_080CF220:\n\
+ movs r4, 0x1\n\
+ movs r0, 0x1\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF2E4\n\
+ bl sub_80CFA5C\n\
+ lsls r0, 24\n\
+ cmp r0, 0\n\
+ beq _080CF2E4\n\
+ ldr r0, =sCanOnlyMove\n\
+ ldrb r0, [r0]\n\
+ cmp r0, 0\n\
+ bne _080CF244\n\
+ movs r0, 0x8\n\
+ b _080CF366\n\
+ .pool\n\
+_080CF244:\n\
+ ldr r1, [r5]\n\
+ ldrb r0, [r1, 0x1]\n\
+ cmp r0, 0x2\n\
+ bne _080CF254\n\
+ ldr r0, =sIsMonBeingMoved\n\
+ ldrb r0, [r0]\n\
+ cmp r0, 0x1\n\
+ bne _080CF2D4\n\
+_080CF254:\n\
+ movs r0, 0\n\
+ bl sub_80CFF98\n\
+ subs r0, 0x1\n\
+ lsls r0, 24\n\
+ asrs r0, 24\n\
+ cmp r0, 0xE\n\
+ bhi _080CF2E4\n\
+ lsls r0, 2\n\
+ ldr r1, =_080CF278\n\
+ adds r0, r1\n\
+ ldr r0, [r0]\n\
+ mov pc, r0\n\
+ .pool\n\
+ .align 2, 0\n\
+_080CF278:\n\
+ .4byte _080CF2B4\n\
+ .4byte _080CF2B8\n\
+ .4byte _080CF2BC\n\
+ .4byte _080CF2C0\n\
+ .4byte _080CF2C4\n\
+ .4byte _080CF2E4\n\
+ .4byte _080CF2E4\n\
+ .4byte _080CF2E4\n\
+ .4byte _080CF2E4\n\
+ .4byte _080CF2E4\n\
+ .4byte _080CF2E4\n\
+ .4byte _080CF2C8\n\
+ .4byte _080CF2CC\n\
+ .4byte _080CF2E4\n\
+ .4byte _080CF2D0\n\
+_080CF2B4:\n\
+ movs r0, 0xB\n\
+ b _080CF366\n\
+_080CF2B8:\n\
+ movs r0, 0xC\n\
+ b _080CF366\n\
+_080CF2BC:\n\
+ movs r0, 0xD\n\
+ b _080CF366\n\
+_080CF2C0:\n\
+ movs r0, 0xE\n\
+ b _080CF366\n\
+_080CF2C4:\n\
+ movs r0, 0xF\n\
+ b _080CF366\n\
+_080CF2C8:\n\
+ movs r0, 0x10\n\
+ b _080CF366\n\
+_080CF2CC:\n\
+ movs r0, 0x11\n\
+ b _080CF366\n\
+_080CF2D0:\n\
+ movs r0, 0x12\n\
+ b _080CF366\n\
+_080CF2D4:\n\
+ ldr r2, =0x000021ff\n\
+ adds r0, r1, r2\n\
+ strb r4, [r0]\n\
+ movs r0, 0x14\n\
+ b _080CF366\n\
+ .pool\n\
+_080CF2E4:\n\
+ ldr r2, =gMain\n\
+ ldrh r1, [r2, 0x2E]\n\
+ movs r0, 0x2\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF2F8\n\
+ movs r0, 0x13\n\
+ b _080CF366\n\
+ .pool\n\
+_080CF2F8:\n\
+ ldr r0, =gSaveBlock2Ptr\n\
+ ldr r0, [r0]\n\
+ ldrb r0, [r0, 0x13]\n\
+ cmp r0, 0x1\n\
+ bne _080CF326\n\
+ ldrh r1, [r2, 0x2C]\n\
+ movs r0, 0x80\n\
+ lsls r0, 2\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF318\n\
+ movs r0, 0xA\n\
+ b _080CF366\n\
+ .pool\n\
+_080CF318:\n\
+ movs r0, 0x80\n\
+ lsls r0, 1\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF326\n\
+ movs r0, 0x9\n\
+ b _080CF366\n\
+_080CF326:\n\
+ ldrh r1, [r2, 0x2E]\n\
+ movs r0, 0x4\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF338\n\
+ bl sub_80CFDC4\n\
+ movs r0, 0\n\
+ b _080CF366\n\
+_080CF338:\n\
+ movs r6, 0\n\
+ b _080CF364\n\
+_080CF33C:\n\
+ movs r6, 0x1\n\
+ movs r0, 0\n\
+ ldrsb r0, [r2, r0]\n\
+ cmp r0, 0x5\n\
+ ble _080CF352\n\
+ lsls r0, r4, 24\n\
+ movs r3, 0xFA\n\
+ lsls r3, 24\n\
+_080CF34C:\n\
+ adds r0, r3\n\
+ lsrs r4, r0, 24\n\
+ b _080CF358\n\
+_080CF352:\n\
+ movs r0, 0x2\n\
+ mov r8, r0\n\
+ movs r4, 0\n\
+_080CF358:\n\
+ cmp r6, 0\n\
+ beq _080CF364\n\
+ mov r0, r8\n\
+ adds r1, r4, 0\n\
+ bl sub_80CD894\n\
+_080CF364:\n\
+ adds r0, r6, 0\n\
+_080CF366:\n\
+ pop {r3-r5}\n\
+ mov r8, r3\n\
+ mov r9, r4\n\
+ mov r10, r5\n\
+ pop {r4-r7}\n\
+ pop {r1}\n\
+ bx r1\n\
+ ");
+}
+#endif
+
+static u8 InBoxInput_GrabbingMultiple(void)
+{
+ if (gMain.heldKeys & A_BUTTON)
+ {
+ if (gMain.newAndRepeatedKeys & DPAD_UP)
+ {
+ if (sBoxCursorPosition / IN_BOX_ROWS != 0)
+ {
+ sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition - IN_BOX_ROWS);
+ return 21;
+ }
+ else
+ {
+ return 24;
+ }
+ }
+ else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ {
+ if (sBoxCursorPosition + IN_BOX_ROWS < IN_BOX_COUNT)
+ {
+ sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition + IN_BOX_ROWS);
+ return 21;
+ }
+ else
+ {
+ return 24;
+ }
+ }
+ else if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ {
+ if (sBoxCursorPosition % IN_BOX_ROWS != 0)
+ {
+ sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition - 1);
+ return 21;
+ }
+ else
+ {
+ return 24;
+ }
+ }
+ else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ {
+ if ((sBoxCursorPosition + 1) % IN_BOX_ROWS != 0)
+ {
+ sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition + 1);
+ return 21;
+ }
+ else
+ {
+ return 24;
+ }
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ if (sub_80D0BA4() == sBoxCursorPosition)
+ {
+ sPSSData->inBoxMovingMode = 0;
+ sPSSData->field_CB8->invisible = FALSE;
+ return 22;
+ }
+ else
+ {
+ sIsMonBeingMoved = (sPSSData->cursorMonSpecies != SPECIES_NONE);
+ sPSSData->inBoxMovingMode = 2;
+ sMovingMonOrigBoxId = StorageGetCurrentBox();
+ return 23;
+ }
+ }
+}
+
+static u8 InBoxInput_MovingMultiple(void)
+{
+ if (gMain.newAndRepeatedKeys & DPAD_UP)
+ {
+ if (sub_80D0580(0))
+ {
+ sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition - IN_BOX_ROWS);
+ return 25;
+ }
+ else
+ {
+ return 24;
+ }
+ }
+ else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ {
+ if (sub_80D0580(1))
+ {
+ sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition + IN_BOX_ROWS);
+ return 25;
+ }
+ else
+ {
+ return 24;
+ }
+ }
+ else if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ {
+ if (sub_80D0580(2))
+ {
+ sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition - 1);
+ return 25;
+ }
+ else
+ {
+ return 10;
+ }
+ }
+ else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ {
+ if (sub_80D0580(3))
+ {
+ sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition + 1);
+ return 25;
+ }
+ else
+ {
+ return 9;
+ }
+ }
+ else if (gMain.newKeys & A_BUTTON)
+ {
+ if (sub_80D0BC0())
+ {
+ sIsMonBeingMoved = FALSE;
+ sPSSData->inBoxMovingMode = 0;
+ return 26;
+ }
+ else
+ {
+ return 24;
+ }
+ }
+ else if (gMain.newKeys & B_BUTTON)
+ {
+ return 24;
+ }
+ else
+ {
+ if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
+ {
+ if (gMain.heldKeys & L_BUTTON)
+ return 10;
+ if (gMain.heldKeys & R_BUTTON)
+ return 9;
+ }
+
+ return 0;
+ }
+}
+
+#ifdef NONMATCHING
+static u8 HandleInput_InParty(void)
+{
+ u8 retVal;
+ bool8 gotoBox;
+ s8 cursorArea = sBoxCursorArea;
+ s8 cursorPosition = sBoxCursorPosition;
+
+ sPSSData->field_CD3 = 0;
+ sPSSData->field_CD2 = 0;
+ sPSSData->field_CD7 = 0;
+ gotoBox = FALSE;
+ retVal = 0;
+
+ if (!(gMain.newAndRepeatedKeys & DPAD_UP))
+ {
+ if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ {
+ if (++cursorPosition > PARTY_SIZE)
+ cursorPosition = 0;
+ if (cursorPosition != sBoxCursorPosition)
+ retVal = 1;
+ }
+ else if ((gMain.newAndRepeatedKeys & DPAD_LEFT) && sBoxCursorPosition != 0)
+ {
+ retVal = 1;
+ sPSSData->field_CD6 = sBoxCursorPosition;
+ cursorPosition = 0;
+ }
+ else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ {
+ if (sBoxCursorPosition == 0)
+ {
+ retVal = 1;
+ cursorPosition = sPSSData->field_CD6;
+ }
+ else
+ {
+ retVal = 6;
+ cursorArea = CURSOR_AREA_IN_BOX;
+ cursorPosition = 0;
+ }
+ }
+ else
+ {
+ if (gMain.newKeys & A_BUTTON)
+ {
+ if (sBoxCursorPosition == PARTY_SIZE)
+ {
+ if (sPSSData->boxOption == BOX_OPTION_DEPOSIT)
+ return 4;
+
+ gotoBox = TRUE;
+ }
+ else if (sub_80CFA5C())
+ {
+ if (!sCanOnlyMove)
+ return 8;
+
+ switch (sub_80CFF98(0))
+ {
+ case 1:
+ return 11;
+ case 2:
+ return 12;
+ case 3:
+ return 13;
+ case 4:
+ return 14;
+ case 5:
+ return 15;
+ case 12:
+ return 16;
+ case 13:
+ return 17;
+ case 15:
+ return 18;
+ }
+ }
+ }
+
+ if (gMain.newKeys & B_BUTTON)
+ {
+ if (sPSSData->boxOption == BOX_OPTION_DEPOSIT)
+ return 19;
+
+ gotoBox = TRUE;
+ }
+
+ if (gotoBox)
+ {
+ retVal = 6;
+ cursorArea = CURSOR_AREA_IN_BOX;
+ cursorPosition = 0;
+ }
+ else if (gMain.newKeys & SELECT_BUTTON)
+ {
+ sub_80CFDC4();
+ return 0;
+ }
+ }
+ }
+ else
+ {
+ if (--cursorPosition < 0)
+ cursorPosition = PARTY_SIZE;
+ if (cursorPosition != sBoxCursorPosition)
+ retVal = 1;
+ }
+ if (retVal != 0)
+ {
+ if (retVal != 6)
+ sub_80CD894(cursorArea, cursorPosition);
+ }
+
+ return retVal;
+}
+#else
+NAKED
+static u8 HandleInput_InParty(void)
+{
+ asm_unified("\n\
+ push {r4-r7,lr}\n\
+ mov r7, r9\n\
+ mov r6, r8\n\
+ push {r6,r7}\n\
+ ldr r0, =sBoxCursorArea\n\
+ ldrb r0, [r0]\n\
+ mov r9, r0\n\
+ ldr r6, =sBoxCursorPosition\n\
+ ldrb r4, [r6]\n\
+ ldr r2, =sPSSData\n\
+ ldr r0, [r2]\n\
+ ldr r1, =0x00000cd3\n\
+ adds r0, r1\n\
+ movs r1, 0\n\
+ strb r1, [r0]\n\
+ ldr r0, [r2]\n\
+ ldr r3, =0x00000cd2\n\
+ adds r0, r3\n\
+ strb r1, [r0]\n\
+ ldr r0, [r2]\n\
+ adds r3, 0x5\n\
+ adds r0, r3\n\
+ strb r1, [r0]\n\
+ mov r8, r1\n\
+ movs r7, 0\n\
+ ldr r1, =gMain\n\
+ ldrh r3, [r1, 0x30]\n\
+ movs r0, 0x40\n\
+ ands r0, r3\n\
+ adds r5, r6, 0\n\
+ mov r12, r1\n\
+ cmp r0, 0\n\
+ beq _080CF608\n\
+ b _080CF7A8\n\
+_080CF608:\n\
+ movs r0, 0x80\n\
+ ands r0, r3\n\
+ cmp r0, 0\n\
+ beq _080CF64C\n\
+ lsls r0, r4, 24\n\
+ movs r1, 0x80\n\
+ lsls r1, 17\n\
+ adds r0, r1\n\
+ lsrs r4, r0, 24\n\
+ asrs r0, 24\n\
+ cmp r0, 0x6\n\
+ ble _080CF622\n\
+ movs r4, 0\n\
+_080CF622:\n\
+ lsls r0, r4, 24\n\
+ asrs r0, 24\n\
+ movs r1, 0\n\
+ ldrsb r1, [r5, r1]\n\
+ cmp r0, r1\n\
+ bne _080CF630\n\
+ b _080CF7C6\n\
+_080CF630:\n\
+ movs r7, 0x1\n\
+ b _080CF7CA\n\
+ .pool\n\
+_080CF64C:\n\
+ movs r0, 0x20\n\
+ ands r0, r3\n\
+ cmp r0, 0\n\
+ beq _080CF670\n\
+ ldrb r1, [r5]\n\
+ movs r0, 0\n\
+ ldrsb r0, [r5, r0]\n\
+ cmp r0, 0\n\
+ beq _080CF670\n\
+ movs r7, 0x1\n\
+ ldr r0, [r2]\n\
+ ldr r2, =0x00000cd6\n\
+ adds r0, r2\n\
+ strb r1, [r0]\n\
+ movs r4, 0\n\
+ b _080CF7C6\n\
+ .pool\n\
+_080CF670:\n\
+ mov r3, r12\n\
+ ldrh r1, [r3, 0x30]\n\
+ movs r0, 0x10\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF69E\n\
+ movs r0, 0\n\
+ ldrsb r0, [r5, r0]\n\
+ cmp r0, 0\n\
+ bne _080CF694\n\
+ movs r7, 0x1\n\
+ ldr r0, [r2]\n\
+ ldr r1, =0x00000cd6\n\
+ adds r0, r1\n\
+ ldrb r4, [r0]\n\
+ b _080CF7C6\n\
+ .pool\n\
+_080CF694:\n\
+ movs r7, 0x6\n\
+ movs r2, 0\n\
+ mov r9, r2\n\
+ movs r4, 0\n\
+ b _080CF7C6\n\
+_080CF69E:\n\
+ mov r3, r12\n\
+ ldrh r1, [r3, 0x2E]\n\
+ movs r0, 0x1\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF75C\n\
+ movs r0, 0\n\
+ ldrsb r0, [r5, r0]\n\
+ cmp r0, 0x6\n\
+ bne _080CF6C4\n\
+ ldr r0, [r2]\n\
+ ldrb r0, [r0, 0x1]\n\
+ cmp r0, 0x1\n\
+ bne _080CF6BE\n\
+ movs r0, 0x4\n\
+ b _080CF7D8\n\
+_080CF6BE:\n\
+ movs r0, 0x1\n\
+ mov r8, r0\n\
+ b _080CF75C\n\
+_080CF6C4:\n\
+ bl sub_80CFA5C\n\
+ lsls r0, 24\n\
+ cmp r0, 0\n\
+ beq _080CF75C\n\
+ ldr r0, =sCanOnlyMove\n\
+ ldrb r0, [r0]\n\
+ cmp r0, 0\n\
+ bne _080CF6E0\n\
+ movs r0, 0x8\n\
+ b _080CF7D8\n\
+ .pool\n\
+_080CF6E0:\n\
+ movs r0, 0\n\
+ bl sub_80CFF98\n\
+ subs r0, 0x1\n\
+ lsls r0, 24\n\
+ asrs r0, 24\n\
+ cmp r0, 0xE\n\
+ bhi _080CF75C\n\
+ lsls r0, 2\n\
+ ldr r1, =_080CF700\n\
+ adds r0, r1\n\
+ ldr r0, [r0]\n\
+ mov pc, r0\n\
+ .pool\n\
+ .align 2, 0\n\
+_080CF700:\n\
+ .4byte _080CF73C\n\
+ .4byte _080CF740\n\
+ .4byte _080CF744\n\
+ .4byte _080CF748\n\
+ .4byte _080CF74C\n\
+ .4byte _080CF75C\n\
+ .4byte _080CF75C\n\
+ .4byte _080CF75C\n\
+ .4byte _080CF75C\n\
+ .4byte _080CF75C\n\
+ .4byte _080CF75C\n\
+ .4byte _080CF750\n\
+ .4byte _080CF754\n\
+ .4byte _080CF75C\n\
+ .4byte _080CF758\n\
+_080CF73C:\n\
+ movs r0, 0xB\n\
+ b _080CF7D8\n\
+_080CF740:\n\
+ movs r0, 0xC\n\
+ b _080CF7D8\n\
+_080CF744:\n\
+ movs r0, 0xD\n\
+ b _080CF7D8\n\
+_080CF748:\n\
+ movs r0, 0xE\n\
+ b _080CF7D8\n\
+_080CF74C:\n\
+ movs r0, 0xF\n\
+ b _080CF7D8\n\
+_080CF750:\n\
+ movs r0, 0x10\n\
+ b _080CF7D8\n\
+_080CF754:\n\
+ movs r0, 0x11\n\
+ b _080CF7D8\n\
+_080CF758:\n\
+ movs r0, 0x12\n\
+ b _080CF7D8\n\
+_080CF75C:\n\
+ ldr r2, =gMain\n\
+ ldrh r1, [r2, 0x2E]\n\
+ movs r0, 0x2\n\
+ ands r0, r1\n\
+ mov r12, r2\n\
+ cmp r0, 0\n\
+ beq _080CF784\n\
+ ldr r0, =sPSSData\n\
+ ldr r0, [r0]\n\
+ ldrb r0, [r0, 0x1]\n\
+ cmp r0, 0x1\n\
+ bne _080CF780\n\
+ movs r0, 0x13\n\
+ b _080CF7D8\n\
+ .pool\n\
+_080CF780:\n\
+ movs r1, 0x1\n\
+ mov r8, r1\n\
+_080CF784:\n\
+ mov r2, r8\n\
+ cmp r2, 0\n\
+ beq _080CF794\n\
+ movs r7, 0x6\n\
+ movs r3, 0\n\
+ mov r9, r3\n\
+ movs r4, 0\n\
+ b _080CF7C6\n\
+_080CF794:\n\
+ mov r0, r12\n\
+ ldrh r1, [r0, 0x2E]\n\
+ movs r0, 0x4\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF7C6\n\
+ bl sub_80CFDC4\n\
+ movs r0, 0\n\
+ b _080CF7D8\n\
+_080CF7A8:\n\
+ lsls r0, r4, 24\n\
+ movs r1, 0xFF\n\
+ lsls r1, 24\n\
+ adds r0, r1\n\
+ lsrs r4, r0, 24\n\
+ cmp r0, 0\n\
+ bge _080CF7B8\n\
+ movs r4, 0x6\n\
+_080CF7B8:\n\
+ lsls r0, r4, 24\n\
+ asrs r0, 24\n\
+ movs r1, 0\n\
+ ldrsb r1, [r6, r1]\n\
+ cmp r0, r1\n\
+ beq _080CF7C6\n\
+ movs r7, 0x1\n\
+_080CF7C6:\n\
+ cmp r7, 0\n\
+ beq _080CF7D6\n\
+_080CF7CA:\n\
+ cmp r7, 0x6\n\
+ beq _080CF7D6\n\
+ mov r0, r9\n\
+ adds r1, r4, 0\n\
+ bl sub_80CD894\n\
+_080CF7D6:\n\
+ adds r0, r7, 0\n\
+_080CF7D8:\n\
+ pop {r3,r4}\n\
+ mov r8, r3\n\
+ mov r9, r4\n\
+ pop {r4-r7}\n\
+ pop {r1}\n\
+ bx r1");
+}
+#endif
+
+#ifdef NONMATCHING
+static u8 HandleInput_OnBox(void)
+{
+ u8 retVal;
+ s8 cursorArea = sBoxCursorArea;
+ s8 cursorPosition = sBoxCursorPosition;
+
+ sPSSData->field_CD3 = 0;
+ sPSSData->field_CD2 = 0;
+ sPSSData->field_CD7 = 0;
+ retVal = 0;
+
+ if (!(gMain.newAndRepeatedKeys & DPAD_UP))
+ {
+ if (gMain.newAndRepeatedKeys & DPAD_DOWN)
+ {
+ retVal = 1;
+ cursorArea = CURSOR_AREA_IN_BOX;
+ cursorPosition = 2;
+ }
+ else
+ {
+ if (gMain.heldKeys & DPAD_LEFT)
+ return 10;
+ if (gMain.heldKeys & DPAD_RIGHT)
+ return 9;
+
+ if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
+ {
+ if (gMain.heldKeys & L_BUTTON)
+ return 10;
+ if (gMain.heldKeys & R_BUTTON)
+ return 9;
+ }
+
+ if (gMain.newKeys & A_BUTTON)
+ {
+ sub_80CD1A8(FALSE);
+ AddBoxMenu();
+ return 7;
+ }
+
+ if (gMain.newKeys & B_BUTTON)
+ return 19;
+
+ if (gMain.newKeys & SELECT_BUTTON)
+ {
+ sub_80CFDC4();
+ return 0;
+ }
+
+ retVal = 0;
+ }
+ }
+ else
+ {
+ retVal = 1;
+ cursorArea = CURSOR_AREA_BUTTONS;
+ cursorPosition = 0;
+ sPSSData->field_CD7 = 1;
+ }
+
+ if (retVal)
+ {
+ if (cursorArea != CURSOR_AREA_BOX)
+ sub_80CD1A8(FALSE);
+ sub_80CD894(cursorArea, cursorPosition);
+ }
+
+ return retVal;
+}
+#else
+NAKED
+static u8 HandleInput_OnBox(void)
+{
+ asm_unified("\n\
+ push {r4-r6,lr}\n\
+ ldr r3, =sPSSData\n\
+ ldr r0, [r3]\n\
+ ldr r1, =0x00000cd3\n\
+ adds r0, r1\n\
+ movs r1, 0\n\
+ strb r1, [r0]\n\
+ ldr r0, [r3]\n\
+ ldr r2, =0x00000cd2\n\
+ adds r0, r2\n\
+ strb r1, [r0]\n\
+ ldr r0, [r3]\n\
+ ldr r5, =0x00000cd7\n\
+ adds r0, r5\n\
+ strb r1, [r0]\n\
+ ldr r1, =gMain\n\
+ ldrh r2, [r1, 0x30]\n\
+ movs r0, 0x40\n\
+ ands r0, r2\n\
+ cmp r0, 0\n\
+ bne _080CF8AA\n\
+ movs r0, 0x80\n\
+ ands r0, r2\n\
+ cmp r0, 0\n\
+ beq _080CF834\n\
+ movs r4, 0x1\n\
+ movs r1, 0\n\
+ movs r6, 0x2\n\
+ b _080CF8B6\n\
+ .pool\n\
+_080CF834:\n\
+ ldrh r2, [r1, 0x2C]\n\
+ movs r0, 0x20\n\
+ ands r0, r2\n\
+ cmp r0, 0\n\
+ bne _080CF85A\n\
+ movs r0, 0x10\n\
+ ands r0, r2\n\
+ cmp r0, 0\n\
+ bne _080CF86E\n\
+ ldr r0, =gSaveBlock2Ptr\n\
+ ldr r0, [r0]\n\
+ ldrb r0, [r0, 0x13]\n\
+ cmp r0, 0x1\n\
+ bne _080CF872\n\
+ movs r0, 0x80\n\
+ lsls r0, 2\n\
+ ands r0, r2\n\
+ cmp r0, 0\n\
+ beq _080CF864\n\
+_080CF85A:\n\
+ movs r0, 0xA\n\
+ b _080CF8D2\n\
+ .pool\n\
+_080CF864:\n\
+ movs r0, 0x80\n\
+ lsls r0, 1\n\
+ ands r0, r2\n\
+ cmp r0, 0\n\
+ beq _080CF872\n\
+_080CF86E:\n\
+ movs r0, 0x9\n\
+ b _080CF8D2\n\
+_080CF872:\n\
+ ldrh r1, [r1, 0x2E]\n\
+ movs r0, 0x1\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF88A\n\
+ movs r0, 0\n\
+ bl sub_80CD1A8\n\
+ bl AddBoxMenu\n\
+ movs r0, 0x7\n\
+ b _080CF8D2\n\
+_080CF88A:\n\
+ movs r0, 0x2\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF896\n\
+ movs r0, 0x13\n\
+ b _080CF8D2\n\
+_080CF896:\n\
+ movs r0, 0x4\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF8A6\n\
+ bl sub_80CFDC4\n\
+ movs r0, 0\n\
+ b _080CF8D2\n\
+_080CF8A6:\n\
+ movs r4, 0\n\
+ b _080CF8D0\n\
+_080CF8AA:\n\
+ movs r4, 0x1\n\
+ movs r1, 0x3\n\
+ movs r6, 0\n\
+ ldr r0, [r3]\n\
+ adds r0, r5\n\
+ strb r4, [r0]\n\
+_080CF8B6:\n\
+ cmp r4, 0\n\
+ beq _080CF8D0\n\
+ lsls r5, r1, 24\n\
+ cmp r1, 0x2\n\
+ beq _080CF8C6\n\
+ movs r0, 0\n\
+ bl sub_80CD1A8\n\
+_080CF8C6:\n\
+ lsrs r0, r5, 24\n\
+ lsls r1, r6, 24\n\
+ lsrs r1, 24\n\
+ bl sub_80CD894\n\
+_080CF8D0:\n\
+ adds r0, r4, 0\n\
+_080CF8D2:\n\
+ pop {r4-r6}\n\
+ pop {r1}\n\
+ bx r1\n\
+ ");
+}
+#endif
+
+#ifdef NONMATCHING
+static u8 HandleInput_OnButtons(void)
+{
+ u8 retVal;
+ s8 cursorArea = sBoxCursorArea;
+ s8 cursorPosition = sBoxCursorPosition;
+
+ sPSSData->field_CD3 = 0;
+ sPSSData->field_CD2 = 0;
+ sPSSData->field_CD7 = 0;
+
+ if (!(gMain.newAndRepeatedKeys & DPAD_UP))
+ {
+ if (gMain.newAndRepeatedKeys & (DPAD_DOWN | START_BUTTON))
+ {
+ retVal = 1;
+ cursorArea = CURSOR_AREA_BOX;
+ cursorPosition = 0;
+ sPSSData->field_CD7 = 1;
+ }
+ else if (gMain.newAndRepeatedKeys & DPAD_LEFT)
+ {
+ retVal = 1;
+ if (--cursorPosition < 0)
+ {
+ cursorPosition = 1;
+ }
+ }
+ else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
+ {
+ retVal = 1;
+ if (++cursorPosition > 1)
+ {
+ cursorPosition = 0;
+ }
+ }
+ else if (gMain.newKeys & A_BUTTON)
+ {
+ return (cursorPosition == 0) ? 5 : 4;
+ }
+ else if (gMain.newKeys & B_BUTTON)
+ {
+ return 19;
+ }
+ else if (gMain.newKeys & SELECT_BUTTON)
+ {
+ sub_80CFDC4();
+ return 0;
+ }
+ else
+ {
+ retVal = 0;
+ }
+ }
+ else
+ {
+ retVal = 1;
+ cursorArea = CURSOR_AREA_IN_BOX;
+ sPSSData->field_CD2 = -1;
+ cursorPosition = (sBoxCursorPosition == 0) ? IN_BOX_COUNT - 1 - 5 : IN_BOX_COUNT - 1;
+ sPSSData->field_CD7 = 1;
+ }
+
+ if (retVal != 0)
+ {
+ sub_80CD894(cursorArea, cursorPosition);
+ }
+
+ return retVal;
+}
+#else
+NAKED
+static u8 HandleInput_OnButtons(void)
+{
+ asm_unified("\n\
+ push {r4-r7,lr}\n\
+ mov r7, r8\n\
+ push {r7}\n\
+ ldr r0, =sBoxCursorArea\n\
+ ldrb r0, [r0]\n\
+ mov r8, r0\n\
+ ldr r0, =sBoxCursorPosition\n\
+ mov r12, r0\n\
+ ldrb r2, [r0]\n\
+ ldr r3, =sPSSData\n\
+ ldr r0, [r3]\n\
+ ldr r1, =0x00000cd3\n\
+ adds r0, r1\n\
+ movs r1, 0\n\
+ strb r1, [r0]\n\
+ ldr r0, [r3]\n\
+ ldr r6, =0x00000cd2\n\
+ adds r0, r6\n\
+ strb r1, [r0]\n\
+ ldr r0, [r3]\n\
+ ldr r5, =0x00000cd7\n\
+ adds r0, r5\n\
+ strb r1, [r0]\n\
+ ldr r7, =gMain\n\
+ ldrh r1, [r7, 0x30]\n\
+ movs r0, 0x40\n\
+ ands r0, r1\n\
+ adds r4, r3, 0\n\
+ cmp r0, 0\n\
+ bne _080CF9B2\n\
+ movs r0, 0x88\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF944\n\
+ movs r7, 0x1\n\
+ movs r0, 0x2\n\
+ mov r8, r0\n\
+ movs r2, 0\n\
+ ldr r0, [r4]\n\
+ b _080CF9D0\n\
+ .pool\n\
+_080CF944:\n\
+ movs r0, 0x20\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF960\n\
+ movs r7, 0x1\n\
+ lsls r0, r2, 24\n\
+ movs r1, 0xFF\n\
+ lsls r1, 24\n\
+ adds r0, r1\n\
+ lsrs r2, r0, 24\n\
+ cmp r0, 0\n\
+ bge _080CF9D4\n\
+ movs r2, 0x1\n\
+ b _080CF9D4\n\
+_080CF960:\n\
+ movs r0, 0x10\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF97E\n\
+ movs r7, 0x1\n\
+ lsls r0, r2, 24\n\
+ movs r1, 0x80\n\
+ lsls r1, 17\n\
+ adds r0, r1\n\
+ lsrs r2, r0, 24\n\
+ asrs r0, 24\n\
+ cmp r0, 0x1\n\
+ ble _080CF9D4\n\
+ movs r2, 0\n\
+ b _080CF9D4\n\
+_080CF97E:\n\
+ ldrh r1, [r7, 0x2E]\n\
+ movs r0, 0x1\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF992\n\
+ movs r0, 0x4\n\
+ cmp r2, 0\n\
+ bne _080CF9E2\n\
+ movs r0, 0x5\n\
+ b _080CF9E2\n\
+_080CF992:\n\
+ movs r0, 0x2\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF99E\n\
+ movs r0, 0x13\n\
+ b _080CF9E2\n\
+_080CF99E:\n\
+ movs r0, 0x4\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _080CF9AE\n\
+ bl sub_80CFDC4\n\
+ movs r0, 0\n\
+ b _080CF9E2\n\
+_080CF9AE:\n\
+ movs r7, 0\n\
+ b _080CF9E0\n\
+_080CF9B2:\n\
+ movs r7, 0x1\n\
+ movs r0, 0\n\
+ mov r8, r0\n\
+ ldr r0, [r3]\n\
+ adds r0, r6\n\
+ movs r1, 0xFF\n\
+ strb r1, [r0]\n\
+ mov r1, r12\n\
+ movs r0, 0\n\
+ ldrsb r0, [r1, r0]\n\
+ movs r2, 0x1D\n\
+ cmp r0, 0\n\
+ bne _080CF9CE\n\
+ movs r2, 0x18\n\
+_080CF9CE:\n\
+ ldr r0, [r3]\n\
+_080CF9D0:\n\
+ adds r0, r5\n\
+ strb r7, [r0]\n\
+_080CF9D4:\n\
+ cmp r7, 0\n\
+ beq _080CF9E0\n\
+ mov r0, r8\n\
+ adds r1, r2, 0\n\
+ bl sub_80CD894\n\
+_080CF9E0:\n\
+ adds r0, r7, 0\n\
+_080CF9E2:\n\
+ pop {r3}\n\
+ mov r8, r3\n\
+ pop {r4-r7}\n\
+ pop {r1}\n\
+ bx r1");
+}
+#endif
+
+static u8 HandleInput(void)
+{
+ struct
+ {
+ u8 (*func)(void);
+ s8 area;
+ }
+ static const inputFuncs[] =
+ {
+ {HandleInput_InBox, CURSOR_AREA_IN_BOX},
+ {HandleInput_InParty, CURSOR_AREA_IN_PARTY},
+ {HandleInput_OnBox, CURSOR_AREA_BOX},
+ {HandleInput_OnButtons, CURSOR_AREA_BUTTONS},
+ {NULL, 0},
+ };
+
+ u16 i = 0;
+ while (inputFuncs[i].func != NULL)
+ {
+ if (inputFuncs[i].area == sBoxCursorArea)
+ return inputFuncs[i].func();
+ i++;
+ }
+
+ return 0;
+}
+
+static void AddBoxMenu(void)
+{
+ InitMenu();
+ SetMenuText(9);
+ SetMenuText(10);
+ SetMenuText(11);
+ SetMenuText(0);
+}
+
+static u8 sub_80CFA5C(void)
+{
+ InitMenu();
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ return sub_80CFA84();
+ else
+ return sub_80CFB44();
+}
+
+static bool8 sub_80CFA84(void)
+{
+ u16 var0 = sub_80CD504();
+
+ switch (sPSSData->boxOption)
+ {
+ case BOX_OPTION_DEPOSIT:
+ if (var0)
+ SetMenuText(1);
+ else
+ return FALSE;
+ break;
+ case BOX_OPTION_WITHDRAW:
+ if (var0)
+ SetMenuText(2);
+ else
+ return FALSE;
+ break;
+ case BOX_OPTION_MOVE_MONS:
+ if (sIsMonBeingMoved)
+ {
+ if (var0)
+ SetMenuText(4);
+ else
+ SetMenuText(5);
+ }
+ else
+ {
+ if (var0)
+ SetMenuText(3);
+ else
+ return FALSE;
+ }
+ break;
+ case BOX_OPTION_MOVE_ITEMS:
+ default:
+ return FALSE;
+ }
+
+ SetMenuText(6);
+ if (sPSSData->boxOption == BOX_OPTION_MOVE_MONS)
+ {
+ if (!sBoxCursorArea)
+ SetMenuText(2);
+ else
+ SetMenuText(1);
+ }
+
+ SetMenuText(8);
+ SetMenuText(7);
+ SetMenuText(0);
+ return TRUE;
+}
+
+static bool8 sub_80CFB44(void)
+{
+ if (sPSSData->cursorMonSpecies == SPECIES_EGG)
+ return FALSE;
+
+ if (!IsActiveItemMoving())
+ {
+ if (sPSSData->cursorMonItem == 0)
+ {
+ if (sPSSData->cursorMonSpecies == SPECIES_NONE)
+ return FALSE;
+
+ SetMenuText(14);
+ }
+ else
+ {
+ if (!ItemIsMail(sPSSData->cursorMonItem))
+ {
+ SetMenuText(12);
+ SetMenuText(16);
+ }
+ SetMenuText(17);
+ }
+ }
+ else
+ {
+ if (sPSSData->cursorMonItem == 0)
+ {
+ if (sPSSData->cursorMonSpecies == SPECIES_NONE)
+ return FALSE;
+
+ SetMenuText(13);
+ }
+ else
+ {
+ if (ItemIsMail(sPSSData->cursorMonItem) == TRUE)
+ return FALSE;
+
+ SetMenuText(15);
+ }
+ }
+
+ SetMenuText(0);
+ return TRUE;
+}
+
+static void sub_80CFBF4(struct Sprite *sprite)
+{
+ sprite->pos1.x = sPSSData->field_CB4->pos1.x;
+ sprite->pos1.y = sPSSData->field_CB4->pos1.y + 20;
+}
+
+static void sub_80CFC14(void)
+{
+ u16 x, y;
+ u8 spriteId;
+ u8 priority, subpriority;
+ struct SpriteSheet spriteSheets[] =
+ {
+ {gHandCursorTiles, 0x800, 0},
+ {gHandCursorShadowTiles, 0x80, 1},
+ {}
+ };
+
+ struct SpritePalette spritePalettes[] =
+ {
+ {gHandCursorPalette, TAG_PAL_DAC7},
+ {}
+ };
+
+ static const struct OamData sOamData_857BA0C =
+ {
+ .size = 2,
+ .priority = 1,
+ };
+ static const struct OamData sOamData_857BA14 =
+ {
+ .size = 1,
+ .priority = 1,
+ };
+
+ static const union AnimCmd sSpriteAnim_857BA1C[] =
+ {
+ ANIMCMD_FRAME(0, 30),
+ ANIMCMD_FRAME(16, 30),
+ ANIMCMD_JUMP(0)
+ };
+ static const union AnimCmd sSpriteAnim_857BA28[] =
+ {
+ ANIMCMD_FRAME(0, 5),
+ ANIMCMD_END
+ };
+ static const union AnimCmd sSpriteAnim_857BA30[] =
+ {
+ ANIMCMD_FRAME(32, 5),
+ ANIMCMD_END
+ };
+ static const union AnimCmd sSpriteAnim_857BA38[] =
+ {
+ ANIMCMD_FRAME(48, 5),
+ ANIMCMD_END
+ };
+
+ static const union AnimCmd *const sSpriteAnimTable_857BA40[] =
+ {
+ sSpriteAnim_857BA1C,
+ sSpriteAnim_857BA28,
+ sSpriteAnim_857BA30,
+ sSpriteAnim_857BA38
+ };
+
+ static const struct SpriteTemplate gSpriteTemplate_857BA50 =
+ {
+ .tileTag = TAG_TILE_0,
+ .paletteTag = TAG_PAL_WAVEFORM,
+ .oam = &sOamData_857BA0C,
+ .anims = sSpriteAnimTable_857BA40,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy,
+ };
+
+ static const struct SpriteTemplate gSpriteTemplate_857BA68 =
+ {
+ .tileTag = TAG_TILE_1,
+ .paletteTag = TAG_PAL_WAVEFORM,
+ .oam = &sOamData_857BA14,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_80CFBF4,
+ };
+
+ LoadSpriteSheets(spriteSheets);
+ LoadSpritePalettes(spritePalettes);
+ sPSSData->field_CD8[0] = IndexOfSpritePaletteTag(TAG_PAL_WAVEFORM);
+ sPSSData->field_CD8[1] = IndexOfSpritePaletteTag(TAG_PAL_DAC7);
+
+ sub_80CD444(sBoxCursorArea, sBoxCursorPosition, &x, &y);
+ spriteId = CreateSprite(&gSpriteTemplate_857BA50, x, y, 6);
+ if (spriteId != MAX_SPRITES)
+ {
+ sPSSData->field_CB4 = &gSprites[spriteId];
+ sPSSData->field_CB4->oam.paletteNum = sPSSData->field_CD8[sCanOnlyMove];
+ sPSSData->field_CB4->oam.priority = 1;
+ if (sIsMonBeingMoved)
+ StartSpriteAnim(sPSSData->field_CB4, 3);
+ }
+ else
+ {
+ sPSSData->field_CB4 = NULL;
+ }
+
+ if (sBoxCursorArea == CURSOR_AREA_IN_PARTY)
+ {
+ subpriority = 13;
+ priority = 1;
+ }
+ else
+ {
+ subpriority = 21;
+ priority = 2;
+ }
+
+ spriteId = CreateSprite(&gSpriteTemplate_857BA68, 0, 0, subpriority);
+ if (spriteId != MAX_SPRITES)
+ {
+ sPSSData->field_CB8 = &gSprites[spriteId];
+ sPSSData->field_CB8->oam.priority = priority;
+ if (sBoxCursorArea)
+ sPSSData->field_CB8->invisible = 1;
+ }
+ else
+ {
+ sPSSData->field_CB8 = NULL;
+ }
+}
+
+static void sub_80CFDC4(void)
+{
+ sCanOnlyMove = !sCanOnlyMove;
+ sPSSData->field_CB4->oam.paletteNum = sPSSData->field_CD8[sCanOnlyMove];
+}
+
+static u8 GetBoxCursorPosition(void)
+{
+ return sBoxCursorPosition;
+}
+
+static void sub_80CFE14(u8 *arg0, u8 *arg1)
+{
+ if (sBoxCursorArea == CURSOR_AREA_IN_BOX)
+ {
+ *arg0 = sBoxCursorPosition % IN_BOX_ROWS;
+ *arg1 = sBoxCursorPosition / IN_BOX_ROWS;
+ }
+ else
+ {
+ *arg0 = 0;
+ *arg1 = 0;
+ }
+}
+
+static void sub_80CFE54(u8 animNum)
+{
+ StartSpriteAnim(sPSSData->field_CB4, animNum);
+}
+
+static u8 sub_80CFE78(void)
+{
+ return sMovingMonOrigBoxId;
+}
+
+static void sub_80CFE84(void)
+{
+ sPSSData->field_CB4->oam.priority = 1;
+}
+
+static void sub_80CFEA8(void)
+{
+ if (sBoxCursorArea == CURSOR_AREA_IN_BOX)
+ sub_80D0E50(CURSOR_AREA_IN_BOX, sBoxCursorPosition);
+}
+
+static void sub_80CFECC(void)
+{
+ if (sBoxCursorArea == CURSOR_AREA_IN_BOX)
+ sub_80D0D8C(CURSOR_AREA_IN_BOX, sBoxCursorPosition);
+}
+
+static void InitMenu(void)
+{
+ sPSSData->menuItemsCount = 0;
+ sPSSData->menuWidth = 0;
+ sPSSData->menuWindow.bg = 0;
+ sPSSData->menuWindow.paletteNum = 15;
+ sPSSData->menuWindow.baseBlock = 92;
+}
+
+static const u8 *const gUnknown_0857BA80[] =
+{
+ gPCText_Cancel,
+ gPCText_Store,
+ gPCText_Withdraw,
+ gPCText_Move,
+ gPCText_Shift,
+ gPCText_Place,
+ gPCText_Summary,
+ gPCText_Release,
+ gPCText_Mark,
+ gPCText_Jump,
+ gPCText_Wallpaper,
+ gPCText_Name,
+ gPCText_Take,
+ gPCText_Give,
+ gPCText_Give,
+ gPCText_Switch,
+ gPCText_Bag,
+ gPCText_Info,
+ gPCText_Scenery1,
+ gPCText_Scenery2,
+ gPCText_Scenery3,
+ gPCText_Etcetera,
+ gPCText_Friends,
+ gPCText_Forest,
+ gPCText_City,
+ gPCText_Desert,
+ gPCText_Savanna,
+ gPCText_Crag,
+ gPCText_Volcano,
+ gPCText_Snow,
+ gPCText_Cave,
+ gPCText_Beach,
+ gPCText_Seafloor,
+ gPCText_River,
+ gPCText_Sky,
+ gPCText_PolkaDot,
+ gPCText_Pokecenter,
+ gPCText_Machine,
+ gPCText_Simple,
+};
+
+static void SetMenuText(u8 textId)
+{
+ if (sPSSData->menuItemsCount < 7)
+ {
+ u8 len;
+ struct StorageMenu *menu = &sPSSData->menuItems[sPSSData->menuItemsCount];
+
+ menu->text = gUnknown_0857BA80[textId];
+ menu->textId = textId;
+ len = StringLength(menu->text);
+ if (len > sPSSData->menuWidth)
+ sPSSData->menuWidth = len;
+
+ sPSSData->menuItemsCount++;
+ }
+}
+
+static s8 sub_80CFF98(u8 arg0)
+{
+ if (arg0 >= sPSSData->menuItemsCount)
+ return -1;
+ else
+ return sPSSData->menuItems[arg0].textId;
+}
+
+static void AddMenu(void)
+{
+ sPSSData->menuWindow.width = sPSSData->menuWidth + 2;
+ sPSSData->menuWindow.height = 2 * sPSSData->menuItemsCount;
+ sPSSData->menuWindow.tilemapLeft = 29 - sPSSData->menuWindow.width;
+ sPSSData->menuWindow.tilemapTop = 15 - sPSSData->menuWindow.height;
+ sPSSData->field_CB0 = AddWindow(&sPSSData->menuWindow);
+ ClearWindowTilemap(sPSSData->field_CB0);
+ SetWindowBorderStyle(sPSSData->field_CB0, FALSE, 11, 14);
+ PrintMenuTable(sPSSData->field_CB0, sPSSData->menuItemsCount, (void*)sPSSData->menuItems);
+ InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sPSSData->field_CB0, sPSSData->menuItemsCount, 0);
+ schedule_bg_copy_tilemap_to_vram(0);
+ sPSSData->field_CAE = 0;
+}
+
+static bool8 sub_80D00A8(void)
+{
+ return FALSE;
+}
+
+static s16 sub_80D00AC(void)
+{
+ s32 textId = -2;
+
+ if (!(gMain.newKeys & A_BUTTON))
+ {
+ if (gMain.newKeys & B_BUTTON)
+ {
+ PlaySE(SE_SELECT);
+ textId = -1;
+ }
+
+ if (gMain.newKeys & DPAD_UP)
+ {
+ PlaySE(SE_SELECT);
+ Menu_MoveCursor(-1);
+ }
+ else if (gMain.newKeys & DPAD_DOWN)
+ {
+ PlaySE(SE_SELECT);
+ Menu_MoveCursor(1);
+ }
+ }
+ else
+ {
+ textId = Menu_GetCursorPos();
+ }
+
+ if (textId != -2)
+ sub_80D013C();
+
+ if (textId >= 0)
+ textId = sPSSData->menuItems[textId].textId;
+
+ #ifndef NONMATCHING
+ asm("":::"r4");
+ #endif // NONMATCHING
+ return textId;
+}
+
+static void sub_80D013C(void)
+{
+ sub_8198070(sPSSData->field_CB0, TRUE);
+ RemoveWindow(sPSSData->field_CB0);
+}
+
+// The functions below handle moving and grabbing multiple mons at once.
+// The icons are converted to background 0 which coordinates are changed while moving mons.
+// There is also a bit of math involved in determining how many column/rows of mons to grab/move.
+
+static const struct WindowTemplate gUnknown_0857BB1C =
+{
+ .bg = 0,
+ .tilemapLeft = 10,
+ .tilemapTop = 3,
+ .width = 20,
+ .height = 18,
+ .paletteNum = 9,
+ .baseBlock = 0xA,
+};
+
+EWRAM_DATA static struct
+{
+ u8 field_0;
+ u8 state;
+ u8 fromRow;
+ u8 fromColumn;
+ u8 toRow;
+ u8 toColumn;
+ u8 field_6;
+ u8 field_7;
+ u8 minRow;
+ u8 minColumn;
+ u8 rowsTotal;
+ u8 columsTotal;
+ u16 bgX;
+ u16 bgY;
+ u16 field_10;
+ struct BoxPokemon boxMons[IN_BOX_COUNT];
+}
+*sMoveMonsPtr = NULL;
+
+static bool8 sub_80D0164(void)
+{
+ sMoveMonsPtr = Alloc(sizeof(*sMoveMonsPtr));
+ if (sMoveMonsPtr != NULL)
+ {
+ sPSSData->field_2200 = AddWindow8Bit(&gUnknown_0857BB1C);
+ if (sPSSData->field_2200 != 0xFF)
+ {
+ FillWindowPixelBuffer(sPSSData->field_2200, 0);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static void sub_80D01B8(void)
+{
+ if (sMoveMonsPtr != NULL)
+ Free(sMoveMonsPtr);
+}
+
+static void sub_80D01D0(u8 arg0)
+{
+ sMoveMonsPtr->field_0 = arg0;
+ sMoveMonsPtr->state = 0;
+}
+
+static bool8 sub_80D01E4(void)
+{
+ switch (sMoveMonsPtr->field_0)
+ {
+ case 0:
+ return sub_80D024C();
+ case 1:
+ return sub_80D0344();
+ case 2:
+ return sub_80D03B0();
+ case 3:
+ return sub_80D0420();
+ case 4:
+ return sub_80D04A0();
+ case 5:
+ return sub_80D04C8();
+ }
+
+ return FALSE;
+}
+
+static bool8 sub_80D024C(void)
+{
+ switch (sMoveMonsPtr->state)
+ {
+ case 0:
+ HideBg(0);
+ sub_80D304C(0x80);
+ sMoveMonsPtr->state++;
+ break;
+ case 1:
+ sub_80CFE14(&sMoveMonsPtr->fromRow, &sMoveMonsPtr->fromColumn);
+ sMoveMonsPtr->toRow = sMoveMonsPtr->fromRow;
+ sMoveMonsPtr->toColumn = sMoveMonsPtr->fromColumn;
+ ChangeBgX(0, -1024, 0);
+ ChangeBgY(0, -1024, 0);
+ FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
+ FillWindowPixelBuffer8Bit(sPSSData->field_2200, 0);
+ sub_80D07B0(sMoveMonsPtr->fromRow, sMoveMonsPtr->fromColumn);
+ SetBgAttribute(0, 4, 1);
+ PutWindowTilemap(sPSSData->field_2200);
+ CopyWindowToVram8Bit(sPSSData->field_2200, 3);
+ BlendPalettes(0x3F00, 8, RGB_WHITE);
+ sub_80CFE54(2);
+ SetGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR);
+ sMoveMonsPtr->state++;
+ break;
+ case 2:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ {
+ ShowBg(0);
+ return FALSE;
+ }
+ break;
+ }
+
+ return TRUE;
+}
+
+static bool8 sub_80D0344(void)
+{
+ switch (sMoveMonsPtr->state)
+ {
+ case 0:
+ HideBg(0);
+ sMoveMonsPtr->state++;
+ break;
+ case 1:
+ sub_80D0B5C();
+ sub_80CFE54(0);
+ sMoveMonsPtr->state++;
+ break;
+ case 2:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ {
+ sub_80CFE84();
+ LoadPalette(stdpal_get(3), 0xD0, 0x20);
+ ShowBg(0);
+ return FALSE;
+ }
+ break;
+ }
+
+ return TRUE;
+}
+
+static bool8 sub_80D03B0(void)
+{
+ switch (sMoveMonsPtr->state)
+ {
+ case 0:
+ if (!sub_80CD554())
+ {
+ sub_80CFE14(&sMoveMonsPtr->field_6, &sMoveMonsPtr->field_7);
+ sub_80D062C();
+ sMoveMonsPtr->toRow = sMoveMonsPtr->field_6;
+ sMoveMonsPtr->toColumn = sMoveMonsPtr->field_7;
+ CopyWindowToVram8Bit(sPSSData->field_2200, 2);
+ sMoveMonsPtr->state++;
+ }
+ break;
+ case 1:
+ return IsDma3ManagerBusyWithBgCopy();
+ }
+
+ return TRUE;
+}
+
+static bool8 sub_80D0420(void)
+{
+ u8 var1, var2;
+
+ switch (sMoveMonsPtr->state)
+ {
+ case 0:
+ sub_80D08CC();
+ sub_80D09A4();
+ sub_80CDC64(FALSE);
+ sMoveMonsPtr->state++;
+ break;
+ case 1:
+ if (!DoMonPlaceChange())
+ {
+ sub_80CFE54(3);
+ sub_80D0884(0, 256, 8);
+ sub_80CDC64(TRUE);
+ sMoveMonsPtr->state++;
+ }
+ break;
+ case 2:
+ var1 = sub_80D0894();
+ var2 = DoMonPlaceChange();
+ if (!var1 && !var2)
+ return FALSE;
+ break;
+ }
+
+ return TRUE;
+}
+
+static bool8 sub_80D04A0(void)
+{
+ u8 var1 = sub_80CD554();
+ u8 var2 = sub_80D0894();
+
+ if (!var1 && !var2)
+ return FALSE;
+ else
+ return TRUE;
+}
+
+static bool8 sub_80D04C8(void)
+{
+ switch (sMoveMonsPtr->state)
+ {
+ case 0:
+ sub_80D0AAC();
+ sub_80D0884(0, -256, 8);
+ sub_80CDC64(FALSE);
+ sMoveMonsPtr->state++;
+ break;
+ case 1:
+ if (!DoMonPlaceChange() && !sub_80D0894())
+ {
+ sub_80D0A1C();
+ sub_80CFE54(2);
+ sub_80CDC64(TRUE);
+ HideBg(0);
+ sMoveMonsPtr->state++;
+ }
+ break;
+ case 2:
+ if (!DoMonPlaceChange())
+ {
+ sub_80CFE54(0);
+ sub_80D0B5C();
+ sMoveMonsPtr->state++;
+ }
+ break;
+ case 3:
+ if (!IsDma3ManagerBusyWithBgCopy())
+ {
+ LoadPalette(stdpal_get(3), 0xD0, 0x20);
+ sub_80CFE84();
+ ShowBg(0);
+ return FALSE;
+ }
+ break;
+ }
+
+ return TRUE;
+}
+
+static bool8 sub_80D0580(u8 arg0)
+{
+ switch (arg0)
+ {
+ case 0:
+ if (sMoveMonsPtr->minColumn == 0)
+ return FALSE;
+ sMoveMonsPtr->minColumn--;
+ sub_80D0884(0, 1024, 6);
+ break;
+ case 1:
+ if (sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal >= 5)
+ return FALSE;
+ sMoveMonsPtr->minColumn++;
+ sub_80D0884(0, -1024, 6);
+ break;
+ case 2:
+ if (sMoveMonsPtr->minRow == 0)
+ return FALSE;
+ sMoveMonsPtr->minRow--;
+ sub_80D0884(1024, 0, 6);
+ break;
+ case 3:
+ if (sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal > 5)
+ return FALSE;
+ sMoveMonsPtr->minRow++;
+ sub_80D0884(-1024, 0, 6);
+ break;
+ }
+
+ return TRUE;
+}
+
+static void sub_80D062C(void)
+{
+ s16 var = (abs(sMoveMonsPtr->fromRow - sMoveMonsPtr->field_6)) - (abs(sMoveMonsPtr->fromRow - sMoveMonsPtr->toRow));
+ s16 var2 = (abs(sMoveMonsPtr->fromColumn - sMoveMonsPtr->field_7)) - (abs(sMoveMonsPtr->fromColumn - sMoveMonsPtr->toColumn));
+
+ if (var > 0)
+ sub_80D06D0(sMoveMonsPtr->field_6, sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn);
+
+ if (var < 0)
+ {
+ sub_80D0740(sMoveMonsPtr->toRow, sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn);
+ sub_80D06D0(sMoveMonsPtr->field_6, sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn);
+ }
+
+ if (var2 > 0)
+ sub_80D0708(sMoveMonsPtr->field_7, sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow);
+
+ if (var2 < 0)
+ {
+ sub_80D0778(sMoveMonsPtr->toColumn, sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow);
+ sub_80D0708(sMoveMonsPtr->field_7, sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow);
+ }
+}
+
+static void sub_80D06D0(u8 arg0, u8 arg1, u8 arg2)
+{
+ u8 var1 = arg1;
+
+ if (arg1 > arg2)
+ {
+ arg1 = arg2;
+ arg2 = var1;
+ }
+
+ while (arg1 <= arg2)
+ sub_80D07B0(arg0, arg1++);
+}
+
+static void sub_80D0708(u8 arg0, u8 arg1, u8 arg2)
+{
+ u8 var1 = arg1;
+
+ if (arg1 > arg2)
+ {
+ arg1 = arg2;
+ arg2 = var1;
+ }
+
+ while (arg1 <= arg2)
+ sub_80D07B0(arg1++, arg0);
+}
+
+static void sub_80D0740(u8 arg0, u8 arg1, u8 arg2)
+{
+ u8 var1 = arg1;
+
+ if (arg1 > arg2)
+ {
+ arg1 = arg2;
+ arg2 = var1;
+ }
+
+ while (arg1 <= arg2)
+ sub_80D0834(arg0, arg1++);
+}
+
+static void sub_80D0778(u8 arg0, u8 arg1, u8 arg2)
+{
+ u8 var1 = arg1;
+
+ if (arg1 > arg2)
+ {
+ arg1 = arg2;
+ arg2 = var1;
+ }
+
+ while (arg1 <= arg2)
+ sub_80D0834(arg1++, arg0);
+}
+
+static void sub_80D07B0(u8 arg0, u8 arg1)
+{
+ u8 position = arg0 + (6 * arg1);
+ u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2);
+ u32 personality = GetCurrentBoxMonData(position, MON_DATA_PERSONALITY);
+
+ if (species != SPECIES_NONE)
+ {
+ const u8 *iconGfx = GetMonIconPtr(species, personality, 1);
+ u8 index = GetValidMonIconPalIndex(species) + 8;
+
+ BlitBitmapRectToWindow4BitTo8Bit(sPSSData->field_2200,
+ iconGfx,
+ 0,
+ 0,
+ 32,
+ 32,
+ 24 * arg0,
+ 24 * arg1,
+ 32,
+ 32,
+ index);
+ }
+}
+
+static void sub_80D0834(u8 arg0, u8 arg1)
+{
+ u8 position = arg0 + (6 * arg1);
+ u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2);
+
+ if (species != SPECIES_NONE)
+ {
+ FillWindowPixelRect8Bit(sPSSData->field_2200,
+ 0,
+ 24 * arg0,
+ 24 * arg1,
+ 32,
+ 32);
+ }
+}
+
+static void sub_80D0884(u16 arg0, u16 arg1, u16 arg2)
+{
+ sMoveMonsPtr->bgX = arg0;
+ sMoveMonsPtr->bgY = arg1;
+ sMoveMonsPtr->field_10 = arg2;
+}
+
+static u8 sub_80D0894(void)
+{
+ if (sMoveMonsPtr->field_10 != 0)
+ {
+ ChangeBgX(0, sMoveMonsPtr->bgX, 1);
+ ChangeBgY(0, sMoveMonsPtr->bgY, 1);
+ sMoveMonsPtr->field_10--;
+ }
+
+ return sMoveMonsPtr->field_10;
+}
+
+static void sub_80D08CC(void)
+{
+ s32 i, j, r8, r9;
+ s32 rowCount, columnCount;
+ u8 boxId;
+ u8 monArrayId;
+
+ sMoveMonsPtr->minRow = min(sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow);
+ sMoveMonsPtr->minColumn = min(sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn);
+ sMoveMonsPtr->rowsTotal = abs(sMoveMonsPtr->fromRow - sMoveMonsPtr->toRow) + 1;
+ sMoveMonsPtr->columsTotal = abs(sMoveMonsPtr->fromColumn - sMoveMonsPtr->toColumn) + 1;
+ boxId = StorageGetCurrentBox();
+ monArrayId = 0;
+ rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal;
+ columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal;
+ for (i = sMoveMonsPtr->minColumn; i < columnCount; i++)
+ {
+ u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow;
+ for (j = sMoveMonsPtr->minRow; j < rowCount; j++)
+ {
+ struct BoxPokemon *boxMon = GetBoxedMonPtr(boxId, boxPosition);
+
+ sMoveMonsPtr->boxMons[monArrayId] = *boxMon;
+ monArrayId++;
+ boxPosition++;
+ }
+ }
+}
+
+static void sub_80D09A4(void)
+{
+ s32 i, j;
+ s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal;
+ s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal;
+ u8 boxId = StorageGetCurrentBox();
+
+ for (i = sMoveMonsPtr->minColumn; i < columnCount; i++)
+ {
+ u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow;
+ for (j = sMoveMonsPtr->minRow; j < rowCount; j++)
+ {
+ DestroyBoxMonIconAtPosition(boxPosition);
+ ZeroBoxMonAt(boxId, boxPosition);
+ boxPosition++;
+ }
+ }
+}
+
+static void sub_80D0A1C(void)
+{
+ s32 i, j;
+ s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal;
+ s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal;
+ u8 monArrayId = 0;
+
+ for (i = sMoveMonsPtr->minColumn; i < columnCount; i++)
+ {
+ u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow;
+ for (j = sMoveMonsPtr->minRow; j < rowCount; j++)
+ {
+ if (GetBoxMonData(&sMoveMonsPtr->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES))
+ sub_80CB140(boxPosition);
+ monArrayId++;
+ boxPosition++;
+ }
+ }
+}
+
+static void sub_80D0AAC(void)
+{
+ s32 i, j;
+ s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal;
+ s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal;
+ u8 boxId = StorageGetCurrentBox();
+ u8 monArrayId = 0;
+
+ for (i = sMoveMonsPtr->minColumn; i < columnCount; i++)
+ {
+ u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow;
+ for (j = sMoveMonsPtr->minRow; j < rowCount; j++)
+ {
+ if (GetBoxMonData(&sMoveMonsPtr->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES))
+ SetBoxMonAt(boxId, boxPosition, &sMoveMonsPtr->boxMons[monArrayId]);
+ boxPosition++;
+ monArrayId++;
+ }
+ }
+}
+
+static void sub_80D0B5C(void)
+{
+ ChangeBgX(0, 0, 0);
+ ChangeBgY(0, 0, 0);
+ SetBgAttribute(0, 4, 0);
+ ClearGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR);
+ FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
+ CopyBgTilemapBufferToVram(0);
+}
+
+static u8 sub_80D0BA4(void)
+{
+ return (IN_BOX_ROWS * sMoveMonsPtr->fromColumn) + sMoveMonsPtr->fromRow;
+}
+
+static bool8 sub_80D0BC0(void)
+{
+ s32 i, j;
+ s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal;
+ s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal;
+ u8 monArrayId = 0;
+
+ for (i = sMoveMonsPtr->minColumn; i < columnCount; i++)
+ {
+ u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow;
+ for (j = sMoveMonsPtr->minRow; j < rowCount; j++)
+ {
+ if (GetBoxMonData(&sMoveMonsPtr->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES)
+ && GetCurrentBoxMonData(boxPosition, MON_DATA_SANITY_HAS_SPECIES))
+ return FALSE;
+
+ monArrayId++;
+ boxPosition++;
+ }
+ }
+
+ return TRUE;
+}
+
+static const u32 gUnknown_0857BB24[] = INCBIN_U32("graphics/pokemon_storage/unknown_frame.4bpp");
+
+static const struct OamData sOamData_857BBA4 =
+{
+ .y = 0,
+ .affineMode = 1,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 0,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 2,
+ .tileNum = 0,
+ .priority = 1,
+ .paletteNum = 0,
+ .affineParam = 0
+};
+
+static const union AffineAnimCmd sSpriteAffineAnim_857BBAC[] =
+{
+ AFFINEANIMCMD_FRAME(128, 128, 0, 0),
+ AFFINEANIMCMD_END
+};
+
+static const union AffineAnimCmd sSpriteAffineAnim_857BBBC[] =
+{
+ AFFINEANIMCMD_FRAME(88, 88, 0, 0),
+ AFFINEANIMCMD_FRAME(5, 5, 0, 8),
+ AFFINEANIMCMD_END
+};
+
+static const union AffineAnimCmd sSpriteAffineAnim_857BBD4[] =
+{
+ AFFINEANIMCMD_FRAME(128, 128, 0, 0),
+ AFFINEANIMCMD_FRAME(-5, -5, 0, 8),
+ AFFINEANIMCMD_END
+};
+
+static const union AffineAnimCmd sSpriteAffineAnim_857BBEC[] =
+{
+ AFFINEANIMCMD_FRAME(128, 128, 0, 0),
+ AFFINEANIMCMD_FRAME(10, 10, 0, 12),
+ AFFINEANIMCMD_FRAME(256, 256, 0, 0),
+ AFFINEANIMCMD_END
+};
+
+static const union AffineAnimCmd sSpriteAffineAnim_857BC0C[] =
+{
+ AFFINEANIMCMD_FRAME(256, 256, 0, 0),
+ AFFINEANIMCMD_FRAME(-10, -10, 0, 12),
+ AFFINEANIMCMD_FRAME(128, 128, 0, 0),
+ AFFINEANIMCMD_END
+};
+
+static const union AffineAnimCmd sSpriteAffineAnim_857BC2C[] =
+{
+ AFFINEANIMCMD_FRAME(256, 256, 0, 0),
+ AFFINEANIMCMD_FRAME(-5, -5, 0, 16),
+ AFFINEANIMCMD_END
+};
+
+static const union AffineAnimCmd sSpriteAffineAnim_857BC44[] =
+{
+ AFFINEANIMCMD_FRAME(256, 256, 0, 0),
+ AFFINEANIMCMD_END
+};
+
+static const union AffineAnimCmd *const sSpriteAffineAnimTable_857BC44[] =
+{
+ sSpriteAffineAnim_857BBAC,
+ sSpriteAffineAnim_857BBBC,
+ sSpriteAffineAnim_857BBD4,
+ sSpriteAffineAnim_857BBEC,
+ sSpriteAffineAnim_857BC0C,
+ sSpriteAffineAnim_857BC2C,
+ sSpriteAffineAnim_857BC44
+};
+
+static const struct SpriteTemplate gSpriteTemplate_857BC70 =
+{
+ .tileTag = TAG_TILE_7,
+ .paletteTag = TAG_PAL_DACB,
+ .oam = &sOamData_857BBA4,
+ .anims = gDummySpriteAnimTable,
+ .images = NULL,
+ .affineAnims = sSpriteAffineAnimTable_857BC44,
+ .callback = SpriteCallbackDummy,
+};
+
+static void sub_80D0C60(void)
+{
+ s32 i;
+ u8 spriteId;
+ struct CompressedSpriteSheet spriteSheet;
+ struct SpriteTemplate spriteTemplate;
+
+ if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS)
+ {
+ spriteSheet.data = gUnknown_03000F78;
+ spriteSheet.size = 0x200;
+ spriteTemplate = gSpriteTemplate_857BC70;
+
+ for (i = 0; i < 3; i++)
+ {
+ spriteSheet.tag = TAG_TILE_7 + i;
+ LoadCompressedSpriteSheet(&spriteSheet);
+ sPSSData->field_2204[i].tiles = GetSpriteTileStartByTag(spriteSheet.tag) * 32 + (void*)(OBJ_VRAM0);
+ sPSSData->field_2204[i].palIndex = AllocSpritePalette(TAG_PAL_DACB + i);
+ sPSSData->field_2204[i].palIndex *= 16;
+ sPSSData->field_2204[i].palIndex += 0x100;
+ spriteTemplate.tileTag = TAG_TILE_7 + i;
+ spriteTemplate.paletteTag = TAG_PAL_DACB + i;
+ spriteId = CreateSprite(&spriteTemplate, 0, 0, 11);
+ sPSSData->field_2204[i].sprite = &gSprites[spriteId];
+ sPSSData->field_2204[i].sprite->invisible = TRUE;
+ sPSSData->field_2204[i].unk10 = 0;
+ }
+ }
+ sPSSData->movingItem = 0;
+}
+
+// The functions below handle new features of MOVE_ITEMS box option.
+static bool32 sub_80D1324(u8 cursorArea, u8 cursorPos);
+static const u32 *GetItemIconPic(u16 itemId);
+static const u32 *GetItemIconPalette(u16 itemId);
+static u8 sub_80D12E8(void);
+static void sub_80D140C(u8 id, u8 cursorArea, u8 cursorPos);
+static void sub_80D1524(u8 id, const u32 *itemTiles, const u32 *itemPal);
+static void sub_80D15D4(u8 id, u8 animNum);
+static void sub_80D1740(u8 id, bool8 arg1);
+static u8 sub_80D1370(u8 cursorArea, u8 cursorPos);
+static void sub_80D1604(u8 id, u8 arg1, u8 arg2, u8 arg3);
+static void sub_80D1AD8(struct Sprite *sprite);
+static void sub_80D1A48(struct Sprite *sprite);
+static void sub_80D1A74(struct Sprite *sprite);
+static void sub_80D1B14(struct Sprite *sprite);
+static void sub_80D1B94(struct Sprite *sprite);
+static void sub_80D1CCC(struct Sprite *sprite);
+static void sub_80D1C30(struct Sprite *sprite);
+
+static void sub_80D0D8C(u8 cursorArea, u8 cursorPos)
+{
+ u16 heldItem;
+
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ return;
+ if (sub_80D1324(cursorArea, cursorPos))
+ return;
+
+ switch (cursorArea)
+ {
+ case CURSOR_AREA_IN_BOX:
+ if (!GetCurrentBoxMonData(cursorPos, MON_DATA_SANITY_HAS_SPECIES))
+ return;
+ heldItem = GetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM);
+ break;
+ case CURSOR_AREA_IN_PARTY:
+ if (cursorPos >= PARTY_SIZE || !GetMonData(&gPlayerParty[cursorPos], MON_DATA_SANITY_HAS_SPECIES))
+ return;
+ heldItem = GetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM);
+ break;
+ default:
+ return;
+ }
+
+ if (heldItem != 0)
+ {
+ const u32 *tiles = GetItemIconPic(heldItem);
+ const u32 *pal = GetItemIconPalette(heldItem);
+ u8 id = sub_80D12E8();
+
+ sub_80D140C(id, cursorArea, cursorPos);
+ sub_80D1524(id, tiles, pal);
+ sub_80D15D4(id, 1);
+ sub_80D1740(id, TRUE);
+ }
+}
+
+static void sub_80D0E50(u8 cursorArea, u8 cursorPos)
+{
+ u8 id;
+
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ return;
+
+ id = sub_80D1370(cursorArea, cursorPos);
+ sub_80D15D4(id, 2);
+ sub_80D1604(id, 0, cursorArea, cursorPos);
+}
+
+static void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos)
+{
+ u8 id;
+ u16 item;
+
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ return;
+
+ id = sub_80D1370(cursorArea, cursorPos);
+ item = 0;
+ sub_80D15D4(id, 3);
+ sub_80D1604(id, 1, cursorArea, cursorPos);
+ sub_80D140C(id, 2, 0);
+ if (cursorArea == CURSOR_AREA_IN_BOX)
+ {
+ SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &item);
+ SetBoxMonIconObjMode(cursorPos, 1);
+ }
+ else
+ {
+ SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &item);
+ SetPartyMonIconObjMode(cursorPos, 1);
+ }
+
+ sPSSData->movingItem = sPSSData->cursorMonItem;
+}
+
+static void sub_80D0F38(u16 item)
+{
+ const u32 *tiles = GetItemIconPic(item);
+ const u32 *pal = GetItemIconPalette(item);
+ u8 id = sub_80D12E8();
+
+ sub_80D1524(id, tiles, pal);
+ sub_80D15D4(id, 6);
+ sub_80D1604(id, 1, 0, 0);
+ sub_80D140C(id, 2, 0);
+ sub_80D1740(id, TRUE);
+ sPSSData->movingItem = item;
+}
+
+static void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos)
+{
+ u8 id;
+ u16 item;
+
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ return;
+
+ id = sub_80D1370(cursorArea, cursorPos);
+ sub_80D15D4(id, 3);
+ sub_80D1604(id, 3, 2, 0);
+ if (cursorArea == CURSOR_AREA_IN_BOX)
+ {
+ item = GetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM);
+ SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sPSSData->movingItem);
+ sPSSData->movingItem = item;
+ }
+ else
+ {
+ item = GetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM);
+ SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sPSSData->movingItem);
+ sPSSData->movingItem = item;
+ }
+
+ id = sub_80D1370(2, 0);
+ sub_80D15D4(id, 4);
+ sub_80D1604(id, 4, cursorArea, cursorPos);
+}
+
+static void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos)
+{
+ u8 id;
+
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ return;
+
+ id = sub_80D1370(2, 0);
+ sub_80D15D4(id, 4);
+ sub_80D1604(id, 2, cursorArea, cursorPos);
+ if (cursorArea == CURSOR_AREA_IN_BOX)
+ {
+ SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sPSSData->movingItem);
+ SetBoxMonIconObjMode(cursorPos, 0);
+ }
+ else
+ {
+ SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sPSSData->movingItem);
+ SetPartyMonIconObjMode(cursorPos, 0);
+ }
+}
+
+static void Item_TakeMons(u8 cursorArea, u8 cursorPos)
+{
+ u8 id;
+ u16 item;
+
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ return;
+
+ item = 0;
+ id = sub_80D1370(cursorArea, cursorPos);
+ sub_80D15D4(id, 2);
+ sub_80D1604(id, 0, cursorArea, cursorPos);
+ if (cursorArea == CURSOR_AREA_IN_BOX)
+ {
+ SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &item);
+ SetBoxMonIconObjMode(cursorPos, 1);
+ }
+ else
+ {
+ SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &item);
+ SetPartyMonIconObjMode(cursorPos, 1);
+ }
+}
+
+static void sub_80D1194(void)
+{
+ if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS)
+ {
+ u8 id = sub_80D1370(2, 0);
+ sub_80D15D4(id, 5);
+ sub_80D1604(id, 0, 2, 0);
+ }
+}
+
+static void sub_80D11CC(void)
+{
+ s32 i;
+
+ if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
+ return;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (sPSSData->field_2204[i].unk10 && sPSSData->field_2204[i].unk8 == 1)
+ sub_80D1604(i, 7, 2, 0);
+ }
+}
+
+static bool8 sub_80D1218(void)
+{
+ s32 i;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (sPSSData->field_2204[i].unk10)
+ {
+ if (!sPSSData->field_2204[i].sprite->affineAnimEnded && sPSSData->field_2204[i].sprite->affineAnimBeginning)
+ return TRUE;
+ if (sPSSData->field_2204[i].sprite->callback != SpriteCallbackDummy && sPSSData->field_2204[i].sprite->callback != sub_80D1AD8)
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static bool8 IsActiveItemMoving(void)
+{
+ s32 i;
+
+ if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS)
+ {
+ for (i = 0; i < 3; i++)
+ {
+ if (sPSSData->field_2204[i].unk10 && sPSSData->field_2204[i].unk8 == 2)
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static const u8 *GetMovingItemName(void)
+{
+ return ItemId_GetName(sPSSData->movingItem);
+}
+
+static u16 GetMovingItem(void)
+{
+ return sPSSData->movingItem;
+}
+
+static u8 sub_80D12E8(void)
+{
+ u8 i;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (sPSSData->field_2204[i].unk10 == 0)
+ {
+ sPSSData->field_2204[i].unk10 = 1;
+ return i;
+ }
+ }
+
+ return 3;
+}
+
+static bool32 sub_80D1324(u8 cursorArea, u8 cursorPos)
+{
+ s32 i;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (sPSSData->field_2204[i].unk10
+ && sPSSData->field_2204[i].unk8 == cursorArea
+ && sPSSData->field_2204[i].unk9 == cursorPos)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static u8 sub_80D1370(u8 cursorArea, u8 cursorPos)
+{
+ u8 i;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (sPSSData->field_2204[i].unk10
+ && sPSSData->field_2204[i].unk8 == cursorArea
+ && sPSSData->field_2204[i].unk9 == cursorPos)
+ return i;
+ }
+
+ return 3;
+}
+
+static u8 sub_80D13C4(struct Sprite *sprite)
+{
+ u8 i;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (sPSSData->field_2204[i].unk10
+ && sPSSData->field_2204[i].sprite == sprite)
+ return i;
+ }
+
+ return 3;
+}
+
+static void sub_80D140C(u8 id, u8 cursorArea, u8 cursorPos)
+{
+ u8 row, column;
+
+ if (id >= 3)
+ return;
+
+ switch (cursorArea)
+ {
+ case CURSOR_AREA_IN_BOX:
+ row = cursorPos % IN_BOX_ROWS;
+ column = cursorPos / IN_BOX_ROWS;
+ sPSSData->field_2204[id].sprite->pos1.x = (24 * row) + 112;
+ sPSSData->field_2204[id].sprite->pos1.y = (24 * column) + 56;
+ sPSSData->field_2204[id].sprite->oam.priority = 2;
+ break;
+ case CURSOR_AREA_IN_PARTY:
+ if (cursorPos == 0)
+ {
+ sPSSData->field_2204[id].sprite->pos1.x = 116;
+ sPSSData->field_2204[id].sprite->pos1.y = 76;
+ }
+ else
+ {
+ sPSSData->field_2204[id].sprite->pos1.x = 164;
+ sPSSData->field_2204[id].sprite->pos1.y = 24 * (cursorPos - 1) + 28;
+ }
+ sPSSData->field_2204[id].sprite->oam.priority = 1;
+ break;
+ }
+
+ sPSSData->field_2204[id].unk8 = cursorArea;
+ sPSSData->field_2204[id].unk9 = cursorPos;
+}
+
+static void sub_80D1524(u8 id, const u32 *itemTiles, const u32 *itemPal)
+{
+ s32 i;
+
+ if (id >= 3)
+ return;
+
+ CpuFastFill(0, sPSSData->field_42C4, 0x200);
+ LZ77UnCompWram(itemTiles, sPSSData->field_22C4);
+ for (i = 0; i < 3; i++)
+ CpuFastCopy(sPSSData->field_22C4 + (i * 0x60), sPSSData->field_42C4 + (i * 0x80), 0x60);
+
+ CpuFastCopy(sPSSData->field_42C4, sPSSData->field_2204[id].tiles, 0x200);
+ LZ77UnCompWram(itemPal, sPSSData->field_42C4);
+ LoadPalette(sPSSData->field_42C4, sPSSData->field_2204[id].palIndex, 0x20);
+}
+
+static void sub_80D15D4(u8 id, u8 animNum)
+{
+ if (id >= 3)
+ return;
+
+ StartSpriteAffineAnim(sPSSData->field_2204[id].sprite, animNum);
+}
+
+static void sub_80D1604(u8 id, u8 arg1, u8 arg2, u8 arg3)
+{
+ if (id >= 3)
+ return;
+
+ switch (arg1)
+ {
+ case 0:
+ sPSSData->field_2204[id].sprite->data[0] = id;
+ sPSSData->field_2204[id].sprite->callback = sub_80D1A48;
+ break;
+ case 1:
+ sPSSData->field_2204[id].sprite->data[0] = 0;
+ sPSSData->field_2204[id].sprite->callback = sub_80D1A74;
+ break;
+ case 2:
+ sPSSData->field_2204[id].sprite->data[0] = 0;
+ sPSSData->field_2204[id].sprite->data[6] = arg2;
+ sPSSData->field_2204[id].sprite->data[7] = arg3;
+ sPSSData->field_2204[id].sprite->callback = sub_80D1B14;
+ break;
+ case 3:
+ sPSSData->field_2204[id].sprite->data[0] = 0;
+ sPSSData->field_2204[id].sprite->callback = sub_80D1B94;
+ sPSSData->field_2204[id].sprite->data[6] = arg2;
+ sPSSData->field_2204[id].sprite->data[7] = arg3;
+ break;
+ case 4:
+ sPSSData->field_2204[id].sprite->data[0] = 0;
+ sPSSData->field_2204[id].sprite->data[6] = arg2;
+ sPSSData->field_2204[id].sprite->data[7] = arg3;
+ sPSSData->field_2204[id].sprite->callback = sub_80D1C30;
+ break;
+ case 7:
+ sPSSData->field_2204[id].sprite->callback = sub_80D1CCC;
+ break;
+ }
+}
+
+static void sub_80D1740(u8 id, bool8 arg1)
+{
+ if (id >= 3)
+ return;
+
+ sPSSData->field_2204[id].unk10 = arg1;
+ sPSSData->field_2204[id].sprite->invisible = (arg1 == FALSE);
+}
+
+static const u32 *GetItemIconPic(u16 itemId)
+{
+ return GetItemIconPicOrPalette(itemId, 0);
+}
+
+static const u32 *GetItemIconPalette(u16 itemId)
+{
+ return GetItemIconPicOrPalette(itemId, 1);
+}
+
+static void PrintItemDescription(void)
+{
+ const u8 *description;
+
+ if (IsActiveItemMoving())
+ description = ItemId_GetDescription(sPSSData->movingItem);
+ else
+ description = ItemId_GetDescription(sPSSData->cursorMonItem);
+
+ FillWindowPixelBuffer(2, 0x11);
+ AddTextPrinterParameterized5(2, 1, description, 4, 0, 0, NULL, 0, 1);
+}
+
+static void sub_80D1818(void)
+{
+ sPSSData->field_2236 = 0x15;
+ LoadBgTiles(0, gUnknown_0857BB24, 0x80, 0x13A);
+ sub_80D19B4(0);
+}
+
+static bool8 sub_80D184C(void)
+{
+ s32 i, var;
+
+ if (sPSSData->field_2236 == 0)
+ return FALSE;
+
+ sPSSData->field_2236--;
+ var = 0x15 - sPSSData->field_2236;
+ for (i = 0; i < var; i++)
+ {
+ WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, 10) + 0x14 + sPSSData->field_2236 + i, i, 13, 1, 7, 15, 21);
+ }
+
+ sub_80D19B4(var);
+ return (sPSSData->field_2236 != 0);
+}
+
+static bool8 sub_80D18E4(void)
+{
+ s32 i, var;
+
+ if (sPSSData->field_2236 == 0x16)
+ return FALSE;
+
+ if (sPSSData->field_2236 == 0)
+ FillBgTilemapBufferRect(0, 0, 21, 12, 1, 9, 17);
+
+ sPSSData->field_2236++;
+ var = 0x15 - sPSSData->field_2236;
+ for (i = 0; i < var; i++)
+ {
+ WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, 10) + 0x14 + sPSSData->field_2236 + i, i, 13, 1, 7, 15, 21);
+ }
+
+ if (var >= 0)
+ sub_80D19B4(var);
+
+ FillBgTilemapBufferRect(0, 0, var + 1, 12, 1, 9, 0x11);
+ schedule_bg_copy_tilemap_to_vram(0);
+ return TRUE;
+}
+
+static void sub_80D19B4(u32 arg0)
+{
+ if (arg0 != 0)
+ {
+ FillBgTilemapBufferRect(0, 0x13A, 0, 0xC, arg0, 1, 0xFu);
+ FillBgTilemapBufferRect(0, 0x93A, 0, 0x14, arg0, 1, 0xFu);
+ }
+ FillBgTilemapBufferRect(0, 0x13B, arg0, 0xD, 1, 7, 0xFu);
+ FillBgTilemapBufferRect(0, 0x13C, arg0, 0xC, 1, 1, 0xFu);
+ FillBgTilemapBufferRect(0, 0x13D, arg0, 0x14, 1, 1, 0xFu);
+ schedule_bg_copy_tilemap_to_vram(0);
+}
+
+static void sub_80D1A48(struct Sprite *sprite)
+{
+ if (sprite->affineAnimEnded)
+ {
+ sub_80D1740(sprite->data[0], FALSE);
+ sprite->callback = SpriteCallbackDummy;
+ }
+}
+
+static void sub_80D1A74(struct Sprite *sprite)
+{
+ switch (sprite->data[0])
+ {
+ case 0:
+ sprite->data[1] = sprite->pos1.x << 4;
+ sprite->data[2] = sprite->pos1.y << 4;
+ sprite->data[3] = 10;
+ sprite->data[4] = 21;
+ sprite->data[5] = 0;
+ sprite->data[0]++;
+ case 1:
+ sprite->data[1] -= sprite->data[3];
+ sprite->data[2] -= sprite->data[4];
+ sprite->pos1.x = sprite->data[1] >> 4;
+ sprite->pos1.y = sprite->data[2] >> 4;
+ if (++sprite->data[5] > 11)
+ sprite->callback = sub_80D1AD8;
+ break;
+ }
+}
+
+static void sub_80D1AD8(struct Sprite *sprite)
+{
+ sprite->pos1.x = sPSSData->field_CB4->pos1.x + 4;
+ sprite->pos1.y = sPSSData->field_CB4->pos1.y + sPSSData->field_CB4->pos2.y + 8;
+ sprite->oam.priority = sPSSData->field_CB4->oam.priority;
+}
+
+static void sub_80D1B14(struct Sprite *sprite)
+{
+ switch (sprite->data[0])
+ {
+ case 0:
+ sprite->data[1] = sprite->pos1.x << 4;
+ sprite->data[2] = sprite->pos1.y << 4;
+ sprite->data[3] = 10;
+ sprite->data[4] = 21;
+ sprite->data[5] = 0;
+ sprite->data[0]++;
+ case 1:
+ sprite->data[1] += sprite->data[3];
+ sprite->data[2] += sprite->data[4];
+ sprite->pos1.x = sprite->data[1] >> 4;
+ sprite->pos1.y = sprite->data[2] >> 4;
+ if (++sprite->data[5] > 11)
+ {
+ sub_80D140C(sub_80D13C4(sprite), sprite->data[6], sprite->data[7]);
+ sprite->callback = SpriteCallbackDummy;
+ }
+ break;
+ }
+}
+
+static void sub_80D1B94(struct Sprite *sprite)
+{
+ switch (sprite->data[0])
+ {
+ case 0:
+ sprite->data[1] = sprite->pos1.x << 4;
+ sprite->data[2] = sprite->pos1.y << 4;
+ sprite->data[3] = 10;
+ sprite->data[4] = 21;
+ sprite->data[5] = 0;
+ sprite->data[0]++;
+ case 1:
+ sprite->data[1] -= sprite->data[3];
+ sprite->data[2] -= sprite->data[4];
+ sprite->pos1.x = sprite->data[1] >> 4;
+ sprite->pos1.y = sprite->data[2] >> 4;
+ sprite->pos2.x = gSineTable[sprite->data[5] * 8] >> 4;
+ if (++sprite->data[5] > 11)
+ {
+ sub_80D140C(sub_80D13C4(sprite), sprite->data[6], sprite->data[7]);
+ sprite->pos2.x = 0;
+ sprite->callback = sub_80D1AD8;
+ }
+ break;
+ }
+}
+
+static void sub_80D1C30(struct Sprite *sprite)
+{
+ switch (sprite->data[0])
+ {
+ case 0:
+ sprite->data[1] = sprite->pos1.x << 4;
+ sprite->data[2] = sprite->pos1.y << 4;
+ sprite->data[3] = 10;
+ sprite->data[4] = 21;
+ sprite->data[5] = 0;
+ sprite->data[0]++;
+ case 1:
+ sprite->data[1] += sprite->data[3];
+ sprite->data[2] += sprite->data[4];
+ sprite->pos1.x = sprite->data[1] >> 4;
+ sprite->pos1.y = sprite->data[2] >> 4;
+ sprite->pos2.x = -(gSineTable[sprite->data[5] * 8] >> 4);
+ if (++sprite->data[5] > 11)
+ {
+ sub_80D140C(sub_80D13C4(sprite), sprite->data[6], sprite->data[7]);
+ sprite->callback = SpriteCallbackDummy;
+ sprite->pos2.x = 0;
+ }
+ break;
+ }
+}
+
+static void sub_80D1CCC(struct Sprite *sprite)
+{
+ sprite->pos1.y -= 8;
+ if (sprite->pos1.y + sprite->pos2.y < -16)
+ {
+ sprite->callback = SpriteCallbackDummy;
+ sub_80D1740(sub_80D13C4(sprite), FALSE);
+ }
+}
+
+void nullsub_pss(void)
+{
+
+}
+
+void nullsub_98(void)
+{
+
+}
+
+// Functions here are general utility functions.
+u8 StorageGetCurrentBox(void)
+{
+ return gPokemonStoragePtr->currentBox;
+}
+
+static void SetCurrentBox(u8 boxId)
+{
+ if (boxId < TOTAL_BOXES_COUNT)
+ gPokemonStoragePtr->currentBox = boxId;
+}
+
+u32 GetBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request)
+{
+ if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
+ return GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request);
+ else
+ return 0;
+}
+
+void SetBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, const void *value)
+{
+ if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
+ SetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request, value);
+}
+
+u32 GetCurrentBoxMonData(u8 boxPosition, s32 request)
+{
+ return GetBoxMonDataAt(gPokemonStoragePtr->currentBox, boxPosition, request);
+}
+
+void SetCurrentBoxMonData(u8 boxPosition, s32 request, const void *value)
+{
+ SetBoxMonDataAt(gPokemonStoragePtr->currentBox, boxPosition, request, value);
+}
+
+void GetBoxMonNickAt(u8 boxId, u8 boxPosition, u8 *dst)
+{
+ if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
+ GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_NICKNAME, dst);
+ else
+ *dst = EOS;
+}
+
+u32 GetBoxMonLevelAt(u8 boxId, u8 boxPosition)
+{
+ u32 lvl;
+
+ // BUG: Missed 'else' statement.
+ if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT && GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_HAS_SPECIES))
+ lvl = GetLevelFromBoxMonExp(&gPokemonStoragePtr->boxes[boxId][boxPosition]);
+ // else
+ lvl = 0;
+
+ return lvl;
+}
+
+void SetBoxMonNickAt(u8 boxId, u8 boxPosition, const u8 *nick)
+{
+ if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
+ SetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_NICKNAME, nick);
+}
+
+u32 GetAndCopyBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, void *dst)
+{
+ if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
+ return GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request, dst);
+ else
+ return 0;
+}
+
+void SetBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon *src)
+{
+ if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
+ gPokemonStoragePtr->boxes[boxId][boxPosition] = *src;
+}
+
+void CopyBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon *dst)
+{
+ if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
+ *dst = gPokemonStoragePtr->boxes[boxId][boxPosition];
+}
+
+void CreateBoxMonAt(u8 boxId, u8 boxPosition, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 personality, u8 otIDType, u32 otID)
+{
+ if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
+ {
+ CreateBoxMon(&gPokemonStoragePtr->boxes[boxId][boxPosition],
+ species,
+ level,
+ fixedIV,
+ hasFixedPersonality, personality,
+ otIDType, otID);
+ }
+}
+
+void ZeroBoxMonAt(u8 boxId, u8 boxPosition)
+{
+ if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
+ ZeroBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition]);
+}
+
+void BoxMonAtToMon(u8 boxId, u8 boxPosition, struct Pokemon *dst)
+{
+ if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
+ BoxMonToMon(&gPokemonStoragePtr->boxes[boxId][boxPosition], dst);
+}
+
+struct BoxPokemon *GetBoxedMonPtr(u8 boxId, u8 boxPosition)
+{
+ if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
+ return &gPokemonStoragePtr->boxes[boxId][boxPosition];
+ else
+ return NULL;
+}
+
+u8 *GetBoxNamePtr(u8 boxId)
+{
+ if (boxId < TOTAL_BOXES_COUNT)
+ return gPokemonStoragePtr->boxNames[boxId];
+ else
+ return NULL;
+}
+
+u8 GetBoxWallpaper(u8 boxId)
+{
+ if (boxId < TOTAL_BOXES_COUNT)
+ return gPokemonStoragePtr->boxWallpapers[boxId];
+ else
+ return 0;
+}
+
+void SetBoxWallpaper(u8 boxId, u8 wallpaperId)
+{
+ if (boxId < TOTAL_BOXES_COUNT && wallpaperId < WALLPAPER_COUNT)
+ gPokemonStoragePtr->boxWallpapers[boxId] = wallpaperId;
+}
+
+s16 sub_80D214C(struct BoxPokemon *boxMons, u8 currIndex, u8 maxIndex, u8 arg3)
+{
+ s16 i;
+ s16 adder = -1;
+
+ if (arg3 < 2)
+ adder = 1;
+
+ if (arg3 == 1 || arg3 == 3)
+ {
+ for (i = (s8)currIndex + adder; i >= 0 && i <= maxIndex; i += adder)
+ {
+ if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE)
+ return i;
+ }
+ }
+ else
+ {
+ for (i = (s8)currIndex + adder; i >= 0 && i <= maxIndex; i += adder)
+ {
+ if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE
+ && !GetBoxMonData(&boxMons[i], MON_DATA_IS_EGG))
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+bool8 CheckFreePokemonStorageSpace(void)
+{
+ s32 i, j;
+
+ for (i = 0; i < TOTAL_BOXES_COUNT; i++)
+ {
+ for (j = 0; j < IN_BOX_COUNT; j++)
+ {
+ if (!GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_HAS_SPECIES))
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+bool32 CheckBoxMonSanityAt(u32 boxId, u32 boxPosition)
+{
+ if (boxId < TOTAL_BOXES_COUNT
+ && boxPosition < IN_BOX_COUNT
+ && GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_HAS_SPECIES)
+ && !GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_IS_EGG)
+ && !GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_IS_BAD_EGG))
+ return TRUE;
+ else
+ return FALSE;
+}
+
+u32 CountStorageNonEggMons(void)
+{
+ s32 i, j;
+ u32 count = 0;
+
+ for (i = 0; i < TOTAL_BOXES_COUNT; i++)
+ {
+ for (j = 0; j < IN_BOX_COUNT; j++)
+ {
+ if (GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_HAS_SPECIES)
+ && !GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_IS_EGG))
+ count++;
+ }
+ }
+
+ return count;
+}
+
+u32 CountAllStorageMons(void)
+{
+ s32 i, j;
+ u32 count = 0;
+
+ for (i = 0; i < TOTAL_BOXES_COUNT; i++)
+ {
+ for (j = 0; j < IN_BOX_COUNT; j++)
+ {
+ if (GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_HAS_SPECIES)
+ || GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_IS_EGG))
+ count++;
+ }
+ }
+
+ return count;
+}
+
+bool32 AnyStorageMonWithMove(u16 moveId)
+{
+ u16 moves[] = {moveId, MOVES_COUNT};
+ s32 i, j;
+
+ for (i = 0; i < TOTAL_BOXES_COUNT; i++)
+ {
+ for (j = 0; j < IN_BOX_COUNT; j++)
+ {
+ if (GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_HAS_SPECIES)
+ && !GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_IS_EGG)
+ && GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_KNOWN_MOVES, moves))
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+void ResetWaldaWallpaper(void)
+{
+ gSaveBlock1Ptr->waldaPhrase.iconId = 0;
+ gSaveBlock1Ptr->waldaPhrase.patternId = 0;
+ gSaveBlock1Ptr->waldaPhrase.patternUnlocked = FALSE;
+ gSaveBlock1Ptr->waldaPhrase.colors[0] = RGB(21, 25, 30);
+ gSaveBlock1Ptr->waldaPhrase.colors[1] = RGB(6, 12, 24);
+ gSaveBlock1Ptr->waldaPhrase.text[0] = EOS;
+}
+
+void SetWaldaWallpaperLockedOrUnlocked(bool32 unlocked)
+{
+ gSaveBlock1Ptr->waldaPhrase.patternUnlocked = unlocked;
+}
+
+bool32 IsWaldaWallpaperUnlocked(void)
+{
+ return gSaveBlock1Ptr->waldaPhrase.patternUnlocked;
+}
+
+u32 GetWaldaWallpaperPatternId(void)
+{
+ return gSaveBlock1Ptr->waldaPhrase.patternId;
+}
+
+void SetWaldaWallpaperPatternId(u8 id)
+{
+ if (id < FRIENDS_WALLPAPERS_COUNT)
+ gSaveBlock1Ptr->waldaPhrase.patternId = id;
+}
+
+u32 GetWaldaWallpaperIconId(void)
+{
+ return gSaveBlock1Ptr->waldaPhrase.iconId;
+}
+
+void SetWaldaWallpaperIconId(u8 id)
+{
+ if (id < 30)
+ gSaveBlock1Ptr->waldaPhrase.iconId = id;
+}
+
+u16 *GetWaldaWallpaperColorsPtr(void)
+{
+ return gSaveBlock1Ptr->waldaPhrase.colors;
+}
+
+void SetWaldaWallpaperColors(u16 color1, u16 color2)
+{
+ gSaveBlock1Ptr->waldaPhrase.colors[0] = color1;
+ gSaveBlock1Ptr->waldaPhrase.colors[1] = color2;
+}
+
+u8 *GetWaldaPhrasePtr(void)
+{
+ return gSaveBlock1Ptr->waldaPhrase.text;
+}
+
+void SetWaldaPhrase(const u8 *src)
+{
+ StringCopy(gSaveBlock1Ptr->waldaPhrase.text, src);
+}
+
+bool32 IsWaldaPhraseEmpty(void)
+{
+ return (gSaveBlock1Ptr->waldaPhrase.text[0] == EOS);
+}
+
+// Not sure what the purpose of these functions is.
+// They seem to only be called while PSS is initialized.
+
+EWRAM_DATA static struct UnkStruct_2039D84 *gUnknown_02039D84 = NULL;
+EWRAM_DATA static u16 gUnknown_02039D88 = 0;
+
+static void sub_80D259C(u8 count)
+{
+ u16 i;
+
+ gUnknown_02039D84 = Alloc(sizeof(*gUnknown_02039D84) * count);
+ gUnknown_02039D88 = (gUnknown_02039D84 == NULL) ? 0 : count;
+ for (i = 0; i < gUnknown_02039D88; i++)
+ {
+ gUnknown_02039D84[i].field_18 = NULL;
+ gUnknown_02039D84[i].field_2C = 0;
+ }
+}
+
+static void sub_80D25F0(void)
+{
+ Free(gUnknown_02039D84);
+}
+
+static void sub_80D2604(void)
+{
+ s32 i;
+
+ for (i = 0; i < gUnknown_02039D88; i++)
+ {
+ if (gUnknown_02039D84[i].field_2C == 1)
+ sub_80D2918(i);
+ }
+}
+
+struct
+{
+ u16 a;
+ u16 b;
+}
+static const sUnkVars[][4] =
+{
+ {
+ {0x0100, 0x0100},
+ {0x0200, 0x0100},
+ {0x0100, 0x0200},
+ {0x0200, 0x0200},
+ },
+ {
+ {0x0080, 0x0080},
+ {0x0100, 0x0100},
+ {0x0200, 0x0200},
+ {0x0400, 0x0400},
+ },
+};
+
+static void sub_80D2644(u8 id, u8 bg, const void *arg2, u16 arg3, u16 arg4)
+{
+ u16 attribute1, attribute2;
+
+ if (id >= gUnknown_02039D88)
+ return;
+
+ gUnknown_02039D84[id].field_18 = NULL;
+ gUnknown_02039D84[id].field_1C = arg2;
+ gUnknown_02039D84[id].field_2B = bg;
+ gUnknown_02039D84[id].field_24 = arg3;
+ gUnknown_02039D84[id].field_26 = arg4;
+
+ attribute1 = GetBgAttribute(bg, 3);
+ attribute2 = GetBgAttribute(bg, 9);
+ gUnknown_02039D84[id].field_20 = sUnkVars[attribute2][attribute1].a;
+ gUnknown_02039D84[id].field_22 = sUnkVars[attribute2][attribute1].b;
+ if (attribute2 != 0)
+ gUnknown_02039D84[id].field_2A = 1;
+ else
+ gUnknown_02039D84[id].field_2A = 2;
+
+ gUnknown_02039D84[id].field_28 = gUnknown_02039D84[id].field_2A * arg3;
+ gUnknown_02039D84[id].field_0[1].field_4 = arg3;
+ gUnknown_02039D84[id].field_0[1].field_6 = arg4;
+ gUnknown_02039D84[id].field_0[1].field_0 = 0;
+ gUnknown_02039D84[id].field_0[1].field_2 = 0;
+ gUnknown_02039D84[id].field_0[1].field_8 = 0;
+ gUnknown_02039D84[id].field_0[1].field_A = 0;
+ gUnknown_02039D84[id].field_0[0] = gUnknown_02039D84[id].field_0[1];
+ gUnknown_02039D84[id].field_2C = 1;
+}
+
+static void sub_80D2740(u8 id, const void *arg1)
+{
+ if (id >= gUnknown_02039D88)
+ return;
+
+ gUnknown_02039D84[id].field_18 = arg1;
+ gUnknown_02039D84[id].field_2C = 1;
+}
+
+static void sub_80D2770(u8 id, u16 arg1, u16 arg2)
+{
+ if (id >= gUnknown_02039D88)
+ return;
+
+ gUnknown_02039D84[id].field_0[1].field_8 = arg1;
+ gUnknown_02039D84[id].field_0[1].field_A = arg2;
+ gUnknown_02039D84[id].field_2C = 1;
+}
+
+static void sub_80D27AC(u8 id, u16 arg1, u16 arg2, u16 arg3, u16 arg4)
+{
+ if (id >= gUnknown_02039D88)
+ return;
+
+ gUnknown_02039D84[id].field_0[1].field_0 = arg1;
+ gUnknown_02039D84[id].field_0[1].field_2 = arg2;
+ gUnknown_02039D84[id].field_0[1].field_4 = arg3;
+ gUnknown_02039D84[id].field_0[1].field_6 = arg4;
+ gUnknown_02039D84[id].field_2C = 1;
+}
+
+static void sub_80D27F4(u8 id, u8 arg1, s8 arg2)
+{
+ if (id >= gUnknown_02039D88)
+ return;
+
+ switch (arg1)
+ {
+ case 0:
+ gUnknown_02039D84[id].field_0[1].field_8 += arg2;
+ gUnknown_02039D84[id].field_0[1].field_4 -= arg2;
+ break;
+ case 1:
+ gUnknown_02039D84[id].field_0[1].field_0 += arg2;
+ gUnknown_02039D84[id].field_0[1].field_4 += arg2;
+ break;
+ case 2:
+ gUnknown_02039D84[id].field_0[1].field_A += arg2;
+ gUnknown_02039D84[id].field_0[1].field_6 -= arg2;
+ break;
+ case 3:
+ gUnknown_02039D84[id].field_0[1].field_2 -= arg2;
+ gUnknown_02039D84[id].field_0[1].field_6 += arg2;
+ break;
+ case 4:
+ gUnknown_02039D84[id].field_0[1].field_8 += arg2;
+ break;
+ case 5:
+ gUnknown_02039D84[id].field_0[1].field_A += arg2;
+ break;
+ }
+
+ gUnknown_02039D84[id].field_2C = 1;
+}
+
+static void sub_80D2918(u8 id)
+{
+ if (id >= gUnknown_02039D88)
+ return;
+
+ if (gUnknown_02039D84[id].field_18 != NULL)
+ sub_80D2960(id);
+
+ sub_80D29F8(id);
+ gUnknown_02039D84[id].field_0[0] = gUnknown_02039D84[id].field_0[1];
+}
+
+static void sub_80D2960(u8 id)
+{
+ s32 i;
+ u32 adder = gUnknown_02039D84[id].field_2A * gUnknown_02039D84[id].field_20;
+ const void *tiles = (gUnknown_02039D84[id].field_18 + (adder * gUnknown_02039D84[id].field_0[0].field_A))
+ + (gUnknown_02039D84[id].field_2A * gUnknown_02039D84[id].field_0[0].field_8);
+
+ for (i = 0; i < gUnknown_02039D84[id].field_0[0].field_6; i++)
+ {
+ CopyToBgTilemapBufferRect(gUnknown_02039D84[id].field_2B,
+ tiles,
+ gUnknown_02039D84[id].field_0[0].field_8,
+ gUnknown_02039D84[id].field_0[0].field_A + i,
+ gUnknown_02039D84[id].field_0[0].field_4,
+ 1);
+ tiles += adder;
+ }
+}
+
+static void sub_80D29F8(u8 id)
+{
+ s32 i;
+ u32 adder = gUnknown_02039D84[id].field_2A * gUnknown_02039D84[id].field_24;
+ const void *tiles = (gUnknown_02039D84[id].field_1C + (adder * gUnknown_02039D84[id].field_0[1].field_2))
+ + (gUnknown_02039D84[id].field_2A * gUnknown_02039D84[id].field_0[1].field_0);
+
+ for (i = 0; i < gUnknown_02039D84[id].field_0[1].field_6; i++)
+ {
+ CopyToBgTilemapBufferRect(gUnknown_02039D84[id].field_2B,
+ tiles,
+ gUnknown_02039D84[id].field_0[1].field_8,
+ gUnknown_02039D84[id].field_0[1].field_A + i,
+ gUnknown_02039D84[id].field_0[1].field_4,
+ 1);
+ tiles += adder;
+ }
+}
+
+EWRAM_DATA static struct UnkStruct_2000020 *gUnknown_02039D8C = NULL;
+
+static void sub_80D2A90(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2)
+{
+ gUnknown_02039D8C = arg0;
+ arg0->unk_00 = arg1;
+ arg0->unk_05 = arg2;
+ arg0->unk_04 = 0;
+}
+
+static void sub_80D2AA4(void)
+{
+ u16 i;
+
+ if (gUnknown_02039D8C->unk_04)
+ {
+ for (i = 0; i < gUnknown_02039D8C->unk_04; i++)
+ {
+ struct UnkStruct_2000028 *unkStruct = &gUnknown_02039D8C->unk_00[i];
+ unkStruct->unk_0c(unkStruct);
+ }
+
+ gUnknown_02039D8C->unk_04 = 0;
+ }
+}
+
+static bool8 sub_80D2AEC(u8 *dest, u16 dLeft, u16 dTop, const u8 *src, u16 sLeft, u16 sTop, u16 width, u16 height, u16 unkArg)
+{
+ struct UnkStruct_2000028 *unkStruct;
+
+ if (gUnknown_02039D8C->unk_04 >= gUnknown_02039D8C->unk_05)
+ return FALSE;
+
+ unkStruct = &gUnknown_02039D8C->unk_00[gUnknown_02039D8C->unk_04++];
+ unkStruct->unk_08 = width * 2;
+ unkStruct->unk_04 = dest + 2 * (dTop * 32 + dLeft);
+ unkStruct->unk_00 = src + 2 * (sTop * unkArg + sLeft);
+ unkStruct->newField = height;
+ unkStruct->unk_0a = unkArg;
+ unkStruct->unk_0c = sub_80D2B88;
+ return TRUE;
+}
+
+static void sub_80D2B88(struct UnkStruct_2000028 *unkStruct)
+{
+ u16 i;
+
+ for (i = 0; i < unkStruct->newField; i++)
+ {
+ CpuSet(unkStruct->unk_00, unkStruct->unk_04, (unkStruct->unk_08 / 2));
+ unkStruct->unk_04 += 64;
+ unkStruct->unk_00 += (unkStruct->unk_0a * 2);
+ }
+}
+
+static bool8 sub_80D2BC0(void *dest, u16 dLeft, u16 dTop, u16 width, u16 height)
+{
+ struct UnkStruct_2000028 *unkStruct;
+
+ if (gUnknown_02039D8C->unk_04 >= gUnknown_02039D8C->unk_05)
+ return FALSE;
+
+ unkStruct = &gUnknown_02039D8C->unk_00[gUnknown_02039D8C->unk_04++];
+ unkStruct->unk_08 = width * 2;
+ unkStruct->unk_04 = dest + ((dTop * 32) + dLeft) * 2;
+ unkStruct->newField = height;
+ unkStruct->unk_0c = sub_80D2C1C;
+ return TRUE;
+}
+
+static void sub_80D2C1C(struct UnkStruct_2000028 *unkStruct)
+{
+ u16 i;
+
+ for (i = 0; i < unkStruct->newField; i++)
+ {
+ Dma3FillLarge_(0, unkStruct->unk_04, unkStruct->unk_08, 16);
+ unkStruct->unk_04 += 64;
+ }
+}
diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c
index fb2a43786..a72e83b96 100644
--- a/src/pokemon_summary_screen.c
+++ b/src/pokemon_summary_screen.c
@@ -1005,7 +1005,7 @@ void ShowPokemonSummaryScreen(u8 mode, void *mons, u8 monIndex, u8 maxMonIndex,
pssData->maxMonIndex = maxMonIndex;
pssData->callback = callback;
- if (mode == PSS_MODE_UNK2)
+ if (mode == PSS_MODE_BOX)
pssData->isBoxMon = TRUE;
else
pssData->isBoxMon = FALSE;
@@ -1013,7 +1013,7 @@ void ShowPokemonSummaryScreen(u8 mode, void *mons, u8 monIndex, u8 maxMonIndex,
switch (mode)
{
case PSS_MODE_NORMAL:
- case PSS_MODE_UNK2:
+ case PSS_MODE_BOX:
pssData->minPageIndex = 0;
pssData->maxPageIndex = 3;
break;
@@ -1255,23 +1255,23 @@ static bool8 SummaryScreen_DecompressGraphics(void)
pssData->unk40F0++;
break;
case 7:
- LoadCompressedObjectPic(&sSpriteSheet_MoveTypes);
+ LoadCompressedSpriteSheet(&sSpriteSheet_MoveTypes);
pssData->unk40F0++;
break;
case 8:
- LoadCompressedObjectPic(&gUnknown_0861D074);
+ LoadCompressedSpriteSheet(&gUnknown_0861D074);
pssData->unk40F0++;
break;
case 9:
- LoadCompressedObjectPic(&gUnknown_0861D0F8);
+ LoadCompressedSpriteSheet(&gUnknown_0861D0F8);
pssData->unk40F0++;
break;
case 10:
- LoadCompressedObjectPalette(&gUnknown_0861D100);
+ LoadCompressedSpritePalette(&gUnknown_0861D100);
pssData->unk40F0++;
break;
case 11:
- LoadCompressedObjectPalette(&gUnknown_0861D07C);
+ LoadCompressedSpritePalette(&gUnknown_0861D07C);
pssData->unk40F0++;
break;
case 12:
@@ -1310,7 +1310,7 @@ static bool8 ExtractMonDataToSummaryStruct(struct Pokemon *a)
sum->altAbility = GetMonData(a, MON_DATA_ALT_ABILITY);
sum->item = GetMonData(a, MON_DATA_HELD_ITEM);
sum->pid = GetMonData(a, MON_DATA_PERSONALITY);
- sum->sanity = GetMonData(a, MON_DATA_SANITY_BIT1);
+ sum->sanity = GetMonData(a, MON_DATA_SANITY_IS_BAD_EGG);
if (sum->sanity)
sum->isEgg = TRUE;
@@ -1327,7 +1327,7 @@ static bool8 ExtractMonDataToSummaryStruct(struct Pokemon *a)
sum->ppBonuses = GetMonData(a, MON_DATA_PP_BONUSES);
break;
case 2:
- if (pssData->monList.mons == gPlayerParty || pssData->mode == PSS_MODE_UNK2 || pssData->unk40EF == TRUE)
+ if (pssData->monList.mons == gPlayerParty || pssData->mode == PSS_MODE_BOX || pssData->unk40EF == TRUE)
{
sum->nature = GetNature(a);
sum->currentHP = GetMonData(a, MON_DATA_HP);
@@ -3829,7 +3829,7 @@ static u8 sub_81C45F4(struct Pokemon *mon, s16 *a1)
{
if (gMonSpritesGfxPtr != NULL)
{
- if (pssData->monList.mons == gPlayerParty || pssData->mode == PSS_MODE_UNK2 || pssData->unk40EF == TRUE)
+ if (pssData->monList.mons == gPlayerParty || pssData->mode == PSS_MODE_BOX || pssData->unk40EF == TRUE)
{
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[summary->species2], gMonSpritesGfxPtr->sprites[1], summary->species2, summary->pid);
}
@@ -3840,7 +3840,7 @@ static u8 sub_81C45F4(struct Pokemon *mon, s16 *a1)
}
else
{
- if (pssData->monList.mons == gPlayerParty || pssData->mode == PSS_MODE_UNK2 || pssData->unk40EF == TRUE)
+ if (pssData->monList.mons == gPlayerParty || pssData->mode == PSS_MODE_BOX || pssData->unk40EF == TRUE)
{
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[summary->species2], sub_806F4F8(0, 1), summary->species2, summary->pid);
}
@@ -3854,7 +3854,7 @@ static u8 sub_81C45F4(struct Pokemon *mon, s16 *a1)
return -1;
case 1:
pal = GetMonSpritePalStructFromOtIdPersonality(summary->species2, summary->OTID, summary->pid);
- LoadCompressedObjectPalette(pal);
+ LoadCompressedSpritePalette(pal);
SetMultiuseSpriteTemplateToPokemon(pal->tag, 1);
(*a1)++;
return -1;
diff --git a/src/post_battle_event_funcs.c b/src/post_battle_event_funcs.c
index 934972b7c..fe5e1089e 100644
--- a/src/post_battle_event_funcs.c
+++ b/src/post_battle_event_funcs.c
@@ -50,8 +50,8 @@ int GameClear(void)
ribbonCounts[i].partyIndex = i;
ribbonCounts[i].count = 0;
- if (GetMonData(mon, MON_DATA_SANITY_BIT2)
- && !GetMonData(mon, MON_DATA_SANITY_BIT3)
+ if (GetMonData(mon, MON_DATA_SANITY_HAS_SPECIES)
+ && !GetMonData(mon, MON_DATA_SANITY_IS_EGG)
&& !GetMonData(mon, MON_DATA_CHAMPION_RIBBON))
{
u8 val[1] = {TRUE};
diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c
index b22e1db32..94d81e30f 100644
--- a/src/rayquaza_scene.c
+++ b/src/rayquaza_scene.c
@@ -1528,14 +1528,14 @@ static void sub_81D706C(void)
LZDecompressWram(gRaySceneClouds1_Tilemap, sRayScene->tilemapBuffers[1]);
LZDecompressWram(gRaySceneClouds3_Tilemap, sRayScene->tilemapBuffers[2]);
LoadCompressedPalette(gRaySceneClouds_Pal, 0, 0x40);
- LoadCompressedObjectPic(&sUnknown_0862A8C4);
- LoadCompressedObjectPic(&sUnknown_0862A8F8);
- LoadCompressedObjectPic(&sUnknown_0862A924);
- LoadCompressedObjectPic(&sUnknown_0862A9D4);
- LoadCompressedObjectPic(&sUnknown_0862AA14);
- LoadCompressedObjectPic(&sUnknown_0862AA34);
- LoadCompressedObjectPalette(&sUnknown_0862A8CC);
- LoadCompressedObjectPalette(&sUnknown_0862A9DC);
+ LoadCompressedSpriteSheet(&sUnknown_0862A8C4);
+ LoadCompressedSpriteSheet(&sUnknown_0862A8F8);
+ LoadCompressedSpriteSheet(&sUnknown_0862A924);
+ LoadCompressedSpriteSheet(&sUnknown_0862A9D4);
+ LoadCompressedSpriteSheet(&sUnknown_0862AA14);
+ LoadCompressedSpriteSheet(&sUnknown_0862AA34);
+ LoadCompressedSpritePalette(&sUnknown_0862A8CC);
+ LoadCompressedSpritePalette(&sUnknown_0862A9DC);
}
static void Task_DuoFightAnim(u8 taskId)
@@ -1943,8 +1943,8 @@ static void sub_81D7E9C(void)
LZDecompressWram(gRaySceneOvercast_Tilemap, sRayScene->tilemapBuffers[1]);
LZDecompressWram(gRaySceneRayquaza_Tilemap, sRayScene->tilemapBuffers[2]);
LoadCompressedPalette(gRaySceneRayquaza_Pal, 0, 0x40);
- LoadCompressedObjectPic(&sUnknown_0862AA90);
- LoadCompressedObjectPalette(&sUnknown_0862AA98);
+ LoadCompressedSpriteSheet(&sUnknown_0862AA90);
+ LoadCompressedSpritePalette(&sUnknown_0862AA98);
}
static void Task_RayTakesFlightAnim(u8 taskId)
@@ -2118,9 +2118,9 @@ static void sub_81D8358(void)
LoadCompressedPalette(gRaySceneOvercast2_Pal, 0, 0x40);
gPlttBufferUnfaded[0] = RGB_WHITE;
gPlttBufferFaded[0] = RGB_WHITE;
- LoadCompressedObjectPic(&sUnknown_0862AAFC);
- LoadCompressedObjectPic(&sUnknown_0862AB04);
- LoadCompressedObjectPalette(&sUnknown_0862AB0C);
+ LoadCompressedSpriteSheet(&sUnknown_0862AAFC);
+ LoadCompressedSpriteSheet(&sUnknown_0862AB04);
+ LoadCompressedSpritePalette(&sUnknown_0862AB0C);
}
static void sub_81D844C(void)
@@ -2489,16 +2489,16 @@ static void sub_81D8CC4(void)
LZDecompressWram(gRaySceneHushBg_Tilemap, sRayScene->tilemapBuffers[0]);
LZDecompressWram(gRaySceneHushRing_Map, sRayScene->tilemapBuffers[2]);
LoadCompressedPalette(gRaySceneHushBg_Pal, 0, 0x60);
- LoadCompressedObjectPic(&sUnknown_0862AC28);
- LoadCompressedObjectPic(&sUnknown_0862AC30);
- LoadCompressedObjectPic(&sUnknown_0862AC38);
- LoadCompressedObjectPic(&sUnknown_0862AC40);
- LoadCompressedObjectPic(&sUnknown_0862AC48);
- LoadCompressedObjectPic(&sUnknown_0862AC50);
- LoadCompressedObjectPalette(&sUnknown_0862AC58);
- LoadCompressedObjectPalette(&sUnknown_0862AC60);
- LoadCompressedObjectPalette(&sUnknown_0862AC68);
- LoadCompressedObjectPalette(&sUnknown_0862AC70);
+ LoadCompressedSpriteSheet(&sUnknown_0862AC28);
+ LoadCompressedSpriteSheet(&sUnknown_0862AC30);
+ LoadCompressedSpriteSheet(&sUnknown_0862AC38);
+ LoadCompressedSpriteSheet(&sUnknown_0862AC40);
+ LoadCompressedSpriteSheet(&sUnknown_0862AC48);
+ LoadCompressedSpriteSheet(&sUnknown_0862AC50);
+ LoadCompressedSpritePalette(&sUnknown_0862AC58);
+ LoadCompressedSpritePalette(&sUnknown_0862AC60);
+ LoadCompressedSpritePalette(&sUnknown_0862AC68);
+ LoadCompressedSpritePalette(&sUnknown_0862AC70);
}
static void Task_RayChasesAwayAnim(u8 taskId)
diff --git a/src/rom_8034C54.c b/src/rom_8034C54.c
index e175ecc64..ba431778f 100644
--- a/src/rom_8034C54.c
+++ b/src/rom_8034C54.c
@@ -133,7 +133,7 @@ bool32 sub_8034D14(u32 id, s32 arg1, const struct UnkStruct3 *arg2)
compSpriteSheet = *(struct CompressedSpriteSheet*)(arg2->spriteSheet);
compSpriteSheet.size = GetDecompressedDataSize(arg2->spriteSheet->data);
- gUnknown_02022E10->array[id].tileStart = LoadCompressedObjectPic(&compSpriteSheet);
+ gUnknown_02022E10->array[id].tileStart = LoadCompressedSpriteSheet(&compSpriteSheet);
}
if (gUnknown_02022E10->array[id].tileStart == 0xFFFF)
diff --git a/src/save.c b/src/save.c
index 4ae516fc9..905f075fb 100644
--- a/src/save.c
+++ b/src/save.c
@@ -5,6 +5,7 @@
#include "decompress.h"
#include "load_save.h"
#include "overworld.h"
+#include "pokemon_storage_system.h"
#include "main.h"
#include "constants/game_stat.h"
diff --git a/src/scrcmd.c b/src/scrcmd.c
index e699bfeab..9d9c62a82 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -1485,7 +1485,7 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx)
StringExpandPlaceholders(gStringVar4, ptr + 6);
- width = GetStringWidth(6, gStringVar4, -1) / 8;
+ width = GetStringWidth(6, gStringVar4, -1) / 8u;
if (width > 0x1C)
width = 0x1C;
diff --git a/src/script_menu.c b/src/script_menu.c
index 2aa546288..6f16b1a8a 100644
--- a/src/script_menu.c
+++ b/src/script_menu.c
@@ -1640,27 +1640,27 @@ static void sub_80E2A94(u8 multichoiceId)
{
case 77:
FillWindowPixelBuffer(0, 0x11);
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBAC[GetMenuCursorPos()], 0, NULL, 2, 1, 3);
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBAC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
break;
case 76:
FillWindowPixelBuffer(0, 0x11);
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BB9C[GetMenuCursorPos()], 0, NULL, 2, 1, 3);
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BB9C[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
break;
case 78:
FillWindowPixelBuffer(0, 0x11);
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBBC[GetMenuCursorPos()], 0, NULL, 2, 1, 3);
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBBC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
break;
case 79:
FillWindowPixelBuffer(0, 0x11);
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBCC[GetMenuCursorPos()], 0, NULL, 2, 1, 3);
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBCC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
break;
case 75:
FillWindowPixelBuffer(0, 0x11);
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBEC[GetMenuCursorPos()], 0, NULL, 2, 1, 3);
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBEC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
break;
case 74:
FillWindowPixelBuffer(0, 0x11);
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBE0[GetMenuCursorPos()], 0, NULL, 2, 1, 3);
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBE0[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
break;
}
}
diff --git a/src/script_pokemon_util_80F87D8.c b/src/script_pokemon_util_80F87D8.c
index fc5a06024..9e4cb7719 100755
--- a/src/script_pokemon_util_80F87D8.c
+++ b/src/script_pokemon_util_80F87D8.c
@@ -335,7 +335,7 @@ void ShowContestEntryMonPic(void)
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[1], species, personality);
palette = GetMonSpritePalStructFromOtIdPersonality(species, otId, personality);
- LoadCompressedObjectPalette(palette);
+ LoadCompressedSpritePalette(palette);
SetMultiuseSpriteTemplateToPokemon(species, 1);
gMultiuseSpriteTemplate.paletteTag = palette->tag;
spriteId = CreateSprite(&gMultiuseSpriteTemplate, (left + 1) * 8 + 32, (top * 8) + 40, 0);
diff --git a/src/smokescreen.c b/src/smokescreen.c
index 9b37cd234..d9780bbb6 100644
--- a/src/smokescreen.c
+++ b/src/smokescreen.c
@@ -14,8 +14,8 @@ u8 sub_807521C(s16 x, s16 y, u8 a3)
if (GetSpriteTileStartByTag(gUnknown_0831C620.tag) == 0xFFFF)
{
- LoadCompressedObjectPicUsingHeap(&gUnknown_0831C620);
- LoadCompressedObjectPaletteUsingHeap(&gUnknown_0831C628);
+ LoadCompressedSpriteSheetUsingHeap(&gUnknown_0831C620);
+ LoadCompressedSpritePaletteUsingHeap(&gUnknown_0831C628);
}
mainSpriteId = CreateInvisibleSpriteWithCallback(sub_8075370);
diff --git a/src/start_menu.c b/src/start_menu.c
index 0e52f05fb..ad7b4b6cc 100644
--- a/src/start_menu.c
+++ b/src/start_menu.c
@@ -574,13 +574,13 @@ static bool8 HandleStartMenuInput(void)
if (gMain.newKeys & DPAD_UP)
{
PlaySE(SE_SELECT);
- sStartMenuCursorPos = MoveMenuCursor(-1);
+ sStartMenuCursorPos = Menu_MoveCursor(-1);
}
if (gMain.newKeys & DPAD_DOWN)
{
PlaySE(SE_SELECT);
- sStartMenuCursorPos = MoveMenuCursor(1);
+ sStartMenuCursorPos = Menu_MoveCursor(1);
}
if (gMain.newKeys & A_BUTTON)
diff --git a/src/starter_choose.c b/src/starter_choose.c
index 46aac5590..afa3fabbf 100644
--- a/src/starter_choose.c
+++ b/src/starter_choose.c
@@ -412,8 +412,8 @@ void CB2_ChooseStarter(void)
LoadPalette(GetOverworldTextboxPalettePtr(), 0xE0, 0x20);
LoadPalette(gBirchBagGrassPal, 0, 0x40);
- LoadCompressedObjectPic(&gUnknown_085B1ED8[0]);
- LoadCompressedObjectPic(&gUnknown_085B1EE8[0]);
+ LoadCompressedSpriteSheet(&gUnknown_085B1ED8[0]);
+ LoadCompressedSpriteSheet(&gUnknown_085B1EE8[0]);
LoadSpritePalettes(gUnknown_085B1EF8);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0);
diff --git a/src/text.c b/src/text.c
index 07c15596e..39e412633 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1858,7 +1858,7 @@ u32 (*GetFontWidthFunc(u8 glyphId))(u16, bool32)
return NULL;
}
-u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
+s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
{
bool8 isJapanese;
int minGlyphWidth;
@@ -1868,7 +1868,7 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
u32 lineWidth;
const u8 *bufferPointer;
int glyphWidth;
- u32 width;
+ s32 width;
isJapanese = 0;
minGlyphWidth = 0;
@@ -2028,7 +2028,8 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
if (lineWidth > width)
return lineWidth;
- return width;
+ else
+ return width;
}
u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str)
diff --git a/src/title_screen.c b/src/title_screen.c
index d60e3fc0b..c6e9aa26f 100644
--- a/src/title_screen.c
+++ b/src/title_screen.c
@@ -518,9 +518,9 @@ void CB2_InitTitleScreen(void)
ResetSpriteData();
FreeAllSpritePalettes();
gReservedSpritePaletteCount = 9;
- LoadCompressedObjectPic(&sSpriteSheet_EmeraldVersion[0]);
- LoadCompressedObjectPic(&sSpriteSheet_PressStart[0]);
- LoadCompressedObjectPic(&sPokemonLogoShineSpriteSheet[0]);
+ LoadCompressedSpriteSheet(&sSpriteSheet_EmeraldVersion[0]);
+ LoadCompressedSpriteSheet(&sSpriteSheet_PressStart[0]);
+ LoadCompressedSpriteSheet(&sPokemonLogoShineSpriteSheet[0]);
LoadPalette(gTitleScreenEmeraldVersionPal, 0x100, 0x20);
LoadSpritePalette(&sSpritePalette_PressStart[0]);
gMain.state = 2;
diff --git a/src/trainer_pokemon_sprites.c b/src/trainer_pokemon_sprites.c
index f5354a1e8..5ddae218b 100644
--- a/src/trainer_pokemon_sprites.c
+++ b/src/trainer_pokemon_sprites.c
@@ -115,7 +115,7 @@ static void LoadPicPaletteByTagOrSlot(u16 species, u32 otId, u32 personality, u8
else
{
sCreatingSpriteTemplate.paletteTag = paletteTag;
- LoadCompressedObjectPalette(GetMonSpritePalStructFromOtIdPersonality(species, otId, personality));
+ LoadCompressedSpritePalette(GetMonSpritePalStructFromOtIdPersonality(species, otId, personality));
}
}
else
@@ -128,7 +128,7 @@ static void LoadPicPaletteByTagOrSlot(u16 species, u32 otId, u32 personality, u8
else
{
sCreatingSpriteTemplate.paletteTag = paletteTag;
- LoadCompressedObjectPalette(&gTrainerFrontPicPaletteTable[species]);
+ LoadCompressedSpritePalette(&gTrainerFrontPicPaletteTable[species]);
}
}
}
diff --git a/src/tv.c b/src/tv.c
index 4e7c46a7e..0ae105580 100644
--- a/src/tv.c
+++ b/src/tv.c
@@ -3469,7 +3469,7 @@ void ChangeBoxPokemonNickname(void)
void ChangeBoxPokemonNickname_CB(void)
{
- SetBoxMonNickFromAnyBox(gSpecialVar_MonBoxId, gSpecialVar_MonBoxPos, gStringVar2);
+ SetBoxMonNickAt(gSpecialVar_MonBoxId, gSpecialVar_MonBoxPos, gStringVar2);
CB2_ReturnToFieldContinueScriptPlayMapMusic();
}
diff --git a/src/unk_transition.c b/src/unk_transition.c
index 18cee2544..220570851 100644
--- a/src/unk_transition.c
+++ b/src/unk_transition.c
@@ -185,7 +185,7 @@ static void sub_81DA700(void)
LZ77UnCompVram(gUnknown_0862AD54, dst2);
LZ77UnCompVram(gUnknown_0862AF30, dst1);
LoadPalette(gUnknown_0862B53C, 0xF0, 0x20);
- LoadCompressedObjectPic(&sUnknown_0862B724);
+ LoadCompressedSpriteSheet(&sUnknown_0862B724);
LoadSpritePalette(&sUnknown_0862B72C);
}
diff --git a/src/walda_phrase.c b/src/walda_phrase.c
index ff2ee7399..83004777f 100644
--- a/src/walda_phrase.c
+++ b/src/walda_phrase.c
@@ -7,18 +7,11 @@
#include "text.h"
#include "new_game.h"
#include "overworld.h"
+#include "pokemon_storage_system.h"
+#include "field_screen_effect.h"
extern const u8 gText_Peekaboo[];
-extern u8 *GetWaldaPhrasePtr(void);
-extern bool32 IsWaldaPhraseEmpty(void);
-extern void sub_80AF168(void);
-extern void SetWaldaPhrase(const u8 *src);
-extern void SetWaldaWallpaperPatternId(u8 patternId);
-extern void SetWaldaWallpaperIconId(u8 iconId);
-extern void SetWaldaWallpaperColors(u16 backgroundColor, u16 foregroundColor);
-extern void SetWaldaWallpaperLockedOrUnlocked(bool32 unlocked);
-
// this file's functions
static void CB2_HandleGivenWaldaPhrase(void);
static u32 GetWaldaPhraseInputCase(u8 *inputPtr);
diff --git a/src/wallclock.c b/src/wallclock.c
index 5c8d920e7..58704c8a3 100644
--- a/src/wallclock.c
+++ b/src/wallclock.c
@@ -623,7 +623,7 @@ static void LoadWallClockGraphics(void)
ResetSpriteData();
ResetPaletteFade();
FreeAllSpritePalettes();
- LoadCompressedObjectPic(&gUnknown_085B2208);
+ LoadCompressedSpriteSheet(&gUnknown_085B2208);
LoadSpritePalettes(gUnknown_085B2218);
}
diff --git a/src/wild_encounter.c b/src/wild_encounter.c
index 906cca3a0..00650fc8c 100644
--- a/src/wild_encounter.c
+++ b/src/wild_encounter.c
@@ -251,7 +251,7 @@ static u8 ChooseWildMonLevel(const struct WildPokemon *wildPokemon)
rand = Random() % range;
// check ability for max level mon
- if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3))
+ if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG))
{
u8 ability = GetMonAbility(&gPlayerParty[0]);
if (ability == ABILITY_HUSTLE || ability == ABILITY_VITAL_SPIRIT || ability == ABILITY_PRESSURE)
@@ -332,7 +332,7 @@ static u8 PickWildMonNature(void)
}
}
// check synchronize for a pokemon with the same ability
- if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3)
+ if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG)
&& GetMonAbility(&gPlayerParty[0]) == ABILITY_SYNCHRONIZE
&& Random() % 2 == 0)
{
@@ -360,7 +360,7 @@ static void CreateWildMon(u16 species, u8 level)
}
if (checkCuteCharm
- && !GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3)
+ && !GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG)
&& GetMonAbility(&gPlayerParty[0]) == ABILITY_CUTE_CHARM
&& Random() % 3 != 0)
{
@@ -478,7 +478,7 @@ static bool8 DoWildEncounterRateTest(u32 encounterRate, bool8 ignoreAbility)
encounterRate = encounterRate * 80 / 100;
ApplyFluteEncounterRateMod(&encounterRate);
ApplyCleanseTagEncounterRateMod(&encounterRate);
- if (!ignoreAbility && !GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3))
+ if (!ignoreAbility && !GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG))
{
u32 ability = GetMonAbility(&gPlayerParty[0]);
@@ -868,7 +868,7 @@ static bool8 IsAbilityAllowingEncounter(u8 level)
{
u8 ability;
- if (GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3))
+ if (GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG))
return TRUE;
ability = GetMonAbility(&gPlayerParty[0]);
@@ -905,7 +905,7 @@ static bool8 TryGetRandomWildMonIndexByType(const struct WildPokemon *wildMon, u
static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u8 ability, u8 *monIndex)
{
- if (GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3))
+ if (GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG))
return FALSE;
else if (GetMonAbility(&gPlayerParty[0]) != ability)
return FALSE;
diff --git a/src/window.c b/src/window.c
index 4e1a38eff..aa1df3a12 100644
--- a/src/window.c
+++ b/src/window.c
@@ -276,16 +276,16 @@ void CopyWindowToVram(u8 windowId, u8 mode)
switch (mode)
{
- case 1:
- CopyBgTilemapBufferToVram(windowLocal.window.bg);
- break;
- case 2:
- LoadBgTiles(windowLocal.window.bg, windowLocal.tileData, windowSize, windowLocal.window.baseBlock);
- break;
- case 3:
- LoadBgTiles(windowLocal.window.bg, windowLocal.tileData, windowSize, windowLocal.window.baseBlock);
- CopyBgTilemapBufferToVram(windowLocal.window.bg);
- break;
+ case 1:
+ CopyBgTilemapBufferToVram(windowLocal.window.bg);
+ break;
+ case 2:
+ LoadBgTiles(windowLocal.window.bg, windowLocal.tileData, windowSize, windowLocal.window.baseBlock);
+ break;
+ case 3:
+ LoadBgTiles(windowLocal.window.bg, windowLocal.tileData, windowSize, windowLocal.window.baseBlock);
+ CopyBgTilemapBufferToVram(windowLocal.window.bg);
+ break;
}
}
@@ -308,16 +308,16 @@ void CopyWindowRectToVram(u32 windowId, u32 mode, u32 x, u32 y, u32 w, u32 h)
switch (mode)
{
- case 1:
- CopyBgTilemapBufferToVram(windowLocal.window.bg);
- break;
- case 2:
- LoadBgTiles(windowLocal.window.bg, windowLocal.tileData + (rectPos * 32), rectSize, windowLocal.window.baseBlock + rectPos);
- break;
- case 3:
- LoadBgTiles(windowLocal.window.bg, windowLocal.tileData + (rectPos * 32), rectSize, windowLocal.window.baseBlock + rectPos);
- CopyBgTilemapBufferToVram(windowLocal.window.bg);
- break;
+ case 1:
+ CopyBgTilemapBufferToVram(windowLocal.window.bg);
+ break;
+ case 2:
+ LoadBgTiles(windowLocal.window.bg, windowLocal.tileData + (rectPos * 32), rectSize, windowLocal.window.baseBlock + rectPos);
+ break;
+ case 3:
+ LoadBgTiles(windowLocal.window.bg, windowLocal.tileData + (rectPos * 32), rectSize, windowLocal.window.baseBlock + rectPos);
+ CopyBgTilemapBufferToVram(windowLocal.window.bg);
+ break;
}
}
}
@@ -601,7 +601,7 @@ static void nullsub_9(void)
}
-u16 AddWindow8Bit(struct WindowTemplate *template)
+u16 AddWindow8Bit(const struct WindowTemplate *template)
{
u16 windowId;
u8* memAddress;
@@ -669,12 +669,12 @@ void FillWindowPixelRect8Bit(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width,
FillBitmapRect8Bit(&pixelRect, x, y, width, height, fillValue);
}
-void BlitBitmapRectToWindow4BitTo8Bit(u8 windowId, u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 paletteNum)
+void BlitBitmapRectToWindow4BitTo8Bit(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 paletteNum)
{
struct Bitmap sourceRect;
struct Bitmap destRect;
- sourceRect.pixels = (u8*)pixels;
+ sourceRect.pixels = (u8*) pixels;
sourceRect.width = srcWidth;
sourceRect.height = srcHeight;
@@ -692,16 +692,16 @@ void CopyWindowToVram8Bit(u8 windowId, u8 mode)
switch (mode)
{
- case 1:
- CopyBgTilemapBufferToVram(sWindowPtr->window.bg);
- break;
- case 2:
- LoadBgTiles(sWindowPtr->window.bg, sWindowPtr->tileData, sWindowSize, sWindowPtr->window.baseBlock);
- break;
- case 3:
- LoadBgTiles(sWindowPtr->window.bg, sWindowPtr->tileData, sWindowSize, sWindowPtr->window.baseBlock);
- CopyBgTilemapBufferToVram(sWindowPtr->window.bg);
- break;
+ case 1:
+ CopyBgTilemapBufferToVram(sWindowPtr->window.bg);
+ break;
+ case 2:
+ LoadBgTiles(sWindowPtr->window.bg, sWindowPtr->tileData, sWindowSize, sWindowPtr->window.baseBlock);
+ break;
+ case 3:
+ LoadBgTiles(sWindowPtr->window.bg, sWindowPtr->tileData, sWindowSize, sWindowPtr->window.baseBlock);
+ CopyBgTilemapBufferToVram(sWindowPtr->window.bg);
+ break;
}
}