diff --git a/generated/text_banks.txt b/generated/text_banks.txt index 2830e1bd42..64eb6fa872 100644 --- a/generated/text_banks.txt +++ b/generated/text_banks.txt @@ -16,7 +16,7 @@ TEXT_BANK_UNK_0014 TEXT_BANK_UNK_0015 TEXT_BANK_UNK_0016 TEXT_BANK_UNK_0017 -TEXT_BANK_UNK_0018 +TEXT_BANK_POKEMON_STORAGE_SYSTEM TEXT_BANK_UNK_0019 TEXT_BANK_UNK_0020 TEXT_BANK_FRONTIER_TRAINER_NAMES diff --git a/include/pokemon.h b/include/pokemon.h index 634eca6b87..3601849d89 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -826,7 +826,7 @@ BOOL sub_02078838(Pokemon *mon); BOOL sub_0207884C(BoxPokemon *boxMon, TrainerInfo *param1, int heapID); int sub_020788D0(int param0); void sub_0207893C(Pokemon *mon); -void sub_0207896C(BoxPokemon *boxMon); +void RestoreBoxedPokemonPP(BoxPokemon *boxMon); /** * @brief Load the animation frames for a given species and a client type diff --git a/include/unk_020797C8.h b/include/unk_020797C8.h index 5127423087..e07520c1d7 100644 --- a/include/unk_020797C8.h +++ b/include/unk_020797C8.h @@ -10,30 +10,31 @@ #define MAX_PC_ROWS 5 #define MAX_PC_COLS 6 #define MAX_MONS_PER_BOX (MAX_PC_ROWS * MAX_PC_COLS) +#define BOX1_TEXT_BANK_ENTRYID 6 -void PCBoxes_Init(PCBoxes *param0); +void PCBoxes_Init(PCBoxes *pcBoxes); u32 PCBoxes_SaveSize(void); -BOOL sub_02079868(PCBoxes *param0, BoxPokemon *boxMon); -BOOL sub_020798A0(PCBoxes *param0, u32 param1, BoxPokemon *boxMon); -BOOL sub_02079914(PCBoxes *param0, u32 param1, u32 param2, BoxPokemon *boxMon); -void sub_02079968(PCBoxes *param0, u32 param1, u32 param2); -u32 sub_0207999C(const PCBoxes *param0); -u32 PCBoxes_FirstEmptyBox(const PCBoxes *param0); -BOOL sub_020799F0(const PCBoxes *param0, int *param1, int *param2); -u32 sub_02079A50(const PCBoxes *param0); -void sub_02079A94(PCBoxes *param0, u32 param1); -u32 sub_02079AA8(const PCBoxes *param0, u32 param1); -void sub_02079AC4(PCBoxes *param0, u32 param1, u32 param2); -void sub_02079AF4(const PCBoxes *param0, u32 param1, Strbuf *param2); -void sub_02079B24(PCBoxes *param0, u32 param1, const Strbuf *param2); -u32 sub_02079B54(const PCBoxes *param0, u32 param1); -u32 sub_02079B98(const PCBoxes *param0, u32 param1); -u32 sub_02079BEC(const PCBoxes *param0); -u32 sub_02079C08(const PCBoxes *param0, u32 param1, u32 param2, int param3, void *param4); -void sub_02079C50(PCBoxes *param0, u32 param1, u32 param2, int param3, void *param4); -BoxPokemon *GetBoxedPokemonFrom(const PCBoxes *pcBoxes, u32 boxIndex, u32 pokemonBoxLocationIndex); -void sub_02079CD8(PCBoxes *param0, u32 param1); -BOOL sub_02079CFC(const PCBoxes *param0, u32 param1); -u32 sub_02079D20(const PCBoxes *param0); +BOOL StorePokemonInPc(PCBoxes *pcBoxes, BoxPokemon *boxMon); +BOOL StorePokemonInBox(PCBoxes *pcBoxes, u32 boxIndex, BoxPokemon *boxMon); +BOOL StorePokemonInPcAt(PCBoxes *pcBoxes, u32 boxIndex, u32 monPosInBox, BoxPokemon *boxMon); +void InitializeBoxedPokemonAt(PCBoxes *pcBoxes, u32 boxIndex, u32 monPosInBox); +u32 GetCurrentBoxId(const PCBoxes *pcBoxes); +u32 PCBoxes_FirstEmptyBox(const PCBoxes *pcBoxes); +BOOL GetNextAvailableBoxSpaceAfter(const PCBoxes *pcBoxes, int *boxIndexParam, int *monPosInBoxParam); +u32 GetBoxedPokemonCount(const PCBoxes *pcBoxes); +void SetCurrentBoxIndex(PCBoxes *pcBoxes, u32 boxIndex); +u32 sub_02079AA8(const PCBoxes *pcBoxes, u32 boxIndex); +void sub_02079AC4(PCBoxes *pcBoxes, u32 boxIndex, u32 param2); +void CopyBoxName(const PCBoxes *pcBoxes, u32 boxIndex, Strbuf *param2); +void RenameBox(PCBoxes *pcBoxes, u32 boxIndex, const Strbuf *newName); +u32 GetPokemonCountInBox(const PCBoxes *pcBoxes, u32 boxIndex); +u32 GetEggCountInBox(const PCBoxes *pcBoxes, u32 boxIndex); +u32 GetTotalBoxedEggCount(const PCBoxes *pcBoxes); +u32 GetBoxedPokemonData(const PCBoxes *pcBoxes, u32 boxIndex, u32 pokemonBoxLocationIndex, enum PokemonDataParam pokemonData, void *dest); +void SetBoxedPokemonDataWithSave(PCBoxes *pcBoxes, u32 boxIndex, u32 pokemonBoxLocationIndex, enum PokemonDataParam pokemonData, void *value); +BoxPokemon *GetBoxedPokemonFrom(const PCBoxes *pcBoxes, u32 boxIndex, u32 monPosInBox); +void sub_02079CD8(PCBoxes *pcBoxes, u32 param1); +BOOL sub_02079CFC(const PCBoxes *pcBoxes, u32 param1); +u32 sub_02079D20(const PCBoxes *pcBoxes); #endif // POKEPLATINUM_UNK_020797C8_H diff --git a/res/text/unk_0018.gmm b/res/text/pokemon_storage_system.gmm similarity index 100% rename from res/text/unk_0018.gmm rename to res/text/pokemon_storage_system.gmm diff --git a/src/battle/battle_script.c b/src/battle/battle_script.c index 989e2ebe07..c9efbe8b56 100644 --- a/src/battle/battle_script.c +++ b/src/battle/battle_script.c @@ -10957,10 +10957,10 @@ static void BattleScript_CatchMonTask(SysTask *param0, void *param1) int v29; v24 = ov16_0223E228(v2->battleSys); - v25 = sub_0207999C(v24); + v25 = GetCurrentBoxId(v24); v26 = PCBoxes_FirstEmptyBox(v24); - sub_02079A94(v24, v26); + SetCurrentBoxIndex(v24, v26); for (v27 = 0; v27 < LEARNED_MOVES_MAX; v27++) { v28 = Pokemon_GetValue(v3, MON_DATA_MOVE1_MAX_PP + v27, NULL); @@ -10971,7 +10971,7 @@ static void BattleScript_CatchMonTask(SysTask *param0, void *param1) ov16_0223F9A0(v2->battleSys, v1); } - sub_020798A0(v24, v26, Pokemon_GetBoxPokemon(v3)); + StorePokemonInBox(v24, v26, Pokemon_GetBoxPokemon(v3)); if (v2->seqNum == 22) { if (v25 == v26) { diff --git a/src/overlay019/ov19_021D0D80.c b/src/overlay019/ov19_021D0D80.c index e54aa06a1a..8a3526236a 100644 --- a/src/overlay019/ov19_021D0D80.c +++ b/src/overlay019/ov19_021D0D80.c @@ -860,7 +860,7 @@ static void ov19_021D1C84(UnkStruct_ov19_021D5DF8 *param0) param0->unk_12C.move = 0; param0->unk_12C.options = param0->unk_1A4; } else if (ov19_021D5E10(¶m0->unk_00) == 0) { - param0->unk_12C.monData = GetBoxedPokemonFrom(param0->unk_120, sub_0207999C(param0->unk_120), 0); + param0->unk_12C.monData = GetBoxedPokemonFrom(param0->unk_120, GetCurrentBoxId(param0->unk_120), 0); param0->unk_12C.dataType = SUMMARY_DATA_BOX_MON; param0->unk_12C.monMax = MAX_MONS_PER_BOX; param0->unk_12C.monIndex = ov19_021D5E24(¶m0->unk_00); @@ -1365,7 +1365,7 @@ static void ov19_021D27E8(UnkStruct_ov19_021D5DF8 *param0, u32 *param1) (*param1) = 2; } else { ov19_021D5D08(¶m0->unk_00, param0->unk_1BC.unk_05); - sub_02079A94(param0->unk_120, param0->unk_1BC.unk_05); + SetCurrentBoxIndex(param0->unk_120, param0->unk_1BC.unk_05); ov19_021D6594(param0->unk_114, 4); (*param1) = 2; } @@ -1588,14 +1588,14 @@ static void ov19_021D2B54(UnkStruct_ov19_021D5DF8 *param0, u32 *param1) case 3: ov19_021D5CE8(¶m0->unk_00); - sub_02079A94(param0->unk_120, ov19_021D5E68(¶m0->unk_00)); + SetCurrentBoxIndex(param0->unk_120, ov19_021D5E68(¶m0->unk_00)); ov19_021D6594(param0->unk_114, 4); *param1 = 5; break; case 4: ov19_021D5CBC(&(param0->unk_00)); - sub_02079A94(param0->unk_120, ov19_021D5E68(¶m0->unk_00)); + SetCurrentBoxIndex(param0->unk_120, ov19_021D5E68(¶m0->unk_00)); ov19_021D6594(param0->unk_114, 4); *param1 = 5; break; @@ -2345,18 +2345,18 @@ static void ov19_021D3B34(UnkStruct_ov19_021D5DF8 *param0, u32 *param1) if (ov19_021D6600(param0->unk_114, 3)) { ov19_021D64A0(param0->unk_114); Heap_Destroy(10); - sub_02079AF4(param0->unk_120, sub_0207999C(param0->unk_120), param0->unk_128->unk_18); + CopyBoxName(param0->unk_120, GetCurrentBoxId(param0->unk_120), param0->unk_128->unk_18); param0->unk_210 = OverlayManager_New(&Unk_020F2DAC, param0->unk_128, 9); (*param1)++; } break; case 2: if (OverlayManager_Exec(param0->unk_210)) { - u32 v0 = sub_0207999C(param0->unk_120); + u32 v0 = GetCurrentBoxId(param0->unk_120); OverlayManager_Free(param0->unk_210); Heap_Create(3, 10, 245760); - sub_02079B24(param0->unk_120, v0, param0->unk_128->unk_18); + RenameBox(param0->unk_120, v0, param0->unk_128->unk_18); ov19_021D4F40(param0->unk_120, ¶m0->unk_00.unk_40); ov19_021D61B0(&(param0->unk_114), ¶m0->unk_00, param0); @@ -2384,7 +2384,7 @@ static void ov19_021D3C28(UnkStruct_ov19_021D5DF8 *param0, u32 *param1) break; case 2: if (OverlayManager_Exec(param0->unk_210)) { - u32 v0 = sub_0207999C(param0->unk_120); + u32 v0 = GetCurrentBoxId(param0->unk_120); OverlayManager_Free(param0->unk_210); Heap_Create(3, 10, 245760); @@ -2802,7 +2802,7 @@ static void ov19_021D45A8(UnkStruct_ov19_021D5DF8 *param0, u32 *param1) { switch (*param1) { case 0: - sub_02079A94(param0->unk_120, ov19_021D5E68(¶m0->unk_00)); + SetCurrentBoxIndex(param0->unk_120, ov19_021D5E68(¶m0->unk_00)); ov19_021D52F4(param0); ov19_021D6594(param0->unk_114, 4); (*param1)++; @@ -2869,7 +2869,7 @@ static void ov19_021D4640(UnkStruct_ov19_021D5DF8 *param0, u32 *param1) u32 v0 = ov19_021D5EB8(¶m0->unk_00); ov19_021D5D08(¶m0->unk_00, v0); - sub_02079A94(param0->unk_120, v0); + SetCurrentBoxIndex(param0->unk_120, v0); ov19_021D52F4(param0); if (ov19_021D5E38(¶m0->unk_00) == 1) { @@ -3225,7 +3225,7 @@ static void ov19_021D4E50(UnkStruct_ov19_021D5594 *param0) static void ov19_021D4E5C(PCBoxes *param0, UnkStruct_ov19_021D4F5C *param1) { - param1->unk_00 = sub_0207999C(param0); + param1->unk_00 = GetCurrentBoxId(param0); param1->unk_04 = Strbuf_Init(20, HEAP_ID_9); ov19_021D4F40(param0, param1); } @@ -3289,7 +3289,7 @@ static void ov19_021D4F34(UnkStruct_ov19_021D4F34 *param0) static void ov19_021D4F40(const PCBoxes *param0, UnkStruct_ov19_021D4F5C *param1) { param1->unk_01 = sub_02079AA8(param0, param1->unk_00); - sub_02079AF4(param0, param1->unk_00, param1->unk_04); + CopyBoxName(param0, param1->unk_00, param1->unk_04); } static void ov19_021D4F5C(UnkStruct_ov19_021D4DF0 *param0, PCBoxes *param1) @@ -3695,7 +3695,7 @@ static void ov19_021D5420(UnkStruct_ov19_021D5DF8 *param0, UnkStruct_ov19_021D4D if (ov19_021D5E10(param1) == 0) { MI_CpuCopy32(v1->unk_00, v0->unk_00, BoxPokemon_GetStructSize()); - sub_02079968(param0->unk_120, 0xffffffff, v1->unk_07); + InitializeBoxedPokemonAt(param0->unk_120, 0xffffffff, v1->unk_07); v0->unk_0B = 0; } else { MI_CpuCopy32(v1->unk_00, v0->unk_00, Pokemon_GetStructSize()); @@ -3737,7 +3737,7 @@ static void ov19_021D54A4(UnkStruct_ov19_021D5DF8 *param0, UnkStruct_ov19_021D4D if (BoxPokemon_GetValue(v10, MON_DATA_SPECIES_EXISTS, NULL)) { MI_CpuCopy32(v10, v12, v9); - sub_02079968(param0->unk_120, 0xffffffff, v6); + InitializeBoxedPokemonAt(param0->unk_120, 0xffffffff, v6); (u8 *)v12 += v9; v11->unk_0C[v8++] = v6; @@ -3785,7 +3785,7 @@ static void ov19_021D55C4(UnkStruct_ov19_021D5DF8 *param0, UnkStruct_ov19_021D4D if (ov19_021D5E10(param1) == 0) { v4 = BoxPokemon_GetValue(v0->unk_00, MON_DATA_FORM, NULL); - sub_02079914(param0->unk_120, 0xffffffff, v1->unk_07, v0->unk_00); + StorePokemonInPcAt(param0->unk_120, 0xffffffff, v1->unk_07, v0->unk_00); v2 = GetBoxedPokemonFrom(param0->unk_120, 0xffffffff, v1->unk_07); if ((BoxPokemon_GetValue(v2, MON_DATA_SPECIES, NULL) == SPECIES_SHAYMIN) && (v4 == 1)) { @@ -3828,7 +3828,7 @@ static void ov19_021D56AC(UnkStruct_ov19_021D5DF8 *param0, UnkStruct_ov19_021D4D for (v1 = 0; v1 < v7->unk_08; v1++) { v4 = v3 + (v7->unk_0C[v1] - v2); - sub_02079914(param0->unk_120, 0xffffffff, v4, v0); + StorePokemonInPcAt(param0->unk_120, 0xffffffff, v4, v0); (u8 *)v0 += v5; } @@ -3855,7 +3855,7 @@ static void ov19_021D5734(UnkStruct_ov19_021D5DF8 *param0, UnkStruct_ov19_021D4D MI_CpuCopy32(v3->unk_00, v2->unk_00, v0); if (ov19_021D5E10(param1) == 0) { - sub_02079914(param0->unk_120, 0xffffffff, v3->unk_07, v1); + StorePokemonInPcAt(param0->unk_120, 0xffffffff, v3->unk_07, v1); v2->unk_0B = 0; } else { if (v2->unk_0B == 0) { @@ -3881,7 +3881,7 @@ static BOOL ov19_021D57D8(UnkStruct_ov19_021D5DF8 *param0, u32 param1) v1 = &v0->unk_08; v2 = &v0->unk_14; - if (sub_020798A0(param0->unk_120, param1, v2->unk_00)) { + if (StorePokemonInBox(param0->unk_120, param1, v2->unk_00)) { v0->unk_08.unk_0B = 1; ov19_021D52F4(param0); return 1; @@ -3898,7 +3898,7 @@ static BOOL ov19_021D5800(UnkStruct_ov19_021D5DF8 *param0, u32 param1) v0 = &(param0->unk_00); v1 = &v0->unk_08; - if (sub_020798A0(param0->unk_120, param1, v1->unk_00)) { + if (StorePokemonInBox(param0->unk_120, param1, v1->unk_00)) { Party_RemovePokemonBySlotIndex(param0->unk_124, v1->unk_08); ov19_021D52F4(param0); return 1; @@ -3928,7 +3928,7 @@ static void ov19_021D584C(UnkStruct_ov19_021D5DF8 *param0) UnkStruct_ov19_021D3CFC *v1 = &v0->unk_08; if (ov19_021D5E10(v0) == 0) { - sub_02079968(param0->unk_120, 0xffffffff, v1->unk_07); + InitializeBoxedPokemonAt(param0->unk_120, 0xffffffff, v1->unk_07); } else { Party_RemovePokemonBySlotIndex(param0->unk_124, v1->unk_08); } @@ -4090,7 +4090,7 @@ static void ov19_021D5BE8(UnkStruct_ov19_021D4DF0 *param0, u16 param1, UnkStruct if ((ov19_021D5E10(param0) == 0) && (ov19_021D5E38(param0) == 1)) { u32 v1 = ov19_021D5E24(param0); - sub_02079C50(param2->unk_120, 0xffffffff, v1, 6, ¶m1); + SetBoxedPokemonDataWithSave(param2->unk_120, 0xffffffff, v1, MON_DATA_HELD_ITEM, ¶m1); } BoxPokemon_SetValue(v0->unk_00, MON_DATA_HELD_ITEM, ¶m1); diff --git a/src/overlay019/ov19_021D79F8.c b/src/overlay019/ov19_021D79F8.c index 6561e6fb1b..c30833c055 100644 --- a/src/overlay019/ov19_021D79F8.c +++ b/src/overlay019/ov19_021D79F8.c @@ -586,7 +586,7 @@ void ov19_021D84E0(UnkStruct_ov19_021D8318 *param0) int v0, v1; BoxPokemon *v2; - v1 = sub_0207999C(param0->unk_58F8->unk_00); + v1 = GetCurrentBoxId(param0->unk_58F8->unk_00); for (v0 = 0; v0 < (5 * 6); v0++) { v2 = GetBoxedPokemonFrom(param0->unk_58F8->unk_00, v1, v0); diff --git a/src/overlay019/ov19_021DB8E4.c b/src/overlay019/ov19_021DB8E4.c index 180a28166e..4ab899feff 100644 --- a/src/overlay019/ov19_021DB8E4.c +++ b/src/overlay019/ov19_021DB8E4.c @@ -388,7 +388,7 @@ static void ov19_021DBDF4(UnkStruct_ov19_021DBA9C *param0) } for (v4 = 0; v4 < 18; v4++) { - param0->unk_94[v4] = sub_02079B54(ov19_021D5E90(param0->unk_0C), v4); + param0->unk_94[v4] = GetPokemonCountInBox(ov19_021D5E90(param0->unk_0C), v4); } } @@ -429,7 +429,7 @@ static void ov19_021DBF4C(UnkStruct_ov19_021DBA9C *param0) v0 = ov19_021D5E90(param0->unk_0C); v1 = ¶m0->unk_10[0]; - sub_02079AF4(v0, param0->unk_E0, param0->unk_4BFC); + CopyBoxName(v0, param0->unk_E0, param0->unk_4BFC); v2 = Font_CalcStrbufWidth(FONT_SYSTEM, param0->unk_4BFC, 0); v3 = 48 - (v2 / 2); diff --git a/src/overlay019/ov19_021DCF88.c b/src/overlay019/ov19_021DCF88.c index 3b7d89144a..780f53c72a 100644 --- a/src/overlay019/ov19_021DCF88.c +++ b/src/overlay019/ov19_021DCF88.c @@ -1507,7 +1507,7 @@ static void ov19_021DE350(UnkStruct_ov19_021DCF88 *param0) } for (v1 = 0; v1 < NELEMS(v0); v1++) { - sub_02079AF4(param0->unk_04->unk_00, v2, param0->unk_84); + CopyBoxName(param0->unk_04->unk_00, v2, param0->unk_84); Window_FillRectWithColor(¶m0->unk_88, 0, v0[v1].unk_00, v0[v1].unk_02, 104, 17); Text_AddPrinterWithParamsAndColor(¶m0->unk_88, FONT_SYSTEM, param0->unk_84, v0[v1].unk_00 + 4, v0[v1].unk_02 + 2, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); diff --git a/src/overlay061/ov61_0222AE60.c b/src/overlay061/ov61_0222AE60.c index 2fac69aa76..5932f971e3 100644 --- a/src/overlay061/ov61_0222AE60.c +++ b/src/overlay061/ov61_0222AE60.c @@ -39,20 +39,20 @@ void ov61_0222AE88(SaveData *param0, const PCBoxes *param1, int param2, UnkStruc MI_CpuClear8(param3, sizeof(UnkStruct_ov62_02239DA4)); v0 = Strbuf_Init(20 * 3, param4); - sub_02079AF4(param1, param2, v0); + CopyBoxName(param1, param2, v0); Strbuf_ToChars(v0, param3->unk_00, 20); Strbuf_Free(v0); for (v1 = 0; v1 < 30; v1++) { - param3->unk_28[v1] = sub_02079C08(param1, param2, v1, 5, NULL); - param3->unk_64[v1] = sub_02079C08(param1, param2, v1, 0, NULL); - param3->unk_DC[v1] = sub_02079C08(param1, param2, v1, 7, NULL); + param3->unk_28[v1] = GetBoxedPokemonData(param1, param2, v1, MON_DATA_SPECIES, NULL); + param3->unk_64[v1] = GetBoxedPokemonData(param1, param2, v1, MON_DATA_PERSONALITY, NULL); + param3->unk_DC[v1] = GetBoxedPokemonData(param1, param2, v1, MON_DATA_OT_ID, NULL); - if (sub_02079C08(param1, param2, v1, 174, NULL) == SPECIES_EGG) { + if (GetBoxedPokemonData(param1, param2, v1, MON_DATA_SPECIES_EGG, NULL) == SPECIES_EGG) { param3->unk_154 |= 1 << v1; } - param3->unk_158[v1] = sub_02079C08(param1, param2, v1, 112, NULL); + param3->unk_158[v1] = GetBoxedPokemonData(param1, param2, v1, MON_DATA_FORM, NULL); } param3->unk_176 = sub_02079AA8(param1, param2); diff --git a/src/overlay094/ov94_0223BCB0.c b/src/overlay094/ov94_0223BCB0.c index 359877b778..88da254870 100644 --- a/src/overlay094/ov94_0223BCB0.c +++ b/src/overlay094/ov94_0223BCB0.c @@ -537,7 +537,7 @@ void ov94_0223C584(UnkStruct_ov94_0223FD4C *param0) static void ov94_0223C598(UnkStruct_ov94_0223FD4C *param0) { if (param0->unk_110E) { - param0->unk_110C += sub_02079B54(param0->unk_00->unk_0C, param0->unk_110E - 1); + param0->unk_110C += GetPokemonCountInBox(param0->unk_00->unk_0C, param0->unk_110E - 1); param0->unk_110E++; if (param0->unk_110E == 19) { diff --git a/src/overlay094/ov94_0223FB48.c b/src/overlay094/ov94_0223FB48.c index 07a49b85f6..90ba629435 100644 --- a/src/overlay094/ov94_0223FB48.c +++ b/src/overlay094/ov94_0223FB48.c @@ -1146,7 +1146,7 @@ static void ov94_02240FA0(UnkStruct_ov94_0223FD4C *param0, int param1) } } - sub_02079AF4(v5, param1, param0->unk_BA4); + CopyBoxName(v5, param1, param0->unk_BA4); } else { int v8 = Party_GetCurrentCount(param0->unk_00->unk_08); diff --git a/src/overlay094/ov94_02242AD0.c b/src/overlay094/ov94_02242AD0.c index 368f0748ac..3e9c287b6c 100644 --- a/src/overlay094/ov94_02242AD0.c +++ b/src/overlay094/ov94_02242AD0.c @@ -1252,7 +1252,7 @@ static void ov94_02243B08(UnkStruct_ov94_0223FD4C *param0, int param1) Pokemon_FromBoxPokemon(GetBoxedPokemonFrom(param0->unk_00->unk_0C, param0->unk_110, param0->unk_112), v0); sub_0202DA7C(param0->unk_00->unk_00, v0, param0->unk_110); - sub_02079968(param0->unk_00->unk_0C, param0->unk_110, param0->unk_112); + InitializeBoxedPokemonAt(param0->unk_00->unk_0C, param0->unk_110, param0->unk_112); Heap_FreeToHeap(v0); } else { Pokemon *v1 = Party_GetPokemonBySlotIndex(param0->unk_00->unk_08, param0->unk_112); @@ -1313,8 +1313,8 @@ static void ov94_02243BC4(UnkStruct_ov94_0223FD4C *param0, Pokemon *param1, int } else { int v4 = 0; - sub_020799F0(param0->unk_00->unk_0C, ¶m2, &v4); - sub_020798A0(param0->unk_00->unk_0C, param2, Pokemon_GetBoxPokemon(param1)); + GetNextAvailableBoxSpaceAfter(param0->unk_00->unk_0C, ¶m2, &v4); + StorePokemonInBox(param0->unk_00->unk_0C, param2, Pokemon_GetBoxPokemon(param1)); param0->unk_124.unk_00 = param2; param0->unk_124.unk_04 = v4; @@ -1361,8 +1361,8 @@ static void ov94_02243CE4(UnkStruct_ov94_0223FD4C *param0, Pokemon *param1, int } else { int v3 = 0; - sub_020799F0(param0->unk_00->unk_0C, ¶m2, &v3); - sub_020798A0(param0->unk_00->unk_0C, param2, Pokemon_GetBoxPokemon(param1)); + GetNextAvailableBoxSpaceAfter(param0->unk_00->unk_0C, ¶m2, &v3); + StorePokemonInBox(param0->unk_00->unk_0C, param2, Pokemon_GetBoxPokemon(param1)); param0->unk_124.unk_00 = param2; param0->unk_124.unk_04 = v3; diff --git a/src/overlay094/ov94_022444C8.c b/src/overlay094/ov94_022444C8.c index 0970726ed4..2ee2173c6d 100644 --- a/src/overlay094/ov94_022444C8.c +++ b/src/overlay094/ov94_022444C8.c @@ -194,8 +194,8 @@ static void ov94_022448E8(UnkStruct_ov94_0223FD4C *param0) } else { int v1 = 0, v2 = 0; - sub_02079968(param0->unk_00->unk_0C, param0->unk_124.unk_00, param0->unk_124.unk_04); - sub_020799F0(param0->unk_00->unk_0C, &v1, &v2); - sub_020798A0(param0->unk_00->unk_0C, v1, Pokemon_GetBoxPokemon(v0)); + InitializeBoxedPokemonAt(param0->unk_00->unk_0C, param0->unk_124.unk_00, param0->unk_124.unk_04); + GetNextAvailableBoxSpaceAfter(param0->unk_00->unk_0C, &v1, &v2); + StorePokemonInBox(param0->unk_00->unk_0C, v1, Pokemon_GetBoxPokemon(v0)); } } diff --git a/src/pokemon.c b/src/pokemon.c index d9fd59b30c..8fe3cf2172 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4839,7 +4839,7 @@ void sub_0207893C(Pokemon *mon) Pokemon_SetValue(mon, MON_DATA_171, &v1); } -void sub_0207896C(BoxPokemon *boxMon) +void RestoreBoxedPokemonPP(BoxPokemon *boxMon) { BOOL reencrypt = BoxPokemon_EnterDecryptionContext(boxMon); diff --git a/src/scrcmd.c b/src/scrcmd.c index 1f92624bf6..7b608ce1e5 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -6728,7 +6728,7 @@ static BOOL ScrCmd_WriteSpeciesSeen(ScriptContext *ctx) static BOOL ScrCmd_252(ScriptContext *ctx) { u16 *v0 = ScriptContext_GetVarPointer(ctx); - u16 v1 = sub_02079A50(SaveData_PCBoxes(ctx->fieldSystem->saveData)); + u16 v1 = GetBoxedPokemonCount(SaveData_PCBoxes(ctx->fieldSystem->saveData)); *v0 = 18 * (5 * 6) - v1; return 0; diff --git a/src/string_template.c b/src/string_template.c index 7a25290e26..5e940e3fe1 100644 --- a/src/string_template.c +++ b/src/string_template.c @@ -423,7 +423,7 @@ void StringTemplate_SetGenderMarker(StringTemplate *template, u32 idx, enum Gend void StringTemplate_SetPCBoxName(StringTemplate *template, u32 idx, const PCBoxes *boxes, u32 boxIdx) { - sub_02079AF4(boxes, boxIdx, template->templateBuf); + CopyBoxName(boxes, boxIdx, template->templateBuf); SetStringTemplateArg(template, idx, template->templateBuf, NULL); } diff --git a/src/unk_0204C500.c b/src/unk_0204C500.c index 896208044d..d76c826a38 100644 --- a/src/unk_0204C500.c +++ b/src/unk_0204C500.c @@ -73,7 +73,7 @@ BOOL ScrCmd_255(ScriptContext *param0) for (v6 = 0; v6 < 6; v6++) { TransferDataToMon(transferData, v6, v2); sub_0209304C(v2, v3, 2, 0, 32); - v5 = sub_02079868(v1, Pokemon_GetBoxPokemon(v2)); + v5 = StorePokemonInPc(v1, Pokemon_GetBoxPokemon(v2)); GF_ASSERT(v5); sub_0202F180(param0->fieldSystem->saveData, v2); } diff --git a/src/unk_0204CFFC.c b/src/unk_0204CFFC.c index 6a994fce4e..0dbbba5a58 100644 --- a/src/unk_0204CFFC.c +++ b/src/unk_0204CFFC.c @@ -456,7 +456,7 @@ BOOL ScrCmd_19C(ScriptContext *param0) } } - v1 += sub_02079BEC(v6); + v1 += GetTotalBoxedEggCount(v6); *v5 = v1; return 0; diff --git a/src/unk_020797C8.c b/src/unk_020797C8.c index 2de628222b..376c5f8b38 100644 --- a/src/unk_020797C8.c +++ b/src/unk_020797C8.c @@ -3,24 +3,26 @@ #include #include +#include "generated/text_banks.h" + #include "message.h" #include "pokemon.h" #include "savedata.h" #include "strbuf.h" typedef struct PCBoxes { - u32 unk_00; - BoxPokemon unk_04[18][30]; - u16 unk_10E4[18][20]; + u32 currentBoxIndex; + BoxPokemon boxedPokemonArray[MAX_PC_BOXES][30]; + u16 boxNames[MAX_PC_BOXES][20]; u8 unk_13B4[18]; - u8 unk_13C6; + u8 unk_13C6; // This seems like some sort of bit flag? but I don't know for what } PCBoxes; -static void sub_020797DC(PCBoxes *param0); +static void sub_020797DC(PCBoxes *pcBoxes); -void PCBoxes_Init(PCBoxes *param0) +void PCBoxes_Init(PCBoxes *pcBoxes) { - sub_020797DC(param0); + sub_020797DC(pcBoxes); SaveData_SetFullSaveRequired(); } @@ -29,92 +31,95 @@ u32 PCBoxes_SaveSize(void) return sizeof(PCBoxes); } -static void sub_020797DC(PCBoxes *param0) +// InitPokemonStorageSystem? +static void sub_020797DC(PCBoxes *pcBoxes) { - u32 v0, v1; - MessageLoader *v2; + u32 boxIndex, monPosInBox; + MessageLoader *messageLoader; - for (v0 = 0; v0 < 18; v0++) { - for (v1 = 0; v1 < (5 * 6); v1++) { - BoxPokemon_Init(&(param0->unk_04[v0][v1])); + for (boxIndex = 0; boxIndex < MAX_PC_BOXES; boxIndex++) { + for (monPosInBox = 0; monPosInBox < MAX_MONS_PER_BOX; monPosInBox++) { + BoxPokemon_Init(&(pcBoxes->boxedPokemonArray[boxIndex][monPosInBox])); } } - for (v0 = 0, v1 = 0; v0 < 18; v0++) { - param0->unk_13B4[v0] = v1++; + // Pretty sure that monPosInBox isn't being used in the same way here as in the previous loop, + // so the variable's name no longer accurately reflects what it's doing in this loop + for (boxIndex = 0, monPosInBox = 0; boxIndex < MAX_PC_BOXES; boxIndex++) { + pcBoxes->unk_13B4[boxIndex] = monPosInBox++; - if (v1 >= 16) { - v1 = 0; + if (monPosInBox >= 16) { + monPosInBox = 0; } } - param0->unk_13C6 = 0; - v2 = MessageLoader_Init(1, 26, 18, HEAP_ID_SYSTEM); + pcBoxes->unk_13C6 = 0; + messageLoader = MessageLoader_Init(MESSAGE_LOADER_NARC_HANDLE, NARC_INDEX_MSGDATA__PL_MSG, TEXT_BANK_POKEMON_STORAGE_SYSTEM, HEAP_ID_SYSTEM); - if (v2) { - for (v0 = 0; v0 < 18; v0++) { - MessageLoader_Get(v2, 6 + v0, param0->unk_10E4[v0]); + if (messageLoader) { + for (boxIndex = 0; boxIndex < MAX_PC_BOXES; boxIndex++) { + MessageLoader_Get(messageLoader, BOX1_TEXT_BANK_ENTRYID + boxIndex, pcBoxes->boxNames[boxIndex]); } - MessageLoader_Free(v2); + MessageLoader_Free(messageLoader); } - param0->unk_00 = 0; + pcBoxes->currentBoxIndex = 0; } -BOOL sub_02079868(PCBoxes *boxes, BoxPokemon *boxMon) +BOOL StorePokemonInPc(PCBoxes *pcBoxes, BoxPokemon *boxMon) { - u32 v0 = boxes->unk_00; + u32 boxIndex = pcBoxes->currentBoxIndex; do { - sub_0207896C(boxMon); + RestoreBoxedPokemonPP(boxMon); - if (sub_020798A0(boxes, v0, boxMon)) { + if (StorePokemonInBox(pcBoxes, boxIndex, boxMon)) { SaveData_SetFullSaveRequired(); - return 1; + return TRUE; } - if (++v0 >= 18) { - v0 = 0; + if (++boxIndex >= MAX_PC_BOXES) { + boxIndex = 0; } - } while (v0 != boxes->unk_00); + } while (boxIndex != pcBoxes->currentBoxIndex); - return 0; + return FALSE; } -BOOL sub_020798A0(PCBoxes *boxes, u32 param1, BoxPokemon *boxMon) +BOOL StorePokemonInBox(PCBoxes *pcBoxes, u32 boxIndex, BoxPokemon *boxMon) { - u32 v0; + u32 monPosInBox; - sub_0207896C(boxMon); + RestoreBoxedPokemonPP(boxMon); BoxPokemon_SetShayminForm(boxMon, 0); - if (param1 == 0xffffffff) { - param1 = boxes->unk_00; + if (boxIndex == -1) { + boxIndex = pcBoxes->currentBoxIndex; } - for (v0 = 0; v0 < (5 * 6); v0++) { - if (BoxPokemon_GetValue(&(boxes->unk_04[param1][v0]), MON_DATA_SPECIES, NULL) == 0) { - boxes->unk_04[param1][v0] = *boxMon; + for (monPosInBox = 0; monPosInBox < MAX_MONS_PER_BOX; monPosInBox++) { + if (BoxPokemon_GetValue(&(pcBoxes->boxedPokemonArray[boxIndex][monPosInBox]), MON_DATA_SPECIES, NULL) == 0) { + pcBoxes->boxedPokemonArray[boxIndex][monPosInBox] = *boxMon; SaveData_SetFullSaveRequired(); - return 1; + return TRUE; } } - return 0; + return FALSE; } -BOOL sub_02079914(PCBoxes *param0, u32 param1, u32 param2, BoxPokemon *boxMon) +BOOL StorePokemonInPcAt(PCBoxes *pcBoxes, u32 param1, u32 param2, BoxPokemon *param3) { - sub_0207896C(boxMon); - BoxPokemon_SetShayminForm(boxMon, 0); + RestoreBoxedPokemonPP(param3); + BoxPokemon_SetShayminForm(param3, 0); if (param1 == 0xffffffff) { - param1 = param0->unk_00; + param1 = pcBoxes->currentBoxIndex; } - if ((param1 < 18) && (param2 < (5 * 6))) { - param0->unk_04[param1][param2] = *boxMon; + if ((param1 < MAX_PC_BOXES) && (param2 < MAX_MONS_PER_BOX)) { + pcBoxes->boxedPokemonArray[param1][param2] = *param3; SaveData_SetFullSaveRequired(); return 1; } else { @@ -124,180 +129,181 @@ BOOL sub_02079914(PCBoxes *param0, u32 param1, u32 param2, BoxPokemon *boxMon) return 0; } -void sub_02079968(PCBoxes *param0, u32 param1, u32 param2) +void InitializeBoxedPokemonAt(PCBoxes *pcBoxes, u32 boxIndex, u32 monPosInBox) { - if (param1 == 0xffffffff) { - param1 = param0->unk_00; + if (boxIndex == -1) { + boxIndex = pcBoxes->currentBoxIndex; } - if ((param2 < (5 * 6)) && (param1 < 18)) { - BoxPokemon_Init(&(param0->unk_04[param1][param2])); + if ((monPosInBox < MAX_MONS_PER_BOX) && (boxIndex < MAX_PC_BOXES)) { + BoxPokemon_Init(&(pcBoxes->boxedPokemonArray[boxIndex][monPosInBox])); SaveData_SetFullSaveRequired(); } else { GF_ASSERT(0); } } -u32 sub_0207999C(const PCBoxes *param0) +u32 GetCurrentBoxId(const PCBoxes *pcBoxes) { - return param0->unk_00; + return pcBoxes->currentBoxIndex; } -u32 PCBoxes_FirstEmptyBox(const PCBoxes *param0) +u32 PCBoxes_FirstEmptyBox(const PCBoxes *pcBoxes) { - int v0, v1; + int boxIndex, monPosInBox; - v0 = param0->unk_00; + boxIndex = pcBoxes->currentBoxIndex; while (TRUE) { - for (v1 = 0; v1 < (5 * 6); v1++) { - if (BoxPokemon_GetValue((BoxPokemon *)(&(param0->unk_04[v0][v1])), MON_DATA_SPECIES_EXISTS, NULL) == 0) { - return v0; + for (monPosInBox = 0; monPosInBox < MAX_MONS_PER_BOX; monPosInBox++) { + if (BoxPokemon_GetValue((BoxPokemon *)(&(pcBoxes->boxedPokemonArray[boxIndex][monPosInBox])), MON_DATA_SPECIES_EXISTS, NULL) == 0) { + return boxIndex; } } - if (++v0 >= 18) { - v0 = 0; + if (++boxIndex >= MAX_PC_BOXES) { + boxIndex = 0; } - if (v0 == param0->unk_00) { + if (boxIndex == pcBoxes->currentBoxIndex) { break; } } - return 18; + return MAX_PC_BOXES; } -BOOL sub_020799F0(const PCBoxes *param0, int *param1, int *param2) +BOOL GetNextAvailableBoxSpaceAfter(const PCBoxes *pcBoxes, int *boxIndexParam, int *monPosInBoxParam) { - int v0, v1; + int boxIndex, monPosInBox; - if (*param1 == 0xffffffff) { - *param1 = param0->unk_00; + if (*boxIndexParam == -1) { + *boxIndexParam = pcBoxes->currentBoxIndex; } - v0 = *param1; - v1 = *param2; + boxIndex = *boxIndexParam; + monPosInBox = *monPosInBoxParam; while (TRUE) { - for (; v1 < (5 * 6); v1++) { - if (BoxPokemon_GetValue((BoxPokemon *)(&(param0->unk_04[v0][v1])), MON_DATA_SPECIES_EXISTS, NULL) == 0) { - *param1 = v0; - *param2 = v1; - return 1; + for (; monPosInBox < MAX_MONS_PER_BOX; monPosInBox++) { + if (BoxPokemon_GetValue((BoxPokemon *)(&(pcBoxes->boxedPokemonArray[boxIndex][monPosInBox])), MON_DATA_SPECIES_EXISTS, NULL) == 0) { + *boxIndexParam = boxIndex; + *monPosInBoxParam = monPosInBox; + return TRUE; } } - if (++v0 >= 18) { - v0 = 0; + if (++boxIndex >= MAX_PC_BOXES) { + boxIndex = 0; } - if (v0 == (*param1)) { + if (boxIndex == (*boxIndexParam)) { break; } - v1 = 0; + monPosInBox = 0; } - return 18; + return MAX_PC_BOXES; } -u32 sub_02079A50(const PCBoxes *param0) +u32 GetBoxedPokemonCount(const PCBoxes *pcBoxes) { - int v0, v1; - u32 v2 = 0; + int boxIndex, monPosInBox; + u32 pokemonCount = 0; - for (v0 = 0; v0 < 18; v0++) { - for (v1 = 0; v1 < (5 * 6); v1++) { - if (BoxPokemon_GetValue((BoxPokemon *)(&(param0->unk_04[v0][v1])), MON_DATA_SPECIES_EXISTS, NULL) != 0) { - v2++; + for (boxIndex = 0; boxIndex < MAX_PC_BOXES; boxIndex++) { + for (monPosInBox = 0; monPosInBox < MAX_MONS_PER_BOX; monPosInBox++) { + if (BoxPokemon_GetValue((BoxPokemon *)(&(pcBoxes->boxedPokemonArray[boxIndex][monPosInBox])), MON_DATA_SPECIES_EXISTS, NULL) != 0) { + pokemonCount++; } } } - return v2; + return pokemonCount; } -void sub_02079A94(PCBoxes *param0, u32 param1) +void SetCurrentBoxIndex(PCBoxes *pcBoxes, u32 boxIndex) { - if (param1 < 18) { - param0->unk_00 = param1; + if (boxIndex < MAX_PC_BOXES) { + pcBoxes->currentBoxIndex = boxIndex; SaveData_SetFullSaveRequired(); } else { GF_ASSERT(0); } } -u32 sub_02079AA8(const PCBoxes *param0, u32 param1) +u32 sub_02079AA8(const PCBoxes *pcBoxes, u32 boxIndex) { - if (param1 < 18) { - return param0->unk_13B4[param1]; + if (boxIndex < MAX_PC_BOXES) { + return pcBoxes->unk_13B4[boxIndex]; } else { GF_ASSERT(0); - return 0; + return FALSE; } } -void sub_02079AC4(PCBoxes *param0, u32 param1, u32 param2) +void sub_02079AC4(PCBoxes *pcBoxes, u32 boxIndex, u32 param2) { - if (param1 == 0xffffffff) { - param1 = param0->unk_00; + if (boxIndex == -1) { + boxIndex = pcBoxes->currentBoxIndex; } - if ((param1 < 18) && (param2 < (16 + 8))) { + // What do 16 and 8 mean here? + if ((boxIndex < MAX_PC_BOXES) && (param2 < (16 + 8))) { if (param2 >= 16) { param2 += 8; } - param0->unk_13B4[param1] = param2; + pcBoxes->unk_13B4[boxIndex] = param2; SaveData_SetFullSaveRequired(); } else { GF_ASSERT(0); } } -void sub_02079AF4(const PCBoxes *param0, u32 param1, Strbuf *param2) +void CopyBoxName(const PCBoxes *pcBoxes, u32 boxIndex, Strbuf *copyDestination) { - if (param1 == 0xffffffff) { - param1 = param0->unk_00; + if (boxIndex == -1) { + boxIndex = pcBoxes->currentBoxIndex; } - if (param1 < 18) { - Strbuf_CopyChars(param2, param0->unk_10E4[param1]); + if (boxIndex < MAX_PC_BOXES) { + Strbuf_CopyChars(copyDestination, pcBoxes->boxNames[boxIndex]); } else { GF_ASSERT(0); } } -void sub_02079B24(PCBoxes *param0, u32 param1, const Strbuf *param2) +void RenameBox(PCBoxes *pcBoxes, u32 boxIndex, const Strbuf *newName) { - if (param1 == 0xffffffff) { - param1 = param0->unk_00; + if (boxIndex == -1) { + boxIndex = pcBoxes->currentBoxIndex; } - if (param1 < 18) { - Strbuf_ToChars(param2, param0->unk_10E4[param1], 20); + if (boxIndex < MAX_PC_BOXES) { + Strbuf_ToChars(newName, pcBoxes->boxNames[boxIndex], 20); SaveData_SetFullSaveRequired(); } } -u32 sub_02079B54(const PCBoxes *param0, u32 param1) +u32 GetPokemonCountInBox(const PCBoxes *pcBoxes, u32 boxIndex) { - if (param1 == 0xffffffff) { - param1 = param0->unk_00; + if (boxIndex == -1) { + boxIndex = pcBoxes->currentBoxIndex; } - if (param1 < 18) { - int v0; - u32 v1 = 0; + if (boxIndex < MAX_PC_BOXES) { + int monPosInBox; + u32 pokemonCount = 0; - for (v0 = 0; v0 < (5 * 6); v0++) { - if (BoxPokemon_GetValue((BoxPokemon *)(&(param0->unk_04[param1][v0])), MON_DATA_SPECIES_EXISTS, NULL)) { - v1++; + for (monPosInBox = 0; monPosInBox < MAX_MONS_PER_BOX; monPosInBox++) { + if (BoxPokemon_GetValue((BoxPokemon *)(&(pcBoxes->boxedPokemonArray[boxIndex][monPosInBox])), MON_DATA_SPECIES_EXISTS, NULL)) { + pokemonCount++; } } - return v1; + return pokemonCount; } else { GF_ASSERT(0); } @@ -305,25 +311,25 @@ u32 sub_02079B54(const PCBoxes *param0, u32 param1) return 0; } -u32 sub_02079B98(const PCBoxes *param0, u32 param1) +u32 GetEggCountInBox(const PCBoxes *pcBoxes, u32 boxIndex) { - if (param1 == 0xffffffff) { - param1 = param0->unk_00; + if (boxIndex == -1) { + boxIndex = pcBoxes->currentBoxIndex; } - if (param1 < 18) { - int v0; - u32 v1 = 0; + if (boxIndex < MAX_PC_BOXES) { + int monPosInBox; + u32 eggCount = 0; - for (v0 = 0; v0 < (5 * 6); v0++) { - if (BoxPokemon_GetValue((BoxPokemon *)(&(param0->unk_04[param1][v0])), MON_DATA_SPECIES_EXISTS, NULL)) { - if (BoxPokemon_GetValue((BoxPokemon *)(&(param0->unk_04[param1][v0])), MON_DATA_IS_EGG, NULL) == 0) { - v1++; + for (monPosInBox = 0; monPosInBox < MAX_MONS_PER_BOX; monPosInBox++) { + if (BoxPokemon_GetValue((BoxPokemon *)(&(pcBoxes->boxedPokemonArray[boxIndex][monPosInBox])), MON_DATA_SPECIES_EXISTS, NULL)) { + if (BoxPokemon_GetValue((BoxPokemon *)(&(pcBoxes->boxedPokemonArray[boxIndex][monPosInBox])), MON_DATA_IS_EGG, NULL) == 0) { + eggCount++; } } } - return v1; + return eggCount; } else { GF_ASSERT(0); } @@ -331,78 +337,79 @@ u32 sub_02079B98(const PCBoxes *param0, u32 param1) return 0; } -u32 sub_02079BEC(const PCBoxes *param0) +u32 GetTotalBoxedEggCount(const PCBoxes *pcBoxes) { - u32 v0, v1; + u32 eggCount, boxIndex; - for (v1 = 0, v0 = 0; v1 < 18; v1++) { - v0 += sub_02079B98(param0, v1); + for (boxIndex = 0, eggCount = 0; boxIndex < MAX_PC_BOXES; boxIndex++) { + eggCount += GetEggCountInBox(pcBoxes, boxIndex); } - return v0; + return eggCount; } -u32 sub_02079C08(const PCBoxes *param0, u32 param1, u32 param2, int param3, void *param4) +u32 GetBoxedPokemonData(const PCBoxes *pcBoxes, u32 boxIndex, u32 monPosInBox, enum PokemonDataParam pokemonData, void *dest) { - GF_ASSERT((param1 < 18) || (param1 == 0xffffffff)); - GF_ASSERT(param2 < (5 * 6)); + GF_ASSERT((boxIndex < MAX_PC_BOXES) || (boxIndex == -1)); + GF_ASSERT(monPosInBox < MAX_MONS_PER_BOX); - if (param1 == 0xffffffff) { - param1 = param0->unk_00; + if (boxIndex == -1) { + boxIndex = pcBoxes->currentBoxIndex; } - return BoxPokemon_GetValue((BoxPokemon *)(¶m0->unk_04[param1][param2]), param3, param4); + return BoxPokemon_GetValue((BoxPokemon *)(&pcBoxes->boxedPokemonArray[boxIndex][monPosInBox]), pokemonData, dest); } -void sub_02079C50(PCBoxes *param0, u32 param1, u32 param2, int param3, void *param4) +void SetBoxedPokemonDataWithSave(PCBoxes *pcBoxes, u32 boxIndex, u32 monPosInBox, enum PokemonDataParam pokemonData, void *value) { - GF_ASSERT((param1 < 18) || (param1 == 0xffffffff)); - GF_ASSERT(param2 < (5 * 6)); + GF_ASSERT((boxIndex < MAX_PC_BOXES) || (boxIndex == -1)); + GF_ASSERT(monPosInBox < MAX_MONS_PER_BOX); - if (param1 == 0xffffffff) { - param1 = param0->unk_00; + if (boxIndex == -1) { + boxIndex = pcBoxes->currentBoxIndex; } - BoxPokemon_SetValue((BoxPokemon *)(¶m0->unk_04[param1][param2]), param3, param4); + BoxPokemon_SetValue((BoxPokemon *)(&pcBoxes->boxedPokemonArray[boxIndex][monPosInBox]), pokemonData, value); SaveData_SetFullSaveRequired(); } -BoxPokemon *GetBoxedPokemonFrom(const PCBoxes *pcBoxes, u32 boxIndex, u32 pokemonBoxLocationIndex) +BoxPokemon *GetBoxedPokemonFrom(const PCBoxes *pcBoxes, u32 boxIndex, u32 monPosInBox) { - GF_ASSERT((boxIndex < 18) || (boxIndex == 0xffffffff)); - GF_ASSERT(pokemonBoxLocationIndex < (5 * 6)); + GF_ASSERT((boxIndex < MAX_PC_BOXES) || (boxIndex == -1)); + GF_ASSERT(monPosInBox < MAX_MONS_PER_BOX); - if (boxIndex == 0xffffffff) { - boxIndex = pcBoxes->unk_00; + if (boxIndex == -1) { + boxIndex = pcBoxes->currentBoxIndex; } - return (BoxPokemon *)&(pcBoxes->unk_04[boxIndex][pokemonBoxLocationIndex]); + return (BoxPokemon *)&(pcBoxes->boxedPokemonArray[boxIndex][monPosInBox]); } -void sub_02079CD8(PCBoxes *param0, u32 param1) +void sub_02079CD8(PCBoxes *pcBoxes, u32 param1) { GF_ASSERT(param1 < 8); - param0->unk_13C6 |= (1 << param1); + pcBoxes->unk_13C6 |= (1 << param1); SaveData_SetFullSaveRequired(); } -BOOL sub_02079CFC(const PCBoxes *param0, u32 param1) +// TODO: figure out unk_13C6, and how it relates to 16 and 8 +BOOL sub_02079CFC(const PCBoxes *pcBoxes, u32 param1) { GF_ASSERT(param1 < 8); - return (param0->unk_13C6 & (1 << param1)) != 0; + return (pcBoxes->unk_13C6 & (1 << param1)) != 0; } -u32 sub_02079D20(const PCBoxes *param0) +u32 sub_02079D20(const PCBoxes *pcBoxes) { - u32 v0, v1; + u32 i, count; - for (v0 = 0, v1 = 0; v0 < 8; v0++) { - if (sub_02079CFC(param0, v0)) { - v1++; + for (i = 0, count = 0; i < 8; i++) { + if (sub_02079CFC(pcBoxes, i)) { + count++; } } - return v1; + return count; } diff --git a/src/unk_0208694C.c b/src/unk_0208694C.c index 00950808de..ff25ce37b2 100644 --- a/src/unk_0208694C.c +++ b/src/unk_0208694C.c @@ -1449,7 +1449,7 @@ static void sub_02087544(UnkStruct_02087A10 *param0, OverlayManager *param1) v0 = Strbuf_Init(200, HEAP_ID_18); param0->unk_180 = NULL; - v2 = sub_0207999C(v1->unk_48); + v2 = GetCurrentBoxId(v1->unk_48); v3 = PCBoxes_FirstEmptyBox(v1->unk_48); StringTemplate_SetPCBoxName(param0->unk_168, 1, v1->unk_48, v2);