diff options
Diffstat (limited to 'src/battle_controller_player.c')
-rw-r--r-- | src/battle_controller_player.c | 97 |
1 files changed, 48 insertions, 49 deletions
diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 94e25fadc..ac8babb60 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -36,9 +36,6 @@ #include "constants/trainers.h" #include "constants/rgb.h" -extern struct MusicPlayerInfo gMPlayInfo_BGM; - -// this file's functions static void PlayerHandleGetMonData(void); static void PlayerHandleSetMonData(void); static void PlayerHandleSetRawMonData(void); @@ -251,17 +248,17 @@ static void HandleInputChooseAction(void) switch (gActionSelectionCursor[gActiveBattler]) { - case 0: - BtlController_EmitTwoReturnValues(1, B_ACTION_USE_MOVE, 0); + case 0: // Top left + BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_MOVE, 0); break; - case 1: - BtlController_EmitTwoReturnValues(1, B_ACTION_USE_ITEM, 0); + case 1: // Top right + BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_ITEM, 0); break; - case 2: - BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); + case 2: // Bottom left + BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SWITCH, 0); break; - case 3: - BtlController_EmitTwoReturnValues(1, B_ACTION_RUN, 0); + case 3: // Bottom right + BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_RUN, 0); break; } PlayerBufferExecCompleted(); @@ -322,7 +319,7 @@ static void HandleInputChooseAction(void) return; } PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(1, B_ACTION_CANCEL_PARTNER, 0); + BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_CANCEL_PARTNER, 0); PlayerBufferExecCompleted(); } } @@ -368,7 +365,7 @@ static void HandleInputChooseTarget(void) { PlaySE(SE_SELECT); gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCb_HideAsMoveTarget; - BtlController_EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); + BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); EndBounceEffect(gMultiUsePlayerCursor, BOUNCE_HEALTHBOX); PlayerBufferExecCompleted(); } @@ -526,7 +523,7 @@ static void HandleInputChooseMove(void) if (!canSelectTarget) { - BtlController_EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); + BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); PlayerBufferExecCompleted(); } else @@ -546,7 +543,7 @@ static void HandleInputChooseMove(void) else if (JOY_NEW(B_BUTTON) || gPlayerDpadHoldFrames > 59) { PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(1, 10, 0xFFFF); + BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0xFFFF); PlayerBufferExecCompleted(); } else if (JOY_NEW(DPAD_LEFT)) @@ -611,7 +608,7 @@ static void HandleInputChooseMove(void) gMultiUsePlayerCursor = gMoveSelectionCursor[gActiveBattler] + 1; MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 27); - BattlePutTextOnWindow(gText_BattleSwitchWhich, 0xB); + BattlePutTextOnWindow(gText_BattleSwitchWhich, B_WIN_SWITCH_PROMPT); gBattlerControllerFuncs[gActiveBattler] = HandleMoveSwitching; } } @@ -858,7 +855,7 @@ static void SetLinkBattleEndCallbacks(void) if (gReceivedRemoteLinkPlayers == 0) { m4aSongNumStop(SE_LOW_HEALTH); - gMain.inBattle = 0; + gMain.inBattle = FALSE; gMain.callback1 = gPreBattleCallback1; SetMainCallback2(CB2_InitEndLinkBattle); if (gBattleOutcome == B_OUTCOME_WON) @@ -871,7 +868,7 @@ static void SetLinkBattleEndCallbacks(void) if (IsLinkTaskFinished()) { m4aSongNumStop(SE_LOW_HEALTH); - gMain.inBattle = 0; + gMain.inBattle = FALSE; gMain.callback1 = gPreBattleCallback1; SetMainCallback2(CB2_InitEndLinkBattle); if (gBattleOutcome == B_OUTCOME_WON) @@ -901,7 +898,7 @@ void SetBattleEndCallbacks(void) else { m4aSongNumStop(SE_LOW_HEALTH); - gMain.inBattle = 0; + gMain.inBattle = FALSE; gMain.callback1 = gPreBattleCallback1; SetMainCallback2(gMain.savedCallback); } @@ -1145,7 +1142,7 @@ static void CompleteOnHealthbarDone(void) static void CompleteOnInactiveTextPrinter(void) { - if (!IsTextPrinterActive(0)) + if (!IsTextPrinterActive(B_WIN_MSG)) PlayerBufferExecCompleted(); } @@ -1177,7 +1174,7 @@ static void Task_GiveExpToMon(u8 taskId) gainedExp -= nextLvlExp - currExp; savedActiveBattler = gActiveBattler; gActiveBattler = battlerId; - BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELED_UP, gainedExp); + BtlController_EmitTwoReturnValues(BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp); gActiveBattler = savedActiveBattler; if (IsDoubleBattle() == TRUE @@ -1256,7 +1253,7 @@ static void Task_GiveExpWithExpBar(u8 taskId) gainedExp -= expOnNextLvl - currExp; savedActiveBattler = gActiveBattler; gActiveBattler = battlerId; - BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELED_UP, gainedExp); + BtlController_EmitTwoReturnValues(BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp); gActiveBattler = savedActiveBattler; gTasks[taskId].func = Task_LaunchLvlUpAnim; } @@ -1341,7 +1338,7 @@ static void FreeMonSpriteAfterSwitchOutAnim(void) static void CompleteOnInactiveTextPrinter2(void) { - if (!IsTextPrinterActive(0)) + if (!IsTextPrinterActive(B_WIN_MSG)) PlayerBufferExecCompleted(); } @@ -1364,9 +1361,9 @@ static void WaitForMonSelection(void) if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active) { if (gPartyMenuUseExitCallback == TRUE) - BtlController_EmitChosenMonReturnValue(1, gSelectedMonPartyId, gBattlePartyCurrentOrder); + BtlController_EmitChosenMonReturnValue(BUFFER_B, gSelectedMonPartyId, gBattlePartyCurrentOrder); else - BtlController_EmitChosenMonReturnValue(1, PARTY_SIZE, NULL); + BtlController_EmitChosenMonReturnValue(BUFFER_B, PARTY_SIZE, NULL); if ((gBattleBufferA[gActiveBattler][1] & 0xF) == 1) PrintLinkStandbyMsg(); @@ -1390,7 +1387,7 @@ static void CompleteWhenChoseItem(void) { if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active) { - BtlController_EmitOneReturnValue(1, gSpecialVar_ItemId); + BtlController_EmitOneReturnValue(BUFFER_B, gSpecialVar_ItemId); PlayerBufferExecCompleted(); } } @@ -1442,9 +1439,9 @@ static void PlayerHandleYesNoInput(void) PlaySE(SE_SELECT); if (gMultiUsePlayerCursor != 0) - BtlController_EmitTwoReturnValues(1, 0xE, 0); + BtlController_EmitTwoReturnValues(BUFFER_B, 0xE, 0); else - BtlController_EmitTwoReturnValues(1, 0xD, 0); + BtlController_EmitTwoReturnValues(BUFFER_B, 0xD, 0); PlayerBufferExecCompleted(); } @@ -1466,7 +1463,8 @@ static void MoveSelectionDisplayMoveNames(void) { MoveSelectionDestroyCursorAt(i); StringCopy(gDisplayedStringBattle, gMoveNames[moveInfo->moves[i]]); - BattlePutTextOnWindow(gDisplayedStringBattle, i + 3); + // Prints on windows B_WIN_MOVE_NAME_1, B_WIN_MOVE_NAME_2, B_WIN_MOVE_NAME_3, B_WIN_MOVE_NAME_4 + BattlePutTextOnWindow(gDisplayedStringBattle, i + B_WIN_MOVE_NAME_1); if (moveInfo->moves[i] != MOVE_NONE) gNumberOfMovesToChoose++; } @@ -1475,7 +1473,7 @@ static void MoveSelectionDisplayMoveNames(void) static void MoveSelectionDisplayPpString(void) { StringCopy(gDisplayedStringBattle, gText_MoveInterfacePP); - BattlePutTextOnWindow(gDisplayedStringBattle, 7); + BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_PP); } static void MoveSelectionDisplayPpNumber(void) @@ -1492,7 +1490,7 @@ static void MoveSelectionDisplayPpNumber(void) *(txtPtr)++ = CHAR_SLASH; ConvertIntToDecimalStringN(txtPtr, moveInfo->maxPp[gMoveSelectionCursor[gActiveBattler]], STR_CONV_MODE_RIGHT_ALIGN, 2); - BattlePutTextOnWindow(gDisplayedStringBattle, 9); + BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_PP_REMAINING); } static void MoveSelectionDisplayMoveType(void) @@ -1506,7 +1504,7 @@ static void MoveSelectionDisplayMoveType(void) *(txtPtr)++ = 1; StringCopy(txtPtr, gTypeNames[gBattleMoves[moveInfo->moves[gMoveSelectionCursor[gActiveBattler]]].type]); - BattlePutTextOnWindow(gDisplayedStringBattle, 10); + BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MOVE_TYPE); } static void MoveSelectionCreateCursorAt(u8 cursorPosition, u8 arg1) @@ -1577,7 +1575,7 @@ static void PrintLinkStandbyMsg(void) { gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - BattlePutTextOnWindow(gText_LinkStandby, 0); + BattlePutTextOnWindow(gText_LinkStandby, B_WIN_MSG); } } @@ -1602,7 +1600,7 @@ static void PlayerHandleGetMonData(void) monToCheck >>= 1; } } - BtlController_EmitDataTransfer(1, size, monData); + BtlController_EmitDataTransfer(BUFFER_B, size, monData); PlayerBufferExecCompleted(); } @@ -1922,7 +1920,7 @@ void PlayerHandleGetRawMonData(void) for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) dst[i] = src[i]; - BtlController_EmitDataTransfer(1, gBattleBufferA[gActiveBattler][2], dst); + BtlController_EmitDataTransfer(BUFFER_B, gBattleBufferA[gActiveBattler][2], dst); PlayerBufferExecCompleted(); } @@ -2228,13 +2226,14 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) static void PlayerHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBattler][1] == 0) + if (!gBattleBufferA[gActiveBattler][1]) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation; } else { + // Skip animation, just remove battler FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); @@ -2549,7 +2548,7 @@ static void PlayerHandlePrintString(void) gBattle_BG0_Y = 0; stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); BufferStringBattle(*stringId); - BattlePutTextOnWindow(gDisplayedStringBattle, 0); + BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG); gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2; BattleTv_SetDataBasedOnString(*stringId); BattleArena_DeductMindPoints(gActiveBattler, *stringId); @@ -2579,14 +2578,14 @@ static void PlayerHandleChooseAction(void) gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3; BattleTv_ClearExplosionFaintCause(); - BattlePutTextOnWindow(gText_BattleMenu, 2); + BattlePutTextOnWindow(gText_BattleMenu, B_WIN_ACTION_MENU); for (i = 0; i < 4; i++) ActionSelectionDestroyCursorAt(i); ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillPkmnDo); - BattlePutTextOnWindow(gDisplayedStringBattle, 1); + BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_ACTION_PROMPT); } static void PlayerHandleYesNoBox(void) @@ -2594,7 +2593,7 @@ static void PlayerHandleYesNoBox(void) if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0); - BattlePutTextOnWindow(gText_BattleYesNoChoice, 12); + BattlePutTextOnWindow(gText_BattleYesNoChoice, B_WIN_YESNO); gMultiUsePlayerCursor = 1; BattleCreateYesNoCursorAt(1); gBattlerControllerFuncs[gActiveBattler] = PlayerHandleYesNoInput; @@ -2622,7 +2621,7 @@ static void PlayerChooseMoveInBattlePalace(void) if (--*(gBattleStruct->arenaMindPoints + gActiveBattler) == 0) { gBattlePalaceMoveSelectionRngValue = gRngValue; - BtlController_EmitTwoReturnValues(1, 10, ChooseMoveAndTargetInBattlePalace()); + BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace()); PlayerBufferExecCompleted(); } } @@ -2672,7 +2671,7 @@ static void PlayerHandleChoosePokemon(void) if (gBattleTypeFlags & BATTLE_TYPE_ARENA && (gBattleBufferA[gActiveBattler][1] & 0xF) != PARTY_ACTION_CANT_SWITCH) { - BtlController_EmitChosenMonReturnValue(1, gBattlerPartyIndexes[gActiveBattler] + 1, gBattlePartyCurrentOrder); + BtlController_EmitChosenMonReturnValue(BUFFER_B, gBattlerPartyIndexes[gActiveBattler] + 1, gBattlePartyCurrentOrder); PlayerBufferExecCompleted(); } else @@ -2829,25 +2828,25 @@ static void PlayerHandleCmd32(void) static void PlayerHandleTwoReturnValues(void) { - BtlController_EmitTwoReturnValues(1, 0, 0); + BtlController_EmitTwoReturnValues(BUFFER_B, 0, 0); PlayerBufferExecCompleted(); } static void PlayerHandleChosenMonReturnValue(void) { - BtlController_EmitChosenMonReturnValue(1, 0, NULL); + BtlController_EmitChosenMonReturnValue(BUFFER_B, 0, NULL); PlayerBufferExecCompleted(); } static void PlayerHandleOneReturnValue(void) { - BtlController_EmitOneReturnValue(1, 0); + BtlController_EmitOneReturnValue(BUFFER_B, 0); PlayerBufferExecCompleted(); } static void PlayerHandleOneReturnValue_Duplicate(void) { - BtlController_EmitOneReturnValue_Duplicate(1, 0); + BtlController_EmitOneReturnValue_Duplicate(BUFFER_B, 0); PlayerBufferExecCompleted(); } @@ -3100,14 +3099,14 @@ static void PlayerHandleLinkStandbyMsg(void) RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][2]); switch (gBattleBufferA[gActiveBattler][1]) { - case 0: + case LINK_STANDBY_MSG_STOP_BOUNCE: PrintLinkStandbyMsg(); // fall through - case 1: + case LINK_STANDBY_STOP_BOUNCE_ONLY: EndBounceEffect(gActiveBattler, BOUNCE_HEALTHBOX); EndBounceEffect(gActiveBattler, BOUNCE_MON); break; - case 2: + case LINK_STANDBY_MSG_ONLY: PrintLinkStandbyMsg(); break; } |