BUFFER_A/B -> BATTLELINKMSGTYPE; link send/recv. task data names

Replaced the BUFFER_A and BUFFER_B constants with the BATTLELINKMSGTYPE enum, which also identifies the "controller becoming idle" message type.

Named the task data for the link send task and the link receive task. Added macros to functions related to those tasks, for legibility.
This commit is contained in:
DavidJCobb
2025-04-26 00:13:42 -04:00
parent 66c07f9c33
commit 9dc48899d3
15 changed files with 325 additions and 268 deletions

View File

@@ -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();
}