From 8f5e2bbebaae3857cbe95b40b0d889f73f7d80f0 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 21 Aug 2021 11:04:28 -0400 Subject: [PATCH] Label swap line margin flag --- include/menu_helpers.h | 5 +---- src/battle_pyramid_bag.c | 2 +- src/item_menu_icons.c | 2 +- src/menu_helpers.c | 10 +++++++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/menu_helpers.h b/include/menu_helpers.h index 1434efcf3..df71ce252 100644 --- a/include/menu_helpers.h +++ b/include/menu_helpers.h @@ -7,7 +7,7 @@ #define MENU_L_PRESSED 1 #define MENU_R_PRESSED 2 -// Exported type declarations +#define SWAP_LINE_HAS_MARGIN (1 << 7) struct YesNoFuncTable { @@ -15,9 +15,6 @@ struct YesNoFuncTable TaskFunc noFunc; }; -// Exported RAM declarations - -// Exported ROM declarations void ResetVramOamAndBgCntRegs(void); void ResetAllBgsCoordinates(void); void SetVBlankHBlankCallbacksToNull(void); diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index 83bf35090..9cc65e14d 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -1608,5 +1608,5 @@ static void SetSwapLineInvisibility(bool8 invisible) static void UpdateSwapLinePos(u8 y) { - UpdateSwapLineSpritesPos(&gPyramidBagMenu->spriteIds[PBAG_SPRITE_SWAP_LINE_START], NUM_SWAP_LINE_SPRITES | 0x80, 120, (y + 1) * 16); + UpdateSwapLineSpritesPos(&gPyramidBagMenu->spriteIds[PBAG_SPRITE_SWAP_LINE_START], NUM_SWAP_LINE_SPRITES | SWAP_LINE_HAS_MARGIN, 120, (y + 1) * 16); } diff --git a/src/item_menu_icons.c b/src/item_menu_icons.c index c8d1cd8d0..8bcf506fb 100644 --- a/src/item_menu_icons.c +++ b/src/item_menu_icons.c @@ -559,7 +559,7 @@ void SetItemMenuSwapLineInvisibility(bool8 invisible) void UpdateItemMenuSwapLinePos(u8 y) { - UpdateSwapLineSpritesPos(&gBagMenu->spriteIds[ITEMMENUSPRITE_SWAP_LINE], ITEMMENU_SWAP_LINE_LENGTH | 0x80, 120, (y + 1) * 16); + UpdateSwapLineSpritesPos(&gBagMenu->spriteIds[ITEMMENUSPRITE_SWAP_LINE], ITEMMENU_SWAP_LINE_LENGTH | SWAP_LINE_HAS_MARGIN, 120, (y + 1) * 16); } static void sub_80D5018(void *mem0, void *mem1) 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;