From 2c706fbc3b24717df2416d8bd58736463aa7c09f Mon Sep 17 00:00:00 2001 From: h2o-DS <71458559+h2o-DS@users.noreply.github.com> Date: Sun, 26 Jan 2025 21:32:32 -0500 Subject: [PATCH 1/2] Pokedex_Search ov21_021D85B0 -> pokedex_search Moved UnkStruct_ov21_021D157C to ov21_021D0D80 and renamed PokedexLoadingScreen Cleaned up pokedex_sort enums --- include/overlay021/ov21_021D0D80.h | 17 +- include/overlay021/ov21_021D85B0.h | 26 - include/overlay021/pokedex_search.h | 35 + include/overlay021/pokedex_sort.h | 16 +- include/overlay021/struct_ov21_021D157C.h | 20 - include/overlay021/struct_ov21_021D3320.h | 2 +- platinum.us/main.lsf | 2 +- src/meson.build | 2 +- src/overlay021/ov21_021D0D80.c | 61 +- src/overlay021/ov21_021D5AEC.c | 29 +- src/overlay021/ov21_021D85B0.c | 1108 --------------------- src/overlay021/ov21_021D94BC.c | 104 +- src/overlay021/pokedex_height_check.c | 35 +- src/overlay021/pokedex_search.c | 1074 ++++++++++++++++++++ src/overlay021/pokedex_sort.c | 4 +- 15 files changed, 1246 insertions(+), 1289 deletions(-) delete mode 100644 include/overlay021/ov21_021D85B0.h create mode 100644 include/overlay021/pokedex_search.h delete mode 100644 include/overlay021/struct_ov21_021D157C.h delete mode 100644 src/overlay021/ov21_021D85B0.c create mode 100644 src/overlay021/pokedex_search.c diff --git a/include/overlay021/ov21_021D0D80.h b/include/overlay021/ov21_021D0D80.h index 42c8aa58b1..cc71ed0cb2 100644 --- a/include/overlay021/ov21_021D0D80.h +++ b/include/overlay021/ov21_021D0D80.h @@ -6,7 +6,6 @@ #include "overlay021/struct_ov21_021D0D80.h" #include "overlay021/struct_ov21_021D0F60_decl.h" #include "overlay021/struct_ov21_021D13FC.h" -#include "overlay021/struct_ov21_021D157C.h" #include "overlay021/struct_ov21_021D22F8.h" #include "overlay021/struct_ov21_021D3320.h" #include "overlay021/struct_ov21_021D3FE0_decl.h" @@ -22,6 +21,18 @@ #include "strbuf.h" #include "touch_screen.h" +typedef struct { + BgConfig *config; + NNSG2dScreenData *screenData; + int layer; + int topStart; + int bottomStart; + int topDist; + int bottomDist; + int counter; + int duration; +} PokedexLoadingScreen; + int ov21_021D0D80(OverlayManager *param0, int *param1); int ov21_021D0E3C(OverlayManager *param0, int *param1); int ov21_021D0EC8(OverlayManager *param0, int *param1); @@ -51,8 +62,8 @@ void ov21_021D144C(CellActor *param0, int param1); void ov21_021D1498(CellActor *param0, UnkStruct_ov21_021D4CA0 *param1, int param2); void ov21_021D1524(CellActor *param0, UnkStruct_ov21_021D4CA0 *param1, int param2, int param3, int param4); void ov21_021D154C(TouchScreenHitTable *hitTable, int param1, int param2, int param3, int param4); -void ov21_021D1558(UnkStruct_ov21_021D157C *param0, BgConfig *param1, int param2, NNSG2dScreenData *param3, int param4, int param5, int param6, int param7, int param8); -BOOL ov21_021D157C(UnkStruct_ov21_021D157C *param0); +void Pokedex_SetLoadingScreenParams(PokedexLoadingScreen *param0, BgConfig *param1, int param2, NNSG2dScreenData *param3, int param4, int param5, int param6, int param7, int param8); +BOOL Pokedex_LoadingScreenMove(PokedexLoadingScreen *param0); void ov21_021D1650(Window *param0, int param1, int param2, int param3); Window *ov21_021D16D8(UnkStruct_ov21_021D13FC *param0, const UnkStruct_ov21_021D3320 *param1, int param2, int param3); Window *ov21_021D170C(UnkStruct_ov21_021D4C0C *param0, int param1, int param2); diff --git a/include/overlay021/ov21_021D85B0.h b/include/overlay021/ov21_021D85B0.h deleted file mode 100644 index b6e3eb8ec8..0000000000 --- a/include/overlay021/ov21_021D85B0.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef POKEPLATINUM_OV21_021D85B0_H -#define POKEPLATINUM_OV21_021D85B0_H - -#include "overlay021/struct_ov21_021D0F60_decl.h" -#include "overlay021/struct_ov21_021E68F4.h" - -#include "heap.h" - -void ov21_021D85B0(UnkStruct_ov21_021E68F4 *param0, UnkStruct_ov21_021D0F60 *param1, enum HeapId heapID); -void ov21_021D8610(UnkStruct_ov21_021E68F4 *param0); -void ov21_021D8628(UnkStruct_ov21_021E68F4 *param0, int param1); -int ov21_021D863C(const UnkStruct_ov21_021E68F4 *param0); -void ov21_021D8644(UnkStruct_ov21_021E68F4 *param0, int param1); -int ov21_021D8658(const UnkStruct_ov21_021E68F4 *param0); -void ov21_021D8660(UnkStruct_ov21_021E68F4 *param0, int param1); -int ov21_021D8674(const UnkStruct_ov21_021E68F4 *param0); -void ov21_021D867C(UnkStruct_ov21_021E68F4 *param0, int param1, int param2); -int ov21_021D8698(const UnkStruct_ov21_021E68F4 *param0, int param1); -void ov21_021D86A8(UnkStruct_ov21_021E68F4 *param0, int param1); -int ov21_021D86BC(const UnkStruct_ov21_021E68F4 *param0); -void ov21_021D86C4(UnkStruct_ov21_021E68F4 *param0, BOOL param1); -BOOL ov21_021D86D0(const UnkStruct_ov21_021E68F4 *param0); -int ov21_021D86D8(const UnkStruct_ov21_021E68F4 *param0); -int ov21_021D86E0(const UnkStruct_ov21_021E68F4 *param0); - -#endif // POKEPLATINUM_OV21_021D85B0_H diff --git a/include/overlay021/pokedex_search.h b/include/overlay021/pokedex_search.h new file mode 100644 index 0000000000..d52d544da8 --- /dev/null +++ b/include/overlay021/pokedex_search.h @@ -0,0 +1,35 @@ +#ifndef POKEPLATINUM_POKEDEX_SEARCH_H +#define POKEPLATINUM_POKEDEX_SEARCH_H + +#include "overlay021/pokedex_sort.h" +#include "overlay021/struct_ov21_021D0F60_decl.h" +#include "overlay021/struct_ov21_021E68F4.h" + +#include "heap.h" + +enum FilterMethod { + FM_ORDER, + FM_NAME, + FM_TYPE, + FM_FORM, + FilterMethod_MAX +}; + +void PokedexSearch_TransitionFunctions(UnkStruct_ov21_021E68F4 *param0, UnkStruct_ov21_021D0F60 *param1, enum HeapId heapID); +void PokedexSearch_FreeData(UnkStruct_ov21_021E68F4 *param0); +void PokedexSearch_SetFilterMethod(UnkStruct_ov21_021E68F4 *param0, enum FilterMethod filterMethod); +enum FilterMethod PokedexSearch_GetFilterMethod(const UnkStruct_ov21_021E68F4 *param0); +void PokedexSearch_SetSortOrder(UnkStruct_ov21_021E68F4 *param0, enum SortOrder sortOrder); +enum SortOrder PokedexSearch_GetSortOrder(const UnkStruct_ov21_021E68F4 *param0); +void PokedexSearch_SetFilterName(UnkStruct_ov21_021E68F4 *param0, enum FilterName filterName); +enum FilterName PokedexSearch_GetFilterName(const UnkStruct_ov21_021E68F4 *param0); +void PokedexSearch_SetFilterType(UnkStruct_ov21_021E68F4 *param0, enum FilterType filterType, int typeSlot); +enum FilterType PokedexSearch_GetFilterType(const UnkStruct_ov21_021E68F4 *param0, int typeSlot); +void PokedexSearch_SetFilterForm(UnkStruct_ov21_021E68F4 *param0, enum FilterForm filterForm); +enum FilterForm PokedexSearch_GetFilterForm(const UnkStruct_ov21_021E68F4 *param0); +void PokedexSearch_SetFilteredState(UnkStruct_ov21_021E68F4 *param0, BOOL applyFilter); +BOOL PokedexSearch_GetFilteredState(const UnkStruct_ov21_021E68F4 *param0); +int PokedexSearch_GetScreenState(const UnkStruct_ov21_021E68F4 *param0); +int PokedexSearch_GetScreenTimer(const UnkStruct_ov21_021E68F4 *param0); + +#endif // POKEPLATINUM_POKEDEX_SEARCH_H diff --git a/include/overlay021/pokedex_sort.h b/include/overlay021/pokedex_sort.h index 64a3f1c3fc..7904978004 100644 --- a/include/overlay021/pokedex_sort.h +++ b/include/overlay021/pokedex_sort.h @@ -14,7 +14,8 @@ enum SortOrder { SO_HEAVIEST, SO_LIGHTEST, SO_TALLEST, - SO_SMALLEST + SO_SMALLEST, + SORTORDER_NUM }; enum FilterName { @@ -27,7 +28,8 @@ enum FilterName { FN_PQR, FN_STU, FN_VWX, - FN_YZ + FN_YZ, + FILTERNAME_NUM }; enum FilterType { @@ -48,7 +50,8 @@ enum FilterType { FT_PSYCHIC, FT_ICE, FT_DRAGON, - FT_DARK + FT_DARK, + FILTERTYPE_NUM }; enum FilterForm { // called form in game, but refers to body shape @@ -66,7 +69,8 @@ enum FilterForm { // called form in game, but refers to body shape FF_TENTACLES, FF_FINS, FF_HEAD, - FF_MULTIBODY + FF_MULTIBODY, + FILTERFORM_NUM }; void PokedexSort_PopulatePokedexStatus(UnkStruct_ov21_021D3320 *param0, UnkStruct_ov21_021D3208 *param1, enum HeapId heapID); @@ -88,8 +92,8 @@ void ov21_021D3434(UnkStruct_ov21_021D3320 *param0, u32 param1); u32 ov21_021D3440(const UnkStruct_ov21_021D3320 *param0); void ov21_021D344C(UnkStruct_ov21_021D3320 *param0, u32 param1); u32 ov21_021D3458(const UnkStruct_ov21_021D3320 *param0); -BOOL PokedexSort_Sort(UnkStruct_ov21_021D3320 *param0, int sortCategory, int firstLetterFilter, int typeFilter1, int typeFilter2, int bodyShapeFilter, int isNationalDex, enum HeapId heapID, BOOL isFiltered); -BOOL PokedexSort_SortUnfiltered(UnkStruct_ov21_021D3320 *param0, int sortOrder, int filterName, int filterType1, int filterType2, int filterForm, int isNationalDex, enum HeapId heapID); +BOOL PokedexSort_Sort(UnkStruct_ov21_021D3320 *param0, enum SortOrder sortOrder, enum FilterName filterName, enum FilterType typeFilter1, enum FilterType typeFilter2, enum FilterForm filterForm, int isNationalDex, enum HeapId heapID, BOOL isFiltered); +BOOL PokedexSort_SortUnfiltered(UnkStruct_ov21_021D3320 *param0, enum SortOrder sortOrder, enum FilterName filterName, enum FilterType filterType1, enum FilterType filterType2, enum FilterForm filterForm, int isNationalDex, enum HeapId heapID); BOOL ov21_021D36A4(const UnkStruct_ov21_021D3320 *param0, int param1); BOOL ov21_021D36C0(UnkStruct_ov21_021D3320 *param0, int param1); int PokedexStatus_IsNationalDex(const UnkStruct_ov21_021D3320 *param0); diff --git a/include/overlay021/struct_ov21_021D157C.h b/include/overlay021/struct_ov21_021D157C.h deleted file mode 100644 index a28b8d8af0..0000000000 --- a/include/overlay021/struct_ov21_021D157C.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_OV21_021D157C_H -#define POKEPLATINUM_STRUCT_OV21_021D157C_H - -#include - -#include "bg_window.h" - -typedef struct { - BgConfig *unk_00; - NNSG2dScreenData *unk_04; - int unk_08; - int unk_0C; - int unk_10; - int unk_14; - int unk_18; - int unk_1C; - int unk_20; -} UnkStruct_ov21_021D157C; - -#endif // POKEPLATINUM_STRUCT_OV21_021D157C_H diff --git a/include/overlay021/struct_ov21_021D3320.h b/include/overlay021/struct_ov21_021D3320.h index 1d925172b8..ea7ca95203 100644 --- a/include/overlay021/struct_ov21_021D3320.h +++ b/include/overlay021/struct_ov21_021D3320.h @@ -15,7 +15,7 @@ typedef struct { BOOL isNationalDexUnlocked; int numEncountered; int numCaught; - int unk_1740; + BOOL unk_1740; int timeOfDay; HeightWeightData *HWData; u32 trainerGameCode; diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index a5114b4269..4bab067497 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -796,7 +796,7 @@ Overlay overlay21 Object main.nef.p/src_overlay021_pokedex_enc_data.c.o Object main.nef.p/src_overlay021_ov21_021D5AEC.c.o Object main.nef.p/src_overlay021_ov21_021D76B0.c.o - Object main.nef.p/src_overlay021_ov21_021D85B0.c.o + Object main.nef.p/src_overlay021_pokedex_search.c.o Object main.nef.p/src_overlay021_ov21_021D94BC.c.o Object main.nef.p/src_overlay021_ov21_021DC9BC.c.o Object main.nef.p/src_overlay021_ov21_021DDD2C.c.o diff --git a/src/meson.build b/src/meson.build index 10d0353d40..daeda74e61 100644 --- a/src/meson.build +++ b/src/meson.build @@ -607,7 +607,7 @@ pokeplatinum_c = files( 'overlay021/pokedex_enc_data.c', 'overlay021/ov21_021D5AEC.c', 'overlay021/ov21_021D76B0.c', - 'overlay021/ov21_021D85B0.c', + 'overlay021/pokedex_search.c', 'overlay021/ov21_021D94BC.c', 'overlay021/ov21_021DC9BC.c', 'overlay021/ov21_021DDD2C.c', diff --git a/src/overlay021/ov21_021D0D80.c b/src/overlay021/ov21_021D0D80.c index 6745e394d0..06cfae56fe 100644 --- a/src/overlay021/ov21_021D0D80.c +++ b/src/overlay021/ov21_021D0D80.c @@ -17,7 +17,6 @@ #include "overlay021/ov21_021D4C0C.h" #include "overlay021/ov21_021D5AEC.h" #include "overlay021/ov21_021D76B0.h" -#include "overlay021/ov21_021D85B0.h" #include "overlay021/ov21_021D94BC.h" #include "overlay021/ov21_021DC9BC.h" #include "overlay021/ov21_021DDD2C.h" @@ -32,12 +31,12 @@ #include "overlay021/ov21_021E737C.h" #include "overlay021/ov21_021E8484.h" #include "overlay021/pokedex_height_check.h" +#include "overlay021/pokedex_search.h" #include "overlay021/pokedex_sort.h" #include "overlay021/pokedex_text.h" #include "overlay021/species_caught_status.h" #include "overlay021/struct_ov21_021D0D80.h" #include "overlay021/struct_ov21_021D13FC.h" -#include "overlay021/struct_ov21_021D157C.h" #include "overlay021/struct_ov21_021D22F8.h" #include "overlay021/struct_ov21_021D3208.h" #include "overlay021/struct_ov21_021D3320.h" @@ -247,7 +246,7 @@ static BOOL ov21_021D0F58(UnkStruct_ov21_021D0F18 *param0) const static UnkFuncPtr_ov21_021E9B74 Unk_ov21_021E9B74[10] = { ov21_021D5AEC, - ov21_021D85B0, + PokedexSearch_TransitionFunctions, ov21_021DE668, ov21_021DF734, ov21_021E0C68, @@ -271,7 +270,7 @@ const static UnkFuncPtr_ov21_021E9B74 Unk_ov21_021E9B34[8] = { const static UnkFuncPtr_ov21_021E9B9C Unk_ov21_021E9B9C[10] = { ov21_021D5B50, - ov21_021D8610, + PokedexSearch_FreeData, ov21_021DE6C0, ov21_021DF78C, ov21_021E0CC0, @@ -607,47 +606,47 @@ void ov21_021D154C(TouchScreenHitTable *hitTable, int param1, int param2, int pa hitTable->rect.right = param4; } -void ov21_021D1558(UnkStruct_ov21_021D157C *param0, BgConfig *param1, int param2, NNSG2dScreenData *param3, int param4, int param5, int param6, int param7, int param8) +void Pokedex_SetLoadingScreenParams(PokedexLoadingScreen *param0, BgConfig *config, int layer, NNSG2dScreenData *screenData, int topStart, int topEnd, int bottomStart, int bottomEnd, int duration) { - param0->unk_00 = param1; - param0->unk_08 = param2; - param0->unk_04 = param3; - param0->unk_0C = param4; - param0->unk_14 = param5 - param4; - param0->unk_10 = param6; - param0->unk_18 = param7 - param6; - param0->unk_20 = param8; - param0->unk_1C = 0; + param0->config = config; + param0->layer = layer; + param0->screenData = screenData; + param0->topStart = topStart; + param0->topDist = topEnd - topStart; + param0->bottomStart = bottomStart; + param0->bottomDist = bottomEnd - bottomStart; + param0->duration = duration; + param0->counter = 0; } -BOOL ov21_021D157C(UnkStruct_ov21_021D157C *param0) +BOOL Pokedex_LoadingScreenMove(PokedexLoadingScreen *loadingScreen) { - int v0; - int v1; + int topPos; + int bottomPos; - if (param0->unk_1C <= param0->unk_20) { - Bg_FillTilemapRect(param0->unk_00, param0->unk_08, 0, 0, 0, 32, 24, 16); + if (loadingScreen->counter <= loadingScreen->duration) { + Bg_FillTilemapRect(loadingScreen->config, loadingScreen->layer, 0, 0, 0, 32, 24, 16); - v0 = (param0->unk_14 * param0->unk_1C) / param0->unk_20; - v1 = (param0->unk_18 * param0->unk_1C) / param0->unk_20; - v0 += param0->unk_0C; - v1 += param0->unk_10; + topPos = (loadingScreen->topDist * loadingScreen->counter) / loadingScreen->duration; + bottomPos = (loadingScreen->bottomDist * loadingScreen->counter) / loadingScreen->duration; + topPos += loadingScreen->topStart; + bottomPos += loadingScreen->bottomStart; - if (v0 > 0) { - Bg_CopyToTilemapRect(param0->unk_00, param0->unk_08, 0, 0, 32, v0, param0->unk_04->rawData, 0, 32 - v0, 32, 32); + if (topPos > 0) { + Bg_CopyToTilemapRect(loadingScreen->config, loadingScreen->layer, 0, 0, 32, topPos, loadingScreen->screenData->rawData, 0, 32 - topPos, 32, 32); } - if ((32 - v1) > 0) { - Bg_CopyToTilemapRect(param0->unk_00, param0->unk_08, 0, 32 - v1, 32, v1, param0->unk_04->rawData, 0, 0, 32, 32); + if ((32 - bottomPos) > 0) { + Bg_CopyToTilemapRect(loadingScreen->config, loadingScreen->layer, 0, 32 - bottomPos, 32, bottomPos, loadingScreen->screenData->rawData, 0, 0, 32, 32); } - Bg_ScheduleTilemapTransfer(param0->unk_00, param0->unk_08); - param0->unk_1C++; + Bg_ScheduleTilemapTransfer(loadingScreen->config, loadingScreen->layer); + loadingScreen->counter++; - return 0; + return FALSE; } - return 1; + return TRUE; } void ov21_021D1650(Window *param0, int param1, int param2, int param3) diff --git a/src/overlay021/ov21_021D5AEC.c b/src/overlay021/ov21_021D5AEC.c index 4cdcecbb8d..c7a99d5244 100644 --- a/src/overlay021/ov21_021D5AEC.c +++ b/src/overlay021/ov21_021D5AEC.c @@ -14,7 +14,6 @@ #include "overlay021/species_caught_status.h" #include "overlay021/struct_ov21_021D0F60_decl.h" #include "overlay021/struct_ov21_021D13FC.h" -#include "overlay021/struct_ov21_021D157C.h" #include "overlay021/struct_ov21_021D2648.h" #include "overlay021/struct_ov21_021D4660.h" #include "overlay021/struct_ov21_021D4CA0.h" @@ -71,7 +70,7 @@ typedef struct { CellActorResourceData unk_B4; void *unk_D8; NNSG2dScreenData *unk_DC; - UnkStruct_ov21_021D157C unk_E0; + PokedexLoadingScreen loadingScreen; UnkStruct_ov21_021D2648 unk_104; UnkStruct_ov21_021D2648 unk_124; int unk_144; @@ -1420,31 +1419,27 @@ static void ov21_021D6FB4(UnkStruct_ov21_021D71A8 *param0, UnkStruct_ov21_021D5C } } - ov21_021D1558(¶m0->unk_E0, param1->unk_00->unk_00, 2, param0->unk_DC, v0, v1, v2, v3, v4); + Pokedex_SetLoadingScreenParams(¶m0->loadingScreen, param1->unk_00->unk_00, 2, param0->unk_DC, v0, v1, v2, v3, v4); } static BOOL ov21_021D7044(UnkStruct_ov21_021D71A8 *param0, UnkStruct_ov21_021D5C08 *param1) { - BOOL v0; - int v1; + BOOL moveComplete = Pokedex_LoadingScreenMove(¶m0->loadingScreen); - v0 = ov21_021D157C(¶m0->unk_E0); + if (moveComplete == FALSE) { + int bottomPos = (param0->loadingScreen.bottomDist * (param0->loadingScreen.counter - 1)) / param0->loadingScreen.duration; + bottomPos += param0->loadingScreen.bottomStart; + bottomPos *= 8; + bottomPos = bottomPos - (14 * 8); - if (v0 == 0) { - v1 = (param0->unk_E0.unk_18 * (param0->unk_E0.unk_1C - 1)) / param0->unk_E0.unk_20; - v1 += param0->unk_E0.unk_10; - v1 = v1; - v1 *= 8; - v1 = v1 - (14 * 8); - - if (v1 < -48) { - v1 = -48; + if (bottomPos < -48) { + bottomPos = -48; } - Bg_ScheduleScroll(param1->unk_00->unk_00, 1, 3, v1); + Bg_ScheduleScroll(param1->unk_00->unk_00, 1, 3, bottomPos); } - return v0; + return moveComplete; } static void ov21_021D7094(UnkStruct_ov21_021D5C08 *param0, const UnkStruct_ov21_021D5B68 *param1, BOOL param2) diff --git a/src/overlay021/ov21_021D85B0.c b/src/overlay021/ov21_021D85B0.c deleted file mode 100644 index 0b252f49c6..0000000000 --- a/src/overlay021/ov21_021D85B0.c +++ /dev/null @@ -1,1108 +0,0 @@ -#include "overlay021/ov21_021D85B0.h" - -#include -#include - -#include "struct_decls/sprite_decl.h" - -#include "gmm/message_bank_pokedex.h" -#include "overlay021/ov21_021D0D80.h" -#include "overlay021/ov21_021D1FA4.h" -#include "overlay021/ov21_021D4340.h" -#include "overlay021/pokedex_sort.h" -#include "overlay021/struct_ov21_021D0F60_decl.h" -#include "overlay021/struct_ov21_021D13FC.h" -#include "overlay021/struct_ov21_021D157C.h" -#include "overlay021/struct_ov21_021D3320.h" -#include "overlay021/struct_ov21_021D4660.h" -#include "overlay021/struct_ov21_021D5B68.h" -#include "overlay021/struct_ov21_021E68F4.h" -#include "overlay021/struct_ov21_021E6A68.h" -#include "overlay021/struct_ov21_021E6B20.h" - -#include "bg_window.h" -#include "cell_actor.h" -#include "font.h" -#include "heap.h" -#include "narc.h" -#include "sprite_resource.h" -#include "strbuf.h" -#include "text.h" -#include "unk_02005474.h" -#include "unk_0200762C.h" -#include "unk_020093B4.h" -#include "unk_0200A328.h" -#include "unk_0200A9DC.h" - -typedef struct { - int *unk_00; - UnkStruct_ov21_021D3320 *unk_04; - UnkStruct_ov21_021D5B68 *unk_08; - int unk_0C; - int unk_10; - int unk_14; - int unk_18; - int unk_1C; - int unk_20; - BOOL unk_24; - BOOL unk_28; - BOOL unk_2C; - int unk_30; - int unk_34; -} UnkStruct_ov21_021D8788; - -typedef struct { - UnkStruct_ov21_021D13FC *unk_00; -} UnkStruct_ov21_021D879C; - -typedef struct { - int unk_00; -} UnkStruct_ov21_021D87CC; - -typedef struct { - int unk_00; - int unk_04; - int unk_08; - int unk_0C; - int unk_10; - int unk_14; - BOOL unk_18; - int unk_1C; - CellActor *unk_20; - SpriteResource *unk_24[4]; - UnkStruct_ov21_021D157C unk_34; - CellActor *unk_58; - void *unk_5C; - NNSG2dScreenData *unk_60; -} UnkStruct_ov21_021D9320; - -static UnkStruct_ov21_021D8788 *ov21_021D86E8(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1); -static UnkStruct_ov21_021D879C *ov21_021D8724(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1); -static UnkStruct_ov21_021D4660 *ov21_021D874C(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1); -static void ov21_021D8788(UnkStruct_ov21_021D8788 *param0); -static void ov21_021D879C(UnkStruct_ov21_021D879C *param0); -static void ov21_021D87B0(UnkStruct_ov21_021D4660 *param0); -static int ov21_021D87C8(void); -static int ov21_021D87CC(UnkStruct_ov21_021E6A68 *param0, void *param1); -static int ov21_021D8804(UnkStruct_ov21_021E6A68 *param0, void *param1); -static int ov21_021D8928(UnkStruct_ov21_021E6A68 *param0, void *param1); -static int ov21_021D893C(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3); -static int ov21_021D89B8(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3); -static int ov21_021D89F4(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3); -static void ov21_021D9320(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1, const UnkStruct_ov21_021D8788 *param2, int param3); -static void ov21_021D9390(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1, const UnkStruct_ov21_021D8788 *param2, int param3); -static void ov21_021D93F4(UnkStruct_ov21_021D879C *param0, int param1); -static void ov21_021D9454(UnkStruct_ov21_021D879C *param0, UnkStruct_ov21_021D9320 *param1, int param2); -static void ov21_021D8A7C(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1, const UnkStruct_ov21_021D8788 *param2, const UnkStruct_ov21_021D87CC *param3, int param4); -static void ov21_021D8B40(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1); -static void ov21_021D8B8C(UnkStruct_ov21_021D879C *param0, const UnkStruct_ov21_021D8788 *param1, int param2); -static void ov21_021D8C1C(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1, int param2); -static void ov21_021D8CC8(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1); -static void ov21_021D8D0C(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1, const UnkStruct_ov21_021D8788 *param2, int param3); -static void ov21_021D8DC0(UnkStruct_ov21_021D9320 *param0); -static void ov21_021D8BC4(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1, const UnkStruct_ov21_021D8788 *param2, int param3, int param4); -static void ov21_021D8BEC(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1); -static void ov21_021D8ED4(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1, const UnkStruct_ov21_021D8788 *param2, int param3); -static void ov21_021D8F98(UnkStruct_ov21_021D879C *param0, int param1, int param2); -static void ov21_021D8DD4(UnkStruct_ov21_021D879C *param0, int param1, int param2); -static void ov21_021D9054(UnkStruct_ov21_021D879C *param0, int param1, int param2); -static void ov21_021D90B4(UnkStruct_ov21_021D879C *param0, int param1, int param2); -static void ov21_021D9234(UnkStruct_ov21_021D879C *param0, int param1, int param2); -static void ov21_021D9240(UnkStruct_ov21_021D879C *param0, int param1, int param2); -static void ov21_021D915C(UnkStruct_ov21_021D879C *param0, int param1, int param2, int param3); -static void ov21_021D924C(UnkStruct_ov21_021D9320 *param0, int param1); -static void ov21_021D8E68(UnkStruct_ov21_021D879C *param0, int param1); -static void ov21_021D8C00(UnkStruct_ov21_021D879C *param0); - -void ov21_021D85B0(UnkStruct_ov21_021E68F4 *param0, UnkStruct_ov21_021D0F60 *param1, enum HeapId heapID) -{ - UnkStruct_ov21_021D8788 *v0; - UnkStruct_ov21_021D879C *v1; - UnkStruct_ov21_021D4660 *v2; - - v0 = ov21_021D86E8(heapID, param1); - v1 = ov21_021D8724(heapID, param1); - v2 = ov21_021D874C(heapID, param1); - - param0->unk_00 = v0; - param0->unk_04 = v1; - param0->unk_20 = v2; - param0->unk_24 = ov21_021D87C8(); - - param0->unk_08[0] = ov21_021D87CC; - param0->unk_08[1] = ov21_021D8804; - param0->unk_08[2] = ov21_021D8928; - param0->unk_14[0] = ov21_021D893C; - param0->unk_14[1] = ov21_021D89B8; - param0->unk_14[2] = ov21_021D89F4; -} - -void ov21_021D8610(UnkStruct_ov21_021E68F4 *param0) -{ - ov21_021D8788(param0->unk_00); - ov21_021D879C(param0->unk_04); - ov21_021D87B0(param0->unk_20); -} - -void ov21_021D8628(UnkStruct_ov21_021E68F4 *param0, int param1) -{ - UnkStruct_ov21_021D8788 *v0 = param0->unk_00; - - GF_ASSERT(param1 < 4); - v0->unk_0C = param1; -} - -int ov21_021D863C(const UnkStruct_ov21_021E68F4 *param0) -{ - const UnkStruct_ov21_021D8788 *v0 = param0->unk_00; - return v0->unk_0C; -} - -void ov21_021D8644(UnkStruct_ov21_021E68F4 *param0, int param1) -{ - UnkStruct_ov21_021D8788 *v0 = param0->unk_00; - - GF_ASSERT(param1 < 6); - v0->unk_10 = param1; -} - -int ov21_021D8658(const UnkStruct_ov21_021E68F4 *param0) -{ - const UnkStruct_ov21_021D8788 *v0 = param0->unk_00; - return v0->unk_10; -} - -void ov21_021D8660(UnkStruct_ov21_021E68F4 *param0, int param1) -{ - UnkStruct_ov21_021D8788 *v0 = param0->unk_00; - - GF_ASSERT(param1 < 10); - v0->unk_14 = param1; -} - -int ov21_021D8674(const UnkStruct_ov21_021E68F4 *param0) -{ - const UnkStruct_ov21_021D8788 *v0 = param0->unk_00; - return v0->unk_14; -} - -void ov21_021D867C(UnkStruct_ov21_021E68F4 *param0, int param1, int param2) -{ - UnkStruct_ov21_021D8788 *v0 = param0->unk_00; - - GF_ASSERT(param1 < 18); - - if (param2 == 0) { - v0->unk_18 = param1; - } else { - v0->unk_1C = param1; - } -} - -int ov21_021D8698(const UnkStruct_ov21_021E68F4 *param0, int param1) -{ - const UnkStruct_ov21_021D8788 *v0 = param0->unk_00; - - if (param1 == 0) { - return v0->unk_18; - } - - return v0->unk_1C; -} - -void ov21_021D86A8(UnkStruct_ov21_021E68F4 *param0, int param1) -{ - UnkStruct_ov21_021D8788 *v0 = param0->unk_00; - - GF_ASSERT(param1 < 15); - v0->unk_20 = param1; -} - -int ov21_021D86BC(const UnkStruct_ov21_021E68F4 *param0) -{ - const UnkStruct_ov21_021D8788 *v0 = param0->unk_00; - return v0->unk_20; -} - -void ov21_021D86C4(UnkStruct_ov21_021E68F4 *param0, BOOL param1) -{ - UnkStruct_ov21_021D8788 *v0 = param0->unk_00; - - v0->unk_24 = 1; - v0->unk_28 = param1; -} - -BOOL ov21_021D86D0(const UnkStruct_ov21_021E68F4 *param0) -{ - const UnkStruct_ov21_021D8788 *v0 = param0->unk_00; - return v0->unk_28; -} - -int ov21_021D86D8(const UnkStruct_ov21_021E68F4 *param0) -{ - const UnkStruct_ov21_021D8788 *v0 = param0->unk_00; - return v0->unk_30; -} - -int ov21_021D86E0(const UnkStruct_ov21_021E68F4 *param0) -{ - const UnkStruct_ov21_021D8788 *v0 = param0->unk_00; - return v0->unk_34; -} - -static UnkStruct_ov21_021D8788 *ov21_021D86E8(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1) -{ - UnkStruct_ov21_021D8788 *v0; - UnkStruct_ov21_021E68F4 *v1; - - v0 = Heap_AllocFromHeap(heapID, sizeof(UnkStruct_ov21_021D8788)); - - GF_ASSERT(v0); - memset(v0, 0, sizeof(UnkStruct_ov21_021D8788)); - - v0->unk_00 = ov21_021D138C(param1); - v0->unk_04 = ov21_021D13EC(param1); - v1 = ov21_021D1410(param1, 0); - v0->unk_08 = v1->unk_00; - - return v0; -} - -static UnkStruct_ov21_021D879C *ov21_021D8724(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1) -{ - UnkStruct_ov21_021D879C *v0; - UnkStruct_ov21_021E68F4 *v1; - - v0 = Heap_AllocFromHeap(heapID, sizeof(UnkStruct_ov21_021D879C)); - - GF_ASSERT(v0); - memset(v0, 0, sizeof(UnkStruct_ov21_021D879C)); - - v0->unk_00 = ov21_021D13FC(param1); - - return v0; -} - -static UnkStruct_ov21_021D4660 *ov21_021D874C(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1) -{ - UnkStruct_ov21_021D4660 *v0; - int v1 = ov21_021D87C8(); - - v0 = Heap_AllocFromHeap(heapID, sizeof(UnkStruct_ov21_021D4660) * v1); - - GF_ASSERT(v0); - memset(v0, 0, sizeof(UnkStruct_ov21_021D4660) * v1); - - ov21_021D47F0(heapID, &v0[0], param1, (0x1 << 1)); - - return v0; -} - -static void ov21_021D8788(UnkStruct_ov21_021D8788 *param0) -{ - GF_ASSERT(param0); - Heap_FreeToHeap(param0); -} - -static void ov21_021D879C(UnkStruct_ov21_021D879C *param0) -{ - GF_ASSERT(param0); - Heap_FreeToHeap(param0); -} - -static void ov21_021D87B0(UnkStruct_ov21_021D4660 *param0) -{ - GF_ASSERT(param0); - - ov21_021D4660(¶m0[0]); - Heap_FreeToHeap(param0); -} - -static int ov21_021D87C8(void) -{ - return 1; -} - -static int ov21_021D87CC(UnkStruct_ov21_021E6A68 *param0, void *param1) -{ - UnkStruct_ov21_021D8788 *v0 = param1; - UnkStruct_ov21_021D87CC *v1; - - v1 = Heap_AllocFromHeap(param0->heapID, sizeof(UnkStruct_ov21_021D87CC)); - - GF_ASSERT(v1); - memset(v1, 0, sizeof(UnkStruct_ov21_021D87CC)); - - param0->unk_08 = v1; - - v0->unk_0C = 0; - v0->unk_10 = 0; - v0->unk_14 = 0; - v0->unk_18 = 0; - v0->unk_1C = 0; - v0->unk_20 = 0; - v0->unk_24 = 0; - v0->unk_28 = 0; - v0->unk_30 = 0; - - return 1; -} - -static int ov21_021D8804(UnkStruct_ov21_021E6A68 *param0, void *param1) -{ - UnkStruct_ov21_021D8788 *v0 = param1; - UnkStruct_ov21_021D87CC *v1 = param0->unk_08; - BOOL v2; - - if (param0->unk_0C == 1) { - return 1; - } - - if (param0->unk_10 == 1) { - return 0; - } - - switch (param0->unk_00) { - case 0: - - if (v0->unk_2C) { - v0->unk_2C = 0; - } - - if (v0->unk_24 == 1) { - if (v0->unk_28 == 0) { - *v0->unk_00 |= (0x1 << 1); - v0->unk_30 = 4; - } else { - v0->unk_30 = 1; - v0->unk_34 = 4; - param0->unk_00++; - } - } - break; - case 1: - v0->unk_34--; - - if (v0->unk_34 < 0) { - param0->unk_00++; - - v0->unk_30 = 2; - v0->unk_34 = 32; - - Sound_PlayEffect(1535); - } - break; - case 2: - v0->unk_34--; - - if (v0->unk_34 < 0) { - param0->unk_00++; - } - break; - case 3: - v2 = 1; - v2 = PokedexSort_Sort(v0->unk_04, v0->unk_10, v0->unk_14, v0->unk_18, v0->unk_1C, v0->unk_20, PokedexStatus_IsNationalDex(v0->unk_04), param0->heapID, 1); - - if (v2 == 1) { - *v0->unk_00 |= (0x1 << 1); - PokedexSort_SetCurrentValues(v0->unk_04, 0); - v0->unk_04->unk_1740 = 1; - v0->unk_08->unk_18 = 1; - } else { - v0->unk_28 = 0; - v0->unk_24 = 0; - v0->unk_2C = 1; - v0->unk_30 = 3; - v0->unk_34 = 4; - - param0->unk_00++; - } - break; - case 4: - v0->unk_34--; - - if (v0->unk_34 < 0) { - v0->unk_30 = 0; - v0->unk_34 = 0; - param0->unk_00 = 0; - } - break; - default: - GF_ASSERT(0); - break; - } - - return 0; -} - -static int ov21_021D8928(UnkStruct_ov21_021E6A68 *param0, void *param1) -{ - UnkStruct_ov21_021D87CC *v0 = param0->unk_08; - UnkStruct_ov21_021D8788 *v1 = param1; - - Heap_FreeToHeap(v0); - param0->unk_08 = NULL; - - return 1; -} - -static int ov21_021D893C(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3) -{ - const UnkStruct_ov21_021D8788 *v0 = param2; - const UnkStruct_ov21_021D87CC *v1 = param3->unk_08; - UnkStruct_ov21_021D879C *v2 = param0; - UnkStruct_ov21_021D9320 *v3 = param1->unk_08; - BOOL v4; - - switch (param1->unk_00) { - case 0: - param1->unk_08 = Heap_AllocFromHeap(param1->heapID, sizeof(UnkStruct_ov21_021D9320)); - memset(param1->unk_08, 0, sizeof(UnkStruct_ov21_021D9320)); - param1->unk_00++; - break; - case 1: - ov21_021D8A7C(v3, v2, v0, v1, param1->heapID); - sub_0200AAE0(1, 0, -16, (GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD), 1); - param1->unk_00++; - break; - case 2: - if (sub_0200AC1C(1)) { - param1->unk_00++; - } - break; - case 3: - return 1; - } - - return 0; -} - -static int ov21_021D89B8(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3) -{ - const UnkStruct_ov21_021D8788 *v0 = param2; - const UnkStruct_ov21_021D87CC *v1 = param3->unk_08; - UnkStruct_ov21_021D879C *v2 = param0; - UnkStruct_ov21_021D9320 *v3 = param1->unk_08; - - if (v0->unk_30 == 0) { - ov21_021D8ED4(v3, v2, v0, param1->heapID); - } else if ((v0->unk_30 == 1) || (v0->unk_30 == 3)) { - ov21_021D9320(v3, v2, v0, param1->heapID); - } else if (v0->unk_30 != 4) { - ov21_021D9390(v3, v2, v0, param1->heapID); - } - - return 0; -} - -static int ov21_021D89F4(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3) -{ - const UnkStruct_ov21_021D8788 *v0 = param2; - const UnkStruct_ov21_021D87CC *v1 = param3->unk_08; - UnkStruct_ov21_021D879C *v2 = param0; - UnkStruct_ov21_021D9320 *v3 = param1->unk_08; - BOOL v4; - - switch (param1->unk_00) { - case 0: - if (v0->unk_28 == 0) { - sub_0200AAE0(6, -16, 0, (GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD), 1); - param1->unk_00++; - } else { - param1->unk_00 = 2; - } - break; - case 1: - if (sub_0200AC1C(1)) { - param1->unk_00++; - } - break; - case 2: - ov21_021D8B40(v3, v2); - param1->unk_00++; - break; - case 3: - Heap_FreeToHeap(param1->unk_08); - param1->unk_08 = NULL; - param1->unk_00++; - break; - case 4: - return 1; - } - - return 0; -} - -static void ov21_021D8A7C(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1, const UnkStruct_ov21_021D8788 *param2, const UnkStruct_ov21_021D87CC *param3, int param4) -{ - Bg_ClearTilemap(param1->unk_00->unk_00, 2); - Bg_ClearTilemap(param1->unk_00->unk_00, 1); - Window_FillTilemap(¶m1->unk_00->unk_04, 0); - Window_SetPalette(¶m1->unk_00->unk_04, 7); - - ov21_021D8C00(param1); - ov21_021D8B8C(param1, param2, param4); - ov21_021D8BC4(param0, param1, param2, param4, PokedexStatus_IsNationalDex(param2->unk_04)); - ov21_021D8C1C(param0, param1, param4); - ov21_021D8D0C(param0, param1, param2, param4); - - ov21_021D8DD4(param1, param2->unk_0C, param4); - ov21_021D8F98(param1, param2->unk_0C, param4); - ov21_021D9054(param1, param2->unk_10, param4); - ov21_021D90B4(param1, param2->unk_14, param4); - ov21_021D9234(param1, param2->unk_18, param4); - ov21_021D9240(param1, param2->unk_1C, param4); - ov21_021D924C(param0, param2->unk_20); - - Bg_SetPriority(1, 1); - Bg_SetPriority(2, 0); -} - -static void ov21_021D8B40(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1) -{ - ov21_021D8DC0(param0); - ov21_021D8CC8(param0, param1); - ov21_021D8BEC(param0, param1); - - Bg_ClearTilemap(param1->unk_00->unk_00, 1); - Window_FillTilemap(¶m1->unk_00->unk_04, 0); - Window_SetPalette(¶m1->unk_00->unk_04, 0); - Bg_SetPriority(1, 0); - Bg_SetPriority(2, 1); -} - -static void ov21_021D8B8C(UnkStruct_ov21_021D879C *param0, const UnkStruct_ov21_021D8788 *param1, int param2) -{ - void *v0; - - ov21_021D2724(param0->unk_00, 28, param0->unk_00->unk_00, 3, 0, 0, 1, param2); - ov21_021D276C(param0->unk_00, 5, 0, 0, 32, param2); -} - -static void ov21_021D8BC4(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1, const UnkStruct_ov21_021D8788 *param2, int param3, int param4) -{ - int v0; - - if (param4 == 1) { - v0 = 42; - } else { - v0 = 40; - } - - param0->unk_5C = ov21_021D27B8(param1->unk_00, v0, 1, ¶m0->unk_60, param3); -} - -static void ov21_021D8BEC(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1) -{ - Heap_FreeToHeap(param0->unk_5C); - param0->unk_5C = NULL; - param0->unk_60 = NULL; -} - -static void ov21_021D8C00(UnkStruct_ov21_021D879C *param0) -{ - Sprite *v0 = ov21_021D2170(param0->unk_00); - - sub_02007DEC(v0, 6, 1); - sub_02008780(v0); -} - -static void ov21_021D8C1C(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1, int param2) -{ - UnkStruct_ov21_021D13FC *v0 = param1->unk_00; - NARC *v1 = ov21_021D26E0(v0); - - param0->unk_24[0] = SpriteResourceCollection_AddTilesFrom(v0->unk_13C[0], v1, 81, 1, 81 + 15000, NNS_G2D_VRAM_TYPE_2DMAIN, param2); - - sub_0200A3DC(param0->unk_24[0]); - SpriteResource_ReleaseData(param0->unk_24[0]); - - param0->unk_24[1] = SpriteResourceCollection_AddPaletteFrom(v0->unk_13C[1], v1, 3, 0, 3 + 15000, NNS_G2D_VRAM_TYPE_2DMAIN, 12, param2); - - sub_0200A640(param0->unk_24[1]); - SpriteResource_ReleaseData(param0->unk_24[1]); - - param0->unk_24[2] = SpriteResourceCollection_AddFrom(v0->unk_13C[2], v1, 79, 1, 79 + 15000, 2, param2); - param0->unk_24[3] = SpriteResourceCollection_AddFrom(v0->unk_13C[3], v1, 80, 1, 80 + 15000, 3, param2); -} - -static void ov21_021D8CC8(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1) -{ - UnkStruct_ov21_021D13FC *v0 = param1->unk_00; - - sub_0200A4E4(param0->unk_24[0]); - sub_0200A6DC(param0->unk_24[1]); - - SpriteResourceCollection_Remove(v0->unk_13C[0], param0->unk_24[0]); - SpriteResourceCollection_Remove(v0->unk_13C[1], param0->unk_24[1]); - SpriteResourceCollection_Remove(v0->unk_13C[2], param0->unk_24[2]); - SpriteResourceCollection_Remove(v0->unk_13C[3], param0->unk_24[3]); -} - -static void ov21_021D8D0C(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1, const UnkStruct_ov21_021D8788 *param2, int param3) -{ - CellActorResourceData v0; - CellActorInitParams v1; - UnkStruct_ov21_021D13FC *v2 = param1->unk_00; - - sub_020093B4(&v0, 81 + 15000, 3 + 15000, 79 + 15000, 80 + 15000, 0xffffffff, 0xffffffff, 0, 2, v2->unk_13C[0], v2->unk_13C[1], v2->unk_13C[2], v2->unk_13C[3], NULL, NULL); - - v1.collection = v2->unk_138; - v1.resourceData = &v0; - v1.priority = 31; - v1.vramType = NNS_G2D_VRAM_TYPE_2DMAIN; - v1.heapID = param3; - - v1.position.x = 128 << FX32_SHIFT; - v1.position.y = 164 << FX32_SHIFT; - param0->unk_20 = CellActorCollection_Add(&v1); - - CellActor_SetAnim(param0->unk_20, 3); - - v1.position.x = 128 << FX32_SHIFT; - v1.position.y = 96 << FX32_SHIFT; - - param0->unk_58 = CellActorCollection_Add(&v1); - - CellActor_SetAnim(param0->unk_58, 17); - CellActor_SetDrawFlag(param0->unk_58, 0); - CellActor_SetAffineOverwriteMode(param0->unk_58, 1); - CellActor_SetExplicitPriority(param0->unk_58, 0); -} - -static void ov21_021D8DC0(UnkStruct_ov21_021D9320 *param0) -{ - CellActor_Delete(param0->unk_20); - CellActor_Delete(param0->unk_58); -} - -static void ov21_021D8DD4(UnkStruct_ov21_021D879C *param0, int param1, int param2) -{ - UnkStruct_ov21_021D13FC *v0 = param0->unk_00; - Strbuf *v1; - int entryID; - - Window_FillRectWithColor(&v0->unk_04, 0, 24, 8, 208, 32); - - switch (param1) { - case 0: - entryID = pl_msg_pokedex_listing_description; - break; - case 1: - entryID = pl_msg_pokedex_alphabetical_description; - break; - case 2: - entryID = pl_msg_pokedex_type_description; - break; - case 3: - entryID = pl_msg_pokedex_body_description; - break; - default: - break; - } - - v1 = GetPokedexMessage(entryID, param2); - - { - u32 v3 = 24 + (208 - Font_CalcMaxLineWidth(FONT_SYSTEM, v1, 0)) / 2; - u32 v4 = 8 + (32 - Strbuf_NumLines(v1) * 16) / 2; - Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, v1, v3, v4, TEXT_SPEED_INSTANT, TEXT_COLOR(2, 1, 0), NULL); - } - - Strbuf_Free(v1); -} - -static void ov21_021D8E68(UnkStruct_ov21_021D879C *param0, int param1) -{ - UnkStruct_ov21_021D13FC *v0 = param0->unk_00; - Strbuf *v1; - - Window_FillRectWithColor(&v0->unk_04, 0, 24, 8, 208, 32); - - v1 = GetPokedexMessage(pl_msg_pokedex_nonefound, param1); - - { - u32 v2 = 24 + (208 - Font_CalcMaxLineWidth(FONT_SYSTEM, v1, 0)) / 2; - u32 v3 = 8 + (32 - Strbuf_NumLines(v1) * 16) / 2; - Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, v1, v2, v3, TEXT_SPEED_INSTANT, TEXT_COLOR(2, 1, 0), NULL); - } - - Strbuf_Free(v1); -} - -static void ov21_021D8ED4(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1, const UnkStruct_ov21_021D8788 *param2, int param3) -{ - if (param2->unk_2C != param0->unk_18) { - param0->unk_18 = param2->unk_2C; - - if (param0->unk_18 == 1) { - param0->unk_1C = 64; - ov21_021D8E68(param1, param3); - } - } - - if (param0->unk_1C > 0) { - param0->unk_1C--; - } else if (param0->unk_1C == 0) { - ov21_021D8DD4(param1, param2->unk_0C, param3); - param0->unk_1C--; - } - - if (param0->unk_00 != param2->unk_0C) { - ov21_021D8F98(param1, param2->unk_0C, param3); - ov21_021D8DD4(param1, param2->unk_0C, param3); - param0->unk_00 = param2->unk_0C; - } - - if (param0->unk_04 != param2->unk_10) { - ov21_021D9054(param1, param2->unk_10, param3); - param0->unk_04 = param2->unk_10; - } - - if (param0->unk_08 != param2->unk_14) { - ov21_021D90B4(param1, param2->unk_14, param3); - param0->unk_08 = param2->unk_14; - } - - if (param0->unk_0C != param2->unk_18) { - ov21_021D9234(param1, param2->unk_18, param3); - param0->unk_0C = param2->unk_18; - } - - if (param0->unk_10 != param2->unk_1C) { - ov21_021D9240(param1, param2->unk_1C, param3); - param0->unk_10 = param2->unk_1C; - } - - if (param0->unk_14 != param2->unk_20) { - ov21_021D924C(param0, param2->unk_20); - param0->unk_14 = param2->unk_20; - } -} - -static void ov21_021D8F98(UnkStruct_ov21_021D879C *param0, int param1, int param2) -{ - void *v0; - NNSG2dScreenData *v1; - int v2, v3; - int v4; - - v0 = ov21_021D27B8(param0->unk_00, 43, 1, &v1, param2); - - Bg_LoadToTilemapRect(param0->unk_00->unk_00, 3, v1->rawData, 0, 0, v1->screenWidth / 8, v1->screenHeight / 8); - Heap_FreeToHeap(v0); - - v2 = 6; - - switch (param1) { - case 0: - v3 = 6; - v4 = 44; - break; - case 1: - v3 = 9; - v4 = 45; - break; - case 2: - v3 = 12; - v4 = 46; - break; - case 3: - v3 = 17; - v4 = 47; - break; - default: - break; - } - - v0 = ov21_021D27B8(param0->unk_00, v4, 1, &v1, param2); - - Bg_LoadToTilemapRect(param0->unk_00->unk_00, 3, v1->rawData, v2, v3, v1->screenWidth / 8, v1->screenHeight / 8); - Heap_FreeToHeap(v0); - Bg_ScheduleTilemapTransfer(param0->unk_00->unk_00, 3); -} - -static void ov21_021D9054(UnkStruct_ov21_021D879C *param0, int param1, int param2) -{ - UnkStruct_ov21_021D13FC *v0 = param0->unk_00; - Strbuf *v1; - int entryID; - - Window_FillRectWithColor(&v0->unk_04, 0, 88, 52, 80, 16); - - entryID = pl_msg_pokedex_numerical + param1; - v1 = GetPokedexMessage(entryID, param2); - - { - u32 v3 = 88 + Font_CalcCenterAlignment(FONT_SYSTEM, v1, 0, 80); - Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, v1, v3, 52, TEXT_SPEED_INSTANT, TEXT_COLOR(4, 3, 0), NULL); - } - - Strbuf_Free(v1); -} - -static void ov21_021D90B4(UnkStruct_ov21_021D879C *param0, int param1, int param2) -{ - UnkStruct_ov21_021D13FC *v0 = param0->unk_00; - Strbuf *v1; - int entryID; - int v3; - - Window_FillRectWithColor(&v0->unk_04, 0, 88, 77, 80, 16); - - switch (param1) { - case 0: - entryID = pl_msg_pokedex_nonealphabetical; - break; - case 1: - entryID = pl_msg_pokedex_abc; - break; - case 2: - entryID = pl_msg_pokedex_def; - break; - case 3: - entryID = pl_msg_pokedex_ghi; - break; - case 4: - entryID = pl_msg_pokedex_jkl; - break; - case 5: - entryID = pl_msg_pokedex_mno; - break; - case 6: - entryID = pl_msg_pokedex_pqr; - break; - case 7: - entryID = pl_msg_pokedex_stu; - break; - case 8: - entryID = pl_msg_pokedex_vwx; - break; - case 9: - entryID = pl_msg_pokedex_yz; - break; - } - - v1 = GetPokedexMessage(entryID, param2); - - { - u32 v4 = 88 + Font_CalcCenterAlignment(FONT_SYSTEM, v1, 0, 80); - Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, v1, v4, 77, TEXT_SPEED_INSTANT, TEXT_COLOR(4, 3, 0), NULL); - } - - Strbuf_Free(v1); -} - -static void ov21_021D915C(UnkStruct_ov21_021D879C *param0, int param1, int param2, int param3) -{ - UnkStruct_ov21_021D13FC *v0 = param0->unk_00; - Strbuf *v1; - int entryID; - int v3; - - Window_FillRectWithColor(&v0->unk_04, 0, 88, param3, 80, 16); - - switch (param1) { - case 0: - entryID = pl_msg_pokedex_dash; - break; - case 1: - entryID = pl_msg_pokedex_normal; - break; - case 2: - entryID = pl_msg_pokedex_fight; - break; - case 3: - entryID = pl_msg_pokedex_flying; - break; - case 4: - entryID = pl_msg_pokedex_poison; - break; - case 5: - entryID = pl_msg_pokedex_ground; - break; - case 6: - entryID = pl_msg_pokedex_rock; - break; - case 7: - entryID = pl_msg_pokedex_bug; - break; - case 8: - entryID = pl_msg_pokedex_ghost; - break; - case 9: - entryID = pl_msg_pokedex_steel; - break; - case 10: - entryID = pl_msg_pokedex_fire; - break; - case 11: - entryID = pl_msg_pokedex_water; - break; - case 12: - entryID = pl_msg_pokedex_grass; - break; - case 13: - entryID = pl_msg_pokedex_electric; - break; - case 14: - entryID = pl_msg_pokedex_psychic; - break; - case 15: - entryID = pl_msg_pokedex_ice; - break; - case 16: - entryID = pl_msg_pokedex_dragon; - break; - case 17: - entryID = pl_msg_pokedex_dark; - break; - } - - v1 = GetPokedexMessage(entryID, param2); - - { - u32 v4 = 88 + Font_CalcCenterAlignment(FONT_SYSTEM, v1, 0, 80); - Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, v1, v4, param3, TEXT_SPEED_INSTANT, TEXT_COLOR(4, 3, 0), NULL); - } - - Strbuf_Free(v1); -} - -static void ov21_021D9234(UnkStruct_ov21_021D879C *param0, int param1, int param2) -{ - ov21_021D915C(param0, param1, param2, 102); -} - -static void ov21_021D9240(UnkStruct_ov21_021D879C *param0, int param1, int param2) -{ - ov21_021D915C(param0, param1, param2, 120); -} - -static void ov21_021D924C(UnkStruct_ov21_021D9320 *param0, int param1) -{ - if (param1 == 0) { - CellActor_SetDrawFlag(param0->unk_20, 0); - } else { - CellActor_SetDrawFlag(param0->unk_20, 1); - - switch (param1) { - case 1: - CellActor_SetAnim(param0->unk_20, 3); - break; - case 2: - CellActor_SetAnim(param0->unk_20, 4); - break; - case 3: - CellActor_SetAnim(param0->unk_20, 5); - break; - case 4: - CellActor_SetAnim(param0->unk_20, 6); - break; - case 5: - CellActor_SetAnim(param0->unk_20, 7); - break; - case 6: - CellActor_SetAnim(param0->unk_20, 8); - break; - case 7: - CellActor_SetAnim(param0->unk_20, 9); - break; - case 8: - CellActor_SetAnim(param0->unk_20, 10); - break; - case 9: - CellActor_SetAnim(param0->unk_20, 11); - break; - case 10: - CellActor_SetAnim(param0->unk_20, 12); - break; - case 11: - CellActor_SetAnim(param0->unk_20, 13); - break; - case 12: - CellActor_SetAnim(param0->unk_20, 14); - break; - case 13: - CellActor_SetAnim(param0->unk_20, 15); - break; - case 14: - CellActor_SetAnim(param0->unk_20, 16); - break; - default: - break; - } - } -} - -static void ov21_021D9320(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1, const UnkStruct_ov21_021D8788 *param2, int param3) -{ - if (param2->unk_34 == 4) { - if (param2->unk_30 == 1) { - ov21_021D1558(¶m0->unk_34, param1->unk_00->unk_00, 2, param0->unk_60, 0, 12, 0, 20, 4); - } else { - ov21_021D9454(param1, param0, param3); - - ov21_021D1558(¶m0->unk_34, param1->unk_00->unk_00, 2, param0->unk_60, 12, 0, 20, 0, 4); - } - } - - ov21_021D157C(¶m0->unk_34); -} - -static void ov21_021D9390(UnkStruct_ov21_021D9320 *param0, UnkStruct_ov21_021D879C *param1, const UnkStruct_ov21_021D8788 *param2, int param3) -{ - int v0; - int v1; - - if (param2->unk_34 == 32) { - CellActor_SetDrawFlag(param0->unk_58, 1); - ov21_021D93F4(param1, param3); - } else if (param2->unk_34 == 0) { - CellActor_SetDrawFlag(param0->unk_58, 0); - Window_FillTilemap(¶m1->unk_00->unk_04, 0); - Window_ScheduleCopyToVRAM(¶m1->unk_00->unk_04); - } - - v1 = 4 - param2->unk_34; - v0 = ((180 * 0xffff) / 360) * v1; - v0 = v0 / 4; - - CellActor_SetAffineZRotation(param0->unk_58, (u16)v0); -} - -static void ov21_021D93F4(UnkStruct_ov21_021D879C *param0, int param1) -{ - UnkStruct_ov21_021D13FC *v0 = param0->unk_00; - Strbuf *v1; - int v2; - - Window_FillTilemap(¶m0->unk_00->unk_04, 0); - - v1 = GetPokedexMessage(pl_msg_pokedex_searching, param1); - - { - u32 v3 = (256 - Font_CalcMaxLineWidth(FONT_SYSTEM, v1, 0)) / 2; - - Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, v1, v3, 128, TEXT_SPEED_INSTANT, TEXT_COLOR(2, 1, 0), NULL); - } - - Strbuf_Free(v1); - Bg_SetPriority(1, 0); - Bg_SetPriority(2, 1); -} - -static void ov21_021D9454(UnkStruct_ov21_021D879C *param0, UnkStruct_ov21_021D9320 *param1, int param2) -{ - Bg_SetPriority(1, 1); - Bg_SetPriority(2, 0); - Window_FillTilemap(¶m0->unk_00->unk_04, 0); - - ov21_021D8F98(param0, param1->unk_00, param2); - ov21_021D8DD4(param0, param1->unk_00, param2); - ov21_021D9054(param0, param1->unk_04, param2); - ov21_021D90B4(param0, param1->unk_08, param2); - ov21_021D9234(param0, param1->unk_0C, param2); - ov21_021D9240(param0, param1->unk_10, param2); - ov21_021D924C(param1, param1->unk_14); -} diff --git a/src/overlay021/ov21_021D94BC.c b/src/overlay021/ov21_021D94BC.c index 0fbe2c9885..042e9e225e 100644 --- a/src/overlay021/ov21_021D94BC.c +++ b/src/overlay021/ov21_021D94BC.c @@ -10,7 +10,7 @@ #include "overlay021/ov21_021D1FA4.h" #include "overlay021/ov21_021D4C0C.h" #include "overlay021/ov21_021D4EE4.h" -#include "overlay021/ov21_021D85B0.h" +#include "overlay021/pokedex_search.h" #include "overlay021/pokedex_sort.h" #include "overlay021/struct_ov21_021D0F60_decl.h" #include "overlay021/struct_ov21_021D13FC.h" @@ -347,11 +347,11 @@ static int ov21_021D964C(UnkStruct_ov21_021E6A68 *param0, void *param1) return 0; } - if (ov21_021D86D8(v0->unk_08) != 0) { + if (PokedexSearch_GetScreenState(v0->unk_08) != 0) { return 0; } - v3 = ov21_021D863C(v0->unk_08); + v3 = PokedexSearch_GetFilterMethod(v0->unk_08); switch (param0->unk_00) { case 0: @@ -468,7 +468,7 @@ static int ov21_021D9830(void *param0, UnkStruct_ov21_021E6B20 *param1, const vo int v6; int v7; - if (ov21_021D86D8(v0->unk_08) != 0) { + if (PokedexSearch_GetScreenState(v0->unk_08) != 0) { ov21_021DC96C(v3, v2, v0); } else { ov21_021DC7C0(v3, v2); @@ -539,7 +539,7 @@ static int ov21_021D9960(void *param0, UnkStruct_ov21_021E6B20 *param1, const vo switch (param1->unk_00) { case 0: - if (ov21_021D86D0(v0->unk_08) == 1) { + if (PokedexSearch_GetFilteredState(v0->unk_08) == 1) { param1->unk_00 = 2; } else { sub_0200AAE0(6, -16, 0, (GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD), 2); @@ -825,33 +825,33 @@ static void ov21_021D9E08(UnkStruct_ov21_021D9B24 *param0, UnkStruct_ov21_021D95 sub_0202404C(param0->unk_08); - switch (ov21_021D8658(param1->unk_08)) { - case 0: + switch (PokedexSearch_GetSortOrder(param1->unk_08)) { + case SO_NUMERICAL: if (param0->unk_44[0] != 2) { param0->unk_44[0] = 1; } break; - case 1: + case SO_ALPHABETICAL: if (param0->unk_44[1] != 2) { param0->unk_44[1] = 1; } break; - case 2: + case SO_HEAVIEST: if (param0->unk_44[2] != 2) { param0->unk_44[2] = 1; } break; - case 3: + case SO_LIGHTEST: if (param0->unk_44[3] != 2) { param0->unk_44[3] = 1; } break; - case 4: + case SO_TALLEST: if (param0->unk_44[4] != 2) { param0->unk_44[4] = 1; } break; - case 5: + case SO_SMALLEST: if (param0->unk_44[5] != 2) { param0->unk_44[5] = 1; } @@ -908,7 +908,7 @@ static void ov21_021D9F44(UnkStruct_ov21_021D9B24 *param0, UnkStruct_ov21_021D95 sub_0202404C(param0->unk_08); - switch (ov21_021D8674(param1->unk_08)) { + switch (PokedexSearch_GetFilterName(param1->unk_08)) { case 1: if (param0->unk_44[0] != 2) { param0->unk_44[0] = 1; @@ -1012,8 +1012,8 @@ static void ov21_021DA0BC(UnkStruct_ov21_021D9B24 *param0, UnkStruct_ov21_021D95 } sub_0202404C(param0->unk_08); - ov21_021DA0FC(param0, ov21_021D8698(param1->unk_08, 0)); - ov21_021DA0FC(param0, ov21_021D8698(param1->unk_08, 1)); + ov21_021DA0FC(param0, PokedexSearch_GetFilterType(param1->unk_08, 0)); + ov21_021DA0FC(param0, PokedexSearch_GetFilterType(param1->unk_08, 1)); } static void ov21_021DA0FC(UnkStruct_ov21_021D9B24 *param0, int param1) @@ -1131,8 +1131,8 @@ static void ov21_021DA280(UnkStruct_ov21_021D9B24 *param0, UnkStruct_ov21_021D95 } sub_0202404C(param0->unk_08); - ov21_021DA308(param0, ov21_021D8698(param1->unk_08, 0)); - ov21_021DA308(param0, ov21_021D8698(param1->unk_08, 1)); + ov21_021DA308(param0, PokedexSearch_GetFilterType(param1->unk_08, 0)); + ov21_021DA308(param0, PokedexSearch_GetFilterType(param1->unk_08, 1)); } static void ov21_021DA2C0(u32 param0, u32 param1, void *param2) @@ -1242,7 +1242,7 @@ static void ov21_021DA41C(UnkStruct_ov21_021D9B24 *param0, UnkStruct_ov21_021D95 sub_0202404C(param0->unk_08); - switch (ov21_021D86BC(param1->unk_08)) { + switch (PokedexSearch_GetFilterForm(param1->unk_08)) { case 1: if (param0->unk_44[7] != 2) { param0->unk_44[7] = 1; @@ -3097,37 +3097,37 @@ static void ov21_021DC3BC(UnkStruct_ov21_021D9B24 *param0, UnkStruct_ov21_021D95 { switch (param0->unk_80) { case 0: - ov21_021D86C4(param1->unk_08, 0); + PokedexSearch_SetFilteredState(param1->unk_08, FALSE); Sound_PlayEffect(1501); break; case 1: - if (ov21_021D863C(param1->unk_08) != 0) { - ov21_021D8628(param1->unk_08, 0); + if (PokedexSearch_GetFilterMethod(param1->unk_08) != FM_ORDER) { + PokedexSearch_SetFilterMethod(param1->unk_08, FM_ORDER); Sound_PlayEffect(1501); } break; case 2: - if (ov21_021D863C(param1->unk_08) != 1) { - ov21_021D8628(param1->unk_08, 1); + if (PokedexSearch_GetFilterMethod(param1->unk_08) != FM_NAME) { + PokedexSearch_SetFilterMethod(param1->unk_08, FM_NAME); Sound_PlayEffect(1501); } break; case 3: - if (ov21_021D863C(param1->unk_08) != 2) { - ov21_021D8628(param1->unk_08, 2); + if (PokedexSearch_GetFilterMethod(param1->unk_08) != FM_TYPE) { + PokedexSearch_SetFilterMethod(param1->unk_08, FM_TYPE); Sound_PlayEffect(1501); param0->unk_88 = 0; } break; case 4: - if (ov21_021D863C(param1->unk_08) != 3) { - ov21_021D8628(param1->unk_08, 3); + if (PokedexSearch_GetFilterMethod(param1->unk_08) != FM_FORM) { + PokedexSearch_SetFilterMethod(param1->unk_08, FM_FORM); Sound_PlayEffect(1501); } break; case 5: if (param0->unk_94 <= 1) { - ov21_021D86C4(param1->unk_08, 1); + PokedexSearch_SetFilteredState(param1->unk_08, TRUE); Sound_PlayEffect(1501); } break; @@ -3140,35 +3140,35 @@ static void ov21_021DC3BC(UnkStruct_ov21_021D9B24 *param0, UnkStruct_ov21_021D95 static void ov21_021DC48C(UnkStruct_ov21_021D9B24 *param0, UnkStruct_ov21_021D95B8 *param1) { - int v0 = 100; + int sortOrder = 100; switch (param0->unk_84) { case 0: - v0 = 0; + sortOrder = SO_NUMERICAL; break; case 1: - v0 = 1; + sortOrder = SO_ALPHABETICAL; break; case 2: - v0 = 2; + sortOrder = SO_HEAVIEST; break; case 3: - v0 = 3; + sortOrder = SO_LIGHTEST; break; case 4: - v0 = 4; + sortOrder = SO_TALLEST; break; case 5: - v0 = 5; + sortOrder = SO_SMALLEST; break; default: break; } - if (v0 != 100) { - if (ov21_021D8658(param1->unk_08) != v0) { + if (sortOrder != 100) { + if (PokedexSearch_GetSortOrder(param1->unk_08) != sortOrder) { Sound_PlayEffect(1501); - ov21_021D8644(param1->unk_08, v0); + PokedexSearch_SetSortOrder(param1->unk_08, sortOrder); } } @@ -3215,10 +3215,10 @@ static void ov21_021DC4F8(UnkStruct_ov21_021D9B24 *param0, UnkStruct_ov21_021D95 } if (v0 != 100) { - if (ov21_021D8674(param1->unk_08) != v0) { + if (PokedexSearch_GetFilterName(param1->unk_08) != v0) { Sound_PlayEffect(1501); - ov21_021D8660(param1->unk_08, v0); + PokedexSearch_SetFilterName(param1->unk_08, v0); } } @@ -3325,21 +3325,21 @@ static void ov21_021DC600(UnkStruct_ov21_021D9B24 *param0, UnkStruct_ov21_021D95 static void ov21_021DC67C(UnkStruct_ov21_021D9B24 *param0, UnkStruct_ov21_021D95B8 *param1, int param2) { if (param2 != 0) { - if ((ov21_021D8698(param1->unk_08, 0) != param2) && (ov21_021D8698(param1->unk_08, 1) != param2)) { - if (ov21_021D8698(param1->unk_08, param0->unk_88) != param2) { - ov21_021D867C(param1->unk_08, param2, param0->unk_88); + if ((PokedexSearch_GetFilterType(param1->unk_08, 0) != param2) && (PokedexSearch_GetFilterType(param1->unk_08, 1) != param2)) { + if (PokedexSearch_GetFilterType(param1->unk_08, param0->unk_88) != param2) { + PokedexSearch_SetFilterType(param1->unk_08, param2, param0->unk_88); param0->unk_88 = (param0->unk_88 + 1) % 2; Sound_PlayEffect(1501); } } } else { - if (ov21_021D8698(param1->unk_08, 0) != 0) { - ov21_021D867C(param1->unk_08, param2, 0); + if (PokedexSearch_GetFilterType(param1->unk_08, 0) != 0) { + PokedexSearch_SetFilterType(param1->unk_08, param2, 0); Sound_PlayEffect(1501); } else { - if (ov21_021D8698(param1->unk_08, 1) != 0) { - ov21_021D867C(param1->unk_08, param2, 1); + if (PokedexSearch_GetFilterType(param1->unk_08, 1) != 0) { + PokedexSearch_SetFilterType(param1->unk_08, param2, 1); Sound_PlayEffect(1501); } } @@ -3403,9 +3403,9 @@ static void ov21_021DC720(UnkStruct_ov21_021D9B24 *param0, UnkStruct_ov21_021D95 } if (v0 != 100) { - if (ov21_021D86BC(param1->unk_08) != v0) { + if (PokedexSearch_GetFilterForm(param1->unk_08) != v0) { Sound_PlayEffect(1501); - ov21_021D86A8(param1->unk_08, v0); + PokedexSearch_SetFilterForm(param1->unk_08, v0); } } @@ -3532,10 +3532,10 @@ static void ov21_021DC93C(UnkStruct_ov21_021DC96C *param0, int param1) static void ov21_021DC96C(UnkStruct_ov21_021DC96C *param0, UnkStruct_ov21_021D95CC *param1, const UnkStruct_ov21_021D95B8 *param2) { - if (ov21_021D86E0(param2->unk_08) == 4) { - if (ov21_021D86D8(param2->unk_08) == 3) { + if (PokedexSearch_GetScreenTimer(param2->unk_08) == 4) { + if (PokedexSearch_GetScreenState(param2->unk_08) == 3) { sub_0200AAE0(4, 0, -16, (GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD), 2); - } else if (ov21_021D86D8(param2->unk_08) == 1) { + } else if (PokedexSearch_GetScreenState(param2->unk_08) == 1) { sub_0200AAE0(4, -16, 0, (GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD), 2); } } diff --git a/src/overlay021/pokedex_height_check.c b/src/overlay021/pokedex_height_check.c index ff4b524cd7..931f5586a9 100644 --- a/src/overlay021/pokedex_height_check.c +++ b/src/overlay021/pokedex_height_check.c @@ -50,13 +50,6 @@ typedef struct { CellActor *trainerHeightCellActor; } HeightCheckVisuals; -enum HeightCheckGraphics { - HCG_TILES, - HCG_PALETTE, - HCG_CELLS, - HCG_ANIMATION, -}; - static UnkStruct_ov21_021E6104 *ov21_021E608C(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1); static UnkStruct_ov21_021E6118 *ov21_021E60D8(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1); static UnkStruct_ov21_021D4660 *ov21_021E6100(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1); @@ -352,30 +345,30 @@ static void GetHeightCheckGraphics(HeightCheckVisuals *heightCheckVisuals, UnkSt UnkStruct_ov21_021D13FC *v0 = param1->unk_00; NARC *pokedexGraphicsNarc = ov21_021D26E0(v0); - heightCheckVisuals->heightCheckGraphics[HCG_TILES] = SpriteResourceCollection_AddTilesFrom(v0->unk_13C[0], pokedexGraphicsNarc, 93, 1, 93 + 7000, NNS_G2D_VRAM_TYPE_2DMAIN, heapID); + heightCheckVisuals->heightCheckGraphics[SPRITE_RESOURCE_TILES] = SpriteResourceCollection_AddTilesFrom(v0->unk_13C[0], pokedexGraphicsNarc, 93, 1, 93 + 7000, NNS_G2D_VRAM_TYPE_2DMAIN, heapID); - sub_0200A3DC(heightCheckVisuals->heightCheckGraphics[HCG_TILES]); - SpriteResource_ReleaseData(heightCheckVisuals->heightCheckGraphics[HCG_TILES]); + sub_0200A3DC(heightCheckVisuals->heightCheckGraphics[SPRITE_RESOURCE_TILES]); + SpriteResource_ReleaseData(heightCheckVisuals->heightCheckGraphics[SPRITE_RESOURCE_TILES]); - heightCheckVisuals->heightCheckGraphics[HCG_PALETTE] = SpriteResourceCollection_AddPaletteFrom(v0->unk_13C[1], pokedexGraphicsNarc, 14, 0, 14 + 7000, NNS_G2D_VRAM_TYPE_2DMAIN, 5, heapID); + heightCheckVisuals->heightCheckGraphics[SPRITE_RESOURCE_PALETTE] = SpriteResourceCollection_AddPaletteFrom(v0->unk_13C[1], pokedexGraphicsNarc, 14, 0, 14 + 7000, NNS_G2D_VRAM_TYPE_2DMAIN, 5, heapID); - sub_0200A640(heightCheckVisuals->heightCheckGraphics[HCG_PALETTE]); - SpriteResource_ReleaseData(heightCheckVisuals->heightCheckGraphics[HCG_PALETTE]); + sub_0200A640(heightCheckVisuals->heightCheckGraphics[SPRITE_RESOURCE_PALETTE]); + SpriteResource_ReleaseData(heightCheckVisuals->heightCheckGraphics[SPRITE_RESOURCE_PALETTE]); - heightCheckVisuals->heightCheckGraphics[HCG_CELLS] = SpriteResourceCollection_AddFrom(v0->unk_13C[2], pokedexGraphicsNarc, 91, 1, 91 + 7000, 2, heapID); - heightCheckVisuals->heightCheckGraphics[HCG_ANIMATION] = SpriteResourceCollection_AddFrom(v0->unk_13C[3], pokedexGraphicsNarc, 92, 1, 92 + 7000, 3, heapID); + heightCheckVisuals->heightCheckGraphics[SPRITE_RESOURCE_SPRITE] = SpriteResourceCollection_AddFrom(v0->unk_13C[2], pokedexGraphicsNarc, 91, 1, 91 + 7000, 2, heapID); + heightCheckVisuals->heightCheckGraphics[SPRITE_RESOURCE_SPRITE_ANIM] = SpriteResourceCollection_AddFrom(v0->unk_13C[3], pokedexGraphicsNarc, 92, 1, 92 + 7000, 3, heapID); } static void FreeSprites(HeightCheckVisuals *heightCheckVisuals, UnkStruct_ov21_021E6118 *param1) { UnkStruct_ov21_021D13FC *v0 = param1->unk_00; - sub_0200A4E4(heightCheckVisuals->heightCheckGraphics[HCG_TILES]); - sub_0200A6DC(heightCheckVisuals->heightCheckGraphics[HCG_PALETTE]); - SpriteResourceCollection_Remove(v0->unk_13C[0], heightCheckVisuals->heightCheckGraphics[HCG_TILES]); - SpriteResourceCollection_Remove(v0->unk_13C[1], heightCheckVisuals->heightCheckGraphics[HCG_PALETTE]); - SpriteResourceCollection_Remove(v0->unk_13C[2], heightCheckVisuals->heightCheckGraphics[HCG_CELLS]); - SpriteResourceCollection_Remove(v0->unk_13C[3], heightCheckVisuals->heightCheckGraphics[HCG_ANIMATION]); + sub_0200A4E4(heightCheckVisuals->heightCheckGraphics[SPRITE_RESOURCE_TILES]); + sub_0200A6DC(heightCheckVisuals->heightCheckGraphics[SPRITE_RESOURCE_PALETTE]); + SpriteResourceCollection_Remove(v0->unk_13C[0], heightCheckVisuals->heightCheckGraphics[SPRITE_RESOURCE_TILES]); + SpriteResourceCollection_Remove(v0->unk_13C[1], heightCheckVisuals->heightCheckGraphics[SPRITE_RESOURCE_PALETTE]); + SpriteResourceCollection_Remove(v0->unk_13C[2], heightCheckVisuals->heightCheckGraphics[SPRITE_RESOURCE_SPRITE]); + SpriteResourceCollection_Remove(v0->unk_13C[3], heightCheckVisuals->heightCheckGraphics[SPRITE_RESOURCE_SPRITE_ANIM]); } static void DisplayTrainerHeight(HeightCheckVisuals *heightCheckVisuals, UnkStruct_ov21_021E6118 *param1, const UnkStruct_ov21_021E6104 *param2, enum HeapId heapID) diff --git a/src/overlay021/pokedex_search.c b/src/overlay021/pokedex_search.c new file mode 100644 index 0000000000..09f6195123 --- /dev/null +++ b/src/overlay021/pokedex_search.c @@ -0,0 +1,1074 @@ +#include "overlay021/pokedex_search.h" + +#include +#include + +#include "struct_decls/sprite_decl.h" + +#include "gmm/message_bank_pokedex.h" +#include "overlay021/ov21_021D0D80.h" +#include "overlay021/ov21_021D1FA4.h" +#include "overlay021/ov21_021D4340.h" +#include "overlay021/pokedex_sort.h" +#include "overlay021/struct_ov21_021D0F60_decl.h" +#include "overlay021/struct_ov21_021D13FC.h" +#include "overlay021/struct_ov21_021D3320.h" +#include "overlay021/struct_ov21_021D4660.h" +#include "overlay021/struct_ov21_021D5B68.h" +#include "overlay021/struct_ov21_021E68F4.h" +#include "overlay021/struct_ov21_021E6A68.h" +#include "overlay021/struct_ov21_021E6B20.h" + +#include "bg_window.h" +#include "cell_actor.h" +#include "font.h" +#include "heap.h" +#include "narc.h" +#include "sprite_resource.h" +#include "strbuf.h" +#include "text.h" +#include "unk_02005474.h" +#include "unk_0200762C.h" +#include "unk_020093B4.h" +#include "unk_0200A328.h" +#include "unk_0200A9DC.h" + +enum ScreenState { + SS_MENU, + SS_SEARCH, + SS_LOADING, + SS_RETURN, + SS_EXIT +}; + +typedef struct { + int *unk_00; + UnkStruct_ov21_021D3320 *unk_04; + UnkStruct_ov21_021D5B68 *unk_08; + enum FilterMethod filterMethod; + enum SortOrder sortOrder; + enum FilterName filterName; + enum FilterType typeFilter1; + enum FilterType typeFilter2; + enum FilterForm filterForm; + BOOL screenChange; + BOOL applyFilter; + BOOL noneFound; + enum ScreenState screenState; + int screenTimer; +} PokedexSearchSettings; + +typedef struct { + UnkStruct_ov21_021D13FC *unk_00; +} UnkStruct_ov21_021D879C; + +typedef struct { + enum FilterMethod filterMethod; + enum SortOrder sortOrder; + enum FilterName filterName; + enum FilterType typeFilter1; + enum FilterType typeFilter2; + enum FilterForm filterForm; + BOOL noneFound; + int noneFoundTimer; + CellActor *form; + SpriteResource *searchGraphics[4]; + PokedexLoadingScreen loadingScreen; + CellActor *pokeball; + void *tileMap; + NNSG2dScreenData *screenData; +} PokedexSearchDisplay; + +static PokedexSearchSettings *InitSearchSettings(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1); +static UnkStruct_ov21_021D879C *ov21_021D8724(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1); +static UnkStruct_ov21_021D4660 *ov21_021D874C(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1); +static void FreeSearchSettings(PokedexSearchSettings *searchSettings); +static void ov21_021D879C(UnkStruct_ov21_021D879C *param0); +static void ov21_021D87B0(UnkStruct_ov21_021D4660 *param0); +static int ov21_021D87C8(void); +static int ResetSearchSettings(UnkStruct_ov21_021E6A68 *param0, void *param1); +static int UpdateScreenState(UnkStruct_ov21_021E6A68 *param0, void *param1); +static int ov21_021D8928(UnkStruct_ov21_021E6A68 *param0, void *param1); +static int EnterPokedexSearch(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3); +static int UpdateDisplay(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3); +static int ExitPokedexSearch(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3); +static void LoadingScreenTransition(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1, const PokedexSearchSettings *searchSettings, enum HeapId heapID); +static void LoadingScreenAnimation(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1, const PokedexSearchSettings *searchSettings, enum HeapId heapID); +static void SearchingMessage(UnkStruct_ov21_021D879C *param0, enum HeapId heapID); +static void ReturnSearchDisplay(UnkStruct_ov21_021D879C *param0, PokedexSearchDisplay *searchDisplay, enum HeapId heapID); +static void DefaultDisplay(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1, const PokedexSearchSettings *searchSettings, const int *param3, int heapID); +static void ClearScreen(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1); +static void ov21_021D8B8C(UnkStruct_ov21_021D879C *param0, const PokedexSearchSettings *searchSettings, enum HeapId heapID); +static void GetSearchGraphics(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1, enum HeapId heapID); +static void FreeSearchGraphics(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1); +static void InitCellActors(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1, const PokedexSearchSettings *searchSettings, enum HeapId heapID); +static void FreeCellActors(PokedexSearchDisplay *searchDisplay); +static void GetDisplayMap(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1, const PokedexSearchSettings *searchSettings, enum HeapId heapID, int param4); +static void FreeDisplayMap(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1); +static void UpdateSelectionDisplay(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1, const PokedexSearchSettings *searchSettings, enum HeapId heapID); +static void FilterMethodMap(UnkStruct_ov21_021D879C *param0, int filterMethod, enum HeapId heapID); +static void DescriptionMessage(UnkStruct_ov21_021D879C *param0, int filterMethod, enum HeapId heapID); +static void SortOrderMessage(UnkStruct_ov21_021D879C *param0, int sortOrder, enum HeapId heapID); +static void FilterNameMessage(UnkStruct_ov21_021D879C *param0, int filterName, enum HeapId heapID); +static void FilterType1Message(UnkStruct_ov21_021D879C *param0, int typeFilter1, enum HeapId heapID); +static void FilterType2Message(UnkStruct_ov21_021D879C *param0, int typeFilter2, enum HeapId heapID); +static void FilterTypeMessage(UnkStruct_ov21_021D879C *param0, int typeFilter, enum HeapId heapID, int y); +static void FilterFormSilhouette(PokedexSearchDisplay *searchDisplay, int filterForm); +static void EmptyDexMessage(UnkStruct_ov21_021D879C *param0, enum HeapId heapID); +static void ov21_021D8C00(UnkStruct_ov21_021D879C *param0); + +void PokedexSearch_TransitionFunctions(UnkStruct_ov21_021E68F4 *param0, UnkStruct_ov21_021D0F60 *param1, enum HeapId heapID) +{ + PokedexSearchSettings *searchSettings = InitSearchSettings(heapID, param1); + UnkStruct_ov21_021D879C *v1 = ov21_021D8724(heapID, param1); + UnkStruct_ov21_021D4660 *v2 = ov21_021D874C(heapID, param1); + + param0->unk_00 = searchSettings; + param0->unk_04 = v1; + param0->unk_20 = v2; + param0->unk_24 = ov21_021D87C8(); + + param0->unk_08[0] = ResetSearchSettings; + param0->unk_08[1] = UpdateScreenState; + param0->unk_08[2] = ov21_021D8928; + param0->unk_14[0] = EnterPokedexSearch; + param0->unk_14[1] = UpdateDisplay; + param0->unk_14[2] = ExitPokedexSearch; +} + +void PokedexSearch_FreeData(UnkStruct_ov21_021E68F4 *param0) +{ + FreeSearchSettings(param0->unk_00); + ov21_021D879C(param0->unk_04); + ov21_021D87B0(param0->unk_20); +} + +void PokedexSearch_SetFilterMethod(UnkStruct_ov21_021E68F4 *param0, enum FilterMethod filterMethod) +{ + PokedexSearchSettings *searchSettings = param0->unk_00; + + GF_ASSERT(filterMethod < FilterMethod_MAX); + searchSettings->filterMethod = filterMethod; +} + +enum FilterMethod PokedexSearch_GetFilterMethod(const UnkStruct_ov21_021E68F4 *param0) +{ + const PokedexSearchSettings *searchSettings = param0->unk_00; + return searchSettings->filterMethod; +} + +void PokedexSearch_SetSortOrder(UnkStruct_ov21_021E68F4 *param0, enum SortOrder sortOrder) +{ + PokedexSearchSettings *searchSettings = param0->unk_00; + + GF_ASSERT(sortOrder < SORTORDER_NUM); + searchSettings->sortOrder = sortOrder; +} + +enum SortOrder PokedexSearch_GetSortOrder(const UnkStruct_ov21_021E68F4 *param0) +{ + const PokedexSearchSettings *searchSettings = param0->unk_00; + return searchSettings->sortOrder; +} + +void PokedexSearch_SetFilterName(UnkStruct_ov21_021E68F4 *param0, enum FilterName filterName) +{ + PokedexSearchSettings *searchSettings = param0->unk_00; + + GF_ASSERT(filterName < FILTERNAME_NUM); + searchSettings->filterName = filterName; +} + +enum FilterName PokedexSearch_GetFilterName(const UnkStruct_ov21_021E68F4 *param0) +{ + const PokedexSearchSettings *searchSettings = param0->unk_00; + return searchSettings->filterName; +} + +void PokedexSearch_SetFilterType(UnkStruct_ov21_021E68F4 *param0, enum FilterType filterType, int typeSlot) +{ + PokedexSearchSettings *searchSettings = param0->unk_00; + + GF_ASSERT(filterType < FILTERTYPE_NUM); + + if (typeSlot == 0) { + searchSettings->typeFilter1 = filterType; + } else { + searchSettings->typeFilter2 = filterType; + } +} + +enum FilterType PokedexSearch_GetFilterType(const UnkStruct_ov21_021E68F4 *param0, int typeSlot) +{ + const PokedexSearchSettings *searchSettings = param0->unk_00; + + if (typeSlot == 0) { + return searchSettings->typeFilter1; + } + + return searchSettings->typeFilter2; +} + +void PokedexSearch_SetFilterForm(UnkStruct_ov21_021E68F4 *param0, enum FilterForm filterForm) +{ + PokedexSearchSettings *searchSettings = param0->unk_00; + + GF_ASSERT(filterForm < FILTERFORM_NUM); + searchSettings->filterForm = filterForm; +} + +enum FilterForm PokedexSearch_GetFilterForm(const UnkStruct_ov21_021E68F4 *param0) +{ + const PokedexSearchSettings *searchSettings = param0->unk_00; + return searchSettings->filterForm; +} + +void PokedexSearch_SetFilteredState(UnkStruct_ov21_021E68F4 *param0, BOOL applyFilter) +{ + PokedexSearchSettings *searchSettings = param0->unk_00; + + searchSettings->screenChange = TRUE; + searchSettings->applyFilter = applyFilter; +} + +BOOL PokedexSearch_GetFilteredState(const UnkStruct_ov21_021E68F4 *param0) +{ + const PokedexSearchSettings *searchSettings = param0->unk_00; + return searchSettings->applyFilter; +} + +int PokedexSearch_GetScreenState(const UnkStruct_ov21_021E68F4 *param0) +{ + const PokedexSearchSettings *searchSettings = param0->unk_00; + return searchSettings->screenState; +} + +int PokedexSearch_GetScreenTimer(const UnkStruct_ov21_021E68F4 *param0) +{ + const PokedexSearchSettings *searchSettings = param0->unk_00; + return searchSettings->screenTimer; +} + +static PokedexSearchSettings *InitSearchSettings(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1) +{ + PokedexSearchSettings *searchSettings = Heap_AllocFromHeap(heapID, sizeof(PokedexSearchSettings)); + + GF_ASSERT(searchSettings); + memset(searchSettings, 0, sizeof(PokedexSearchSettings)); + + searchSettings->unk_00 = ov21_021D138C(param1); + searchSettings->unk_04 = ov21_021D13EC(param1); + UnkStruct_ov21_021E68F4 *v1 = ov21_021D1410(param1, 0); + searchSettings->unk_08 = v1->unk_00; + + return searchSettings; +} + +static UnkStruct_ov21_021D879C *ov21_021D8724(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1) +{ + UnkStruct_ov21_021D879C *v0 = Heap_AllocFromHeap(heapID, sizeof(UnkStruct_ov21_021D879C)); + + GF_ASSERT(v0); + memset(v0, 0, sizeof(UnkStruct_ov21_021D879C)); + + v0->unk_00 = ov21_021D13FC(param1); + + return v0; +} + +static UnkStruct_ov21_021D4660 *ov21_021D874C(enum HeapId heapID, UnkStruct_ov21_021D0F60 *param1) +{ + int v1 = ov21_021D87C8(); + + UnkStruct_ov21_021D4660 *v0 = Heap_AllocFromHeap(heapID, sizeof(UnkStruct_ov21_021D4660) * v1); + + GF_ASSERT(v0); + memset(v0, 0, sizeof(UnkStruct_ov21_021D4660) * v1); + + ov21_021D47F0(heapID, &v0[0], param1, (0x1 << 1)); + + return v0; +} + +static void FreeSearchSettings(PokedexSearchSettings *searchSettings) +{ + GF_ASSERT(searchSettings); + Heap_FreeToHeap(searchSettings); +} + +static void ov21_021D879C(UnkStruct_ov21_021D879C *param0) +{ + GF_ASSERT(param0); + Heap_FreeToHeap(param0); +} + +static void ov21_021D87B0(UnkStruct_ov21_021D4660 *param0) +{ + GF_ASSERT(param0); + + ov21_021D4660(¶m0[0]); + Heap_FreeToHeap(param0); +} + +static int ov21_021D87C8(void) +{ + return 1; +} + +static int ResetSearchSettings(UnkStruct_ov21_021E6A68 *param0, void *param1) +{ + PokedexSearchSettings *searchSettings = param1; + int *v1 = Heap_AllocFromHeap(param0->heapID, sizeof(int)); + + GF_ASSERT(v1); + memset(v1, 0, sizeof(int)); + + param0->unk_08 = v1; + + searchSettings->filterMethod = FM_ORDER; + searchSettings->sortOrder = SO_NUMERICAL; + searchSettings->filterName = FN_NONE; + searchSettings->typeFilter1 = FT_NONE; + searchSettings->typeFilter2 = FT_NONE; + searchSettings->filterForm = FF_NONE; + searchSettings->screenChange = FALSE; + searchSettings->applyFilter = FALSE; + searchSettings->screenState = SS_MENU; + + return 1; +} + +static int UpdateScreenState(UnkStruct_ov21_021E6A68 *param0, void *param1) +{ + PokedexSearchSettings *searchSettings = param1; + + if (param0->unk_0C == 1) { + return 1; + } + + if (param0->unk_10 == 1) { + return 0; + } + + switch (param0->unk_00) { + case 0: + + if (searchSettings->noneFound) { + searchSettings->noneFound = FALSE; + } + + if (searchSettings->screenChange == TRUE) { + if (searchSettings->applyFilter == FALSE) { + *searchSettings->unk_00 |= (0x1 << 1); + searchSettings->screenState = SS_EXIT; + } else { + searchSettings->screenState = SS_SEARCH; + searchSettings->screenTimer = 4; + param0->unk_00++; + } + } + break; + case 1: + searchSettings->screenTimer--; + + if (searchSettings->screenTimer < 0) { + param0->unk_00++; + + searchSettings->screenState = SS_LOADING; + searchSettings->screenTimer = 32; + + Sound_PlayEffect(1535); + } + break; + case 2: + searchSettings->screenTimer--; + + if (searchSettings->screenTimer < 0) { + param0->unk_00++; + } + break; + case 3: + BOOL dexExists = TRUE; + dexExists = PokedexSort_Sort(searchSettings->unk_04, searchSettings->sortOrder, searchSettings->filterName, searchSettings->typeFilter1, searchSettings->typeFilter2, searchSettings->filterForm, PokedexStatus_IsNationalDex(searchSettings->unk_04), param0->heapID, TRUE); + + if (dexExists == TRUE) { + *searchSettings->unk_00 |= (0x1 << 1); + PokedexSort_SetCurrentValues(searchSettings->unk_04, 0); + searchSettings->unk_04->unk_1740 = 1; + searchSettings->unk_08->unk_18 = 1; + } else { + searchSettings->applyFilter = FALSE; + searchSettings->screenChange = FALSE; + searchSettings->noneFound = TRUE; + searchSettings->screenState = SS_RETURN; + searchSettings->screenTimer = 4; + + param0->unk_00++; + } + break; + case 4: + searchSettings->screenTimer--; + + if (searchSettings->screenTimer < 0) { + searchSettings->screenState = SS_MENU; + searchSettings->screenTimer = 0; + param0->unk_00 = 0; + } + break; + default: + GF_ASSERT(FALSE); + break; + } + + return 0; +} + +static int ov21_021D8928(UnkStruct_ov21_021E6A68 *param0, void *param1) +{ + int *v0 = param0->unk_08; + + Heap_FreeToHeap(v0); + param0->unk_08 = NULL; + + return 1; +} + +static int EnterPokedexSearch(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3) +{ + const PokedexSearchSettings *searchSettings = param2; + const int *v1 = param3->unk_08; + UnkStruct_ov21_021D879C *v2 = param0; + PokedexSearchDisplay *searchDisplay = param1->unk_08; + + switch (param1->unk_00) { + case 0: + param1->unk_08 = Heap_AllocFromHeap(param1->heapID, sizeof(PokedexSearchDisplay)); + memset(param1->unk_08, 0, sizeof(PokedexSearchDisplay)); + param1->unk_00++; + break; + case 1: + DefaultDisplay(searchDisplay, v2, searchSettings, v1, param1->heapID); + sub_0200AAE0(1, 0, -16, (GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD), 1); + param1->unk_00++; + break; + case 2: + if (sub_0200AC1C(1)) { + param1->unk_00++; + } + break; + case 3: + return 1; + } + + return 0; +} + +static int UpdateDisplay(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3) +{ + const PokedexSearchSettings *searchSettings = param2; + UnkStruct_ov21_021D879C *v2 = param0; + PokedexSearchDisplay *searchDisplay = param1->unk_08; + + if (searchSettings->screenState == SS_MENU) { + UpdateSelectionDisplay(searchDisplay, v2, searchSettings, param1->heapID); + } else if ((searchSettings->screenState == SS_SEARCH) || (searchSettings->screenState == SS_RETURN)) { + LoadingScreenTransition(searchDisplay, v2, searchSettings, param1->heapID); + } else if (searchSettings->screenState != SS_EXIT) { + LoadingScreenAnimation(searchDisplay, v2, searchSettings, param1->heapID); + } + + return 0; +} + +static int ExitPokedexSearch(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3) +{ + const PokedexSearchSettings *searchSettings = param2; + UnkStruct_ov21_021D879C *v2 = param0; + PokedexSearchDisplay *searchDisplay = param1->unk_08; + + switch (param1->unk_00) { + case 0: + if (searchSettings->applyFilter == FALSE) { + sub_0200AAE0(6, -16, 0, (GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD), 1); + param1->unk_00++; + } else { + param1->unk_00 = 2; + } + break; + case 1: + if (sub_0200AC1C(1)) { + param1->unk_00++; + } + break; + case 2: + ClearScreen(searchDisplay, v2); + param1->unk_00++; + break; + case 3: + Heap_FreeToHeap(param1->unk_08); + param1->unk_08 = NULL; + param1->unk_00++; + break; + case 4: + return 1; + } + + return 0; +} + +static void DefaultDisplay(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1, const PokedexSearchSettings *searchSettings, const int *param3, int heapID) +{ + Bg_ClearTilemap(param1->unk_00->unk_00, 2); + Bg_ClearTilemap(param1->unk_00->unk_00, 1); + Window_FillTilemap(¶m1->unk_00->unk_04, 0); + Window_SetPalette(¶m1->unk_00->unk_04, 7); + + ov21_021D8C00(param1); + ov21_021D8B8C(param1, searchSettings, heapID); + GetDisplayMap(searchDisplay, param1, searchSettings, heapID, PokedexStatus_IsNationalDex(searchSettings->unk_04)); + GetSearchGraphics(searchDisplay, param1, heapID); + InitCellActors(searchDisplay, param1, searchSettings, heapID); + + DescriptionMessage(param1, searchSettings->filterMethod, heapID); + FilterMethodMap(param1, searchSettings->filterMethod, heapID); + SortOrderMessage(param1, searchSettings->sortOrder, heapID); + FilterNameMessage(param1, searchSettings->filterName, heapID); + FilterType1Message(param1, searchSettings->typeFilter1, heapID); + FilterType2Message(param1, searchSettings->typeFilter2, heapID); + FilterFormSilhouette(searchDisplay, searchSettings->filterForm); + + Bg_SetPriority(1, 1); + Bg_SetPriority(2, 0); +} + +static void ClearScreen(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1) +{ + FreeCellActors(searchDisplay); + FreeSearchGraphics(searchDisplay, param1); + FreeDisplayMap(searchDisplay, param1); + + Bg_ClearTilemap(param1->unk_00->unk_00, 1); + Window_FillTilemap(¶m1->unk_00->unk_04, 0); + Window_SetPalette(¶m1->unk_00->unk_04, 0); + Bg_SetPriority(1, 0); + Bg_SetPriority(2, 1); +} + +static void ov21_021D8B8C(UnkStruct_ov21_021D879C *param0, const PokedexSearchSettings *searchSettings, enum HeapId heapID) +{ + ov21_021D2724(param0->unk_00, 28, param0->unk_00->unk_00, 3, 0, 0, 1, heapID); + ov21_021D276C(param0->unk_00, 5, 0, 0, 32, heapID); +} + +static void GetDisplayMap(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1, const PokedexSearchSettings *searchSettings, enum HeapId heapID, int param4) +{ + int mapIndex; + + if (param4 == 1) { + mapIndex = 42; + } else { + mapIndex = 40; + } + + searchDisplay->tileMap = ov21_021D27B8(param1->unk_00, mapIndex, 1, &searchDisplay->screenData, heapID); +} + +static void FreeDisplayMap(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1) +{ + Heap_FreeToHeap(searchDisplay->tileMap); + searchDisplay->tileMap = NULL; + searchDisplay->screenData = NULL; +} + +static void ov21_021D8C00(UnkStruct_ov21_021D879C *param0) +{ + Sprite *v0 = ov21_021D2170(param0->unk_00); + + sub_02007DEC(v0, 6, 1); + sub_02008780(v0); +} + +static void GetSearchGraphics(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1, enum HeapId heapID) +{ + UnkStruct_ov21_021D13FC *v0 = param1->unk_00; + NARC *pokedexGraphics = ov21_021D26E0(v0); + + searchDisplay->searchGraphics[SPRITE_RESOURCE_TILES] = SpriteResourceCollection_AddTilesFrom(v0->unk_13C[0], pokedexGraphics, 81, 1, 81 + 15000, NNS_G2D_VRAM_TYPE_2DMAIN, heapID); + + sub_0200A3DC(searchDisplay->searchGraphics[SPRITE_RESOURCE_TILES]); + SpriteResource_ReleaseData(searchDisplay->searchGraphics[SPRITE_RESOURCE_TILES]); + + searchDisplay->searchGraphics[SPRITE_RESOURCE_PALETTE] = SpriteResourceCollection_AddPaletteFrom(v0->unk_13C[1], pokedexGraphics, 3, 0, 3 + 15000, NNS_G2D_VRAM_TYPE_2DMAIN, 12, heapID); + + sub_0200A640(searchDisplay->searchGraphics[SPRITE_RESOURCE_PALETTE]); + SpriteResource_ReleaseData(searchDisplay->searchGraphics[SPRITE_RESOURCE_PALETTE]); + + searchDisplay->searchGraphics[SPRITE_RESOURCE_SPRITE] = SpriteResourceCollection_AddFrom(v0->unk_13C[2], pokedexGraphics, 79, 1, 79 + 15000, SPRITE_RESOURCE_SPRITE, heapID); + searchDisplay->searchGraphics[SPRITE_RESOURCE_SPRITE_ANIM] = SpriteResourceCollection_AddFrom(v0->unk_13C[3], pokedexGraphics, 80, 1, 80 + 15000, SPRITE_RESOURCE_SPRITE_ANIM, heapID); +} + +static void FreeSearchGraphics(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1) +{ + UnkStruct_ov21_021D13FC *v0 = param1->unk_00; + + sub_0200A4E4(searchDisplay->searchGraphics[SPRITE_RESOURCE_TILES]); + sub_0200A6DC(searchDisplay->searchGraphics[SPRITE_RESOURCE_PALETTE]); + + SpriteResourceCollection_Remove(v0->unk_13C[0], searchDisplay->searchGraphics[SPRITE_RESOURCE_TILES]); + SpriteResourceCollection_Remove(v0->unk_13C[1], searchDisplay->searchGraphics[SPRITE_RESOURCE_PALETTE]); + SpriteResourceCollection_Remove(v0->unk_13C[2], searchDisplay->searchGraphics[SPRITE_RESOURCE_SPRITE]); + SpriteResourceCollection_Remove(v0->unk_13C[3], searchDisplay->searchGraphics[SPRITE_RESOURCE_SPRITE_ANIM]); +} + +static void InitCellActors(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1, const PokedexSearchSettings *searchSettings, enum HeapId heapID) +{ + CellActorResourceData v0; + CellActorInitParams v1; + UnkStruct_ov21_021D13FC *v2 = param1->unk_00; + + sub_020093B4(&v0, 81 + 15000, 3 + 15000, 79 + 15000, 80 + 15000, 0xffffffff, 0xffffffff, 0, 2, v2->unk_13C[0], v2->unk_13C[1], v2->unk_13C[2], v2->unk_13C[3], NULL, NULL); + + v1.collection = v2->unk_138; + v1.resourceData = &v0; + v1.priority = 31; + v1.vramType = NNS_G2D_VRAM_TYPE_2DMAIN; + v1.heapID = heapID; + + v1.position.x = 128 << FX32_SHIFT; + v1.position.y = 164 << FX32_SHIFT; + searchDisplay->form = CellActorCollection_Add(&v1); + + CellActor_SetAnim(searchDisplay->form, 3); + + v1.position.x = 128 << FX32_SHIFT; + v1.position.y = 96 << FX32_SHIFT; + + searchDisplay->pokeball = CellActorCollection_Add(&v1); + + CellActor_SetAnim(searchDisplay->pokeball, 17); + CellActor_SetDrawFlag(searchDisplay->pokeball, FALSE); + CellActor_SetAffineOverwriteMode(searchDisplay->pokeball, AFFINE_OVERWRITE_MODE_NORMAL); + CellActor_SetExplicitPriority(searchDisplay->pokeball, 0); +} + +static void FreeCellActors(PokedexSearchDisplay *searchDisplay) +{ + CellActor_Delete(searchDisplay->form); + CellActor_Delete(searchDisplay->pokeball); +} + +static void DescriptionMessage(UnkStruct_ov21_021D879C *param0, int filterMethod, enum HeapId heapID) +{ + UnkStruct_ov21_021D13FC *v0 = param0->unk_00; + int entryID; + + Window_FillRectWithColor(&v0->unk_04, 0, 24, 8, 208, 32); + + switch (filterMethod) { + case FM_ORDER: + entryID = pl_msg_pokedex_listing_description; + break; + case FM_NAME: + entryID = pl_msg_pokedex_alphabetical_description; + break; + case FM_TYPE: + entryID = pl_msg_pokedex_type_description; + break; + case FM_FORM: + entryID = pl_msg_pokedex_body_description; + break; + default: + break; + } + + Strbuf *descriptionMessage = GetPokedexMessage(entryID, heapID); + + { + u32 v3 = 24 + (208 - Font_CalcMaxLineWidth(FONT_SYSTEM, descriptionMessage, 0)) / 2; + u32 v4 = 8 + (32 - Strbuf_NumLines(descriptionMessage) * 16) / 2; + Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, descriptionMessage, v3, v4, TEXT_SPEED_INSTANT, TEXT_COLOR(2, 1, 0), NULL); + } + + Strbuf_Free(descriptionMessage); +} + +static void EmptyDexMessage(UnkStruct_ov21_021D879C *param0, enum HeapId heapID) +{ + UnkStruct_ov21_021D13FC *v0 = param0->unk_00; + + Window_FillRectWithColor(&v0->unk_04, 0, 24, 8, 208, 32); + + Strbuf *noneMessage = GetPokedexMessage(pl_msg_pokedex_nonefound, heapID); + + { + u32 xOffset = 24 + (208 - Font_CalcMaxLineWidth(FONT_SYSTEM, noneMessage, 0)) / 2; + u32 yOffset = 8 + (32 - Strbuf_NumLines(noneMessage) * 16) / 2; + Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, noneMessage, xOffset, yOffset, TEXT_SPEED_INSTANT, TEXT_COLOR(2, 1, 0), NULL); + } + + Strbuf_Free(noneMessage); +} + +static void UpdateSelectionDisplay(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1, const PokedexSearchSettings *searchSettings, enum HeapId heapID) +{ + if (searchSettings->noneFound != searchDisplay->noneFound) { + searchDisplay->noneFound = searchSettings->noneFound; + + if (searchDisplay->noneFound == TRUE) { + searchDisplay->noneFoundTimer = 64; + EmptyDexMessage(param1, heapID); + } + } + + if (searchDisplay->noneFoundTimer > 0) { + searchDisplay->noneFoundTimer--; + } else if (searchDisplay->noneFoundTimer == 0) { + DescriptionMessage(param1, searchSettings->filterMethod, heapID); + searchDisplay->noneFoundTimer--; + } + + if (searchDisplay->filterMethod != searchSettings->filterMethod) { + FilterMethodMap(param1, searchSettings->filterMethod, heapID); + DescriptionMessage(param1, searchSettings->filterMethod, heapID); + searchDisplay->filterMethod = searchSettings->filterMethod; + } + + if (searchDisplay->sortOrder != searchSettings->sortOrder) { + SortOrderMessage(param1, searchSettings->sortOrder, heapID); + searchDisplay->sortOrder = searchSettings->sortOrder; + } + + if (searchDisplay->filterName != searchSettings->filterName) { + FilterNameMessage(param1, searchSettings->filterName, heapID); + searchDisplay->filterName = searchSettings->filterName; + } + + if (searchDisplay->typeFilter1 != searchSettings->typeFilter1) { + FilterType1Message(param1, searchSettings->typeFilter1, heapID); + searchDisplay->typeFilter1 = searchSettings->typeFilter1; + } + + if (searchDisplay->typeFilter2 != searchSettings->typeFilter2) { + FilterType2Message(param1, searchSettings->typeFilter2, heapID); + searchDisplay->typeFilter2 = searchSettings->typeFilter2; + } + + if (searchDisplay->filterForm != searchSettings->filterForm) { + FilterFormSilhouette(searchDisplay, searchSettings->filterForm); + searchDisplay->filterForm = searchSettings->filterForm; + } +} + +static void FilterMethodMap(UnkStruct_ov21_021D879C *param0, int filterMethod, enum HeapId heapID) +{ + void *v0; + NNSG2dScreenData *v1; + int y; + int mapIndex; + + v0 = ov21_021D27B8(param0->unk_00, 43, 1, &v1, heapID); + + Bg_LoadToTilemapRect(param0->unk_00->unk_00, 3, v1->rawData, 0, 0, v1->screenWidth / 8, v1->screenHeight / 8); + Heap_FreeToHeap(v0); + + switch (filterMethod) { + case FM_ORDER: + y = 6; + mapIndex = 44; + break; + case FM_NAME: + y = 9; + mapIndex = 45; + break; + case FM_TYPE: + y = 12; + mapIndex = 46; + break; + case FM_FORM: + y = 17; + mapIndex = 47; + break; + default: + break; + } + + v0 = ov21_021D27B8(param0->unk_00, mapIndex, 1, &v1, heapID); + + Bg_LoadToTilemapRect(param0->unk_00->unk_00, 3, v1->rawData, 6, y, v1->screenWidth / 8, v1->screenHeight / 8); + Heap_FreeToHeap(v0); + Bg_ScheduleTilemapTransfer(param0->unk_00->unk_00, 3); +} + +static void SortOrderMessage(UnkStruct_ov21_021D879C *param0, int sortOrder, enum HeapId heapID) +{ + UnkStruct_ov21_021D13FC *v0 = param0->unk_00; + + Window_FillRectWithColor(&v0->unk_04, 0, 88, 52, 80, 16); + + int entryID = pl_msg_pokedex_numerical + sortOrder; + Strbuf *sortMessage = GetPokedexMessage(entryID, heapID); + + { + u32 v3 = 88 + Font_CalcCenterAlignment(FONT_SYSTEM, sortMessage, 0, 80); + Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, sortMessage, v3, 52, TEXT_SPEED_INSTANT, TEXT_COLOR(4, 3, 0), NULL); + } + + Strbuf_Free(sortMessage); +} + +static void FilterNameMessage(UnkStruct_ov21_021D879C *param0, int filterName, enum HeapId heapID) +{ + UnkStruct_ov21_021D13FC *v0 = param0->unk_00; + int entryID; + + Window_FillRectWithColor(&v0->unk_04, 0, 88, 77, 80, 16); + + switch (filterName) { + case FN_NONE: + entryID = pl_msg_pokedex_nonealphabetical; + break; + case FN_ABC: + entryID = pl_msg_pokedex_abc; + break; + case FN_DEF: + entryID = pl_msg_pokedex_def; + break; + case FN_GHI: + entryID = pl_msg_pokedex_ghi; + break; + case FN_JKL: + entryID = pl_msg_pokedex_jkl; + break; + case FN_MNO: + entryID = pl_msg_pokedex_mno; + break; + case FN_PQR: + entryID = pl_msg_pokedex_pqr; + break; + case FN_STU: + entryID = pl_msg_pokedex_stu; + break; + case FN_VWX: + entryID = pl_msg_pokedex_vwx; + break; + case FN_YZ: + entryID = pl_msg_pokedex_yz; + break; + } + + Strbuf *filterMessage = GetPokedexMessage(entryID, heapID); + + { + u32 v4 = 88 + Font_CalcCenterAlignment(FONT_SYSTEM, filterMessage, 0, 80); + Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, filterMessage, v4, 77, TEXT_SPEED_INSTANT, TEXT_COLOR(4, 3, 0), NULL); + } + + Strbuf_Free(filterMessage); +} + +static void FilterTypeMessage(UnkStruct_ov21_021D879C *param0, int typeFilter, enum HeapId heapID, int y) +{ + UnkStruct_ov21_021D13FC *v0 = param0->unk_00; + int entryID; + + Window_FillRectWithColor(&v0->unk_04, 0, 88, y, 80, 16); + + switch (typeFilter) { + case FT_NONE: + entryID = pl_msg_pokedex_dash; + break; + case FT_NORMAL: + entryID = pl_msg_pokedex_normal; + break; + case FT_FIGHTING: + entryID = pl_msg_pokedex_fight; + break; + case FT_FLYING: + entryID = pl_msg_pokedex_flying; + break; + case FT_POISON: + entryID = pl_msg_pokedex_poison; + break; + case FT_GROUND: + entryID = pl_msg_pokedex_ground; + break; + case FT_ROCK: + entryID = pl_msg_pokedex_rock; + break; + case FT_BUG: + entryID = pl_msg_pokedex_bug; + break; + case FT_GHOST: + entryID = pl_msg_pokedex_ghost; + break; + case FT_STEEL: + entryID = pl_msg_pokedex_steel; + break; + case FT_FIRE: + entryID = pl_msg_pokedex_fire; + break; + case FT_WATER: + entryID = pl_msg_pokedex_water; + break; + case FT_GRASS: + entryID = pl_msg_pokedex_grass; + break; + case FT_ELECTRIC: + entryID = pl_msg_pokedex_electric; + break; + case FT_PSYCHIC: + entryID = pl_msg_pokedex_psychic; + break; + case FT_ICE: + entryID = pl_msg_pokedex_ice; + break; + case FT_DRAGON: + entryID = pl_msg_pokedex_dragon; + break; + case FT_DARK: + entryID = pl_msg_pokedex_dark; + break; + } + + Strbuf *filterMessage = GetPokedexMessage(entryID, heapID); + + { + u32 v4 = 88 + Font_CalcCenterAlignment(FONT_SYSTEM, filterMessage, 0, 80); + Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, filterMessage, v4, y, TEXT_SPEED_INSTANT, TEXT_COLOR(4, 3, 0), NULL); + } + + Strbuf_Free(filterMessage); +} + +static void FilterType1Message(UnkStruct_ov21_021D879C *param0, int typeFilter1, enum HeapId heapID) +{ + FilterTypeMessage(param0, typeFilter1, heapID, 102); +} + +static void FilterType2Message(UnkStruct_ov21_021D879C *param0, int typeFilter2, enum HeapId heapID) +{ + FilterTypeMessage(param0, typeFilter2, heapID, 120); +} + +static void FilterFormSilhouette(PokedexSearchDisplay *searchDisplay, int filterForm) +{ + if (filterForm == FF_NONE) { + CellActor_SetDrawFlag(searchDisplay->form, 0); + } else { + CellActor_SetDrawFlag(searchDisplay->form, 1); + + switch (filterForm) { + case FF_QUADRUPED: + CellActor_SetAnim(searchDisplay->form, 3); + break; + case FF_BIPEDALTAILLESS: + CellActor_SetAnim(searchDisplay->form, 4); + break; + case FF_BIPEDALTAILED: + CellActor_SetAnim(searchDisplay->form, 5); + break; + case FF_SERPENTINE: + CellActor_SetAnim(searchDisplay->form, 6); + break; + case FF_MULTIWINGED: + CellActor_SetAnim(searchDisplay->form, 7); + break; + case FF_WINGED: + CellActor_SetAnim(searchDisplay->form, 8); + break; + case FF_INSECTOID: + CellActor_SetAnim(searchDisplay->form, 9); + break; + case FF_HEADBASE: + CellActor_SetAnim(searchDisplay->form, 10); + break; + case FF_HEADARMS: + CellActor_SetAnim(searchDisplay->form, 11); + break; + case FF_HEADLEGS: + CellActor_SetAnim(searchDisplay->form, 12); + break; + case FF_TENTACLES: + CellActor_SetAnim(searchDisplay->form, 13); + break; + case FF_FINS: + CellActor_SetAnim(searchDisplay->form, 14); + break; + case FF_HEAD: + CellActor_SetAnim(searchDisplay->form, 15); + break; + case FF_MULTIBODY: + CellActor_SetAnim(searchDisplay->form, 16); + break; + default: + break; + } + } +} + +static void LoadingScreenTransition(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1, const PokedexSearchSettings *searchSettings, enum HeapId heapID) +{ + if (searchSettings->screenTimer == 4) { + if (searchSettings->screenState == SS_SEARCH) { + Pokedex_SetLoadingScreenParams(&searchDisplay->loadingScreen, param1->unk_00->unk_00, 2, searchDisplay->screenData, 0, 12, 0, 20, 4); + } else { + ReturnSearchDisplay(param1, searchDisplay, heapID); + + Pokedex_SetLoadingScreenParams(&searchDisplay->loadingScreen, param1->unk_00->unk_00, 2, searchDisplay->screenData, 12, 0, 20, 0, 4); + } + } + + Pokedex_LoadingScreenMove(&searchDisplay->loadingScreen); +} + +static void LoadingScreenAnimation(PokedexSearchDisplay *searchDisplay, UnkStruct_ov21_021D879C *param1, const PokedexSearchSettings *searchSettings, enum HeapId heapID) +{ + if (searchSettings->screenTimer == 32) { + CellActor_SetDrawFlag(searchDisplay->pokeball, TRUE); + SearchingMessage(param1, heapID); + } else if (searchSettings->screenTimer == 0) { + CellActor_SetDrawFlag(searchDisplay->pokeball, FALSE); + Window_FillTilemap(¶m1->unk_00->unk_04, 0); + Window_ScheduleCopyToVRAM(¶m1->unk_00->unk_04); + } + + int time = 4 - searchSettings->screenTimer; + int angle = ((180 * 0xffff) / 360) * time; + angle = angle / 4; + + CellActor_SetAffineZRotation(searchDisplay->pokeball, (u16)angle); +} + +static void SearchingMessage(UnkStruct_ov21_021D879C *param0, enum HeapId heapID) +{ + UnkStruct_ov21_021D13FC *v0 = param0->unk_00; + + Window_FillTilemap(¶m0->unk_00->unk_04, 0); + + Strbuf *searchingMessage = GetPokedexMessage(pl_msg_pokedex_searching, heapID); + + { + u32 xOffset = (256 - Font_CalcMaxLineWidth(FONT_SYSTEM, searchingMessage, 0)) / 2; + + Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, searchingMessage, xOffset, 128, TEXT_SPEED_INSTANT, TEXT_COLOR(2, 1, 0), NULL); + } + + Strbuf_Free(searchingMessage); + Bg_SetPriority(1, 0); + Bg_SetPriority(2, 1); +} + +static void ReturnSearchDisplay(UnkStruct_ov21_021D879C *param0, PokedexSearchDisplay *searchDisplay, enum HeapId heapID) +{ + Bg_SetPriority(1, 1); + Bg_SetPriority(2, 0); + Window_FillTilemap(¶m0->unk_00->unk_04, 0); + + FilterMethodMap(param0, searchDisplay->filterMethod, heapID); + DescriptionMessage(param0, searchDisplay->filterMethod, heapID); + SortOrderMessage(param0, searchDisplay->sortOrder, heapID); + FilterNameMessage(param0, searchDisplay->filterName, heapID); + FilterType1Message(param0, searchDisplay->typeFilter1, heapID); + FilterType2Message(param0, searchDisplay->typeFilter2, heapID); + FilterFormSilhouette(searchDisplay, searchDisplay->filterForm); +} diff --git a/src/overlay021/pokedex_sort.c b/src/overlay021/pokedex_sort.c index 5eaa7b04f3..3200b52bfa 100644 --- a/src/overlay021/pokedex_sort.c +++ b/src/overlay021/pokedex_sort.c @@ -263,7 +263,7 @@ u32 ov21_021D3458(const UnkStruct_ov21_021D3320 *param0) return param0->unk_175E; } -BOOL PokedexSort_Sort(UnkStruct_ov21_021D3320 *param0, int sortOrder, int filterName, int filterType1, int filterType2, int filterForm, int isNationalDex, enum HeapId heapID, BOOL isFiltered) +BOOL PokedexSort_Sort(UnkStruct_ov21_021D3320 *param0, enum SortOrder sortOrder, enum FilterName filterName, enum FilterType filterType1, enum FilterType filterType2, enum FilterForm filterForm, int isNationalDex, enum HeapId heapID, BOOL isFiltered) { u16 *encounteredPokedex; int caughtStatusLength; @@ -379,7 +379,7 @@ BOOL PokedexSort_Sort(UnkStruct_ov21_021D3320 *param0, int sortOrder, int filter return dexExists; } -BOOL PokedexSort_SortUnfiltered(UnkStruct_ov21_021D3320 *param0, int sortOrder, int filterName, int filterType1, int filterType2, int filterForm, int isNationalDex, enum HeapId heapID) +BOOL PokedexSort_SortUnfiltered(UnkStruct_ov21_021D3320 *param0, enum SortOrder sortOrder, enum FilterName filterName, enum FilterType filterType1, enum FilterType filterType2, enum FilterForm filterForm, int isNationalDex, enum HeapId heapID) { return PokedexSort_Sort(param0, sortOrder, filterName, filterType1, filterType2, filterForm, isNationalDex, heapID, FALSE); } From 08dad45c75778ceb721007ec5c75052ecd2a131e Mon Sep 17 00:00:00 2001 From: h2o-DS <71458559+h2o-DS@users.noreply.github.com> Date: Mon, 27 Jan 2025 22:48:56 -0500 Subject: [PATCH 2/2] Polish config -> bgConfig MAX_X enums SearchSettings->exitFlag 1535 -> SEQ_SE_DP_Z_SEARCH Removed unnecessary scope blocks --- include/overlay021/ov21_021D0D80.h | 4 +-- include/overlay021/pokedex_search.h | 2 +- include/overlay021/pokedex_sort.h | 8 ++--- src/overlay021/ov21_021D0D80.c | 12 +++---- src/overlay021/pokedex_search.c | 54 ++++++++++++++--------------- 5 files changed, 39 insertions(+), 41 deletions(-) diff --git a/include/overlay021/ov21_021D0D80.h b/include/overlay021/ov21_021D0D80.h index cc71ed0cb2..e4a1ba97cb 100644 --- a/include/overlay021/ov21_021D0D80.h +++ b/include/overlay021/ov21_021D0D80.h @@ -21,8 +21,8 @@ #include "strbuf.h" #include "touch_screen.h" -typedef struct { - BgConfig *config; +typedef struct PokedexLoadingScreen { + BgConfig *bgConfig; NNSG2dScreenData *screenData; int layer; int topStart; diff --git a/include/overlay021/pokedex_search.h b/include/overlay021/pokedex_search.h index d52d544da8..db526b4177 100644 --- a/include/overlay021/pokedex_search.h +++ b/include/overlay021/pokedex_search.h @@ -12,7 +12,7 @@ enum FilterMethod { FM_NAME, FM_TYPE, FM_FORM, - FilterMethod_MAX + MAX_FILTER_METHOD }; void PokedexSearch_TransitionFunctions(UnkStruct_ov21_021E68F4 *param0, UnkStruct_ov21_021D0F60 *param1, enum HeapId heapID); diff --git a/include/overlay021/pokedex_sort.h b/include/overlay021/pokedex_sort.h index 7904978004..b85b8128ee 100644 --- a/include/overlay021/pokedex_sort.h +++ b/include/overlay021/pokedex_sort.h @@ -15,7 +15,7 @@ enum SortOrder { SO_LIGHTEST, SO_TALLEST, SO_SMALLEST, - SORTORDER_NUM + MAX_SORT_ORDER }; enum FilterName { @@ -29,7 +29,7 @@ enum FilterName { FN_STU, FN_VWX, FN_YZ, - FILTERNAME_NUM + MAX_FILTER_NAME }; enum FilterType { @@ -51,7 +51,7 @@ enum FilterType { FT_ICE, FT_DRAGON, FT_DARK, - FILTERTYPE_NUM + MAX_FILTER_TYPE }; enum FilterForm { // called form in game, but refers to body shape @@ -70,7 +70,7 @@ enum FilterForm { // called form in game, but refers to body shape FF_FINS, FF_HEAD, FF_MULTIBODY, - FILTERFORM_NUM + MAX_FILTER_FORM }; void PokedexSort_PopulatePokedexStatus(UnkStruct_ov21_021D3320 *param0, UnkStruct_ov21_021D3208 *param1, enum HeapId heapID); diff --git a/src/overlay021/ov21_021D0D80.c b/src/overlay021/ov21_021D0D80.c index 06cfae56fe..6ecaa5888c 100644 --- a/src/overlay021/ov21_021D0D80.c +++ b/src/overlay021/ov21_021D0D80.c @@ -606,9 +606,9 @@ void ov21_021D154C(TouchScreenHitTable *hitTable, int param1, int param2, int pa hitTable->rect.right = param4; } -void Pokedex_SetLoadingScreenParams(PokedexLoadingScreen *param0, BgConfig *config, int layer, NNSG2dScreenData *screenData, int topStart, int topEnd, int bottomStart, int bottomEnd, int duration) +void Pokedex_SetLoadingScreenParams(PokedexLoadingScreen *param0, BgConfig *bgConfig, int layer, NNSG2dScreenData *screenData, int topStart, int topEnd, int bottomStart, int bottomEnd, int duration) { - param0->config = config; + param0->bgConfig = bgConfig; param0->layer = layer; param0->screenData = screenData; param0->topStart = topStart; @@ -625,7 +625,7 @@ BOOL Pokedex_LoadingScreenMove(PokedexLoadingScreen *loadingScreen) int bottomPos; if (loadingScreen->counter <= loadingScreen->duration) { - Bg_FillTilemapRect(loadingScreen->config, loadingScreen->layer, 0, 0, 0, 32, 24, 16); + Bg_FillTilemapRect(loadingScreen->bgConfig, loadingScreen->layer, 0, 0, 0, 32, 24, 16); topPos = (loadingScreen->topDist * loadingScreen->counter) / loadingScreen->duration; bottomPos = (loadingScreen->bottomDist * loadingScreen->counter) / loadingScreen->duration; @@ -633,14 +633,14 @@ BOOL Pokedex_LoadingScreenMove(PokedexLoadingScreen *loadingScreen) bottomPos += loadingScreen->bottomStart; if (topPos > 0) { - Bg_CopyToTilemapRect(loadingScreen->config, loadingScreen->layer, 0, 0, 32, topPos, loadingScreen->screenData->rawData, 0, 32 - topPos, 32, 32); + Bg_CopyToTilemapRect(loadingScreen->bgConfig, loadingScreen->layer, 0, 0, 32, topPos, loadingScreen->screenData->rawData, 0, 32 - topPos, 32, 32); } if ((32 - bottomPos) > 0) { - Bg_CopyToTilemapRect(loadingScreen->config, loadingScreen->layer, 0, 32 - bottomPos, 32, bottomPos, loadingScreen->screenData->rawData, 0, 0, 32, 32); + Bg_CopyToTilemapRect(loadingScreen->bgConfig, loadingScreen->layer, 0, 32 - bottomPos, 32, bottomPos, loadingScreen->screenData->rawData, 0, 0, 32, 32); } - Bg_ScheduleTilemapTransfer(loadingScreen->config, loadingScreen->layer); + Bg_ScheduleTilemapTransfer(loadingScreen->bgConfig, loadingScreen->layer); loadingScreen->counter++; return FALSE; diff --git a/src/overlay021/pokedex_search.c b/src/overlay021/pokedex_search.c index 09f6195123..bc66689969 100644 --- a/src/overlay021/pokedex_search.c +++ b/src/overlay021/pokedex_search.c @@ -3,6 +3,8 @@ #include #include +#include "consts/sdat.h" + #include "struct_decls/sprite_decl.h" #include "gmm/message_bank_pokedex.h" @@ -33,6 +35,8 @@ #include "unk_0200A328.h" #include "unk_0200A9DC.h" +#define EXITSEARCH (1 << 1) + enum ScreenState { SS_MENU, SS_SEARCH, @@ -42,7 +46,7 @@ enum ScreenState { }; typedef struct { - int *unk_00; + int *exitFlag; UnkStruct_ov21_021D3320 *unk_04; UnkStruct_ov21_021D5B68 *unk_08; enum FilterMethod filterMethod; @@ -147,7 +151,7 @@ void PokedexSearch_SetFilterMethod(UnkStruct_ov21_021E68F4 *param0, enum FilterM { PokedexSearchSettings *searchSettings = param0->unk_00; - GF_ASSERT(filterMethod < FilterMethod_MAX); + GF_ASSERT(filterMethod < MAX_FILTER_METHOD); searchSettings->filterMethod = filterMethod; } @@ -161,7 +165,7 @@ void PokedexSearch_SetSortOrder(UnkStruct_ov21_021E68F4 *param0, enum SortOrder { PokedexSearchSettings *searchSettings = param0->unk_00; - GF_ASSERT(sortOrder < SORTORDER_NUM); + GF_ASSERT(sortOrder < MAX_SORT_ORDER); searchSettings->sortOrder = sortOrder; } @@ -175,7 +179,7 @@ void PokedexSearch_SetFilterName(UnkStruct_ov21_021E68F4 *param0, enum FilterNam { PokedexSearchSettings *searchSettings = param0->unk_00; - GF_ASSERT(filterName < FILTERNAME_NUM); + GF_ASSERT(filterName < MAX_FILTER_NAME); searchSettings->filterName = filterName; } @@ -189,7 +193,7 @@ void PokedexSearch_SetFilterType(UnkStruct_ov21_021E68F4 *param0, enum FilterTyp { PokedexSearchSettings *searchSettings = param0->unk_00; - GF_ASSERT(filterType < FILTERTYPE_NUM); + GF_ASSERT(filterType < MAX_FILTER_TYPE); if (typeSlot == 0) { searchSettings->typeFilter1 = filterType; @@ -213,7 +217,7 @@ void PokedexSearch_SetFilterForm(UnkStruct_ov21_021E68F4 *param0, enum FilterFor { PokedexSearchSettings *searchSettings = param0->unk_00; - GF_ASSERT(filterForm < FILTERFORM_NUM); + GF_ASSERT(filterForm < MAX_FILTER_FORM); searchSettings->filterForm = filterForm; } @@ -256,7 +260,7 @@ static PokedexSearchSettings *InitSearchSettings(enum HeapId heapID, UnkStruct_o GF_ASSERT(searchSettings); memset(searchSettings, 0, sizeof(PokedexSearchSettings)); - searchSettings->unk_00 = ov21_021D138C(param1); + searchSettings->exitFlag = ov21_021D138C(param1); searchSettings->unk_04 = ov21_021D13EC(param1); UnkStruct_ov21_021E68F4 *v1 = ov21_021D1410(param1, 0); searchSettings->unk_08 = v1->unk_00; @@ -285,7 +289,7 @@ static UnkStruct_ov21_021D4660 *ov21_021D874C(enum HeapId heapID, UnkStruct_ov21 GF_ASSERT(v0); memset(v0, 0, sizeof(UnkStruct_ov21_021D4660) * v1); - ov21_021D47F0(heapID, &v0[0], param1, (0x1 << 1)); + ov21_021D47F0(heapID, &v0[0], param1, (1 << 1)); return v0; } @@ -359,7 +363,7 @@ static int UpdateScreenState(UnkStruct_ov21_021E6A68 *param0, void *param1) if (searchSettings->screenChange == TRUE) { if (searchSettings->applyFilter == FALSE) { - *searchSettings->unk_00 |= (0x1 << 1); + *searchSettings->exitFlag |= EXITSEARCH; searchSettings->screenState = SS_EXIT; } else { searchSettings->screenState = SS_SEARCH; @@ -377,7 +381,7 @@ static int UpdateScreenState(UnkStruct_ov21_021E6A68 *param0, void *param1) searchSettings->screenState = SS_LOADING; searchSettings->screenTimer = 32; - Sound_PlayEffect(1535); + Sound_PlayEffect(SEQ_SE_DP_Z_SEARCH); } break; case 2: @@ -392,7 +396,7 @@ static int UpdateScreenState(UnkStruct_ov21_021E6A68 *param0, void *param1) dexExists = PokedexSort_Sort(searchSettings->unk_04, searchSettings->sortOrder, searchSettings->filterName, searchSettings->typeFilter1, searchSettings->typeFilter2, searchSettings->filterForm, PokedexStatus_IsNationalDex(searchSettings->unk_04), param0->heapID, TRUE); if (dexExists == TRUE) { - *searchSettings->unk_00 |= (0x1 << 1); + *searchSettings->exitFlag |= EXITSEARCH; PokedexSort_SetCurrentValues(searchSettings->unk_04, 0); searchSettings->unk_04->unk_1740 = 1; searchSettings->unk_08->unk_18 = 1; @@ -683,11 +687,9 @@ static void DescriptionMessage(UnkStruct_ov21_021D879C *param0, int filterMethod Strbuf *descriptionMessage = GetPokedexMessage(entryID, heapID); - { - u32 v3 = 24 + (208 - Font_CalcMaxLineWidth(FONT_SYSTEM, descriptionMessage, 0)) / 2; - u32 v4 = 8 + (32 - Strbuf_NumLines(descriptionMessage) * 16) / 2; - Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, descriptionMessage, v3, v4, TEXT_SPEED_INSTANT, TEXT_COLOR(2, 1, 0), NULL); - } + u32 xOffset = 24 + (208 - Font_CalcMaxLineWidth(FONT_SYSTEM, descriptionMessage, 0)) / 2; + u32 yOffset = 8 + (32 - Strbuf_NumLines(descriptionMessage) * 16) / 2; + Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, descriptionMessage, xOffset, yOffset, TEXT_SPEED_INSTANT, TEXT_COLOR(2, 1, 0), NULL); Strbuf_Free(descriptionMessage); } @@ -808,10 +810,8 @@ static void SortOrderMessage(UnkStruct_ov21_021D879C *param0, int sortOrder, enu int entryID = pl_msg_pokedex_numerical + sortOrder; Strbuf *sortMessage = GetPokedexMessage(entryID, heapID); - { - u32 v3 = 88 + Font_CalcCenterAlignment(FONT_SYSTEM, sortMessage, 0, 80); - Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, sortMessage, v3, 52, TEXT_SPEED_INSTANT, TEXT_COLOR(4, 3, 0), NULL); - } + u32 xOffset = 88 + Font_CalcCenterAlignment(FONT_SYSTEM, sortMessage, 0, 80); + Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, sortMessage, xOffset, 52, TEXT_SPEED_INSTANT, TEXT_COLOR(4, 3, 0), NULL); Strbuf_Free(sortMessage); } @@ -859,8 +859,8 @@ static void FilterNameMessage(UnkStruct_ov21_021D879C *param0, int filterName, e Strbuf *filterMessage = GetPokedexMessage(entryID, heapID); { - u32 v4 = 88 + Font_CalcCenterAlignment(FONT_SYSTEM, filterMessage, 0, 80); - Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, filterMessage, v4, 77, TEXT_SPEED_INSTANT, TEXT_COLOR(4, 3, 0), NULL); + u32 xOffset = 88 + Font_CalcCenterAlignment(FONT_SYSTEM, filterMessage, 0, 80); + Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, filterMessage, xOffset, 77, TEXT_SPEED_INSTANT, TEXT_COLOR(4, 3, 0), NULL); } Strbuf_Free(filterMessage); @@ -933,8 +933,8 @@ static void FilterTypeMessage(UnkStruct_ov21_021D879C *param0, int typeFilter, e Strbuf *filterMessage = GetPokedexMessage(entryID, heapID); { - u32 v4 = 88 + Font_CalcCenterAlignment(FONT_SYSTEM, filterMessage, 0, 80); - Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, filterMessage, v4, y, TEXT_SPEED_INSTANT, TEXT_COLOR(4, 3, 0), NULL); + u32 x = 88 + Font_CalcCenterAlignment(FONT_SYSTEM, filterMessage, 0, 80); + Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, filterMessage, x, y, TEXT_SPEED_INSTANT, TEXT_COLOR(4, 3, 0), NULL); } Strbuf_Free(filterMessage); @@ -1047,11 +1047,9 @@ static void SearchingMessage(UnkStruct_ov21_021D879C *param0, enum HeapId heapID Strbuf *searchingMessage = GetPokedexMessage(pl_msg_pokedex_searching, heapID); - { - u32 xOffset = (256 - Font_CalcMaxLineWidth(FONT_SYSTEM, searchingMessage, 0)) / 2; + u32 xOffset = (256 - Font_CalcMaxLineWidth(FONT_SYSTEM, searchingMessage, 0)) / 2; - Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, searchingMessage, xOffset, 128, TEXT_SPEED_INSTANT, TEXT_COLOR(2, 1, 0), NULL); - } + Text_AddPrinterWithParamsAndColor(&v0->unk_04, FONT_SYSTEM, searchingMessage, xOffset, 128, TEXT_SPEED_INSTANT, TEXT_COLOR(2, 1, 0), NULL); Strbuf_Free(searchingMessage); Bg_SetPriority(1, 0);