From c786a9b20c7d70546523a13406d7871f5fa5be2b Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 11 Apr 2021 16:23:10 -0400 Subject: Document pokeblock menu --- src/menu_helpers.c | 60 +++++++++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 32 deletions(-) (limited to 'src/menu_helpers.c') diff --git a/src/menu_helpers.c b/src/menu_helpers.c index e7385a5ed..5a6ac8394 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -18,19 +18,17 @@ #include "constants/items.h" #include "constants/maps.h" -// this file's functions +#define TAG_SWAP_LINE 109 + static void Task_ContinueTaskAfterMessagePrints(u8 taskId); static void Task_CallYesOrNoCallback(u8 taskId); -// EWRAM vars EWRAM_DATA static struct YesNoFuncTable gUnknown_0203A138 = {0}; EWRAM_DATA static u8 gUnknown_0203A140 = 0; -// IWRAM bss vars static TaskFunc gUnknown_0300117C; -// const rom data -static const struct OamData sOamData_859F4E8 = +static const struct OamData sOamData_SwapLine = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -47,47 +45,47 @@ static const struct OamData sOamData_859F4E8 = .affineParam = 0 }; -static const union AnimCmd sSpriteAnim_859F4F0[] = +static const union AnimCmd sAnim_SwapLine_RightArrow[] = { ANIMCMD_FRAME(0, 0), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_859F4F8[] = +static const union AnimCmd sAnim_SwapLine_Line[] = { ANIMCMD_FRAME(4, 0), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_859F500[] = +static const union AnimCmd sAnim_SwapLine_LeftArrow[] = { - ANIMCMD_FRAME(0, 0, 1, 0), + ANIMCMD_FRAME(0, 0, .hFlip = TRUE), ANIMCMD_END }; -static const union AnimCmd *const sSpriteAnimTable_859F508[] = +static const union AnimCmd *const sAnims_SwapLine[] = { - sSpriteAnim_859F4F0, - sSpriteAnim_859F4F8, - sSpriteAnim_859F500 + sAnim_SwapLine_RightArrow, + sAnim_SwapLine_Line, + sAnim_SwapLine_LeftArrow }; -static const struct CompressedSpriteSheet gUnknown_0859F514 = +static const struct CompressedSpriteSheet sSpriteSheet_SwapLine = { - gBagSwapLineGfx, 0x100, 109 + gBagSwapLineGfx, 0x100, TAG_SWAP_LINE }; -static const struct CompressedSpritePalette gUnknown_0859F51C = +static const struct CompressedSpritePalette sSpritePalette_SwapLine = { - gBagSwapLinePal, 109 + gBagSwapLinePal, TAG_SWAP_LINE }; -static const struct SpriteTemplate gUnknown_0859F524 = +static const struct SpriteTemplate sSpriteTemplate_SwapLine = { - .tileTag = 109, - .paletteTag = 109, - .oam = &sOamData_859F4E8, - .anims = sSpriteAnimTable_859F508, + .tileTag = TAG_SWAP_LINE, + .paletteTag = TAG_SWAP_LINE, + .oam = &sOamData_SwapLine, + .anims = sAnims_SwapLine, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy, @@ -390,19 +388,19 @@ void sub_8122298(u16 *arg0, u16 *arg1, u8 arg2, u8 arg3, u8 arg4) } } -void LoadListMenuArrowsGfx(void) +void LoadListMenuSwapLineGfx(void) { - LoadCompressedSpriteSheet(&gUnknown_0859F514); - LoadCompressedSpritePalette(&gUnknown_0859F51C); + LoadCompressedSpriteSheet(&sSpriteSheet_SwapLine); + LoadCompressedSpritePalette(&sSpritePalette_SwapLine); } -void sub_8122344(u8 *spriteIds, u8 count) +void CreateSwapLineSprites(u8 *spriteIds, u8 count) { u8 i; for (i = 0; i < count; i++) { - spriteIds[i] = CreateSprite(&gUnknown_0859F524, i * 16, 0, 0); + spriteIds[i] = CreateSprite(&sSpriteTemplate_SwapLine, i * 16, 0, 0); if (i != 0) StartSpriteAnim(&gSprites[spriteIds[i]], 1); @@ -410,7 +408,7 @@ void sub_8122344(u8 *spriteIds, u8 count) } } -void sub_81223B0(u8 *spriteIds, u8 count) +void DestroySwapLineSprites(u8 *spriteIds, u8 count) { u8 i; @@ -423,17 +421,15 @@ void sub_81223B0(u8 *spriteIds, u8 count) } } -void sub_81223FC(u8 *spriteIds, u8 count, bool8 invisible) +void SetSwapLineSpritesInvisibility(u8 *spriteIds, u8 count, bool8 invisible) { u8 i; for (i = 0; i < count; i++) - { gSprites[spriteIds[i]].invisible = invisible; - } } -void sub_8122448(u8 *spriteIds, u8 count, s16 x, u16 y) +void UpdateSwapLineSpritesPos(u8 *spriteIds, u8 count, s16 x, u16 y) { u8 i; bool8 unknownBit = count & 0x80; -- cgit v1.2.3 From 8c820878bfa91e7a00953e02a5e93847c5428468 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 22 Apr 2021 18:49:54 -0400 Subject: Document Battle Pyramid Bag --- src/menu_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/menu_helpers.c') diff --git a/src/menu_helpers.c b/src/menu_helpers.c index 5a6ac8394..151de0bd4 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -287,7 +287,7 @@ bool8 sub_8122148(u16 itemId) return FALSE; } -bool8 itemid_80BF6D8_mail_related(u16 itemId) +bool8 IsWritingMailAllowed(u16 itemId) { if (IsUpdateLinkStateCBActive() != TRUE && InUnionRoom() != TRUE) return TRUE; -- cgit v1.2.3 From 810ca5f8ff79aeec6ffe8e982f4786aade616b4d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 7 Jul 2021 09:11:52 -0400 Subject: Flatten pos fields in struct Sprite --- src/menu_helpers.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/menu_helpers.c') diff --git a/src/menu_helpers.c b/src/menu_helpers.c index 151de0bd4..dce00e51e 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -438,10 +438,10 @@ void UpdateSwapLineSpritesPos(u8 *spriteIds, u8 count, s16 x, u16 y) for (i = 0; i < count; i++) { if (i == count - 1 && unknownBit) - gSprites[spriteIds[i]].pos2.x = x - 8; + gSprites[spriteIds[i]].x2 = x - 8; else - gSprites[spriteIds[i]].pos2.x = x; + gSprites[spriteIds[i]].x2 = x; - gSprites[spriteIds[i]].pos1.y = 1 + y; + gSprites[spriteIds[i]].y = 1 + y; } } -- cgit v1.2.3 From 06b909bcd80e5b3f882273a317ac957cd57f07a5 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 25 Apr 2021 12:07:08 -0400 Subject: Document player pc --- src/menu_helpers.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src/menu_helpers.c') diff --git a/src/menu_helpers.c b/src/menu_helpers.c index 5a6ac8394..7da4f939b 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -323,36 +323,38 @@ bool8 MenuHelpers_CallLinkSomething(void) return TRUE; } -void sub_812220C(struct ItemSlot *slots, u8 count, u8 *arg2, u8 *usedSlotsCount, u8 maxUsedSlotsCount) +void SetItemListPerPageCount(struct ItemSlot *slots, u8 slotsCount, u8 *pageItems, u8 *totalItems, u8 maxPerPage) { u16 i; struct ItemSlot *slots_ = slots; - (*usedSlotsCount) = 0; - for (i = 0; i < count; i++) + // Count the number of non-empty item slots + *totalItems = 0; + for (i = 0; i < slotsCount; i++) { if (slots_[i].itemId != ITEM_NONE) - (*usedSlotsCount)++; + (*totalItems)++; } + (*totalItems)++; // + 1 for 'Cancel' - (*usedSlotsCount)++; - if ((*usedSlotsCount) > maxUsedSlotsCount) - *arg2 = maxUsedSlotsCount; + // Set number of items per page + if (*totalItems > maxPerPage) + *pageItems = maxPerPage; else - *arg2 = (*usedSlotsCount); + *pageItems = *totalItems; } -void sub_812225C(u16 *scrollOffset, u16 *cursorPos, u8 maxShownItems, u8 numItems) +void SetCursorWithinListBounds(u16 *scrollOffset, u16 *cursorPos, u8 maxShownItems, u8 totalItems) { - if (*scrollOffset != 0 && *scrollOffset + maxShownItems > numItems) - *scrollOffset = numItems - maxShownItems; + if (*scrollOffset != 0 && *scrollOffset + maxShownItems > totalItems) + *scrollOffset = totalItems - maxShownItems; - if (*scrollOffset + *cursorPos >= numItems) + if (*scrollOffset + *cursorPos >= totalItems) { - if (numItems == 0) + if (totalItems == 0) *cursorPos = 0; else - *cursorPos = numItems - 1; + *cursorPos = totalItems - 1; } } -- cgit v1.2.3 From 28a8fe191af71a71d45afb93480dc59f98e790cf Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 3 Aug 2021 02:17:01 -0400 Subject: Document item menu --- src/menu_helpers.c | 60 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 27 deletions(-) (limited to 'src/menu_helpers.c') diff --git a/src/menu_helpers.c b/src/menu_helpers.c index dce00e51e..1a257ae8f 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -23,10 +23,10 @@ static void Task_ContinueTaskAfterMessagePrints(u8 taskId); static void Task_CallYesOrNoCallback(u8 taskId); -EWRAM_DATA static struct YesNoFuncTable gUnknown_0203A138 = {0}; -EWRAM_DATA static u8 gUnknown_0203A140 = 0; +EWRAM_DATA static struct YesNoFuncTable sYesNo = {0}; +EWRAM_DATA static u8 sMessageWindowId = 0; -static TaskFunc gUnknown_0300117C; +static TaskFunc sMessageNextTask; static const struct OamData sOamData_SwapLine = { @@ -122,17 +122,17 @@ void SetVBlankHBlankCallbacksToNull(void) SetHBlankCallback(NULL); } -void DisplayMessageAndContinueTask(u8 taskId, u8 windowId, u16 arg2, u8 arg3, u8 fontId, u8 textSpeed, const u8 *string, void *taskFunc) +void DisplayMessageAndContinueTask(u8 taskId, u8 windowId, u16 tileNum, u8 paletteNum, u8 fontId, u8 textSpeed, const u8 *string, void *taskFunc) { - gUnknown_0203A140 = windowId; - DrawDialogFrameWithCustomTileAndPalette(windowId, TRUE, arg2, arg3); + sMessageWindowId = windowId; + DrawDialogFrameWithCustomTileAndPalette(windowId, TRUE, tileNum, paletteNum); if (string != gStringVar4) StringExpandPlaceholders(gStringVar4, string); gTextFlags.canABSpeedUpPrint = 1; AddTextPrinterParameterized2(windowId, fontId, gStringVar4, textSpeed, NULL, 2, 1, 3); - gUnknown_0300117C = taskFunc; + sMessageNextTask = taskFunc; gTasks[taskId].func = Task_ContinueTaskAfterMessagePrints; } @@ -144,20 +144,20 @@ bool16 RunTextPrintersRetIsActive(u8 textPrinterId) static void Task_ContinueTaskAfterMessagePrints(u8 taskId) { - if (!RunTextPrintersRetIsActive(gUnknown_0203A140)) - gUnknown_0300117C(taskId); + if (!RunTextPrintersRetIsActive(sMessageWindowId)) + sMessageNextTask(taskId); } void DoYesNoFuncWithChoice(u8 taskId, const struct YesNoFuncTable *data) { - gUnknown_0203A138 = *data; + sYesNo = *data; gTasks[taskId].func = Task_CallYesOrNoCallback; } void CreateYesNoMenuWithCallbacks(u8 taskId, const struct WindowTemplate *template, u8 arg2, u8 arg3, u8 arg4, u16 tileStart, u8 palette, const struct YesNoFuncTable *yesNo) { CreateYesNoMenu(template, tileStart, palette, 0); - gUnknown_0203A138 = *yesNo; + sYesNo = *yesNo; gTasks[taskId].func = Task_CallYesOrNoCallback; } @@ -167,12 +167,12 @@ static void Task_CallYesOrNoCallback(u8 taskId) { case 0: PlaySE(SE_SELECT); - gUnknown_0203A138.yesFunc(taskId); + sYesNo.yesFunc(taskId); break; case 1: case MENU_B_PRESSED: PlaySE(SE_SELECT); - gUnknown_0203A138.noFunc(taskId); + sYesNo.noFunc(taskId); break; } } @@ -275,11 +275,13 @@ u8 GetLRKeysPressedAndHeld(void) return 0; } -bool8 sub_8122148(u16 itemId) +bool8 IsHoldingItemAllowed(u16 itemId) { + // Enigma Berry can't be held in link areas if (itemId != ITEM_ENIGMA_BERRY) return TRUE; - else if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(TRADE_CENTER) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRADE_CENTER)) + else if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(TRADE_CENTER) + && gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRADE_CENTER)) return FALSE; else if (InUnionRoom() != TRUE) return TRUE; @@ -356,33 +358,37 @@ void sub_812225C(u16 *scrollOffset, u16 *cursorPos, u8 maxShownItems, u8 numItem } } -void sub_8122298(u16 *arg0, u16 *arg1, u8 arg2, u8 arg3, u8 arg4) +void SetCursorScrollWithinListBounds(u16 *scrollOffset, u16 *cursorPos, u8 shownItems, u8 totalItems, u8 maxShownItems) { u8 i; - if (arg4 % 2 != 0) + if (maxShownItems % 2 != 0) { - if ((*arg1) >= arg4 / 2) + // Is cursor at least halfway down visible list + if (*cursorPos >= maxShownItems / 2) { - for (i = 0; i < (*arg1) - (arg4 / 2); i++) + for (i = 0; i < *cursorPos - (maxShownItems / 2); i++) { - if ((*arg0) + arg2 == arg3) + // Stop if reached end of list + if (*scrollOffset + shownItems == totalItems) break; - (*arg1)--; - (*arg0)++; + (*cursorPos)--; + (*scrollOffset)++; } } } else { - if ((*arg1) >= (arg4 / 2) + 1) + // Is cursor at least halfway down visible list + if (*cursorPos >= (maxShownItems / 2) + 1) { - for (i = 0; i <= (*arg1) - (arg4 / 2); i++) + for (i = 0; i <= *cursorPos - (maxShownItems / 2); i++) { - if ((*arg0) + arg2 == arg3) + // Stop if reached end of list + if (*scrollOffset + shownItems == totalItems) break; - (*arg1)--; - (*arg0)++; + (*cursorPos)--; + (*scrollOffset)++; } } } -- cgit v1.2.3 From 8f5e2bbebaae3857cbe95b40b0d889f73f7d80f0 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 21 Aug 2021 11:04:28 -0400 Subject: Label swap line margin flag --- src/menu_helpers.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/menu_helpers.c') diff --git a/src/menu_helpers.c b/src/menu_helpers.c index 3e8148a42..95b67f78c 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -440,12 +440,16 @@ void SetSwapLineSpritesInvisibility(u8 *spriteIds, u8 count, bool8 invisible) void UpdateSwapLineSpritesPos(u8 *spriteIds, u8 count, s16 x, u16 y) { u8 i; - bool8 unknownBit = count & 0x80; - count &= ~(0x80); + bool8 hasMargin = count & SWAP_LINE_HAS_MARGIN; + count &= ~SWAP_LINE_HAS_MARGIN; for (i = 0; i < count; i++) { - if (i == count - 1 && unknownBit) + // If the list menu has a right margin, the swap line + // shouldn't extend all the way to the edge of the screen. + // If this is the last sprite in the line, move it a bit + // to the left to keep it out of the margin. + if (i == count - 1 && hasMargin) gSprites[spriteIds[i]].x2 = x - 8; else gSprites[spriteIds[i]].x2 = x; -- cgit v1.2.3