From 43e942c3af39bf230e37dde9b406e99b12800f63 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 9 Nov 2021 12:50:35 -0500 Subject: [PATCH 01/19] Clean up pokenav ribbons --- include/pokenav.h | 8 +- ld_script.txt | 8 +- src/pokenav.c | 8 +- ...nav_ribbons_1.c => pokenav_ribbons_list.c} | 260 +++++----- ..._ribbons_2.c => pokenav_ribbons_summary.c} | 452 +++++++++--------- sym_bss.txt | 2 +- 6 files changed, 369 insertions(+), 369 deletions(-) rename src/{pokenav_ribbons_1.c => pokenav_ribbons_list.c} (66%) rename src/{pokenav_ribbons_2.c => pokenav_ribbons_summary.c} (67%) diff --git a/include/pokenav.h b/include/pokenav.h index 3fc01ede3..b1c73056d 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -459,18 +459,18 @@ void CreateSearchResultsLoopedTask(s32); u32 IsSearchResultLoopedTaskActive(void); void FreeSearchResultSubstruct2(void); -// pokenav_ribbons_1.c +// pokenav_ribbons_list.c u32 PokenavCallback_Init_MonRibbonList(void); u32 PokenavCallback_Init_RibbonsMonListFromSummary(void); u32 GetRibbonsMonListCallback(void); -void FreeRibbonsMonList1(void); +void FreeRibbonsMonList(void); bool32 OpenRibbonsMonList(void); bool32 OpenRibbonsMonListFromRibbonsSummary(void); void CreateRibbonsMonListLoopedTask(s32); u32 IsRibbonsMonListLoopedTaskActive(void); -void FreeRibbonsMonList2(void); +void FreeRibbonsMonMenu(void); -// pokenav_ribbons_2.c +// pokenav_ribbons_summary.c u32 PokenavCallback_Init_RibbonsSummaryMenu(void); u32 GetRibbonsSummaryMenuCallback(void); void FreeRibbonsSummaryScreen1(void); diff --git a/ld_script.txt b/ld_script.txt index e310bf717..ca0480e0f 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -319,8 +319,8 @@ SECTIONS { src/pokenav_conditions_1.o(.text); src/pokenav_conditions_2.o(.text); src/pokenav_conditions_3.o(.text); - src/pokenav_ribbons_1.o(.text); - src/pokenav_ribbons_2.o(.text); + src/pokenav_ribbons_list.o(.text); + src/pokenav_ribbons_summary.o(.text); src/pokenav_match_call_data.o(.text); src/menu_specialized.o(.text); src/ereader_helpers.o(.text); @@ -673,8 +673,8 @@ SECTIONS { src/pokenav_region_map.o(.rodata); src/pokenav_conditions_2.o(.rodata); src/pokenav_conditions_3.o(.rodata); - src/pokenav_ribbons_1.o(.rodata); - src/pokenav_ribbons_2.o(.rodata); + src/pokenav_ribbons_list.o(.rodata); + src/pokenav_ribbons_summary.o(.rodata); src/pokenav_match_call_data.o(.rodata); src/menu_specialized.o(.rodata); src/ereader_helpers.o(.rodata); diff --git a/src/pokenav.c b/src/pokenav.c index d30c523f9..4338023db 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -179,8 +179,8 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] = .open = OpenRibbonsMonList, .createLoopTask = CreateRibbonsMonListLoopedTask, .isLoopTaskActive = IsRibbonsMonListLoopedTaskActive, - .free1 = FreeRibbonsMonList1, - .free2 = FreeRibbonsMonList2, + .free1 = FreeRibbonsMonList, + .free2 = FreeRibbonsMonMenu, }, [POKENAV_RIBBONS_SUMMARY_SCREEN - POKENAV_MENU_IDS_START] = { @@ -199,8 +199,8 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] = .open = OpenRibbonsMonListFromRibbonsSummary, .createLoopTask = CreateRibbonsMonListLoopedTask, .isLoopTaskActive = IsRibbonsMonListLoopedTaskActive, - .free1 = FreeRibbonsMonList1, - .free2 = FreeRibbonsMonList2, + .free1 = FreeRibbonsMonList, + .free2 = FreeRibbonsMonMenu, }, }; diff --git a/src/pokenav_ribbons_1.c b/src/pokenav_ribbons_list.c similarity index 66% rename from src/pokenav_ribbons_1.c rename to src/pokenav_ribbons_list.c index 862128967..b5d412e12 100644 --- a/src/pokenav_ribbons_1.c +++ b/src/pokenav_ribbons_list.c @@ -20,9 +20,9 @@ enum }; -struct PokenavSub9 +struct Pokenav_RibbonsMonList { - u32 (*callback)(struct PokenavSub9*); + u32 (*callback)(struct Pokenav_RibbonsMonList*); u32 loopedTaskId; u16 winid; s32 boxId; @@ -32,35 +32,35 @@ struct PokenavSub9 struct PokenavSub18 *monList; }; -struct PokenavSub10 +struct Pokenav_RibbonsMonMenu { bool32 (*callback)(void); - u32 ltid; + u32 loopedTaskId; u16 winid; bool32 fromSummary; u8 buff[BG_SCREEN_SIZE]; }; -static u32 HandleRibbonsMonListInput_WaitListInit(struct PokenavSub9 *structPtr); -static u32 HandleRibbonsMonListInput(struct PokenavSub9 *structPtr); -static u32 RibbonsMonMenu_ReturnToMainMenu(struct PokenavSub9 *structPtr); -static u32 RibbonsMonMenu_ToSummaryScreen(struct PokenavSub9 *structPtr); -static u32 BuildPartyMonRibbonList(s32 state); -static u32 InitBoxMonRibbonList(s32 state); -static u32 BuildBoxMonRibbonList(s32 state); -static u32 GetMonRibbonListLoopTaskFunc(s32 state); -static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item); -static u32 LoopedTask_OpenRibbonsMonList(s32 state); +static u32 HandleRibbonsMonListInput_WaitListInit(struct Pokenav_RibbonsMonList *); +static u32 HandleRibbonsMonListInput(struct Pokenav_RibbonsMonList *); +static u32 RibbonsMonMenu_ReturnToMainMenu(struct Pokenav_RibbonsMonList *); +static u32 RibbonsMonMenu_ToSummaryScreen(struct Pokenav_RibbonsMonList *); +static u32 BuildPartyMonRibbonList(s32); +static u32 InitBoxMonRibbonList(s32); +static u32 BuildBoxMonRibbonList(s32); +static u32 GetMonRibbonListLoopTaskFunc(s32); +static void InsertMonListItem(struct Pokenav_RibbonsMonList *, struct PokenavMonList *); +static u32 LoopedTask_OpenRibbonsMonList(s32); static bool32 GetRibbonsMonCurrentLoopedTaskActive(void); -static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state); -static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state); -static u32 LoopedTask_RibbonsListMovePageUp(s32 state); -static u32 LoopedTask_RibbonsListMovePageDown(s32 state); -static u32 LoopedTask_RibbonsListReturnToMainMenu(s32 state); -static u32 LoopedTask_RibbonsListOpenSummary(s32 state); -static void sub_81D02B0(s32 windowId, s32 val1, s32 val2); -static void AddRibbonsMonListWindow(struct PokenavSub10 *ptr); -static void sub_81D0288(struct PokenavSub10 *ptr); +static u32 LoopedTask_RibbonsListMoveCursorUp(s32); +static u32 LoopedTask_RibbonsListMoveCursorDown(s32); +static u32 LoopedTask_RibbonsListMovePageUp(s32); +static u32 LoopedTask_RibbonsListMovePageDown(s32); +static u32 LoopedTask_RibbonsListReturnToMainMenu(s32); +static u32 LoopedTask_RibbonsListOpenSummary(s32); +static void DrawListIndexNumber(s32, s32, s32); +static void AddRibbonsMonListWindow(struct Pokenav_RibbonsMonMenu *); +static void UpdateIndexNumberDisplay(struct Pokenav_RibbonsMonMenu *); static void InitMonRibbonPokenavListMenuTemplate(void); static void BufferRibbonMonInfoText(struct PokenavMonList *, u8 *); @@ -125,54 +125,54 @@ static const u8 sText_NoGenderSymbol[] = _("{UNK_SPACER}"); bool32 PokenavCallback_Init_MonRibbonList(void) { - struct PokenavSub9 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, sizeof(struct PokenavSub9)); - if (structPtr == NULL) + struct Pokenav_RibbonsMonList *list = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, sizeof(struct Pokenav_RibbonsMonList)); + if (list == NULL) return FALSE; - structPtr->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18)); - if (structPtr->monList == NULL) + list->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18)); + if (list->monList == NULL) return FALSE; - structPtr->callback = HandleRibbonsMonListInput_WaitListInit; - structPtr->loopedTaskId = CreateLoopedTask(GetMonRibbonListLoopTaskFunc, 1); - structPtr->changeBgs = 0; + list->callback = HandleRibbonsMonListInput_WaitListInit; + list->loopedTaskId = CreateLoopedTask(GetMonRibbonListLoopTaskFunc, 1); + list->changeBgs = 0; return TRUE; } bool32 PokenavCallback_Init_RibbonsMonListFromSummary(void) { - struct PokenavSub9 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, sizeof(struct PokenavSub9)); - if (structPtr == NULL) + struct Pokenav_RibbonsMonList *list = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, sizeof(struct Pokenav_RibbonsMonList)); + if (list == NULL) return FALSE; - structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - structPtr->callback = HandleRibbonsMonListInput; - structPtr->changeBgs = 1; + list->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + list->callback = HandleRibbonsMonListInput; + list->changeBgs = 1; return TRUE; } u32 GetRibbonsMonListCallback(void) { - struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); - return structPtr->callback(structPtr); + struct Pokenav_RibbonsMonList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + return list->callback(list); } -void FreeRibbonsMonList1(void) +void FreeRibbonsMonList(void) { - struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); - if (!structPtr->saveMonList) + struct Pokenav_RibbonsMonList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + if (!list->saveMonList) FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST); FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); } -static u32 HandleRibbonsMonListInput_WaitListInit(struct PokenavSub9 *structPtr) +static u32 HandleRibbonsMonListInput_WaitListInit(struct Pokenav_RibbonsMonList *list) { - if (!IsLoopedTaskActive(structPtr->loopedTaskId)) - structPtr->callback = HandleRibbonsMonListInput; + if (!IsLoopedTaskActive(list->loopedTaskId)) + list->callback = HandleRibbonsMonListInput; return 0; } -static u32 HandleRibbonsMonListInput(struct PokenavSub9 *structPtr) +static u32 HandleRibbonsMonListInput(struct Pokenav_RibbonsMonList *list) { if (JOY_REPEAT(DPAD_UP)) return RIBBONS_MON_LIST_FUNC_MOVE_UP; @@ -184,60 +184,60 @@ static u32 HandleRibbonsMonListInput(struct PokenavSub9 *structPtr) return RIBBONS_MON_LIST_FUNC_PAGE_DOWN; if (JOY_NEW(B_BUTTON)) { - structPtr->saveMonList = 0; - structPtr->callback = RibbonsMonMenu_ReturnToMainMenu; + list->saveMonList = 0; + list->callback = RibbonsMonMenu_ReturnToMainMenu; return RIBBONS_MON_LIST_FUNC_EXIT; } if (JOY_NEW(A_BUTTON)) { - structPtr->monList->currIndex = GetSelectedPokenavListIndex(); - structPtr->saveMonList = 1; - structPtr->callback = RibbonsMonMenu_ToSummaryScreen; + list->monList->currIndex = GetSelectedPokenavListIndex(); + list->saveMonList = 1; + list->callback = RibbonsMonMenu_ToSummaryScreen; return RIBBONS_MON_LIST_FUNC_OPEN_RIBBONS_SUMMARY; } return RIBBONS_MON_LIST_FUNC_NONE; } -static u32 RibbonsMonMenu_ReturnToMainMenu(struct PokenavSub9 *structPtr) +static u32 RibbonsMonMenu_ReturnToMainMenu(struct Pokenav_RibbonsMonList *list) { return POKENAV_MAIN_MENU_CURSOR_ON_RIBBONS; } -static u32 RibbonsMonMenu_ToSummaryScreen(struct PokenavSub9 *structPtr) +static u32 RibbonsMonMenu_ToSummaryScreen(struct Pokenav_RibbonsMonList *list) { return POKENAV_RIBBONS_SUMMARY_SCREEN; } static u32 UpdateMonListBgs(void) { - struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); - return structPtr->changeBgs; + struct Pokenav_RibbonsMonList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + return list->changeBgs; } static struct PokenavMonList *GetMonRibbonMonListData(void) { - struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); - return ptr->monList->monData; + struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + return list->monList->monData; } static s32 GetRibbonsMonListCount(void) { - struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); - return ptr->monList->listCount; + struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + return list->monList->listCount; } //unused static s32 GetMonRibbonSelectedMonData(void) { - struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); s32 idx = GetSelectedPokenavListIndex(); - return ptr->monList->monData[idx].data; + return list->monList->monData[idx].data; } static s32 GetRibbonListMenuCurrIndex(void) { - struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); - return ptr->monList->currIndex; + struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + return list->monList->currIndex; } static u32 GetMonRibbonListLoopTaskFunc(s32 state) @@ -249,10 +249,10 @@ static u32 BuildPartyMonRibbonList(s32 state) { s32 i; struct PokenavMonList item; - struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); - ptr->monList->listCount = 0; - ptr->monList->currIndex = 0; + list->monList->listCount = 0; + list->monList->currIndex = 0; item.boxId = TOTAL_BOXES_COUNT; for (i = 0; i < PARTY_SIZE; i++) { @@ -266,7 +266,7 @@ static u32 BuildPartyMonRibbonList(s32 state) { item.monId = i; item.data = ribbonCount; - sub_81CFCEC(ptr, &item); + InsertMonListItem(list, &item); } } } @@ -276,17 +276,17 @@ static u32 BuildPartyMonRibbonList(s32 state) static u32 InitBoxMonRibbonList(s32 state) { - struct PokenavSub9 *ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); - ptr->monId = 0; - ptr->boxId = 0; + struct Pokenav_RibbonsMonList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + list->monId = 0; + list->boxId = 0; return LT_INC_AND_CONTINUE; } static u32 BuildBoxMonRibbonList(s32 state) { - struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); - s32 boxId = ptr->boxId; - s32 monId = ptr->monId; + struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + s32 boxId = list->boxId; + s32 monId = list->monId; s32 boxCount = 0; struct PokenavMonList item; @@ -302,15 +302,15 @@ static u32 BuildBoxMonRibbonList(s32 state) item.boxId = boxId; item.monId = monId; item.data = ribbonCount; - sub_81CFCEC(ptr, &item); + InsertMonListItem(list, &item); } } boxCount++; monId++; if (boxCount > TOTAL_BOXES_COUNT) { - ptr->boxId = boxId; - ptr->monId = monId; + list->boxId = boxId; + list->monId = monId; return LT_CONTINUE; } } @@ -318,28 +318,28 @@ static u32 BuildBoxMonRibbonList(s32 state) boxId++; } - ptr->changeBgs = 1; + list->changeBgs = 1; return LT_FINISH; } -static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item) +static void InsertMonListItem(struct Pokenav_RibbonsMonList *list, struct PokenavMonList *item) { u32 left = 0; - u32 right = structPtr->monList->listCount; + u32 right = list->monList->listCount; u32 insertionIdx = left + (right - left) / 2; while (right != insertionIdx) { - if (item->data > structPtr->monList->monData[insertionIdx].data) + if (item->data > list->monList->monData[insertionIdx].data) right = insertionIdx; else left = insertionIdx + 1; insertionIdx = left + (right - left) / 2; } - for (right = structPtr->monList->listCount; right > insertionIdx; right--) - structPtr->monList->monData[right] = structPtr->monList->monData[right - 1]; - structPtr->monList->monData[insertionIdx] = *item; - structPtr->monList->listCount++; + for (right = list->monList->listCount; right > insertionIdx; right--) + list->monList->monData[right] = list->monList->monData[right - 1]; + list->monList->monData[insertionIdx] = *item; + list->monList->listCount++; } // Unused @@ -374,62 +374,62 @@ static bool32 PlayerHasRibbonsMon(void) bool32 OpenRibbonsMonList(void) { - struct PokenavSub10 *ptr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct PokenavSub10)); - if (ptr == NULL) + struct Pokenav_RibbonsMonMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct Pokenav_RibbonsMonMenu)); + if (menu == NULL) return FALSE; - ptr->ltid = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1); - ptr->callback = GetRibbonsMonCurrentLoopedTaskActive; - ptr->fromSummary = FALSE; + menu->loopedTaskId = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1); + menu->callback = GetRibbonsMonCurrentLoopedTaskActive; + menu->fromSummary = FALSE; return TRUE; } bool32 OpenRibbonsMonListFromRibbonsSummary(void) { - struct PokenavSub10 *monMenu = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct PokenavSub10)); - if (monMenu == NULL) + struct Pokenav_RibbonsMonMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct Pokenav_RibbonsMonMenu)); + if (menu == NULL) return FALSE; - monMenu->ltid = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1); - monMenu->callback = GetRibbonsMonCurrentLoopedTaskActive; - monMenu->fromSummary = TRUE; + menu->loopedTaskId = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1); + menu->callback = GetRibbonsMonCurrentLoopedTaskActive; + menu->fromSummary = TRUE; return TRUE; } void CreateRibbonsMonListLoopedTask(s32 idx) { - struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); - monMenu->ltid = CreateLoopedTask(sRibbonsMonMenuLoopTaskFuncs[idx], 1); - monMenu->callback = GetRibbonsMonCurrentLoopedTaskActive; + struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); + menu->loopedTaskId = CreateLoopedTask(sRibbonsMonMenuLoopTaskFuncs[idx], 1); + menu->callback = GetRibbonsMonCurrentLoopedTaskActive; } bool32 IsRibbonsMonListLoopedTaskActive(void) { - struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); - return monMenu->callback(); + struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); + return menu->callback(); } bool32 GetRibbonsMonCurrentLoopedTaskActive(void) { - struct PokenavSub10 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); - return IsLoopedTaskActive(ptr->ltid); + struct Pokenav_RibbonsMonMenu * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); + return IsLoopedTaskActive(menu->loopedTaskId); } -void FreeRibbonsMonList2(void) +void FreeRibbonsMonMenu(void) { - struct PokenavSub10 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); + struct Pokenav_RibbonsMonMenu * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); sub_81C8234(); - RemoveWindow(ptr->winid); + RemoveWindow(menu->winid); FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); } static u32 LoopedTask_OpenRibbonsMonList(s32 state) { - struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); + struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); switch (state) { case 0: InitBgTemplates(sMonRibbonListBgTemplates, ARRAY_COUNT(sMonRibbonListBgTemplates)); DecompressAndCopyTileDataToVram(1, sMonRibbonListFrameTiles, 0, 0, 0); - SetBgTilemapBuffer(1, monMenu->buff); + SetBgTilemapBuffer(1, menu->buff); CopyToBgTilemapBuffer(1, sMonRibbonListFrameTilemap, 0, 0); CopyPaletteIntoBufferUnfaded(sMonRibbonListFramePal, 0x10, 0x20); CopyBgTilemapBufferToVram(1); @@ -452,7 +452,7 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state) case 3: if (sub_81C8224()) return LT_PAUSE; - AddRibbonsMonListWindow(monMenu); + AddRibbonsMonListWindow(menu); return LT_INC_AND_PAUSE; case 4: if (FreeTempTileDataBuffersIfPossible()) @@ -461,7 +461,7 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state) HideBg(3); PrintHelpBarText(HELPBAR_RIBBONS_MON_LIST); PokenavFadeScreen(1); - if (!monMenu->fromSummary) + if (!menu->fromSummary) { LoadLeftHeaderGfxForIndex(POKENAV_GFX_RIBBONS_MENU); ShowLeftHeaderGfx(POKENAV_GFX_RIBBONS_MENU, 1, 0); @@ -479,7 +479,7 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state) static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state) { - struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); + struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); switch (state) { case 0: @@ -500,7 +500,7 @@ static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state) return LT_PAUSE; // fallthrough case 2: - sub_81D0288(monMenu); + UpdateIndexNumberDisplay(menu); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -512,7 +512,7 @@ static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state) static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state) { - struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); + struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); switch (state) { case 0: @@ -533,7 +533,7 @@ static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state) return LT_PAUSE; // fallthrough case 2: - sub_81D0288(monMenu); + UpdateIndexNumberDisplay(menu); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -545,7 +545,7 @@ static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state) static u32 LoopedTask_RibbonsListMovePageUp(s32 state) { - struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); + struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); switch (state) { case 0: @@ -566,7 +566,7 @@ static u32 LoopedTask_RibbonsListMovePageUp(s32 state) return LT_PAUSE; // fallthrough case 2: - sub_81D0288(monMenu); + UpdateIndexNumberDisplay(menu); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -578,7 +578,7 @@ static u32 LoopedTask_RibbonsListMovePageUp(s32 state) static u32 LoopedTask_RibbonsListMovePageDown(s32 state) { - struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); + struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); switch (state) { case 0: @@ -599,7 +599,7 @@ static u32 LoopedTask_RibbonsListMovePageDown(s32 state) return LT_PAUSE; // fallthrough case 2: - sub_81D0288(monMenu); + UpdateIndexNumberDisplay(menu); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -645,34 +645,34 @@ static u32 LoopedTask_RibbonsListOpenSummary(s32 state) return LT_FINISH; } -static void AddRibbonsMonListWindow(struct PokenavSub10 *monMenu) +static void AddRibbonsMonListWindow(struct Pokenav_RibbonsMonMenu *menu) { - s32 r2; - monMenu->winid = AddWindow(&sRibbonsMonListWindowTemplate); - PutWindowTilemap(monMenu->winid); - r2 = GetRibbonsMonListCount(); - sub_81D02B0(monMenu->winid, 0, r2); - CopyWindowToVram(monMenu->winid, COPYWIN_MAP); - sub_81D0288(monMenu); + s32 listCount; + menu->winid = AddWindow(&sRibbonsMonListWindowTemplate); + PutWindowTilemap(menu->winid); + listCount = GetRibbonsMonListCount(); + DrawListIndexNumber(menu->winid, 0, listCount); + CopyWindowToVram(menu->winid, COPYWIN_MAP); + UpdateIndexNumberDisplay(menu); } -static void sub_81D0288(struct PokenavSub10 *monMenu) +static void UpdateIndexNumberDisplay(struct Pokenav_RibbonsMonMenu *menu) { - s32 r4 = GetSelectedPokenavListIndex(); - s32 r2 = GetRibbonsMonListCount(); - sub_81D02B0(monMenu->winid, r4 + 1, r2); - CopyWindowToVram(monMenu->winid, COPYWIN_GFX); + s32 listIndex = GetSelectedPokenavListIndex(); + s32 listCount = GetRibbonsMonListCount(); + DrawListIndexNumber(menu->winid, listIndex + 1, listCount); + CopyWindowToVram(menu->winid, COPYWIN_GFX); } -static void sub_81D02B0(s32 windowId, s32 val1, s32 val2) +static void DrawListIndexNumber(s32 windowId, s32 index, s32 max) { u8 strbuf[16]; u32 x; u8 * ptr = strbuf; - ptr = ConvertIntToDecimalStringN(ptr, val1, STR_CONV_MODE_RIGHT_ALIGN, 3); + ptr = ConvertIntToDecimalStringN(ptr, index, STR_CONV_MODE_RIGHT_ALIGN, 3); *ptr++ = CHAR_SLASH; - ConvertIntToDecimalStringN(ptr, val2, STR_CONV_MODE_RIGHT_ALIGN, 3); + ConvertIntToDecimalStringN(ptr, max, STR_CONV_MODE_RIGHT_ALIGN, 3); x = GetStringCenterAlignXOffset(FONT_NORMAL, strbuf, 56); AddTextPrinterParameterized(windowId, FONT_NORMAL, strbuf, x, 1, TEXT_SKIP_DRAW, NULL); } diff --git a/src/pokenav_ribbons_2.c b/src/pokenav_ribbons_summary.c similarity index 67% rename from src/pokenav_ribbons_2.c rename to src/pokenav_ribbons_summary.c index ef08ba392..a7a27ee31 100644 --- a/src/pokenav_ribbons_2.c +++ b/src/pokenav_ribbons_summary.c @@ -39,7 +39,7 @@ enum #define MON_SPRITE_X_OFF -32 #define MON_SPRITE_Y 104 -struct PokenavSub13 +struct Pokenav_RibbonsSummaryList { u8 unused1[8]; struct PokenavSub18 *monList; @@ -50,10 +50,10 @@ struct PokenavSub13 u32 ribbonIds[FIRST_GIFT_RIBBON]; u32 giftRibbonIds[NUM_GIFT_RIBBONS]; u32 unused2; - u32 (*callback)(struct PokenavSub13 *); + u32 (*callback)(struct Pokenav_RibbonsSummaryList *); }; -struct PokenavSub14 +struct Pokenav_RibbonsSummaryMenu { u32 (*callback)(void); u32 loopedTaskId; @@ -71,31 +71,31 @@ struct PokenavSub14 static u32 sRibbonDraw_Total; static u32 sRibbonDraw_Current; -static void PrintCurrentMonRibbonCount(struct PokenavSub14 *); -static void PrintRibbbonsSummaryMonInfo(struct PokenavSub14 *); -static void PrintRibbonsMonListIndex(struct PokenavSub14 *); -static void ZoomOutSelectedRibbon(struct PokenavSub14 *); -static void UpdateAndZoomInSelectedRibbon(struct PokenavSub14 *); -static void PrintRibbonNameAndDescription(struct PokenavSub14 *); -static void ResetSpritesAndDrawMonFrontPic(struct PokenavSub14 *); -static void AddRibbonListIndexWindow(struct PokenavSub14 *); -static void DestroyRibbonsMonFrontPic(struct PokenavSub14 *); -static void SlideMonSpriteOff(struct PokenavSub14 *); -static void SlideMonSpriteOn(struct PokenavSub14 *); -static void AddRibbonCountWindow(struct PokenavSub14 *); -static void CreateBigRibbonSprite(struct PokenavSub14 *); -static void AddRibbonSummaryMonNameWindow(struct PokenavSub14 *); -static void DrawAllRibbonsSmall(struct PokenavSub14 *); -static bool32 IsRibbonAnimating(struct PokenavSub14 *); -static bool32 IsMonSpriteAnimating(struct PokenavSub14 *); -static void GetMonRibbons(struct PokenavSub13 *); -static u32 HandleExpandedRibbonInput(struct PokenavSub13 *); -static u32 RibbonsSummaryHandleInput(struct PokenavSub13 *); -static u32 ReturnToRibbonsListFromSummary(struct PokenavSub13 *); -static bool32 TrySelectRibbonUp(struct PokenavSub13 *); -static bool32 TrySelectRibbonRight(struct PokenavSub13 *); -static bool32 TrySelectRibbonLeft(struct PokenavSub13 *); -static bool32 TrySelectRibbonDown(struct PokenavSub13 *); +static void PrintCurrentMonRibbonCount(struct Pokenav_RibbonsSummaryMenu *); +static void PrintRibbbonsSummaryMonInfo(struct Pokenav_RibbonsSummaryMenu *); +static void PrintRibbonsMonListIndex(struct Pokenav_RibbonsSummaryMenu *); +static void ZoomOutSelectedRibbon(struct Pokenav_RibbonsSummaryMenu *); +static void UpdateAndZoomInSelectedRibbon(struct Pokenav_RibbonsSummaryMenu *); +static void PrintRibbonNameAndDescription(struct Pokenav_RibbonsSummaryMenu *); +static void ResetSpritesAndDrawMonFrontPic(struct Pokenav_RibbonsSummaryMenu *); +static void AddRibbonListIndexWindow(struct Pokenav_RibbonsSummaryMenu *); +static void DestroyRibbonsMonFrontPic(struct Pokenav_RibbonsSummaryMenu *); +static void SlideMonSpriteOff(struct Pokenav_RibbonsSummaryMenu *); +static void SlideMonSpriteOn(struct Pokenav_RibbonsSummaryMenu *); +static void AddRibbonCountWindow(struct Pokenav_RibbonsSummaryMenu *); +static void CreateBigRibbonSprite(struct Pokenav_RibbonsSummaryMenu *); +static void AddRibbonSummaryMonNameWindow(struct Pokenav_RibbonsSummaryMenu *); +static void DrawAllRibbonsSmall(struct Pokenav_RibbonsSummaryMenu *); +static bool32 IsRibbonAnimating(struct Pokenav_RibbonsSummaryMenu *); +static bool32 IsMonSpriteAnimating(struct Pokenav_RibbonsSummaryMenu *); +static void GetMonRibbons(struct Pokenav_RibbonsSummaryList *); +static u32 HandleExpandedRibbonInput(struct Pokenav_RibbonsSummaryList *); +static u32 RibbonsSummaryHandleInput(struct Pokenav_RibbonsSummaryList *); +static u32 ReturnToRibbonsListFromSummary(struct Pokenav_RibbonsSummaryList *); +static bool32 TrySelectRibbonUp(struct Pokenav_RibbonsSummaryList *); +static bool32 TrySelectRibbonRight(struct Pokenav_RibbonsSummaryList *); +static bool32 TrySelectRibbonLeft(struct Pokenav_RibbonsSummaryList *); +static bool32 TrySelectRibbonDown(struct Pokenav_RibbonsSummaryList *); static bool32 GetCurrentLoopedTaskActive(void); static u32 GetRibbonsSummaryCurrentIndex(void); static u32 GetRibbonsSummaryMonListCount(void); @@ -186,16 +186,16 @@ static const LoopedTask sRibbonsSummaryMenuLoopTaskFuncs[] = bool32 PokenavCallback_Init_RibbonsSummaryMenu(void) { - struct PokenavSub13 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST, sizeof(struct PokenavSub13)); - if (structPtr == NULL) + struct Pokenav_RibbonsSummaryList *list = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST, sizeof(struct Pokenav_RibbonsSummaryList)); + if (list == NULL) return FALSE; - structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - if (structPtr->monList == NULL) + list->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + if (list->monList == NULL) return FALSE; - GetMonRibbons(structPtr); - structPtr->callback = RibbonsSummaryHandleInput; + GetMonRibbons(list); + list->callback = RibbonsSummaryHandleInput; gKeyRepeatContinueDelay = 3; gKeyRepeatStartDelay = 10; return TRUE; @@ -203,8 +203,8 @@ bool32 PokenavCallback_Init_RibbonsSummaryMenu(void) u32 GetRibbonsSummaryMenuCallback(void) { - struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); - return structPtr->callback(structPtr); + struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + return list->callback(list); } void FreeRibbonsSummaryScreen1(void) @@ -213,150 +213,150 @@ void FreeRibbonsSummaryScreen1(void) } // Handles input when a specific ribbon is not currently selected -static u32 RibbonsSummaryHandleInput(struct PokenavSub13 *structPtr) +static u32 RibbonsSummaryHandleInput(struct Pokenav_RibbonsSummaryList *list) { // Handle Up/Down movement to select a new Pokémon to show ribbons for - if (JOY_REPEAT(DPAD_UP) && structPtr->monList->currIndex != 0) + if (JOY_REPEAT(DPAD_UP) && list->monList->currIndex != 0) { - structPtr->monList->currIndex--; - structPtr->selectedPos = 0; - GetMonRibbons(structPtr); + list->monList->currIndex--; + list->selectedPos = 0; + GetMonRibbons(list); return RIBBONS_SUMMARY_FUNC_SWITCH_MONS; } - if (JOY_REPEAT(DPAD_DOWN) && structPtr->monList->currIndex < structPtr->monList->listCount - 1) + if (JOY_REPEAT(DPAD_DOWN) && list->monList->currIndex < list->monList->listCount - 1) { - structPtr->monList->currIndex++; - structPtr->selectedPos = 0; - GetMonRibbons(structPtr); + list->monList->currIndex++; + list->selectedPos = 0; + GetMonRibbons(list); return RIBBONS_SUMMARY_FUNC_SWITCH_MONS; } if (JOY_NEW(A_BUTTON)) { // Enter ribbon selection - structPtr->callback = HandleExpandedRibbonInput; + list->callback = HandleExpandedRibbonInput; return RIBBONS_SUMMARY_FUNC_SELECT_RIBBON; } if (JOY_NEW(B_BUTTON)) { // Exit ribbon summary menu - structPtr->callback = ReturnToRibbonsListFromSummary; + list->callback = ReturnToRibbonsListFromSummary; return RIBBONS_SUMMARY_FUNC_EXIT; } return RIBBONS_SUMMARY_FUNC_NONE; } // Handles input when a ribbon is selected -static u32 HandleExpandedRibbonInput(struct PokenavSub13 *structPtr) +static u32 HandleExpandedRibbonInput(struct Pokenav_RibbonsSummaryList *list) { // Handle movement while a ribbon is selected - if (JOY_REPEAT(DPAD_UP) && TrySelectRibbonUp(structPtr)) + if (JOY_REPEAT(DPAD_UP) && TrySelectRibbonUp(list)) return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE; - if (JOY_REPEAT(DPAD_DOWN) && TrySelectRibbonDown(structPtr)) + if (JOY_REPEAT(DPAD_DOWN) && TrySelectRibbonDown(list)) return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE; - if (JOY_REPEAT(DPAD_LEFT) && TrySelectRibbonLeft(structPtr)) + if (JOY_REPEAT(DPAD_LEFT) && TrySelectRibbonLeft(list)) return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE; - if (JOY_REPEAT(DPAD_RIGHT) && TrySelectRibbonRight(structPtr)) + if (JOY_REPEAT(DPAD_RIGHT) && TrySelectRibbonRight(list)) return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE; if (JOY_NEW(B_BUTTON)) { // Exit ribbon selection - structPtr->callback = RibbonsSummaryHandleInput; + list->callback = RibbonsSummaryHandleInput; return RIBBONS_SUMMARY_FUNC_EXPANDED_CANCEL; } return RIBBONS_SUMMARY_FUNC_NONE; } -static u32 ReturnToRibbonsListFromSummary(struct PokenavSub13 *structPtr) +static u32 ReturnToRibbonsListFromSummary(struct Pokenav_RibbonsSummaryList *list) { return POKENAV_RIBBONS_RETURN_TO_MON_LIST; } -static bool32 TrySelectRibbonUp(struct PokenavSub13 *structPtr) +static bool32 TrySelectRibbonUp(struct Pokenav_RibbonsSummaryList *list) { - if (structPtr->selectedPos < FIRST_GIFT_RIBBON) + if (list->selectedPos < FIRST_GIFT_RIBBON) { // In normal ribbons, try to move up a row - if (structPtr->selectedPos < RIBBONS_PER_ROW) + if (list->selectedPos < RIBBONS_PER_ROW) return FALSE; - structPtr->selectedPos -= RIBBONS_PER_ROW; + list->selectedPos -= RIBBONS_PER_ROW; return TRUE; } - if (structPtr->numNormalRibbons != 0) + if (list->numNormalRibbons != 0) { // In gift ribbons, try to move up into normal ribbons // If there's > 1 row of gift ribbons (not normally possible) // it's impossible to move up between them - u32 ribbonPos = structPtr->selectedPos - GIFT_RIBBON_START_POS; - structPtr->selectedPos = ribbonPos + structPtr->normalRibbonLastRowStart; - if (structPtr->selectedPos >= structPtr->numNormalRibbons) - structPtr->selectedPos = structPtr->numNormalRibbons - 1; + u32 ribbonPos = list->selectedPos - GIFT_RIBBON_START_POS; + list->selectedPos = ribbonPos + list->normalRibbonLastRowStart; + if (list->selectedPos >= list->numNormalRibbons) + list->selectedPos = list->numNormalRibbons - 1; return TRUE; } return FALSE; } -static bool32 TrySelectRibbonDown(struct PokenavSub13 *structPtr) +static bool32 TrySelectRibbonDown(struct Pokenav_RibbonsSummaryList *list) { - if (structPtr->selectedPos >= FIRST_GIFT_RIBBON) + if (list->selectedPos >= FIRST_GIFT_RIBBON) return FALSE; - if (structPtr->selectedPos < structPtr->normalRibbonLastRowStart) + if (list->selectedPos < list->normalRibbonLastRowStart) { // Not in last row of normal ribbons, advance to next row - structPtr->selectedPos += RIBBONS_PER_ROW; - if (structPtr->selectedPos >= structPtr->numNormalRibbons) - structPtr->selectedPos = structPtr->numNormalRibbons - 1; + list->selectedPos += RIBBONS_PER_ROW; + if (list->selectedPos >= list->numNormalRibbons) + list->selectedPos = list->numNormalRibbons - 1; return TRUE; } - if (structPtr->numGiftRibbons != 0) + if (list->numGiftRibbons != 0) { // In/beyond last of row of normal ribbons and gift ribbons present, move down to gift ribbon row - int ribbonPos = structPtr->selectedPos - structPtr->normalRibbonLastRowStart; - if (ribbonPos >= structPtr->numGiftRibbons) - ribbonPos = structPtr->numGiftRibbons - 1; + int ribbonPos = list->selectedPos - list->normalRibbonLastRowStart; + if (ribbonPos >= list->numGiftRibbons) + ribbonPos = list->numGiftRibbons - 1; - structPtr->selectedPos = ribbonPos + GIFT_RIBBON_START_POS; + list->selectedPos = ribbonPos + GIFT_RIBBON_START_POS; return TRUE; } return FALSE; } -static bool32 TrySelectRibbonLeft(struct PokenavSub13 *structPtr) +static bool32 TrySelectRibbonLeft(struct Pokenav_RibbonsSummaryList *list) { - u16 column = structPtr->selectedPos % RIBBONS_PER_ROW; + u16 column = list->selectedPos % RIBBONS_PER_ROW; if (column != 0) { - structPtr->selectedPos--; + list->selectedPos--; return TRUE; } return FALSE; } -static bool32 TrySelectRibbonRight(struct PokenavSub13 *structPtr) +static bool32 TrySelectRibbonRight(struct Pokenav_RibbonsSummaryList *list) { - int column = structPtr->selectedPos % RIBBONS_PER_ROW; + int column = list->selectedPos % RIBBONS_PER_ROW; if (column >= RIBBONS_PER_ROW - 1) return FALSE; - if (structPtr->selectedPos < GIFT_RIBBON_START_POS) + if (list->selectedPos < GIFT_RIBBON_START_POS) { // Move right in normal ribbon row - if (structPtr->selectedPos < structPtr->numNormalRibbons - 1) + if (list->selectedPos < list->numNormalRibbons - 1) { - structPtr->selectedPos++; + list->selectedPos++; return TRUE; } } else { // Move right in gift ribbon row - if (column < structPtr->numGiftRibbons - 1) + if (column < list->numGiftRibbons - 1) { - structPtr->selectedPos++; + list->selectedPos++; return TRUE; } } @@ -365,20 +365,20 @@ static bool32 TrySelectRibbonRight(struct PokenavSub13 *structPtr) static u32 GetRibbonsSummaryCurrentIndex(void) { - struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); - return structPtr->monList->currIndex; + struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + return list->monList->currIndex; } static u32 GetRibbonsSummaryMonListCount(void) { - struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); - return structPtr->monList->listCount; + struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + return list->monList->listCount; } static void GetMonNicknameLevelGender(u8 *nick, u8 *level, u8 *gender) { - struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); - struct PokenavSub18 *mons = structPtr->monList; + struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + struct PokenavSub18 *mons = list->monList; struct PokenavMonList *monInfo = &mons->monData[mons->currIndex]; if (monInfo->boxId == TOTAL_BOXES_COUNT) @@ -402,8 +402,8 @@ static void GetMonNicknameLevelGender(u8 *nick, u8 *level, u8 *gender) static void GetMonSpeciesPersonalityOtId(u16 *species, u32 *personality, u32 *otId) { - struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); - struct PokenavSub18 *mons = structPtr->monList; + struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + struct PokenavSub18 *mons = list->monList; struct PokenavMonList *monInfo = &mons->monData[mons->currIndex]; if (monInfo->boxId == TOTAL_BOXES_COUNT) @@ -426,8 +426,8 @@ static void GetMonSpeciesPersonalityOtId(u16 *species, u32 *personality, u32 *ot static u32 GetCurrMonRibbonCount(void) { - struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); - struct PokenavSub18 *mons = structPtr->monList; + struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + struct PokenavSub18 *mons = list->monList; struct PokenavMonList *monInfo = &mons->monData[mons->currIndex]; if (monInfo->boxId == TOTAL_BOXES_COUNT) @@ -436,11 +436,11 @@ static u32 GetCurrMonRibbonCount(void) return GetBoxMonDataAt(monInfo->boxId, monInfo->monId, MON_DATA_RIBBON_COUNT); } -static void GetMonRibbons(struct PokenavSub13 *structPtr) +static void GetMonRibbons(struct Pokenav_RibbonsSummaryList *list) { u32 ribbonFlags; s32 i, j; - struct PokenavSub18 *mons = structPtr->monList; + struct PokenavSub18 *mons = list->monList; struct PokenavMonList *monInfo = &mons->monData[mons->currIndex]; if (monInfo->boxId == TOTAL_BOXES_COUNT) @@ -448,8 +448,8 @@ static void GetMonRibbons(struct PokenavSub13 *structPtr) else ribbonFlags = GetBoxMonDataAt(monInfo->boxId, monInfo->monId, MON_DATA_RIBBONS); - structPtr->numNormalRibbons = 0; - structPtr->numGiftRibbons = 0; + list->numNormalRibbons = 0; + list->numGiftRibbons = 0; for (i = 0; i < ARRAY_COUNT(sRibbonData); i++) { // For all non-contest ribbons, numRibbons will be 1 if they have it, 0 if they don't @@ -458,119 +458,119 @@ static void GetMonRibbons(struct PokenavSub13 *structPtr) if (!sRibbonData[i].isGiftRibbon) { for (j = 0; j < numRibbons; j++) - structPtr->ribbonIds[structPtr->numNormalRibbons++] = sRibbonData[i].ribbonId + j; + list->ribbonIds[list->numNormalRibbons++] = sRibbonData[i].ribbonId + j; } else { for (j = 0; j < numRibbons; j++) - structPtr->giftRibbonIds[structPtr->numGiftRibbons++] = sRibbonData[i].ribbonId + j; + list->giftRibbonIds[list->numGiftRibbons++] = sRibbonData[i].ribbonId + j; } ribbonFlags >>= sRibbonData[i].numBits; } - if (structPtr->numNormalRibbons != 0) + if (list->numNormalRibbons != 0) { - structPtr->normalRibbonLastRowStart = ((structPtr->numNormalRibbons - 1) / RIBBONS_PER_ROW) * RIBBONS_PER_ROW; - structPtr->selectedPos = 0; + list->normalRibbonLastRowStart = ((list->numNormalRibbons - 1) / RIBBONS_PER_ROW) * RIBBONS_PER_ROW; + list->selectedPos = 0; } else { // There are no normal ribbons, move cursor to first gift ribbon - structPtr->normalRibbonLastRowStart = 0; - structPtr->selectedPos = GIFT_RIBBON_START_POS; + list->normalRibbonLastRowStart = 0; + list->selectedPos = GIFT_RIBBON_START_POS; } } static u32 *GetNormalRibbonIds(u32 *size) { - struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); - *size = structPtr->numNormalRibbons; - return structPtr->ribbonIds; + struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + *size = list->numNormalRibbons; + return list->ribbonIds; } static u32 *GetGiftRibbonIds(u32 *size) { - struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); - *size = structPtr->numGiftRibbons; - return structPtr->giftRibbonIds; + struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + *size = list->numGiftRibbons; + return list->giftRibbonIds; } static u16 GetSelectedPosition(void) { - struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); - return structPtr->selectedPos; + struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + return list->selectedPos; } static u32 GetRibbonId(void) { - struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); - int ribbonPos = structPtr->selectedPos; + struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + int ribbonPos = list->selectedPos; if (ribbonPos < FIRST_GIFT_RIBBON) - return structPtr->ribbonIds[ribbonPos]; + return list->ribbonIds[ribbonPos]; else - return structPtr->giftRibbonIds[ribbonPos - GIFT_RIBBON_START_POS]; + return list->giftRibbonIds[ribbonPos - GIFT_RIBBON_START_POS]; } bool32 OpenRibbonsSummaryMenu(void) { - struct PokenavSub14 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU, sizeof(struct PokenavSub14)); - if (structPtr == NULL) + struct Pokenav_RibbonsSummaryMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU, sizeof(struct Pokenav_RibbonsSummaryMenu)); + if (menu == NULL) return FALSE; - structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_OpenRibbonsSummaryMenu, 1); - structPtr->callback = GetCurrentLoopedTaskActive; + menu->loopedTaskId = CreateLoopedTask(LoopedTask_OpenRibbonsSummaryMenu, 1); + menu->callback = GetCurrentLoopedTaskActive; return TRUE; } void CreateRibbonsSummaryLoopedTask(s32 id) { - struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); - structPtr->loopedTaskId = CreateLoopedTask(sRibbonsSummaryMenuLoopTaskFuncs[id], 1); - structPtr->callback = GetCurrentLoopedTaskActive; + struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); + menu->loopedTaskId = CreateLoopedTask(sRibbonsSummaryMenuLoopTaskFuncs[id], 1); + menu->callback = GetCurrentLoopedTaskActive; } u32 IsRibbonsSummaryLoopedTaskActive(void) { - struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); - return structPtr->callback(); + struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); + return menu->callback(); } void FreeRibbonsSummaryScreen2(void) { - struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); - RemoveWindow(structPtr->ribbonCountWindowId); - RemoveWindow(structPtr->nameWindowId); - RemoveWindow(structPtr->listIdxWindowId); + struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); + RemoveWindow(menu->ribbonCountWindowId); + RemoveWindow(menu->nameWindowId); + RemoveWindow(menu->listIdxWindowId); #ifndef BUGFIX - RemoveWindow(structPtr->unusedWindowId); // Removing window, but window id is never set + RemoveWindow(menu->unusedWindowId); // Removing window, but window id is never set #endif - DestroyRibbonsMonFrontPic(structPtr); + DestroyRibbonsMonFrontPic(menu); FreeSpriteTilesByTag(GFXTAG_RIBBON_ICONS_BIG); FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_1); FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_2); FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_3); FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_4); FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_5); - FreeSpriteOamMatrix(structPtr->bigRibbonSprite); - DestroySprite(structPtr->bigRibbonSprite); + FreeSpriteOamMatrix(menu->bigRibbonSprite); + DestroySprite(menu->bigRibbonSprite); FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); } static bool32 GetCurrentLoopedTaskActive(void) { - struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); - return IsLoopedTaskActive(structPtr->loopedTaskId); + struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); + return IsLoopedTaskActive(menu->loopedTaskId); } static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state) { - struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); + struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); switch (state) { case 0: InitBgTemplates(sBgTemplates, ARRAY_COUNT(sBgTemplates)); DecompressAndCopyTileDataToVram(2, gPokenavRibbonsSummaryBg_Gfx, 0, 0, 0); - SetBgTilemapBuffer(2, structPtr->tilemapBuffers[0]); + SetBgTilemapBuffer(2, menu->tilemapBuffers[0]); CopyToBgTilemapBuffer(2, gPokenavRibbonsSummaryBg_Tilemap, 0, 0); CopyPaletteIntoBufferUnfaded(gPokenavRibbonsSummaryBg_Pal, 0x10, 0x20); CopyBgTilemapBufferToVram(2); @@ -580,7 +580,7 @@ static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state) { BgDmaFill(1, 0, 0, 1); DecompressAndCopyTileDataToVram(1, sRibbonIconsSmall_Gfx, 0, 1, 0); - SetBgTilemapBuffer(1, structPtr->tilemapBuffers[1]); + SetBgTilemapBuffer(1, menu->tilemapBuffers[1]); FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 32, 20); CopyPaletteIntoBufferUnfaded(sRibbonIcons1_Pal, 0x20, 0xA0); CopyPaletteIntoBufferUnfaded(sMonInfo_Pal, 0xA0, 0x20); @@ -591,21 +591,21 @@ static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state) case 2: if (!FreeTempTileDataBuffersIfPossible()) { - AddRibbonCountWindow(structPtr); + AddRibbonCountWindow(menu); return LT_INC_AND_PAUSE; } return LT_PAUSE; case 3: if (!FreeTempTileDataBuffersIfPossible()) { - AddRibbonSummaryMonNameWindow(structPtr); + AddRibbonSummaryMonNameWindow(menu); return LT_INC_AND_PAUSE; } return LT_PAUSE; case 4: if (!FreeTempTileDataBuffersIfPossible()) { - AddRibbonListIndexWindow(structPtr); + AddRibbonListIndexWindow(menu); return LT_INC_AND_PAUSE; } return LT_PAUSE; @@ -619,18 +619,18 @@ static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state) case 6: if (!IsDma3ManagerBusyWithBgCopy()) { - ResetSpritesAndDrawMonFrontPic(structPtr); + ResetSpritesAndDrawMonFrontPic(menu); return LT_INC_AND_CONTINUE; } return LT_PAUSE; case 7: - DrawAllRibbonsSmall(structPtr); + DrawAllRibbonsSmall(menu); PrintHelpBarText(HELPBAR_RIBBONS_LIST); return LT_INC_AND_PAUSE; case 8: if (!IsDma3ManagerBusyWithBgCopy()) { - CreateBigRibbonSprite(structPtr); + CreateBigRibbonSprite(menu); ChangeBgX(1, 0, BG_COORD_SET); ChangeBgY(1, 0, BG_COORD_SET); ChangeBgX(2, 0, BG_COORD_SET); @@ -667,38 +667,38 @@ static u32 LoopedTask_ExitRibbonsSummaryMenu(s32 state) static u32 LoopedTask_SwitchRibbonsSummaryMon(s32 state) { - struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); + struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); switch (state) { case 0: PlaySE(SE_SELECT); - SlideMonSpriteOff(structPtr); + SlideMonSpriteOff(menu); return LT_INC_AND_PAUSE; case 1: - if (!IsMonSpriteAnimating(structPtr)) + if (!IsMonSpriteAnimating(menu)) { - PrintRibbbonsSummaryMonInfo(structPtr); + PrintRibbbonsSummaryMonInfo(menu); return LT_INC_AND_CONTINUE; } return LT_PAUSE; case 2: - DrawAllRibbonsSmall(structPtr); + DrawAllRibbonsSmall(menu); return LT_INC_AND_CONTINUE; case 3: - PrintRibbonsMonListIndex(structPtr); + PrintRibbonsMonListIndex(menu); return LT_INC_AND_CONTINUE; case 4: - PrintCurrentMonRibbonCount(structPtr); + PrintCurrentMonRibbonCount(menu); return LT_INC_AND_CONTINUE; case 5: if (!IsDma3ManagerBusyWithBgCopy()) { - SlideMonSpriteOn(structPtr); + SlideMonSpriteOn(menu); return LT_INC_AND_PAUSE; } return LT_PAUSE; case 6: - if (IsMonSpriteAnimating(structPtr)) + if (IsMonSpriteAnimating(menu)) return LT_PAUSE; } return LT_FINISH; @@ -706,17 +706,17 @@ static u32 LoopedTask_SwitchRibbonsSummaryMon(s32 state) static u32 LoopedTask_ExpandSelectedRibbon(s32 state) { - struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); + struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); switch (state) { case 0: PlaySE(SE_SELECT); - UpdateAndZoomInSelectedRibbon(structPtr); + UpdateAndZoomInSelectedRibbon(menu); return LT_INC_AND_PAUSE; case 1: - if (!IsRibbonAnimating(structPtr)) + if (!IsRibbonAnimating(menu)) { - PrintRibbonNameAndDescription(structPtr); + PrintRibbonNameAndDescription(menu); PrintHelpBarText(HELPBAR_RIBBONS_CHECK); return LT_INC_AND_PAUSE; } @@ -730,24 +730,24 @@ static u32 LoopedTask_ExpandSelectedRibbon(s32 state) static u32 LoopedTask_MoveRibbonsCursorExpanded(s32 state) { - struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); + struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); switch (state) { case 0: PlaySE(SE_SELECT); - ZoomOutSelectedRibbon(structPtr); + ZoomOutSelectedRibbon(menu); return LT_INC_AND_PAUSE; case 1: - if (!IsRibbonAnimating(structPtr)) + if (!IsRibbonAnimating(menu)) { - UpdateAndZoomInSelectedRibbon(structPtr); + UpdateAndZoomInSelectedRibbon(menu); return LT_INC_AND_PAUSE; } return LT_PAUSE; case 2: - if (!IsRibbonAnimating(structPtr)) + if (!IsRibbonAnimating(menu)) { - PrintRibbonNameAndDescription(structPtr); + PrintRibbonNameAndDescription(menu); return LT_INC_AND_PAUSE; } return LT_PAUSE; @@ -760,17 +760,17 @@ static u32 LoopedTask_MoveRibbonsCursorExpanded(s32 state) static u32 LoopedTask_ShrinkExpandedRibbon(s32 state) { - struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); + struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); switch (state) { case 0: PlaySE(SE_SELECT); - ZoomOutSelectedRibbon(structPtr); + ZoomOutSelectedRibbon(menu); return LT_INC_AND_PAUSE; case 1: - if (!IsRibbonAnimating(structPtr)) + if (!IsRibbonAnimating(menu)) { - PrintCurrentMonRibbonCount(structPtr); + PrintCurrentMonRibbonCount(menu); PrintHelpBarText(HELPBAR_RIBBONS_LIST); return LT_INC_AND_PAUSE; } @@ -793,14 +793,14 @@ static const struct WindowTemplate sRibbonCountWindowTemplate = .baseBlock = 0x14, }; -static void AddRibbonCountWindow(struct PokenavSub14 *structPtr) +static void AddRibbonCountWindow(struct Pokenav_RibbonsSummaryMenu *menu) { - structPtr->ribbonCountWindowId = AddWindow(&sRibbonCountWindowTemplate); - PutWindowTilemap(structPtr->ribbonCountWindowId); - PrintCurrentMonRibbonCount(structPtr); + menu->ribbonCountWindowId = AddWindow(&sRibbonCountWindowTemplate); + PutWindowTilemap(menu->ribbonCountWindowId); + PrintCurrentMonRibbonCount(menu); } -static void PrintCurrentMonRibbonCount(struct PokenavSub14 *structPtr) +static void PrintCurrentMonRibbonCount(struct Pokenav_RibbonsSummaryMenu *menu) { u8 color[] = {TEXT_COLOR_RED, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY}; @@ -808,23 +808,23 @@ static void PrintCurrentMonRibbonCount(struct PokenavSub14 *structPtr) DynamicPlaceholderTextUtil_Reset(); DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1); DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_RibbonsF700); - FillWindowPixelBuffer(structPtr->ribbonCountWindowId, PIXEL_FILL(4)); - AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, FONT_NORMAL, 0, 1, color, TEXT_SKIP_DRAW, gStringVar4); - CopyWindowToVram(structPtr->ribbonCountWindowId, COPYWIN_GFX); + FillWindowPixelBuffer(menu->ribbonCountWindowId, PIXEL_FILL(4)); + AddTextPrinterParameterized3(menu->ribbonCountWindowId, FONT_NORMAL, 0, 1, color, TEXT_SKIP_DRAW, gStringVar4); + CopyWindowToVram(menu->ribbonCountWindowId, COPYWIN_GFX); } -static void PrintRibbonNameAndDescription(struct PokenavSub14 *structPtr) +static void PrintRibbonNameAndDescription(struct Pokenav_RibbonsSummaryMenu *menu) { s32 i; u32 ribbonId = GetRibbonId(); u8 color[] = {TEXT_COLOR_RED, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY}; - FillWindowPixelBuffer(structPtr->ribbonCountWindowId, PIXEL_FILL(4)); + FillWindowPixelBuffer(menu->ribbonCountWindowId, PIXEL_FILL(4)); if (ribbonId < FIRST_GIFT_RIBBON) { // Print normal ribbon name/description for (i = 0; i < 2; i++) - AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, FONT_NORMAL, 0, (i * 16) + 1, color, TEXT_SKIP_DRAW, gRibbonDescriptionPointers[ribbonId][i]); + AddTextPrinterParameterized3(menu->ribbonCountWindowId, FONT_NORMAL, 0, (i * 16) + 1, color, TEXT_SKIP_DRAW, gRibbonDescriptionPointers[ribbonId][i]); } else { @@ -840,10 +840,10 @@ static void PrintRibbonNameAndDescription(struct PokenavSub14 *structPtr) // Print gift ribbon name/description ribbonId--; for (i = 0; i < 2; i++) - AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, FONT_NORMAL, 0, (i * 16) + 1, color, TEXT_SKIP_DRAW, gGiftRibbonDescriptionPointers[ribbonId][i]); + AddTextPrinterParameterized3(menu->ribbonCountWindowId, FONT_NORMAL, 0, (i * 16) + 1, color, TEXT_SKIP_DRAW, gGiftRibbonDescriptionPointers[ribbonId][i]); } - CopyWindowToVram(structPtr->ribbonCountWindowId, COPYWIN_GFX); + CopyWindowToVram(menu->ribbonCountWindowId, COPYWIN_GFX); } static const struct WindowTemplate sRibbonSummaryMonNameWindowTemplate = @@ -857,23 +857,23 @@ static const struct WindowTemplate sRibbonSummaryMonNameWindowTemplate = .baseBlock = 0x54, }; -static void AddRibbonSummaryMonNameWindow(struct PokenavSub14 *structPtr) +static void AddRibbonSummaryMonNameWindow(struct Pokenav_RibbonsSummaryMenu *menu) { - structPtr->nameWindowId = AddWindow(&sRibbonSummaryMonNameWindowTemplate); - PutWindowTilemap(structPtr->nameWindowId); - PrintRibbbonsSummaryMonInfo(structPtr); + menu->nameWindowId = AddWindow(&sRibbonSummaryMonNameWindowTemplate); + PutWindowTilemap(menu->nameWindowId); + PrintRibbbonsSummaryMonInfo(menu); } static const u8 sMaleIconString[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_RED}{WHITE}{GREEN}♂{COLOR_HIGHLIGHT_SHADOW}{DARK_GRAY}{WHITE}{LIGHT_GRAY}"); static const u8 sFemaleIconString[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_GREEN}{WHITE}{BLUE}♀{COLOR_HIGHLIGHT_SHADOW}{DARK_GRAY}{WHITE}{LIGHT_GRAY}"); static const u8 sGenderlessIconString[] = _("{UNK_SPACER}"); -static void PrintRibbbonsSummaryMonInfo(struct PokenavSub14 *structPtr) +static void PrintRibbbonsSummaryMonInfo(struct Pokenav_RibbonsSummaryMenu *menu) { const u8 *genderTxt; u8 *txtPtr; u8 level, gender; - u16 windowId = structPtr->nameWindowId; + u16 windowId = menu->nameWindowId; FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); GetMonNicknameLevelGender(gStringVar3, &level, &gender); @@ -914,15 +914,15 @@ static const struct WindowTemplate sRibbonMonListIndexWindowTemplate[] = {}, }; -static void AddRibbonListIndexWindow(struct PokenavSub14 *structPtr) +static void AddRibbonListIndexWindow(struct Pokenav_RibbonsSummaryMenu *menu) { - structPtr->listIdxWindowId = AddWindow(sRibbonMonListIndexWindowTemplate); - FillWindowPixelBuffer(structPtr->listIdxWindowId, PIXEL_FILL(1)); - PutWindowTilemap(structPtr->listIdxWindowId); - PrintRibbonsMonListIndex(structPtr); + menu->listIdxWindowId = AddWindow(sRibbonMonListIndexWindowTemplate); + FillWindowPixelBuffer(menu->listIdxWindowId, PIXEL_FILL(1)); + PutWindowTilemap(menu->listIdxWindowId); + PrintRibbonsMonListIndex(menu); } -static void PrintRibbonsMonListIndex(struct PokenavSub14 *structPtr) +static void PrintRibbonsMonListIndex(struct Pokenav_RibbonsSummaryMenu *menu) { s32 x; u8 *txtPtr; @@ -933,24 +933,24 @@ static void PrintRibbonsMonListIndex(struct PokenavSub14 *structPtr) *(txtPtr++) = CHAR_SLASH; ConvertIntToDecimalStringN(txtPtr, count, STR_CONV_MODE_RIGHT_ALIGN, 3); x = GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar1, 56); - AddTextPrinterParameterized(structPtr->listIdxWindowId, FONT_NORMAL, gStringVar1, x, 1, TEXT_SKIP_DRAW, NULL); - CopyWindowToVram(structPtr->listIdxWindowId, COPYWIN_GFX); + AddTextPrinterParameterized(menu->listIdxWindowId, FONT_NORMAL, gStringVar1, x, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(menu->listIdxWindowId, COPYWIN_GFX); } -static void ResetSpritesAndDrawMonFrontPic(struct PokenavSub14 *structPtr) +static void ResetSpritesAndDrawMonFrontPic(struct Pokenav_RibbonsSummaryMenu *menu) { u16 species; u32 personality, otId; GetMonSpeciesPersonalityOtId(&species, &personality, &otId); ResetAllPicSprites(); - structPtr->monSpriteId = DrawRibbonsMonFrontPic(MON_SPRITE_X_ON, MON_SPRITE_Y); + menu->monSpriteId = DrawRibbonsMonFrontPic(MON_SPRITE_X_ON, MON_SPRITE_Y); PokenavFillPalette(15, 0); } -static void DestroyRibbonsMonFrontPic(struct PokenavSub14 *structPtr) +static void DestroyRibbonsMonFrontPic(struct Pokenav_RibbonsSummaryMenu *menu) { - FreeAndDestroyMonPicSprite(structPtr->monSpriteId); + FreeAndDestroyMonPicSprite(menu->monSpriteId); } // x and y arguments are ignored @@ -967,25 +967,25 @@ static u16 DrawRibbonsMonFrontPic(s32 x, s32 y) return spriteId; } -static void SlideMonSpriteOff(struct PokenavSub14 *structPtr) +static void SlideMonSpriteOff(struct Pokenav_RibbonsSummaryMenu *menu) { - StartMonSpriteSlide(&gSprites[structPtr->monSpriteId], MON_SPRITE_X_ON, MON_SPRITE_X_OFF, 6); + StartMonSpriteSlide(&gSprites[menu->monSpriteId], MON_SPRITE_X_ON, MON_SPRITE_X_OFF, 6); } -static void SlideMonSpriteOn(struct PokenavSub14 *structPtr) +static void SlideMonSpriteOn(struct Pokenav_RibbonsSummaryMenu *menu) { // Switch to new mon sprite - FreeAndDestroyMonPicSprite(structPtr->monSpriteId); - structPtr->monSpriteId = DrawRibbonsMonFrontPic(MON_SPRITE_X_OFF, MON_SPRITE_Y); + FreeAndDestroyMonPicSprite(menu->monSpriteId); + menu->monSpriteId = DrawRibbonsMonFrontPic(MON_SPRITE_X_OFF, MON_SPRITE_Y); // Slide on - StartMonSpriteSlide(&gSprites[structPtr->monSpriteId], MON_SPRITE_X_OFF, MON_SPRITE_X_ON, 6); + StartMonSpriteSlide(&gSprites[menu->monSpriteId], MON_SPRITE_X_OFF, MON_SPRITE_X_ON, 6); } // Is Pokémon summary sprite still sliding off/on -static bool32 IsMonSpriteAnimating(struct PokenavSub14 *structPtr) +static bool32 IsMonSpriteAnimating(struct Pokenav_RibbonsSummaryMenu *menu) { - return (gSprites[structPtr->monSpriteId].callback != SpriteCallbackDummy); + return (gSprites[menu->monSpriteId].callback != SpriteCallbackDummy); } #define sCurrX data[0] @@ -1030,7 +1030,7 @@ static void SpriteCB_MonSpriteSlide(struct Sprite *sprite) #undef sTime #undef sDestX -static void DrawAllRibbonsSmall(struct PokenavSub14 *structPtr) +static void DrawAllRibbonsSmall(struct Pokenav_RibbonsSummaryMenu *menu) { u32 *ribbonIds; @@ -1211,7 +1211,7 @@ static const struct SpriteTemplate sSpriteTemplate_RibbonIconBig = }; // Create dummy sprite to be used for the zoomed in version of the selected ribbon -static void CreateBigRibbonSprite(struct PokenavSub14 *structPtr) +static void CreateBigRibbonSprite(struct Pokenav_RibbonsSummaryMenu *menu) { u8 spriteId; @@ -1219,45 +1219,45 @@ static void CreateBigRibbonSprite(struct PokenavSub14 *structPtr) Pokenav_AllocAndLoadPalettes(sSpritePalettes_RibbonIcons); spriteId = CreateSprite(&sSpriteTemplate_RibbonIconBig, 0, 0, 0); - structPtr->bigRibbonSprite = &gSprites[spriteId]; - structPtr->bigRibbonSprite->invisible = TRUE; + menu->bigRibbonSprite = &gSprites[spriteId]; + menu->bigRibbonSprite->invisible = TRUE; } #define sInvisibleWhenDone data[0] -static void UpdateAndZoomInSelectedRibbon(struct PokenavSub14 *structPtr) +static void UpdateAndZoomInSelectedRibbon(struct Pokenav_RibbonsSummaryMenu *menu) { u32 ribbonId; s32 position = GetSelectedPosition(); s32 x = (position % RIBBONS_PER_ROW) * 16 + 96; s32 y = (position / RIBBONS_PER_ROW) * 16 + 40; - structPtr->bigRibbonSprite->x = x; - structPtr->bigRibbonSprite->y = y; + menu->bigRibbonSprite->x = x; + menu->bigRibbonSprite->y = y; // Set new selected ribbon's gfx data ribbonId = GetRibbonId(); - structPtr->bigRibbonSprite->oam.tileNum = (sRibbonGfxData[ribbonId].tileNumOffset * 16) + GetSpriteTileStartByTag(GFXTAG_RIBBON_ICONS_BIG); - structPtr->bigRibbonSprite->oam.paletteNum = IndexOfSpritePaletteTag(sRibbonGfxData[ribbonId].palNumOffset + PALTAG_RIBBON_ICONS_1); + menu->bigRibbonSprite->oam.tileNum = (sRibbonGfxData[ribbonId].tileNumOffset * 16) + GetSpriteTileStartByTag(GFXTAG_RIBBON_ICONS_BIG); + menu->bigRibbonSprite->oam.paletteNum = IndexOfSpritePaletteTag(sRibbonGfxData[ribbonId].palNumOffset + PALTAG_RIBBON_ICONS_1); // Start zoom in animation - StartSpriteAffineAnim(structPtr->bigRibbonSprite, RIBBONANIM_ZOOM_IN); - structPtr->bigRibbonSprite->invisible = FALSE; - structPtr->bigRibbonSprite->sInvisibleWhenDone = FALSE; - structPtr->bigRibbonSprite->callback = SpriteCB_WaitForRibbonAnimation; + StartSpriteAffineAnim(menu->bigRibbonSprite, RIBBONANIM_ZOOM_IN); + menu->bigRibbonSprite->invisible = FALSE; + menu->bigRibbonSprite->sInvisibleWhenDone = FALSE; + menu->bigRibbonSprite->callback = SpriteCB_WaitForRibbonAnimation; } // Start animation to zoom out of selected ribbon -static void ZoomOutSelectedRibbon(struct PokenavSub14 *structPtr) +static void ZoomOutSelectedRibbon(struct Pokenav_RibbonsSummaryMenu *menu) { - structPtr->bigRibbonSprite->sInvisibleWhenDone = TRUE; - StartSpriteAffineAnim(structPtr->bigRibbonSprite, RIBBONANIM_ZOOM_OUT); - structPtr->bigRibbonSprite->callback = SpriteCB_WaitForRibbonAnimation; + menu->bigRibbonSprite->sInvisibleWhenDone = TRUE; + StartSpriteAffineAnim(menu->bigRibbonSprite, RIBBONANIM_ZOOM_OUT); + menu->bigRibbonSprite->callback = SpriteCB_WaitForRibbonAnimation; } -static bool32 IsRibbonAnimating(struct PokenavSub14 *structPtr) +static bool32 IsRibbonAnimating(struct Pokenav_RibbonsSummaryMenu *menu) { - return (structPtr->bigRibbonSprite->callback != SpriteCallbackDummy); + return (menu->bigRibbonSprite->callback != SpriteCallbackDummy); } static void SpriteCB_WaitForRibbonAnimation(struct Sprite *sprite) diff --git a/sym_bss.txt b/sym_bss.txt index 3166aee45..8724f02d7 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -51,7 +51,7 @@ .include "src/mirage_tower.o" .include "src/berry_fix_program.o" .include "src/pokenav_conditions_2.o" - .include "src/pokenav_ribbons_2.o" + .include "src/pokenav_ribbons_summary.o" .include "src/ereader_helpers.o" .include "src/faraway_island.o" .include "src/m4a_1.o" From 343ac990496dd4adb551bb15001f5fb1845666cb Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 9 Nov 2021 20:02:12 -0500 Subject: [PATCH 02/19] Start pokenav conditions doc --- .../{8623228.png => condition/graph_data.png} | Bin include/constants/pokemon.h | 4 +- include/gba/defines.h | 1 - include/menu_specialized.h | 60 +++- include/pokenav.h | 16 +- src/menu_specialized.c | 276 ++++++++---------- src/pokenav_conditions_1.c | 191 ++++++------ src/pokenav_conditions_2.c | 182 ++++++------ src/pokenav_menu_handler_2.c | 8 +- src/use_pokeblock.c | 164 +++++------ 10 files changed, 453 insertions(+), 449 deletions(-) rename graphics/pokenav/{8623228.png => condition/graph_data.png} (100%) diff --git a/graphics/pokenav/8623228.png b/graphics/pokenav/condition/graph_data.png similarity index 100% rename from graphics/pokenav/8623228.png rename to graphics/pokenav/condition/graph_data.png diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 827725fc2..af5d0ea8a 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -270,7 +270,9 @@ #define FRIENDSHIP_EVENT_FAINT_FIELD_PSN 7 #define FRIENDSHIP_EVENT_FAINT_LARGE 8 // If opponent was >= 30 levels higher. See AdjustFriendshipOnBattleFaint -#define MAX_FRIENDSHIP 0xFF +#define MAX_FRIENDSHIP 255 +#define MAX_SHEEN 255 +#define MAX_CONDITION 255 #define MAX_PER_STAT_IVS 31 #define MAX_IV_MASK 31 diff --git a/include/gba/defines.h b/include/gba/defines.h index ad06aaad2..c52d7ef4f 100644 --- a/include/gba/defines.h +++ b/include/gba/defines.h @@ -6,7 +6,6 @@ #define TRUE 1 #define FALSE 0 -#define BSS_DATA __attribute__((section(".bss"))) #define IWRAM_DATA __attribute__((section("iwram_data"))) #define EWRAM_DATA __attribute__((section("ewram_data"))) #define UNUSED __attribute__((unused)) diff --git a/include/menu_specialized.h b/include/menu_specialized.h index c29110662..2f212b5d6 100644 --- a/include/menu_specialized.h +++ b/include/menu_specialized.h @@ -7,14 +7,24 @@ #include "pokemon.h" #include "constants/berry.h" -#define TAG_CONDITION_MON 100 -#define TAG_CONDITION_BALL 101 -#define TAG_CONDITION_CANCEL 102 -#define TAG_CONDITION_BALL_PLACEHOLDER 103 -#define TAG_CONDITION_SPARKLE 104 +enum { + TAG_CONDITION_MON = 100, + TAG_CONDITION_BALL, + TAG_CONDITION_CANCEL, + TAG_CONDITION_BALL_PLACEHOLDER, + TAG_CONDITION_SPARKLE, + TAG_CONDITION_MON_MARKINGS, + TAG_CONDITION_MARKINGS_MENU, + TAG_CONDITION_MARKINGS_MENU_2, // Used implicitly by CreateMonMarkingsMenuSprites +}; + #define MAX_CONDITION_SPARKLES 10 +// The number of extra sparkles shown on a Pokémon's condition screen. +// All Pokémon start with 1, so the max here is MAX_CONDITION_SPARKLES - 1 +#define GET_NUM_CONDITION_SPARKLES(sheen)((sheen) != MAX_SHEEN) ? (sheen) / ((u32)MAX_SHEEN / (MAX_CONDITION_SPARKLES - 1) + 1) : MAX_CONDITION_SPARKLES - 1; + // Window IDs for the Player PC Mailbox enum { MAILBOXWIN_TITLE, @@ -29,17 +39,35 @@ struct UnknownSubStruct_81D1ED4 u16 unk2; }; +#define CONDITION_GRAPH_CENTER_X 155 +#define CONDITION_GRAPH_TOP_Y 56 +#define CONDITION_GRAPH_BOTTOM_Y 121 +#define CONDITION_GRAPH_HEIGHT (CONDITION_GRAPH_BOTTOM_Y - CONDITION_GRAPH_TOP_Y + 1) +#define CONDITION_GRAPH_UNK_1 10 +#define CONDITION_GRAPH_UNK_2 9 +#define CONDITION_GRAPH_UNK 91 + +// Equivalent to flavor and contest values, but in a different order. +enum { + CONDITION_COOL, + CONDITION_TOUGH, + CONDITION_SMART, + CONDITION_CUTE, + CONDITION_BEAUTY, + CONDITION_COUNT +}; + struct ConditionGraph { - /*0x000*/ u8 stat[4][FLAVOR_COUNT]; - /*0x014*/ struct UnknownSubStruct_81D1ED4 unk14[4][FLAVOR_COUNT]; - /*0x064*/ struct UnknownSubStruct_81D1ED4 unk64[10][FLAVOR_COUNT]; - /*0x12C*/ struct UnknownSubStruct_81D1ED4 unk12C[FLAVOR_COUNT]; - /*0x140*/ u16 unk140[66][2]; - /*0x248*/ u16 unk248[66][2]; + /*0x000*/ u8 conditions[4][CONDITION_COUNT]; + /*0x014*/ struct UnknownSubStruct_81D1ED4 unk14[4][CONDITION_COUNT]; + /*0x064*/ struct UnknownSubStruct_81D1ED4 unk64[CONDITION_GRAPH_UNK_1][CONDITION_COUNT]; + /*0x12C*/ struct UnknownSubStruct_81D1ED4 unk12C[CONDITION_COUNT]; + /*0x140*/ u16 scanlineRight[CONDITION_GRAPH_HEIGHT][2]; + /*0x248*/ u16 scanlineLeft[CONDITION_GRAPH_HEIGHT][2]; /*0x350*/ u16 unk350; /*0x352*/ u16 unk352; - /*0x354*/ u8 unk354; + /*0x354*/ bool8 unk354; /*0x355*/ u8 state; }; @@ -49,13 +77,13 @@ u8 MailboxMenu_CreateList(struct PlayerPCItemPageStruct *page); void MailboxMenu_AddScrollArrows(struct PlayerPCItemPageStruct *page); void MailboxMenu_Free(void); void MailboxMenu_RemoveWindow(u8 windowIdx); -void InitConditionGraphData(struct ConditionGraph *graph); +void ConditionGraph_Init(struct ConditionGraph *graph); void sub_81D2108(struct ConditionGraph *graph); void SetConditionGraphIOWindows(u8 bg); void InitConditionGraphState(struct ConditionGraph *graph); void sub_81D2230(struct ConditionGraph *graph); bool8 SetupConditionGraphScanlineParams(struct ConditionGraph *graph); -bool32 TransitionConditionGraph(struct ConditionGraph *graph); +bool8 TransitionConditionGraph(struct ConditionGraph *graph); void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1); void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2); void MoveRelearnerPrintText(u8 *str); @@ -69,8 +97,8 @@ void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *sheen, u16 void GetConditionMenuMonGfx(void *tilesDst, void *palDst, u16 boxId, u16 monId, u16 partyId, u16 numMons, bool8 excludesCancel); bool8 MoveConditionMonOnscreen(s16 *x); bool8 MoveConditionMonOffscreen(s16 *x); -bool8 TryUpdateConditionMonTransitionOn(struct ConditionGraph *graph, s16 *x); -bool8 TryUpdateConditionMonTransitionOff(struct ConditionGraph *graph, s16 *x); +bool8 ConditionGraph_UpdateMonEnter(struct ConditionGraph *graph, s16 *x); +bool8 ConditionGraph_UpdateMonExit(struct ConditionGraph *graph, s16 *x); void LoadConditionMonPicTemplate(struct SpriteSheet *sheet, struct SpriteTemplate *template, struct SpritePalette *pal); void LoadConditionSelectionIcons(struct SpriteSheet *sheets, struct SpriteTemplate * template, struct SpritePalette *pals); void LoadConditionSparkle(struct SpriteSheet *sheet, struct SpritePalette *pal); diff --git a/include/pokenav.h b/include/pokenav.h index b1c73056d..445ce752b 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -256,6 +256,14 @@ enum PartyConditionFuncIds PARTY_CONDITION_FUNC_CLOSE_MARKINGS, }; +enum +{ + CONDITION_MON_0, + CONDITION_MON_1, + CONDITION_MON_2, + NUM_CONDITION_MONS +}; + #define POKENAV_MENU_FUNC_EXIT -1 enum @@ -432,11 +440,11 @@ bool32 IsConditionMenuSearchMode(void); struct ConditionGraph *GetConditionGraphDataPtr(void); u16 GetConditionGraphCurrentMonIndex(void); u16 GetMonListCount(void); -u8 GetMonSheen(void); -bool32 SetConditionGraphData(u8 arg0); +u8 GetNumConditionMonSparkles(void); +bool32 SetConditionGraphData(u8 mode); u8 TryGetMonMarkId(void); -u8 *GetConditionMonNameBuffer(u8 id); -u8 *GetConditionMonLocationBuffer(u8 id); +u8 *GetConditionMonNameText(u8 id); +u8 *GetConditionMonLocationText(u8 id); u16 GetConditionMonDataBuffer(void); void *GetConditionMonPicGfx(u8 id); void *GetConditionMonPal(u8 id); diff --git a/src/menu_specialized.c b/src/menu_specialized.c index 3a6a60885..abeaba2c9 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -31,14 +31,14 @@ extern const struct CompressedSpriteSheet gMonFrontPicTable[]; EWRAM_DATA static u8 sMailboxWindowIds[MAILBOXWIN_COUNT] = {0}; EWRAM_DATA static struct ListMenuItem *sMailboxList = NULL; -static void MailboxMenu_MoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMenu *list); -static void sub_81D24A4(struct ConditionGraph *a0); -static void sub_81D2634(struct ConditionGraph *a0); -static void MoveRelearnerCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *list); -static void nullsub_79(void); -static void SetNextConditionSparkle(struct Sprite *sprite); -static void SpriteCB_ConditionSparkle(struct Sprite *sprite); -static void ShowAllConditionSparkles(struct Sprite *sprite); +static void MailboxMenu_MoveCursorFunc(s32, bool8, struct ListMenu *); +static void sub_81D24A4(struct ConditionGraph *); +static void sub_81D2634(struct ConditionGraph *); +static void MoveRelearnerCursorCallback(s32, bool8, struct ListMenu *); +static void MoveRelearnerDummy(void); +static void SetNextConditionSparkle(struct Sprite *); +static void SpriteCB_ConditionSparkle(struct Sprite *); +static void ShowAllConditionSparkles(struct Sprite *); static const struct WindowTemplate sWindowTemplates_MailboxMenu[MAILBOXWIN_COUNT] = { @@ -80,46 +80,29 @@ static const u8 sEmptyItemName[] = _(""); static const struct ScanlineEffectParams sConditionGraphScanline = { - .dmaDest = (void*)REG_ADDR_WIN0H, + .dmaDest = ®_WIN0H, .dmaControl = SCANLINE_EFFECT_DMACNT_32BIT, .initState = 1, }; -static const u8 sUnknown_08625410[] = +static const u8 sUnknown_08625410[MAX_CONDITION + 1] = { - 4, - 5, - 6, - 7, - 8, - 9, 9, - 10, 10, - 0xB, 0xB, - 0xC, 0xC, - 0xD, 0xD, - 0xD, 0xD, - 0xE, 0xE, 0xE, 0xE, - 0xF, 0xF, 0xF, 0xF, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, - 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, - 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, - 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, - 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, - 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, - 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, - 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, - 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, - 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, - 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x23 + 4, 5, 6, 7, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 13, + 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 17, + 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, + 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, + 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35 }; @@ -320,29 +303,29 @@ void MailboxMenu_Free(void) Free(sMailboxList); } -void InitConditionGraphData(struct ConditionGraph *graph) +void ConditionGraph_Init(struct ConditionGraph *graph) { u8 i, j; - for (j = 0; j < FLAVOR_COUNT; j++) + for (j = 0; j < CONDITION_COUNT; j++) { - for (i = 0; i < 10; i++) + for (i = 0; i < CONDITION_GRAPH_UNK_1; i++) { graph->unk64[i][j].unk0 = 0; graph->unk64[i][j].unk2 = 0; } for (i = 0; i < 4; i++) { - graph->stat[i][j] = 0; - graph->unk14[i][j].unk0 = 155; - graph->unk14[i][j].unk2 = 91; + graph->conditions[i][j] = 0; + graph->unk14[i][j].unk0 = CONDITION_GRAPH_CENTER_X; + graph->unk14[i][j].unk2 = CONDITION_GRAPH_UNK; } graph->unk12C[j].unk0 = 0; graph->unk12C[j].unk2 = 0; } - graph->unk354 = 0; + graph->unk354 = FALSE; graph->unk352 = 0; } @@ -351,11 +334,11 @@ void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 * u16 i, j; s32 r5, r6; - for (i = 0; i < FLAVOR_COUNT; i++) + for (i = 0; i < CONDITION_COUNT; i++) { r5 = arg1[i].unk0 << 8; - r6 = ((arg2[i].unk0 - arg1[i].unk0) << 8) / 10; - for (j = 0; j < 9; j++) + r6 = ((arg2[i].unk0 - arg1[i].unk0) << 8) / CONDITION_GRAPH_UNK_1; + for (j = 0; j < CONDITION_GRAPH_UNK_2; j++) { graph->unk64[j][i].unk0 = (r5 >> 8) + ((r5 >> 7) & 1); r5 += r6; @@ -363,8 +346,8 @@ void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 * graph->unk64[j][i].unk0 = arg2[i].unk0; r5 = arg1[i].unk2 << 8; - r6 = ((arg2[i].unk2 - arg1[i].unk2) << 8) / 10; - for (j = 0; j < 9; j++) + r6 = ((arg2[i].unk2 - arg1[i].unk2) << 8) / CONDITION_GRAPH_UNK_1; + for (j = 0; j < CONDITION_GRAPH_UNK_2; j++) { graph->unk64[j][i].unk2 = (r5 >> 8) + ((r5 >> 7) & 1); r5 += r6; @@ -375,12 +358,12 @@ void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 * graph->unk352 = 0; } -bool32 TransitionConditionGraph(struct ConditionGraph *graph) +bool8 TransitionConditionGraph(struct ConditionGraph *graph) { - if (graph->unk352 < 10) + if (graph->unk352 < CONDITION_GRAPH_UNK_1) { sub_81D2230(graph); - return (++graph->unk352 != 10); + return (++graph->unk352 != CONDITION_GRAPH_UNK_1); } else { @@ -417,35 +400,36 @@ void sub_81D2108(struct ConditionGraph *graph) { u16 i; - if (graph->unk354 == 0) + if (!graph->unk354) return; sub_81D24A4(graph); sub_81D2634(graph); - for (i = 0; i < 66; i++) + for (i = 0; i < CONDITION_GRAPH_HEIGHT; i++) { - gScanlineEffectRegBuffers[1][(i + 55) * 2] = gScanlineEffectRegBuffers[0][(i + 55) * 2] = (graph->unk140[i][0] << 8) | (graph->unk140[i][1]); - gScanlineEffectRegBuffers[1][(i + 55) * 2 + 1] = gScanlineEffectRegBuffers[0][(i + 55) * 2 + 1] = (graph->unk248[i][0] << 8) | (graph->unk248[i][1]); + gScanlineEffectRegBuffers[1][(i + 55) * 2] = gScanlineEffectRegBuffers[0][(i + 55) * 2] = (graph->scanlineRight[i][0] << 8) | (graph->scanlineRight[i][1]); + gScanlineEffectRegBuffers[1][(i + 55) * 2 + 1] = gScanlineEffectRegBuffers[0][(i + 55) * 2 + 1] = (graph->scanlineLeft[i][0] << 8) | (graph->scanlineLeft[i][1]); } - graph->unk354 = 0; + graph->unk354 = FALSE; } void SetConditionGraphIOWindows(u8 bg) { u32 flags; - if (bg > 3) + if (bg >= NUM_BACKGROUNDS) bg = 0; // Unset the WINOUT flag for the bg. flags = (WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ) & ~(1 << bg); - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE( 0, DISPLAY_WIDTH)); - SetGpuReg(REG_OFFSET_WIN1H, WIN_RANGE( 0, 155)); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(56, 121)); - SetGpuReg(REG_OFFSET_WIN1V, WIN_RANGE(56, 121)); + // Set limits for graph data + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE( 0, DISPLAY_WIDTH)); // Right side horizontal + SetGpuReg(REG_OFFSET_WIN1H, WIN_RANGE( 0, CONDITION_GRAPH_CENTER_X)); // Left side horizontal + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(CONDITION_GRAPH_TOP_Y, CONDITION_GRAPH_BOTTOM_Y)); // Right side vertical + SetGpuReg(REG_OFFSET_WIN1V, WIN_RANGE(CONDITION_GRAPH_TOP_Y, CONDITION_GRAPH_BOTTOM_Y)); // Left side vertical SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR); SetGpuReg(REG_OFFSET_WINOUT, flags); } @@ -453,19 +437,18 @@ void SetConditionGraphIOWindows(u8 bg) void sub_81D2230(struct ConditionGraph *graph) { u16 i; - for (i = 0; i < FLAVOR_COUNT; i++) + for (i = 0; i < CONDITION_COUNT; i++) graph->unk12C[i] = graph->unk64[graph->unk352][i]; - graph->unk354 = 1; + graph->unk354 = TRUE; } static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownSubStruct_81D1ED4 *arg2, struct UnknownSubStruct_81D1ED4 *arg3, u8 arg4, u16 *arg5) { u16 i, r8, r10, r0, var_30; u16 *ptr; - s32 r4, var_2C; + s32 r4, var_2C = 0; - var_2C = 0; if (arg2->unk2 < arg3->unk2) { r10 = arg2->unk2; @@ -490,7 +473,7 @@ static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownS r8++; if (arg5 == NULL) { - arg1 += (r10 - 56) * 2; + arg1 += (r10 - CONDITION_GRAPH_TOP_Y) * 2; for (i = 0; i < r8; i++) { arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4; @@ -502,16 +485,16 @@ static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownS } else if (var_2C > 0) { - arg5 += (r10 - 56) * 2; + arg5 += (r10 - CONDITION_GRAPH_TOP_Y) * 2; // Less readable than the other loops, but it has to be written this way to match. for (i = 0; i < r8; arg5[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4, r4 += var_2C, arg5 += 2, i++) { - if (r4 >= (155 << 10)) + if (r4 >= (CONDITION_GRAPH_CENTER_X << 10)) break; } graph->unk350 = r10 + i; - arg1 += (graph->unk350 - 56) * 2; + arg1 += (graph->unk350 - CONDITION_GRAPH_TOP_Y) * 2; for (; i < r8; i++) { arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4; @@ -523,13 +506,13 @@ static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownS } else if (var_2C < 0) { - arg1 += (r10 - 56) * 2; + arg1 += (r10 - CONDITION_GRAPH_TOP_Y) * 2; for (i = 0; i < r8; i++) { arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4; - if (r4 < (155 << 10)) + if (r4 < (CONDITION_GRAPH_CENTER_X << 10)) { - arg1[arg4] = 155; + arg1[arg4] = CONDITION_GRAPH_CENTER_X; break; } r4 += var_2C; @@ -537,7 +520,7 @@ static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownS } graph->unk350 = r10 + i; - arg5 += (graph->unk350 - 56) * 2; + arg5 += (graph->unk350 - CONDITION_GRAPH_TOP_Y) * 2; for (; i < r8; i++) { arg5[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4; @@ -550,11 +533,11 @@ static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownS else { graph->unk350 = r10; - arg1 += (r10 - 56) * 2; - arg5 += (r10 - 56) * 2; + arg1 += (r10 - CONDITION_GRAPH_TOP_Y) * 2; + arg5 += (r10 - CONDITION_GRAPH_TOP_Y) * 2; arg1[1] = arg2->unk0 + 1; arg5[0] = arg3->unk0; - arg5[1] = 155; + arg5[1] = CONDITION_GRAPH_CENTER_X; return; } @@ -568,38 +551,38 @@ static void sub_81D24A4(struct ConditionGraph *graph) if (graph->unk12C[0].unk2 < graph->unk12C[1].unk2) { r6 = graph->unk12C[0].unk2; - sub_81D2278(graph, graph->unk140[0], &graph->unk12C[0], &graph->unk12C[1], 1, NULL); + sub_81D2278(graph, graph->scanlineRight[0], &graph->unk12C[0], &graph->unk12C[1], 1, NULL); } else { r6 = graph->unk12C[1].unk2; - sub_81D2278(graph, graph->unk140[0], &graph->unk12C[1], &graph->unk12C[0], 0, NULL); + sub_81D2278(graph, graph->scanlineRight[0], &graph->unk12C[1], &graph->unk12C[0], 0, NULL); } - sub_81D2278(graph, graph->unk140[0], &graph->unk12C[1], &graph->unk12C[2], 1, NULL); + sub_81D2278(graph, graph->scanlineRight[0], &graph->unk12C[1], &graph->unk12C[2], 1, NULL); i = (graph->unk12C[2].unk2 <= graph->unk12C[3].unk2); - sub_81D2278(graph, graph->unk140[0], &graph->unk12C[2], &graph->unk12C[3], i, graph->unk248[0]); - for (i = 56; i < r6; i++) + sub_81D2278(graph, graph->scanlineRight[0], &graph->unk12C[2], &graph->unk12C[3], i, graph->scanlineLeft[0]); + for (i = CONDITION_GRAPH_TOP_Y; i < r6; i++) { - graph->unk140[i - 56][0] = 0; - graph->unk140[i - 56][1] = 0; + graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = 0; + graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][1] = 0; } for (i = graph->unk12C[0].unk2; i <= graph->unk350; i++) - graph->unk140[i - 56][0] = 155; + graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = CONDITION_GRAPH_CENTER_X; varMax = max(graph->unk350, graph->unk12C[2].unk2); - for (i = varMax + 1; i < 122; i++) + for (i = varMax + 1; i <= CONDITION_GRAPH_BOTTOM_Y; i++) { - graph->unk140[i - 56][0] = 0; - graph->unk140[i - 56][1] = 0; + graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = 0; + graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][1] = 0; } - for (i = 56; i < 122; i++) + for (i = CONDITION_GRAPH_TOP_Y; i <= CONDITION_GRAPH_BOTTOM_Y; i++) { - if (graph->unk140[i - 56][0] == 0 && graph->unk140[i - 56][1] != 0) - graph->unk140[i - 56][0] = 155; + if (graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] == 0 && graph->scanlineRight[i - 56][1] != 0) + graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = CONDITION_GRAPH_CENTER_X; } } @@ -610,69 +593,69 @@ static void sub_81D2634(struct ConditionGraph *graph) if (graph->unk12C[0].unk2 < graph->unk12C[4].unk2) { r6 = graph->unk12C[0].unk2; - sub_81D2278(graph, graph->unk248[0], &graph->unk12C[0], &graph->unk12C[4], 0, NULL); + sub_81D2278(graph, graph->scanlineLeft[0], &graph->unk12C[0], &graph->unk12C[4], 0, NULL); } else { r6 = graph->unk12C[4].unk2; - sub_81D2278(graph, graph->unk248[0], &graph->unk12C[4], &graph->unk12C[0], 1, NULL); + sub_81D2278(graph, graph->scanlineLeft[0], &graph->unk12C[4], &graph->unk12C[0], 1, NULL); } - sub_81D2278(graph, graph->unk248[0], &graph->unk12C[4], &graph->unk12C[3], 0, NULL); + sub_81D2278(graph, graph->scanlineLeft[0], &graph->unk12C[4], &graph->unk12C[3], 0, NULL); - for (i = 56; i < r6; i++) + for (i = CONDITION_GRAPH_TOP_Y; i < r6; i++) { - graph->unk140[i + 10][0] = 0; - graph->unk140[i + 10][1] = 0; + graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][0] = 0; + graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][1] = 0; } for (i = graph->unk12C[0].unk2; i <= graph->unk350; i++) - graph->unk140[i + 10][1] = 155; + graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][1] = CONDITION_GRAPH_CENTER_X; varMax = max(graph->unk350, graph->unk12C[3].unk2 + 1); - for (i = varMax; i < 122; i++) + for (i = varMax; i <= CONDITION_GRAPH_BOTTOM_Y; i++) { - graph->unk140[i + 10][0] = 0; - graph->unk140[i + 10][1] = 0; + graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][0] = 0; + graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][1] = 0; } - for (i = 0; i < 66; i++) + for (i = 0; i < CONDITION_GRAPH_HEIGHT; i++) { - if (graph->unk248[i][0] >= graph->unk248[i][1]) + if (graph->scanlineLeft[i][0] >= graph->scanlineLeft[i][1]) { - graph->unk248[i][1] = 0; - graph->unk248[i][0] = 0; + graph->scanlineLeft[i][1] = 0; + graph->scanlineLeft[i][0] = 0; } } } -void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1) +void sub_81D2754(u8 *conditions, struct UnknownSubStruct_81D1ED4 *arg1) { - u8 r2, r7; + u8 r2, sinIdx; s8 r12; u16 i; - r2 = sUnknown_08625410[*(arg0++)]; - arg1->unk0 = 155; - arg1->unk2 = 91 - r2; + r2 = sUnknown_08625410[*(conditions++)]; + arg1->unk0 = CONDITION_GRAPH_CENTER_X; + arg1->unk2 = CONDITION_GRAPH_UNK - r2; - r7 = 64; + sinIdx = 64; r12 = 0; - for (i = 1; i < 5; i++) + for (i = 1; i < CONDITION_COUNT; i++) { - r7 += 51; + sinIdx += 51; if (--r12 < 0) r12 = 4; if (r12 == 2) - r7++; + sinIdx++; - r2 = sUnknown_08625410[*(arg0++)]; - arg1[r12].unk0 = 155 + ((r2 * gSineTable[64 + r7]) >> 8); - arg1[r12].unk2 = 91 - ((r2 * gSineTable[r7]) >> 8); + r2 = sUnknown_08625410[*(conditions++)]; + arg1[r12].unk0 = CONDITION_GRAPH_CENTER_X + ((r2 * gSineTable[64 + sinIdx]) >> 8); + arg1[r12].unk2 = CONDITION_GRAPH_UNK - ((r2 * gSineTable[sinIdx]) >> 8); if (r12 < 3 && (r2 != 32 || r12 != 2)) - arg1[r12].unk0 = 156 + ((r2 * gSineTable[64 + r7]) >> 8); + arg1[r12].unk0 = CONDITION_GRAPH_CENTER_X + 1 + ((r2 * gSineTable[64 + sinIdx]) >> 8); } } @@ -685,10 +668,8 @@ void InitMoveRelearnerWindows(bool8 useContextWindow) LoadUserWindowBorderGfx(0, 1, 0xE0); LoadPalette(gStandardMenuPalette, 0xF0, 0x20); - for (i = 0; i < 5; i++) - { + for (i = 0; i < ARRAY_COUNT(sMoveRelearnerWindowTemplates) - 1; i++) FillWindowPixelBuffer(i, PIXEL_FILL(1)); - } if (!useContextWindow) { @@ -704,11 +685,11 @@ void InitMoveRelearnerWindows(bool8 useContextWindow) PutWindowTilemap(3); DrawStdFrameWithCustomTileAndPalette(2, 0, 1, 0xE); DrawStdFrameWithCustomTileAndPalette(3, 0, 1, 0xE); - nullsub_79(); + MoveRelearnerDummy(); ScheduleBgCopyTilemapToVram(1); } -static void nullsub_79(void) +static void MoveRelearnerDummy(void) { } @@ -720,13 +701,10 @@ u8 LoadMoveRelearnerMovesList(const struct ListMenuItem *items, u16 numChoices) gMultiuseListMenuTemplate.items = items; if (numChoices < 6) - { gMultiuseListMenuTemplate.maxShowed = numChoices; - } else - { gMultiuseListMenuTemplate.maxShowed = 6; - } + return gMultiuseListMenuTemplate.maxShowed; } @@ -734,7 +712,7 @@ static void MoveRelearnerLoadBattleMoveDescription(u32 chosenMove) { s32 x; const struct BattleMove *move; - u8 buffer[0x20]; + u8 buffer[32]; const u8 *str; FillWindowPixelBuffer(0, PIXEL_FILL(1)); @@ -1010,7 +988,7 @@ void GetConditionMenuMonNameAndLocString(u8 *locationDst, u8 *nameDst, u16 boxId } } -void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *sheen, u16 boxId, u16 monId, u16 partyId, u16 id, u16 numMons, bool8 excludesCancel) +void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *numSparkles, u16 boxId, u16 monId, u16 partyId, u16 id, u16 numMons, bool8 excludesCancel) { u16 i; @@ -1019,25 +997,23 @@ void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *sheen, u16 if (partyId != numMons) { - graph->stat[id][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); - graph->stat[id][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); - graph->stat[id][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); - graph->stat[id][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); - graph->stat[id][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); + graph->conditions[id][CONDITION_COOL] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); + graph->conditions[id][CONDITION_TOUGH] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); + graph->conditions[id][CONDITION_SMART] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); + graph->conditions[id][CONDITION_CUTE] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); + graph->conditions[id][CONDITION_BEAUTY] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); - sheen[id] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 0xFF) - ? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u - : 9; + numSparkles[id] = GET_NUM_CONDITION_SPARKLES(GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL)); - sub_81D2754(graph->stat[id], graph->unk14[id]); + sub_81D2754(graph->conditions[id], graph->unk14[id]); } else { - for (i = 0; i < FLAVOR_COUNT; i++) + for (i = 0; i < CONDITION_COUNT; i++) { - graph->stat[id][i] = 0; - graph->unk14[id][i].unk0 = 155; - graph->unk14[id][i].unk2 = 91; + graph->conditions[id][i] = 0; + graph->unk14[id][i].unk0 = CONDITION_GRAPH_CENTER_X; + graph->unk14[id][i].unk2 = CONDITION_GRAPH_UNK; } } } @@ -1076,7 +1052,7 @@ bool8 MoveConditionMonOffscreen(s16 *x) return (*x != -80); } -bool8 TryUpdateConditionMonTransitionOn(struct ConditionGraph *graph, s16 *x) +bool8 ConditionGraph_UpdateMonEnter(struct ConditionGraph *graph, s16 *x) { bool8 graphUpdating = TransitionConditionGraph(graph); bool8 monUpdating = MoveConditionMonOnscreen(x); @@ -1084,7 +1060,7 @@ bool8 TryUpdateConditionMonTransitionOn(struct ConditionGraph *graph, s16 *x) return (graphUpdating || monUpdating); } -bool8 TryUpdateConditionMonTransitionOff(struct ConditionGraph *graph, s16 *x) +bool8 ConditionGraph_UpdateMonExit(struct ConditionGraph *graph, s16 *x) { bool8 graphUpdating = TransitionConditionGraph(graph); bool8 monUpdating = MoveConditionMonOffscreen(x); diff --git a/src/pokenav_conditions_1.c b/src/pokenav_conditions_1.c index a01b93a80..8eacf2e70 100644 --- a/src/pokenav_conditions_1.c +++ b/src/pokenav_conditions_1.c @@ -15,18 +15,18 @@ struct PokenavSub11 { - u32 monPal[3][0x20]; + u32 monPal[NUM_CONDITION_MONS][0x20]; u8 fill[0x180]; - u32 monPicGfx[3][MON_PIC_SIZE]; + u32 monPicGfx[NUM_CONDITION_MONS][MON_PIC_SIZE]; u8 searchMode; s16 monIndex; u32 (*callback)(struct PokenavSub11 *); u8 fill2[0x6320 - 0x6308]; - u8 searchLocBuffer[3][24]; - u8 nameBuffer[3][64]; + u8 locationText[NUM_CONDITION_MONS][24]; + u8 nameText[NUM_CONDITION_MONS][64]; struct ConditionGraph conditionData; - u8 sheen[3]; - u8 monMarks[3]; + u8 numSparkles[NUM_CONDITION_MONS]; + u8 monMarks[NUM_CONDITION_MONS]; s8 mark; s8 unk6787; s8 unk6788; @@ -34,18 +34,17 @@ struct PokenavSub11 u8 state; }; -void InitPartyConditionListParameters(void); -void sub_81CD9F8(void); -u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr); -u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr); -u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr); -u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr); -u8 SwitchConditionSummaryIndex(u8 moveUp); -void CopyMonNameGenderLocation(s16 id, u8 arg1); -void GetMonConditionGraphData(s16 id, u8 arg1); -void ConditionGraphDrawMonPic(s16 id, u8 arg1); +static void InitPartyConditionListParameters(void); +static void InitSearchResultsConditionList(void); +static u32 HandlePartyConditionInput(struct PokenavSub11 *); +static u32 GetConditionReturnCallback(struct PokenavSub11 *); +static u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *); +static u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *); +static u8 SwitchConditionSummaryIndex(bool8); +static void CopyMonNameGenderLocation(s16, u8); +static void GetMonConditionGraphData(s16, u8); +static void ConditionGraphDrawMonPic(s16, u8); -// code bool32 PokenavCallback_Init_PartyCondition(void) { struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11)); @@ -53,7 +52,7 @@ bool32 PokenavCallback_Init_PartyCondition(void) if (structPtr == NULL) return FALSE; - InitConditionGraphData(&structPtr->conditionData); + ConditionGraph_Init(&structPtr->conditionData); InitPartyConditionListParameters(); gKeyRepeatStartDelay = 20; structPtr->callback = HandlePartyConditionInput; @@ -67,8 +66,8 @@ bool32 PokenavCallback_Init_ConditionGraphFromSearch(void) if (structPtr == NULL) return FALSE; - InitConditionGraphData(&structPtr->conditionData); - sub_81CD9F8(); + ConditionGraph_Init(&structPtr->conditionData); + InitSearchResultsConditionList(); gKeyRepeatStartDelay = 20; structPtr->callback = HandlePartyConditionInput; return TRUE; @@ -81,7 +80,7 @@ u32 GetPartyConditionCallback(void) return structPtr->callback(structPtr); } -u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr) +static u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr) { struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); u32 ret = ConditionGraphHandleDpadInput(structPtr); @@ -117,7 +116,7 @@ u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr) return ret; } -u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr) +static u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr) { struct PokenavSub18 *monListPtr; u8 markings; @@ -143,7 +142,7 @@ u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr) return ret; } -u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr) +static u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr) { if (structPtr->searchMode == 0) return POKENAV_CONDITION_MENU; @@ -160,7 +159,7 @@ void FreePartyConditionSubstruct1(void) FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH); } -u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr) +static u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr) { struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); u8 ret = 0; @@ -170,7 +169,7 @@ u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr) if (structPtr->searchMode == 0 || monListPtr->currIndex != 0) { PlaySE(SE_SELECT); - ret = SwitchConditionSummaryIndex(1); + ret = SwitchConditionSummaryIndex(TRUE); } } else if (JOY_HELD(DPAD_DOWN)) @@ -178,14 +177,14 @@ u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr) if (structPtr->searchMode == 0 || monListPtr->currIndex < monListPtr->listCount - 1) { PlaySE(SE_SELECT); - ret = SwitchConditionSummaryIndex(0); + ret = SwitchConditionSummaryIndex(FALSE); } } return ret; } -u8 SwitchConditionSummaryIndex(u8 moveUp) +static u8 SwitchConditionSummaryIndex(u8 moveUp) { u16 r7; bool8 wasNotLastMon, isNotLastMon; @@ -235,28 +234,28 @@ bool32 LoadPartyConditionMenuGfx(void) switch (structPtr->state) { case 0: - CopyMonNameGenderLocation(monListPtr->currIndex, 0); + CopyMonNameGenderLocation(monListPtr->currIndex, CONDITION_MON_0); break; case 1: - GetMonConditionGraphData(monListPtr->currIndex, 0); + GetMonConditionGraphData(monListPtr->currIndex, CONDITION_MON_0); break; case 2: - ConditionGraphDrawMonPic(monListPtr->currIndex, 0); + ConditionGraphDrawMonPic(monListPtr->currIndex, CONDITION_MON_0); break; case 3: if (monListPtr->listCount == 1) { - structPtr->mark = 0; - structPtr->unk6787 = 0; - structPtr->unk6788 = 0; + structPtr->mark = CONDITION_MON_0; + structPtr->unk6787 = CONDITION_MON_0; + structPtr->unk6788 = CONDITION_MON_0; structPtr->state = 0; return TRUE; } else { - structPtr->mark = 0; - structPtr->unk6787 = 1; - structPtr->unk6788 = 2; + structPtr->mark = CONDITION_MON_0; + structPtr->unk6787 = CONDITION_MON_1; + structPtr->unk6788 = CONDITION_MON_2; } break; // These were probably ternaries just like cases 7-9, but couldn't match it any other way. @@ -264,28 +263,28 @@ bool32 LoadPartyConditionMenuGfx(void) var = monListPtr->currIndex + 1; if (var >= monListPtr->listCount) var = 0; - CopyMonNameGenderLocation(var, 1); + CopyMonNameGenderLocation(var, CONDITION_MON_1); break; case 5: var = monListPtr->currIndex + 1; if (var >= monListPtr->listCount) var = 0; - GetMonConditionGraphData(var, 1); + GetMonConditionGraphData(var, CONDITION_MON_1); break; case 6: var = monListPtr->currIndex + 1; if (var >= monListPtr->listCount) var = 0; - ConditionGraphDrawMonPic(var, 1); + ConditionGraphDrawMonPic(var, CONDITION_MON_1); break; case 7: - CopyMonNameGenderLocation((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2); + CopyMonNameGenderLocation((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2); break; case 8: - GetMonConditionGraphData((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2); + GetMonConditionGraphData((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2); break; case 9: - ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2); + ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2); structPtr->state = 0; return TRUE; } @@ -326,15 +325,15 @@ u8 *CopyStringLeftAlignedToConditionData(u8 *dst, const u8 *src, s16 n) return dst; } -u8 *CopyMonConditionNameGender(u8 *str, u16 id, bool8 arg3) +static u8 *CopyConditionMonNameGender(u8 *str, u16 listId, bool8 arg3) { u16 boxId, monId, gender, species, level, lvlDigits; struct BoxPokemon *boxMon; u8 *txtPtr, *str_; struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - boxId = monListPtr->monData[id].boxId; - monId = monListPtr->monData[id].monId; + boxId = monListPtr->monData[listId].boxId; + monId = monListPtr->monData[listId].monId; *(str++) = EXT_CTRL_CODE_BEGIN; *(str++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; *(str++) = TEXT_COLOR_BLUE; @@ -417,39 +416,39 @@ u8 *CopyMonConditionNameGender(u8 *str, u16 id, bool8 arg3) return str_; } -void CopyMonNameGenderLocation(s16 id, u8 arg1) +static void CopyMonNameGenderLocation(s16 listId, u8 loadId) { u16 boxId, i; struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - if (id != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) + if (listId != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) { - CopyMonConditionNameGender(structPtr->nameBuffer[arg1], id, FALSE); - boxId = monListPtr->monData[id].boxId; - structPtr->searchLocBuffer[arg1][0] = EXT_CTRL_CODE_BEGIN; - structPtr->searchLocBuffer[arg1][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; - structPtr->searchLocBuffer[arg1][2] = TEXT_COLOR_BLUE; - structPtr->searchLocBuffer[arg1][3] = TEXT_COLOR_TRANSPARENT; - structPtr->searchLocBuffer[arg1][4] = TEXT_COLOR_LIGHT_BLUE; + CopyConditionMonNameGender(structPtr->nameText[loadId], listId, FALSE); + boxId = monListPtr->monData[listId].boxId; + structPtr->locationText[loadId][0] = EXT_CTRL_CODE_BEGIN; + structPtr->locationText[loadId][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; + structPtr->locationText[loadId][2] = TEXT_COLOR_BLUE; + structPtr->locationText[loadId][3] = TEXT_COLOR_TRANSPARENT; + structPtr->locationText[loadId][4] = TEXT_COLOR_LIGHT_BLUE; if (boxId == TOTAL_BOXES_COUNT) - CopyStringLeftAlignedToConditionData(&structPtr->searchLocBuffer[arg1][5], gText_InParty, 8); + CopyStringLeftAlignedToConditionData(&structPtr->locationText[loadId][5], gText_InParty, BOX_NAME_LENGTH); else - CopyStringLeftAlignedToConditionData(&structPtr->searchLocBuffer[arg1][5], GetBoxNamePtr(boxId), BOX_NAME_LENGTH); + CopyStringLeftAlignedToConditionData(&structPtr->locationText[loadId][5], GetBoxNamePtr(boxId), BOX_NAME_LENGTH); } else { for (i = 0; i < 12; i++) - structPtr->nameBuffer[arg1][i] = CHAR_SPACE; - structPtr->nameBuffer[arg1][i] = EOS; + structPtr->nameText[loadId][i] = CHAR_SPACE; + structPtr->nameText[loadId][i] = EOS; - for (i = 0; i < 8; i++) - structPtr->searchLocBuffer[arg1][i] = CHAR_SPACE; - structPtr->searchLocBuffer[arg1][i] = EOS; + for (i = 0; i < BOX_NAME_LENGTH; i++) + structPtr->locationText[loadId][i] = CHAR_SPACE; + structPtr->locationText[loadId][i] = EOS; } } -void InitPartyConditionListParameters(void) +static void InitPartyConditionListParameters(void) { u16 i, count; struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); @@ -475,62 +474,60 @@ void InitPartyConditionListParameters(void) structPtr->state = 0; } -void sub_81CD9F8(void) +static void InitSearchResultsConditionList(void) { struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); structPtr->searchMode = 1; structPtr->state = 0; } -void GetMonConditionGraphData(s16 id, u8 arg1) +static void GetMonConditionGraphData(s16 listId, u8 loadId) { u16 boxId, monId, i; struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - if (id != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) + if (listId != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) { - boxId = monListPtr->monData[id].boxId; - monId = monListPtr->monData[id].monId; - structPtr->conditionData.stat[arg1][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); - structPtr->conditionData.stat[arg1][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); - structPtr->conditionData.stat[arg1][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); - structPtr->conditionData.stat[arg1][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); - structPtr->conditionData.stat[arg1][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); - structPtr->sheen[arg1] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 255) - ? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u - : 9; - structPtr->monMarks[arg1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL); - sub_81D2754(structPtr->conditionData.stat[arg1], structPtr->conditionData.unk14[arg1]); + boxId = monListPtr->monData[listId].boxId; + monId = monListPtr->monData[listId].monId; + structPtr->conditionData.conditions[loadId][CONDITION_COOL] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); + structPtr->conditionData.conditions[loadId][CONDITION_TOUGH] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); + structPtr->conditionData.conditions[loadId][CONDITION_SMART] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); + structPtr->conditionData.conditions[loadId][CONDITION_CUTE] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); + structPtr->conditionData.conditions[loadId][CONDITION_BEAUTY] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); + structPtr->numSparkles[loadId] = GET_NUM_CONDITION_SPARKLES(GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL)); + structPtr->monMarks[loadId] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL); + sub_81D2754(structPtr->conditionData.conditions[loadId], structPtr->conditionData.unk14[loadId]); } else { - for (i = 0; i < FLAVOR_COUNT; i++) + for (i = 0; i < CONDITION_COUNT; i++) { - structPtr->conditionData.stat[arg1][i] = 0; - structPtr->conditionData.unk14[arg1][i].unk0 = 155; - structPtr->conditionData.unk14[arg1][i].unk2 = 91; + structPtr->conditionData.conditions[loadId][i] = 0; + structPtr->conditionData.unk14[loadId][i].unk0 = CONDITION_GRAPH_CENTER_X; + structPtr->conditionData.unk14[loadId][i].unk2 = CONDITION_GRAPH_UNK; } } } -void ConditionGraphDrawMonPic(s16 index, u8 arg1) +static void ConditionGraphDrawMonPic(s16 listId, u8 loadId) { u16 boxId, monId, species; u32 personality, tid; struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - if (index == (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) + if (listId == (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) return; - boxId = monListPtr->monData[index].boxId; - monId = monListPtr->monData[index].monId; + boxId = monListPtr->monData[listId].boxId; + monId = monListPtr->monData[listId].monId; species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL); tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL); personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL); - LoadSpecialPokePic(&gMonFrontPicTable[species], structPtr->monPicGfx[arg1], species, personality, TRUE); - LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), structPtr->monPal[arg1]); + LoadSpecialPokePic(&gMonFrontPicTable[species], structPtr->monPicGfx[loadId], species, personality, TRUE); + LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), structPtr->monPal[loadId]); } u16 GetMonListCount(void) @@ -563,16 +560,16 @@ u8 sub_81CDC9C(void) return structPtr->monIndex; } -void *GetConditionMonPicGfx(u8 id) +void *GetConditionMonPicGfx(u8 loadId) { struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return structPtr->monPicGfx[id]; + return structPtr->monPicGfx[loadId]; } -void *GetConditionMonPal(u8 id) +void *GetConditionMonPal(u8 loadId) { struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return structPtr->monPal[id]; + return structPtr->monPal[loadId]; } u8 sub_81CDCEC(void) @@ -581,16 +578,16 @@ u8 sub_81CDCEC(void) return structPtr->unk6789; } -u8 *GetConditionMonNameBuffer(u8 id) +u8 *GetConditionMonNameText(u8 loadId) { struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return structPtr->nameBuffer[id]; + return structPtr->nameText[loadId]; } -u8 *GetConditionMonLocationBuffer(u8 id) +u8 *GetConditionMonLocationText(u8 loadId) { struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return structPtr->searchLocBuffer[id]; + return structPtr->locationText[loadId]; } u16 GetConditionMonDataBuffer(void) @@ -617,8 +614,8 @@ u8 TryGetMonMarkId(void) return 0; } -u8 GetMonSheen(void) +u8 GetNumConditionMonSparkles(void) { struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return structPtr->sheen[structPtr->mark]; + return structPtr->numSparkles[structPtr->mark]; } diff --git a/src/pokenav_conditions_2.c b/src/pokenav_conditions_2.c index 4799b163c..ef07c9be6 100644 --- a/src/pokenav_conditions_2.c +++ b/src/pokenav_conditions_2.c @@ -15,22 +15,22 @@ #include "strings.h" #include "text.h" -u32 LoopedTask_TransitionMons(s32); -u32 LoopedTask_ExitPartyConditionMenu(s32); -u32 LoopedTask_MoveCursorNoTransition(s32); -u32 LoopedTask_SlideMonOut(s32); -u32 LoopedTask_OpenMonMarkingsWindow(s32); -u32 LoopedTask_CloseMonMarkingsWindow(s32); +static u32 LoopedTask_TransitionMons(s32); +static u32 LoopedTask_ExitPartyConditionMenu(s32); +static u32 LoopedTask_MoveCursorNoTransition(s32); +static u32 LoopedTask_SlideMonOut(s32); +static u32 LoopedTask_OpenMonMarkingsWindow(s32); +static u32 LoopedTask_CloseMonMarkingsWindow(s32); -BSS_DATA u8 gUnknown_030012BC; +static u8 sUnknown_030012BC; const u16 gConditionGraphData_Pal[] = INCBIN_U16("graphics/pokenav/condition/graph_data.gbapal"); const u16 gConditionText_Pal[] = INCBIN_U16("graphics/pokenav/condition/text.gbapal"); -const u32 gUnknown_08623228[] = INCBIN_U32("graphics/pokenav/8623228.4bpp.lz"); -const u32 sConditionGraph_Tilemap[] = INCBIN_U32("graphics/pokenav/862323C.bin.lz"); -const u16 sConditionGraphMonMarkingsPal[] = INCBIN_U16("graphics/pokenav/8623338.gbapal"); +static const u32 sUnknown_08623228[] = INCBIN_U32("graphics/pokenav/condition/graph_data.4bpp.lz"); +static const u32 sConditionGraph_Tilemap[] = INCBIN_U32("graphics/pokenav/862323C.bin.lz"); +static const u16 sConditionGraphMonMarkingsPal[] = INCBIN_U16("graphics/pokenav/8623338.gbapal"); -const struct BgTemplate sPartyConditionBgTemplates[3] = +static const struct BgTemplate sPartyConditionBgTemplates[3] = { { .bg = 1, @@ -61,7 +61,7 @@ const struct BgTemplate sPartyConditionBgTemplates[3] = } }; -const struct WindowTemplate sMonNameGenderWindowTemplate = +static const struct WindowTemplate sMonNameGenderWindowTemplate = { .bg = 1, .tilemapLeft = 13, @@ -72,7 +72,7 @@ const struct WindowTemplate sMonNameGenderWindowTemplate = .baseBlock = 2 }; -const struct WindowTemplate sConditionGraphListIdWindowTemplate = +static const struct WindowTemplate sConditionGraphListIdWindowTemplate = { .bg = 1, .tilemapLeft = 1, @@ -83,7 +83,7 @@ const struct WindowTemplate sConditionGraphListIdWindowTemplate = .baseBlock = 0x36 }; -const struct WindowTemplate sUnusedWindowTemplate1 = +static const struct WindowTemplate sUnusedWindowTemplate1 = { .bg = 1, .tilemapLeft = 1, @@ -94,7 +94,7 @@ const struct WindowTemplate sUnusedWindowTemplate1 = .baseBlock = 0x44 }; -const struct WindowTemplate sUnusedWindowTemplate2 = +static const struct WindowTemplate sUnusedWindowTemplate2 = { .bg = 1, .tilemapLeft = 13, @@ -105,7 +105,7 @@ const struct WindowTemplate sUnusedWindowTemplate2 = .baseBlock = 0x44 }; -const LoopedTask sPartyConditionLoopedTaskFuncs[] = +static const LoopedTask sPartyConditionLoopedTaskFuncs[] = { [PARTY_CONDITION_FUNC_NONE] = NULL, [PARTY_CONDITION_FUNC_SLIDE_MON_IN] = LoopedTask_TransitionMons, @@ -132,26 +132,26 @@ struct Pokenav7Struct u8 listIndexWindowId; u8 unusedWindowId1; u8 unusedWindowId2; - struct MonMarkingsMenu monMarks; + struct MonMarkingsMenu marksMenu; struct Sprite *monMarksSprite; struct Sprite *conditionSparkleSprites[MAX_CONDITION_SPARKLES]; u8 windowModeState; - u8 filler2[0x38ac - 0x2909]; + u8 filler2[0xFA3]; }; extern s8 GetMonMarkIndex(void); // This function's declaration here is s8 vs. u8 in pokenav_conditions_1.c -u32 LoopedTask_OpenPartyConditionGraph(s32 state); -u32 GetPartyConditionLoopedTaskActive(void); -void CreateConditionMonPic(u8 var); -void CreateMonMarkingsOrPokeballIndicators(void); -void CopyUnusedConditionWindowsToVram(void); -bool32 UpdateConditionGraphWindows(u8 a0, u16 a1, bool8 a2); -void sub_81CEE44(void); -void DoConditionGraphTransition(void); -void sub_81CEEC8(void); -void sub_81CEE68(void); -void ToggleBg2(bool8 showBg); +static u32 LoopedTask_OpenPartyConditionGraph(s32 state); +static u32 GetPartyConditionLoopedTaskActive(void); +static void CreateConditionMonPic(u8 var); +static void CreateMonMarkingsOrPokeballIndicators(void); +static void CopyUnusedConditionWindowsToVram(void); +static bool32 UpdateConditionGraphWindows(u8 a0, u16 a1, bool8 a2); +static void sub_81CEE44(void); +static void DoConditionGraphTransition(void); +static void sub_81CEEC8(void); +static void sub_81CEE68(void); +static void ToggleGraphData(bool8 showBg); // code bool32 OpenPartyConditionMenu(void) @@ -181,13 +181,13 @@ u32 IsPartyConditionLoopedTaskActive(void) return structPtr->callback(); } -u32 GetPartyConditionLoopedTaskActive(void) +static u32 GetPartyConditionLoopedTaskActive(void) { struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); return IsLoopedTaskActive(structPtr->loopedTaskId); } -u32 LoopedTask_OpenPartyConditionGraph(s32 state) +static u32 LoopedTask_OpenPartyConditionGraph(s32 state) { struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); @@ -213,7 +213,7 @@ u32 LoopedTask_OpenPartyConditionGraph(s32 state) case 2: if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - DecompressAndCopyTileDataToVram(2, gUnknown_08623228, 0, 0, 0); + DecompressAndCopyTileDataToVram(2, sUnknown_08623228, 0, 0, 0); return LT_INC_AND_PAUSE; case 3: if (FreeTempTileDataBuffersIfPossible()) @@ -320,14 +320,14 @@ u32 LoopedTask_OpenPartyConditionGraph(s32 state) return LT_PAUSE; return LT_INC_AND_PAUSE; case 19: - ToggleBg2(TRUE); + ToggleGraphData(TRUE); return LT_INC_AND_PAUSE; case 20: - if (!TryUpdateConditionMonTransitionOn(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) + if (!ConditionGraph_UpdateMonEnter(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) { ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); if (IsConditionMenuSearchMode() == TRUE || GetConditionGraphCurrentMonIndex() != GetMonListCount()) - CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetMonSheen()); + CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles()); return LT_FINISH; } @@ -337,7 +337,7 @@ u32 LoopedTask_OpenPartyConditionGraph(s32 state) return LT_FINISH; } -u32 LoopedTask_ExitPartyConditionMenu(s32 state) +static u32 LoopedTask_ExitPartyConditionMenu(s32 state) { struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); @@ -348,9 +348,9 @@ u32 LoopedTask_ExitPartyConditionMenu(s32 state) DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); return LT_INC_AND_CONTINUE; case 1: - if (TryUpdateConditionMonTransitionOff(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) + if (ConditionGraph_UpdateMonExit(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) return 2; - ToggleBg2(FALSE); + ToggleGraphData(FALSE); return LT_INC_AND_CONTINUE; case 2: PokenavFadeScreen(0); @@ -370,10 +370,10 @@ u32 LoopedTask_ExitPartyConditionMenu(s32 state) return LT_FINISH; } -u32 LoopedTask_TransitionMons(s32 state) +static u32 LoopedTask_TransitionMons(s32 state) { struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); - struct ConditionGraph *unkPtr = GetConditionGraphDataPtr(); + struct ConditionGraph *graph = GetConditionGraphDataPtr(); switch (state) { @@ -388,7 +388,7 @@ u32 LoopedTask_TransitionMons(s32 state) DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); return LT_INC_AND_CONTINUE; case 3: - TransitionConditionGraph(unkPtr); + TransitionConditionGraph(graph); return LT_INC_AND_CONTINUE; case 4: if (!MoveConditionMonOffscreen(&structPtr->monTransitionX)) @@ -411,14 +411,14 @@ u32 LoopedTask_TransitionMons(s32 state) return LT_INC_AND_CONTINUE; return LT_PAUSE; case 9: - unkPtr = GetConditionGraphDataPtr(); - if (!TryUpdateConditionMonTransitionOn(unkPtr, &structPtr->monTransitionX)) + graph = GetConditionGraphDataPtr(); + if (!ConditionGraph_UpdateMonEnter(graph, &structPtr->monTransitionX)) { ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); if (IsConditionMenuSearchMode() != TRUE && GetConditionGraphCurrentMonIndex() == GetMonListCount()) return LT_INC_AND_CONTINUE; - CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetMonSheen()); + CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles()); return LT_INC_AND_CONTINUE; } return LT_PAUSE; @@ -427,7 +427,7 @@ u32 LoopedTask_TransitionMons(s32 state) return LT_FINISH; } -u32 LoopedTask_MoveCursorNoTransition(s32 state) +static u32 LoopedTask_MoveCursorNoTransition(s32 state) { struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); @@ -459,10 +459,10 @@ u32 LoopedTask_MoveCursorNoTransition(s32 state) return LT_INC_AND_CONTINUE; return LT_PAUSE; case 8: - if (!TryUpdateConditionMonTransitionOn(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) + if (!ConditionGraph_UpdateMonEnter(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) { ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); - CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetMonSheen()); + CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles()); return LT_INC_AND_CONTINUE; } return LT_PAUSE; @@ -471,7 +471,7 @@ u32 LoopedTask_MoveCursorNoTransition(s32 state) return LT_FINISH; } -u32 LoopedTask_SlideMonOut(s32 state) +static u32 LoopedTask_SlideMonOut(s32 state) { struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); @@ -488,7 +488,7 @@ u32 LoopedTask_SlideMonOut(s32 state) DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); return LT_INC_AND_CONTINUE; case 3: - if (!TryUpdateConditionMonTransitionOff(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) + if (!ConditionGraph_UpdateMonExit(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) return LT_INC_AND_CONTINUE; return LT_PAUSE; case 4: @@ -509,7 +509,7 @@ u32 LoopedTask_SlideMonOut(s32 state) return LT_FINISH; } -u32 LoopedTask_OpenMonMarkingsWindow(s32 state) +static u32 LoopedTask_OpenMonMarkingsWindow(s32 state) { switch (state) { @@ -528,7 +528,7 @@ u32 LoopedTask_OpenMonMarkingsWindow(s32 state) return LT_FINISH; } -u32 LoopedTask_CloseMonMarkingsWindow(s32 state) +static u32 LoopedTask_CloseMonMarkingsWindow(s32 state) { switch (state) { @@ -555,7 +555,7 @@ static u8 *UnusedPrintNumberString(u8 *dst, u16 num) return txtPtr; } -bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode) +static bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode) { u8 text[32]; const u8 *str; @@ -571,23 +571,23 @@ bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode) case 1: if (GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1 || IsConditionMenuSearchMode() == TRUE) { - str = GetConditionMonNameBuffer(bufferIndex); + str = GetConditionMonNameText(bufferIndex); AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 1, 0, NULL); } break; case 2: if (IsConditionMenuSearchMode() == TRUE) { - str = GetConditionMonLocationBuffer(bufferIndex); + str = GetConditionMonLocationText(bufferIndex); AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 17, 0, NULL); text[0] = EXT_CTRL_CODE_BEGIN; text[1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; text[2] = TEXT_COLOR_BLUE; text[3] = TEXT_COLOR_TRANSPARENT; text[4] = TEXT_COLOR_LIGHT_BLUE; - StringCopy(text + 5, gText_Number2); + StringCopy(&text[5], gText_Number2); AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 4, 1, 0, NULL); - ConvertIntToDecimalStringN(text + 5, GetConditionMonDataBuffer(), STR_CONV_MODE_RIGHT_ALIGN, 4); + ConvertIntToDecimalStringN(&text[5], GetConditionMonDataBuffer(), STR_CONV_MODE_RIGHT_ALIGN, 4); AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 28, 1, 0, NULL); } break; @@ -624,7 +624,7 @@ bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode) return FALSE; } -void CopyUnusedConditionWindowsToVram(void) +static void CopyUnusedConditionWindowsToVram(void) { struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); @@ -643,9 +643,9 @@ void sub_81CE964(struct Sprite *sprite) void HighlightCurrentPartyIndexPokeball(struct Sprite *sprite) { if (GetConditionGraphCurrentMonIndex() == GetMonListCount() - 1) - sprite->oam.paletteNum = IndexOfSpritePaletteTag(0x65); + sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_BALL); else - sprite->oam.paletteNum = IndexOfSpritePaletteTag(0x66); + sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_CANCEL); } void MonMarkingsCallback(struct Sprite *sprite) @@ -653,7 +653,7 @@ void MonMarkingsCallback(struct Sprite *sprite) StartSpriteAnim(sprite, TryGetMonMarkId()); } -void CreateMonMarkingsOrPokeballIndicators(void) +static void CreateMonMarkingsOrPokeballIndicators(void) { struct SpriteSheet sprSheets[4]; struct SpriteTemplate sprTemplate; @@ -666,17 +666,17 @@ void CreateMonMarkingsOrPokeballIndicators(void) LoadConditionSelectionIcons(sprSheets, &sprTemplate, sprPals); if (IsConditionMenuSearchMode() == TRUE) { - structPtr->monMarks.baseTileTag = 0x6A; - structPtr->monMarks.basePaletteTag = 0x6A; - InitMonMarkingsMenu(&structPtr->monMarks); + structPtr->marksMenu.baseTileTag = TAG_CONDITION_MARKINGS_MENU; + structPtr->marksMenu.basePaletteTag = TAG_CONDITION_MARKINGS_MENU; + InitMonMarkingsMenu(&structPtr->marksMenu); BufferMonMarkingsMenuTiles(); - sprite = CreateMonMarkingAllCombosSprite(0x69, 0x69, sConditionGraphMonMarkingsPal); + sprite = CreateMonMarkingAllCombosSprite(TAG_CONDITION_MON_MARKINGS, TAG_CONDITION_MON_MARKINGS, sConditionGraphMonMarkingsPal); sprite->oam.priority = 3; sprite->x = 192; sprite->y = 32; sprite->callback = MonMarkingsCallback; structPtr->monMarksSprite = sprite; - PokenavFillPalette(IndexOfSpritePaletteTag(0x69), 0); + PokenavFillPalette(IndexOfSpritePaletteTag(TAG_CONDITION_MON_MARKINGS), 0); } else { @@ -698,7 +698,7 @@ void CreateMonMarkingsOrPokeballIndicators(void) } } - sprTemplate.tileTag = 0x67; + sprTemplate.tileTag = TAG_CONDITION_BALL_PLACEHOLDER; sprTemplate.callback = SpriteCallbackDummy; for (; i < 6; i++) { @@ -714,7 +714,7 @@ void CreateMonMarkingsOrPokeballIndicators(void) } } - sprTemplate.tileTag = 0x66; + sprTemplate.tileTag = TAG_CONDITION_CANCEL; sprTemplate.callback = HighlightCurrentPartyIndexPokeball; spriteId = CreateSprite(&sprTemplate, 222, (i * 20) + 8, 0); if (spriteId != MAX_SPRITES) @@ -742,28 +742,28 @@ void sub_81CEBF4(struct Pokenav7Struct *structPtr) if (IsConditionMenuSearchMode() == TRUE) { DestroySprite(structPtr->monMarksSprite); - FreeSpriteTilesByTag(0x6A); - FreeSpriteTilesByTag(0x69); - FreeSpritePaletteByTag(0x6A); - FreeSpritePaletteByTag(0x69); + FreeSpriteTilesByTag(TAG_CONDITION_MARKINGS_MENU); + FreeSpriteTilesByTag(TAG_CONDITION_MON_MARKINGS); + FreeSpritePaletteByTag(TAG_CONDITION_MARKINGS_MENU); + FreeSpritePaletteByTag(TAG_CONDITION_MON_MARKINGS); } else { for (i = 0; i < 7; i++) DestroySprite(&gSprites[structPtr->partyPokeballSpriteIds[i]]); - FreeSpriteTilesByTag(0x65); - FreeSpriteTilesByTag(0x66); - FreeSpriteTilesByTag(0x67); - FreeSpritePaletteByTag(0x65); - FreeSpritePaletteByTag(0x66); + FreeSpriteTilesByTag(TAG_CONDITION_BALL); + FreeSpriteTilesByTag(TAG_CONDITION_CANCEL); + FreeSpriteTilesByTag(TAG_CONDITION_BALL_PLACEHOLDER); + FreeSpritePaletteByTag(TAG_CONDITION_BALL); + FreeSpritePaletteByTag(TAG_CONDITION_CANCEL); } if (structPtr->monPicSpriteId != SPRITE_NONE) { DestroySprite(&gSprites[structPtr->monPicSpriteId]); - FreeSpriteTilesByTag(0x64); - FreeSpritePaletteByTag(0x64); + FreeSpriteTilesByTag(TAG_CONDITION_MON); + FreeSpritePaletteByTag(TAG_CONDITION_MON); } } @@ -795,7 +795,7 @@ void MonPicGfxSpriteCallback(struct Sprite *sprite) sprite->x = structPtr->monTransitionX + 38; } -void CreateConditionMonPic(u8 id) +static void CreateConditionMonPic(u8 id) { struct SpriteTemplate sprTemplate; struct SpriteSheet sprSheet; @@ -814,15 +814,15 @@ void CreateConditionMonPic(u8 id) structPtr->monPicSpriteId = spriteId; if (spriteId == MAX_SPRITES) { - FreeSpriteTilesByTag(0x64); - FreeSpritePaletteByTag(0x64); + FreeSpriteTilesByTag(TAG_CONDITION_MON); + FreeSpritePaletteByTag(TAG_CONDITION_MON); structPtr->monPicSpriteId = SPRITE_NONE; } else { structPtr->monPicSpriteId = spriteId; gSprites[structPtr->monPicSpriteId].callback = MonPicGfxSpriteCallback; - structPtr->unk181C = (void*)(VRAM) + 0x10000 + (structPtr->monGfxTileStart * 32); + structPtr->unk181C = (void*)VRAM + BG_VRAM_SIZE + (structPtr->monGfxTileStart * 32); structPtr->monPalIndex = (structPtr->monPalIndex * 16) + 0x100; } } @@ -833,22 +833,22 @@ void CreateConditionMonPic(u8 id) } } -void sub_81CEE44(void) +static void sub_81CEE44(void) { - struct ConditionGraph *unk = GetConditionGraphDataPtr(); + struct ConditionGraph *graph = GetConditionGraphDataPtr(); LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); - sub_81D2108(unk); + sub_81D2108(graph); ScanlineEffect_InitHBlankDmaTransfer(); } -void sub_81CEE68(void) +static void sub_81CEE68(void) { SetPokenavVBlankCallback(); } -void ToggleBg2(bool8 showBg) +static void ToggleGraphData(bool8 showBg) { if (showBg) ShowBg(2); @@ -856,17 +856,17 @@ void ToggleBg2(bool8 showBg) HideBg(2); } -void DoConditionGraphTransition(void) +static void DoConditionGraphTransition(void) { struct ConditionGraph *conditionPtr = GetConditionGraphDataPtr(); u8 id = GetMonMarkIndex(); - gUnknown_030012BC = id; + sUnknown_030012BC = id; sub_81D1F84(conditionPtr, conditionPtr->unk14[3], conditionPtr->unk14[id]); TransitionConditionGraph(conditionPtr); } -void sub_81CEEC8(void) +static void sub_81CEEC8(void) { struct ConditionGraph *conditionPtr = GetConditionGraphDataPtr(); @@ -879,7 +879,7 @@ u8 GetMonMarkingsData(void) struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); if (IsConditionMenuSearchMode() == 1) - return structPtr->monMarks.markings; + return structPtr->marksMenu.markings; else return 0; } diff --git a/src/pokenav_menu_handler_2.c b/src/pokenav_menu_handler_2.c index bcfe94cb7..4724eab0e 100644 --- a/src/pokenav_menu_handler_2.c +++ b/src/pokenav_menu_handler_2.c @@ -314,10 +314,10 @@ static const struct SpriteTemplate sMatchCallBlueLightSpriteTemplate = static const struct ScanlineEffectParams sPokenavMainMenuScanlineEffectParams = { - (void *)REG_ADDR_WIN0H, - ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, - 1, - 0 + ®_WIN0H, + ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, + 1, + 0 }; static bool32 PlayerHasTrainerRematches(void) diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 9f8918ba2..a8b01b827 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -57,14 +57,14 @@ struct UsePokeblockSession u8 mainState; u8 unused1; u8 timer; - u8 statId; + u8 condition; u8 numEnhancements; u8 unused2; bool8 monInTopHalf; - u8 conditionsBeforeBlock[FLAVOR_COUNT]; - u8 conditionsAfterBlock[FLAVOR_COUNT]; - u8 enhancements[FLAVOR_COUNT]; - s16 pokeblockStatBoosts[FLAVOR_COUNT]; + u8 conditionsBeforeBlock[CONDITION_COUNT]; + u8 conditionsAfterBlock[CONDITION_COUNT]; + u8 enhancements[CONDITION_COUNT]; + s16 pokeblockStatBoosts[CONDITION_COUNT]; u8 numSelections; // num in party + 1 (for Cancel) u8 curSelection; bool8 (*loadNewSelection)(void); @@ -142,7 +142,7 @@ static void LoadAndCreateUpDownSprites(void); static void CalculateNumAdditionalSparkles(u8); static void PrintFirstEnhancement(void); static bool8 TryPrintNextEnhancement(void); -static void BufferEnhancedStatText(u8 *, u8, s16); +static void BufferEnhancedText(u8 *, u8, s16); static void PrintMenuWindowText(const u8 *); static void CalculatePokeblockEffectiveness(struct Pokeblock *, struct Pokemon *); static void SpriteCB_UpDown(struct Sprite *); @@ -178,22 +178,22 @@ static const u32 sGraphData_Tilemap[] = INCBIN_U32("graphics/pokeblock/use_scree // The condition/flavors aren't listed in their normal order in this file, they're listed as shown on the graph going counter-clockwise // Normally they would go Cool/Spicy, Beauty/Dry, Cute/Sweet, Smart/Bitter, Tough/Sour (also graph order, but clockwise) -static const u32 sMonDataConditions[FLAVOR_COUNT] = +static const u32 sConditionToMonData[CONDITION_COUNT] = { - MON_DATA_COOL, - MON_DATA_TOUGH, - MON_DATA_SMART, - MON_DATA_CUTE, - MON_DATA_BEAUTY + [CONDITION_COOL] = MON_DATA_COOL, + [CONDITION_TOUGH] = MON_DATA_TOUGH, + [CONDITION_SMART] = MON_DATA_SMART, + [CONDITION_CUTE] = MON_DATA_CUTE, + [CONDITION_BEAUTY] = MON_DATA_BEAUTY }; -static const u8 sFlavors[FLAVOR_COUNT] = +static const u8 sConditionToFlavor[CONDITION_COUNT] = { - FLAVOR_SPICY, - FLAVOR_SOUR, - FLAVOR_BITTER, - FLAVOR_SWEET, - FLAVOR_DRY + [CONDITION_COOL] = FLAVOR_SPICY, + [CONDITION_TOUGH] = FLAVOR_SOUR, + [CONDITION_SMART] = FLAVOR_BITTER, + [CONDITION_CUTE] = FLAVOR_SWEET, + [CONDITION_BEAUTY] = FLAVOR_DRY }; static const u8 sNatureTextColors[] = @@ -286,13 +286,13 @@ static const struct WindowTemplate sUsePokeblockYesNoWinTemplate = .baseBlock = 0x83 }; -static const u8 *const sContestStatNames[] = +static const u8 *const sConditionNames[CONDITION_COUNT] = { - gText_Coolness, - gText_Toughness, - gText_Smartness, - gText_Cuteness, - gText_Beauty3 + [CONDITION_COOL] = gText_Coolness, + [CONDITION_TOUGH] = gText_Toughness, + [CONDITION_SMART] = gText_Smartness, + [CONDITION_CUTE] = gText_Cuteness, + [CONDITION_BEAUTY] = gText_Beauty3 }; static const struct SpriteSheet sSpriteSheet_UpDown = @@ -305,13 +305,13 @@ static const struct SpritePalette sSpritePalette_UpDown = gUsePokeblockUpDown_Pal, TAG_UP_DOWN }; -static const s16 sUpDownCoordsOnGraph[FLAVOR_COUNT][2] = +static const s16 sUpDownCoordsOnGraph[CONDITION_COUNT][2] = { - {156, 36}, - {117, 59}, - {117, 118}, - {197, 118}, - {197, 59} + [CONDITION_COOL] = {156, 36}, + [CONDITION_TOUGH] = {117, 59}, + [CONDITION_SMART] = {117, 118}, + [CONDITION_CUTE] = {197, 118}, + [CONDITION_BEAUTY] = {197, 59} }; static const struct OamData sOam_UpDown = @@ -487,7 +487,7 @@ static void LoadUsePokeblockMenu(void) { case 0: sMenu->curMonSpriteId = SPRITE_NONE; - InitConditionGraphData(&sMenu->graph); + ConditionGraph_Init(&sMenu->graph); sInfo->mainState++; break; case 1: @@ -537,7 +537,7 @@ static void LoadUsePokeblockMenu(void) sInfo->mainState++; break; case 11: - sub_81D2754(sMenu->graph.stat[0], sMenu->graph.unk14[0]); + sub_81D2754(sMenu->graph.conditions[0], sMenu->graph.unk14[0]); InitConditionGraphState(&sMenu->graph); sInfo->mainState++; break; @@ -767,8 +767,6 @@ static void ShowUsePokeblockMenuForResults(void) static void ShowPokeblockResults(void) { - u8 var; - switch (sInfo->mainState) { case 0: @@ -789,8 +787,7 @@ static void ShowPokeblockResults(void) sInfo->mainState++; break; case 3: - var = TransitionConditionGraph(&sMenu->graph); - if (!var) + if (!TransitionConditionGraph(&sMenu->graph)) { CalculateNumAdditionalSparkles(GetPartyIdFromSelectionId(sMenu->info.curSelection)); if (sMenu->info.curSelection != sMenu->info.numSelections - 1) @@ -906,16 +903,16 @@ static void PrintFirstEnhancement(void) DrawTextBorderOuter(WIN_TEXT, 151, 14); FillWindowPixelBuffer(WIN_TEXT, 17); - for (sInfo->statId = 0; sInfo->statId < FLAVOR_COUNT; sInfo->statId++) + for (sInfo->condition = 0; sInfo->condition < CONDITION_COUNT; sInfo->condition++) { - if (sInfo->enhancements[sInfo->statId] != 0) + if (sInfo->enhancements[sInfo->condition] != 0) break; } - if (sInfo->statId < FLAVOR_COUNT) - BufferEnhancedStatText(gStringVar4, sInfo->statId, sInfo->enhancements[sInfo->statId]); + if (sInfo->condition < CONDITION_COUNT) + BufferEnhancedText(gStringVar4, sInfo->condition, sInfo->enhancements[sInfo->condition]); else - BufferEnhancedStatText(gStringVar4, sInfo->statId, 0); + BufferEnhancedText(gStringVar4, sInfo->condition, 0); PrintMenuWindowText(gStringVar4); PutWindowTilemap(WIN_TEXT); @@ -928,20 +925,20 @@ static bool8 TryPrintNextEnhancement(void) while (1) { - sInfo->statId++; - if (sInfo->statId < FLAVOR_COUNT) + sInfo->condition++; + if (sInfo->condition < CONDITION_COUNT) { - if (sInfo->enhancements[sInfo->statId] != 0) + if (sInfo->enhancements[sInfo->condition] != 0) break; } else { - sInfo->statId = FLAVOR_COUNT; + sInfo->condition = CONDITION_COUNT; return FALSE; } } - BufferEnhancedStatText(gStringVar4, sInfo->statId, sInfo->enhancements[sInfo->statId]); + BufferEnhancedText(gStringVar4, sInfo->condition, sInfo->enhancements[sInfo->condition]); PrintMenuWindowText(gStringVar4); CopyWindowToVram(WIN_TEXT, COPYWIN_GFX); @@ -969,7 +966,7 @@ static void PrintMenuWindowText(const u8 *message) AddTextPrinterParameterized(WIN_TEXT, FONT_NORMAL, gStringVar4, 0, 1, 0, NULL); } -static void BufferEnhancedStatText(u8 *dest, u8 statId, s16 enhancement) +static void BufferEnhancedText(u8 *dest, u8 condition, s16 enhancement) { switch (enhancement) { @@ -979,7 +976,7 @@ static void BufferEnhancedStatText(u8 *dest, u8 statId, s16 enhancement) case -32768 ... -1: // if < 0 if (enhancement) dest[(u16)enhancement] += 0; // something you can't imagine - StringCopy(dest, sContestStatNames[statId]); + StringCopy(dest, sConditionNames[condition]); StringAppend(dest, gText_WasEnhanced); break; case 0: @@ -992,36 +989,36 @@ static void GetMonConditions(struct Pokemon *mon, u8 *data) { u16 i; - for (i = 0; i < FLAVOR_COUNT; i++) - data[i] = GetMonData(mon, sMonDataConditions[i]); + for (i = 0; i < CONDITION_COUNT; i++) + data[i] = GetMonData(mon, sConditionToMonData[i]); } static void AddPokeblockToConditions(struct Pokeblock *pokeblock, struct Pokemon *mon) { u16 i; - s16 cstat; + s16 stat; u8 data; - if (GetMonData(mon, MON_DATA_SHEEN) != 255) + if (GetMonData(mon, MON_DATA_SHEEN) != MAX_SHEEN) { CalculatePokeblockEffectiveness(pokeblock, mon); - for (i = 0; i < FLAVOR_COUNT; i++) + for (i = 0; i < CONDITION_COUNT; i++) { - data = GetMonData(mon, sMonDataConditions[i]); - cstat = data + sInfo->pokeblockStatBoosts[i]; - if (cstat < 0) - cstat = 0; - if (cstat > 255) - cstat = 255; - data = cstat; - SetMonData(mon, sMonDataConditions[i], &data); + data = GetMonData(mon, sConditionToMonData[i]); + stat = data + sInfo->pokeblockStatBoosts[i]; + if (stat < 0) + stat = 0; + if (stat > MAX_CONDITION) + stat = MAX_CONDITION; + data = stat; + SetMonData(mon, sConditionToMonData[i], &data); } - cstat = (u8)(GetMonData(mon, MON_DATA_SHEEN)) + pokeblock->feel; - if (cstat > 255) - cstat = 255; + stat = (u8)(GetMonData(mon, MON_DATA_SHEEN)) + pokeblock->feel; + if (stat > MAX_SHEEN) + stat = MAX_SHEEN; - data = cstat; + data = stat; SetMonData(mon, MON_DATA_SHEEN, &data); } } @@ -1035,19 +1032,19 @@ static void CalculateConditionEnhancements(void) GetMonConditions(mon, sInfo->conditionsBeforeBlock); AddPokeblockToConditions(sInfo->pokeblock, mon); GetMonConditions(mon, sInfo->conditionsAfterBlock); - for (i = 0; i < FLAVOR_COUNT; i++) + for (i = 0; i < CONDITION_COUNT; i++) sInfo->enhancements[i] = sInfo->conditionsAfterBlock[i] - sInfo->conditionsBeforeBlock[i]; } static void CalculatePokeblockEffectiveness(struct Pokeblock *pokeblock, struct Pokemon *mon) { - s8 i, direction, taste; + s8 i, direction, flavor; - sInfo->pokeblockStatBoosts[0] = pokeblock->spicy; - sInfo->pokeblockStatBoosts[1] = pokeblock->sour; - sInfo->pokeblockStatBoosts[2] = pokeblock->bitter; - sInfo->pokeblockStatBoosts[3] = pokeblock->sweet; - sInfo->pokeblockStatBoosts[4] = pokeblock->dry; + sInfo->pokeblockStatBoosts[CONDITION_COOL] = pokeblock->spicy; + sInfo->pokeblockStatBoosts[CONDITION_TOUGH] = pokeblock->sour; + sInfo->pokeblockStatBoosts[CONDITION_SMART] = pokeblock->bitter; + sInfo->pokeblockStatBoosts[CONDITION_CUTE] = pokeblock->sweet; + sInfo->pokeblockStatBoosts[CONDITION_BEAUTY] = pokeblock->dry; if (gPokeblockGain > 0) direction = 1; @@ -1056,7 +1053,7 @@ static void CalculatePokeblockEffectiveness(struct Pokeblock *pokeblock, struct else return; - for (i = 0; i < FLAVOR_COUNT; i++) + for (i = 0; i < CONDITION_COUNT; i++) { s16 amount = sInfo->pokeblockStatBoosts[i]; s8 boost = amount / 10; @@ -1064,9 +1061,9 @@ static void CalculatePokeblockEffectiveness(struct Pokeblock *pokeblock, struct if (amount % 10 >= 5) // round to the nearest boost++; - taste = GetMonFlavorRelation(mon, sFlavors[i]); - if (taste == direction) - sInfo->pokeblockStatBoosts[i] += boost * taste; + flavor = GetMonFlavorRelation(mon, sConditionToFlavor[i]); + if (flavor == direction) + sInfo->pokeblockStatBoosts[i] += boost * flavor; } } @@ -1075,7 +1072,7 @@ static bool8 IsSheenMaxed(void) if (GetBoxOrPartyMonData(sMenu->party[sMenu->info.curSelection].boxId, sMenu->party[sMenu->info.curSelection].monId, MON_DATA_SHEEN, - NULL) == 255) + NULL) == MAX_SHEEN) return TRUE; else return FALSE; @@ -1125,7 +1122,7 @@ static void LoadAndCreateUpDownSprites(void) LoadSpritePalette(&sSpritePalette_UpDown); sInfo->numEnhancements = 0; - for (i = 0; i < FLAVOR_COUNT; i++) + for (i = 0; i < CONDITION_COUNT; i++) { if (sInfo->enhancements[i] != 0) { @@ -1487,7 +1484,7 @@ static bool8 LoadNewSelection_CancelToMon(void) sMenu->info.helperState++; break; case 2: - if (!TryUpdateConditionMonTransitionOn(&sMenu->graph, &sMenu->curMonXOffset)) + if (!ConditionGraph_UpdateMonEnter(&sMenu->graph, &sMenu->curMonXOffset)) { // Load the new adjacent pokemon (not the one being shown) LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId); @@ -1514,7 +1511,7 @@ static bool8 LoadNewSelection_MonToCancel(void) switch (sMenu->info.helperState) { case 0: - if (!TryUpdateConditionMonTransitionOff(&sMenu->graph, &sMenu->curMonXOffset)) + if (!ConditionGraph_UpdateMonExit(&sMenu->graph, &sMenu->curMonXOffset)) sMenu->info.helperState++; break; case 1: @@ -1550,7 +1547,7 @@ static bool8 LoadNewSelection_MonToMon(void) sMenu->info.helperState++; break; case 2: - if (!TryUpdateConditionMonTransitionOn(&sMenu->graph, &sMenu->curMonXOffset)) + if (!ConditionGraph_UpdateMonEnter(&sMenu->graph, &sMenu->curMonXOffset)) { // Load the new adjacent pokemon (not the one being shown) LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId); @@ -1599,10 +1596,7 @@ static void SpriteCB_SelectionIconCancel(struct Sprite *sprite) static void CalculateNumAdditionalSparkles(u8 monIndex) { u8 sheen = GetMonData(&gPlayerParty[monIndex], MON_DATA_SHEEN); - - sMenu->numSparkles[sMenu->curLoadId] = (sheen != 255) - ? sheen / (255 / (MAX_CONDITION_SPARKLES - 1) + 1) - : MAX_CONDITION_SPARKLES - 1; + sMenu->numSparkles[sMenu->curLoadId] = GET_NUM_CONDITION_SPARKLES(sheen); } static void LoadConditionGfx(void) From 45908873591abb9fcb87a68721690c9a35559139 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 10 Nov 2021 17:01:21 -0500 Subject: [PATCH 03/19] Clean up some register constant use --- include/gba/io_reg.h | 1 + src/battle_anim_effects_2.c | 4 ++-- src/battle_anim_ghost.c | 4 ++-- src/battle_anim_water.c | 2 +- src/battle_dome.c | 2 +- src/battle_main.c | 4 ++-- src/field_screen_effect.c | 2 +- src/intro.c | 4 ++-- src/libisagbprn.c | 10 +++++----- src/librfu_intr.c | 4 ++-- src/multiboot.c | 18 +++++++++--------- src/overworld.c | 2 +- src/rayquaza_scene.c | 2 +- 13 files changed, 30 insertions(+), 29 deletions(-) diff --git a/include/gba/io_reg.h b/include/gba/io_reg.h index 1daa99e1d..148ce31db 100644 --- a/include/gba/io_reg.h +++ b/include/gba/io_reg.h @@ -482,6 +482,7 @@ #define REG_SIODATA32 (*(vu32 *)REG_ADDR_SIODATA32) #define REG_SIOMLT_SEND (*(vu16 *)REG_ADDR_SIOMLT_SEND) #define REG_SIOMLT_RECV (*(vu64 *)REG_ADDR_SIOMLT_RECV) +#define REG_SIOMULTI(n) (*(vu16 *)(REG_ADDR_SIOMULTI0 + (n) * 2)) #define REG_SIOMULTI0 (*(vu16 *)REG_ADDR_SIOMULTI0) #define REG_SIOMULTI1 (*(vu16 *)REG_ADDR_SIOMULTI1) #define REG_SIOMULTI2 (*(vu16 *)REG_ADDR_SIOMULTI2) diff --git a/src/battle_anim_effects_2.c b/src/battle_anim_effects_2.c index 27149873d..5944bc511 100755 --- a/src/battle_anim_effects_2.c +++ b/src/battle_anim_effects_2.c @@ -2394,12 +2394,12 @@ void AnimTask_SketchDrawMon(u8 taskId) if (GetBattlerSpriteBGPriorityRank(gBattleAnimTarget) == 1) { task->data[6] = gBattle_BG1_X; - params.dmaDest = (u16 *)REG_ADDR_BG1HOFS; + params.dmaDest = ®_BG1HOFS; } else { task->data[6] = gBattle_BG2_X; - params.dmaDest = (u16 *)REG_ADDR_BG2HOFS; + params.dmaDest = ®_BG2HOFS; } for (i = task->data[0] - 0x40; i <= task->data[0]; i++) diff --git a/src/battle_anim_ghost.c b/src/battle_anim_ghost.c index 03a003c60..60e943adf 100644 --- a/src/battle_anim_ghost.c +++ b/src/battle_anim_ghost.c @@ -653,9 +653,9 @@ static void AnimTask_SpiteTargetShadow_Step1(u8 taskId) startLine = 0; if (position == 1) - task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, 4, 1); + task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, SCANLINE_EFFECT_REG_BG1HOFS, 1); else - task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, 8, 1); + task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, SCANLINE_EFFECT_REG_BG2HOFS, 1); task->data[15]++; break; diff --git a/src/battle_anim_water.c b/src/battle_anim_water.c index 50918a24e..44df78421 100644 --- a/src/battle_anim_water.c +++ b/src/battle_anim_water.c @@ -960,7 +960,7 @@ static void AnimTask_SurfWaveScanlineEffect(u8 taskId) else gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[2]; - params.dmaDest = (vu16 *)REG_ADDR_BLDALPHA; + params.dmaDest = ®_BLDALPHA; params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT; params.initState = 1; params.unused9 = 0; diff --git a/src/battle_dome.c b/src/battle_dome.c index 45df83c7c..1b067924f 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -870,7 +870,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] = static const struct ScanlineEffectParams sTourneyTreeScanlineEffectParams = { - .dmaDest = (void *)REG_ADDR_BG3CNT, + .dmaDest = ®_BG3CNT, .dmaControl = SCANLINE_EFFECT_DMACNT_16BIT, .initState = 1, }; diff --git a/src/battle_main.c b/src/battle_main.c index 8079546d4..85e1e1796 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -249,13 +249,13 @@ u8 gBattleControllerData[MAX_BATTLERS_COUNT]; // Used by the battle controllers static const struct ScanlineEffectParams sIntroScanlineParams16Bit = { - (void *)REG_ADDR_BG3HOFS, SCANLINE_EFFECT_DMACNT_16BIT, 1 + ®_BG3HOFS, SCANLINE_EFFECT_DMACNT_16BIT, 1 }; // unused static const struct ScanlineEffectParams sIntroScanlineParams32Bit = { - (void *)REG_ADDR_BG3HOFS, SCANLINE_EFFECT_DMACNT_32BIT, 1 + ®_BG3HOFS, SCANLINE_EFFECT_DMACNT_32BIT, 1 }; const struct SpriteTemplate gUnusedBattleInitSprite = diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index c27ec6c4c..0cf5e4145 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -56,7 +56,7 @@ const s32 gMaxFlashLevel = ARRAY_COUNT(sFlashLevelPixelRadii) - 1; const struct ScanlineEffectParams sFlashEffectParams = { - (void *)REG_ADDR_WIN0H, + ®_WIN0H, ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, 1 }; diff --git a/src/intro.c b/src/intro.c index 5cf99c97e..024706f6c 100644 --- a/src/intro.c +++ b/src/intro.c @@ -1848,7 +1848,7 @@ static void Task_Scene3_StartGroudon(u8 taskId) { gTasks[taskId].tState = 0; gTasks[taskId].func = Task_Scene3_Groudon; - ScanlineEffect_InitWave(0, 160, 4, 4, 1, 4, 0); + ScanlineEffect_InitWave(0, 160, 4, 4, 1, SCANLINE_EFFECT_REG_BG1HOFS, 0); } #define tScreenX data[1] @@ -2058,7 +2058,7 @@ static void Task_Scene3_LoadKyogre(u8 taskId) gTasks[taskId].tDelay = 16; gTasks[taskId].tZoom = 256; PanFadeAndZoomScreen(gTasks[taskId].tScreenX, gTasks[taskId].tScreenY, gTasks[taskId].tZoom, 0); - ScanlineEffect_InitWave(0, 0xA0, 4, 4, 1, 6, 0); + ScanlineEffect_InitWave(0, 0xA0, 4, 4, 1, SCANLINE_EFFECT_REG_BG1VOFS, 0); } static void Task_Scene3_Kyogre(u8 taskId) diff --git a/src/libisagbprn.c b/src/libisagbprn.c index e0e979e95..69c6986ae 100644 --- a/src/libisagbprn.c +++ b/src/libisagbprn.c @@ -31,7 +31,7 @@ void AGBPrintFlush1Block(void); void AGBPrintInit(void) { volatile struct AGBPrintStruct *pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; - u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT; + u16 *pWSCNT = ®_WAITCNT; u16 *pProtect = (u16 *)AGB_PRINT_PROTECT_ADDR; u16 nOldWSCNT = *pWSCNT; *pWSCNT = WSCNT_DATA; @@ -57,7 +57,7 @@ static void AGBPutcInternal(const char cChr) void AGBPutc(const char cChr) { - u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT; + u16 *pWSCNT = ®_WAITCNT; u16 nOldWSCNT = *pWSCNT; volatile struct AGBPrintStruct *pPrint; *pWSCNT = WSCNT_DATA; @@ -71,7 +71,7 @@ void AGBPutc(const char cChr) void AGBPrint(const char *pBuf) { volatile struct AGBPrintStruct *pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; - u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT; + u16 *pWSCNT = ®_WAITCNT; u16 nOldWSCNT = *pWSCNT; *pWSCNT = WSCNT_DATA; while (*pBuf) @@ -105,9 +105,9 @@ static void AGBPrintTransferDataInternal(u32 bAllData) pProtect = (u16 *)AGB_PRINT_PROTECT_ADDR; pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; lpfnFuncFlush = (LPFN_PRINT_FLUSH)AGB_PRINT_FLUSH_ADDR; - pIME = (u16 *)REG_ADDR_IME; + pIME = ®_IME; nIME = *pIME; - pWSCNT = (u16 *)REG_ADDR_WAITCNT; + pWSCNT = ®_WAITCNT; nOldWSCNT = *pWSCNT; *pIME = nIME & ~1; *pWSCNT = WSCNT_DATA; diff --git a/src/librfu_intr.c b/src/librfu_intr.c index 19ea60b06..d902b1c45 100644 --- a/src/librfu_intr.c +++ b/src/librfu_intr.c @@ -336,8 +336,8 @@ static u16 handshake_wait(u16 slot) static void STWI_set_timer_in_RAM(u8 count) { - vu16* regTMCNTL = (vu16*)(REG_ADDR_TMCNT_L + gSTWIStatus->timerSelect * 4); - vu16* regTMCNTH = (vu16*)(REG_ADDR_TMCNT_H + gSTWIStatus->timerSelect * 4); + vu16* regTMCNTL = ®_TMCNT_L(gSTWIStatus->timerSelect); + vu16* regTMCNTH = ®_TMCNT_H(gSTWIStatus->timerSelect); REG_IME = 0; switch (count) { diff --git a/src/multiboot.c b/src/multiboot.c index 19245b5b3..15b062ed6 100644 --- a/src/multiboot.c +++ b/src/multiboot.c @@ -90,7 +90,7 @@ output_burst: k = 0x0e; for (i = MULTIBOOT_NCHILD; i != 0; i--) { - if (*(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2) != 0xffff) + if (REG_SIOMULTI(i) != 0xffff) { break; } @@ -102,7 +102,7 @@ output_burst: for (i = MULTIBOOT_NCHILD; i != 0; i--) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); if (mp->client_bit & (1 << i)) { if (j != ((MULTIBOOT_CLIENT_INFO << 8) | (1 << i))) @@ -141,7 +141,7 @@ output_burst: mp->probe_target_bit = 0; for (i = MULTIBOOT_NCHILD; i != 0; i--) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); if ((j >> 8) == MULTIBOOT_CLIENT_INFO) { MultiBoot_required_data[i - 1] = j; @@ -166,7 +166,7 @@ output_burst: { if (mp->probe_target_bit & (1 << i)) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); if (j != MultiBoot_required_data[i - 1]) { mp->probe_target_bit ^= 1 << i; @@ -179,7 +179,7 @@ output_burst: k = 1; for (i = MULTIBOOT_NCHILD; i != 0; i--) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); mp->client_data[i - 1] = j; if (mp->probe_target_bit & (1 << i)) { @@ -214,7 +214,7 @@ output_burst: case 0xd1: for (i = MULTIBOOT_NCHILD; i != 0; i--) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); if (mp->probe_target_bit & (1 << i)) { if ((j >> 8) != MULTIBOOT_CLIENT_DLREADY) @@ -242,7 +242,7 @@ output_burst: { if (mp->probe_target_bit & (1 << i)) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); if ((j >> 8) != (MULTIBOOT_MASTER_START_PROBE + 1 - (mp->probe_count >> 1)) || ((j & 0xff) != (1 << i))) { @@ -391,7 +391,7 @@ static int MultiBootHandShake(struct MultiBootParam *mp) default: for (i = MULTIBOOT_NCHILD; i != 0; i--) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); if ((mp->client_bit & (1 << i)) && j != must_data) { @@ -413,7 +413,7 @@ static int MultiBootHandShake(struct MultiBootParam *mp) case 0xe8: for (i = MULTIBOOT_NCHILD; i != 0; i--) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); if ((mp->client_bit & (1 << i)) && j != must_data) { MultiBootInit(mp); diff --git a/src/overworld.c b/src/overworld.c index 9a5c41a7f..c9aa9ba57 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -313,7 +313,7 @@ static const struct BgTemplate sOverworldBgTemplates[] = static const struct ScanlineEffectParams sFlashEffectParams = { - (void *)REG_ADDR_WIN0H, + ®_WIN0H, ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, 1, 0, diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c index 51498fa1d..6525daa1e 100644 --- a/src/rayquaza_scene.c +++ b/src/rayquaza_scene.c @@ -490,7 +490,7 @@ static const struct SpriteTemplate sSpriteTemplate_DuoFightPre_KyogreDorsalFin = static const struct ScanlineEffectParams sScanlineParams_DuoFight_Clouds = { - .dmaDest = (vu16 *)REG_ADDR_BG1HOFS, + .dmaDest = ®_BG1HOFS, .dmaControl = SCANLINE_EFFECT_DMACNT_16BIT, .initState = 1 }; From 7efdc0902b5951575560ee44023c6ce8f240a4b5 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 10 Nov 2021 18:52:30 -0500 Subject: [PATCH 04/19] Finish condition graph doc --- include/menu_specialized.h | 115 +++++++----- include/pokenav.h | 2 +- src/menu_specialized.c | 370 +++++++++++++++++++++---------------- src/pokenav_conditions_1.c | 30 +-- src/pokenav_conditions_2.c | 42 ++--- src/use_pokeblock.c | 30 +-- 6 files changed, 324 insertions(+), 265 deletions(-) diff --git a/include/menu_specialized.h b/include/menu_specialized.h index 2f212b5d6..146b930b4 100644 --- a/include/menu_specialized.h +++ b/include/menu_specialized.h @@ -7,6 +7,14 @@ #include "pokemon.h" #include "constants/berry.h" +// Window IDs for the Player PC Mailbox +enum { + MAILBOXWIN_TITLE, + MAILBOXWIN_LIST, + MAILBOXWIN_OPTIONS, + MAILBOXWIN_COUNT +}; + enum { TAG_CONDITION_MON = 100, TAG_CONDITION_BALL, @@ -18,34 +26,19 @@ enum { TAG_CONDITION_MARKINGS_MENU_2, // Used implicitly by CreateMonMarkingsMenuSprites }; - #define MAX_CONDITION_SPARKLES 10 // The number of extra sparkles shown on a Pokémon's condition screen. // All Pokémon start with 1, so the max here is MAX_CONDITION_SPARKLES - 1 #define GET_NUM_CONDITION_SPARKLES(sheen)((sheen) != MAX_SHEEN) ? (sheen) / ((u32)MAX_SHEEN / (MAX_CONDITION_SPARKLES - 1) + 1) : MAX_CONDITION_SPARKLES - 1; -// Window IDs for the Player PC Mailbox -enum { - MAILBOXWIN_TITLE, - MAILBOXWIN_LIST, - MAILBOXWIN_OPTIONS, - MAILBOXWIN_COUNT -}; - -struct UnknownSubStruct_81D1ED4 -{ - u16 unk0; - u16 unk2; -}; - -#define CONDITION_GRAPH_CENTER_X 155 -#define CONDITION_GRAPH_TOP_Y 56 +#define CONDITION_GRAPH_TOP_Y 56 #define CONDITION_GRAPH_BOTTOM_Y 121 -#define CONDITION_GRAPH_HEIGHT (CONDITION_GRAPH_BOTTOM_Y - CONDITION_GRAPH_TOP_Y + 1) -#define CONDITION_GRAPH_UNK_1 10 -#define CONDITION_GRAPH_UNK_2 9 -#define CONDITION_GRAPH_UNK 91 +#define CONDITION_GRAPH_HEIGHT (CONDITION_GRAPH_BOTTOM_Y - CONDITION_GRAPH_TOP_Y + 1) +#define CONDITION_GRAPH_CENTER_X 155 +#define CONDITION_GRAPH_CENTER_Y ((CONDITION_GRAPH_BOTTOM_Y + CONDITION_GRAPH_TOP_Y) / 2 + 3) +#define CONDITION_GRAPH_UPDATE_STEPS 10 +#define CONDITION_GRAPH_LOAD_MAX 4 // Equivalent to flavor and contest values, but in a different order. enum { @@ -57,55 +50,75 @@ enum { CONDITION_COUNT }; -struct ConditionGraph -{ - /*0x000*/ u8 conditions[4][CONDITION_COUNT]; - /*0x014*/ struct UnknownSubStruct_81D1ED4 unk14[4][CONDITION_COUNT]; - /*0x064*/ struct UnknownSubStruct_81D1ED4 unk64[CONDITION_GRAPH_UNK_1][CONDITION_COUNT]; - /*0x12C*/ struct UnknownSubStruct_81D1ED4 unk12C[CONDITION_COUNT]; - /*0x140*/ u16 scanlineRight[CONDITION_GRAPH_HEIGHT][2]; - /*0x248*/ u16 scanlineLeft[CONDITION_GRAPH_HEIGHT][2]; - /*0x350*/ u16 unk350; - /*0x352*/ u16 unk352; - /*0x354*/ bool8 unk354; - /*0x355*/ u8 state; +// Yet another order. This one is the same (by coincidence) as the contest categories +enum { + GRAPH_COOL, + GRAPH_BEAUTY, + GRAPH_CUTE, + GRAPH_SMART, + GRAPH_TOUGH, }; +struct ConditionGraph +{ + /*0x000*/ u8 conditions[CONDITION_GRAPH_LOAD_MAX][CONDITION_COUNT]; + /*0x014*/ struct UCoords16 savedPositions[CONDITION_GRAPH_LOAD_MAX][CONDITION_COUNT]; + /*0x064*/ struct UCoords16 newPositions[CONDITION_GRAPH_UPDATE_STEPS][CONDITION_COUNT]; + /*0x12C*/ struct UCoords16 curPositions[CONDITION_COUNT]; + /*0x140*/ u16 scanlineRight[CONDITION_GRAPH_HEIGHT][2]; + /*0x248*/ u16 scanlineLeft[CONDITION_GRAPH_HEIGHT][2]; + /*0x350*/ u16 bottom; + /*0x352*/ u16 updateCounter; + /*0x354*/ bool8 needsDraw; + /*0x355*/ u8 scanlineResetState; +}; + +// Mailbox menu bool8 MailboxMenu_Alloc(u8 count); u8 MailboxMenu_AddWindow(u8 windowIdx); u8 MailboxMenu_CreateList(struct PlayerPCItemPageStruct *page); void MailboxMenu_AddScrollArrows(struct PlayerPCItemPageStruct *page); void MailboxMenu_Free(void); void MailboxMenu_RemoveWindow(u8 windowIdx); + +// Condition graph void ConditionGraph_Init(struct ConditionGraph *graph); -void sub_81D2108(struct ConditionGraph *graph); -void SetConditionGraphIOWindows(u8 bg); -void InitConditionGraphState(struct ConditionGraph *graph); -void sub_81D2230(struct ConditionGraph *graph); -bool8 SetupConditionGraphScanlineParams(struct ConditionGraph *graph); -bool8 TransitionConditionGraph(struct ConditionGraph *graph); -void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1); -void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2); -void MoveRelearnerPrintText(u8 *str); -bool16 MoveRelearnerRunTextPrinters(void); -void MoveRelearnerCreateYesNoMenu(void); -u8 LoadMoveRelearnerMovesList(const struct ListMenuItem *items, u16 numChoices); -void InitMoveRelearnerWindows(bool8 useContextWindow); -s32 GetBoxOrPartyMonData(u16 boxId, u16 monId, s32 request, u8 *dst); +void ConditionGraph_InitWindow(u8 bg); +void ConditionGraph_InitResetScanline(struct ConditionGraph *graph); +bool8 ConditionGraph_ResetScanline(struct ConditionGraph *graph); +void ConditionGraph_Draw(struct ConditionGraph *graph); +bool8 ConditionGraph_TryUpdate(struct ConditionGraph *graph); +void ConditionGraph_Update(struct ConditionGraph *graph); +void ConditionGraph_CalcPositions(u8 *conditions, struct UCoords16 *positions); +void ConditionGraph_SetNewPositions(struct ConditionGraph *graph, struct UCoords16 *arg1, struct UCoords16 *arg2); + +// Condition menu +bool8 ConditionMenu_UpdateMonEnter(struct ConditionGraph *graph, s16 *x); +bool8 ConditionMenu_UpdateMonExit(struct ConditionGraph *graph, s16 *x); +bool8 MoveConditionMonOnscreen(s16 *x); +bool8 MoveConditionMonOffscreen(s16 *x); void GetConditionMenuMonNameAndLocString(u8 *locationDst, u8 *nameDst, u16 boxId, u16 monId, u16 partyId, u16 numMons, bool8 excludesCancel); void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *sheen, u16 boxId, u16 monId, u16 partyId, u16 id, u16 numMons, bool8 excludesCancel); void GetConditionMenuMonGfx(void *tilesDst, void *palDst, u16 boxId, u16 monId, u16 partyId, u16 numMons, bool8 excludesCancel); -bool8 MoveConditionMonOnscreen(s16 *x); -bool8 MoveConditionMonOffscreen(s16 *x); -bool8 ConditionGraph_UpdateMonEnter(struct ConditionGraph *graph, s16 *x); -bool8 ConditionGraph_UpdateMonExit(struct ConditionGraph *graph, s16 *x); void LoadConditionMonPicTemplate(struct SpriteSheet *sheet, struct SpriteTemplate *template, struct SpritePalette *pal); void LoadConditionSelectionIcons(struct SpriteSheet *sheets, struct SpriteTemplate * template, struct SpritePalette *pals); +s32 GetBoxOrPartyMonData(u16 boxId, u16 monId, s32 request, u8 *dst); + +// Condition sparkles void LoadConditionSparkle(struct SpriteSheet *sheet, struct SpritePalette *pal); void ResetConditionSparkleSprites(struct Sprite **sprites); void CreateConditionSparkleSprites(struct Sprite **sprites, u8 monSpriteId, u8 count); void DestroyConditionSparkleSprites(struct Sprite **sprites); void FreeConditionSparkles(struct Sprite **sprites); + +// Move relearner +void MoveRelearnerPrintText(u8 *str); +bool16 MoveRelearnerRunTextPrinters(void); +void MoveRelearnerCreateYesNoMenu(void); +u8 LoadMoveRelearnerMovesList(const struct ListMenuItem *items, u16 numChoices); +void InitMoveRelearnerWindows(bool8 useContextWindow); + +// Level up window void DrawLevelUpWindowPg1(u16 windowId, u16 *statsBefore, u16 *statsAfter, u8 bgClr, u8 fgClr, u8 shadowClr); void DrawLevelUpWindowPg2(u16 windowId, u16 *currStats, u8 bgClr, u8 fgClr, u8 shadowClr); void GetMonLevelUpWindowStats(struct Pokemon *mon, u16 *currStats); diff --git a/include/pokenav.h b/include/pokenav.h index 445ce752b..b8c2178d1 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -437,7 +437,7 @@ u32 GetPartyConditionCallback(void); void FreePartyConditionSubstruct1(void); bool32 LoadPartyConditionMenuGfx(void); bool32 IsConditionMenuSearchMode(void); -struct ConditionGraph *GetConditionGraphDataPtr(void); +struct ConditionGraph *GetConditionGraphPtr(void); u16 GetConditionGraphCurrentMonIndex(void); u16 GetMonListCount(void); u8 GetNumConditionMonSparkles(void); diff --git a/src/menu_specialized.c b/src/menu_specialized.c index abeaba2c9..074621de4 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -32,8 +32,8 @@ EWRAM_DATA static u8 sMailboxWindowIds[MAILBOXWIN_COUNT] = {0}; EWRAM_DATA static struct ListMenuItem *sMailboxList = NULL; static void MailboxMenu_MoveCursorFunc(s32, bool8, struct ListMenu *); -static void sub_81D24A4(struct ConditionGraph *); -static void sub_81D2634(struct ConditionGraph *); +static void ConditionGraph_CalcRightHalf(struct ConditionGraph *); +static void ConditionGraph_CalcLeftHalf(struct ConditionGraph *); static void MoveRelearnerCursorCallback(s32, bool8, struct ListMenu *); static void MoveRelearnerDummy(void); static void SetNextConditionSparkle(struct Sprite *); @@ -85,7 +85,7 @@ static const struct ScanlineEffectParams sConditionGraphScanline = .initState = 1, }; -static const u8 sUnknown_08625410[MAX_CONDITION + 1] = +static const u8 sConditionToLineLength[MAX_CONDITION + 1] = { 4, 5, 6, 7, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 17, @@ -190,6 +190,10 @@ static const struct ListMenuTemplate sMoveRelearnerMovesListTemplate = .cursorKind = 0 }; +//-------------- +// Mailbox menu +//-------------- + bool8 MailboxMenu_Alloc(u8 count) { u8 i; @@ -303,67 +307,83 @@ void MailboxMenu_Free(void) Free(sMailboxList); } +//--------------------------------------- +// Condition graph +// +// This is the graph in the Pokénav and +// Pokéblock case that shows a Pokémon's +// conditions (Beauty, Tough, etc.). +// It works by using scanlines to +// selectively reveal a bg that has been +// filled with the graph color. +//--------------------------------------- + +#define UNK_VAL(n, s)(((n) >> (s)) + (((n) >> ((s) - 1)) & 1)) + void ConditionGraph_Init(struct ConditionGraph *graph) { u8 i, j; for (j = 0; j < CONDITION_COUNT; j++) { - for (i = 0; i < CONDITION_GRAPH_UNK_1; i++) + for (i = 0; i < CONDITION_GRAPH_UPDATE_STEPS; i++) { - graph->unk64[i][j].unk0 = 0; - graph->unk64[i][j].unk2 = 0; + graph->newPositions[i][j].x = 0; + graph->newPositions[i][j].y = 0; } - for (i = 0; i < 4; i++) + + for (i = 0; i < CONDITION_GRAPH_LOAD_MAX; i++) { graph->conditions[i][j] = 0; - graph->unk14[i][j].unk0 = CONDITION_GRAPH_CENTER_X; - graph->unk14[i][j].unk2 = CONDITION_GRAPH_UNK; + graph->savedPositions[i][j].x = CONDITION_GRAPH_CENTER_X; + graph->savedPositions[i][j].y = CONDITION_GRAPH_CENTER_Y; } - graph->unk12C[j].unk0 = 0; - graph->unk12C[j].unk2 = 0; + graph->curPositions[j].x = 0; + graph->curPositions[j].y = 0; } - graph->unk354 = FALSE; - graph->unk352 = 0; + graph->needsDraw = FALSE; + graph->updateCounter = 0; } -void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2) +// Fills the newPositions array with incremental positions between +// old and new for the graph transition when switching between Pokémon. +void ConditionGraph_SetNewPositions(struct ConditionGraph *graph, struct UCoords16 *old, struct UCoords16 *new) { u16 i, j; - s32 r5, r6; + s32 coord, increment; for (i = 0; i < CONDITION_COUNT; i++) { - r5 = arg1[i].unk0 << 8; - r6 = ((arg2[i].unk0 - arg1[i].unk0) << 8) / CONDITION_GRAPH_UNK_1; - for (j = 0; j < CONDITION_GRAPH_UNK_2; j++) + coord = old[i].x << 8; + increment = ((new[i].x - old[i].x) << 8) / CONDITION_GRAPH_UPDATE_STEPS; + for (j = 0; j < CONDITION_GRAPH_UPDATE_STEPS - 1; j++) { - graph->unk64[j][i].unk0 = (r5 >> 8) + ((r5 >> 7) & 1); - r5 += r6; + graph->newPositions[j][i].x = UNK_VAL(coord, 8); + coord += increment; } - graph->unk64[j][i].unk0 = arg2[i].unk0; + graph->newPositions[j][i].x = new[i].x; - r5 = arg1[i].unk2 << 8; - r6 = ((arg2[i].unk2 - arg1[i].unk2) << 8) / CONDITION_GRAPH_UNK_1; - for (j = 0; j < CONDITION_GRAPH_UNK_2; j++) + coord = old[i].y << 8; + increment = ((new[i].y - old[i].y) << 8) / CONDITION_GRAPH_UPDATE_STEPS; + for (j = 0; j < CONDITION_GRAPH_UPDATE_STEPS - 1; j++) { - graph->unk64[j][i].unk2 = (r5 >> 8) + ((r5 >> 7) & 1); - r5 += r6; + graph->newPositions[j][i].y = UNK_VAL(coord, 8); + coord += increment; } - graph->unk64[j][i].unk2 = arg2[i].unk2; + graph->newPositions[j][i].y = new[i].y; } - graph->unk352 = 0; + graph->updateCounter = 0; } -bool8 TransitionConditionGraph(struct ConditionGraph *graph) +bool8 ConditionGraph_TryUpdate(struct ConditionGraph *graph) { - if (graph->unk352 < CONDITION_GRAPH_UNK_1) + if (graph->updateCounter < CONDITION_GRAPH_UPDATE_STEPS) { - sub_81D2230(graph); - return (++graph->unk352 != CONDITION_GRAPH_UNK_1); + ConditionGraph_Update(graph); + return (++graph->updateCounter != CONDITION_GRAPH_UPDATE_STEPS); } else { @@ -371,51 +391,55 @@ bool8 TransitionConditionGraph(struct ConditionGraph *graph) } } -void InitConditionGraphState(struct ConditionGraph *graph) +void ConditionGraph_InitResetScanline(struct ConditionGraph *graph) { - graph->state = 0; + graph->scanlineResetState = 0; } -bool8 SetupConditionGraphScanlineParams(struct ConditionGraph *graph) +bool8 ConditionGraph_ResetScanline(struct ConditionGraph *graph) { struct ScanlineEffectParams params; - switch (graph->state) + switch (graph->scanlineResetState) { case 0: ScanlineEffect_Clear(); - graph->state++; + graph->scanlineResetState++; return TRUE; case 1: params = sConditionGraphScanline; ScanlineEffect_SetParams(params); - graph->state++; + graph->scanlineResetState++; return FALSE; default: return FALSE; } } -void sub_81D2108(struct ConditionGraph *graph) +void ConditionGraph_Draw(struct ConditionGraph *graph) { u16 i; - if (!graph->unk354) + if (!graph->needsDraw) return; - sub_81D24A4(graph); - sub_81D2634(graph); + ConditionGraph_CalcRightHalf(graph); + ConditionGraph_CalcLeftHalf(graph); for (i = 0; i < CONDITION_GRAPH_HEIGHT; i++) { - gScanlineEffectRegBuffers[1][(i + 55) * 2] = gScanlineEffectRegBuffers[0][(i + 55) * 2] = (graph->scanlineRight[i][0] << 8) | (graph->scanlineRight[i][1]); - gScanlineEffectRegBuffers[1][(i + 55) * 2 + 1] = gScanlineEffectRegBuffers[0][(i + 55) * 2 + 1] = (graph->scanlineLeft[i][0] << 8) | (graph->scanlineLeft[i][1]); + // Draw right half + gScanlineEffectRegBuffers[1][(i + CONDITION_GRAPH_TOP_Y - 1) * 2 + 0] = // double assignment + gScanlineEffectRegBuffers[0][(i + CONDITION_GRAPH_TOP_Y - 1) * 2 + 0] = (graph->scanlineRight[i][0] << 8) | (graph->scanlineRight[i][1]); + // Draw left half + gScanlineEffectRegBuffers[1][(i + CONDITION_GRAPH_TOP_Y - 1) * 2 + 1] = // double assignment + gScanlineEffectRegBuffers[0][(i + CONDITION_GRAPH_TOP_Y - 1) * 2 + 1] = (graph->scanlineLeft[i][0] << 8) | (graph->scanlineLeft[i][1]); } - graph->unk354 = FALSE; + graph->needsDraw = FALSE; } -void SetConditionGraphIOWindows(u8 bg) +void ConditionGraph_InitWindow(u8 bg) { u32 flags; @@ -434,146 +458,153 @@ void SetConditionGraphIOWindows(u8 bg) SetGpuReg(REG_OFFSET_WINOUT, flags); } -void sub_81D2230(struct ConditionGraph *graph) +void ConditionGraph_Update(struct ConditionGraph *graph) { u16 i; for (i = 0; i < CONDITION_COUNT; i++) - graph->unk12C[i] = graph->unk64[graph->unk352][i]; + graph->curPositions[i] = graph->newPositions[graph->updateCounter][i]; - graph->unk354 = TRUE; + graph->needsDraw = TRUE; } -static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownSubStruct_81D1ED4 *arg2, struct UnknownSubStruct_81D1ED4 *arg3, u8 arg4, u16 *arg5) +static void ConditionGraph_CalcLine(struct ConditionGraph *graph, u16 *scanline, struct UCoords16 *pos1, struct UCoords16 *pos2, bool8 dir, u16 *overflowScanline) { - u16 i, r8, r10, r0, var_30; + u16 i, height, top, bottom, x2; u16 *ptr; - s32 r4, var_2C = 0; + s32 x, xIncrement = 0; - if (arg2->unk2 < arg3->unk2) + if (pos1->y < pos2->y) { - r10 = arg2->unk2; - r0 = arg3->unk2; - r4 = arg2->unk0 << 10; - var_30 = arg3->unk0; - r8 = r0 - r10; - if (r8 != 0) - var_2C = ((var_30 - arg2->unk0) << 10) / r8; + top = pos1->y; + bottom = pos2->y; + x = pos1->x << 10; + x2 = pos2->x; + height = bottom - top; + if (height != 0) + xIncrement = ((x2 - pos1->x) << 10) / height; } else { - r0 = arg2->unk2; - r10 = arg3->unk2; - r4 = arg3->unk0 << 10; - var_30 = arg2->unk0; - r8 = r0 - r10; - if (r8 != 0) - var_2C = ((var_30 - arg3->unk0) << 10) / r8; + bottom = pos1->y; + top = pos2->y; + x = pos2->x << 10; + x2 = pos1->x; + height = bottom - top; + if (height != 0) + xIncrement = ((x2 - pos2->x) << 10) / height; } - r8++; - if (arg5 == NULL) + height++; + if (overflowScanline == NULL) { - arg1 += (r10 - CONDITION_GRAPH_TOP_Y) * 2; - for (i = 0; i < r8; i++) + scanline += (top - CONDITION_GRAPH_TOP_Y) * 2; + for (i = 0; i < height; i++) { - arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4; - r4 += var_2C; - arg1 += 2; + scanline[dir] = UNK_VAL(x, 10) + dir; + x += xIncrement; + scanline += 2; } - ptr = arg1 - 2; + ptr = scanline - 2; } - else if (var_2C > 0) + else if (xIncrement > 0) { - arg5 += (r10 - CONDITION_GRAPH_TOP_Y) * 2; + overflowScanline += (top - CONDITION_GRAPH_TOP_Y) * 2; // Less readable than the other loops, but it has to be written this way to match. - for (i = 0; i < r8; arg5[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4, r4 += var_2C, arg5 += 2, i++) + for (i = 0; i < height; overflowScanline[dir] = UNK_VAL(x, 10) + dir, x += xIncrement, overflowScanline += 2, i++) { - if (r4 >= (CONDITION_GRAPH_CENTER_X << 10)) + if (x >= (CONDITION_GRAPH_CENTER_X << 10)) break; } - graph->unk350 = r10 + i; - arg1 += (graph->unk350 - CONDITION_GRAPH_TOP_Y) * 2; - for (; i < r8; i++) + graph->bottom = top + i; + scanline += (graph->bottom - CONDITION_GRAPH_TOP_Y) * 2; + for (; i < height; i++) { - arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4; - r4 += var_2C; - arg1 += 2; + scanline[dir] = UNK_VAL(x, 10) + dir; + x += xIncrement; + scanline += 2; } - ptr = arg1 - 2; + ptr = scanline - 2; } - else if (var_2C < 0) + else if (xIncrement < 0) { - arg1 += (r10 - CONDITION_GRAPH_TOP_Y) * 2; - for (i = 0; i < r8; i++) + scanline += (top - CONDITION_GRAPH_TOP_Y) * 2; + for (i = 0; i < height; i++) { - arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4; - if (r4 < (CONDITION_GRAPH_CENTER_X << 10)) + scanline[dir] = UNK_VAL(x, 10) + dir; + if (x < (CONDITION_GRAPH_CENTER_X << 10)) { - arg1[arg4] = CONDITION_GRAPH_CENTER_X; + scanline[dir] = CONDITION_GRAPH_CENTER_X; break; } - r4 += var_2C; - arg1 += 2; + x += xIncrement; + scanline += 2; } - graph->unk350 = r10 + i; - arg5 += (graph->unk350 - CONDITION_GRAPH_TOP_Y) * 2; - for (; i < r8; i++) + graph->bottom = top + i; + overflowScanline += (graph->bottom - CONDITION_GRAPH_TOP_Y) * 2; + for (; i < height; i++) { - arg5[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4; - r4 += var_2C; - arg5 += 2; + overflowScanline[dir] = UNK_VAL(x, 10) + dir; + x += xIncrement; + overflowScanline += 2; } - ptr = arg5 - 2; + ptr = overflowScanline - 2; } else { - graph->unk350 = r10; - arg1 += (r10 - CONDITION_GRAPH_TOP_Y) * 2; - arg5 += (r10 - CONDITION_GRAPH_TOP_Y) * 2; - arg1[1] = arg2->unk0 + 1; - arg5[0] = arg3->unk0; - arg5[1] = CONDITION_GRAPH_CENTER_X; + graph->bottom = top; + scanline += (top - CONDITION_GRAPH_TOP_Y) * 2; + overflowScanline += (top - CONDITION_GRAPH_TOP_Y) * 2; + scanline[1] = pos1->x + 1; + overflowScanline[0] = pos2->x; + overflowScanline[1] = CONDITION_GRAPH_CENTER_X; return; } - ptr[arg4] = arg4 + var_30; + ptr[dir] = dir + x2; } -static void sub_81D24A4(struct ConditionGraph *graph) +static void ConditionGraph_CalcRightHalf(struct ConditionGraph *graph) { - u16 i, r6, varMax; + u16 i, y, bottom; - if (graph->unk12C[0].unk2 < graph->unk12C[1].unk2) + // Calculate Cool -> Beauty line + if (graph->curPositions[GRAPH_COOL].y < graph->curPositions[GRAPH_BEAUTY].y) { - r6 = graph->unk12C[0].unk2; - sub_81D2278(graph, graph->scanlineRight[0], &graph->unk12C[0], &graph->unk12C[1], 1, NULL); + y = graph->curPositions[GRAPH_COOL].y; + ConditionGraph_CalcLine(graph, graph->scanlineRight[0], &graph->curPositions[GRAPH_COOL], &graph->curPositions[GRAPH_BEAUTY], TRUE, NULL); } else { - r6 = graph->unk12C[1].unk2; - sub_81D2278(graph, graph->scanlineRight[0], &graph->unk12C[1], &graph->unk12C[0], 0, NULL); + y = graph->curPositions[GRAPH_BEAUTY].y; + ConditionGraph_CalcLine(graph, graph->scanlineRight[0], &graph->curPositions[GRAPH_BEAUTY], &graph->curPositions[GRAPH_COOL], FALSE, NULL); } - sub_81D2278(graph, graph->scanlineRight[0], &graph->unk12C[1], &graph->unk12C[2], 1, NULL); + // Calculate Beauty -> Cute line + // No need for conditional, positions on the Beauty line are always above the Cute line + ConditionGraph_CalcLine(graph, graph->scanlineRight[0], &graph->curPositions[GRAPH_BEAUTY], &graph->curPositions[GRAPH_CUTE], TRUE, NULL); - i = (graph->unk12C[2].unk2 <= graph->unk12C[3].unk2); - sub_81D2278(graph, graph->scanlineRight[0], &graph->unk12C[2], &graph->unk12C[3], i, graph->scanlineLeft[0]); - for (i = CONDITION_GRAPH_TOP_Y; i < r6; i++) + // Calculate Cute -> Tough line (includes left scanline because this crosses the halfway point) + i = (graph->curPositions[GRAPH_CUTE].y <= graph->curPositions[GRAPH_SMART].y); + ConditionGraph_CalcLine(graph, graph->scanlineRight[0], &graph->curPositions[GRAPH_CUTE], &graph->curPositions[GRAPH_SMART], i, graph->scanlineLeft[0]); + + // Clear down to new top + for (i = CONDITION_GRAPH_TOP_Y; i < y; i++) { graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = 0; graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][1] = 0; } - for (i = graph->unk12C[0].unk2; i <= graph->unk350; i++) + for (i = graph->curPositions[GRAPH_COOL].y; i <= graph->bottom; i++) graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = CONDITION_GRAPH_CENTER_X; - varMax = max(graph->unk350, graph->unk12C[2].unk2); - for (i = varMax + 1; i <= CONDITION_GRAPH_BOTTOM_Y; i++) + // Clear after new bottom + bottom = max(graph->bottom, graph->curPositions[GRAPH_CUTE].y); + for (i = bottom + 1; i <= CONDITION_GRAPH_BOTTOM_Y; i++) { graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = 0; graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][1] = 0; @@ -581,42 +612,48 @@ static void sub_81D24A4(struct ConditionGraph *graph) for (i = CONDITION_GRAPH_TOP_Y; i <= CONDITION_GRAPH_BOTTOM_Y; i++) { - if (graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] == 0 && graph->scanlineRight[i - 56][1] != 0) + if (graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] == 0 + && graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][1] != 0) graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = CONDITION_GRAPH_CENTER_X; } } -static void sub_81D2634(struct ConditionGraph *graph) +static void ConditionGraph_CalcLeftHalf(struct ConditionGraph *graph) { - s32 i, r6, varMax; + s32 i, y, bottom; - if (graph->unk12C[0].unk2 < graph->unk12C[4].unk2) + // Calculate Cool -> Tough line + if (graph->curPositions[GRAPH_COOL].y < graph->curPositions[GRAPH_TOUGH].y) { - r6 = graph->unk12C[0].unk2; - sub_81D2278(graph, graph->scanlineLeft[0], &graph->unk12C[0], &graph->unk12C[4], 0, NULL); + y = graph->curPositions[GRAPH_COOL].y; + ConditionGraph_CalcLine(graph, graph->scanlineLeft[0], &graph->curPositions[GRAPH_COOL], &graph->curPositions[GRAPH_TOUGH], FALSE, NULL); } else { - r6 = graph->unk12C[4].unk2; - sub_81D2278(graph, graph->scanlineLeft[0], &graph->unk12C[4], &graph->unk12C[0], 1, NULL); + y = graph->curPositions[GRAPH_TOUGH].y; + ConditionGraph_CalcLine(graph, graph->scanlineLeft[0], &graph->curPositions[GRAPH_TOUGH], &graph->curPositions[GRAPH_COOL], TRUE, NULL); } - sub_81D2278(graph, graph->scanlineLeft[0], &graph->unk12C[4], &graph->unk12C[3], 0, NULL); + // Calculate Tough -> Smart line + // No need for conditional, positions on the Tough line are always above the Smart line + ConditionGraph_CalcLine(graph, graph->scanlineLeft[0], &graph->curPositions[GRAPH_TOUGH], &graph->curPositions[GRAPH_SMART], FALSE, NULL); - for (i = CONDITION_GRAPH_TOP_Y; i < r6; i++) + // Clear down to new top + for (i = CONDITION_GRAPH_TOP_Y; i < y; i++) { - graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][0] = 0; - graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][1] = 0; + graph->scanlineLeft[i - CONDITION_GRAPH_TOP_Y][0] = 0; + graph->scanlineLeft[i - CONDITION_GRAPH_TOP_Y][1] = 0; } - for (i = graph->unk12C[0].unk2; i <= graph->unk350; i++) - graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][1] = CONDITION_GRAPH_CENTER_X; + for (i = graph->curPositions[GRAPH_COOL].y; i <= graph->bottom; i++) + graph->scanlineLeft[i - CONDITION_GRAPH_TOP_Y][1] = CONDITION_GRAPH_CENTER_X; - varMax = max(graph->unk350, graph->unk12C[3].unk2 + 1); - for (i = varMax; i <= CONDITION_GRAPH_BOTTOM_Y; i++) + // Clear after new bottom + bottom = max(graph->bottom, graph->curPositions[GRAPH_SMART].y + 1); + for (i = bottom; i <= CONDITION_GRAPH_BOTTOM_Y; i++) { - graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][0] = 0; - graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][1] = 0; + graph->scanlineLeft[i - CONDITION_GRAPH_TOP_Y][0] = 0; + graph->scanlineLeft[i - CONDITION_GRAPH_TOP_Y][1] = 0; } for (i = 0; i < CONDITION_GRAPH_HEIGHT; i++) @@ -629,36 +666,41 @@ static void sub_81D2634(struct ConditionGraph *graph) } } -void sub_81D2754(u8 *conditions, struct UnknownSubStruct_81D1ED4 *arg1) +void ConditionGraph_CalcPositions(u8 *conditions, struct UCoords16 *positions) { - u8 r2, sinIdx; - s8 r12; + u8 lineLength, sinIdx; + s8 posIdx; u16 i; - r2 = sUnknown_08625410[*(conditions++)]; - arg1->unk0 = CONDITION_GRAPH_CENTER_X; - arg1->unk2 = CONDITION_GRAPH_UNK - r2; + // Cool is straight up-and-down (not angled), so no need for Sin + lineLength = sConditionToLineLength[*(conditions++)]; + positions[GRAPH_COOL].x = CONDITION_GRAPH_CENTER_X; + positions[GRAPH_COOL].y = CONDITION_GRAPH_CENTER_Y - lineLength; sinIdx = 64; - r12 = 0; + posIdx = GRAPH_COOL; for (i = 1; i < CONDITION_COUNT; i++) { sinIdx += 51; - if (--r12 < 0) - r12 = 4; + if (--posIdx < 0) + posIdx = CONDITION_COUNT - 1; - if (r12 == 2) + if (posIdx == GRAPH_CUTE) sinIdx++; - r2 = sUnknown_08625410[*(conditions++)]; - arg1[r12].unk0 = CONDITION_GRAPH_CENTER_X + ((r2 * gSineTable[64 + sinIdx]) >> 8); - arg1[r12].unk2 = CONDITION_GRAPH_UNK - ((r2 * gSineTable[sinIdx]) >> 8); + lineLength = sConditionToLineLength[*(conditions++)]; + positions[posIdx].x = CONDITION_GRAPH_CENTER_X + ((lineLength * gSineTable[64 + sinIdx]) >> 8); + positions[posIdx].y = CONDITION_GRAPH_CENTER_Y - ((lineLength * gSineTable[sinIdx]) >> 8); - if (r12 < 3 && (r2 != 32 || r12 != 2)) - arg1[r12].unk0 = CONDITION_GRAPH_CENTER_X + 1 + ((r2 * gSineTable[64 + sinIdx]) >> 8); + if (posIdx <= GRAPH_CUTE && (lineLength != 32 || posIdx != GRAPH_CUTE)) + positions[posIdx].x++; } } +//---------------- +// Move relearner +//---------------- + void InitMoveRelearnerWindows(bool8 useContextWindow) { u8 i; @@ -834,6 +876,10 @@ void MoveRelearnerCreateYesNoMenu(void) CreateYesNoMenu(&sMoveRelearnerYesNoMenuTemplate, 1, 0xE, 0); } +//---------------- +// Condition menu +//---------------- + s32 GetBoxOrPartyMonData(u16 boxId, u16 monId, s32 request, u8 *dst) { s32 ret; @@ -1005,15 +1051,15 @@ void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *numSparkles numSparkles[id] = GET_NUM_CONDITION_SPARKLES(GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL)); - sub_81D2754(graph->conditions[id], graph->unk14[id]); + ConditionGraph_CalcPositions(graph->conditions[id], graph->savedPositions[id]); } else { for (i = 0; i < CONDITION_COUNT; i++) { graph->conditions[id][i] = 0; - graph->unk14[id][i].unk0 = CONDITION_GRAPH_CENTER_X; - graph->unk14[id][i].unk2 = CONDITION_GRAPH_UNK; + graph->savedPositions[id][i].x = CONDITION_GRAPH_CENTER_X; + graph->savedPositions[id][i].y = CONDITION_GRAPH_CENTER_Y; } } } @@ -1052,17 +1098,17 @@ bool8 MoveConditionMonOffscreen(s16 *x) return (*x != -80); } -bool8 ConditionGraph_UpdateMonEnter(struct ConditionGraph *graph, s16 *x) +bool8 ConditionMenu_UpdateMonEnter(struct ConditionGraph *graph, s16 *x) { - bool8 graphUpdating = TransitionConditionGraph(graph); + bool8 graphUpdating = ConditionGraph_TryUpdate(graph); bool8 monUpdating = MoveConditionMonOnscreen(x); return (graphUpdating || monUpdating); } -bool8 ConditionGraph_UpdateMonExit(struct ConditionGraph *graph, s16 *x) +bool8 ConditionMenu_UpdateMonExit(struct ConditionGraph *graph, s16 *x) { - bool8 graphUpdating = TransitionConditionGraph(graph); + bool8 graphUpdating = ConditionGraph_TryUpdate(graph); bool8 monUpdating = MoveConditionMonOffscreen(x); return (graphUpdating || monUpdating); diff --git a/src/pokenav_conditions_1.c b/src/pokenav_conditions_1.c index 8eacf2e70..607437c47 100644 --- a/src/pokenav_conditions_1.c +++ b/src/pokenav_conditions_1.c @@ -24,7 +24,7 @@ struct PokenavSub11 u8 fill2[0x6320 - 0x6308]; u8 locationText[NUM_CONDITION_MONS][24]; u8 nameText[NUM_CONDITION_MONS][64]; - struct ConditionGraph conditionData; + struct ConditionGraph graph; u8 numSparkles[NUM_CONDITION_MONS]; u8 monMarks[NUM_CONDITION_MONS]; s8 mark; @@ -52,7 +52,7 @@ bool32 PokenavCallback_Init_PartyCondition(void) if (structPtr == NULL) return FALSE; - ConditionGraph_Init(&structPtr->conditionData); + ConditionGraph_Init(&structPtr->graph); InitPartyConditionListParameters(); gKeyRepeatStartDelay = 20; structPtr->callback = HandlePartyConditionInput; @@ -66,7 +66,7 @@ bool32 PokenavCallback_Init_ConditionGraphFromSearch(void) if (structPtr == NULL) return FALSE; - ConditionGraph_Init(&structPtr->conditionData); + ConditionGraph_Init(&structPtr->graph); InitSearchResultsConditionList(); gKeyRepeatStartDelay = 20; structPtr->callback = HandlePartyConditionInput; @@ -192,7 +192,7 @@ static u8 SwitchConditionSummaryIndex(u8 moveUp) struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); r7 = (moveUp) ? structPtr->unk6788 : structPtr->unk6787; - sub_81D1F84(&structPtr->conditionData, structPtr->conditionData.unk14[structPtr->mark], structPtr->conditionData.unk14[r7]); + ConditionGraph_SetNewPositions(&structPtr->graph, structPtr->graph.savedPositions[structPtr->mark], structPtr->graph.savedPositions[r7]); wasNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1)); if (moveUp) { @@ -491,22 +491,22 @@ static void GetMonConditionGraphData(s16 listId, u8 loadId) { boxId = monListPtr->monData[listId].boxId; monId = monListPtr->monData[listId].monId; - structPtr->conditionData.conditions[loadId][CONDITION_COOL] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); - structPtr->conditionData.conditions[loadId][CONDITION_TOUGH] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); - structPtr->conditionData.conditions[loadId][CONDITION_SMART] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); - structPtr->conditionData.conditions[loadId][CONDITION_CUTE] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); - structPtr->conditionData.conditions[loadId][CONDITION_BEAUTY] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); + structPtr->graph.conditions[loadId][CONDITION_COOL] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); + structPtr->graph.conditions[loadId][CONDITION_TOUGH] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); + structPtr->graph.conditions[loadId][CONDITION_SMART] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); + structPtr->graph.conditions[loadId][CONDITION_CUTE] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); + structPtr->graph.conditions[loadId][CONDITION_BEAUTY] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); structPtr->numSparkles[loadId] = GET_NUM_CONDITION_SPARKLES(GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL)); structPtr->monMarks[loadId] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL); - sub_81D2754(structPtr->conditionData.conditions[loadId], structPtr->conditionData.unk14[loadId]); + ConditionGraph_CalcPositions(structPtr->graph.conditions[loadId], structPtr->graph.savedPositions[loadId]); } else { for (i = 0; i < CONDITION_COUNT; i++) { - structPtr->conditionData.conditions[loadId][i] = 0; - structPtr->conditionData.unk14[loadId][i].unk0 = CONDITION_GRAPH_CENTER_X; - structPtr->conditionData.unk14[loadId][i].unk2 = CONDITION_GRAPH_UNK; + structPtr->graph.conditions[loadId][i] = 0; + structPtr->graph.savedPositions[loadId][i].x = CONDITION_GRAPH_CENTER_X; + structPtr->graph.savedPositions[loadId][i].y = CONDITION_GRAPH_CENTER_Y; } } } @@ -542,10 +542,10 @@ u16 GetConditionGraphCurrentMonIndex(void) return monListPtr->currIndex; } -struct ConditionGraph *GetConditionGraphDataPtr(void) +struct ConditionGraph *GetConditionGraphPtr(void) { struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return &structPtr->conditionData; + return &structPtr->graph; } u8 GetMonMarkIndex(void) diff --git a/src/pokenav_conditions_2.c b/src/pokenav_conditions_2.c index ef07c9be6..c2e8cadea 100644 --- a/src/pokenav_conditions_2.c +++ b/src/pokenav_conditions_2.c @@ -147,7 +147,7 @@ static void CreateConditionMonPic(u8 var); static void CreateMonMarkingsOrPokeballIndicators(void); static void CopyUnusedConditionWindowsToVram(void); static bool32 UpdateConditionGraphWindows(u8 a0, u16 a1, bool8 a2); -static void sub_81CEE44(void); +static void VBlankCB_PokenavConditionGraph(void); static void DoConditionGraphTransition(void); static void sub_81CEEC8(void); static void sub_81CEE68(void); @@ -237,7 +237,7 @@ static u32 LoopedTask_OpenPartyConditionGraph(s32 state) SetBgTilemapBuffer(2, structPtr->tilemapBuffers[2]); CopyBgTilemapBufferToVram(2); CopyPaletteIntoBufferUnfaded(gConditionGraphData_Pal, 0x30, 0x20); - SetConditionGraphIOWindows(2); + ConditionGraph_InitWindow(2); return LT_INC_AND_PAUSE; case 5: BgDmaFill(1, 0, 0, 1); @@ -309,21 +309,21 @@ static u32 LoopedTask_OpenPartyConditionGraph(s32 state) return LT_PAUSE; if (!IsConditionMenuSearchMode() && AreLeftHeaderSpritesMoving()) return LT_PAUSE; - SetVBlankCallback_(sub_81CEE44); + SetVBlankCallback_(VBlankCB_PokenavConditionGraph); return LT_INC_AND_PAUSE; case 17: DoConditionGraphTransition(); - InitConditionGraphState(GetConditionGraphDataPtr()); + ConditionGraph_InitResetScanline(GetConditionGraphPtr()); return LT_INC_AND_PAUSE; case 18: - if (SetupConditionGraphScanlineParams(GetConditionGraphDataPtr())) + if (ConditionGraph_ResetScanline(GetConditionGraphPtr())) return LT_PAUSE; return LT_INC_AND_PAUSE; case 19: ToggleGraphData(TRUE); return LT_INC_AND_PAUSE; case 20: - if (!ConditionGraph_UpdateMonEnter(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) + if (!ConditionMenu_UpdateMonEnter(GetConditionGraphPtr(), &structPtr->monTransitionX)) { ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); if (IsConditionMenuSearchMode() == TRUE || GetConditionGraphCurrentMonIndex() != GetMonListCount()) @@ -348,7 +348,7 @@ static u32 LoopedTask_ExitPartyConditionMenu(s32 state) DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); return LT_INC_AND_CONTINUE; case 1: - if (ConditionGraph_UpdateMonExit(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) + if (ConditionMenu_UpdateMonExit(GetConditionGraphPtr(), &structPtr->monTransitionX)) return 2; ToggleGraphData(FALSE); return LT_INC_AND_CONTINUE; @@ -373,7 +373,7 @@ static u32 LoopedTask_ExitPartyConditionMenu(s32 state) static u32 LoopedTask_TransitionMons(s32 state) { struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); - struct ConditionGraph *graph = GetConditionGraphDataPtr(); + struct ConditionGraph *graph = GetConditionGraphPtr(); switch (state) { @@ -388,7 +388,7 @@ static u32 LoopedTask_TransitionMons(s32 state) DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); return LT_INC_AND_CONTINUE; case 3: - TransitionConditionGraph(graph); + ConditionGraph_TryUpdate(graph); return LT_INC_AND_CONTINUE; case 4: if (!MoveConditionMonOffscreen(&structPtr->monTransitionX)) @@ -411,8 +411,8 @@ static u32 LoopedTask_TransitionMons(s32 state) return LT_INC_AND_CONTINUE; return LT_PAUSE; case 9: - graph = GetConditionGraphDataPtr(); - if (!ConditionGraph_UpdateMonEnter(graph, &structPtr->monTransitionX)) + graph = GetConditionGraphPtr(); + if (!ConditionMenu_UpdateMonEnter(graph, &structPtr->monTransitionX)) { ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); if (IsConditionMenuSearchMode() != TRUE && GetConditionGraphCurrentMonIndex() == GetMonListCount()) @@ -459,7 +459,7 @@ static u32 LoopedTask_MoveCursorNoTransition(s32 state) return LT_INC_AND_CONTINUE; return LT_PAUSE; case 8: - if (!ConditionGraph_UpdateMonEnter(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) + if (!ConditionMenu_UpdateMonEnter(GetConditionGraphPtr(), &structPtr->monTransitionX)) { ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles()); @@ -488,7 +488,7 @@ static u32 LoopedTask_SlideMonOut(s32 state) DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); return LT_INC_AND_CONTINUE; case 3: - if (!ConditionGraph_UpdateMonExit(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) + if (!ConditionMenu_UpdateMonExit(GetConditionGraphPtr(), &structPtr->monTransitionX)) return LT_INC_AND_CONTINUE; return LT_PAUSE; case 4: @@ -833,13 +833,13 @@ static void CreateConditionMonPic(u8 id) } } -static void sub_81CEE44(void) +static void VBlankCB_PokenavConditionGraph(void) { - struct ConditionGraph *graph = GetConditionGraphDataPtr(); + struct ConditionGraph *graph = GetConditionGraphPtr(); LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); - sub_81D2108(graph); + ConditionGraph_Draw(graph); ScanlineEffect_InitHBlankDmaTransfer(); } @@ -858,20 +858,20 @@ static void ToggleGraphData(bool8 showBg) static void DoConditionGraphTransition(void) { - struct ConditionGraph *conditionPtr = GetConditionGraphDataPtr(); + struct ConditionGraph *graph = GetConditionGraphPtr(); u8 id = GetMonMarkIndex(); sUnknown_030012BC = id; - sub_81D1F84(conditionPtr, conditionPtr->unk14[3], conditionPtr->unk14[id]); - TransitionConditionGraph(conditionPtr); + ConditionGraph_SetNewPositions(graph, graph->savedPositions[CONDITION_GRAPH_LOAD_MAX - 1], graph->savedPositions[id]); + ConditionGraph_TryUpdate(graph); } static void sub_81CEEC8(void) { - struct ConditionGraph *conditionPtr = GetConditionGraphDataPtr(); + struct ConditionGraph *graph = GetConditionGraphPtr(); if (IsConditionMenuSearchMode() || GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1) - sub_81D1F84(conditionPtr, conditionPtr->unk14[GetMonMarkIndex()], conditionPtr->unk14[3]); + ConditionGraph_SetNewPositions(graph, graph->savedPositions[GetMonMarkIndex()], graph->savedPositions[CONDITION_GRAPH_LOAD_MAX - 1]); } u8 GetMonMarkingsData(void) diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index a8b01b827..8cf8480cc 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -471,7 +471,7 @@ static void VBlankCB_UsePokeblockMenu(void) LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); - sub_81D2108(&sMenu->graph); + ConditionGraph_Draw(&sMenu->graph); ScanlineEffect_InitHBlankDmaTransfer(); } @@ -537,19 +537,19 @@ static void LoadUsePokeblockMenu(void) sInfo->mainState++; break; case 11: - sub_81D2754(sMenu->graph.conditions[0], sMenu->graph.unk14[0]); - InitConditionGraphState(&sMenu->graph); + ConditionGraph_CalcPositions(sMenu->graph.conditions[0], sMenu->graph.savedPositions[0]); + ConditionGraph_InitResetScanline(&sMenu->graph); sInfo->mainState++; break; case 12: - if (!SetupConditionGraphScanlineParams(&sMenu->graph)) + if (!ConditionGraph_ResetScanline(&sMenu->graph)) { - sub_81D1F84(&sMenu->graph, sMenu->graph.unk14[0], sMenu->graph.unk14[0]); + ConditionGraph_SetNewPositions(&sMenu->graph, sMenu->graph.savedPositions[0], sMenu->graph.savedPositions[0]); sInfo->mainState++; } break; case 13: - sub_81D2230(&sMenu->graph); + ConditionGraph_Update(&sMenu->graph); sInfo->mainState++; break; case 14: @@ -781,13 +781,13 @@ static void ShowPokeblockResults(void) break; case 2: CalculateConditionEnhancements(); - sub_81D2754(sInfo->conditionsAfterBlock, sMenu->graph.unk14[3]); - sub_81D1F84(&sMenu->graph, sMenu->graph.unk14[sMenu->curLoadId], sMenu->graph.unk14[3]); + ConditionGraph_CalcPositions(sInfo->conditionsAfterBlock, sMenu->graph.savedPositions[CONDITION_GRAPH_LOAD_MAX - 1]); + ConditionGraph_SetNewPositions(&sMenu->graph, sMenu->graph.savedPositions[sMenu->curLoadId], sMenu->graph.savedPositions[CONDITION_GRAPH_LOAD_MAX - 1]); LoadAndCreateUpDownSprites(); sInfo->mainState++; break; case 3: - if (!TransitionConditionGraph(&sMenu->graph)) + if (!ConditionGraph_TryUpdate(&sMenu->graph)) { CalculateNumAdditionalSparkles(GetPartyIdFromSelectionId(sMenu->info.curSelection)); if (sMenu->info.curSelection != sMenu->info.numSelections - 1) @@ -1365,7 +1365,7 @@ static bool8 LoadUsePokeblockMenuGfx(void) LoadBgTilemap(2, sMenu->tilemapBuffer, 1280, 0); LoadPalette(gConditionGraphData_Pal, 48, 32); LoadPalette(gConditionText_Pal, 240, 32); - SetConditionGraphIOWindows(2); + ConditionGraph_InitWindow(2); break; default: sMenu->info.helperState = 0; @@ -1416,7 +1416,7 @@ static void UpdateSelection(bool8 up) else newLoadId = sMenu->nextLoadId; - sub_81D1F84(&sMenu->graph, sMenu->graph.unk14[sMenu->curLoadId], sMenu->graph.unk14[newLoadId]); + ConditionGraph_SetNewPositions(&sMenu->graph, sMenu->graph.savedPositions[sMenu->curLoadId], sMenu->graph.savedPositions[newLoadId]); if (sMenu->info.curSelection == sMenu->info.numSelections - 1) startedOnMon = FALSE; // moving off of Cancel @@ -1484,7 +1484,7 @@ static bool8 LoadNewSelection_CancelToMon(void) sMenu->info.helperState++; break; case 2: - if (!ConditionGraph_UpdateMonEnter(&sMenu->graph, &sMenu->curMonXOffset)) + if (!ConditionMenu_UpdateMonEnter(&sMenu->graph, &sMenu->curMonXOffset)) { // Load the new adjacent pokemon (not the one being shown) LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId); @@ -1511,7 +1511,7 @@ static bool8 LoadNewSelection_MonToCancel(void) switch (sMenu->info.helperState) { case 0: - if (!ConditionGraph_UpdateMonExit(&sMenu->graph, &sMenu->curMonXOffset)) + if (!ConditionMenu_UpdateMonExit(&sMenu->graph, &sMenu->curMonXOffset)) sMenu->info.helperState++; break; case 1: @@ -1535,7 +1535,7 @@ static bool8 LoadNewSelection_MonToMon(void) switch (sMenu->info.helperState) { case 0: - TransitionConditionGraph(&sMenu->graph); + ConditionGraph_TryUpdate(&sMenu->graph); if (!MoveConditionMonOffscreen(&sMenu->curMonXOffset)) { UpdateMonPic(sMenu->curLoadId); @@ -1547,7 +1547,7 @@ static bool8 LoadNewSelection_MonToMon(void) sMenu->info.helperState++; break; case 2: - if (!ConditionGraph_UpdateMonEnter(&sMenu->graph, &sMenu->curMonXOffset)) + if (!ConditionMenu_UpdateMonEnter(&sMenu->graph, &sMenu->curMonXOffset)) { // Load the new adjacent pokemon (not the one being shown) LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId); From f5152094a9521222e64f003785662295ad8931e7 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 11 Nov 2021 16:50:36 -0500 Subject: [PATCH 05/19] Finish pokenav conditions doc --- .../{862323C.bin => condition/graph_data.bin} | 0 .../mon_markings.pal} | 0 .../search_results.bin} | Bin .../search_results.png} | Bin .../search_results_list.pal} | 0 include/menu_specialized.h | 5 + include/pokenav.h | 74 ++-- include/strings.h | 4 +- src/menu_specialized.c | 20 +- src/pokenav.c | 32 +- src/pokenav_conditions_1.c | 317 +++++++------- src/pokenav_conditions_2.c | 397 +++++++++--------- src/pokenav_conditions_3.c | 317 +++++++------- src/pokenav_menu_handler_1.c | 2 +- src/pokenav_menu_handler_2.c | 2 +- src/strings.c | 2 +- src/use_pokeblock.c | 4 +- 17 files changed, 604 insertions(+), 572 deletions(-) rename graphics/pokenav/{862323C.bin => condition/graph_data.bin} (100%) rename graphics/pokenav/{8623338.pal => condition/mon_markings.pal} (100%) rename graphics/pokenav/{condition_search2.bin => condition/search_results.bin} (100%) rename graphics/pokenav/{condition_search2.png => condition/search_results.png} (100%) rename graphics/pokenav/{8623570.pal => condition/search_results_list.pal} (100%) diff --git a/graphics/pokenav/862323C.bin b/graphics/pokenav/condition/graph_data.bin similarity index 100% rename from graphics/pokenav/862323C.bin rename to graphics/pokenav/condition/graph_data.bin diff --git a/graphics/pokenav/8623338.pal b/graphics/pokenav/condition/mon_markings.pal similarity index 100% rename from graphics/pokenav/8623338.pal rename to graphics/pokenav/condition/mon_markings.pal diff --git a/graphics/pokenav/condition_search2.bin b/graphics/pokenav/condition/search_results.bin similarity index 100% rename from graphics/pokenav/condition_search2.bin rename to graphics/pokenav/condition/search_results.bin diff --git a/graphics/pokenav/condition_search2.png b/graphics/pokenav/condition/search_results.png similarity index 100% rename from graphics/pokenav/condition_search2.png rename to graphics/pokenav/condition/search_results.png diff --git a/graphics/pokenav/8623570.pal b/graphics/pokenav/condition/search_results_list.pal similarity index 100% rename from graphics/pokenav/8623570.pal rename to graphics/pokenav/condition/search_results_list.pal diff --git a/include/menu_specialized.h b/include/menu_specialized.h index 146b930b4..d1e30d4d6 100644 --- a/include/menu_specialized.h +++ b/include/menu_specialized.h @@ -26,6 +26,11 @@ enum { TAG_CONDITION_MARKINGS_MENU_2, // Used implicitly by CreateMonMarkingsMenuSprites }; +enum { + CONDITION_ICON_SELECTED, + CONDITION_ICON_UNSELECTED, +}; + #define MAX_CONDITION_SPARKLES 10 // The number of extra sparkles shown on a Pokémon's condition screen. diff --git a/include/pokenav.h b/include/pokenav.h index b8c2178d1..847d4b7e7 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -65,8 +65,7 @@ enum POKENAV_MODE_FORCE_CALL_EXIT, // Pokenav tutorial after calling Mr. Stone }; -// TODO - refine these names -enum Substructures +enum { POKENAV_SUBSTRUCT_MAIN_MENU, POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, @@ -76,11 +75,11 @@ enum Substructures POKENAV_SUBSTRUCT_MATCH_CALL_MAIN, POKENAV_SUBSTRUCT_MATCH_CALL_OPEN, POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS, - POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST, + POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX, POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, - POKENAV_SUBSTRUCT_CONDITION_GRAPH, - POKENAV_SUBSTRUCT_MON_MARK_MENU, + POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU, + POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX, POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST, POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU, POKENAV_SUBSTRUCT_15, //unused @@ -113,21 +112,21 @@ enum #define POKENAV_MENU_IDS_START 100000 enum { - POKENAV_MAIN_MENU = POKENAV_MENU_IDS_START, + POKENAV_MAIN_MENU = POKENAV_MENU_IDS_START, // The main menu where the player selects Hoenn Map/Condition/Match Call/Ribbons POKENAV_MAIN_MENU_CURSOR_ON_MAP, - POKENAV_CONDITION_MENU, - POKENAV_CONDITION_SEARCH_MENU, + POKENAV_CONDITION_MENU, // The first Condition screen where the player selects Party or Search + POKENAV_CONDITION_SEARCH_MENU, // The Condition search menu where the player selects a search parameter POKENAV_MAIN_MENU_CURSOR_ON_MATCH_CALL, POKENAV_MAIN_MENU_CURSOR_ON_RIBBONS, POKENAV_REGION_MAP, - POKENAV_CONDITION_PARTY, - POKENAV_CONDITION_SEARCH_RESULTS, - POKENAV_CONDITION_GRAPH_FROM_SEARCH, // opening condition graph from search list - POKENAV_RETURN_CONDITION_SEARCH, //return to search list from condition graph + POKENAV_CONDITION_GRAPH_PARTY, // The Condition graph screen when Party has been selected + POKENAV_CONDITION_SEARCH_RESULTS, // The list of results from a Condition search + POKENAV_CONDITION_GRAPH_SEARCH, // The Condition graph screen when a search result has been selected + POKENAV_RETURN_CONDITION_SEARCH, // Exited the graph screen back to the list of Condition search results POKENAV_MATCH_CALL, - POKENAV_RIBBONS_MON_LIST, - POKENAV_RIBBONS_SUMMARY_SCREEN, - POKENAV_RIBBONS_RETURN_TO_MON_LIST, + POKENAV_RIBBONS_MON_LIST, // The list of Pokémon with ribbons + POKENAV_RIBBONS_SUMMARY_SCREEN, // The ribbon summary screen shown when a Pokémon has been selected + POKENAV_RIBBONS_RETURN_TO_MON_LIST, // Exited the summary screen back to the ribbon list }; enum @@ -245,15 +244,15 @@ enum RegionMapFuncIds POKENAV_MENU_FUNC_OPEN_FEATURE, }; -enum PartyConditionFuncIds +enum { - PARTY_CONDITION_FUNC_NONE, - PARTY_CONDITION_FUNC_SLIDE_MON_IN, - PARTY_CONDITION_FUNC_RETURN, - PARTY_CONDITION_FUNC_NO_TRANSITION, - PARTY_CONDITION_FUNC_SLIDE_MON_OUT, - PARTY_CONDITION_FUNC_ADD_MARKINGS, - PARTY_CONDITION_FUNC_CLOSE_MARKINGS, + CONDITION_FUNC_NONE, + CONDITION_FUNC_SLIDE_MON_IN, + CONDITION_FUNC_RETURN, + CONDITION_FUNC_NO_TRANSITION, + CONDITION_FUNC_SLIDE_MON_OUT, + CONDITION_FUNC_ADD_MARKINGS, + CONDITION_FUNC_CLOSE_MARKINGS, }; enum @@ -264,6 +263,13 @@ enum NUM_CONDITION_MONS }; +enum +{ + CONDITION_LOAD_MON_INFO, + CONDITION_LOAD_GRAPH, + CONDITION_LOAD_MON_PIC, +}; + #define POKENAV_MENU_FUNC_EXIT -1 enum @@ -431,17 +437,17 @@ void FreeRegionMapSubstruct1(void); void FreeRegionMapSubstruct2(void); // pokenav_conditions_1.c -u32 PokenavCallback_Init_PartyCondition(void); -u32 PokenavCallback_Init_ConditionGraphFromSearch(void); -u32 GetPartyConditionCallback(void); -void FreePartyConditionSubstruct1(void); -bool32 LoadPartyConditionMenuGfx(void); +u32 PokenavCallback_Init_ConditionGraph_Party(void); +u32 PokenavCallback_Init_ConditionGraph_Search(void); +u32 GetConditionGraphMenuCallback(void); +void FreeConditionGraphMenuSubstruct1(void); +bool32 LoadConditionGraphMenuGfx(void); bool32 IsConditionMenuSearchMode(void); struct ConditionGraph *GetConditionGraphPtr(void); -u16 GetConditionGraphCurrentMonIndex(void); +u16 GetConditionGraphCurrentListIndex(void); u16 GetMonListCount(void); u8 GetNumConditionMonSparkles(void); -bool32 SetConditionGraphData(u8 mode); +bool32 LoadNextConditionMenuMonData(u8 mode); u8 TryGetMonMarkId(void); u8 *GetConditionMonNameText(u8 id); u8 *GetConditionMonLocationText(u8 id); @@ -450,10 +456,10 @@ void *GetConditionMonPicGfx(u8 id); void *GetConditionMonPal(u8 id); // pokenav_conditions_2.c -bool32 OpenPartyConditionMenu(void); -void CreatePartyConditionLoopedTask(s32); -u32 IsPartyConditionLoopedTaskActive(void); -void FreePartyConditionSubstruct2(void); +bool32 OpenConditionGraphMenu(void); +void CreateConditionGraphMenuLoopedTask(s32); +u32 IsConditionGraphMenuLoopedTaskActive(void); +void FreeConditionGraphMenuSubstruct2(void); u8 GetMonMarkingsData(void); // pokenav_conditions_3.c diff --git a/include/strings.h b/include/strings.h index 7317f8aac..48a2eccd7 100644 --- a/include/strings.h +++ b/include/strings.h @@ -2974,8 +2974,8 @@ extern const u8 gText_FindToughPokemon[]; extern const u8 gText_ReturnToConditionMenu[]; extern const u8 gText_NoRibbonWinners[]; -// Pokenav Ribbons -extern const u8 gText_NumberF700[]; +// Pokenav +extern const u8 gText_NumberIndex[]; extern const u8 gText_RibbonsF700[]; // use_pokeblock diff --git a/src/menu_specialized.c b/src/menu_specialized.c index 074621de4..d1cc3ff58 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -318,7 +318,7 @@ void MailboxMenu_Free(void) // filled with the graph color. //--------------------------------------- -#define UNK_VAL(n, s)(((n) >> (s)) + (((n) >> ((s) - 1)) & 1)) +#define SHIFT_RIGHT_ADJUSTED(n, s)(((n) >> (s)) + (((n) >> ((s) - 1)) & 1)) void ConditionGraph_Init(struct ConditionGraph *graph) { @@ -360,7 +360,7 @@ void ConditionGraph_SetNewPositions(struct ConditionGraph *graph, struct UCoords increment = ((new[i].x - old[i].x) << 8) / CONDITION_GRAPH_UPDATE_STEPS; for (j = 0; j < CONDITION_GRAPH_UPDATE_STEPS - 1; j++) { - graph->newPositions[j][i].x = UNK_VAL(coord, 8); + graph->newPositions[j][i].x = SHIFT_RIGHT_ADJUSTED(coord, 8); coord += increment; } graph->newPositions[j][i].x = new[i].x; @@ -369,7 +369,7 @@ void ConditionGraph_SetNewPositions(struct ConditionGraph *graph, struct UCoords increment = ((new[i].y - old[i].y) << 8) / CONDITION_GRAPH_UPDATE_STEPS; for (j = 0; j < CONDITION_GRAPH_UPDATE_STEPS - 1; j++) { - graph->newPositions[j][i].y = UNK_VAL(coord, 8); + graph->newPositions[j][i].y = SHIFT_RIGHT_ADJUSTED(coord, 8); coord += increment; } graph->newPositions[j][i].y = new[i].y; @@ -500,7 +500,7 @@ static void ConditionGraph_CalcLine(struct ConditionGraph *graph, u16 *scanline, scanline += (top - CONDITION_GRAPH_TOP_Y) * 2; for (i = 0; i < height; i++) { - scanline[dir] = UNK_VAL(x, 10) + dir; + scanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir; x += xIncrement; scanline += 2; } @@ -511,7 +511,7 @@ static void ConditionGraph_CalcLine(struct ConditionGraph *graph, u16 *scanline, { overflowScanline += (top - CONDITION_GRAPH_TOP_Y) * 2; // Less readable than the other loops, but it has to be written this way to match. - for (i = 0; i < height; overflowScanline[dir] = UNK_VAL(x, 10) + dir, x += xIncrement, overflowScanline += 2, i++) + for (i = 0; i < height; overflowScanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir, x += xIncrement, overflowScanline += 2, i++) { if (x >= (CONDITION_GRAPH_CENTER_X << 10)) break; @@ -521,7 +521,7 @@ static void ConditionGraph_CalcLine(struct ConditionGraph *graph, u16 *scanline, scanline += (graph->bottom - CONDITION_GRAPH_TOP_Y) * 2; for (; i < height; i++) { - scanline[dir] = UNK_VAL(x, 10) + dir; + scanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir; x += xIncrement; scanline += 2; } @@ -533,7 +533,7 @@ static void ConditionGraph_CalcLine(struct ConditionGraph *graph, u16 *scanline, scanline += (top - CONDITION_GRAPH_TOP_Y) * 2; for (i = 0; i < height; i++) { - scanline[dir] = UNK_VAL(x, 10) + dir; + scanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir; if (x < (CONDITION_GRAPH_CENTER_X << 10)) { scanline[dir] = CONDITION_GRAPH_CENTER_X; @@ -547,7 +547,7 @@ static void ConditionGraph_CalcLine(struct ConditionGraph *graph, u16 *scanline, overflowScanline += (graph->bottom - CONDITION_GRAPH_TOP_Y) * 2; for (; i < height; i++) { - overflowScanline[dir] = UNK_VAL(x, 10) + dir; + overflowScanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir; x += xIncrement; overflowScanline += 2; } @@ -1167,8 +1167,8 @@ static const union AnimCmd sAnim_ConditionSelectionIcon_Unselected[] = static const union AnimCmd *const sAnims_ConditionSelectionIcon[] = { - sAnim_ConditionSelectionIcon_Selected, - sAnim_ConditionSelectionIcon_Unselected + [CONDITION_ICON_SELECTED] = sAnim_ConditionSelectionIcon_Selected, + [CONDITION_ICON_UNSELECTED] = sAnim_ConditionSelectionIcon_Unselected }; // Just loads the generic data, up to the caller to load the actual sheet/pal for the specific mon diff --git a/src/pokenav.c b/src/pokenav.c index 4338023db..b09fc9da0 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -122,15 +122,15 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] = .free1 = FreeRegionMapSubstruct1, .free2 = FreeRegionMapSubstruct2, }, - [POKENAV_CONDITION_PARTY - POKENAV_MENU_IDS_START] = + [POKENAV_CONDITION_GRAPH_PARTY - POKENAV_MENU_IDS_START] = { - .init = PokenavCallback_Init_PartyCondition, - .callback = GetPartyConditionCallback, - .open = OpenPartyConditionMenu, - .createLoopTask = CreatePartyConditionLoopedTask, - .isLoopTaskActive = IsPartyConditionLoopedTaskActive, - .free1 = FreePartyConditionSubstruct1, - .free2 = FreePartyConditionSubstruct2, + .init = PokenavCallback_Init_ConditionGraph_Party, + .callback = GetConditionGraphMenuCallback, + .open = OpenConditionGraphMenu, + .createLoopTask = CreateConditionGraphMenuLoopedTask, + .isLoopTaskActive = IsConditionGraphMenuLoopedTaskActive, + .free1 = FreeConditionGraphMenuSubstruct1, + .free2 = FreeConditionGraphMenuSubstruct2, }, [POKENAV_CONDITION_SEARCH_RESULTS - POKENAV_MENU_IDS_START] = { @@ -142,15 +142,15 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] = .free1 = FreeSearchResultSubstruct1, .free2 = FreeSearchResultSubstruct2, }, - [POKENAV_CONDITION_GRAPH_FROM_SEARCH - POKENAV_MENU_IDS_START] = + [POKENAV_CONDITION_GRAPH_SEARCH - POKENAV_MENU_IDS_START] = { - .init = PokenavCallback_Init_ConditionGraphFromSearch, - .callback = GetPartyConditionCallback, - .open = OpenPartyConditionMenu, - .createLoopTask = CreatePartyConditionLoopedTask, - .isLoopTaskActive = IsPartyConditionLoopedTaskActive, - .free1 = FreePartyConditionSubstruct1, - .free2 = FreePartyConditionSubstruct2, + .init = PokenavCallback_Init_ConditionGraph_Search, + .callback = GetConditionGraphMenuCallback, + .open = OpenConditionGraphMenu, + .createLoopTask = CreateConditionGraphMenuLoopedTask, + .isLoopTaskActive = IsConditionGraphMenuLoopedTaskActive, + .free1 = FreeConditionGraphMenuSubstruct1, + .free2 = FreeConditionGraphMenuSubstruct2, }, [POKENAV_RETURN_CONDITION_SEARCH - POKENAV_MENU_IDS_START] = { diff --git a/src/pokenav_conditions_1.c b/src/pokenav_conditions_1.c index 607437c47..fc188db71 100644 --- a/src/pokenav_conditions_1.c +++ b/src/pokenav_conditions_1.c @@ -13,102 +13,105 @@ #include "text.h" #include "constants/songs.h" -struct PokenavSub11 +struct Pokenav_ConditionMenu { u32 monPal[NUM_CONDITION_MONS][0x20]; u8 fill[0x180]; u32 monPicGfx[NUM_CONDITION_MONS][MON_PIC_SIZE]; - u8 searchMode; - s16 monIndex; - u32 (*callback)(struct PokenavSub11 *); - u8 fill2[0x6320 - 0x6308]; + bool8 inSearchMode; + s16 toLoadListIndex; + u32 (*callback)(struct Pokenav_ConditionMenu *); + u8 fill2[0x18]; u8 locationText[NUM_CONDITION_MONS][24]; u8 nameText[NUM_CONDITION_MONS][64]; struct ConditionGraph graph; u8 numSparkles[NUM_CONDITION_MONS]; u8 monMarks[NUM_CONDITION_MONS]; - s8 mark; - s8 unk6787; - s8 unk6788; - s8 unk6789; + s8 loadId; + s8 nextLoadIdDown; + s8 nextLoadIdUp; + s8 toLoadId; u8 state; }; static void InitPartyConditionListParameters(void); static void InitSearchResultsConditionList(void); -static u32 HandlePartyConditionInput(struct PokenavSub11 *); -static u32 GetConditionReturnCallback(struct PokenavSub11 *); -static u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *); -static u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *); +static u32 HandleConditionMenuInput(struct Pokenav_ConditionMenu *); +static u32 GetConditionReturnCallback(struct Pokenav_ConditionMenu *); +static u32 OpenMarkingsMenu(struct Pokenav_ConditionMenu *); +static u8 ConditionGraphHandleDpadInput(struct Pokenav_ConditionMenu *); static u8 SwitchConditionSummaryIndex(bool8); static void CopyMonNameGenderLocation(s16, u8); static void GetMonConditionGraphData(s16, u8); static void ConditionGraphDrawMonPic(s16, u8); -bool32 PokenavCallback_Init_PartyCondition(void) +bool32 PokenavCallback_Init_ConditionGraph_Party(void) { - struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11)); + struct Pokenav_ConditionMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU, sizeof(struct Pokenav_ConditionMenu)); - if (structPtr == NULL) + if (menu == NULL) return FALSE; - ConditionGraph_Init(&structPtr->graph); + ConditionGraph_Init(&menu->graph); InitPartyConditionListParameters(); gKeyRepeatStartDelay = 20; - structPtr->callback = HandlePartyConditionInput; + menu->callback = HandleConditionMenuInput; return TRUE; } -bool32 PokenavCallback_Init_ConditionGraphFromSearch(void) +bool32 PokenavCallback_Init_ConditionGraph_Search(void) { - struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11)); + struct Pokenav_ConditionMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU, sizeof(struct Pokenav_ConditionMenu)); - if (structPtr == NULL) + if (menu == NULL) return FALSE; - ConditionGraph_Init(&structPtr->graph); + ConditionGraph_Init(&menu->graph); InitSearchResultsConditionList(); gKeyRepeatStartDelay = 20; - structPtr->callback = HandlePartyConditionInput; + menu->callback = HandleConditionMenuInput; return TRUE; } -u32 GetPartyConditionCallback(void) +u32 GetConditionGraphMenuCallback(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); - return structPtr->callback(structPtr); + return menu->callback(menu); } -static u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr) +static u32 HandleConditionMenuInput(struct Pokenav_ConditionMenu *menu) { struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - u32 ret = ConditionGraphHandleDpadInput(structPtr); + u32 ret = ConditionGraphHandleDpadInput(menu); - if (ret == PARTY_CONDITION_FUNC_NONE) + if (ret == CONDITION_FUNC_NONE) { if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); - structPtr->callback = GetConditionReturnCallback; - ret = PARTY_CONDITION_FUNC_RETURN; + menu->callback = GetConditionReturnCallback; + ret = CONDITION_FUNC_RETURN; } else if (JOY_NEW(A_BUTTON)) { - if (structPtr->searchMode == 0) + if (!menu->inSearchMode) { + // In Party mode, pressing A only applies to the Cancel button if (monListPtr->currIndex == monListPtr->listCount - 1) { + // Cancel PlaySE(SE_SELECT); - structPtr->callback = GetConditionReturnCallback; - ret = PARTY_CONDITION_FUNC_RETURN; + menu->callback = GetConditionReturnCallback; + ret = CONDITION_FUNC_RETURN; } } else { + // In Search mode pressing A brings up the markings menu PlaySE(SE_SELECT); - ret = PARTY_CONDITION_FUNC_ADD_MARKINGS; - structPtr->callback = ConditionMenu_OpenMarkingsMenu; + ret = CONDITION_FUNC_ADD_MARKINGS; + menu->callback = OpenMarkingsMenu; } } } @@ -116,57 +119,58 @@ static u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr) return ret; } -static u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr) +static u32 OpenMarkingsMenu(struct Pokenav_ConditionMenu *menu) { struct PokenavSub18 *monListPtr; u8 markings; - u32 ret = PARTY_CONDITION_FUNC_NONE, boxId, monId; + u32 ret = CONDITION_FUNC_NONE, boxId, monId; if (!HandleMonMarkingsMenuInput()) { - structPtr->monMarks[structPtr->mark] = GetMonMarkingsData(); + menu->monMarks[menu->loadId] = GetMonMarkingsData(); monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); boxId = monListPtr->monData[monListPtr->currIndex].boxId; monId = monListPtr->monData[monListPtr->currIndex].monId; - markings = structPtr->monMarks[structPtr->mark]; + markings = menu->monMarks[menu->loadId]; if (boxId == TOTAL_BOXES_COUNT) SetMonData(&gPlayerParty[monId], MON_DATA_MARKINGS, &markings); else SetBoxMonDataAt(boxId, monId, MON_DATA_MARKINGS, &markings); - structPtr->callback = HandlePartyConditionInput; - ret = PARTY_CONDITION_FUNC_CLOSE_MARKINGS; + menu->callback = HandleConditionMenuInput; + ret = CONDITION_FUNC_CLOSE_MARKINGS; } return ret; } -static u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr) +static u32 GetConditionReturnCallback(struct Pokenav_ConditionMenu *menu) { - if (structPtr->searchMode == 0) + if (!menu->inSearchMode) return POKENAV_CONDITION_MENU; else return POKENAV_RETURN_CONDITION_SEARCH; } -void FreePartyConditionSubstruct1(void) +void FreeConditionGraphMenuSubstruct1(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - if (structPtr->searchMode == 0) + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); + if (!menu->inSearchMode) FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST); - FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); } -static u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr) +static u8 ConditionGraphHandleDpadInput(struct Pokenav_ConditionMenu *menu) { struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - u8 ret = 0; + u8 ret = CONDITION_FUNC_NONE; if (JOY_HELD(DPAD_UP)) { - if (structPtr->searchMode == 0 || monListPtr->currIndex != 0) + // Prevent input wrapping in search mode + if (!menu->inSearchMode || monListPtr->currIndex != 0) { PlaySE(SE_SELECT); ret = SwitchConditionSummaryIndex(TRUE); @@ -174,7 +178,8 @@ static u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr) } else if (JOY_HELD(DPAD_DOWN)) { - if (structPtr->searchMode == 0 || monListPtr->currIndex < monListPtr->listCount - 1) + // Prevent input wrapping in search mode + if (!menu->inSearchMode || monListPtr->currIndex < monListPtr->listCount - 1) { PlaySE(SE_SELECT); ret = SwitchConditionSummaryIndex(FALSE); @@ -186,52 +191,52 @@ static u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr) static u8 SwitchConditionSummaryIndex(u8 moveUp) { - u16 r7; + u16 newLoadId; bool8 wasNotLastMon, isNotLastMon; - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - r7 = (moveUp) ? structPtr->unk6788 : structPtr->unk6787; - ConditionGraph_SetNewPositions(&structPtr->graph, structPtr->graph.savedPositions[structPtr->mark], structPtr->graph.savedPositions[r7]); - wasNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1)); + newLoadId = (moveUp) ? menu->nextLoadIdUp : menu->nextLoadIdDown; + ConditionGraph_SetNewPositions(&menu->graph, menu->graph.savedPositions[menu->loadId], menu->graph.savedPositions[newLoadId]); + wasNotLastMon = (monListPtr->currIndex != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1)); if (moveUp) { - structPtr->unk6788 = structPtr->unk6787; - structPtr->unk6787 = structPtr->mark; - structPtr->mark = r7; - structPtr->unk6789 = structPtr->unk6788; + menu->nextLoadIdUp = menu->nextLoadIdDown; + menu->nextLoadIdDown = menu->loadId; + menu->loadId = newLoadId; + menu->toLoadId = menu->nextLoadIdUp; monListPtr->currIndex = (monListPtr->currIndex == 0) ? monListPtr->listCount - 1 : monListPtr->currIndex - 1; - structPtr->monIndex = (monListPtr->currIndex != 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1; + menu->toLoadListIndex = (monListPtr->currIndex != 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1; } else { - structPtr->unk6787 = structPtr->unk6788; - structPtr->unk6788 = structPtr->mark; - structPtr->mark = r7; - structPtr->unk6789 = structPtr->unk6787; + menu->nextLoadIdDown = menu->nextLoadIdUp; + menu->nextLoadIdUp = menu->loadId; + menu->loadId = newLoadId; + menu->toLoadId = menu->nextLoadIdDown; monListPtr->currIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0; - structPtr->monIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0; + menu->toLoadListIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0; } - isNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1)); + isNotLastMon = (monListPtr->currIndex != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1)); if (!wasNotLastMon) - return PARTY_CONDITION_FUNC_NO_TRANSITION; + return CONDITION_FUNC_NO_TRANSITION; else if (!isNotLastMon) - return PARTY_CONDITION_FUNC_SLIDE_MON_OUT; + return CONDITION_FUNC_SLIDE_MON_OUT; else - return PARTY_CONDITION_FUNC_SLIDE_MON_IN; + return CONDITION_FUNC_SLIDE_MON_IN; } -bool32 LoadPartyConditionMenuGfx(void) +bool32 LoadConditionGraphMenuGfx(void) { s32 var; - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - switch (structPtr->state) + switch (menu->state) { case 0: CopyMonNameGenderLocation(monListPtr->currIndex, CONDITION_MON_0); @@ -245,17 +250,17 @@ bool32 LoadPartyConditionMenuGfx(void) case 3: if (monListPtr->listCount == 1) { - structPtr->mark = CONDITION_MON_0; - structPtr->unk6787 = CONDITION_MON_0; - structPtr->unk6788 = CONDITION_MON_0; - structPtr->state = 0; + menu->loadId = CONDITION_MON_0; + menu->nextLoadIdDown = CONDITION_MON_0; + menu->nextLoadIdUp = CONDITION_MON_0; + menu->state = 0; return TRUE; } else { - structPtr->mark = CONDITION_MON_0; - structPtr->unk6787 = CONDITION_MON_1; - structPtr->unk6788 = CONDITION_MON_2; + menu->loadId = CONDITION_MON_0; + menu->nextLoadIdDown = CONDITION_MON_1; + menu->nextLoadIdUp = CONDITION_MON_2; } break; // These were probably ternaries just like cases 7-9, but couldn't match it any other way. @@ -285,28 +290,28 @@ bool32 LoadPartyConditionMenuGfx(void) break; case 9: ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2); - structPtr->state = 0; + menu->state = 0; return TRUE; } - structPtr->state++; + menu->state++; return FALSE; } -bool32 SetConditionGraphData(u8 mode) +bool32 LoadNextConditionMenuMonData(u8 mode) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); switch (mode) { - case 0: - CopyMonNameGenderLocation(structPtr->monIndex, structPtr->unk6789); + case CONDITION_LOAD_MON_INFO: + CopyMonNameGenderLocation(menu->toLoadListIndex, menu->toLoadId); break; - case 1: - GetMonConditionGraphData(structPtr->monIndex, structPtr->unk6789); + case CONDITION_LOAD_GRAPH: + GetMonConditionGraphData(menu->toLoadListIndex, menu->toLoadId); break; - case 2: - ConditionGraphDrawMonPic(structPtr->monIndex, structPtr->unk6789); + case CONDITION_LOAD_MON_PIC: + ConditionGraphDrawMonPic(menu->toLoadListIndex, menu->toLoadId); return TRUE; } @@ -419,42 +424,42 @@ static u8 *CopyConditionMonNameGender(u8 *str, u16 listId, bool8 arg3) static void CopyMonNameGenderLocation(s16 listId, u8 loadId) { u16 boxId, i; - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - if (listId != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) + if (listId != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1)) { - CopyConditionMonNameGender(structPtr->nameText[loadId], listId, FALSE); + CopyConditionMonNameGender(menu->nameText[loadId], listId, FALSE); boxId = monListPtr->monData[listId].boxId; - structPtr->locationText[loadId][0] = EXT_CTRL_CODE_BEGIN; - structPtr->locationText[loadId][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; - structPtr->locationText[loadId][2] = TEXT_COLOR_BLUE; - structPtr->locationText[loadId][3] = TEXT_COLOR_TRANSPARENT; - structPtr->locationText[loadId][4] = TEXT_COLOR_LIGHT_BLUE; + menu->locationText[loadId][0] = EXT_CTRL_CODE_BEGIN; + menu->locationText[loadId][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; + menu->locationText[loadId][2] = TEXT_COLOR_BLUE; + menu->locationText[loadId][3] = TEXT_COLOR_TRANSPARENT; + menu->locationText[loadId][4] = TEXT_COLOR_LIGHT_BLUE; if (boxId == TOTAL_BOXES_COUNT) - CopyStringLeftAlignedToConditionData(&structPtr->locationText[loadId][5], gText_InParty, BOX_NAME_LENGTH); + CopyStringLeftAlignedToConditionData(&menu->locationText[loadId][5], gText_InParty, BOX_NAME_LENGTH); else - CopyStringLeftAlignedToConditionData(&structPtr->locationText[loadId][5], GetBoxNamePtr(boxId), BOX_NAME_LENGTH); + CopyStringLeftAlignedToConditionData(&menu->locationText[loadId][5], GetBoxNamePtr(boxId), BOX_NAME_LENGTH); } else { for (i = 0; i < 12; i++) - structPtr->nameText[loadId][i] = CHAR_SPACE; - structPtr->nameText[loadId][i] = EOS; + menu->nameText[loadId][i] = CHAR_SPACE; + menu->nameText[loadId][i] = EOS; for (i = 0; i < BOX_NAME_LENGTH; i++) - structPtr->locationText[loadId][i] = CHAR_SPACE; - structPtr->locationText[loadId][i] = EOS; + menu->locationText[loadId][i] = CHAR_SPACE; + menu->locationText[loadId][i] = EOS; } } static void InitPartyConditionListParameters(void) { u16 i, count; - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); struct PokenavSub18 *monListPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18)); - structPtr->searchMode = 0; + menu->inSearchMode = FALSE; for (i = 0, count = 0; i < CalculatePlayerPartyCount(); i++) { if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)) @@ -471,42 +476,43 @@ static void InitPartyConditionListParameters(void) monListPtr->monData[count].data = 0; monListPtr->currIndex = 0; monListPtr->listCount = count + 1; - structPtr->state = 0; + menu->state = 0; } static void InitSearchResultsConditionList(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - structPtr->searchMode = 1; - structPtr->state = 0; + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); + menu->inSearchMode = TRUE; + menu->state = 0; } static void GetMonConditionGraphData(s16 listId, u8 loadId) { u16 boxId, monId, i; - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - if (listId != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) + if (listId != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1)) { boxId = monListPtr->monData[listId].boxId; monId = monListPtr->monData[listId].monId; - structPtr->graph.conditions[loadId][CONDITION_COOL] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); - structPtr->graph.conditions[loadId][CONDITION_TOUGH] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); - structPtr->graph.conditions[loadId][CONDITION_SMART] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); - structPtr->graph.conditions[loadId][CONDITION_CUTE] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); - structPtr->graph.conditions[loadId][CONDITION_BEAUTY] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); - structPtr->numSparkles[loadId] = GET_NUM_CONDITION_SPARKLES(GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL)); - structPtr->monMarks[loadId] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL); - ConditionGraph_CalcPositions(structPtr->graph.conditions[loadId], structPtr->graph.savedPositions[loadId]); + menu->graph.conditions[loadId][CONDITION_COOL] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); + menu->graph.conditions[loadId][CONDITION_TOUGH] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); + menu->graph.conditions[loadId][CONDITION_SMART] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); + menu->graph.conditions[loadId][CONDITION_CUTE] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); + menu->graph.conditions[loadId][CONDITION_BEAUTY] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); + menu->numSparkles[loadId] = GET_NUM_CONDITION_SPARKLES(GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL)); + menu->monMarks[loadId] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL); + ConditionGraph_CalcPositions(menu->graph.conditions[loadId], menu->graph.savedPositions[loadId]); } else { + // Set empty graph point for (i = 0; i < CONDITION_COUNT; i++) { - structPtr->graph.conditions[loadId][i] = 0; - structPtr->graph.savedPositions[loadId][i].x = CONDITION_GRAPH_CENTER_X; - structPtr->graph.savedPositions[loadId][i].y = CONDITION_GRAPH_CENTER_Y; + menu->graph.conditions[loadId][i] = 0; + menu->graph.savedPositions[loadId][i].x = CONDITION_GRAPH_CENTER_X; + menu->graph.savedPositions[loadId][i].y = CONDITION_GRAPH_CENTER_Y; } } } @@ -515,10 +521,10 @@ static void ConditionGraphDrawMonPic(s16 listId, u8 loadId) { u16 boxId, monId, species; u32 personality, tid; - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - if (listId == (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) + if (listId == (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1)) return; boxId = monListPtr->monData[listId].boxId; @@ -526,8 +532,8 @@ static void ConditionGraphDrawMonPic(s16 listId, u8 loadId) species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL); tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL); personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL); - LoadSpecialPokePic(&gMonFrontPicTable[species], structPtr->monPicGfx[loadId], species, personality, TRUE); - LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), structPtr->monPal[loadId]); + LoadSpecialPokePic(&gMonFrontPicTable[species], menu->monPicGfx[loadId], species, personality, TRUE); + LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), menu->monPal[loadId]); } u16 GetMonListCount(void) @@ -536,7 +542,7 @@ u16 GetMonListCount(void) return monListPtr->listCount; } -u16 GetConditionGraphCurrentMonIndex(void) +u16 GetConditionGraphCurrentListIndex(void) { struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); return monListPtr->currIndex; @@ -544,50 +550,50 @@ u16 GetConditionGraphCurrentMonIndex(void) struct ConditionGraph *GetConditionGraphPtr(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return &structPtr->graph; + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); + return &menu->graph; } -u8 GetMonMarkIndex(void) +u8 GetConditionGraphMenuCurrentLoadIndex(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return structPtr->mark; + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); + return menu->loadId; } -u8 sub_81CDC9C(void) +u8 GetConditionGraphMenuToLoadListIndex(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return structPtr->monIndex; + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); + return menu->toLoadListIndex; } void *GetConditionMonPicGfx(u8 loadId) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return structPtr->monPicGfx[loadId]; + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); + return menu->monPicGfx[loadId]; } void *GetConditionMonPal(u8 loadId) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return structPtr->monPal[loadId]; + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); + return menu->monPal[loadId]; } -u8 sub_81CDCEC(void) +u8 GetConditionGraphMenuToLoadId(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return structPtr->unk6789; + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); + return menu->toLoadId; } u8 *GetConditionMonNameText(u8 loadId) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return structPtr->nameText[loadId]; + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); + return menu->nameText[loadId]; } u8 *GetConditionMonLocationText(u8 loadId) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return structPtr->locationText[loadId]; + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); + return menu->locationText[loadId]; } u16 GetConditionMonDataBuffer(void) @@ -598,24 +604,25 @@ u16 GetConditionMonDataBuffer(void) bool32 IsConditionMenuSearchMode(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - if (structPtr->searchMode == 1) + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); + if (menu->inSearchMode == TRUE) return TRUE; else return FALSE; } +// Markings are only shown in search mode u8 TryGetMonMarkId(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - if (structPtr->searchMode == 1) - return structPtr->monMarks[structPtr->mark]; + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); + if (menu->inSearchMode == TRUE) + return menu->monMarks[menu->loadId]; else return 0; } u8 GetNumConditionMonSparkles(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return structPtr->numSparkles[structPtr->mark]; + struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); + return menu->numSparkles[menu->loadId]; } diff --git a/src/pokenav_conditions_2.c b/src/pokenav_conditions_2.c index c2e8cadea..cecba800c 100644 --- a/src/pokenav_conditions_2.c +++ b/src/pokenav_conditions_2.c @@ -16,21 +16,21 @@ #include "text.h" static u32 LoopedTask_TransitionMons(s32); -static u32 LoopedTask_ExitPartyConditionMenu(s32); +static u32 LoopedTask_ExitConditionGraphMenu(s32); static u32 LoopedTask_MoveCursorNoTransition(s32); static u32 LoopedTask_SlideMonOut(s32); static u32 LoopedTask_OpenMonMarkingsWindow(s32); static u32 LoopedTask_CloseMonMarkingsWindow(s32); -static u8 sUnknown_030012BC; +static u8 sInitialLoadId; // Never read const u16 gConditionGraphData_Pal[] = INCBIN_U16("graphics/pokenav/condition/graph_data.gbapal"); const u16 gConditionText_Pal[] = INCBIN_U16("graphics/pokenav/condition/text.gbapal"); -static const u32 sUnknown_08623228[] = INCBIN_U32("graphics/pokenav/condition/graph_data.4bpp.lz"); -static const u32 sConditionGraph_Tilemap[] = INCBIN_U32("graphics/pokenav/862323C.bin.lz"); -static const u16 sConditionGraphMonMarkingsPal[] = INCBIN_U16("graphics/pokenav/8623338.gbapal"); +static const u32 sConditionGraphData_Gfx[] = INCBIN_U32("graphics/pokenav/condition/graph_data.4bpp.lz"); +static const u32 sConditionGraphData_Tilemap[] = INCBIN_U32("graphics/pokenav/condition/graph_data.bin.lz"); +static const u16 sMonMarkings_Pal[] = INCBIN_U16("graphics/pokenav/condition/mon_markings.gbapal"); -static const struct BgTemplate sPartyConditionBgTemplates[3] = +static const struct BgTemplate sMenuBgTemplates[3] = { { .bg = 1, @@ -72,7 +72,7 @@ static const struct WindowTemplate sMonNameGenderWindowTemplate = .baseBlock = 2 }; -static const struct WindowTemplate sConditionGraphListIdWindowTemplate = +static const struct WindowTemplate sListIndexWindowTemplate = { .bg = 1, .tilemapLeft = 1, @@ -105,29 +105,29 @@ static const struct WindowTemplate sUnusedWindowTemplate2 = .baseBlock = 0x44 }; -static const LoopedTask sPartyConditionLoopedTaskFuncs[] = +static const LoopedTask sLoopedTaskFuncs[] = { - [PARTY_CONDITION_FUNC_NONE] = NULL, - [PARTY_CONDITION_FUNC_SLIDE_MON_IN] = LoopedTask_TransitionMons, - [PARTY_CONDITION_FUNC_RETURN] = LoopedTask_ExitPartyConditionMenu, - [PARTY_CONDITION_FUNC_NO_TRANSITION] = LoopedTask_MoveCursorNoTransition, - [PARTY_CONDITION_FUNC_SLIDE_MON_OUT] = LoopedTask_SlideMonOut, - [PARTY_CONDITION_FUNC_ADD_MARKINGS] = LoopedTask_OpenMonMarkingsWindow, - [PARTY_CONDITION_FUNC_CLOSE_MARKINGS] = LoopedTask_CloseMonMarkingsWindow + [CONDITION_FUNC_NONE] = NULL, + [CONDITION_FUNC_SLIDE_MON_IN] = LoopedTask_TransitionMons, + [CONDITION_FUNC_RETURN] = LoopedTask_ExitConditionGraphMenu, + [CONDITION_FUNC_NO_TRANSITION] = LoopedTask_MoveCursorNoTransition, + [CONDITION_FUNC_SLIDE_MON_OUT] = LoopedTask_SlideMonOut, + [CONDITION_FUNC_ADD_MARKINGS] = LoopedTask_OpenMonMarkingsWindow, + [CONDITION_FUNC_CLOSE_MARKINGS] = LoopedTask_CloseMonMarkingsWindow }; -struct Pokenav7Struct +struct Pokenav_ConditionMenuGfx { u32 loopedTaskId; u8 tilemapBuffers[3][BG_SCREEN_SIZE]; u8 filler[2]; - u8 partyPokeballSpriteIds[10]; + u8 partyPokeballSpriteIds[PARTY_SIZE + 1]; u32 (*callback)(void); s16 monTransitionX; u8 monPicSpriteId; u16 monPalIndex; u16 monGfxTileStart; - void *unk181C; + void *monGfxPtr; u8 nameGenderWindowId; u8 listIndexWindowId; u8 unusedWindowId1; @@ -139,66 +139,65 @@ struct Pokenav7Struct u8 filler2[0xFA3]; }; -extern s8 GetMonMarkIndex(void); // This function's declaration here is s8 vs. u8 in pokenav_conditions_1.c +extern s8 GetConditionGraphMenuCurrentLoadIndex(void); // This function's declaration here is s8 vs. u8 in pokenav_conditions_1.c -static u32 LoopedTask_OpenPartyConditionGraph(s32 state); -static u32 GetPartyConditionLoopedTaskActive(void); -static void CreateConditionMonPic(u8 var); +static u32 LoopedTask_OpenConditionGraphMenu(s32); +static u32 GetConditionGraphMenuLoopedTaskActive(void); +static void CreateConditionMonPic(u8); static void CreateMonMarkingsOrPokeballIndicators(void); static void CopyUnusedConditionWindowsToVram(void); -static bool32 UpdateConditionGraphWindows(u8 a0, u16 a1, bool8 a2); +static bool32 UpdateConditionGraphMenuWindows(u8, u16, bool8); static void VBlankCB_PokenavConditionGraph(void); -static void DoConditionGraphTransition(void); -static void sub_81CEEC8(void); -static void sub_81CEE68(void); -static void ToggleGraphData(bool8 showBg); +static void DoConditionGraphEnterTransition(void); +static void DoConditionGraphExitTransition(void); +static void SetExitVBlank(void); +static void ToggleGraphData(bool8); -// code -bool32 OpenPartyConditionMenu(void) +bool32 OpenConditionGraphMenu(void) { - struct Pokenav7Struct *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_MARK_MENU, sizeof(struct Pokenav7Struct)); + struct Pokenav_ConditionMenuGfx *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX, sizeof(struct Pokenav_ConditionMenuGfx)); - if (structPtr == NULL) + if (menu == NULL) return FALSE; - structPtr->monPicSpriteId = SPRITE_NONE; - structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_OpenPartyConditionGraph, 1); - structPtr->callback = GetPartyConditionLoopedTaskActive; - structPtr->windowModeState = 0; + menu->monPicSpriteId = SPRITE_NONE; + menu->loopedTaskId = CreateLoopedTask(LoopedTask_OpenConditionGraphMenu, 1); + menu->callback = GetConditionGraphMenuLoopedTaskActive; + menu->windowModeState = 0; return TRUE; } -void CreatePartyConditionLoopedTask(s32 id) +void CreateConditionGraphMenuLoopedTask(s32 id) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); - structPtr->loopedTaskId = CreateLoopedTask(sPartyConditionLoopedTaskFuncs[id], 1); - structPtr->callback = GetPartyConditionLoopedTaskActive; + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); + menu->loopedTaskId = CreateLoopedTask(sLoopedTaskFuncs[id], 1); + menu->callback = GetConditionGraphMenuLoopedTaskActive; } -u32 IsPartyConditionLoopedTaskActive(void) +u32 IsConditionGraphMenuLoopedTaskActive(void) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); - return structPtr->callback(); + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); + return menu->callback(); } -static u32 GetPartyConditionLoopedTaskActive(void) +static u32 GetConditionGraphMenuLoopedTaskActive(void) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); - return IsLoopedTaskActive(structPtr->loopedTaskId); + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); + return IsLoopedTaskActive(menu->loopedTaskId); } -static u32 LoopedTask_OpenPartyConditionGraph(s32 state) +static u32 LoopedTask_OpenConditionGraphMenu(s32 state) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); switch (state) { case 0: - if (LoadPartyConditionMenuGfx() != TRUE) + if (LoadConditionGraphMenuGfx() != TRUE) return LT_PAUSE; return LT_INC_AND_PAUSE; case 1: - InitBgTemplates(sPartyConditionBgTemplates, ARRAY_COUNT(sPartyConditionBgTemplates)); + InitBgTemplates(sMenuBgTemplates, ARRAY_COUNT(sMenuBgTemplates)); ChangeBgX(1, 0, BG_COORD_SET); ChangeBgY(1, 0, BG_COORD_SET); ChangeBgX(2, 0, BG_COORD_SET); @@ -213,28 +212,28 @@ static u32 LoopedTask_OpenPartyConditionGraph(s32 state) case 2: if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - DecompressAndCopyTileDataToVram(2, sUnknown_08623228, 0, 0, 0); + DecompressAndCopyTileDataToVram(2, sConditionGraphData_Gfx, 0, 0, 0); return LT_INC_AND_PAUSE; case 3: if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - LZ77UnCompVram(gPokenavCondition_Tilemap, structPtr->tilemapBuffers[0]); - SetBgTilemapBuffer(3, structPtr->tilemapBuffers[0]); + LZ77UnCompVram(gPokenavCondition_Tilemap, menu->tilemapBuffers[0]); + SetBgTilemapBuffer(3, menu->tilemapBuffers[0]); if (IsConditionMenuSearchMode() == TRUE) CopyToBgTilemapBufferRect(3, gPokenavOptions_Tilemap, 0, 5, 9, 4); CopyBgTilemapBufferToVram(3); CopyPaletteIntoBufferUnfaded(gPokenavCondition_Pal, 0x10, 0x20); CopyPaletteIntoBufferUnfaded(gConditionText_Pal, 0xF0, 0x20); - structPtr->monTransitionX = -80; + menu->monTransitionX = -80; return LT_INC_AND_PAUSE; case 4: if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - LZ77UnCompVram(sConditionGraph_Tilemap, structPtr->tilemapBuffers[2]); - SetBgTilemapBuffer(2, structPtr->tilemapBuffers[2]); + LZ77UnCompVram(sConditionGraphData_Tilemap, menu->tilemapBuffers[2]); + SetBgTilemapBuffer(2, menu->tilemapBuffers[2]); CopyBgTilemapBufferToVram(2); CopyPaletteIntoBufferUnfaded(gConditionGraphData_Pal, 0x30, 0x20); ConditionGraph_InitWindow(2); @@ -242,19 +241,19 @@ static u32 LoopedTask_OpenPartyConditionGraph(s32 state) case 5: BgDmaFill(1, 0, 0, 1); BgDmaFill(1, 17, 1, 1); - CpuFill32(0, structPtr->tilemapBuffers[1], BG_SCREEN_SIZE); - SetBgTilemapBuffer(1, structPtr->tilemapBuffers[1]); + CpuFill32(0, menu->tilemapBuffers[1], BG_SCREEN_SIZE); + SetBgTilemapBuffer(1, menu->tilemapBuffers[1]); return LT_INC_AND_PAUSE; case 6: if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - structPtr->nameGenderWindowId = AddWindow(&sMonNameGenderWindowTemplate); + menu->nameGenderWindowId = AddWindow(&sMonNameGenderWindowTemplate); if (IsConditionMenuSearchMode() == TRUE) { - structPtr->listIndexWindowId = AddWindow(&sConditionGraphListIdWindowTemplate); - structPtr->unusedWindowId1 = AddWindow(&sUnusedWindowTemplate1); - structPtr->unusedWindowId2 = AddWindow(&sUnusedWindowTemplate2); + menu->listIndexWindowId = AddWindow(&sListIndexWindowTemplate); + menu->unusedWindowId1 = AddWindow(&sUnusedWindowTemplate1); + menu->unusedWindowId2 = AddWindow(&sUnusedWindowTemplate2); } DeactivateAllTextPrinters(); return LT_INC_AND_PAUSE; @@ -269,23 +268,23 @@ static u32 LoopedTask_OpenPartyConditionGraph(s32 state) CopyUnusedConditionWindowsToVram(); return LT_INC_AND_PAUSE; case 10: - UpdateConditionGraphWindows(0, GetMonMarkIndex(), TRUE); + UpdateConditionGraphMenuWindows(0, GetConditionGraphMenuCurrentLoadIndex(), TRUE); return LT_INC_AND_PAUSE; case 11: - UpdateConditionGraphWindows(1, GetMonMarkIndex(), TRUE); + UpdateConditionGraphMenuWindows(1, GetConditionGraphMenuCurrentLoadIndex(), TRUE); return LT_INC_AND_PAUSE; case 12: - UpdateConditionGraphWindows(2, GetMonMarkIndex(), TRUE); + UpdateConditionGraphMenuWindows(2, GetConditionGraphMenuCurrentLoadIndex(), TRUE); return LT_INC_AND_PAUSE; case 13: - if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), TRUE) != TRUE) + if (UpdateConditionGraphMenuWindows(3, GetConditionGraphMenuCurrentLoadIndex(), TRUE) != TRUE) return LT_PAUSE; - PutWindowTilemap(structPtr->nameGenderWindowId); + PutWindowTilemap(menu->nameGenderWindowId); if (IsConditionMenuSearchMode() == TRUE) { - PutWindowTilemap(structPtr->listIndexWindowId); - PutWindowTilemap(structPtr->unusedWindowId1); - PutWindowTilemap(structPtr->unusedWindowId2); + PutWindowTilemap(menu->listIndexWindowId); + PutWindowTilemap(menu->unusedWindowId1); + PutWindowTilemap(menu->unusedWindowId2); } return LT_INC_AND_PAUSE; case 14: @@ -312,7 +311,7 @@ static u32 LoopedTask_OpenPartyConditionGraph(s32 state) SetVBlankCallback_(VBlankCB_PokenavConditionGraph); return LT_INC_AND_PAUSE; case 17: - DoConditionGraphTransition(); + DoConditionGraphEnterTransition(); ConditionGraph_InitResetScanline(GetConditionGraphPtr()); return LT_INC_AND_PAUSE; case 18: @@ -323,11 +322,11 @@ static u32 LoopedTask_OpenPartyConditionGraph(s32 state) ToggleGraphData(TRUE); return LT_INC_AND_PAUSE; case 20: - if (!ConditionMenu_UpdateMonEnter(GetConditionGraphPtr(), &structPtr->monTransitionX)) + if (!ConditionMenu_UpdateMonEnter(GetConditionGraphPtr(), &menu->monTransitionX)) { - ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); - if (IsConditionMenuSearchMode() == TRUE || GetConditionGraphCurrentMonIndex() != GetMonListCount()) - CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles()); + ResetConditionSparkleSprites(menu->conditionSparkleSprites); + if (IsConditionMenuSearchMode() == TRUE || GetConditionGraphCurrentListIndex() != GetMonListCount()) + CreateConditionSparkleSprites(menu->conditionSparkleSprites, menu->monPicSpriteId, GetNumConditionMonSparkles()); return LT_FINISH; } @@ -337,18 +336,18 @@ static u32 LoopedTask_OpenPartyConditionGraph(s32 state) return LT_FINISH; } -static u32 LoopedTask_ExitPartyConditionMenu(s32 state) +static u32 LoopedTask_ExitConditionGraphMenu(s32 state) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); switch (state) { case 0: - sub_81CEEC8(); - DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); + DoConditionGraphExitTransition(); + DestroyConditionSparkleSprites(menu->conditionSparkleSprites); return LT_INC_AND_CONTINUE; case 1: - if (ConditionMenu_UpdateMonExit(GetConditionGraphPtr(), &structPtr->monTransitionX)) + if (ConditionMenu_UpdateMonExit(GetConditionGraphPtr(), &menu->monTransitionX)) return 2; ToggleGraphData(FALSE); return LT_INC_AND_CONTINUE; @@ -360,7 +359,7 @@ static u32 LoopedTask_ExitPartyConditionMenu(s32 state) case 3: if (IsPaletteFadeActive() || MainMenuLoopedTaskIsBusy()) return LT_PAUSE; - FreeConditionSparkles(structPtr->conditionSparkleSprites); + FreeConditionSparkles(menu->conditionSparkleSprites); HideBg(1); HideBg(2); HideBg(3); @@ -372,53 +371,53 @@ static u32 LoopedTask_ExitPartyConditionMenu(s32 state) static u32 LoopedTask_TransitionMons(s32 state) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); struct ConditionGraph *graph = GetConditionGraphPtr(); switch (state) { case 0: - SetConditionGraphData(0); + LoadNextConditionMenuMonData(CONDITION_LOAD_MON_INFO); return LT_INC_AND_CONTINUE; case 1: - SetConditionGraphData(1); + LoadNextConditionMenuMonData(CONDITION_LOAD_GRAPH); return LT_INC_AND_CONTINUE; case 2: - SetConditionGraphData(2); - DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); + LoadNextConditionMenuMonData(CONDITION_LOAD_MON_PIC); + DestroyConditionSparkleSprites(menu->conditionSparkleSprites); return LT_INC_AND_CONTINUE; case 3: ConditionGraph_TryUpdate(graph); return LT_INC_AND_CONTINUE; case 4: - if (!MoveConditionMonOffscreen(&structPtr->monTransitionX)) + if (!MoveConditionMonOffscreen(&menu->monTransitionX)) { - CreateConditionMonPic(GetMonMarkIndex()); + CreateConditionMonPic(GetConditionGraphMenuCurrentLoadIndex()); return LT_INC_AND_CONTINUE; } return LT_PAUSE; case 5: - UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE); + UpdateConditionGraphMenuWindows(0, GetConditionGraphMenuCurrentLoadIndex(), FALSE); return LT_INC_AND_CONTINUE; case 6: - UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE); + UpdateConditionGraphMenuWindows(1, GetConditionGraphMenuCurrentLoadIndex(), FALSE); return LT_INC_AND_CONTINUE; case 7: - UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE); + UpdateConditionGraphMenuWindows(2, GetConditionGraphMenuCurrentLoadIndex(), FALSE); return LT_INC_AND_CONTINUE; case 8: - if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE) + if (UpdateConditionGraphMenuWindows(3, GetConditionGraphMenuCurrentLoadIndex(), FALSE) == TRUE) return LT_INC_AND_CONTINUE; return LT_PAUSE; case 9: graph = GetConditionGraphPtr(); - if (!ConditionMenu_UpdateMonEnter(graph, &structPtr->monTransitionX)) + if (!ConditionMenu_UpdateMonEnter(graph, &menu->monTransitionX)) { - ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); - if (IsConditionMenuSearchMode() != TRUE && GetConditionGraphCurrentMonIndex() == GetMonListCount()) + ResetConditionSparkleSprites(menu->conditionSparkleSprites); + if (IsConditionMenuSearchMode() != TRUE && GetConditionGraphCurrentListIndex() == GetMonListCount()) return LT_INC_AND_CONTINUE; - CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles()); + CreateConditionSparkleSprites(menu->conditionSparkleSprites, menu->monPicSpriteId, GetNumConditionMonSparkles()); return LT_INC_AND_CONTINUE; } return LT_PAUSE; @@ -429,40 +428,40 @@ static u32 LoopedTask_TransitionMons(s32 state) static u32 LoopedTask_MoveCursorNoTransition(s32 state) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); switch (state) { case 0: - SetConditionGraphData(0); + LoadNextConditionMenuMonData(CONDITION_LOAD_MON_INFO); return LT_INC_AND_CONTINUE; case 1: - SetConditionGraphData(1); + LoadNextConditionMenuMonData(CONDITION_LOAD_GRAPH); return LT_INC_AND_CONTINUE; case 2: - SetConditionGraphData(2); + LoadNextConditionMenuMonData(CONDITION_LOAD_MON_PIC); return LT_INC_AND_CONTINUE; case 3: - CreateConditionMonPic(GetMonMarkIndex()); + CreateConditionMonPic(GetConditionGraphMenuCurrentLoadIndex()); return LT_INC_AND_CONTINUE; case 4: - UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE); + UpdateConditionGraphMenuWindows(0, GetConditionGraphMenuCurrentLoadIndex(), FALSE); return LT_INC_AND_CONTINUE; case 5: - UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE); + UpdateConditionGraphMenuWindows(1, GetConditionGraphMenuCurrentLoadIndex(), FALSE); return LT_INC_AND_CONTINUE; case 6: - UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE); + UpdateConditionGraphMenuWindows(2, GetConditionGraphMenuCurrentLoadIndex(), FALSE); return LT_INC_AND_CONTINUE; case 7: - if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE) + if (UpdateConditionGraphMenuWindows(3, GetConditionGraphMenuCurrentLoadIndex(), FALSE) == TRUE) return LT_INC_AND_CONTINUE; return LT_PAUSE; case 8: - if (!ConditionMenu_UpdateMonEnter(GetConditionGraphPtr(), &structPtr->monTransitionX)) + if (!ConditionMenu_UpdateMonEnter(GetConditionGraphPtr(), &menu->monTransitionX)) { - ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); - CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles()); + ResetConditionSparkleSprites(menu->conditionSparkleSprites); + CreateConditionSparkleSprites(menu->conditionSparkleSprites, menu->monPicSpriteId, GetNumConditionMonSparkles()); return LT_INC_AND_CONTINUE; } return LT_PAUSE; @@ -473,35 +472,35 @@ static u32 LoopedTask_MoveCursorNoTransition(s32 state) static u32 LoopedTask_SlideMonOut(s32 state) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); switch (state) { case 0: - SetConditionGraphData(0); + LoadNextConditionMenuMonData(CONDITION_LOAD_MON_INFO); return LT_INC_AND_CONTINUE; case 1: - SetConditionGraphData(1); + LoadNextConditionMenuMonData(CONDITION_LOAD_GRAPH); return LT_INC_AND_CONTINUE; case 2: - SetConditionGraphData(2); - DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); + LoadNextConditionMenuMonData(CONDITION_LOAD_MON_PIC); + DestroyConditionSparkleSprites(menu->conditionSparkleSprites); return LT_INC_AND_CONTINUE; case 3: - if (!ConditionMenu_UpdateMonExit(GetConditionGraphPtr(), &structPtr->monTransitionX)) + if (!ConditionMenu_UpdateMonExit(GetConditionGraphPtr(), &menu->monTransitionX)) return LT_INC_AND_CONTINUE; return LT_PAUSE; case 4: - UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE); + UpdateConditionGraphMenuWindows(0, GetConditionGraphMenuCurrentLoadIndex(), FALSE); return LT_INC_AND_CONTINUE; case 5: - UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE); + UpdateConditionGraphMenuWindows(1, GetConditionGraphMenuCurrentLoadIndex(), FALSE); return LT_INC_AND_CONTINUE; case 6: - UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE); + UpdateConditionGraphMenuWindows(2, GetConditionGraphMenuCurrentLoadIndex(), FALSE); return LT_INC_AND_CONTINUE; case 7: - if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE) + if (UpdateConditionGraphMenuWindows(3, GetConditionGraphMenuCurrentLoadIndex(), FALSE) == TRUE) return LT_INC_AND_CONTINUE; return LT_PAUSE; } @@ -555,68 +554,68 @@ static u8 *UnusedPrintNumberString(u8 *dst, u16 num) return txtPtr; } -static bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode) +static bool32 UpdateConditionGraphMenuWindows(u8 mode, u16 bufferIndex, bool8 winMode) { u8 text[32]; const u8 *str; - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); switch (mode) { case 0: - FillWindowPixelBuffer(structPtr->nameGenderWindowId, 0); + FillWindowPixelBuffer(menu->nameGenderWindowId, 0); if (IsConditionMenuSearchMode() == TRUE) - FillWindowPixelBuffer(structPtr->listIndexWindowId, 0); + FillWindowPixelBuffer(menu->listIndexWindowId, 0); break; case 1: - if (GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1 || IsConditionMenuSearchMode() == TRUE) + if (GetConditionGraphCurrentListIndex() != GetMonListCount() - 1 || IsConditionMenuSearchMode() == TRUE) { str = GetConditionMonNameText(bufferIndex); - AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 1, 0, NULL); + AddTextPrinterParameterized(menu->nameGenderWindowId, FONT_NORMAL, str, 0, 1, 0, NULL); } break; case 2: if (IsConditionMenuSearchMode() == TRUE) { str = GetConditionMonLocationText(bufferIndex); - AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 17, 0, NULL); + AddTextPrinterParameterized(menu->nameGenderWindowId, FONT_NORMAL, str, 0, 17, 0, NULL); text[0] = EXT_CTRL_CODE_BEGIN; text[1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; text[2] = TEXT_COLOR_BLUE; text[3] = TEXT_COLOR_TRANSPARENT; text[4] = TEXT_COLOR_LIGHT_BLUE; StringCopy(&text[5], gText_Number2); - AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 4, 1, 0, NULL); + AddTextPrinterParameterized(menu->listIndexWindowId, FONT_NORMAL, text, 4, 1, 0, NULL); ConvertIntToDecimalStringN(&text[5], GetConditionMonDataBuffer(), STR_CONV_MODE_RIGHT_ALIGN, 4); - AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 28, 1, 0, NULL); + AddTextPrinterParameterized(menu->listIndexWindowId, FONT_NORMAL, text, 28, 1, 0, NULL); } break; case 3: - switch (structPtr->windowModeState) + switch (menu->windowModeState) { case 0: if (winMode) - CopyWindowToVram(structPtr->nameGenderWindowId, COPYWIN_FULL); + CopyWindowToVram(menu->nameGenderWindowId, COPYWIN_FULL); else - CopyWindowToVram(structPtr->nameGenderWindowId, COPYWIN_GFX); + CopyWindowToVram(menu->nameGenderWindowId, COPYWIN_GFX); if (IsConditionMenuSearchMode() == TRUE) { - structPtr->windowModeState++; + menu->windowModeState++; return FALSE; } else { - structPtr->windowModeState = 0; + menu->windowModeState = 0; return TRUE; } case 1: if (winMode) - CopyWindowToVram(structPtr->listIndexWindowId, COPYWIN_FULL); + CopyWindowToVram(menu->listIndexWindowId, COPYWIN_FULL); else - CopyWindowToVram(structPtr->listIndexWindowId, COPYWIN_GFX); + CopyWindowToVram(menu->listIndexWindowId, COPYWIN_GFX); - structPtr->windowModeState = 0; + menu->windowModeState = 0; return TRUE; } } @@ -626,23 +625,23 @@ static bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMod static void CopyUnusedConditionWindowsToVram(void) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); - CopyWindowToVram(structPtr->unusedWindowId1, COPYWIN_FULL); - CopyWindowToVram(structPtr->unusedWindowId2, COPYWIN_FULL); + CopyWindowToVram(menu->unusedWindowId1, COPYWIN_FULL); + CopyWindowToVram(menu->unusedWindowId2, COPYWIN_FULL); } -void sub_81CE964(struct Sprite *sprite) +static void SpriteCB_PartyPokeball(struct Sprite *sprite) { - if (sprite->data[0] == GetConditionGraphCurrentMonIndex()) - StartSpriteAnim(sprite, 0); + if (sprite->data[0] == GetConditionGraphCurrentListIndex()) + StartSpriteAnim(sprite, CONDITION_ICON_SELECTED); else - StartSpriteAnim(sprite, 1); + StartSpriteAnim(sprite, CONDITION_ICON_UNSELECTED); } void HighlightCurrentPartyIndexPokeball(struct Sprite *sprite) { - if (GetConditionGraphCurrentMonIndex() == GetMonListCount() - 1) + if (GetConditionGraphCurrentListIndex() == GetMonListCount() - 1) sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_BALL); else sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_CANCEL); @@ -661,71 +660,76 @@ static void CreateMonMarkingsOrPokeballIndicators(void) struct SpriteSheet sprSheet; struct Sprite *sprite; u16 i, spriteId; - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); LoadConditionSelectionIcons(sprSheets, &sprTemplate, sprPals); if (IsConditionMenuSearchMode() == TRUE) { - structPtr->marksMenu.baseTileTag = TAG_CONDITION_MARKINGS_MENU; - structPtr->marksMenu.basePaletteTag = TAG_CONDITION_MARKINGS_MENU; - InitMonMarkingsMenu(&structPtr->marksMenu); + // Search Mode, load markings menu + menu->marksMenu.baseTileTag = TAG_CONDITION_MARKINGS_MENU; + menu->marksMenu.basePaletteTag = TAG_CONDITION_MARKINGS_MENU; + InitMonMarkingsMenu(&menu->marksMenu); BufferMonMarkingsMenuTiles(); - sprite = CreateMonMarkingAllCombosSprite(TAG_CONDITION_MON_MARKINGS, TAG_CONDITION_MON_MARKINGS, sConditionGraphMonMarkingsPal); + sprite = CreateMonMarkingAllCombosSprite(TAG_CONDITION_MON_MARKINGS, TAG_CONDITION_MON_MARKINGS, sMonMarkings_Pal); sprite->oam.priority = 3; sprite->x = 192; sprite->y = 32; sprite->callback = MonMarkingsCallback; - structPtr->monMarksSprite = sprite; + menu->monMarksSprite = sprite; PokenavFillPalette(IndexOfSpritePaletteTag(TAG_CONDITION_MON_MARKINGS), 0); } else { - // party mode -> add pokeballs on right hand side + // Party Mode, load Pokéball selection icons LoadSpriteSheets(sprSheets); Pokenav_AllocAndLoadPalettes(sprPals); + + // Add icons for occupied slots for (i = 0; i < GetMonListCount() - 1; i++) { spriteId = CreateSprite(&sprTemplate, 226, (i * 20) + 8, 0); if (spriteId != MAX_SPRITES) { - structPtr->partyPokeballSpriteIds[i] = spriteId; + menu->partyPokeballSpriteIds[i] = spriteId; gSprites[spriteId].data[0] = i; - gSprites[spriteId].callback = sub_81CE964; + gSprites[spriteId].callback = SpriteCB_PartyPokeball; } else { - structPtr->partyPokeballSpriteIds[i] = SPRITE_NONE; + menu->partyPokeballSpriteIds[i] = SPRITE_NONE; } } + // Add icons for empty slots sprTemplate.tileTag = TAG_CONDITION_BALL_PLACEHOLDER; sprTemplate.callback = SpriteCallbackDummy; - for (; i < 6; i++) + for (; i < PARTY_SIZE; i++) { spriteId = CreateSprite(&sprTemplate, 230, (i * 20) + 8, 0); if (spriteId != MAX_SPRITES) { - structPtr->partyPokeballSpriteIds[i] = spriteId; + menu->partyPokeballSpriteIds[i] = spriteId; gSprites[spriteId].oam.size = 0; } else { - structPtr->partyPokeballSpriteIds[i] = SPRITE_NONE; + menu->partyPokeballSpriteIds[i] = SPRITE_NONE; } } + // Add cancel icon sprTemplate.tileTag = TAG_CONDITION_CANCEL; sprTemplate.callback = HighlightCurrentPartyIndexPokeball; spriteId = CreateSprite(&sprTemplate, 222, (i * 20) + 8, 0); if (spriteId != MAX_SPRITES) { - structPtr->partyPokeballSpriteIds[i] = spriteId; + menu->partyPokeballSpriteIds[i] = spriteId; gSprites[spriteId].oam.shape = SPRITE_SHAPE(32x16); gSprites[spriteId].oam.size = SPRITE_SIZE(32x16); } else { - structPtr->partyPokeballSpriteIds[i] = SPRITE_NONE; + menu->partyPokeballSpriteIds[i] = SPRITE_NONE; } } @@ -735,13 +739,13 @@ static void CreateMonMarkingsOrPokeballIndicators(void) Pokenav_AllocAndLoadPalettes(sprPals); } -void sub_81CEBF4(struct Pokenav7Struct *structPtr) +static void FreeConditionMenuGfx(struct Pokenav_ConditionMenuGfx *menu) { u8 i; if (IsConditionMenuSearchMode() == TRUE) { - DestroySprite(structPtr->monMarksSprite); + DestroySprite(menu->monMarksSprite); FreeSpriteTilesByTag(TAG_CONDITION_MARKINGS_MENU); FreeSpriteTilesByTag(TAG_CONDITION_MON_MARKINGS); FreeSpritePaletteByTag(TAG_CONDITION_MARKINGS_MENU); @@ -749,8 +753,8 @@ void sub_81CEBF4(struct Pokenav7Struct *structPtr) } else { - for (i = 0; i < 7; i++) - DestroySprite(&gSprites[structPtr->partyPokeballSpriteIds[i]]); + for (i = 0; i < PARTY_SIZE + 1; i++) + DestroySprite(&gSprites[menu->partyPokeballSpriteIds[i]]); FreeSpriteTilesByTag(TAG_CONDITION_BALL); FreeSpriteTilesByTag(TAG_CONDITION_CANCEL); @@ -759,24 +763,24 @@ void sub_81CEBF4(struct Pokenav7Struct *structPtr) FreeSpritePaletteByTag(TAG_CONDITION_CANCEL); } - if (structPtr->monPicSpriteId != SPRITE_NONE) + if (menu->monPicSpriteId != SPRITE_NONE) { - DestroySprite(&gSprites[structPtr->monPicSpriteId]); + DestroySprite(&gSprites[menu->monPicSpriteId]); FreeSpriteTilesByTag(TAG_CONDITION_MON); FreeSpritePaletteByTag(TAG_CONDITION_MON); } } -void FreePartyConditionSubstruct2(void) +void FreeConditionGraphMenuSubstruct2(void) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); - RemoveWindow(structPtr->nameGenderWindowId); + RemoveWindow(menu->nameGenderWindowId); if (IsConditionMenuSearchMode() == TRUE) { - RemoveWindow(structPtr->listIndexWindowId); - RemoveWindow(structPtr->unusedWindowId1); - RemoveWindow(structPtr->unusedWindowId2); + RemoveWindow(menu->listIndexWindowId); + RemoveWindow(menu->unusedWindowId1); + RemoveWindow(menu->unusedWindowId2); } else { @@ -784,15 +788,15 @@ void FreePartyConditionSubstruct2(void) } SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP); - sub_81CEBF4(structPtr); - sub_81CEE68(); - FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_MARK_MENU); + FreeConditionMenuGfx(menu); + SetExitVBlank(); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); } void MonPicGfxSpriteCallback(struct Sprite *sprite) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); - sprite->x = structPtr->monTransitionX + 38; + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); + sprite->x = menu->monTransitionX + 38; } static void CreateConditionMonPic(u8 id) @@ -801,35 +805,35 @@ static void CreateConditionMonPic(u8 id) struct SpriteSheet sprSheet; struct SpritePalette sprPal; u8 spriteId; - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); - if (structPtr->monPicSpriteId == SPRITE_NONE) + if (menu->monPicSpriteId == SPRITE_NONE) { LoadConditionMonPicTemplate(&sprSheet, &sprTemplate, &sprPal); sprSheet.data = GetConditionMonPicGfx(id); sprPal.data = GetConditionMonPal(id); - structPtr->monPalIndex = LoadSpritePalette(&sprPal); - structPtr->monGfxTileStart = LoadSpriteSheet(&sprSheet); + menu->monPalIndex = LoadSpritePalette(&sprPal); + menu->monGfxTileStart = LoadSpriteSheet(&sprSheet); spriteId = CreateSprite(&sprTemplate, 38, 104, 0); - structPtr->monPicSpriteId = spriteId; + menu->monPicSpriteId = spriteId; if (spriteId == MAX_SPRITES) { FreeSpriteTilesByTag(TAG_CONDITION_MON); FreeSpritePaletteByTag(TAG_CONDITION_MON); - structPtr->monPicSpriteId = SPRITE_NONE; + menu->monPicSpriteId = SPRITE_NONE; } else { - structPtr->monPicSpriteId = spriteId; - gSprites[structPtr->monPicSpriteId].callback = MonPicGfxSpriteCallback; - structPtr->unk181C = (void*)VRAM + BG_VRAM_SIZE + (structPtr->monGfxTileStart * 32); - structPtr->monPalIndex = (structPtr->monPalIndex * 16) + 0x100; + menu->monPicSpriteId = spriteId; + gSprites[menu->monPicSpriteId].callback = MonPicGfxSpriteCallback; + menu->monGfxPtr = (void*)VRAM + BG_VRAM_SIZE + (menu->monGfxTileStart * 32); + menu->monPalIndex = (menu->monPalIndex * 16) + 0x100; } } else { - DmaCopy16Defvars(3, GetConditionMonPicGfx(id), structPtr->unk181C, MON_PIC_SIZE); - LoadPalette(GetConditionMonPal(id), structPtr->monPalIndex, 0x20); + DmaCopy16Defvars(3, GetConditionMonPicGfx(id), menu->monGfxPtr, MON_PIC_SIZE); + LoadPalette(GetConditionMonPal(id), menu->monPalIndex, 0x20); } } @@ -843,7 +847,7 @@ static void VBlankCB_PokenavConditionGraph(void) ScanlineEffect_InitHBlankDmaTransfer(); } -static void sub_81CEE68(void) +static void SetExitVBlank(void) { SetPokenavVBlankCallback(); } @@ -856,30 +860,33 @@ static void ToggleGraphData(bool8 showBg) HideBg(2); } -static void DoConditionGraphTransition(void) +static void DoConditionGraphEnterTransition(void) { struct ConditionGraph *graph = GetConditionGraphPtr(); - u8 id = GetMonMarkIndex(); + u8 id = GetConditionGraphMenuCurrentLoadIndex(); - sUnknown_030012BC = id; + sInitialLoadId = id; ConditionGraph_SetNewPositions(graph, graph->savedPositions[CONDITION_GRAPH_LOAD_MAX - 1], graph->savedPositions[id]); ConditionGraph_TryUpdate(graph); } -static void sub_81CEEC8(void) +// Transition the graph back to empty before exiting. +// This is skipped if the player is in party mode and the cursor +// is on Cancel, in which case the graph is already empty. +static void DoConditionGraphExitTransition(void) { struct ConditionGraph *graph = GetConditionGraphPtr(); - if (IsConditionMenuSearchMode() || GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1) - ConditionGraph_SetNewPositions(graph, graph->savedPositions[GetMonMarkIndex()], graph->savedPositions[CONDITION_GRAPH_LOAD_MAX - 1]); + if (IsConditionMenuSearchMode() || GetConditionGraphCurrentListIndex() != GetMonListCount() - 1) + ConditionGraph_SetNewPositions(graph, graph->savedPositions[GetConditionGraphMenuCurrentLoadIndex()], graph->savedPositions[CONDITION_GRAPH_LOAD_MAX - 1]); } u8 GetMonMarkingsData(void) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX); if (IsConditionMenuSearchMode() == 1) - return structPtr->marksMenu.markings; + return menu->marksMenu.markings; else return 0; } diff --git a/src/pokenav_conditions_3.c b/src/pokenav_conditions_3.c index 1172774d7..d9bd2273f 100644 --- a/src/pokenav_conditions_3.c +++ b/src/pokenav_conditions_3.c @@ -21,48 +21,48 @@ enum CONDITION_SEARCH_FUNC_SELECT_MON, }; -struct PokenavSub7 +struct Pokenav_SearchResults { - u32 (*callback)(struct PokenavSub7 *); + u32 (*callback)(struct Pokenav_SearchResults *); u32 loopedTaskId; u8 fill1[4]; s32 boxId; s32 monId; u32 conditionDataId; - u32 returnFromGraph; - u32 isPartyCondition; + bool32 returnFromGraph; + bool32 saveResultsList; struct PokenavSub18 *monList; }; -struct PokenavSub8 +struct Pokenav_SearchResultsGfx { bool32 (*callback)(void); - u32 ltid; //looped task Id + u32 loopedTaskId; u16 winid; bool32 fromGraph; u8 buff[BG_SCREEN_SIZE]; }; // size: 0x810 -static u32 HandleConditionSearchInput_WaitSetup(struct PokenavSub7 *structPtr); -static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr); -static u32 OpenConditionGraphFromSearchList(struct PokenavSub7 *structPtr); -static u32 ReturnToConditionSearchList(struct PokenavSub7 *structPtr); -static u32 GetConditionSearchLoopedTask(s32 state); -static u32 BuildPartyMonSearchResults(s32 state); -static u32 InitBoxMonSearchResults(s32 state); -static u32 BuildBoxMonSearchResults(s32 state); -static u32 sub_81CF278(s32 state); -static u32 LoopedTask_MoveSearchListCursorUp(s32 state); -static u32 LoopedTask_MoveSearchListCursorDown(s32 state); -static u32 LoopedTask_MoveSearchListPageUp(s32 state); -static u32 LoopedTask_MoveSearchListPageDown(s32 state); -static u32 LoopedTask_ExitConditionSearchMenu(s32 state); -static u32 LoopedTask_SelectSearchResult(s32 state); -static void sub_81CF2C4(struct PokenavSub7 *structPtr, struct PokenavMonList *item); +static u32 HandleConditionSearchInput_WaitSetup(struct Pokenav_SearchResults *); +static u32 HandleConditionSearchInput(struct Pokenav_SearchResults *); +static u32 OpenConditionGraphFromSearchList(struct Pokenav_SearchResults *); +static u32 ReturnToConditionSearchList(struct Pokenav_SearchResults *); +static u32 GetConditionSearchLoopedTask(s32); +static u32 BuildPartyMonSearchResults(s32); +static u32 InitBoxMonSearchResults(s32); +static u32 BuildBoxMonSearchResults(s32); +static u32 ConvertConditionsToListRanks(s32); +static u32 LoopedTask_MoveSearchListCursorUp(s32); +static u32 LoopedTask_MoveSearchListCursorDown(s32); +static u32 LoopedTask_MoveSearchListPageUp(s32); +static u32 LoopedTask_MoveSearchListPageDown(s32); +static u32 LoopedTask_ExitConditionSearchMenu(s32); +static u32 LoopedTask_SelectSearchResult(s32); +static void InsertMonListItem(struct Pokenav_SearchResults *, struct PokenavMonList *); static bool32 GetSearchResultCurrentLoopedTaskActive(void); -static u32 LoopedTask_OpenConditionSearchResults(s32 state); -static void AddSearchResultListMenuWindow(struct PokenavSub8 *); -static void PrintSearchResultListMenuItems(struct PokenavSub8 *); +static u32 LoopedTask_OpenConditionSearchResults(s32); +static void AddSearchResultListMenuWindow(struct Pokenav_SearchResultsGfx *); +static void PrintSearchResultListMenuItems(struct Pokenav_SearchResultsGfx *); static void InitConditionSearchListMenuTemplate(void); static void PrintSearchMonListItem(struct PokenavMonList *, u8 *); @@ -73,13 +73,13 @@ static const LoopedTask sConditionSearchLoopedTaskFuncs[] = BuildPartyMonSearchResults, InitBoxMonSearchResults, BuildBoxMonSearchResults, - sub_81CF278 + ConvertConditionsToListRanks }; -static const u16 sConditionSearchResultFramePal[] = INCBIN_U16("graphics/pokenav/condition_search2.gbapal"); -static const u32 sConditionSearchResultTiles[] = INCBIN_U32("graphics/pokenav/condition_search2.4bpp.lz"); -static const u32 sConditionSearchResultTilemap[] = INCBIN_U32("graphics/pokenav/condition_search2.bin.lz"); -static const u16 gUnknown_08623570[] = INCBIN_U16("graphics/pokenav/8623570.gbapal"); +static const u16 sConditionSearchResultFramePal[] = INCBIN_U16("graphics/pokenav/condition/search_results.gbapal"); +static const u32 sConditionSearchResultTiles[] = INCBIN_U32("graphics/pokenav/condition/search_results.4bpp.lz"); +static const u32 sConditionSearchResultTilemap[] = INCBIN_U32("graphics/pokenav/condition/search_results.bin.lz"); +static const u16 sListBg_Pal[] = INCBIN_U16("graphics/pokenav/condition/search_results_list.gbapal"); static const struct BgTemplate sConditionSearchResultBgTemplates[] = { @@ -130,57 +130,57 @@ static const u8 sText_NoGenderSymbol[] = _("{UNK_SPACER}"); bool32 PokenavCallback_Init_ConditionSearch(void) { - struct PokenavSub7 *structPtr = AllocSubstruct(7, sizeof(struct PokenavSub7)); - if (structPtr == NULL) + struct Pokenav_SearchResults *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS, sizeof(struct Pokenav_SearchResults)); + if (menu == NULL) return FALSE; - structPtr->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18)); - if (structPtr->monList == NULL) + menu->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18)); + if (menu->monList == NULL) return FALSE; - structPtr->callback = HandleConditionSearchInput_WaitSetup; - structPtr->loopedTaskId = CreateLoopedTask(GetConditionSearchLoopedTask, 1); - structPtr->returnFromGraph = 0; - structPtr->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()]; + menu->callback = HandleConditionSearchInput_WaitSetup; + menu->loopedTaskId = CreateLoopedTask(GetConditionSearchLoopedTask, 1); + menu->returnFromGraph = FALSE; + menu->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()]; return TRUE; } // return to search results from condition graph bool32 PokenavCallback_Init_ReturnToMonSearchList(void) { - struct PokenavSub7 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS, sizeof(struct PokenavSub7)); - if (structPtr == NULL) + struct Pokenav_SearchResults *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS, sizeof(struct Pokenav_SearchResults)); + if (menu == NULL) return FALSE; - structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - structPtr->callback = HandleConditionSearchInput; - structPtr->returnFromGraph = 1; - structPtr->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()]; + menu->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + menu->callback = HandleConditionSearchInput; + menu->returnFromGraph = TRUE; + menu->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()]; return TRUE; } u32 GetConditionSearchResultsCallback(void) { - struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); - return structPtr->callback(structPtr); + struct Pokenav_SearchResults *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + return menu->callback(menu); } void FreeSearchResultSubstruct1(void) { - struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); - if (structPtr->isPartyCondition == 0) + struct Pokenav_SearchResults *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + if (!menu->saveResultsList) FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST); FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); } -static bool32 HandleConditionSearchInput_WaitSetup(struct PokenavSub7 *structPtr) +static bool32 HandleConditionSearchInput_WaitSetup(struct Pokenav_SearchResults *menu) { - if (!IsLoopedTaskActive(structPtr->loopedTaskId)) - structPtr->callback = HandleConditionSearchInput; + if (!IsLoopedTaskActive(menu->loopedTaskId)) + menu->callback = HandleConditionSearchInput; return FALSE; } -static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr) +static u32 HandleConditionSearchInput(struct Pokenav_SearchResults *menu) { if (JOY_REPEAT(DPAD_UP)) return CONDITION_SEARCH_FUNC_MOVE_UP; @@ -192,60 +192,63 @@ static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr) return CONDITION_SEARCH_FUNC_PAGE_DOWN; else if (JOY_NEW(B_BUTTON)) { - structPtr->isPartyCondition = 0; - structPtr->callback = ReturnToConditionSearchList; + // Exiting back to main search menu + menu->saveResultsList = FALSE; + menu->callback = ReturnToConditionSearchList; return CONDITION_SEARCH_FUNC_EXIT; } else if (JOY_NEW(A_BUTTON)) { - structPtr->monList->currIndex = GetSelectedPokenavListIndex(); - structPtr->isPartyCondition = 1; - structPtr->callback = OpenConditionGraphFromSearchList; + // Entering graph menu + menu->monList->currIndex = GetSelectedPokenavListIndex(); + menu->saveResultsList = TRUE; + menu->callback = OpenConditionGraphFromSearchList; return CONDITION_SEARCH_FUNC_SELECT_MON; } else return CONDITION_SEARCH_FUNC_NONE; } -static u32 ReturnToConditionSearchList(struct PokenavSub7 *structPtr) +static u32 ReturnToConditionSearchList(struct Pokenav_SearchResults *menu) { return POKENAV_CONDITION_SEARCH_MENU; } -static u32 OpenConditionGraphFromSearchList(struct PokenavSub7 *structPtr) +static u32 OpenConditionGraphFromSearchList(struct Pokenav_SearchResults *menu) { - return POKENAV_CONDITION_GRAPH_FROM_SEARCH; + return POKENAV_CONDITION_GRAPH_SEARCH; } -static u32 sub_81CF0C0(void) +static u32 GetReturningFromGraph(void) { - struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); - return structPtr->returnFromGraph; + struct Pokenav_SearchResults *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + return menu->returnFromGraph; } static struct PokenavMonList * GetSearchResultsMonDataList(void) { - struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); - return ptr->monList->monData; + struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + return menu->monList->monData; } static u16 GetSearchResultsMonListCount(void) { - struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); - return ptr->monList->listCount; + struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + return menu->monList->listCount; } -static s32 GetSearchResultsSelectedMonData(void) +// data below has been set by ConvertConditionsToListRanks +static s32 GetSearchResultsSelectedMonRank(void) { - struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); s32 i = GetSelectedPokenavListIndex(); - return ptr->monList->monData[i].data; + return menu->monList->monData[i].data; } -static u16 sub_81CF10C(void) +static u16 GetSearchResultsCurrentListIndex(void) { - struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); - return ptr->monList->currIndex; + struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + return menu->monList->currIndex; } static u32 GetConditionSearchLoopedTask(s32 state) @@ -257,11 +260,11 @@ static u32 BuildPartyMonSearchResults(s32 state) { s32 i; struct PokenavMonList item; - struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); - ptr->monList->listCount = 0; - ptr->monList->currIndex = 0; - item.boxId = 14; + menu->monList->listCount = 0; + menu->monList->currIndex = 0; + item.boxId = TOTAL_BOXES_COUNT; for (i = 0; i < PARTY_SIZE; i++) { struct Pokemon * pokemon = &gPlayerParty[i]; @@ -270,8 +273,8 @@ static u32 BuildPartyMonSearchResults(s32 state) if (!GetMonData(pokemon, MON_DATA_SANITY_IS_EGG)) { item.monId = i; - item.data = GetMonData(pokemon, ptr->conditionDataId); - sub_81CF2C4(ptr, &item); + item.data = GetMonData(pokemon, menu->conditionDataId); + InsertMonListItem(menu, &item); } } @@ -280,17 +283,17 @@ static u32 BuildPartyMonSearchResults(s32 state) static u32 InitBoxMonSearchResults(s32 state) { - struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); - ptr->monId = 0; - ptr->boxId = 0; + struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + menu->monId = 0; + menu->boxId = 0; return LT_INC_AND_CONTINUE; } static u32 BuildBoxMonSearchResults(s32 state) { - struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); - s32 boxId = ptr->boxId; - s32 monId = ptr->monId; + struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + s32 boxId = menu->boxId; + s32 monId = menu->monId; s32 boxCount = 0; struct PokenavMonList item; @@ -302,15 +305,15 @@ static u32 BuildBoxMonSearchResults(s32 state) { item.boxId = boxId; item.monId = monId; - item.data = GetBoxMonDataAt(boxId, monId, ptr->conditionDataId); - sub_81CF2C4(ptr, &item); + item.data = GetBoxMonDataAt(boxId, monId, menu->conditionDataId); + InsertMonListItem(menu, &item); } boxCount++; monId++; - if (boxCount > 14) + if (boxCount > TOTAL_BOXES_COUNT) { - ptr->boxId = boxId; - ptr->monId = monId; + menu->boxId = boxId; + menu->monId = monId; return LT_CONTINUE; } } @@ -321,107 +324,111 @@ static u32 BuildBoxMonSearchResults(s32 state) return LT_INC_AND_CONTINUE; } -static u32 sub_81CF278(s32 state) +// Data below is initially set by BuildPartyMonSearchResults / BuildBoxMonSearchResults, and +// is the Pokémon's condition value for the condition they are sorted by. +// The condition value in data is then overwritten with their ranking. +static u32 ConvertConditionsToListRanks(s32 state) { - struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); - s32 r6 = ptr->monList->listCount; - s32 r4 = ptr->monList->monData[0].data; + struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + s32 listCount = menu->monList->listCount; + s32 prevCondition = menu->monList->monData[0].data; s32 i; - ptr->monList->monData[0].data = 1; - for (i = 1; i < r6; i++) + menu->monList->monData[0].data = 1; + for (i = 1; i < listCount; i++) { - if (ptr->monList->monData[i].data == r4) + if (menu->monList->monData[i].data == prevCondition) { - ptr->monList->monData[i].data = ptr->monList->monData[i - 1].data; + // Same condition value as prev, share rank + menu->monList->monData[i].data = menu->monList->monData[i - 1].data; } else { - r4 = ptr->monList->monData[i].data; - ptr->monList->monData[i].data = i + 1; + prevCondition = menu->monList->monData[i].data; + menu->monList->monData[i].data = i + 1; } } - ptr->returnFromGraph = 1; + menu->returnFromGraph = TRUE; return LT_FINISH; } -static void sub_81CF2C4(struct PokenavSub7 *structPtr, struct PokenavMonList *item) +static void InsertMonListItem(struct Pokenav_SearchResults *menu, struct PokenavMonList *item) { u32 left = 0; - u32 right = structPtr->monList->listCount; + u32 right = menu->monList->listCount; u32 insertionIdx = left + (right - left) / 2; while (right != insertionIdx) { - if (item->data > structPtr->monList->monData[insertionIdx].data) + if (item->data > menu->monList->monData[insertionIdx].data) right = insertionIdx; else left = insertionIdx + 1; insertionIdx = left + (right - left) / 2; } - for (right = structPtr->monList->listCount; right > insertionIdx; right--) - structPtr->monList->monData[right] = structPtr->monList->monData[right - 1]; - structPtr->monList->monData[insertionIdx] = *item; - structPtr->monList->listCount++; + for (right = menu->monList->listCount; right > insertionIdx; right--) + menu->monList->monData[right] = menu->monList->monData[right - 1]; + menu->monList->monData[insertionIdx] = *item; + menu->monList->listCount++; } bool32 OpenConditionSearchResults(void) { - struct PokenavSub8 *searchList = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST, sizeof(struct PokenavSub8)); - if (searchList == NULL) + struct Pokenav_SearchResultsGfx *gfx = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX, sizeof(struct Pokenav_SearchResultsGfx)); + if (gfx == NULL) return FALSE; - searchList->ltid = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1); - searchList->callback = GetSearchResultCurrentLoopedTaskActive; - searchList->fromGraph = FALSE; + gfx->loopedTaskId = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1); + gfx->callback = GetSearchResultCurrentLoopedTaskActive; + gfx->fromGraph = FALSE; return TRUE; } bool32 OpenConditionSearchListFromGraph(void) { - struct PokenavSub8 *searchList = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST, sizeof(struct PokenavSub8)); - if (searchList == NULL) + struct Pokenav_SearchResultsGfx *gfx = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX, sizeof(struct Pokenav_SearchResultsGfx)); + if (gfx == NULL) return FALSE; - searchList->ltid = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1); - searchList->callback = GetSearchResultCurrentLoopedTaskActive; - searchList->fromGraph = TRUE; + gfx->loopedTaskId = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1); + gfx->callback = GetSearchResultCurrentLoopedTaskActive; + gfx->fromGraph = TRUE; return TRUE; } void CreateSearchResultsLoopedTask(s32 idx) { - struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); - searchList->ltid = CreateLoopedTask(sSearchResultLoopTaskFuncs[idx], 1); - searchList->callback = GetSearchResultCurrentLoopedTaskActive; + struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX); + gfx->loopedTaskId = CreateLoopedTask(sSearchResultLoopTaskFuncs[idx], 1); + gfx->callback = GetSearchResultCurrentLoopedTaskActive; } bool32 IsSearchResultLoopedTaskActive(void) { - struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); - return searchList->callback(); + struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX); + return gfx->callback(); } bool32 GetSearchResultCurrentLoopedTaskActive(void) { - struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); - return IsLoopedTaskActive(searchList->ltid); + struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX); + return IsLoopedTaskActive(gfx->loopedTaskId); } void FreeSearchResultSubstruct2(void) { - struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); + struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX); sub_81C8234(); - RemoveWindow(searchList->winid); - FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); + RemoveWindow(gfx->winid); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX); } static u32 LoopedTask_OpenConditionSearchResults(s32 state) { - struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); + struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX); switch (state) { case 0: InitBgTemplates(sConditionSearchResultBgTemplates, ARRAY_COUNT(sConditionSearchResultBgTemplates)); DecompressAndCopyTileDataToVram(1, sConditionSearchResultTiles, 0, 0, 0); - SetBgTilemapBuffer(1, searchList->buff); + SetBgTilemapBuffer(1, gfx->buff); CopyToBgTilemapBuffer(1, sConditionSearchResultTilemap, 0, 0); CopyBgTilemapBufferToVram(1); CopyPaletteIntoBufferUnfaded(sConditionSearchResultFramePal, 0x10, 0x20); @@ -430,19 +437,19 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state) case 1: if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - if (!sub_81CF0C0()) + if (!GetReturningFromGraph()) return LT_PAUSE; return LT_INC_AND_PAUSE; case 2: if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - CopyPaletteIntoBufferUnfaded(gUnknown_08623570, 0x20, 32); + CopyPaletteIntoBufferUnfaded(sListBg_Pal, 0x20, 32); InitConditionSearchListMenuTemplate(); return LT_INC_AND_PAUSE; case 3: if (sub_81C8224()) return LT_PAUSE; - AddSearchResultListMenuWindow(searchList); + AddSearchResultListMenuWindow(gfx); PrintHelpBarText(HELPBAR_CONDITION_MON_LIST); return LT_INC_AND_PAUSE; case 4: @@ -453,7 +460,7 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state) ShowBg(1); ShowBg(2); HideBg(3); - if (!searchList->fromGraph) + if (!gfx->fromGraph) { u8 searchGfxId = GetSelectedConditionSearch() + POKENAV_MENUITEM_CONDITION_SEARCH_COOL; LoadLeftHeaderGfxForIndex(searchGfxId); @@ -474,7 +481,7 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state) static u32 LoopedTask_MoveSearchListCursorUp(s32 state) { - struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); + struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX); switch (state) { case 0: @@ -495,7 +502,7 @@ static u32 LoopedTask_MoveSearchListCursorUp(s32 state) return LT_PAUSE; // fallthrough case 2: - PrintSearchResultListMenuItems(searchList); + PrintSearchResultListMenuItems(gfx); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -507,7 +514,7 @@ static u32 LoopedTask_MoveSearchListCursorUp(s32 state) static u32 LoopedTask_MoveSearchListCursorDown(s32 state) { - struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); + struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX); switch (state) { case 0: @@ -528,7 +535,7 @@ static u32 LoopedTask_MoveSearchListCursorDown(s32 state) return LT_PAUSE; // fallthrough case 2: - PrintSearchResultListMenuItems(searchList); + PrintSearchResultListMenuItems(gfx); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -540,7 +547,7 @@ static u32 LoopedTask_MoveSearchListCursorDown(s32 state) static u32 LoopedTask_MoveSearchListPageUp(s32 state) { - struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); + struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX); switch (state) { case 0: @@ -561,7 +568,7 @@ static u32 LoopedTask_MoveSearchListPageUp(s32 state) return LT_PAUSE; // fallthrough case 2: - PrintSearchResultListMenuItems(searchList); + PrintSearchResultListMenuItems(gfx); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -573,7 +580,7 @@ static u32 LoopedTask_MoveSearchListPageUp(s32 state) static u32 LoopedTask_MoveSearchListPageDown(s32 state) { - struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); + struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX); switch (state) { case 0: @@ -594,7 +601,7 @@ static u32 LoopedTask_MoveSearchListPageDown(s32 state) return LT_PAUSE; // fallthrough case 2: - PrintSearchResultListMenuItems(searchList); + PrintSearchResultListMenuItems(gfx); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -640,25 +647,25 @@ static u32 LoopedTask_SelectSearchResult(s32 state) return LT_FINISH; } -static void AddSearchResultListMenuWindow(struct PokenavSub8 *searchList) +static void AddSearchResultListMenuWindow(struct Pokenav_SearchResultsGfx *gfx) { - searchList->winid = AddWindow(&sSearchResultListMenuWindowTemplate); - PutWindowTilemap(searchList->winid); - CopyWindowToVram(searchList->winid, COPYWIN_MAP); - PrintSearchResultListMenuItems(searchList); + gfx->winid = AddWindow(&sSearchResultListMenuWindowTemplate); + PutWindowTilemap(gfx->winid); + CopyWindowToVram(gfx->winid, COPYWIN_MAP); + PrintSearchResultListMenuItems(gfx); } -static void PrintSearchResultListMenuItems(struct PokenavSub8 *searchList) +static void PrintSearchResultListMenuItems(struct Pokenav_SearchResultsGfx *gfx) { - s32 r7 = GetSearchResultsSelectedMonData(); + s32 rank = GetSearchResultsSelectedMonRank(); DynamicPlaceholderTextUtil_Reset(); DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1); *gStringVar1 = EOS; - DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar2, gText_NumberF700); - AddTextPrinterParameterized(searchList->winid, FONT_NORMAL, gStringVar2, 4, 1, TEXT_SKIP_DRAW, NULL); - ConvertIntToDecimalStringN(gStringVar1, r7, STR_CONV_MODE_RIGHT_ALIGN, 3); - AddTextPrinterParameterized(searchList->winid, FONT_NORMAL, gStringVar1, 34, 1, TEXT_SKIP_DRAW, NULL); - CopyWindowToVram(searchList->winid, COPYWIN_GFX); + DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar2, gText_NumberIndex); + AddTextPrinterParameterized(gfx->winid, FONT_NORMAL, gStringVar2, 4, 1, TEXT_SKIP_DRAW, NULL); + ConvertIntToDecimalStringN(gStringVar1, rank, STR_CONV_MODE_RIGHT_ALIGN, 3); + AddTextPrinterParameterized(gfx->winid, FONT_NORMAL, gStringVar1, 34, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(gfx->winid, COPYWIN_GFX); } static void InitConditionSearchListMenuTemplate(void) @@ -668,7 +675,7 @@ static void InitConditionSearchListMenuTemplate(void) template.list.monList = GetSearchResultsMonDataList(); template.count = GetSearchResultsMonListCount(); template.unk8 = 4; - template.unk6 = sub_81CF10C(); + template.unk6 = GetSearchResultsCurrentListIndex(); template.item_X = 13; template.windowWidth = 17; template.listTop = 1; diff --git a/src/pokenav_menu_handler_1.c b/src/pokenav_menu_handler_1.c index 4792756c1..a500e7c18 100644 --- a/src/pokenav_menu_handler_1.c +++ b/src/pokenav_menu_handler_1.c @@ -355,7 +355,7 @@ static u32 HandleConditionMenuInput(struct Pokenav1Struct *state) return POKENAV_MENU_FUNC_OPEN_CONDITION_SEARCH; case POKENAV_MENUITEM_CONDITION_PARTY: state->helpBarIndex = 0; - SetMenuIdAndCB(state, POKENAV_CONDITION_PARTY); + SetMenuIdAndCB(state, POKENAV_CONDITION_GRAPH_PARTY); return POKENAV_MENU_FUNC_OPEN_FEATURE; case POKENAV_MENUITEM_CONDITION_CANCEL: PlaySE(SE_SELECT); diff --git a/src/pokenav_menu_handler_2.c b/src/pokenav_menu_handler_2.c index 4724eab0e..a50f45106 100644 --- a/src/pokenav_menu_handler_2.c +++ b/src/pokenav_menu_handler_2.c @@ -359,7 +359,7 @@ bool32 OpenPokenavMenuNotInitial(void) static struct Pokenav2Struct * OpenPokenavMenu(void) { - struct Pokenav2Struct * state = AllocSubstruct(2, sizeof(struct Pokenav2Struct)); + struct Pokenav2Struct * state = AllocSubstruct(POKENAV_SUBSTRUCT_MENU_ICONS, sizeof(struct Pokenav2Struct)); if (state != NULL) { diff --git a/src/strings.c b/src/strings.c index 3785766ce..eebf367d7 100644 --- a/src/strings.c +++ b/src/strings.c @@ -990,7 +990,7 @@ const u8 gText_Unknown[] = _("UNKNOWN"); const u8 gText_Call[] = _("CALL"); const u8 gText_Check[] = _("CHECK"); const u8 gText_Cancel6[] = _("CANCEL"); -const u8 gText_NumberF700[] = _("No. {DYNAMIC 0}"); +const u8 gText_NumberIndex[] = _("No. {DYNAMIC 0}"); const u8 gText_RibbonsF700[] = _("RIBBONS {DYNAMIC 0}"); const u8 gText_PokemonMaleLv2[] = _("{DYNAMIC 0}{COLOR_HIGHLIGHT_SHADOW LIGHT_RED WHITE GREEN}♂{COLOR_HIGHLIGHT_SHADOW DARK_GRAY WHITE LIGHT_GRAY}/{LV}{DYNAMIC 1}{DYNAMIC 2}"); // Unused const u8 gText_PokemonFemaleLv2[] = _("{DYNAMIC 0}{COLOR_HIGHLIGHT_SHADOW LIGHT_GREEN WHITE BLUE}♀{COLOR_HIGHLIGHT_SHADOW DARK_GRAY WHITE LIGHT_GRAY}/{LV}{DYNAMIC 1}{DYNAMIC 2}"); // Unused diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 8cf8480cc..ef5fdfaf5 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -1577,9 +1577,9 @@ static void SpriteCB_MonPic(struct Sprite *sprite) static void SpriteCB_SelectionIconPokeball(struct Sprite *sprite) { if (sprite->data[0] == sMenu->info.curSelection) - StartSpriteAnim(sprite, 0); + StartSpriteAnim(sprite, CONDITION_ICON_SELECTED); else - StartSpriteAnim(sprite, 1); + StartSpriteAnim(sprite, CONDITION_ICON_UNSELECTED); } static void SpriteCB_SelectionIconCancel(struct Sprite *sprite) From 35aeff1b6df8efc4e088bd20c71e4243b95c6599 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 12 Nov 2021 11:07:52 -0500 Subject: [PATCH 06/19] Rename pokenav conditions files --- include/pokenav.h | 6 +++--- ld_script.txt | 10 +++++----- src/{pokenav_conditions_1.c => pokenav_conditions.c} | 0 ...pokenav_conditions_2.c => pokenav_conditions_gfx.c} | 2 +- ...ditions_3.c => pokenav_conditions_search_results.c} | 0 sym_bss.txt | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) rename src/{pokenav_conditions_1.c => pokenav_conditions.c} (100%) rename src/{pokenav_conditions_2.c => pokenav_conditions_gfx.c} (99%) rename src/{pokenav_conditions_3.c => pokenav_conditions_search_results.c} (100%) diff --git a/include/pokenav.h b/include/pokenav.h index 847d4b7e7..971354633 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -436,7 +436,7 @@ bool32 IsRegionMapLoopedTaskActive(void); void FreeRegionMapSubstruct1(void); void FreeRegionMapSubstruct2(void); -// pokenav_conditions_1.c +// pokenav_conditions.c u32 PokenavCallback_Init_ConditionGraph_Party(void); u32 PokenavCallback_Init_ConditionGraph_Search(void); u32 GetConditionGraphMenuCallback(void); @@ -455,14 +455,14 @@ u16 GetConditionMonDataBuffer(void); void *GetConditionMonPicGfx(u8 id); void *GetConditionMonPal(u8 id); -// pokenav_conditions_2.c +// pokenav_conditions_gfx.c bool32 OpenConditionGraphMenu(void); void CreateConditionGraphMenuLoopedTask(s32); u32 IsConditionGraphMenuLoopedTaskActive(void); void FreeConditionGraphMenuSubstruct2(void); u8 GetMonMarkingsData(void); -// pokenav_conditions_3.c +// pokenav_conditions_search_results.c u32 PokenavCallback_Init_ConditionSearch(void); u32 PokenavCallback_Init_ReturnToMonSearchList(void); u32 GetConditionSearchResultsCallback(void); diff --git a/ld_script.txt b/ld_script.txt index ca0480e0f..c4283265d 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -316,9 +316,9 @@ SECTIONS { src/pokenav_match_call_1.o(.text); src/pokenav_match_call_2.o(.text); src/pokenav_region_map.o(.text); - src/pokenav_conditions_1.o(.text); - src/pokenav_conditions_2.o(.text); - src/pokenav_conditions_3.o(.text); + src/pokenav_conditions.o(.text); + src/pokenav_conditions_gfx.o(.text); + src/pokenav_conditions_search_results.o(.text); src/pokenav_ribbons_list.o(.text); src/pokenav_ribbons_summary.o(.text); src/pokenav_match_call_data.o(.text); @@ -671,8 +671,8 @@ SECTIONS { src/pokenav_match_call_1.o(.rodata); src/pokenav_match_call_2.o(.rodata); src/pokenav_region_map.o(.rodata); - src/pokenav_conditions_2.o(.rodata); - src/pokenav_conditions_3.o(.rodata); + src/pokenav_conditions_gfx.o(.rodata); + src/pokenav_conditions_search_results.o(.rodata); src/pokenav_ribbons_list.o(.rodata); src/pokenav_ribbons_summary.o(.rodata); src/pokenav_match_call_data.o(.rodata); diff --git a/src/pokenav_conditions_1.c b/src/pokenav_conditions.c similarity index 100% rename from src/pokenav_conditions_1.c rename to src/pokenav_conditions.c diff --git a/src/pokenav_conditions_2.c b/src/pokenav_conditions_gfx.c similarity index 99% rename from src/pokenav_conditions_2.c rename to src/pokenav_conditions_gfx.c index cecba800c..a1593983d 100644 --- a/src/pokenav_conditions_2.c +++ b/src/pokenav_conditions_gfx.c @@ -139,7 +139,7 @@ struct Pokenav_ConditionMenuGfx u8 filler2[0xFA3]; }; -extern s8 GetConditionGraphMenuCurrentLoadIndex(void); // This function's declaration here is s8 vs. u8 in pokenav_conditions_1.c +extern s8 GetConditionGraphMenuCurrentLoadIndex(void); // This function's declaration here is s8 vs. u8 in pokenav_conditions.c static u32 LoopedTask_OpenConditionGraphMenu(s32); static u32 GetConditionGraphMenuLoopedTaskActive(void); diff --git a/src/pokenav_conditions_3.c b/src/pokenav_conditions_search_results.c similarity index 100% rename from src/pokenav_conditions_3.c rename to src/pokenav_conditions_search_results.c diff --git a/sym_bss.txt b/sym_bss.txt index 8724f02d7..75da960bf 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -50,7 +50,7 @@ .include "src/multiboot.o" .include "src/mirage_tower.o" .include "src/berry_fix_program.o" - .include "src/pokenav_conditions_2.o" + .include "src/pokenav_conditions_gfx.o" .include "src/pokenav_ribbons_summary.o" .include "src/ereader_helpers.o" .include "src/faraway_island.o" From 004d1cab3fd7eb7b67fd32b457848604836b3c1a Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 12 Nov 2021 11:13:49 -0500 Subject: [PATCH 07/19] Clean up pokenav conditions doc --- include/pokenav.h | 8 -------- src/menu_specialized.c | 2 +- src/pokenav_conditions.c | 44 +++++++++++++++++++++------------------- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/include/pokenav.h b/include/pokenav.h index 971354633..a0e293453 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -255,14 +255,6 @@ enum CONDITION_FUNC_CLOSE_MARKINGS, }; -enum -{ - CONDITION_MON_0, - CONDITION_MON_1, - CONDITION_MON_2, - NUM_CONDITION_MONS -}; - enum { CONDITION_LOAD_MON_INFO, diff --git a/src/menu_specialized.c b/src/menu_specialized.c index d1cc3ff58..20d67ca7f 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -591,7 +591,7 @@ static void ConditionGraph_CalcRightHalf(struct ConditionGraph *graph) // Calculate Cute -> Tough line (includes left scanline because this crosses the halfway point) i = (graph->curPositions[GRAPH_CUTE].y <= graph->curPositions[GRAPH_SMART].y); ConditionGraph_CalcLine(graph, graph->scanlineRight[0], &graph->curPositions[GRAPH_CUTE], &graph->curPositions[GRAPH_SMART], i, graph->scanlineLeft[0]); - + // Clear down to new top for (i = CONDITION_GRAPH_TOP_Y; i < y; i++) { diff --git a/src/pokenav_conditions.c b/src/pokenav_conditions.c index fc188db71..6007acc2b 100644 --- a/src/pokenav_conditions.c +++ b/src/pokenav_conditions.c @@ -13,20 +13,22 @@ #include "text.h" #include "constants/songs.h" +#define CONDITION_MONS_LOADED 3 + struct Pokenav_ConditionMenu { - u32 monPal[NUM_CONDITION_MONS][0x20]; + u32 monPal[CONDITION_MONS_LOADED][0x20]; u8 fill[0x180]; - u32 monPicGfx[NUM_CONDITION_MONS][MON_PIC_SIZE]; + u32 monPicGfx[CONDITION_MONS_LOADED][MON_PIC_SIZE]; bool8 inSearchMode; s16 toLoadListIndex; u32 (*callback)(struct Pokenav_ConditionMenu *); u8 fill2[0x18]; - u8 locationText[NUM_CONDITION_MONS][24]; - u8 nameText[NUM_CONDITION_MONS][64]; + u8 locationText[CONDITION_MONS_LOADED][24]; + u8 nameText[CONDITION_MONS_LOADED][64]; struct ConditionGraph graph; - u8 numSparkles[NUM_CONDITION_MONS]; - u8 monMarks[NUM_CONDITION_MONS]; + u8 numSparkles[CONDITION_MONS_LOADED]; + u8 monMarks[CONDITION_MONS_LOADED]; s8 loadId; s8 nextLoadIdDown; s8 nextLoadIdUp; @@ -239,28 +241,28 @@ bool32 LoadConditionGraphMenuGfx(void) switch (menu->state) { case 0: - CopyMonNameGenderLocation(monListPtr->currIndex, CONDITION_MON_0); + CopyMonNameGenderLocation(monListPtr->currIndex, 0); break; case 1: - GetMonConditionGraphData(monListPtr->currIndex, CONDITION_MON_0); + GetMonConditionGraphData(monListPtr->currIndex, 0); break; case 2: - ConditionGraphDrawMonPic(monListPtr->currIndex, CONDITION_MON_0); + ConditionGraphDrawMonPic(monListPtr->currIndex, 0); break; case 3: if (monListPtr->listCount == 1) { - menu->loadId = CONDITION_MON_0; - menu->nextLoadIdDown = CONDITION_MON_0; - menu->nextLoadIdUp = CONDITION_MON_0; + menu->loadId = 0; + menu->nextLoadIdDown = 0; + menu->nextLoadIdUp = 0; menu->state = 0; return TRUE; } else { - menu->loadId = CONDITION_MON_0; - menu->nextLoadIdDown = CONDITION_MON_1; - menu->nextLoadIdUp = CONDITION_MON_2; + menu->loadId = 0; + menu->nextLoadIdDown = 1; + menu->nextLoadIdUp = 2; } break; // These were probably ternaries just like cases 7-9, but couldn't match it any other way. @@ -268,28 +270,28 @@ bool32 LoadConditionGraphMenuGfx(void) var = monListPtr->currIndex + 1; if (var >= monListPtr->listCount) var = 0; - CopyMonNameGenderLocation(var, CONDITION_MON_1); + CopyMonNameGenderLocation(var, 1); break; case 5: var = monListPtr->currIndex + 1; if (var >= monListPtr->listCount) var = 0; - GetMonConditionGraphData(var, CONDITION_MON_1); + GetMonConditionGraphData(var, 1); break; case 6: var = monListPtr->currIndex + 1; if (var >= monListPtr->listCount) var = 0; - ConditionGraphDrawMonPic(var, CONDITION_MON_1); + ConditionGraphDrawMonPic(var, 1); break; case 7: - CopyMonNameGenderLocation((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2); + CopyMonNameGenderLocation((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2); break; case 8: - GetMonConditionGraphData((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2); + GetMonConditionGraphData((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2); break; case 9: - ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2); + ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2); menu->state = 0; return TRUE; } From baeacbe2f10ef69468d3bdb223d8ca74c963e9d6 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 12 Nov 2021 12:40:36 -0500 Subject: [PATCH 08/19] Clean up pokenav general menus, organize pokenav graphics --- graphics/pokenav/icon2_unused.png | Bin 194 -> 0 bytes .../{arrows_matchcall.png => list_arrows.png} | Bin graphics/pokenav/{ => match_call}/86226E0.pal | 0 graphics/pokenav/{ => match_call}/8622700.pal | 0 .../{arrow2.png => match_call/arrow.png} | Bin .../{icon.png => match_call/nav_icon.png} | Bin .../{8622720.pal => match_call/pokeball.pal} | 0 .../pokeball.png} | Bin .../{ui_matchcall.bin => match_call/ui.bin} | Bin .../{ui_matchcall.png => match_call/ui.png} | Bin .../window.png} | Bin graphics/pokenav/{icon2.png => nav_icon.png} | Bin graphics/pokenav/pokeball_matchcall.pal | 35 - .../pokenav/{ => region_map}/brendan_icon.png | Bin graphics/pokenav/{ => region_map}/cursor.pal | 0 .../pokenav/{ => region_map}/cursor_large.png | Bin .../pokenav/{ => region_map}/cursor_small.png | Bin .../{ => region_map}/fly_target_icons.png | Bin .../{map_frame.bin => region_map/frame.bin} | Bin .../{map_frame.png => region_map/frame.png} | Bin .../info_window.pal} | 0 .../pokenav/{ => region_map}/may_icon.png | Bin graphics_file_rules.mk | 2 +- include/pokenav.h | 6 +- src/match_call.c | 8 +- src/pokenav.c | 1 - src/pokenav_main_menu.c | 271 ++++---- src/pokenav_match_call_2.c | 20 +- src/pokenav_match_call_ui.c | 4 +- src/pokenav_menu_handler_1.c | 302 ++++----- src/pokenav_menu_handler_2.c | 636 ++++++++++-------- src/pokenav_region_map.c | 4 +- src/region_map.c | 33 +- 33 files changed, 687 insertions(+), 635 deletions(-) delete mode 100644 graphics/pokenav/icon2_unused.png rename graphics/pokenav/{arrows_matchcall.png => list_arrows.png} (100%) rename graphics/pokenav/{ => match_call}/86226E0.pal (100%) rename graphics/pokenav/{ => match_call}/8622700.pal (100%) rename graphics/pokenav/{arrow2.png => match_call/arrow.png} (100%) rename graphics/pokenav/{icon.png => match_call/nav_icon.png} (100%) rename graphics/pokenav/{8622720.pal => match_call/pokeball.pal} (100%) rename graphics/pokenav/{pokeball_matchcall.png => match_call/pokeball.png} (100%) rename graphics/pokenav/{ui_matchcall.bin => match_call/ui.bin} (100%) rename graphics/pokenav/{ui_matchcall.png => match_call/ui.png} (100%) rename graphics/pokenav/{match_call_window.png => match_call/window.png} (100%) rename graphics/pokenav/{icon2.png => nav_icon.png} (100%) delete mode 100644 graphics/pokenav/pokeball_matchcall.pal rename graphics/pokenav/{ => region_map}/brendan_icon.png (100%) rename graphics/pokenav/{ => region_map}/cursor.pal (100%) rename graphics/pokenav/{ => region_map}/cursor_large.png (100%) rename graphics/pokenav/{ => region_map}/cursor_small.png (100%) rename graphics/pokenav/{ => region_map}/fly_target_icons.png (100%) rename graphics/pokenav/{map_frame.bin => region_map/frame.bin} (100%) rename graphics/pokenav/{map_frame.png => region_map/frame.png} (100%) rename graphics/pokenav/{region_map_info_window.pal => region_map/info_window.pal} (100%) rename graphics/pokenav/{ => region_map}/may_icon.png (100%) diff --git a/graphics/pokenav/icon2_unused.png b/graphics/pokenav/icon2_unused.png deleted file mode 100644 index c32a9b9be9f17feb7585d641a220838974e2e0dc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Et!VDx^^%AmxltF+`i0l9V|JNjGu9-4r%bGR+ zj~0KcPFk|$Y*NxUpg6~t|3Fo6aQ5ugHEZ@NEI8W&6!P_SaSV}|y0zbsiNTPCWpBgx z)t^l57x*5QeK%``v1qUkx0cB4%GQO>LKCWImHWsvcMIqyZi&`eEVO8UK?~o*{=OZ` i$8LVSQBga^`n7%Z*Gfgh6Q@3c?DBN=b6Mw<&;$ULGfE%; diff --git a/graphics/pokenav/arrows_matchcall.png b/graphics/pokenav/list_arrows.png similarity index 100% rename from graphics/pokenav/arrows_matchcall.png rename to graphics/pokenav/list_arrows.png diff --git a/graphics/pokenav/86226E0.pal b/graphics/pokenav/match_call/86226E0.pal similarity index 100% rename from graphics/pokenav/86226E0.pal rename to graphics/pokenav/match_call/86226E0.pal diff --git a/graphics/pokenav/8622700.pal b/graphics/pokenav/match_call/8622700.pal similarity index 100% rename from graphics/pokenav/8622700.pal rename to graphics/pokenav/match_call/8622700.pal diff --git a/graphics/pokenav/arrow2.png b/graphics/pokenav/match_call/arrow.png similarity index 100% rename from graphics/pokenav/arrow2.png rename to graphics/pokenav/match_call/arrow.png diff --git a/graphics/pokenav/icon.png b/graphics/pokenav/match_call/nav_icon.png similarity index 100% rename from graphics/pokenav/icon.png rename to graphics/pokenav/match_call/nav_icon.png diff --git a/graphics/pokenav/8622720.pal b/graphics/pokenav/match_call/pokeball.pal similarity index 100% rename from graphics/pokenav/8622720.pal rename to graphics/pokenav/match_call/pokeball.pal diff --git a/graphics/pokenav/pokeball_matchcall.png b/graphics/pokenav/match_call/pokeball.png similarity index 100% rename from graphics/pokenav/pokeball_matchcall.png rename to graphics/pokenav/match_call/pokeball.png diff --git a/graphics/pokenav/ui_matchcall.bin b/graphics/pokenav/match_call/ui.bin similarity index 100% rename from graphics/pokenav/ui_matchcall.bin rename to graphics/pokenav/match_call/ui.bin diff --git a/graphics/pokenav/ui_matchcall.png b/graphics/pokenav/match_call/ui.png similarity index 100% rename from graphics/pokenav/ui_matchcall.png rename to graphics/pokenav/match_call/ui.png diff --git a/graphics/pokenav/match_call_window.png b/graphics/pokenav/match_call/window.png similarity index 100% rename from graphics/pokenav/match_call_window.png rename to graphics/pokenav/match_call/window.png diff --git a/graphics/pokenav/icon2.png b/graphics/pokenav/nav_icon.png similarity index 100% rename from graphics/pokenav/icon2.png rename to graphics/pokenav/nav_icon.png diff --git a/graphics/pokenav/pokeball_matchcall.pal b/graphics/pokenav/pokeball_matchcall.pal deleted file mode 100644 index 25baec517..000000000 --- a/graphics/pokenav/pokeball_matchcall.pal +++ /dev/null @@ -1,35 +0,0 @@ -JASC-PAL -0100 -32 -0 197 0 -246 197 123 -255 255 255 -106 115 123 -0 0 0 -189 106 65 -49 65 74 -255 222 156 -180 131 82 -189 139 106 -197 197 197 -255 255 255 -0 0 0 -0 0 0 -0 0 0 -255 74 16 -0 197 0 -246 197 123 -255 255 255 -106 115 123 -0 0 0 -189 106 65 -49 65 74 -255 222 156 -180 131 82 -189 139 106 -197 197 197 -197 197 197 -0 0 0 -0 0 0 -0 0 0 -189 106 65 diff --git a/graphics/pokenav/brendan_icon.png b/graphics/pokenav/region_map/brendan_icon.png similarity index 100% rename from graphics/pokenav/brendan_icon.png rename to graphics/pokenav/region_map/brendan_icon.png diff --git a/graphics/pokenav/cursor.pal b/graphics/pokenav/region_map/cursor.pal similarity index 100% rename from graphics/pokenav/cursor.pal rename to graphics/pokenav/region_map/cursor.pal diff --git a/graphics/pokenav/cursor_large.png b/graphics/pokenav/region_map/cursor_large.png similarity index 100% rename from graphics/pokenav/cursor_large.png rename to graphics/pokenav/region_map/cursor_large.png diff --git a/graphics/pokenav/cursor_small.png b/graphics/pokenav/region_map/cursor_small.png similarity index 100% rename from graphics/pokenav/cursor_small.png rename to graphics/pokenav/region_map/cursor_small.png diff --git a/graphics/pokenav/fly_target_icons.png b/graphics/pokenav/region_map/fly_target_icons.png similarity index 100% rename from graphics/pokenav/fly_target_icons.png rename to graphics/pokenav/region_map/fly_target_icons.png diff --git a/graphics/pokenav/map_frame.bin b/graphics/pokenav/region_map/frame.bin similarity index 100% rename from graphics/pokenav/map_frame.bin rename to graphics/pokenav/region_map/frame.bin diff --git a/graphics/pokenav/map_frame.png b/graphics/pokenav/region_map/frame.png similarity index 100% rename from graphics/pokenav/map_frame.png rename to graphics/pokenav/region_map/frame.png diff --git a/graphics/pokenav/region_map_info_window.pal b/graphics/pokenav/region_map/info_window.pal similarity index 100% rename from graphics/pokenav/region_map_info_window.pal rename to graphics/pokenav/region_map/info_window.pal diff --git a/graphics/pokenav/may_icon.png b/graphics/pokenav/region_map/may_icon.png similarity index 100% rename from graphics/pokenav/may_icon.png rename to graphics/pokenav/region_map/may_icon.png diff --git a/graphics_file_rules.mk b/graphics_file_rules.mk index bc503eec2..eb36d4255 100644 --- a/graphics_file_rules.mk +++ b/graphics_file_rules.mk @@ -697,7 +697,7 @@ $(PKNAVGFXDIR)/header.4bpp: %.4bpp: %.png $(PKNAVGFXDIR)/device_outline.4bpp: %.4bpp: %.png $(GFX) $< $@ -num_tiles 53 -$(PKNAVGFXDIR)/ui_matchcall.4bpp: %.4bpp: %.png +$(PKNAVGFXDIR)/match_call/ui.4bpp: %.4bpp: %.png $(GFX) $< $@ -num_tiles 13 $(INTERFACEGFXDIR)/region_map.8bpp: %.8bpp: %.png diff --git a/include/pokenav.h b/include/pokenav.h index a0e293453..6dc88cab7 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -69,7 +69,7 @@ enum { POKENAV_SUBSTRUCT_MAIN_MENU, POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, - POKENAV_SUBSTRUCT_MENU_ICONS, + POKENAV_SUBSTRUCT_MENU_GFX, POKENAV_SUBSTRUCT_REGION_MAP_STATE, POKENAV_SUBSTRUCT_REGION_MAP_ZOOM, POKENAV_SUBSTRUCT_MATCH_CALL_MAIN, @@ -82,7 +82,7 @@ enum POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX, POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST, POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU, - POKENAV_SUBSTRUCT_15, //unused + POKENAV_SUBSTRUCT_UNUSED, POKENAV_SUBSTRUCT_REGION_MAP, POKENAV_SUBSTRUCT_MATCH_CALL_LIST, POKENAV_SUBSTRUCT_MON_LIST, @@ -358,7 +358,7 @@ void SlideMenuHeaderDown(void); bool32 MainMenuLoopedTaskIsBusy(void); void SetLeftHeaderSpritesInvisibility(void); void PokenavCopyPalette(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u16 *palette); -void sub_81C7B40(void); +void FadeToBlackExceptPrimary(void); struct Sprite *PauseSpinningPokenavSprite(void); void ResumeSpinningPokenavSprite(void); void UpdateRegionMapRightHeaderTiles(u32 arg0); diff --git a/src/match_call.c b/src/match_call.c index 9e4659ee6..0595ad3e3 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -1187,10 +1187,10 @@ static void StartMatchCall(void) CreateTask(ExecuteMatchCall, 1); } -static const u16 sMatchCallWindow_Pal[] = INCBIN_U16("graphics/pokenav/match_call_window.gbapal"); -static const u8 sMatchCallWindow_Gfx[] = INCBIN_U8("graphics/pokenav/match_call_window.4bpp"); -static const u16 sPokenavIcon_Pal[] = INCBIN_U16("graphics/pokenav/icon.gbapal"); -static const u32 sPokenavIcon_Gfx[] = INCBIN_U32("graphics/pokenav/icon.4bpp.lz"); +static const u16 sMatchCallWindow_Pal[] = INCBIN_U16("graphics/pokenav/match_call/window.gbapal"); +static const u8 sMatchCallWindow_Gfx[] = INCBIN_U8("graphics/pokenav/match_call/window.4bpp"); +static const u16 sPokenavIcon_Pal[] = INCBIN_U16("graphics/pokenav/match_call/nav_icon.gbapal"); +static const u32 sPokenavIcon_Gfx[] = INCBIN_U32("graphics/pokenav/match_call/nav_icon.4bpp.lz"); static const u8 sText_PokenavCallEllipsis[] = _("………………\p"); diff --git a/src/pokenav.c b/src/pokenav.c index b09fc9da0..f9a6614a8 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -49,7 +49,6 @@ static void Task_RunLoopedTask(u8 taskId); static void Task_Pokenav(u8 taskId); static void CB2_InitPokenavForTutorial(void); -// TODO: Use MENU ids const struct PokenavCallbacks PokenavMenuCallbacks[15] = { [POKENAV_MAIN_MENU - POKENAV_MENU_IDS_START] = diff --git a/src/pokenav_main_menu.c b/src/pokenav_main_menu.c index 714c8221a..77faecaa3 100644 --- a/src/pokenav_main_menu.c +++ b/src/pokenav_main_menu.c @@ -13,7 +13,7 @@ #include "menu.h" #include "dma3.h" -struct PokenavMainMenuResources +struct Pokenav_MainMenu { void (*loopTask)(u32); u32 (*isLoopTaskActiveFunc)(void); @@ -24,7 +24,7 @@ struct PokenavMainMenuResources struct Sprite *spinningPokenav; struct Sprite *leftHeaderSprites[2]; struct Sprite *submenuLeftHeaderSprites[2]; - u8 tilemapBuffer[0x800]; + u8 tilemapBuffer[BG_SCREEN_SIZE]; }; // This struct uses a 32bit tag, and doesn't have a size field. @@ -36,26 +36,26 @@ struct CompressedSpriteSheetNoSize }; static void CleanupPokenavMainMenuResources(void); -static void LoadLeftHeaderGfxForSubMenu(u32 arg0); -static void LoadLeftHeaderGfxForMenu(u32 index); -static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide); -static void HideLeftHeaderSprites(bool32 isOnRightSide); -static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide); -static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide); -static void MoveLeftHeader(struct Sprite *sprite, s32 startX, s32 endX, s32 duration); -static void SpriteCB_MoveLeftHeader(struct Sprite *sprite); +static void LoadLeftHeaderGfxForSubMenu(u32); +static void LoadLeftHeaderGfxForMenu(u32); +static void HideLeftHeaderSubmenuSprites(bool32); +static void HideLeftHeaderSprites(bool32); +static void ShowLeftHeaderSprites(u32, bool32); +static void ShowLeftHeaderSubmenuSprites(u32, bool32); +static void MoveLeftHeader(struct Sprite *, s32, s32, s32); +static void SpriteCB_MoveLeftHeader(struct Sprite *); static void InitPokenavMainMenuResources(void); -static void InitHoennMapHeaderSprites(void); +static void CreateLeftHeaderSprites(void); static void InitHelpBar(void); -static u32 LoopedTask_SlideMenuHeaderUp(s32 a0); -static u32 LoopedTask_SlideMenuHeaderDown(s32 a0); -static void DrawHelpBar(u32 windowId); -static void SpriteCB_SpinningPokenav(struct Sprite* sprite); -static u32 LoopedTask_InitPokenavMenu(s32 a0); +static u32 LoopedTask_SlideMenuHeaderUp(s32); +static u32 LoopedTask_SlideMenuHeaderDown(s32); +static void DrawHelpBar(u32); +static void SpriteCB_SpinningPokenav(struct Sprite*); +static u32 LoopedTask_InitPokenavMenu(s32); -const u16 gSpinningPokenavPaletteData[] = INCBIN_U16("graphics/pokenav/icon2.gbapal"); -const u32 gSpinningPokenavGfx[] = INCBIN_U32("graphics/pokenav/icon2.4bpp.lz"); -const u32 gUnused_SpinningPokenavGfx2[] = INCBIN_U32("graphics/pokenav/icon2_unused.4bpp.lz"); +static const u16 sSpinningPokenav_Pal[] = INCBIN_U16("graphics/pokenav/nav_icon.gbapal"); +static const u32 sSpinningPokenav_Gfx[] = INCBIN_U32("graphics/pokenav/nav_icon.4bpp.lz"); +static const u32 sBlueLightCopy[] = INCBIN_U32("graphics/pokenav/blue_light.4bpp.lz"); // Unused copy of sMatchCallBlueLightTiles const struct BgTemplate gPokenavMainMenuBgTemplates[] = { @@ -108,7 +108,7 @@ static const u8 sHelpBarTextColors[3] = static const struct CompressedSpriteSheet gSpinningPokenavSpriteSheet[] = { { - .data = gSpinningPokenavGfx, + .data = sSpinningPokenav_Gfx, .size = 0x1000, .tag = 0, } @@ -117,20 +117,20 @@ static const struct CompressedSpriteSheet gSpinningPokenavSpriteSheet[] = static const struct SpritePalette gSpinningNavgearPalettes[] = { { - .data = gSpinningPokenavPaletteData, + .data = sSpinningPokenav_Pal, .tag = 0, }, {} }; -static const struct CompressedSpriteSheet sPokenavHoennMapLeftHeaderSpriteSheet = +static const struct CompressedSpriteSheet sMenuLeftHeaderSpriteSheet = { - .data = gPokenavLeftHeaderHoennMap_Gfx, + .data = gPokenavLeftHeaderHoennMap_Gfx, // Hoenn map is the first of the headers listed .size = 0xC00, .tag = 2 }; -static const struct CompressedSpriteSheet sPokenavMenuLeftHeaderSpriteSheets[] = +static const struct CompressedSpriteSheet sMenuLeftHeaderSpriteSheets[] = { [POKENAV_GFX_MAIN_MENU] = { .data = gPokenavLeftHeaderMainMenu_Gfx, @@ -239,7 +239,7 @@ static const struct SpriteTemplate sSpinningPokenavSpriteTemplate = .callback = SpriteCB_SpinningPokenav }; -static const struct OamData sPokenavLeftHeaderHoennMapSpriteOam = +static const struct OamData sOamData_LeftHeader = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -253,7 +253,7 @@ static const struct OamData sPokenavLeftHeaderHoennMapSpriteOam = .paletteNum = 0, }; -static const struct OamData sUnknown_0861FB24 = +static const struct OamData sOamData_SubmenuLeftHeader = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -268,22 +268,22 @@ static const struct OamData sUnknown_0861FB24 = .paletteNum = 0, }; -static const struct SpriteTemplate sPokenavLeftHeaderHoennMapSpriteTemplate = +static const struct SpriteTemplate sLeftHeaderSpriteTemplate = { .tileTag = 2, .paletteTag = 1, - .oam = &sPokenavLeftHeaderHoennMapSpriteOam, + .oam = &sOamData_LeftHeader, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteTemplate sUnknown_0861FB44 = +static const struct SpriteTemplate sSubmenuLeftHeaderSpriteTemplate = { .tileTag = 2, .paletteTag = 2, - .oam = &sUnknown_0861FB24, + .oam = &sOamData_SubmenuLeftHeader, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, @@ -292,22 +292,22 @@ static const struct SpriteTemplate sUnknown_0861FB44 = bool32 InitPokenavMainMenu(void) { - struct PokenavMainMenuResources *structPtr; + struct Pokenav_MainMenu *menu; - structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU, sizeof(struct PokenavMainMenuResources)); - if (structPtr == NULL) + menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU, sizeof(struct Pokenav_MainMenu)); + if (menu == NULL) return FALSE; ResetSpriteData(); FreeAllSpritePalettes(); - structPtr->currentTaskId = CreateLoopedTask(LoopedTask_InitPokenavMenu, 1); + menu->currentTaskId = CreateLoopedTask(LoopedTask_InitPokenavMenu, 1); return TRUE; } u32 PokenavMainMenuLoopedTaskIsActive(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - return IsLoopedTaskActive(structPtr->currentTaskId); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + return IsLoopedTaskActive(menu->currentTaskId); } void ShutdownPokenav(void) @@ -330,11 +330,11 @@ bool32 WaitForPokenavShutdownFade(void) return TRUE; } -static u32 LoopedTask_InitPokenavMenu(s32 a0) +static u32 LoopedTask_InitPokenavMenu(s32 state) { - struct PokenavMainMenuResources *structPtr; + struct Pokenav_MainMenu *menu; - switch (a0) + switch (state) { case 0: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); @@ -345,9 +345,9 @@ static u32 LoopedTask_InitPokenavMenu(s32 a0) ResetTempTileDataBuffers(); return LT_INC_AND_CONTINUE; case 1: - structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); DecompressAndCopyTileDataToVram(0, &gPokenavHeader_Gfx, 0, 0, 0); - SetBgTilemapBuffer(0, structPtr->tilemapBuffer); + SetBgTilemapBuffer(0, menu->tilemapBuffer); CopyToBgTilemapBuffer(0, &gPokenavHeader_Tilemap, 0, 0); CopyPaletteIntoBufferUnfaded(gPokenavHeader_Pal, 0, 0x20); CopyBgTilemapBufferToVram(0); @@ -363,7 +363,7 @@ static u32 LoopedTask_InitPokenavMenu(s32 a0) return LT_PAUSE; InitPokenavMainMenuResources(); - InitHoennMapHeaderSprites(); + CreateLeftHeaderSprites(); ShowBg(0); return LT_FINISH; default: @@ -373,46 +373,46 @@ static u32 LoopedTask_InitPokenavMenu(s32 a0) void SetActiveMenuLoopTasks(void *createLoopTask, void *isLoopTaskActive) // Fix types later. { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - structPtr->loopTask = createLoopTask; - structPtr->isLoopTaskActiveFunc = isLoopTaskActive; - structPtr->unused = 0; + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + menu->loopTask = createLoopTask; + menu->isLoopTaskActiveFunc = isLoopTaskActive; + menu->unused = 0; } -void RunMainMenuLoopedTask(u32 a0) +void RunMainMenuLoopedTask(u32 state) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - structPtr->unused = 0; - structPtr->loopTask(a0); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + menu->unused = 0; + menu->loopTask(state); } u32 IsActiveMenuLoopTaskActive(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - return structPtr->isLoopTaskActiveFunc(); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + return menu->isLoopTaskActiveFunc(); } void SlideMenuHeaderUp(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - structPtr->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderUp, 4); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + menu->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderUp, 4); } void SlideMenuHeaderDown(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - structPtr->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderDown, 4); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + menu->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderDown, 4); } bool32 MainMenuLoopedTaskIsBusy(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - return IsLoopedTaskActive(structPtr->currentTaskId); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + return IsLoopedTaskActive(menu->currentTaskId); } -static u32 LoopedTask_SlideMenuHeaderUp(s32 a0) +static u32 LoopedTask_SlideMenuHeaderUp(s32 state) { - switch (a0) + switch (state) { default: return LT_FINISH; @@ -431,7 +431,7 @@ static u32 LoopedTask_SlideMenuHeaderUp(s32 a0) } } -static u32 LoopedTask_SlideMenuHeaderDown(s32 a0) +static u32 LoopedTask_SlideMenuHeaderDown(s32 state) { if (ChangeBgY(0, 384, BG_COORD_SUB) <= 0) { @@ -510,15 +510,15 @@ void PokenavCopyPalette(const u16 *src, const u16 *dest, int size, int a3, int a void PokenavFadeScreen(s32 fadeType) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); switch (fadeType) { case 0: - BeginNormalPaletteFade(structPtr->palettes, -2, 0, 16, RGB_BLACK); + BeginNormalPaletteFade(menu->palettes, -2, 0, 16, RGB_BLACK); break; case 1: - BeginNormalPaletteFade(structPtr->palettes, -2, 16, 0, RGB_BLACK); + BeginNormalPaletteFade(menu->palettes, -2, 16, 0, RGB_BLACK); break; case 2: BeginNormalPaletteFade(PALETTES_ALL, -2, 0, 16, RGB_BLACK); @@ -534,9 +534,10 @@ bool32 IsPaletteFadeActive(void) return gPaletteFade.active; } -void sub_81C7B40(void) +// Excludes the first obj and bg palettes +void FadeToBlackExceptPrimary(void) { - BlendPalettes(PALETTES_ALL & ~(0x10000 | 0x1), 16, RGB_BLACK); + BlendPalettes(PALETTES_ALL & ~(1 << 16 | 1), 16, RGB_BLACK); } void InitBgTemplates(const struct BgTemplate *templates, int count) @@ -549,21 +550,21 @@ void InitBgTemplates(const struct BgTemplate *templates, int count) static void InitHelpBar(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); InitWindows(&sHelpBarWindowTemplate[0]); - structPtr->helpBarWindowId = 0; - DrawHelpBar(structPtr->helpBarWindowId); - PutWindowTilemap(structPtr->helpBarWindowId); - CopyWindowToVram(structPtr->helpBarWindowId, COPYWIN_FULL); + menu->helpBarWindowId = 0; + DrawHelpBar(menu->helpBarWindowId); + PutWindowTilemap(menu->helpBarWindowId); + CopyWindowToVram(menu->helpBarWindowId, COPYWIN_FULL); } void PrintHelpBarText(u32 textId) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - DrawHelpBar(structPtr->helpBarWindowId); - AddTextPrinterParameterized3(structPtr->helpBarWindowId, FONT_NORMAL, 0, 1, sHelpBarTextColors, 0, sHelpBarTexts[textId]); + DrawHelpBar(menu->helpBarWindowId); + AddTextPrinterParameterized3(menu->helpBarWindowId, FONT_NORMAL, 0, 1, sHelpBarTextColors, 0, sHelpBarTexts[textId]); } bool32 WaitForHelpBar(void) @@ -581,22 +582,22 @@ static void InitPokenavMainMenuResources(void) { s32 i; u8 spriteId; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); for (i = 0; i < ARRAY_COUNT(gSpinningPokenavSpriteSheet); i++) LoadCompressedSpriteSheet(&gSpinningPokenavSpriteSheet[i]); Pokenav_AllocAndLoadPalettes(gSpinningNavgearPalettes); - structPtr->palettes = ~1 & ~(0x10000 << IndexOfSpritePaletteTag(0)); + menu->palettes = ~1 & ~(0x10000 << IndexOfSpritePaletteTag(0)); spriteId = CreateSprite(&sSpinningPokenavSpriteTemplate, 220, 12, 0); - structPtr->spinningPokenav = &gSprites[spriteId]; + menu->spinningPokenav = &gSprites[spriteId]; } static void CleanupPokenavMainMenuResources(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - DestroySprite(structPtr->spinningPokenav); + DestroySprite(menu->spinningPokenav); FreeSpriteTilesByTag(0); FreeSpritePaletteByTag(0); } @@ -609,45 +610,47 @@ static void SpriteCB_SpinningPokenav(struct Sprite *sprite) struct Sprite *PauseSpinningPokenavSprite(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - structPtr->spinningPokenav->callback = SpriteCallbackDummy; - return structPtr->spinningPokenav; + menu->spinningPokenav->callback = SpriteCallbackDummy; + return menu->spinningPokenav; } void ResumeSpinningPokenavSprite(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - structPtr->spinningPokenav->x = 220; - structPtr->spinningPokenav->y = 12; - structPtr->spinningPokenav->callback = SpriteCB_SpinningPokenav; - structPtr->spinningPokenav->invisible = FALSE; - structPtr->spinningPokenav->oam.priority = 0; - structPtr->spinningPokenav->subpriority = 0; + menu->spinningPokenav->x = 220; + menu->spinningPokenav->y = 12; + menu->spinningPokenav->callback = SpriteCB_SpinningPokenav; + menu->spinningPokenav->invisible = FALSE; + menu->spinningPokenav->oam.priority = 0; + menu->spinningPokenav->subpriority = 0; } -static void InitHoennMapHeaderSprites(void) +static void CreateLeftHeaderSprites(void) { s32 i, spriteId; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - LoadCompressedSpriteSheet(&sPokenavHoennMapLeftHeaderSpriteSheet); + LoadCompressedSpriteSheet(&sMenuLeftHeaderSpriteSheet); AllocSpritePalette(1); AllocSpritePalette(2); - for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++) { - spriteId = CreateSprite(&sPokenavLeftHeaderHoennMapSpriteTemplate, 0, 0, 1); - structPtr->leftHeaderSprites[i] = &gSprites[spriteId]; - structPtr->leftHeaderSprites[i]->invisible = TRUE; - structPtr->leftHeaderSprites[i]->x2 = i * 64; + // Create main left header + spriteId = CreateSprite(&sLeftHeaderSpriteTemplate, 0, 0, 1); + menu->leftHeaderSprites[i] = &gSprites[spriteId]; + menu->leftHeaderSprites[i]->invisible = TRUE; + menu->leftHeaderSprites[i]->x2 = i * 64; - spriteId = CreateSprite(&sUnknown_0861FB44, 0, 0, 2); - structPtr->submenuLeftHeaderSprites[i] = &gSprites[spriteId]; - structPtr->submenuLeftHeaderSprites[i]->invisible = TRUE; - structPtr->submenuLeftHeaderSprites[i]->x2 = i * 32; - structPtr->submenuLeftHeaderSprites[i]->y2 = 18; - structPtr->submenuLeftHeaderSprites[i]->oam.tileNum += (i * 8) + 64; + // Create submenu left header + spriteId = CreateSprite(&sSubmenuLeftHeaderSpriteTemplate, 0, 0, 2); + menu->submenuLeftHeaderSprites[i] = &gSprites[spriteId]; + menu->submenuLeftHeaderSprites[i]->invisible = TRUE; + menu->submenuLeftHeaderSprites[i]->x2 = i * 32; + menu->submenuLeftHeaderSprites[i]->y2 = 18; + menu->submenuLeftHeaderSprites[i]->oam.tileNum += (i * 8) + 64; } } @@ -661,34 +664,34 @@ void LoadLeftHeaderGfxForIndex(u32 menuGfxId) void UpdateRegionMapRightHeaderTiles(u32 menuGfxId) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT) - structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 32; + menu->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 32; else - structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 64; + menu->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 64; } static void LoadLeftHeaderGfxForMenu(u32 menuGfxId) { - struct PokenavMainMenuResources *structPtr; + struct Pokenav_MainMenu *menu; u32 size, tag; if (menuGfxId >= POKENAV_GFX_SUBMENUS_START) return; - structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - tag = sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].tag; - size = GetDecompressedDataSize(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data); + menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + tag = sMenuLeftHeaderSpriteSheets[menuGfxId].tag; + size = GetDecompressedDataSize(sMenuLeftHeaderSpriteSheets[menuGfxId].data); LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], (IndexOfSpritePaletteTag(1) * 16) + 0x100, 0x20); - LZ77UnCompWram(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data, gDecompressionBuffer); + LZ77UnCompWram(sMenuLeftHeaderSpriteSheets[menuGfxId].data, gDecompressionBuffer); RequestDma3Copy(gDecompressionBuffer, (void *)OBJ_VRAM0 + (GetSpriteTileStartByTag(2) * 32), size, 1); - structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].size; + menu->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + sMenuLeftHeaderSpriteSheets[menuGfxId].size; if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT || menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_IN) - structPtr->leftHeaderSprites[1]->x2 = 56; + menu->leftHeaderSprites[1]->x2 = 56; else - structPtr->leftHeaderSprites[1]->x2 = 64; + menu->leftHeaderSprites[1]->x2 = 64; } static void LoadLeftHeaderGfxForSubMenu(u32 menuGfxId) @@ -731,20 +734,20 @@ void HideMainOrSubMenuLeftHeader(u32 id, bool32 onRightSide) void SetLeftHeaderSpritesInvisibility(void) { s32 i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++) { - structPtr->leftHeaderSprites[i]->invisible = TRUE; - structPtr->submenuLeftHeaderSprites[i]->invisible = TRUE; + menu->leftHeaderSprites[i]->invisible = TRUE; + menu->submenuLeftHeaderSprites[i]->invisible = TRUE; } } bool32 AreLeftHeaderSpritesMoving(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - if (structPtr->leftHeaderSprites[0]->callback == SpriteCallbackDummy && structPtr->submenuLeftHeaderSprites[0]->callback == SpriteCallbackDummy) + if (menu->leftHeaderSprites[0]->callback == SpriteCallbackDummy && menu->submenuLeftHeaderSprites[0]->callback == SpriteCallbackDummy) return FALSE; else return TRUE; @@ -753,66 +756,66 @@ bool32 AreLeftHeaderSpritesMoving(void) static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide) { s32 start, end, i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (!isOnRightSide) start = -96, end = 32; else start = 256, end = 160; - for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++) { - structPtr->leftHeaderSprites[i]->y = startY; - MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12); + menu->leftHeaderSprites[i]->y = startY; + MoveLeftHeader(menu->leftHeaderSprites[i], start, end, 12); } } static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide) { s32 start, end, i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (!isOnRightSide) start = -96, end = 16; else start = 256, end = 192; - for (i = 0; i < (s32)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(menu->submenuLeftHeaderSprites); i++) { - structPtr->submenuLeftHeaderSprites[i]->y = startY; - MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12); + menu->submenuLeftHeaderSprites[i]->y = startY; + MoveLeftHeader(menu->submenuLeftHeaderSprites[i], start, end, 12); } } static void HideLeftHeaderSprites(bool32 isOnRightSide) { s32 start, end, i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (!isOnRightSide) start = 32, end = -96; else start = 192, end = 256; - for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++) { - MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12); + MoveLeftHeader(menu->leftHeaderSprites[i], start, end, 12); } } static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide) { s32 start, end, i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (!isOnRightSide) start = 16, end = -96; else start = 192, end = 256; - for (i = 0; i < (s32)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(menu->submenuLeftHeaderSprites); i++) { - MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12); + MoveLeftHeader(menu->submenuLeftHeaderSprites[i], start, end, 12); } } diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index 8f2220957..29cb0a06d 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -109,15 +109,15 @@ u32 ShowCheckPageDown(s32); u32 ExitCheckPage(s32); u32 ExitMatchCall(s32); -static const u16 sMatchCallUI_Pal[] = INCBIN_U16("graphics/pokenav/ui_matchcall.gbapal"); -static const u32 sMatchCallUI_Gfx[] = INCBIN_U32("graphics/pokenav/ui_matchcall.4bpp.lz"); -static const u32 sMatchCallUI_Tilemap[] = INCBIN_U32("graphics/pokenav/ui_matchcall.bin.lz"); -static const u16 gUnknown_08622698[] = INCBIN_U16("graphics/pokenav/arrow2.gbapal"); -static const u32 gUnknown_086226B8[] = INCBIN_U32("graphics/pokenav/arrow2.4bpp.lz"); -static const u16 gUnknown_086226E0[] = INCBIN_U16("graphics/pokenav/86226E0.gbapal"); -static const u16 gUnknown_08622700[] = INCBIN_U16("graphics/pokenav/8622700.gbapal"); -static const u16 gUnknown_08622720[] = INCBIN_U16("graphics/pokenav/pokeball_matchcall.gbapal"); -static const u32 gUnknown_08622760[] = INCBIN_U32("graphics/pokenav/pokeball_matchcall.4bpp.lz"); +static const u16 sMatchCallUI_Pal[] = INCBIN_U16("graphics/pokenav/match_call/ui.gbapal"); +static const u32 sMatchCallUI_Gfx[] = INCBIN_U32("graphics/pokenav/match_call/ui.4bpp.lz"); +static const u32 sMatchCallUI_Tilemap[] = INCBIN_U32("graphics/pokenav/match_call/ui.bin.lz"); +static const u16 gUnknown_08622698[] = INCBIN_U16("graphics/pokenav/match_call/arrow.gbapal"); +static const u32 gUnknown_086226B8[] = INCBIN_U32("graphics/pokenav/match_call/arrow.4bpp.lz"); +static const u16 gUnknown_086226E0[] = INCBIN_U16("graphics/pokenav/match_call/86226E0.gbapal"); +static const u16 gUnknown_08622700[] = INCBIN_U16("graphics/pokenav/match_call/8622700.gbapal"); +static const u16 gUnknown_08622720[] = INCBIN_U16("graphics/pokenav/match_call/pokeball.gbapal"); +static const u32 gUnknown_08622760[] = INCBIN_U32("graphics/pokenav/match_call/pokeball.4bpp.lz"); const struct BgTemplate sMatchCallBgTemplates[3] = { @@ -1062,7 +1062,7 @@ static void sub_81CC034(struct Pokenav4Struct *state) { state->msgBoxWindowId = AddWindow(&sCallMsgBoxWindowTemplate); LoadMatchCallWindowGfx(state->msgBoxWindowId, 1, 4); - sub_81C7B40(); + FadeToBlackExceptPrimary(); } static void DrawMsgBoxForMatchCallMsg(struct Pokenav4Struct *state) diff --git a/src/pokenav_match_call_ui.c b/src/pokenav_match_call_ui.c index 47226ca72..ce3db25c5 100644 --- a/src/pokenav_match_call_ui.c +++ b/src/pokenav_match_call_ui.c @@ -94,8 +94,8 @@ u32 LoopedTask_sub_81C8870(s32 state); u32 LoopedTask_sub_81C8A28(s32 state); u32 LoopedTask_PrintCheckPageInfo(s32 state); -static const u16 sMatchcallArrowPaletteData[] = INCBIN_U16("graphics/pokenav/arrows_matchcall.gbapal"); -static const u32 sMatchcallArrowSpriteSheetData[] = INCBIN_U32("graphics/pokenav/arrows_matchcall.4bpp.lz"); +static const u16 sMatchcallArrowPaletteData[] = INCBIN_U16("graphics/pokenav/list_arrows.gbapal"); +static const u32 sMatchcallArrowSpriteSheetData[] = INCBIN_U32("graphics/pokenav/list_arrows.4bpp.lz"); EWRAM_DATA u32 gUnknown_0203CF44 = 0; diff --git a/src/pokenav_menu_handler_1.c b/src/pokenav_menu_handler_1.c index a500e7c18..b72247742 100644 --- a/src/pokenav_menu_handler_1.c +++ b/src/pokenav_menu_handler_1.c @@ -5,31 +5,31 @@ #include "sound.h" #include "constants/songs.h" -struct Pokenav1Struct +struct Pokenav_Menu { u16 menuType; s16 cursorPos; u16 currMenuItem; u16 helpBarIndex; u32 menuId; - u32 (*callback)(struct Pokenav1Struct*); + u32 (*callback)(struct Pokenav_Menu*); }; -static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state); -static void ReturnToConditionMenu(struct Pokenav1Struct *state); -static void ReturnToMainMenu(struct Pokenav1Struct *state); -static u32 GetMenuId(struct Pokenav1Struct *state); -static void SetMenuIdAndCB(struct Pokenav1Struct *state, u32 a1); -static u32 CB2_ReturnToConditionMenu(struct Pokenav1Struct *state); -static u32 CB2_ReturnToMainMenu(struct Pokenav1Struct *state); -static u32 HandleConditionSearchMenuInput(struct Pokenav1Struct *state); -static u32 HandleConditionMenuInput(struct Pokenav1Struct *state); -static u32 HandleCantOpenRibbonsInput(struct Pokenav1Struct *state); -static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state); -static u32 HandleMainMenuInputTutorial(struct Pokenav1Struct *state); -static u32 HandleMainMenuInput(struct Pokenav1Struct *state); -static u32 (*GetMainMenuInputHandler(void))(struct Pokenav1Struct*); -static void SetMenuInputHandler(struct Pokenav1Struct *state); +static bool32 UpdateMenuCursorPos(struct Pokenav_Menu *); +static void ReturnToConditionMenu(struct Pokenav_Menu *); +static void ReturnToMainMenu(struct Pokenav_Menu *); +static u32 GetMenuId(struct Pokenav_Menu *); +static void SetMenuIdAndCB(struct Pokenav_Menu *, u32); +static u32 CB2_ReturnToConditionMenu(struct Pokenav_Menu *); +static u32 CB2_ReturnToMainMenu(struct Pokenav_Menu *); +static u32 HandleConditionSearchMenuInput(struct Pokenav_Menu *); +static u32 HandleConditionMenuInput(struct Pokenav_Menu *); +static u32 HandleCantOpenRibbonsInput(struct Pokenav_Menu *); +static u32 HandleMainMenuInputEndTutorial(struct Pokenav_Menu *); +static u32 HandleMainMenuInputTutorial(struct Pokenav_Menu *); +static u32 HandleMainMenuInput(struct Pokenav_Menu *); +static u32 (*GetMainMenuInputHandler(void))(struct Pokenav_Menu*); +static void SetMenuInputHandler(struct Pokenav_Menu *); // Number of entries - 1 for that menu type static const u8 sLastCursorPositions[] = @@ -41,20 +41,20 @@ static const u8 sLastCursorPositions[] = [POKENAV_MENU_TYPE_CONDITION_SEARCH] = 5 }; -static const u8 sMenuItems[][6] = +static const u8 sMenuItems[][MAX_POKENAV_MENUITEMS] = { [POKENAV_MENU_TYPE_DEFAULT] = { POKENAV_MENUITEM_MAP, POKENAV_MENUITEM_CONDITION, - [2 ... 5] = POKENAV_MENUITEM_SWITCH_OFF + [2 ... MAX_POKENAV_MENUITEMS - 1] = POKENAV_MENUITEM_SWITCH_OFF }, [POKENAV_MENU_TYPE_UNLOCK_MC] = { POKENAV_MENUITEM_MAP, POKENAV_MENUITEM_CONDITION, POKENAV_MENUITEM_MATCH_CALL, - [3 ... 5] = POKENAV_MENUITEM_SWITCH_OFF + [3 ... MAX_POKENAV_MENUITEMS - 1] = POKENAV_MENUITEM_SWITCH_OFF }, [POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS] = { @@ -62,14 +62,14 @@ static const u8 sMenuItems[][6] = POKENAV_MENUITEM_CONDITION, POKENAV_MENUITEM_MATCH_CALL, POKENAV_MENUITEM_RIBBONS, - [4 ... 5] = POKENAV_MENUITEM_SWITCH_OFF + [4 ... MAX_POKENAV_MENUITEMS - 1] = POKENAV_MENUITEM_SWITCH_OFF }, [POKENAV_MENU_TYPE_CONDITION] = { POKENAV_MENUITEM_CONDITION_PARTY, POKENAV_MENUITEM_CONDITION_SEARCH, POKENAV_MENUITEM_CONDITION_CANCEL, - [3 ... 5] = POKENAV_MENUITEM_SWITCH_OFF + [3 ... MAX_POKENAV_MENUITEMS - 1] = POKENAV_MENUITEM_SWITCH_OFF }, [POKENAV_MENU_TYPE_CONDITION_SEARCH] = { @@ -99,94 +99,94 @@ static u8 GetPokenavMainMenuType(void) bool32 PokenavCallback_Init_MainMenuCursorOnMap(void) { - struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); - if (!state) + struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu)); + if (!menu) return FALSE; - state->menuType = GetPokenavMainMenuType(); - state->cursorPos = POKENAV_MENUITEM_MAP; - state->currMenuItem = POKENAV_MENUITEM_MAP; - state->helpBarIndex = HELPBAR_NONE; - SetMenuInputHandler(state); + menu->menuType = GetPokenavMainMenuType(); + menu->cursorPos = POKENAV_MENUITEM_MAP; + menu->currMenuItem = POKENAV_MENUITEM_MAP; + menu->helpBarIndex = HELPBAR_NONE; + SetMenuInputHandler(menu); return TRUE; } bool32 PokenavCallback_Init_MainMenuCursorOnMatchCall(void) { - struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); - if (!state) + struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu)); + if (!menu) return FALSE; - state->menuType = GetPokenavMainMenuType(); - state->cursorPos = POKENAV_MENUITEM_MATCH_CALL; - state->currMenuItem = POKENAV_MENUITEM_MATCH_CALL; - state->helpBarIndex = HELPBAR_NONE; - SetMenuInputHandler(state); + menu->menuType = GetPokenavMainMenuType(); + menu->cursorPos = POKENAV_MENUITEM_MATCH_CALL; + menu->currMenuItem = POKENAV_MENUITEM_MATCH_CALL; + menu->helpBarIndex = HELPBAR_NONE; + SetMenuInputHandler(menu); return TRUE; } bool32 PokenavCallback_Init_MainMenuCursorOnRibbons(void) { - struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); - if (!state) + struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu)); + if (!menu) return FALSE; - state->menuType = GetPokenavMainMenuType(); - state->cursorPos = POKENAV_MENUITEM_RIBBONS; - state->currMenuItem = POKENAV_MENUITEM_RIBBONS; - SetMenuInputHandler(state); + menu->menuType = GetPokenavMainMenuType(); + menu->cursorPos = POKENAV_MENUITEM_RIBBONS; + menu->currMenuItem = POKENAV_MENUITEM_RIBBONS; + SetMenuInputHandler(menu); return TRUE; } bool32 PokenavCallback_Init_ConditionMenu(void) { - struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); - if (!state) + struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu)); + if (!menu) return FALSE; - state->menuType = POKENAV_MENU_TYPE_CONDITION; - state->cursorPos = 0; //party - state->currMenuItem = POKENAV_MENUITEM_CONDITION_PARTY; - state->helpBarIndex = HELPBAR_NONE; - SetMenuInputHandler(state); + menu->menuType = POKENAV_MENU_TYPE_CONDITION; + menu->cursorPos = 0; //party + menu->currMenuItem = POKENAV_MENUITEM_CONDITION_PARTY; + menu->helpBarIndex = HELPBAR_NONE; + SetMenuInputHandler(menu); return TRUE; } bool32 PokenavCallback_Init_ConditionSearchMenu(void) { - struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); - if (!state) + struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu)); + if (!menu) return FALSE; - state->menuType = POKENAV_MENU_TYPE_CONDITION_SEARCH; - state->cursorPos = GetSelectedConditionSearch(); - state->currMenuItem = state->cursorPos + POKENAV_MENUITEM_CONDITION_SEARCH_COOL; - state->helpBarIndex = HELPBAR_NONE; - SetMenuInputHandler(state); + menu->menuType = POKENAV_MENU_TYPE_CONDITION_SEARCH; + menu->cursorPos = GetSelectedConditionSearch(); + menu->currMenuItem = menu->cursorPos + POKENAV_MENUITEM_CONDITION_SEARCH_COOL; + menu->helpBarIndex = HELPBAR_NONE; + SetMenuInputHandler(menu); return TRUE; } -static void SetMenuInputHandler(struct Pokenav1Struct *state) +static void SetMenuInputHandler(struct Pokenav_Menu *menu) { - switch (state->menuType) + switch (menu->menuType) { case POKENAV_MENU_TYPE_DEFAULT: SetPokenavMode(POKENAV_MODE_NORMAL); // fallthrough case POKENAV_MENU_TYPE_UNLOCK_MC: case POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS: - state->callback = GetMainMenuInputHandler(); + menu->callback = GetMainMenuInputHandler(); break; case POKENAV_MENU_TYPE_CONDITION: - state->callback = HandleConditionMenuInput; + menu->callback = HandleConditionMenuInput; break; case POKENAV_MENU_TYPE_CONDITION_SEARCH: - state->callback = HandleConditionSearchMenuInput; + menu->callback = HandleConditionSearchMenuInput; break; } } -static u32 (*GetMainMenuInputHandler(void))(struct Pokenav1Struct*) +static u32 (*GetMainMenuInputHandler(void))(struct Pokenav_Menu*) { switch (GetPokenavMode()) { @@ -202,8 +202,8 @@ static u32 (*GetMainMenuInputHandler(void))(struct Pokenav1Struct*) u32 GetMenuHandlerCallback(void) { - struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); - return state->callback(state); + struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); + return menu->callback(menu); } void FreeMenuHandlerSubstruct1(void) @@ -211,39 +211,39 @@ void FreeMenuHandlerSubstruct1(void) FreePokenavSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); } -static u32 HandleMainMenuInput(struct Pokenav1Struct *state) +static u32 HandleMainMenuInput(struct Pokenav_Menu *menu) { - if (UpdateMenuCursorPos(state)) + if (UpdateMenuCursorPos(menu)) return POKENAV_MENU_FUNC_MOVE_CURSOR; if (JOY_NEW(A_BUTTON)) { - switch (sMenuItems[state->menuType][state->cursorPos]) + switch (sMenuItems[menu->menuType][menu->cursorPos]) { case POKENAV_MENUITEM_MAP: - state->helpBarIndex = gSaveBlock2Ptr->regionMapZoom ? HELPBAR_MAP_ZOOMED_IN : HELPBAR_MAP_ZOOMED_OUT; - SetMenuIdAndCB(state, POKENAV_REGION_MAP); + menu->helpBarIndex = gSaveBlock2Ptr->regionMapZoom ? HELPBAR_MAP_ZOOMED_IN : HELPBAR_MAP_ZOOMED_OUT; + SetMenuIdAndCB(menu, POKENAV_REGION_MAP); return POKENAV_MENU_FUNC_OPEN_FEATURE; case POKENAV_MENUITEM_CONDITION: - state->menuType = POKENAV_MENU_TYPE_CONDITION; - state->cursorPos = 0; - state->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION][0]; - state->callback = HandleConditionMenuInput; + menu->menuType = POKENAV_MENU_TYPE_CONDITION; + menu->cursorPos = 0; + menu->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION][0]; + menu->callback = HandleConditionMenuInput; return POKENAV_MENU_FUNC_OPEN_CONDITION; case POKENAV_MENUITEM_MATCH_CALL: - state->helpBarIndex = HELPBAR_MC_TRAINER_LIST; - SetMenuIdAndCB(state, POKENAV_MATCH_CALL); + menu->helpBarIndex = HELPBAR_MC_TRAINER_LIST; + SetMenuIdAndCB(menu, POKENAV_MATCH_CALL); return POKENAV_MENU_FUNC_OPEN_FEATURE; case POKENAV_MENUITEM_RIBBONS: if (CanViewRibbonsMenu()) { - state->helpBarIndex = HELPBAR_RIBBONS_MON_LIST; - SetMenuIdAndCB(state, POKENAV_RIBBONS_MON_LIST); + menu->helpBarIndex = HELPBAR_RIBBONS_MON_LIST; + SetMenuIdAndCB(menu, POKENAV_RIBBONS_MON_LIST); return POKENAV_MENU_FUNC_OPEN_FEATURE; } else { - state->callback = HandleCantOpenRibbonsInput; + menu->callback = HandleCantOpenRibbonsInput; return POKENAV_MENU_FUNC_NO_RIBBON_WINNERS; } case POKENAV_MENUITEM_SWITCH_OFF: @@ -258,17 +258,17 @@ static u32 HandleMainMenuInput(struct Pokenav1Struct *state) } // Force the player to select Match Call during the call Mr. Stone pokenav tutorial -static u32 HandleMainMenuInputTutorial(struct Pokenav1Struct *state) +static u32 HandleMainMenuInputTutorial(struct Pokenav_Menu *menu) { - if (UpdateMenuCursorPos(state)) + if (UpdateMenuCursorPos(menu)) return POKENAV_MENU_FUNC_MOVE_CURSOR; if (JOY_NEW(A_BUTTON)) { - if (sMenuItems[state->menuType][state->cursorPos] == POKENAV_MENUITEM_MATCH_CALL) + if (sMenuItems[menu->menuType][menu->cursorPos] == POKENAV_MENUITEM_MATCH_CALL) { - state->helpBarIndex = HELPBAR_MC_TRAINER_LIST; - SetMenuIdAndCB(state, POKENAV_MATCH_CALL); + menu->helpBarIndex = HELPBAR_MC_TRAINER_LIST; + SetMenuIdAndCB(menu, POKENAV_MATCH_CALL); return POKENAV_MENU_FUNC_OPEN_FEATURE; } else @@ -288,14 +288,14 @@ static u32 HandleMainMenuInputTutorial(struct Pokenav1Struct *state) } // After calling Mr. Stone during the pokenav tutorial, force player to exit or use Match Call again -static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state) +static u32 HandleMainMenuInputEndTutorial(struct Pokenav_Menu *menu) { - if (UpdateMenuCursorPos(state)) + if (UpdateMenuCursorPos(menu)) return POKENAV_MENU_FUNC_MOVE_CURSOR; if (JOY_NEW(A_BUTTON)) { - u32 menuItem = sMenuItems[state->menuType][state->cursorPos]; + u32 menuItem = sMenuItems[menu->menuType][menu->cursorPos]; if (menuItem != POKENAV_MENUITEM_MATCH_CALL && menuItem != POKENAV_MENUITEM_SWITCH_OFF) { PlaySE(SE_FAILURE); @@ -303,8 +303,8 @@ static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state) } else if (menuItem == POKENAV_MENUITEM_MATCH_CALL) { - state->helpBarIndex = HELPBAR_MC_TRAINER_LIST; - SetMenuIdAndCB(state, POKENAV_MATCH_CALL); + menu->helpBarIndex = HELPBAR_MC_TRAINER_LIST; + SetMenuIdAndCB(menu, POKENAV_MATCH_CALL); return POKENAV_MENU_FUNC_OPEN_FEATURE; } else @@ -321,60 +321,60 @@ static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state) // Handles input after selecting Ribbons when there are no ribbon winners left // Selecting it again just reprints the Ribbon description to replace the "No Ribbon winners" message -static u32 HandleCantOpenRibbonsInput(struct Pokenav1Struct *state) +static u32 HandleCantOpenRibbonsInput(struct Pokenav_Menu *menu) { - if (UpdateMenuCursorPos(state)) + if (UpdateMenuCursorPos(menu)) { - state->callback = GetMainMenuInputHandler(); + menu->callback = GetMainMenuInputHandler(); return POKENAV_MENU_FUNC_MOVE_CURSOR; } if (JOY_NEW(A_BUTTON | B_BUTTON)) { - state->callback = GetMainMenuInputHandler(); + menu->callback = GetMainMenuInputHandler(); return POKENAV_MENU_FUNC_RESHOW_DESCRIPTION; } return POKENAV_MENU_FUNC_NONE; } -static u32 HandleConditionMenuInput(struct Pokenav1Struct *state) +static u32 HandleConditionMenuInput(struct Pokenav_Menu *menu) { - if (UpdateMenuCursorPos(state)) + if (UpdateMenuCursorPos(menu)) return POKENAV_MENU_FUNC_MOVE_CURSOR; if (JOY_NEW(A_BUTTON)) { - switch (sMenuItems[state->menuType][state->cursorPos]) + switch (sMenuItems[menu->menuType][menu->cursorPos]) { case POKENAV_MENUITEM_CONDITION_SEARCH: - state->menuType = POKENAV_MENU_TYPE_CONDITION_SEARCH; - state->cursorPos = 0; - state->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION_SEARCH][0]; - state->callback = HandleConditionSearchMenuInput; + menu->menuType = POKENAV_MENU_TYPE_CONDITION_SEARCH; + menu->cursorPos = 0; + menu->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION_SEARCH][0]; + menu->callback = HandleConditionSearchMenuInput; return POKENAV_MENU_FUNC_OPEN_CONDITION_SEARCH; case POKENAV_MENUITEM_CONDITION_PARTY: - state->helpBarIndex = 0; - SetMenuIdAndCB(state, POKENAV_CONDITION_GRAPH_PARTY); + menu->helpBarIndex = 0; + SetMenuIdAndCB(menu, POKENAV_CONDITION_GRAPH_PARTY); return POKENAV_MENU_FUNC_OPEN_FEATURE; case POKENAV_MENUITEM_CONDITION_CANCEL: PlaySE(SE_SELECT); - ReturnToMainMenu(state); + ReturnToMainMenu(menu); return POKENAV_MENU_FUNC_RETURN_TO_MAIN; } } if (JOY_NEW(B_BUTTON)) { - if (state->cursorPos != sLastCursorPositions[state->menuType]) + if (menu->cursorPos != sLastCursorPositions[menu->menuType]) { - state->cursorPos = sLastCursorPositions[state->menuType]; - state->callback = CB2_ReturnToMainMenu; + menu->cursorPos = sLastCursorPositions[menu->menuType]; + menu->callback = CB2_ReturnToMainMenu; return POKENAV_MENU_FUNC_MOVE_CURSOR; } else { PlaySE(SE_SELECT); - ReturnToMainMenu(state); + ReturnToMainMenu(menu); return POKENAV_MENU_FUNC_RETURN_TO_MAIN; } } @@ -382,102 +382,102 @@ static u32 HandleConditionMenuInput(struct Pokenav1Struct *state) return POKENAV_MENU_FUNC_NONE; } -static u32 HandleConditionSearchMenuInput(struct Pokenav1Struct *state) +static u32 HandleConditionSearchMenuInput(struct Pokenav_Menu *menu) { - if (UpdateMenuCursorPos(state)) + if (UpdateMenuCursorPos(menu)) return POKENAV_MENU_FUNC_MOVE_CURSOR; if (JOY_NEW(A_BUTTON)) { - u8 menuItem = sMenuItems[state->menuType][state->cursorPos]; + u8 menuItem = sMenuItems[menu->menuType][menu->cursorPos]; if (menuItem != POKENAV_MENUITEM_CONDITION_SEARCH_CANCEL) { SetSelectedConditionSearch(menuItem - POKENAV_MENUITEM_CONDITION_SEARCH_COOL); - SetMenuIdAndCB(state, POKENAV_CONDITION_SEARCH_RESULTS); - state->helpBarIndex = HELPBAR_CONDITION_MON_LIST; + SetMenuIdAndCB(menu, POKENAV_CONDITION_SEARCH_RESULTS); + menu->helpBarIndex = HELPBAR_CONDITION_MON_LIST; return POKENAV_MENU_FUNC_OPEN_FEATURE; } else { PlaySE(SE_SELECT); - ReturnToConditionMenu(state); + ReturnToConditionMenu(menu); return POKENAV_MENU_FUNC_RETURN_TO_CONDITION; } } if (JOY_NEW(B_BUTTON)) { - if (state->cursorPos != sLastCursorPositions[state->menuType]) + if (menu->cursorPos != sLastCursorPositions[menu->menuType]) { - state->cursorPos = sLastCursorPositions[state->menuType]; - state->callback = CB2_ReturnToConditionMenu; + menu->cursorPos = sLastCursorPositions[menu->menuType]; + menu->callback = CB2_ReturnToConditionMenu; return POKENAV_MENU_FUNC_MOVE_CURSOR; } else { PlaySE(SE_SELECT); - ReturnToConditionMenu(state); + ReturnToConditionMenu(menu); return POKENAV_MENU_FUNC_RETURN_TO_CONDITION; } } return POKENAV_MENU_FUNC_NONE; } -static u32 CB2_ReturnToMainMenu(struct Pokenav1Struct *state) +static u32 CB2_ReturnToMainMenu(struct Pokenav_Menu *menu) { - ReturnToMainMenu(state); + ReturnToMainMenu(menu); return POKENAV_MENU_FUNC_RETURN_TO_MAIN; } -static u32 CB2_ReturnToConditionMenu(struct Pokenav1Struct *state) +static u32 CB2_ReturnToConditionMenu(struct Pokenav_Menu *menu) { - ReturnToConditionMenu(state); + ReturnToConditionMenu(menu); return POKENAV_MENU_FUNC_RETURN_TO_CONDITION; } -static void SetMenuIdAndCB(struct Pokenav1Struct *state, u32 menuId) +static void SetMenuIdAndCB(struct Pokenav_Menu *menu, u32 menuId) { - state->menuId = menuId; - state->callback = GetMenuId; + menu->menuId = menuId; + menu->callback = GetMenuId; } -static u32 GetMenuId(struct Pokenav1Struct *state) +static u32 GetMenuId(struct Pokenav_Menu *menu) { - return state->menuId; + return menu->menuId; } -static void ReturnToMainMenu(struct Pokenav1Struct *state) +static void ReturnToMainMenu(struct Pokenav_Menu *menu) { - state->menuType = GetPokenavMainMenuType(); - state->cursorPos = 1; - state->currMenuItem = sMenuItems[state->menuType][state->cursorPos]; - state->callback = HandleMainMenuInput; + menu->menuType = GetPokenavMainMenuType(); + menu->cursorPos = 1; + menu->currMenuItem = sMenuItems[menu->menuType][menu->cursorPos]; + menu->callback = HandleMainMenuInput; } -static void ReturnToConditionMenu(struct Pokenav1Struct *state) +static void ReturnToConditionMenu(struct Pokenav_Menu *menu) { - state->menuType = POKENAV_MENU_TYPE_CONDITION; - state->cursorPos = 1; - state->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION][1]; - state->callback = HandleConditionMenuInput; + menu->menuType = POKENAV_MENU_TYPE_CONDITION; + menu->cursorPos = 1; + menu->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION][1]; + menu->callback = HandleConditionMenuInput; } -static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state) +static bool32 UpdateMenuCursorPos(struct Pokenav_Menu *menu) { if (JOY_NEW(DPAD_UP)) { - if (--state->cursorPos < 0) - state->cursorPos = sLastCursorPositions[state->menuType]; + if (--menu->cursorPos < 0) + menu->cursorPos = sLastCursorPositions[menu->menuType]; - state->currMenuItem = sMenuItems[state->menuType][state->cursorPos]; + menu->currMenuItem = sMenuItems[menu->menuType][menu->cursorPos]; return TRUE; } else if (JOY_NEW(DPAD_DOWN)) { - state->cursorPos++; - if (state->cursorPos > sLastCursorPositions[state->menuType]) - state->cursorPos = 0; + menu->cursorPos++; + if (menu->cursorPos > sLastCursorPositions[menu->menuType]) + menu->cursorPos = 0; - state->currMenuItem = sMenuItems[state->menuType][state->cursorPos]; + menu->currMenuItem = sMenuItems[menu->menuType][menu->cursorPos]; return TRUE; } else @@ -488,26 +488,26 @@ static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state) int GetPokenavMenuType(void) { - struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); - return state->menuType; + struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); + return menu->menuType; } // Position of cursor relative to number of current menu options int GetPokenavCursorPos(void) { - struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); - return state->cursorPos; + struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); + return menu->cursorPos; } // ID of menu item the cursor is currently on int GetCurrentMenuItemId(void) { - struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); - return state->currMenuItem; + struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); + return menu->currMenuItem; } u16 GetHelpBarTextId(void) { - struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); - return state->helpBarIndex; + struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); + return menu->helpBarIndex; } diff --git a/src/pokenav_menu_handler_2.c b/src/pokenav_menu_handler_2.c index a50f45106..1738142ac 100644 --- a/src/pokenav_menu_handler_2.c +++ b/src/pokenav_menu_handler_2.c @@ -17,68 +17,86 @@ #include "constants/songs.h" #include "constants/rgb.h" -struct Pokenav2Struct +#define GFXTAG_BLUE_LIGHT 1 +#define GFXTAG_OPTIONS 3 + +#define PALTAG_BLUE_LIGHT 3 +#define PALTAG_OPTIONS_DEFAULT 4 // Includes green for Smart/Region Map and yellow for Tough +#define PALTAG_OPTIONS_BLUE 5 +#define PALTAG_OPTIONS_PINK 6 +#define PALTAG_OPTIONS_BEIGE 7 +#define PALTAG_OPTIONS_RED 8 + +#define PALTAG_OPTIONS_START PALTAG_OPTIONS_DEFAULT + +#define NUM_OPTION_SUBSPRITES 4 + +#define OPTION_DEFAULT_X 140 +#define OPTION_SELECTED_X 130 +#define OPTION_EXIT_X (DISPLAY_WIDTH + 16) + +struct Pokenav_MenuGfx { bool32 (*isTaskActiveCB)(void); u32 loopedTaskId; u16 optionDescWindowId; u8 bg3ScrollTaskId; u8 cursorPos; - bool8 otherIconsInMotion; + u8 numIconsBlending; bool8 pokenavAlreadyOpen; bool32 iconVisible[MAX_POKENAV_MENUITEMS]; - struct Sprite * blueLightSpriteId; - struct Sprite * iconSprites[MAX_POKENAV_MENUITEMS][4]; - u16 bg1TilemapBuffer[0x400]; + struct Sprite * blueLightSprite; + struct Sprite * iconSprites[MAX_POKENAV_MENUITEMS][NUM_OPTION_SUBSPRITES]; + u8 bg1TilemapBuffer[BG_SCREEN_SIZE]; }; -static struct Pokenav2Struct * OpenPokenavMenu(void); +static struct Pokenav_MenuGfx * OpenPokenavMenu(void); static bool32 GetCurrentLoopedTaskActive(void); -static u32 LoopedTask_OpenMenu(s32 state); -static u32 LoopedTask_MoveMenuCursor(s32 state); -static u32 LoopedTask_OpenConditionMenu(s32 state); -static u32 LoopedTask_ReturnToMainMenu(s32 state); -static u32 LoopedTask_OpenConditionSearchMenu(s32 state); -static u32 LoopedTask_ReturnToConditionMenu(s32 state); -static u32 LoopedTask_SelectRibbonsNoWinners(s32 state); -static u32 LoopedTask_ReShowDescription(s32 state); -static u32 LoopedTask_OpenPokenavFeature(s32 state); +static u32 LoopedTask_OpenMenu(s32); +static u32 LoopedTask_MoveMenuCursor(s32); +static u32 LoopedTask_OpenConditionMenu(s32); +static u32 LoopedTask_ReturnToMainMenu(s32); +static u32 LoopedTask_OpenConditionSearchMenu(s32); +static u32 LoopedTask_ReturnToConditionMenu(s32); +static u32 LoopedTask_SelectRibbonsNoWinners(s32); +static u32 LoopedTask_ReShowDescription(s32); +static u32 LoopedTask_OpenPokenavFeature(s32); static void LoadPokenavOptionPalettes(void); static void FreeAndDestroyMainMenuSprites(void); static void CreateMenuOptionSprites(void); static void DestroyMenuOptionSprites(void); -static void sub_81CA0C8(void); -static void DrawOptionLabelGfx(const u16 *const * a0, s32 yPos, s32 a2); -static void SetupCurrentMenuOptionsGfx(void); -static void SetMenuOptionGfxParams_CursorMoved(void); -static void SetMenuOptionGfxParamsInactive(struct Sprite ** sprites, s32 x, s32 a2, s32 a3); -static void SetMenuOptionGfxParamsActive(struct Sprite ** sprites); -static void SetupPokenavMenuOptions(void); +static void DrawCurrentMenuOptionLabels(void); +static void DrawOptionLabelGfx(const u16 *const *, s32, s32); +static void StartOptionAnimations_Enter(void); +static void StartOptionAnimations_CursorMoved(void); +static void StartOptionAnimations_Exit(void); +static void StartOptionSlide(struct Sprite **, s32, s32, s32); +static void StartOptionZoom(struct Sprite **); static bool32 AreMenuOptionSpritesMoving(void); -static void SetMenuOptionGfxInvisibility(struct Sprite ** sprites, bool32 a1); -static void sub_81CA474(struct Sprite * sprite); -static void sub_81CA4AC(struct Sprite * sprite); -static void sub_81CA580(u8 taskId); +static void SetOptionInvisibility(struct Sprite **, bool32); +static void SpriteCB_OptionSlide(struct Sprite *); +static void SpriteCB_OptionZoom(struct Sprite *); +static void Task_OptionBlend(u8); static void CreateMatchCallBlueLightSprite(void); -static void SpriteCB_BlinkingBlueLight(struct Sprite * sprite); -static void DestroyRematchBlueLightSpriteId(void); +static void SpriteCB_BlinkingBlueLight(struct Sprite *); +static void DestroyRematchBlueLightSprite(void); static void AddOptionDescriptionWindow(void); static void PrintCurrentOptionDescription(void); static void PrintNoRibbonWinners(void); static bool32 IsDma3ManagerBusyWithBgCopy_(void); static void CreateMovingBgDotsTask(void); static void DestroyMovingDotsBgTask(void); -static void Task_MoveBgDots(u8 taskId); +static void Task_MoveBgDots(u8); static void CreateBgDotPurplePalTask(void); static void ChangeBgDotsColorToPurple(void); static void CreateBgDotLightBluePalTask(void); static bool32 IsTaskActive_UpdateBgDotsPalette(void); -static void Task_UpdateBgDotsPalette(u8 taskId); +static void Task_UpdateBgDotsPalette(u8); static void SetupPokenavMenuScanlineEffects(void); static void DestroyMenuOptionGlowTask(void); static void ResetBldCnt(void); static void InitMenuOptionGlow(void); -static void Task_CurrentMenuOptionGlow(u8 taskId); +static void Task_CurrentMenuOptionGlow(u8); static void SetMenuOptionGlow(void); static const u16 sPokenavBgDotsPal[] = INCBIN_U16("graphics/pokenav/bg_dots.gbapal"); @@ -136,78 +154,103 @@ static const struct CompressedSpriteSheet sPokenavOptionsSpriteSheets[] = { .data = gPokenavOptions_Gfx, .size = 0x3400, - .tag = 0x0003 + .tag = GFXTAG_OPTIONS }, { .data = sMatchCallBlueLightTiles, .size = 0x0100, - .tag = 0x0001 + .tag = GFXTAG_BLUE_LIGHT } }; static const struct SpritePalette sPokenavOptionsSpritePalettes[] = { - {gPokenavOptions_Pal + 0x00, 4}, - {gPokenavOptions_Pal + 0x10, 5}, - {gPokenavOptions_Pal + 0x20, 6}, - {gPokenavOptions_Pal + 0x30, 7}, - {gPokenavOptions_Pal + 0x40, 8}, - {sMatchCallBlueLightPal, 3}, + {&gPokenavOptions_Pal[0x00], PALTAG_OPTIONS_DEFAULT}, + {&gPokenavOptions_Pal[0x10], PALTAG_OPTIONS_BLUE}, + {&gPokenavOptions_Pal[0x20], PALTAG_OPTIONS_PINK}, + {&gPokenavOptions_Pal[0x30], PALTAG_OPTIONS_BEIGE}, + {&gPokenavOptions_Pal[0x40], PALTAG_OPTIONS_RED}, + {sMatchCallBlueLightPal, PALTAG_BLUE_LIGHT}, {} }; -static const u16 sOptionsLabelGfx_RegionMap[] = {0, 0}; -static const u16 sOptionsLabelGfx_Condition[] = {0x20, 1}; -static const u16 sOptionsLabelGfx_MatchCall[] = {0x40, 4}; -static const u16 sOptionsLabelGfx_Ribbons[] = {0x60, 2}; -static const u16 sOptionsLabelGfx_SwitchOff[] = {0x80, 3}; -static const u16 sOptionsLabelGfx_Party[] = {0xA0, 1}; -static const u16 sOptionsLabelGfx_Search[] = {0xC0, 1}; -static const u16 sOptionsLabelGfx_Cool[] = {0xE0, 4}; -static const u16 sOptionsLabelGfx_Beauty[] = {0x100, 1}; -static const u16 sOptionsLabelGfx_Cute[] = {0x120, 2}; -static const u16 sOptionsLabelGfx_Smart[] = {0x140, 0}; -static const u16 sOptionsLabelGfx_Tough[] = {0x160, 0}; -static const u16 sOptionsLabelGfx_Cancel[] = {0x180, 3}; +// Tile number, palette tag offset +static const u16 sOptionsLabelGfx_RegionMap[] = {0x000, PALTAG_OPTIONS_DEFAULT - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Condition[] = {0x020, PALTAG_OPTIONS_BLUE - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_MatchCall[] = {0x040, PALTAG_OPTIONS_RED - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Ribbons[] = {0x060, PALTAG_OPTIONS_PINK - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_SwitchOff[] = {0x080, PALTAG_OPTIONS_BEIGE - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Party[] = {0x0A0, PALTAG_OPTIONS_BLUE - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Search[] = {0x0C0, PALTAG_OPTIONS_BLUE - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Cool[] = {0x0E0, PALTAG_OPTIONS_RED - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Beauty[] = {0x100, PALTAG_OPTIONS_BLUE - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Cute[] = {0x120, PALTAG_OPTIONS_PINK - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Smart[] = {0x140, PALTAG_OPTIONS_DEFAULT - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Tough[] = {0x160, PALTAG_OPTIONS_DEFAULT - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Cancel[] = {0x180, PALTAG_OPTIONS_BEIGE - PALTAG_OPTIONS_START}; -struct OptionsLabelGfx +struct { u16 yStart; u16 deltaY; - const u16 *tiles[MAX_POKENAV_MENUITEMS]; -}; - -static const struct OptionsLabelGfx sPokenavMenuOptionLabelGfx[POKENAV_MENU_TYPE_COUNT] = + const u16 *gfx[MAX_POKENAV_MENUITEMS]; +} static const sPokenavMenuOptionLabelGfx[POKENAV_MENU_TYPE_COUNT] = { [POKENAV_MENU_TYPE_DEFAULT] = { .yStart = 42, .deltaY = 20, - {sOptionsLabelGfx_RegionMap, sOptionsLabelGfx_Condition, sOptionsLabelGfx_SwitchOff} + .gfx = { + sOptionsLabelGfx_RegionMap, + sOptionsLabelGfx_Condition, + sOptionsLabelGfx_SwitchOff + } }, [POKENAV_MENU_TYPE_UNLOCK_MC] = { .yStart = 42, .deltaY = 20, - {sOptionsLabelGfx_RegionMap, sOptionsLabelGfx_Condition, sOptionsLabelGfx_MatchCall, sOptionsLabelGfx_SwitchOff} + .gfx = { + sOptionsLabelGfx_RegionMap, + sOptionsLabelGfx_Condition, + sOptionsLabelGfx_MatchCall, + sOptionsLabelGfx_SwitchOff + } }, [POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS] = { .yStart = 42, .deltaY = 20, - {sOptionsLabelGfx_RegionMap, sOptionsLabelGfx_Condition, sOptionsLabelGfx_MatchCall, sOptionsLabelGfx_Ribbons, sOptionsLabelGfx_SwitchOff} + .gfx = { + sOptionsLabelGfx_RegionMap, + sOptionsLabelGfx_Condition, + sOptionsLabelGfx_MatchCall, + sOptionsLabelGfx_Ribbons, + sOptionsLabelGfx_SwitchOff + } }, [POKENAV_MENU_TYPE_CONDITION] = { .yStart = 56, .deltaY = 20, - {sOptionsLabelGfx_Party, sOptionsLabelGfx_Search, sOptionsLabelGfx_Cancel} + .gfx = { + sOptionsLabelGfx_Party, + sOptionsLabelGfx_Search, + sOptionsLabelGfx_Cancel + } }, [POKENAV_MENU_TYPE_CONDITION_SEARCH] = { .yStart = 40, .deltaY = 16, - {sOptionsLabelGfx_Cool, sOptionsLabelGfx_Beauty, sOptionsLabelGfx_Cute, sOptionsLabelGfx_Smart, sOptionsLabelGfx_Tough, sOptionsLabelGfx_Cancel} + .gfx = { + sOptionsLabelGfx_Cool, + sOptionsLabelGfx_Beauty, + sOptionsLabelGfx_Cute, + sOptionsLabelGfx_Smart, + sOptionsLabelGfx_Tough, + sOptionsLabelGfx_Cancel + } }, }; @@ -216,8 +259,8 @@ static const struct WindowTemplate sOptionDescWindowTemplate = .bg = 1, .tilemapLeft = 3, .tilemapTop = 17, - .width = 0x18, - .height = 0x2, + .width = 24, + .height = 2, .paletteNum = 1, .baseBlock = 8 }; @@ -257,33 +300,33 @@ static const struct OamData sOamData_MenuOption = .paletteNum = 0, }; -static const union AffineAnimCmd gUnknown_0862031C[] = +static const union AffineAnimCmd sAffineAnim_MenuOption_Normal[] = { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), AFFINEANIMCMD_END, }; -static const union AffineAnimCmd gUnknown_0862032C[] = +static const union AffineAnimCmd sAffineAnim_MenuOption_Zoom[] = { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x10, 0x10, 0, 0x12), AFFINEANIMCMD_END, }; -static const union AffineAnimCmd *const sSpriteAnims_MenuOption[] = +static const union AffineAnimCmd *const sAffineAnims_MenuOption[] = { - gUnknown_0862031C, - gUnknown_0862032C + sAffineAnim_MenuOption_Normal, + sAffineAnim_MenuOption_Zoom }; static const struct SpriteTemplate sMenuOptionSpriteTemplate = { - .tileTag = 3, - .paletteTag = 4, + .tileTag = GFXTAG_OPTIONS, + .paletteTag = PALTAG_OPTIONS_START, .oam = &sOamData_MenuOption, .anims = gDummySpriteAnimTable, .images = NULL, - .affineAnims = sSpriteAnims_MenuOption, + .affineAnims = sAffineAnims_MenuOption, .callback = SpriteCallbackDummy, }; @@ -303,8 +346,8 @@ static const struct OamData sBlueLightOamData = static const struct SpriteTemplate sMatchCallBlueLightSpriteTemplate = { - .tileTag = 1, - .paletteTag = 3, + .tileTag = GFXTAG_BLUE_LIGHT, + .paletteTag = PALTAG_BLUE_LIGHT, .oam = &sBlueLightOamData, .anims = gDummySpriteAnimTable, .images = NULL, @@ -320,7 +363,7 @@ static const struct ScanlineEffectParams sPokenavMainMenuScanlineEffectParams = 0 }; -static bool32 PlayerHasTrainerRematches(void) +static bool32 AreAnyTrainerRematchesNearby(void) { s32 i; @@ -337,81 +380,81 @@ static bool32 PlayerHasTrainerRematches(void) bool32 OpenPokenavMenuInitial(void) { - struct Pokenav2Struct * state = OpenPokenavMenu(); + struct Pokenav_MenuGfx * gfx = OpenPokenavMenu(); - if (state == NULL) + if (gfx == NULL) return FALSE; - state->pokenavAlreadyOpen = FALSE; + gfx->pokenavAlreadyOpen = FALSE; return TRUE; } bool32 OpenPokenavMenuNotInitial(void) { - struct Pokenav2Struct * state = OpenPokenavMenu(); + struct Pokenav_MenuGfx * gfx = OpenPokenavMenu(); - if (state == NULL) + if (gfx == NULL) return FALSE; - state->pokenavAlreadyOpen = TRUE; + gfx->pokenavAlreadyOpen = TRUE; return TRUE; } -static struct Pokenav2Struct * OpenPokenavMenu(void) +static struct Pokenav_MenuGfx * OpenPokenavMenu(void) { - struct Pokenav2Struct * state = AllocSubstruct(POKENAV_SUBSTRUCT_MENU_ICONS, sizeof(struct Pokenav2Struct)); + struct Pokenav_MenuGfx * gfx = AllocSubstruct(POKENAV_SUBSTRUCT_MENU_GFX, sizeof(struct Pokenav_MenuGfx)); - if (state != NULL) + if (gfx != NULL) { - state->otherIconsInMotion = FALSE; - state->loopedTaskId = CreateLoopedTask(LoopedTask_OpenMenu, 1); - state->isTaskActiveCB = GetCurrentLoopedTaskActive; + gfx->numIconsBlending = 0; + gfx->loopedTaskId = CreateLoopedTask(LoopedTask_OpenMenu, 1); + gfx->isTaskActiveCB = GetCurrentLoopedTaskActive; } - return state; + return gfx; } void CreateMenuHandlerLoopedTask(s32 ltIdx) { - struct Pokenav2Struct * state = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - state->loopedTaskId = CreateLoopedTask(sMenuHandlerLoopTaskFuncs[ltIdx], 1); - state->isTaskActiveCB = GetCurrentLoopedTaskActive; + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); + gfx->loopedTaskId = CreateLoopedTask(sMenuHandlerLoopTaskFuncs[ltIdx], 1); + gfx->isTaskActiveCB = GetCurrentLoopedTaskActive; } bool32 IsMenuHandlerLoopedTaskActive(void) { - struct Pokenav2Struct * state = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - return state->isTaskActiveCB(); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); + return gfx->isTaskActiveCB(); } void FreeMenuHandlerSubstruct2(void) { - struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); DestroyMovingDotsBgTask(); - RemoveWindow(unk->optionDescWindowId); + RemoveWindow(gfx->optionDescWindowId); FreeAndDestroyMainMenuSprites(); DestroyMenuOptionGlowTask(); - FreePokenavSubstruct(POKENAV_SUBSTRUCT_MENU_ICONS); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_MENU_GFX); } static bool32 GetCurrentLoopedTaskActive(void) { - struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); - return IsLoopedTaskActive(unk->loopedTaskId); + return IsLoopedTaskActive(gfx->loopedTaskId); } static u32 LoopedTask_OpenMenu(s32 state) { - struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); switch (state) { case 0: InitBgTemplates(sPokenavMainMenuBgTemplates, ARRAY_COUNT(sPokenavMainMenuBgTemplates)); DecompressAndCopyTileDataToVram(1, gPokenavMessageBox_Gfx, 0, 0, 0); - SetBgTilemapBuffer(1, unk->bg1TilemapBuffer); + SetBgTilemapBuffer(1, gfx->bg1TilemapBuffer); CopyToBgTilemapBuffer(1, gPokenavMessageBox_Tilemap, 0, 0); CopyBgTilemapBufferToVram(1); CopyPaletteIntoBufferUnfaded(gPokenavMessageBox_Pal, 0x10, 0x20); @@ -451,7 +494,7 @@ static u32 LoopedTask_OpenMenu(s32 state) PrintCurrentOptionDescription(); CreateMenuOptionSprites(); CreateMatchCallBlueLightSprite(); - sub_81CA0C8(); + DrawCurrentMenuOptionLabels(); return LT_INC_AND_PAUSE; case 6: if (IsDma3ManagerBusyWithBgCopy_()) @@ -461,7 +504,7 @@ static u32 LoopedTask_OpenMenu(s32 state) ShowBg(1); ShowBg(2); ShowBg(3); - if (unk->pokenavAlreadyOpen) + if (gfx->pokenavAlreadyOpen) PokenavFadeScreen(1); else { @@ -496,7 +539,7 @@ static u32 LoopedTask_OpenMenu(s32 state) ShowLeftHeaderGfx(0, FALSE, FALSE); break; } - SetupCurrentMenuOptionsGfx(); + StartOptionAnimations_Enter(); SetupPokenavMenuScanlineEffects(); return LT_INC_AND_CONTINUE; case 9: @@ -515,7 +558,7 @@ static u32 LoopedTask_MoveMenuCursor(s32 state) { case 0: SetMenuOptionGlow(); - SetMenuOptionGfxParams_CursorMoved(); + StartOptionAnimations_CursorMoved(); PrintCurrentOptionDescription(); PlaySE(SE_SELECT); return LT_INC_AND_PAUSE; @@ -535,7 +578,7 @@ static u32 LoopedTask_OpenConditionMenu(s32 state) { case 0: ResetBldCnt(); - SetupPokenavMenuOptions(); + StartOptionAnimations_Exit(); HideMainOrSubMenuLeftHeader(POKENAV_GFX_MAIN_MENU, 0); PlaySE(SE_SELECT); return LT_INC_AND_PAUSE; @@ -544,11 +587,11 @@ static u32 LoopedTask_OpenConditionMenu(s32 state) return LT_PAUSE; if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; - sub_81CA0C8(); + DrawCurrentMenuOptionLabels(); LoadLeftHeaderGfxForIndex(1); return LT_INC_AND_PAUSE; case 2: - SetupCurrentMenuOptionsGfx(); + StartOptionAnimations_Enter(); ShowLeftHeaderGfx(1, FALSE, FALSE); CreateBgDotPurplePalTask(); PrintCurrentOptionDescription(); @@ -574,7 +617,7 @@ static u32 LoopedTask_ReturnToMainMenu(s32 state) { case 0: ResetBldCnt(); - SetupPokenavMenuOptions(); + StartOptionAnimations_Exit(); HideMainOrSubMenuLeftHeader(POKENAV_GFX_CONDITION_MENU, 0); return LT_INC_AND_PAUSE; case 1: @@ -582,11 +625,11 @@ static u32 LoopedTask_ReturnToMainMenu(s32 state) return LT_PAUSE; if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; - sub_81CA0C8(); + DrawCurrentMenuOptionLabels(); LoadLeftHeaderGfxForIndex(0); return LT_INC_AND_PAUSE; case 2: - SetupCurrentMenuOptionsGfx(); + StartOptionAnimations_Enter(); ShowLeftHeaderGfx(0, FALSE, FALSE); CreateBgDotLightBluePalTask(); PrintCurrentOptionDescription(); @@ -612,17 +655,17 @@ static u32 LoopedTask_OpenConditionSearchMenu(s32 state) { case 0: ResetBldCnt(); - SetupPokenavMenuOptions(); + StartOptionAnimations_Exit(); PlaySE(SE_SELECT); return LT_INC_AND_PAUSE; case 1: if (AreMenuOptionSpritesMoving()) return LT_PAUSE; LoadLeftHeaderGfxForIndex(7); - sub_81CA0C8(); + DrawCurrentMenuOptionLabels(); return LT_INC_AND_PAUSE; case 2: - SetupCurrentMenuOptionsGfx(); + StartOptionAnimations_Enter(); ShowLeftHeaderGfx(7, FALSE, FALSE); PrintCurrentOptionDescription(); return LT_INC_AND_PAUSE; @@ -645,7 +688,7 @@ static u32 LoopedTask_ReturnToConditionMenu(s32 state) { case 0: ResetBldCnt(); - SetupPokenavMenuOptions(); + StartOptionAnimations_Exit(); HideMainOrSubMenuLeftHeader(POKENAV_GFX_SEARCH_MENU, 0); return LT_INC_AND_PAUSE; case 1: @@ -653,10 +696,10 @@ static u32 LoopedTask_ReturnToConditionMenu(s32 state) return LT_PAUSE; if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; - sub_81CA0C8(); + DrawCurrentMenuOptionLabels(); return LT_INC_AND_PAUSE; case 2: - SetupCurrentMenuOptionsGfx(); + StartOptionAnimations_Enter(); PrintCurrentOptionDescription(); return LT_INC_AND_PAUSE; case 3: @@ -716,7 +759,7 @@ static u32 LoopedTask_OpenPokenavFeature(s32 state) return LT_PAUSE; SlideMenuHeaderUp(); ResetBldCnt(); - SetupPokenavMenuOptions(); + StartOptionAnimations_Exit(); switch (GetPokenavMenuType()) { case POKENAV_MENU_TYPE_CONDITION_SEARCH: @@ -757,30 +800,29 @@ static void LoadPokenavOptionPalettes(void) static void FreeAndDestroyMainMenuSprites(void) { - FreeSpriteTilesByTag(3); - FreeSpriteTilesByTag(1); - FreeSpritePaletteByTag(4); - FreeSpritePaletteByTag(5); - FreeSpritePaletteByTag(6); - FreeSpritePaletteByTag(7); - FreeSpritePaletteByTag(8); - FreeSpritePaletteByTag(3); + FreeSpriteTilesByTag(GFXTAG_OPTIONS); + FreeSpriteTilesByTag(GFXTAG_BLUE_LIGHT); + FreeSpritePaletteByTag(PALTAG_OPTIONS_DEFAULT); + FreeSpritePaletteByTag(PALTAG_OPTIONS_BLUE); + FreeSpritePaletteByTag(PALTAG_OPTIONS_PINK); + FreeSpritePaletteByTag(PALTAG_OPTIONS_BEIGE); + FreeSpritePaletteByTag(PALTAG_OPTIONS_RED); + FreeSpritePaletteByTag(PALTAG_BLUE_LIGHT); DestroyMenuOptionSprites(); - DestroyRematchBlueLightSpriteId(); + DestroyRematchBlueLightSprite(); } static void CreateMenuOptionSprites(void) { s32 i, j; - struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - // Each menu option is 4 subsprites - for (j = 0; j < 4; j++) + for (j = 0; j < NUM_OPTION_SUBSPRITES; j++) { u8 spriteId = CreateSprite(&sMenuOptionSpriteTemplate, 0x8c, 20 * i + 40, 3); - unk->iconSprites[i][j] = &gSprites[spriteId]; + gfx->iconSprites[i][j] = &gSprites[spriteId]; gSprites[spriteId].x2 = 32 * j; } } @@ -789,97 +831,102 @@ static void CreateMenuOptionSprites(void) static void DestroyMenuOptionSprites(void) { s32 i, j; - struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - for (j = 0; j < 4; j++) + for (j = 0; j < NUM_OPTION_SUBSPRITES; j++) { - FreeSpriteOamMatrix(unk->iconSprites[i][j]); - DestroySprite(unk->iconSprites[i][j]); + FreeSpriteOamMatrix(gfx->iconSprites[i][j]); + DestroySprite(gfx->iconSprites[i][j]); } } } -static void sub_81CA0C8(void) +static void DrawCurrentMenuOptionLabels(void) { s32 menuType = GetPokenavMenuType(); - DrawOptionLabelGfx(sPokenavMenuOptionLabelGfx[menuType].tiles, sPokenavMenuOptionLabelGfx[menuType].yStart, sPokenavMenuOptionLabelGfx[menuType].deltaY); + DrawOptionLabelGfx(sPokenavMenuOptionLabelGfx[menuType].gfx, sPokenavMenuOptionLabelGfx[menuType].yStart, sPokenavMenuOptionLabelGfx[menuType].deltaY); } -static void DrawOptionLabelGfx(const u16 *const *tiles, s32 yPos, s32 deltaY) +static void DrawOptionLabelGfx(const u16 *const *optionGfx, s32 yPos, s32 deltaY) { s32 i, j; - struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - s32 sp04 = GetSpriteTileStartByTag(3); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); + s32 baseTile = GetSpriteTileStartByTag(GFXTAG_OPTIONS); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (*tiles != NULL) + if (*optionGfx != NULL) { - for (j = 0; j < 4; j++) + for (j = 0; j < NUM_OPTION_SUBSPRITES; j++) { - unk->iconSprites[i][j]->oam.tileNum = (*tiles)[0] + sp04 + 8 * j; - unk->iconSprites[i][j]->oam.paletteNum = IndexOfSpritePaletteTag((*tiles)[1] + 4); - unk->iconSprites[i][j]->invisible = TRUE; - unk->iconSprites[i][j]->y = yPos; - unk->iconSprites[i][j]->x = 0x8c; - unk->iconSprites[i][j]->x2 = 32 * j; + gfx->iconSprites[i][j]->oam.tileNum = (*optionGfx)[0] + baseTile + 8 * j; + gfx->iconSprites[i][j]->oam.paletteNum = IndexOfSpritePaletteTag((*optionGfx)[1] + PALTAG_OPTIONS_START); + gfx->iconSprites[i][j]->invisible = TRUE; + gfx->iconSprites[i][j]->y = yPos; + gfx->iconSprites[i][j]->x = OPTION_DEFAULT_X; + gfx->iconSprites[i][j]->x2 = 32 * j; } - unk->iconVisible[i] = TRUE; + gfx->iconVisible[i] = TRUE; } else { - for (j = 0; j < 4; j++) - { - unk->iconSprites[i][j]->invisible = TRUE; - } - unk->iconVisible[i] = FALSE; + for (j = 0; j < NUM_OPTION_SUBSPRITES; j++) + gfx->iconSprites[i][j]->invisible = TRUE; + + gfx->iconVisible[i] = FALSE; } - tiles++; + optionGfx++; yPos += deltaY; } } -static void SetupCurrentMenuOptionsGfx(void) +static void StartOptionAnimations_Enter(void) { s32 i; - struct Pokenav2Struct *icons = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - s32 r8 = GetPokenavCursorPos(); - s32 r7 = 0; - s32 r2; + struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); + s32 cursorPos = GetPokenavCursorPos(); + s32 iconCount = 0; + s32 x; for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (icons->iconVisible[i]) + if (gfx->iconVisible[i]) { - if (r7++ == r8) + if (iconCount++ == cursorPos) { - r2 = 0x82; - icons->cursorPos = i; + x = OPTION_SELECTED_X; + gfx->cursorPos = i; } else - r2 = 0x8c; - SetMenuOptionGfxParamsInactive(icons->iconSprites[i], 0x100, r2, 0xC); - SetMenuOptionGfxInvisibility(icons->iconSprites[i], FALSE); + { + // Not selected, set default position + x = OPTION_DEFAULT_X; + } + + // Slide new options in + StartOptionSlide(gfx->iconSprites[i], OPTION_EXIT_X, x, 12); + SetOptionInvisibility(gfx->iconSprites[i], FALSE); } else { - SetMenuOptionGfxInvisibility(icons->iconSprites[i], TRUE); + SetOptionInvisibility(gfx->iconSprites[i], TRUE); } } } -static void SetMenuOptionGfxParams_CursorMoved(void) +static void StartOptionAnimations_CursorMoved(void) { s32 i; - struct Pokenav2Struct *icons = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); s32 prevPos = GetPokenavCursorPos(); s32 newPos; + // Get the index of the next visible option for (i = 0, newPos = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (icons->iconVisible[i]) + if (gfx->iconVisible[i]) { if (newPos == prevPos) { @@ -890,24 +937,28 @@ static void SetMenuOptionGfxParams_CursorMoved(void) } } - SetMenuOptionGfxParamsInactive(icons->iconSprites[icons->cursorPos], 0x82, 0x8c, 0x4); - SetMenuOptionGfxParamsInactive(icons->iconSprites[newPos], 0x8c, 0x82, 0x4); - icons->cursorPos = newPos; + // The selected option slides out a bit and the previously + // selected option slides back to its original position. + StartOptionSlide(gfx->iconSprites[gfx->cursorPos], OPTION_SELECTED_X, OPTION_DEFAULT_X, 4); + StartOptionSlide(gfx->iconSprites[newPos], OPTION_DEFAULT_X, OPTION_SELECTED_X, 4); + gfx->cursorPos = newPos; } -static void SetupPokenavMenuOptions(void) +static void StartOptionAnimations_Exit(void) { s32 i; - struct Pokenav2Struct *optionIcons = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (optionIcons->iconVisible[i]) + if (gfx->iconVisible[i]) { - if (optionIcons->cursorPos != i) - SetMenuOptionGfxParamsInactive(optionIcons->iconSprites[i], 0x8C, 0x100, 0x8); + // Unselected options slide out, + // selected option zooms in + if (gfx->cursorPos != i) + StartOptionSlide(gfx->iconSprites[i], OPTION_DEFAULT_X, OPTION_EXIT_X, 8); else - SetMenuOptionGfxParamsActive(optionIcons->iconSprites[i]); + StartOptionZoom(gfx->iconSprites[i]); } } } @@ -915,120 +966,145 @@ static void SetupPokenavMenuOptions(void) static bool32 AreMenuOptionSpritesMoving(void) { s32 i; - struct Pokenav2Struct *icons = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (icons->iconSprites[i][0]->callback != SpriteCallbackDummy) + if (gfx->iconSprites[i][0]->callback != SpriteCallbackDummy) return TRUE; } - if (icons->otherIconsInMotion) + if (gfx->numIconsBlending != 0) return TRUE; return FALSE; } -static void SetMenuOptionGfxParamsInactive(struct Sprite ** sprites, s32 x, s32 a2, s32 a3) +#define sSlideTime data[0] +#define sSlideAccel data[1] +#define sSlideSpeed data[2] +#define sSlideEndX data[7] + +static void StartOptionSlide(struct Sprite ** sprites, s32 startX, s32 endX, s32 time) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_OPTION_SUBSPRITES; i++) { - (*sprites)->x = x; - (*sprites)->data[0] = a3; - (*sprites)->data[1] = 16 * (a2 - x) / a3; - (*sprites)->data[2] = 16 * x; - (*sprites)->data[7] = a2; - (*sprites)->callback = sub_81CA474; + (*sprites)->x = startX; + (*sprites)->sSlideTime = time; + (*sprites)->sSlideAccel = 16 * (endX - startX) / time; + (*sprites)->sSlideSpeed = 16 * startX; + (*sprites)->sSlideEndX = endX; + (*sprites)->callback = SpriteCB_OptionSlide; sprites++; } } -static void SetMenuOptionGfxParamsActive(struct Sprite ** sprites) +#define sZoomDelay data[0] +#define sZoomSetAffine data[1] +#define sZoomSpeed data[2] +#define sZoomSubspriteId data[7] + +#define tBlendDelay data[0] +#define tBlendState data[1] +#define tBlendTarget1 data[2] +#define tBlendTarget2 data[3] +#define tBlendCounter data[4] + +// When an option is selected it zooms in and blends away as part +// of the transition to the next screen. +static void StartOptionZoom(struct Sprite ** sprites) { s32 i; - struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); u8 taskId; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_OPTION_SUBSPRITES; i++) { (*sprites)->oam.objMode = ST_OAM_OBJ_BLEND; (*sprites)->oam.affineMode = ST_OAM_AFFINE_DOUBLE; - (*sprites)->callback = sub_81CA4AC; - (*sprites)->data[0] = 8; - (*sprites)->data[1] = 0; - (*sprites)->data[7] = i; + (*sprites)->callback = SpriteCB_OptionZoom; + (*sprites)->sZoomDelay = 8; + (*sprites)->sZoomSetAffine = FALSE; + (*sprites)->sZoomSubspriteId = i; InitSpriteAffineAnim(sprites[0]); StartSpriteAffineAnim(sprites[0], 0); sprites++; } - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0x10, 0x00)); - taskId = CreateTask(sub_81CA580, 3); - gTasks[taskId].data[0] = 8; - unk->otherIconsInMotion++; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0)); + taskId = CreateTask(Task_OptionBlend, 3); + gTasks[taskId].tBlendDelay = 8; + gfx->numIconsBlending++; } -static void SetMenuOptionGfxInvisibility(struct Sprite ** sprites, bool32 invisible) +static void SetOptionInvisibility(struct Sprite ** sprites, bool32 invisible) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_OPTION_SUBSPRITES; i++) { (*sprites)->invisible = invisible; sprites++; } } -static void sub_81CA474(struct Sprite * sprite) +static void SpriteCB_OptionSlide(struct Sprite * sprite) { - sprite->data[0]--; - if (sprite->data[0] != -1) + sprite->sSlideTime--; + if (sprite->sSlideTime != -1) { - sprite->data[2] += sprite->data[1]; - sprite->x = sprite->data[2] >> 4; + sprite->sSlideSpeed += sprite->sSlideAccel; + sprite->x = sprite->sSlideSpeed >> 4; } else { - sprite->x = sprite->data[7]; + sprite->x = sprite->sSlideEndX; sprite->callback = SpriteCallbackDummy; } } -static void sub_81CA4AC(struct Sprite * sprite) +#undef sSlideTime +#undef sSlideAccel +#undef sSlideSpeed +#undef sSlideEndX + +static void SpriteCB_OptionZoom(struct Sprite * sprite) { - s32 r0; - s32 r1; - if (sprite->data[0] == 0) + s32 temp; + s32 x; + if (sprite->sZoomDelay == 0) { - if (sprite->data[1] == 0) + if (!sprite->sZoomSetAffine) { StartSpriteAffineAnim(sprite, 1); - sprite->data[1]++; - sprite->data[2] = 0x100; + sprite->sZoomSetAffine++; + sprite->sZoomSpeed = 0x100; sprite->x += sprite->x2; sprite->x2 = 0; } else { - sprite->data[2] += 16; - r0 = sprite->data[2]; - r1 = r0 >> 3; - r1 = (r1 - 32) / 2; - switch (sprite->data[7]) + sprite->sZoomSpeed += 16; + temp = sprite->sZoomSpeed; + x = temp >> 3; + x = (x - 32) / 2; + + // Each subsprite needs to zoom to a different degree/direction + switch (sprite->sZoomSubspriteId) { case 0: - sprite->x2 = -r1 * 3; + sprite->x2 = -x * 3; break; case 1: - sprite->x2 = -r1; + sprite->x2 = -x; break; case 2: - sprite->x2 = r1; + sprite->x2 = x; break; case 3: - sprite->x2 = r1 * 3; + sprite->x2 = x * 3; break; } if (sprite->affineAnimEnded) @@ -1044,68 +1120,82 @@ static void sub_81CA4AC(struct Sprite * sprite) } else { - sprite->data[0]--; + sprite->sZoomDelay--; } } -static void sub_81CA580(u8 taskId) +#undef sZoomDelay +#undef sZoomSetAffine +#undef sZoomSpeed +#undef sZoomSubspriteId + +static void Task_OptionBlend(u8 taskId) { s16 * data = gTasks[taskId].data; - if (data[0] == 0) + if (tBlendDelay == 0) { - switch (data[1]) + switch (tBlendState) { case 0: - data[2] = 16; - data[3] = 0; + tBlendTarget1 = 16; + tBlendTarget2 = 0; SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_NONE | BLDCNT_TGT2_ALL); - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0x10, 0x00)); - data[1]++; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0)); + tBlendState++; break; case 1: - if (data[4] & 1) + if (tBlendCounter & 1) { - data[2] -= 3; - if (data[2] < 0) - data[2] = 0; + tBlendTarget1 -= 3; + if (tBlendTarget1 < 0) + tBlendTarget1 = 0; } else { - data[3] += 3; - if (data[3] > 16) - data[3] = 16; + tBlendTarget2 += 3; + if (tBlendTarget2 > 16) + tBlendTarget2 = 16; } - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(data[2], data[3])); - data[4]++; - if (data[4] == 12) + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(tBlendTarget1, tBlendTarget2)); + tBlendCounter++; + if (tBlendCounter == 12) { - ((struct Pokenav2Struct *)GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS))->otherIconsInMotion--; - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0x00, 0x10)); + ((struct Pokenav_MenuGfx *)GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX))->numIconsBlending--; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); DestroyTask(taskId); } break; } } else - data[0]--; + { + tBlendDelay--; + } } +#undef tBlendDelay +#undef tBlendState +#undef tBlendTarget1 +#undef tBlendTarget2 +#undef tBlendCounter + +// Blue light that blinks if there are available rematches nearby static void CreateMatchCallBlueLightSprite(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); u8 spriteId = CreateSprite(&sMatchCallBlueLightSpriteTemplate, 0x10, 0x60, 4); - ptr->blueLightSpriteId = &gSprites[spriteId]; - if (PlayerHasTrainerRematches()) - ptr->blueLightSpriteId->callback = SpriteCB_BlinkingBlueLight; + gfx->blueLightSprite = &gSprites[spriteId]; + if (AreAnyTrainerRematchesNearby()) + gfx->blueLightSprite->callback = SpriteCB_BlinkingBlueLight; else - ptr->blueLightSpriteId->invisible = TRUE; + gfx->blueLightSprite->invisible = TRUE; } -static void DestroyRematchBlueLightSpriteId(void) +static void DestroyRematchBlueLightSprite(void) { - struct Pokenav2Struct *ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - DestroySprite(ptr->blueLightSpriteId); + struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); + DestroySprite(gfx->blueLightSprite); } static void SpriteCB_BlinkingBlueLight(struct Sprite * sprite) @@ -1120,33 +1210,33 @@ static void SpriteCB_BlinkingBlueLight(struct Sprite * sprite) static void AddOptionDescriptionWindow(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); - ptr->optionDescWindowId = AddWindow(&sOptionDescWindowTemplate); - PutWindowTilemap(ptr->optionDescWindowId); - FillWindowPixelBuffer(ptr->optionDescWindowId, PIXEL_FILL(6)); - CopyWindowToVram(ptr->optionDescWindowId, COPYWIN_FULL); + gfx->optionDescWindowId = AddWindow(&sOptionDescWindowTemplate); + PutWindowTilemap(gfx->optionDescWindowId); + FillWindowPixelBuffer(gfx->optionDescWindowId, PIXEL_FILL(6)); + CopyWindowToVram(gfx->optionDescWindowId, COPYWIN_FULL); } static void PrintCurrentOptionDescription(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); int menuItem = GetCurrentMenuItemId(); - const u8 * s = sPageDescriptions[menuItem]; - u32 width = GetStringWidth(FONT_NORMAL, s, -1); - FillWindowPixelBuffer(ptr->optionDescWindowId, PIXEL_FILL(6)); - AddTextPrinterParameterized3(ptr->optionDescWindowId, FONT_NORMAL, (192 - width) / 2, 1, sOptionDescTextColors, 0, s); + const u8 * desc = sPageDescriptions[menuItem]; + u32 width = GetStringWidth(FONT_NORMAL, desc, -1); + FillWindowPixelBuffer(gfx->optionDescWindowId, PIXEL_FILL(6)); + AddTextPrinterParameterized3(gfx->optionDescWindowId, FONT_NORMAL, (192 - width) / 2, 1, sOptionDescTextColors, 0, desc); } // Printed when Ribbons is selected if no PC/party mons have ribbons // Can occur by obtaining a mon with a ribbon and then releasing all ribbon winners static void PrintNoRibbonWinners(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); const u8 * s = gText_NoRibbonWinners; u32 width = GetStringWidth(FONT_NORMAL, s, -1); - FillWindowPixelBuffer(ptr->optionDescWindowId, PIXEL_FILL(6)); - AddTextPrinterParameterized3(ptr->optionDescWindowId, FONT_NORMAL, (192 - width) / 2, 1, sOptionDescTextColors2, 0, s); + FillWindowPixelBuffer(gfx->optionDescWindowId, PIXEL_FILL(6)); + AddTextPrinterParameterized3(gfx->optionDescWindowId, FONT_NORMAL, (192 - width) / 2, 1, sOptionDescTextColors2, 0, s); } static bool32 IsDma3ManagerBusyWithBgCopy_(void) @@ -1156,14 +1246,14 @@ static bool32 IsDma3ManagerBusyWithBgCopy_(void) static void CreateMovingBgDotsTask(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - ptr->bg3ScrollTaskId = CreateTask(Task_MoveBgDots, 2); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); + gfx->bg3ScrollTaskId = CreateTask(Task_MoveBgDots, 2); } static void DestroyMovingDotsBgTask(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - DestroyTask(ptr->bg3ScrollTaskId); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); + DestroyTask(gfx->bg3ScrollTaskId); } static void Task_MoveBgDots(u8 taskId) @@ -1269,8 +1359,8 @@ static void SetMenuOptionGlow(void) int menuType = GetPokenavMenuType(); int cursorPos = GetPokenavCursorPos(); int r4 = sPokenavMenuOptionLabelGfx[menuType].deltaY * cursorPos + sPokenavMenuOptionLabelGfx[menuType].yStart - 8; - CpuFill16(0, gScanlineEffectRegBuffers[0], 0x140); - CpuFill16(0, gScanlineEffectRegBuffers[1], 0x140); + CpuFill16(0, gScanlineEffectRegBuffers[0], DISPLAY_HEIGHT * 2); + CpuFill16(0, gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); CpuFill16(RGB(16, 23, 28), &gScanlineEffectRegBuffers[0][r4], 0x20); CpuFill16(RGB(16, 23, 28), &gScanlineEffectRegBuffers[1][r4], 0x20); } diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index 89bd2f7c7..4ea3b3b19 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -74,7 +74,7 @@ static u32 LoopedTask_ExitRegionMap(s32); extern const u16 gRegionMapCityZoomTiles_Pal[]; extern const u32 gRegionMapCityZoomText_Gfx[]; -static const u16 sMapSecInfoWindow_Pal[] = INCBIN_U16("graphics/pokenav/region_map_info_window.gbapal"); +static const u16 sMapSecInfoWindow_Pal[] = INCBIN_U16("graphics/pokenav/region_map/info_window.gbapal"); static const u32 sRegionMapCityZoomTiles_Gfx[] = INCBIN_U32("graphics/pokenav/zoom_tiles.4bpp.lz"); #include "data/region_map/city_map_tilemaps.h" @@ -346,7 +346,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState) return LT_PAUSE; UpdateMapSecInfoWindow(state); - sub_81C7B40(); + FadeToBlackExceptPrimary(); return LT_INC_AND_PAUSE; case 5: if (IsDma3ManagerBusyWithBgCopy_(state)) diff --git a/src/region_map.c b/src/region_map.c index 021ef7c71..759a26e84 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -116,19 +116,18 @@ static void CB_FadeInFlyMap(void); static void CB_HandleFlyMapInput(void); static void CB_ExitFlyMap(void); -// .rodata - -static const u16 sRegionMapCursorPal[] = INCBIN_U16("graphics/pokenav/cursor.gbapal"); -static const u32 sRegionMapCursorSmallGfxLZ[] = INCBIN_U32("graphics/pokenav/cursor_small.4bpp.lz"); -static const u32 sRegionMapCursorLargeGfxLZ[] = INCBIN_U32("graphics/pokenav/cursor_large.4bpp.lz"); +// NOTE: Some of the below graphics are not in graphics/pokenav/region_map +// because porymap expects them to be in their current location. +static const u16 sRegionMapCursorPal[] = INCBIN_U16("graphics/pokenav/region_map/cursor.gbapal"); +static const u32 sRegionMapCursorSmallGfxLZ[] = INCBIN_U32("graphics/pokenav/region_map/cursor_small.4bpp.lz"); +static const u32 sRegionMapCursorLargeGfxLZ[] = INCBIN_U32("graphics/pokenav/region_map/cursor_large.4bpp.lz"); static const u16 sRegionMapBg_Pal[] = INCBIN_U16("graphics/pokenav/region_map.gbapal"); static const u32 sRegionMapBg_GfxLZ[] = INCBIN_U32("graphics/pokenav/region_map.8bpp.lz"); static const u32 sRegionMapBg_TilemapLZ[] = INCBIN_U32("graphics/pokenav/region_map_map.bin.lz"); -static const u16 sRegionMapPlayerIcon_BrendanPal[] = INCBIN_U16("graphics/pokenav/brendan_icon.gbapal"); -static const u8 sRegionMapPlayerIcon_BrendanGfx[] = INCBIN_U8("graphics/pokenav/brendan_icon.4bpp"); -static const u16 sRegionMapPlayerIcon_MayPal[] = INCBIN_U16("graphics/pokenav/may_icon.gbapal"); -static const u8 sRegionMapPlayerIcon_MayGfx[] = INCBIN_U8("graphics/pokenav/may_icon.4bpp"); - +static const u16 sRegionMapPlayerIcon_BrendanPal[] = INCBIN_U16("graphics/pokenav/region_map/brendan_icon.gbapal"); +static const u8 sRegionMapPlayerIcon_BrendanGfx[] = INCBIN_U8("graphics/pokenav/region_map/brendan_icon.4bpp"); +static const u16 sRegionMapPlayerIcon_MayPal[] = INCBIN_U16("graphics/pokenav/region_map/may_icon.gbapal"); +static const u8 sRegionMapPlayerIcon_MayGfx[] = INCBIN_U8("graphics/pokenav/region_map/may_icon.4bpp"); static const u8 sRegionMap_MapSectionLayout[] = INCBIN_U8("graphics/pokenav/region_map_section_layout.bin"); #include "data/region_map/region_map_entries.h" @@ -283,15 +282,11 @@ static const u8 sMapSecIdsOffMap[] = MAPSEC_NAVEL_ROCK }; -static const u16 sRegionMapFramePal[] = INCBIN_U16("graphics/pokenav/map_frame.gbapal"); - -static const u32 sRegionMapFrameGfxLZ[] = INCBIN_U32("graphics/pokenav/map_frame.4bpp.lz"); - -static const u32 sRegionMapFrameTilemapLZ[] = INCBIN_U32("graphics/pokenav/map_frame.bin.lz"); - -static const u16 sFlyTargetIcons_Pal[] = INCBIN_U16("graphics/pokenav/fly_target_icons.gbapal"); - -static const u32 sFlyTargetIcons_Gfx[] = INCBIN_U32("graphics/pokenav/fly_target_icons.4bpp.lz"); +static const u16 sRegionMapFramePal[] = INCBIN_U16("graphics/pokenav/region_map/frame.gbapal"); +static const u32 sRegionMapFrameGfxLZ[] = INCBIN_U32("graphics/pokenav/region_map/frame.4bpp.lz"); +static const u32 sRegionMapFrameTilemapLZ[] = INCBIN_U32("graphics/pokenav/region_map/frame.bin.lz"); +static const u16 sFlyTargetIcons_Pal[] = INCBIN_U16("graphics/pokenav/region_map/fly_target_icons.gbapal"); +static const u32 sFlyTargetIcons_Gfx[] = INCBIN_U32("graphics/pokenav/region_map/fly_target_icons.4bpp.lz"); static const u8 sMapHealLocations[][3] = { From ffe2970e30f64f46a7539ac69d61ab4ea353a92c Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 12 Nov 2021 17:13:50 -0500 Subject: [PATCH 09/19] Rename pokenav menu handler files --- include/pokenav.h | 4 ++-- ld_script.txt | 8 ++++---- src/{pokenav_menu_handler_1.c => pokenav_menu_handler.c} | 0 ...okenav_menu_handler_2.c => pokenav_menu_handler_gfx.c} | 0 4 files changed, 6 insertions(+), 6 deletions(-) rename src/{pokenav_menu_handler_1.c => pokenav_menu_handler.c} (100%) rename src/{pokenav_menu_handler_2.c => pokenav_menu_handler_gfx.c} (100%) diff --git a/include/pokenav.h b/include/pokenav.h index 6dc88cab7..59f670089 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -370,7 +370,7 @@ bool32 WaitForPokenavShutdownFade(void); void SetActiveMenuLoopTasks(void *func1, void *func2); void ShutdownPokenav(void); -// pokenav_menu_handler_1.c +// pokenav_menu_handler.c bool32 PokenavCallback_Init_MainMenuCursorOnMap(void); bool32 PokenavCallback_Init_MainMenuCursorOnMatchCall(void); bool32 PokenavCallback_Init_MainMenuCursorOnRibbons(void); @@ -383,7 +383,7 @@ int GetPokenavCursorPos(void); int GetCurrentMenuItemId(void); u16 GetHelpBarTextId(void); -// pokenav_menu_handler_2.c +// pokenav_menu_handler_gfx.c bool32 OpenPokenavMenuInitial(void); bool32 OpenPokenavMenuNotInitial(void); void CreateMenuHandlerLoopedTask(s32 ltIdx); diff --git a/ld_script.txt b/ld_script.txt index c4283265d..257fb3c6e 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -311,8 +311,8 @@ SECTIONS { src/pokenav.o(.text); src/pokenav_main_menu.o(.text); src/pokenav_match_call_ui.o(.text); - src/pokenav_menu_handler_1.o(.text); - src/pokenav_menu_handler_2.o(.text); + src/pokenav_menu_handler.o(.text); + src/pokenav_menu_handler_gfx.o(.text); src/pokenav_match_call_1.o(.text); src/pokenav_match_call_2.o(.text); src/pokenav_region_map.o(.text); @@ -666,8 +666,8 @@ SECTIONS { src/pokenav.o(.rodata); src/pokenav_main_menu.o(.rodata); src/pokenav_match_call_ui.o(.rodata); - src/pokenav_menu_handler_1.o(.rodata); - src/pokenav_menu_handler_2.o(.rodata); + src/pokenav_menu_handler.o(.rodata); + src/pokenav_menu_handler_gfx.o(.rodata); src/pokenav_match_call_1.o(.rodata); src/pokenav_match_call_2.o(.rodata); src/pokenav_region_map.o(.rodata); diff --git a/src/pokenav_menu_handler_1.c b/src/pokenav_menu_handler.c similarity index 100% rename from src/pokenav_menu_handler_1.c rename to src/pokenav_menu_handler.c diff --git a/src/pokenav_menu_handler_2.c b/src/pokenav_menu_handler_gfx.c similarity index 100% rename from src/pokenav_menu_handler_2.c rename to src/pokenav_menu_handler_gfx.c From da5752fd0d94a1b7fdef354b7fe4bfb055b4a545 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 12 Nov 2021 17:28:06 -0500 Subject: [PATCH 10/19] Start match call menu doc --- .../{arrow.png => options_cursor.png} | Bin include/pokenav.h | 14 +- src/pokenav_conditions_gfx.c | 4 +- src/pokenav_conditions_search_results.c | 6 +- src/pokenav_main_menu.c | 22 +- src/pokenav_match_call_1.c | 14 +- src/pokenav_match_call_2.c | 791 +++++++++--------- src/pokenav_match_call_ui.c | 4 +- src/pokenav_menu_handler_gfx.c | 6 +- src/pokenav_region_map.c | 4 +- src/pokenav_ribbons_list.c | 6 +- src/pokenav_ribbons_summary.c | 4 +- 12 files changed, 452 insertions(+), 423 deletions(-) rename graphics/pokenav/match_call/{arrow.png => options_cursor.png} (100%) diff --git a/graphics/pokenav/match_call/arrow.png b/graphics/pokenav/match_call/options_cursor.png similarity index 100% rename from graphics/pokenav/match_call/arrow.png rename to graphics/pokenav/match_call/options_cursor.png diff --git a/include/pokenav.h b/include/pokenav.h index 59f670089..ba9f1cbe9 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -276,7 +276,7 @@ enum POKENAV_MC_FUNC_CANCEL, POKENAV_MC_FUNC_CALL_MSG, POKENAV_MC_FUNC_NEARBY_MSG, - POKENAV_MC_FUNC_10, + POKENAV_MC_FUNC_EXIT_CALL, POKENAV_MC_FUNC_SHOW_CHECK_PAGE, POKENAV_MC_FUNC_CHECK_PAGE_UP, POKENAV_MC_FUNC_CHECK_PAGE_DOWN, @@ -293,6 +293,14 @@ enum POKENAV_MAP_FUNC_EXIT, }; +// Modes for PokenavFadeScreen +enum { + POKENAV_FADE_TO_BLACK, + POKENAV_FADE_FROM_BLACK, + POKENAV_FADE_TO_BLACK_ALL, + POKENAV_FADE_FROM_BLACK_ALL, +}; + // pokenav.c void SetSelectedConditionSearch(u32); u32 GetSelectedConditionSearch(void); @@ -359,8 +367,8 @@ bool32 MainMenuLoopedTaskIsBusy(void); void SetLeftHeaderSpritesInvisibility(void); void PokenavCopyPalette(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u16 *palette); void FadeToBlackExceptPrimary(void); -struct Sprite *PauseSpinningPokenavSprite(void); -void ResumeSpinningPokenavSprite(void); +struct Sprite *GetSpinningPokenavSprite(void); +void HideSpinningPokenavSprite(void); void UpdateRegionMapRightHeaderTiles(u32 arg0); void HideMainOrSubMenuLeftHeader(u32 id, bool32 onRightSide); void SlideMenuHeaderUp(void); diff --git a/src/pokenav_conditions_gfx.c b/src/pokenav_conditions_gfx.c index a1593983d..d2fb715ab 100644 --- a/src/pokenav_conditions_gfx.c +++ b/src/pokenav_conditions_gfx.c @@ -295,7 +295,7 @@ static u32 LoopedTask_OpenConditionGraphMenu(s32 state) PrintHelpBarText(HELPBAR_CONDITION_MON_STATUS); return LT_INC_AND_PAUSE; case 15: - PokenavFadeScreen(1); + PokenavFadeScreen(POKENAV_FADE_FROM_BLACK); if (!IsConditionMenuSearchMode()) { LoadLeftHeaderGfxForIndex(POKENAV_GFX_PARTY_MENU); @@ -352,7 +352,7 @@ static u32 LoopedTask_ExitConditionGraphMenu(s32 state) ToggleGraphData(FALSE); return LT_INC_AND_CONTINUE; case 2: - PokenavFadeScreen(0); + PokenavFadeScreen(POKENAV_FADE_TO_BLACK); if (!IsConditionMenuSearchMode()) SlideMenuHeaderDown(); return LT_INC_AND_PAUSE; diff --git a/src/pokenav_conditions_search_results.c b/src/pokenav_conditions_search_results.c index d9bd2273f..770d0d01a 100644 --- a/src/pokenav_conditions_search_results.c +++ b/src/pokenav_conditions_search_results.c @@ -467,7 +467,7 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state) ShowLeftHeaderGfx(searchGfxId, 1, 0); ShowLeftHeaderGfx(POKENAV_GFX_CONDITION_MENU, 1, 0); } - PokenavFadeScreen(1); + PokenavFadeScreen(POKENAV_FADE_FROM_BLACK); return LT_INC_AND_PAUSE; case 5: if (IsPaletteFadeActive()) @@ -617,7 +617,7 @@ static u32 LoopedTask_ExitConditionSearchMenu(s32 state) { case 0: PlaySE(SE_SELECT); - PokenavFadeScreen(0); + PokenavFadeScreen(POKENAV_FADE_TO_BLACK); SlideMenuHeaderDown(); return LT_INC_AND_PAUSE; case 1: @@ -637,7 +637,7 @@ static u32 LoopedTask_SelectSearchResult(s32 state) { case 0: PlaySE(SE_SELECT); - PokenavFadeScreen(0); + PokenavFadeScreen(POKENAV_FADE_TO_BLACK); return LT_INC_AND_PAUSE; case 1: if (IsPaletteFadeActive()) diff --git a/src/pokenav_main_menu.c b/src/pokenav_main_menu.c index 77faecaa3..318ed520d 100644 --- a/src/pokenav_main_menu.c +++ b/src/pokenav_main_menu.c @@ -473,7 +473,6 @@ void PokenavFillPalette(u32 palIndex, u16 fillValue) void PokenavCopyPalette(const u16 *src, const u16 *dest, int size, int a3, int a4, u16 *palette) { - if (a4 == 0) { CpuCopy16(src, palette, size * 2); @@ -496,11 +495,11 @@ void PokenavCopyPalette(const u16 *src, const u16 *dest, int size, int a3, int a g1 = ((((GET_G(*dest) << 8) - (g << 8)) / a3) * a4) >> 8; b1 = ((((GET_B(*dest) << 8) - (b << 8)) / a3) * a4) >> 8; - r = (r + r1) & 0x1F; //_RGB(r + r1, g + g1, b + b1); doesn't match; I have to assign the value of ((r + r1) & 0x1F) to r - g = (g + g1) & 0x1F; //See above - b = (b + b1) & 0x1F; //See above + r = (r + r1) & 0x1F; //_RGB(r + r1, g + g1, b + b1); doesn't match + g = (g + g1) & 0x1F; + b = (b + b1) & 0x1F; - *palette = RGB2(r, g, b); //See above comment + *palette = RGB2(r, g, b); src++, dest++; palette++; @@ -514,16 +513,16 @@ void PokenavFadeScreen(s32 fadeType) switch (fadeType) { - case 0: + case POKENAV_FADE_TO_BLACK: BeginNormalPaletteFade(menu->palettes, -2, 0, 16, RGB_BLACK); break; - case 1: + case POKENAV_FADE_FROM_BLACK: BeginNormalPaletteFade(menu->palettes, -2, 16, 0, RGB_BLACK); break; - case 2: + case POKENAV_FADE_TO_BLACK_ALL: BeginNormalPaletteFade(PALETTES_ALL, -2, 0, 16, RGB_BLACK); break; - case 3: + case POKENAV_FADE_FROM_BLACK_ALL: BeginNormalPaletteFade(PALETTES_ALL, -2, 16, 0, RGB_BLACK); break; } @@ -608,7 +607,7 @@ static void SpriteCB_SpinningPokenav(struct Sprite *sprite) sprite->y2 = (GetBgY(0) / 256u) * -1; } -struct Sprite *PauseSpinningPokenavSprite(void) +struct Sprite *GetSpinningPokenavSprite(void) { struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); @@ -616,10 +615,11 @@ struct Sprite *PauseSpinningPokenavSprite(void) return menu->spinningPokenav; } -void ResumeSpinningPokenavSprite(void) +void HideSpinningPokenavSprite(void) { struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + // Move sprite so it's no longer visible menu->spinningPokenav->x = 220; menu->spinningPokenav->y = 12; menu->spinningPokenav->callback = SpriteCB_SpinningPokenav; diff --git a/src/pokenav_match_call_1.c b/src/pokenav_match_call_1.c index 5612ba6cb..63b8fcbf5 100755 --- a/src/pokenav_match_call_1.c +++ b/src/pokenav_match_call_1.c @@ -32,9 +32,9 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *); static u32 GetExitMatchCallMenuId(struct Pokenav3Struct *); static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *); static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *); -static u32 CB2_HandleCallInput(struct Pokenav3Struct *); +static u32 CB2_HandleCallExitInput(struct Pokenav3Struct *); static u32 sub_81CAD20(s32); -static bool32 sub_81CB1D0(void); +static bool32 ShouldDoNearbyMessage(void); #include "data/text/match_call_messages.h" @@ -155,8 +155,8 @@ static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state) if (GetPokenavMode() == POKENAV_MODE_FORCE_CALL_READY) SetPokenavMode(POKENAV_MODE_FORCE_CALL_EXIT); - state->callback = CB2_HandleCallInput; - if (sub_81CB1D0()) + state->callback = CB2_HandleCallExitInput; + if (ShouldDoNearbyMessage()) return POKENAV_MC_FUNC_NEARBY_MSG; return POKENAV_MC_FUNC_CALL_MSG; @@ -191,12 +191,12 @@ static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *state) return POKENAV_MC_FUNC_NONE; } -static u32 CB2_HandleCallInput(struct Pokenav3Struct *state) +static u32 CB2_HandleCallExitInput(struct Pokenav3Struct *state) { if (JOY_NEW(A_BUTTON | B_BUTTON)) { state->callback = CB2_HandleMatchCallInput; - return POKENAV_MC_FUNC_10; + return POKENAV_MC_FUNC_EXIT_CALL; } return POKENAV_MC_FUNC_NONE; @@ -486,7 +486,7 @@ bool32 unref_sub_81CB16C(void) return FALSE; } -static bool32 sub_81CB1D0(void) +static bool32 ShouldDoNearbyMessage(void) { struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); int selection = GetSelectedPokenavListIndex(); diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index 29cb0a06d..e91257d14 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -24,100 +24,105 @@ #include "constants/region_map_sections.h" #include "constants/songs.h" -struct Pokenav4Struct +#define GFXTAG_CURSOR 7 +#define GFXTAG_TRAINER_PIC 8 +#define PALTAG_CURSOR 12 +#define PALTAG_TRAINER_PIC 13 + +struct Pokenav_MatchCallGfx { bool32 (*isTaskActiveCB)(void); u32 loopTaskId; - u8 filler8[0x6]; - u8 unkE; + u8 filler8[6]; + bool8 unkE; u8 unkF; u16 locWindowId; u16 infoBoxWindowId; u16 msgBoxWindowId; - s16 unk16; + s16 pageDelta; u8 unused18; u8 unused19; - u16 unk1A; + u16 trainerPicPalOffset; struct Sprite *optionsCursorSprite; struct Sprite *trainerPicSprite; - u8 unk24[0x800]; - u8 unk824[0x800]; - u8 unk1024[0x800]; - u8 *unk1824; - u8 unk1828[0x800]; - u8 unk2028[0x20]; + u8 bgTilemapBuffer1[BG_SCREEN_SIZE]; + u8 unusedTilemapBuffer[BG_SCREEN_SIZE]; + u8 bgTilemapBuffer2[BG_SCREEN_SIZE]; + u8 *trainerPicGfxPtr; + u8 trainerPicGfx[0x800]; + u8 trainerPicPal[0x20]; }; static bool32 GetCurrentLoopedTaskActive(void); static u32 LoopedTask_OpenMatchCall(s32); static void InitMatchCallPokenavListMenuTemplate(void); static void sub_81CBC1C(void); -static void RemoveMatchCallSprites(void); -static void sub_81CC034(struct Pokenav4Struct *); -static void DrawMatchCallLeftColumnWindows(struct Pokenav4Struct *); -static void UpdateMatchCallInfoBox(struct Pokenav4Struct *); -static void PrintMatchCallLocation(struct Pokenav4Struct *, int); -static void sub_81CC214(void); -static void sub_81CBC38(int); -static void PrintMatchCallSelectionOptions(struct Pokenav4Struct *); -static bool32 sub_81CBFC4(struct Pokenav4Struct *); -static void UpdateCursorGfxPos(struct Pokenav4Struct *, int); -static bool32 IsDma3ManagerBusyWithBgCopy1(struct Pokenav4Struct *); -static void UpdateWindowsReturnToTrainerList(struct Pokenav4Struct *); -static void DrawMsgBoxForMatchCallMsg(struct Pokenav4Struct *); -static bool32 IsDma3ManagerBusyWithBgCopy2(struct Pokenav4Struct *); -static void PrintCallingDots(struct Pokenav4Struct *); -static bool32 WaitForCallingDotsText(struct Pokenav4Struct *); -static void PrintMatchCallMessage(struct Pokenav4Struct *); -static bool32 WaitForMatchCallMessageText(struct Pokenav4Struct *); -static void DrawMsgBoxForCloseByMsg(struct Pokenav4Struct *); -static void PrintTrainerIsCloseBy(struct Pokenav4Struct *); -static bool32 WaitForTrainerIsCloseByText(struct Pokenav4Struct *); -static void DrawSpinningPokenavForCall(struct Pokenav4Struct *); -static bool32 WaitForSpinningPokenav(struct Pokenav4Struct *); -static void UpdateWindowsToShowCheckPage(struct Pokenav4Struct *); -static void LoadCheckPageTrainerPic(struct Pokenav4Struct *); -static bool32 WaitForTrainerPic(struct Pokenav4Struct *); -static void TrainerPicSlideOffscreen(struct Pokenav4Struct *); -static void sub_81CBC64(u8 taskId); -static void TryDrawRematchPokeballIcon(u16 windowId, u32, u32); -static void PrintNumberRegisteredLabel(u16 windowId); -static void PrintNumberRegistered(u16 windowId); -static void PrintNumberOfBattlesLabel(u16 windowId); -static void PrintNumberOfBattles(u16 windowId); -static void PrintMatchCallInfoLabel(u16 windowId, const u8 *str, int top); -static void PrintMatchCallInfoNumber(u16 windowId, const u8 *str, int top); -static void sub_81CC2F0(struct Pokenav4Struct *, int); -static void CloseMatchCallSelectOptionsWindow(struct Pokenav4Struct *); +static void FreeMatchCallSprites(void); +static void LoadCallWindowAndFade(struct Pokenav_MatchCallGfx *); +static void DrawMatchCallLeftColumnWindows(struct Pokenav_MatchCallGfx *); +static void UpdateMatchCallInfoBox(struct Pokenav_MatchCallGfx *); +static void PrintMatchCallLocation(struct Pokenav_MatchCallGfx *, int); +static void AllocMatchCallSprites(void); +static void SetPokeballIconsFlashing(bool32); +static void PrintMatchCallSelectionOptions(struct Pokenav_MatchCallGfx *); +static bool32 ShowOptionsCursor(struct Pokenav_MatchCallGfx *); +static void UpdateCursorGfxPos(struct Pokenav_MatchCallGfx *, int); +static bool32 IsDma3ManagerBusyWithBgCopy1(struct Pokenav_MatchCallGfx *); +static void UpdateWindowsReturnToTrainerList(struct Pokenav_MatchCallGfx *); +static void DrawMsgBoxForMatchCallMsg(struct Pokenav_MatchCallGfx *); +static bool32 IsDma3ManagerBusyWithBgCopy2(struct Pokenav_MatchCallGfx *); +static void PrintCallingDots(struct Pokenav_MatchCallGfx *); +static bool32 WaitForCallingDotsText(struct Pokenav_MatchCallGfx *); +static void PrintMatchCallMessage(struct Pokenav_MatchCallGfx *); +static bool32 WaitForMatchCallMessageText(struct Pokenav_MatchCallGfx *); +static void DrawMsgBoxForCloseByMsg(struct Pokenav_MatchCallGfx *); +static void PrintTrainerIsCloseBy(struct Pokenav_MatchCallGfx *); +static bool32 WaitForTrainerIsCloseByText(struct Pokenav_MatchCallGfx *); +static void EraseCallMessageBox(struct Pokenav_MatchCallGfx *); +static bool32 WaitForCallMessageBoxErase(struct Pokenav_MatchCallGfx *); +static void UpdateWindowsToShowCheckPage(struct Pokenav_MatchCallGfx *); +static void LoadCheckPageTrainerPic(struct Pokenav_MatchCallGfx *); +static bool32 WaitForTrainerPic(struct Pokenav_MatchCallGfx *); +static void TrainerPicSlideOffscreen(struct Pokenav_MatchCallGfx *); +static void Task_FlashPokeballIcons(u8); +static void TryDrawRematchPokeballIcon(u16, u32, u32); +static void PrintNumberRegisteredLabel(u16); +static void PrintNumberRegistered(u16); +static void PrintNumberOfBattlesLabel(u16); +static void PrintNumberOfBattles(u16); +static void PrintMatchCallInfoLabel(u16, const u8 *, int); +static void PrintMatchCallInfoNumber(u16, const u8 *, int); +static void CreateOptionsCursorSprite(struct Pokenav_MatchCallGfx *, int); +static void CloseMatchCallSelectOptionsWindow(struct Pokenav_MatchCallGfx *); static struct Sprite *CreateTrainerPicSprite(void); -static void SpriteCB_TrainerPicSlideOnscreen(struct Sprite *sprite); -static void SpriteCB_TrainerPicSlideOffscreen(struct Sprite *sprite); -void SpriteCB_OptionsCursor(struct Sprite *sprite); -u32 MatchCallListCursorDown(s32); -u32 MatchCallListCursorUp(s32); -u32 MatchCallListPageDown(s32); -u32 MatchCallListPageUp(s32); -u32 SelectMatchCallEntry(s32); -u32 MoveMatchCallOptionsCursor(s32); +static void SpriteCB_TrainerPicSlideOnscreen(struct Sprite *); +static void SpriteCB_TrainerPicSlideOffscreen(struct Sprite *); +static void SpriteCB_OptionsCursor(struct Sprite *); +static u32 MatchCallListCursorDown(s32); +static u32 MatchCallListCursorUp(s32); +static u32 MatchCallListPageDown(s32); +static u32 MatchCallListPageUp(s32); +static u32 SelectMatchCallEntry(s32); +static u32 MoveMatchCallOptionsCursor(s32); static u32 CancelMatchCallSelection(s32); -u32 DoMatchCallMessage(s32); -u32 DoTrainerCloseByMessage(s32); -u32 sub_81CB888(s32); -u32 ShowCheckPage(s32); -u32 ShowCheckPageUp(s32); -u32 ShowCheckPageDown(s32); -u32 ExitCheckPage(s32); -u32 ExitMatchCall(s32); +static u32 DoMatchCallMessage(s32); +static u32 DoTrainerCloseByMessage(s32); +static u32 CloseMatchCallMessage(s32); +static u32 ShowCheckPage(s32); +static u32 ShowCheckPageUp(s32); +static u32 ShowCheckPageDown(s32); +static u32 ExitCheckPage(s32); +static u32 ExitMatchCall(s32); static const u16 sMatchCallUI_Pal[] = INCBIN_U16("graphics/pokenav/match_call/ui.gbapal"); static const u32 sMatchCallUI_Gfx[] = INCBIN_U32("graphics/pokenav/match_call/ui.4bpp.lz"); static const u32 sMatchCallUI_Tilemap[] = INCBIN_U32("graphics/pokenav/match_call/ui.bin.lz"); -static const u16 gUnknown_08622698[] = INCBIN_U16("graphics/pokenav/match_call/arrow.gbapal"); -static const u32 gUnknown_086226B8[] = INCBIN_U32("graphics/pokenav/match_call/arrow.4bpp.lz"); +static const u16 sOptionsCursor_Pal[] = INCBIN_U16("graphics/pokenav/match_call/options_cursor.gbapal"); +static const u32 sOptionsCursor_Gfx[] = INCBIN_U32("graphics/pokenav/match_call/options_cursor.4bpp.lz"); static const u16 gUnknown_086226E0[] = INCBIN_U16("graphics/pokenav/match_call/86226E0.gbapal"); static const u16 gUnknown_08622700[] = INCBIN_U16("graphics/pokenav/match_call/8622700.gbapal"); -static const u16 gUnknown_08622720[] = INCBIN_U16("graphics/pokenav/match_call/pokeball.gbapal"); -static const u32 gUnknown_08622760[] = INCBIN_U32("graphics/pokenav/match_call/pokeball.4bpp.lz"); +static const u16 sPokeball_Pal[] = INCBIN_U16("graphics/pokenav/match_call/pokeball.gbapal"); +static const u32 sPokeball_Gfx[] = INCBIN_U32("graphics/pokenav/match_call/pokeball.4bpp.lz"); const struct BgTemplate sMatchCallBgTemplates[3] = { @@ -162,7 +167,7 @@ static const LoopedTask sMatchCallLoopTaskFuncs[] = [POKENAV_MC_FUNC_CANCEL] = CancelMatchCallSelection, [POKENAV_MC_FUNC_CALL_MSG] = DoMatchCallMessage, [POKENAV_MC_FUNC_NEARBY_MSG] = DoTrainerCloseByMessage, - [POKENAV_MC_FUNC_10] = sub_81CB888, + [POKENAV_MC_FUNC_EXIT_CALL] = CloseMatchCallMessage, [POKENAV_MC_FUNC_SHOW_CHECK_PAGE] = ShowCheckPage, [POKENAV_MC_FUNC_CHECK_PAGE_UP] = ShowCheckPageUp, [POKENAV_MC_FUNC_CHECK_PAGE_DOWN] = ShowCheckPageDown, @@ -200,27 +205,27 @@ static const u8 *const sMatchCallOptionTexts[MATCH_CALL_OPTION_COUNT] = }; // The series of 5 dots that appear when someone is called with Match Call -static const u8 sText_CallingDots[] = _("·{PAUSE 0x04}·{PAUSE 0x04}·{PAUSE 0x04}·{PAUSE 0x04}·\p"); +static const u8 sText_CallingDots[] = _("·{PAUSE 4}·{PAUSE 4}·{PAUSE 4}·{PAUSE 4}·\p"); static const struct WindowTemplate sCallMsgBoxWindowTemplate = { .bg = 1, .tilemapLeft = 1, .tilemapTop = 12, - .width = 0x1C, - .height = 0x04, + .width = 28, + .height = 4, .paletteNum = 1, .baseBlock = 10 }; -const struct CompressedSpriteSheet gUnknown_08622810[1] = +static const struct CompressedSpriteSheet sOptionsCursorSpriteSheets[1] = { - {gUnknown_086226B8, 0x40, 7} + {sOptionsCursor_Gfx, 0x40, GFXTAG_CURSOR} }; -const struct SpritePalette gUnknown_08622818[2] = +const struct SpritePalette sOptionsCursorSpritePalettes[2] = { - {gUnknown_08622698, 12} + {sOptionsCursor_Pal, PALTAG_CURSOR} }; static const struct OamData sOptionsCursorOamData = @@ -239,8 +244,8 @@ static const struct OamData sOptionsCursorOamData = static const struct SpriteTemplate sOptionsCursorSpriteTemplate = { - .tileTag = 7, - .paletteTag = 12, + .tileTag = GFXTAG_CURSOR, + .paletteTag = PALTAG_CURSOR, .oam = &sOptionsCursorOamData, .anims = gDummySpriteAnimTable, .images = NULL, @@ -264,8 +269,8 @@ static const struct OamData sTrainerPicOamData = static const struct SpriteTemplate sTrainerPicSpriteTemplate = { - .tileTag = 8, - .paletteTag = 13, + .tileTag = GFXTAG_TRAINER_PIC, + .paletteTag = PALTAG_TRAINER_PIC, .oam = &sTrainerPicOamData, .anims = gDummySpriteAnimTable, .images = NULL, @@ -275,57 +280,57 @@ static const struct SpriteTemplate sTrainerPicSpriteTemplate = bool32 OpenMatchCall(void) { - struct Pokenav4Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN, sizeof(struct Pokenav4Struct)); - if (!state) + struct Pokenav_MatchCallGfx *gfx = AllocSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN, sizeof(struct Pokenav_MatchCallGfx)); + if (!gfx) return FALSE; - state->unused19 = 0; - state->loopTaskId = CreateLoopedTask(LoopedTask_OpenMatchCall, 1); - state->isTaskActiveCB = GetCurrentLoopedTaskActive; + gfx->unused19 = 0; + gfx->loopTaskId = CreateLoopedTask(LoopedTask_OpenMatchCall, 1); + gfx->isTaskActiveCB = GetCurrentLoopedTaskActive; return TRUE; } void CreateMatchCallLoopedTask(s32 index) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - state->loopTaskId = CreateLoopedTask(sMatchCallLoopTaskFuncs[index], 1); - state->isTaskActiveCB = GetCurrentLoopedTaskActive; + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + gfx->loopTaskId = CreateLoopedTask(sMatchCallLoopTaskFuncs[index], 1); + gfx->isTaskActiveCB = GetCurrentLoopedTaskActive; } bool32 IsMatchCallLoopedTaskActive(void) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - return state->isTaskActiveCB(); + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + return gfx->isTaskActiveCB(); } void FreeMatchCallSubstruct2(void) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - RemoveMatchCallSprites(); + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + FreeMatchCallSprites(); sub_81CBC1C(); - RemoveWindow(state->infoBoxWindowId); - RemoveWindow(state->locWindowId); - RemoveWindow(state->msgBoxWindowId); - FreePokenavSubstruct(6); + RemoveWindow(gfx->infoBoxWindowId); + RemoveWindow(gfx->locWindowId); + RemoveWindow(gfx->msgBoxWindowId); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); } static bool32 GetCurrentLoopedTaskActive(void) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - return IsLoopedTaskActive(state->loopTaskId); + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + return IsLoopedTaskActive(gfx->loopTaskId); } -static u32 LoopedTask_OpenMatchCall(s32 taskState) +static u32 LoopedTask_OpenMatchCall(s32 state) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - switch (taskState) + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + switch (state) { case 0: InitBgTemplates(sMatchCallBgTemplates, ARRAY_COUNT(sMatchCallBgTemplates)); ChangeBgX(2, 0, BG_COORD_SET); ChangeBgY(2, 0, BG_COORD_SET); DecompressAndCopyTileDataToVram(2, sMatchCallUI_Gfx, 0, 0, 0); - SetBgTilemapBuffer(2, state->unk1024); + SetBgTilemapBuffer(2, gfx->bgTilemapBuffer2); CopyToBgTilemapBuffer(2, sMatchCallUI_Tilemap, 0, 0); CopyBgTilemapBufferToVram(2); CopyPaletteIntoBufferUnfaded(sMatchCallUI_Pal, 0x20, 0x20); @@ -336,7 +341,7 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState) return LT_PAUSE; BgDmaFill(1, 0, 0, 1); - SetBgTilemapBuffer(1, state->unk24); + SetBgTilemapBuffer(1, gfx->bgTilemapBuffer1); FillBgTilemapBufferRect_Palette0(1, 0x1000, 0, 0, 32, 20); CopyPaletteIntoBufferUnfaded(gUnknown_086226E0, 0x10, 0x20); CopyBgTilemapBufferToVram(1); @@ -345,10 +350,10 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState) if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - sub_81CC034(state); - DecompressAndCopyTileDataToVram(3, gUnknown_08622760, 0, 0, 0); + LoadCallWindowAndFade(gfx); + DecompressAndCopyTileDataToVram(3, sPokeball_Gfx, 0, 0, 0); CopyPaletteIntoBufferUnfaded(gUnknown_08622700, 0x30, 0x20); - CopyPaletteIntoBufferUnfaded(gUnknown_08622720, 0x50, 0x20); + CopyPaletteIntoBufferUnfaded(sPokeball_Pal, 0x50, 0x20); return LT_INC_AND_PAUSE; case 3: if (FreeTempTileDataBuffersIfPossible() || !sub_81CAE28()) @@ -360,11 +365,11 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState) if (sub_81C8224()) return LT_PAUSE; - DrawMatchCallLeftColumnWindows(state); + DrawMatchCallLeftColumnWindows(gfx); return LT_INC_AND_PAUSE; case 5: - UpdateMatchCallInfoBox(state); - PrintMatchCallLocation(state, 0); + UpdateMatchCallInfoBox(gfx); + PrintMatchCallLocation(gfx, 0); return LT_INC_AND_PAUSE; case 6: ChangeBgX(1, 0, BG_COORD_SET); @@ -372,50 +377,50 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState) ShowBg(2); ShowBg(3); ShowBg(1); - sub_81CC214(); + AllocMatchCallSprites(); LoadLeftHeaderGfxForIndex(3); ShowLeftHeaderGfx(POKENAV_GFX_MATCH_CALL_MENU, 1, 0); - PokenavFadeScreen(1); + PokenavFadeScreen(POKENAV_FADE_FROM_BLACK); return LT_INC_AND_PAUSE; case 7: if (IsPaletteFadeActive() || AreLeftHeaderSpritesMoving()) return LT_PAUSE; - sub_81CBC38(1); + SetPokeballIconsFlashing(TRUE); return LT_FINISH; default: return LT_FINISH; } } -u32 MatchCallListCursorDown(s32 taskState) +static u32 MatchCallListCursorDown(s32 state) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - switch (taskState) + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + switch (state) { case 0: switch (MatchCall_MoveCursorDown()) { - case 0: - break; - case 1: - PlaySE(SE_SELECT); - return 7; - case 2: - PlaySE(SE_SELECT); - // fall through - default: - return LT_INC_AND_PAUSE; + case 0: + break; + case 1: + PlaySE(SE_SELECT); + return LT_SET_STATE(2); + case 2: + PlaySE(SE_SELECT); + // fall through + default: + return LT_INC_AND_PAUSE; } break; case 1: if (IsMonListLoopedTaskActive()) return LT_PAUSE; - PrintMatchCallLocation(state, 0); + PrintMatchCallLocation(gfx, 0); return LT_INC_AND_PAUSE; case 2: - PrintMatchCallLocation(state, 0); + PrintMatchCallLocation(gfx, 0); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -425,34 +430,34 @@ u32 MatchCallListCursorDown(s32 taskState) return LT_FINISH; } -u32 MatchCallListCursorUp(s32 taskState) +static u32 MatchCallListCursorUp(s32 state) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - switch (taskState) + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + switch (state) { case 0: switch (MatchCall_MoveCursorUp()) { - case 0: - break; - case 1: - PlaySE(SE_SELECT); - return 7; - case 2: - PlaySE(SE_SELECT); - // fall through - default: - return LT_INC_AND_PAUSE; + case 0: + break; + case 1: + PlaySE(SE_SELECT); + return LT_SET_STATE(2); + case 2: + PlaySE(SE_SELECT); + // fall through + default: + return LT_INC_AND_PAUSE; } break; case 1: if (IsMonListLoopedTaskActive()) return LT_PAUSE; - PrintMatchCallLocation(state, 0); + PrintMatchCallLocation(gfx, 0); return LT_INC_AND_PAUSE; case 2: - PrintMatchCallLocation(state, 0); + PrintMatchCallLocation(gfx, 0); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -462,34 +467,34 @@ u32 MatchCallListCursorUp(s32 taskState) return LT_FINISH; } -u32 MatchCallListPageDown(s32 taskState) +static u32 MatchCallListPageDown(s32 state) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - switch (taskState) + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + switch (state) { case 0: switch (MatchCall_PageDown()) { - case 0: - break; - case 1: - PlaySE(SE_SELECT); - return 7; - case 2: - PlaySE(SE_SELECT); - // fall through - default: - return LT_INC_AND_PAUSE; + case 0: + break; + case 1: + PlaySE(SE_SELECT); + return LT_SET_STATE(2); + case 2: + PlaySE(SE_SELECT); + // fall through + default: + return LT_INC_AND_PAUSE; } break; case 1: if (IsMonListLoopedTaskActive()) return LT_PAUSE; - PrintMatchCallLocation(state, 0); + PrintMatchCallLocation(gfx, 0); return LT_INC_AND_PAUSE; case 2: - PrintMatchCallLocation(state, 0); + PrintMatchCallLocation(gfx, 0); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -499,34 +504,34 @@ u32 MatchCallListPageDown(s32 taskState) return LT_FINISH; } -u32 MatchCallListPageUp(s32 taskState) +static u32 MatchCallListPageUp(s32 state) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - switch (taskState) + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + switch (state) { case 0: switch (MatchCall_PageUp()) { - case 0: - break; - case 1: - PlaySE(SE_SELECT); - return 7; - case 2: - PlaySE(SE_SELECT); - // fall through - default: - return LT_INC_AND_PAUSE; + case 0: + break; + case 1: + PlaySE(SE_SELECT); + return LT_SET_STATE(2); + case 2: + PlaySE(SE_SELECT); + // fall through + default: + return LT_INC_AND_PAUSE; } break; case 1: if (IsMonListLoopedTaskActive()) return LT_PAUSE; - PrintMatchCallLocation(state, 0); + PrintMatchCallLocation(gfx, 0); return LT_INC_AND_PAUSE; case 2: - PrintMatchCallLocation(state, 0); + PrintMatchCallLocation(gfx, 0); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -536,18 +541,18 @@ u32 MatchCallListPageUp(s32 taskState) return LT_FINISH; } -u32 SelectMatchCallEntry(s32 taskState) +static u32 SelectMatchCallEntry(s32 state) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - switch (taskState) + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + switch (state) { case 0: PlaySE(SE_SELECT); - PrintMatchCallSelectionOptions(state); + PrintMatchCallSelectionOptions(gfx); PrintHelpBarText(HELPBAR_MC_CALL_MENU); return LT_INC_AND_PAUSE; case 1: - if (sub_81CBFC4(state)) + if (ShowOptionsCursor(gfx)) return LT_PAUSE; break; } @@ -555,30 +560,30 @@ u32 SelectMatchCallEntry(s32 taskState) return LT_FINISH; } -u32 MoveMatchCallOptionsCursor(s32 taskState) +static u32 MoveMatchCallOptionsCursor(s32 state) { - struct Pokenav4Struct *state; + struct Pokenav_MatchCallGfx *gfx; u16 cursorPos; PlaySE(SE_SELECT); - state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); cursorPos = GetMatchCallOptionCursorPos(); - UpdateCursorGfxPos(state, cursorPos); + UpdateCursorGfxPos(gfx, cursorPos); return LT_FINISH; } -u32 CancelMatchCallSelection(s32 taskState) +static u32 CancelMatchCallSelection(s32 state) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - switch (taskState) + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + switch (state) { case 0: PlaySE(SE_SELECT); - UpdateWindowsReturnToTrainerList(state); + UpdateWindowsReturnToTrainerList(gfx); PrintHelpBarText(HELPBAR_MC_TRAINER_LIST); return LT_INC_AND_PAUSE; case 1: - if (IsDma3ManagerBusyWithBgCopy1(state)) + if (IsDma3ManagerBusyWithBgCopy1(gfx)) return LT_PAUSE; break; } @@ -586,31 +591,31 @@ u32 CancelMatchCallSelection(s32 taskState) return LT_FINISH; } -u32 DoMatchCallMessage(s32 taskState) +static u32 DoMatchCallMessage(s32 state) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - switch (taskState) + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + switch (state) { case 0: ToggleMatchCallVerticalArrows(TRUE); - DrawMsgBoxForMatchCallMsg(state); + DrawMsgBoxForMatchCallMsg(gfx); return LT_INC_AND_PAUSE; case 1: - if (IsDma3ManagerBusyWithBgCopy2(state)) + if (IsDma3ManagerBusyWithBgCopy2(gfx)) return LT_PAUSE; - PrintCallingDots(state); + PrintCallingDots(gfx); PlaySE(SE_POKENAV_CALL); - state->unkE = 0; + gfx->unkE = 0; return LT_INC_AND_PAUSE; case 2: - if (WaitForCallingDotsText(state)) + if (WaitForCallingDotsText(gfx)) return LT_PAUSE; - PrintMatchCallMessage(state); + PrintMatchCallMessage(gfx); return LT_INC_AND_PAUSE; case 3: - if (WaitForMatchCallMessageText(state)) + if (WaitForMatchCallMessageText(gfx)) return LT_PAUSE; break; } @@ -618,25 +623,25 @@ u32 DoMatchCallMessage(s32 taskState) return LT_FINISH; } -u32 DoTrainerCloseByMessage(s32 taskState) +static u32 DoTrainerCloseByMessage(s32 state) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - switch (taskState) + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + switch (state) { case 0: PlaySE(SE_SELECT); - DrawMsgBoxForCloseByMsg(state); + DrawMsgBoxForCloseByMsg(gfx); ToggleMatchCallVerticalArrows(TRUE); - state->unkE = 1; + gfx->unkE = 1; return LT_INC_AND_PAUSE; case 1: - if (IsDma3ManagerBusyWithBgCopy2(state)) + if (IsDma3ManagerBusyWithBgCopy2(gfx)) return LT_PAUSE; - PrintTrainerIsCloseBy(state); + PrintTrainerIsCloseBy(gfx); return LT_INC_AND_PAUSE; case 2: - if (WaitForTrainerIsCloseByText(state)) + if (WaitForTrainerIsCloseByText(gfx)) return LT_PAUSE; break; } @@ -644,31 +649,31 @@ u32 DoTrainerCloseByMessage(s32 taskState) return LT_FINISH; } -u32 sub_81CB888(s32 taskState) +static u32 CloseMatchCallMessage(s32 state) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); u32 result = LT_INC_AND_PAUSE; - switch (taskState) + switch (state) { case 0: - if (!state->unkE) + if (!gfx->unkE) PlaySE(SE_POKENAV_HANG_UP); PlaySE(SE_SELECT); break; case 1: - DrawSpinningPokenavForCall(state); + EraseCallMessageBox(gfx); break; case 2: - if (WaitForSpinningPokenav(state)) + if (WaitForCallMessageBoxErase(gfx)) result = LT_PAUSE; break; case 3: - UpdateWindowsReturnToTrainerList(state); + UpdateWindowsReturnToTrainerList(gfx); break; case 4: - if (IsDma3ManagerBusyWithBgCopy1(state)) + if (IsDma3ManagerBusyWithBgCopy1(gfx)) result = LT_PAUSE; PrintHelpBarText(HELPBAR_MC_TRAINER_LIST); @@ -680,7 +685,7 @@ u32 sub_81CB888(s32 taskState) } else { - if (state->unkF) + if (gfx->unkF) { sub_81C8838(); result = LT_INC_AND_CONTINUE; @@ -708,28 +713,28 @@ u32 sub_81CB888(s32 taskState) return result; } -u32 ShowCheckPage(s32 taskState) +static u32 ShowCheckPage(s32 state) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - switch (taskState) + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + switch (state) { case 0: PlaySE(SE_SELECT); sub_81C877C(); - UpdateWindowsToShowCheckPage(state); + UpdateWindowsToShowCheckPage(gfx); return LT_INC_AND_PAUSE; case 1: - if (IsMatchCallListTaskActive() || IsDma3ManagerBusyWithBgCopy1(state)) + if (IsMatchCallListTaskActive() || IsDma3ManagerBusyWithBgCopy1(gfx)) return LT_PAUSE; PrintHelpBarText(HELPBAR_MC_CHECK_PAGE); return LT_INC_AND_PAUSE; case 2: PrintCheckPageInfo(0); - LoadCheckPageTrainerPic(state); + LoadCheckPageTrainerPic(gfx); return LT_INC_AND_PAUSE; case 3: - if (IsMatchCallListTaskActive() || WaitForTrainerPic(state) || WaitForHelpBar()) + if (IsMatchCallListTaskActive() || WaitForTrainerPic(gfx) || WaitForHelpBar()) return LT_PAUSE; break; } @@ -737,12 +742,12 @@ u32 ShowCheckPage(s32 taskState) return LT_FINISH; } -u32 ShowCheckPageDown(s32 taskState) +static u32 ShowCheckPageDown(s32 state) { int topId; int delta; - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - switch (taskState) + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + switch (state) { case 0: topId = GetMatchCallListTopIndex(); @@ -750,25 +755,25 @@ u32 ShowCheckPageDown(s32 taskState) if (delta) { PlaySE(SE_SELECT); - state->unk16 = delta; - TrainerPicSlideOffscreen(state); + gfx->pageDelta = delta; + TrainerPicSlideOffscreen(gfx); return LT_INC_AND_PAUSE; } break; case 1: - if (WaitForTrainerPic(state)) + if (WaitForTrainerPic(gfx)) return LT_PAUSE; - PrintMatchCallLocation(state, state->unk16); + PrintMatchCallLocation(gfx, gfx->pageDelta); return LT_INC_AND_PAUSE; case 2: - PrintCheckPageInfo(state->unk16); + PrintCheckPageInfo(gfx->pageDelta); return LT_INC_AND_PAUSE; case 3: - LoadCheckPageTrainerPic(state); + LoadCheckPageTrainerPic(gfx); return LT_INC_AND_PAUSE; case 4: - if (IsMatchCallListTaskActive() || WaitForTrainerPic(state)) + if (IsMatchCallListTaskActive() || WaitForTrainerPic(gfx)) return LT_PAUSE; break; } @@ -776,22 +781,22 @@ u32 ShowCheckPageDown(s32 taskState) return LT_FINISH; } -u32 ExitCheckPage(s32 taskState) +static u32 ExitCheckPage(s32 state) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - switch (taskState) + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + switch (state) { case 0: PlaySE(SE_SELECT); - TrainerPicSlideOffscreen(state); + TrainerPicSlideOffscreen(gfx); sub_81C87F0(); return LT_INC_AND_PAUSE; case 1: - if (IsMatchCallListTaskActive() || WaitForTrainerPic(state)) + if (IsMatchCallListTaskActive() || WaitForTrainerPic(gfx)) return LT_PAUSE; PrintHelpBarText(HELPBAR_MC_TRAINER_LIST); - UpdateMatchCallInfoBox(state); + UpdateMatchCallInfoBox(gfx); return LT_INC_AND_PAUSE; case 2: if (IsDma3ManagerBusyWithBgCopy()) @@ -802,12 +807,12 @@ u32 ExitCheckPage(s32 taskState) return LT_FINISH; } -u32 ShowCheckPageUp(s32 taskState) +static u32 ShowCheckPageUp(s32 state) { int topId; int delta; - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - switch (taskState) + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + switch (state) { case 0: topId = GetMatchCallListTopIndex(); @@ -815,25 +820,25 @@ u32 ShowCheckPageUp(s32 taskState) if (delta) { PlaySE(SE_SELECT); - state->unk16 = delta; - TrainerPicSlideOffscreen(state); + gfx->pageDelta = delta; + TrainerPicSlideOffscreen(gfx); return LT_INC_AND_PAUSE; } break; case 1: - if (WaitForTrainerPic(state)) + if (WaitForTrainerPic(gfx)) return LT_PAUSE; - PrintMatchCallLocation(state, state->unk16); + PrintMatchCallLocation(gfx, gfx->pageDelta); return LT_INC_AND_PAUSE; case 2: - PrintCheckPageInfo(state->unk16); + PrintCheckPageInfo(gfx->pageDelta); return LT_INC_AND_PAUSE; case 3: - LoadCheckPageTrainerPic(state); + LoadCheckPageTrainerPic(gfx); return LT_INC_AND_PAUSE; case 4: - if (IsMatchCallListTaskActive() || WaitForTrainerPic(state)) + if (IsMatchCallListTaskActive() || WaitForTrainerPic(gfx)) return LT_PAUSE; break; } @@ -841,14 +846,14 @@ u32 ShowCheckPageUp(s32 taskState) return LT_FINISH; } -u32 ExitMatchCall(s32 taskState) +static u32 ExitMatchCall(s32 state) { - switch (taskState) + switch (state) { case 0: PlaySE(SE_SELECT); - sub_81CBC38(0); - PokenavFadeScreen(0); + SetPokeballIconsFlashing(FALSE); + PokenavFadeScreen(POKENAV_FADE_TO_BLACK); SlideMenuHeaderDown(); return LT_INC_AND_PAUSE; case 1: @@ -878,36 +883,50 @@ static void InitMatchCallPokenavListMenuTemplate(void) template.listFunc.unk10_2 = BufferMatchCallNameAndDesc; template.unk14 = TryDrawRematchPokeballIcon; sub_81C81D4(&sMatchCallBgTemplates[2], &template, 2); - CreateTask(sub_81CBC64, 7); + CreateTask(Task_FlashPokeballIcons, 7); } static void sub_81CBC1C(void) { sub_81C8234(); - DestroyTask(FindTaskIdByFunc(sub_81CBC64)); + DestroyTask(FindTaskIdByFunc(Task_FlashPokeballIcons)); } -static void sub_81CBC38(int arg0) +#define tSinIdx data[0] +#define tSinVal data[1] +#define tActive data[15] + +static void SetPokeballIconsFlashing(bool32 active) { - u8 taskId = FindTaskIdByFunc(sub_81CBC64); + u8 taskId = FindTaskIdByFunc(Task_FlashPokeballIcons); if (taskId != TASK_NONE) - gTasks[taskId].data[15] = arg0; + gTasks[taskId].tActive = active; } -static void sub_81CBC64(u8 taskId) +static void Task_FlashPokeballIcons(u8 taskId) { - s16 *taskData = gTasks[taskId].data; - if (taskData[15]) + s16 *data = gTasks[taskId].data; + if (tActive) { - taskData[0] += 4; - taskData[0] &= 0x7F; - taskData[1] = gSineTable[taskData[0]] >> 4; - PokenavCopyPalette(gUnknown_08622720, gUnknown_08622720 + 0x10, 0x10, 0x10, taskData[1], gPlttBufferUnfaded + 0x50); + tSinIdx += 4; + tSinIdx &= 0x7F; + tSinVal = gSineTable[tSinIdx] >> 4; + PokenavCopyPalette(sPokeball_Pal, &sPokeball_Pal[0x10], 0x10, 0x10, tSinVal, &gPlttBufferUnfaded[0x50]); if (!gPaletteFade.active) - CpuCopy32(gPlttBufferUnfaded + 0x50, gPlttBufferFaded + 0x50, 0x20); + CpuCopy32(&gPlttBufferUnfaded[0x50], &gPlttBufferFaded[0x50], 0x20); } } +#undef tSinIdx +#undef tSinVal +#undef tActive + +enum { + POKEBALL_ICON_TOP = 0x5000, + POKEBALL_ICON_BOTTOM, + POKEBALL_ICON_EMPTY, +}; + static void TryDrawRematchPokeballIcon(u16 windowId, u32 rematchId, u32 arg2) { u8 bg = GetWindowAttribute(windowId, WINDOW_BG); @@ -915,13 +934,13 @@ static void TryDrawRematchPokeballIcon(u16 windowId, u32 rematchId, u32 arg2) tilemap += arg2 * 0x40 + 0x1D; if (ShouldDrawRematchPokeballIcon(rematchId)) { - tilemap[0] = 0x5000; - tilemap[0x20] = 0x5001; + tilemap[0] = POKEBALL_ICON_TOP; + tilemap[0x20] = POKEBALL_ICON_BOTTOM; } else { - tilemap[0] = 0x5002; - tilemap[0x20] = 0x5002; + tilemap[0] = POKEBALL_ICON_EMPTY; + tilemap[0x20] = POKEBALL_ICON_EMPTY; } } @@ -930,29 +949,29 @@ void ClearRematchPokeballIcon(u16 windowId, u32 arg0) u8 bg = GetWindowAttribute(windowId, WINDOW_BG); u16 *tilemap = GetBgTilemapBuffer(bg); tilemap += arg0 * 0x40 + 0x1D; - tilemap[0] = 0x5002; - tilemap[0x20] = 0x5002; + tilemap[0] = POKEBALL_ICON_EMPTY; + tilemap[0x20] = POKEBALL_ICON_EMPTY; } -static void DrawMatchCallLeftColumnWindows(struct Pokenav4Struct *state) +static void DrawMatchCallLeftColumnWindows(struct Pokenav_MatchCallGfx *gfx) { - state->locWindowId = AddWindow(&sMatchCallLocationWindowTemplate); - state->infoBoxWindowId = AddWindow(&sMatchCallInfoBoxWindowTemplate); - FillWindowPixelBuffer(state->locWindowId, PIXEL_FILL(1)); - PutWindowTilemap(state->locWindowId); - FillWindowPixelBuffer(state->infoBoxWindowId, PIXEL_FILL(1)); - PutWindowTilemap(state->infoBoxWindowId); - CopyWindowToVram(state->locWindowId, COPYWIN_MAP); + gfx->locWindowId = AddWindow(&sMatchCallLocationWindowTemplate); + gfx->infoBoxWindowId = AddWindow(&sMatchCallInfoBoxWindowTemplate); + FillWindowPixelBuffer(gfx->locWindowId, PIXEL_FILL(1)); + PutWindowTilemap(gfx->locWindowId); + FillWindowPixelBuffer(gfx->infoBoxWindowId, PIXEL_FILL(1)); + PutWindowTilemap(gfx->infoBoxWindowId); + CopyWindowToVram(gfx->locWindowId, COPYWIN_MAP); } -static void UpdateMatchCallInfoBox(struct Pokenav4Struct *state) +static void UpdateMatchCallInfoBox(struct Pokenav_MatchCallGfx *gfx) { - FillWindowPixelBuffer(state->infoBoxWindowId, PIXEL_FILL(1)); - PrintNumberRegisteredLabel(state->infoBoxWindowId); - PrintNumberRegistered(state->infoBoxWindowId); - PrintNumberOfBattlesLabel(state->infoBoxWindowId); - PrintNumberOfBattles(state->infoBoxWindowId); - CopyWindowToVram(state->infoBoxWindowId, COPYWIN_GFX); + FillWindowPixelBuffer(gfx->infoBoxWindowId, PIXEL_FILL(1)); + PrintNumberRegisteredLabel(gfx->infoBoxWindowId); + PrintNumberRegistered(gfx->infoBoxWindowId); + PrintNumberOfBattlesLabel(gfx->infoBoxWindowId); + PrintNumberOfBattles(gfx->infoBoxWindowId); + CopyWindowToVram(gfx->infoBoxWindowId, COPYWIN_GFX); } static void PrintNumberRegisteredLabel(u16 windowId) @@ -996,11 +1015,11 @@ static void PrintMatchCallInfoNumber(u16 windowId, const u8 *str, int top) AddTextPrinterParameterized(windowId, FONT_NARROW, str, x, y, TEXT_SKIP_DRAW, NULL); } -static void PrintMatchCallLocation(struct Pokenav4Struct *state, int arg1) +static void PrintMatchCallLocation(struct Pokenav_MatchCallGfx *gfx, int delta) { u8 mapName[32]; int x; - int index = GetSelectedPokenavListIndex() + arg1; + int index = GetSelectedPokenavListIndex() + delta; int mapSec = GetMatchCallMapSec(index); if (mapSec != MAPSEC_NONE) GetMapName(mapName, mapSec, 0); @@ -1008,207 +1027,209 @@ static void PrintMatchCallLocation(struct Pokenav4Struct *state, int arg1) StringCopy(mapName, gText_Unknown); x = GetStringCenterAlignXOffset(FONT_NARROW, mapName, 88); - FillWindowPixelBuffer(state->locWindowId, PIXEL_FILL(1)); - AddTextPrinterParameterized(state->locWindowId, FONT_NARROW, mapName, x, 1, 0, NULL); + FillWindowPixelBuffer(gfx->locWindowId, PIXEL_FILL(1)); + AddTextPrinterParameterized(gfx->locWindowId, FONT_NARROW, mapName, x, 1, 0, NULL); } -static void PrintMatchCallSelectionOptions(struct Pokenav4Struct *state) +static void PrintMatchCallSelectionOptions(struct Pokenav_MatchCallGfx *gfx) { u32 i; - FillWindowPixelBuffer(state->infoBoxWindowId, PIXEL_FILL(1)); + FillWindowPixelBuffer(gfx->infoBoxWindowId, PIXEL_FILL(1)); for (i = 0; i < MATCH_CALL_OPTION_COUNT; i++) { int optionText = GetMatchCallOptionId(i); if (optionText == MATCH_CALL_OPTION_COUNT) break; - AddTextPrinterParameterized(state->infoBoxWindowId, FONT_NARROW, sMatchCallOptionTexts[optionText], 16, i * 16 + 1, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(gfx->infoBoxWindowId, FONT_NARROW, sMatchCallOptionTexts[optionText], 16, i * 16 + 1, TEXT_SKIP_DRAW, NULL); } - CopyWindowToVram(state->infoBoxWindowId, COPYWIN_GFX); + CopyWindowToVram(gfx->infoBoxWindowId, COPYWIN_GFX); } -static bool32 sub_81CBFC4(struct Pokenav4Struct *state) +static bool32 ShowOptionsCursor(struct Pokenav_MatchCallGfx *gfx) { if (!IsDma3ManagerBusyWithBgCopy()) { - sub_81CC2F0(state, GetMatchCallOptionCursorPos()); + CreateOptionsCursorSprite(gfx, GetMatchCallOptionCursorPos()); return FALSE; } return TRUE; } -static void UpdateWindowsReturnToTrainerList(struct Pokenav4Struct *state) +static void UpdateWindowsReturnToTrainerList(struct Pokenav_MatchCallGfx *gfx) { - CloseMatchCallSelectOptionsWindow(state); - UpdateMatchCallInfoBox(state); + CloseMatchCallSelectOptionsWindow(gfx); + UpdateMatchCallInfoBox(gfx); } -static bool32 IsDma3ManagerBusyWithBgCopy1(struct Pokenav4Struct *state) +static bool32 IsDma3ManagerBusyWithBgCopy1(struct Pokenav_MatchCallGfx *gfx) { return IsDma3ManagerBusyWithBgCopy(); } -static void UpdateWindowsToShowCheckPage(struct Pokenav4Struct *state) +static void UpdateWindowsToShowCheckPage(struct Pokenav_MatchCallGfx *gfx) { - CloseMatchCallSelectOptionsWindow(state); - FillWindowPixelBuffer(state->infoBoxWindowId, PIXEL_FILL(1)); - CopyWindowToVram(state->infoBoxWindowId, COPYWIN_GFX); + CloseMatchCallSelectOptionsWindow(gfx); + FillWindowPixelBuffer(gfx->infoBoxWindowId, PIXEL_FILL(1)); + CopyWindowToVram(gfx->infoBoxWindowId, COPYWIN_GFX); } -static void sub_81CC034(struct Pokenav4Struct *state) +static void LoadCallWindowAndFade(struct Pokenav_MatchCallGfx *gfx) { - state->msgBoxWindowId = AddWindow(&sCallMsgBoxWindowTemplate); - LoadMatchCallWindowGfx(state->msgBoxWindowId, 1, 4); + gfx->msgBoxWindowId = AddWindow(&sCallMsgBoxWindowTemplate); + LoadMatchCallWindowGfx(gfx->msgBoxWindowId, 1, 4); FadeToBlackExceptPrimary(); } -static void DrawMsgBoxForMatchCallMsg(struct Pokenav4Struct *state) +static void DrawMsgBoxForMatchCallMsg(struct Pokenav_MatchCallGfx *gfx) { struct Sprite *sprite; - LoadMatchCallWindowGfx(state->msgBoxWindowId, 1, 4); - DrawMatchCallTextBoxBorder(state->msgBoxWindowId, 1, 4); - FillWindowPixelBuffer(state->msgBoxWindowId, PIXEL_FILL(1)); - PutWindowTilemap(state->msgBoxWindowId); - CopyWindowToVram(state->msgBoxWindowId, COPYWIN_FULL); - sprite = PauseSpinningPokenavSprite(); + LoadMatchCallWindowGfx(gfx->msgBoxWindowId, 1, 4); + DrawMatchCallTextBoxBorder(gfx->msgBoxWindowId, 1, 4); + FillWindowPixelBuffer(gfx->msgBoxWindowId, PIXEL_FILL(1)); + PutWindowTilemap(gfx->msgBoxWindowId); + CopyWindowToVram(gfx->msgBoxWindowId, COPYWIN_FULL); + sprite = GetSpinningPokenavSprite(); sprite->x = 24; sprite->y = 112; sprite->y2 = 0; } -static void DrawMsgBoxForCloseByMsg(struct Pokenav4Struct *state) +static void DrawMsgBoxForCloseByMsg(struct Pokenav_MatchCallGfx *gfx) { - LoadUserWindowBorderGfx(state->msgBoxWindowId, 1, 0x40); - DrawTextBorderOuter(state->msgBoxWindowId, 1, 4); - FillWindowPixelBuffer(state->msgBoxWindowId, PIXEL_FILL(1)); - PutWindowTilemap(state->msgBoxWindowId); - CopyWindowToVram(state->msgBoxWindowId, COPYWIN_FULL); + LoadUserWindowBorderGfx(gfx->msgBoxWindowId, 1, 0x40); + DrawTextBorderOuter(gfx->msgBoxWindowId, 1, 4); + FillWindowPixelBuffer(gfx->msgBoxWindowId, PIXEL_FILL(1)); + PutWindowTilemap(gfx->msgBoxWindowId); + CopyWindowToVram(gfx->msgBoxWindowId, COPYWIN_FULL); } -static bool32 IsDma3ManagerBusyWithBgCopy2(struct Pokenav4Struct *state) +static bool32 IsDma3ManagerBusyWithBgCopy2(struct Pokenav_MatchCallGfx *gfx) { return IsDma3ManagerBusyWithBgCopy(); } -static void PrintCallingDots(struct Pokenav4Struct *state) +static void PrintCallingDots(struct Pokenav_MatchCallGfx *gfx) { - AddTextPrinterParameterized(state->msgBoxWindowId, FONT_NORMAL, sText_CallingDots, 32, 1, 1, NULL); + AddTextPrinterParameterized(gfx->msgBoxWindowId, FONT_NORMAL, sText_CallingDots, 32, 1, 1, NULL); } -static bool32 WaitForCallingDotsText(struct Pokenav4Struct *state) +static bool32 WaitForCallingDotsText(struct Pokenav_MatchCallGfx *gfx) { RunTextPrinters(); - return IsTextPrinterActive(state->msgBoxWindowId); + return IsTextPrinterActive(gfx->msgBoxWindowId); } -static void PrintTrainerIsCloseBy(struct Pokenav4Struct *state) +static void PrintTrainerIsCloseBy(struct Pokenav_MatchCallGfx *gfx) { - AddTextPrinterParameterized(state->msgBoxWindowId, FONT_NORMAL, gText_TrainerCloseBy, 0, 1, 1, NULL); + AddTextPrinterParameterized(gfx->msgBoxWindowId, FONT_NORMAL, gText_TrainerCloseBy, 0, 1, 1, NULL); } -static bool32 WaitForTrainerIsCloseByText(struct Pokenav4Struct *state) +static bool32 WaitForTrainerIsCloseByText(struct Pokenav_MatchCallGfx *gfx) { RunTextPrinters(); - return IsTextPrinterActive(state->msgBoxWindowId); + return IsTextPrinterActive(gfx->msgBoxWindowId); } -static void PrintMatchCallMessage(struct Pokenav4Struct *state) +static void PrintMatchCallMessage(struct Pokenav_MatchCallGfx *gfx) { int index = GetSelectedPokenavListIndex(); - const u8 *str = GetMatchCallMessageText(index, &state->unkF); + const u8 *str = GetMatchCallMessageText(index, &gfx->unkF); u8 speed = GetPlayerTextSpeedDelay(); - AddTextPrinterParameterized(state->msgBoxWindowId, FONT_NORMAL, str, 32, 1, speed, NULL); + AddTextPrinterParameterized(gfx->msgBoxWindowId, FONT_NORMAL, str, 32, 1, speed, NULL); } -static bool32 WaitForMatchCallMessageText(struct Pokenav4Struct *state) +static bool32 WaitForMatchCallMessageText(struct Pokenav_MatchCallGfx *gfx) { if (JOY_HELD(A_BUTTON)) - gTextFlags.canABSpeedUpPrint = 1; + gTextFlags.canABSpeedUpPrint = TRUE; else - gTextFlags.canABSpeedUpPrint = 0; + gTextFlags.canABSpeedUpPrint = FALSE; RunTextPrinters(); - return IsTextPrinterActive(state->msgBoxWindowId); + return IsTextPrinterActive(gfx->msgBoxWindowId); } -static void DrawSpinningPokenavForCall(struct Pokenav4Struct *state) +static void EraseCallMessageBox(struct Pokenav_MatchCallGfx *gfx) { - ResumeSpinningPokenavSprite(); + HideSpinningPokenavSprite(); FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 32, 20); CopyBgTilemapBufferToVram(1); } -static bool32 WaitForSpinningPokenav(struct Pokenav4Struct *state) +static bool32 WaitForCallMessageBoxErase(struct Pokenav_MatchCallGfx *gfx) { return IsDma3ManagerBusyWithBgCopy(); } -static void sub_81CC214(void) +static void AllocMatchCallSprites(void) { int i; u8 paletteNum; struct SpriteSheet spriteSheet; - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - for (i = 0; i < ARRAY_COUNT(gUnknown_08622810); i++) - LoadCompressedSpriteSheet(&gUnknown_08622810[i]); + // Load options cursor gfx + for (i = 0; i < ARRAY_COUNT(sOptionsCursorSpriteSheets); i++) + LoadCompressedSpriteSheet(&sOptionsCursorSpriteSheets[i]); + Pokenav_AllocAndLoadPalettes(sOptionsCursorSpritePalettes); + gfx->optionsCursorSprite = NULL; - Pokenav_AllocAndLoadPalettes(gUnknown_08622818); - state->optionsCursorSprite = NULL; - spriteSheet.data = state->unk1828; - spriteSheet.size = 0x800; - spriteSheet.tag = 8; - state->unk1824 = (u8 *)OBJ_VRAM0 + LoadSpriteSheet(&spriteSheet) * 0x20; - paletteNum = AllocSpritePalette(13); - state->unk1A = 0x100 + paletteNum * 0x10; - state->trainerPicSprite = CreateTrainerPicSprite(); - state->trainerPicSprite->invisible = TRUE; + // Load trainer pic gfx + spriteSheet.data = gfx->trainerPicGfx; + spriteSheet.size = sizeof(gfx->trainerPicGfx); + spriteSheet.tag = GFXTAG_TRAINER_PIC; + gfx->trainerPicGfxPtr = (u8 *)OBJ_VRAM0 + LoadSpriteSheet(&spriteSheet) * 0x20; + paletteNum = AllocSpritePalette(PALTAG_TRAINER_PIC); + gfx->trainerPicPalOffset = 0x100 + paletteNum * 0x10; + gfx->trainerPicSprite = CreateTrainerPicSprite(); + gfx->trainerPicSprite->invisible = TRUE; } -static void RemoveMatchCallSprites(void) +static void FreeMatchCallSprites(void) { - struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); - if (state->optionsCursorSprite) - DestroySprite(state->optionsCursorSprite); - if (state->trainerPicSprite) - DestroySprite(state->trainerPicSprite); + struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + if (gfx->optionsCursorSprite) + DestroySprite(gfx->optionsCursorSprite); + if (gfx->trainerPicSprite) + DestroySprite(gfx->trainerPicSprite); - FreeSpriteTilesByTag(8); - FreeSpriteTilesByTag(7); - FreeSpritePaletteByTag(12); - FreeSpritePaletteByTag(13); + FreeSpriteTilesByTag(GFXTAG_TRAINER_PIC); + FreeSpriteTilesByTag(GFXTAG_CURSOR); + FreeSpritePaletteByTag(PALTAG_CURSOR); + FreeSpritePaletteByTag(PALTAG_TRAINER_PIC); } -static void sub_81CC2F0(struct Pokenav4Struct *state, int top) +static void CreateOptionsCursorSprite(struct Pokenav_MatchCallGfx *gfx, int top) { - if (!state->optionsCursorSprite) + if (!gfx->optionsCursorSprite) { u8 spriteId = CreateSprite(&sOptionsCursorSpriteTemplate, 4, 80, 5); - state->optionsCursorSprite = &gSprites[spriteId]; - UpdateCursorGfxPos(state, top); + gfx->optionsCursorSprite = &gSprites[spriteId]; + UpdateCursorGfxPos(gfx, top); } } -static void CloseMatchCallSelectOptionsWindow(struct Pokenav4Struct *state) +static void CloseMatchCallSelectOptionsWindow(struct Pokenav_MatchCallGfx *gfx) { - DestroySprite(state->optionsCursorSprite); - state->optionsCursorSprite = NULL; + DestroySprite(gfx->optionsCursorSprite); + gfx->optionsCursorSprite = NULL; } -static void UpdateCursorGfxPos(struct Pokenav4Struct *state, int top) +static void UpdateCursorGfxPos(struct Pokenav_MatchCallGfx *gfx, int top) { - state->optionsCursorSprite->y2 = top * 16; + gfx->optionsCursorSprite->y2 = top * 16; } -void SpriteCB_OptionsCursor(struct Sprite *sprite) +static void SpriteCB_OptionsCursor(struct Sprite *sprite) { if (++sprite->data[0] > 3) { sprite->data[0] = 0; - sprite->x2 = (sprite->x2 + 1) & 0x7; + sprite->x2 = (sprite->x2 + 1) & 7; } } @@ -1218,30 +1239,30 @@ static struct Sprite *CreateTrainerPicSprite(void) return &gSprites[spriteId]; } -static void LoadCheckPageTrainerPic(struct Pokenav4Struct *state) +static void LoadCheckPageTrainerPic(struct Pokenav_MatchCallGfx *gfx) { u16 cursor; int trainerPic = GetMatchCallTrainerPic(GetSelectedPokenavListIndex()); if (trainerPic >= 0) { - DecompressPicFromTable(&gTrainerFrontPicTable[trainerPic], state->unk1828, SPECIES_NONE); - LZ77UnCompWram(gTrainerFrontPicPaletteTable[trainerPic].data, state->unk2028); - cursor = RequestDma3Copy(state->unk1828, state->unk1824, 0x800, 1); - LoadPalette(state->unk2028, state->unk1A, 0x20); - state->trainerPicSprite->data[0] = 0; - state->trainerPicSprite->data[7] = cursor; - state->trainerPicSprite->callback = SpriteCB_TrainerPicSlideOnscreen; + DecompressPicFromTable(&gTrainerFrontPicTable[trainerPic], gfx->trainerPicGfx, SPECIES_NONE); + LZ77UnCompWram(gTrainerFrontPicPaletteTable[trainerPic].data, gfx->trainerPicPal); + cursor = RequestDma3Copy(gfx->trainerPicGfx, gfx->trainerPicGfxPtr, sizeof(gfx->trainerPicGfx), 1); + LoadPalette(gfx->trainerPicPal, gfx->trainerPicPalOffset, sizeof(gfx->trainerPicPal)); + gfx->trainerPicSprite->data[0] = 0; + gfx->trainerPicSprite->data[7] = cursor; + gfx->trainerPicSprite->callback = SpriteCB_TrainerPicSlideOnscreen; } } -static void TrainerPicSlideOffscreen(struct Pokenav4Struct *state) +static void TrainerPicSlideOffscreen(struct Pokenav_MatchCallGfx *gfx) { - state->trainerPicSprite->callback = SpriteCB_TrainerPicSlideOffscreen; + gfx->trainerPicSprite->callback = SpriteCB_TrainerPicSlideOffscreen; } -static bool32 WaitForTrainerPic(struct Pokenav4Struct *state) +static bool32 WaitForTrainerPic(struct Pokenav_MatchCallGfx *gfx) { - return state->trainerPicSprite->callback != SpriteCallbackDummy; + return gfx->trainerPicSprite->callback != SpriteCallbackDummy; } static void SpriteCB_TrainerPicSlideOnscreen(struct Sprite *sprite) diff --git a/src/pokenav_match_call_ui.c b/src/pokenav_match_call_ui.c index ce3db25c5..83720f4cf 100644 --- a/src/pokenav_match_call_ui.c +++ b/src/pokenav_match_call_ui.c @@ -468,10 +468,10 @@ void sub_81C877C(void) structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C8870, 6); } -void PrintCheckPageInfo(s16 a0) +void PrintCheckPageInfo(s16 delta) { struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); - structPtr->unk888.windowTopIndex += a0; + structPtr->unk888.windowTopIndex += delta; structPtr->unk89C = 0; structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_PrintCheckPageInfo, 6); } diff --git a/src/pokenav_menu_handler_gfx.c b/src/pokenav_menu_handler_gfx.c index 1738142ac..b9dd13046 100644 --- a/src/pokenav_menu_handler_gfx.c +++ b/src/pokenav_menu_handler_gfx.c @@ -505,11 +505,11 @@ static u32 LoopedTask_OpenMenu(s32 state) ShowBg(2); ShowBg(3); if (gfx->pokenavAlreadyOpen) - PokenavFadeScreen(1); + PokenavFadeScreen(POKENAV_FADE_FROM_BLACK); else { PlaySE(SE_POKENAV_ON); - PokenavFadeScreen(3); + PokenavFadeScreen(POKENAV_FADE_FROM_BLACK_ALL); } switch (GetPokenavMenuType()) { @@ -779,7 +779,7 @@ static u32 LoopedTask_OpenPokenavFeature(s32 state) return LT_PAUSE; if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; - PokenavFadeScreen(0); + PokenavFadeScreen(POKENAV_FADE_TO_BLACK); return LT_INC_AND_PAUSE; case 3: if (IsPaletteFadeActive()) diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index 4ea3b3b19..4b9ff9f10 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -364,7 +364,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState) LoadLeftHeaderGfxForIndex(menuGfxId); ShowLeftHeaderGfx(menuGfxId, 1, 1); - PokenavFadeScreen(1); + PokenavFadeScreen(POKENAV_FADE_FROM_BLACK); return LT_INC_AND_PAUSE; case 7: if (IsPaletteFadeActive() || AreLeftHeaderSpritesMoving()) @@ -457,7 +457,7 @@ static u32 LoopedTask_ExitRegionMap(s32 taskState) { case 0: PlaySE(SE_SELECT); - PokenavFadeScreen(0); + PokenavFadeScreen(POKENAV_FADE_TO_BLACK); return LT_INC_AND_PAUSE; case 1: if (IsPaletteFadeActive()) diff --git a/src/pokenav_ribbons_list.c b/src/pokenav_ribbons_list.c index b5d412e12..9f4ea5d4a 100644 --- a/src/pokenav_ribbons_list.c +++ b/src/pokenav_ribbons_list.c @@ -460,7 +460,7 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state) ShowBg(2); HideBg(3); PrintHelpBarText(HELPBAR_RIBBONS_MON_LIST); - PokenavFadeScreen(1); + PokenavFadeScreen(POKENAV_FADE_FROM_BLACK); if (!menu->fromSummary) { LoadLeftHeaderGfxForIndex(POKENAV_GFX_RIBBONS_MENU); @@ -615,7 +615,7 @@ static u32 LoopedTask_RibbonsListReturnToMainMenu(s32 state) { case 0: PlaySE(SE_SELECT); - PokenavFadeScreen(0); + PokenavFadeScreen(POKENAV_FADE_TO_BLACK); SlideMenuHeaderDown(); return LT_INC_AND_PAUSE; case 1: @@ -635,7 +635,7 @@ static u32 LoopedTask_RibbonsListOpenSummary(s32 state) { case 0: PlaySE(SE_SELECT); - PokenavFadeScreen(0); + PokenavFadeScreen(POKENAV_FADE_TO_BLACK); return LT_INC_AND_PAUSE; case 1: if (IsPaletteFadeActive()) diff --git a/src/pokenav_ribbons_summary.c b/src/pokenav_ribbons_summary.c index a7a27ee31..c12f78ef5 100644 --- a/src/pokenav_ribbons_summary.c +++ b/src/pokenav_ribbons_summary.c @@ -638,7 +638,7 @@ static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state) ShowBg(1); ShowBg(2); HideBg(3); - PokenavFadeScreen(1); + PokenavFadeScreen(POKENAV_FADE_FROM_BLACK); return LT_INC_AND_PAUSE; } return LT_PAUSE; @@ -655,7 +655,7 @@ static u32 LoopedTask_ExitRibbonsSummaryMenu(s32 state) { case 0: PlaySE(SE_SELECT); - PokenavFadeScreen(0); + PokenavFadeScreen(POKENAV_FADE_TO_BLACK); return LT_INC_AND_PAUSE; case 1: if (IsPaletteFadeActive()) From 3b91d8fdaf2a1e13c4af938dfb867d407ccb280f Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 12 Nov 2021 20:24:14 -0500 Subject: [PATCH 11/19] Start pokenav list ui doc --- include/pokenav.h | 20 +++++++++---------- src/pokenav_conditions.c | 26 ++++++++++++------------- src/pokenav_conditions_search_results.c | 20 +++++++++---------- src/pokenav_match_call_1.c | 6 +++--- src/pokenav_match_call_2.c | 2 +- src/pokenav_match_call_ui.c | 9 ++++----- src/pokenav_ribbons_list.c | 22 ++++++++++----------- src/pokenav_ribbons_summary.c | 18 ++++++++--------- src/use_pokeblock.c | 2 +- 9 files changed, 62 insertions(+), 63 deletions(-) diff --git a/include/pokenav.h b/include/pokenav.h index ba9f1cbe9..254f9c7f7 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -7,14 +7,14 @@ typedef u32 (*LoopedTask)(s32 state); -struct PokenavMonList +struct PokenavMonListItem { u8 boxId; u8 monId; u16 data; }; -struct PokenavMatchCallEntries +struct PokenavMatchCallEntry { bool8 isSpecialTrainer; u8 mapSec; @@ -24,8 +24,8 @@ struct PokenavMatchCallEntries struct PokenavListTemplate { union { - struct PokenavMonList *monList; - struct PokenavMatchCallEntries *matchCallEntries; + struct PokenavMonListItem *monList; + struct PokenavMatchCallEntry *matchCallEntries; } list; u16 count; u16 unk6; @@ -37,17 +37,17 @@ struct PokenavListTemplate u8 fillValue; u8 fontId; union { - void (*printMonFunc)(struct PokenavMonList *item, u8 *dest); - void (*unk10_2)(struct PokenavMatchCallEntries *, u8 *a1); + void (*bufferMonItemFunc)(struct PokenavMonListItem *, u8 *); + void (*bufferMatchCallItemFunc)(struct PokenavMatchCallEntry *, u8 *); } listFunc; void (*unk14)(u16 a0, u32 a1, u32 a2); }; -struct PokenavSub18 +struct PokenavMonList { u16 listCount; u16 currIndex; - struct PokenavMonList monData[TOTAL_BOXES_COUNT * IN_BOX_COUNT + PARTY_SIZE]; + struct PokenavMonListItem monData[TOTAL_BOXES_COUNT * IN_BOX_COUNT + PARTY_SIZE]; }; // Return values of LoopedTask functions. @@ -406,7 +406,7 @@ void FreeMatchCallSubstruct1(void); int sub_81CAE28(void); int GetNumberRegistered(void); int sub_81CAE48(void); -struct PokenavMatchCallEntries *sub_81CAE94(void); +struct PokenavMatchCallEntry *sub_81CAE94(void); u16 GetMatchCallMapSec(int); bool32 ShouldDrawRematchPokeballIcon(int index); void ClearRematchPokeballIcon(u16 windowId, u32 a1); @@ -415,7 +415,7 @@ const u8 *GetMatchCallFlavorText(int index, int textType); const u8 *GetMatchCallMessageText(int index, u8 *arg1); u16 GetMatchCallOptionCursorPos(void); u16 GetMatchCallOptionId(int arg0); -void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntries * arg0, u8 *str); +void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntry * arg0, u8 *str); u8 GetMatchTableMapSectionId(int rematchIndex); int GetIndexDeltaOfNextCheckPageDown(int index); int GetIndexDeltaOfNextCheckPageUp(int index); diff --git a/src/pokenav_conditions.c b/src/pokenav_conditions.c index 6007acc2b..e61b11568 100644 --- a/src/pokenav_conditions.c +++ b/src/pokenav_conditions.c @@ -84,7 +84,7 @@ u32 GetConditionGraphMenuCallback(void) static u32 HandleConditionMenuInput(struct Pokenav_ConditionMenu *menu) { - struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); u32 ret = ConditionGraphHandleDpadInput(menu); if (ret == CONDITION_FUNC_NONE) @@ -123,7 +123,7 @@ static u32 HandleConditionMenuInput(struct Pokenav_ConditionMenu *menu) static u32 OpenMarkingsMenu(struct Pokenav_ConditionMenu *menu) { - struct PokenavSub18 *monListPtr; + struct PokenavMonList *monListPtr; u8 markings; u32 ret = CONDITION_FUNC_NONE, boxId, monId; @@ -166,7 +166,7 @@ void FreeConditionGraphMenuSubstruct1(void) static u8 ConditionGraphHandleDpadInput(struct Pokenav_ConditionMenu *menu) { - struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); u8 ret = CONDITION_FUNC_NONE; if (JOY_HELD(DPAD_UP)) @@ -196,7 +196,7 @@ static u8 SwitchConditionSummaryIndex(u8 moveUp) u16 newLoadId; bool8 wasNotLastMon, isNotLastMon; struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); - struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); newLoadId = (moveUp) ? menu->nextLoadIdUp : menu->nextLoadIdDown; ConditionGraph_SetNewPositions(&menu->graph, menu->graph.savedPositions[menu->loadId], menu->graph.savedPositions[newLoadId]); @@ -236,7 +236,7 @@ bool32 LoadConditionGraphMenuGfx(void) { s32 var; struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); - struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); switch (menu->state) { @@ -337,7 +337,7 @@ static u8 *CopyConditionMonNameGender(u8 *str, u16 listId, bool8 arg3) u16 boxId, monId, gender, species, level, lvlDigits; struct BoxPokemon *boxMon; u8 *txtPtr, *str_; - struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); boxId = monListPtr->monData[listId].boxId; monId = monListPtr->monData[listId].monId; @@ -427,7 +427,7 @@ static void CopyMonNameGenderLocation(s16 listId, u8 loadId) { u16 boxId, i; struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); - struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); if (listId != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1)) { @@ -459,7 +459,7 @@ static void InitPartyConditionListParameters(void) { u16 i, count; struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); - struct PokenavSub18 *monListPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18)); + struct PokenavMonList *monListPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavMonList)); menu->inSearchMode = FALSE; for (i = 0, count = 0; i < CalculatePlayerPartyCount(); i++) @@ -492,7 +492,7 @@ static void GetMonConditionGraphData(s16 listId, u8 loadId) { u16 boxId, monId, i; struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); - struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); if (listId != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1)) { @@ -524,7 +524,7 @@ static void ConditionGraphDrawMonPic(s16 listId, u8 loadId) u16 boxId, monId, species; u32 personality, tid; struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU); - struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); if (listId == (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1)) return; @@ -540,13 +540,13 @@ static void ConditionGraphDrawMonPic(s16 listId, u8 loadId) u16 GetMonListCount(void) { - struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); return monListPtr->listCount; } u16 GetConditionGraphCurrentListIndex(void) { - struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); return monListPtr->currIndex; } @@ -600,7 +600,7 @@ u8 *GetConditionMonLocationText(u8 loadId) u16 GetConditionMonDataBuffer(void) { - struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); return monListPtr->monData[monListPtr->currIndex].data; } diff --git a/src/pokenav_conditions_search_results.c b/src/pokenav_conditions_search_results.c index 770d0d01a..2151fdc42 100644 --- a/src/pokenav_conditions_search_results.c +++ b/src/pokenav_conditions_search_results.c @@ -31,7 +31,7 @@ struct Pokenav_SearchResults u32 conditionDataId; bool32 returnFromGraph; bool32 saveResultsList; - struct PokenavSub18 *monList; + struct PokenavMonList *monList; }; struct Pokenav_SearchResultsGfx @@ -58,13 +58,13 @@ static u32 LoopedTask_MoveSearchListPageUp(s32); static u32 LoopedTask_MoveSearchListPageDown(s32); static u32 LoopedTask_ExitConditionSearchMenu(s32); static u32 LoopedTask_SelectSearchResult(s32); -static void InsertMonListItem(struct Pokenav_SearchResults *, struct PokenavMonList *); +static void InsertMonListItem(struct Pokenav_SearchResults *, struct PokenavMonListItem *); static bool32 GetSearchResultCurrentLoopedTaskActive(void); static u32 LoopedTask_OpenConditionSearchResults(s32); static void AddSearchResultListMenuWindow(struct Pokenav_SearchResultsGfx *); static void PrintSearchResultListMenuItems(struct Pokenav_SearchResultsGfx *); static void InitConditionSearchListMenuTemplate(void); -static void PrintSearchMonListItem(struct PokenavMonList *, u8 *); +static void BufferSearchMonListItem(struct PokenavMonListItem *, u8 *); static const u32 sSearchMonDataIds[] = {MON_DATA_COOL, MON_DATA_BEAUTY, MON_DATA_CUTE, MON_DATA_SMART, MON_DATA_TOUGH}; @@ -134,7 +134,7 @@ bool32 PokenavCallback_Init_ConditionSearch(void) if (menu == NULL) return FALSE; - menu->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18)); + menu->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavMonList)); if (menu->monList == NULL) return FALSE; @@ -225,7 +225,7 @@ static u32 GetReturningFromGraph(void) return menu->returnFromGraph; } -static struct PokenavMonList * GetSearchResultsMonDataList(void) +static struct PokenavMonListItem * GetSearchResultsMonDataList(void) { struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); return menu->monList->monData; @@ -259,7 +259,7 @@ static u32 GetConditionSearchLoopedTask(s32 state) static u32 BuildPartyMonSearchResults(s32 state) { s32 i; - struct PokenavMonList item; + struct PokenavMonListItem item; struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); menu->monList->listCount = 0; @@ -295,7 +295,7 @@ static u32 BuildBoxMonSearchResults(s32 state) s32 boxId = menu->boxId; s32 monId = menu->monId; s32 boxCount = 0; - struct PokenavMonList item; + struct PokenavMonListItem item; while (boxId < TOTAL_BOXES_COUNT) { @@ -351,7 +351,7 @@ static u32 ConvertConditionsToListRanks(s32 state) return LT_FINISH; } -static void InsertMonListItem(struct Pokenav_SearchResults *menu, struct PokenavMonList *item) +static void InsertMonListItem(struct Pokenav_SearchResults *menu, struct PokenavMonListItem *item) { u32 left = 0; u32 right = menu->monList->listCount; @@ -682,12 +682,12 @@ static void InitConditionSearchListMenuTemplate(void) template.maxShowed = 8; template.fillValue = 2; template.fontId = FONT_NORMAL; - template.listFunc.printMonFunc = PrintSearchMonListItem; + template.listFunc.bufferMonItemFunc = BufferSearchMonListItem; template.unk14 = NULL; sub_81C81D4(&sConditionSearchResultBgTemplates[1], &template, 0); } -static void PrintSearchMonListItem(struct PokenavMonList * item, u8 * dest) +static void BufferSearchMonListItem(struct PokenavMonListItem * item, u8 * dest) { u8 gender; u8 level; diff --git a/src/pokenav_match_call_1.c b/src/pokenav_match_call_1.c index 63b8fcbf5..65698c344 100755 --- a/src/pokenav_match_call_1.c +++ b/src/pokenav_match_call_1.c @@ -25,7 +25,7 @@ struct Pokenav3Struct u32 unk10; u32 unk14; u32 (*callback)(struct Pokenav3Struct*); - struct PokenavMatchCallEntries matchCallEntries[MAX_REMATCH_ENTRIES - 1]; + struct PokenavMatchCallEntry matchCallEntries[MAX_REMATCH_ENTRIES - 1]; }; static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *); @@ -298,7 +298,7 @@ int unref_sub_81CAE6C(int arg0) return state->matchCallEntries[arg0].headerId; } -struct PokenavMatchCallEntries *sub_81CAE94(void) +struct PokenavMatchCallEntry *sub_81CAE94(void) { struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->matchCallEntries; @@ -394,7 +394,7 @@ u16 GetMatchCallOptionId(int optionId) return state->matchCallOptions[optionId]; } -void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntries *matchCallEntry, u8 *str) +void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntry *matchCallEntry, u8 *str) { const u8 *trainerName; const u8 *className; diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index e91257d14..ae900c61d 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -880,7 +880,7 @@ static void InitMatchCallPokenavListMenuTemplate(void) template.maxShowed = 8; template.fillValue = 3; template.fontId = FONT_NARROW; - template.listFunc.unk10_2 = BufferMatchCallNameAndDesc; + template.listFunc.bufferMatchCallItemFunc = BufferMatchCallNameAndDesc; template.unk14 = TryDrawRematchPokeballIcon; sub_81C81D4(&sMatchCallBgTemplates[2], &template, 2); CreateTask(Task_FlashPokeballIcons, 7); diff --git a/src/pokenav_match_call_ui.c b/src/pokenav_match_call_ui.c index 83720f4cf..2cf6bf24e 100644 --- a/src/pokenav_match_call_ui.c +++ b/src/pokenav_match_call_ui.c @@ -49,7 +49,7 @@ struct PokenavSub17Substruct u32 loopedTaskId; s32 unk2C; u32 unk30; - void (*unk34)(struct PokenavMatchCallEntries *, u8*); + void (*unk34)(struct PokenavMatchCallEntry *, u8*); void (*unk38)(u16, u32, u32); struct Sprite *rightArrow; struct Sprite *upArrow; @@ -57,7 +57,6 @@ struct PokenavSub17Substruct u8 unkTextBuffer[0x40]; }; -// Generally at index 0x11 (17) struct PokenavSub17 { struct PokenavSub17Substruct list; @@ -68,7 +67,7 @@ struct PokenavSub17 }; void sub_81C82E4(struct PokenavSub17 *matchCall); -bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *a0, const struct BgTemplate *a1, struct PokenavListTemplate *a2, s32 a3); +static bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *a0, const struct BgTemplate *a1, struct PokenavListTemplate *a2, s32 a3); void InitMatchCallWindowState(struct MatchCallWindowState *a0, struct PokenavListTemplate *a1); void SpriteCB_MatchCallUpArrow(struct Sprite *sprite); void SpriteCB_MatchCallDownArrow(struct Sprite *sprite); @@ -963,13 +962,13 @@ void InitMatchCallWindowState(struct MatchCallWindowState *dst, struct PokenavLi } } -bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *dest, const struct BgTemplate *bgTemplate, struct PokenavListTemplate *template, s32 a3) +static bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *dest, const struct BgTemplate *bgTemplate, struct PokenavListTemplate *template, s32 a3) { struct WindowTemplate window; dest->listWindow.bg = bgTemplate->bg; dest->listWindow.unk6 = a3; - dest->unk34 = template->listFunc.unk10_2; + dest->unk34 = template->listFunc.bufferMatchCallItemFunc; dest->unk38 = template->unk14; dest->listWindow.unk1 = template->fillValue; dest->listWindow.unk2 = template->item_X; diff --git a/src/pokenav_ribbons_list.c b/src/pokenav_ribbons_list.c index 9f4ea5d4a..c07460bee 100644 --- a/src/pokenav_ribbons_list.c +++ b/src/pokenav_ribbons_list.c @@ -29,7 +29,7 @@ struct Pokenav_RibbonsMonList s32 monId; u32 changeBgs; u32 saveMonList; - struct PokenavSub18 *monList; + struct PokenavMonList *monList; }; struct Pokenav_RibbonsMonMenu @@ -49,7 +49,7 @@ static u32 BuildPartyMonRibbonList(s32); static u32 InitBoxMonRibbonList(s32); static u32 BuildBoxMonRibbonList(s32); static u32 GetMonRibbonListLoopTaskFunc(s32); -static void InsertMonListItem(struct Pokenav_RibbonsMonList *, struct PokenavMonList *); +static void InsertMonListItem(struct Pokenav_RibbonsMonList *, struct PokenavMonListItem *); static u32 LoopedTask_OpenRibbonsMonList(s32); static bool32 GetRibbonsMonCurrentLoopedTaskActive(void); static u32 LoopedTask_RibbonsListMoveCursorUp(s32); @@ -62,7 +62,7 @@ static void DrawListIndexNumber(s32, s32, s32); static void AddRibbonsMonListWindow(struct Pokenav_RibbonsMonMenu *); static void UpdateIndexNumberDisplay(struct Pokenav_RibbonsMonMenu *); static void InitMonRibbonPokenavListMenuTemplate(void); -static void BufferRibbonMonInfoText(struct PokenavMonList *, u8 *); +static void BufferRibbonMonInfoText(struct PokenavMonListItem *, u8 *); static const LoopedTask sMonRibbonListLoopTaskFuncs[] = { @@ -129,7 +129,7 @@ bool32 PokenavCallback_Init_MonRibbonList(void) if (list == NULL) return FALSE; - list->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18)); + list->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavMonList)); if (list->monList == NULL) return FALSE; @@ -214,7 +214,7 @@ static u32 UpdateMonListBgs(void) return list->changeBgs; } -static struct PokenavMonList *GetMonRibbonMonListData(void) +static struct PokenavMonListItem *GetMonRibbonMonListData(void) { struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); return list->monList->monData; @@ -248,7 +248,7 @@ static u32 GetMonRibbonListLoopTaskFunc(s32 state) static u32 BuildPartyMonRibbonList(s32 state) { s32 i; - struct PokenavMonList item; + struct PokenavMonListItem item; struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); list->monList->listCount = 0; @@ -288,7 +288,7 @@ static u32 BuildBoxMonRibbonList(s32 state) s32 boxId = list->boxId; s32 monId = list->monId; s32 boxCount = 0; - struct PokenavMonList item; + struct PokenavMonListItem item; while (boxId < TOTAL_BOXES_COUNT) { @@ -322,7 +322,7 @@ static u32 BuildBoxMonRibbonList(s32 state) return LT_FINISH; } -static void InsertMonListItem(struct Pokenav_RibbonsMonList *list, struct PokenavMonList *item) +static void InsertMonListItem(struct Pokenav_RibbonsMonList *list, struct PokenavMonListItem *item) { u32 left = 0; u32 right = list->monList->listCount; @@ -690,19 +690,19 @@ static void InitMonRibbonPokenavListMenuTemplate(void) template.maxShowed = 8; template.fillValue = 2; template.fontId = FONT_NORMAL; - template.listFunc.printMonFunc = BufferRibbonMonInfoText; + template.listFunc.bufferMonItemFunc = BufferRibbonMonInfoText; template.unk14 = NULL; sub_81C81D4(&sMonRibbonListBgTemplates[1], &template, 0); } // Buffers the "Nickname gender/level" text for the ribbon mon list -static void BufferRibbonMonInfoText(struct PokenavMonList * item0, u8 * dest) +static void BufferRibbonMonInfoText(struct PokenavMonListItem * item0, u8 * dest) { u8 gender; u8 level; u8 * s; const u8 * genderStr; - struct PokenavMonList * item = item0; + struct PokenavMonListItem * item = item0; // Mon is in party if (item->boxId == TOTAL_BOXES_COUNT) diff --git a/src/pokenav_ribbons_summary.c b/src/pokenav_ribbons_summary.c index c12f78ef5..81d5b900b 100644 --- a/src/pokenav_ribbons_summary.c +++ b/src/pokenav_ribbons_summary.c @@ -42,7 +42,7 @@ enum struct Pokenav_RibbonsSummaryList { u8 unused1[8]; - struct PokenavSub18 *monList; + struct PokenavMonList *monList; u16 selectedPos; u16 normalRibbonLastRowStart; u16 numNormalRibbons; @@ -378,8 +378,8 @@ static u32 GetRibbonsSummaryMonListCount(void) static void GetMonNicknameLevelGender(u8 *nick, u8 *level, u8 *gender) { struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); - struct PokenavSub18 *mons = list->monList; - struct PokenavMonList *monInfo = &mons->monData[mons->currIndex]; + struct PokenavMonList *mons = list->monList; + struct PokenavMonListItem *monInfo = &mons->monData[mons->currIndex]; if (monInfo->boxId == TOTAL_BOXES_COUNT) { @@ -403,8 +403,8 @@ static void GetMonNicknameLevelGender(u8 *nick, u8 *level, u8 *gender) static void GetMonSpeciesPersonalityOtId(u16 *species, u32 *personality, u32 *otId) { struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); - struct PokenavSub18 *mons = list->monList; - struct PokenavMonList *monInfo = &mons->monData[mons->currIndex]; + struct PokenavMonList *mons = list->monList; + struct PokenavMonListItem *monInfo = &mons->monData[mons->currIndex]; if (monInfo->boxId == TOTAL_BOXES_COUNT) { @@ -427,8 +427,8 @@ static void GetMonSpeciesPersonalityOtId(u16 *species, u32 *personality, u32 *ot static u32 GetCurrMonRibbonCount(void) { struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); - struct PokenavSub18 *mons = list->monList; - struct PokenavMonList *monInfo = &mons->monData[mons->currIndex]; + struct PokenavMonList *mons = list->monList; + struct PokenavMonListItem *monInfo = &mons->monData[mons->currIndex]; if (monInfo->boxId == TOTAL_BOXES_COUNT) return GetMonData(&gPlayerParty[monInfo->monId], MON_DATA_RIBBON_COUNT); @@ -440,8 +440,8 @@ static void GetMonRibbons(struct Pokenav_RibbonsSummaryList *list) { u32 ribbonFlags; s32 i, j; - struct PokenavSub18 *mons = list->monList; - struct PokenavMonList *monInfo = &mons->monData[mons->currIndex]; + struct PokenavMonList *mons = list->monList; + struct PokenavMonListItem *monInfo = &mons->monData[mons->currIndex]; if (monInfo->boxId == TOTAL_BOXES_COUNT) ribbonFlags = GetMonData(&gPlayerParty[monInfo->monId], MON_DATA_RIBBONS); diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index ef5fdfaf5..312e2107e 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -73,7 +73,7 @@ struct UsePokeblockSession u8 natureText[34]; }; -// This struct is identical to PokenavMonList, the struct used for managing lists of pokemon in the pokenav +// This struct is identical to PokenavMonListItem, the struct used for managing lists of pokemon in the pokenav // Given that this screen is essentially duplicated in the poknav, this struct was probably the same one with // a more general name/purpose // TODO: Once the pokenav conditions screens are documented, resolve the above From ec051575683a781d912ded5837936f409057539e Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 13 Nov 2021 11:27:11 -0500 Subject: [PATCH 12/19] Move pokenav list item union out of list struct --- include/pokenav.h | 19 +++++++++++-------- src/pokenav_conditions_search_results.c | 4 ++-- src/pokenav_match_call_2.c | 4 ++-- src/pokenav_match_call_ui.c | 6 +++--- src/pokenav_ribbons_list.c | 4 ++-- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/include/pokenav.h b/include/pokenav.h index 254f9c7f7..68c33bf7c 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -6,6 +6,7 @@ #include "pokemon_storage_system.h" typedef u32 (*LoopedTask)(s32 state); +typedef void (*PokenavListItemBufferFunc)(struct PokenavListItem *, u8 *); struct PokenavMonListItem { @@ -21,12 +22,17 @@ struct PokenavMatchCallEntry u16 headerId; }; -struct PokenavListTemplate +struct PokenavListItem { union { - struct PokenavMonListItem *monList; - struct PokenavMatchCallEntry *matchCallEntries; - } list; + struct PokenavMonListItem mon; + struct PokenavMatchCallEntry call; + } item; +}; + +struct PokenavListTemplate +{ + struct PokenavListItem * list; u16 count; u16 unk6; u8 unk8; @@ -36,10 +42,7 @@ struct PokenavListTemplate u8 maxShowed; u8 fillValue; u8 fontId; - union { - void (*bufferMonItemFunc)(struct PokenavMonListItem *, u8 *); - void (*bufferMatchCallItemFunc)(struct PokenavMatchCallEntry *, u8 *); - } listFunc; + PokenavListItemBufferFunc bufferItemFunc; void (*unk14)(u16 a0, u32 a1, u32 a2); }; diff --git a/src/pokenav_conditions_search_results.c b/src/pokenav_conditions_search_results.c index 2151fdc42..c58b22ecf 100644 --- a/src/pokenav_conditions_search_results.c +++ b/src/pokenav_conditions_search_results.c @@ -672,7 +672,7 @@ static void InitConditionSearchListMenuTemplate(void) { struct PokenavListTemplate template; - template.list.monList = GetSearchResultsMonDataList(); + template.list = (struct PokenavListItem *)GetSearchResultsMonDataList(); template.count = GetSearchResultsMonListCount(); template.unk8 = 4; template.unk6 = GetSearchResultsCurrentListIndex(); @@ -682,7 +682,7 @@ static void InitConditionSearchListMenuTemplate(void) template.maxShowed = 8; template.fillValue = 2; template.fontId = FONT_NORMAL; - template.listFunc.bufferMonItemFunc = BufferSearchMonListItem; + template.bufferItemFunc = (PokenavListItemBufferFunc)BufferSearchMonListItem; template.unk14 = NULL; sub_81C81D4(&sConditionSearchResultBgTemplates[1], &template, 0); } diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index ae900c61d..5f5792504 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -870,7 +870,7 @@ static u32 ExitMatchCall(s32 state) static void InitMatchCallPokenavListMenuTemplate(void) { struct PokenavListTemplate template; - template.list.matchCallEntries = sub_81CAE94(); + template.list = (struct PokenavListItem *)sub_81CAE94(); template.count = GetNumberRegistered(); template.unk8 = 4; template.unk6 = 0; @@ -880,7 +880,7 @@ static void InitMatchCallPokenavListMenuTemplate(void) template.maxShowed = 8; template.fillValue = 3; template.fontId = FONT_NARROW; - template.listFunc.bufferMatchCallItemFunc = BufferMatchCallNameAndDesc; + template.bufferItemFunc = (PokenavListItemBufferFunc)BufferMatchCallNameAndDesc; template.unk14 = TryDrawRematchPokeballIcon; sub_81C81D4(&sMatchCallBgTemplates[2], &template, 2); CreateTask(Task_FlashPokeballIcons, 7); diff --git a/src/pokenav_match_call_ui.c b/src/pokenav_match_call_ui.c index 2cf6bf24e..8392b613c 100644 --- a/src/pokenav_match_call_ui.c +++ b/src/pokenav_match_call_ui.c @@ -49,7 +49,7 @@ struct PokenavSub17Substruct u32 loopedTaskId; s32 unk2C; u32 unk30; - void (*unk34)(struct PokenavMatchCallEntry *, u8*); + PokenavListItemBufferFunc unk34; void (*unk38)(u16, u32, u32); struct Sprite *rightArrow; struct Sprite *upArrow; @@ -936,7 +936,7 @@ void ToggleMatchCallVerticalArrows(bool32 shouldHide) void InitMatchCallWindowState(struct MatchCallWindowState *dst, struct PokenavListTemplate *template) { - dst->unk10 = template->list.matchCallEntries; + dst->unk10 = template->list; dst->windowTopIndex = template->unk6; dst->listLength = template->count; dst->unkC = template->unk8; @@ -968,7 +968,7 @@ static bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *dest, co dest->listWindow.bg = bgTemplate->bg; dest->listWindow.unk6 = a3; - dest->unk34 = template->listFunc.bufferMatchCallItemFunc; + dest->unk34 = template->bufferItemFunc; dest->unk38 = template->unk14; dest->listWindow.unk1 = template->fillValue; dest->listWindow.unk2 = template->item_X; diff --git a/src/pokenav_ribbons_list.c b/src/pokenav_ribbons_list.c index c07460bee..4233819a3 100644 --- a/src/pokenav_ribbons_list.c +++ b/src/pokenav_ribbons_list.c @@ -680,7 +680,7 @@ static void DrawListIndexNumber(s32 windowId, s32 index, s32 max) static void InitMonRibbonPokenavListMenuTemplate(void) { struct PokenavListTemplate template; - template.list.monList = GetMonRibbonMonListData(); + template.list = (struct PokenavListItem *)GetMonRibbonMonListData(); template.count = GetRibbonsMonListCount(); template.unk8 = 4; template.unk6 = GetRibbonListMenuCurrIndex(); @@ -690,7 +690,7 @@ static void InitMonRibbonPokenavListMenuTemplate(void) template.maxShowed = 8; template.fillValue = 2; template.fontId = FONT_NORMAL; - template.listFunc.bufferMonItemFunc = BufferRibbonMonInfoText; + template.bufferItemFunc = (PokenavListItemBufferFunc)BufferRibbonMonInfoText; template.unk14 = NULL; sub_81C81D4(&sMonRibbonListBgTemplates[1], &template, 0); } From b3e593dff5cf8f062afe5b03bb38937f5c23f4ec Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 13 Nov 2021 12:52:41 -0500 Subject: [PATCH 13/19] Continue pokenav list ui doc --- include/pokenav.h | 35 +- src/match_call.c | 6 +- src/pokenav_conditions_search_results.c | 36 +- src/pokenav_match_call_1.c | 6 +- src/pokenav_match_call_2.c | 54 +- src/pokenav_match_call_ui.c | 642 ++++++++++++------------ src/pokenav_ribbons_list.c | 42 +- 7 files changed, 419 insertions(+), 402 deletions(-) diff --git a/include/pokenav.h b/include/pokenav.h index 68c33bf7c..9c530e11e 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -6,7 +6,6 @@ #include "pokemon_storage_system.h" typedef u32 (*LoopedTask)(s32 state); -typedef void (*PokenavListItemBufferFunc)(struct PokenavListItem *, u8 *); struct PokenavMonListItem { @@ -30,20 +29,22 @@ struct PokenavListItem } item; }; +typedef void (*PokenavListBufferItemFunc)(struct PokenavListItem *, u8 *); + struct PokenavListTemplate { struct PokenavListItem * list; u16 count; - u16 unk6; - u8 unk8; + u16 startIndex; + u8 itemSize; u8 item_X; u8 windowWidth; u8 listTop; u8 maxShowed; u8 fillValue; u8 fontId; - PokenavListItemBufferFunc bufferItemFunc; - void (*unk14)(u16 a0, u32 a1, u32 a2); + PokenavListBufferItemFunc bufferItemFunc; + void (*iconDrawFunc)(u16 windowId, u32 listItemId, u32 baseTile); }; struct PokenavMonList @@ -87,7 +88,7 @@ enum POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU, POKENAV_SUBSTRUCT_UNUSED, POKENAV_SUBSTRUCT_REGION_MAP, - POKENAV_SUBSTRUCT_MATCH_CALL_LIST, + POKENAV_SUBSTRUCT_LIST, POKENAV_SUBSTRUCT_MON_LIST, POKENAV_SUBSTRUCT_COUNT, }; @@ -323,22 +324,22 @@ void SetPokenavVBlankCallback(void); void SetVBlankCallback_(IntrCallback callback); // pokenav_match_call_ui.c +bool32 CreatePokenavList(const struct BgTemplate *bgTemplate, struct PokenavListTemplate *listTemplate, s32 tileOffset); +bool32 IsCreatePokenavListTaskActive(void); +void DestroyPokenavList(void); u32 GetSelectedPokenavListIndex(void); -bool32 sub_81C8224(void); -int MatchCall_MoveCursorUp(void); -int MatchCall_MoveCursorDown(void); -int MatchCall_PageDown(void); -int MatchCall_PageUp(void); -bool32 IsMonListLoopedTaskActive(void); -void ToggleMatchCallVerticalArrows(bool32 shouldHide); -void sub_81C8838(void); +int PokenavList_MoveCursorUp(void); +int PokenavList_MoveCursorDown(void); +int PokenavList_PageDown(void); +int PokenavList_PageUp(void); +bool32 IsMovePokenavListWindowTaskActive(void); +void PokenavList_ToggleVerticalArrows(bool32 shouldHide); +void PokenavList_DrawCurrentItemIcon(void); void sub_81C877C(void); bool32 IsMatchCallListTaskActive(void); void PrintCheckPageInfo(s16 a0); u32 GetMatchCallListTopIndex(void); void sub_81C87F0(void); -bool32 sub_81C81D4(const struct BgTemplate *arg0, struct PokenavListTemplate *arg1, s32 arg2); -void sub_81C8234(void); // pokenav_match_call_data.c bool32 MatchCall_HasCheckPage(u32 idx); @@ -415,7 +416,7 @@ bool32 ShouldDrawRematchPokeballIcon(int index); void ClearRematchPokeballIcon(u16 windowId, u32 a1); int GetMatchCallTrainerPic(int index); const u8 *GetMatchCallFlavorText(int index, int textType); -const u8 *GetMatchCallMessageText(int index, u8 *arg1); +const u8 *GetMatchCallMessageText(int index, bool8 *newRematchRequest); u16 GetMatchCallOptionCursorPos(void); u16 GetMatchCallOptionId(int arg0); void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntry * arg0, u8 *str); diff --git a/src/match_call.c b/src/match_call.c index 0595ad3e3..85df5822d 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -1499,7 +1499,7 @@ bool32 SelectMatchCallMessage(int trainerId, u8 *str) { u32 matchCallId; const struct MatchCallText *matchCallText; - bool32 retVal = FALSE; + bool32 newRematchRequest = FALSE; matchCallId = GetTrainerMatchCallId(trainerId); sBattleFrontierStreakInfo.facilityId = 0; @@ -1517,7 +1517,7 @@ bool32 SelectMatchCallMessage(int trainerId, u8 *str) else if (ShouldTrainerRequestBattle(matchCallId)) { matchCallText = GetDifferentRouteMatchCallText(matchCallId, str); - retVal = TRUE; + newRematchRequest = TRUE; UpdateRematchIfDefeated(matchCallId); } else if (Random() % 3) @@ -1532,7 +1532,7 @@ bool32 SelectMatchCallMessage(int trainerId, u8 *str) } BuildMatchCallString(matchCallId, matchCallText, str); - return retVal; + return newRematchRequest; } static int GetTrainerMatchCallId(int trainerId) diff --git a/src/pokenav_conditions_search_results.c b/src/pokenav_conditions_search_results.c index c58b22ecf..09bb7c9ac 100644 --- a/src/pokenav_conditions_search_results.c +++ b/src/pokenav_conditions_search_results.c @@ -63,7 +63,7 @@ static bool32 GetSearchResultCurrentLoopedTaskActive(void); static u32 LoopedTask_OpenConditionSearchResults(s32); static void AddSearchResultListMenuWindow(struct Pokenav_SearchResultsGfx *); static void PrintSearchResultListMenuItems(struct Pokenav_SearchResultsGfx *); -static void InitConditionSearchListMenuTemplate(void); +static void CreateSearchResultsList(void); static void BufferSearchMonListItem(struct PokenavMonListItem *, u8 *); static const u32 sSearchMonDataIds[] = {MON_DATA_COOL, MON_DATA_BEAUTY, MON_DATA_CUTE, MON_DATA_SMART, MON_DATA_TOUGH}; @@ -415,7 +415,7 @@ bool32 GetSearchResultCurrentLoopedTaskActive(void) void FreeSearchResultSubstruct2(void) { struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX); - sub_81C8234(); + DestroyPokenavList(); RemoveWindow(gfx->winid); FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX); } @@ -444,10 +444,10 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state) if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; CopyPaletteIntoBufferUnfaded(sListBg_Pal, 0x20, 32); - InitConditionSearchListMenuTemplate(); + CreateSearchResultsList(); return LT_INC_AND_PAUSE; case 3: - if (sub_81C8224()) + if (IsCreatePokenavListTaskActive()) return LT_PAUSE; AddSearchResultListMenuWindow(gfx); PrintHelpBarText(HELPBAR_CONDITION_MON_LIST); @@ -485,7 +485,7 @@ static u32 LoopedTask_MoveSearchListCursorUp(s32 state) switch (state) { case 0: - switch (MatchCall_MoveCursorUp()) + switch (PokenavList_MoveCursorUp()) { case 0: return LT_FINISH; @@ -498,7 +498,7 @@ static u32 LoopedTask_MoveSearchListCursorUp(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMonListLoopedTaskActive()) + if (IsMovePokenavListWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -518,7 +518,7 @@ static u32 LoopedTask_MoveSearchListCursorDown(s32 state) switch (state) { case 0: - switch (MatchCall_MoveCursorDown()) + switch (PokenavList_MoveCursorDown()) { case 0: return LT_FINISH; @@ -531,7 +531,7 @@ static u32 LoopedTask_MoveSearchListCursorDown(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMonListLoopedTaskActive()) + if (IsMovePokenavListWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -551,7 +551,7 @@ static u32 LoopedTask_MoveSearchListPageUp(s32 state) switch (state) { case 0: - switch (MatchCall_PageUp()) + switch (PokenavList_PageUp()) { case 0: return LT_FINISH; @@ -564,7 +564,7 @@ static u32 LoopedTask_MoveSearchListPageUp(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMonListLoopedTaskActive()) + if (IsMovePokenavListWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -584,7 +584,7 @@ static u32 LoopedTask_MoveSearchListPageDown(s32 state) switch (state) { case 0: - switch (MatchCall_PageDown()) + switch (PokenavList_PageDown()) { case 0: return LT_FINISH; @@ -597,7 +597,7 @@ static u32 LoopedTask_MoveSearchListPageDown(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMonListLoopedTaskActive()) + if (IsMovePokenavListWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -668,23 +668,23 @@ static void PrintSearchResultListMenuItems(struct Pokenav_SearchResultsGfx *gfx) CopyWindowToVram(gfx->winid, COPYWIN_GFX); } -static void InitConditionSearchListMenuTemplate(void) +static void CreateSearchResultsList(void) { struct PokenavListTemplate template; template.list = (struct PokenavListItem *)GetSearchResultsMonDataList(); template.count = GetSearchResultsMonListCount(); - template.unk8 = 4; - template.unk6 = GetSearchResultsCurrentListIndex(); + template.itemSize = sizeof(struct PokenavListItem); + template.startIndex = GetSearchResultsCurrentListIndex(); template.item_X = 13; template.windowWidth = 17; template.listTop = 1; template.maxShowed = 8; template.fillValue = 2; template.fontId = FONT_NORMAL; - template.bufferItemFunc = (PokenavListItemBufferFunc)BufferSearchMonListItem; - template.unk14 = NULL; - sub_81C81D4(&sConditionSearchResultBgTemplates[1], &template, 0); + template.bufferItemFunc = (PokenavListBufferItemFunc)BufferSearchMonListItem; + template.iconDrawFunc = NULL; + CreatePokenavList(&sConditionSearchResultBgTemplates[1], &template, 0); } static void BufferSearchMonListItem(struct PokenavMonListItem * item, u8 * dest) diff --git a/src/pokenav_match_call_1.c b/src/pokenav_match_call_1.c index 65698c344..b2b9179c3 100755 --- a/src/pokenav_match_call_1.c +++ b/src/pokenav_match_call_1.c @@ -346,15 +346,15 @@ int GetMatchCallTrainerPic(int index) return gFacilityClassToPicIndex[index]; } -const u8 *GetMatchCallMessageText(int index, u8 *arg1) +const u8 *GetMatchCallMessageText(int index, bool8 *newRematchRequest) { struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); - *arg1 = 0; + *newRematchRequest = FALSE; if (!Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType)) return gText_CallCantBeMadeHere; if (!state->matchCallEntries[index].isSpecialTrainer) - *arg1 = SelectMatchCallMessage(GetTrainerIdxByRematchIdx(state->matchCallEntries[index].headerId), gStringVar4); + *newRematchRequest = SelectMatchCallMessage(GetTrainerIdxByRematchIdx(state->matchCallEntries[index].headerId), gStringVar4); else MatchCall_GetMessage(state->matchCallEntries[index].headerId, gStringVar4); diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index 5f5792504..420dac5f8 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -35,7 +35,7 @@ struct Pokenav_MatchCallGfx u32 loopTaskId; u8 filler8[6]; bool8 unkE; - u8 unkF; + bool8 newRematchRequest; u16 locWindowId; u16 infoBoxWindowId; u16 msgBoxWindowId; @@ -55,7 +55,7 @@ struct Pokenav_MatchCallGfx static bool32 GetCurrentLoopedTaskActive(void); static u32 LoopedTask_OpenMatchCall(s32); -static void InitMatchCallPokenavListMenuTemplate(void); +static void CreateMatchCallList(void); static void sub_81CBC1C(void); static void FreeMatchCallSprites(void); static void LoadCallWindowAndFade(struct Pokenav_MatchCallGfx *); @@ -359,10 +359,10 @@ static u32 LoopedTask_OpenMatchCall(s32 state) if (FreeTempTileDataBuffersIfPossible() || !sub_81CAE28()) return LT_PAUSE; - InitMatchCallPokenavListMenuTemplate(); + CreateMatchCallList(); return LT_INC_AND_PAUSE; case 4: - if (sub_81C8224()) + if (IsCreatePokenavListTaskActive()) return LT_PAUSE; DrawMatchCallLeftColumnWindows(gfx); @@ -399,7 +399,7 @@ static u32 MatchCallListCursorDown(s32 state) switch (state) { case 0: - switch (MatchCall_MoveCursorDown()) + switch (PokenavList_MoveCursorDown()) { case 0: break; @@ -414,7 +414,7 @@ static u32 MatchCallListCursorDown(s32 state) } break; case 1: - if (IsMonListLoopedTaskActive()) + if (IsMovePokenavListWindowTaskActive()) return LT_PAUSE; PrintMatchCallLocation(gfx, 0); @@ -436,7 +436,7 @@ static u32 MatchCallListCursorUp(s32 state) switch (state) { case 0: - switch (MatchCall_MoveCursorUp()) + switch (PokenavList_MoveCursorUp()) { case 0: break; @@ -451,7 +451,7 @@ static u32 MatchCallListCursorUp(s32 state) } break; case 1: - if (IsMonListLoopedTaskActive()) + if (IsMovePokenavListWindowTaskActive()) return LT_PAUSE; PrintMatchCallLocation(gfx, 0); @@ -473,7 +473,7 @@ static u32 MatchCallListPageDown(s32 state) switch (state) { case 0: - switch (MatchCall_PageDown()) + switch (PokenavList_PageDown()) { case 0: break; @@ -488,7 +488,7 @@ static u32 MatchCallListPageDown(s32 state) } break; case 1: - if (IsMonListLoopedTaskActive()) + if (IsMovePokenavListWindowTaskActive()) return LT_PAUSE; PrintMatchCallLocation(gfx, 0); @@ -510,7 +510,7 @@ static u32 MatchCallListPageUp(s32 state) switch (state) { case 0: - switch (MatchCall_PageUp()) + switch (PokenavList_PageUp()) { case 0: break; @@ -525,7 +525,7 @@ static u32 MatchCallListPageUp(s32 state) } break; case 1: - if (IsMonListLoopedTaskActive()) + if (IsMovePokenavListWindowTaskActive()) return LT_PAUSE; PrintMatchCallLocation(gfx, 0); @@ -597,7 +597,7 @@ static u32 DoMatchCallMessage(s32 state) switch (state) { case 0: - ToggleMatchCallVerticalArrows(TRUE); + PokenavList_ToggleVerticalArrows(TRUE); DrawMsgBoxForMatchCallMsg(gfx); return LT_INC_AND_PAUSE; case 1: @@ -631,7 +631,7 @@ static u32 DoTrainerCloseByMessage(s32 state) case 0: PlaySE(SE_SELECT); DrawMsgBoxForCloseByMsg(gfx); - ToggleMatchCallVerticalArrows(TRUE); + PokenavList_ToggleVerticalArrows(TRUE); gfx->unkE = 1; return LT_INC_AND_PAUSE; case 1: @@ -685,14 +685,16 @@ static u32 CloseMatchCallMessage(s32 state) } else { - if (gfx->unkF) + if (gfx->newRematchRequest) { - sub_81C8838(); + // This call was a new rematch request, + // add the Pokéball icon to their entry + PokenavList_DrawCurrentItemIcon(); result = LT_INC_AND_CONTINUE; } else { - ToggleMatchCallVerticalArrows(FALSE); + PokenavList_ToggleVerticalArrows(FALSE); result = LT_FINISH; } } @@ -704,7 +706,7 @@ static u32 CloseMatchCallMessage(s32 state) } else { - ToggleMatchCallVerticalArrows(FALSE); + PokenavList_ToggleVerticalArrows(FALSE); result = LT_FINISH; } break; @@ -867,28 +869,28 @@ static u32 ExitMatchCall(s32 state) return LT_FINISH; } -static void InitMatchCallPokenavListMenuTemplate(void) +static void CreateMatchCallList(void) { struct PokenavListTemplate template; template.list = (struct PokenavListItem *)sub_81CAE94(); template.count = GetNumberRegistered(); - template.unk8 = 4; - template.unk6 = 0; + template.itemSize = sizeof(struct PokenavListItem); + template.startIndex = 0; template.item_X = 13; template.windowWidth = 16; template.listTop = 1; template.maxShowed = 8; template.fillValue = 3; template.fontId = FONT_NARROW; - template.bufferItemFunc = (PokenavListItemBufferFunc)BufferMatchCallNameAndDesc; - template.unk14 = TryDrawRematchPokeballIcon; - sub_81C81D4(&sMatchCallBgTemplates[2], &template, 2); + template.bufferItemFunc = (PokenavListBufferItemFunc)BufferMatchCallNameAndDesc; + template.iconDrawFunc = TryDrawRematchPokeballIcon; + CreatePokenavList(&sMatchCallBgTemplates[2], &template, 2); CreateTask(Task_FlashPokeballIcons, 7); } static void sub_81CBC1C(void) { - sub_81C8234(); + DestroyPokenavList(); DestroyTask(FindTaskIdByFunc(Task_FlashPokeballIcons)); } @@ -1137,7 +1139,7 @@ static bool32 WaitForTrainerIsCloseByText(struct Pokenav_MatchCallGfx *gfx) static void PrintMatchCallMessage(struct Pokenav_MatchCallGfx *gfx) { int index = GetSelectedPokenavListIndex(); - const u8 *str = GetMatchCallMessageText(index, &gfx->unkF); + const u8 *str = GetMatchCallMessageText(index, &gfx->newRematchRequest); u8 speed = GetPlayerTextSpeedDelay(); AddTextPrinterParameterized(gfx->msgBoxWindowId, FONT_NORMAL, str, 32, 1, speed, NULL); } diff --git a/src/pokenav_match_call_ui.c b/src/pokenav_match_call_ui.c index 8392b613c..70e541b55 100644 --- a/src/pokenav_match_call_ui.c +++ b/src/pokenav_match_call_ui.c @@ -8,23 +8,24 @@ #include "decompress.h" #include "international_string_util.h" -// TODO: This UI isnt just for match call, seems to be the general pokenav list UI +#define GFXTAG_ARROW 10 +#define PALTAG_ARROW 20 struct PokenavListMenuWindow { u8 bg; - u8 unk1; - u8 unk2; - u8 unk3; - u8 unk4; + u8 fillValue; + u8 x; + u8 y; + u8 width; u8 fontId; - u16 unk6; + u16 tileOffset; u16 windowId; u16 unkA; - u16 unkC; - u16 unkE; + u16 numPrinted; + u16 numToPrint; }; -struct MatchCallWindowState { +struct PokenavListWindowState { // The index of the element at the top of the window. u16 windowTopIndex; u16 listLength; @@ -33,203 +34,203 @@ struct MatchCallWindowState { u16 selectedIndexOffset; u16 visibleEntries; u16 unkA; - u32 unkC; - void * unk10; + u32 listItemSize; + void * listPtr; }; struct PokenavSub17Substruct { struct PokenavListMenuWindow listWindow; u32 unk10; - u32 unk14; - u32 unk18; - void * unk1C; - s32 unk20; - s32 unk24; + u32 printIndex; + u32 itemSize; + void * listPtr; + s32 startBgY; + s32 endBgY; u32 loopedTaskId; - s32 unk2C; - u32 unk30; - PokenavListItemBufferFunc unk34; - void (*unk38)(u16, u32, u32); + s32 moveDelta; + u32 bgMoveType; + PokenavListBufferItemFunc bufferItemFunc; + void (*iconDrawFunc)(u16, u32, u32); struct Sprite *rightArrow; struct Sprite *upArrow; struct Sprite *downArrow; - u8 unkTextBuffer[0x40]; + u8 itemTextBuffer[64]; }; struct PokenavSub17 { struct PokenavSub17Substruct list; - u8 tilemapBuffer[0x800]; - struct MatchCallWindowState unk888; + u8 tilemapBuffer[BG_SCREEN_SIZE]; + struct PokenavListWindowState windowState; s32 unk89C; u32 loopedTaskId; }; -void sub_81C82E4(struct PokenavSub17 *matchCall); -static bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *a0, const struct BgTemplate *a1, struct PokenavListTemplate *a2, s32 a3); -void InitMatchCallWindowState(struct MatchCallWindowState *a0, struct PokenavListTemplate *a1); -void SpriteCB_MatchCallUpArrow(struct Sprite *sprite); -void SpriteCB_MatchCallDownArrow(struct Sprite *sprite); -void SpriteCB_MatchCallRightArrow(struct Sprite *sprite); -void ToggleMatchCallArrows(struct PokenavSub17Substruct *a0, u32 a1); -void DestroyMatchCallListArrows(struct PokenavSub17Substruct *a0); -void CreateMatchCallArrowSprites(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1); -void sub_81C8ED0(void); -static void PrintMatchCallFlavorText(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1, u32 a2); -void PrintMatchCallFieldNames(struct PokenavSub17Substruct *a0, u32 a1); -void sub_81C8D4C(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1); -void sub_81C8CB4(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1); -void sub_81C8B70(struct PokenavListMenuWindow *a0, s32 a1, s32 a2); -void sub_81C8568(s32 a0, struct PokenavSub17Substruct *a1); -void sub_81C83AC(void * a0, u32 a1, u32 a2, u32 a3, u32 a4, struct PokenavSub17Substruct *a5); -void sub_81C837C(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1); -void sub_81C835C(struct PokenavListMenuWindow *a0); -u32 LoopedTask_sub_81C8254(s32 state); -bool32 sub_81C83E0(void); -u32 LoopedTask_sub_81C83F0(s32 state); -u32 LoopedTask_sub_81C85A0(s32 state); -u32 LoopedTask_sub_81C8870(s32 state); -u32 LoopedTask_sub_81C8A28(s32 state); -u32 LoopedTask_PrintCheckPageInfo(s32 state); +static void InitPokenavListBg(struct PokenavSub17 *); +static bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *, const struct BgTemplate *, struct PokenavListTemplate *, s32); +static void InitPokenavListWindowState(struct PokenavListWindowState *, struct PokenavListTemplate *); +static void SpriteCB_UpArrow(struct Sprite *); +static void SpriteCB_DownArrow(struct Sprite *); +static void SpriteCB_RightArrow(struct Sprite *); +static void ToggleListArrows(struct PokenavSub17Substruct *, u32); +static void DestroyListArrows(struct PokenavSub17Substruct *); +static void CreateListArrowSprites(struct PokenavListWindowState *, struct PokenavSub17Substruct *); +static void LoadListArrowGfx(void); +static void PrintMatchCallFlavorText(struct PokenavListWindowState *, struct PokenavSub17Substruct *, u32); +static void PrintMatchCallFieldNames(struct PokenavSub17Substruct *, u32); +static void PrintMatchCallListTrainerName(struct PokenavListWindowState *, struct PokenavSub17Substruct *); +static void PrintCheckPageTrainerName(struct PokenavListWindowState *, struct PokenavSub17Substruct *); +static void sub_81C8B70(struct PokenavListMenuWindow *, s32, s32); +static void CreateMoveListWindowTask(s32, struct PokenavSub17Substruct *); +static void PrintListItems(void *, u32, u32, u32, u32, struct PokenavSub17Substruct *); +static void InitListItems(struct PokenavListWindowState *, struct PokenavSub17Substruct *); +static void InitPokenavListWindow(struct PokenavListMenuWindow *); +static u32 LoopedTask_CreatePokenavList(s32); +static bool32 IsPrintListItemsTaskActive(void); +static u32 LoopedTask_PrintListItems(s32); +static u32 LoopedTask_MoveListWindow(s32); +static u32 LoopedTask_sub_81C8870(s32); +static u32 LoopedTask_sub_81C8A28(s32); +static u32 LoopedTask_PrintCheckPageInfo(s32); -static const u16 sMatchcallArrowPaletteData[] = INCBIN_U16("graphics/pokenav/list_arrows.gbapal"); -static const u32 sMatchcallArrowSpriteSheetData[] = INCBIN_U32("graphics/pokenav/list_arrows.4bpp.lz"); +static const u16 sListArrow_Pal[] = INCBIN_U16("graphics/pokenav/list_arrows.gbapal"); +static const u32 sListArrow_Gfx[] = INCBIN_U32("graphics/pokenav/list_arrows.4bpp.lz"); -EWRAM_DATA u32 gUnknown_0203CF44 = 0; +static EWRAM_DATA u32 gUnknown_0203CF44 = 0; -bool32 sub_81C81D4(const struct BgTemplate *arg0, struct PokenavListTemplate *arg1, s32 arg2) +bool32 CreatePokenavList(const struct BgTemplate *bgTemplate, struct PokenavListTemplate *listTemplate, s32 tileOffset) { - struct PokenavSub17 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_LIST, sizeof(struct PokenavSub17)); + struct PokenavSub17 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_LIST, sizeof(struct PokenavSub17)); if (structPtr == NULL) return FALSE; - InitMatchCallWindowState(&structPtr->unk888, arg1); - if (!CopyPokenavListMenuTemplate(&structPtr->list, arg0, arg1, arg2)) + InitPokenavListWindowState(&structPtr->windowState, listTemplate); + if (!CopyPokenavListMenuTemplate(&structPtr->list, bgTemplate, listTemplate, tileOffset)) return FALSE; - CreateLoopedTask(LoopedTask_sub_81C8254, 6); + CreateLoopedTask(LoopedTask_CreatePokenavList, 6); return TRUE; } -bool32 sub_81C8224(void) +bool32 IsCreatePokenavListTaskActive(void) { - return FuncIsActiveLoopedTask(LoopedTask_sub_81C8254); + return FuncIsActiveLoopedTask(LoopedTask_CreatePokenavList); } -void sub_81C8234(void) +void DestroyPokenavList(void) { - struct PokenavSub17 *structPtr; - - structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); - DestroyMatchCallListArrows(&structPtr->list); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + DestroyListArrows(&structPtr->list); RemoveWindow(structPtr->list.listWindow.windowId); - FreePokenavSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_LIST); } -u32 LoopedTask_sub_81C8254(s32 state) +static u32 LoopedTask_CreatePokenavList(s32 state) { struct PokenavSub17 *structPtr; if (IsDma3ManagerBusyWithBgCopy()) return LT_PAUSE; - structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); switch (state) { case 0: - sub_81C82E4(structPtr); + InitPokenavListBg(structPtr); return LT_INC_AND_PAUSE; case 1: - sub_81C835C(&structPtr->list.listWindow); + InitPokenavListWindow(&structPtr->list.listWindow); return LT_INC_AND_PAUSE; case 2: - sub_81C837C(&structPtr->unk888, &structPtr->list); + InitListItems(&structPtr->windowState, &structPtr->list); return LT_INC_AND_PAUSE; case 3: - if (sub_81C83E0()) + if (IsPrintListItemsTaskActive()) { return LT_PAUSE; } else { - sub_81C8ED0(); + LoadListArrowGfx(); return LT_INC_AND_CONTINUE; } case 4: - CreateMatchCallArrowSprites(&structPtr->unk888, &structPtr->list); + CreateListArrowSprites(&structPtr->windowState, &structPtr->list); return LT_FINISH; default: return LT_FINISH; } } -void sub_81C82E4(struct PokenavSub17 *matchCall) +static void InitPokenavListBg(struct PokenavSub17 *a0) { - u16 tileNum = (matchCall->list.listWindow.unk1 << 12) | matchCall->list.listWindow.unk6; - BgDmaFill(matchCall->list.listWindow.bg, PIXEL_FILL(1), matchCall->list.listWindow.unk6, 1); - BgDmaFill(matchCall->list.listWindow.bg, PIXEL_FILL(4), matchCall->list.listWindow.unk6 + 1, 1); - SetBgTilemapBuffer(matchCall->list.listWindow.bg, matchCall->tilemapBuffer); - FillBgTilemapBufferRect_Palette0(matchCall->list.listWindow.bg, tileNum, 0, 0, 32, 32); - ChangeBgY(matchCall->list.listWindow.bg, 0, BG_COORD_SET); - ChangeBgX(matchCall->list.listWindow.bg, 0, BG_COORD_SET); - ChangeBgY(matchCall->list.listWindow.bg, matchCall->list.listWindow.unk3 << 11, BG_COORD_SUB); - CopyBgTilemapBufferToVram(matchCall->list.listWindow.bg); + u16 tileNum = (a0->list.listWindow.fillValue << 12) | a0->list.listWindow.tileOffset; + BgDmaFill(a0->list.listWindow.bg, PIXEL_FILL(1), a0->list.listWindow.tileOffset, 1); + BgDmaFill(a0->list.listWindow.bg, PIXEL_FILL(4), a0->list.listWindow.tileOffset + 1, 1); + SetBgTilemapBuffer(a0->list.listWindow.bg, a0->tilemapBuffer); + FillBgTilemapBufferRect_Palette0(a0->list.listWindow.bg, tileNum, 0, 0, 32, 32); + ChangeBgY(a0->list.listWindow.bg, 0, BG_COORD_SET); + ChangeBgX(a0->list.listWindow.bg, 0, BG_COORD_SET); + ChangeBgY(a0->list.listWindow.bg, a0->list.listWindow.y << 11, BG_COORD_SUB); + CopyBgTilemapBufferToVram(a0->list.listWindow.bg); } -void sub_81C835C(struct PokenavListMenuWindow *listWindow) +static void InitPokenavListWindow(struct PokenavListMenuWindow *listWindow) { FillWindowPixelBuffer(listWindow->windowId, PIXEL_FILL(1)); PutWindowTilemap(listWindow->windowId); CopyWindowToVram(listWindow->windowId, COPYWIN_MAP); } -void sub_81C837C(struct MatchCallWindowState *state, struct PokenavSub17Substruct *a1) +static void InitListItems(struct PokenavListWindowState *windowState, struct PokenavSub17Substruct *a1) { - s32 arg2 = state->listLength - state->windowTopIndex; - if (arg2 > state->visibleEntries) - arg2 = state->visibleEntries; + s32 numToPrint = windowState->listLength - windowState->windowTopIndex; + if (numToPrint > windowState->visibleEntries) + numToPrint = windowState->visibleEntries; - sub_81C83AC(state->unk10, state->windowTopIndex, arg2, state->unkC, 0, a1); + PrintListItems(windowState->listPtr, windowState->windowTopIndex, numToPrint, windowState->listItemSize, 0, a1); } -void sub_81C83AC(void * a0, u32 a1, u32 a2, u32 a3, u32 a4, struct PokenavSub17Substruct *list) +static void PrintListItems(void * listPtr, u32 topIndex, u32 numItems, u32 itemSize, u32 a4, struct PokenavSub17Substruct *list) { - if (a2 == 0) + if (numItems == 0) return; - list->unk1C = a0 + a1 * a3; - list->unk18 = a3; - list->listWindow.unkC = 0; - list->listWindow.unkE = a2; - list->unk14 = a1; + list->listPtr = listPtr + topIndex * itemSize; + list->itemSize = itemSize; + list->listWindow.numPrinted = 0; + list->listWindow.numToPrint = numItems; + list->printIndex = topIndex; list->unk10 = a4; - CreateLoopedTask(LoopedTask_sub_81C83F0, 5); + CreateLoopedTask(LoopedTask_PrintListItems, 5); } -bool32 sub_81C83E0(void) +static bool32 IsPrintListItemsTaskActive(void) { - return FuncIsActiveLoopedTask(LoopedTask_sub_81C83F0); + return FuncIsActiveLoopedTask(LoopedTask_PrintListItems); } -u32 LoopedTask_sub_81C83F0(s32 state) +static u32 LoopedTask_PrintListItems(s32 state) { u32 v1; - struct PokenavSub17Substruct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + struct PokenavSub17Substruct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); switch (state) { case 0: - v1 = (structPtr->listWindow.unkA + structPtr->listWindow.unkC + structPtr->unk10) & 0xF; - structPtr->unk34(structPtr->unk1C, structPtr->unkTextBuffer); - if (structPtr->unk38 != NULL) - structPtr->unk38(structPtr->listWindow.windowId, structPtr->unk14, v1); + v1 = (structPtr->listWindow.unkA + structPtr->listWindow.numPrinted + structPtr->unk10) & 0xF; + structPtr->bufferItemFunc(structPtr->listPtr, structPtr->itemTextBuffer); + if (structPtr->iconDrawFunc != NULL) + structPtr->iconDrawFunc(structPtr->listWindow.windowId, structPtr->printIndex, v1); - AddTextPrinterParameterized(structPtr->listWindow.windowId, structPtr->listWindow.fontId, structPtr->unkTextBuffer, 8, (v1 << 4) + 1, 255, NULL); - if (++structPtr->listWindow.unkC >= structPtr->listWindow.unkE) + AddTextPrinterParameterized(structPtr->listWindow.windowId, structPtr->listWindow.fontId, structPtr->itemTextBuffer, 8, (v1 << 4) + 1, 255, NULL); + if (++structPtr->listWindow.numPrinted >= structPtr->listWindow.numToPrint) { - if (structPtr->unk38 != NULL) + // Finished printing items. If icons were being drawn, draw the + // window tilemap and graphics. Otherwise just do the graphics + if (structPtr->iconDrawFunc != NULL) CopyWindowToVram(structPtr->listWindow.windowId, COPYWIN_FULL); else CopyWindowToVram(structPtr->listWindow.windowId, COPYWIN_GFX); @@ -237,8 +238,8 @@ u32 LoopedTask_sub_81C83F0(s32 state) } else { - structPtr->unk1C += structPtr->unk18; - structPtr->unk14++; + structPtr->listPtr += structPtr->itemSize; + structPtr->printIndex++; return LT_CONTINUE; } case 1: @@ -251,88 +252,88 @@ u32 LoopedTask_sub_81C83F0(s32 state) bool32 ShouldShowUpArrow(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - return (structPtr->unk888.windowTopIndex != 0); + return (structPtr->windowState.windowTopIndex != 0); } bool32 ShouldShowDownArrow(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); - struct MatchCallWindowState *subPtr = &structPtr->unk888; + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavListWindowState *subPtr = &structPtr->windowState; return (subPtr->windowTopIndex + subPtr->visibleEntries < subPtr->listLength); } -void MatchCall_MoveWindow(s32 a0, bool32 a1) +static void MoveListWindow(s32 delta, bool32 a1) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); - struct MatchCallWindowState *subPtr = &structPtr->unk888; + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavListWindowState *subPtr = &structPtr->windowState; - if (a0 < 0) + if (delta < 0) { - if (subPtr->windowTopIndex + a0 < 0) - a0 = -1 * subPtr->windowTopIndex; + if (subPtr->windowTopIndex + delta < 0) + delta = -1 * subPtr->windowTopIndex; if (a1) - sub_81C83AC(subPtr->unk10, subPtr->windowTopIndex + a0, a0 * -1, subPtr->unkC, a0, &structPtr->list); + PrintListItems(subPtr->listPtr, subPtr->windowTopIndex + delta, delta * -1, subPtr->listItemSize, delta, &structPtr->list); } else if (a1) { s32 temp = gUnknown_0203CF44 = subPtr->windowTopIndex + subPtr->visibleEntries; - if (temp + a0 >= subPtr->listLength) - a0 = subPtr->listLength - temp; + if (temp + delta >= subPtr->listLength) + delta = subPtr->listLength - temp; - sub_81C83AC(subPtr->unk10, gUnknown_0203CF44, a0, subPtr->unkC, subPtr->visibleEntries, &structPtr->list); + PrintListItems(subPtr->listPtr, gUnknown_0203CF44, delta, subPtr->listItemSize, subPtr->visibleEntries, &structPtr->list); } - sub_81C8568(a0, &structPtr->list); - subPtr->windowTopIndex += a0; + CreateMoveListWindowTask(delta, &structPtr->list); + subPtr->windowTopIndex += delta; } -void sub_81C8568(s32 a0, struct PokenavSub17Substruct *list) +static void CreateMoveListWindowTask(s32 delta, struct PokenavSub17Substruct *list) { - list->unk20 = GetBgY(list->listWindow.bg); - list->unk24 = list->unk20 + (a0 << 12); - if (a0 > 0) - list->unk30 = BG_COORD_ADD; + list->startBgY = GetBgY(list->listWindow.bg); + list->endBgY = list->startBgY + (delta << 12); + if (delta > 0) + list->bgMoveType = BG_COORD_ADD; else - list->unk30 = BG_COORD_SUB; - list->unk2C = a0; - list->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C85A0, 6); + list->bgMoveType = BG_COORD_SUB; + list->moveDelta = delta; + list->loopedTaskId = CreateLoopedTask(LoopedTask_MoveListWindow, 6); } -u32 LoopedTask_sub_81C85A0(s32 state) +static u32 LoopedTask_MoveListWindow(s32 state) { - s32 y, v1; - bool32 flag; - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + s32 oldY, newY; + bool32 finished; + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); struct PokenavSub17Substruct *subPtr = &structPtr->list; switch (state) { case 0: - if (!sub_81C83E0()) + if (!IsPrintListItemsTaskActive()) return LT_INC_AND_CONTINUE; return LT_PAUSE; case 1: - flag = FALSE; - y = GetBgY(subPtr->listWindow.bg); - v1 = ChangeBgY(subPtr->listWindow.bg, 0x1000, subPtr->unk30); - if (subPtr->unk30 == BG_COORD_SUB) + finished = FALSE; + oldY = GetBgY(subPtr->listWindow.bg); + newY = ChangeBgY(subPtr->listWindow.bg, 0x1000, subPtr->bgMoveType); + if (subPtr->bgMoveType == BG_COORD_SUB) { - if ((y > subPtr->unk24 || y <= subPtr->unk20) && v1 <= subPtr->unk24) - flag = TRUE; + if ((oldY > subPtr->endBgY || oldY <= subPtr->startBgY) && newY <= subPtr->endBgY) + finished = TRUE; } else // BG_COORD_ADD { - if ((y < subPtr->unk24 || y >= subPtr->unk20) && v1 >= subPtr->unk24) - flag = TRUE; + if ((oldY < subPtr->endBgY || oldY >= subPtr->startBgY) && newY >= subPtr->endBgY) + finished = TRUE; } - if (flag) + if (finished) { - subPtr->listWindow.unkA = (subPtr->listWindow.unkA + subPtr->unk2C) & 0xF; - ChangeBgY(subPtr->listWindow.bg, subPtr->unk24, BG_COORD_SET); + subPtr->listWindow.unkA = (subPtr->listWindow.unkA + subPtr->moveDelta) & 0xF; + ChangeBgY(subPtr->listWindow.bg, subPtr->endBgY, BG_COORD_SET); return LT_FINISH; } return LT_PAUSE; @@ -340,21 +341,21 @@ u32 LoopedTask_sub_81C85A0(s32 state) return LT_FINISH; } -bool32 IsMonListLoopedTaskActive(void) +bool32 IsMovePokenavListWindowTaskActive(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); return IsLoopedTaskActive(structPtr->list.loopedTaskId); } -struct MatchCallWindowState *GetMatchCallWindowStruct(void) +static struct PokenavListWindowState *GetPokenavListWindowState(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); - return &structPtr->unk888; + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + return &structPtr->windowState; } -int MatchCall_MoveCursorUp(void) +int PokenavList_MoveCursorUp(void) { - struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct(); + struct PokenavListWindowState *structPtr = GetPokenavListWindowState(); if (structPtr->selectedIndexOffset != 0) { @@ -363,15 +364,15 @@ int MatchCall_MoveCursorUp(void) } if (ShouldShowUpArrow()) { - MatchCall_MoveWindow(-1, TRUE); + MoveListWindow(-1, TRUE); return 2; } return 0; } -int MatchCall_MoveCursorDown(void) +int PokenavList_MoveCursorDown(void) { - struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct(); + struct PokenavListWindowState *structPtr = GetPokenavListWindowState(); if (structPtr->windowTopIndex + structPtr->selectedIndexOffset >= structPtr->listLength - 1) return 0; @@ -382,16 +383,16 @@ int MatchCall_MoveCursorDown(void) } if (ShouldShowDownArrow()) { - MatchCall_MoveWindow(1, TRUE); + MoveListWindow(1, TRUE); return 2; } return 0; } -int MatchCall_PageUp(void) +int PokenavList_PageUp(void) { s32 scroll; - struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct(); + struct PokenavListWindowState *structPtr = GetPokenavListWindowState(); if (ShouldShowUpArrow()) { @@ -399,7 +400,7 @@ int MatchCall_PageUp(void) scroll = structPtr->visibleEntries; else scroll = structPtr->windowTopIndex; - MatchCall_MoveWindow(scroll * -1, TRUE); + MoveListWindow(scroll * -1, TRUE); return 2; } else if (structPtr->selectedIndexOffset != 0) @@ -410,9 +411,9 @@ int MatchCall_PageUp(void) return 0; } -int MatchCall_PageDown(void) +int PokenavList_PageDown(void) { - struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct(); + struct PokenavListWindowState *structPtr = GetPokenavListWindowState(); if (ShouldShowDownArrow()) { @@ -421,7 +422,7 @@ int MatchCall_PageDown(void) if (windowBottomIndex <= structPtr->unk4) scroll = structPtr->visibleEntries; - MatchCall_MoveWindow(scroll, TRUE); + MoveListWindow(scroll, TRUE); return 2; } else @@ -448,66 +449,65 @@ int MatchCall_PageDown(void) u32 GetSelectedPokenavListIndex(void) { - struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct(); + struct PokenavListWindowState *structPtr = GetPokenavListWindowState(); return structPtr->windowTopIndex + structPtr->selectedIndexOffset; } u32 GetMatchCallListTopIndex(void) { - struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct(); + struct PokenavListWindowState *structPtr = GetPokenavListWindowState(); return structPtr->windowTopIndex; } void sub_81C877C(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); structPtr->unk89C = 0; structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C8870, 6); } void PrintCheckPageInfo(s16 delta) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); - structPtr->unk888.windowTopIndex += delta; + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + structPtr->windowState.windowTopIndex += delta; structPtr->unk89C = 0; structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_PrintCheckPageInfo, 6); } void sub_81C87F0(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); structPtr->unk89C = 0; structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C8A28, 6); } bool32 IsMatchCallListTaskActive(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); return IsLoopedTaskActive(structPtr->loopedTaskId); } -void sub_81C8838(void) +void PokenavList_DrawCurrentItemIcon(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); - struct MatchCallWindowState *subPtr = &structPtr->unk888; - structPtr->list.unk38(structPtr->list.listWindow.windowId, subPtr->windowTopIndex + subPtr->selectedIndexOffset, (structPtr->list.listWindow.unkA + subPtr->selectedIndexOffset) & 0xF); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavListWindowState *subPtr = &structPtr->windowState; + structPtr->list.iconDrawFunc(structPtr->list.listWindow.windowId, subPtr->windowTopIndex + subPtr->selectedIndexOffset, (structPtr->list.listWindow.unkA + subPtr->selectedIndexOffset) & 0xF); CopyWindowToVram(structPtr->list.listWindow.windowId, COPYWIN_MAP); } -// TODO: -u32 LoopedTask_sub_81C8870(s32 state) +static u32 LoopedTask_sub_81C8870(s32 state) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); switch (state) { case 0: - ToggleMatchCallArrows(&structPtr->list, 1); + ToggleListArrows(&structPtr->list, 1); // fall-through case 1: - if (structPtr->unk89C != structPtr->unk888.selectedIndexOffset) + if (structPtr->unk89C != structPtr->windowState.selectedIndexOffset) sub_81C8B70(&structPtr->list.listWindow, structPtr->unk89C, 1); structPtr->unk89C++; @@ -515,10 +515,10 @@ u32 LoopedTask_sub_81C8870(s32 state) case 2: if (!IsDma3ManagerBusyWithBgCopy()) { - if (structPtr->unk89C != structPtr->unk888.visibleEntries) + if (structPtr->unk89C != structPtr->windowState.visibleEntries) return 6; - if (structPtr->unk888.selectedIndexOffset != 0) - sub_81C8B70(&structPtr->list.listWindow, structPtr->unk89C, structPtr->unk888.selectedIndexOffset); + if (structPtr->windowState.selectedIndexOffset != 0) + sub_81C8B70(&structPtr->list.listWindow, structPtr->unk89C, structPtr->windowState.selectedIndexOffset); return LT_INC_AND_PAUSE; } @@ -526,55 +526,55 @@ u32 LoopedTask_sub_81C8870(s32 state) case 3: if (!IsDma3ManagerBusyWithBgCopy()) { - if (structPtr->unk888.selectedIndexOffset != 0) + if (structPtr->windowState.selectedIndexOffset != 0) { - MatchCall_MoveWindow(structPtr->unk888.selectedIndexOffset, FALSE); + MoveListWindow(structPtr->windowState.selectedIndexOffset, FALSE); return LT_INC_AND_PAUSE; } return LT_FINISH; } return LT_PAUSE; case 4: - if (IsMonListLoopedTaskActive()) + if (IsMovePokenavListWindowTaskActive()) return LT_PAUSE; - structPtr->unk888.selectedIndexOffset = 0; + structPtr->windowState.selectedIndexOffset = 0; return LT_FINISH; } return LT_FINISH; } -u32 LoopedTask_PrintCheckPageInfo(s32 state) +static u32 LoopedTask_PrintCheckPageInfo(s32 state) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); if (IsDma3ManagerBusyWithBgCopy()) return LT_PAUSE; switch (state) { case 0: - sub_81C8CB4(&structPtr->unk888, &structPtr->list); + PrintCheckPageTrainerName(&structPtr->windowState, &structPtr->list); break; case 1: PrintMatchCallFieldNames(&structPtr->list, 0); break; case 2: - PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_STRATEGY); + PrintMatchCallFlavorText(&structPtr->windowState, &structPtr->list, CHECK_PAGE_STRATEGY); break; case 3: PrintMatchCallFieldNames(&structPtr->list, 1); break; case 4: - PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_POKEMON); + PrintMatchCallFlavorText(&structPtr->windowState, &structPtr->list, CHECK_PAGE_POKEMON); break; case 5: PrintMatchCallFieldNames(&structPtr->list, 2); break; case 6: - PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_INTRO_1); + PrintMatchCallFlavorText(&structPtr->windowState, &structPtr->list, CHECK_PAGE_INTRO_1); break; case 7: - PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_INTRO_2); + PrintMatchCallFlavorText(&structPtr->windowState, &structPtr->list, CHECK_PAGE_INTRO_2); break; default: return LT_FINISH; @@ -582,95 +582,95 @@ u32 LoopedTask_PrintCheckPageInfo(s32 state) return LT_INC_AND_PAUSE; } -u32 LoopedTask_sub_81C8A28(s32 state) +static u32 LoopedTask_sub_81C8A28(s32 state) { struct PokenavSub17 *structPtr; - struct MatchCallWindowState *subPtr888; + struct PokenavListWindowState *windowState; struct PokenavSub17Substruct *subPtr0; s32 r5, *ptr; if (IsDma3ManagerBusyWithBgCopy()) return LT_PAUSE; - structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); - subPtr888 = &structPtr->unk888; + structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + windowState = &structPtr->windowState; subPtr0 = &structPtr->list; switch (state) { case 0: - sub_81C8D4C(subPtr888, subPtr0); + PrintMatchCallListTrainerName(windowState, subPtr0); return LT_INC_AND_PAUSE; case 1: ptr = &structPtr->unk89C; - if (++(*ptr) < structPtr->unk888.visibleEntries) + if (++(*ptr) < structPtr->windowState.visibleEntries) { sub_81C8B70(&subPtr0->listWindow, *ptr, 1); return LT_PAUSE; } *ptr = 0; - if (subPtr888->listLength <= subPtr888->visibleEntries) + if (windowState->listLength <= windowState->visibleEntries) { - if (subPtr888->windowTopIndex != 0) + if (windowState->windowTopIndex != 0) { - s32 r4 = subPtr888->windowTopIndex; + s32 r4 = windowState->windowTopIndex; r5 = -r4; sub_81C8B70(&subPtr0->listWindow, r5, r4); - subPtr888->selectedIndexOffset = r4; + windowState->selectedIndexOffset = r4; *ptr = r5; return LT_INC_AND_PAUSE; } } else { - if (subPtr888->windowTopIndex + subPtr888->visibleEntries > subPtr888->listLength) + if (windowState->windowTopIndex + windowState->visibleEntries > windowState->listLength) { - s32 r4 = subPtr888->windowTopIndex + subPtr888->visibleEntries - subPtr888->listLength; + s32 r4 = windowState->windowTopIndex + windowState->visibleEntries - windowState->listLength; r5 = -r4; sub_81C8B70(&subPtr0->listWindow, r5, r4); - subPtr888->selectedIndexOffset = r4; + windowState->selectedIndexOffset = r4; *ptr = r5; return LT_INC_AND_PAUSE; } } return 9; case 2: - MatchCall_MoveWindow(structPtr->unk89C, FALSE); + MoveListWindow(structPtr->unk89C, FALSE); return LT_INC_AND_PAUSE; case 3: - if (!IsMonListLoopedTaskActive()) + if (!IsMovePokenavListWindowTaskActive()) { structPtr->unk89C = 0; return 1; } return 2; case 4: - sub_81C83AC(subPtr888->unk10, subPtr888->windowTopIndex + structPtr->unk89C, 1, subPtr888->unkC, structPtr->unk89C, &structPtr->list); + PrintListItems(windowState->listPtr, windowState->windowTopIndex + structPtr->unk89C, 1, windowState->listItemSize, structPtr->unk89C, &structPtr->list); return LT_INC_AND_PAUSE; case 5: - if (sub_81C83E0()) + if (IsPrintListItemsTaskActive()) return LT_PAUSE; - if (++structPtr->unk89C >= subPtr888->listLength || structPtr->unk89C >= subPtr888->visibleEntries) + if (++structPtr->unk89C >= windowState->listLength || structPtr->unk89C >= windowState->visibleEntries) return LT_INC_AND_CONTINUE; return 9; case 6: - ToggleMatchCallArrows(subPtr0, 0); + ToggleListArrows(subPtr0, 0); return LT_FINISH; } return LT_FINISH; } -void sub_81C8B70(struct PokenavListMenuWindow *listWindow, s32 a1, s32 a2) +static void sub_81C8B70(struct PokenavListMenuWindow *listWindow, s32 a1, s32 a2) { - u8 *v1 = (u8*)GetWindowAttribute(listWindow->windowId, WINDOW_TILE_DATA); - u32 v2 = listWindow->unk4 * 64; + u8 *tileData = (u8*)GetWindowAttribute(listWindow->windowId, WINDOW_TILE_DATA); + u32 v2 = listWindow->width * 64; a1 = (listWindow->unkA + a1) & 0xF; if (a1 + a2 <= 16) { - CpuFastFill8(PIXEL_FILL(1), v1 + a1 * v2, a2 * v2); + CpuFastFill8(PIXEL_FILL(1), tileData + a1 * v2, a2 * v2); CopyWindowToVram(listWindow->windowId, COPYWIN_GFX); } else @@ -678,8 +678,8 @@ void sub_81C8B70(struct PokenavListMenuWindow *listWindow, s32 a1, s32 a2) u32 v3 = 16 - a1; u32 v4 = a2 - v3; - CpuFastFill8(PIXEL_FILL(1), v1 + a1 * v2, v3 * v2); - CpuFastFill8(PIXEL_FILL(1), v1, v4 * v2); + CpuFastFill8(PIXEL_FILL(1), tileData + a1 * v2, v3 * v2); + CpuFastFill8(PIXEL_FILL(1), tileData, v4 * v2); CopyWindowToVram(listWindow->windowId, COPYWIN_GFX); } @@ -693,50 +693,56 @@ void sub_81C8C64(struct PokenavListMenuWindow *listWindow, u32 a1) { u16 var; u16 *v1 = (u16*)GetBgTilemapBuffer(GetWindowAttribute(listWindow->windowId, WINDOW_BG)); - v1 += ((listWindow->unkA << 6) + listWindow->unk2) - 1; + v1 += ((listWindow->unkA << 6) + listWindow->x) - 1; if (a1 != 0) - var = (listWindow->unk1 << 12) | (listWindow->unk6 + 1); + var = (listWindow->fillValue << 12) | (listWindow->tileOffset + 1); else - var = (listWindow->unk1 << 12) | (listWindow->unk6); + var = (listWindow->fillValue << 12) | (listWindow->tileOffset); v1[0] = var; v1[0x20] = var; } -void sub_81C8CB4(struct MatchCallWindowState *state, struct PokenavSub17Substruct *list) +// Print the trainer's name and title at the top of their check page +static void PrintCheckPageTrainerName(struct PokenavListWindowState *state, struct PokenavSub17Substruct *list) { u8 colors[3] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_RED}; - list->unk34(state->unk10 + state->unkC * state->windowTopIndex, list->unkTextBuffer); - list->unk38(list->listWindow.windowId, state->windowTopIndex, list->listWindow.unkA); - FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(4), 0, list->listWindow.unkA * 16, list->listWindow.unk4 * 8, 16); - AddTextPrinterParameterized3(list->listWindow.windowId, list->listWindow.fontId, 8, (list->listWindow.unkA * 16) + 1, colors, TEXT_SKIP_DRAW, list->unkTextBuffer); + list->bufferItemFunc(state->listPtr + state->listItemSize * state->windowTopIndex, list->itemTextBuffer); + list->iconDrawFunc(list->listWindow.windowId, state->windowTopIndex, list->listWindow.unkA); + FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(4), 0, list->listWindow.unkA * 16, list->listWindow.width * 8, 16); + AddTextPrinterParameterized3(list->listWindow.windowId, list->listWindow.fontId, 8, (list->listWindow.unkA * 16) + 1, colors, TEXT_SKIP_DRAW, list->itemTextBuffer); sub_81C8C64(&list->listWindow, 1); - CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_FULL, 0, list->listWindow.unkA * 2, list->listWindow.unk4, 2); + CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_FULL, 0, list->listWindow.unkA * 2, list->listWindow.width, 2); } -void sub_81C8D4C(struct MatchCallWindowState *state, struct PokenavSub17Substruct *list) +// Print the trainer's name and title for the list (to replace the check page name and title, which has a red background) +static void PrintMatchCallListTrainerName(struct PokenavListWindowState *state, struct PokenavSub17Substruct *list) { - list->unk34(state->unk10 + state->unkC * state->windowTopIndex, list->unkTextBuffer); - FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, list->listWindow.unkA * 16, list->listWindow.unk4 * 8, 16); - AddTextPrinterParameterized(list->listWindow.windowId, list->listWindow.fontId, list->unkTextBuffer, 8, list->listWindow.unkA * 16 + 1, TEXT_SKIP_DRAW, NULL); + list->bufferItemFunc(state->listPtr + state->listItemSize * state->windowTopIndex, list->itemTextBuffer); + FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, list->listWindow.unkA * 16, list->listWindow.width * 8, 16); + AddTextPrinterParameterized(list->listWindow.windowId, list->listWindow.fontId, list->itemTextBuffer, 8, list->listWindow.unkA * 16 + 1, TEXT_SKIP_DRAW, NULL); sub_81C8C64(&list->listWindow, 0); CopyWindowToVram(list->listWindow.windowId, COPYWIN_FULL); } -void PrintMatchCallFieldNames(struct PokenavSub17Substruct *list, u32 fieldId) +static void PrintMatchCallFieldNames(struct PokenavSub17Substruct *list, u32 fieldId) { - const u8 *fieldNames[] = {gText_PokenavMatchCall_Strategy, gText_PokenavMatchCall_TrainerPokemon, gText_PokenavMatchCall_SelfIntroduction}; + const u8 *fieldNames[] = { + gText_PokenavMatchCall_Strategy, + gText_PokenavMatchCall_TrainerPokemon, + gText_PokenavMatchCall_SelfIntroduction + }; u8 colors[3] = {TEXT_COLOR_WHITE, TEXT_COLOR_RED, TEXT_COLOR_LIGHT_RED}; u32 top = (list->listWindow.unkA + 1 + (fieldId * 2)) & 0xF; - FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, top << 4, list->listWindow.unk4, 16); + FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, top << 4, list->listWindow.width, 16); AddTextPrinterParameterized3(list->listWindow.windowId, FONT_NARROW, 2, (top << 4) + 1, colors, TEXT_SKIP_DRAW, fieldNames[fieldId]); - CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_GFX, 0, top << 1, list->listWindow.unk4, 2); + CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_GFX, 0, top << 1, list->listWindow.width, 2); } -static void PrintMatchCallFlavorText(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *list, u32 checkPageEntry) +static void PrintMatchCallFlavorText(struct PokenavListWindowState *a0, struct PokenavSub17Substruct *list, u32 checkPageEntry) { // lines 1, 3, and 5 are the field names printed by PrintMatchCallFieldNames static const u8 lineOffsets[CHECK_PAGE_ENTRY_COUNT] = @@ -752,31 +758,31 @@ static void PrintMatchCallFlavorText(struct MatchCallWindowState *a0, struct Pok if (str != NULL) { - FillWindowTilesByRow(list->listWindow.windowId, 1, r6 * 2, list->listWindow.unk4 - 1, 2); + FillWindowTilesByRow(list->listWindow.windowId, 1, r6 * 2, list->listWindow.width - 1, 2); AddTextPrinterParameterized(list->listWindow.windowId, FONT_NARROW, str, 2, (r6 << 4) + 1, TEXT_SKIP_DRAW, NULL); - CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_GFX, 0, r6 * 2, list->listWindow.unk4, 2); + CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_GFX, 0, r6 * 2, list->listWindow.width, 2); } } -static const struct CompressedSpriteSheet sMatchcallArrowSpriteSheets[] = +static const struct CompressedSpriteSheet sListArrowSpriteSheets[] = { { - .data = sMatchcallArrowSpriteSheetData, + .data = sListArrow_Gfx, .size = 192, - .tag = 0xA + .tag = GFXTAG_ARROW } }; -static const struct SpritePalette sMatchcallArrowPalettes[] = +static const struct SpritePalette sListArrowPalettes[] = { { - .data = sMatchcallArrowPaletteData, - .tag = 0x14 + .data = sListArrow_Pal, + .tag = PALTAG_ARROW }, {} }; -static const struct OamData sMatchCallRightArrowSpriteOam = +static const struct OamData sOamData_RightArrow = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -790,18 +796,18 @@ static const struct OamData sMatchCallRightArrowSpriteOam = .paletteNum = 0 }; -static const struct SpriteTemplate sMatchCallRightArrowSprite = +static const struct SpriteTemplate sSpriteTemplate_RightArrow = { - .tileTag = 0xA, - .paletteTag = 0x14, - .oam = &sMatchCallRightArrowSpriteOam, + .tileTag = GFXTAG_ARROW, + .paletteTag = PALTAG_ARROW, + .oam = &sOamData_RightArrow, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCB_MatchCallRightArrow + .callback = SpriteCB_RightArrow }; -static const struct OamData sMatchCallUpDownArrowSpriteOam = +static const struct OamData sOamData_UpDownArrow = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -815,60 +821,60 @@ static const struct OamData sMatchCallUpDownArrowSpriteOam = .paletteNum = 0 }; -static const struct SpriteTemplate sMatchCallUpDownArrowSprite = +static const struct SpriteTemplate sSpriteTemplate_UpDownArrow = { - .tileTag = 0xA, - .paletteTag = 0x14, - .oam = &sMatchCallUpDownArrowSpriteOam, + .tileTag = GFXTAG_ARROW, + .paletteTag = PALTAG_ARROW, + .oam = &sOamData_UpDownArrow, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -void sub_81C8ED0(void) +static void LoadListArrowGfx(void) { u32 i; const struct CompressedSpriteSheet *ptr; - for (i = 0, ptr = sMatchcallArrowSpriteSheets; i < ARRAY_COUNT(sMatchcallArrowSpriteSheets); ptr++, i++) + for (i = 0, ptr = sListArrowSpriteSheets; i < ARRAY_COUNT(sListArrowSpriteSheets); ptr++, i++) LoadCompressedSpriteSheet(ptr); - Pokenav_AllocAndLoadPalettes(sMatchcallArrowPalettes); + Pokenav_AllocAndLoadPalettes(sListArrowPalettes); } -void CreateMatchCallArrowSprites(struct MatchCallWindowState *windowState, struct PokenavSub17Substruct *list) +static void CreateListArrowSprites(struct PokenavListWindowState *windowState, struct PokenavSub17Substruct *list) { u32 spriteId; s16 x; - spriteId = CreateSprite(&sMatchCallRightArrowSprite, list->listWindow.unk2 * 8 + 3, (list->listWindow.unk3 + 1) * 8, 7); + spriteId = CreateSprite(&sSpriteTemplate_RightArrow, list->listWindow.x * 8 + 3, (list->listWindow.y + 1) * 8, 7); list->rightArrow = &gSprites[spriteId]; - x = list->listWindow.unk2 * 8 + (list->listWindow.unk4 - 1) * 4; - spriteId = CreateSprite(&sMatchCallUpDownArrowSprite, x, list->listWindow.unk3 * 8 + windowState->visibleEntries * 16, 7); + x = list->listWindow.x * 8 + (list->listWindow.width - 1) * 4; + spriteId = CreateSprite(&sSpriteTemplate_UpDownArrow, x, list->listWindow.y * 8 + windowState->visibleEntries * 16, 7); list->downArrow = &gSprites[spriteId]; list->downArrow->oam.tileNum += 2; - list->downArrow->callback = SpriteCB_MatchCallDownArrow; + list->downArrow->callback = SpriteCB_DownArrow; - spriteId = CreateSprite(&sMatchCallUpDownArrowSprite, x, list->listWindow.unk3 * 8, 7); + spriteId = CreateSprite(&sSpriteTemplate_UpDownArrow, x, list->listWindow.y * 8, 7); list->upArrow = &gSprites[spriteId]; list->upArrow->oam.tileNum += 4; - list->upArrow->callback = SpriteCB_MatchCallUpArrow; + list->upArrow->callback = SpriteCB_UpArrow; } -void DestroyMatchCallListArrows(struct PokenavSub17Substruct *list) +static void DestroyListArrows(struct PokenavSub17Substruct *list) { DestroySprite(list->rightArrow); DestroySprite(list->upArrow); DestroySprite(list->downArrow); - FreeSpriteTilesByTag(0xA); - FreeSpritePaletteByTag(0x14); + FreeSpriteTilesByTag(GFXTAG_ARROW); + FreeSpritePaletteByTag(PALTAG_ARROW); } -void ToggleMatchCallArrows(struct PokenavSub17Substruct *list, bool32 shouldHide) +static void ToggleListArrows(struct PokenavSub17Substruct *list, bool32 invisible) { - if (shouldHide) + if (invisible) { list->rightArrow->callback = SpriteCallbackDummy; list->upArrow->callback = SpriteCallbackDummy; @@ -876,76 +882,84 @@ void ToggleMatchCallArrows(struct PokenavSub17Substruct *list, bool32 shouldHide } else { - list->rightArrow->callback = SpriteCB_MatchCallRightArrow; - list->upArrow->callback = SpriteCB_MatchCallUpArrow; - list->downArrow->callback = SpriteCB_MatchCallDownArrow; + list->rightArrow->callback = SpriteCB_RightArrow; + list->upArrow->callback = SpriteCB_UpArrow; + list->downArrow->callback = SpriteCB_DownArrow; } - list->rightArrow->invisible = shouldHide; - list->upArrow->invisible = shouldHide; - list->downArrow->invisible = shouldHide; + list->rightArrow->invisible = invisible; + list->upArrow->invisible = invisible; + list->downArrow->invisible = invisible; } -void SpriteCB_MatchCallRightArrow(struct Sprite *sprite) +static void SpriteCB_RightArrow(struct Sprite *sprite) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); - sprite->y2 = structPtr->unk888.selectedIndexOffset << 4; + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + sprite->y2 = structPtr->windowState.selectedIndexOffset << 4; } -void SpriteCB_MatchCallDownArrow(struct Sprite *sprite) +#define sTimer data[0] +#define sOffset data[1] +#define sInvisible data[7] + +static void SpriteCB_DownArrow(struct Sprite *sprite) { - if (sprite->data[7] == 0 && ShouldShowDownArrow()) + if (!sprite->sInvisible && ShouldShowDownArrow()) sprite->invisible = FALSE; else sprite->invisible = TRUE; - if (++sprite->data[0] > 3) + if (++sprite->sTimer > 3) { s16 offset; - sprite->data[0] = 0; - offset = (sprite->data[1] + 1) & 7; - sprite->data[1] = offset; + sprite->sTimer = 0; + offset = (sprite->sOffset + 1) & 7; + sprite->sOffset = offset; sprite->y2 = offset; } } -void SpriteCB_MatchCallUpArrow(struct Sprite *sprite) +static void SpriteCB_UpArrow(struct Sprite *sprite) { - if (sprite->data[7] == 0 && ShouldShowUpArrow()) + if (!sprite->sInvisible && ShouldShowUpArrow()) sprite->invisible = FALSE; else sprite->invisible = TRUE; - if (++sprite->data[0] > 3) + if (++sprite->sTimer > 3) { s16 offset; - sprite->data[0] = 0; - offset = (sprite->data[1] + 1) & 7; - sprite->data[1] = offset; + sprite->sTimer = 0; + offset = (sprite->sOffset + 1) & 7; + sprite->sOffset = offset; sprite->y2 = -1 * offset; } } -void ToggleMatchCallVerticalArrows(bool32 shouldHide) +void PokenavList_ToggleVerticalArrows(bool32 invisible) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); - structPtr->list.upArrow->data[7] = shouldHide; - structPtr->list.downArrow->data[7] = shouldHide; + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + structPtr->list.upArrow->sInvisible = invisible; + structPtr->list.downArrow->sInvisible = invisible; } -void InitMatchCallWindowState(struct MatchCallWindowState *dst, struct PokenavListTemplate *template) +#undef sTimer +#undef sOffset +#undef sInvisible + +static void InitPokenavListWindowState(struct PokenavListWindowState *dst, struct PokenavListTemplate *template) { - dst->unk10 = template->list; - dst->windowTopIndex = template->unk6; + dst->listPtr = template->list; + dst->windowTopIndex = template->startIndex; dst->listLength = template->count; - dst->unkC = template->unk8; + dst->listItemSize = template->itemSize; dst->visibleEntries = template->maxShowed; if (dst->visibleEntries >= dst->listLength) { dst->windowTopIndex = 0; dst->unk4 = 0; - dst->selectedIndexOffset = template->unk6; + dst->selectedIndexOffset = template->startIndex; } else { @@ -953,7 +967,7 @@ void InitMatchCallWindowState(struct MatchCallWindowState *dst, struct PokenavLi if (dst->windowTopIndex + dst->visibleEntries > dst->listLength) { dst->selectedIndexOffset = dst->windowTopIndex + dst->visibleEntries - dst->listLength; - dst->windowTopIndex = template->unk6 - dst->selectedIndexOffset; + dst->windowTopIndex = template->startIndex - dst->selectedIndexOffset; } else { @@ -962,18 +976,18 @@ void InitMatchCallWindowState(struct MatchCallWindowState *dst, struct PokenavLi } } -static bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *dest, const struct BgTemplate *bgTemplate, struct PokenavListTemplate *template, s32 a3) +static bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *dest, const struct BgTemplate *bgTemplate, struct PokenavListTemplate *template, s32 tileOffset) { struct WindowTemplate window; dest->listWindow.bg = bgTemplate->bg; - dest->listWindow.unk6 = a3; - dest->unk34 = template->bufferItemFunc; - dest->unk38 = template->unk14; - dest->listWindow.unk1 = template->fillValue; - dest->listWindow.unk2 = template->item_X; - dest->listWindow.unk3 = template->listTop; - dest->listWindow.unk4 = template->windowWidth; + dest->listWindow.tileOffset = tileOffset; + dest->bufferItemFunc = template->bufferItemFunc; + dest->iconDrawFunc = template->iconDrawFunc; + dest->listWindow.fillValue = template->fillValue; + dest->listWindow.x = template->item_X; + dest->listWindow.y = template->listTop; + dest->listWindow.width = template->windowWidth; dest->listWindow.fontId = template->fontId; window.bg = bgTemplate->bg; @@ -982,7 +996,7 @@ static bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *dest, co window.width = template->windowWidth; window.height = 32; window.paletteNum = template->fillValue; - window.baseBlock = a3 + 2; + window.baseBlock = tileOffset + 2; dest->listWindow.windowId = AddWindow(&window); if (dest->listWindow.windowId == WINDOW_NONE) diff --git a/src/pokenav_ribbons_list.c b/src/pokenav_ribbons_list.c index 4233819a3..c70554eb0 100644 --- a/src/pokenav_ribbons_list.c +++ b/src/pokenav_ribbons_list.c @@ -61,8 +61,8 @@ static u32 LoopedTask_RibbonsListOpenSummary(s32); static void DrawListIndexNumber(s32, s32, s32); static void AddRibbonsMonListWindow(struct Pokenav_RibbonsMonMenu *); static void UpdateIndexNumberDisplay(struct Pokenav_RibbonsMonMenu *); -static void InitMonRibbonPokenavListMenuTemplate(void); -static void BufferRibbonMonInfoText(struct PokenavMonListItem *, u8 *); +static void CreateRibbonMonsList(void); +static void BufferRibbonMonInfoText(struct PokenavListItem *, u8 *); static const LoopedTask sMonRibbonListLoopTaskFuncs[] = { @@ -416,7 +416,7 @@ bool32 GetRibbonsMonCurrentLoopedTaskActive(void) void FreeRibbonsMonMenu(void) { struct Pokenav_RibbonsMonMenu * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); - sub_81C8234(); + DestroyPokenavList(); RemoveWindow(menu->winid); FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); } @@ -447,10 +447,10 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state) if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; CopyPaletteIntoBufferUnfaded(sMonRibbonListUi_Pal, 0x20, 0x20); - InitMonRibbonPokenavListMenuTemplate(); + CreateRibbonMonsList(); return LT_INC_AND_PAUSE; case 3: - if (sub_81C8224()) + if (IsCreatePokenavListTaskActive()) return LT_PAUSE; AddRibbonsMonListWindow(menu); return LT_INC_AND_PAUSE; @@ -483,7 +483,7 @@ static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state) switch (state) { case 0: - switch (MatchCall_MoveCursorUp()) + switch (PokenavList_MoveCursorUp()) { case 0: return LT_FINISH; @@ -496,7 +496,7 @@ static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMonListLoopedTaskActive()) + if (IsMovePokenavListWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -516,7 +516,7 @@ static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state) switch (state) { case 0: - switch (MatchCall_MoveCursorDown()) + switch (PokenavList_MoveCursorDown()) { case 0: return LT_FINISH; @@ -529,7 +529,7 @@ static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMonListLoopedTaskActive()) + if (IsMovePokenavListWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -549,7 +549,7 @@ static u32 LoopedTask_RibbonsListMovePageUp(s32 state) switch (state) { case 0: - switch (MatchCall_PageUp()) + switch (PokenavList_PageUp()) { case 0: return LT_FINISH; @@ -562,7 +562,7 @@ static u32 LoopedTask_RibbonsListMovePageUp(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMonListLoopedTaskActive()) + if (IsMovePokenavListWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -582,7 +582,7 @@ static u32 LoopedTask_RibbonsListMovePageDown(s32 state) switch (state) { case 0: - switch (MatchCall_PageDown()) + switch (PokenavList_PageDown()) { case 0: return LT_FINISH; @@ -595,7 +595,7 @@ static u32 LoopedTask_RibbonsListMovePageDown(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMonListLoopedTaskActive()) + if (IsMovePokenavListWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -677,32 +677,32 @@ static void DrawListIndexNumber(s32 windowId, s32 index, s32 max) AddTextPrinterParameterized(windowId, FONT_NORMAL, strbuf, x, 1, TEXT_SKIP_DRAW, NULL); } -static void InitMonRibbonPokenavListMenuTemplate(void) +static void CreateRibbonMonsList(void) { struct PokenavListTemplate template; template.list = (struct PokenavListItem *)GetMonRibbonMonListData(); template.count = GetRibbonsMonListCount(); - template.unk8 = 4; - template.unk6 = GetRibbonListMenuCurrIndex(); + template.itemSize = sizeof(struct PokenavListItem); + template.startIndex = GetRibbonListMenuCurrIndex(); template.item_X = 13; template.windowWidth = 17; template.listTop = 1; template.maxShowed = 8; template.fillValue = 2; template.fontId = FONT_NORMAL; - template.bufferItemFunc = (PokenavListItemBufferFunc)BufferRibbonMonInfoText; - template.unk14 = NULL; - sub_81C81D4(&sMonRibbonListBgTemplates[1], &template, 0); + template.bufferItemFunc = BufferRibbonMonInfoText; + template.iconDrawFunc = NULL; + CreatePokenavList(&sMonRibbonListBgTemplates[1], &template, 0); } // Buffers the "Nickname gender/level" text for the ribbon mon list -static void BufferRibbonMonInfoText(struct PokenavMonListItem * item0, u8 * dest) +static void BufferRibbonMonInfoText(struct PokenavListItem * listItem, u8 * dest) { u8 gender; u8 level; u8 * s; const u8 * genderStr; - struct PokenavMonListItem * item = item0; + struct PokenavMonListItem * item = (struct PokenavMonListItem *)listItem; // Mon is in party if (item->boxId == TOTAL_BOXES_COUNT) From 7e27a0746de931a99d78e5db584e8fbdb84c8edd Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 14 Nov 2021 09:55:30 -0500 Subject: [PATCH 14/19] Misc text clean-up --- gflib/text.c | 248 +++++++++--------- gflib/text.h | 8 - .../{down_arrow_RS.png => down_arrow_alt.png} | Bin src/braille.c | 6 +- 4 files changed, 129 insertions(+), 133 deletions(-) rename graphics/fonts/{down_arrow_RS.png => down_arrow_alt.png} (100%) diff --git a/gflib/text.c b/gflib/text.c index bf5b01e48..557c11704 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -13,8 +13,8 @@ #include "dynamic_placeholder_text_util.h" #include "fonts.h" -static u16 RenderText(struct TextPrinter *textPrinter); -static u32 RenderFont(struct TextPrinter *textPrinter); +static u16 RenderText(struct TextPrinter *); +static u32 RenderFont(struct TextPrinter *); static u16 FontFunc_Small(struct TextPrinter *); static u16 FontFunc_Normal(struct TextPrinter *); static u16 FontFunc_Short(struct TextPrinter *); @@ -23,32 +23,32 @@ static u16 FontFunc_ShortCopy2(struct TextPrinter *); static u16 FontFunc_ShortCopy3(struct TextPrinter *); static u16 FontFunc_Narrow(struct TextPrinter *); static u16 FontFunc_SmallNarrow(struct TextPrinter *); -static void DecompressGlyph_Small(u16 glyphId, bool32 isJapanese); -static void DecompressGlyph_Normal(u16 glyphId, bool32 isJapanese); -static void DecompressGlyph_Short(u16 glyphId, bool32 isJapanese); -static void DecompressGlyph_Narrow(u16 glyphId, bool32 isJapanese); -static void DecompressGlyph_SmallNarrow(u16 glyphId, bool32 isJapanese); -static void DecompressGlyph_Bold(u16 glyphId); -static u32 GetGlyphWidth_Small(u16 glyphId, bool32 isJapanese); -static u32 GetGlyphWidth_Normal(u16 glyphId, bool32 isJapanese); -static u32 GetGlyphWidth_Short(u16 glyphId, bool32 isJapanese); -static u32 GetGlyphWidth_Narrow(u16 glyphId, bool32 isJapanese); -static u32 GetGlyphWidth_SmallNarrow(u16 glyphId, bool32 isJapanese); +static void DecompressGlyph_Small(u16, bool32); +static void DecompressGlyph_Normal(u16, bool32); +static void DecompressGlyph_Short(u16, bool32); +static void DecompressGlyph_Narrow(u16, bool32); +static void DecompressGlyph_SmallNarrow(u16, bool32); +static void DecompressGlyph_Bold(u16); +static u32 GetGlyphWidth_Small(u16, bool32); +static u32 GetGlyphWidth_Normal(u16, bool32); +static u32 GetGlyphWidth_Short(u16, bool32); +static u32 GetGlyphWidth_Narrow(u16, bool32); +static u32 GetGlyphWidth_SmallNarrow(u16, bool32); -EWRAM_DATA struct TextPrinter gTempTextPrinter = {0}; -EWRAM_DATA struct TextPrinter gTextPrinters[NUM_TEXT_PRINTERS] = {0}; +static EWRAM_DATA struct TextPrinter sTempTextPrinter = {0}; +static EWRAM_DATA struct TextPrinter sTextPrinters[NUM_TEXT_PRINTERS] = {0}; -static u16 gFontHalfRowLookupTable[0x51]; -static u16 gLastTextBgColor; -static u16 gLastTextFgColor; -static u16 gLastTextShadowColor; +static u16 sFontHalfRowLookupTable[0x51]; +static u16 sLastTextBgColor; +static u16 sLastTextFgColor; +static u16 sLastTextShadowColor; const struct FontInfo *gFonts; bool8 gDisableTextPrinters; struct TextGlyph gCurGlyph; TextFlags gTextFlags; -const u8 gFontHalfRowOffsets[] = +static const u8 sFontHalfRowOffsets[] = { 0x00, 0x01, 0x02, 0x00, 0x03, 0x04, 0x05, 0x03, 0x06, 0x07, 0x08, 0x06, 0x00, 0x01, 0x02, 0x00, 0x09, 0x0A, 0x0B, 0x09, 0x0C, 0x0D, 0x0E, 0x0C, 0x0F, 0x10, 0x11, 0x0F, 0x09, 0x0A, 0x0B, 0x09, @@ -68,12 +68,16 @@ const u8 gFontHalfRowOffsets[] = 0x00, 0x01, 0x02, 0x00, 0x03, 0x04, 0x05, 0x03, 0x06, 0x07, 0x08, 0x06, 0x00, 0x01, 0x02, 0x00 }; -const u8 gDownArrowTiles[] = INCBIN_U8("graphics/fonts/down_arrow.4bpp"); -const u8 gDarkDownArrowTiles[] = INCBIN_U8("graphics/fonts/down_arrow_RS.4bpp"); -const u8 gUnusedFRLGBlankedDownArrow[] = INCBIN_U8("graphics/fonts/unused_frlg_blanked_down_arrow.4bpp"); -const u8 gUnusedFRLGDownArrow[] = INCBIN_U8("graphics/fonts/unused_frlg_down_arrow.4bpp"); -const u8 gDownArrowYCoords[] = { 0, 1, 2, 1 }; -const u8 gWindowVerticalScrollSpeeds[] = { 1, 2, 4, 0x0 }; +static const u8 sDownArrowTiles[] = INCBIN_U8("graphics/fonts/down_arrow.4bpp"); +static const u8 sDarkDownArrowTiles[] = INCBIN_U8("graphics/fonts/down_arrow_alt.4bpp"); +static const u8 sUnusedFRLGBlankedDownArrow[] = INCBIN_U8("graphics/fonts/unused_frlg_blanked_down_arrow.4bpp"); +static const u8 sUnusedFRLGDownArrow[] = INCBIN_U8("graphics/fonts/unused_frlg_down_arrow.4bpp"); +static const u8 sDownArrowYCoords[] = { 0, 1, 2, 1 }; +static const u8 sWindowVerticalScrollSpeeds[] = { + [OPTIONS_TEXT_SPEED_SLOW] = 1, + [OPTIONS_TEXT_SPEED_MID] = 2, + [OPTIONS_TEXT_SPEED_FAST] = 4, +}; static const struct GlyphWidthFunc sGlyphWidthFuncs[] = { @@ -88,24 +92,29 @@ static const struct GlyphWidthFunc sGlyphWidthFuncs[] = { FONT_SMALL_NARROW, GetGlyphWidth_SmallNarrow } }; -const struct KeypadIcon gKeypadIcons[] = +struct { - [CHAR_A_BUTTON] = { 0x0, 0x8, 0xC }, - [CHAR_B_BUTTON] = { 0x1, 0x8, 0xC }, - [CHAR_L_BUTTON] = { 0x2, 0x10, 0xC }, - [CHAR_R_BUTTON] = { 0x4, 0x10, 0xC }, - [CHAR_START_BUTTON] = { 0x6, 0x18, 0xC }, - [CHAR_SELECT_BUTTON] = { 0x9, 0x18, 0xC }, - [CHAR_DPAD_UP] = { 0xC, 0x8, 0xC }, - [CHAR_DPAD_DOWN] = { 0xD, 0x8, 0xC }, - [CHAR_DPAD_LEFT] = { 0xE, 0x8, 0xC }, - [CHAR_DPAD_RIGHT] = { 0xF, 0x8, 0xC }, - [CHAR_DPAD_UPDOWN] = { 0x20, 0x8, 0xC }, - [CHAR_DPAD_LEFTRIGHT] = { 0x21, 0x8, 0xC }, - [CHAR_DPAD_NONE] = { 0x22, 0x8, 0xC } + u16 tileOffset; + u8 width; + u8 height; +} static const sKeypadIcons[] = +{ + [CHAR_A_BUTTON] = { 0x00, 8, 12 }, + [CHAR_B_BUTTON] = { 0x01, 8, 12 }, + [CHAR_L_BUTTON] = { 0x02, 16, 12 }, + [CHAR_R_BUTTON] = { 0x04, 16, 12 }, + [CHAR_START_BUTTON] = { 0x06, 24, 12 }, + [CHAR_SELECT_BUTTON] = { 0x09, 24, 12 }, + [CHAR_DPAD_UP] = { 0x0C, 8, 12 }, + [CHAR_DPAD_DOWN] = { 0x0D, 8, 12 }, + [CHAR_DPAD_LEFT] = { 0x0E, 8, 12 }, + [CHAR_DPAD_RIGHT] = { 0x0F, 8, 12 }, + [CHAR_DPAD_UPDOWN] = { 0x20, 8, 12 }, + [CHAR_DPAD_LEFTRIGHT] = { 0x21, 8, 12 }, + [CHAR_DPAD_NONE] = { 0x22, 8, 12 } }; -const u8 gKeypadIconTiles[] = INCBIN_U8("graphics/fonts/keypad_icons.4bpp"); +static const u8 sKeypadIconTiles[] = INCBIN_U8("graphics/fonts/keypad_icons.4bpp"); static const struct FontInfo sFontInfos[] = { @@ -225,7 +234,7 @@ static const u8 sMenuCursorDimensions[][2] = [FONT_BOLD] = {} }; -const u16 gFontBoldJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/bold.hwjpnfont"); +static const u16 sFontBoldJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/bold.hwjpnfont"); static void SetFontsPointer(const struct FontInfo *fonts) { @@ -236,7 +245,7 @@ void DeactivateAllTextPrinters(void) { int printer; for (printer = 0; printer < NUM_TEXT_PRINTERS; ++printer) - gTextPrinters[printer].active = FALSE; + sTextPrinters[printer].active = FALSE; } u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)) @@ -267,41 +276,41 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, voi if (!gFonts) return FALSE; - gTempTextPrinter.active = TRUE; - gTempTextPrinter.state = RENDER_STATE_HANDLE_CHAR; - gTempTextPrinter.textSpeed = speed; - gTempTextPrinter.delayCounter = 0; - gTempTextPrinter.scrollDistance = 0; + sTempTextPrinter.active = TRUE; + sTempTextPrinter.state = RENDER_STATE_HANDLE_CHAR; + sTempTextPrinter.textSpeed = speed; + sTempTextPrinter.delayCounter = 0; + sTempTextPrinter.scrollDistance = 0; - for (i = 0; i < (int)ARRAY_COUNT(gTempTextPrinter.subStructFields); i++) - gTempTextPrinter.subStructFields[i] = 0; + for (i = 0; i < (int)ARRAY_COUNT(sTempTextPrinter.subStructFields); i++) + sTempTextPrinter.subStructFields[i] = 0; - gTempTextPrinter.printerTemplate = *printerTemplate; - gTempTextPrinter.callback = callback; - gTempTextPrinter.minLetterSpacing = 0; - gTempTextPrinter.japanese = 0; + sTempTextPrinter.printerTemplate = *printerTemplate; + sTempTextPrinter.callback = callback; + sTempTextPrinter.minLetterSpacing = 0; + sTempTextPrinter.japanese = 0; GenerateFontHalfRowLookupTable(printerTemplate->fgColor, printerTemplate->bgColor, printerTemplate->shadowColor); if (speed != TEXT_SKIP_DRAW && speed != 0) { - --gTempTextPrinter.textSpeed; - gTextPrinters[printerTemplate->windowId] = gTempTextPrinter; + --sTempTextPrinter.textSpeed; + sTextPrinters[printerTemplate->windowId] = sTempTextPrinter; } else { - gTempTextPrinter.textSpeed = 0; + sTempTextPrinter.textSpeed = 0; // Render all text (up to limit) at once for (j = 0; j < 0x400; ++j) { - if (RenderFont(&gTempTextPrinter) == RENDER_FINISH) + if (RenderFont(&sTempTextPrinter) == RENDER_FINISH) break; } // All the text is rendered to the window but don't draw it yet. if (speed != TEXT_SKIP_DRAW) - CopyWindowToVram(gTempTextPrinter.printerTemplate.windowId, COPYWIN_GFX); - gTextPrinters[printerTemplate->windowId].active = FALSE; + CopyWindowToVram(sTempTextPrinter.printerTemplate.windowId, COPYWIN_GFX); + sTextPrinters[printerTemplate->windowId].active = FALSE; } gDisableTextPrinters = FALSE; return TRUE; @@ -315,19 +324,19 @@ void RunTextPrinters(void) { for (i = 0; i < NUM_TEXT_PRINTERS; ++i) { - if (gTextPrinters[i].active) + if (sTextPrinters[i].active) { - u16 temp = RenderFont(&gTextPrinters[i]); + u16 temp = RenderFont(&sTextPrinters[i]); switch (temp) { case RENDER_PRINT: - CopyWindowToVram(gTextPrinters[i].printerTemplate.windowId, COPYWIN_GFX); + CopyWindowToVram(sTextPrinters[i].printerTemplate.windowId, COPYWIN_GFX); case RENDER_UPDATE: - if (gTextPrinters[i].callback != 0) - gTextPrinters[i].callback(&gTextPrinters[i].printerTemplate, temp); + if (sTextPrinters[i].callback != 0) + sTextPrinters[i].callback(&sTextPrinters[i].printerTemplate, temp); break; case RENDER_FINISH: - gTextPrinters[i].active = FALSE; + sTextPrinters[i].active = FALSE; break; } } @@ -337,7 +346,7 @@ void RunTextPrinters(void) bool16 IsTextPrinterActive(u8 id) { - return gTextPrinters[id].active; + return sTextPrinters[id].active; } static u32 RenderFont(struct TextPrinter *textPrinter) @@ -356,11 +365,11 @@ void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor) u32 fg12, bg12, shadow12; u32 temp; - u16 *current = gFontHalfRowLookupTable; + u16 *current = sFontHalfRowLookupTable; - gLastTextBgColor = bgColor; - gLastTextFgColor = fgColor; - gLastTextShadowColor = shadowColor; + sLastTextBgColor = bgColor; + sLastTextFgColor = fgColor; + sLastTextShadowColor = shadowColor; bg12 = bgColor << 12; fg12 = fgColor << 12; @@ -504,9 +513,9 @@ void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor) void SaveTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor) { - *bgColor = gLastTextBgColor; - *fgColor = gLastTextFgColor; - *shadowColor = gLastTextShadowColor; + *bgColor = sLastTextBgColor; + *fgColor = sLastTextFgColor; + *shadowColor = sLastTextShadowColor; } void RestoreTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor) @@ -521,40 +530,41 @@ void DecompressGlyphTile(const void *src_, void *dest_) u32 *dest = dest_; temp = *(src++); - *(dest)++ = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]); + *(dest)++ = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]); temp = *(src++); - *(dest++) = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]); + *(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]); temp = *(src++); - *(dest++) = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]); + *(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]); temp = *(src++); - *(dest++) = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]); + *(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]); temp = *(src++); - *(dest++) = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]); + *(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]); temp = *(src++); - *(dest++) = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]); + *(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]); temp = *(src++); - *(dest++) = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]); + *(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]); temp = *(src++); - *(dest++) = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]); + *(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]); } -u8 GetLastTextColor(u8 colorType) +// Unused +static u8 GetLastTextColor(u8 colorType) { switch (colorType) { case 0: - return gLastTextFgColor; + return sLastTextFgColor; case 2: - return gLastTextBgColor; + return sLastTextBgColor; case 1: - return gLastTextShadowColor; + return sLastTextShadowColor; default: return 0; } @@ -644,7 +654,7 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width) struct TextGlyph *glyph; u8* glyphHeight; - if (gLastTextBgColor != 0) + if (sLastTextBgColor != TEXT_COLOR_TRANSPARENT) { window = &gWindows[textPrinter->printerTemplate.windowId]; pixels_data.pixels = window->tileData; @@ -660,7 +670,7 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width) textPrinter->printerTemplate.currentY, width, *glyphHeight, - gLastTextBgColor); + sLastTextBgColor); } } @@ -798,20 +808,20 @@ void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter) switch (gTextFlags.useAlternateDownArrow) { - case FALSE: - default: - arrowTiles = gDownArrowTiles; - break; - case TRUE: - arrowTiles = gDarkDownArrowTiles; - break; + case FALSE: + default: + arrowTiles = sDownArrowTiles; + break; + case TRUE: + arrowTiles = sDarkDownArrowTiles; + break; } BlitBitmapRectToWindow( textPrinter->printerTemplate.windowId, arrowTiles, 0, - gDownArrowYCoords[subStruct->downArrowYPosIdx], + sDownArrowYCoords[subStruct->downArrowYPosIdx], 8, 16, textPrinter->printerTemplate.currentX, @@ -905,26 +915,16 @@ void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *c { switch (gTextFlags.useAlternateDownArrow) { - case 0: - default: - arrowTiles = gDownArrowTiles; - break; - case 1: - arrowTiles = gDarkDownArrowTiles; - break; + case FALSE: + default: + arrowTiles = sDownArrowTiles; + break; + case TRUE: + arrowTiles = sDarkDownArrowTiles; + break; } - BlitBitmapRectToWindow( - windowId, - arrowTiles, - 0, - gDownArrowYCoords[*yCoordIndex & 3], - 0x8, - 0x10, - x, - y - 2, - 0x8, - 0x10); + BlitBitmapRectToWindow(windowId, arrowTiles, 0, sDownArrowYCoords[*yCoordIndex & 3], 8, 16, x, y - 2, 8, 16); CopyWindowToVram(windowId, COPYWIN_GFX); *counter = 8; ++*yCoordIndex; @@ -942,7 +942,7 @@ static u16 RenderText(struct TextPrinter *textPrinter) switch (textPrinter->state) { case RENDER_STATE_HANDLE_CHAR: - if ((JOY_HELD(A_BUTTON | B_BUTTON)) && subStruct->hasPrintBeenSpedUp) + if (JOY_HELD(A_BUTTON | B_BUTTON) && subStruct->hasPrintBeenSpedUp) textPrinter->delayCounter = 0; if (textPrinter->delayCounter && textPrinter->textSpeed) @@ -1191,7 +1191,7 @@ static u16 RenderText(struct TextPrinter *textPrinter) if (textPrinter->scrollDistance) { int scrollSpeed = GetPlayerTextSpeed(); - int speed = gWindowVerticalScrollSpeeds[scrollSpeed]; + int speed = sWindowVerticalScrollSpeeds[scrollSpeed]; if (textPrinter->scrollDistance < speed) { ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, PIXEL_FILL(textPrinter->printerTemplate.bgColor)); @@ -1612,31 +1612,31 @@ u8 DrawKeypadIcon(u8 windowId, u8 keypadIconId, u16 x, u16 y) { BlitBitmapRectToWindow( windowId, - gKeypadIconTiles + (gKeypadIcons[keypadIconId].tileOffset * 0x20), + sKeypadIconTiles + (sKeypadIcons[keypadIconId].tileOffset * 0x20), 0, 0, 0x80, 0x80, x, y, - gKeypadIcons[keypadIconId].width, - gKeypadIcons[keypadIconId].height); - return gKeypadIcons[keypadIconId].width; + sKeypadIcons[keypadIconId].width, + sKeypadIcons[keypadIconId].height); + return sKeypadIcons[keypadIconId].width; } u8 GetKeypadIconTileOffset(u8 keypadIconId) { - return gKeypadIcons[keypadIconId].tileOffset; + return sKeypadIcons[keypadIconId].tileOffset; } u8 GetKeypadIconWidth(u8 keypadIconId) { - return gKeypadIcons[keypadIconId].width; + return sKeypadIcons[keypadIconId].width; } u8 GetKeypadIconHeight(u8 keypadIconId) { - return gKeypadIcons[keypadIconId].height; + return sKeypadIcons[keypadIconId].height; } void SetDefaultFontsPointer(void) @@ -1898,7 +1898,7 @@ static void DecompressGlyph_Bold(u16 glyphId) { const u16* glyphs; - glyphs = gFontBoldJapaneseGlyphs + (0x100 * (glyphId >> 4)) + (0x8 * (glyphId & 0xF)); + glyphs = sFontBoldJapaneseGlyphs + (0x100 * (glyphId >> 4)) + (0x8 * (glyphId & 0xF)); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); gCurGlyph.width = 8; diff --git a/gflib/text.h b/gflib/text.h index 110df8b87..2f660354f 100644 --- a/gflib/text.h +++ b/gflib/text.h @@ -117,13 +117,6 @@ struct GlyphWidthFunc u32 (*func)(u16 glyphId, bool32 isJapanese); }; -struct KeypadIcon -{ - u16 tileOffset; - u8 width; - u8 height; -}; - typedef struct { bool8 canABSpeedUpPrint:1; bool8 useAlternateDownArrow:1; @@ -153,7 +146,6 @@ void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor); void SaveTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor); void RestoreTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor); void DecompressGlyphTile(const void *src_, void *dest_); -u8 GetLastTextColor(u8 colorType); void CopyGlyphToWindow(struct TextPrinter *x); void ClearTextSpan(struct TextPrinter *textPrinter, u32 width); u8 GetMenuCursorDimensionByFont(u8, u8); diff --git a/graphics/fonts/down_arrow_RS.png b/graphics/fonts/down_arrow_alt.png similarity index 100% rename from graphics/fonts/down_arrow_RS.png rename to graphics/fonts/down_arrow_alt.png diff --git a/src/braille.c b/src/braille.c index b4ee43ad0..704f50760 100644 --- a/src/braille.c +++ b/src/braille.c @@ -8,7 +8,11 @@ // For printing braille messages, see ScrCmd_braillemessage ALIGNED(4) -static const u8 sScrollDistances[] = {1, 2, 4}; +static const u8 sScrollDistances[] = { + [OPTIONS_TEXT_SPEED_SLOW] = 1, + [OPTIONS_TEXT_SPEED_MID] = 2, + [OPTIONS_TEXT_SPEED_FAST] = 4, +}; static const u16 sFont_Braille[] = INCBIN_U16("graphics/fonts/braille.fwjpnfont"); static void DecompressGlyph_Braille(u16); From d4d42342839719389596f26cc291b89e77f69813 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 14 Nov 2021 22:21:50 -0500 Subject: [PATCH 15/19] Finish pokenav list ui doc --- include/pokenav.h | 12 +- src/pokenav_conditions_search_results.c | 12 +- src/pokenav_match_call_1.c | 4 +- src/pokenav_match_call_2.c | 40 ++--- src/pokenav_match_call_ui.c | 187 ++++++++++++------------ src/pokenav_ribbons_list.c | 14 +- 6 files changed, 135 insertions(+), 134 deletions(-) diff --git a/include/pokenav.h b/include/pokenav.h index 9c530e11e..b5eb20a7f 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -327,19 +327,19 @@ void SetVBlankCallback_(IntrCallback callback); bool32 CreatePokenavList(const struct BgTemplate *bgTemplate, struct PokenavListTemplate *listTemplate, s32 tileOffset); bool32 IsCreatePokenavListTaskActive(void); void DestroyPokenavList(void); -u32 GetSelectedPokenavListIndex(void); +u32 PokenavList_GetSelectedIndex(void); int PokenavList_MoveCursorUp(void); int PokenavList_MoveCursorDown(void); int PokenavList_PageDown(void); int PokenavList_PageUp(void); -bool32 IsMovePokenavListWindowTaskActive(void); +bool32 PokenavList_IsMoveWindowTaskActive(void); void PokenavList_ToggleVerticalArrows(bool32 shouldHide); void PokenavList_DrawCurrentItemIcon(void); -void sub_81C877C(void); -bool32 IsMatchCallListTaskActive(void); +void PokenavList_EraseListForCheckPage(void); +bool32 PokenavList_IsTaskActive(void); void PrintCheckPageInfo(s16 a0); -u32 GetMatchCallListTopIndex(void); -void sub_81C87F0(void); +u32 PokenavList_GetTopIndex(void); +void PokenavList_ReshowListFromCheckPage(void); // pokenav_match_call_data.c bool32 MatchCall_HasCheckPage(u32 idx); diff --git a/src/pokenav_conditions_search_results.c b/src/pokenav_conditions_search_results.c index 09bb7c9ac..c8790e359 100644 --- a/src/pokenav_conditions_search_results.c +++ b/src/pokenav_conditions_search_results.c @@ -200,7 +200,7 @@ static u32 HandleConditionSearchInput(struct Pokenav_SearchResults *menu) else if (JOY_NEW(A_BUTTON)) { // Entering graph menu - menu->monList->currIndex = GetSelectedPokenavListIndex(); + menu->monList->currIndex = PokenavList_GetSelectedIndex(); menu->saveResultsList = TRUE; menu->callback = OpenConditionGraphFromSearchList; return CONDITION_SEARCH_FUNC_SELECT_MON; @@ -241,7 +241,7 @@ static u16 GetSearchResultsMonListCount(void) static s32 GetSearchResultsSelectedMonRank(void) { struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); - s32 i = GetSelectedPokenavListIndex(); + s32 i = PokenavList_GetSelectedIndex(); return menu->monList->monData[i].data; } @@ -498,7 +498,7 @@ static u32 LoopedTask_MoveSearchListCursorUp(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMovePokenavListWindowTaskActive()) + if (PokenavList_IsMoveWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -531,7 +531,7 @@ static u32 LoopedTask_MoveSearchListCursorDown(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMovePokenavListWindowTaskActive()) + if (PokenavList_IsMoveWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -564,7 +564,7 @@ static u32 LoopedTask_MoveSearchListPageUp(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMovePokenavListWindowTaskActive()) + if (PokenavList_IsMoveWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -597,7 +597,7 @@ static u32 LoopedTask_MoveSearchListPageDown(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMovePokenavListWindowTaskActive()) + if (PokenavList_IsMoveWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: diff --git a/src/pokenav_match_call_1.c b/src/pokenav_match_call_1.c index b2b9179c3..e0e5306e1 100755 --- a/src/pokenav_match_call_1.c +++ b/src/pokenav_match_call_1.c @@ -92,7 +92,7 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) { state->callback = CB2_HandleMatchCallOptionsInput; state->optionCursorPos = 0; - selection = GetSelectedPokenavListIndex(); + selection = PokenavList_GetSelectedIndex(); if (!state->matchCallEntries[selection].isSpecialTrainer || MatchCall_HasCheckPage(state->matchCallEntries[selection].headerId)) { @@ -489,7 +489,7 @@ bool32 unref_sub_81CB16C(void) static bool32 ShouldDoNearbyMessage(void) { struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); - int selection = GetSelectedPokenavListIndex(); + int selection = PokenavList_GetSelectedIndex(); if (!state->matchCallEntries[selection].isSpecialTrainer) { if (GetMatchCallMapSec(selection) == gMapHeader.regionMapSectionId) diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index 420dac5f8..d8704919f 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -414,7 +414,7 @@ static u32 MatchCallListCursorDown(s32 state) } break; case 1: - if (IsMovePokenavListWindowTaskActive()) + if (PokenavList_IsMoveWindowTaskActive()) return LT_PAUSE; PrintMatchCallLocation(gfx, 0); @@ -451,7 +451,7 @@ static u32 MatchCallListCursorUp(s32 state) } break; case 1: - if (IsMovePokenavListWindowTaskActive()) + if (PokenavList_IsMoveWindowTaskActive()) return LT_PAUSE; PrintMatchCallLocation(gfx, 0); @@ -488,7 +488,7 @@ static u32 MatchCallListPageDown(s32 state) } break; case 1: - if (IsMovePokenavListWindowTaskActive()) + if (PokenavList_IsMoveWindowTaskActive()) return LT_PAUSE; PrintMatchCallLocation(gfx, 0); @@ -525,7 +525,7 @@ static u32 MatchCallListPageUp(s32 state) } break; case 1: - if (IsMovePokenavListWindowTaskActive()) + if (PokenavList_IsMoveWindowTaskActive()) return LT_PAUSE; PrintMatchCallLocation(gfx, 0); @@ -722,11 +722,11 @@ static u32 ShowCheckPage(s32 state) { case 0: PlaySE(SE_SELECT); - sub_81C877C(); + PokenavList_EraseListForCheckPage(); UpdateWindowsToShowCheckPage(gfx); return LT_INC_AND_PAUSE; case 1: - if (IsMatchCallListTaskActive() || IsDma3ManagerBusyWithBgCopy1(gfx)) + if (PokenavList_IsTaskActive() || IsDma3ManagerBusyWithBgCopy1(gfx)) return LT_PAUSE; PrintHelpBarText(HELPBAR_MC_CHECK_PAGE); @@ -736,7 +736,7 @@ static u32 ShowCheckPage(s32 state) LoadCheckPageTrainerPic(gfx); return LT_INC_AND_PAUSE; case 3: - if (IsMatchCallListTaskActive() || WaitForTrainerPic(gfx) || WaitForHelpBar()) + if (PokenavList_IsTaskActive() || WaitForTrainerPic(gfx) || WaitForHelpBar()) return LT_PAUSE; break; } @@ -752,7 +752,7 @@ static u32 ShowCheckPageDown(s32 state) switch (state) { case 0: - topId = GetMatchCallListTopIndex(); + topId = PokenavList_GetTopIndex(); delta = GetIndexDeltaOfNextCheckPageDown(topId); if (delta) { @@ -775,7 +775,7 @@ static u32 ShowCheckPageDown(s32 state) LoadCheckPageTrainerPic(gfx); return LT_INC_AND_PAUSE; case 4: - if (IsMatchCallListTaskActive() || WaitForTrainerPic(gfx)) + if (PokenavList_IsTaskActive() || WaitForTrainerPic(gfx)) return LT_PAUSE; break; } @@ -791,10 +791,10 @@ static u32 ExitCheckPage(s32 state) case 0: PlaySE(SE_SELECT); TrainerPicSlideOffscreen(gfx); - sub_81C87F0(); + PokenavList_ReshowListFromCheckPage(); return LT_INC_AND_PAUSE; case 1: - if (IsMatchCallListTaskActive() || WaitForTrainerPic(gfx)) + if (PokenavList_IsTaskActive() || WaitForTrainerPic(gfx)) return LT_PAUSE; PrintHelpBarText(HELPBAR_MC_TRAINER_LIST); @@ -817,7 +817,7 @@ static u32 ShowCheckPageUp(s32 state) switch (state) { case 0: - topId = GetMatchCallListTopIndex(); + topId = PokenavList_GetTopIndex(); delta = GetIndexDeltaOfNextCheckPageUp(topId); if (delta) { @@ -840,7 +840,7 @@ static u32 ShowCheckPageUp(s32 state) LoadCheckPageTrainerPic(gfx); return LT_INC_AND_PAUSE; case 4: - if (IsMatchCallListTaskActive() || WaitForTrainerPic(gfx)) + if (PokenavList_IsTaskActive() || WaitForTrainerPic(gfx)) return LT_PAUSE; break; } @@ -929,11 +929,11 @@ enum { POKEBALL_ICON_EMPTY, }; -static void TryDrawRematchPokeballIcon(u16 windowId, u32 rematchId, u32 arg2) +static void TryDrawRematchPokeballIcon(u16 windowId, u32 rematchId, u32 tileOffset) { u8 bg = GetWindowAttribute(windowId, WINDOW_BG); u16 *tilemap = GetBgTilemapBuffer(bg); - tilemap += arg2 * 0x40 + 0x1D; + tilemap += tileOffset * 64 + 0x1D; if (ShouldDrawRematchPokeballIcon(rematchId)) { tilemap[0] = POKEBALL_ICON_TOP; @@ -946,11 +946,11 @@ static void TryDrawRematchPokeballIcon(u16 windowId, u32 rematchId, u32 arg2) } } -void ClearRematchPokeballIcon(u16 windowId, u32 arg0) +void ClearRematchPokeballIcon(u16 windowId, u32 tileOffset) { u8 bg = GetWindowAttribute(windowId, WINDOW_BG); u16 *tilemap = GetBgTilemapBuffer(bg); - tilemap += arg0 * 0x40 + 0x1D; + tilemap += tileOffset * 64 + 0x1D; tilemap[0] = POKEBALL_ICON_EMPTY; tilemap[0x20] = POKEBALL_ICON_EMPTY; } @@ -1021,7 +1021,7 @@ static void PrintMatchCallLocation(struct Pokenav_MatchCallGfx *gfx, int delta) { u8 mapName[32]; int x; - int index = GetSelectedPokenavListIndex() + delta; + int index = PokenavList_GetSelectedIndex() + delta; int mapSec = GetMatchCallMapSec(index); if (mapSec != MAPSEC_NONE) GetMapName(mapName, mapSec, 0); @@ -1138,7 +1138,7 @@ static bool32 WaitForTrainerIsCloseByText(struct Pokenav_MatchCallGfx *gfx) static void PrintMatchCallMessage(struct Pokenav_MatchCallGfx *gfx) { - int index = GetSelectedPokenavListIndex(); + int index = PokenavList_GetSelectedIndex(); const u8 *str = GetMatchCallMessageText(index, &gfx->newRematchRequest); u8 speed = GetPlayerTextSpeedDelay(); AddTextPrinterParameterized(gfx->msgBoxWindowId, FONT_NORMAL, str, 32, 1, speed, NULL); @@ -1244,7 +1244,7 @@ static struct Sprite *CreateTrainerPicSprite(void) static void LoadCheckPageTrainerPic(struct Pokenav_MatchCallGfx *gfx) { u16 cursor; - int trainerPic = GetMatchCallTrainerPic(GetSelectedPokenavListIndex()); + int trainerPic = GetMatchCallTrainerPic(PokenavList_GetSelectedIndex()); if (trainerPic >= 0) { DecompressPicFromTable(&gTrainerFrontPicTable[trainerPic], gfx->trainerPicGfx, SPECIES_NONE); diff --git a/src/pokenav_match_call_ui.c b/src/pokenav_match_call_ui.c index 70e541b55..97437e3cd 100644 --- a/src/pokenav_match_call_ui.c +++ b/src/pokenav_match_call_ui.c @@ -29,11 +29,10 @@ struct PokenavListWindowState { // The index of the element at the top of the window. u16 windowTopIndex; u16 listLength; - u16 unk4; + u16 entriesOffscreen; // The index of the cursor, relative to the top of the window. u16 selectedIndexOffset; - u16 visibleEntries; - u16 unkA; + u16 entriesOnscreen; u32 listItemSize; void * listPtr; }; @@ -63,7 +62,7 @@ struct PokenavSub17 struct PokenavSub17Substruct list; u8 tilemapBuffer[BG_SCREEN_SIZE]; struct PokenavListWindowState windowState; - s32 unk89C; + s32 eraseIndex; u32 loopedTaskId; }; @@ -81,7 +80,7 @@ static void PrintMatchCallFlavorText(struct PokenavListWindowState *, struct Pok static void PrintMatchCallFieldNames(struct PokenavSub17Substruct *, u32); static void PrintMatchCallListTrainerName(struct PokenavListWindowState *, struct PokenavSub17Substruct *); static void PrintCheckPageTrainerName(struct PokenavListWindowState *, struct PokenavSub17Substruct *); -static void sub_81C8B70(struct PokenavListMenuWindow *, s32, s32); +static void EraseListEntry(struct PokenavListMenuWindow *, s32, s32); static void CreateMoveListWindowTask(s32, struct PokenavSub17Substruct *); static void PrintListItems(void *, u32, u32, u32, u32, struct PokenavSub17Substruct *); static void InitListItems(struct PokenavListWindowState *, struct PokenavSub17Substruct *); @@ -90,14 +89,14 @@ static u32 LoopedTask_CreatePokenavList(s32); static bool32 IsPrintListItemsTaskActive(void); static u32 LoopedTask_PrintListItems(s32); static u32 LoopedTask_MoveListWindow(s32); -static u32 LoopedTask_sub_81C8870(s32); -static u32 LoopedTask_sub_81C8A28(s32); +static u32 LoopedTask_EraseListForCheckPage(s32); +static u32 LoopedTask_ReshowListFromCheckPage(s32); static u32 LoopedTask_PrintCheckPageInfo(s32); static const u16 sListArrow_Pal[] = INCBIN_U16("graphics/pokenav/list_arrows.gbapal"); static const u32 sListArrow_Gfx[] = INCBIN_U32("graphics/pokenav/list_arrows.4bpp.lz"); -static EWRAM_DATA u32 gUnknown_0203CF44 = 0; +static EWRAM_DATA u32 sMoveWindowDownIndex = 0; // Read, but pointlessly bool32 CreatePokenavList(const struct BgTemplate *bgTemplate, struct PokenavListTemplate *listTemplate, s32 tileOffset) { @@ -187,8 +186,8 @@ static void InitPokenavListWindow(struct PokenavListMenuWindow *listWindow) static void InitListItems(struct PokenavListWindowState *windowState, struct PokenavSub17Substruct *a1) { s32 numToPrint = windowState->listLength - windowState->windowTopIndex; - if (numToPrint > windowState->visibleEntries) - numToPrint = windowState->visibleEntries; + if (numToPrint > windowState->entriesOnscreen) + numToPrint = windowState->entriesOnscreen; PrintListItems(windowState->listPtr, windowState->windowTopIndex, numToPrint, windowState->listItemSize, 0, a1); } @@ -214,18 +213,18 @@ static bool32 IsPrintListItemsTaskActive(void) static u32 LoopedTask_PrintListItems(s32 state) { - u32 v1; + u32 row; struct PokenavSub17Substruct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); switch (state) { case 0: - v1 = (structPtr->listWindow.unkA + structPtr->listWindow.numPrinted + structPtr->unk10) & 0xF; + row = (structPtr->listWindow.unkA + structPtr->listWindow.numPrinted + structPtr->unk10) & 0xF; structPtr->bufferItemFunc(structPtr->listPtr, structPtr->itemTextBuffer); if (structPtr->iconDrawFunc != NULL) - structPtr->iconDrawFunc(structPtr->listWindow.windowId, structPtr->printIndex, v1); + structPtr->iconDrawFunc(structPtr->listWindow.windowId, structPtr->printIndex, row); - AddTextPrinterParameterized(structPtr->listWindow.windowId, structPtr->listWindow.fontId, structPtr->itemTextBuffer, 8, (v1 << 4) + 1, 255, NULL); + AddTextPrinterParameterized(structPtr->listWindow.windowId, structPtr->listWindow.fontId, structPtr->itemTextBuffer, 8, (row << 4) + 1, TEXT_SKIP_DRAW, NULL); if (++structPtr->listWindow.numPrinted >= structPtr->listWindow.numToPrint) { // Finished printing items. If icons were being drawn, draw the @@ -250,22 +249,22 @@ static u32 LoopedTask_PrintListItems(s32 state) return LT_FINISH; } -bool32 ShouldShowUpArrow(void) +static bool32 ShouldShowUpArrow(void) { struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); return (structPtr->windowState.windowTopIndex != 0); } -bool32 ShouldShowDownArrow(void) +static bool32 ShouldShowDownArrow(void) { struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); struct PokenavListWindowState *subPtr = &structPtr->windowState; - return (subPtr->windowTopIndex + subPtr->visibleEntries < subPtr->listLength); + return (subPtr->windowTopIndex + subPtr->entriesOnscreen < subPtr->listLength); } -static void MoveListWindow(s32 delta, bool32 a1) +static void MoveListWindow(s32 delta, bool32 printItems) { struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); struct PokenavListWindowState *subPtr = &structPtr->windowState; @@ -274,16 +273,16 @@ static void MoveListWindow(s32 delta, bool32 a1) { if (subPtr->windowTopIndex + delta < 0) delta = -1 * subPtr->windowTopIndex; - if (a1) + if (printItems) PrintListItems(subPtr->listPtr, subPtr->windowTopIndex + delta, delta * -1, subPtr->listItemSize, delta, &structPtr->list); } - else if (a1) + else if (printItems) { - s32 temp = gUnknown_0203CF44 = subPtr->windowTopIndex + subPtr->visibleEntries; - if (temp + delta >= subPtr->listLength) - delta = subPtr->listLength - temp; + s32 index = sMoveWindowDownIndex = subPtr->windowTopIndex + subPtr->entriesOnscreen; + if (index + delta >= subPtr->listLength) + delta = subPtr->listLength - index; - PrintListItems(subPtr->listPtr, gUnknown_0203CF44, delta, subPtr->listItemSize, subPtr->visibleEntries, &structPtr->list); + PrintListItems(subPtr->listPtr, index, delta, subPtr->listItemSize, subPtr->entriesOnscreen, &structPtr->list); } CreateMoveListWindowTask(delta, &structPtr->list); @@ -341,7 +340,7 @@ static u32 LoopedTask_MoveListWindow(s32 state) return LT_FINISH; } -bool32 IsMovePokenavListWindowTaskActive(void) +bool32 PokenavList_IsMoveWindowTaskActive(void) { struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); return IsLoopedTaskActive(structPtr->list.loopedTaskId); @@ -376,7 +375,7 @@ int PokenavList_MoveCursorDown(void) if (structPtr->windowTopIndex + structPtr->selectedIndexOffset >= structPtr->listLength - 1) return 0; - if (structPtr->selectedIndexOffset < structPtr->visibleEntries - 1) + if (structPtr->selectedIndexOffset < structPtr->entriesOnscreen - 1) { structPtr->selectedIndexOffset++; return 1; @@ -396,8 +395,8 @@ int PokenavList_PageUp(void) if (ShouldShowUpArrow()) { - if (structPtr->windowTopIndex >= structPtr->visibleEntries) - scroll = structPtr->visibleEntries; + if (structPtr->windowTopIndex >= structPtr->entriesOnscreen) + scroll = structPtr->entriesOnscreen; else scroll = structPtr->windowTopIndex; MoveListWindow(scroll * -1, TRUE); @@ -417,21 +416,21 @@ int PokenavList_PageDown(void) if (ShouldShowDownArrow()) { - s32 windowBottomIndex = structPtr->windowTopIndex + structPtr->visibleEntries; - s32 scroll = structPtr->unk4 - structPtr->windowTopIndex; + s32 windowBottomIndex = structPtr->windowTopIndex + structPtr->entriesOnscreen; + s32 scroll = structPtr->entriesOffscreen - structPtr->windowTopIndex; - if (windowBottomIndex <= structPtr->unk4) - scroll = structPtr->visibleEntries; + if (windowBottomIndex <= structPtr->entriesOffscreen) + scroll = structPtr->entriesOnscreen; MoveListWindow(scroll, TRUE); return 2; } else { s32 cursor, lastVisibleIndex; - if (structPtr->listLength >= structPtr->visibleEntries) + if (structPtr->listLength >= structPtr->entriesOnscreen) { cursor = structPtr->selectedIndexOffset; - lastVisibleIndex = structPtr->visibleEntries; + lastVisibleIndex = structPtr->entriesOnscreen; } else { @@ -447,43 +446,43 @@ int PokenavList_PageDown(void) } } -u32 GetSelectedPokenavListIndex(void) +u32 PokenavList_GetSelectedIndex(void) { struct PokenavListWindowState *structPtr = GetPokenavListWindowState(); return structPtr->windowTopIndex + structPtr->selectedIndexOffset; } -u32 GetMatchCallListTopIndex(void) +u32 PokenavList_GetTopIndex(void) { struct PokenavListWindowState *structPtr = GetPokenavListWindowState(); return structPtr->windowTopIndex; } -void sub_81C877C(void) +void PokenavList_EraseListForCheckPage(void) { struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - structPtr->unk89C = 0; - structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C8870, 6); + structPtr->eraseIndex = 0; + structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_EraseListForCheckPage, 6); } void PrintCheckPageInfo(s16 delta) { struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); structPtr->windowState.windowTopIndex += delta; - structPtr->unk89C = 0; + structPtr->eraseIndex = 0; structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_PrintCheckPageInfo, 6); } -void sub_81C87F0(void) +void PokenavList_ReshowListFromCheckPage(void) { struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - structPtr->unk89C = 0; - structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C8A28, 6); + structPtr->eraseIndex = 0; + structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_ReshowListFromCheckPage, 6); } -bool32 IsMatchCallListTaskActive(void) +bool32 PokenavList_IsTaskActive(void) { struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); return IsLoopedTaskActive(structPtr->loopedTaskId); @@ -497,7 +496,7 @@ void PokenavList_DrawCurrentItemIcon(void) CopyWindowToVram(structPtr->list.listWindow.windowId, COPYWIN_MAP); } -static u32 LoopedTask_sub_81C8870(s32 state) +static u32 LoopedTask_EraseListForCheckPage(s32 state) { struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); @@ -507,18 +506,18 @@ static u32 LoopedTask_sub_81C8870(s32 state) ToggleListArrows(&structPtr->list, 1); // fall-through case 1: - if (structPtr->unk89C != structPtr->windowState.selectedIndexOffset) - sub_81C8B70(&structPtr->list.listWindow, structPtr->unk89C, 1); + if (structPtr->eraseIndex != structPtr->windowState.selectedIndexOffset) + EraseListEntry(&structPtr->list.listWindow, structPtr->eraseIndex, 1); - structPtr->unk89C++; + structPtr->eraseIndex++; return LT_INC_AND_PAUSE; case 2: if (!IsDma3ManagerBusyWithBgCopy()) { - if (structPtr->unk89C != structPtr->windowState.visibleEntries) - return 6; + if (structPtr->eraseIndex != structPtr->windowState.entriesOnscreen) + return LT_SET_STATE(1); if (structPtr->windowState.selectedIndexOffset != 0) - sub_81C8B70(&structPtr->list.listWindow, structPtr->unk89C, structPtr->windowState.selectedIndexOffset); + EraseListEntry(&structPtr->list.listWindow, structPtr->eraseIndex, structPtr->windowState.selectedIndexOffset); return LT_INC_AND_PAUSE; } @@ -535,7 +534,7 @@ static u32 LoopedTask_sub_81C8870(s32 state) } return LT_PAUSE; case 4: - if (IsMovePokenavListWindowTaskActive()) + if (PokenavList_IsMoveWindowTaskActive()) return LT_PAUSE; structPtr->windowState.selectedIndexOffset = 0; @@ -582,7 +581,7 @@ static u32 LoopedTask_PrintCheckPageInfo(s32 state) return LT_INC_AND_PAUSE; } -static u32 LoopedTask_sub_81C8A28(s32 state) +static u32 LoopedTask_ReshowListFromCheckPage(s32 state) { struct PokenavSub17 *structPtr; struct PokenavListWindowState *windowState; @@ -599,24 +598,26 @@ static u32 LoopedTask_sub_81C8A28(s32 state) switch (state) { case 0: + // Rewrite the name of the trainer whose check page was just being viewed. + // This is done to erase the red background it had. PrintMatchCallListTrainerName(windowState, subPtr0); return LT_INC_AND_PAUSE; case 1: - ptr = &structPtr->unk89C; - if (++(*ptr) < structPtr->windowState.visibleEntries) + ptr = &structPtr->eraseIndex; + if (++(*ptr) < structPtr->windowState.entriesOnscreen) { - sub_81C8B70(&subPtr0->listWindow, *ptr, 1); + EraseListEntry(&subPtr0->listWindow, *ptr, 1); return LT_PAUSE; } *ptr = 0; - if (windowState->listLength <= windowState->visibleEntries) + if (windowState->listLength <= windowState->entriesOnscreen) { if (windowState->windowTopIndex != 0) { s32 r4 = windowState->windowTopIndex; r5 = -r4; - sub_81C8B70(&subPtr0->listWindow, r5, r4); + EraseListEntry(&subPtr0->listWindow, r5, r4); windowState->selectedIndexOffset = r4; *ptr = r5; return LT_INC_AND_PAUSE; @@ -624,36 +625,36 @@ static u32 LoopedTask_sub_81C8A28(s32 state) } else { - if (windowState->windowTopIndex + windowState->visibleEntries > windowState->listLength) + if (windowState->windowTopIndex + windowState->entriesOnscreen > windowState->listLength) { - s32 r4 = windowState->windowTopIndex + windowState->visibleEntries - windowState->listLength; + s32 r4 = windowState->windowTopIndex + windowState->entriesOnscreen - windowState->listLength; r5 = -r4; - sub_81C8B70(&subPtr0->listWindow, r5, r4); + EraseListEntry(&subPtr0->listWindow, r5, r4); windowState->selectedIndexOffset = r4; *ptr = r5; return LT_INC_AND_PAUSE; } } - return 9; + return LT_SET_STATE(4); case 2: - MoveListWindow(structPtr->unk89C, FALSE); + MoveListWindow(structPtr->eraseIndex, FALSE); return LT_INC_AND_PAUSE; case 3: - if (!IsMovePokenavListWindowTaskActive()) + if (!PokenavList_IsMoveWindowTaskActive()) { - structPtr->unk89C = 0; - return 1; + structPtr->eraseIndex = 0; + return LT_INC_AND_CONTINUE; } - return 2; + return LT_PAUSE; case 4: - PrintListItems(windowState->listPtr, windowState->windowTopIndex + structPtr->unk89C, 1, windowState->listItemSize, structPtr->unk89C, &structPtr->list); + PrintListItems(windowState->listPtr, windowState->windowTopIndex + structPtr->eraseIndex, 1, windowState->listItemSize, structPtr->eraseIndex, &structPtr->list); return LT_INC_AND_PAUSE; case 5: if (IsPrintListItemsTaskActive()) return LT_PAUSE; - if (++structPtr->unk89C >= windowState->listLength || structPtr->unk89C >= windowState->visibleEntries) + if (++structPtr->eraseIndex >= windowState->listLength || structPtr->eraseIndex >= windowState->entriesOnscreen) return LT_INC_AND_CONTINUE; - return 9; + return LT_SET_STATE(4); case 6: ToggleListArrows(subPtr0, 0); return LT_FINISH; @@ -662,15 +663,15 @@ static u32 LoopedTask_sub_81C8A28(s32 state) return LT_FINISH; } -static void sub_81C8B70(struct PokenavListMenuWindow *listWindow, s32 a1, s32 a2) +static void EraseListEntry(struct PokenavListMenuWindow *listWindow, s32 a1, s32 a2) { u8 *tileData = (u8*)GetWindowAttribute(listWindow->windowId, WINDOW_TILE_DATA); - u32 v2 = listWindow->width * 64; + u32 width = listWindow->width * 64; a1 = (listWindow->unkA + a1) & 0xF; if (a1 + a2 <= 16) { - CpuFastFill8(PIXEL_FILL(1), tileData + a1 * v2, a2 * v2); + CpuFastFill8(PIXEL_FILL(1), tileData + a1 * width, a2 * width); CopyWindowToVram(listWindow->windowId, COPYWIN_GFX); } else @@ -678,8 +679,8 @@ static void sub_81C8B70(struct PokenavListMenuWindow *listWindow, s32 a1, s32 a2 u32 v3 = 16 - a1; u32 v4 = a2 - v3; - CpuFastFill8(PIXEL_FILL(1), tileData + a1 * v2, v3 * v2); - CpuFastFill8(PIXEL_FILL(1), tileData, v4 * v2); + CpuFastFill8(PIXEL_FILL(1), tileData + a1 * width, v3 * width); + CpuFastFill8(PIXEL_FILL(1), tileData, v4 * width); CopyWindowToVram(listWindow->windowId, COPYWIN_GFX); } @@ -689,19 +690,20 @@ static void sub_81C8B70(struct PokenavListMenuWindow *listWindow, s32 a1, s32 a2 CopyWindowToVram(listWindow->windowId, COPYWIN_MAP); } -void sub_81C8C64(struct PokenavListMenuWindow *listWindow, u32 a1) +// Pointless +static void SetListMarginTile(struct PokenavListMenuWindow *listWindow, bool32 draw) { u16 var; - u16 *v1 = (u16*)GetBgTilemapBuffer(GetWindowAttribute(listWindow->windowId, WINDOW_BG)); - v1 += ((listWindow->unkA << 6) + listWindow->x) - 1; + u16 *tilemapBuffer = (u16*)GetBgTilemapBuffer(GetWindowAttribute(listWindow->windowId, WINDOW_BG)); + tilemapBuffer += (listWindow->unkA << 6) + listWindow->x - 1; - if (a1 != 0) + if (draw) var = (listWindow->fillValue << 12) | (listWindow->tileOffset + 1); else var = (listWindow->fillValue << 12) | (listWindow->tileOffset); - v1[0] = var; - v1[0x20] = var; + tilemapBuffer[0] = var; + tilemapBuffer[0x20] = var; } // Print the trainer's name and title at the top of their check page @@ -713,7 +715,7 @@ static void PrintCheckPageTrainerName(struct PokenavListWindowState *state, stru list->iconDrawFunc(list->listWindow.windowId, state->windowTopIndex, list->listWindow.unkA); FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(4), 0, list->listWindow.unkA * 16, list->listWindow.width * 8, 16); AddTextPrinterParameterized3(list->listWindow.windowId, list->listWindow.fontId, 8, (list->listWindow.unkA * 16) + 1, colors, TEXT_SKIP_DRAW, list->itemTextBuffer); - sub_81C8C64(&list->listWindow, 1); + SetListMarginTile(&list->listWindow, TRUE); CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_FULL, 0, list->listWindow.unkA * 2, list->listWindow.width, 2); } @@ -723,7 +725,7 @@ static void PrintMatchCallListTrainerName(struct PokenavListWindowState *state, list->bufferItemFunc(state->listPtr + state->listItemSize * state->windowTopIndex, list->itemTextBuffer); FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, list->listWindow.unkA * 16, list->listWindow.width * 8, 16); AddTextPrinterParameterized(list->listWindow.windowId, list->listWindow.fontId, list->itemTextBuffer, 8, list->listWindow.unkA * 16 + 1, TEXT_SKIP_DRAW, NULL); - sub_81C8C64(&list->listWindow, 0); + SetListMarginTile(&list->listWindow, FALSE); CopyWindowToVram(list->listWindow.windowId, COPYWIN_FULL); } @@ -745,8 +747,7 @@ static void PrintMatchCallFieldNames(struct PokenavSub17Substruct *list, u32 fie static void PrintMatchCallFlavorText(struct PokenavListWindowState *a0, struct PokenavSub17Substruct *list, u32 checkPageEntry) { // lines 1, 3, and 5 are the field names printed by PrintMatchCallFieldNames - static const u8 lineOffsets[CHECK_PAGE_ENTRY_COUNT] = - { + static const u8 lineOffsets[CHECK_PAGE_ENTRY_COUNT] = { [CHECK_PAGE_STRATEGY] = 2, [CHECK_PAGE_POKEMON] = 4, [CHECK_PAGE_INTRO_1] = 6, @@ -768,7 +769,7 @@ static const struct CompressedSpriteSheet sListArrowSpriteSheets[] = { { .data = sListArrow_Gfx, - .size = 192, + .size = 0xC0, .tag = GFXTAG_ARROW } }; @@ -852,7 +853,7 @@ static void CreateListArrowSprites(struct PokenavListWindowState *windowState, s list->rightArrow = &gSprites[spriteId]; x = list->listWindow.x * 8 + (list->listWindow.width - 1) * 4; - spriteId = CreateSprite(&sSpriteTemplate_UpDownArrow, x, list->listWindow.y * 8 + windowState->visibleEntries * 16, 7); + spriteId = CreateSprite(&sSpriteTemplate_UpDownArrow, x, list->listWindow.y * 8 + windowState->entriesOnscreen * 16, 7); list->downArrow = &gSprites[spriteId]; list->downArrow->oam.tileNum += 2; list->downArrow->callback = SpriteCB_DownArrow; @@ -954,19 +955,19 @@ static void InitPokenavListWindowState(struct PokenavListWindowState *dst, struc dst->windowTopIndex = template->startIndex; dst->listLength = template->count; dst->listItemSize = template->itemSize; - dst->visibleEntries = template->maxShowed; - if (dst->visibleEntries >= dst->listLength) + dst->entriesOnscreen = template->maxShowed; + if (dst->entriesOnscreen >= dst->listLength) { dst->windowTopIndex = 0; - dst->unk4 = 0; + dst->entriesOffscreen = 0; dst->selectedIndexOffset = template->startIndex; } else { - dst->unk4 = dst->listLength - dst->visibleEntries; - if (dst->windowTopIndex + dst->visibleEntries > dst->listLength) + dst->entriesOffscreen = dst->listLength - dst->entriesOnscreen; + if (dst->windowTopIndex + dst->entriesOnscreen > dst->listLength) { - dst->selectedIndexOffset = dst->windowTopIndex + dst->visibleEntries - dst->listLength; + dst->selectedIndexOffset = dst->windowTopIndex + dst->entriesOnscreen - dst->listLength; dst->windowTopIndex = template->startIndex - dst->selectedIndexOffset; } else diff --git a/src/pokenav_ribbons_list.c b/src/pokenav_ribbons_list.c index c70554eb0..1d72f6a98 100644 --- a/src/pokenav_ribbons_list.c +++ b/src/pokenav_ribbons_list.c @@ -190,7 +190,7 @@ static u32 HandleRibbonsMonListInput(struct Pokenav_RibbonsMonList *list) } if (JOY_NEW(A_BUTTON)) { - list->monList->currIndex = GetSelectedPokenavListIndex(); + list->monList->currIndex = PokenavList_GetSelectedIndex(); list->saveMonList = 1; list->callback = RibbonsMonMenu_ToSummaryScreen; return RIBBONS_MON_LIST_FUNC_OPEN_RIBBONS_SUMMARY; @@ -230,7 +230,7 @@ static s32 GetRibbonsMonListCount(void) static s32 GetMonRibbonSelectedMonData(void) { struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); - s32 idx = GetSelectedPokenavListIndex(); + s32 idx = PokenavList_GetSelectedIndex(); return list->monList->monData[idx].data; } @@ -496,7 +496,7 @@ static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMovePokenavListWindowTaskActive()) + if (PokenavList_IsMoveWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -529,7 +529,7 @@ static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMovePokenavListWindowTaskActive()) + if (PokenavList_IsMoveWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -562,7 +562,7 @@ static u32 LoopedTask_RibbonsListMovePageUp(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMovePokenavListWindowTaskActive()) + if (PokenavList_IsMoveWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -595,7 +595,7 @@ static u32 LoopedTask_RibbonsListMovePageDown(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (IsMovePokenavListWindowTaskActive()) + if (PokenavList_IsMoveWindowTaskActive()) return LT_PAUSE; // fallthrough case 2: @@ -658,7 +658,7 @@ static void AddRibbonsMonListWindow(struct Pokenav_RibbonsMonMenu *menu) static void UpdateIndexNumberDisplay(struct Pokenav_RibbonsMonMenu *menu) { - s32 listIndex = GetSelectedPokenavListIndex(); + s32 listIndex = PokenavList_GetSelectedIndex(); s32 listCount = GetRibbonsMonListCount(); DrawListIndexNumber(menu->winid, listIndex + 1, listCount); CopyWindowToVram(menu->winid, COPYWIN_GFX); From c779d03b3e9032254bbd7a08f4c9203e14373933 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 15 Nov 2021 00:21:40 -0500 Subject: [PATCH 16/19] Rename pokenav_match_call_ui --- include/pokenav.h | 4 +- ld_script.txt | 4 +- ...pokenav_match_call_ui.c => pokenav_list.c} | 98 +++++++++---------- sym_ewram.txt | 2 +- 4 files changed, 54 insertions(+), 54 deletions(-) rename src/{pokenav_match_call_ui.c => pokenav_list.c} (90%) diff --git a/include/pokenav.h b/include/pokenav.h index b5eb20a7f..34206d3ae 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -323,7 +323,7 @@ bool32 CanViewRibbonsMenu(void); void SetPokenavVBlankCallback(void); void SetVBlankCallback_(IntrCallback callback); -// pokenav_match_call_ui.c +// pokenav_list.c bool32 CreatePokenavList(const struct BgTemplate *bgTemplate, struct PokenavListTemplate *listTemplate, s32 tileOffset); bool32 IsCreatePokenavListTaskActive(void); void DestroyPokenavList(void); @@ -337,7 +337,7 @@ void PokenavList_ToggleVerticalArrows(bool32 shouldHide); void PokenavList_DrawCurrentItemIcon(void); void PokenavList_EraseListForCheckPage(void); bool32 PokenavList_IsTaskActive(void); -void PrintCheckPageInfo(s16 a0); +void PrintCheckPageInfo(s16 delta); u32 PokenavList_GetTopIndex(void); void PokenavList_ReshowListFromCheckPage(void); diff --git a/ld_script.txt b/ld_script.txt index 257fb3c6e..5a312cba2 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -310,7 +310,7 @@ SECTIONS { src/battle_pyramid_bag.o(.text); src/pokenav.o(.text); src/pokenav_main_menu.o(.text); - src/pokenav_match_call_ui.o(.text); + src/pokenav_list.o(.text); src/pokenav_menu_handler.o(.text); src/pokenav_menu_handler_gfx.o(.text); src/pokenav_match_call_1.o(.text); @@ -665,7 +665,7 @@ SECTIONS { src/battle_pyramid_bag.o(.rodata); src/pokenav.o(.rodata); src/pokenav_main_menu.o(.rodata); - src/pokenav_match_call_ui.o(.rodata); + src/pokenav_list.o(.rodata); src/pokenav_menu_handler.o(.rodata); src/pokenav_menu_handler_gfx.o(.rodata); src/pokenav_match_call_1.o(.rodata); diff --git a/src/pokenav_match_call_ui.c b/src/pokenav_list.c similarity index 90% rename from src/pokenav_match_call_ui.c rename to src/pokenav_list.c index 97437e3cd..bdba1d2c0 100644 --- a/src/pokenav_match_call_ui.c +++ b/src/pokenav_list.c @@ -37,7 +37,7 @@ struct PokenavListWindowState { void * listPtr; }; -struct PokenavSub17Substruct +struct PokenavListSub { struct PokenavListMenuWindow listWindow; u32 unk10; @@ -57,33 +57,33 @@ struct PokenavSub17Substruct u8 itemTextBuffer[64]; }; -struct PokenavSub17 +struct PokenavList { - struct PokenavSub17Substruct list; + struct PokenavListSub list; u8 tilemapBuffer[BG_SCREEN_SIZE]; struct PokenavListWindowState windowState; s32 eraseIndex; u32 loopedTaskId; }; -static void InitPokenavListBg(struct PokenavSub17 *); -static bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *, const struct BgTemplate *, struct PokenavListTemplate *, s32); +static void InitPokenavListBg(struct PokenavList *); +static bool32 CopyPokenavListMenuTemplate(struct PokenavListSub *, const struct BgTemplate *, struct PokenavListTemplate *, s32); static void InitPokenavListWindowState(struct PokenavListWindowState *, struct PokenavListTemplate *); static void SpriteCB_UpArrow(struct Sprite *); static void SpriteCB_DownArrow(struct Sprite *); static void SpriteCB_RightArrow(struct Sprite *); -static void ToggleListArrows(struct PokenavSub17Substruct *, u32); -static void DestroyListArrows(struct PokenavSub17Substruct *); -static void CreateListArrowSprites(struct PokenavListWindowState *, struct PokenavSub17Substruct *); +static void ToggleListArrows(struct PokenavListSub *, u32); +static void DestroyListArrows(struct PokenavListSub *); +static void CreateListArrowSprites(struct PokenavListWindowState *, struct PokenavListSub *); static void LoadListArrowGfx(void); -static void PrintMatchCallFlavorText(struct PokenavListWindowState *, struct PokenavSub17Substruct *, u32); -static void PrintMatchCallFieldNames(struct PokenavSub17Substruct *, u32); -static void PrintMatchCallListTrainerName(struct PokenavListWindowState *, struct PokenavSub17Substruct *); -static void PrintCheckPageTrainerName(struct PokenavListWindowState *, struct PokenavSub17Substruct *); +static void PrintMatchCallFlavorText(struct PokenavListWindowState *, struct PokenavListSub *, u32); +static void PrintMatchCallFieldNames(struct PokenavListSub *, u32); +static void PrintMatchCallListTrainerName(struct PokenavListWindowState *, struct PokenavListSub *); +static void PrintCheckPageTrainerName(struct PokenavListWindowState *, struct PokenavListSub *); static void EraseListEntry(struct PokenavListMenuWindow *, s32, s32); -static void CreateMoveListWindowTask(s32, struct PokenavSub17Substruct *); -static void PrintListItems(void *, u32, u32, u32, u32, struct PokenavSub17Substruct *); -static void InitListItems(struct PokenavListWindowState *, struct PokenavSub17Substruct *); +static void CreateMoveListWindowTask(s32, struct PokenavListSub *); +static void PrintListItems(void *, u32, u32, u32, u32, struct PokenavListSub *); +static void InitListItems(struct PokenavListWindowState *, struct PokenavListSub *); static void InitPokenavListWindow(struct PokenavListMenuWindow *); static u32 LoopedTask_CreatePokenavList(s32); static bool32 IsPrintListItemsTaskActive(void); @@ -100,7 +100,7 @@ static EWRAM_DATA u32 sMoveWindowDownIndex = 0; // Read, but pointlessly bool32 CreatePokenavList(const struct BgTemplate *bgTemplate, struct PokenavListTemplate *listTemplate, s32 tileOffset) { - struct PokenavSub17 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_LIST, sizeof(struct PokenavSub17)); + struct PokenavList *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_LIST, sizeof(struct PokenavList)); if (structPtr == NULL) return FALSE; @@ -119,7 +119,7 @@ bool32 IsCreatePokenavListTaskActive(void) void DestroyPokenavList(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); DestroyListArrows(&structPtr->list); RemoveWindow(structPtr->list.listWindow.windowId); FreePokenavSubstruct(POKENAV_SUBSTRUCT_LIST); @@ -127,7 +127,7 @@ void DestroyPokenavList(void) static u32 LoopedTask_CreatePokenavList(s32 state) { - struct PokenavSub17 *structPtr; + struct PokenavList *structPtr; if (IsDma3ManagerBusyWithBgCopy()) return LT_PAUSE; @@ -163,7 +163,7 @@ static u32 LoopedTask_CreatePokenavList(s32 state) } } -static void InitPokenavListBg(struct PokenavSub17 *a0) +static void InitPokenavListBg(struct PokenavList *a0) { u16 tileNum = (a0->list.listWindow.fillValue << 12) | a0->list.listWindow.tileOffset; BgDmaFill(a0->list.listWindow.bg, PIXEL_FILL(1), a0->list.listWindow.tileOffset, 1); @@ -183,7 +183,7 @@ static void InitPokenavListWindow(struct PokenavListMenuWindow *listWindow) CopyWindowToVram(listWindow->windowId, COPYWIN_MAP); } -static void InitListItems(struct PokenavListWindowState *windowState, struct PokenavSub17Substruct *a1) +static void InitListItems(struct PokenavListWindowState *windowState, struct PokenavListSub *a1) { s32 numToPrint = windowState->listLength - windowState->windowTopIndex; if (numToPrint > windowState->entriesOnscreen) @@ -192,7 +192,7 @@ static void InitListItems(struct PokenavListWindowState *windowState, struct Pok PrintListItems(windowState->listPtr, windowState->windowTopIndex, numToPrint, windowState->listItemSize, 0, a1); } -static void PrintListItems(void * listPtr, u32 topIndex, u32 numItems, u32 itemSize, u32 a4, struct PokenavSub17Substruct *list) +static void PrintListItems(void * listPtr, u32 topIndex, u32 numItems, u32 itemSize, u32 a4, struct PokenavListSub *list) { if (numItems == 0) return; @@ -214,7 +214,7 @@ static bool32 IsPrintListItemsTaskActive(void) static u32 LoopedTask_PrintListItems(s32 state) { u32 row; - struct PokenavSub17Substruct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavListSub *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); switch (state) { @@ -251,14 +251,14 @@ static u32 LoopedTask_PrintListItems(s32 state) static bool32 ShouldShowUpArrow(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); return (structPtr->windowState.windowTopIndex != 0); } static bool32 ShouldShowDownArrow(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); struct PokenavListWindowState *subPtr = &structPtr->windowState; return (subPtr->windowTopIndex + subPtr->entriesOnscreen < subPtr->listLength); @@ -266,7 +266,7 @@ static bool32 ShouldShowDownArrow(void) static void MoveListWindow(s32 delta, bool32 printItems) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); struct PokenavListWindowState *subPtr = &structPtr->windowState; if (delta < 0) @@ -289,7 +289,7 @@ static void MoveListWindow(s32 delta, bool32 printItems) subPtr->windowTopIndex += delta; } -static void CreateMoveListWindowTask(s32 delta, struct PokenavSub17Substruct *list) +static void CreateMoveListWindowTask(s32 delta, struct PokenavListSub *list) { list->startBgY = GetBgY(list->listWindow.bg); list->endBgY = list->startBgY + (delta << 12); @@ -305,8 +305,8 @@ static u32 LoopedTask_MoveListWindow(s32 state) { s32 oldY, newY; bool32 finished; - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - struct PokenavSub17Substruct *subPtr = &structPtr->list; + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavListSub *subPtr = &structPtr->list; switch (state) { @@ -342,13 +342,13 @@ static u32 LoopedTask_MoveListWindow(s32 state) bool32 PokenavList_IsMoveWindowTaskActive(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); return IsLoopedTaskActive(structPtr->list.loopedTaskId); } static struct PokenavListWindowState *GetPokenavListWindowState(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); return &structPtr->windowState; } @@ -462,14 +462,14 @@ u32 PokenavList_GetTopIndex(void) void PokenavList_EraseListForCheckPage(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); structPtr->eraseIndex = 0; structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_EraseListForCheckPage, 6); } void PrintCheckPageInfo(s16 delta) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); structPtr->windowState.windowTopIndex += delta; structPtr->eraseIndex = 0; structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_PrintCheckPageInfo, 6); @@ -477,20 +477,20 @@ void PrintCheckPageInfo(s16 delta) void PokenavList_ReshowListFromCheckPage(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); structPtr->eraseIndex = 0; structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_ReshowListFromCheckPage, 6); } bool32 PokenavList_IsTaskActive(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); return IsLoopedTaskActive(structPtr->loopedTaskId); } void PokenavList_DrawCurrentItemIcon(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); struct PokenavListWindowState *subPtr = &structPtr->windowState; structPtr->list.iconDrawFunc(structPtr->list.listWindow.windowId, subPtr->windowTopIndex + subPtr->selectedIndexOffset, (structPtr->list.listWindow.unkA + subPtr->selectedIndexOffset) & 0xF); CopyWindowToVram(structPtr->list.listWindow.windowId, COPYWIN_MAP); @@ -498,7 +498,7 @@ void PokenavList_DrawCurrentItemIcon(void) static u32 LoopedTask_EraseListForCheckPage(s32 state) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); switch (state) { @@ -545,7 +545,7 @@ static u32 LoopedTask_EraseListForCheckPage(s32 state) static u32 LoopedTask_PrintCheckPageInfo(s32 state) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); if (IsDma3ManagerBusyWithBgCopy()) return LT_PAUSE; @@ -583,9 +583,9 @@ static u32 LoopedTask_PrintCheckPageInfo(s32 state) static u32 LoopedTask_ReshowListFromCheckPage(s32 state) { - struct PokenavSub17 *structPtr; + struct PokenavList *structPtr; struct PokenavListWindowState *windowState; - struct PokenavSub17Substruct *subPtr0; + struct PokenavListSub *subPtr0; s32 r5, *ptr; if (IsDma3ManagerBusyWithBgCopy()) @@ -707,7 +707,7 @@ static void SetListMarginTile(struct PokenavListMenuWindow *listWindow, bool32 d } // Print the trainer's name and title at the top of their check page -static void PrintCheckPageTrainerName(struct PokenavListWindowState *state, struct PokenavSub17Substruct *list) +static void PrintCheckPageTrainerName(struct PokenavListWindowState *state, struct PokenavListSub *list) { u8 colors[3] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_RED}; @@ -720,7 +720,7 @@ static void PrintCheckPageTrainerName(struct PokenavListWindowState *state, stru } // Print the trainer's name and title for the list (to replace the check page name and title, which has a red background) -static void PrintMatchCallListTrainerName(struct PokenavListWindowState *state, struct PokenavSub17Substruct *list) +static void PrintMatchCallListTrainerName(struct PokenavListWindowState *state, struct PokenavListSub *list) { list->bufferItemFunc(state->listPtr + state->listItemSize * state->windowTopIndex, list->itemTextBuffer); FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, list->listWindow.unkA * 16, list->listWindow.width * 8, 16); @@ -729,7 +729,7 @@ static void PrintMatchCallListTrainerName(struct PokenavListWindowState *state, CopyWindowToVram(list->listWindow.windowId, COPYWIN_FULL); } -static void PrintMatchCallFieldNames(struct PokenavSub17Substruct *list, u32 fieldId) +static void PrintMatchCallFieldNames(struct PokenavListSub *list, u32 fieldId) { const u8 *fieldNames[] = { gText_PokenavMatchCall_Strategy, @@ -744,7 +744,7 @@ static void PrintMatchCallFieldNames(struct PokenavSub17Substruct *list, u32 fie CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_GFX, 0, top << 1, list->listWindow.width, 2); } -static void PrintMatchCallFlavorText(struct PokenavListWindowState *a0, struct PokenavSub17Substruct *list, u32 checkPageEntry) +static void PrintMatchCallFlavorText(struct PokenavListWindowState *a0, struct PokenavListSub *list, u32 checkPageEntry) { // lines 1, 3, and 5 are the field names printed by PrintMatchCallFieldNames static const u8 lineOffsets[CHECK_PAGE_ENTRY_COUNT] = { @@ -844,7 +844,7 @@ static void LoadListArrowGfx(void) Pokenav_AllocAndLoadPalettes(sListArrowPalettes); } -static void CreateListArrowSprites(struct PokenavListWindowState *windowState, struct PokenavSub17Substruct *list) +static void CreateListArrowSprites(struct PokenavListWindowState *windowState, struct PokenavListSub *list) { u32 spriteId; s16 x; @@ -864,7 +864,7 @@ static void CreateListArrowSprites(struct PokenavListWindowState *windowState, s list->upArrow->callback = SpriteCB_UpArrow; } -static void DestroyListArrows(struct PokenavSub17Substruct *list) +static void DestroyListArrows(struct PokenavListSub *list) { DestroySprite(list->rightArrow); DestroySprite(list->upArrow); @@ -873,7 +873,7 @@ static void DestroyListArrows(struct PokenavSub17Substruct *list) FreeSpritePaletteByTag(PALTAG_ARROW); } -static void ToggleListArrows(struct PokenavSub17Substruct *list, bool32 invisible) +static void ToggleListArrows(struct PokenavListSub *list, bool32 invisible) { if (invisible) { @@ -894,7 +894,7 @@ static void ToggleListArrows(struct PokenavSub17Substruct *list, bool32 invisibl static void SpriteCB_RightArrow(struct Sprite *sprite) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); sprite->y2 = structPtr->windowState.selectedIndexOffset << 4; } @@ -940,7 +940,7 @@ static void SpriteCB_UpArrow(struct Sprite *sprite) void PokenavList_ToggleVerticalArrows(bool32 invisible) { - struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); structPtr->list.upArrow->sInvisible = invisible; structPtr->list.downArrow->sInvisible = invisible; } @@ -977,7 +977,7 @@ static void InitPokenavListWindowState(struct PokenavListWindowState *dst, struc } } -static bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *dest, const struct BgTemplate *bgTemplate, struct PokenavListTemplate *template, s32 tileOffset) +static bool32 CopyPokenavListMenuTemplate(struct PokenavListSub *dest, const struct BgTemplate *bgTemplate, struct PokenavListTemplate *template, s32 tileOffset) { struct WindowTemplate window; diff --git a/sym_ewram.txt b/sym_ewram.txt index a9ec00e3b..414b7a3b2 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -143,7 +143,7 @@ .include "src/pokedex_area_region_map.o" .include "src/battle_pyramid_bag.o" .include "src/pokenav.o" - .include "src/pokenav_match_call_ui.o" + .include "src/pokenav_list.o" .include "src/menu_specialized.o" .include "src/faraway_island.o" .include "src/trainer_hill.o" From 14d78d76332a99f0942f1ad5c05f439ce27d789f Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 15 Nov 2021 00:42:23 -0500 Subject: [PATCH 17/19] Finish match call menu doc --- .../{86226E0.pal => call_window.pal} | 0 .../{8622700.pal => list_window.pal} | 0 include/pokenav.h | 5 +- src/pokenav_match_call_1.c | 114 +++++++++--------- src/pokenav_match_call_2.c | 22 ++-- 5 files changed, 73 insertions(+), 68 deletions(-) rename graphics/pokenav/match_call/{86226E0.pal => call_window.pal} (100%) rename graphics/pokenav/match_call/{8622700.pal => list_window.pal} (100%) diff --git a/graphics/pokenav/match_call/86226E0.pal b/graphics/pokenav/match_call/call_window.pal similarity index 100% rename from graphics/pokenav/match_call/86226E0.pal rename to graphics/pokenav/match_call/call_window.pal diff --git a/graphics/pokenav/match_call/8622700.pal b/graphics/pokenav/match_call/list_window.pal similarity index 100% rename from graphics/pokenav/match_call/8622700.pal rename to graphics/pokenav/match_call/list_window.pal diff --git a/include/pokenav.h b/include/pokenav.h index 34206d3ae..595198136 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -407,10 +407,9 @@ void ResetBldCnt_(void); bool32 PokenavCallback_Init_MatchCall(void); u32 GetMatchCallCallback(void); void FreeMatchCallSubstruct1(void); -int sub_81CAE28(void); +int IsMatchCallListInitFinished(void); int GetNumberRegistered(void); -int sub_81CAE48(void); -struct PokenavMatchCallEntry *sub_81CAE94(void); +struct PokenavMatchCallEntry *GetMatchCallList(void); u16 GetMatchCallMapSec(int); bool32 ShouldDrawRematchPokeballIcon(int index); void ClearRematchPokeballIcon(u16 windowId, u32 a1); diff --git a/src/pokenav_match_call_1.c b/src/pokenav_match_call_1.c index e0e5306e1..d56cfdb62 100755 --- a/src/pokenav_match_call_1.c +++ b/src/pokenav_match_call_1.c @@ -14,26 +14,26 @@ #include "strings.h" #include "constants/songs.h" -struct Pokenav3Struct +struct Pokenav_MatchCallMenu { u16 optionCursorPos; u16 maxOptionId; const u8 *matchCallOptions; u16 headerId; u16 numRegistered; - u16 unkC; - u32 unk10; - u32 unk14; - u32 (*callback)(struct Pokenav3Struct*); + u16 numSpecialTrainers; + bool32 initFinished; + u32 loopedTaskId; + u32 (*callback)(struct Pokenav_MatchCallMenu*); struct PokenavMatchCallEntry matchCallEntries[MAX_REMATCH_ENTRIES - 1]; }; -static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *); -static u32 GetExitMatchCallMenuId(struct Pokenav3Struct *); -static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *); -static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *); -static u32 CB2_HandleCallExitInput(struct Pokenav3Struct *); -static u32 sub_81CAD20(s32); +static u32 CB2_HandleMatchCallInput(struct Pokenav_MatchCallMenu *); +static u32 GetExitMatchCallMenuId(struct Pokenav_MatchCallMenu *); +static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav_MatchCallMenu *); +static u32 CB2_HandleCheckPageInput(struct Pokenav_MatchCallMenu *); +static u32 CB2_HandleCallExitInput(struct Pokenav_MatchCallMenu *); +static u32 LoopedTask_BuildMatchCallList(s32); static bool32 ShouldDoNearbyMessage(void); #include "data/text/match_call_messages.h" @@ -53,20 +53,20 @@ static const u8 sMatchCallOptionsHasCheckPage[] = bool32 PokenavCallback_Init_MatchCall(void) { - struct Pokenav3Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN, sizeof(struct Pokenav3Struct)); + struct Pokenav_MatchCallMenu *state = AllocSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN, sizeof(struct Pokenav_MatchCallMenu)); if (!state) return FALSE; state->callback = CB2_HandleMatchCallInput; state->headerId = 0; - state->unk10 = 0; - state->unk14 = CreateLoopedTask(sub_81CAD20, 1); + state->initFinished = FALSE; + state->loopedTaskId = CreateLoopedTask(LoopedTask_BuildMatchCallList, 1); return TRUE; } u32 GetMatchCallCallback(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->callback(state); } @@ -75,7 +75,7 @@ void FreeMatchCallSubstruct1(void) FreePokenavSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); } -static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) +static u32 CB2_HandleMatchCallInput(struct Pokenav_MatchCallMenu *state) { int selection; @@ -125,20 +125,20 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) return POKENAV_MC_FUNC_NONE; } -static u32 GetExitMatchCallMenuId(struct Pokenav3Struct *state) +static u32 GetExitMatchCallMenuId(struct Pokenav_MatchCallMenu *state) { return POKENAV_MAIN_MENU_CURSOR_ON_MATCH_CALL; } -static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state) +static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav_MatchCallMenu *state) { - if ((JOY_NEW(DPAD_UP)) && state->optionCursorPos) + if (JOY_NEW(DPAD_UP) && state->optionCursorPos) { state->optionCursorPos--; return POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR; } - if ((JOY_NEW(DPAD_DOWN)) && state->optionCursorPos < state->maxOptionId) + if (JOY_NEW(DPAD_DOWN) && state->optionCursorPos < state->maxOptionId) { state->optionCursorPos++; return POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR; @@ -175,7 +175,7 @@ static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state) return POKENAV_MC_FUNC_NONE; } -static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *state) +static u32 CB2_HandleCheckPageInput(struct Pokenav_MatchCallMenu *state) { if (JOY_REPEAT(DPAD_UP)) return POKENAV_MC_FUNC_CHECK_PAGE_UP; @@ -191,7 +191,7 @@ static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *state) return POKENAV_MC_FUNC_NONE; } -static u32 CB2_HandleCallExitInput(struct Pokenav3Struct *state) +static u32 CB2_HandleCallExitInput(struct Pokenav_MatchCallMenu *state) { if (JOY_NEW(A_BUTTON | B_BUTTON)) { @@ -202,10 +202,10 @@ static u32 CB2_HandleCallExitInput(struct Pokenav3Struct *state) return POKENAV_MC_FUNC_NONE; } -static u32 sub_81CAD20(s32 taskState) +static u32 LoopedTask_BuildMatchCallList(s32 taskState) { int i, j; - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); switch (taskState) { case 0: @@ -213,6 +213,7 @@ static u32 sub_81CAD20(s32 taskState) state->numRegistered = 0; return LT_INC_AND_CONTINUE; case 1: + // Load special trainers (e.g. Rival, gym leaders) for (i = 0, j = state->headerId; i < 30; i++, j++) { if (MatchCall_GetEnabled(j)) @@ -225,7 +226,7 @@ static u32 sub_81CAD20(s32 taskState) if (++state->headerId >= MC_HEADER_COUNT) { - state->unkC = state->headerId; + state->numSpecialTrainers = state->headerId; state->headerId = 0; return LT_INC_AND_CONTINUE; } @@ -233,6 +234,7 @@ static u32 sub_81CAD20(s32 taskState) return LT_CONTINUE; case 2: + // Load normal trainers for (i = 0, j = state->headerId; i < 30; i++, j++) { if (!MatchCall_HasRematchId(state->headerId) && IsRematchEntryRegistered(state->headerId)) @@ -249,7 +251,7 @@ static u32 sub_81CAD20(s32 taskState) return LT_CONTINUE; case 3: - state->unk10 = 1; + state->initFinished = TRUE; break; } @@ -264,55 +266,58 @@ bool32 IsRematchEntryRegistered(int rematchIndex) return FALSE; } -int sub_81CAE28(void) +int IsMatchCallListInitFinished(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); - return state->unk10; + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + return state->initFinished; } int GetNumberRegistered(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->numRegistered; } -int sub_81CAE48(void) +// Unused +static int GetNumSpecialTrainers(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); - return state->unkC; + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + return state->numSpecialTrainers; } -int unref_sub_81CAE58(void) +// Unused +static int GetNumNormalTrainers(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); - return state->numRegistered - state->unkC; + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + return state->numRegistered - state->numSpecialTrainers; } -int unref_sub_81CAE6C(int arg0) +// Unused +static int GetNormalTrainerHeaderId(int index) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); - arg0 += state->unkC; - if (arg0 >= state->numRegistered) + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + index += state->numSpecialTrainers; + if (index >= state->numRegistered) return REMATCH_TABLE_ENTRIES; - return state->matchCallEntries[arg0].headerId; + return state->matchCallEntries[index].headerId; } -struct PokenavMatchCallEntry *sub_81CAE94(void) +struct PokenavMatchCallEntry *GetMatchCallList(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->matchCallEntries; } u16 GetMatchCallMapSec(int index) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->matchCallEntries[index].mapSec; } bool32 ShouldDrawRematchPokeballIcon(int index) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); if (!state->matchCallEntries[index].isSpecialTrainer) index = state->matchCallEntries[index].headerId; else @@ -327,7 +332,7 @@ bool32 ShouldDrawRematchPokeballIcon(int index) int GetMatchCallTrainerPic(int index) { int headerId; - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); if (!state->matchCallEntries[index].isSpecialTrainer) { index = GetTrainerIdxByRematchIdx(state->matchCallEntries[index].headerId); @@ -348,7 +353,7 @@ int GetMatchCallTrainerPic(int index) const u8 *GetMatchCallMessageText(int index, bool8 *newRematchRequest) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); *newRematchRequest = FALSE; if (!Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType)) return gText_CallCantBeMadeHere; @@ -364,7 +369,7 @@ const u8 *GetMatchCallMessageText(int index, bool8 *newRematchRequest) const u8 *GetMatchCallFlavorText(int index, int checkPageEntry) { int rematchId; - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); if (state->matchCallEntries[index].isSpecialTrainer) { rematchId = MatchCall_GetRematchTableIdx(state->matchCallEntries[index].headerId); @@ -381,13 +386,13 @@ const u8 *GetMatchCallFlavorText(int index, int checkPageEntry) u16 GetMatchCallOptionCursorPos(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->optionCursorPos; } u16 GetMatchCallOptionId(int optionId) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); if (state->maxOptionId < optionId) return MATCH_CALL_OPTION_COUNT; @@ -431,7 +436,7 @@ u8 GetMatchTableMapSectionId(int rematchIndex) int GetIndexDeltaOfNextCheckPageDown(int index) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); int count = 1; while (++index < state->numRegistered) { @@ -448,7 +453,7 @@ int GetIndexDeltaOfNextCheckPageDown(int index) int GetIndexDeltaOfNextCheckPageUp(int index) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); int count = -1; while (--index >= 0) { @@ -463,7 +468,8 @@ int GetIndexDeltaOfNextCheckPageUp(int index) return 0; } -bool32 unref_sub_81CB16C(void) +// Unused +static bool32 HasRematchEntry(void) { int i; @@ -488,7 +494,7 @@ bool32 unref_sub_81CB16C(void) static bool32 ShouldDoNearbyMessage(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); int selection = PokenavList_GetSelectedIndex(); if (!state->matchCallEntries[selection].isSpecialTrainer) { diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index d8704919f..d7e9476f9 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -56,7 +56,7 @@ struct Pokenav_MatchCallGfx static bool32 GetCurrentLoopedTaskActive(void); static u32 LoopedTask_OpenMatchCall(s32); static void CreateMatchCallList(void); -static void sub_81CBC1C(void); +static void DestroyMatchCallList(void); static void FreeMatchCallSprites(void); static void LoadCallWindowAndFade(struct Pokenav_MatchCallGfx *); static void DrawMatchCallLeftColumnWindows(struct Pokenav_MatchCallGfx *); @@ -119,12 +119,12 @@ static const u32 sMatchCallUI_Gfx[] = INCBIN_U32("graphics/pokenav/match_call/ui static const u32 sMatchCallUI_Tilemap[] = INCBIN_U32("graphics/pokenav/match_call/ui.bin.lz"); static const u16 sOptionsCursor_Pal[] = INCBIN_U16("graphics/pokenav/match_call/options_cursor.gbapal"); static const u32 sOptionsCursor_Gfx[] = INCBIN_U32("graphics/pokenav/match_call/options_cursor.4bpp.lz"); -static const u16 gUnknown_086226E0[] = INCBIN_U16("graphics/pokenav/match_call/86226E0.gbapal"); -static const u16 gUnknown_08622700[] = INCBIN_U16("graphics/pokenav/match_call/8622700.gbapal"); +static const u16 sCallWindow_Pal[] = INCBIN_U16("graphics/pokenav/match_call/call_window.gbapal"); +static const u16 sListWindow_Pal[] = INCBIN_U16("graphics/pokenav/match_call/list_window.gbapal"); static const u16 sPokeball_Pal[] = INCBIN_U16("graphics/pokenav/match_call/pokeball.gbapal"); static const u32 sPokeball_Gfx[] = INCBIN_U32("graphics/pokenav/match_call/pokeball.4bpp.lz"); -const struct BgTemplate sMatchCallBgTemplates[3] = +static const struct BgTemplate sMatchCallBgTemplates[3] = { { .bg = 1, @@ -223,7 +223,7 @@ static const struct CompressedSpriteSheet sOptionsCursorSpriteSheets[1] = {sOptionsCursor_Gfx, 0x40, GFXTAG_CURSOR} }; -const struct SpritePalette sOptionsCursorSpritePalettes[2] = +static const struct SpritePalette sOptionsCursorSpritePalettes[2] = { {sOptionsCursor_Pal, PALTAG_CURSOR} }; @@ -307,7 +307,7 @@ void FreeMatchCallSubstruct2(void) { struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); FreeMatchCallSprites(); - sub_81CBC1C(); + DestroyMatchCallList(); RemoveWindow(gfx->infoBoxWindowId); RemoveWindow(gfx->locWindowId); RemoveWindow(gfx->msgBoxWindowId); @@ -343,7 +343,7 @@ static u32 LoopedTask_OpenMatchCall(s32 state) BgDmaFill(1, 0, 0, 1); SetBgTilemapBuffer(1, gfx->bgTilemapBuffer1); FillBgTilemapBufferRect_Palette0(1, 0x1000, 0, 0, 32, 20); - CopyPaletteIntoBufferUnfaded(gUnknown_086226E0, 0x10, 0x20); + CopyPaletteIntoBufferUnfaded(sCallWindow_Pal, 0x10, 0x20); CopyBgTilemapBufferToVram(1); return LT_INC_AND_PAUSE; case 2: @@ -352,11 +352,11 @@ static u32 LoopedTask_OpenMatchCall(s32 state) LoadCallWindowAndFade(gfx); DecompressAndCopyTileDataToVram(3, sPokeball_Gfx, 0, 0, 0); - CopyPaletteIntoBufferUnfaded(gUnknown_08622700, 0x30, 0x20); + CopyPaletteIntoBufferUnfaded(sListWindow_Pal, 0x30, 0x20); CopyPaletteIntoBufferUnfaded(sPokeball_Pal, 0x50, 0x20); return LT_INC_AND_PAUSE; case 3: - if (FreeTempTileDataBuffersIfPossible() || !sub_81CAE28()) + if (FreeTempTileDataBuffersIfPossible() || !IsMatchCallListInitFinished()) return LT_PAUSE; CreateMatchCallList(); @@ -872,7 +872,7 @@ static u32 ExitMatchCall(s32 state) static void CreateMatchCallList(void) { struct PokenavListTemplate template; - template.list = (struct PokenavListItem *)sub_81CAE94(); + template.list = (struct PokenavListItem *)GetMatchCallList(); template.count = GetNumberRegistered(); template.itemSize = sizeof(struct PokenavListItem); template.startIndex = 0; @@ -888,7 +888,7 @@ static void CreateMatchCallList(void) CreateTask(Task_FlashPokeballIcons, 7); } -static void sub_81CBC1C(void) +static void DestroyMatchCallList(void) { DestroyPokenavList(); DestroyTask(FindTaskIdByFunc(Task_FlashPokeballIcons)); From 4275cf4b9033c6a4350057169af49fdcfa4a097a Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 15 Nov 2021 01:23:27 -0500 Subject: [PATCH 18/19] Rename pokenav match call files --- include/pokenav.h | 4 ++-- ld_script.txt | 8 ++++---- src/{pokenav_match_call_2.c => pokenav_match_call_gfx.c} | 8 ++++---- src/{pokenav_match_call_1.c => pokenav_match_call_list.c} | 0 4 files changed, 10 insertions(+), 10 deletions(-) rename src/{pokenav_match_call_2.c => pokenav_match_call_gfx.c} (99%) rename src/{pokenav_match_call_1.c => pokenav_match_call_list.c} (100%) diff --git a/include/pokenav.h b/include/pokenav.h index 595198136..d3edb1422 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -403,7 +403,7 @@ bool32 IsMenuHandlerLoopedTaskActive(void); void FreeMenuHandlerSubstruct2(void); void ResetBldCnt_(void); -// pokenav_match_call_1.c +// pokenav_match_call_list.c bool32 PokenavCallback_Init_MatchCall(void); u32 GetMatchCallCallback(void); void FreeMatchCallSubstruct1(void); @@ -424,7 +424,7 @@ int GetIndexDeltaOfNextCheckPageDown(int index); int GetIndexDeltaOfNextCheckPageUp(int index); bool32 IsRematchEntryRegistered(int index); -// pokenav_match_call_2.c +// pokenav_match_call_gfx.c bool32 OpenMatchCall(void); void CreateMatchCallLoopedTask(s32 index); bool32 IsMatchCallLoopedTaskActive(void); diff --git a/ld_script.txt b/ld_script.txt index 5a312cba2..b9302e47b 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -313,8 +313,8 @@ SECTIONS { src/pokenav_list.o(.text); src/pokenav_menu_handler.o(.text); src/pokenav_menu_handler_gfx.o(.text); - src/pokenav_match_call_1.o(.text); - src/pokenav_match_call_2.o(.text); + src/pokenav_match_call_list.o(.text); + src/pokenav_match_call_gfx.o(.text); src/pokenav_region_map.o(.text); src/pokenav_conditions.o(.text); src/pokenav_conditions_gfx.o(.text); @@ -668,8 +668,8 @@ SECTIONS { src/pokenav_list.o(.rodata); src/pokenav_menu_handler.o(.rodata); src/pokenav_menu_handler_gfx.o(.rodata); - src/pokenav_match_call_1.o(.rodata); - src/pokenav_match_call_2.o(.rodata); + src/pokenav_match_call_list.o(.rodata); + src/pokenav_match_call_gfx.o(.rodata); src/pokenav_region_map.o(.rodata); src/pokenav_conditions_gfx.o(.rodata); src/pokenav_conditions_search_results.o(.rodata); diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_gfx.c similarity index 99% rename from src/pokenav_match_call_2.c rename to src/pokenav_match_call_gfx.c index d7e9476f9..056ab2f1d 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_gfx.c @@ -34,7 +34,7 @@ struct Pokenav_MatchCallGfx bool32 (*isTaskActiveCB)(void); u32 loopTaskId; u8 filler8[6]; - bool8 unkE; + bool8 skipHangUpSE; bool8 newRematchRequest; u16 locWindowId; u16 infoBoxWindowId; @@ -606,7 +606,7 @@ static u32 DoMatchCallMessage(s32 state) PrintCallingDots(gfx); PlaySE(SE_POKENAV_CALL); - gfx->unkE = 0; + gfx->skipHangUpSE = FALSE; return LT_INC_AND_PAUSE; case 2: if (WaitForCallingDotsText(gfx)) @@ -632,7 +632,7 @@ static u32 DoTrainerCloseByMessage(s32 state) PlaySE(SE_SELECT); DrawMsgBoxForCloseByMsg(gfx); PokenavList_ToggleVerticalArrows(TRUE); - gfx->unkE = 1; + gfx->skipHangUpSE = TRUE; return LT_INC_AND_PAUSE; case 1: if (IsDma3ManagerBusyWithBgCopy2(gfx)) @@ -657,7 +657,7 @@ static u32 CloseMatchCallMessage(s32 state) switch (state) { case 0: - if (!gfx->unkE) + if (!gfx->skipHangUpSE) PlaySE(SE_POKENAV_HANG_UP); PlaySE(SE_SELECT); diff --git a/src/pokenav_match_call_1.c b/src/pokenav_match_call_list.c similarity index 100% rename from src/pokenav_match_call_1.c rename to src/pokenav_match_call_list.c From d98bd4dba70eed415d36cb67e12c79d851b1964a Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 15 Nov 2021 01:37:17 -0500 Subject: [PATCH 19/19] Name pokenav region map structs --- src/pokenav_region_map.c | 89 +++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index 4b9ff9f10..16ba48070 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -17,22 +17,25 @@ #include "constants/songs.h" #include "constants/region_map_sections.h" +#define GFXTAG_CITY_ZOOM 6 +#define PALTAG_CITY_ZOOM 11 + #define NUM_CITY_MAPS 22 -struct Pokenav5Struct +struct Pokenav_RegionMapMenu { - u8 filler0[0xC]; + u8 unused[12]; bool32 zoomDisabled; - u32 (*callback)(struct Pokenav5Struct *); + u32 (*callback)(struct Pokenav_RegionMapMenu *); }; -struct Pokenav5Struct_2 +struct Pokenav_RegionMapGfx { bool32 (*isTaskActiveCB)(void); u32 loopTaskId; u16 infoWindowId; struct Sprite *cityZoomTextSprites[3]; - u8 tilemapBuffer[0x800]; + u8 tilemapBuffer[BG_SCREEN_SIZE]; u8 cityZoomPics[NUM_CITY_MAPS][200]; }; @@ -43,9 +46,9 @@ struct CityMapEntry const u32 *tilemap; }; -static u32 HandleRegionMapInput(struct Pokenav5Struct *); -static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *); -static u32 GetExitRegionMapMenuId(struct Pokenav5Struct *); +static u32 HandleRegionMapInput(struct Pokenav_RegionMapMenu *); +static u32 HandleRegionMapInputZoomDisabled(struct Pokenav_RegionMapMenu *); +static u32 GetExitRegionMapMenuId(struct Pokenav_RegionMapMenu *); static u32 LoopedTask_OpenRegionMap(s32); static u32 LoopedTask_DecompressCityMaps(s32); static bool32 GetCurrentLoopedTaskActive(void); @@ -53,15 +56,15 @@ static void FreeCityZoomViewGfx(void); static void LoadCityZoomViewGfx(void); static void DecompressCityMaps(void); static bool32 IsDecompressCityMapsActive(void); -static void LoadPokenavRegionMapGfx(struct Pokenav5Struct_2 *); +static void LoadPokenavRegionMapGfx(struct Pokenav_RegionMapGfx *); static bool32 TryFreeTempTileDataBuffers(void); -static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *); -static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav5Struct_2 *); +static void UpdateMapSecInfoWindow(struct Pokenav_RegionMapGfx *); +static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav_RegionMapGfx *); static void ChangeBgYForZoom(bool32); static bool32 IsChangeBgYForZoomActive(void); static void CreateCityZoomTextSprites(void); -static void DrawCityMap(struct Pokenav5Struct_2 *, int, int); -static void PrintLandmarkNames(struct Pokenav5Struct_2 *, int, int); +static void DrawCityMap(struct Pokenav_RegionMapGfx *, int, int); +static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *, int, int); static void SetCityZoomTextInvisibility(bool32); static void Task_ChangeBgYForZoom(u8 taskId); static void UpdateCityZoomTextPosition(void); @@ -121,12 +124,12 @@ static const LoopedTask sRegionMapLoopTaskFuncs[] = static const struct CompressedSpriteSheet sCityZoomTextSpriteSheet[1] = { - {gRegionMapCityZoomText_Gfx, 0x800, 6} + {gRegionMapCityZoomText_Gfx, 0x800, GFXTAG_CITY_ZOOM} }; static const struct SpritePalette sCityZoomTilesSpritePalette[] = { - {gRegionMapCityZoomTiles_Pal, 11}, + {gRegionMapCityZoomTiles_Pal, PALTAG_CITY_ZOOM}, {} }; @@ -159,8 +162,8 @@ const struct OamData sCityZoomTextSprite_OamData = static const struct SpriteTemplate sCityZoomTextSpriteTemplate = { - .tileTag = 6, - .paletteTag = 11, + .tileTag = GFXTAG_CITY_ZOOM, + .paletteTag = PALTAG_CITY_ZOOM, .oam = &sCityZoomTextSprite_OamData, .anims = gDummySpriteAnimTable, .images = NULL, @@ -170,7 +173,7 @@ static const struct SpriteTemplate sCityZoomTextSpriteTemplate = u32 PokenavCallback_Init_RegionMap(void) { - struct Pokenav5Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_STATE, sizeof(struct Pokenav5Struct)); + struct Pokenav_RegionMapMenu *state = AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_STATE, sizeof(struct Pokenav_RegionMapMenu)); if (!state) return FALSE; @@ -195,11 +198,11 @@ void FreeRegionMapSubstruct1(void) u32 GetRegionMapCallback(void) { - struct Pokenav5Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE); + struct Pokenav_RegionMapMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE); return state->callback(state); } -static u32 HandleRegionMapInput(struct Pokenav5Struct *state) +static u32 HandleRegionMapInput(struct Pokenav_RegionMapMenu *state) { switch (DoRegionMapInputCallback()) { @@ -217,7 +220,7 @@ static u32 HandleRegionMapInput(struct Pokenav5Struct *state) return POKENAV_MAP_FUNC_NONE; } -static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *state) +static u32 HandleRegionMapInputZoomDisabled(struct Pokenav_RegionMapMenu *state) { if (JOY_NEW(B_BUTTON)) { @@ -228,20 +231,20 @@ static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *state) return POKENAV_MAP_FUNC_NONE; } -static u32 GetExitRegionMapMenuId(struct Pokenav5Struct *state) +static u32 GetExitRegionMapMenuId(struct Pokenav_RegionMapMenu *state) { return POKENAV_MAIN_MENU_CURSOR_ON_MAP; } bool32 GetZoomDisabled(void) { - struct Pokenav5Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE); + struct Pokenav_RegionMapMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE); return state->zoomDisabled; } bool32 OpenPokenavRegionMap(void) { - struct Pokenav5Struct_2 *state = AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM, sizeof(struct Pokenav5Struct_2)); + struct Pokenav_RegionMapGfx *state = AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM, sizeof(struct Pokenav_RegionMapGfx)); if (!state) return FALSE; @@ -252,20 +255,20 @@ bool32 OpenPokenavRegionMap(void) void CreateRegionMapLoopedTask(s32 index) { - struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); + struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); state->loopTaskId = CreateLoopedTask(sRegionMapLoopTaskFuncs[index], 1); state->isTaskActiveCB = GetCurrentLoopedTaskActive; } bool32 IsRegionMapLoopedTaskActive(void) { - struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); + struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); return state->isTaskActiveCB(); } void FreeRegionMapSubstruct2(void) { - struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); + struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); FreeRegionMapIconResources(); FreeCityZoomViewGfx(); RemoveWindow(state->infoWindowId); @@ -285,7 +288,7 @@ static void VBlankCB_RegionMap(void) static bool32 GetCurrentLoopedTaskActive(void) { - struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); + struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); return IsLoopedTaskActive(state->loopTaskId); } @@ -301,7 +304,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState) { int menuGfxId; struct RegionMap *regionMap; - struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); + struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); switch (taskState) { case 0: @@ -377,7 +380,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState) static u32 LoopedTask_UpdateInfoAfterCursorMove(s32 taskState) { - struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); + struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); switch (taskState) { case 0: @@ -420,7 +423,7 @@ static u32 LoopedTask_RegionMapZoomOut(s32 taskState) static u32 LoopedTask_RegionMapZoomIn(s32 taskState) { - struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); + struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); switch (taskState) { case 0: @@ -492,14 +495,14 @@ static void LoadCityZoomViewGfx(void) static void FreeCityZoomViewGfx(void) { int i; - struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); - FreeSpriteTilesByTag(6); - FreeSpritePaletteByTag(11); + struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); + FreeSpriteTilesByTag(GFXTAG_CITY_ZOOM); + FreeSpritePaletteByTag(PALTAG_CITY_ZOOM); for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) DestroySprite(state->cityZoomTextSprites[i]); } -static void LoadPokenavRegionMapGfx(struct Pokenav5Struct_2 *state) +static void LoadPokenavRegionMapGfx(struct Pokenav_RegionMapGfx *state) { BgDmaFill(1, PIXEL_FILL(0), 0x40, 1); BgDmaFill(1, PIXEL_FILL(1), 0x41, 1); @@ -527,7 +530,7 @@ static bool32 TryFreeTempTileDataBuffers(void) return FreeTempTileDataBuffersIfPossible(); } -static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *state) +static void UpdateMapSecInfoWindow(struct Pokenav_RegionMapGfx *state) { struct RegionMap *regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP); switch (regionMap->mapSecType) @@ -565,7 +568,7 @@ static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *state) } } -static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav5Struct_2 *state) +static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav_RegionMapGfx *state) { return IsDma3ManagerBusyWithBgCopy(); } @@ -621,7 +624,7 @@ static bool32 IsDecompressCityMapsActive(void) static u32 LoopedTask_DecompressCityMaps(s32 taskState) { - struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); + struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); if (taskState < NUM_CITY_MAPS) { LZ77UnCompWram(sPokenavCityMaps[taskState].tilemap, state->cityZoomPics[taskState]); @@ -631,7 +634,7 @@ static u32 LoopedTask_DecompressCityMaps(s32 taskState) return LT_FINISH; } -static void DrawCityMap(struct Pokenav5Struct_2 *state, int mapSecId, int pos) +static void DrawCityMap(struct Pokenav_RegionMapGfx *state, int mapSecId, int pos) { int i; for (i = 0; i < NUM_CITY_MAPS && (sPokenavCityMaps[i].mapSecId != mapSecId || sPokenavCityMaps[i].index != pos); i++) @@ -644,7 +647,7 @@ static void DrawCityMap(struct Pokenav5Struct_2 *state, int mapSecId, int pos) CopyToBgTilemapBufferRect(1, state->cityZoomPics[i], 18, 6, 10, 10); } -static void PrintLandmarkNames(struct Pokenav5Struct_2 *state, int mapSecId, int pos) +static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *state, int mapSecId, int pos) { int i = 0; while (1) @@ -664,7 +667,7 @@ static void CreateCityZoomTextSprites(void) int i; int y; struct Sprite *sprite; - struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); + struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); // When not zoomed in the text is still created but its pushed off screen if (!IsRegionMapZoomed()) @@ -724,7 +727,7 @@ static void SpriteCB_CityZoomText(struct Sprite *sprite) static void UpdateCityZoomTextPosition(void) { int i; - struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); + struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); int y = 132 - (GetBgY(1) >> 8); for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) state->cityZoomTextSprites[i]->y = y; @@ -733,7 +736,7 @@ static void UpdateCityZoomTextPosition(void) static void SetCityZoomTextInvisibility(bool32 invisible) { int i; - struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); + struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) state->cityZoomTextSprites[i]->invisible = invisible; }