diff --git a/include/battle_controllers.h b/include/battle_controllers.h index 6e295a7590..91b4ab1e56 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -66,9 +66,10 @@ enum { // Special arguments for Battle Controller functions. -enum { // Values given to the emit functions to choose gBattleBufferA or gBattleBufferB - BUFFER_A, - BUFFER_B +enum { + BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER = 0, // gBattleBufferA + BATTLELINKMSGTYPE_CONTROLLER_TO_ENGINE = 1, // gBattleBufferB + BATTLELINKMSGTYPE_CONTROLLER_BECOMING_IDLE = 2, }; enum { diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index 236db2a428..280b1e2103 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -518,7 +518,7 @@ static void LinkOpponentBufferExecCompleted(void) { u8 playerId = GetMultiplayerId(); - PrepareBufferDataTransferLink(2, 4, &playerId); + PrepareBufferDataTransferLink(BATTLELINKMSGTYPE_CONTROLLER_BECOMING_IDLE, 4, &playerId); gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else @@ -548,7 +548,7 @@ static void LinkOpponentHandleGetMonData(void) monToCheck >>= 1; } } - BtlController_EmitDataTransfer(BUFFER_B, size, monData); + BtlController_EmitDataTransfer(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, size, monData); LinkOpponentBufferExecCompleted(); } diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 7a437b958c..7e5eb37e91 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -400,7 +400,7 @@ static void LinkPartnerBufferExecCompleted(void) { u8 playerId = GetMultiplayerId(); - PrepareBufferDataTransferLink(2, 4, &playerId); + PrepareBufferDataTransferLink(BATTLELINKMSGTYPE_CONTROLLER_BECOMING_IDLE, 4, &playerId); gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else @@ -442,7 +442,7 @@ static void LinkPartnerHandleGetMonData(void) monToCheck >>= 1; } } - BtlController_EmitDataTransfer(BUFFER_B, size, monData); + BtlController_EmitDataTransfer(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, size, monData); LinkPartnerBufferExecCompleted(); } diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index c01dcb442f..12603f72bc 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -531,7 +531,7 @@ static void OpponentBufferExecCompleted(void) { u8 playerId = GetMultiplayerId(); - PrepareBufferDataTransferLink(2, 4, &playerId); + PrepareBufferDataTransferLink(BATTLELINKMSGTYPE_CONTROLLER_BECOMING_IDLE, 4, &playerId); gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else @@ -561,7 +561,7 @@ static void OpponentHandleGetMonData(void) monToCheck >>= 1; } } - BtlController_EmitDataTransfer(BUFFER_B, size, monData); + BtlController_EmitDataTransfer(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, size, monData); OpponentBufferExecCompleted(); } @@ -881,7 +881,7 @@ static void OpponentHandleGetRawMonData(void) for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) dst[i] = src[i]; - BtlController_EmitDataTransfer(BUFFER_B, gBattleBufferA[gActiveBattler][2], dst); + BtlController_EmitDataTransfer(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattleBufferA[gActiveBattler][2], dst); OpponentBufferExecCompleted(); } @@ -1552,7 +1552,7 @@ static void OpponentHandleChooseMove(void) { if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace()); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, ChooseMoveAndTargetInBattlePalace()); OpponentBufferExecCompleted(); } else @@ -1569,13 +1569,13 @@ static void OpponentHandleChooseMove(void) switch (chosenMoveId) { case AI_CHOICE_WATCH: - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_WATCH_CAREFULLY, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_SAFARI_WATCH_CAREFULLY, 0); break; case AI_CHOICE_FLEE: - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_RUN, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_RUN, 0); break; case 6: - BtlController_EmitTwoReturnValues(BUFFER_B, 15, gBattlerTarget); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 15, gBattlerTarget); break; default: if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) @@ -1586,7 +1586,7 @@ static void OpponentHandleChooseMove(void) if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); } - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8)); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, (chosenMoveId) | (gBattlerTarget << 8)); break; } OpponentBufferExecCompleted(); @@ -1601,11 +1601,11 @@ static void OpponentHandleChooseMove(void) } while (move == MOVE_NONE); if (gBattleMoves[move].target & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gActiveBattler << 8)); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, (chosenMoveId) | (gActiveBattler << 8)); else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8)); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8)); else - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8)); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8)); OpponentBufferExecCompleted(); } @@ -1614,7 +1614,7 @@ static void OpponentHandleChooseMove(void) static void OpponentHandleChooseItem(void) { - BtlController_EmitOneReturnValue(BUFFER_B, *(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2)); + BtlController_EmitOneReturnValue(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, *(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2)); OpponentBufferExecCompleted(); } @@ -1671,7 +1671,7 @@ static void OpponentHandleChoosePokemon(void) *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId; - BtlController_EmitChosenMonReturnValue(BUFFER_B, chosenMonId, NULL); + BtlController_EmitChosenMonReturnValue(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, chosenMonId, NULL); OpponentBufferExecCompleted(); } diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index e447858fc8..9c4d755110 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -204,7 +204,7 @@ static void PlayerBufferExecCompleted(void) { u8 playerId = GetMultiplayerId(); - PrepareBufferDataTransferLink(2, 4, &playerId); + PrepareBufferDataTransferLink(BATTLELINKMSGTYPE_CONTROLLER_BECOMING_IDLE, 4, &playerId); gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else @@ -249,16 +249,16 @@ static void HandleInputChooseAction(void) switch (gActionSelectionCursor[gActiveBattler]) { case 0: // Top left - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_MOVE, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_USE_MOVE, 0); break; case 1: // Top right - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_ITEM, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_USE_ITEM, 0); break; case 2: // Bottom left - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SWITCH, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_SWITCH, 0); break; case 3: // Bottom right - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_RUN, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_RUN, 0); break; } PlayerBufferExecCompleted(); @@ -319,7 +319,7 @@ static void HandleInputChooseAction(void) return; } PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_CANCEL_PARTNER, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_CANCEL_PARTNER, 0); PlayerBufferExecCompleted(); } } @@ -365,7 +365,7 @@ static void HandleInputChooseTarget(void) { PlaySE(SE_SELECT); gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCB_HideAsMoveTarget; - BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); EndBounceEffect(gMultiUsePlayerCursor, BOUNCE_HEALTHBOX); PlayerBufferExecCompleted(); } @@ -523,7 +523,7 @@ static void HandleInputChooseMove(void) if (!canSelectTarget) { - BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); PlayerBufferExecCompleted(); } else @@ -543,7 +543,7 @@ static void HandleInputChooseMove(void) else if (JOY_NEW(B_BUTTON) || gPlayerDpadHoldFrames > 59) { PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0xFFFF); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, 0xFFFF); PlayerBufferExecCompleted(); } else if (JOY_NEW(DPAD_LEFT)) @@ -1174,7 +1174,7 @@ static void Task_GiveExpToMon(u8 taskId) gainedExp -= nextLvlExp - currExp; savedActiveBattler = gActiveBattler; gActiveBattler = battlerId; - BtlController_EmitTwoReturnValues(BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, RET_VALUE_LEVELED_UP, gainedExp); gActiveBattler = savedActiveBattler; if (IsDoubleBattle() == TRUE @@ -1253,7 +1253,7 @@ static void Task_GiveExpWithExpBar(u8 taskId) gainedExp -= expOnNextLvl - currExp; savedActiveBattler = gActiveBattler; gActiveBattler = battlerId; - BtlController_EmitTwoReturnValues(BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, RET_VALUE_LEVELED_UP, gainedExp); gActiveBattler = savedActiveBattler; gTasks[taskId].func = Task_LaunchLvlUpAnim; } @@ -1361,9 +1361,9 @@ static void WaitForMonSelection(void) if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active) { if (gPartyMenuUseExitCallback == TRUE) - BtlController_EmitChosenMonReturnValue(BUFFER_B, gSelectedMonPartyId, gBattlePartyCurrentOrder); + BtlController_EmitChosenMonReturnValue(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gSelectedMonPartyId, gBattlePartyCurrentOrder); else - BtlController_EmitChosenMonReturnValue(BUFFER_B, PARTY_SIZE, NULL); + BtlController_EmitChosenMonReturnValue(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, PARTY_SIZE, NULL); if ((gBattleBufferA[gActiveBattler][1] & 0xF) == 1) PrintLinkStandbyMsg(); @@ -1387,7 +1387,7 @@ static void CompleteWhenChoseItem(void) { if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active) { - BtlController_EmitOneReturnValue(BUFFER_B, gSpecialVar_ItemId); + BtlController_EmitOneReturnValue(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gSpecialVar_ItemId); PlayerBufferExecCompleted(); } } @@ -1439,9 +1439,9 @@ static void PlayerHandleYesNoInput(void) PlaySE(SE_SELECT); if (gMultiUsePlayerCursor != 0) - BtlController_EmitTwoReturnValues(BUFFER_B, 0xE, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 0xE, 0); else - BtlController_EmitTwoReturnValues(BUFFER_B, 0xD, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 0xD, 0); PlayerBufferExecCompleted(); } @@ -1600,7 +1600,7 @@ static void PlayerHandleGetMonData(void) monToCheck >>= 1; } } - BtlController_EmitDataTransfer(BUFFER_B, size, monData); + BtlController_EmitDataTransfer(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, size, monData); PlayerBufferExecCompleted(); } @@ -1920,7 +1920,7 @@ void PlayerHandleGetRawMonData(void) for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) dst[i] = src[i]; - BtlController_EmitDataTransfer(BUFFER_B, gBattleBufferA[gActiveBattler][2], dst); + BtlController_EmitDataTransfer(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattleBufferA[gActiveBattler][2], dst); PlayerBufferExecCompleted(); } @@ -2621,7 +2621,7 @@ static void PlayerChooseMoveInBattlePalace(void) if (--*(gBattleStruct->arenaMindPoints + gActiveBattler) == 0) { gBattlePalaceMoveSelectionRngValue = gRngValue; - BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace()); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, ChooseMoveAndTargetInBattlePalace()); PlayerBufferExecCompleted(); } } @@ -2671,7 +2671,7 @@ static void PlayerHandleChoosePokemon(void) if (gBattleTypeFlags & BATTLE_TYPE_ARENA && (gBattleBufferA[gActiveBattler][1] & 0xF) != PARTY_ACTION_CANT_SWITCH) { - BtlController_EmitChosenMonReturnValue(BUFFER_B, gBattlerPartyIndexes[gActiveBattler] + 1, gBattlePartyCurrentOrder); + BtlController_EmitChosenMonReturnValue(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattlerPartyIndexes[gActiveBattler] + 1, gBattlePartyCurrentOrder); PlayerBufferExecCompleted(); } else @@ -2828,25 +2828,25 @@ static void PlayerHandleCmd32(void) static void PlayerHandleTwoReturnValues(void) { - BtlController_EmitTwoReturnValues(BUFFER_B, 0, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 0, 0); PlayerBufferExecCompleted(); } static void PlayerHandleChosenMonReturnValue(void) { - BtlController_EmitChosenMonReturnValue(BUFFER_B, 0, NULL); + BtlController_EmitChosenMonReturnValue(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 0, NULL); PlayerBufferExecCompleted(); } static void PlayerHandleOneReturnValue(void) { - BtlController_EmitOneReturnValue(BUFFER_B, 0); + BtlController_EmitOneReturnValue(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 0); PlayerBufferExecCompleted(); } static void PlayerHandleOneReturnValue_Duplicate(void) { - BtlController_EmitOneReturnValue_Duplicate(BUFFER_B, 0); + BtlController_EmitOneReturnValue_Duplicate(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 0); PlayerBufferExecCompleted(); } diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 307eeca26a..37a72e3aaa 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -332,7 +332,7 @@ static void Task_GiveExpToMon(u8 taskId) gainedExp -= nextLvlExp - currExp; savedActiveBank = gActiveBattler; gActiveBattler = battlerId; - BtlController_EmitTwoReturnValues(BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, RET_VALUE_LEVELED_UP, gainedExp); gActiveBattler = savedActiveBank; if (IsDoubleBattle() == TRUE @@ -411,7 +411,7 @@ static void Task_GiveExpWithExpBar(u8 taskId) gainedExp -= expOnNextLvl - currExp; savedActiveBank = gActiveBattler; gActiveBattler = battlerId; - BtlController_EmitTwoReturnValues(BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, RET_VALUE_LEVELED_UP, gainedExp); gActiveBattler = savedActiveBank; gTasks[taskId].func = Task_LaunchLvlUpAnim; } @@ -584,7 +584,7 @@ static void PlayerPartnerBufferExecCompleted(void) { u8 playerId = GetMultiplayerId(); - PrepareBufferDataTransferLink(2, 4, &playerId); + PrepareBufferDataTransferLink(BATTLELINKMSGTYPE_CONTROLLER_BECOMING_IDLE, 4, &playerId); gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else @@ -626,7 +626,7 @@ static void PlayerPartnerHandleGetMonData(void) monToCheck >>= 1; } } - BtlController_EmitDataTransfer(BUFFER_B, size, monData); + BtlController_EmitDataTransfer(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, size, monData); PlayerPartnerBufferExecCompleted(); } @@ -1527,7 +1527,7 @@ static void PlayerPartnerHandleChooseMove(void) gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); } - BtlController_EmitTwoReturnValues(BUFFER_B, 10, chosenMoveId | (gBattlerTarget << 8)); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, chosenMoveId | (gBattlerTarget << 8)); PlayerPartnerBufferExecCompleted(); } @@ -1557,7 +1557,7 @@ static void PlayerPartnerHandleChoosePokemon(void) } *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId; - BtlController_EmitChosenMonReturnValue(BUFFER_B, chosenMonId, NULL); + BtlController_EmitChosenMonReturnValue(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, chosenMonId, NULL); PlayerPartnerBufferExecCompleted(); } diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 7cb5839bc5..2a04c9d219 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -504,7 +504,7 @@ static void RecordedOpponentBufferExecCompleted(void) { u8 playerId = GetMultiplayerId(); - PrepareBufferDataTransferLink(2, 4, &playerId); + PrepareBufferDataTransferLink(BATTLELINKMSGTYPE_CONTROLLER_BECOMING_IDLE, 4, &playerId); gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else @@ -534,7 +534,7 @@ static void RecordedOpponentHandleGetMonData(void) monToCheck >>= 1; } } - BtlController_EmitDataTransfer(BUFFER_B, size, monData); + BtlController_EmitDataTransfer(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, size, monData); RecordedOpponentBufferExecCompleted(); } @@ -1402,7 +1402,7 @@ static void RecordedOpponentHandlePrintSelectionString(void) static void RecordedOpponentHandleChooseAction(void) { - BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(gActiveBattler), 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, RecordedBattle_GetBattlerAction(gActiveBattler), 0); RecordedOpponentBufferExecCompleted(); } @@ -1415,13 +1415,13 @@ static void RecordedOpponentHandleChooseMove(void) { if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace()); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, ChooseMoveAndTargetInBattlePalace()); } else { u8 moveId = RecordedBattle_GetBattlerAction(gActiveBattler); u8 target = RecordedBattle_GetBattlerAction(gActiveBattler); - BtlController_EmitTwoReturnValues(BUFFER_B, 10, moveId | (target << 8)); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, moveId | (target << 8)); } RecordedOpponentBufferExecCompleted(); @@ -1435,7 +1435,7 @@ static void RecordedOpponentHandleChooseItem(void) static void RecordedOpponentHandleChoosePokemon(void) { *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBattlerAction(gActiveBattler); - BtlController_EmitChosenMonReturnValue(BUFFER_B, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL); + BtlController_EmitChosenMonReturnValue(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL); RecordedOpponentBufferExecCompleted(); } diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 5a7be7f347..fda899712e 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -475,7 +475,7 @@ static void RecordedPlayerBufferExecCompleted(void) { u8 playerId = GetMultiplayerId(); - PrepareBufferDataTransferLink(2, 4, &playerId); + PrepareBufferDataTransferLink(BATTLELINKMSGTYPE_CONTROLLER_BECOMING_IDLE, 4, &playerId); gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else @@ -517,7 +517,7 @@ static void RecordedPlayerHandleGetMonData(void) monToCheck >>= 1; } } - BtlController_EmitDataTransfer(BUFFER_B, size, monData); + BtlController_EmitDataTransfer(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, size, monData); RecordedPlayerBufferExecCompleted(); } @@ -1414,7 +1414,7 @@ static void ChooseActionInBattlePalace(void) { if (gBattleCommunication[4] >= gBattlersCount / 2) { - BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(gActiveBattler), 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, RecordedBattle_GetBattlerAction(gActiveBattler), 0); RecordedPlayerBufferExecCompleted(); } } @@ -1427,7 +1427,7 @@ static void RecordedPlayerHandleChooseAction(void) } else { - BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(gActiveBattler), 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, RecordedBattle_GetBattlerAction(gActiveBattler), 0); RecordedPlayerBufferExecCompleted(); } } @@ -1441,13 +1441,13 @@ static void RecordedPlayerHandleChooseMove(void) { if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace()); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, ChooseMoveAndTargetInBattlePalace()); } else { u8 moveId = RecordedBattle_GetBattlerAction(gActiveBattler); u8 target = RecordedBattle_GetBattlerAction(gActiveBattler); - BtlController_EmitTwoReturnValues(BUFFER_B, 10, moveId | (target << 8)); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, moveId | (target << 8)); } RecordedPlayerBufferExecCompleted(); @@ -1461,7 +1461,7 @@ static void RecordedPlayerHandleChooseItem(void) static void RecordedPlayerHandleChoosePokemon(void) { *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBattlerAction(gActiveBattler); - BtlController_EmitChosenMonReturnValue(BUFFER_B, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL); + BtlController_EmitChosenMonReturnValue(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL); RecordedPlayerBufferExecCompleted(); } diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 157bb6954c..09727b6cfd 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -176,16 +176,16 @@ static void HandleInputChooseAction(void) switch (gActionSelectionCursor[gActiveBattler]) { case 0: - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_BALL, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_SAFARI_BALL, 0); break; case 1: - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_POKEBLOCK, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_SAFARI_POKEBLOCK, 0); break; case 2: - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_GO_NEAR, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_SAFARI_GO_NEAR, 0); break; case 3: - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_RUN, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_SAFARI_RUN, 0); break; } SafariBufferExecCompleted(); @@ -280,7 +280,7 @@ static void CompleteWhenChosePokeblock(void) { if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active) { - BtlController_EmitOneReturnValue(BUFFER_B, gSpecialVar_ItemId); + BtlController_EmitOneReturnValue(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gSpecialVar_ItemId); SafariBufferExecCompleted(); } } @@ -298,7 +298,7 @@ static void SafariBufferExecCompleted(void) { u8 playerId = GetMultiplayerId(); - PrepareBufferDataTransferLink(2, 4, &playerId); + PrepareBufferDataTransferLink(BATTLELINKMSGTYPE_CONTROLLER_BECOMING_IDLE, 4, &playerId); gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index 67950b8965..e0dabb23c4 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -196,7 +196,7 @@ static void WallyHandleActions(void) if (--gBattleStruct->wallyWaitFrames == 0) { PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_MOVE, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_USE_MOVE, 0); WallyBufferExecCompleted(); gBattleStruct->wallyBattleState++; gBattleStruct->wallyMovesState = 0; @@ -207,7 +207,7 @@ static void WallyHandleActions(void) if (--gBattleStruct->wallyWaitFrames == 0) { PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_MOVE, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_USE_MOVE, 0); WallyBufferExecCompleted(); gBattleStruct->wallyBattleState++; gBattleStruct->wallyMovesState = 0; @@ -217,7 +217,7 @@ static void WallyHandleActions(void) case 3: if (--gBattleStruct->wallyWaitFrames == 0) { - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_WALLY_THROW, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_WALLY_THROW, 0); WallyBufferExecCompleted(); gBattleStruct->wallyBattleState++; gBattleStruct->wallyMovesState = 0; @@ -238,7 +238,7 @@ static void WallyHandleActions(void) if (--gBattleStruct->wallyWaitFrames == 0) { PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_ITEM, 0); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ACTION_USE_ITEM, 0); WallyBufferExecCompleted(); } break; @@ -278,7 +278,7 @@ static void CompleteOnChosenItem(void) { if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active) { - BtlController_EmitOneReturnValue(BUFFER_B, gSpecialVar_ItemId); + BtlController_EmitOneReturnValue(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gSpecialVar_ItemId); WallyBufferExecCompleted(); } } @@ -408,7 +408,7 @@ static void WallyBufferExecCompleted(void) { u8 playerId = GetMultiplayerId(); - PrepareBufferDataTransferLink(2, 4, &playerId); + PrepareBufferDataTransferLink(BATTLELINKMSGTYPE_CONTROLLER_BECOMING_IDLE, 4, &playerId); gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else @@ -444,7 +444,7 @@ static void WallyHandleGetMonData(void) monToCheck >>= 1; } } - BtlController_EmitDataTransfer(BUFFER_B, size, monData); + BtlController_EmitDataTransfer(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, size, monData); WallyBufferExecCompleted(); } @@ -1241,7 +1241,7 @@ static void WallyHandleChooseMove(void) if (--gBattleStruct->wallyMoveFrames == 0) { PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0x100); + BtlController_EmitTwoReturnValues(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, 10, 0x100); WallyBufferExecCompleted(); } break; diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 02276a7e14..8247e278bf 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -659,11 +659,11 @@ static void PrepareBufferDataTransfer(u8 bufferId, u8 *data, u16 size) { switch (bufferId) { - case BUFFER_A: + case BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER: for (i = 0; i < size; data++, i++) gBattleBufferA[gActiveBattler][i] = *data; break; - case BUFFER_B: + case BATTLELINKMSGTYPE_CONTROLLER_TO_ENGINE: for (i = 0; i < size; data++, i++) gBattleBufferB[gActiveBattler][i] = *data; break; @@ -671,20 +671,41 @@ static void PrepareBufferDataTransfer(u8 bufferId, u8 *data, u16 size) } } +#define tInitialDelayTimer data[10] +#define tState data[11] +#define tCurrentBlock_WrapFrom data[12] +#define tBlockSendDelayTimer data[13] +#define tCurrentBlock_End data[14] +#define tCurrentBlock_Start data[15] +// +// Inbound communications are stored in one buffer; outbound communications +// in another. Both buffers work pretty similarly: the next message will be +// written into the buffer after the previous message (with 4-byte alignment), +// unless we're too close to the end of the buffer, in which case we jump back +// to the start. +// +// Regarding the task variable names above: these variables are altered in- +// place, so the precise operational definition of "current" depends on when +// the variables are being accessed. When data is present in the send and +// receive buffers, "current" refers to the most recently received message; +// but when a message is actually being placed in the buffers, "current" +// refers to the previous message, until such time that we finish updating it +// to refer to the new message. + static void CreateTasksForSendRecvLinkBuffers(void) { sLinkSendTaskId = CreateTask(Task_HandleSendLinkBuffersData, 0); - gTasks[sLinkSendTaskId].data[11] = 0; - gTasks[sLinkSendTaskId].data[12] = 0; - gTasks[sLinkSendTaskId].data[13] = 0; - gTasks[sLinkSendTaskId].data[14] = 0; - gTasks[sLinkSendTaskId].data[15] = 0; + gTasks[sLinkSendTaskId].tState = 0; + gTasks[sLinkSendTaskId].tCurrentBlock_WrapFrom = 0; + gTasks[sLinkSendTaskId].tBlockSendDelayTimer = 0; + gTasks[sLinkSendTaskId].tCurrentBlock_End = 0; + gTasks[sLinkSendTaskId].tCurrentBlock_Start = 0; sLinkReceiveTaskId = CreateTask(Task_HandleCopyReceivedLinkBuffersData, 0); - gTasks[sLinkReceiveTaskId].data[12] = 0; - gTasks[sLinkReceiveTaskId].data[13] = 0; - gTasks[sLinkReceiveTaskId].data[14] = 0; - gTasks[sLinkReceiveTaskId].data[15] = 0; + gTasks[sLinkReceiveTaskId].tCurrentBlock_WrapFrom = 0; + gTasks[sLinkReceiveTaskId].tBlockSendDelayTimer = 0; // not used by "receive" task + gTasks[sLinkReceiveTaskId].tCurrentBlock_End = 0; + gTasks[sLinkReceiveTaskId].tCurrentBlock_Start = 0; sUnused = 0; } @@ -702,52 +723,72 @@ enum LINK_BUFF_DATA, }; +// We want to send a message. Place it into the "send" buffer. +// First argument is a BATTLELINKMSGTYPE_... void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data) { s32 alignedSize; s32 i; alignedSize = size - size % 4 + 4; - if (gTasks[sLinkSendTaskId].data[14] + alignedSize + LINK_BUFF_DATA + 1 > BATTLE_BUFFER_LINK_SIZE) + if (gTasks[sLinkSendTaskId].tCurrentBlock_End + alignedSize + LINK_BUFF_DATA + 1 > BATTLE_BUFFER_LINK_SIZE) { - gTasks[sLinkSendTaskId].data[12] = gTasks[sLinkSendTaskId].data[14]; - gTasks[sLinkSendTaskId].data[14] = 0; + gTasks[sLinkSendTaskId].tCurrentBlock_WrapFrom = gTasks[sLinkSendTaskId].tCurrentBlock_End; + gTasks[sLinkSendTaskId].tCurrentBlock_End = 0; } - gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_BUFFER_ID] = bufferId; - gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_ACTIVE_BATTLER] = gActiveBattler; - gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_ATTACKER] = gBattlerAttacker; - gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_TARGET] = gBattlerTarget; - gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_SIZE_LO] = alignedSize; - gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_SIZE_HI] = (alignedSize & 0x0000FF00) >> 8; - gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_ABSENT_BATTLER_FLAGS] = gAbsentBattlerFlags; - gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_EFFECT_BATTLER] = gEffectBattler; + + #define BYTE_TO_SEND(offset) \ + gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].tCurrentBlock_End + offset] + + BYTE_TO_SEND(LINK_BUFF_BUFFER_ID) = bufferId; + BYTE_TO_SEND(LINK_BUFF_ACTIVE_BATTLER) = gActiveBattler; + BYTE_TO_SEND(LINK_BUFF_ATTACKER) = gBattlerAttacker; + BYTE_TO_SEND(LINK_BUFF_TARGET) = gBattlerTarget; + BYTE_TO_SEND(LINK_BUFF_SIZE_LO) = alignedSize; + BYTE_TO_SEND(LINK_BUFF_SIZE_HI) = (alignedSize & 0x0000FF00) >> 8; + BYTE_TO_SEND(LINK_BUFF_ABSENT_BATTLER_FLAGS) = gAbsentBattlerFlags; + BYTE_TO_SEND(LINK_BUFF_EFFECT_BATTLER) = gEffectBattler; for (i = 0; i < size; i++) - gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_DATA + i] = data[i]; + BYTE_TO_SEND(LINK_BUFF_DATA + i) = data[i]; - gTasks[sLinkSendTaskId].data[14] = gTasks[sLinkSendTaskId].data[14] + alignedSize + LINK_BUFF_DATA; + #undef BYTE_TO_SEND + + gTasks[sLinkSendTaskId].tCurrentBlock_End = gTasks[sLinkSendTaskId].tCurrentBlock_End + alignedSize + LINK_BUFF_DATA; } +enum { + SENDTASK_STATE_INITIALIZE = 0, + SENDTASK_STATE_INITIAL_DELAY = 1, + SENDTASK_STATE_COUNT_PLAYERS = 2, + SENDTASK_STATE_BEGIN_SEND_BLOCK = 3, + SENDTASK_STATE_FINISH_SEND_BLOCK = 4, + SENDTASK_STATE_UNUSED_STATE = 5, +}; + static void Task_HandleSendLinkBuffersData(u8 taskId) { u16 numPlayers; u16 blockSize; + + #define BYTE_TO_SEND(offset) \ + gLinkBattleSendBuffer[gTasks[taskId].tCurrentBlock_Start + offset] - switch (gTasks[taskId].data[11]) + switch (gTasks[taskId].tState) { - case 0: - gTasks[taskId].data[10] = 100; - gTasks[taskId].data[11]++; + case SENDTASK_STATE_INITIALIZE: + gTasks[taskId].tInitialDelayTimer = 100; + gTasks[taskId].tState++; break; - case 1: - gTasks[taskId].data[10]--; - if (gTasks[taskId].data[10] == 0) - gTasks[taskId].data[11]++; + case SENDTASK_STATE_INITIAL_DELAY: + gTasks[taskId].tInitialDelayTimer--; + if (gTasks[taskId].tInitialDelayTimer == 0) + gTasks[taskId].tState++; break; - case 2: + case SENDTASK_STATE_COUNT_PLAYERS: if (gWirelessCommType) { - gTasks[taskId].data[11]++; + gTasks[taskId].tState++; } else { @@ -761,56 +802,59 @@ static void Task_HandleSendLinkBuffersData(u8 taskId) if (IsLinkMaster()) { CheckShouldAdvanceLinkState(); - gTasks[taskId].data[11]++; + gTasks[taskId].tState++; } else { - gTasks[taskId].data[11]++; + gTasks[taskId].tState++; } } } break; - case 3: - if (gTasks[taskId].data[15] != gTasks[taskId].data[14]) + case SENDTASK_STATE_BEGIN_SEND_BLOCK: + if (gTasks[taskId].tCurrentBlock_Start != gTasks[taskId].tCurrentBlock_End) { - if (gTasks[taskId].data[13] == 0) + if (gTasks[taskId].tBlockSendDelayTimer == 0) { - if (gTasks[taskId].data[15] > gTasks[taskId].data[14] - && gTasks[taskId].data[15] == gTasks[taskId].data[12]) + if (gTasks[taskId].tCurrentBlock_Start > gTasks[taskId].tCurrentBlock_End + && gTasks[taskId].tCurrentBlock_Start == gTasks[taskId].tCurrentBlock_WrapFrom) { - gTasks[taskId].data[12] = 0; - gTasks[taskId].data[15] = 0; + gTasks[taskId].tCurrentBlock_WrapFrom = 0; + gTasks[taskId].tCurrentBlock_Start = 0; } - blockSize = (gLinkBattleSendBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_LO] | (gLinkBattleSendBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_HI] << 8)) + LINK_BUFF_DATA; - SendBlock(BitmaskAllOtherLinkPlayers(), &gLinkBattleSendBuffer[gTasks[taskId].data[15]], blockSize); - gTasks[taskId].data[11]++; + blockSize = (BYTE_TO_SEND(LINK_BUFF_SIZE_LO) | (BYTE_TO_SEND(LINK_BUFF_SIZE_HI) << 8)) + LINK_BUFF_DATA; + SendBlock(BitmaskAllOtherLinkPlayers(), &BYTE_TO_SEND(0), blockSize); + gTasks[taskId].tState++; } else { - gTasks[taskId].data[13]--; + gTasks[taskId].tBlockSendDelayTimer--; break; } } break; - case 4: + case SENDTASK_STATE_FINISH_SEND_BLOCK: if (IsLinkTaskFinished()) { - blockSize = gLinkBattleSendBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_LO] | (gLinkBattleSendBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_HI] << 8); - gTasks[taskId].data[13] = 1; - gTasks[taskId].data[15] = gTasks[taskId].data[15] + blockSize + LINK_BUFF_DATA; - gTasks[taskId].data[11] = 3; + blockSize = BYTE_TO_SEND(LINK_BUFF_SIZE_LO) | (BYTE_TO_SEND(LINK_BUFF_SIZE_HI) << 8); + gTasks[taskId].tBlockSendDelayTimer = 1; + gTasks[taskId].tCurrentBlock_Start = gTasks[taskId].tCurrentBlock_Start + blockSize + LINK_BUFF_DATA; + gTasks[taskId].tState = SENDTASK_STATE_BEGIN_SEND_BLOCK; } break; - case 5: - if (--gTasks[taskId].data[13] == 0) + case SENDTASK_STATE_UNUSED_STATE: + if (--gTasks[taskId].tBlockSendDelayTimer == 0) { - gTasks[taskId].data[13] = 1; - gTasks[taskId].data[11] = 3; + gTasks[taskId].tBlockSendDelayTimer = 1; + gTasks[taskId].tState = SENDTASK_STATE_BEGIN_SEND_BLOCK; } break; } + + #undef BYTE_TO_SEND } +// We have received a message. Place it into the "receive" buffer. void TryReceiveLinkBattleData(void) { u8 i; @@ -830,19 +874,19 @@ void TryReceiveLinkBattleData(void) u8 *dest, *src; u16 dataSize = gBlockRecvBuffer[i][2]; - if (gTasks[sLinkReceiveTaskId].data[14] + 9 + dataSize > 0x1000) + if (gTasks[sLinkReceiveTaskId].tCurrentBlock_End + 9 + dataSize > 0x1000) { - gTasks[sLinkReceiveTaskId].data[12] = gTasks[sLinkReceiveTaskId].data[14]; - gTasks[sLinkReceiveTaskId].data[14] = 0; + gTasks[sLinkReceiveTaskId].tCurrentBlock_WrapFrom = gTasks[sLinkReceiveTaskId].tCurrentBlock_End; + gTasks[sLinkReceiveTaskId].tCurrentBlock_End = 0; } - dest = &gLinkBattleRecvBuffer[gTasks[sLinkReceiveTaskId].data[14]]; + dest = &gLinkBattleRecvBuffer[gTasks[sLinkReceiveTaskId].tCurrentBlock_End]; src = recvBuffer; for (j = 0; j < dataSize + 8; j++) dest[j] = src[j]; - gTasks[sLinkReceiveTaskId].data[14] = gTasks[sLinkReceiveTaskId].data[14] + dataSize + 8; + gTasks[sLinkReceiveTaskId].tCurrentBlock_End = gTasks[sLinkReceiveTaskId].tCurrentBlock_End + dataSize + 8; } } } @@ -853,49 +897,61 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId) { u16 blockSize; u8 battlerId; - u8 var; + u8 playerId; + + #define BYTE_TO_RECEIVE(offset) \ + gLinkBattleRecvBuffer[gTasks[taskId].tCurrentBlock_Start + offset] - if (gTasks[taskId].data[15] != gTasks[taskId].data[14]) + if (gTasks[taskId].tCurrentBlock_Start != gTasks[taskId].tCurrentBlock_End) { - if (gTasks[taskId].data[15] > gTasks[taskId].data[14] - && gTasks[taskId].data[15] == gTasks[taskId].data[12]) + if (gTasks[taskId].tCurrentBlock_Start > gTasks[taskId].tCurrentBlock_End + && gTasks[taskId].tCurrentBlock_Start == gTasks[taskId].tCurrentBlock_WrapFrom) { - gTasks[taskId].data[12] = 0; - gTasks[taskId].data[15] = 0; + gTasks[taskId].tCurrentBlock_WrapFrom = 0; + gTasks[taskId].tCurrentBlock_Start = 0; } - battlerId = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_ACTIVE_BATTLER]; - blockSize = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_LO] | (gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_HI] << 8); + battlerId = BYTE_TO_RECEIVE(LINK_BUFF_ACTIVE_BATTLER); + blockSize = BYTE_TO_RECEIVE(LINK_BUFF_SIZE_LO) | (BYTE_TO_RECEIVE(LINK_BUFF_SIZE_HI) << 8); - switch (gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 0]) + switch (BYTE_TO_RECEIVE(0)) { - case 0: + case BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER: if (gBattleControllerExecFlags & gBitTable[battlerId]) return; - memcpy(gBattleBufferA[battlerId], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA], blockSize); + memcpy(gBattleBufferA[battlerId], &BYTE_TO_RECEIVE(LINK_BUFF_DATA), blockSize); MarkBattlerReceivedLinkData(battlerId); if (!(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER)) { - gBattlerAttacker = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_ATTACKER]; - gBattlerTarget = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_TARGET]; - gAbsentBattlerFlags = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_ABSENT_BATTLER_FLAGS]; - gEffectBattler = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_EFFECT_BATTLER]; + gBattlerAttacker = BYTE_TO_RECEIVE(LINK_BUFF_ATTACKER); + gBattlerTarget = BYTE_TO_RECEIVE(LINK_BUFF_TARGET); + gAbsentBattlerFlags = BYTE_TO_RECEIVE(LINK_BUFF_ABSENT_BATTLER_FLAGS); + gEffectBattler = BYTE_TO_RECEIVE(LINK_BUFF_EFFECT_BATTLER); } break; - case 1: - memcpy(gBattleBufferB[battlerId], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA], blockSize); + case BATTLELINKMSGTYPE_CONTROLLER_TO_ENGINE: + memcpy(gBattleBufferB[battlerId], &gLinkBattleRecvBuffer[gTasks[taskId].tCurrentBlock_Start + LINK_BUFF_DATA], blockSize); break; - case 2: - var = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA]; - gBattleControllerExecFlags &= ~(gBitTable[battlerId] << (var * 4)); + case BATTLELINKMSGTYPE_CONTROLLER_BECOMING_IDLE: + playerId = BYTE_TO_RECEIVE(LINK_BUFF_DATA); + gBattleControllerExecFlags &= ~(gBitTable[battlerId] << (playerId * 4)); break; } - gTasks[taskId].data[15] = gTasks[taskId].data[15] + blockSize + LINK_BUFF_DATA; + gTasks[taskId].tCurrentBlock_Start = gTasks[taskId].tCurrentBlock_Start + blockSize + LINK_BUFF_DATA; } + + #undef BYTE_TO_RECEIVE } +#undef tInitialDelayTimer +#undef tState +#undef tCurrentBlock_WrapFrom +#undef tBlockSendDelayTimer +#undef tCurrentBlock_End +#undef tCurrentBlock_Start + void BtlController_EmitGetMonData(u8 bufferId, u8 requestId, u8 monToCheck) { sBattleBuffersTransferData[0] = CONTROLLER_GETMONDATA; diff --git a/src/battle_main.c b/src/battle_main.c index 87fa0d3981..46f163586f 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3360,7 +3360,7 @@ static void BattleIntroGetMonsData(void) { case 0: gActiveBattler = gBattleCommunication[1]; - BtlController_EmitGetMonData(BUFFER_A, REQUEST_ALL_BATTLE, 0); + BtlController_EmitGetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_ALL_BATTLE, 0); MarkBattlerForControllerExec(gActiveBattler); gBattleCommunication[MULTIUSE_STATE]++; break; @@ -3382,7 +3382,7 @@ static void BattleIntroPrepareBackgroundSlide(void) if (gBattleControllerExecFlags == 0) { gActiveBattler = GetBattlerAtPosition(0); - BtlController_EmitIntroSlide(BUFFER_A, gBattleEnvironment); + BtlController_EmitIntroSlide(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattleEnvironment); MarkBattlerForControllerExec(gActiveBattler); gBattleMainFunc = BattleIntroDrawTrainersOrMonsSprites; gBattleCommunication[MULTIUSE_STATE] = 0; @@ -3513,7 +3513,7 @@ static void BattleIntroDrawPartySummaryScreens(void) } } gActiveBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); - BtlController_EmitDrawPartyStatusSummary(BUFFER_A, hpStatus, PARTY_SUMM_SKIP_DRAW_DELAY); + BtlController_EmitDrawPartyStatusSummary(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, hpStatus, PARTY_SUMM_SKIP_DRAW_DELAY); MarkBattlerForControllerExec(gActiveBattler); for (i = 0; i < PARTY_SIZE; i++) @@ -3531,7 +3531,7 @@ static void BattleIntroDrawPartySummaryScreens(void) } } gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); - BtlController_EmitDrawPartyStatusSummary(BUFFER_A, hpStatus, PARTY_SUMM_SKIP_DRAW_DELAY); + BtlController_EmitDrawPartyStatusSummary(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, hpStatus, PARTY_SUMM_SKIP_DRAW_DELAY); MarkBattlerForControllerExec(gActiveBattler); gBattleMainFunc = BattleIntroPrintTrainerWantsToBattle; @@ -3825,7 +3825,7 @@ static void UNUSED BattleIntroSwitchInPlayerMons(void) { if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { - BtlController_EmitSwitchInAnim(BUFFER_A, gBattlerPartyIndexes[gActiveBattler], FALSE); + BtlController_EmitSwitchInAnim(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattlerPartyIndexes[gActiveBattler], FALSE); MarkBattlerForControllerExec(gActiveBattler); } } @@ -4165,7 +4165,7 @@ static void HandleTurnActionSelectionState(void) } else { - BtlController_EmitChooseAction(BUFFER_A, gChosenActionByBattler[0], gBattleBufferB[0][1] | (gBattleBufferB[0][2] << 8)); + BtlController_EmitChooseAction(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gChosenActionByBattler[0], gBattleBufferB[0][1] | (gBattleBufferB[0][2] << 8)); MarkBattlerForControllerExec(gActiveBattler); gBattleCommunication[gActiveBattler]++; } @@ -4214,7 +4214,7 @@ static void HandleTurnActionSelectionState(void) i); } - BtlController_EmitChooseMove(BUFFER_A, (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) != 0, FALSE, &moveInfo); + BtlController_EmitChooseMove(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) != 0, FALSE, &moveInfo); MarkBattlerForControllerExec(gActiveBattler); } break; @@ -4233,7 +4233,7 @@ static void HandleTurnActionSelectionState(void) } else { - BtlController_EmitChooseItem(BUFFER_A, gBattleStruct->battlerPartyOrders[gActiveBattler]); + BtlController_EmitChooseItem(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattleStruct->battlerPartyOrders[gActiveBattler]); MarkBattlerForControllerExec(gActiveBattler); } break; @@ -4243,7 +4243,7 @@ static void HandleTurnActionSelectionState(void) || gBattleTypeFlags & BATTLE_TYPE_ARENA || gStatuses3[gActiveBattler] & STATUS3_ROOTED) { - BtlController_EmitChoosePokemon(BUFFER_A, PARTY_ACTION_CANT_SWITCH, PARTY_SIZE, ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]); + BtlController_EmitChoosePokemon(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, PARTY_ACTION_CANT_SWITCH, PARTY_SIZE, ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]); } else if ((i = ABILITY_ON_OPPOSING_FIELD(gActiveBattler, ABILITY_SHADOW_TAG)) || ((i = ABILITY_ON_OPPOSING_FIELD(gActiveBattler, ABILITY_ARENA_TRAP)) @@ -4252,16 +4252,16 @@ static void HandleTurnActionSelectionState(void) || ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BATTLER, gActiveBattler, ABILITY_MAGNET_PULL, 0, 0)) && IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_STEEL))) { - BtlController_EmitChoosePokemon(BUFFER_A, ((i - 1) << 4) | PARTY_ACTION_ABILITY_PREVENTS, PARTY_SIZE, gLastUsedAbility, gBattleStruct->battlerPartyOrders[gActiveBattler]); + BtlController_EmitChoosePokemon(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, ((i - 1) << 4) | PARTY_ACTION_ABILITY_PREVENTS, PARTY_SIZE, gLastUsedAbility, gBattleStruct->battlerPartyOrders[gActiveBattler]); } else { if (gActiveBattler == 2 && gChosenActionByBattler[0] == B_ACTION_SWITCH) - BtlController_EmitChoosePokemon(BUFFER_A, PARTY_ACTION_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 0), ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]); + BtlController_EmitChoosePokemon(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, PARTY_ACTION_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 0), ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]); else if (gActiveBattler == 3 && gChosenActionByBattler[1] == B_ACTION_SWITCH) - BtlController_EmitChoosePokemon(BUFFER_A, PARTY_ACTION_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 1), ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]); + BtlController_EmitChoosePokemon(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, PARTY_ACTION_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 1), ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]); else - BtlController_EmitChoosePokemon(BUFFER_A, PARTY_ACTION_CHOOSE_MON, PARTY_SIZE, ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]); + BtlController_EmitChoosePokemon(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, PARTY_ACTION_CHOOSE_MON, PARTY_SIZE, ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]); } MarkBattlerForControllerExec(gActiveBattler); break; @@ -4276,7 +4276,7 @@ static void HandleTurnActionSelectionState(void) } break; case B_ACTION_SAFARI_POKEBLOCK: - BtlController_EmitChooseItem(BUFFER_A, gBattleStruct->battlerPartyOrders[gActiveBattler]); + BtlController_EmitChooseItem(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattleStruct->battlerPartyOrders[gActiveBattler]); MarkBattlerForControllerExec(gActiveBattler); break; case B_ACTION_CANCEL_PARTNER: @@ -4471,11 +4471,11 @@ static void HandleTurnActionSelectionState(void) || (position & BIT_FLANK) != B_FLANK_LEFT || (*(&gBattleStruct->absentBattlerFlags) & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(position))])) { - BtlController_EmitLinkStandbyMsg(BUFFER_A, LINK_STANDBY_MSG_STOP_BOUNCE, i); + BtlController_EmitLinkStandbyMsg(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, LINK_STANDBY_MSG_STOP_BOUNCE, i); } else { - BtlController_EmitLinkStandbyMsg(BUFFER_A, LINK_STANDBY_STOP_BOUNCE_ONLY, i); + BtlController_EmitLinkStandbyMsg(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, LINK_STANDBY_STOP_BOUNCE_ONLY, i); } MarkBattlerForControllerExec(gActiveBattler); gBattleCommunication[gActiveBattler]++; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 9665479140..48951f0732 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1239,7 +1239,7 @@ static void Cmd_ppreduce(void) if (MOVE_IS_PERMANENT(gBattlerAttacker, gCurrMovePos)) { gActiveBattler = gBattlerAttacker; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_PPMOVE1_BATTLE + gCurrMovePos, 0, + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_PPMOVE1_BATTLE + gCurrMovePos, 0, sizeof(gBattleMons[gBattlerAttacker].pp[gCurrMovePos]), &gBattleMons[gBattlerAttacker].pp[gCurrMovePos]); MarkBattlerForControllerExec(gBattlerAttacker); @@ -1784,7 +1784,7 @@ static void Cmd_attackanimation(void) multihit = gMultiHitCounter; } - BtlController_EmitMoveAnimation(BUFFER_A, gCurrentMove, gBattleScripting.animTurn, gBattleMovePower, gBattleMoveDamage, gBattleMons[gBattlerAttacker].friendship, &gDisableStructs[gBattlerAttacker], multihit); + BtlController_EmitMoveAnimation(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gCurrentMove, gBattleScripting.animTurn, gBattleMovePower, gBattleMoveDamage, gBattleMons[gBattlerAttacker].friendship, &gDisableStructs[gBattlerAttacker], multihit); gBattleScripting.animTurn++; gBattleScripting.animTargetsHit++; MarkBattlerForControllerExec(gBattlerAttacker); @@ -1829,7 +1829,7 @@ static void Cmd_healthbarupdate(void) else healthValue = maxPossibleDmgValue; - BtlController_EmitHealthBarUpdate(BUFFER_A, healthValue); + BtlController_EmitHealthBarUpdate(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, healthValue); MarkBattlerForControllerExec(gActiveBattler); if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER && gBattleMoveDamage > 0) @@ -1971,7 +1971,7 @@ static void Cmd_datahpupdate(void) gHitMarker &= ~HITMARKER_PASSIVE_DAMAGE; // Send updated HP - BtlController_EmitSetMonData(BUFFER_A, REQUEST_HP_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].hp), &gBattleMons[gActiveBattler].hp); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_HP_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].hp), &gBattleMons[gActiveBattler].hp); MarkBattlerForControllerExec(gActiveBattler); } } @@ -2009,11 +2009,11 @@ static void Cmd_effectivenesssound(void) switch (gMoveResultFlags & (u8)(~MOVE_RESULT_MISSED)) { case MOVE_RESULT_SUPER_EFFECTIVE: - BtlController_EmitPlaySE(BUFFER_A, SE_SUPER_EFFECTIVE); + BtlController_EmitPlaySE(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, SE_SUPER_EFFECTIVE); MarkBattlerForControllerExec(gActiveBattler); break; case MOVE_RESULT_NOT_VERY_EFFECTIVE: - BtlController_EmitPlaySE(BUFFER_A, SE_NOT_EFFECTIVE); + BtlController_EmitPlaySE(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, SE_NOT_EFFECTIVE); MarkBattlerForControllerExec(gActiveBattler); break; case MOVE_RESULT_DOESNT_AFFECT_FOE: @@ -2026,17 +2026,17 @@ static void Cmd_effectivenesssound(void) default: if (gMoveResultFlags & MOVE_RESULT_SUPER_EFFECTIVE) { - BtlController_EmitPlaySE(BUFFER_A, SE_SUPER_EFFECTIVE); + BtlController_EmitPlaySE(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, SE_SUPER_EFFECTIVE); MarkBattlerForControllerExec(gActiveBattler); } else if (gMoveResultFlags & MOVE_RESULT_NOT_VERY_EFFECTIVE) { - BtlController_EmitPlaySE(BUFFER_A, SE_NOT_EFFECTIVE); + BtlController_EmitPlaySE(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, SE_NOT_EFFECTIVE); MarkBattlerForControllerExec(gActiveBattler); } else if (!(gMoveResultFlags & (MOVE_RESULT_DOESNT_AFFECT_FOE | MOVE_RESULT_FAILED))) { - BtlController_EmitPlaySE(BUFFER_A, SE_EFFECTIVE); + BtlController_EmitPlaySE(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, SE_EFFECTIVE); MarkBattlerForControllerExec(gActiveBattler); } break; @@ -2149,7 +2149,7 @@ static void Cmd_printselectionstring(void) { gActiveBattler = gBattlerAttacker; - BtlController_EmitPrintSelectionString(BUFFER_A, T2_READ_16(gBattlescriptCurrInstr + 1)); + BtlController_EmitPrintSelectionString(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, T2_READ_16(gBattlescriptCurrInstr + 1)); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 3; @@ -2199,7 +2199,7 @@ static void Cmd_printselectionstringfromtable(void) ptr += gBattleCommunication[MULTISTRING_CHOOSER]; gActiveBattler = gBattlerAttacker; - BtlController_EmitPrintSelectionString(BUFFER_A, *ptr); + BtlController_EmitPrintSelectionString(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, *ptr); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 5; @@ -2485,7 +2485,7 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]]; gActiveBattler = gEffectBattler; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gEffectBattler].status1), &gBattleMons[gEffectBattler].status1); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gEffectBattler].status1), &gBattleMons[gEffectBattler].status1); MarkBattlerForControllerExec(gActiveBattler); if (gHitMarker & HITMARKER_STATUS_ABILITY_EFFECT) @@ -2787,11 +2787,11 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattleMons[gBattlerTarget].item = ITEM_NONE; gActiveBattler = gBattlerAttacker; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gLastUsedItem), &gLastUsedItem); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_HELDITEM_BATTLE, 0, sizeof(gLastUsedItem), &gLastUsedItem); MarkBattlerForControllerExec(gBattlerAttacker); gActiveBattler = gBattlerTarget; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gBattlerTarget].item), &gBattleMons[gBattlerTarget].item); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gBattlerTarget].item), &gBattleMons[gBattlerTarget].item); MarkBattlerForControllerExec(gBattlerTarget); BattleScriptPush(gBattlescriptCurrInstr + 1); @@ -2829,7 +2829,7 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattleMons[gBattlerTarget].status1 &= ~STATUS1_PARALYSIS; gActiveBattler = gBattlerTarget; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].status1), &gBattleMons[gActiveBattler].status1); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].status1), &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); BattleScriptPush(gBattlescriptCurrInstr + 1); @@ -3036,7 +3036,7 @@ static void Cmd_tryfaintmon(void) BattleScriptPush(gBattlescriptCurrInstr); gBattlescriptCurrInstr = BattleScript_GrudgeTakesPp; gActiveBattler = gBattlerAttacker; - BtlController_EmitSetMonData(BUFFER_A, moveIndex + REQUEST_PPMOVE1_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].pp[moveIndex]), &gBattleMons[gActiveBattler].pp[moveIndex]); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, moveIndex + REQUEST_PPMOVE1_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].pp[moveIndex]), &gBattleMons[gActiveBattler].pp[moveIndex]); MarkBattlerForControllerExec(gActiveBattler); PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].moves[moveIndex]) @@ -3069,7 +3069,7 @@ static void Cmd_cleareffectsonfaint(void) if (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || gBattleMons[gActiveBattler].hp == 0) { gBattleMons[gActiveBattler].status1 = 0; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].status1), &gBattleMons[gActiveBattler].status1); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].status1), &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); } @@ -3438,7 +3438,7 @@ static void Cmd_getexp(void) gBattleResources->beforeLvlUp->stats[STAT_SPDEF] = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPDEF); gActiveBattler = gBattleStruct->expGetterBattlerId; - BtlController_EmitExpUpdate(BUFFER_A, gBattleStruct->expGetterMonId, gBattleMoveDamage); + BtlController_EmitExpUpdate(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattleStruct->expGetterMonId, gBattleMoveDamage); MarkBattlerForControllerExec(gActiveBattler); } gBattleScripting.getexpState++; @@ -3937,7 +3937,7 @@ static void Cmd_healthbar_update(void) else gActiveBattler = gBattlerAttacker; - BtlController_EmitHealthBarUpdate(BUFFER_A, gBattleMoveDamage); + BtlController_EmitHealthBarUpdate(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattleMoveDamage); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 2; } @@ -4012,7 +4012,7 @@ static void Cmd_playanimation(void) || gBattlescriptCurrInstr[2] == B_ANIM_SNATCH_MOVE || gBattlescriptCurrInstr[2] == B_ANIM_SUBSTITUTE_FADE) { - BtlController_EmitBattleAnimation(BUFFER_A, gBattlescriptCurrInstr[2], *argumentPtr); + BtlController_EmitBattleAnimation(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattlescriptCurrInstr[2], *argumentPtr); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 7; } @@ -4026,7 +4026,7 @@ static void Cmd_playanimation(void) || gBattlescriptCurrInstr[2] == B_ANIM_SANDSTORM_CONTINUES || gBattlescriptCurrInstr[2] == B_ANIM_HAIL_CONTINUES) { - BtlController_EmitBattleAnimation(BUFFER_A, gBattlescriptCurrInstr[2], *argumentPtr); + BtlController_EmitBattleAnimation(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattlescriptCurrInstr[2], *argumentPtr); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 7; } @@ -4036,7 +4036,7 @@ static void Cmd_playanimation(void) } else { - BtlController_EmitBattleAnimation(BUFFER_A, gBattlescriptCurrInstr[2], *argumentPtr); + BtlController_EmitBattleAnimation(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattlescriptCurrInstr[2], *argumentPtr); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 7; } @@ -4056,7 +4056,7 @@ static void Cmd_playanimation_var(void) || *animationIdPtr == B_ANIM_SNATCH_MOVE || *animationIdPtr == B_ANIM_SUBSTITUTE_FADE) { - BtlController_EmitBattleAnimation(BUFFER_A, *animationIdPtr, *argumentPtr); + BtlController_EmitBattleAnimation(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, *animationIdPtr, *argumentPtr); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 10; } @@ -4069,7 +4069,7 @@ static void Cmd_playanimation_var(void) || *animationIdPtr == B_ANIM_SANDSTORM_CONTINUES || *animationIdPtr == B_ANIM_HAIL_CONTINUES) { - BtlController_EmitBattleAnimation(BUFFER_A, *animationIdPtr, *argumentPtr); + BtlController_EmitBattleAnimation(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, *animationIdPtr, *argumentPtr); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 10; } @@ -4079,7 +4079,7 @@ static void Cmd_playanimation_var(void) } else { - BtlController_EmitBattleAnimation(BUFFER_A, *animationIdPtr, *argumentPtr); + BtlController_EmitBattleAnimation(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, *animationIdPtr, *argumentPtr); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 10; } @@ -4195,7 +4195,7 @@ static void Cmd_playstatchangeanimation(void) } else if (changeableStatsCount != 0 && !gBattleScripting.statAnimPlayed) { - BtlController_EmitBattleAnimation(BUFFER_A, B_ANIM_STATS_CHANGE, statAnimId); + BtlController_EmitBattleAnimation(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ANIM_STATS_CHANGE, statAnimId); MarkBattlerForControllerExec(gActiveBattler); if (gBattlescriptCurrInstr[3] & STAT_CHANGE_MULTIPLE_STATS && changeableStatsCount > 1) gBattleScripting.statAnimPlayed = TRUE; @@ -4264,7 +4264,7 @@ static void Cmd_moveend(void) { gBattleMons[gBattlerTarget].status1 &= ~STATUS1_FREEZE; gActiveBattler = gBattlerTarget; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gBattlerTarget].status1), &gBattleMons[gBattlerTarget].status1); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gBattlerTarget].status1), &gBattleMons[gBattlerTarget].status1); MarkBattlerForControllerExec(gActiveBattler); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_DefrostedViaFireMove; @@ -4343,7 +4343,7 @@ static void Cmd_moveend(void) && gHitMarker & HITMARKER_NO_ANIMATIONS) { gActiveBattler = gBattlerAttacker; - BtlController_EmitSpriteInvisibility(BUFFER_A, TRUE); + BtlController_EmitSpriteInvisibility(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, TRUE); MarkBattlerForControllerExec(gActiveBattler); gBattleScripting.moveendState++; return; @@ -4356,7 +4356,7 @@ static void Cmd_moveend(void) || WasUnableToUseMove(gBattlerAttacker)) { gActiveBattler = gBattlerAttacker; - BtlController_EmitSpriteInvisibility(BUFFER_A, FALSE); + BtlController_EmitSpriteInvisibility(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, FALSE); MarkBattlerForControllerExec(gActiveBattler); gStatuses3[gBattlerAttacker] &= ~STATUS3_SEMI_INVULNERABLE; gSpecialStatuses[gBattlerAttacker].restoredBattlerSprite = 1; @@ -4370,7 +4370,7 @@ static void Cmd_moveend(void) && !(gStatuses3[gBattlerTarget] & STATUS3_SEMI_INVULNERABLE)) { gActiveBattler = gBattlerTarget; - BtlController_EmitSpriteInvisibility(BUFFER_A, FALSE); + BtlController_EmitSpriteInvisibility(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, FALSE); MarkBattlerForControllerExec(gActiveBattler); gStatuses3[gBattlerTarget] &= ~STATUS3_SEMI_INVULNERABLE; gBattleScripting.moveendState++; @@ -4597,7 +4597,7 @@ static void Cmd_returnatktoball(void) gActiveBattler = gBattlerAttacker; if (!(gHitMarker & HITMARKER_FAINTED(gActiveBattler))) { - BtlController_EmitReturnMonToBall(BUFFER_A, FALSE); + BtlController_EmitReturnMonToBall(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, FALSE); MarkBattlerForControllerExec(gActiveBattler); } gBattlescriptCurrInstr++; @@ -4612,7 +4612,7 @@ static void Cmd_getswitchedmondata(void) gBattlerPartyIndexes[gActiveBattler] = *(gBattleStruct->monToSwitchIntoId + gActiveBattler); - BtlController_EmitGetMonData(BUFFER_A, REQUEST_ALL_BATTLE, gBitTable[gBattlerPartyIndexes[gActiveBattler]]); + BtlController_EmitGetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_ALL_BATTLE, gBitTable[gBattlerPartyIndexes[gActiveBattler]]); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 2; @@ -4688,7 +4688,7 @@ static void Cmd_switchinanim(void) gAbsentBattlerFlags &= ~(gBitTable[gActiveBattler]); - BtlController_EmitSwitchInAnim(BUFFER_A, gBattlerPartyIndexes[gActiveBattler], gBattlescriptCurrInstr[2]); + BtlController_EmitSwitchInAnim(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattlerPartyIndexes[gActiveBattler], gBattlescriptCurrInstr[2]); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 3; @@ -4858,7 +4858,7 @@ static void ChooseMonToSendOut(u8 slotId) *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = PARTY_SIZE; gBattleStruct->field_93 &= ~(gBitTable[gActiveBattler]); - BtlController_EmitChoosePokemon(BUFFER_A, PARTY_ACTION_SEND_OUT, slotId, ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]); + BtlController_EmitChoosePokemon(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, PARTY_ACTION_SEND_OUT, slotId, ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]); MarkBattlerForControllerExec(gActiveBattler); } @@ -4885,7 +4885,7 @@ static void Cmd_openpartyscreen(void) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; gHitMarker &= ~HITMARKER_FAINTED(gActiveBattler); - BtlController_EmitLinkStandbyMsg(BUFFER_A, LINK_STANDBY_MSG_ONLY, FALSE); + BtlController_EmitLinkStandbyMsg(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, LINK_STANDBY_MSG_ONLY, FALSE); MarkBattlerForControllerExec(gActiveBattler); } else if (!gSpecialStatuses[gActiveBattler].faintedHasReplacement) @@ -4896,7 +4896,7 @@ static void Cmd_openpartyscreen(void) } else { - BtlController_EmitLinkStandbyMsg(BUFFER_A, LINK_STANDBY_MSG_ONLY, FALSE); + BtlController_EmitLinkStandbyMsg(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, LINK_STANDBY_MSG_ONLY, FALSE); MarkBattlerForControllerExec(gActiveBattler); } } @@ -4924,7 +4924,7 @@ static void Cmd_openpartyscreen(void) } else { - BtlController_EmitLinkStandbyMsg(BUFFER_A, LINK_STANDBY_MSG_ONLY, FALSE); + BtlController_EmitLinkStandbyMsg(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, LINK_STANDBY_MSG_ONLY, FALSE); MarkBattlerForControllerExec(gActiveBattler); flags |= 1; } @@ -4946,7 +4946,7 @@ static void Cmd_openpartyscreen(void) } else if (!(flags & 1)) { - BtlController_EmitLinkStandbyMsg(BUFFER_A, LINK_STANDBY_MSG_ONLY, FALSE); + BtlController_EmitLinkStandbyMsg(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, LINK_STANDBY_MSG_ONLY, FALSE); MarkBattlerForControllerExec(gActiveBattler); } } @@ -4967,7 +4967,7 @@ static void Cmd_openpartyscreen(void) } else { - BtlController_EmitLinkStandbyMsg(BUFFER_A, LINK_STANDBY_MSG_ONLY, FALSE); + BtlController_EmitLinkStandbyMsg(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, LINK_STANDBY_MSG_ONLY, FALSE); MarkBattlerForControllerExec(gActiveBattler); flags |= 2; } @@ -4989,7 +4989,7 @@ static void Cmd_openpartyscreen(void) } else if (!(flags & 2)) { - BtlController_EmitLinkStandbyMsg(BUFFER_A, LINK_STANDBY_MSG_ONLY, FALSE); + BtlController_EmitLinkStandbyMsg(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, LINK_STANDBY_MSG_ONLY, FALSE); MarkBattlerForControllerExec(gActiveBattler); } } @@ -5005,7 +5005,7 @@ static void Cmd_openpartyscreen(void) else gActiveBattler = 0; - BtlController_EmitLinkStandbyMsg(BUFFER_A, LINK_STANDBY_MSG_ONLY, FALSE); + BtlController_EmitLinkStandbyMsg(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, LINK_STANDBY_MSG_ONLY, FALSE); MarkBattlerForControllerExec(gActiveBattler); } @@ -5021,7 +5021,7 @@ static void Cmd_openpartyscreen(void) else gActiveBattler = 1; - BtlController_EmitLinkStandbyMsg(BUFFER_A, LINK_STANDBY_MSG_ONLY, FALSE); + BtlController_EmitLinkStandbyMsg(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, LINK_STANDBY_MSG_ONLY, FALSE); MarkBattlerForControllerExec(gActiveBattler); } } @@ -5117,7 +5117,7 @@ static void Cmd_openpartyscreen(void) *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = PARTY_SIZE; gBattleStruct->field_93 &= ~(gBitTable[gActiveBattler]); - BtlController_EmitChoosePokemon(BUFFER_A, hitmarkerFaintBits, *(gBattleStruct->monToSwitchIntoId + BATTLE_PARTNER(gActiveBattler)), ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]); + BtlController_EmitChoosePokemon(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, hitmarkerFaintBits, *(gBattleStruct->monToSwitchIntoId + BATTLE_PARTNER(gActiveBattler)), ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 6; @@ -5131,7 +5131,7 @@ static void Cmd_openpartyscreen(void) { if (gActiveBattler != battlerId) { - BtlController_EmitLinkStandbyMsg(BUFFER_A, LINK_STANDBY_MSG_ONLY, FALSE); + BtlController_EmitLinkStandbyMsg(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, LINK_STANDBY_MSG_ONLY, FALSE); MarkBattlerForControllerExec(gActiveBattler); } } @@ -5142,7 +5142,7 @@ static void Cmd_openpartyscreen(void) if (gAbsentBattlerFlags & gBitTable[gActiveBattler]) gActiveBattler ^= BIT_FLANK; - BtlController_EmitLinkStandbyMsg(BUFFER_A, LINK_STANDBY_MSG_ONLY, FALSE); + BtlController_EmitLinkStandbyMsg(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, LINK_STANDBY_MSG_ONLY, FALSE); MarkBattlerForControllerExec(gActiveBattler); } } @@ -5310,7 +5310,7 @@ static void Cmd_trainerslidein(void) static void Cmd_playse(void) { gActiveBattler = gBattlerAttacker; - BtlController_EmitPlaySE(BUFFER_A, T2_READ_16(gBattlescriptCurrInstr + 1)); + BtlController_EmitPlaySE(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, T2_READ_16(gBattlescriptCurrInstr + 1)); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 3; @@ -5319,7 +5319,7 @@ static void Cmd_playse(void) static void Cmd_fanfare(void) { gActiveBattler = gBattlerAttacker; - BtlController_EmitPlayFanfareOrBGM(BUFFER_A, T2_READ_16(gBattlescriptCurrInstr + 1), FALSE); + BtlController_EmitPlayFanfareOrBGM(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, T2_READ_16(gBattlescriptCurrInstr + 1), FALSE); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 3; @@ -5337,7 +5337,7 @@ static void Cmd_playfaintcry(void) static void Cmd_endlinkbattle(void) { gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); - BtlController_EmitEndLinkBattle(BUFFER_A, gBattleOutcome); + BtlController_EmitEndLinkBattle(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattleOutcome); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 1; @@ -5346,7 +5346,7 @@ static void Cmd_endlinkbattle(void) static void Cmd_returntoball(void) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); - BtlController_EmitReturnMonToBall(BUFFER_A, TRUE); + BtlController_EmitReturnMonToBall(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, TRUE); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 2; @@ -5652,7 +5652,7 @@ static void Cmd_updatebattlermoves(void) switch (gBattleCommunication[0]) { case 0: - BtlController_EmitGetMonData(BUFFER_A, REQUEST_ALL_BATTLE, 0); + BtlController_EmitGetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_ALL_BATTLE, 0); MarkBattlerForControllerExec(gActiveBattler); gBattleCommunication[0]++; break; @@ -5725,7 +5725,7 @@ static void Cmd_drawpartystatussummary(void) } } - BtlController_EmitDrawPartyStatusSummary(BUFFER_A, hpStatuses, 1); + BtlController_EmitDrawPartyStatusSummary(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, hpStatuses, 1); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 2; @@ -5759,7 +5759,7 @@ static void Cmd_statusanimation(void) && gDisableStructs[gActiveBattler].substituteHP == 0 && !(gHitMarker & HITMARKER_NO_ANIMATIONS)) { - BtlController_EmitStatusAnimation(BUFFER_A, FALSE, gBattleMons[gActiveBattler].status1); + BtlController_EmitStatusAnimation(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, FALSE, gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); } gBattlescriptCurrInstr += 2; @@ -5778,7 +5778,7 @@ static void Cmd_status2animation(void) && gDisableStructs[gActiveBattler].substituteHP == 0 && !(gHitMarker & HITMARKER_NO_ANIMATIONS)) { - BtlController_EmitStatusAnimation(BUFFER_A, TRUE, gBattleMons[gActiveBattler].status2 & wantedToAnimate); + BtlController_EmitStatusAnimation(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, TRUE, gBattleMons[gActiveBattler].status2 & wantedToAnimate); MarkBattlerForControllerExec(gActiveBattler); } gBattlescriptCurrInstr += 6; @@ -5797,7 +5797,7 @@ static void Cmd_chosenstatusanimation(void) && gDisableStructs[gActiveBattler].substituteHP == 0 && !(gHitMarker & HITMARKER_NO_ANIMATIONS)) { - BtlController_EmitStatusAnimation(BUFFER_A, gBattlescriptCurrInstr[2], wantedStatus); + BtlController_EmitStatusAnimation(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattlescriptCurrInstr[2], wantedStatus); MarkBattlerForControllerExec(gActiveBattler); } gBattlescriptCurrInstr += 7; @@ -5908,7 +5908,7 @@ static void Cmd_removeitem(void) *usedHeldItem = gBattleMons[gActiveBattler].item; gBattleMons[gActiveBattler].item = ITEM_NONE; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].item), &gBattleMons[gActiveBattler].item); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].item), &gBattleMons[gActiveBattler].item); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 2; @@ -6217,7 +6217,7 @@ static void Cmd_setatktoplayer0(void) static void Cmd_makevisible(void) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); - BtlController_EmitSpriteInvisibility(BUFFER_A, FALSE); + BtlController_EmitSpriteInvisibility(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, FALSE); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 2; @@ -6456,7 +6456,7 @@ static void Cmd_various(void) gActiveBattler = 1; if (gBattleMons[gActiveBattler].hp != 0) { - BtlController_EmitReturnMonToBall(BUFFER_A, FALSE); + BtlController_EmitReturnMonToBall(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, FALSE); MarkBattlerForControllerExec(gActiveBattler); } break; @@ -6466,7 +6466,7 @@ static void Cmd_various(void) gActiveBattler = 3; if (gBattleMons[gActiveBattler].hp != 0) { - BtlController_EmitReturnMonToBall(BUFFER_A, FALSE); + BtlController_EmitReturnMonToBall(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, FALSE); MarkBattlerForControllerExec(gActiveBattler); } } @@ -6491,7 +6491,7 @@ static void Cmd_various(void) gBattleOutcome = B_OUTCOME_MON_TELEPORTED; break; case VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC: - BtlController_EmitPlayFanfareOrBGM(BUFFER_A, MUS_VICTORY_TRAINER, TRUE); + BtlController_EmitPlayFanfareOrBGM(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, MUS_VICTORY_TRAINER, TRUE); MarkBattlerForControllerExec(gActiveBattler); break; } @@ -6552,7 +6552,7 @@ static void Cmd_tryexplosion(void) // Success, no battlers with Damp. Drop user's HP bar to 0 gActiveBattler = gBattlerAttacker; gBattleMoveDamage = gBattleMons[gActiveBattler].hp; - BtlController_EmitHealthBarUpdate(BUFFER_A, INSTANT_HP_BAR_DROP); + BtlController_EmitHealthBarUpdate(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, INSTANT_HP_BAR_DROP); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr++; @@ -6581,7 +6581,7 @@ static void Cmd_setatkhptozero(void) gActiveBattler = gBattlerAttacker; gBattleMons[gActiveBattler].hp = 0; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_HP_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].hp), &gBattleMons[gActiveBattler].hp); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_HP_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].hp), &gBattleMons[gActiveBattler].hp); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr++; @@ -6777,7 +6777,7 @@ static void Cmd_trysetrest(void) gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_REST; gBattleMons[gBattlerTarget].status1 = STATUS1_SLEEP_TURN(3); - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].status1), &gBattleMons[gActiveBattler].status1); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].status1), &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 5; } @@ -7727,7 +7727,7 @@ static void Cmd_updatestatusicon(void) if (gBattlescriptCurrInstr[1] != BS_ATTACKER_WITH_PARTNER) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); - BtlController_EmitStatusIconUpdate(BUFFER_A, gBattleMons[gActiveBattler].status1, gBattleMons[gActiveBattler].status2); + BtlController_EmitStatusIconUpdate(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattleMons[gActiveBattler].status1, gBattleMons[gActiveBattler].status2); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 2; } @@ -7736,7 +7736,7 @@ static void Cmd_updatestatusicon(void) gActiveBattler = gBattlerAttacker; if (!(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { - BtlController_EmitStatusIconUpdate(BUFFER_A, gBattleMons[gActiveBattler].status1, gBattleMons[gActiveBattler].status2); + BtlController_EmitStatusIconUpdate(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattleMons[gActiveBattler].status1, gBattleMons[gActiveBattler].status2); MarkBattlerForControllerExec(gActiveBattler); } if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) @@ -7744,7 +7744,7 @@ static void Cmd_updatestatusicon(void) gActiveBattler = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker))); if (!(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { - BtlController_EmitStatusIconUpdate(BUFFER_A, gBattleMons[gActiveBattler].status1, gBattleMons[gActiveBattler].status2); + BtlController_EmitStatusIconUpdate(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, gBattleMons[gActiveBattler].status1, gBattleMons[gActiveBattler].status2); MarkBattlerForControllerExec(gActiveBattler); } } @@ -7822,7 +7822,7 @@ static void Cmd_transformdataexecution(void) } gActiveBattler = gBattlerAttacker; - BtlController_EmitResetActionMoveSelection(BUFFER_A, RESET_MOVE_SELECTION); + BtlController_EmitResetActionMoveSelection(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, RESET_MOVE_SELECTION); MarkBattlerForControllerExec(gActiveBattler); gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_TRANSFORMED; } @@ -8202,7 +8202,7 @@ static void Cmd_copymovepermanently(void) } movePpData.ppBonuses = gBattleMons[gBattlerAttacker].ppBonuses; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_MOVES_PP_BATTLE, 0, sizeof(movePpData), &movePpData); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_MOVES_PP_BATTLE, 0, sizeof(movePpData), &movePpData); MarkBattlerForControllerExec(gActiveBattler); PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastPrintedMoves[gBattlerTarget]) @@ -8370,7 +8370,7 @@ static void Cmd_tryspiteppreduce(void) if (!(gDisableStructs[gActiveBattler].mimickedMoves & gBitTable[i]) && !(gBattleMons[gActiveBattler].status2 & STATUS2_TRANSFORMED)) { - BtlController_EmitSetMonData(BUFFER_A, REQUEST_PPMOVE1_BATTLE + i, 0, sizeof(gBattleMons[gActiveBattler].pp[i]), &gBattleMons[gActiveBattler].pp[i]); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_PPMOVE1_BATTLE + i, 0, sizeof(gBattleMons[gActiveBattler].pp[i]), &gBattleMons[gActiveBattler].pp[i]); MarkBattlerForControllerExec(gActiveBattler); } @@ -8481,7 +8481,7 @@ static void Cmd_healpartystatus(void) if (toHeal) { gActiveBattler = gBattlerAttacker; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, toHeal, sizeof(zero), &zero); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, toHeal, sizeof(zero), &zero); MarkBattlerForControllerExec(gActiveBattler); } @@ -9106,7 +9106,7 @@ static void Cmd_trymemento(void) // Success, drop user's HP bar to 0 gActiveBattler = gBattlerAttacker; gBattleMoveDamage = gBattleMons[gActiveBattler].hp; - BtlController_EmitHealthBarUpdate(BUFFER_A, INSTANT_HP_BAR_DROP); + BtlController_EmitHealthBarUpdate(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, INSTANT_HP_BAR_DROP); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 5; } @@ -9146,7 +9146,7 @@ static void Cmd_cureifburnedparalysedorpoisoned(void) gBattleMons[gBattlerAttacker].status1 = 0; gBattlescriptCurrInstr += 5; gActiveBattler = gBattlerAttacker; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].status1), &gBattleMons[gActiveBattler].status1); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].status1), &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); } else @@ -9268,11 +9268,11 @@ static void Cmd_tryswapitems(void) gBattleMons[gBattlerTarget].item = oldItemAtk; gActiveBattler = gBattlerAttacker; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(*newItemAtk), newItemAtk); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_HELDITEM_BATTLE, 0, sizeof(*newItemAtk), newItemAtk); MarkBattlerForControllerExec(gBattlerAttacker); gActiveBattler = gBattlerTarget; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gBattlerTarget].item), &gBattleMons[gBattlerTarget].item); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gBattlerTarget].item), &gBattleMons[gBattlerTarget].item); MarkBattlerForControllerExec(gBattlerTarget); *(u8 *)((u8 *)(&gBattleStruct->choicedMove[gBattlerTarget]) + 0) = 0; @@ -9618,7 +9618,7 @@ static void Cmd_switchoutabilities(void) { case ABILITY_NATURAL_CURE: gBattleMons[gActiveBattler].status1 = 0; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, gBitTable[*(gBattleStruct->battlerPartyIndexes + gActiveBattler)], sizeof(gBattleMons[gActiveBattler].status1), &gBattleMons[gActiveBattler].status1); @@ -9758,7 +9758,7 @@ static void Cmd_docastformchangeanimation(void) if (gBattleMons[gActiveBattler].status2 & STATUS2_SUBSTITUTE) *(&gBattleStruct->formToChangeInto) |= CASTFORM_SUBSTITUTE; - BtlController_EmitBattleAnimation(BUFFER_A, B_ANIM_CASTFORM_CHANGE, gBattleStruct->formToChangeInto); + BtlController_EmitBattleAnimation(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, B_ANIM_CASTFORM_CHANGE, gBattleStruct->formToChangeInto); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr++; @@ -9840,7 +9840,7 @@ static void Cmd_tryrecycleitem(void) *usedHeldItem = ITEM_NONE; gBattleMons[gActiveBattler].item = gLastUsedItem; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].item), &gBattleMons[gActiveBattler].item); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].item), &gBattleMons[gActiveBattler].item); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 5; @@ -9937,13 +9937,13 @@ static void Cmd_handleballthrow(void) if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) { - BtlController_EmitBallThrowAnim(BUFFER_A, BALL_TRAINER_BLOCK); + BtlController_EmitBallThrowAnim(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, BALL_TRAINER_BLOCK); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr = BattleScript_TrainerBallBlock; } else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL) { - BtlController_EmitBallThrowAnim(BUFFER_A, BALL_3_SHAKES_SUCCESS); + BtlController_EmitBallThrowAnim(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, BALL_3_SHAKES_SUCCESS); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr = BattleScript_WallyBallThrow; } @@ -10031,7 +10031,7 @@ static void Cmd_handleballthrow(void) if (odds > 254) // mon caught { - BtlController_EmitBallThrowAnim(BUFFER_A, BALL_3_SHAKES_SUCCESS); + BtlController_EmitBallThrowAnim(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, BALL_3_SHAKES_SUCCESS); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); @@ -10053,7 +10053,7 @@ static void Cmd_handleballthrow(void) if (gLastUsedItem == ITEM_MASTER_BALL) shakes = BALL_3_SHAKES_SUCCESS; // why calculate the shakes before that check? - BtlController_EmitBallThrowAnim(BUFFER_A, shakes); + BtlController_EmitBallThrowAnim(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, shakes); MarkBattlerForControllerExec(gActiveBattler); if (shakes == BALL_3_SHAKES_SUCCESS) // mon caught, copy of the code above diff --git a/src/battle_util.c b/src/battle_util.c index 6e201a2956..46a2dba310 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -759,7 +759,7 @@ void PressurePPLose(u8 target, u8 attacker, u16 move) if (MOVE_IS_PERMANENT(attacker, moveIndex)) { gActiveBattler = attacker; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_PPMOVE1_BATTLE + moveIndex, 0, 1, &gBattleMons[gActiveBattler].pp[moveIndex]); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_PPMOVE1_BATTLE + moveIndex, 0, 1, &gBattleMons[gActiveBattler].pp[moveIndex]); MarkBattlerForControllerExec(gActiveBattler); } } @@ -791,7 +791,7 @@ void PressurePPLoseOnUsingImprison(u8 attacker) if (imprisonPos != MAX_MON_MOVES && MOVE_IS_PERMANENT(attacker, imprisonPos)) { gActiveBattler = attacker; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_PPMOVE1_BATTLE + imprisonPos, 0, 1, &gBattleMons[gActiveBattler].pp[imprisonPos]); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_PPMOVE1_BATTLE + imprisonPos, 0, 1, &gBattleMons[gActiveBattler].pp[imprisonPos]); MarkBattlerForControllerExec(gActiveBattler); } } @@ -822,7 +822,7 @@ void PressurePPLoseOnUsingPerishSong(u8 attacker) if (perishSongPos != MAX_MON_MOVES && MOVE_IS_PERMANENT(attacker, perishSongPos)) { gActiveBattler = attacker; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_PPMOVE1_BATTLE + perishSongPos, 0, 1, &gBattleMons[gActiveBattler].pp[perishSongPos]); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_PPMOVE1_BATTLE + perishSongPos, 0, 1, &gBattleMons[gActiveBattler].pp[perishSongPos]); MarkBattlerForControllerExec(gActiveBattler); } } @@ -893,7 +893,7 @@ bool8 WasUnableToUseMove(u8 battler) void PrepareStringBattle(u16 stringId, u8 battler) { gActiveBattler = battler; - BtlController_EmitPrintString(BUFFER_A, stringId); + BtlController_EmitPrintString(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, stringId); MarkBattlerForControllerExec(gActiveBattler); } @@ -1622,7 +1622,7 @@ u8 DoBattlerEndTurnEffects(void) gBattleCommunication[MULTISTRING_CHOOSER] = 1; BattleScriptExecute(BattleScript_MonWokeUpInUproar); gActiveBattler = gBattlerAttacker; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); break; } @@ -1747,7 +1747,7 @@ u8 DoBattlerEndTurnEffects(void) { CancelMultiTurnMoves(gActiveBattler); gBattleMons[gActiveBattler].status1 |= STATUS1_SLEEP_TURN((Random() & 3) + 2); // 2-5 turns of sleep - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); gEffectBattler = gActiveBattler; BattleScriptExecute(BattleScript_YawnMakesAsleep); @@ -2257,7 +2257,7 @@ u8 AtkCanceller_UnableToUseMove(void) if (effect == 2) { gActiveBattler = gBattlerAttacker; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); } return effect; @@ -2621,7 +2621,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gBattleMons[battler].status2 &= ~STATUS2_NIGHTMARE; // fix nightmare glitch gBattleScripting.battler = gActiveBattler = battler; BattleScriptPushCursorAndCallback(BattleScript_ShedSkinActivates); - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[battler].status1); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[battler].status1); MarkBattlerForControllerExec(gActiveBattler); effect++; } @@ -2933,7 +2933,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gBattlescriptCurrInstr = BattleScript_AbilityCuredStatus; gBattleScripting.battler = battler; gActiveBattler = battler; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); return effect; } @@ -3361,7 +3361,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) PREPARE_MOVE_BUFFER(gBattleTextBuff1, move); BattleScriptExecute(BattleScript_BerryPPHealEnd2); - BtlController_EmitSetMonData(BUFFER_A, i + REQUEST_PPMOVE1_BATTLE, 0, 1, &changedPP); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, i + REQUEST_PPMOVE1_BATTLE, 0, 1, &changedPP); MarkBattlerForControllerExec(gActiveBattler); effect = ITEM_PP_CHANGE; } @@ -3596,7 +3596,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) switch (effect) { case ITEM_STATUS_CHANGE: - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[battlerId].status1); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[battlerId].status1); MarkBattlerForControllerExec(gActiveBattler); break; case ITEM_PP_CHANGE: @@ -3747,7 +3747,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) gBattleScripting.battler = battlerId; gPotentialItemEffectBattler = battlerId; gActiveBattler = battlerId; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); break; } diff --git a/src/battle_util2.c b/src/battle_util2.c index 8ecb0a79b4..7ec395cd96 100644 --- a/src/battle_util2.c +++ b/src/battle_util2.c @@ -204,7 +204,7 @@ u32 BattlePalace_TryEscapeStatus(u8 battlerId) if (effect == 2) { gActiveBattler = battlerId; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + BtlController_EmitSetMonData(BATTLELINKMSGTYPE_ENGINE_TO_CONTROLLER, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); }