From 45ca90f253cbf28f765000ae8dd45d791beb1571 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 12 May 2025 15:39:37 +0200 Subject: [PATCH] Rename to FriendList --- include/{code_8023868.h => friend_list.h} | 18 +- ld_script.txt | 4 +- src/code_801D014.c | 2 +- src/code_8023868.c | 476 ---------------------- src/data/code_8023868.h | 27 -- src/debug_menu4.c | 18 +- src/friend_area_action_menu.c | 16 +- src/friend_list.c | 476 ++++++++++++++++++++++ src/friend_list_menu.c | 20 +- src/friend_rescue.c | 28 +- src/gulpin_shop_801FB50.c | 16 +- src/wonder_mail.c | 24 +- sym_iwram_init.txt | 2 +- 13 files changed, 550 insertions(+), 577 deletions(-) rename include/{code_8023868.h => friend_list.h} (52%) delete mode 100644 src/code_8023868.c delete mode 100644 src/data/code_8023868.h create mode 100644 src/friend_list.c diff --git a/include/code_8023868.h b/include/friend_list.h similarity index 52% rename from include/code_8023868.h rename to include/friend_list.h index be8155345..2cc67daaa 100644 --- a/include/code_8023868.h +++ b/include/friend_list.h @@ -1,5 +1,5 @@ -#ifndef GUARD_CODE_8023868_H -#define GUARD_CODE_8023868_H +#ifndef GUARD_FRIEND_LIST_H +#define GUARD_FRIEND_LIST_H #include "structs/struct_sub80095e4.h" @@ -21,12 +21,12 @@ struct unkStruct_3001B60 }; // code_8023868.s -bool8 sub_8023868(u32 r5, u32 windowId, DungeonPos *pos, u32 r10); -extern u32 sub_8023A94(bool8); -extern s32 sub_8023B44(void); +bool8 FriendList_Init(u32 r5, u32 windowId, DungeonPos *pos, u32 r10); +u32 FriendList_HandleInput(bool8); +s32 FriendList_GetCurrId(void); void sub_8023B7C(bool8 addCursor); -extern void sub_8023C60(void); -extern void sub_8023DA4(void); -extern bool8 sub_8024108(s32); +void FriendList_Free(void); +void FriendList_ShowWindow(void); +bool8 sub_8024108(s32); -#endif // GUARD_CODE_8023868_H +#endif // GUARD_FRIEND_LIST_H diff --git a/ld_script.txt b/ld_script.txt index a2b578cf2..6641e139d 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -136,7 +136,7 @@ SECTIONS { src/wigglytuff_shop3.o(.text); src/code_80227B8.o(.text); src/code_8023144.o(.text); - src/code_8023868.o(.text); + src/friend_list.o(.text); src/code_8024458.o(.text); src/luminous_cave.o(.text); src/friend_list_menu.o(.text); @@ -491,7 +491,7 @@ SECTIONS { src/wigglytuff_shop3.o(.rodata); src/code_80227B8.o(.rodata); src/code_8023144.o(.rodata); - src/code_8023868.o(.rodata); + src/friend_list.o(.rodata); src/code_8024458.o(.rodata); src/luminous_cave.o(.rodata); src/friend_list_menu.o(.rodata); diff --git a/src/code_801D014.c b/src/code_801D014.c index de746eabe..f752fca99 100644 --- a/src/code_801D014.c +++ b/src/code_801D014.c @@ -5,7 +5,7 @@ #include "code_800D090.h" #include "code_801D014.h" #include "code_80227B8.h" -#include "code_8023868.h" +#include "friend_list.h" #include "code_8024458.h" #include "code_80958E8.h" #include "common_strings.h" diff --git a/src/code_8023868.c b/src/code_8023868.c deleted file mode 100644 index 55e5b4134..000000000 --- a/src/code_8023868.c +++ /dev/null @@ -1,476 +0,0 @@ -#include "global.h" -#include "globaldata.h" -#include "code_800D090.h" -#include "code_8023868.h" -#include "code_80118A4.h" -#include "pokemon.h" -#include "structs/str_text.h" -#include "text_util.h" -#include "text_1.h" -#include "text_2.h" -#include "text_3.h" -#include "event_flag.h" -#include "menu_input.h" -#include "rescue_team_info.h" -#include "input.h" -#include "memory.h" -#include "ground_map_1.h" -#include "constants/input.h" - -extern const u8 sUnknown_80DC988[]; -extern const u8 sUnknown_80DC980[]; -extern const u8 sUnknown_80DC998[]; - -extern bool8 sub_808D750(s32 index_); - -//static // MAKE STATIC WHEN code_8023868.s IS DONE -IWRAM_INIT struct unkStruct_3001B60 *gUnknown_3001B60 = {NULL}; - -#include "data/code_8023868.h" - -static void SortbyAlphabetNo(s32, s32); -static void SortbyInternalNo(s32, s32); -static void SortbyName(s32, s32); -s32 sub_8023BD8(void); -bool8 sub_8024184(PokemonStruct1 *pokemon, u8 area); -void sub_80241A8(void); -void sub_8023CF4(void); -void sub_8023DA4(void); -s32 sub_8023F8C(void); -bool8 sub_8024108(s32 param_1); - -extern s32 gUnknown_203B2A0; -extern s32 gUnknown_203B2A4; -extern u16 gUnknown_203B2A8; -extern u16 gUnknown_203B2AA; - -// THE REMAINING CODE FROM THIS FILE IS IN code_8023868.s STARTING WITH sub_8023868 - -bool8 sub_8023868(u32 r5, u32 windowId, DungeonPos *pos, u32 r10) -{ - if (sub_8024108(r5)) { - return FALSE; - } - - if (gUnknown_3001B60 == NULL) { - gUnknown_3001B60 = MemoryAlloc(sizeof(*gUnknown_3001B60), 8); - } - - gUnknown_3001B60->unk0 = r5; - if (gUnknown_203B2A0 != r5) { - gUnknown_3001B60->sortMethod = 1; - } - else { - gUnknown_3001B60->sortMethod = gUnknown_203B2A4; - } - - gUnknown_3001B60->unk14 = 0; - gUnknown_3001B60->unk15 = 0; - gUnknown_3001B60->unk16 = 0; - gUnknown_3001B60->unk17 = 0; - gUnknown_3001B60->unk18 = 0; - switch (gUnknown_3001B60->unk0) { - case 0: - break; - case 1: - gUnknown_3001B60->unk18 = 1; - break; - case 2: - gUnknown_3001B60->unk14 = 1; - break; - case 3: - gUnknown_3001B60->unk17 = 1; - gUnknown_3001B60->unk15 = 1; - gUnknown_3001B60->unk16 = 1; - break; - case 4: - gUnknown_3001B60->unk18 = 1; - gUnknown_3001B60->unk15 = 1; - if (!sub_80023E4(9)) { - gUnknown_3001B60->unk16 = 1; - } - break; - } - - if (gUnknown_3001B60->unk0 == 4) { - gUnknown_3001B60->unk354 = sub_8002658(sub_80A5728()); - } - else { - gUnknown_3001B60->unk354 = 0; - } - - gUnknown_3001B60->unk358.s0.winId = windowId; - gUnknown_3001B60->unk358.s0.unk38 = &gUnknown_3001B60->unk358.s0.windows.id[windowId]; - RestoreSavedWindows(&gUnknown_3001B60->unk358.s0.windows); - gUnknown_3001B60->unk358.s0.windows.id[gUnknown_3001B60->unk358.s0.winId] = sUnknown_80DC968; - gUnknown_3001B60->unk358.s0.unk38->header = &gUnknown_3001B60->unk358.header; - if (pos != NULL) { - gUnknown_3001B60->unk358.s0.windows.id[gUnknown_3001B60->unk358.s0.winId].pos = *pos; - } - sub_8012D08(gUnknown_3001B60->unk358.s0.unk38, r10); - ResetUnusedInputStruct(); - ShowWindows(&gUnknown_3001B60->unk358.s0.windows, TRUE, TRUE); - sub_8013818(&gUnknown_3001B60->unk358.s0.input, sub_8023F8C(), r10, windowId); - if (gUnknown_203B2A0 == gUnknown_3001B60->unk0) { - gUnknown_3001B60->unk358.s0.input.menuIndex = gUnknown_203B2A8; - gUnknown_3001B60->unk358.s0.input.unk1E = gUnknown_203B2AA; - sub_8013984(&gUnknown_3001B60->unk358.s0.input); - } - sub_8023CF4(); - sub_8023DA4(); - return TRUE; -} - -u32 sub_8023A94(bool8 a0) -{ - if (!a0) { - sub_8013660(&gUnknown_3001B60->unk358.s0.input); - return 0; - } - - switch (GetKeyPress(&gUnknown_3001B60->unk358.s0.input)) { - case INPUT_B_BUTTON: - PlayMenuSoundEffect(1); - return 2; - case INPUT_START_BUTTON: - PlayMenuSoundEffect(4); - return 4; - case INPUT_A_BUTTON: - PlayMenuSoundEffect(0); - return 3; - case INPUT_SELECT_BUTTON: - PlayMenuSoundEffect(5); - gUnknown_3001B60->sortMethod = (gUnknown_3001B60->sortMethod < 3) ? gUnknown_3001B60->sortMethod + 1 : 1; - sub_8023F8C(); - sub_8023CF4(); - sub_8023DA4(); - return 1; - default: - if (sub_80138B8(&gUnknown_3001B60->unk358.s0.input, TRUE)) { - sub_8023CF4(); - sub_8023DA4(); - return 1; - } - return 0; - } -} - -s32 sub_8023B44(void) -{ - return gUnknown_3001B60->unk1A[(gUnknown_3001B60->unk358.s0.input.unk1E * gUnknown_3001B60->unk358.s0.input.unk1C) + gUnknown_3001B60->unk358.s0.input.menuIndex]; -} - -void sub_8023B7C(bool8 addCursor) -{ - ResetUnusedInputStruct(); - ShowWindows(&gUnknown_3001B60->unk358.s0.windows, FALSE, FALSE); - gUnknown_3001B60->unk358.s0.input.unk22 = sub_8023BD8(); - sub_8013984(&gUnknown_3001B60->unk358.s0.input); - sub_8023CF4(); - sub_8023DA4(); - if (addCursor) { - AddMenuCursorSprite(&gUnknown_3001B60->unk358.s0.input); - } -} - -s32 sub_8023BD8(void) -{ - s32 i, j; - - for (i = 0; i < gUnknown_3001B60->unk8; i++) { - s32 id = gUnknown_3001B60->unk1A[i]; - if (!PokemonFlag1(&gRecruitedPokemonRef->pokemon[id])) { - gUnknown_3001B60->unk8--; - for (j = i; j < gUnknown_3001B60->unk8; j++) { - gUnknown_3001B60->unk1A[j] = gUnknown_3001B60->unk1A[j + 1]; - } - } - } - - return gUnknown_3001B60->unk8; -} - -void sub_8023C60(void) -{ - if (gUnknown_3001B60 != NULL) { - gUnknown_203B2A0 = gUnknown_3001B60->unk0; - gUnknown_203B2A4 = gUnknown_3001B60->sortMethod; - gUnknown_203B2A8 = gUnknown_3001B60->unk358.s0.input.menuIndex; - gUnknown_203B2AA = gUnknown_3001B60->unk358.s0.input.unk1E; - gUnknown_3001B60->unk358.s0.windows.id[gUnknown_3001B60->unk358.s0.winId] = sUnknown_80DC950; - ResetUnusedInputStruct(); - ShowWindows(&gUnknown_3001B60->unk358.s0.windows, TRUE, TRUE); - MemoryFree(gUnknown_3001B60); - gUnknown_3001B60 = NULL; - } -} - -struct unkStruct_3001B60 *sub_8023CE8(void) -{ - return gUnknown_3001B60; -} - -void sub_8023CF4(void) -{ - gUnknown_3001B60->unk358.header.count = 1; - gUnknown_3001B60->unk358.header.currId = 0; - gUnknown_3001B60->unk358.header.f3 = 0; - switch (gUnknown_3001B60->unk0) { - case 2: - gUnknown_3001B60->unk358.header.width = 12; - break; - case 4: - gUnknown_3001B60->unk358.header.width = 12; - break; - default: - gUnknown_3001B60->unk358.header.width = 12; - break; - } - - SUB_80095E4_CALL_2(gUnknown_3001B60->unk358.s0); -} - -void sub_8023DA4(void) -{ - s32 i, x; - u8 winTxtBuff[40]; - u8 nameTxtBuff[20]; - u8 txtBuff3[20]; - - CallPrepareTextbox_8008C54(gUnknown_3001B60->unk358.s0.winId); - sub_80073B8(gUnknown_3001B60->unk358.s0.winId); - switch (gUnknown_3001B60->unk0) { - case 2: - sub_80920D8(winTxtBuff); - PrintStringOnWindow(10, 0, winTxtBuff, gUnknown_3001B60->unk358.s0.winId, '\0'); - break; - case 4: - PrintStringOnWindow(10, 0, sUnknown_80DC980, gUnknown_3001B60->unk358.s0.winId, '\0'); - x = (gUnknown_3001B60->unk358.header.width * 8) + 4; - sub_8012BC4(x, 0, gUnknown_3001B60->unk358.s0.input.unk1E + 1, 2, 7, gUnknown_3001B60->unk358.s0.winId); - break; - default: - PrintStringOnWindow(10, 0, sUnknown_80DC988, gUnknown_3001B60->unk358.s0.winId, '\0'); - x = (gUnknown_3001B60->unk358.header.width * 8) + 4; - sub_8012BC4(x, 0, gUnknown_3001B60->unk358.s0.input.unk1E + 1, 2, 7, gUnknown_3001B60->unk358.s0.winId); - break; - } - - for (i = 0; i < gUnknown_3001B60->unk358.s0.input.unk1A; i++) { - s32 id = gUnknown_3001B60->unk1A[(gUnknown_3001B60->unk358.s0.input.unk1E * gUnknown_3001B60->unk358.s0.input.unk1C) + i]; - PokemonStruct1 *pokePtr = &gRecruitedPokemonRef->pokemon[id]; - s32 r6 = 7; - - if (PokemonFlag2(pokePtr)) { - if (IsMonPartner(pokePtr)) { - r6 = 6; - } - if (IsMonLeader(pokePtr)) { - r6 = 6; - } - if (pokePtr->isTeamLeader) { - r6 = 5; - } - } - else if (gUnknown_3001B60->unk18) { - if (sub_808D750(id)) { - r6 = 4; - } - else { - r6 = 2; - } - } - - if (gUnknown_3001B60->unk0 == 4) { - sub_8024184(pokePtr, gUnknown_3001B60->unk354); - } - // Needed to match. agbcc moment - else if (gUnknown_3001B60->unk0 == 2) { - - } - - sub_80922B4(nameTxtBuff, pokePtr->name, POKEMON_NAME_LENGTH); - sub_808D930(txtBuff3, pokePtr->speciesNum); - sprintfStatic(winTxtBuff, sUnknown_80DC998, r6, nameTxtBuff); - PrintStringOnWindow(8, GetMenuEntryYCoord(&gUnknown_3001B60->unk358.s0.input, i), winTxtBuff, gUnknown_3001B60->unk358.s0.winId, '\0'); - } - sub_80073E0(gUnknown_3001B60->unk358.s0.winId); -} - -s32 sub_8023F8C(void) -{ - s32 i; - PokemonStruct1 *pokeStruct; - - gUnknown_3001B60->unk8 = 0; - if (!gUnknown_3001B60->unk15) { - for (i = 0; i < NUM_MONSTERS; i++) { - pokeStruct = &gRecruitedPokemonRef->pokemon[i]; - if (pokeStruct->isTeamLeader && PokemonFlag1(pokeStruct)) { - gUnknown_3001B60->unk1A[gUnknown_3001B60->unk8++] = i; - break; - } - } - } - - if (!gUnknown_3001B60->unk16) { - for (i = 0; i < NUM_MONSTERS; i++) { - pokeStruct = &gRecruitedPokemonRef->pokemon[i]; - if (IsMonPartner(pokeStruct) && !pokeStruct->isTeamLeader && PokemonFlag2(pokeStruct) && PokemonFlag1(pokeStruct)) { - gUnknown_3001B60->unk1A[gUnknown_3001B60->unk8++] = i; - break; - } - } - } - gUnknown_3001B60->unkC = gUnknown_3001B60->unk8; - - if (!gUnknown_3001B60->unk17) { - for (i = 0; i < NUM_MONSTERS; i++) { - pokeStruct = &gRecruitedPokemonRef->pokemon[i]; - if (PokemonFlag2(pokeStruct) && PokemonFlag1(pokeStruct) && !pokeStruct->isTeamLeader && !IsMonPartner(pokeStruct)) { - gUnknown_3001B60->unk1A[gUnknown_3001B60->unk8++] = i; - if (gUnknown_3001B60->unk8 >= 4) { - break; - } - } - } - } - gUnknown_3001B60->unk10 = gUnknown_3001B60->unk8; - - if (!gUnknown_3001B60->unk14) { - for (i = 0; i < NUM_MONSTERS; i++) { - pokeStruct = &gRecruitedPokemonRef->pokemon[i]; - if (PokemonFlag1(pokeStruct) && !PokemonFlag2(&gRecruitedPokemonRef->pokemon[i])) { - gUnknown_3001B60->unk1A[gUnknown_3001B60->unk8++] = i; - } - } - } - - sub_80241A8(); - return gUnknown_3001B60->unk8; -} - -bool8 sub_8024108(s32 param_1) -{ - s32 i; - - for (i = 0; i < NUM_MONSTERS; i++) { - PokemonStruct1 *pokeStruct = &gRecruitedPokemonRef->pokemon[i]; - if (PokemonFlag1(pokeStruct)) { - if (param_1 == 2) { - if (!PokemonFlag2(pokeStruct)) continue; - } - else if (param_1 == 3) { - if (PokemonFlag2(pokeStruct)) continue; - } - else if (param_1 == 4) { - if (pokeStruct->isTeamLeader) continue; - if (!sub_80023E4(9)) { - if (!IsMonPartner(pokeStruct)) return FALSE; - if (PokemonFlag2(pokeStruct)) continue; - } - } - return FALSE; - } - } - return TRUE; -} - -//static // MAKE STATIC WHEN code_8023868.s IS DONE -bool8 sub_8024184(PokemonStruct1 *pokemon, u8 area) -{ - if (area == GetFriendArea(pokemon->speciesNum)) - return TRUE; - return FALSE; -} - -//static // MAKE STATIC WHEN code_8023868.s IS DONE -void sub_80241A8(void) -{ - switch (gUnknown_3001B60->sortMethod) { - case 2: - if (gUnknown_3001B60->unkC != gUnknown_3001B60->unk10) - SortbyAlphabetNo(gUnknown_3001B60->unkC, gUnknown_3001B60->unk10); - - if (gUnknown_3001B60->unk10 != gUnknown_3001B60->unk8) - SortbyAlphabetNo(gUnknown_3001B60->unk10, gUnknown_3001B60->unk8); - break; - case 3: - if (gUnknown_3001B60->unkC != gUnknown_3001B60->unk10) - SortbyName(gUnknown_3001B60->unkC, gUnknown_3001B60->unk10); - - if (gUnknown_3001B60->unk10 != gUnknown_3001B60->unk8) - SortbyName(gUnknown_3001B60->unk10, gUnknown_3001B60->unk8); - break; - case 1: - if (gUnknown_3001B60->unkC != gUnknown_3001B60->unk10) - SortbyInternalNo(gUnknown_3001B60->unkC, gUnknown_3001B60->unk10); - - if (gUnknown_3001B60->unk10 != gUnknown_3001B60->unk8) - SortbyInternalNo(gUnknown_3001B60->unk10, gUnknown_3001B60->unk8); - break; - } -} - -static void SortbyInternalNo(s32 startId, s32 arrId) -{ - s32 temp; - s32 i, j; - s16 *arrPtr = &gUnknown_3001B60->unk1A[arrId - 1]; - - for (i = startId; i < arrId - 1; i++) { - s16 *curr = arrPtr; - for (j = arrId - 1; j > i; j--) { - if (GetInternalNo(gRecruitedPokemonRef->pokemon[curr[-1]].speciesNum) > GetInternalNo(gRecruitedPokemonRef->pokemon[curr[0]].speciesNum)) { - SWAP(curr[0], curr[-1], temp); - } - curr--; - } - } -} - -static void SortbyAlphabetNo(s32 startId, s32 arrId) -{ - s32 temp; - s32 i, j; - s16 *arrPtr = &gUnknown_3001B60->unk1A[arrId - 1]; - - for (i = startId; i < arrId - 1; i++) { - s16 *curr = arrPtr; - for (j = arrId - 1; j > i; j--) { - if (GetAlphabetParentNo(gRecruitedPokemonRef->pokemon[curr[-1]].speciesNum, 0) > GetAlphabetParentNo(gRecruitedPokemonRef->pokemon[curr[0]].speciesNum, 0)) { - SWAP(curr[0], curr[-1], temp); - } - curr--; - } - } -} - -static void SortbyName(s32 startId, s32 arrId) -{ - s32 temp; - s32 i, j; - s16 *arrPtr = &gUnknown_3001B60->unk1A[arrId - 1]; - - for (i = startId; i < arrId - 1; i++) { - s16 * currPtr = arrPtr; - for (j = arrId - 1; j > i; j--) { - s16 *belowPtr = currPtr - 1; - if (ComparePokemonNames(*belowPtr, *currPtr)) { - SWAP(*currPtr, *belowPtr, temp); - } - currPtr--; - } - } -} - -UNUSED static PokemonStruct1 *sub_80243E8(void) -{ - u8 buffer[40]; - u8 nameBuffer[20]; - PokemonStruct1 *pokeStruct = &gRecruitedPokemonRef->pokemon[gUnknown_3001B60->unk1A[(gUnknown_3001B60->unk358.s0.input.unk1E * gUnknown_3001B60->unk358.s0.input.unk1C) + gUnknown_3001B60->unk358.s0.input.menuIndex]]; - - sub_80922B4(nameBuffer, pokeStruct->name, POKEMON_NAME_LENGTH); - sprintfStatic(buffer, sUnknown_80DC9A4, nameBuffer); - return pokeStruct; -} diff --git a/src/data/code_8023868.h b/src/data/code_8023868.h deleted file mode 100644 index 2222d6cb9..000000000 --- a/src/data/code_8023868.h +++ /dev/null @@ -1,27 +0,0 @@ -//static // MAKE STATIC WHEN code_8023868.s IS DONE -const WindowTemplate sUnknown_80DC950 = { - 0, - 3, - 0, 0, - 0, 0, - 0, 0, - NULL -}; -//static // MAKE STATIC WHEN code_8023868.s IS DONE -const WindowTemplate sUnknown_80DC968 = { - 0, - 6, - 2, 2, - 15, 14, - 14, 0, - NULL -}; - -ALIGNED(4) //static // MAKE STATIC WHEN code_8023868.s IS DONE -const u8 sUnknown_80DC980[] = _("Friends"); -ALIGNED(4) //static // MAKE STATIC WHEN code_8023868.s IS DONE -const u8 sUnknown_80DC988[] = _("Pokémon Friends"); -ALIGNED(4) //static // MAKE STATIC WHEN code_8023868.s IS DONE -const u8 sUnknown_80DC998[] = _("{color}%c%s{reset}"); -ALIGNED(4) //static // MAKE STATIC WHEN code_8023868.s IS DONE -const u8 sUnknown_80DC9A4[] = _("%s"); diff --git a/src/debug_menu4.c b/src/debug_menu4.c index ec236869f..a9ed900d2 100644 --- a/src/debug_menu4.c +++ b/src/debug_menu4.c @@ -1,7 +1,7 @@ #include "global.h" #include "globaldata.h" #include "code_801602C.h" -#include "code_8023868.h" +#include "friend_list.h" #include "debug_menu4.h" #include "input.h" #include "memory.h" @@ -109,13 +109,13 @@ static void sub_803AD88(void) { switch (sUnknown_203B3F8->state) { case 1: - sub_8023868(1, 0, 0, 10); + FriendList_Init(1, 0, 0, 10); break; case 2: sub_8023B7C(1); break; case 3: - sub_8023DA4(); + FriendList_ShowWindow(); sub_8012D60(&sUnknown_203B3F8->unk10, sUnknown_203B3F8->unk90, 0, sUnknown_203B3F8->unkD0, sUnknown_203B3F8->menuAction, 2); break; case 5: @@ -148,7 +148,7 @@ static void sub_803AE58(void) PrintStringOnWindow(4, 0, sNumberPrompt, sUnknown_203B3F8->unk60.unk14, 0); sub_8013C68(&sUnknown_203B3F8->unk60); sub_80073E0(sUnknown_203B3F8->unk60.unk14); - sub_8023DA4(); + FriendList_ShowWindow(); sub_8012EA4(&sUnknown_203B3F8->unk10, 0); } @@ -181,14 +181,14 @@ static void sub_803AEB0(void) static void sub_803AF38(void) { - switch (sub_8023A94(TRUE)) { + switch (FriendList_HandleInput(TRUE)) { case 3: - sUnknown_203B3F8->unk4 = sub_8023B44(); + sUnknown_203B3F8->unk4 = FriendList_GetCurrId(); sUnknown_203B3F8->pokemon = &gRecruitedPokemonRef->pokemon[sUnknown_203B3F8->unk4]; sub_803ACD0(3); break; case 2: - sub_8023C60(); + FriendList_Free(); sub_803ACD0(7); break; case 1: @@ -203,7 +203,7 @@ static void sub_803AF88(void) menuAction = 0; - sub_8023A94(FALSE); + FriendList_HandleInput(FALSE); if (sub_8012FD8(&sUnknown_203B3F8->unk10) == 0) sub_8013114(&sUnknown_203B3F8->unk10, &menuAction); @@ -225,7 +225,7 @@ static void sub_803AF88(void) static void sub_803AFE8(void) { - sub_8023A94(FALSE); + FriendList_HandleInput(FALSE); sub_8012FD8(&sUnknown_203B3F8->unk10); switch (sub_8013BBC(&sUnknown_203B3F8->unk60)) { diff --git a/src/friend_area_action_menu.c b/src/friend_area_action_menu.c index 996ff97f8..06dff887b 100644 --- a/src/friend_area_action_menu.c +++ b/src/friend_area_action_menu.c @@ -4,7 +4,7 @@ #include "code_801B3C0.h" #include "code_801EE10.h" #include "code_801EE10_mid.h" -#include "code_8023868.h" +#include "friend_list.h" #include "code_8024458.h" #include "code_8098BDC.h" #include "code_8099360.h" @@ -175,14 +175,14 @@ void sub_8027274(void) case FRIEND_AREA_ACTION_MENU_EXIT: break; case FRIEND_AREA_ACTION_MENU_MAIN: - sub_8023868(1,0,0,7); + FriendList_Init(1,0,0,7); break; case FRIEND_AREA_ACTION_MENU_MAIN_2: sub_8023B7C(1); break; case 3: sub_8027D40(3, &sUnknown_203B2BC->item2); - sub_8023DA4(); + FriendList_ShowWindow(); sub_8012D60(&sUnknown_203B2BC->unk7C, sUnknown_203B2BC->menuItems, 0, sUnknown_203B2BC->unk16C, sUnknown_203B2BC->menuAction1, 2); break; case FRIEND_AREA_ACTION_MENU_SUMMARY: @@ -383,12 +383,12 @@ void sub_80277FC(void) { PokemonStruct1 *pokeStruct; - switch(sub_8023A94(TRUE)) { + switch(FriendList_HandleInput(TRUE)) { case 0: case 1: break; case 3: - sUnknown_203B2BC->targetPoke = sub_8023B44(); + sUnknown_203B2BC->targetPoke = FriendList_GetCurrId(); pokeStruct = &gRecruitedPokemonRef->pokemon[sUnknown_203B2BC->targetPoke]; sUnknown_203B2BC->pokeStruct = pokeStruct; sUnknown_203B2BC->isTeamLeader = pokeStruct->isTeamLeader; @@ -396,7 +396,7 @@ void sub_80277FC(void) SetFriendAreaActionMenuState(3); break; case 4: - sUnknown_203B2BC->targetPoke = sub_8023B44(); + sUnknown_203B2BC->targetPoke = FriendList_GetCurrId(); pokeStruct = &gRecruitedPokemonRef->pokemon[sUnknown_203B2BC->targetPoke]; sUnknown_203B2BC->pokeStruct = pokeStruct; sUnknown_203B2BC->isTeamLeader = pokeStruct->isTeamLeader; @@ -404,7 +404,7 @@ void sub_80277FC(void) SetFriendAreaActionMenuState(4); break; case 2: - sub_8023C60(); + FriendList_Free(); SetFriendAreaActionMenuState(FRIEND_AREA_ACTION_MENU_EXIT); break; } @@ -417,7 +417,7 @@ void sub_80278B4(void) u32 menuAction; menuAction = 0; - sub_8023A94(FALSE); + FriendList_HandleInput(FALSE); if ((sub_8012FD8(&sUnknown_203B2BC->unk7C) == 0) && (sub_8013114(&sUnknown_203B2BC->unk7C,&menuAction), menuAction != FRIEND_AREA_ACTION_MENU_ACTION_NONE)) { sUnknown_203B2BC->menuAction1 = menuAction; } diff --git a/src/friend_list.c b/src/friend_list.c new file mode 100644 index 000000000..3c43f103d --- /dev/null +++ b/src/friend_list.c @@ -0,0 +1,476 @@ +#include "global.h" +#include "globaldata.h" +#include "friend_list.h" +#include "code_800D090.h" +#include "code_80118A4.h" +#include "pokemon.h" +#include "structs/str_text.h" +#include "text_util.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" +#include "event_flag.h" +#include "menu_input.h" +#include "rescue_team_info.h" +#include "input.h" +#include "memory.h" +#include "ground_map_1.h" +#include "constants/input.h" + +extern bool8 sub_808D750(s32 index_); + +static IWRAM_INIT struct unkStruct_3001B60 *sFriendList = {NULL}; + +static void SortbyAlphabetNo(s32, s32); +static void SortbyInternalNo(s32, s32); +static void SortbyName(s32, s32); +static bool8 MonHasFriendArea(PokemonStruct1 *pokemon, u8 area); +static void SortNames(void); +static void SetUpWindowHeader(void); +static s32 sub_8023BD8(void); +static s32 sub_8023F8C(void); + +extern s32 gUnknown_203B2A0; +extern s32 gUnknown_203B2A4; +extern u16 gUnknown_203B2A8; +extern u16 gUnknown_203B2AA; + +static const WindowTemplate sDummyWinTemplate = WIN_TEMPLATE_DUMMY; + +static const WindowTemplate sUnknown_80DC968 = { + .unk0 = 0, + .type = WINDOW_TYPE_WITH_HEADER, + .pos = {2, 2}, + .width = 15, + .height = 14, + .unk10 = 14, + .unk12 = 0, + .header = NULL +}; + +bool8 FriendList_Init(u32 r5, u32 windowId, DungeonPos *pos, u32 r10) +{ + if (sub_8024108(r5)) { + return FALSE; + } + + if (sFriendList == NULL) { + sFriendList = MemoryAlloc(sizeof(*sFriendList), 8); + } + + sFriendList->unk0 = r5; + if (gUnknown_203B2A0 != r5) { + sFriendList->sortMethod = 1; + } + else { + sFriendList->sortMethod = gUnknown_203B2A4; + } + + sFriendList->unk14 = 0; + sFriendList->unk15 = 0; + sFriendList->unk16 = 0; + sFriendList->unk17 = 0; + sFriendList->unk18 = 0; + switch (sFriendList->unk0) { + case 0: + break; + case 1: + sFriendList->unk18 = 1; + break; + case 2: + sFriendList->unk14 = 1; + break; + case 3: + sFriendList->unk17 = 1; + sFriendList->unk15 = 1; + sFriendList->unk16 = 1; + break; + case 4: + sFriendList->unk18 = 1; + sFriendList->unk15 = 1; + if (!sub_80023E4(9)) { + sFriendList->unk16 = 1; + } + break; + } + + if (sFriendList->unk0 == 4) { + sFriendList->unk354 = sub_8002658(sub_80A5728()); + } + else { + sFriendList->unk354 = 0; + } + + sFriendList->unk358.s0.winId = windowId; + sFriendList->unk358.s0.unk38 = &sFriendList->unk358.s0.windows.id[windowId]; + RestoreSavedWindows(&sFriendList->unk358.s0.windows); + sFriendList->unk358.s0.windows.id[sFriendList->unk358.s0.winId] = sUnknown_80DC968; + sFriendList->unk358.s0.unk38->header = &sFriendList->unk358.header; + if (pos != NULL) { + sFriendList->unk358.s0.windows.id[sFriendList->unk358.s0.winId].pos = *pos; + } + sub_8012D08(sFriendList->unk358.s0.unk38, r10); + ResetUnusedInputStruct(); + ShowWindows(&sFriendList->unk358.s0.windows, TRUE, TRUE); + sub_8013818(&sFriendList->unk358.s0.input, sub_8023F8C(), r10, windowId); + if (gUnknown_203B2A0 == sFriendList->unk0) { + sFriendList->unk358.s0.input.menuIndex = gUnknown_203B2A8; + sFriendList->unk358.s0.input.unk1E = gUnknown_203B2AA; + sub_8013984(&sFriendList->unk358.s0.input); + } + SetUpWindowHeader(); + FriendList_ShowWindow(); + return TRUE; +} + +u32 FriendList_HandleInput(bool8 a0) +{ + if (!a0) { + sub_8013660(&sFriendList->unk358.s0.input); + return 0; + } + + switch (GetKeyPress(&sFriendList->unk358.s0.input)) { + case INPUT_B_BUTTON: + PlayMenuSoundEffect(1); + return 2; + case INPUT_START_BUTTON: + PlayMenuSoundEffect(4); + return 4; + case INPUT_A_BUTTON: + PlayMenuSoundEffect(0); + return 3; + case INPUT_SELECT_BUTTON: + PlayMenuSoundEffect(5); + sFriendList->sortMethod = (sFriendList->sortMethod < 3) ? sFriendList->sortMethod + 1 : 1; + sub_8023F8C(); + SetUpWindowHeader(); + FriendList_ShowWindow(); + return 1; + default: + if (sub_80138B8(&sFriendList->unk358.s0.input, TRUE)) { + SetUpWindowHeader(); + FriendList_ShowWindow(); + return 1; + } + return 0; + } +} + +s32 FriendList_GetCurrId(void) +{ + return sFriendList->unk1A[(sFriendList->unk358.s0.input.unk1E * sFriendList->unk358.s0.input.unk1C) + sFriendList->unk358.s0.input.menuIndex]; +} + +void sub_8023B7C(bool8 addCursor) +{ + ResetUnusedInputStruct(); + ShowWindows(&sFriendList->unk358.s0.windows, FALSE, FALSE); + sFriendList->unk358.s0.input.unk22 = sub_8023BD8(); + sub_8013984(&sFriendList->unk358.s0.input); + SetUpWindowHeader(); + FriendList_ShowWindow(); + if (addCursor) { + AddMenuCursorSprite(&sFriendList->unk358.s0.input); + } +} + +static s32 sub_8023BD8(void) +{ + s32 i, j; + + for (i = 0; i < sFriendList->unk8; i++) { + s32 id = sFriendList->unk1A[i]; + if (!PokemonFlag1(&gRecruitedPokemonRef->pokemon[id])) { + sFriendList->unk8--; + for (j = i; j < sFriendList->unk8; j++) { + sFriendList->unk1A[j] = sFriendList->unk1A[j + 1]; + } + } + } + + return sFriendList->unk8; +} + +void FriendList_Free(void) +{ + if (sFriendList != NULL) { + gUnknown_203B2A0 = sFriendList->unk0; + gUnknown_203B2A4 = sFriendList->sortMethod; + gUnknown_203B2A8 = sFriendList->unk358.s0.input.menuIndex; + gUnknown_203B2AA = sFriendList->unk358.s0.input.unk1E; + sFriendList->unk358.s0.windows.id[sFriendList->unk358.s0.winId] = sDummyWinTemplate; + ResetUnusedInputStruct(); + ShowWindows(&sFriendList->unk358.s0.windows, TRUE, TRUE); + MemoryFree(sFriendList); + sFriendList = NULL; + } +} + +struct unkStruct_3001B60 *FriendList_GetPtr(void) +{ + return sFriendList; +} + +static void SetUpWindowHeader(void) +{ + sFriendList->unk358.header.count = 1; + sFriendList->unk358.header.currId = 0; + sFriendList->unk358.header.f3 = 0; + switch (sFriendList->unk0) { + case 2: + sFriendList->unk358.header.width = 12; + break; + case 4: + sFriendList->unk358.header.width = 12; + break; + default: + sFriendList->unk358.header.width = 12; + break; + } + + SUB_80095E4_CALL_2(sFriendList->unk358.s0); +} + +void FriendList_ShowWindow(void) +{ + s32 i, x; + u8 winTxtBuff[40]; + u8 nameTxtBuff[POKEMON_NAME_LENGTH * 2]; + u8 txtBuff3[20]; + + CallPrepareTextbox_8008C54(sFriendList->unk358.s0.winId); + sub_80073B8(sFriendList->unk358.s0.winId); + switch (sFriendList->unk0) { + case 2: + sub_80920D8(winTxtBuff); + PrintStringOnWindow(10, 0, winTxtBuff, sFriendList->unk358.s0.winId, '\0'); + break; + case 4: + PrintStringOnWindow(10, 0, "Friends", sFriendList->unk358.s0.winId, '\0'); + x = (sFriendList->unk358.header.width * 8) + 4; + sub_8012BC4(x, 0, sFriendList->unk358.s0.input.unk1E + 1, 2, 7, sFriendList->unk358.s0.winId); + break; + default: + PrintStringOnWindow(10, 0, _("Pokémon Friends"), sFriendList->unk358.s0.winId, '\0'); + x = (sFriendList->unk358.header.width * 8) + 4; + sub_8012BC4(x, 0, sFriendList->unk358.s0.input.unk1E + 1, 2, 7, sFriendList->unk358.s0.winId); + break; + } + + for (i = 0; i < sFriendList->unk358.s0.input.unk1A; i++) { + s32 id = sFriendList->unk1A[(sFriendList->unk358.s0.input.unk1E * sFriendList->unk358.s0.input.unk1C) + i]; + PokemonStruct1 *pokePtr = &gRecruitedPokemonRef->pokemon[id]; + u8 color = 7; + + if (PokemonFlag2(pokePtr)) { + if (IsMonPartner(pokePtr)) { + color = 6; + } + if (IsMonLeader(pokePtr)) { + color = 6; + } + if (pokePtr->isTeamLeader) { + color = 5; + } + } + else if (sFriendList->unk18) { + if (sub_808D750(id)) { + color = 4; + } + else { + color = 2; + } + } + + // This code doesn't do anything, but it's needed to match. + if (sFriendList->unk0 == 4 && MonHasFriendArea(pokePtr, sFriendList->unk354)) { + ; + } + else if (sFriendList->unk0 == 2) { + ; + } + + sub_80922B4(nameTxtBuff, pokePtr->name, POKEMON_NAME_LENGTH); + sub_808D930(txtBuff3, pokePtr->speciesNum); + sprintfStatic(winTxtBuff, _("{color}%c%s{reset}"), color, nameTxtBuff); + PrintStringOnWindow(8, GetMenuEntryYCoord(&sFriendList->unk358.s0.input, i), winTxtBuff, sFriendList->unk358.s0.winId, '\0'); + } + sub_80073E0(sFriendList->unk358.s0.winId); +} + +static s32 sub_8023F8C(void) +{ + s32 i; + PokemonStruct1 *pokeStruct; + + sFriendList->unk8 = 0; + if (!sFriendList->unk15) { + for (i = 0; i < NUM_MONSTERS; i++) { + pokeStruct = &gRecruitedPokemonRef->pokemon[i]; + if (pokeStruct->isTeamLeader && PokemonFlag1(pokeStruct)) { + sFriendList->unk1A[sFriendList->unk8++] = i; + break; + } + } + } + + if (!sFriendList->unk16) { + for (i = 0; i < NUM_MONSTERS; i++) { + pokeStruct = &gRecruitedPokemonRef->pokemon[i]; + if (IsMonPartner(pokeStruct) && !pokeStruct->isTeamLeader && PokemonFlag2(pokeStruct) && PokemonFlag1(pokeStruct)) { + sFriendList->unk1A[sFriendList->unk8++] = i; + break; + } + } + } + sFriendList->unkC = sFriendList->unk8; + + if (!sFriendList->unk17) { + for (i = 0; i < NUM_MONSTERS; i++) { + pokeStruct = &gRecruitedPokemonRef->pokemon[i]; + if (PokemonFlag2(pokeStruct) && PokemonFlag1(pokeStruct) && !pokeStruct->isTeamLeader && !IsMonPartner(pokeStruct)) { + sFriendList->unk1A[sFriendList->unk8++] = i; + if (sFriendList->unk8 >= 4) { + break; + } + } + } + } + sFriendList->unk10 = sFriendList->unk8; + + if (!sFriendList->unk14) { + for (i = 0; i < NUM_MONSTERS; i++) { + pokeStruct = &gRecruitedPokemonRef->pokemon[i]; + if (PokemonFlag1(pokeStruct) && !PokemonFlag2(&gRecruitedPokemonRef->pokemon[i])) { + sFriendList->unk1A[sFriendList->unk8++] = i; + } + } + } + + SortNames(); + return sFriendList->unk8; +} + +bool8 sub_8024108(s32 param_1) +{ + s32 i; + + for (i = 0; i < NUM_MONSTERS; i++) { + PokemonStruct1 *pokeStruct = &gRecruitedPokemonRef->pokemon[i]; + if (PokemonFlag1(pokeStruct)) { + if (param_1 == 2) { + if (!PokemonFlag2(pokeStruct)) continue; + } + else if (param_1 == 3) { + if (PokemonFlag2(pokeStruct)) continue; + } + else if (param_1 == 4) { + if (pokeStruct->isTeamLeader) continue; + if (!sub_80023E4(9)) { + if (!IsMonPartner(pokeStruct)) return FALSE; + if (PokemonFlag2(pokeStruct)) continue; + } + } + return FALSE; + } + } + return TRUE; +} + +static bool8 MonHasFriendArea(PokemonStruct1 *pokemon, u8 area) +{ + if (area == GetFriendArea(pokemon->speciesNum)) + return TRUE; + return FALSE; +} + +static void SortNames(void) +{ + switch (sFriendList->sortMethod) { + case 2: + if (sFriendList->unkC != sFriendList->unk10) + SortbyAlphabetNo(sFriendList->unkC, sFriendList->unk10); + + if (sFriendList->unk10 != sFriendList->unk8) + SortbyAlphabetNo(sFriendList->unk10, sFriendList->unk8); + break; + case 3: + if (sFriendList->unkC != sFriendList->unk10) + SortbyName(sFriendList->unkC, sFriendList->unk10); + + if (sFriendList->unk10 != sFriendList->unk8) + SortbyName(sFriendList->unk10, sFriendList->unk8); + break; + case 1: + if (sFriendList->unkC != sFriendList->unk10) + SortbyInternalNo(sFriendList->unkC, sFriendList->unk10); + + if (sFriendList->unk10 != sFriendList->unk8) + SortbyInternalNo(sFriendList->unk10, sFriendList->unk8); + break; + } +} + +static void SortbyInternalNo(s32 startId, s32 arrId) +{ + s32 temp; + s32 i, j; + s16 *arrPtr = &sFriendList->unk1A[arrId - 1]; + + for (i = startId; i < arrId - 1; i++) { + s16 *curr = arrPtr; + for (j = arrId - 1; j > i; j--) { + if (GetInternalNo(gRecruitedPokemonRef->pokemon[curr[-1]].speciesNum) > GetInternalNo(gRecruitedPokemonRef->pokemon[curr[0]].speciesNum)) { + SWAP(curr[0], curr[-1], temp); + } + curr--; + } + } +} + +static void SortbyAlphabetNo(s32 startId, s32 arrId) +{ + s32 temp; + s32 i, j; + s16 *arrPtr = &sFriendList->unk1A[arrId - 1]; + + for (i = startId; i < arrId - 1; i++) { + s16 *curr = arrPtr; + for (j = arrId - 1; j > i; j--) { + if (GetAlphabetParentNo(gRecruitedPokemonRef->pokemon[curr[-1]].speciesNum, 0) > GetAlphabetParentNo(gRecruitedPokemonRef->pokemon[curr[0]].speciesNum, 0)) { + SWAP(curr[0], curr[-1], temp); + } + curr--; + } + } +} + +static void SortbyName(s32 startId, s32 arrId) +{ + s32 temp; + s32 i, j; + s16 *arrPtr = &sFriendList->unk1A[arrId - 1]; + + for (i = startId; i < arrId - 1; i++) { + s16 * currPtr = arrPtr; + for (j = arrId - 1; j > i; j--) { + s16 *belowPtr = currPtr - 1; + if (ComparePokemonNames(*belowPtr, *currPtr)) { + SWAP(*currPtr, *belowPtr, temp); + } + currPtr--; + } + } +} + +UNUSED static PokemonStruct1 *sub_80243E8(void) +{ + u8 buffer[40]; + u8 nameBuffer[20]; + PokemonStruct1 *pokeStruct = &gRecruitedPokemonRef->pokemon[sFriendList->unk1A[(sFriendList->unk358.s0.input.unk1E * sFriendList->unk358.s0.input.unk1C) + sFriendList->unk358.s0.input.menuIndex]]; + + sub_80922B4(nameBuffer, pokeStruct->name, POKEMON_NAME_LENGTH); + sprintfStatic(buffer, "%s", nameBuffer); + return pokeStruct; +} diff --git a/src/friend_list_menu.c b/src/friend_list_menu.c index 9afb0977e..7c8a78298 100644 --- a/src/friend_list_menu.c +++ b/src/friend_list_menu.c @@ -6,7 +6,7 @@ #include "code_801B3C0.h" #include "code_801EE10.h" #include "code_801EE10_mid.h" -#include "code_8023868.h" +#include "friend_list.h" #include "code_8024458.h" #include "code_8098BDC.h" #include "code_8099360.h" @@ -188,7 +188,7 @@ void sub_8025518(void) if (gUnknown_203B2B4->unk0 == 0) { uVar3 = 2; } - sub_8023868(uVar3,0,0,10); + FriendList_Init(uVar3,0,0,10); break; case 2: sub_8023B7C(1); @@ -197,7 +197,7 @@ void sub_8025518(void) if (gUnknown_203B2B4->unk0 == 0) { sub_8025E68(3,&gUnknown_203B2B4->item2); } - sub_8023DA4(); + FriendList_ShowWindow(); PrintColoredPokeNameToBuffer(gFormatBuffer_Monsters[0],gUnknown_203B2B4->pokeStruct,7); PrintColoredPokeNameToBuffer(gFormatBuffer_Monsters[1],gUnknown_203B2B4->pokeStruct,6); sub_8012D60(&gUnknown_203B2B4->unk78,gUnknown_203B2B4->unkC8,0,gUnknown_203B2B4->unk108,gUnknown_203B2B4->menuAction1,2); @@ -371,22 +371,22 @@ void sub_802591C(void) void sub_80259F0(void) { - switch(sub_8023A94(TRUE)) + switch(FriendList_HandleInput(TRUE)) { case 3: - gUnknown_203B2B4->species = sub_8023B44(); + gUnknown_203B2B4->species = FriendList_GetCurrId(); gUnknown_203B2B4->pokeStruct = &gRecruitedPokemonRef->pokemon[gUnknown_203B2B4->species]; PeekPokemonItem(gUnknown_203B2B4->species, &gUnknown_203B2B4->item2); SetFriendListMenuState(3); break; case 4: - gUnknown_203B2B4->species = sub_8023B44(); + gUnknown_203B2B4->species = FriendList_GetCurrId(); gUnknown_203B2B4->pokeStruct = &gRecruitedPokemonRef->pokemon[gUnknown_203B2B4->species]; PeekPokemonItem(gUnknown_203B2B4->species, &gUnknown_203B2B4->item2); SetFriendListMenuState(FRIEND_LIST_MENU_STATE_SUMMARY); break; case 2: - sub_8023C60(); + FriendList_Free(); SetFriendListMenuState(FRIEND_LIST_MENU_STATE_EXIT); break; } @@ -396,7 +396,7 @@ void sub_8025A84(void) { s32 menuAction = 0; - sub_8023A94(FALSE); + FriendList_HandleInput(FALSE); if(!sub_8012FD8(&gUnknown_203B2B4->unk78)) { sub_8013114(&gUnknown_203B2B4->unk78, &menuAction); @@ -406,7 +406,7 @@ void sub_8025A84(void) { case FRIEND_LIST_MENU_VISIT: gUnknown_203B2B4->unkD = GetFriendArea(gUnknown_203B2B4->pokeStruct->speciesNum); - sub_8023C60(); + FriendList_Free(); SetFriendListMenuState(FRIEND_LIST_MENU_STATE_EXIT); break; case FRIEND_LIST_MENU_GIVE: @@ -429,7 +429,7 @@ void sub_8025A84(void) gUnknown_203B2B4->pokeStruct->unk0 &= ~(FLAG_ON_TEAM); nullsub_104(); sub_808ED00(); - sub_8023C60(); + FriendList_Free(); SetFriendListMenuState(FRIEND_LIST_MENU_STATE_STANDBY); break; case FRIEND_LIST_MENU_MOVES: diff --git a/src/friend_rescue.c b/src/friend_rescue.c index 8ec5e3ba1..27cb19f60 100644 --- a/src/friend_rescue.c +++ b/src/friend_rescue.c @@ -7,7 +7,7 @@ #include "code_80118A4.h" #include "code_801B3C0.h" #include "code_801C8C4.h" -#include "code_8023868.h" +#include "friend_list.h" #include "code_8024458.h" #include "code_802F204.h" #include "code_8094F88.h" @@ -304,7 +304,7 @@ extern u32 sub_8039068(u32, u8 *passwordBuffer, unkStruct_203B480 *r0); extern void sub_8031E10(void); extern u8 sub_800D588(void); -extern u32 sub_8023CE8(void); +extern u32 FriendList_GetPtr(void); extern bool8 sub_8031D70(u32 mailIndex, s32); extern u32 GetDungeonTeamRankPts(DungeonLocation *, u32); @@ -687,7 +687,7 @@ void CleanFriendRescueMenu(void) gUnknown_203B33C = NULL; sub_803084C(); sub_8031E10(); - sub_8023C60(); + FriendList_Free(); sub_80155F0(); sub_801CBB8(); sub_802F2C0(); @@ -894,16 +894,16 @@ void sub_8032828(void) CreateDialogueBoxAndPortrait(&gUnknown_80E2C48[0], 0, 0, 0x101); break; case 0x26: - if (sub_8023CE8() != 0) - sub_8023C60(); + if (FriendList_GetPtr() != 0) + FriendList_Free(); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); - sub_8023868(3, 0, 0, 9); + FriendList_Init(3, 0, 0, 9); break; case 0x27: RestoreSavedWindows(&gUnknown_203B33C->unk35C); SetMenuItems(gUnknown_203B33C->unk21C, &gUnknown_203B33C->unk35C, 3, &gUnknown_80E2334, gUnknown_80E234C, TRUE, 0, FALSE); - sub_8023DA4(); + FriendList_ShowWindow(); sub_8035CF4(gUnknown_203B33C->unk21C, 3, 1); break; case 0x24: @@ -1857,16 +1857,16 @@ void sub_8034130(void) void sub_803418C(void) { - switch(sub_8023A94(TRUE)) + switch(FriendList_HandleInput(TRUE)) { case 2: - sub_8023C60(); + FriendList_Free(); SetFriendRescueMenuState(FRIEND_RESCUE_MENU_MAIN); sub_8035D1C(); gUnknown_203B33C->speciesNum = -1; break; case 3: - gUnknown_203B33C->speciesNum = sub_8023B44(); + gUnknown_203B33C->speciesNum = FriendList_GetCurrId(); if(gUnknown_203B33C->unk524 == 0xE) SetFriendRescueMenuState(9); else @@ -1874,7 +1874,7 @@ void sub_803418C(void) break; case 4: gUnknown_203B33C->fallbackState = 0x26; - gUnknown_203B33C->speciesNum = sub_8023B44(); + gUnknown_203B33C->speciesNum = FriendList_GetCurrId(); RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); @@ -1889,13 +1889,13 @@ void sub_8034254(void) s32 menuAction; menuAction = -1; - sub_8023A94(FALSE); + FriendList_HandleInput(FALSE); if(!sub_8012FD8(&gUnknown_203B33C->unk21C[3])) sub_8013114(&gUnknown_203B33C->unk21C[3], &menuAction); switch(menuAction) { case 9: - sub_8023C60(); + FriendList_Free(); SetFriendRescueMenuState(0x29); break; case 10: @@ -1909,7 +1909,7 @@ void sub_8034254(void) case 5: case 8: sub_8035CC0(&gUnknown_203B33C->unk35C, 3); - sub_8023DA4(); + FriendList_ShowWindow(); SetFriendRescueMenuState(0x26); break; } diff --git a/src/gulpin_shop_801FB50.c b/src/gulpin_shop_801FB50.c index 3a049c240..3f4f11a1b 100644 --- a/src/gulpin_shop_801FB50.c +++ b/src/gulpin_shop_801FB50.c @@ -3,7 +3,7 @@ #include "code_80118A4.h" #include "code_801EE10.h" #include "code_801EE10_mid.h" -#include "code_8023868.h" +#include "friend_list.h" #include "code_8024458.h" #include "common_strings.h" #include "felicity_bank.h" @@ -306,13 +306,13 @@ static void sub_801FF28(void) CreateDialogueBoxAndPortrait(gCommonGulpin[gUnknown_203B27C->mode][GULPIN_DLG_08],0,gUnknown_203B27C->monPortraitPtr,0x10d); break; case 0xf: - sub_8023868(2,0,0,10); + FriendList_Init(2,0,0,10); break; case 0x10: sub_8023B7C(1); break; case 0x11: - sub_8023DA4(); + FriendList_ShowWindow(); sub_8012D60(&gUnknown_203B27C->unkCC,gUnknown_203B27C->unk7C,0,gUnknown_203B27C->unkBC,gUnknown_203B27C->menuAction2,2); break; case 0x12: @@ -682,17 +682,17 @@ static void sub_8020A34(void) static void sub_8020A80(void) { - switch(sub_8023A94(TRUE)) + switch(FriendList_HandleInput(TRUE)) { case 3: - gUnknown_203B27C->speciesNum = sub_8023B44(); + gUnknown_203B27C->speciesNum = FriendList_GetCurrId(); gUnknown_203B27C->pokeStruct = &gRecruitedPokemonRef->pokemon[gUnknown_203B27C->speciesNum]; gUnknown_203B27C->isTeamLeader = gUnknown_203B27C->pokeStruct->isTeamLeader; PrintPokeNameToBuffer(gFormatBuffer_Monsters[5], gUnknown_203B27C->pokeStruct); sub_801FDA8(0x11); break; case 4: - gUnknown_203B27C->speciesNum = sub_8023B44(); + gUnknown_203B27C->speciesNum = FriendList_GetCurrId(); gUnknown_203B27C->pokeStruct = &gRecruitedPokemonRef->pokemon[gUnknown_203B27C->speciesNum]; gUnknown_203B27C->isTeamLeader = gUnknown_203B27C->pokeStruct->isTeamLeader; PrintPokeNameToBuffer(gFormatBuffer_Monsters[5], gUnknown_203B27C->pokeStruct); @@ -702,7 +702,7 @@ static void sub_8020A80(void) case 1: break; case 2: - sub_8023C60(); + FriendList_Free(); sub_801FDA8(7); break; } @@ -713,7 +713,7 @@ static void sub_8020B38(void) s32 menuAction; menuAction = 0; - sub_8023A94(FALSE); + FriendList_HandleInput(FALSE); if (!sub_8012FD8(&gUnknown_203B27C->unkCC)) { sub_8013114(&gUnknown_203B27C->unkCC,&menuAction); if (menuAction != CANCEL_ACTION) { diff --git a/src/wonder_mail.c b/src/wonder_mail.c index 8528a1391..c2a4207b4 100644 --- a/src/wonder_mail.c +++ b/src/wonder_mail.c @@ -2,7 +2,7 @@ #include "globaldata.h" #include "constants/communication_error_codes.h" #include "code_80118A4.h" -#include "code_8023868.h" +#include "friend_list.h" #include "code_8024458.h" #include "code_8094F88.h" #include "code_80A26CC.h" @@ -39,7 +39,7 @@ extern void sub_8031E10(); extern void sub_8031E00(); extern void sub_8031E10(void); extern void sub_8031D70(u8, u32); -extern u32 sub_8023CE8(void); +extern u32 FriendList_GetPtr(void); extern void sub_8030F58(u32); extern void sub_8029B34(void); extern void sub_8029AD8(void); @@ -401,7 +401,7 @@ void sub_80282FC(void) MemoryFree(sUnknown_203B2C0); sUnknown_203B2C0 = NULL; sub_8031E10(); - sub_8023C60(); + FriendList_Free(); sub_803084C(); sub_80155F0(); sub_80310B4(); @@ -454,17 +454,17 @@ void sub_8028348(void) CreateDialogueBoxAndPortrait(gUnknown_80DDCBC, 0, 0,0x101); break; case SELECT_HELPER_POKEMON: - if(sub_8023CE8() == 0) + if(FriendList_GetPtr() == 0) { ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); - sub_8023868(3, 0, 0, 9); + FriendList_Init(3, 0, 0, 9); } break; case 0x34: RestoreSavedWindows(&sUnknown_203B2C0->unk35C); SetMenuItems(sUnknown_203B2C0->unk21C, &sUnknown_203B2C0->unk35C, 3, &gUnknown_80DDAE4, gUnknown_80DDAFC, TRUE, 0, FALSE); - sub_8023DA4(); + FriendList_ShowWindow(); sub_8035CF4(sUnknown_203B2C0->unk21C, 3, TRUE); break; case NO_POKEMON_IN_FRIEND_AREA: @@ -1559,20 +1559,20 @@ void sub_80297B8(void) void sub_80297D4(void) { - switch(sub_8023A94(TRUE)) + switch(FriendList_HandleInput(TRUE)) { case 2: - sub_8023C60(); + FriendList_Free(); SetFriendRescueCounterState(FRIEND_RESCUE_MAIN); sUnknown_203B2C0->speciesNum = -1; break; case 3: - sUnknown_203B2C0->speciesNum = sub_8023B44(); + sUnknown_203B2C0->speciesNum = FriendList_GetCurrId(); SetFriendRescueCounterState(0x34); break; case 4: sUnknown_203B2C0->fallbackState = SELECT_HELPER_POKEMON; - sUnknown_203B2C0->speciesNum = sub_8023B44(); + sUnknown_203B2C0->speciesNum = FriendList_GetCurrId(); RestoreSavedWindows(&sUnknown_203B2C0->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); @@ -1586,7 +1586,7 @@ void sub_8029884(void) { s32 menuAction; menuAction = -1; - sub_8023A94(FALSE); + FriendList_HandleInput(FALSE); if(sub_8012FD8(&(sUnknown_203B2C0->unk21C[3])) == 0) { sub_8013114(&(sUnknown_203B2C0->unk21C[3]), &menuAction); @@ -1594,7 +1594,7 @@ void sub_8029884(void) switch(menuAction) { case CONFIRM_ACTION: - sub_8023C60(); + FriendList_Free(); SetFriendRescueCounterState(4); break; case INFO_ACTION: diff --git a/sym_iwram_init.txt b/sym_iwram_init.txt index 08fa71ef3..1af424969 100644 --- a/sym_iwram_init.txt +++ b/sym_iwram_init.txt @@ -2,7 +2,7 @@ .include "src/code_80035F0.o" .include "src/code_8023144.o" -.include "src/code_8023868.o" +.include "src/friend_list.o" .include "src/code_809A560.o" .include "src/code_809C5C4.o" .include "src/ground_map.o"