From aec7eb60892a745115c3521a7f049798f2d84f36 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 31 Oct 2019 14:11:55 -0400 Subject: [PATCH] Clean up party_menu doc --- include/party_menu.h | 14 +- include/pokemon.h | 4 +- include/pokemon_icon.h | 2 +- src/battle_controllers.c | 34 ++-- src/battle_gfx_sfx_util.c | 2 +- src/battle_pyramid_bag.c | 4 +- src/contest.c | 10 +- src/party_menu.c | 317 ++++++++++++++++---------------------- src/pokemon.c | 12 +- src/pokemon_icon.c | 2 +- src/trade.c | 12 +- 11 files changed, 184 insertions(+), 229 deletions(-) diff --git a/include/party_menu.h b/include/party_menu.h index c8926c0b95..0140901c19 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -40,14 +40,14 @@ void Task_HandleChooseMonInput(u8 taskId); u8* GetMonNickname(struct Pokemon *mon, u8 *dest); u8 DisplayPartyMenuMessage(const u8* str, bool8 keepOpen); bool8 IsPartyMenuTextPrinterActive(void); -void PartyMenuModifyHP(u8 taskId, u8 slot, s8 c, s16 HPDifference, TaskFunc func); +void PartyMenuModifyHP(u8 taskId, u8 slot, s8 hpIncrement, s16 HPDifference, TaskFunc task); u8 GetAilmentFromStatus(u32 status); u8 GetMonAilment(struct Pokemon *mon); -void DisplayPartyMenuStdMessage(u32 stringID); +void DisplayPartyMenuStdMessage(u32 stringId); bool8 FieldCallback_PrepareFadeInFromMenu(void); void CB2_ReturnToPartyMenuFromFlyMap(void); void LoadHeldItemIcons(void); -void DrawHeldItemIconsForTrade(u8 *a, u8 *b, u8 c); +void DrawHeldItemIconsForTrade(u8 *partyCounts, u8 *partySpriteIds, u8 whichParty); void CB2_ShowPartyMenuForItemUse(void); void ItemUseCB_Medicine(u8 taskId, TaskFunc task); void ItemUseCB_ReduceEV(u8 taskId, TaskFunc task); @@ -66,13 +66,13 @@ void CB2_ChooseMonToGiveItem(void); void ChooseMonToGiveMailFromMailbox(void); void InitChooseHalfPartyForBattle(u8 unused); void ClearSelectedPartyOrder(void); -void ChooseMonForTradingBoard(u8 initArg, MainCallback callback); +void ChooseMonForTradingBoard(u8 menuType, MainCallback callback); void ChooseMonForMoveTutor(void); void ChooseMonForWirelessMinigame(void); -void OpenPartyMenuInBattle(u8 arg); +void OpenPartyMenuInBattle(u8 partyAction); void ChooseMonForInBattleItem(void); -void sub_81B8C68(void); -void sub_81B8D64(u8 battlerId, u8 multiplayerFlag); +void BufferBattlePartyCurrentOrder(void); +void BufferBattlePartyCurrentOrderBySide(u8 battlerId, u8 flankId); void SwitchPartyOrderLinkMulti(u8 battlerId, u8 slot, u8 arrayIndex); void SwitchPartyMonSlots(u8 slot, u8 slot2); u8 GetPartyIdFromBattlePartyId(u8 slot); diff --git a/include/pokemon.h b/include/pokemon.h index bb71aa8779..316fbc2b3a 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -356,8 +356,8 @@ u16 SpeciesToCryId(u16 species); void sub_806D544(u16 species, u32 personality, u8 *dest); void DrawSpindaSpots(u16 species, u32 personality, u8 *dest, u8 a4); void EvolutionRenameMon(struct Pokemon *mon, u16 oldSpecies, u16 newSpecies); -bool8 sub_806D7EC(void); -bool16 GetLinkTrainerFlankId(u8 id); +u8 GetPlayerFlankId(void); +u16 GetLinkTrainerFlankId(u8 id); s32 GetBattlerMultiplayerId(u16 a1); u8 GetTrainerEncounterMusicId(u16 trainerOpponentId); u16 ModifyStatByNature(u8 nature, u16 n, u8 statIndex); diff --git a/include/pokemon_icon.h b/include/pokemon_icon.h index 4fb9903026..9d56aebcb0 100644 --- a/include/pokemon_icon.h +++ b/include/pokemon_icon.h @@ -21,7 +21,7 @@ u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u u8 UpdateMonIconFrame(struct Sprite *sprite); void LoadMonIconPalette(u16 species); void sub_80D328C(struct Sprite *sprite); -void MonIconSpriteCallback(struct Sprite *sprite); +void SpriteCB_MonIcon(struct Sprite *sprite); void SetPartyHPBarSprite(struct Sprite *sprite, u8 animNum); u8 GetMonIconPaletteIndexFromSpecies(u16 species); diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 29540f3a94..d0e76ab1b1 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -95,7 +95,7 @@ void sub_8032768(void) if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { for (i = 0; i < gBattlersCount; i++) - sub_81B8D64(i, 0); + BufferBattlePartyCurrentOrderBySide(i, 0); } for (i = 0; i < sizeof(gBattleStruct->tvMovePoints); i++) @@ -144,10 +144,10 @@ static void InitSinglePlayerBtlControllers(void) gBattlersCount = MAX_BATTLERS_COUNT; - sub_81B8D64(0, 0); - sub_81B8D64(1, 0); - sub_81B8D64(2, 1); - sub_81B8D64(3, 1); + BufferBattlePartyCurrentOrderBySide(0, 0); + BufferBattlePartyCurrentOrderBySide(1, 0); + BufferBattlePartyCurrentOrderBySide(2, 1); + BufferBattlePartyCurrentOrderBySide(3, 1); gBattlerPartyIndexes[0] = 0; gBattlerPartyIndexes[1] = 0; @@ -247,10 +247,10 @@ static void InitSinglePlayerBtlControllers(void) gBattlersCount = MAX_BATTLERS_COUNT; - sub_81B8D64(0, 0); - sub_81B8D64(1, 0); - sub_81B8D64(2, 1); - sub_81B8D64(3, 1); + BufferBattlePartyCurrentOrderBySide(0, 0); + BufferBattlePartyCurrentOrderBySide(1, 0); + BufferBattlePartyCurrentOrderBySide(2, 1); + BufferBattlePartyCurrentOrderBySide(3, 1); gBattlerPartyIndexes[0] = 0; gBattlerPartyIndexes[1] = 0; @@ -267,11 +267,11 @@ static void InitSinglePlayerBtlControllers(void) { case 0: case 3: - sub_81B8D64(gLinkPlayers[i].id, 0); + BufferBattlePartyCurrentOrderBySide(gLinkPlayers[i].id, 0); break; case 1: case 2: - sub_81B8D64(gLinkPlayers[i].id, 1); + BufferBattlePartyCurrentOrderBySide(gLinkPlayers[i].id, 1); break; } @@ -487,10 +487,10 @@ static void InitLinkBtlControllers(void) gBattlersCount = MAX_BATTLERS_COUNT; } - sub_81B8D64(0, 0); - sub_81B8D64(1, 0); - sub_81B8D64(2, 1); - sub_81B8D64(3, 1); + BufferBattlePartyCurrentOrderBySide(0, 0); + BufferBattlePartyCurrentOrderBySide(1, 0); + BufferBattlePartyCurrentOrderBySide(2, 1); + BufferBattlePartyCurrentOrderBySide(3, 1); gBattlerPartyIndexes[0] = 0; gBattlerPartyIndexes[1] = 0; gBattlerPartyIndexes[2] = 3; @@ -509,11 +509,11 @@ static void InitLinkBtlControllers(void) { case 0: case 3: - sub_81B8D64(gLinkPlayers[i].id, 0); + BufferBattlePartyCurrentOrderBySide(gLinkPlayers[i].id, 0); break; case 1: case 2: - sub_81B8D64(gLinkPlayers[i].id, 1); + BufferBattlePartyCurrentOrderBySide(gLinkPlayers[i].id, 1); break; } diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index c29bf7526e..341cd4a6a8 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -811,7 +811,7 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId) break; case 6: LoadAndCreateEnemyShadowSprites(); - sub_81B8C68(); + BufferBattlePartyCurrentOrder(); retVal = TRUE; break; } diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index 8ad7e57582..c904d4e98a 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -981,7 +981,7 @@ static void HandleMenuActionInput(u8 taskId) sub_8199134(0, 1); } } - else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == 1) + else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) { if (id & 1 && IsValidMenuAction(id - 1)) { @@ -989,7 +989,7 @@ static void HandleMenuActionInput(u8 taskId) sub_8199134(-1, 0); } } - else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == 2) + else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) { if (!(id & 1) && IsValidMenuAction(id + 1)) { diff --git a/src/contest.c b/src/contest.c index 20fa9e1a8d..2ad1890580 100644 --- a/src/contest.c +++ b/src/contest.c @@ -2802,7 +2802,7 @@ void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame) u8 GetContestEntryEligibility(struct Pokemon *pkmn) { u8 ribbon; - u8 contestViability; + u8 eligibility; if (GetMonData(pkmn, MON_DATA_IS_EGG)) return CANT_ENTER_CONTEST_EGG; @@ -2833,12 +2833,12 @@ u8 GetContestEntryEligibility(struct Pokemon *pkmn) // Returns 2, 1, or 0 respectively if ribbon's rank is above, equal, or below // the current contest rank. if (ribbon > gSpecialVar_ContestRank) - contestViability = CAN_ENTER_CONTEST_HIGH_RANK; + eligibility = CAN_ENTER_CONTEST_HIGH_RANK; else if (ribbon >= gSpecialVar_ContestRank) - contestViability = CAN_ENTER_CONTEST_EQUAL_RANK; + eligibility = CAN_ENTER_CONTEST_EQUAL_RANK; else - contestViability = CANT_ENTER_CONTEST; - return contestViability; + eligibility = CANT_ENTER_CONTEST; + return eligibility; } static void DrawContestantWindowText(void) diff --git a/src/party_menu.c b/src/party_menu.c index 07042774be..aad7cb7b44 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -148,7 +148,7 @@ static EWRAM_DATA struct PartyMenuBox *sPartyMenuBoxes = NULL; static EWRAM_DATA u8 *sPartyBgGfxTilemap = NULL; static EWRAM_DATA u8 *sPartyBgTilemapBuffer = NULL; EWRAM_DATA bool8 gPartyMenuUseExitCallback = 0; -EWRAM_DATA u8 gSelectedMonPartyId = 0; // only used for switching mons, oddly +EWRAM_DATA u8 gSelectedMonPartyId = 0; EWRAM_DATA MainCallback gPostMenuFieldCallback = NULL; static EWRAM_DATA u16 *sSlot1TilemapBuffer = 0; // for switching party slots static EWRAM_DATA u16 *sSlot2TilemapBuffer = 0; // @@ -367,8 +367,8 @@ static u8 GetBattleEntryLevelCap(void); static u8 GetMaxBattleEntries(void); static u8 GetMinBattleEntries(void); static void Task_ContinueChoosingHalfParty(u8); -static void sub_81B8C88(u8*, bool8); -static void sub_81B8D88(u8*, u8, u8); +static void BufferBattlePartyOrder(u8*, bool8); +static void BufferBattlePartyOrderBySide(u8*, u8, u8); static void Task_InitMultiPartnerPartySlideIn(u8); static void Task_MultiPartnerPartySlideIn(u8); static void SlideMultiPartyMenuBoxSpritesOneStep(u8); @@ -378,31 +378,31 @@ static void Task_PartyMenuWaitForFade(u8 taskId); static void Task_ChooseContestMon(u8 taskId); static void CB2_ChooseContestMon(void); static void Task_ChoosePartyMon(u8 taskId); -static void Task_ChooseMonForMoveRelearner(u8 taskId); +static void Task_ChooseMonForMoveRelearner(u8); static void CB2_ChooseMonForMoveRelearner(void); -static void Task_BattlePyramidChooseMonHeldItems(u8 taskId); +static void Task_BattlePyramidChooseMonHeldItems(u8); static void ShiftMoveSlot(struct Pokemon*, u8, u8); -static void BlitBitmapToPartyWindow_LeftColumn(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 f); -static void BlitBitmapToPartyWindow_RightColumn(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 f); -static void CursorCb_Summary(u8 taskId); -static void CursorCb_Switch(u8 taskId); -static void CursorCb_Cancel1(u8 taskId); -static void CursorCb_Item(u8 taskId); -static void CursorCb_Give(u8 taskId); -static void CursorCb_TakeItem(u8 taskId); -static void CursorCb_Mail(u8 taskId); -static void CursorCb_Read(u8 taskId); -static void CursorCb_TakeMail(u8 taskId); -static void CursorCb_Cancel2(u8 taskId); -static void CursorCb_SendMon(u8 taskId); -static void CursorCb_Enter(u8 taskId); -static void CursorCb_NoEntry(u8 taskId); -static void CursorCb_Store(u8 taskId); -static void CursorCb_Register(u8 taskId); -static void CursorCb_Trade1(u8 taskId); -static void CursorCb_Trade2(u8 taskId); -static void CursorCb_Toss(u8 taskId); -static void CursorCb_FieldMove(u8 taskId); +static void BlitBitmapToPartyWindow_LeftColumn(u8, u8, u8, u8, u8, u8); +static void BlitBitmapToPartyWindow_RightColumn(u8, u8, u8, u8, u8, u8); +static void CursorCb_Summary(u8); +static void CursorCb_Switch(u8); +static void CursorCb_Cancel1(u8); +static void CursorCb_Item(u8); +static void CursorCb_Give(u8); +static void CursorCb_TakeItem(u8); +static void CursorCb_Mail(u8); +static void CursorCb_Read(u8); +static void CursorCb_TakeMail(u8); +static void CursorCb_Cancel2(u8); +static void CursorCb_SendMon(u8); +static void CursorCb_Enter(u8); +static void CursorCb_NoEntry(u8); +static void CursorCb_Store(u8); +static void CursorCb_Register(u8); +static void CursorCb_Trade1(u8); +static void CursorCb_Trade2(u8); +static void CursorCb_Toss(u8); +static void CursorCb_FieldMove(u8); static bool8 SetUpFieldMove_Surf(void); static bool8 SetUpFieldMove_Fly(void); static bool8 SetUpFieldMove_Waterfall(void); @@ -1734,7 +1734,7 @@ static void CB2_InitPartyMenu(void) { while (TRUE) { - if (sub_81221EC() == TRUE || ShowPartyMenu() == TRUE || sub_81221AC() == TRUE) //SKP + if (sub_81221EC() == TRUE || ShowPartyMenu() == TRUE || sub_81221AC() == TRUE) break; } } @@ -1767,7 +1767,7 @@ static bool8 ShowPartyMenu(void) gMain.state++; break; case 5: - if (!sub_81221AC()) //SKP + if (!sub_81221AC()) ResetTasks(); gMain.state++; break; @@ -2213,7 +2213,7 @@ static void DisplayPartyPokemonDataForMultiBattle(u8 slot) menuBox->infoRects->blitFunc(menuBox->windowId, 0, 0, 0, 0, FALSE); StringCopy(gStringVar1, gMultiPartnerParty[actualSlot].nickname); StringGetEnd10(gStringVar1); - sub_81DB52C(gStringVar1); //SKP + sub_81DB52C(gStringVar1); DisplayPartyPokemonBarDetail(menuBox->windowId, gStringVar1, 0, menuBox->infoRects->dimensions); DisplayPartyPokemonLevel(gMultiPartnerParty[actualSlot].level, menuBox); DisplayPartyPokemonGender(gMultiPartnerParty[actualSlot].gender, gMultiPartnerParty[actualSlot].species, gMultiPartnerParty[actualSlot].nickname, menuBox); @@ -2440,7 +2440,7 @@ u8 GetPartyMenuType(void) void Task_HandleChooseMonInput(u8 taskId) { - if (!gPaletteFade.active && sub_81221EC() != TRUE) //SKP + if (!gPaletteFade.active && sub_81221EC() != TRUE) { s8 *slotPtr = GetCurrentPartySlotPtr(); @@ -2577,7 +2577,7 @@ static void HandleChooseMonCancel(u8 taskId, s8 *slotPtr) PlaySE(SE_SELECT); if (DisplayCancelChooseMonYesNo(taskId) != TRUE) { - if (!sub_81221AC()) //SKP + if (!sub_81221AC()) gSpecialVar_0x8004 = PARTY_SIZE + 1; gPartyMenuUseExitCallback = FALSE; *slotPtr = PARTY_SIZE + 1; @@ -2704,7 +2704,7 @@ static void UpdateCurrentPartySelection(s8 *slotPtr, s8 movementDir) static void UpdatePartySelectionSingleLayout(s8 *slotPtr, s8 movementDir) { - // PARTY_SIZE + 1 is Cancel, PARTY_SIZE is Confirm (when choosing half only) + // PARTY_SIZE + 1 is Cancel, PARTY_SIZE is Confirm switch (movementDir) { case MENU_DIR_UP: @@ -2769,7 +2769,7 @@ static void UpdatePartySelectionSingleLayout(s8 *slotPtr, s8 movementDir) static void UpdatePartySelectionDoubleLayout(s8 *slotPtr, s8 movementDir) { - // PARTY_SIZE + 1 is Cancel, PARTY_SIZE is Confirm (when choosing half only) + // PARTY_SIZE + 1 is Cancel, PARTY_SIZE is Confirm // newSlot is used temporarily as a movement direction during its later assignment s8 newSlot = movementDir; @@ -2917,7 +2917,7 @@ bool8 IsPartyMenuTextPrinterActive(void) static void Task_WaitForLinkAndReturnToChooseMon(u8 taskId) { - if (sub_81221EC() != TRUE) //SKP + if (sub_81221EC() != TRUE) { DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); gTasks[taskId].func = Task_HandleChooseMonInput; @@ -2930,7 +2930,7 @@ static void Task_ReturnToChooseMonAfterText(u8 taskId) { ClearStdWindowAndFrameToTransparent(6, 0); ClearWindowTilemap(6); - if (sub_81221AC() == TRUE) //SKP + if (sub_81221AC() == TRUE) { gTasks[taskId].func = Task_WaitForLinkAndReturnToChooseMon; } @@ -3037,7 +3037,7 @@ static void Task_PartyMenuModifyHP(u8 taskId) } } -void PartyMenuModifyHP(u8 taskId, u8 slot, s8 hpIncrement, s16 hpDifference, TaskFunc followUpFunc) +void PartyMenuModifyHP(u8 taskId, u8 slot, s8 hpIncrement, s16 hpDifference, TaskFunc task) { struct Pokemon *mon = &gPlayerParty[slot]; s16 *data = gTasks[taskId].data; @@ -3048,7 +3048,7 @@ void PartyMenuModifyHP(u8 taskId, u8 slot, s8 hpIncrement, s16 hpDifference, Tas tHPToAdd = hpDifference; tPartyId = slot; tStartHP = tHP; - SetTaskFuncWithFollowupFunc(taskId, Task_PartyMenuModifyHP, followUpFunc); + SetTaskFuncWithFollowupFunc(taskId, Task_PartyMenuModifyHP, task); } // The usage of hp in this function is mostly nonsense @@ -3379,7 +3379,6 @@ static void DrawEmptySlot(u8 windowId) BlitBitmapToPartyWindow(windowId, sEmptySlotTileNums, 18, 0, 0, 18, 3); } -// If LoadPartyBoxPalette is too dense, this macro could be used to replace the LoadPalette triplets #define LOAD_PARTY_BOX_PAL(paletteIds, paletteOffsets) \ { \ LoadPalette(GetPartyMenuPalBufferPtr(paletteIds[0]), paletteOffsets[0] + palNum, 2); \ @@ -3393,120 +3392,74 @@ static void LoadPartyBoxPalette(struct PartyMenuBox *menuBox, u8 palFlags) if (palFlags & PARTY_PAL_NO_MON) { - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxNoMonPalIds[0]), sPartyBoxNoMonPalOffsets[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxNoMonPalIds[1]), sPartyBoxNoMonPalOffsets[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxNoMonPalIds[2]), sPartyBoxNoMonPalOffsets[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxNoMonPalIds, sPartyBoxNoMonPalOffsets); } else if (palFlags & PARTY_PAL_TO_SOFTBOIL) { if (palFlags & PARTY_PAL_SELECTED) { - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[0]), sPartyBoxPalOffsets1[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[1]), sPartyBoxPalOffsets1[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[2]), sPartyBoxPalOffsets1[2] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[0]), sPartyBoxPalOffsets2[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[1]), sPartyBoxPalOffsets2[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[2]), sPartyBoxPalOffsets2[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionPalIds2, sPartyBoxPalOffsets2); } else { - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[0]), sPartyBoxPalOffsets1[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[1]), sPartyBoxPalOffsets1[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[2]), sPartyBoxPalOffsets1[2] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds2[0]), sPartyBoxPalOffsets2[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds2[1]), sPartyBoxPalOffsets2[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds2[2]), sPartyBoxPalOffsets2[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds2, sPartyBoxPalOffsets2); } } else if (palFlags & PARTY_PAL_SWITCHING) { - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[0]), sPartyBoxPalOffsets1[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[1]), sPartyBoxPalOffsets1[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[2]), sPartyBoxPalOffsets1[2] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds2[0]), sPartyBoxPalOffsets2[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds2[1]), sPartyBoxPalOffsets2[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds2[2]), sPartyBoxPalOffsets2[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds2, sPartyBoxPalOffsets2); } else if (palFlags & PARTY_PAL_TO_SWITCH) { if (palFlags & PARTY_PAL_SELECTED) { - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[0]), sPartyBoxPalOffsets1[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[1]), sPartyBoxPalOffsets1[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[2]), sPartyBoxPalOffsets1[2] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[0]), sPartyBoxPalOffsets2[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[1]), sPartyBoxPalOffsets2[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[2]), sPartyBoxPalOffsets2[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionPalIds2, sPartyBoxPalOffsets2); } else { - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[0]), sPartyBoxPalOffsets1[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[1]), sPartyBoxPalOffsets1[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds1[2]), sPartyBoxPalOffsets1[2] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds2[0]), sPartyBoxPalOffsets2[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds2[1]), sPartyBoxPalOffsets2[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxSelectedForActionPalIds2[2]), sPartyBoxPalOffsets2[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds2, sPartyBoxPalOffsets2); } } else if (palFlags & PARTY_PAL_FAINTED) { if (palFlags & PARTY_PAL_SELECTED) { - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionFaintedPalIds[0]), sPartyBoxPalOffsets1[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionFaintedPalIds[1]), sPartyBoxPalOffsets1[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionFaintedPalIds[2]), sPartyBoxPalOffsets1[2] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[0]), sPartyBoxPalOffsets2[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[1]), sPartyBoxPalOffsets2[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[2]), sPartyBoxPalOffsets2[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionFaintedPalIds, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionPalIds2, sPartyBoxPalOffsets2); } else { - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxFaintedPalIds1[0]), sPartyBoxPalOffsets1[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxFaintedPalIds1[1]), sPartyBoxPalOffsets1[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxFaintedPalIds1[2]), sPartyBoxPalOffsets1[2] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxFaintedPalIds2[0]), sPartyBoxPalOffsets2[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxFaintedPalIds2[1]), sPartyBoxPalOffsets2[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxFaintedPalIds2[2]), sPartyBoxPalOffsets2[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxFaintedPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxFaintedPalIds2, sPartyBoxPalOffsets2); } } else if (palFlags & PARTY_PAL_MULTI_ALT) { if (palFlags & PARTY_PAL_SELECTED) { - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionMultiPalIds[0]), sPartyBoxPalOffsets1[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionMultiPalIds[1]), sPartyBoxPalOffsets1[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionMultiPalIds[2]), sPartyBoxPalOffsets1[2] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[0]), sPartyBoxPalOffsets2[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[1]), sPartyBoxPalOffsets2[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[2]), sPartyBoxPalOffsets2[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionMultiPalIds, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionPalIds2, sPartyBoxPalOffsets2); } else { - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxMultiPalIds1[0]), sPartyBoxPalOffsets1[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxMultiPalIds1[1]), sPartyBoxPalOffsets1[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxMultiPalIds1[2]), sPartyBoxPalOffsets1[2] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxMultiPalIds2[0]), sPartyBoxPalOffsets2[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxMultiPalIds2[1]), sPartyBoxPalOffsets2[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxMultiPalIds2[2]), sPartyBoxPalOffsets2[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxMultiPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxMultiPalIds2, sPartyBoxPalOffsets2); } } else if (palFlags & PARTY_PAL_SELECTED) { - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds1[0]), sPartyBoxPalOffsets1[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds1[1]), sPartyBoxPalOffsets1[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds1[2]), sPartyBoxPalOffsets1[2] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[0]), sPartyBoxPalOffsets2[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[1]), sPartyBoxPalOffsets2[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxCurrSelectionPalIds2[2]), sPartyBoxPalOffsets2[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionPalIds2, sPartyBoxPalOffsets2); } else { - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxEmptySlotPalIds1[0]), sPartyBoxPalOffsets1[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxEmptySlotPalIds1[1]), sPartyBoxPalOffsets1[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxEmptySlotPalIds1[2]), sPartyBoxPalOffsets1[2] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxEmptySlotPalIds2[0]), sPartyBoxPalOffsets2[0] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxEmptySlotPalIds2[1]), sPartyBoxPalOffsets2[1] + palNum, 2); - LoadPalette(GetPartyMenuPalBufferPtr(sPartyBoxEmptySlotPalIds2[2]), sPartyBoxPalOffsets2[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxEmptySlotPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxEmptySlotPalIds2, sPartyBoxPalOffsets2); } } @@ -3687,16 +3640,16 @@ static void PartyMenuRemoveWindow(u8 *ptr) } } -void DisplayPartyMenuStdMessage(u32 stringID) +void DisplayPartyMenuStdMessage(u32 stringId) { u8 *windowPtr = &sPartyMenuInternal->windowId[1]; if (*windowPtr != 0xFF) PartyMenuRemoveWindow(windowPtr); - if (stringID != PARTY_MSG_NONE) + if (stringId != PARTY_MSG_NONE) { - switch (stringID) + switch (stringId) { case PARTY_MSG_DO_WHAT_WITH_MON: *windowPtr = AddWindow(&sDoWhatWithMonMsgWindowTemplate); @@ -3719,15 +3672,15 @@ void DisplayPartyMenuStdMessage(u32 stringID) break; } - if (stringID == PARTY_MSG_CHOOSE_MON) + if (stringId == PARTY_MSG_CHOOSE_MON) { if (sPartyMenuInternal->chooseHalf) - stringID = PARTY_MSG_CHOOSE_MON_AND_CONFIRM; + stringId = PARTY_MSG_CHOOSE_MON_AND_CONFIRM; else if (!ShouldUseChooseMonText()) - stringID = PARTY_MSG_CHOOSE_MON_OR_CANCEL; + stringId = PARTY_MSG_CHOOSE_MON_OR_CANCEL; } DrawStdFrameWithCustomTileAndPalette(*windowPtr, FALSE, 0x4F, 0xD); - StringExpandPlaceholders(gStringVar4, sActionStringTable[stringID]); + StringExpandPlaceholders(gStringVar4, sActionStringTable[stringId]); AddTextPrinterParameterized(*windowPtr, 1, gStringVar4, 0, 1, 0, 0); schedule_bg_copy_tilemap_to_vram(2); } @@ -3970,7 +3923,7 @@ static void Task_TryCreateSelectionWindow(u8 taskId) static void Task_HandleSelectionMenuInput(u8 taskId) { - if (!gPaletteFade.active && sub_81221EC() != TRUE) //SKP + if (!gPaletteFade.active && sub_81221EC() != TRUE) { s8 input; s16 *data = gTasks[taskId].data; @@ -4097,41 +4050,42 @@ static void SwitchSelectedMons(u8 taskId) } // returns FALSE if the slot has slid fully offscreen / back onscreen -static bool8 TryMovePartySlot(s16 a, s16 srcWidth, u8 *srcX, u8 *srcHeight, u8 *destY) +static bool8 TryMovePartySlot(s16 x, s16 width, u8 *leftMove, u8 *newX, u8 *newWidth) { - if ((a + srcWidth) < 0) + if ((x + width) < 0) return FALSE; - if (a > 31) + if (x > 31) return FALSE; - if (a < 0) + if (x < 0) { - *srcX = a * -1; - *srcHeight = 0; - *destY = srcWidth + a; + *leftMove = x * -1; + *newX = 0; + *newWidth = width + x; } else { - *srcX = 0; - *srcHeight = a; - if ((a + srcWidth) > 31) - *destY = 32 - a; + *leftMove = 0; + *newX = x; + if ((x + width) > 31) + *newWidth = 32 - x; else - *destY = srcWidth; + *newWidth = width; } return TRUE; } -static void MoveAndBufferPartySlot(const void *rectSrc, s16 a, s16 destX, s16 srcWidth, s16 rectWidth, s16 offset) +static void MoveAndBufferPartySlot(const void *rectSrc, s16 x, s16 y, s16 width, s16 height, s16 dir) { - u8 srcX, srcHeight, destY; + // The use of the dimension parameters here is a mess + u8 leftMove, newX, newWidth; // leftMove is used as a srcX, newX is used as both x and srcHeight, newWidth is used as both width and destY - if (TryMovePartySlot(a, srcWidth, &srcX, &srcHeight, &destY)) + if (TryMovePartySlot(x, width, &leftMove, &newX, &newWidth)) { - FillBgTilemapBufferRect_Palette0(0, 0, srcHeight, destX, destY, rectWidth); - if (TryMovePartySlot(a + offset, srcWidth, &srcX, &srcHeight, &destY)) - CopyRectToBgTilemapBufferRect(0, rectSrc, srcX, 0, srcWidth, rectWidth, srcHeight, destX, destY, rectWidth, 17, 0, 0); + FillBgTilemapBufferRect_Palette0(0, 0, newX, y, newWidth, height); + if (TryMovePartySlot(x + dir, width, &leftMove, &newX, &newWidth)) + CopyRectToBgTilemapBufferRect(0, rectSrc, leftMove, 0, width, height, newX, y, newWidth, height, 17, 0, 0); } } @@ -4913,7 +4867,7 @@ static void Task_SpinTradeYesNo(u8 taskId) } } -// See comment on CursorCb_Trade2. Selecting YES (0) to spin trade just closes the party menu +// See comment on CursorCb_Trade2. Because no callback is set, selecting YES (0) to spin trade just closes the party menu static void Task_HandleSpinTradeYesNoInput(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) @@ -4941,7 +4895,7 @@ static void CursorCb_FieldMove(u8 taskId) PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); - if (sub_81221AC() == TRUE || InUnionRoom() == TRUE) //SKP + if (sub_81221AC() == TRUE || InUnionRoom() == TRUE) { if (fieldMove == FIELD_MOVE_MILK_DRINK || fieldMove == FIELD_MOVE_SOFT_BOILED) DisplayPartyMenuStdMessage(PARTY_MSG_CANT_USE_HERE); @@ -5174,7 +5128,7 @@ static void CreatePartyMonIconSpriteParameterized(u16 species, u32 pid, struct P { if (species != SPECIES_NONE) { - menuBox->monSpriteId = CreateMonIcon(species, MonIconSpriteCallback, menuBox->spriteCoords[0], menuBox->spriteCoords[1], 4, pid, handleDeoxys); + menuBox->monSpriteId = CreateMonIcon(species, SpriteCB_MonIcon, menuBox->spriteCoords[0], menuBox->spriteCoords[1], 4, pid, handleDeoxys); gSprites[menuBox->monSpriteId].oam.priority = priority; } } @@ -6973,9 +6927,9 @@ static const u8* GetFacilityCancelString(void) return gText_CancelChallenge; } -void ChooseMonForTradingBoard(u8 initArg, MainCallback callback) +void ChooseMonForTradingBoard(u8 menuType, MainCallback callback) { - InitPartyMenu(initArg, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_MON, FALSE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, callback); + InitPartyMenu(menuType, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_MON, FALSE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, callback); } void ChooseMonForMoveTutor(void) @@ -7082,20 +7036,21 @@ static bool8 TrySwitchInPokemon(void) return TRUE; } -//TODO -void sub_81B8C68(void) +void BufferBattlePartyCurrentOrder(void) { - sub_81B8C88(gBattlePartyCurrentOrder, sub_806D7EC()); + BufferBattlePartyOrder(gBattlePartyCurrentOrder, GetPlayerFlankId()); } -static void sub_81B8C88(u8 *partyBattleOrder, bool8 multiplayerFlag) +static void BufferBattlePartyOrder(u8 *partyBattleOrder, u8 flankId) { - u8 partyIndexes[PARTY_SIZE]; + u8 partyIds[PARTY_SIZE]; int i, j; if (IsMultiBattle() == TRUE) { - if (multiplayerFlag) + // Party ids are packed in 4 bits at a time + // i.e. the party id order below would be 0, 3, 5, 4, 2, 1, and the two parties would be 0,5,4 and 3,2,1 + if (flankId != 0) { partyBattleOrder[0] = 0 | (3 << 4); partyBattleOrder[1] = 5 | (4 << 4); @@ -7112,12 +7067,12 @@ static void sub_81B8C88(u8 *partyBattleOrder, bool8 multiplayerFlag) else if (IsDoubleBattle() == FALSE) { j = 1; - partyIndexes[0] = gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]; + partyIds[0] = gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]; for (i = 0; i < PARTY_SIZE; i++) { - if (i != partyIndexes[0]) + if (i != partyIds[0]) { - partyIndexes[j] = i; + partyIds[j] = i; j++; } } @@ -7125,28 +7080,28 @@ static void sub_81B8C88(u8 *partyBattleOrder, bool8 multiplayerFlag) else { j = 2; - partyIndexes[0] = gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]; - partyIndexes[1] = gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT)]; + partyIds[0] = gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]; + partyIds[1] = gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT)]; for (i = 0; i < PARTY_SIZE; i++) { - if (i != partyIndexes[0] && i != partyIndexes[1]) + if (i != partyIds[0] && i != partyIds[1]) { - partyIndexes[j] = i; + partyIds[j] = i; j++; } } } for (i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); i++) - partyBattleOrder[i] = (partyIndexes[0 + (i * 2)] << 4) | partyIndexes[1 + (i * 2)]; + partyBattleOrder[i] = (partyIds[0 + (i * 2)] << 4) | partyIds[1 + (i * 2)]; } -//TODO -void sub_81B8D64(u8 battlerId, u8 multiplayerFlag) +void BufferBattlePartyCurrentOrderBySide(u8 battlerId, u8 flankId) { - sub_81B8D88(gBattleStruct->field_60[battlerId], multiplayerFlag, battlerId); + BufferBattlePartyOrderBySide(gBattleStruct->field_60[battlerId], flankId, battlerId); } -static void sub_81B8D88(u8 *ptr, bool8 multiplayerFlag, u8 battlerId) +// when GetBattlerSide(battlerId) == B_SIDE_PLAYER, this function is identical the one above +static void BufferBattlePartyOrderBySide(u8 *partyBattleOrder, u8 flankId, u8 battlerId) { u8 partyIndexes[PARTY_SIZE]; int i, j; @@ -7166,17 +7121,17 @@ static void sub_81B8D88(u8 *ptr, bool8 multiplayerFlag, u8 battlerId) if (IsMultiBattle() == TRUE) { - if (multiplayerFlag) + if (flankId != 0) { - ptr[0] = 0 | (3 << 4); - ptr[1] = 5 | (4 << 4); - ptr[2] = 2 | (1 << 4); + partyBattleOrder[0] = 0 | (3 << 4); + partyBattleOrder[1] = 5 | (4 << 4); + partyBattleOrder[2] = 2 | (1 << 4); } else { - ptr[0] = 3 | (0 << 4); - ptr[1] = 2 | (1 << 4); - ptr[2] = 5 | (4 << 4); + partyBattleOrder[0] = 3 | (0 << 4); + partyBattleOrder[1] = 2 | (1 << 4); + partyBattleOrder[2] = 5 | (4 << 4); } return; } @@ -7209,43 +7164,42 @@ static void sub_81B8D88(u8 *ptr, bool8 multiplayerFlag, u8 battlerId) } for (i = 0; i < 3; i++) - ptr[i] = (partyIndexes[0 + (i * 2)] << 4) | partyIndexes[1 + (i * 2)]; + partyBattleOrder[i] = (partyIndexes[0 + (i * 2)] << 4) | partyIndexes[1 + (i * 2)]; } -//TODO clean up -void SwitchPartyOrderLinkMulti(u8 battlerId, u8 slot, u8 arrayIndex) +void SwitchPartyOrderLinkMulti(u8 battlerId, u8 slot, u8 slot2) { - u8 possiblePartyIndexes[PARTY_SIZE]; - u8 slot2 = 0; + u8 partyIds[PARTY_SIZE]; + u8 tempSlot = 0; int i, j; - u8 *battleStructRelated; - u8 possiblePartyIndexBuffer; + u8 *partyBattleOrder; + u8 partyIdBuffer; if (IsMultiBattle()) { - battleStructRelated = gBattleStruct->field_60[battlerId]; + partyBattleOrder = gBattleStruct->field_60[battlerId]; for (i = j = 0; i < 3; j++, i++) { - possiblePartyIndexes[j] = battleStructRelated[i] >> 4; + partyIds[j] = partyBattleOrder[i] >> 4; j++; - possiblePartyIndexes[j] = battleStructRelated[i] & 0xF; + partyIds[j] = partyBattleOrder[i] & 0xF; } - possiblePartyIndexBuffer = possiblePartyIndexes[arrayIndex]; + partyIdBuffer = partyIds[slot2]; for (i = 0; i < PARTY_SIZE; i++) { - if (possiblePartyIndexes[i] == slot) + if (partyIds[i] == slot) { - slot2 = possiblePartyIndexes[i]; - possiblePartyIndexes[i] = possiblePartyIndexBuffer; + tempSlot = partyIds[i]; + partyIds[i] = partyIdBuffer; break; } } if (i != PARTY_SIZE) { - possiblePartyIndexes[arrayIndex] = slot2; - battleStructRelated[0] = (possiblePartyIndexes[0] << 4) | possiblePartyIndexes[1]; - battleStructRelated[1] = (possiblePartyIndexes[2] << 4) | possiblePartyIndexes[3]; - battleStructRelated[2] = (possiblePartyIndexes[4] << 4) | possiblePartyIndexes[5]; + partyIds[slot2] = tempSlot; + partyBattleOrder[0] = (partyIds[0] << 4) | partyIds[1]; + partyBattleOrder[1] = (partyIds[2] << 4) | partyIds[3]; + partyBattleOrder[2] = (partyIds[4] << 4) | partyIds[5]; } } } @@ -7355,7 +7309,6 @@ void ShowPartyMenuToShowcaseMultiBattleParty(void) #define tXPos data[0] -// set up multi party partner slide static void Task_InitMultiPartnerPartySlideIn(u8 taskId) { // The first slide step also sets the sprites offscreen diff --git a/src/pokemon.c b/src/pokemon.c index ea8dcf0ccd..a30e20ea23 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5658,21 +5658,23 @@ void EvolutionRenameMon(struct Pokemon *mon, u16 oldSpecies, u16 newSpecies) SetMonData(mon, MON_DATA_NICKNAME, gSpeciesNames[newSpecies]); } -bool8 sub_806D7EC(void) +// The below two functions determine which side of a multi battle the trainer battles on +// 0 is the left (top in party menu), 1 is right (bottom in party menu) +u8 GetPlayerFlankId(void) { - bool8 retVal = FALSE; + u8 flankId = 0; switch (gLinkPlayers[GetMultiplayerId()].id) { case 0: case 3: - retVal = FALSE; + flankId = 0; break; case 1: case 2: - retVal = TRUE; + flankId = 1; break; } - return retVal; + return flankId; } u16 GetLinkTrainerFlankId(u8 linkPlayerId) diff --git a/src/pokemon_icon.c b/src/pokemon_icon.c index 0a758f8eec..70af9f956d 100644 --- a/src/pokemon_icon.c +++ b/src/pokemon_icon.c @@ -1184,7 +1184,7 @@ void FreeMonIconPalette(u16 species) FreeSpritePaletteByTag(gMonIconPaletteTable[palIndex].tag); } -void MonIconSpriteCallback(struct Sprite *sprite) +void SpriteCB_MonIcon(struct Sprite *sprite) { UpdateMonIconFrame(sprite); } diff --git a/src/trade.c b/src/trade.c index 004cffe713..909abe540e 100644 --- a/src/trade.c +++ b/src/trade.c @@ -481,7 +481,7 @@ static void CB2_CreateTradeMenu(void) { struct Pokemon *mon = &gPlayerParty[i]; sTradeMenuData->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), - MonIconSpriteCallback, + SpriteCB_MonIcon, (sTradeMonSpriteCoords[i][0] * 8) + 14, (sTradeMonSpriteCoords[i][1] * 8) - 12, 1, @@ -493,7 +493,7 @@ static void CB2_CreateTradeMenu(void) { struct Pokemon *mon = &gEnemyParty[i]; sTradeMenuData->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), - MonIconSpriteCallback, + SpriteCB_MonIcon, (sTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (sTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, 1, @@ -668,7 +668,7 @@ static void CB2_ReturnToTradeMenu(void) { struct Pokemon *mon = &gPlayerParty[i]; sTradeMenuData->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), - MonIconSpriteCallback, + SpriteCB_MonIcon, (sTradeMonSpriteCoords[i][0] * 8) + 14, (sTradeMonSpriteCoords[i][1] * 8) - 12, 1, @@ -680,7 +680,7 @@ static void CB2_ReturnToTradeMenu(void) { struct Pokemon *mon = &gEnemyParty[i]; sTradeMenuData->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), - MonIconSpriteCallback, + SpriteCB_MonIcon, (sTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (sTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, 1, @@ -1809,7 +1809,7 @@ static void DrawTradeMenuParty(u8 whichParty) gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[0] = 20; gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[2] = (sTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + sTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[4] = (sTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; - StoreSpriteCallbackInData6(&gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]], MonIconSpriteCallback); + StoreSpriteCallbackInData6(&gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]], SpriteCB_MonIcon); sTradeMenuData->drawPartyState[whichParty]++; TradeMenuBouncePartySprites(&gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]]); CopyToBgTilemapBufferRect_ChangePalette(1, sTradePartyBoxTilemap, whichParty * 15, 0, 15, 17, 0); @@ -1820,7 +1820,7 @@ static void DrawTradeMenuParty(u8 whichParty) PrintNicknamesForTradeMenu(); break; case 2: - if (gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].callback == MonIconSpriteCallback) + if (gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].callback == SpriteCB_MonIcon) sTradeMenuData->drawPartyState[whichParty] = 3; break; case 3: