From 28ef2fb774bf596a3e7f81055453304e0d2ce066 Mon Sep 17 00:00:00 2001 From: PokeCodec <67983839+PokeCodec@users.noreply.github.com> Date: Fri, 4 Sep 2020 21:11:55 -0400 Subject: Switch to button macros --- src/party_menu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/party_menu.c') diff --git a/src/party_menu.c b/src/party_menu.c index 7514cf545..e509ef6e0 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -1411,7 +1411,7 @@ static u16 PartyMenuButtonHandler(s8 *slotPtr) break; } - if (gMain.newKeys & START_BUTTON) + if (JOY_NEW(START_BUTTON)) return 8; if (movementDir) @@ -1421,10 +1421,10 @@ static u16 PartyMenuButtonHandler(s8 *slotPtr) } // Pressed Cancel - if ((gMain.newKeys & A_BUTTON) && *slotPtr == PARTY_SIZE + 1) + if ((JOY_NEW(A_BUTTON)) && *slotPtr == PARTY_SIZE + 1) return 2; - return gMain.newKeys & (A_BUTTON | B_BUTTON); + return JOY_NEW(A_BUTTON | B_BUTTON); } static void UpdateCurrentPartySelection(s8 *slotPtr, s8 movementDir) @@ -3765,7 +3765,7 @@ static u16 GetFieldMoveMonSpecies(void) static void Task_CancelAfterAorBPress(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) CursorCb_Cancel1(taskId); } @@ -4722,7 +4722,7 @@ static void Task_DoLearnedMoveFanfareAfterText(u8 taskId) static void Task_LearnNextMoveOrClosePartyMenu(u8 taskId) { - if (IsFanfareTaskInactive() && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) + if (IsFanfareTaskInactive() && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))) { if (gPartyMenu.learnMoveState == 1) Task_TryLearningNextMove(taskId); @@ -4931,7 +4931,7 @@ static void UpdateMonDisplayInfoAfterRareCandy(u8 slot, struct Pokemon *mon) static void Task_DisplayLevelUpStatsPg1(u8 taskId) { - if (WaitFanfare(FALSE) && IsPartyMenuTextPrinterActive() != TRUE && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) + if (WaitFanfare(FALSE) && IsPartyMenuTextPrinterActive() != TRUE && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))) { PlaySE(SE_SELECT); DisplayLevelUpStatsPg1(taskId); @@ -4941,7 +4941,7 @@ static void Task_DisplayLevelUpStatsPg1(u8 taskId) static void Task_DisplayLevelUpStatsPg2(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) { PlaySE(SE_SELECT); DisplayLevelUpStatsPg2(taskId); @@ -4972,7 +4972,7 @@ static void Task_TryLearnNewMoves(u8 taskId) { u16 learnMove; - if (WaitFanfare(0) && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) + if (WaitFanfare(0) && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))) { RemoveLevelUpStatsWindow(); learnMove = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], TRUE); @@ -5609,7 +5609,7 @@ static void Task_ValidateChosenHalfParty(u8 taskId) static void Task_ContinueChoosingHalfParty(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) { PlaySE(SE_SELECT); DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); -- cgit v1.2.3 From f952144922b23d258c6b98ce3da79276d5c1e643 Mon Sep 17 00:00:00 2001 From: Kaz Date: Sun, 13 Sep 2020 03:02:41 -0400 Subject: party_menu fakematch fix --- src/party_menu.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/party_menu.c') diff --git a/src/party_menu.c b/src/party_menu.c index e509ef6e0..39f74e58d 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -1964,19 +1964,17 @@ static u8 CanMonLearnTMTutor(struct Pokemon *mon, u16 item, u8 tutor) if (item >= ITEM_TM01_FOCUS_PUNCH) { - if (CanMonLearnTMHM(mon, item - ITEM_TM01_FOCUS_PUNCH)) - move = ItemIdToBattleMoveId(item); - else + if (!CanMonLearnTMHM(mon, item - ITEM_TM01_FOCUS_PUNCH)) return CANNOT_LEARN_MOVE; - do {} while (0); // :morphon: - } - else if (CanLearnTutorMove(GetMonData(mon, MON_DATA_SPECIES), tutor) == FALSE) - { - return CANNOT_LEARN_MOVE; + else + move = ItemIdToBattleMoveId(item); } else { - move = GetTutorMove(tutor); + if (!CanLearnTutorMove(GetMonData(mon, MON_DATA_SPECIES), tutor)) + return CANNOT_LEARN_MOVE; + else + move = GetTutorMove(tutor); } if (MonKnowsMove(mon, move) == TRUE) -- cgit v1.2.3 From 7dc95a0103af08c95c9093b6efa6c77af77a2538 Mon Sep 17 00:00:00 2001 From: aaaaaa123456789 Date: Sun, 13 Sep 2020 04:22:50 -0300 Subject: Undo PokeCodec's PRs This commit undoes most of PokeCodec's PRs after the debate in chat. Some harmless or completely superseded PRs have been left alone, as there is not much benefit in attempting to undo them. Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136, #1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179, #1180, #1181, #1182 and #1183. --- src/party_menu.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/party_menu.c') diff --git a/src/party_menu.c b/src/party_menu.c index e509ef6e0..7f4697d7d 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -1411,7 +1411,7 @@ static u16 PartyMenuButtonHandler(s8 *slotPtr) break; } - if (JOY_NEW(START_BUTTON)) + if (gMain.newKeys & START_BUTTON) return 8; if (movementDir) @@ -1421,10 +1421,10 @@ static u16 PartyMenuButtonHandler(s8 *slotPtr) } // Pressed Cancel - if ((JOY_NEW(A_BUTTON)) && *slotPtr == PARTY_SIZE + 1) + if ((gMain.newKeys & A_BUTTON) && *slotPtr == PARTY_SIZE + 1) return 2; - return JOY_NEW(A_BUTTON | B_BUTTON); + return gMain.newKeys & (A_BUTTON | B_BUTTON); } static void UpdateCurrentPartySelection(s8 *slotPtr, s8 movementDir) @@ -1862,7 +1862,7 @@ u8 GetMonAilment(struct Pokemon *mon) static void SetPartyMonsAllowedInMinigame(void) { - s16 *ptr; + u16 *ptr; if (gPartyMenu.menuType == PARTY_MENU_TYPE_MINIGAME) { @@ -3765,7 +3765,7 @@ static u16 GetFieldMoveMonSpecies(void) static void Task_CancelAfterAorBPress(u8 taskId) { - if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) CursorCb_Cancel1(taskId); } @@ -4722,7 +4722,7 @@ static void Task_DoLearnedMoveFanfareAfterText(u8 taskId) static void Task_LearnNextMoveOrClosePartyMenu(u8 taskId) { - if (IsFanfareTaskInactive() && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))) + if (IsFanfareTaskInactive() && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) { if (gPartyMenu.learnMoveState == 1) Task_TryLearningNextMove(taskId); @@ -4931,7 +4931,7 @@ static void UpdateMonDisplayInfoAfterRareCandy(u8 slot, struct Pokemon *mon) static void Task_DisplayLevelUpStatsPg1(u8 taskId) { - if (WaitFanfare(FALSE) && IsPartyMenuTextPrinterActive() != TRUE && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))) + if (WaitFanfare(FALSE) && IsPartyMenuTextPrinterActive() != TRUE && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) { PlaySE(SE_SELECT); DisplayLevelUpStatsPg1(taskId); @@ -4941,7 +4941,7 @@ static void Task_DisplayLevelUpStatsPg1(u8 taskId) static void Task_DisplayLevelUpStatsPg2(u8 taskId) { - if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) { PlaySE(SE_SELECT); DisplayLevelUpStatsPg2(taskId); @@ -4951,9 +4951,9 @@ static void Task_DisplayLevelUpStatsPg2(u8 taskId) static void DisplayLevelUpStatsPg1(u8 taskId) { - u16 *arrayPtr = (u16*)sPartyMenuInternal->data; + s16 *arrayPtr = sPartyMenuInternal->data; - arrayPtr[12] = (u16)CreateLevelUpStatsWindow(); + arrayPtr[12] = CreateLevelUpStatsWindow(); DrawLevelUpWindowPg1(arrayPtr[12], arrayPtr, &arrayPtr[6], TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY); CopyWindowToVram(arrayPtr[12], 2); ScheduleBgCopyTilemapToVram(2); @@ -4961,7 +4961,7 @@ static void DisplayLevelUpStatsPg1(u8 taskId) static void DisplayLevelUpStatsPg2(u8 taskId) { - u16 *arrayPtr = (u16 *)sPartyMenuInternal->data; + s16 *arrayPtr = sPartyMenuInternal->data; DrawLevelUpWindowPg2(arrayPtr[12], &arrayPtr[6], TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY); CopyWindowToVram(arrayPtr[12], 2); @@ -4972,7 +4972,7 @@ static void Task_TryLearnNewMoves(u8 taskId) { u16 learnMove; - if (WaitFanfare(0) && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))) + if (WaitFanfare(0) && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) { RemoveLevelUpStatsWindow(); learnMove = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], TRUE); @@ -5609,7 +5609,7 @@ static void Task_ValidateChosenHalfParty(u8 taskId) static void Task_ContinueChoosingHalfParty(u8 taskId) { - if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) { PlaySE(SE_SELECT); DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); -- cgit v1.2.3 From 52598983250fd8ad7b66ff2b9d77046859f169c8 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 1 Oct 2020 17:20:38 -0400 Subject: Replace POKEMON_SLOTS_NUMBER --- src/party_menu.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/party_menu.c') diff --git a/src/party_menu.c b/src/party_menu.c index e509ef6e0..1d4952375 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -74,7 +74,6 @@ #include "constants/party_menu.h" #include "constants/rgb.h" #include "constants/songs.h" -#include "constants/species.h" #define PARTY_PAL_SELECTED (1 << 0) #define PARTY_PAL_FAINTED (1 << 1) -- cgit v1.2.3 From 2239f3aa6068925f04350b3089714dc8e1eafa9a Mon Sep 17 00:00:00 2001 From: Thomas Winwood Date: Wed, 21 Oct 2020 20:07:34 +0100 Subject: Eliminate goto in ItemUseCB_Medicine --- src/party_menu.c | 85 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 41 deletions(-) (limited to 'src/party_menu.c') diff --git a/src/party_menu.c b/src/party_menu.c index 1d4952375..862302229 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -4325,9 +4325,13 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task) u16 hp = 0; struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; u16 item = gSpecialVar_ItemId; - bool8 canHeal; + bool8 canHeal, cannotUse; - if (NotUsingHPEVItemOnShedinja(mon, item)) + if (NotUsingHPEVItemOnShedinja(mon, item) == FALSE) + { + cannotUse = TRUE; + } + else { canHeal = IsHPRecoveryItem(item); if (canHeal == TRUE) @@ -4336,50 +4340,49 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task) if (hp == GetMonData(mon, MON_DATA_MAX_HP)) canHeal = FALSE; } - if (ExecuteTableBasedItemEffect_(gPartyMenu.slotId, item, 0)) - { - iTriedHonestlyIDid: - gPartyMenuUseExitCallback = FALSE; - PlaySE(SE_SELECT); - DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); - ScheduleBgCopyTilemapToVram(2); - gTasks[taskId].func = task; - return; - } - } - else - { - goto iTriedHonestlyIDid; //TODO: resolve this goto + cannotUse = ExecuteTableBasedItemEffect_(gPartyMenu.slotId, item, 0); } - gPartyMenuUseExitCallback = TRUE; - if (!IsItemFlute(item)) - { - PlaySE(SE_USE_ITEM); - if (gPartyMenu.action != PARTY_ACTION_REUSABLE_ITEM) - RemoveBagItem(item, 1); - } - else - { - PlaySE(SE_GLASS_FLUTE); - } - SetPartyMonAilmentGfx(mon, &sPartyMenuBoxes[gPartyMenu.slotId]); - if (gSprites[sPartyMenuBoxes[gPartyMenu.slotId].statusSpriteId].invisible) - DisplayPartyPokemonLevelCheck(mon, &sPartyMenuBoxes[gPartyMenu.slotId], 1); - if (canHeal == TRUE) + + if (cannotUse != FALSE) { - if (hp == 0) - AnimatePartySlot(gPartyMenu.slotId, 1); - PartyMenuModifyHP(taskId, gPartyMenu.slotId, 1, GetMonData(mon, MON_DATA_HP) - hp, Task_DisplayHPRestoredMessage); - ResetHPTaskData(taskId, 0, hp); - return; + gPartyMenuUseExitCallback = FALSE; + PlaySE(SE_SELECT); + DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); + ScheduleBgCopyTilemapToVram(2); + gTasks[taskId].func = task; } else { - GetMonNickname(mon, gStringVar1); - GetMedicineItemEffectMessage(item); - DisplayPartyMenuMessage(gStringVar4, TRUE); - ScheduleBgCopyTilemapToVram(2); - gTasks[taskId].func = task; + gPartyMenuUseExitCallback = TRUE; + if (!IsItemFlute(item)) + { + PlaySE(SE_USE_ITEM); + if (gPartyMenu.action != PARTY_ACTION_REUSABLE_ITEM) + RemoveBagItem(item, 1); + } + else + { + PlaySE(SE_GLASS_FLUTE); + } + SetPartyMonAilmentGfx(mon, &sPartyMenuBoxes[gPartyMenu.slotId]); + if (gSprites[sPartyMenuBoxes[gPartyMenu.slotId].statusSpriteId].invisible) + DisplayPartyPokemonLevelCheck(mon, &sPartyMenuBoxes[gPartyMenu.slotId], 1); + if (canHeal == TRUE) + { + if (hp == 0) + AnimatePartySlot(gPartyMenu.slotId, 1); + PartyMenuModifyHP(taskId, gPartyMenu.slotId, 1, GetMonData(mon, MON_DATA_HP) - hp, Task_DisplayHPRestoredMessage); + ResetHPTaskData(taskId, 0, hp); + return; + } + else + { + GetMonNickname(mon, gStringVar1); + GetMedicineItemEffectMessage(item); + DisplayPartyMenuMessage(gStringVar4, TRUE); + ScheduleBgCopyTilemapToVram(2); + gTasks[taskId].func = task; + } } } -- cgit v1.2.3 From bacc831aa91d059936bd7c852bf0a0fb44d8f27a Mon Sep 17 00:00:00 2001 From: aaaaaa123456789 Date: Mon, 2 Nov 2020 22:02:39 -0300 Subject: Re-apply joypad macros (minus merge conflicts) --- src/party_menu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/party_menu.c') diff --git a/src/party_menu.c b/src/party_menu.c index 6e22fa542..cc69b1fcd 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -1410,7 +1410,7 @@ static u16 PartyMenuButtonHandler(s8 *slotPtr) break; } - if (gMain.newKeys & START_BUTTON) + if (JOY_NEW(START_BUTTON)) return 8; if (movementDir) @@ -1420,10 +1420,10 @@ static u16 PartyMenuButtonHandler(s8 *slotPtr) } // Pressed Cancel - if ((gMain.newKeys & A_BUTTON) && *slotPtr == PARTY_SIZE + 1) + if ((JOY_NEW(A_BUTTON)) && *slotPtr == PARTY_SIZE + 1) return 2; - return gMain.newKeys & (A_BUTTON | B_BUTTON); + return JOY_NEW(A_BUTTON | B_BUTTON); } static void UpdateCurrentPartySelection(s8 *slotPtr, s8 movementDir) @@ -3764,7 +3764,7 @@ static u16 GetFieldMoveMonSpecies(void) static void Task_CancelAfterAorBPress(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) CursorCb_Cancel1(taskId); } @@ -4721,7 +4721,7 @@ static void Task_DoLearnedMoveFanfareAfterText(u8 taskId) static void Task_LearnNextMoveOrClosePartyMenu(u8 taskId) { - if (IsFanfareTaskInactive() && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) + if (IsFanfareTaskInactive() && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))) { if (gPartyMenu.learnMoveState == 1) Task_TryLearningNextMove(taskId); @@ -4930,7 +4930,7 @@ static void UpdateMonDisplayInfoAfterRareCandy(u8 slot, struct Pokemon *mon) static void Task_DisplayLevelUpStatsPg1(u8 taskId) { - if (WaitFanfare(FALSE) && IsPartyMenuTextPrinterActive() != TRUE && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) + if (WaitFanfare(FALSE) && IsPartyMenuTextPrinterActive() != TRUE && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))) { PlaySE(SE_SELECT); DisplayLevelUpStatsPg1(taskId); @@ -4940,7 +4940,7 @@ static void Task_DisplayLevelUpStatsPg1(u8 taskId) static void Task_DisplayLevelUpStatsPg2(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) { PlaySE(SE_SELECT); DisplayLevelUpStatsPg2(taskId); @@ -4971,7 +4971,7 @@ static void Task_TryLearnNewMoves(u8 taskId) { u16 learnMove; - if (WaitFanfare(0) && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) + if (WaitFanfare(0) && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))) { RemoveLevelUpStatsWindow(); learnMove = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], TRUE); @@ -5608,7 +5608,7 @@ static void Task_ValidateChosenHalfParty(u8 taskId) static void Task_ContinueChoosingHalfParty(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) { PlaySE(SE_SELECT); DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); -- cgit v1.2.3