summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/engine/naming_screen.c2
-rw-r--r--src/field/choose_party.c3
-rw-r--r--src/field/field_effect.c1
-rw-r--r--src/field/pc_screen_effect.c17
-rw-r--r--src/field/use_pokeblock.c1
-rw-r--r--src/pokemon/mon_markings.c20
-rw-r--r--src/pokemon/pokemon_storage_system.c738
-rw-r--r--src/pokemon/pokemon_storage_system_2.c2063
-rw-r--r--src/pokemon/pokemon_storage_system_3.c655
-rw-r--r--src/pokemon/pokemon_storage_system_4.c23
-rw-r--r--src/pokemon/pokemon_storage_system_5.c16
-rw-r--r--src/pokemon/pokemon_summary_screen.c29
-rw-r--r--src/pokenav_before.c1
-rw-r--r--src/scene/hall_of_fame.c44
14 files changed, 3471 insertions, 142 deletions
diff --git a/src/engine/naming_screen.c b/src/engine/naming_screen.c
index eddfdeda5..6aa706893 100644
--- a/src/engine/naming_screen.c
+++ b/src/engine/naming_screen.c
@@ -26,8 +26,6 @@
#define COLUMN_COUNT 10
#endif
-extern u16 gKeyRepeatStartDelay;
-
extern u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, u32 personality);
const u8 gSpriteImage_83CE094[] = INCBIN_U8("graphics/naming_screen/pc_icon/0.4bpp");
diff --git a/src/field/choose_party.c b/src/field/choose_party.c
index 3ba04e489..1d6b6541a 100644
--- a/src/field/choose_party.c
+++ b/src/field/choose_party.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "decoration.h"
+#include "event_data.h"
#include "field_fadetransition.h"
#include "main.h"
#include "menu.h"
@@ -7,6 +7,7 @@
#include "palette.h"
#include "party_menu.h"
#include "pokemon_menu.h"
+#include "field_weather.h"
#include "pokemon.h"
#include "pokemon_summary_screen.h"
#include "overworld.h"
diff --git a/src/field/field_effect.c b/src/field/field_effect.c
index 5ff89574b..435978034 100644
--- a/src/field/field_effect.c
+++ b/src/field/field_effect.c
@@ -25,6 +25,7 @@
#include "field_map_obj.h"
#include "util.h"
#include "field_effect_helpers.h"
+#include "pokemon_storage_system.h"
#define subsprite_table(ptr) {.subsprites = ptr, .subspriteCount = (sizeof ptr) / (sizeof(struct Subsprite))}
diff --git a/src/field/pc_screen_effect.c b/src/field/pc_screen_effect.c
index 364fca0aa..dda569ea4 100644
--- a/src/field/pc_screen_effect.c
+++ b/src/field/pc_screen_effect.c
@@ -2,18 +2,7 @@
#include "main.h"
#include "palette.h"
#include "sprite.h"
-
-struct UnkStruct
-{
- /*0x00*/ u16 tileTag;
- /*0x02*/ u16 paletteTag;
- /*0x04*/ u16 unk04;
- /*0x06*/ u16 unk06;
- /*0x08*/ u16 unk08;
- /*0x0A*/ u16 unk0A;
- /*0x0C*/ s16 unk0C;
- /*0x10*/ u32 selectedPalettes;
-};
+#include "pc_screen_effect.h"
void sub_80C603C(void);
void sub_80C6078(void);
@@ -30,7 +19,7 @@ extern const u16 gUnknownPal_083D18EC[16];
extern const u8 gUnknownGfx_083D190C[128];
-extern struct UnkStruct *gUnknown_020387EC;
+extern struct PCScreenEffectStruct *gUnknown_020387EC;
const struct SpriteSheet gUnknown_083D1898 = { gUnknownGfx_083D190C, sizeof(gUnknownGfx_083D190C), 0 };
@@ -58,7 +47,7 @@ const struct SpriteTemplate gSpriteTemplate_83D18C0 =
sub_80C6130,
};
-void sub_80C5CD4(struct UnkStruct *unkStruct)
+void sub_80C5CD4(struct PCScreenEffectStruct *unkStruct)
{
u16 i;
diff --git a/src/field/use_pokeblock.c b/src/field/use_pokeblock.c
index 42020c49a..8ea93aab8 100644
--- a/src/field/use_pokeblock.c
+++ b/src/field/use_pokeblock.c
@@ -104,7 +104,6 @@ static EWRAM_DATA struct Pokeblock *gUnknown_0203930C = NULL;
EWRAM_DATA u8 gPokeblockMonID = 0;
EWRAM_DATA s16 gPokeblockGain = 0;
-extern u16 gKeyRepeatStartDelay;
extern u16 gSpecialVar_ItemId; // FIXME: remove after merge of #349 Pokeblock
static void launch_c3_walk_stairs_and_run_once(void (*const)(void));
diff --git a/src/pokemon/mon_markings.c b/src/pokemon/mon_markings.c
index 3734856b8..149dda45f 100644
--- a/src/pokemon/mon_markings.c
+++ b/src/pokemon/mon_markings.c
@@ -5,6 +5,7 @@
#include "constants/songs.h"
#include "sound.h"
#include "sprite.h"
+#include "mon_markings.h"
#ifdef GERMAN
#define MENU_TEXT_SPRITE_X_OFFSET 24
@@ -12,25 +13,6 @@
#define MENU_TEXT_SPRITE_X_OFFSET 32
#endif
-struct PokemonMarkMenu
-{
- /*0x0000*/ u16 baseTileTag;
- /*0x0002*/ u16 basePaletteTag;
- /*0x0004*/ u8 markings; // bit flags
- /*0x0005*/ s8 cursorPos;
- /*0x0006*/ bool8 markingsArray[4];
- /*0x000A*/ u8 cursorBaseY;
- /*0x000B*/ bool8 spriteSheetLoadRequired;
- /*0x000C*/ struct Sprite *menuWindowSprites[2]; // upper and lower halves of menu window
- /*0x0014*/ struct Sprite *menuMarkingSprites[4];
- /*0x0024*/ struct Sprite *menuTextSprite;
- /*0x0028*/ const u8 *frameTiles;
- /*0x002C*/ const u16 *framePalette;
- /*0x0030*/ u8 menuWindowSpriteTiles[0x1000];
- /*0x1030*/ u8 filler1030[0x80];
- /*0x10B0*/ u8 tileLoadState;
-};
-
extern u8 gPokenavConditionMenuMisc_Gfx[];
extern u16 gUnknown_08E966B8[];
diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c
index 001cebe45..80081c963 100644
--- a/src/pokemon/pokemon_storage_system.c
+++ b/src/pokemon/pokemon_storage_system.c
@@ -1,93 +1,711 @@
#include "global.h"
-#include "pokemon_storage_system.h"
+#include "palette.h"
+#include "constants/songs.h"
+#include "sound.h"
+#include "field_weather.h"
+#include "overworld.h"
+#include "field_fadetransition.h"
#include "menu.h"
+#include "main.h"
+#include "strings.h"
#include "string_util.h"
-#include "ewram.h"
+#include "event_data.h"
+#include "script.h"
+#include "pokemon_storage_system.h"
+
+void StorageSystemCreatePrimaryMenu(u8 whichMenu);
+void sub_80963D0(u8 curBox);
+void sub_809658C(void);
+void sub_80965F8(void);
+void sub_809662C(void);
+void sub_809665C(void);
+void sub_80966F4(const u8 *sourceString, u16 x, u16 y);
+void sub_8096784(struct Sprite *sprite);
+
+EWRAM_DATA struct PokemonStorage gPokemonStorage = {0};
+EWRAM_DATA u8 gUnknown_02038470[3] = {};
+EWRAM_DATA u8 gUnknown_02038473 = 0;
+EWRAM_DATA u8 gUnknown_02038474 = 0;
+EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_02038478 = NULL;
-struct StorageAction {
- u8 *text;
- u8 format;
+const struct PSS_MenuStringPtrs gUnknown_083B600C[] = {
+ {PCText_WithdrawPoke, PCText_MovePokeToParty},
+ {PCText_DepositPoke, PCText_StorePokeInBox},
+ {PCText_MovePoke, PCText_OrganizeBoxesParty},
+ {PCText_SeeYa, PCText_ReturnToPrevMenu}
};
-extern const struct StorageAction gUnknown_083B6DF4[];
+const union AnimCmd gSpriteAnim_83B602C[] = {
+ ANIMCMD_FRAME( 0, 5),
+ ANIMCMD_END
+};
-EWRAM_DATA struct PokemonStorage gPokemonStorage = {0};
+const union AnimCmd gSpriteAnim_83B6034[] = {
+ ANIMCMD_FRAME( 4, 5),
+ ANIMCMD_END
+};
+
+const union AnimCmd gSpriteAnim_83B603C[] = {
+ ANIMCMD_FRAME( 6, 5),
+ ANIMCMD_END
+};
+
+const union AnimCmd gSpriteAnim_83B6044[] = {
+ ANIMCMD_FRAME(10, 5),
+ ANIMCMD_END
+};
+
+const union AnimCmd *const gSpriteAnimTable_83B604C[] = {
+ gSpriteAnim_83B602C,
+ gSpriteAnim_83B6034,
+ gSpriteAnim_83B603C,
+ gSpriteAnim_83B6044
+};
+
+const union AffineAnimCmd gSpriteAffineAnim_83B605C[] = {
+ AFFINEANIMCMD_FRAME(0xe0, 0xe0, 0, 0),
+ AFFINEANIMCMD_END
+};
+
+const union AffineAnimCmd *const gSpriteAffineAnimTable_83B606C[] = {
+ gSpriteAffineAnim_83B605C
+};
+
+const u16 gBoxSelectionPopupPalette[] = INCBIN_U16("graphics/pokemon_storage/box_selection_popup.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");
+
+u8 CountPokemonInBoxN(u8 boxId)
+{
+ u16 i;
+ u16 count;
+
+ for (i = 0, count = 0; i < 30; i++)
+ {
+ if (GetBoxMonData(gPokemonStorage.boxes[boxId] + i, MON_DATA_SPECIES) != 0)
+ count++;
+ }
+ return count;
+}
+
+s16 GetIndexOfFirstEmptySpaceInBoxN(u8 boxId)
+{
+ u16 i;
+
+ for (i = 0; i < 30; i++)
+ {
+ if (GetBoxMonData(gPokemonStorage.boxes[boxId] + i, MON_DATA_SPECIES) == 0)
+ return i;
+ }
+ return -1;
+}
-void sub_8098898(u8 index) {
- u8 *ptr;
+u8 GetNumValidDaycarePartyMons(void)
+{
+ u16 i;
+ u16 count;
- Menu_DrawStdWindowFrame(10, 16, 29, 19);
+ for (i = 0, count = 0; i < PARTY_SIZE; i++)
+ {
+ struct Pokemon *pokemon = gPlayerParty + i;
+ if (GetMonData(pokemon, MON_DATA_SPECIES) != 0 && !GetMonData(pokemon, MON_DATA_IS_EGG))
+ count++;
+ }
+ return count;
+}
+
+u8 CountAlivePartyMonsExceptOne(u8 toSkip)
+{
+ u16 i;
+ u16 count;
- switch (gUnknown_083B6DF4[index].format)
+ for (i = 0, count = 0; i < PARTY_SIZE; i++)
{
+ if (i != toSkip)
+ {
+ struct Pokemon *pokemon = gPlayerParty + i;
+ if (GetMonData(pokemon, MON_DATA_SPECIES) != 0 && !GetMonData(pokemon, MON_DATA_IS_EGG) && GetMonData(pokemon, MON_DATA_HP) != 0)
+ count++;
+ }
+ }
+ return count;
+}
+
+u8 CountAlivePartyMonsExceptSelectedOne(void)
+{
+ return CountAlivePartyMonsExceptOne(gSpecialVar_0x8004);
+}
- case 2:
- ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text);
- ptr = StringCopy(ptr, gUnk20011fa);
- break;
+u8 StorageSystemGetPartySize(void)
+{
+ u16 i;
+ u16 count;
- case 5:
- ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text);
- ptr = StringCopy(ptr, gUnk20026e4);
- break;
+ for (i = 0, count = 0; i < PARTY_SIZE; i++)
+ {
+ if (GetMonData(gPlayerParty + i, MON_DATA_SPECIES) != 0)
+ count++;
+ }
+ return count;
+}
+
+u8 *unref_sub_8095C60(u8 *dest, const u8 *src, u16 pad)
+{
+ u8 *_dest = StringCopy(dest, src);
+ while (_dest < dest + pad)
+ {
+ *_dest++ = CHAR_SPACE;
+ }
+ *_dest = EOS;
+ return _dest;
+}
- case 1:
- // {var} + " is selected."
- ptr = StringCopy(gUnk2002694, gUnk20011fa);
- ptr = StringCopy(ptr, gUnknown_083B6DF4[index].text);
- break;
+void sub_8095C8C(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, u16 src_left, u16 src_top, u16 dest_width, u16 dest_height, u16 src_width)
+{
+ u16 i;
- case 4:
- // {var} + " was released."
- ptr = StringCopy(gUnk2002694, gUnk20026e4);
-#if ENGLISH
- ptr = StringCopy(ptr, gUnknown_083B6DF4[index].text);
-#elif GERMAN
- ptr = de_sub_8073174(gUnk2002694, gUnknown_083B6DF4[index].text);
+ dest_width *= 2;
+ dest += dest_top * 0x20 + dest_left;
+ src += src_top * src_width + src_left;
+ for (i = 0; i < dest_height; i++)
+ {
+ CpuCopy16(src, dest, dest_width);
+ dest += 0x20;
+ src += src_width;
+ }
+}
+
+#ifdef NONMATCHING
+void unref_sub_8095D08(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height)
+{
+ u16 i;
+
+ dest += dest_top * 0x20 + dest_left;
+ width *= 2;
+ for (i = 0; i < height; dest += 0x20, i++)
+ {
+ void *_dest = dest;
+ size_t _size = width;
+ if (_size <= 0x1000)
+ {
+ DmaFill16(3, 0, _dest, _size);
+ }
+ else
+ {
+ while (1)
+ {
+ DmaFill16(3, 0, _dest, 0x1000);
+ _dest += 0x1000;
+ _size -= 0x1000;
+ if (_size <= 0x1000)
+ {
+ DmaFill16(3, 0, _dest, _size);
+ break;
+ }
+ }
+ }
+ }
+}
+#else
+__attribute__((naked)) void unref_sub_8095D08(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height)
+{
+ asm_unified("\tpush {r4-r7,lr}\n"
+ "\tmov r7, r10\n"
+ "\tmov r6, r9\n"
+ "\tmov r5, r8\n"
+ "\tpush {r5-r7}\n"
+ "\tsub sp, 0x8\n"
+ "\tadds r4, r0, 0\n"
+ "\tldr r0, [sp, 0x28]\n"
+ "\tlsls r1, 16\n"
+ "\tlsrs r1, 16\n"
+ "\tlsls r2, 16\n"
+ "\tlsls r0, 16\n"
+ "\tlsrs r0, 16\n"
+ "\tmov r10, r0\n"
+ "\tlsrs r2, 11\n"
+ "\tadds r2, r1\n"
+ "\tlsls r2, 1\n"
+ "\tadds r4, r2\n"
+ "\tlsls r3, 17\n"
+ "\tlsrs r0, r3, 16\n"
+ "\tstr r0, [sp, 0x4]\n"
+ "\tmovs r0, 0\n"
+ "\tcmp r0, r10\n"
+ "\tbcs _08095DB2\n"
+ "\tmovs r6, 0x80\n"
+ "\tlsls r6, 5\n"
+ "\tmov r5, sp\n"
+ "\tldr r7, _08095D74 @ =0x040000d4\n"
+ "\tlsrs r3, 17\n"
+ "\tmov r9, r3\n"
+ "\tmov r1, r9\n"
+ "\tmovs r2, 0x81\n"
+ "\tlsls r2, 24\n"
+ "\torrs r1, r2\n"
+ "\tmov r9, r1\n"
+ "_08095D4E:\n"
+ "\tadds r3, r4, 0\n"
+ "\tldr r2, [sp, 0x4]\n"
+ "\tmovs r1, 0x40\n"
+ "\tadds r1, r4\n"
+ "\tmov r8, r1\n"
+ "\tadds r0, 0x1\n"
+ "\tmov r12, r0\n"
+ "\tcmp r2, r6\n"
+ "\tbhi _08095D78\n"
+ "\tmovs r0, 0\n"
+ "\tstrh r0, [r5]\n"
+ "\tmov r2, sp\n"
+ "\tstr r2, [r7]\n"
+ "\tstr r4, [r7, 0x4]\n"
+ "\tmov r0, r9\n"
+ "\tstr r0, [r7, 0x8]\n"
+ "\tldr r0, [r7, 0x8]\n"
+ "\tb _08095DA6\n"
+ "\t.align 2, 0\n"
+ "_08095D74: .4byte 0x040000d4\n"
+ "_08095D78:\n"
+ "\tmovs r4, 0\n"
+ "\tstrh r4, [r5]\n"
+ "\tldr r1, _08095DC4 @ =0x040000d4\n"
+ "\tmov r0, sp\n"
+ "\tstr r0, [r1]\n"
+ "\tstr r3, [r1, 0x4]\n"
+ "\tldr r0, _08095DC8 @ =0x81000800\n"
+ "\tstr r0, [r1, 0x8]\n"
+ "\tldr r0, [r1, 0x8]\n"
+ "\tadds r3, r6\n"
+ "\tsubs r2, r6\n"
+ "\tcmp r2, r6\n"
+ "\tbhi _08095D78\n"
+ "\tstrh r4, [r5]\n"
+ "\tmov r0, sp\n"
+ "\tstr r0, [r1]\n"
+ "\tstr r3, [r1, 0x4]\n"
+ "\tlsrs r0, r2, 1\n"
+ "\tmovs r2, 0x81\n"
+ "\tlsls r2, 24\n"
+ "\torrs r0, r2\n"
+ "\tstr r0, [r1, 0x8]\n"
+ "\tldr r0, [r1, 0x8]\n"
+ "_08095DA6:\n"
+ "\tmov r4, r8\n"
+ "\tmov r1, r12\n"
+ "\tlsls r0, r1, 16\n"
+ "\tlsrs r0, 16\n"
+ "\tcmp r0, r10\n"
+ "\tbcc _08095D4E\n"
+ "_08095DB2:\n"
+ "\tadd sp, 0x8\n"
+ "\tpop {r3-r5}\n"
+ "\tmov r8, r3\n"
+ "\tmov r9, r4\n"
+ "\tmov r10, r5\n"
+ "\tpop {r4-r7}\n"
+ "\tpop {r0}\n"
+ "\tbx r0\n"
+ "\t.align 2, 0\n"
+ "_08095DC4: .4byte 0x040000d4\n"
+ "_08095DC8: .4byte 0x81000800");
+}
#endif
- break;
- case 3:
+s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx, u8 mode)
+{
+ s16 i;
+ s16 direction;
+ if (mode == 0 || mode == 2)
{
- u8 *stringLength;
- u8 *text;
+ direction = 1;
+ }
+ else
+ {
+ direction = -1;
+ }
+ if (mode == 2 || mode == 3)
+ {
+ for (i = startIdx + direction; i >= 0 && i <= stopIdx; i += direction)
+ {
+ if (GetBoxMonData(box + i, MON_DATA_SPECIES) != 0)
+ return i;
+ }
+ }
+ else
+ {
+ for (i = startIdx + direction; i >= 0 && i <= stopIdx; i += direction)
+ {
+ if (GetBoxMonData(box + i, MON_DATA_SPECIES) != 0 && !GetBoxMonData(box + i, MON_DATA_IS_EGG))
+ return i;
+ }
+ }
+ return -1;
+}
+
+void StorageSystemClearMessageWindow(void)
+{
+ Menu_BlankWindowRect(2, 15, 27, 18);
+}
- text = gUnknown_083B6DF4[index].text;
- stringLength = &text[StringLength(text)] + 1;
+void Task_PokemonStorageSystem(u8 taskId)
+{
+ struct Task *task = gTasks + taskId;
+ switch (task->data[0])
+ {
+ case 0:
+ StorageSystemCreatePrimaryMenu(task->data[1]);
+ Menu_DisplayDialogueFrame();
+ Menu_PrintText(gUnknown_083B600C[task->data[1]].desc, 2, 15);
+ task->data[0]++;
+ break;
+ case 1:
+ if (sub_807D770())
+ {
+ task->data[0]++;
+ }
+ break;
+ case 2:
+ task->data[2] = Menu_ProcessInput();
+ switch(task->data[2])
+ {
+ case -2:
+ task->data[3] = task->data[1];
+ if (gMain.newKeys & DPAD_UP && --task->data[3] < 0)
+ task->data[3] = 3;
- ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text);
- ptr = StringCopy(ptr, gUnk20011fa);
- ptr = StringCopy(ptr, stringLength);
+ if (gMain.newKeys & DPAD_DOWN && ++task->data[3] > 3)
+ task->data[3] = 0;
+ if (task->data[1] != task->data[3])
+ {
+ task->data[1] = task->data[3];
+ StorageSystemClearMessageWindow();
+ Menu_PrintText(gUnknown_083B600C[task->data[1]].desc, 2, 15);
+ }
+ break;
+ case -1:
+ case 3:
+ Menu_DestroyCursor();
+ Menu_EraseWindowRect(0, 0, 13, 9);
+ ScriptContext2_Disable();
+ EnableBothScriptContexts();
+ DestroyTask(taskId);
+ break;
+ default:
+ if (task->data[2] == 0 && StorageSystemGetPartySize() == PARTY_SIZE)
+ {
+ StorageSystemClearMessageWindow();
+ Menu_PrintText(gPCText_PartyFull2, 2, 15);
+ task->data[0] = 3;
+ }
+ else if (task->data[2] == 1 && StorageSystemGetPartySize() == 1)
+ {
+ StorageSystemClearMessageWindow();
+ Menu_PrintText(gPCText_OnlyOne, 2, 15);
+ task->data[0] = 3;
+ }
+ else
+ {
+ fade_screen(1, 0);
+ task->data[0] = 4;
+ }
+ break;
+ }
+ break;
+ case 3:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ {
+ StorageSystemClearMessageWindow();
+ Menu_PrintText(gUnknown_083B600C[task->data[1]].desc, 2, 15);
+ task->data[0] = 2;
+ }
+ else if (gMain.newKeys & DPAD_UP)
+ {
+ if (--task->data[1] < 0)
+ task->data[1] = 3;
+ Menu_MoveCursor(-1);
+ task->data[1] = Menu_GetCursorPos();
+ StorageSystemClearMessageWindow();
+ Menu_PrintText(gUnknown_083B600C[task->data[1]].desc, 2, 15);
+ task->data[0] = 2;
+ }
+ else if (gMain.newKeys & DPAD_DOWN)
+ {
+ if (++task->data[1] > 3)
+ task->data[1] = 0;
+ Menu_MoveCursor(1);
+ task->data[1] = Menu_GetCursorPos();
+ StorageSystemClearMessageWindow();
+ Menu_PrintText(gUnknown_083B600C[task->data[1]].desc, 2, 15);
+ task->data[0] = 2;
+ }
+ break;
+ case 4:
+ if (!gPaletteFade.active)
+ {
+ task_intro_29(task->data[2]);
+ DestroyTask(taskId);
+ }
+ break;
}
- break;
+}
+
+void ShowPokemonStorageSystem(void)
+{
+ u8 taskId = CreateTask(Task_PokemonStorageSystem, 80);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = 0;
+ ScriptContext2_Enable();
+}
+
+void FieldCB_ReturnToOverworld(void)
+{
+ u8 taskId = CreateTask(Task_PokemonStorageSystem, 80);
+ gTasks[taskId].data[0] = 0;
+ gTasks[taskId].data[1] = gUnknown_02038474;
+ pal_fill_black();
+}
+
+void StorageSystemCreatePrimaryMenu(u8 whichMenu)
+{
+ Menu_DrawStdWindowFrame(0, 0, 13, 9);
+ Menu_PrintItems(1, 1, 4, (const struct MenuAction *)gUnknown_083B600C);
+ InitMenu(0, 1, 1, 4, whichMenu, 12);
+}
+
+void sub_80961A8(void)
+{
+ gUnknown_02038474 = gPokemonStorageSystemPtr->unk_0005;
+ gFieldCallback = FieldCB_ReturnToOverworld;
+ SetMainCallback2(c2_exit_to_overworld_2_switch);
+}
+
+void ResetPokemonStorageSystem(void)
+{
+ u16 boxId;
+ u16 boxMon;
- case 6:
- // "Bye-bye, ".substr(0, -1) + {var} + "Bye-bye, !".substr(-1, 1)
+ gPokemonStorage.currentBox = 0;
+ for (boxId = 0; boxId < 14; boxId++)
+ {
+ for (boxMon = 0; boxMon < 30; boxMon++)
+ {
+ ZeroBoxMonData(gPokemonStorage.boxes[boxId] + boxMon);
+ }
+ }
+ for (boxId = 0; boxId < 14; boxId++)
{
- u8 *stringLength;
- u8 *text;
+ u8 *dest = StringCopy(gPokemonStorage.boxNames[boxId], gPCText_BOX);
+ ConvertIntToDecimalStringN(dest, boxId + 1, STR_CONV_MODE_LEFT_ALIGN, 2);
+ }
+ for (boxId = 0; boxId < 14; boxId++)
+ {
+ gPokemonStorage.wallpaper[boxId] = boxId & 0x03;
+ }
+}
- text = gUnknown_083B6DF4[index].text;
- stringLength = &text[StringLength(text)] - 1;
+void sub_8096264(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3)
+{
+ struct SpritePalette palette = {
+ gBoxSelectionPopupPalette, palTag
+ };
+ struct SpriteSheet sheets[] = {
+ {gBoxSelectionPopupCenterTiles, 0x800, tileTag},
+ {gBoxSelectionPopupSidesTiles, 0x180, tileTag + 1},
+ {}
+ };
+ LoadSpritePalette(&palette);
+ LoadSpriteSheets(sheets);
+ gUnknown_02038478 = a0;
+ a0->unk_0240 = tileTag;
+ a0->unk_0242 = palTag;
+ a0->unk_023e = a3;
+}
+
+void sub_8096310(void)
+{
+ FreeSpritePaletteByTag(gUnknown_02038478->unk_0242);
+ FreeSpriteTilesByTag(gUnknown_02038478->unk_0240);
+ FreeSpriteTilesByTag(gUnknown_02038478->unk_0240 + 1);
+}
- ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text);
- ptr = StringCopy(ptr - 1, gUnk20026e4);
- ptr = StringCopy(ptr, stringLength);
+void sub_809634C(u8 curBox)
+{
+ sub_80963D0(curBox);
+}
+
+void sub_809635C(void)
+{
+ sub_809658C();
+}
+
+u8 sub_8096368(void)
+{
+ if (gMain.newKeys & B_BUTTON)
+ {
+ PlaySE(SE_SELECT);
+ return 201;
+ }
+ if (gMain.newKeys & A_BUTTON)
+ {
+ PlaySE(SE_SELECT);
+ return gUnknown_02038478->curBox;
+ }
+ if (gMain.newKeys & DPAD_LEFT)
+ {
+ PlaySE(SE_SELECT);
+ sub_809662C();
+ }
+ else if (gMain.newKeys & DPAD_RIGHT)
+ {
+ PlaySE(SE_SELECT);
+ sub_80965F8();
}
- break;
+ return 200;
+}
- case 0:
- default:
- ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text);
- break;
+void sub_80963D0(u8 curBox)
+{
+ u16 i;
+ u8 spriteId;
+ struct SpriteTemplate template;
+ struct OamData oamData = {};
+ oamData.size = 3;
+ oamData.paletteNum = 1;
+ template = (struct SpriteTemplate){
+ 0, 0, &oamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
+ };
+
+ gUnknown_02038478->curBox = curBox;
+ template.tileTag = gUnknown_02038478->unk_0240;
+ template.paletteTag = gUnknown_02038478->unk_0242;
+
+ spriteId = CreateSprite(&template, 0xA0, 0x60, 0);
+ gUnknown_02038478->unk_0000 = gSprites + spriteId;
+
+ oamData.shape = ST_OAM_V_RECTANGLE;
+ oamData.size = 1;
+ template.tileTag = gUnknown_02038478->unk_0240 + 1;
+ template.anims = gSpriteAnimTable_83B604C;
+ for (i = 0; i < 4; i++)
+ {
+ u16 r5;
+ spriteId = CreateSprite(&template, 0x7c, 0x50, gUnknown_02038478->unk_023e);
+ gUnknown_02038478->unk_0004[i] = gSprites + spriteId;
+ r5 = 0;
+ if (i & 2)
+ {
+ gUnknown_02038478->unk_0004[i]->pos1.x = 0xc4;
+ r5 = 2;
+ }
+ if (i & 1)
+ {
+ gUnknown_02038478->unk_0004[i]->pos1.y = 0x70;
+ gUnknown_02038478->unk_0004[i]->oam.size = 0;
+ r5++;
+ }
+ StartSpriteAnim(gUnknown_02038478->unk_0004[i], r5);
}
+ for (i = 0; i < 2; i++)
+ {
+ gUnknown_02038478->unk_0020[i] = sub_809A9A0(72 * i + 0x7c, 0x58, i, 0, gUnknown_02038478->unk_023e);
+ if (gUnknown_02038478->unk_0020[i])
+ {
+ gUnknown_02038478->unk_0020[i]->data[0] = (i == 0 ? -1 : 1);
+ gUnknown_02038478->unk_0020[i]->callback = sub_8096784;
+ }
+ }
+ sub_809665C();
+}
- while (ptr < gUnk20026A6)
+void sub_809658C(void)
+{
+ u16 i;
+ if (gUnknown_02038478->unk_0000)
+ {
+ DestroySprite(gUnknown_02038478->unk_0000);
+ gUnknown_02038478->unk_0000 = NULL;
+ }
+ for (i = 0; i < 4; i++)
+ {
+ if (gUnknown_02038478->unk_0004[i])
+ {
+ DestroySprite(gUnknown_02038478->unk_0004[i]);
+ gUnknown_02038478->unk_0004[i] = NULL;
+ }
+ }
+ for (i = 0; i < 2; i++)
{
- ptr[0] = CHAR_SPACE;
- ptr++;
+ if (gUnknown_02038478->unk_0020[i])
+ DestroySprite(gUnknown_02038478->unk_0020[i]);
}
+}
- ptr[0] = EOS;
- Menu_PrintText(gUnk2002694, 11, 17);
+void sub_80965F8(void)
+{
+ if (++gUnknown_02038478->curBox > 13)
+ gUnknown_02038478->curBox = 0;
+ sub_809665C();
+}
+
+void sub_809662C(void)
+{
+ gUnknown_02038478->curBox = (gUnknown_02038478->curBox == 0 ? 13 : gUnknown_02038478->curBox - 1);
+ sub_809665C();
+}
+
+void sub_809665C(void)
+{
+ u8 nPokemonInBox = CountPokemonInBoxN(gUnknown_02038478->curBox);
+ u8 *stringVar = gStringVar1;
+
+ stringVar[0] = EXT_CTRL_CODE_BEGIN;
+ stringVar[1] = 0x04; // EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW
+ stringVar[2] = 0x0F; // TEXT_COLOR_WHITE2
+ stringVar[3] = 0x01; // TEXT_COLOR_DARK_GREY
+ stringVar[4] = 0x0E; // TEXT_COLOR_LIGHT_BLUE
+ stringVar += 5;
+
+ stringVar = StringCopy(stringVar, gPokemonStorage.boxNames[gUnknown_02038478->curBox]);
+
+ stringVar[0] = CHAR_NEWLINE;
+ stringVar[1] = EXT_CTRL_CODE_BEGIN;
+ stringVar[2] = 0x11; // EXT_CTRL_CODE_CLEAR
+ if (nPokemonInBox < 10)
+ stringVar[3] = 0x28;
+ else
+ stringVar[3] = 0x22;
+ stringVar += 4;
+
+ stringVar = ConvertIntToDecimalString(stringVar, nPokemonInBox);
+
+ stringVar[0] = CHAR_SLASH;
+ stringVar[1] = CHAR_0 + 3;
+ stringVar[2] = CHAR_0 + 0;
+ stringVar[3] = EOS;
+ sub_80966F4(gStringVar1, 0, 1);
+}
+
+void sub_80966F4(const u8 *sourceString, u16 x, u16 y)
+{
+ u16 *vdest = (u16 *)(BG_CHAR_ADDR(4) + (GetSpriteTileStartByTag(gUnknown_02038478->unk_0240) * 32) + y * 256 + x * 32);
+ u8 *tileBuff = gUnknown_083B6DB8;
+ DmaFill16(3, 0x1111, tileBuff, 0x400);
+ Text_InitWindow8004E3C(&gWindowTemplate_81E6D38, tileBuff, sourceString);
+ DmaCopy16(3, tileBuff, vdest, 0x400);
+}
+
+void sub_8096784(struct Sprite *sprite)
+{
+ if (++sprite->data[1] > 3)
+ {
+ sprite->data[1] = 0;
+ sprite->pos2.x += sprite->data[0];
+ if (++sprite->data[2] > 5)
+ {
+ sprite->data[2] = 0;
+ sprite->pos2.x = 0;
+ }
+ }
}
diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c
new file mode 100644
index 000000000..290fa120a
--- /dev/null
+++ b/src/pokemon/pokemon_storage_system_2.c
@@ -0,0 +1,2063 @@
+
+// Includes
+#include "global.h"
+#include "decompress.h"
+#include "constants/songs.h"
+#include "constants/species.h"
+#include "data2.h"
+#include "sound.h"
+#include "ewram.h"
+#include "task.h"
+#include "main.h"
+#include "palette.h"
+#include "menu.h"
+#include "graphics.h"
+#include "strings.h"
+#include "string_util.h"
+#include "pokemon_summary_screen.h"
+#include "mail_data.h"
+#include "naming_screen.h"
+#include "pokemon_storage_system.h"
+
+// Static type declarations
+
+// Static RAM declarations
+
+EWRAM_DATA u8 gUnknown_0203847C = 0;
+EWRAM_DATA u8 gUnknown_0203847D = 0;
+EWRAM_DATA u8 gUnknown_0203847E = 0;
+EWRAM_DATA u8 gUnknown_0203847F = 0;
+
+// Static ROM declarations
+
+void sub_8096884(void);
+void sub_8096AFC(void);
+void sub_8096B38(void);
+void SetPSSCallback(void (*func)(void));
+void sub_8096BF0(void);
+void sub_8096C68(void);
+void sub_8096C84(void);
+void sub_8096FC8(void);
+void sub_8097004(void);
+void sub_8097078(void);
+void sub_80972A8(void);
+void sub_80972FC(void);
+void c3_0808DC50(void);
+void sub_8097390(void);
+void sub_809746C(void);
+void sub_8097594(void);
+void sub_8097788(void);
+void sub_80977E4(void);
+void sub_8097858(void);
+void sub_809789C(void);
+void sub_8097974(void);
+void sub_8097A64(void);
+void sub_8097B44(void);
+void sub_8097BA0(void);
+void sub_8097CC0(void);
+void sub_8097DE0(void);
+void sub_8097E44(void);
+void sub_8097E70(void);
+void sub_8097F58(void);
+void sub_8097FB8(void);
+void sub_809801C(void);
+void BoxSetMosaic(void);
+void sub_8098090(struct Sprite *sprite);
+void sub_80980D4(void);
+void sub_80981F0(u16 species, u32 pid);
+void sub_80982B4(void);
+void sub_8098350(void);
+void sub_8098400(void);
+void add_to_c3_somehow(void);
+void sub_8098780(void);
+void sub_8098690(bool8 flag);
+bool8 sub_80985CC(void);
+void sub_80986E8(void);
+void sub_8098710(void);
+void sub_8098734(void);
+void sub_80987DC(void);
+void sub_809880C(void);
+bool8 sub_8098830(void);
+void PrintStorageActionText(u8 index);
+void sub_8098A38(s8);
+void sub_8098A5C(void);
+void sub_8098A80(void);
+void sub_8098AA8(u8 a0);
+
+// .rodata
+
+const u16 gPokemonStorageScrollingBGPalette[] = INCBIN_U16("graphics/pokemon_storage/scrolling_bg.gbapal");
+
+const u16 gPokemonStorageScrollingBGTile[] = INCBIN_U16("graphics/pokemon_storage/scrolling_bg.4bpp");
+
+const u8 gPokemonStorageScrollingBGTilemap[] = INCBIN_U8("graphics/pokemon_storage/scrolling_bg_map.bin.lz");
+
+const u16 sUnknownTilemap[] = {
+ 0x1281,
+ 0x1282,
+ 0x1283,
+ 0x1284,
+ 0x1285,
+ 0x1286,
+ 0x1287,
+ 0x1288,
+ 0x128C,
+ 0x128D,
+ 0x128E,
+ 0x128F,
+ 0x1290,
+ 0x1291,
+ 0x1292,
+ 0x1293,
+ 0x0281,
+ 0x0282,
+ 0x0283,
+ 0x0284,
+ 0x0285,
+ 0x0286,
+ 0x0287,
+ 0x0288,
+ 0x028C,
+ 0x028D,
+ 0x028E,
+ 0x028F,
+ 0x0290,
+ 0x0291,
+ 0x0292,
+ 0x0293,
+ 0x12AD,
+ 0x12AE,
+ 0x12A8,
+ 0x12A8
+};
+
+const u16 WaveformPalette[] = INCBIN_U16("graphics/pokemon_storage/waveform.gbapal");
+
+const u8 WaveformTiles[] = INCBIN_U8("graphics/pokemon_storage/waveform.4bpp");
+
+const u16 gUnknown_083B6D74[] = INCBIN_U16("graphics/pokemon_storage/83B6D74.gbapal");
+
+const u16 gUnknown_083B6D94[] = INCBIN_U16("graphics/pokemon_storage/83B6D94.gbapal");
+
+struct PokemonStorageSystemData *const gPokemonStorageSystemPtr = &ePokemonStorageSystem;
+
+u8 *const gUnknown_083B6DB8 = gTileBuffer;
+
+const struct SpritePalette gWaveformSpritePalette = {
+ WaveformPalette, 0xdacd
+};
+
+// .text
+
+void task_intro_29(u8 whichMenu)
+{
+ gUnknown_0203847D = whichMenu;
+ gPokemonStorageSystemPtr->unk_0005 = whichMenu;
+ SetMainCallback2(sub_8096884);
+}
+
+void sub_80967DC(void)
+{
+ REG_BG0HOFS = 0;
+ REG_BG0VOFS = 0;
+ REG_BG1HOFS = 0;
+ REG_BG1VOFS = 0;
+ REG_BG2VOFS = 0;
+ REG_BG2HOFS = 0;
+ REG_BG3HOFS = 0;
+ REG_BG3VOFS = 0;
+}
+
+void sub_8096804(void)
+{
+ ResetPaletteFade();
+ ResetSpriteData();
+ FreeSpriteTileRanges();
+ FreeAllSpritePalettes();
+ ResetTasks();
+ gReservedSpriteTileCount = 0x280;
+ sub_809CFDC(&gPokemonStorageSystemPtr->unk_0020, gPokemonStorageSystemPtr->unk_0028, 8);
+ gKeyRepeatStartDelay = 20;
+}
+
+void sub_8096848(void)
+{
+ sub_809B0D4();
+ gUnknown_0203847C = (gPokemonStorageSystemPtr->unk_0005 == 1 ? 1 : 0);
+ gUnknown_0203847E = 0;
+}
+
+void sub_8096874(void)
+{
+ REG_DISPCNT = DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON;
+}
+
+void sub_8096884(void)
+{
+ switch (gMain.state)
+ {
+ case 0:
+ SetVBlankCallback(NULL);
+ REG_DISPCNT = 0;
+ sub_8096804();
+ gMain.state++;
+ break;
+ case 1:
+ Text_LoadWindowTemplate(&gWindowTemplate_81E6D00);
+ gMain.state++;
+ break;
+ case 2:
+ InitMenuWindow(&gWindowTemplate_81E6D00);
+ Menu_EraseScreen();
+ gMain.state++;
+ break;
+ case 3:
+ sub_80967DC();
+ sub_8096848();
+ gMain.state++;
+ break;
+ case 4:
+ ResetPSSMonIconSprites();
+ sub_809AA24();
+ gMain.state++;
+ break;
+ case 5:
+ sub_8097DE0();
+ gMain.state++;
+ break;
+ case 6:
+ sub_8097E70();
+ gMain.state++;
+ break;
+ case 7:
+ sub_8098400();
+ gMain.state++;
+ break;
+ case 8:
+ sub_8099BF8(gPokemonStorage.currentBox);
+ gPokemonStorageSystemPtr->unk_12bc.baseTileTag = 0x000a;
+ gPokemonStorageSystemPtr->unk_12bc.basePaletteTag = 0xdacb;
+ sub_80F727C(&gPokemonStorageSystemPtr->unk_12bc);
+ sub_80F7404();
+ gMain.state++;
+ break;
+ case 9:
+ sub_8096874();
+ SetPSSCallback(sub_8096BF0);
+ SetMainCallback2(sub_8096B38);
+ SetVBlankCallback(sub_8096AFC);
+ gMain.state++;
+ break;
+ }
+}
+
+void sub_80969A0(void)
+{
+ switch (gMain.state)
+ {
+ case 0:
+ SetVBlankCallback(NULL);
+ REG_DISPCNT = 0x0000;
+ gPokemonStorageSystemPtr->unk_0005 = gUnknown_0203847D;
+ sub_8096804();
+ if (gUnknown_0203847F == 1)
+ sub_809BBC0();
+ if (gUnknown_0203847F == 0)
+ sub_809BD14();
+ gMain.state++;
+ break;
+ case 1:
+ Text_LoadWindowTemplate(&gWindowTemplate_81E6D00);
+ gMain.state++;
+ break;
+ case 2:
+ InitMenuWindow(&gWindowTemplate_81E6D00);
+ Menu_EraseScreen();
+ gMain.state++;
+ break;
+ case 3:
+ sub_80967DC();
+ gMain.state++;
+ break;
+ case 4:
+ ResetPSSMonIconSprites();
+ sub_809AA98();
+ gMain.state++;
+ break;
+ case 5:
+ sub_8097DE0();
+ gMain.state++;
+ break;
+ case 6:
+ sub_8097E70();
+ gMain.state++;
+ break;
+ case 7:
+ sub_8098400();
+ gMain.state++;
+ break;
+ case 8:
+ sub_8099BF8(gPokemonStorage.currentBox);
+ gPokemonStorageSystemPtr->unk_12bc.baseTileTag = 0x000a;
+ gPokemonStorageSystemPtr->unk_12bc.basePaletteTag = 0xdacb;
+ sub_80F727C(&gPokemonStorageSystemPtr->unk_12bc);
+ sub_80F7404();
+ gMain.state++;
+ break;
+ case 9:
+ BeginNormalPaletteFade(0xffffffff, 0, 16, 0, 0);
+ SetVBlankCallback(sub_8096AFC);
+ gMain.state++;
+ break;
+ case 10:
+ sub_8096874();
+ SetPSSCallback(sub_8096C68);
+ SetMainCallback2(sub_8096B38);
+ gMain.state++;
+ break;
+ }
+}
+
+void sub_8096AFC(void)
+{
+ REG_BG2HOFS = gPokemonStorageSystemPtr->unk_08b4;
+ REG_BG3HOFS = gPokemonStorageSystemPtr->unk_000a;
+ REG_BG3VOFS = gPokemonStorageSystemPtr->unk_0008;
+ LoadOam();
+ ProcessSpriteCopyRequests();
+ sub_809CFF0();
+ TransferPlttBuffer();
+}
+
+void sub_8096B38(void)
+{
+ gPokemonStorageSystemPtr->unk_0000();
+ sub_8097E44();
+ sub_8098734();
+ AnimateSprites();
+ BuildOamBuffer();
+}
+
+void sub_8096B5C(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0006)
+ {
+ case 0:
+ ShowPokemonSummaryScreen(gPokemonStorageSystemPtr->unk_2690, gPokemonStorageSystemPtr->unk_268d, gPokemonStorageSystemPtr->unk_268c, sub_80969A0, gPokemonStorageSystemPtr->unk_268e);
+ break;
+ case 1:
+ DoNamingScreen(1, gPokemonStorage.boxNames[gPokemonStorage.currentBox], 0, 0, 0, sub_80969A0);
+ break;
+ }
+}
+
+void SetPSSCallback(void (*func)(void))
+{
+ gPokemonStorageSystemPtr->unk_0000 = func;
+ gPokemonStorageSystemPtr->unk_0004 = 0;
+}
+
+void sub_8096BF0(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ BlendPalettes(0xffffffff, 16, 0);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 1:
+ PlaySE(SE_PC_LOGON);
+ gPokemonStorageSystemPtr->unk_000c.tileTag = 14;
+ gPokemonStorageSystemPtr->unk_000c.paletteTag = 0xdad0;
+ gPokemonStorageSystemPtr->unk_000c.unk04 = 0;
+ gPokemonStorageSystemPtr->unk_000c.unk06 = 0;
+ sub_80C5CD4(&gPokemonStorageSystemPtr->unk_000c);
+ BlendPalettes(0xffffffff, 0, 0);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 2:
+ if (sub_80C5DCC())
+ SetPSSCallback(sub_8096C84);
+ break;
+ }
+}
+
+void sub_8096C68(void)
+{
+ if (!UpdatePaletteFade())
+ SetPSSCallback(sub_8096C84);
+}
+
+void sub_8096C84(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ switch (sub_809CA40())
+ {
+ case 1:
+ PlaySE(SE_SELECT);
+ gPokemonStorageSystemPtr->unk_0004 = 1;
+ break;
+ case 5:
+ if (gPokemonStorageSystemPtr->unk_0005 != 2)
+ {
+ PrintStorageActionText(PC_TEXT_WHICH_ONE_WILL_TAKE);
+ gPokemonStorageSystemPtr->unk_0004 = 3;
+ }
+ else
+ {
+ sub_809B0D4();
+ SetPSSCallback(sub_8096FC8);
+ }
+ break;
+ case 6:
+ if (gPokemonStorageSystemPtr->unk_0005 == 2)
+ {
+ if (sub_809BF20() && ItemIsMail(gPokemonStorageSystemPtr->unk_11f2))
+ {
+ gPokemonStorageSystemPtr->unk_0004 = 5;
+ }
+ else
+ {
+ SetPSSCallback(sub_8097004);
+ }
+ }
+ break;
+ case 4:
+ SetPSSCallback(sub_8097BA0);
+ break;
+ case 16:
+ SetPSSCallback(sub_8097CC0);
+ break;
+ case 7:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(sub_809789C);
+ break;
+ case 8:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(sub_8097078);
+ break;
+ case 9:
+ PlaySE(SE_SELECT);
+ gPokemonStorageSystemPtr->unk_08b2 = gPokemonStorage.currentBox + 1;
+ if (gPokemonStorageSystemPtr->unk_08b2 > 13)
+ gPokemonStorageSystemPtr->unk_08b2 = 0;
+ sub_8099C70(gPokemonStorageSystemPtr->unk_08b2);
+ gPokemonStorageSystemPtr->unk_0004 = 2;
+ break;
+ case 10:
+ PlaySE(SE_SELECT);
+ gPokemonStorageSystemPtr->unk_08b2 = gPokemonStorage.currentBox - 1;
+ if (gPokemonStorageSystemPtr->unk_08b2 < 0)
+ gPokemonStorageSystemPtr->unk_08b2 = 13;
+ sub_8099C70(gPokemonStorageSystemPtr->unk_08b2);
+ gPokemonStorageSystemPtr->unk_0004 = 2;
+ break;
+ case 11:
+ if (!sub_809BE80())
+ {
+ if (ItemIsMail(gPokemonStorageSystemPtr->unk_11f2))
+ {
+ gPokemonStorageSystemPtr->unk_0004 = 5;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ SetPSSCallback(sub_809746C);
+ }
+ }
+ else
+ {
+ gPokemonStorageSystemPtr->unk_0004 = 4;
+ }
+ break;
+ case 13:
+ if (sub_809BE80())
+ {
+ gPokemonStorageSystemPtr->unk_0004 = 4;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ SetPSSCallback(sub_80972A8);
+ }
+ break;
+ case 14:
+ if (!sub_809BEBC())
+ {
+ gPokemonStorageSystemPtr->unk_0004 = 4;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ SetPSSCallback(c3_0808DC50);
+ }
+ break;
+ case 12:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(sub_8097390);
+ break;
+ case 15:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(sub_80972FC);
+ break;
+ }
+ break;
+ case 1:
+ if (!sub_809AC00())
+ {
+ if (sub_809BF48())
+ sub_80986E8();
+ else
+ sub_8098710();
+ if (gPokemonStorageSystemPtr->unk_11f6)
+ BoxSetMosaic();
+ gPokemonStorageSystemPtr->unk_0004 = 0;
+ }
+ break;
+ case 2:
+ if (!sub_8099D34())
+ {
+ gPokemonStorage.currentBox = gPokemonStorageSystemPtr->unk_08b2;
+ if (!gUnknown_0203847C && !sub_809BF20())
+ {
+ sub_809B440();
+ BoxSetMosaic();
+ }
+ gPokemonStorageSystemPtr->unk_0004 = 0;
+ }
+ break;
+ case 3:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ sub_8098A5C();
+ gPokemonStorageSystemPtr->unk_0004 = 0;
+ }
+ break;
+ case 4:
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_LAST_POKE);
+ gPokemonStorageSystemPtr->unk_0004 = 6;
+ break;
+ case 5:
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL);
+ gPokemonStorageSystemPtr->unk_0004 = 6;
+ break;
+ case 6:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ sub_8098A5C();
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ }
+}
+
+void sub_8096FC8(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ sub_809880C();
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 1:
+ if (!sub_8098830())
+ SetPSSCallback(sub_8096C84);
+ break;
+ }
+}
+
+void sub_8097004(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ PlaySE(SE_SELECT);
+ add_to_c3_somehow();
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 1:
+ if (!sub_80985CC())
+ {
+ sub_809B0C0(sub_809B0F4());
+ gPokemonStorageSystemPtr->unk_0004++;
+ }
+ break;
+ case 2:
+ if (!sub_809AC00())
+ {
+ if (gPokemonStorageSystemPtr->unk_11f6)
+ BoxSetMosaic();
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ }
+}
+
+void sub_8097078(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ PrintStorageActionText(PC_TEXT_IS_SELECTED);
+ sub_809CE84();
+ gPokemonStorageSystemPtr->unk_0004 = 1;
+ break;
+ case 1:
+ switch (sub_809CF30())
+ {
+ case -1:
+ case 0:
+ sub_8098A5C();
+ SetPSSCallback(sub_8096C84);
+ break;
+ case 3:
+ if (sub_809BE80())
+ {
+ gPokemonStorageSystemPtr->unk_0004 = 2;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ sub_8098A5C();
+ SetPSSCallback(sub_80972A8);
+ }
+ break;
+ case 5:
+ PlaySE(SE_SELECT);
+ sub_8098A5C();
+ SetPSSCallback(sub_80972FC);
+ break;
+ case 4:
+ if (!sub_809BEBC())
+ {
+ gPokemonStorageSystemPtr->unk_0004 = 2;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ sub_8098A5C();
+ SetPSSCallback(c3_0808DC50);
+ }
+ break;
+ case 2:
+ PlaySE(SE_SELECT);
+ sub_8098A5C();
+ SetPSSCallback(sub_8097390);
+ break;
+ case 1:
+ if (sub_809BE80())
+ {
+ gPokemonStorageSystemPtr->unk_0004 = 2;
+ }
+ else if (ItemIsMail(gPokemonStorageSystemPtr->unk_11f2))
+ {
+ gPokemonStorageSystemPtr->unk_0004 = 3;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ sub_8098A5C();
+ SetPSSCallback(sub_809746C);
+ }
+ break;
+ case 7:
+ if (sub_809BE80())
+ {
+ gPokemonStorageSystemPtr->unk_0004 = 2;
+ }
+ else if (gPokemonStorageSystemPtr->unk_11f9)
+ {
+ gPokemonStorageSystemPtr->unk_0004 = 4;
+ }
+ else if (ItemIsMail(gPokemonStorageSystemPtr->unk_11f2))
+ {
+ gPokemonStorageSystemPtr->unk_0004 = 3;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ SetPSSCallback(sub_8097594);
+ }
+ break;
+ case 6:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(sub_8097788);
+ break;
+ case 8:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(sub_80977E4);
+ break;
+ }
+ break;
+ case 2:
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_LAST_POKE);
+ gPokemonStorageSystemPtr->unk_0004 = 5;
+ break;
+ case 4:
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_CANT_RELEASE_EGG);
+ gPokemonStorageSystemPtr->unk_0004 = 5;
+ break;
+ case 3:
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL);
+ gPokemonStorageSystemPtr->unk_0004 = 5;
+ break;
+ case 5:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ sub_8098A5C();
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ }
+}
+
+void sub_80972A8(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ sub_809B100(0);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 1:
+ if (!sub_809B130())
+ {
+ if (gUnknown_0203847C)
+ SetPSSCallback(sub_8097858);
+ else
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ }
+}
+
+void sub_80972FC(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ sub_809B100(1);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 1:
+ if (!sub_809B130())
+ {
+ if (gUnknown_0203847C)
+ SetPSSCallback(sub_8097858);
+ else
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ }
+}
+
+void c3_0808DC50(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ sub_809B100(2);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 1:
+ if (!sub_809B130())
+ {
+ BoxSetMosaic();
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ }
+}
+
+void sub_8097390(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ if (CalculatePlayerPartyCount() == 6)
+ {
+ PrintStorageActionText(PC_TEXT_PARTY_FULL);
+ gPokemonStorageSystemPtr->unk_0004 = 1;
+ }
+ else
+ {
+ sub_809B0E0();
+ sub_809B100(0);
+ gPokemonStorageSystemPtr->unk_0004 = 2;
+ }
+ break;
+ case 1:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ sub_8098A5C();
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ case 2:
+ if (!sub_809B130())
+ {
+ sub_809880C();
+ gPokemonStorageSystemPtr->unk_0004++;
+ }
+ break;
+ case 3:
+ if (!sub_8098830())
+ {
+ sub_809B100(1);
+ gPokemonStorageSystemPtr->unk_0004++;
+ }
+ break;
+ case 4:
+ if (!sub_809B130())
+ {
+ sub_80987DC();
+ gPokemonStorageSystemPtr->unk_0004++;
+ }
+ break;
+ case 5:
+ SetPSSCallback(sub_8097004);
+ break;
+ }
+}
+
+void sub_809746C(void)
+{
+ u8 r4;
+
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX);
+ sub_8096264(&gPokemonStorageSystemPtr->unk_2370, 0x0007, 0xdaca, 3);
+ sub_809634C(gUnknown_0203847E);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 1:
+ r4 = sub_8096368();
+ if (r4 == 200);
+ else if (r4 == 201)
+ {
+ sub_8098A5C();
+ sub_809635C();
+ sub_8096310();
+ SetPSSCallback(sub_8096C84);
+ }
+ else
+ {
+ if (sub_809B62C(r4))
+ {
+ sub_8098A5C();
+ sub_809635C();
+ sub_8096310();
+ gPokemonStorageSystemPtr->unk_0004 = 2;
+ }
+ else
+ {
+ PrintStorageActionText(PC_TEXT_BOX_IS_FULL);
+ gPokemonStorageSystemPtr->unk_0004 = 4;
+ }
+ gUnknown_0203847E = r4;
+ }
+ break;
+ case 2:
+ party_compaction();
+ sub_8099310();
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 3:
+ if (sub_8099374() == 0)
+ {
+ sub_809B6BC();
+ BoxSetMosaic();
+ sub_80987DC();
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ case 4:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ {
+ PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX);
+ gPokemonStorageSystemPtr->unk_0004 = 1;
+ }
+ break;
+ }
+}
+
+void sub_8097594(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ PrintStorageActionText(PC_TEXT_RELEASE_POKE);
+ sub_8098A38(1);
+ gPokemonStorageSystemPtr->unk_0004++;
+ // fallthrough
+ case 1:
+ switch (Menu_ProcessInputNoWrap())
+ {
+ case -1:
+ case 1:
+ sub_8098A5C();
+ SetPSSCallback(sub_8096C84);
+ break;
+ case 0:
+ sub_8098A5C();
+ sub_809B7D4();
+ sub_809B6DC();
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ }
+ break;
+ case 2:
+ sub_809B960();
+ if (!sub_809B734())
+ {
+ while (1)
+ {
+ s8 r0 = sub_809B960();
+ if (r0 == 1)
+ {
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ }
+ if (r0 == 0)
+ {
+ gPokemonStorageSystemPtr->unk_0004 = 8;
+ break;
+ }
+ }
+ }
+ break;
+ case 3:
+ sub_809B760();
+ sub_809801C();
+ PrintStorageActionText(PC_TEXT_WAS_RELEASED);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 4:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ {
+ PrintStorageActionText(PC_TEXT_BYE_BYE);
+ gPokemonStorageSystemPtr->unk_0004++;
+ }
+ break;
+ case 5:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ {
+ sub_8098A5C();
+ if (gUnknown_0203847C)
+ {
+ party_compaction();
+ sub_8099310();
+ gPokemonStorageSystemPtr->unk_0004++;
+ }
+ else
+ {
+ gPokemonStorageSystemPtr->unk_0004 = 7;
+ }
+ }
+ break;
+ case 6:
+ if (sub_8099374() == 0)
+ {
+ sub_809B440();
+ BoxSetMosaic();
+ sub_80987DC();
+ gPokemonStorageSystemPtr->unk_0004++;
+ }
+ break;
+ case 7:
+ SetPSSCallback(sub_8096C84);
+ break;
+ case 8:
+ PrintStorageActionText(PC_TEXT_WAS_RELEASED);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 9:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ {
+ PrintStorageActionText(PC_TEXT_SURPRISE);
+ gPokemonStorageSystemPtr->unk_0004++;
+ }
+ break;
+ case 10:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ {
+ sub_8098A5C();
+ sub_8099958();
+ gPokemonStorageSystemPtr->unk_0004++;
+ }
+ break;
+ case 11:
+ if (!sub_8099990())
+ {
+ sub_809B7AC();
+ PrintStorageActionText(PC_TEXT_CAME_BACK);
+ gPokemonStorageSystemPtr->unk_0004++;
+ }
+ break;
+ case 12:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ {
+ PrintStorageActionText(PC_TEXT_WORRIED);
+ gPokemonStorageSystemPtr->unk_0004++;
+ }
+ break;
+ case 13:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON))
+ {
+ sub_8098A5C();
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ }
+}
+
+void sub_8097788(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ sub_809BC18();
+ BeginNormalPaletteFade(0xffffffff, 0, 0, 16, 0);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 1:
+ if (!UpdatePaletteFade())
+ {
+ gUnknown_0203847F = 0;
+ gPokemonStorageSystemPtr->unk_0006 = 0;
+ SetMainCallback2(sub_8096B5C);
+ }
+ break;
+ }
+}
+
+void sub_80977E4(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ PrintStorageActionText(PC_TEXT_MARK_POKE);
+ gPokemonStorageSystemPtr->unk_12bc.markings = gPokemonStorageSystemPtr->unk_11f7;
+ sub_80F7418(gPokemonStorageSystemPtr->unk_11f7, 0xb0, 0x10);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 1:
+ if (!sub_80F7500())
+ {
+ sub_80F7470();
+ sub_8098A5C();
+ sub_809BDD8(gPokemonStorageSystemPtr->unk_12bc.markings);
+ sub_809801C();
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ }
+}
+
+void sub_8097858(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ party_compaction();
+ sub_8099310();
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 1:
+ if (sub_8099374() == 0)
+ {
+ sub_80987DC();
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ }
+}
+
+void sub_809789C(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ PrintStorageActionText(PC_TEXT_WHAT_YOU_DO);
+ sub_809CE84();
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 1:
+ switch (sub_809CF30())
+ {
+ case -1:
+ case 0:
+ sub_809A860(1);
+ sub_8098A5C();
+ SetPSSCallback(sub_8096C84);
+ break;
+ case 11:
+ PlaySE(SE_SELECT);
+ SetPSSCallback(sub_8097B44);
+ break;
+ case 10:
+ PlaySE(SE_SELECT);
+ sub_8098A5C();
+ SetPSSCallback(sub_8097974);
+ break;
+ case 9:
+ PlaySE(SE_SELECT);
+ sub_8098A5C();
+ SetPSSCallback(sub_8097A64);
+ break;
+ }
+ break;
+ }
+}
+
+void sub_8097974(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ sub_8098A80();
+ PrintStorageActionText(PC_TEXT_PICK_A_THEME);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 1:
+ gPokemonStorageSystemPtr->unk_0d5e = sub_809CF30();
+ switch (gPokemonStorageSystemPtr->unk_0d5e)
+ {
+ case -1:
+ sub_809A860(1);
+ sub_8098A5C();
+ SetPSSCallback(sub_8096C84);
+ break;
+ case 12 ... 15:
+ PlaySE(SE_SELECT);
+ gPokemonStorageSystemPtr->unk_0d5e -= 12;
+ sub_8098AA8(gPokemonStorageSystemPtr->unk_0d5e);
+ PrintStorageActionText(PC_TEXT_PICK_A_WALLPAPER);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ }
+ break;
+ case 2:
+ gPokemonStorageSystemPtr->unk_0d60 = sub_809CF30();
+ switch (gPokemonStorageSystemPtr->unk_0d60)
+ {
+ case -1:
+ sub_8098A5C();
+ gPokemonStorageSystemPtr->unk_0004 = 0;
+ break;
+ case -2:
+ break;
+ default:
+ PlaySE(SE_SELECT);
+ sub_8098A5C();
+ gPokemonStorageSystemPtr->unk_0d60 -= 16;
+ sub_8099DCC(gPokemonStorageSystemPtr->unk_0d60);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ }
+ break;
+ case 3:
+ if (!sub_8099E08())
+ {
+ sub_809A860(1);
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ }
+}
+
+void sub_8097A64(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ PrintStorageActionText(PC_TEXT_JUMP_TO_WHICH_BOX);
+ sub_8096264(&gPokemonStorageSystemPtr->unk_2370, 0x0007, 0xdaca, 3);
+ sub_809634C(gPokemonStorage.currentBox);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 1:
+ gPokemonStorageSystemPtr->unk_08b2 = sub_8096368();
+ switch (gPokemonStorageSystemPtr->unk_08b2)
+ {
+ case 200:
+ break;
+ default:
+ sub_8098A5C();
+ sub_809635C();
+ sub_8096310();
+ if (gPokemonStorageSystemPtr->unk_08b2 == 201 || gPokemonStorageSystemPtr->unk_08b2 == gPokemonStorage.currentBox)
+ {
+ sub_809A860(1);
+ SetPSSCallback(sub_8096C84);
+ }
+ else
+ {
+ gPokemonStorageSystemPtr->unk_0004++;
+ }
+ break;
+ }
+ break;
+ case 2:
+ sub_8099C70(gPokemonStorageSystemPtr->unk_08b2);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 3:
+ if (!sub_8099D34())
+ {
+ gPokemonStorage.currentBox = gPokemonStorageSystemPtr->unk_08b2;
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ }
+}
+
+void sub_8097B44(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ sub_809BB90();
+ BeginNormalPaletteFade(0xffffffff, 0, 0, 16, 0);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 1:
+ if (!UpdatePaletteFade())
+ {
+ gUnknown_0203847F = 1;
+ gPokemonStorageSystemPtr->unk_0006 = 1;
+ SetMainCallback2(sub_8096B5C);
+ }
+ break;
+ }
+}
+
+void sub_8097BA0(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_0004)
+ {
+ case 0:
+ if (sub_809BF20())
+ {
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_HOLDING_POKE);
+ gPokemonStorageSystemPtr->unk_0004 = 1;
+ }
+ else
+ {
+ PlaySE(SE_SELECT);
+ PrintStorageActionText(PC_TEXT_EXIT_BOX);
+ sub_8098A38(0);
+ gPokemonStorageSystemPtr->unk_0004 = 2;
+ }
+ break;
+ case 1:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY))
+ {
+ sub_8098A5C();
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ case 2:
+ switch (Menu_ProcessInputNoWrap())
+ {
+ case 1:
+ case -1:
+ sub_8098A5C();
+ SetPSSCallback(sub_8096C84);
+ break;
+ case 0:
+ PlaySE(SE_PC_OFF);
+ sub_8098A5C();
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ }
+ break;
+ case 3:
+ gPokemonStorageSystemPtr->unk_000c.tileTag = 0x000e;
+ gPokemonStorageSystemPtr->unk_000c.paletteTag = 0xdad0;
+ gPokemonStorageSystemPtr->unk_000c.unk04 = 20;
+ gPokemonStorageSystemPtr->unk_000c.unk06 = 0;
+ sub_80C5E38(&gPokemonStorageSystemPtr->unk_000c);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 4:
+ if (sub_80C5F98())
+ {
+ gPlayerPartyCount = CalculatePlayerPartyCount();
+ SetMainCallback2(sub_80961A8);
+ }
+ break;
+ }
+}
+
+void sub_8097CC0(void) {
+ switch (gPokemonStorageSystemPtr->unk_0004) {
+ case 0:
+ if (sub_809BF20()) {
+ PlaySE(SE_HAZURE);
+ PrintStorageActionText(PC_TEXT_HOLDING_POKE);
+ gPokemonStorageSystemPtr->unk_0004 = 1;
+ }
+ else {
+ PlaySE(SE_SELECT);
+ PrintStorageActionText(PC_TEXT_CONTINUE_BOX);
+ sub_8098A38(0);
+ gPokemonStorageSystemPtr->unk_0004 = 2;
+ }
+ break;
+ case 1:
+ if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) {
+ sub_8098A5C();
+ SetPSSCallback(sub_8096C84);
+ }
+ break;
+ case 2:
+ switch (Menu_ProcessInputNoWrap()) {
+ case 0:
+ sub_8098A5C();
+ SetPSSCallback(sub_8096C84);
+ break;
+ case -1:
+ case 1:
+ PlaySE(SE_PC_OFF);
+ sub_8098A5C();
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ }
+ break;
+ case 3:
+ gPokemonStorageSystemPtr->unk_000c.tileTag = 0x000e;
+ gPokemonStorageSystemPtr->unk_000c.paletteTag = 0xdad0;
+ gPokemonStorageSystemPtr->unk_000c.unk04 = 20;
+ gPokemonStorageSystemPtr->unk_000c.unk06 = 0;
+ sub_80C5E38(&gPokemonStorageSystemPtr->unk_000c);
+ gPokemonStorageSystemPtr->unk_0004++;
+ break;
+ case 4:
+ if (sub_80C5F98()) {
+ gPlayerPartyCount = CalculatePlayerPartyCount();
+ SetMainCallback2(sub_80961A8);
+ }
+ break;
+ }
+}
+
+void sub_8097DE0(void)
+{
+ gPokemonStorageSystemPtr->unk_0007 = 0;
+ gPokemonStorageSystemPtr->unk_0008 = 0;
+ gPokemonStorageSystemPtr->unk_000a = 0;
+ REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(3) | BGCNT_SCREENBASE(30);
+ DmaCopy16Defvars(3, gPokemonStorageScrollingBGTile, BG_SCREEN_ADDR(28), sizeof gPokemonStorageScrollingBGTile);
+ LZ77UnCompVram(gPokemonStorageScrollingBGTilemap, BG_SCREEN_ADDR(30));
+ LoadPalette(gPokemonStorageScrollingBGPalette, 0xd0, 0x10);
+}
+
+void sub_8097E44(void)
+{
+ if (++gPokemonStorageSystemPtr->unk_0007 >= 2)
+ {
+ gPokemonStorageSystemPtr->unk_0007 = 0;
+ gPokemonStorageSystemPtr->unk_0008--;
+ gPokemonStorageSystemPtr->unk_000a++;
+ }
+}
+
+void sub_8097E70(void)
+{
+ LZ77UnCompVram(gPSSMenuHeader_Gfx, BG_SCREEN_ADDR(10));
+ LZ77UnCompWram(gPSSMenuHeader_Tilemap, gUnknown_02039760);
+ sub_809D034(BG_SCREEN_ADDR(15), 0, 0, gUnknown_02039760, 0, 0, 10, 20);
+ LoadPalette(gPSSMenu1_Pal, 0x10, 0x20);
+ LoadPalette(gPSSMenu2_Pal, 0x00, 0x20);
+ LoadPalette(gUnknown_083B6D74, 0xB0, 0x20);
+ LoadPalette(gUnknown_083B6D94, 0xC0, 0x20);
+ LoadPalette(gUnknownPalette_81E6692 + 1, 0xF1, 0x02);
+ LoadPalette(gUnknownPalette_81E6692 + 1, 0xF2, 0x02);
+ LoadPalette(gUnknownPalette_81E6692 + 5, 0xF3, 0x02);
+ LoadPalette(gUnknownPalette_81E6692 + 12, 0xF4, 0x04);
+ LoadPalette(gUnknownPalette_81E6692 + 10, 0xF6, 0x04);
+ LoadPalette(gUnknownPalette_81E6692 + 2, 0xFF, 0x02);
+ LoadSpritePalette(&gWaveformSpritePalette);
+ sub_80980D4();
+ sub_8097F58();
+ sub_8097FB8();
+ sub_809801C();
+}
+
+void sub_8097F58(void)
+{
+ gPokemonStorageSystemPtr->unk_12ac = sub_80F7940(0x000d, 0xdace, 0);
+ gPokemonStorageSystemPtr->unk_12ac->oam.priority = 0;
+ gPokemonStorageSystemPtr->unk_12ac->subpriority = 1;
+ gPokemonStorageSystemPtr->unk_12ac->pos1.x = 0x28;
+ gPokemonStorageSystemPtr->unk_12ac->pos1.y = 0x95;
+ gPokemonStorageSystemPtr->unk_12b8 = BG_CHAR_ADDR(4) + 32 * GetSpriteTileStartByTag(0x000d);
+}
+
+const struct SpriteTemplate gSpriteTemplate_83B6EFC;
+
+void sub_8097FB8(void)
+{
+ u16 i;
+ struct SpriteSheet sheet = {WaveformTiles, 0x1c0, 0x0005};
+
+ LoadSpriteSheet(&sheet);
+ for (i = 0; i < 2; i++)
+ {
+ u8 spriteId = CreateSprite(&gSpriteTemplate_83B6EFC, i * 63 + 8, 9, 2);
+ gPokemonStorageSystemPtr->unk_12b0[i] = gSprites + spriteId;
+ }
+}
+
+void sub_809801C(void)
+{
+ sub_80981F0(gPokemonStorageSystemPtr->unk_11f0, gPokemonStorageSystemPtr->unk_11ec);
+ sub_80982B4();
+ sub_8098350();
+}
+
+void BoxSetMosaic(void)
+{
+ sub_809801C();
+ if (gPokemonStorageSystemPtr->unk_2700)
+ {
+ gPokemonStorageSystemPtr->unk_2700->oam.mosaic = TRUE;
+ gPokemonStorageSystemPtr->unk_2700->data[0] = 10;
+ gPokemonStorageSystemPtr->unk_2700->data[1] = 1;
+ gPokemonStorageSystemPtr->unk_2700->callback = sub_8098090;
+ REG_MOSAIC = (gPokemonStorageSystemPtr->unk_2700->data[0] << 12) | (gPokemonStorageSystemPtr->unk_2700->data[0] << 8);
+ }
+}
+
+void sub_8098090(struct Sprite *sprite)
+{
+ sprite->data[0] -= sprite->data[1];
+ if (sprite->data[0] < 0)
+ sprite->data[0] = 0;
+ REG_MOSAIC = (sprite->data[0] << 12) | (sprite->data[0] << 8);
+ if (sprite->data[0] == 0)
+ {
+ sprite->oam.mosaic = FALSE;
+ sprite->callback = SpriteCallbackDummy;
+ }
+}
+
+// sub_80980D4
+
+const struct OamData gOamData_83B6EAC;
+
+#ifdef NONMATCHING
+void sub_80980D4(void)
+{
+ u16 i;
+ u16 tileStart;
+ u8 palSlot;
+ u8 spriteId;
+ struct SpriteSheet sheet = {gPokemonStorageSystemPtr->unk_2784, 0x800, 0x0002};
+ struct SpritePalette palette = {gPokemonStorageSystemPtr->unk_2704, 0xdac7};
+ struct SpriteTemplate template = {
+ 0x0002, 0xdac7, &gOamData_83B6EAC, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
+ };
+
+ for (i = 0; i < 0x800; i++)
+ gPokemonStorageSystemPtr->unk_2784[i] = 0;
+ for (i = 0; i < 0x10; i++)
+ gPokemonStorageSystemPtr->unk_2704[i] = 0;
+
+ gPokemonStorageSystemPtr->unk_2700 = NULL;
+ if ((tileStart = LoadSpriteSheet(&sheet)) != 0
+ && (palSlot = LoadSpritePalette(&palette)) != 0xff
+ && (spriteId = CreateSprite(&template, 0x28, 0x30, 0)) != MAX_SPRITES)
+ {
+ // FIXME this gets compiled as a separate block between the palSlot check and the spriteId check
+ gPokemonStorageSystemPtr->unk_2700 = gSprites + spriteId;
+ gPokemonStorageSystemPtr->unk_26fa = palSlot * 16 + 0x100;
+ gPokemonStorageSystemPtr->unk_26fc = BG_CHAR_ADDR(4) + tileStart * 32;
+ }
+
+ if (gPokemonStorageSystemPtr->unk_2700 == NULL)
+ {
+ FreeSpriteTilesByTag(0x0002);
+ FreeSpritePaletteByTag(0xdac7);
+ }
+}
+#else
+
+const struct SpriteSheet gUnknown_083B6DCC = {ePokemonStorageSystem.unk_2784, 0x800, 0x0002};
+const struct SpritePalette gUnknown_083B6DD4 = {ePokemonStorageSystem.unk_2704, 0xdac7};
+const struct SpriteTemplate gSpriteTemplate_83B6DDC = {
+ 0x0002, 0xdac7, &gOamData_83B6EAC, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
+};
+
+__attribute__((naked)) void sub_80980D4(void)
+{
+ asm_unified("\tpush {r4,r5,lr}\n"
+ "\tsub sp, 0x28\n"
+ "\tldr r0, _08098150 @ =gUnknown_083B6DCC\n"
+ "\tldr r1, [r0, 0x4]\n"
+ "\tldr r0, [r0]\n"
+ "\tstr r0, [sp, 0x18]\n"
+ "\tstr r1, [sp, 0x1C]\n"
+ "\tldr r0, _08098154 @ =gUnknown_083B6DD4\n"
+ "\tldr r1, [r0, 0x4]\n"
+ "\tldr r0, [r0]\n"
+ "\tstr r0, [sp, 0x20]\n"
+ "\tstr r1, [sp, 0x24]\n"
+ "\tmov r1, sp\n"
+ "\tldr r0, _08098158 @ =gSpriteTemplate_83B6DDC\n"
+ "\tldm r0!, {r2-r4}\n"
+ "\tstm r1!, {r2-r4}\n"
+ "\tldm r0!, {r2-r4}\n"
+ "\tstm r1!, {r2-r4}\n"
+ "\tmovs r1, 0\n"
+ "\tadd r5, sp, 0x18\n"
+ "\tldr r4, _0809815C @ =gSharedMem + 0x2784\n"
+ "\tmovs r3, 0\n"
+ "\tldr r2, _08098160 @ =0x000007ff\n"
+ "_08098102:\n"
+ "\tadds r0, r1, r4\n"
+ "\tstrb r3, [r0]\n"
+ "\tadds r0, r1, 0x1\n"
+ "\tlsls r0, 16\n"
+ "\tlsrs r1, r0, 16\n"
+ "\tcmp r1, r2\n"
+ "\tbls _08098102\n"
+ "\tmovs r1, 0\n"
+ "\tldr r3, _08098164 @ =gSharedMem + 0x2704\n"
+ "\tmovs r2, 0\n"
+ "_08098116:\n"
+ "\tlsls r0, r1, 1\n"
+ "\tadds r0, r3\n"
+ "\tstrh r2, [r0]\n"
+ "\tadds r0, r1, 0x1\n"
+ "\tlsls r0, 16\n"
+ "\tlsrs r1, r0, 16\n"
+ "\tcmp r1, 0xF\n"
+ "\tbls _08098116\n"
+ "\tldr r0, _08098168 @ =gSharedMem\n"
+ "\tmovs r1, 0x9C\n"
+ "\tlsls r1, 6\n"
+ "\tadds r0, r1\n"
+ "\tmovs r1, 0\n"
+ "\tstr r1, [r0]\n"
+ "\tadds r0, r5, 0\n"
+ "\tbl LoadSpriteSheet\n"
+ "\tlsls r0, 16\n"
+ "\tlsrs r5, r0, 16\n"
+ "\tcmp r5, 0\n"
+ "\tbeq _080981C4\n"
+ "\tadd r0, sp, 0x20\n"
+ "\tbl LoadSpritePalette\n"
+ "\tlsls r0, 24\n"
+ "\tlsrs r4, r0, 24\n"
+ "\tcmp r4, 0xFF\n"
+ "\tbeq _080981C4\n"
+ "\tb _080981B0\n"
+ "\t.align 2, 0\n"
+ "_08098150: .4byte gUnknown_083B6DCC\n"
+ "_08098154: .4byte gUnknown_083B6DD4\n"
+ "_08098158: .4byte gSpriteTemplate_83B6DDC\n"
+ "_0809815C: .4byte gSharedMem + 0x2784\n"
+ "_08098160: .4byte 0x000007ff\n"
+ "_08098164: .4byte gSharedMem + 0x2704\n"
+ "_08098168: .4byte gSharedMem\n"
+ "_0809816C:\n"
+ "\tldr r2, _0809819C @ =gSharedMem\n"
+ "\tmovs r0, 0x9C\n"
+ "\tlsls r0, 6\n"
+ "\tadds r3, r2, r0\n"
+ "\tlsls r0, r1, 4\n"
+ "\tadds r0, r1\n"
+ "\tlsls r0, 2\n"
+ "\tldr r1, _080981A0 @ =gSprites\n"
+ "\tadds r0, r1\n"
+ "\tstr r0, [r3]\n"
+ "\tlsls r0, r4, 4\n"
+ "\tmovs r1, 0x80\n"
+ "\tlsls r1, 1\n"
+ "\tadds r0, r1\n"
+ "\tldr r3, _080981A4 @ =0x000026fa\n"
+ "\tadds r1, r2, r3\n"
+ "\tstrh r0, [r1]\n"
+ "\tldr r4, _080981A8 @ =0x000026fc\n"
+ "\tadds r2, r4\n"
+ "\tlsls r0, r5, 5\n"
+ "\tldr r1, _080981AC @ =0x06010000\n"
+ "\tadds r0, r1\n"
+ "\tstr r0, [r2]\n"
+ "\tb _080981C4\n"
+ "\t.align 2, 0\n"
+ "_0809819C: .4byte gSharedMem\n"
+ "_080981A0: .4byte gSprites\n"
+ "_080981A4: .4byte 0x000026fa\n"
+ "_080981A8: .4byte 0x000026fc\n"
+ "_080981AC: .4byte 0x06010000\n"
+ "_080981B0:\n"
+ "\tmov r0, sp\n"
+ "\tmovs r1, 0x28\n"
+ "\tmovs r2, 0x30\n"
+ "\tmovs r3, 0\n"
+ "\tbl CreateSprite\n"
+ "\tlsls r0, 24\n"
+ "\tlsrs r1, r0, 24\n"
+ "\tcmp r1, 0x40\n"
+ "\tbne _0809816C\n"
+ "_080981C4:\n"
+ "\tldr r0, _080981E8 @ =gSharedMem\n"
+ "\tmovs r2, 0x9C\n"
+ "\tlsls r2, 6\n"
+ "\tadds r0, r2\n"
+ "\tldr r0, [r0]\n"
+ "\tcmp r0, 0\n"
+ "\tbne _080981DE\n"
+ "\tmovs r0, 0x2\n"
+ "\tbl FreeSpriteTilesByTag\n"
+ "\tldr r0, _080981EC @ =0x0000dac7\n"
+ "\tbl FreeSpritePaletteByTag\n"
+ "_080981DE:\n"
+ "\tadd sp, 0x28\n"
+ "\tpop {r4,r5}\n"
+ "\tpop {r0}\n"
+ "\tbx r0\n"
+ "\t.align 2, 0\n"
+ "_080981E8: .4byte gSharedMem\n"
+ "_080981EC: .4byte 0x0000dac7");
+}
+#endif
+
+void sub_80981F0(u16 species, u32 pid)
+{
+ if (gPokemonStorageSystemPtr->unk_2700)
+ {
+ if (species != SPECIES_NONE)
+ {
+ HandleLoadSpecialPokePic(gMonFrontPicTable + species, gMonFrontPicCoords[species].coords, 1, (intptr_t)gPokemonStorageSystemPtr->unk_4784, gPokemonStorageSystemPtr->unk_2784, species, pid);
+ LZ77UnCompWram(gPokemonStorageSystemPtr->unk_11e8, gPokemonStorageSystemPtr->unk_2704);
+ CpuCopy32(gPokemonStorageSystemPtr->unk_2784, gPokemonStorageSystemPtr->unk_26fc, 0x800);
+ LoadPalette(gPokemonStorageSystemPtr->unk_2704, gPokemonStorageSystemPtr->unk_26fa, 0x20);
+ gPokemonStorageSystemPtr->unk_2700->invisible = FALSE;
+ }
+ else
+ {
+ gPokemonStorageSystemPtr->unk_2700->invisible = TRUE;
+ }
+ }
+}
+
+void sub_80982B4(void)
+{
+ if (gPokemonStorageSystemPtr->unk_11f0)
+ {
+ sub_80F7A10(gPokemonStorageSystemPtr->unk_11f7, gPokemonStorageSystemPtr->unk_12b8);
+ gPokemonStorageSystemPtr->unk_12ac->invisible = FALSE;
+ }
+ else
+ {
+ gPokemonStorageSystemPtr->unk_12ac->invisible = TRUE;
+ }
+ Menu_EraseWindowRect(0, 11, 9, 17);
+ Menu_PrintText(gPokemonStorageSystemPtr->unk_127a, 1, 16);
+ Menu_PrintText(gPokemonStorageSystemPtr->unk_120f, 1, 11);
+ Menu_PrintText(gPokemonStorageSystemPtr->unk_1234, 0, 13);
+ Menu_PrintText(gPokemonStorageSystemPtr->unk_1259, 1, 15);
+}
+
+void sub_8098350(void)
+{
+ u16 i;
+
+ if (gPokemonStorageSystemPtr->unk_11f0)
+ {
+ sub_809D034(BG_SCREEN_ADDR(15), 1, 0, gUnknown_02039760, 1, 0, 8, 2);
+ for (i = 0; i < 2; i++)
+ StartSpriteAnimIfDifferent(gPokemonStorageSystemPtr->unk_12b0[i], i * 2 + 1);
+ }
+ else
+ {
+ sub_809D034(BG_SCREEN_ADDR(15), 1, 0, gUnknown_02039760, 10, 0, 8, 2);
+ for (i = 0; i < 2; i++)
+ StartSpriteAnim(gPokemonStorageSystemPtr->unk_12b0[i], i * 2);
+ }
+}
+
+void sub_8098400(void)
+{
+ REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_SCREENBASE(15);
+ LZ77UnCompVram(gPSSMenuMisc_Gfx, BG_SCREEN_ADDR(13));
+ LZ77UnCompWram(gPSSMenuMisc_Tilemap, gPokemonStorageSystemPtr->unk_00a8);
+ LoadPalette(gPSSMenu3_Pal, 0x20, 0x20);
+ LoadPalette(gPSSMenu4_Pal, 0x30, 0x20);
+ DmaClear16(3, BG_SCREEN_ADDR(15), 0x800);
+ sub_8098780();
+ if (gUnknown_0203847C)
+ {
+ sub_8098690(TRUE);
+ sub_8099200(TRUE);
+ sub_809D034(BG_SCREEN_ADDR(15), 10, 0, gPokemonStorageSystemPtr->unk_00a8, 0, 0, 12, 22);
+ }
+ else
+ {
+ sub_809D034(BG_SCREEN_ADDR(15), 10, 0, gPokemonStorageSystemPtr->unk_00a8, 0, 20, 12, 2);
+ sub_8098690(TRUE);
+ }
+ gPokemonStorageSystemPtr->unk_08af = 0;
+}
+
+void sub_80984E8(void)
+{
+ gPokemonStorageSystemPtr->unk_08a8 = 20;
+ gPokemonStorageSystemPtr->unk_08aa = 2;
+ gPokemonStorageSystemPtr->unk_08ad = 0;
+ sub_8099200(FALSE);
+}
+
+bool8 sub_8098520(void)
+{
+ if (gPokemonStorageSystemPtr->unk_08ad == 20)
+ return FALSE;
+ gPokemonStorageSystemPtr->unk_08a8--;
+ gPokemonStorageSystemPtr->unk_08aa++;
+ sub_809D034(BG_SCREEN_ADDR(15), 10, 0, gPokemonStorageSystemPtr->unk_00a8, 0, gPokemonStorageSystemPtr->unk_08a8, 12, gPokemonStorageSystemPtr->unk_08aa);
+ sub_80994A8(8);
+ if (++gPokemonStorageSystemPtr->unk_08ad == 20)
+ {
+ gUnknown_0203847C = 1;
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void add_to_c3_somehow(void)
+{
+ gPokemonStorageSystemPtr->unk_08a8 = 0;
+ gPokemonStorageSystemPtr->unk_08aa = 22;
+ gPokemonStorageSystemPtr->unk_08ad = 0;
+}
+
+bool8 sub_80985CC(void)
+{
+ if (gPokemonStorageSystemPtr->unk_08ad == 20)
+ return FALSE;
+ gPokemonStorageSystemPtr->unk_08a8++;
+ gPokemonStorageSystemPtr->unk_08aa--;
+ sub_809D034(BG_SCREEN_ADDR(15), 10, 0, gPokemonStorageSystemPtr->unk_00a8, 0, gPokemonStorageSystemPtr->unk_08a8, 12, gPokemonStorageSystemPtr->unk_08aa);
+ sub_809D16C(BG_SCREEN_ADDR(15), 10, gPokemonStorageSystemPtr->unk_08aa, 12, 1);
+ sub_80994A8(-8);
+ if (++gPokemonStorageSystemPtr->unk_08ad == 20)
+ {
+ gUnknown_0203847C = 0;
+ sub_809954C();
+ party_compaction();
+ sub_809D034(BG_SCREEN_ADDR(15), 21, 0, gPokemonStorageSystemPtr->unk_00a8, 12, 0, 1, 2);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void sub_8098690(bool8 flag)
+{
+ if (flag)
+ sub_809D034(BG_SCREEN_ADDR(15), 21, 0, gPokemonStorageSystemPtr->unk_00a8, 12, 0, 9, 2);
+ else
+ sub_809D034(BG_SCREEN_ADDR(15), 21, 0, gPokemonStorageSystemPtr->unk_00a8, 12, 2, 9, 2);
+}
+
+void sub_80986E8(void)
+{
+ gPokemonStorageSystemPtr->unk_08af = 1;
+ gPokemonStorageSystemPtr->unk_08b0 = 30;
+ gPokemonStorageSystemPtr->unk_08b1 = 1;
+}
+
+void sub_8098710(void)
+{
+ if (gPokemonStorageSystemPtr->unk_08af)
+ {
+ gPokemonStorageSystemPtr->unk_08af = 0;
+ sub_8098690(TRUE);
+ }
+}
+
+void sub_8098734(void)
+{
+ if (gPokemonStorageSystemPtr->unk_08af && ++gPokemonStorageSystemPtr->unk_08b0 > 30)
+ {
+ gPokemonStorageSystemPtr->unk_08b0 = 0;
+ gPokemonStorageSystemPtr->unk_08b1 = gPokemonStorageSystemPtr->unk_08b1 ? FALSE : TRUE;
+ sub_8098690(gPokemonStorageSystemPtr->unk_08b1);
+ }
+}
+
+void sub_8098780(void)
+{
+ int i;
+
+ for (i = 1; i < PARTY_SIZE; i++)
+ {
+ u16 r1;
+ bool32 r0 = GetMonData(gPlayerParty + i, MON_DATA_SPECIES);
+ if (r0)
+ r0 = TRUE;
+ r1 = r0 ? 12 : 16;
+ sub_809D104(gPokemonStorageSystemPtr->unk_00a8, 7, (i - 1) * 3 + 1, gPokemonStorageSystemPtr->unk_00a8, r1, 4, 4, 3);
+ }
+}
+
+void sub_80987DC(void)
+{
+ sub_8098780();
+ sub_809D034(BG_SCREEN_ADDR(15), 10, 0, gPokemonStorageSystemPtr->unk_00a8, 0, 0, 12, 22);
+}
+
+void sub_809880C(void)
+{
+ gPokemonStorageSystemPtr->unk_08ae = 0;
+ PlaySE(SE_WIN_OPEN);
+ sub_80984E8();
+}
+
+bool8 sub_8098830(void)
+{
+ switch (gPokemonStorageSystemPtr->unk_08ae)
+ {
+ case 0:
+ if (!sub_8098520())
+ {
+ sub_809B068();
+ gPokemonStorageSystemPtr->unk_08ae++;
+ }
+ break;
+ case 1:
+ if (!sub_809AC00())
+ {
+ if (gPokemonStorageSystemPtr->unk_11f6)
+ BoxSetMosaic();
+ gPokemonStorageSystemPtr->unk_08ae++;
+ }
+ break;
+ case 2:
+ return FALSE;
+ }
+ return TRUE;
+}
+
+const struct StorageAction gPCStorageActionTexts[] = {
+ {PCText_ExitBox, 0},
+ {PCText_WhatYouDo, 0},
+ {PCText_PickATheme, 0},
+ {PCText_PickAWallpaper, 0},
+ {PCText_IsSelected, 1},
+ {PCText_JumpToWhichBox, 0},
+ {PCText_DepositInWhichBox, 0},
+ {PCText_WasDeposited, 1},
+ {PCText_BoxIsFull, 0},
+ {PCText_ReleasePoke, 0},
+ {PCText_WasReleased, 4},
+ {PCText_ByeBye, 6},
+ {PCText_MarkPoke, 0},
+ {PCText_LastPoke, 0},
+ {PCText_PartyFull, 0},
+ {PCText_HoldingPoke, 0},
+ {PCText_WhichOneWillTake, 0},
+ {PCText_CantReleaseEgg, 0},
+ {PCText_ContinueBox, 0},
+ {PCText_CameBack, 1},
+ {PCText_Worried, 0},
+ {PCText_Surprise, 0},
+ {PCText_PleaseRemoveMail, 0}
+};
+
+void PrintStorageActionText(u8 index) {
+ u8 *ptr;
+
+ Menu_DrawStdWindowFrame(10, 16, 29, 19);
+
+ switch (gPCStorageActionTexts[index].format)
+ {
+
+ case PC_TEXT_FMT_UNK_02:
+ ptr = StringCopy(gPokemonStorageSystemPtr->unk_2694, gPCStorageActionTexts[index].text);
+ ptr = StringCopy(ptr, gPokemonStorageSystemPtr->unk_11fa);
+ break;
+
+ case PC_TEXT_FMT_UNK_05:
+ ptr = StringCopy(gPokemonStorageSystemPtr->unk_2694, gPCStorageActionTexts[index].text);
+ ptr = StringCopy(ptr, gPokemonStorageSystemPtr->unk_26e4);
+ break;
+
+ case PC_TEXT_FMT_MON_NAME:
+ // {var} + " is selected."
+ ptr = StringCopy(gPokemonStorageSystemPtr->unk_2694, gPokemonStorageSystemPtr->unk_11fa);
+ ptr = StringCopy(ptr, gPCStorageActionTexts[index].text);
+ break;
+
+ case PC_TEXT_FMT_MON_NAME_2:
+ // {var} + " was released."
+ ptr = StringCopy(gPokemonStorageSystemPtr->unk_2694, gPokemonStorageSystemPtr->unk_26e4);
+#if ENGLISH
+ ptr = StringCopy(ptr, gPCStorageActionTexts[index].text);
+#elif GERMAN
+ ptr = de_sub_8073174(gPokemonStorageSystemPtr->unk_2694, gPCStorageActionTexts[index].text);
+#endif
+ break;
+
+ case PC_TEXT_FMT_UNK_03:
+ {
+ const u8 *stringLength;
+ const u8 *text;
+
+ text = gPCStorageActionTexts[index].text;
+ stringLength = &text[StringLength(text)] + 1;
+
+ ptr = StringCopy(gPokemonStorageSystemPtr->unk_2694, gPCStorageActionTexts[index].text);
+ ptr = StringCopy(ptr, gPokemonStorageSystemPtr->unk_11fa);
+ ptr = StringCopy(ptr, stringLength);
+ }
+ break;
+
+ case PC_TEXT_FMT_MON_NAME_AFTER_EXCL_MARK:
+ // "Bye-bye, ".substr(0, -1) + {var} + "Bye-bye, !".substr(-1, 1)
+ {
+ const u8 *stringLength;
+ const u8 *text;
+
+ text = gPCStorageActionTexts[index].text;
+ stringLength = &text[StringLength(text)] - 1;
+
+ ptr = StringCopy(gPokemonStorageSystemPtr->unk_2694, gPCStorageActionTexts[index].text);
+ ptr = StringCopy(ptr - 1, gPokemonStorageSystemPtr->unk_26e4);
+ ptr = StringCopy(ptr, stringLength);
+ }
+ break;
+
+ case PC_TEXT_FMT_NORMAL:
+ default:
+ ptr = StringCopy(gPokemonStorageSystemPtr->unk_2694, gPCStorageActionTexts[index].text);
+ break;
+ }
+
+ while (ptr < gPokemonStorageSystemPtr->unk_26a6)
+ {
+ ptr[0] = CHAR_SPACE;
+ ptr++;
+ }
+
+ ptr[0] = EOS;
+ Menu_PrintText(gPokemonStorageSystemPtr->unk_2694, 11, 17);
+}
+
+const struct OamData gOamData_83B6EAC = {
+ .size = 3
+};
+
+const struct OamData gOamData_83B6EB4 = {
+ .shape = ST_OAM_H_RECTANGLE
+};
+
+const union AnimCmd gSpriteAnim_83B6EBC[] = {
+ ANIMCMD_FRAME(0, 5),
+ ANIMCMD_END
+};
+
+const union AnimCmd gSpriteAnim_83B6EC4[] = {
+ ANIMCMD_FRAME(2, 8),
+ ANIMCMD_FRAME(4, 8),
+ ANIMCMD_FRAME(6, 8),
+ ANIMCMD_JUMP(0)
+};
+
+const union AnimCmd gSpriteAnim_83B6ED4[] = {
+ ANIMCMD_FRAME(8, 5),
+ ANIMCMD_END
+};
+
+const union AnimCmd gSpriteAnim_83B6EDC[] = {
+ ANIMCMD_FRAME(10, 8),
+ ANIMCMD_FRAME( 4, 8),
+ ANIMCMD_FRAME(12, 8),
+ ANIMCMD_JUMP(0)
+};
+
+const union AnimCmd *const gSpriteAnimTable_83B6EEC[] = {
+ gSpriteAnim_83B6EBC,
+ gSpriteAnim_83B6EC4,
+ gSpriteAnim_83B6ED4,
+ gSpriteAnim_83B6EDC
+};
+
+const struct SpriteTemplate gSpriteTemplate_83B6EFC = {
+ 0x0005,
+ 0xdacd,
+ &gOamData_83B6EB4,
+ gSpriteAnimTable_83B6EEC,
+ NULL,
+ gDummySpriteAffineAnimTable,
+ SpriteCallbackDummy
+};
+
+void sub_8098A38(s8 a0)
+{
+ DisplayYesNoMenu(23, 10, 0);
+ Menu_MoveCursor(a0);
+}
+
+void sub_8098A5C(void)
+{
+ Menu_DestroyCursor();
+ Menu_EraseWindowRect(10, 16, 29, 19);
+ Menu_EraseWindowRect(23, 10, 29, 15);
+}
+
+void sub_8098A80(void)
+{
+ sub_809CDCC();
+ sub_809CDEC(12);
+ sub_809CDEC(13);
+ sub_809CDEC(14);
+ sub_809CDEC(15);
+ sub_809CE84();
+}
+
+void sub_8098AA8(u8 a0)
+{
+ sub_809CDCC();
+ switch (a0)
+ {
+ case 0:
+ sub_809CDEC(16);
+ sub_809CDEC(17);
+ sub_809CDEC(18);
+ sub_809CDEC(19);
+ break;
+ case 1:
+ sub_809CDEC(20);
+ sub_809CDEC(21);
+ sub_809CDEC(22);
+ sub_809CDEC(23);
+ break;
+ case 2:
+ sub_809CDEC(24);
+ sub_809CDEC(25);
+ sub_809CDEC(26);
+ sub_809CDEC(27);
+ break;
+ case 3:
+ sub_809CDEC(28);
+ sub_809CDEC(29);
+ sub_809CDEC(30);
+ sub_809CDEC(31);
+ break;
+ }
+ sub_809CE84();
+}
diff --git a/src/pokemon/pokemon_storage_system_3.c b/src/pokemon/pokemon_storage_system_3.c
new file mode 100644
index 000000000..da26c6fc5
--- /dev/null
+++ b/src/pokemon/pokemon_storage_system_3.c
@@ -0,0 +1,655 @@
+
+// Includes
+#include "global.h"
+#include "constants/species.h"
+#include "sprite.h"
+#include "trig.h"
+#include "pokemon_icon.h"
+#include "pokemon_storage_system.h"
+
+// Static type declarations
+
+// Static RAM declarations
+
+// Static ROM declarations
+
+static void sub_8098E68(struct Sprite *sprite);
+static void sub_8099388(struct Sprite *sprite, u16 a1);
+static void sub_80993F4(struct Sprite *sprite);
+static void sub_80999C4(struct Sprite *sprite);
+static struct Sprite *PSS_SpawnMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 priority, u8 subpriority);
+static void PSS_DestroyMonIconSprite(struct Sprite *sprite);
+
+// .rodata
+
+const struct OamData gOamData_83B6F2C;
+
+// .text
+
+u8 get_preferred_box(void)
+{
+ return gPokemonStorage.currentBox;
+}
+
+void ResetPSSMonIconSprites(void)
+{
+ u16 i;
+
+ sub_809D51C();
+ for (i = 0; i < 40; i++)
+ gPokemonStorageSystemPtr->unk_10d0[i] = 0;
+ for (i = 0; i < 40; i++)
+ gPokemonStorageSystemPtr->unk_1120[i] = 0;
+ for (i = 0; i < 6; i++)
+ gPokemonStorageSystemPtr->unk_1038[i] = NULL;
+ for (i = 0; i < 30; i++)
+ gPokemonStorageSystemPtr->unk_1050[i] = NULL;
+ gPokemonStorageSystemPtr->unk_1034 = NULL;
+ gPokemonStorageSystemPtr->unk_0d5c = 0;
+}
+
+void sub_8098BF0(void)
+{
+ u32 personality = GetMonData(&gPokemonStorageSystemPtr->unk_25b4, MON_DATA_PERSONALITY);
+ gPokemonStorageSystemPtr->unk_1034 = PSS_SpawnMonIconSprite(GetMonData(&gPokemonStorageSystemPtr->unk_25b4, MON_DATA_SPECIES2), personality, 0, 0, 1, 7);
+ gPokemonStorageSystemPtr->unk_1034->callback = sub_80999C4;
+}
+
+void SpawnBoxIconSprites(u8 boxId)
+{
+ struct BoxPokemon *box = gPokemonStorage.boxes[boxId];
+ u16 i;
+ u16 k = 0;
+ for (i = 0; i < 5; i++)
+ {
+ u16 j;
+ for (j = 0; j < 6; j++)
+ {
+ u16 species = GetBoxMonData(box, MON_DATA_SPECIES2);
+ if (species != SPECIES_NONE)
+ gPokemonStorageSystemPtr->unk_1050[k] = PSS_SpawnMonIconSprite(species, GetBoxMonData(box, MON_DATA_PERSONALITY), 24 * j + 0x64, 24 * i + 0x2c, 2, 18 - j);
+ else
+ gPokemonStorageSystemPtr->unk_1050[k] = NULL;
+ box++;
+ k++;
+ }
+ }
+}
+
+void sub_8098D20(u8 monId)
+{
+ struct BoxPokemon *mon = gPokemonStorage.boxes[get_preferred_box()] + monId;
+ u16 species = GetBoxMonData(mon, MON_DATA_SPECIES2);
+ if (species != SPECIES_NONE)
+ {
+ s16 x = 24 * (monId % 6) + 0x64;
+ s16 y = 24 * (monId / 6) + 0x2c;
+ gPokemonStorageSystemPtr->unk_1050[monId] = PSS_SpawnMonIconSprite(species, GetBoxMonData(mon, MON_DATA_PERSONALITY), x, y, 2, 18 - (monId % 6));
+ }
+}
+
+static void sub_8098DE0(s16 a0)
+{
+ u16 monId;
+ for (monId = 0; monId < 30; monId++)
+ {
+ if (gPokemonStorageSystemPtr->unk_1050[monId])
+ {
+ gPokemonStorageSystemPtr->unk_1050[monId]->data[2] = a0;
+ gPokemonStorageSystemPtr->unk_1050[monId]->data[4] = 1;
+ gPokemonStorageSystemPtr->unk_1050[monId]->callback = sub_8098E68;
+ }
+ }
+}
+
+static void sub_8098E24(struct Sprite *sprite)
+{
+ if (sprite->data[1] != 0)
+ {
+ sprite->data[1]--;
+ sprite->pos1.x += sprite->data[2];
+ }
+ else
+ {
+ gPokemonStorageSystemPtr->unk_1178--;
+ sprite->pos1.x = sprite->data[3];
+ sprite->callback = SpriteCallbackDummy;
+ }
+}
+
+static void sub_8098E68(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] < 0x45 || sprite->data[5] > 0xfb)
+ sprite->callback = SpriteCallbackDummy;
+ }
+}
+
+static void sub_8098EA0(u8 col)
+{
+ u16 i;
+
+ for (i = 0; i < 5; i++)
+ {
+ if (gPokemonStorageSystemPtr->unk_1050[col])
+ {
+ PSS_DestroyMonIconSprite(gPokemonStorageSystemPtr->unk_1050[col]);
+ gPokemonStorageSystemPtr->unk_1050[col] = NULL;
+ }
+ col += 6;
+ }
+}
+
+static u8 sub_8098EE0(u8 col, u16 a1, s16 a2)
+{
+ u16 i;
+ u16 x;
+ u16 y;
+ u8 count;
+ u8 x1;
+ u16 curX;
+
+ y = 0x2c;
+ x = 24 * col + 0x64;
+ curX = x - (a1 + 1) * a2;
+ x1 = 18 - col;
+ count = 0;
+
+ for (i = 0; i < 5; i++)
+ {
+ u16 species = GetBoxMonData(gPokemonStorage.boxes[gPokemonStorageSystemPtr->unk_117d] + col, MON_DATA_SPECIES2);
+ if (species != SPECIES_NONE)
+ {
+ gPokemonStorageSystemPtr->unk_1050[col] = PSS_SpawnMonIconSprite(species, GetBoxMonData(gPokemonStorage.boxes[gPokemonStorageSystemPtr->unk_117d] + col, MON_DATA_PERSONALITY), curX, y, 2, x1);
+ if (gPokemonStorageSystemPtr->unk_1050[col])
+ {
+ gPokemonStorageSystemPtr->unk_1050[col]->data[1] = a1;
+ gPokemonStorageSystemPtr->unk_1050[col]->data[2] = a2;
+ gPokemonStorageSystemPtr->unk_1050[col]->data[3] = x;
+ gPokemonStorageSystemPtr->unk_1050[col]->callback = sub_8098E24;
+ count++;
+ }
+ }
+ col += 6;
+ y += 24;
+ }
+ return count;
+}
+
+void sub_809900C(u8 a0, s8 a1)
+{
+ gPokemonStorageSystemPtr->unk_117c = 0;
+ gPokemonStorageSystemPtr->unk_117d = a0;
+ gPokemonStorageSystemPtr->unk_117b = a1;
+ gPokemonStorageSystemPtr->unk_1172 = 32;
+ gPokemonStorageSystemPtr->unk_1176 = -6 * a1;
+ gPokemonStorageSystemPtr->unk_1178 = 0;
+ if (a1 > 0)
+ gPokemonStorageSystemPtr->unk_117a = 0;
+ else
+ gPokemonStorageSystemPtr->unk_117a = 5;
+ gPokemonStorageSystemPtr->unk_1174 = 24 * gPokemonStorageSystemPtr->unk_117a + 0x64;
+ sub_8098DE0(gPokemonStorageSystemPtr->unk_1176);
+}
+
+bool8 sub_80990AC(void)
+{
+ if (gPokemonStorageSystemPtr->unk_1172)
+ gPokemonStorageSystemPtr->unk_1172--;
+ switch (gPokemonStorageSystemPtr->unk_117c)
+ {
+ case 0:
+ gPokemonStorageSystemPtr->unk_1174 += gPokemonStorageSystemPtr->unk_1176;
+ if (gPokemonStorageSystemPtr->unk_1174 < 0x41 || gPokemonStorageSystemPtr->unk_1174 > 0xfb)
+ {
+ sub_8098EA0(gPokemonStorageSystemPtr->unk_117a);
+ gPokemonStorageSystemPtr->unk_1174 += 24 * gPokemonStorageSystemPtr->unk_117b;
+ gPokemonStorageSystemPtr->unk_117c++;
+ }
+ break;
+ case 1:
+ gPokemonStorageSystemPtr->unk_1174 += gPokemonStorageSystemPtr->unk_1176;
+ gPokemonStorageSystemPtr->unk_1178 += sub_8098EE0(gPokemonStorageSystemPtr->unk_117a, gPokemonStorageSystemPtr->unk_1172, gPokemonStorageSystemPtr->unk_1176);
+ if ((gPokemonStorageSystemPtr->unk_117b > 0 && gPokemonStorageSystemPtr->unk_117a == 5) || (gPokemonStorageSystemPtr->unk_117b < 0 && gPokemonStorageSystemPtr->unk_117a == 0))
+ {
+ gPokemonStorageSystemPtr->unk_117c++;
+ }
+ else
+ {
+ gPokemonStorageSystemPtr->unk_117a += gPokemonStorageSystemPtr->unk_117b;
+ gPokemonStorageSystemPtr->unk_117c = 0;
+ }
+ break;
+ case 2:
+ if (gPokemonStorageSystemPtr->unk_1178 == 0)
+ {
+ gPokemonStorageSystemPtr->unk_1172++;
+ return FALSE;
+ }
+ break;
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void sub_8099200(bool8 a0)
+{
+ u16 count;
+ u16 i;
+ u16 species = GetMonData(gPlayerParty + 0, MON_DATA_SPECIES2);
+ u32 personality = GetMonData(gPlayerParty + 0, MON_DATA_PERSONALITY);
+ gPokemonStorageSystemPtr->unk_1038[0] = PSS_SpawnMonIconSprite(species, personality, 0x68, 0x40, 1, 11);
+ 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);
+ gPokemonStorageSystemPtr->unk_1038[i] = PSS_SpawnMonIconSprite(species, personality, 0x98, (i - 1) * 24 + 0x10, 1, 11);
+ count++;
+ }
+ else
+ {
+ gPokemonStorageSystemPtr->unk_1038[i] = NULL;
+ }
+ }
+ if (!a0)
+ {
+ for (i = 0; i < count; i++)
+ {
+ // this routine assumes party_compaction has been called
+ gPokemonStorageSystemPtr->unk_1038[i]->pos1.y -= 0xa0;
+ gPokemonStorageSystemPtr->unk_1038[i]->invisible = TRUE;
+ }
+ }
+}
+
+void sub_8099310(void)
+{
+ u16 i;
+ u16 count;
+
+ gPokemonStorageSystemPtr->unk_1171 = 0;
+ for (i = 0, count = 0; i < PARTY_SIZE; i++)
+ {
+ if (gPokemonStorageSystemPtr->unk_1038[i])
+ {
+ if (i != count)
+ {
+ sub_8099388(gPokemonStorageSystemPtr->unk_1038[i], count);
+ gPokemonStorageSystemPtr->unk_1038[i] = NULL;
+ gPokemonStorageSystemPtr->unk_1171++;
+ }
+ count++;
+ }
+ }
+}
+
+u8 sub_8099374(void)
+{
+ return gPokemonStorageSystemPtr->unk_1171;
+}
+
+static void sub_8099388(struct Sprite *sprite, u16 a1)
+{
+ s16 r3;
+ s16 r4;
+
+ sprite->data[1] = a1;
+ if (a1 == 0)
+ {
+ r3 = 0x68;
+ r4 = 0x40;
+ }
+ else
+ {
+ r3 = 0x98;
+ r4 = 24 * (a1 - 1) + 0x10;
+ }
+ sprite->data[2] = sprite->pos1.x << 3;
+ sprite->data[3] = sprite->pos1.y << 3;
+ sprite->data[4] = (r3 * 8 - sprite->data[2]) / 8;
+ sprite->data[5] = (r4 * 8 - sprite->data[3]) / 8;
+ sprite->data[6] = 8;
+ sprite->callback = sub_80993F4;
+}
+
+static void sub_80993F4(struct Sprite *sprite)
+{
+ if (sprite->data[6])
+ {
+ sprite->data[2] += sprite->data[4];
+ sprite->data[3] += sprite->data[5];
+ sprite->pos1.x = sprite->data[2] >> 3;
+ sprite->pos1.y = sprite->data[3] >> 3;
+ sprite->data[6]--;
+ }
+ else
+ {
+ if (sprite->data[1] == 0)
+ {
+ sprite->pos1.x = 0x68;
+ sprite->pos1.y = 0x40;
+ }
+ else
+ {
+ sprite->pos1.x = 0x98;
+ sprite->pos1.y = (sprite->data[1] - 1) * 24 + 0x10;
+ }
+ sprite->callback = SpriteCallbackDummy;
+ gPokemonStorageSystemPtr->unk_1038[sprite->data[1]] = sprite;
+ gPokemonStorageSystemPtr->unk_1171--;
+ }
+}
+
+void sub_8099480(void)
+{
+ if (gPokemonStorageSystemPtr->unk_1034)
+ {
+ PSS_DestroyMonIconSprite(gPokemonStorageSystemPtr->unk_1034);
+ gPokemonStorageSystemPtr->unk_1034 = NULL;
+ }
+}
+
+void sub_80994A8(s16 y)
+{
+ u16 i;
+
+ for (i = 0; i < PARTY_SIZE; i++)
+ {
+ if (gPokemonStorageSystemPtr->unk_1038[i])
+ {
+ s16 yy;
+ gPokemonStorageSystemPtr->unk_1038[i]->pos1.y += y;
+ yy = gPokemonStorageSystemPtr->unk_1038[i]->pos1.y + gPokemonStorageSystemPtr->unk_1038[i]->pos2.y + gPokemonStorageSystemPtr->unk_1038[i]->centerToCornerVecY;
+ if (yy < -0x10 || yy > 0xb0)
+ gPokemonStorageSystemPtr->unk_1038[i]->invisible = TRUE;
+ else
+ gPokemonStorageSystemPtr->unk_1038[i]->invisible = FALSE;
+ }
+ }
+}
+
+void sub_8099520(u8 a0)
+{
+ if (gPokemonStorageSystemPtr->unk_1038[a0])
+ {
+ PSS_DestroyMonIconSprite(gPokemonStorageSystemPtr->unk_1038[a0]);
+ gPokemonStorageSystemPtr->unk_1038[a0] = NULL;
+ }
+}
+
+void sub_809954C(void)
+{
+ u16 i;
+
+ for (i = 0; i < PARTY_SIZE; i++)
+ {
+ if (gPokemonStorageSystemPtr->unk_1038[i])
+ {
+ PSS_DestroyMonIconSprite(gPokemonStorageSystemPtr->unk_1038[i]);
+ gPokemonStorageSystemPtr->unk_1038[i] = NULL;
+ }
+ }
+}
+
+void sub_8099584(u8 a0, u8 a1)
+{
+ if (a0 == 0)
+ {
+ gPokemonStorageSystemPtr->unk_1034 = gPokemonStorageSystemPtr->unk_1038[a1];
+ gPokemonStorageSystemPtr->unk_1038[a1] = NULL;
+ }
+ else if (a0 == 1)
+ {
+ gPokemonStorageSystemPtr->unk_1034 = gPokemonStorageSystemPtr->unk_1050[a1];
+ gPokemonStorageSystemPtr->unk_1050[a1] = NULL;
+ }
+ else
+ {
+ return;
+ }
+ gPokemonStorageSystemPtr->unk_1034->callback = sub_80999C4;
+ gPokemonStorageSystemPtr->unk_1034->oam.priority = 1;
+ gPokemonStorageSystemPtr->unk_1034->subpriority = 7;
+}
+
+void sub_809960C(u8 a0, u8 a1)
+{
+ if (a0 == 14)
+ {
+ gPokemonStorageSystemPtr->unk_1038[a1] = gPokemonStorageSystemPtr->unk_1034;
+ gPokemonStorageSystemPtr->unk_1038[a1]->oam.priority = 1;
+ gPokemonStorageSystemPtr->unk_1038[a1]->subpriority = 11;
+ }
+ else
+ {
+ gPokemonStorageSystemPtr->unk_1050[a1] = gPokemonStorageSystemPtr->unk_1034;
+ gPokemonStorageSystemPtr->unk_1050[a1]->oam.priority = 2;
+ gPokemonStorageSystemPtr->unk_1050[a1]->subpriority = 18 - (a1 % 6);
+ }
+ gPokemonStorageSystemPtr->unk_1034->callback = SpriteCallbackDummy;
+ gPokemonStorageSystemPtr->unk_1034 = NULL;
+}
+
+void sub_80996B0(u8 a0, u8 a1)
+{
+ if (a0 == 14)
+ gPokemonStorageSystemPtr->unk_10c8 = gPokemonStorageSystemPtr->unk_1038 + a1;
+ else
+ gPokemonStorageSystemPtr->unk_10c8 = gPokemonStorageSystemPtr->unk_1050 + a1;
+ gPokemonStorageSystemPtr->unk_1034->callback = SpriteCallbackDummy;
+ gPokemonStorageSystemPtr->unk_1170 = 0;
+}
+
+bool8 sub_809971C(void)
+{
+ if (gPokemonStorageSystemPtr->unk_1170 == 16)
+ return FALSE;
+ gPokemonStorageSystemPtr->unk_1170++;
+ if (gPokemonStorageSystemPtr->unk_1170 & 1)
+ {
+ (*gPokemonStorageSystemPtr->unk_10c8)->pos1.y--;
+ gPokemonStorageSystemPtr->unk_1034->pos1.y++;
+ }
+ (*gPokemonStorageSystemPtr->unk_10c8)->pos2.x = gSineTable[gPokemonStorageSystemPtr->unk_1170 * 8] / 16;
+ gPokemonStorageSystemPtr->unk_1034->pos2.x = -(gSineTable[gPokemonStorageSystemPtr->unk_1170 * 8] / 16);
+ if (gPokemonStorageSystemPtr->unk_1170 == 8)
+ {
+ gPokemonStorageSystemPtr->unk_1034->oam.priority = (*gPokemonStorageSystemPtr->unk_10c8)->oam.priority;
+ gPokemonStorageSystemPtr->unk_1034->subpriority = (*gPokemonStorageSystemPtr->unk_10c8)->subpriority;
+ (*gPokemonStorageSystemPtr->unk_10c8)->oam.priority = 1;
+ (*gPokemonStorageSystemPtr->unk_10c8)->subpriority = 7;
+ }
+ if (gPokemonStorageSystemPtr->unk_1170 == 16)
+ {
+ struct Sprite *sprite = gPokemonStorageSystemPtr->unk_1034;
+ gPokemonStorageSystemPtr->unk_1034 = *(gPokemonStorageSystemPtr->unk_10c8);
+ (*gPokemonStorageSystemPtr->unk_10c8) = sprite;
+ gPokemonStorageSystemPtr->unk_1034->callback = sub_80999C4;
+ (*gPokemonStorageSystemPtr->unk_10c8)->callback = SpriteCallbackDummy;
+ }
+ return TRUE;
+}
+
+const union AffineAnimCmd *const gSpriteAffineAnimTable_83B6F5C[];
+
+void sub_809981C(u8 mode, u8 idx)
+{
+ switch (mode)
+ {
+ case 0:
+ gPokemonStorageSystemPtr->unk_10cc = gPokemonStorageSystemPtr->unk_1038 + idx;
+ break;
+ case 1:
+ gPokemonStorageSystemPtr->unk_10cc = gPokemonStorageSystemPtr->unk_1050 + idx;
+ break;
+ case 2:
+ gPokemonStorageSystemPtr->unk_10cc = &gPokemonStorageSystemPtr->unk_1034;
+ break;
+ default:
+ return;
+ }
+ if (*gPokemonStorageSystemPtr->unk_10cc)
+ {
+ InitSpriteAffineAnim(*gPokemonStorageSystemPtr->unk_10cc);
+ (*gPokemonStorageSystemPtr->unk_10cc)->oam.affineMode = ST_OAM_AFFINE_NORMAL;
+ (*gPokemonStorageSystemPtr->unk_10cc)->affineAnims = gSpriteAffineAnimTable_83B6F5C;
+ StartSpriteAffineAnim(*gPokemonStorageSystemPtr->unk_10cc, 0);
+ }
+}
+
+bool8 sub_80998D8(void)
+{
+ if (*gPokemonStorageSystemPtr->unk_10cc == NULL || (*gPokemonStorageSystemPtr->unk_10cc)->invisible)
+ return FALSE;
+ if ((*gPokemonStorageSystemPtr->unk_10cc)->affineAnimEnded)
+ {
+ (*gPokemonStorageSystemPtr->unk_10cc)->invisible = TRUE;
+ }
+ return TRUE;
+}
+
+void sub_8099920(void)
+{
+ if (*gPokemonStorageSystemPtr->unk_10cc)
+ {
+ FreeOamMatrix((*gPokemonStorageSystemPtr->unk_10cc)->oam.matrixNum);
+ PSS_DestroyMonIconSprite(*gPokemonStorageSystemPtr->unk_10cc);
+ *gPokemonStorageSystemPtr->unk_10cc = NULL;
+ }
+}
+
+void sub_8099958(void)
+{
+ if (*gPokemonStorageSystemPtr->unk_10cc)
+ {
+ (*gPokemonStorageSystemPtr->unk_10cc)->invisible = FALSE;
+ StartSpriteAffineAnim(*gPokemonStorageSystemPtr->unk_10cc, 1);
+ }
+}
+
+bool8 sub_8099990(void)
+{
+ if (gPokemonStorageSystemPtr->unk_10cc == NULL)
+ return FALSE;
+ if ((*gPokemonStorageSystemPtr->unk_10cc)->affineAnimEnded)
+ gPokemonStorageSystemPtr->unk_10cc = NULL;
+ return TRUE;
+}
+
+static void sub_80999C4(struct Sprite *sprite)
+{
+ sprite->pos1.x = gPokemonStorageSystemPtr->unk_11c0->pos1.x;
+ sprite->pos1.y = gPokemonStorageSystemPtr->unk_11c0->pos1.y + gPokemonStorageSystemPtr->unk_11c0->pos2.y + 4;
+}
+
+static u16 PSS_LoadSpeciesIconGfx(u16 a0)
+{
+ u16 i;
+ u16 retval;
+
+ for (i = 0; i < 40; i++)
+ {
+ if (gPokemonStorageSystemPtr->unk_1120[i] == a0)
+ break;
+ }
+ if (i == 40)
+ {
+ for (i = 0; i < 40; i++)
+ {
+ if (gPokemonStorageSystemPtr->unk_1120[i] == 0)
+ break;
+ }
+ }
+ if (i != 40)
+ {
+ gPokemonStorageSystemPtr->unk_1120[i] = a0;
+ gPokemonStorageSystemPtr->unk_10d0[i]++;
+ retval = i * 16;
+ CpuCopy32(gMonIconTable[a0], BG_CHAR_ADDR(4) + 32 * retval, 0x200);
+ return retval;
+ }
+ return 0xFFFF;
+}
+
+static void PSS_ForgetSpeciesIcon(u16 a0)
+{
+ u16 i;
+
+ for (i = 0; i < 40; i++)
+ {
+ if (gPokemonStorageSystemPtr->unk_1120[i] == a0)
+ {
+ if (--gPokemonStorageSystemPtr->unk_10d0[i] == 0)
+ gPokemonStorageSystemPtr->unk_1120[i] = 0;
+ break;
+ }
+ }
+}
+
+static struct Sprite *PSS_SpawnMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 priority, u8 subpriority)
+{
+ struct SpriteTemplate template = {
+ 0x000f,
+ 0xdac0,
+ &gOamData_83B6F2C,
+ gDummySpriteAnimTable,
+ NULL,
+ gDummySpriteAffineAnimTable,
+ SpriteCallbackDummy
+ };
+ u16 tileNum;
+ u8 spriteId;
+
+ species = mon_icon_convert_unown_species_id(species, personality);
+ template.paletteTag = 0xdac0 + gMonIconPaletteIndices[species];
+ tileNum = PSS_LoadSpeciesIconGfx(species);
+ if (tileNum == 0xFFFF)
+ return NULL;
+ spriteId = CreateSprite(&template, x, y, subpriority);
+ if (spriteId == MAX_SPRITES)
+ {
+ PSS_ForgetSpeciesIcon(species);
+ return NULL;
+ }
+ gSprites[spriteId].oam.tileNum = tileNum;
+ gSprites[spriteId].oam.priority = priority;
+ gSprites[spriteId].data[0] = species;
+ return gSprites + spriteId;
+}
+
+static void PSS_DestroyMonIconSprite(struct Sprite *sprite)
+{
+ PSS_ForgetSpeciesIcon(sprite->data[0]);
+ DestroySprite(sprite);
+}
+
+const struct OamData gOamData_83B6F2C = {
+ .size = 2
+};
+
+const union AffineAnimCmd gSpriteAffineAnim_83B6F34[] = {
+ AFFINEANIMCMD_FRAME(-2, -2, 0, 120),
+ AFFINEANIMCMD_END
+};
+
+const union AffineAnimCmd gSpriteAffineAnim_83B6F44[] = {
+ AFFINEANIMCMD_FRAME(16, 16, 0, 0),
+ AFFINEANIMCMD_FRAME(16, 16, 0, 15),
+ AFFINEANIMCMD_END
+};
+
+const union AffineAnimCmd *const gSpriteAffineAnimTable_83B6F5C[] = {
+ gSpriteAffineAnim_83B6F34,
+ gSpriteAffineAnim_83B6F44
+};
diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c
new file mode 100644
index 000000000..f7a008db2
--- /dev/null
+++ b/src/pokemon/pokemon_storage_system_4.c
@@ -0,0 +1,23 @@
+
+// Includes
+#include "global.h"
+#include "pokemon_storage_system.h"
+
+// Static type declarations
+
+// Static RAM declarations
+
+EWRAM_DATA struct Pokemon gUnknown_02038480 = {};
+EWRAM_DATA u8 gUnknown_020384E4 = 0;
+EWRAM_DATA u8 gUnknown_020384E5 = 0;
+EWRAM_DATA u8 gUnknown_020384E6 = 0;
+EWRAM_DATA u8 gUnknown_020384E7 = 0;
+EWRAM_DATA u8 gUnknown_020384E8 = 0;
+EWRAM_DATA u8 gUnknown_020384E9 = 0;
+EWRAM_DATA u16 gUnknown_020384EA = 0;
+
+// Static ROM declarations
+
+// .rodata
+
+// .text
diff --git a/src/pokemon/pokemon_storage_system_5.c b/src/pokemon/pokemon_storage_system_5.c
new file mode 100644
index 000000000..b7c3d42f5
--- /dev/null
+++ b/src/pokemon/pokemon_storage_system_5.c
@@ -0,0 +1,16 @@
+
+// Includes
+#include "global.h"
+#include "pokemon_storage_system.h"
+
+// Static type declarations
+
+// Static RAM declarations
+
+EWRAM_DATA struct UnkStruct_2000020 *gUnknown_020384EC = NULL;
+
+// Static ROM declarations
+
+// .rodata
+
+// .text
diff --git a/src/pokemon/pokemon_summary_screen.c b/src/pokemon/pokemon_summary_screen.c
index bf8306fc0..ce83ad070 100644
--- a/src/pokemon/pokemon_summary_screen.c
+++ b/src/pokemon/pokemon_summary_screen.c
@@ -146,7 +146,6 @@ extern const u8 gUnknown_08E74E88[];
extern const u8 gUnknown_08E73508[];
extern const u8 gStatusScreen_Gfx[];
extern const u8 gFontDefaultPalette[];
-extern const u8 gUnknownPalette_81E6692[];
extern const u8 gAbilityNames[][13];
extern const u8 * const gAbilityDescriptions[];
extern const u8 * const gContestEffectStrings[];
@@ -940,21 +939,21 @@ static bool8 LoadPokemonSummaryScreenGraphics(void)
static void sub_809E044(void)
{
- LoadPalette(&gUnknownPalette_81E6692[28], 129, 2);
- LoadPalette(&gUnknownPalette_81E6692[30], 136, 2);
- LoadPalette(&gUnknownPalette_81E6692[28], 143, 2);
- LoadPalette(&gUnknownPalette_81E6692[30], 137, 2);
- LoadPalette(&gUnknownPalette_81E6692[12], 209, 4);
- LoadPalette(&gUnknownPalette_81E6692[20], 211, 4);
- LoadPalette(&gUnknownPalette_81E6692[28], 213, 4);
- LoadPalette(&gUnknownPalette_81E6692[12], 215, 4);
- LoadPalette(&gUnknownPalette_81E6692[8], 217, 4);
- LoadPalette(&gUnknownPalette_81E6692[16], 219, 4);
- LoadPalette(&gUnknownPalette_81E6692[4], 221, 2);
- LoadPalette(&gUnknownPalette_81E6692[6], 222, 2);
- LoadPalette(&gUnknownPalette_81E6692[2], 223, 2);
+ LoadPalette(gUnknownPalette_81E6692 + 14, 129, 2);
+ LoadPalette(gUnknownPalette_81E6692 + 15, 136, 2);
+ LoadPalette(gUnknownPalette_81E6692 + 14, 143, 2);
+ LoadPalette(gUnknownPalette_81E6692 + 15, 137, 2);
+ LoadPalette(gUnknownPalette_81E6692 + 6, 209, 4);
+ LoadPalette(gUnknownPalette_81E6692 + 10, 211, 4);
+ LoadPalette(gUnknownPalette_81E6692 + 14, 213, 4);
+ LoadPalette(gUnknownPalette_81E6692 + 6, 215, 4);
+ LoadPalette(gUnknownPalette_81E6692 + 4, 217, 4);
+ LoadPalette(gUnknownPalette_81E6692 + 8, 219, 4);
+ LoadPalette(gUnknownPalette_81E6692 + 2, 221, 2);
+ LoadPalette(gUnknownPalette_81E6692 + 3, 222, 2);
+ LoadPalette(gUnknownPalette_81E6692 + 1, 223, 2);
LoadPalette(gFontDefaultPalette, 240, 32);
- LoadPalette(&gUnknownPalette_81E6692[6], 249, 2);
+ LoadPalette(gUnknownPalette_81E6692 + 3, 249, 2);
}
static void SummaryScreenExit(u8 taskId)
diff --git a/src/pokenav_before.c b/src/pokenav_before.c
index b31be2ce1..600c5aba8 100644
--- a/src/pokenav_before.c
+++ b/src/pokenav_before.c
@@ -102,7 +102,6 @@ extern const u16 gPokenavConditionSearch2_Pal[];
extern const u8 gUnknown_083E0334[];
extern const u16 gUnknown_083E02B4[];
extern const u8 gPokenavConditionSearch2_Gfx[];
-extern const u8 gUnknownPalette_81E6692[];
extern const u8 gUnknown_083E0254[];
extern const u8 gUnknown_08E9FEB4[];
extern const u8 gUnknown_083E01AC[];
diff --git a/src/scene/hall_of_fame.c b/src/scene/hall_of_fame.c
index 303dcf3e0..bfa0d1705 100644
--- a/src/scene/hall_of_fame.c
+++ b/src/scene/hall_of_fame.c
@@ -18,6 +18,9 @@
#include "random.h"
#include "scanline_effect.h"
#include "trig.h"
+#include "hof_pc.h"
+#include "credits.h"
+#include "pc_screen_effect.h"
#include "ewram.h"
static EWRAM_DATA u32 sUnknown_0203931C = 0;
@@ -88,15 +91,6 @@ static u32 HallOfFame_LoadPokemonPic(u16 species, s16 posX, s16 posY, u16 pokeID
static u32 HallOfFame_LoadTrainerPic(u16 trainerPicID, s16 posX, s16 posY, u16 a3);
static bool8 sub_81438C4(void);
-// functions from different files
-void sub_81439D0(void);
-void sub_80C5CD4(void*); // ?
-void sub_80C5E38(void*); // ?
-bool8 sub_80C5DCC(void);
-bool8 sub_80C5F98(void);
-void ReturnFromHallOfFamePC(void);
-u16 SpeciesToPokedexNum(u16 species);
-
// data and gfx
static const struct CompressedSpriteSheet sHallOfFame_ConfettiSpriteSheet =
@@ -130,9 +124,9 @@ static const s16 sHallOfFame_MonsHalfTeamPositions[3][4] =
{-41, 214, 184, 64}
};
-static const struct HallofFameMon sDummyFameMon =
-{
- 0x3EA03EA, 0, 0, 0, {0}
+static const struct PCScreenEffectStruct sPCScreenEffectTemplate = {
+ .tileTag = 0x3ea,
+ .paletteTag = 0x3ea
};
static const u8 sUnused2[6] = {2, 1, 3, 6, 4, 5};
@@ -800,20 +794,15 @@ void sub_81428CC(void)
}
break;
case 3:
- {
- struct HallofFameMons* fameMons;
-
- REG_BLDCNT = 0;
- REG_BLDALPHA = 0;
- REG_BLDY = 0;
- sub_81435B8();
+ REG_BLDCNT = 0;
+ REG_BLDALPHA = 0;
+ REG_BLDY = 0;
+ sub_81435B8();
- fameMons = eHallOfFameMons1;
- fameMons->mons[0] = sDummyFameMon;
+ eHOFPCScreenEffect = sPCScreenEffectTemplate;
- sub_80C5CD4(fameMons);
- gMain.state++;
- }
+ sub_80C5CD4(&eHOFPCScreenEffect);
+ gMain.state++;
break;
case 4:
AnimateSprites();
@@ -1022,12 +1011,9 @@ static void sub_8142DF4(u8 taskID)
static void sub_8142F78(u8 taskID)
{
- struct HallofFameMons* fameMons;
-
CpuSet(gPlttBufferFaded, gPlttBufferUnfaded, 0x200);
- fameMons = eHallOfFameMons1;
- fameMons->mons[0] = sDummyFameMon;
- sub_80C5E38(fameMons);
+ eHOFPCScreenEffect = sPCScreenEffectTemplate;
+ sub_80C5E38(&eHOFPCScreenEffect);
gTasks[taskID].func = sub_8142FCC;
}