Removed all instances of gBitTable[x] (#5123)

* Replaced all the gBitTable[X] usages with 1 << X, and cleaned up script output

* Fixed failed merge in online viewer

---------

Co-authored-by: Hedara <hedara90@gmail.com>
This commit is contained in:
hedara90 2024-08-17 17:28:09 +02:00 committed by GitHub
parent 15348eae84
commit e4c81ba6e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 362 additions and 399 deletions

View file

@ -42,7 +42,7 @@
// Used to exclude moves learned temporarily by Transform or Mimic
#define MOVE_IS_PERMANENT(battler, moveSlot) \
(!(gBattleMons[battler].status2 & STATUS2_TRANSFORMED) \
&& !(gDisableStructs[battler].mimickedMoves & gBitTable[moveSlot]))
&& !(gDisableStructs[battler].mimickedMoves & (1u << moveSlot)))
// Battle Actions
// These determine what each battler will do in a turn
@ -819,8 +819,8 @@ STATIC_ASSERT(sizeof(((struct BattleStruct *)0)->palaceFlags) * 8 >= MAX_BATTLER
#define IS_MOVE_RECOIL(move)(gMovesInfo[move].recoil > 0 || gMovesInfo[move].effect == EFFECT_RECOIL_IF_MISS)
#define BATTLER_MAX_HP(battlerId)(gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP)
#define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0) || (gBattleStruct->enduredDamage & gBitTable[gBattlerTarget]))
#define BATTLER_TURN_DAMAGED(battlerId) ((gSpecialStatuses[battlerId].physicalDmg != 0 || gSpecialStatuses[battlerId].specialDmg != 0) || (gBattleStruct->enduredDamage & gBitTable[battler]))
#define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0) || (gBattleStruct->enduredDamage & (1u << gBattlerTarget)))
#define BATTLER_TURN_DAMAGED(battlerId) ((gSpecialStatuses[battlerId].physicalDmg != 0 || gSpecialStatuses[battlerId].specialDmg != 0) || (gBattleStruct->enduredDamage & (1u << battler)))
#define IS_BATTLER_OF_TYPE(battlerId, type)((GetBattlerType(battlerId, 0, FALSE) == type || GetBattlerType(battlerId, 1, FALSE) == type || (GetBattlerType(battlerId, 2, FALSE) != TYPE_MYSTERY && GetBattlerType(battlerId, 2, FALSE) == type)))
#define IS_BATTLER_OF_BASE_TYPE(battlerId, type)((GetBattlerType(battlerId, 0, TRUE) == type || GetBattlerType(battlerId, 1, TRUE) == type || (GetBattlerType(battlerId, 2, TRUE) != TYPE_MYSTERY && GetBattlerType(battlerId, 2, TRUE) == type)))

View file

@ -137,7 +137,7 @@
#define STATUS2_WRAPPED (1 << 13)
#define STATUS2_POWDER (1 << 14)
#define STATUS2_INFATUATION (1 << 16 | 1 << 17 | 1 << 18 | 1 << 19) // 4 bits, one for every battler
#define STATUS2_INFATUATED_WITH(battler) (gBitTable[battler] << 16)
#define STATUS2_INFATUATED_WITH(battler) (1u << (battler + 16))
#define STATUS2_DEFENSE_CURL (1 << 20)
#define STATUS2_TRANSFORMED (1 << 21)
#define STATUS2_RECHARGE (1 << 22)
@ -217,8 +217,8 @@
#define HITMARKER_OBEYS (1 << 25)
#define HITMARKER_NEVER_SET (1 << 26) // Cleared as part of a large group. Never set or checked
#define HITMARKER_CHARGING (1 << 27)
#define HITMARKER_FAINTED(battler) (gBitTable[battler] << 28)
#define HITMARKER_FAINTED2(battler) ((1 << 28) << battler)
#define HITMARKER_FAINTED(battler) (1u << (battler + 28))
#define HITMARKER_FAINTED2(battler) HITMARKER_FAINTED(battler)
#define HITMARKER_STRING_PRINTED (1 << 29)
// Per-side statuses that affect an entire party

View file

@ -4,7 +4,6 @@
#include "sprite.h"
extern const u8 gMiscBlank_Gfx[]; // unused in Emerald
extern const u32 gBitTable[];
u8 CreateInvisibleSpriteWithCallback(void (*)(struct Sprite *));
void StoreWordInTwoHalfwords(u16 *, u32);

View file

@ -262,7 +262,7 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves, u32 battler)
// Ignore moves that aren't possible to use.
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (gBitTable[i] & moveLimitations)
if ((1u << i) & moveLimitations)
SET_SCORE(battler, i, 0);
}
@ -446,7 +446,7 @@ static void SetBattlerAiMovesData(struct AiLogicData *aiData, u32 battlerAtk, u3
if (move != 0
&& move != 0xFFFF
//&& gMovesInfo[move].power != 0 /* we want to get effectiveness and accuracy of status moves */
&& !(aiData->moveLimitations[battlerAtk] & gBitTable[i]))
&& !(aiData->moveLimitations[battlerAtk] & (1u << i)))
{
if (AI_THINKING_STRUCT->aiFlags[battlerAtk] & AI_FLAG_RISKY)
dmg = AI_CalcDamage(move, battlerAtk, battlerDef, &effectiveness, TRUE, weather, DMG_ROLL_HIGHEST);
@ -506,12 +506,12 @@ static bool32 AI_SwitchMonIfSuitable(u32 battler, bool32 doubleBattle)
if (doubleBattle)
{
u32 partner = BATTLE_PARTNER(battler);
if (AI_DATA->shouldSwitchMon & gBitTable[partner] && AI_DATA->monToSwitchId[partner] == monToSwitchId)
if (AI_DATA->shouldSwitchMon & (1u << partner) && AI_DATA->monToSwitchId[partner] == monToSwitchId)
{
return FALSE;
}
}
AI_DATA->shouldSwitchMon |= gBitTable[battler];
AI_DATA->shouldSwitchMon |= 1 << battler;
AI_DATA->monToSwitchId[battler] = monToSwitchId;
return TRUE;
}

View file

@ -40,7 +40,7 @@ static void InitializeSwitchinCandidate(struct Pokemon *mon)
static bool32 IsAceMon(u32 battler, u32 monPartyId)
{
if (AI_THINKING_STRUCT->aiFlags[battler] & AI_FLAG_ACE_POKEMON
&& !(gBattleStruct->forcedSwitch & gBitTable[battler])
&& !(gBattleStruct->forcedSwitch & (1u << battler))
&& monPartyId == CalculateEnemyPartyCount()-1)
return TRUE;
return FALSE;
@ -218,9 +218,9 @@ static bool32 HasBadOdds(u32 battler, bool32 emitResult)
static bool32 ShouldSwitchIfAllBadMoves(u32 battler, bool32 emitResult)
{
if (AI_DATA->shouldSwitchMon & gBitTable[battler])
if (AI_DATA->shouldSwitchMon & (1u << battler))
{
AI_DATA->shouldSwitchMon &= ~(gBitTable[battler]);
AI_DATA->shouldSwitchMon &= ~(1u << battler);
gBattleStruct->AI_monToSwitchIntoId[battler] = AI_DATA->monToSwitchId[battler];
if (emitResult)
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SWITCH, 0);
@ -321,7 +321,7 @@ static bool32 FindMonThatAbsorbsOpponentsMove(u32 battler, bool32 emitResult)
if (IsDoubleBattle())
{
battlerIn1 = battler;
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)))])
if (gAbsentBattlerFlags & (1u << GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)))))
battlerIn2 = battler;
else
battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)));
@ -690,7 +690,7 @@ static bool32 HasSuperEffectiveMoveAgainstOpponents(u32 battler, bool32 noRng)
u32 opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(battler));
u32 opposingBattler = GetBattlerAtPosition(opposingPosition);
if (!(gAbsentBattlerFlags & gBitTable[opposingBattler]))
if (!(gAbsentBattlerFlags & (1u << opposingBattler)))
{
for (i = 0; i < MAX_MON_MOVES; i++)
{
@ -712,7 +712,7 @@ static bool32 HasSuperEffectiveMoveAgainstOpponents(u32 battler, bool32 noRng)
opposingBattler = GetBattlerAtPosition(BATTLE_PARTNER(opposingPosition));
if (!(gAbsentBattlerFlags & gBitTable[opposingBattler]))
if (!(gAbsentBattlerFlags & (1u << opposingBattler)))
{
for (i = 0; i < MAX_MON_MOVES; i++)
{
@ -768,7 +768,7 @@ static bool32 FindMonWithFlagsAndSuperEffective(u32 battler, u16 flags, u32 modu
if (IsDoubleBattle())
{
battlerIn1 = battler;
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)))])
if (gAbsentBattlerFlags & (1u << GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)))))
battlerIn2 = battler;
else
battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)));
@ -849,7 +849,7 @@ static bool32 CanMonSurviveHazardSwitchin(u32 battler)
if (IsDoubleBattle())
{
battlerIn1 = battler;
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)))])
if (gAbsentBattlerFlags & (1u << GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)))))
battlerIn2 = battler;
else
battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)));
@ -1028,7 +1028,7 @@ bool32 ShouldSwitch(u32 battler, bool32 emitResult)
if (IsDoubleBattle())
{
battlerIn1 = battler;
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)))])
if (gAbsentBattlerFlags & (1u << GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)))))
battlerIn2 = battler;
else
battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)));
@ -1197,14 +1197,14 @@ static u32 GetBestMonBatonPass(struct Pokemon *party, int firstId, int lastId, u
for (i = firstId; i < lastId; i++)
{
if (invalidMons & gBitTable[i])
if (invalidMons & (1u << i))
continue;
for (j = 0; j < MAX_MON_MOVES; j++)
{
if (GetMonData(&party[i], MON_DATA_MOVE1 + j, NULL) == MOVE_BATON_PASS)
{
bits |= gBitTable[i];
bits |= 1u << i;
break;
}
}
@ -1215,7 +1215,7 @@ static u32 GetBestMonBatonPass(struct Pokemon *party, int firstId, int lastId, u
do
{
i = (Random() % (lastId - firstId)) + firstId;
} while (!(bits & gBitTable[i]));
} while (!(bits & (1 << i)));
return i;
}
@ -1233,7 +1233,7 @@ static u32 GetBestMonTypeMatchup(struct Pokemon *party, int firstId, int lastId,
// Find the mon whose type is the most suitable defensively.
for (i = firstId; i < lastId; i++)
{
if (!(gBitTable[i] & invalidMons) && !(gBitTable[i] & bits))
if (!((1u << i) & invalidMons) && !((1u << i) & bits))
{
u16 species = GetMonData(&party[i], MON_DATA_SPECIES);
uq4_12_t typeEffectiveness = UQ_4_12(1.0);
@ -1273,7 +1273,7 @@ static u32 GetBestMonTypeMatchup(struct Pokemon *party, int firstId, int lastId,
if (i != MAX_MON_MOVES)
return bestMonId; // Has both the typing and at least one super effective move.
bits |= gBitTable[bestMonId]; // Sorry buddy, we want something better.
bits |= (1u << bestMonId); // Sorry buddy, we want something better.
}
else
{
@ -1295,7 +1295,7 @@ static u32 GetBestMonDmg(struct Pokemon *party, int firstId, int lastId, u8 inva
// If we couldn't find the best mon in terms of typing, find the one that deals most damage.
for (i = firstId; i < lastId; i++)
{
if (gBitTable[i] & invalidMons)
if ((1 << (i)) & invalidMons)
continue;
InitializeSwitchinCandidate(&party[i]);
for (j = 0; j < MAX_MON_MOVES; j++)
@ -1735,7 +1735,7 @@ static int GetRandomSwitchinWithBatonPass(int aliveCount, int bits, int firstId,
do
{
return (Random() % (lastId - firstId)) + firstId;
} while (!(bits & gBitTable[currentMonId]));
} while (!(bits & (1 << (currentMonId))));
}
// Catch any other cases (such as only one mon alive and it has Baton Pass)
@ -1875,7 +1875,7 @@ static u32 GetBestMonIntegrated(struct Pokemon *party, int firstId, int lastId,
// Check for Baton Pass; hitsToKO requirements mean mon can boost and BP without dying whether it's slower or not
if (aiMove == MOVE_BATON_PASS && ((hitsToKOAI > hitsToKOAIThreshold + 1 && AI_DATA->switchinCandidate.battleMon.speed < playerMonSpeed) || (hitsToKOAI > hitsToKOAIThreshold && AI_DATA->switchinCandidate.battleMon.speed > playerMonSpeed)))
bits |= gBitTable[i];
bits |= 1u << i;
// Check for mon with resistance and super effective move for GetBestMonTypeMatchup
if (aiMove != MOVE_NONE && gMovesInfo[aiMove].power != 0)
@ -2045,13 +2045,13 @@ u32 GetMostSuitableMonToSwitchInto(u32 battler, bool32 switchAfterMonKOd)
if (IsDoubleBattle())
{
battlerIn1 = battler;
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)))])
if (gAbsentBattlerFlags & (1u << GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)))))
battlerIn2 = battler;
else
battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler)));
opposingBattler = BATTLE_OPPOSITE(battlerIn1);
if (gAbsentBattlerFlags & gBitTable[opposingBattler])
if (gAbsentBattlerFlags & (1u << opposingBattler))
opposingBattler ^= BIT_FLANK;
}
else
@ -2097,12 +2097,12 @@ u32 GetMostSuitableMonToSwitchInto(u32 battler, bool32 switchAfterMonKOd)
|| i == gBattleStruct->monToSwitchIntoId[battlerIn2]
|| (GetMonAbility(&party[i]) == ABILITY_TRUANT && IsTruantMonVulnerable(battler, opposingBattler))) // While not really invalid per se, not really wise to switch into this mon.)
{
invalidMons |= gBitTable[i];
invalidMons |= 1u << i;
}
else if (IsAceMon(battler, i))// Save Ace Pokemon for last.
{
aceMonId = i;
invalidMons |= gBitTable[i];
invalidMons |= 1u << i;
}
else
{

View file

@ -351,12 +351,12 @@ bool32 MovesWithCategoryUnusable(u32 attacker, u32 target, u32 category)
if (moves[i] != MOVE_NONE
&& moves[i] != MOVE_UNAVAILABLE
&& GetBattleMoveCategory(moves[i]) == category
&& !(unusable & gBitTable[i]))
&& !(unusable & (1u << i)))
{
SetTypeBeforeUsingMove(moves[i], attacker);
moveType = GetMoveType(moves[i]);
if (CalcTypeEffectivenessMultiplier(moves[i], moveType, attacker, target, AI_DATA->abilities[target], FALSE) != 0)
usable |= gBitTable[i];
usable |= 1u << i;
}
}
@ -1105,7 +1105,7 @@ bool32 CanTargetFaintAi(u32 battlerDef, u32 battlerAtk)
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i] != MOVE_NONE && moves[i] != MOVE_UNAVAILABLE && !(unusable & gBitTable[i])
if (moves[i] != MOVE_NONE && moves[i] != MOVE_UNAVAILABLE && !(unusable & (1u << i))
&& AI_DATA->simulatedDmg[battlerDef][battlerAtk][i].expected >= gBattleMons[battlerAtk].hp)
{
return TRUE;
@ -1143,7 +1143,7 @@ u32 GetBestDmgMoveFromBattler(u32 battlerAtk, u32 battlerDef)
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i] != MOVE_NONE && moves[i] != MOVE_UNAVAILABLE && !(unusable & gBitTable[i])
if (moves[i] != MOVE_NONE && moves[i] != MOVE_UNAVAILABLE && !(unusable & (1u << i))
&& bestDmg < AI_DATA->simulatedDmg[battlerAtk][battlerDef][i].expected)
{
bestDmg = AI_DATA->simulatedDmg[battlerAtk][battlerDef][i].expected;
@ -1164,7 +1164,7 @@ u32 GetBestDmgFromBattler(u32 battler, u32 battlerTarget)
{
if (moves[i] != MOVE_NONE
&& moves[i] != MOVE_UNAVAILABLE
&& !(unusable & gBitTable[i])
&& !(unusable & (1u << i))
&& bestDmg < AI_DATA->simulatedDmg[battler][battlerTarget][i].expected)
{
bestDmg = AI_DATA->simulatedDmg[battler][battlerTarget][i].expected;
@ -1184,7 +1184,7 @@ bool32 CanAIFaintTarget(u32 battlerAtk, u32 battlerDef, u32 numHits)
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i] != MOVE_NONE && moves[i] != MOVE_UNAVAILABLE && !(moveLimitations & gBitTable[i]))
if (moves[i] != MOVE_NONE && moves[i] != MOVE_UNAVAILABLE && !(moveLimitations & (1u << i)))
{
// Use the pre-calculated value in simulatedDmg instead of re-calculating it
dmg = AI_DATA->simulatedDmg[battlerAtk][battlerDef][i].expected;
@ -1229,7 +1229,7 @@ bool32 CanTargetFaintAiWithMod(u32 battlerDef, u32 battlerAtk, s32 hpMod, s32 dm
if (dmgMod)
dmg *= dmgMod;
if (moves[i] != MOVE_NONE && moves[i] != MOVE_UNAVAILABLE && !(unusable & gBitTable[i]) && dmg >= hpCheck)
if (moves[i] != MOVE_NONE && moves[i] != MOVE_UNAVAILABLE && !(unusable & (1u << i)) && dmg >= hpCheck)
{
return TRUE;
}
@ -2091,7 +2091,7 @@ bool32 HasMoveWithLowAccuracy(u32 battlerAtk, u32 battlerDef, u32 accCheck, bool
if (moves[i] == MOVE_NONE || moves[i] == MOVE_UNAVAILABLE)
continue;
if (!(gBitTable[i] & moveLimitations))
if (!((1u << i) & moveLimitations))
{
if (ignoreStatus && IS_MOVE_STATUS(moves[i]))
continue;
@ -2117,7 +2117,7 @@ bool32 HasSleepMoveWithLowAccuracy(u32 battlerAtk, u32 battlerDef)
{
if (moves[i] == MOVE_NONE)
break;
if (!(gBitTable[i] & moveLimitations))
if (!((1u << i) & moveLimitations))
{
if (gMovesInfo[moves[i]].effect == EFFECT_SLEEP
&& AI_DATA->moveAccuracy[battlerAtk][battlerDef][i] < 85)

View file

@ -386,9 +386,9 @@ void BattleArena_AddSkillPoints(u8 battler)
if (gHitMarker & HITMARKER_OBEYS)
{
u8 *failedMoveBits = &gBattleStruct->alreadyStatusedMoveAttempt;
if (*failedMoveBits & gBitTable[battler])
if (*failedMoveBits & (1u << battler))
{
*failedMoveBits &= ~(gBitTable[battler]);
*failedMoveBits &= ~((1u << battler));
skillPoints[battler] -= 2;
}
else if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT)

View file

@ -118,7 +118,7 @@ void SetControllerToLinkOpponent(u32 battler)
static void LinkOpponentBufferRunCommand(u32 battler)
{
if (gBattleControllerExecFlags & gBitTable[battler])
if (gBattleControllerExecFlags & (1u << battler))
{
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sLinkOpponentBufferCommands))
sLinkOpponentBufferCommands[gBattleResources->bufferA[battler][0]](battler);
@ -376,7 +376,7 @@ static void LinkOpponentBufferExecCompleted(u32 battler)
}
else
{
gBattleControllerExecFlags &= ~gBitTable[battler];
gBattleControllerExecFlags &= ~(1u << battler);
}
}

View file

@ -117,7 +117,7 @@ void SetControllerToLinkPartner(u32 battler)
static void LinkPartnerBufferRunCommand(u32 battler)
{
if (gBattleControllerExecFlags & gBitTable[battler])
if (gBattleControllerExecFlags & (1u << battler))
{
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sLinkPartnerBufferCommands))
sLinkPartnerBufferCommands[gBattleResources->bufferA[battler][0]](battler);
@ -202,7 +202,7 @@ static void LinkPartnerBufferExecCompleted(u32 battler)
}
else
{
gBattleControllerExecFlags &= ~gBitTable[battler];
gBattleControllerExecFlags &= ~(1u << battler);
}
}

View file

@ -132,7 +132,7 @@ void SetControllerToOpponent(u32 battler)
static void OpponentBufferRunCommand(u32 battler)
{
if (gBattleControllerExecFlags & gBitTable[battler])
if (gBattleControllerExecFlags & (1u << battler))
{
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sOpponentBufferCommands))
sOpponentBufferCommands[gBattleResources->bufferA[battler][0]](battler);
@ -390,7 +390,7 @@ static void OpponentBufferExecCompleted(u32 battler)
}
else
{
gBattleControllerExecFlags &= ~gBitTable[battler];
gBattleControllerExecFlags &= ~(1u << battler);
}
}
@ -549,7 +549,7 @@ static void OpponentHandleChooseMove(u32 battler)
if (GetBattlerMoveTargetType(battler, chosenMove) & MOVE_TARGET_BOTH)
{
gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
if (gAbsentBattlerFlags & gBitTable[gBattlerTarget])
if (gAbsentBattlerFlags & (1u << gBattlerTarget))
gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
}
// If opponent can and should use a gimmick (considering trainer data), do it

View file

@ -180,13 +180,13 @@ static void PlayerBufferExecCompleted(u32 battler)
}
else
{
gBattleControllerExecFlags &= ~gBitTable[battler];
gBattleControllerExecFlags &= ~(1u << battler);
}
}
static void PlayerBufferRunCommand(u32 battler)
{
if (gBattleControllerExecFlags & gBitTable[battler])
if (gBattleControllerExecFlags & (1u << battler))
{
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sPlayerBufferCommands))
sPlayerBufferCommands[gBattleResources->bufferA[battler][0]](battler);
@ -381,7 +381,7 @@ static void HandleInputChooseAction(u32 battler)
{
if (IsDoubleBattle()
&& GetBattlerPosition(battler) == B_POSITION_PLAYER_RIGHT
&& !(gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)])
&& !(gAbsentBattlerFlags & (1u << GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)))
&& !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
// Return item to bag if partner had selected one.
@ -507,7 +507,7 @@ void HandleInputChooseTarget(u32 battler)
break;
}
if (gAbsentBattlerFlags & gBitTable[gMultiUsePlayerCursor]
if (gAbsentBattlerFlags & (1u << gMultiUsePlayerCursor)
|| !CanTargetBattler(battler, gMultiUsePlayerCursor, move))
i = 0;
} while (i == 0);
@ -557,7 +557,7 @@ void HandleInputChooseTarget(u32 battler)
break;
}
if (gAbsentBattlerFlags & gBitTable[gMultiUsePlayerCursor]
if (gAbsentBattlerFlags & (1u << gMultiUsePlayerCursor)
|| !CanTargetBattler(battler, gMultiUsePlayerCursor, move))
i = 0;
} while (i == 0);
@ -753,7 +753,7 @@ void HandleInputChooseMove(u32 battler)
if (moveTarget & (MOVE_TARGET_USER | MOVE_TARGET_USER_OR_SELECTED))
gMultiUsePlayerCursor = battler;
else if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)])
else if (gAbsentBattlerFlags & (1u << GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)))
gMultiUsePlayerCursor = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
else
gMultiUsePlayerCursor = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
@ -994,10 +994,10 @@ void HandleMoveSwitching(u32 battler)
moveInfo->maxPp[gMoveSelectionCursor[battler]] = moveInfo->maxPp[gMultiUsePlayerCursor];
moveInfo->maxPp[gMultiUsePlayerCursor] = i;
if (gDisableStructs[battler].mimickedMoves & gBitTable[gMoveSelectionCursor[battler]])
if (gDisableStructs[battler].mimickedMoves & (1u << gMoveSelectionCursor[battler]))
{
gDisableStructs[battler].mimickedMoves &= (~gBitTable[gMoveSelectionCursor[battler]]);
gDisableStructs[battler].mimickedMoves |= gBitTable[gMultiUsePlayerCursor];
gDisableStructs[battler].mimickedMoves &= ~(1u << gMoveSelectionCursor[battler]);
gDisableStructs[battler].mimickedMoves |= 1u << gMultiUsePlayerCursor;
}
MoveSelectionDisplayMoveNames(battler);
@ -2109,7 +2109,7 @@ void PlayerHandleChooseMove(u32 battler)
gBattleStruct->gimmick.playerSelect = FALSE;
AssignUsableZMoves(battler, moveInfo->moves);
gBattleStruct->zmove.viable = (gBattleStruct->zmove.possibleZMoves[battler] & gBitTable[gMoveSelectionCursor[battler]]) != 0;
gBattleStruct->zmove.viable = (gBattleStruct->zmove.possibleZMoves[battler] & (1u << gMoveSelectionCursor[battler])) != 0;
if (!IsGimmickTriggerSpriteActive())
gBattleStruct->gimmick.triggerSpriteId = 0xFF;

View file

@ -121,7 +121,7 @@ void SetControllerToPlayerPartner(u32 battler)
static void PlayerPartnerBufferRunCommand(u32 battler)
{
if (gBattleControllerExecFlags & gBitTable[battler])
if (gBattleControllerExecFlags & (1u << battler))
{
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sPlayerPartnerBufferCommands))
sPlayerPartnerBufferCommands[gBattleResources->bufferA[battler][0]](battler);
@ -274,7 +274,7 @@ static void PlayerPartnerBufferExecCompleted(u32 battler)
}
else
{
gBattleControllerExecFlags &= ~gBitTable[battler];
gBattleControllerExecFlags &= ~(1u << battler);
}
}
@ -365,7 +365,7 @@ static void PlayerPartnerHandleChooseMove(u32 battler)
if (gMovesInfo[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH)
{
gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
if (gAbsentBattlerFlags & gBitTable[gBattlerTarget])
if (gAbsentBattlerFlags & (1u << gBattlerTarget))
gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
}
// If partner can and should use a gimmick (considering trainer data), do it

View file

@ -124,7 +124,7 @@ void SetControllerToRecordedOpponent(u32 battler)
static void RecordedOpponentBufferRunCommand(u32 battler)
{
if (gBattleControllerExecFlags & gBitTable[battler])
if (gBattleControllerExecFlags & (1u << battler))
{
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sRecordedOpponentBufferCommands))
sRecordedOpponentBufferCommands[gBattleResources->bufferA[battler][0]](battler);
@ -145,7 +145,7 @@ static void RecordedOpponentBufferExecCompleted(u32 battler)
}
else
{
gBattleControllerExecFlags &= ~gBitTable[battler];
gBattleControllerExecFlags &= ~(1u << battler);
}
}

View file

@ -121,7 +121,7 @@ void SetControllerToRecordedPlayer(u32 battler)
static void RecordedPlayerBufferRunCommand(u32 battler)
{
if (gBattleControllerExecFlags & gBitTable[battler])
if (gBattleControllerExecFlags & (1u << battler))
{
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sRecordedPlayerBufferCommands))
sRecordedPlayerBufferCommands[gBattleResources->bufferA[battler][0]](battler);
@ -351,7 +351,7 @@ static void RecordedPlayerBufferExecCompleted(u32 battler)
}
else
{
gBattleControllerExecFlags &= ~gBitTable[battler];
gBattleControllerExecFlags &= ~(1u << battler);
}
}

View file

@ -112,7 +112,7 @@ void SetControllerToSafari(u32 battler)
static void SafariBufferRunCommand(u32 battler)
{
if (gBattleControllerExecFlags & gBitTable[battler])
if (gBattleControllerExecFlags & (1u << battler))
{
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sSafariBufferCommands))
sSafariBufferCommands[gBattleResources->bufferA[battler][0]](battler);
@ -240,7 +240,7 @@ static void SafariBufferExecCompleted(u32 battler)
}
else
{
gBattleControllerExecFlags &= ~gBitTable[battler];
gBattleControllerExecFlags &= ~(1u << battler);
}
}

View file

@ -129,7 +129,7 @@ void SetControllerToWally(u32 battler)
static void WallyBufferRunCommand(u32 battler)
{
if (gBattleControllerExecFlags & gBitTable[battler])
if (gBattleControllerExecFlags & (1u << battler))
{
if (gBattleResources->bufferA[battler][0] < ARRAY_COUNT(sWallyBufferCommands))
sWallyBufferCommands[gBattleResources->bufferA[battler][0]](battler);
@ -288,7 +288,7 @@ static void WallyBufferExecCompleted(u32 battler)
}
else
{
gBattleControllerExecFlags &= ~gBitTable[battler];
gBattleControllerExecFlags &= ~(1u << battler);
}
}

View file

@ -851,7 +851,7 @@ void TryReceiveLinkBattleData(void)
DestroyTask_RfuIdle();
for (i = 0; i < GetLinkPlayerCount(); i++)
{
if (GetBlockReceivedStatus() & gBitTable[i])
if (GetBlockReceivedStatus() & (1 << (i)))
{
ResetBlockReceivedFlag(i);
recvBuffer = (u8 *)gBlockRecvBuffer[i];
@ -898,7 +898,7 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId)
switch (gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 0])
{
case 0:
if (gBattleControllerExecFlags & gBitTable[battler])
if (gBattleControllerExecFlags & (1u << battler))
return;
memcpy(gBattleResources->bufferA[battler], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA], blockSize);
@ -917,7 +917,7 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId)
break;
case 2:
var = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA];
gBattleControllerExecFlags &= ~(gBitTable[battler] << (var * 4));
gBattleControllerExecFlags &= ~(1u << (battler + var * 4));
break;
}

View file

@ -2030,8 +2030,8 @@ static void InitDomeTrainers(void)
rankingScores[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_SPDEF, NULL);
rankingScores[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_SPEED, NULL);
rankingScores[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_MAX_HP, NULL);
monTypesBits |= gBitTable[gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[0]];
monTypesBits |= gBitTable[gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[1]];
monTypesBits |= 1u << gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[0];
monTypesBits |= 1u << gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[1];
}
// Count the number of types in the players party, to factor into the ranking
@ -2062,8 +2062,8 @@ static void InitDomeTrainers(void)
rankingScores[i] += statValues[STAT_SPDEF];
rankingScores[i] += statValues[STAT_SPEED];
rankingScores[i] += statValues[STAT_HP];
monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[0]];
monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[1]];
monTypesBits |= 1u << gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[0];
monTypesBits |= 1u << gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[1];
}
for (monTypesCount = 0, j = 0; j < 32; j++)
@ -2344,9 +2344,9 @@ static int SelectOpponentMonsFromParty(int *partyMovePoints, bool8 allowRandom)
while (i != DOME_BATTLE_PARTY_SIZE)
{
u32 rand = Random() & FRONTIER_PARTY_SIZE;
if (rand != FRONTIER_PARTY_SIZE && !(selectedMonBits & gBitTable[rand]))
if (rand != FRONTIER_PARTY_SIZE && !(selectedMonBits & (1u << rand)))
{
selectedMonBits |= gBitTable[rand];
selectedMonBits |= 1u << rand;
i++;
}
}
@ -2376,7 +2376,7 @@ static int SelectOpponentMonsFromParty(int *partyMovePoints, bool8 allowRandom)
for (i = 0; i < DOME_BATTLE_PARTY_SIZE; i++)
{
selectedMonBits |= gBitTable[partyPositions[i]];
selectedMonBits |= 1u << partyPositions[i];
}
}
@ -5802,8 +5802,8 @@ static void InitRandomTourneyTreeResults(void)
statSums[i] += statValues[STAT_SPDEF];
statSums[i] += statValues[STAT_SPEED];
statSums[i] += statValues[STAT_HP];
monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[0]];
monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[1]];
monTypesBits |= 1u << gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[0];
monTypesBits |= 1u << gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[1];
}
// Because GF hates temporary vars, trainerId acts like monTypesCount here.

View file

@ -126,7 +126,7 @@ u16 ChooseMoveAndTargetInBattlePalace(u32 battler)
// If battler is < 50% HP and not asleep, use second set of move group likelihoods
// otherwise use first set
i = (gBattleStruct->palaceFlags & gBitTable[battler]) ? 2 : 0;
i = (gBattleStruct->palaceFlags & (1u << battler)) ? 2 : 0;
minGroupNum = i;
maxGroupNum = i + 2; // + 2 because there are two percentages per set of likelihoods
@ -150,7 +150,7 @@ u16 ChooseMoveAndTargetInBattlePalace(u32 battler)
if (moveInfo->moves[i] == MOVE_NONE)
break;
if (selectedGroup == GetBattlePalaceMoveGroup(battler, moveInfo->moves[i]) && moveInfo->currentPp[i] != 0)
selectedMoves |= gBitTable[i];
selectedMoves |= 1u << i;
}
// Pass selected moves to AI, pick one
@ -178,11 +178,11 @@ u16 ChooseMoveAndTargetInBattlePalace(u32 battler)
{
// Count the number of usable moves the battler has in each move group.
// The totals will be stored separately in 3 groups of 4 bits each in numMovesPerGroup.
if (GetBattlePalaceMoveGroup(battler, moveInfo->moves[i]) == PALACE_MOVE_GROUP_ATTACK && !(gBitTable[i] & unusableMovesBits))
if (GetBattlePalaceMoveGroup(battler, moveInfo->moves[i]) == PALACE_MOVE_GROUP_ATTACK && !((1u << i) & unusableMovesBits))
numMovesPerGroup += (1 << 0);
if (GetBattlePalaceMoveGroup(battler, moveInfo->moves[i]) == PALACE_MOVE_GROUP_DEFENSE && !(gBitTable[i] & unusableMovesBits))
if (GetBattlePalaceMoveGroup(battler, moveInfo->moves[i]) == PALACE_MOVE_GROUP_DEFENSE && !((1u << i) & unusableMovesBits))
numMovesPerGroup += (1 << 4);
if (GetBattlePalaceMoveGroup(battler, moveInfo->moves[i]) == PALACE_MOVE_GROUP_SUPPORT && !(gBitTable[i] & unusableMovesBits))
if (GetBattlePalaceMoveGroup(battler, moveInfo->moves[i]) == PALACE_MOVE_GROUP_SUPPORT && !((1u << i) & unusableMovesBits))
numMovesPerGroup += (1 << 8);
}
@ -215,7 +215,7 @@ u16 ChooseMoveAndTargetInBattlePalace(u32 battler)
do
{
i = Random() % MAX_MON_MOVES;
if (!(gBitTable[i] & unusableMovesBits))
if (!((1u << i) & unusableMovesBits))
chosenMoveId = i;
} while (chosenMoveId == -1);
}
@ -241,7 +241,7 @@ u16 ChooseMoveAndTargetInBattlePalace(u32 battler)
do
{
i = Random() % MAX_MON_MOVES;
if (!(gBitTable[i] & unusableMovesBits) && randSelectGroup == GetBattlePalaceMoveGroup(battler, moveInfo->moves[i]))
if (!((1u << i) & unusableMovesBits) && randSelectGroup == GetBattlePalaceMoveGroup(battler, moveInfo->moves[i]))
chosenMoveId = i;
} while (chosenMoveId == -1);
}

View file

@ -45,7 +45,7 @@ bool32 IsGimmickSelected(u32 battler, enum Gimmick gimmick)
{
// There's no player select in tests, but some gimmicks need to test choice before they are fully activated.
if (TESTING)
return (gBattleStruct->gimmick.toActivate & gBitTable[battler]) && gBattleStruct->gimmick.usableGimmick[battler] == gimmick;
return (gBattleStruct->gimmick.toActivate & (1u << battler)) && gBattleStruct->gimmick.usableGimmick[battler] == gimmick;
else
return gBattleStruct->gimmick.usableGimmick[battler] == gimmick && gBattleStruct->gimmick.playerSelect;
}
@ -99,7 +99,7 @@ bool32 HasTrainerUsedGimmick(u32 battler, enum Gimmick gimmick)
if (IsDoubleBattle()
&& IsPartnerMonFromSameTrainer(battler)
&& (gBattleStruct->gimmick.activated[BATTLE_PARTNER(battler)][gimmick]
|| ((gBattleStruct->gimmick.toActivate & gBitTable[BATTLE_PARTNER(battler)]
|| ((gBattleStruct->gimmick.toActivate & (1u << BATTLE_PARTNER(battler))
&& gBattleStruct->gimmick.usableGimmick[BATTLE_PARTNER(battler)] == gimmick))))
{
return TRUE;

View file

@ -1377,7 +1377,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
// fainted mon
gSprites[ballIconSpritesIds[i]].oam.tileNum += 3;
}
else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->arenaLostPlayerMons & gBitTable[j])
else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->arenaLostPlayerMons & (1u << j))
{
// fainted arena mon
gSprites[ballIconSpritesIds[i]].oam.tileNum += 3;
@ -1433,7 +1433,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
// fainted mon
gSprites[ballIconSpritesIds[PARTY_SIZE - 1 - var]].oam.tileNum += 3;
}
else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->arenaLostOpponentMons & gBitTable[j])
else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->arenaLostOpponentMons & (1u << j))
{
// fainted arena mon
gSprites[ballIconSpritesIds[PARTY_SIZE - 1 - var]].oam.tileNum += 3;
@ -2718,7 +2718,7 @@ void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle)
LoadSpriteSheet(&sSpriteSheet_AbilityPopUp);
LoadSpritePalette(&sSpritePalette_AbilityPopUp);
}
gBattleStruct->activeAbilityPopUps |= gBitTable[battlerId];
gBattleStruct->activeAbilityPopUps |= 1u << battlerId;
battlerPosition = GetBattlerPosition(battlerId);
if (isDoubleBattle)
@ -2809,7 +2809,7 @@ static void SpriteCb_AbilityPopUp(struct Sprite *sprite)
||(sprite->tRightToLeft && (sprite->x -= 4) <= sprite->tOriginalX - ABILITY_POP_UP_POS_X_SLIDE)
)
{
gBattleStruct->activeAbilityPopUps &= ~(gBitTable[sprite->tBattlerId]);
gBattleStruct->activeAbilityPopUps &= ~(1u << sprite->tBattlerId);
DestroySprite(sprite);
}
}
@ -2823,7 +2823,7 @@ static void SpriteCb_AbilityPopUp(struct Sprite *sprite)
void DestroyAbilityPopUp(u8 battlerId)
{
if (gBattleStruct->activeAbilityPopUps & gBitTable[battlerId])
if (gBattleStruct->activeAbilityPopUps & (1u << battlerId))
{
gSprites[gBattleStruct->abilityPopUpSpriteIds[battlerId][0]].tFrames = 0;
gSprites[gBattleStruct->abilityPopUpSpriteIds[battlerId][1]].tFrames = 0;

View file

@ -3218,9 +3218,9 @@ void SwitchInClearSetData(u32 battler)
gBattleStruct->lastTakenMoveFrom[battler][1] = 0;
gBattleStruct->lastTakenMoveFrom[battler][2] = 0;
gBattleStruct->lastTakenMoveFrom[battler][3] = 0;
gBattleStruct->lastMoveFailed &= ~(gBitTable[battler]);
gBattleStruct->palaceFlags &= ~(gBitTable[battler]);
gBattleStruct->boosterEnergyActivates &= ~(gBitTable[battler]);
gBattleStruct->lastMoveFailed &= ~(1u << battler);
gBattleStruct->palaceFlags &= ~(1u << battler);
gBattleStruct->boosterEnergyActivates &= ~(1u << battler);
for (i = 0; i < ARRAY_COUNT(gSideTimers); i++)
{
@ -3245,7 +3245,7 @@ void SwitchInClearSetData(u32 battler)
// Reset damage to prevent things like red card activating if the switched-in mon is holding it
gSpecialStatuses[battler].physicalDmg = 0;
gSpecialStatuses[battler].specialDmg = 0;
gBattleStruct->enduredDamage &= ~gBitTable[battler];
gBattleStruct->enduredDamage &= ~(1u << battler);
// Reset G-Max Chi Strike boosts.
gBattleStruct->bonusCritStages[battler] = 0;
@ -3348,8 +3348,8 @@ const u8* FaintClearSetData(u32 battler)
gBattleStruct->lastTakenMoveFrom[battler][2] = 0;
gBattleStruct->lastTakenMoveFrom[battler][3] = 0;
gBattleStruct->palaceFlags &= ~(gBitTable[battler]);
gBattleStruct->boosterEnergyActivates &= ~(gBitTable[battler]);
gBattleStruct->palaceFlags &= ~(1u << battler);
gBattleStruct->boosterEnergyActivates &= ~(1u << battler);
for (i = 0; i < ARRAY_COUNT(gSideTimers); i++)
{
@ -3790,7 +3790,7 @@ static void TryDoEventsBeforeFirstTurn(void)
struct Pokemon *party = GetBattlerParty(i);
struct Pokemon *mon = &party[gBattlerPartyIndexes[i]];
if (!IsBattlerAlive(i) || gBattleMons[i].species == SPECIES_NONE || GetMonData(mon, MON_DATA_IS_EGG))
gAbsentBattlerFlags |= gBitTable[i];
gAbsentBattlerFlags |= 1u << i;
}
}
@ -3923,7 +3923,7 @@ static void TryDoEventsBeforeFirstTurn(void)
gBattleMons[i].status2 &= ~STATUS2_FLINCHED;
// Record party slots of player's mons that appeared in battle
if (!BattlerHasAi(i))
gBattleStruct->appearedInBattle |= gBitTable[gBattlerPartyIndexes[i]];
gBattleStruct->appearedInBattle |= 1u << gBattlerPartyIndexes[i];
}
*(&gBattleStruct->turnEffectsTracker) = 0;
@ -4195,10 +4195,10 @@ static void HandleTurnActionSelectionState(void)
*(gBattleStruct->monToSwitchIntoId + battler) = PARTY_SIZE;
if (gBattleTypeFlags & BATTLE_TYPE_MULTI
|| (position & BIT_FLANK) == B_FLANK_LEFT
|| gBattleStruct->absentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(position))]
|| gBattleStruct->absentBattlerFlags & (1u << GetBattlerAtPosition(BATTLE_PARTNER(position)))
|| gBattleCommunication[GetBattlerAtPosition(BATTLE_PARTNER(position))] == STATE_WAIT_ACTION_CONFIRMED)
{
if (gBattleStruct->absentBattlerFlags & gBitTable[battler])
if (gBattleStruct->absentBattlerFlags & (1u << battler))
{
gChosenActionByBattler[battler] = B_ACTION_NOTHING_FAINTED;
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI))
@ -4234,7 +4234,7 @@ static void HandleTurnActionSelectionState(void)
}
break;
case STATE_WAIT_ACTION_CHOSEN: // Try to perform an action.
if (!(gBattleControllerExecFlags & ((gBitTable[battler]) | (0xF << 28) | (gBitTable[battler] << 4) | (gBitTable[battler] << 8) | (gBitTable[battler] << 12))))
if (!(gBattleControllerExecFlags & (((1u << battler)) | (0xF << 28) | ((1u << battler) << 4) | ((1u << battler) << 8) | ((1u << battler) << 12))))
{
RecordedBattle_SetBattlerAction(battler, gBattleResources->bufferB[battler][1]);
gChosenActionByBattler[battler] = gBattleResources->bufferB[battler][1];
@ -4386,7 +4386,7 @@ static void HandleTurnActionSelectionState(void)
RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battler))), 3);
}
gBattleStruct->gimmick.toActivate &= ~(gBitTable[BATTLE_PARTNER(GetBattlerPosition(battler))]);
gBattleStruct->gimmick.toActivate &= ~((1u << BATTLE_PARTNER(GetBattlerPosition(battler))));
BtlController_EmitEndBounceEffect(battler, BUFFER_A);
MarkBattlerForControllerExec(battler);
return;
@ -4429,7 +4429,7 @@ static void HandleTurnActionSelectionState(void)
}
break;
case STATE_WAIT_ACTION_CASE_CHOSEN:
if (!(gBattleControllerExecFlags & ((gBitTable[battler]) | (0xF << 28) | (gBitTable[battler] << 4) | (gBitTable[battler] << 8) | (gBitTable[battler] << 12))))
if (!(gBattleControllerExecFlags & (((1u << battler)) | (0xF << 28) | ((1u << battler) << 4) | ((1u << battler) << 8) | ((1u << battler) << 12))))
{
switch (gChosenActionByBattler[battler])
{
@ -4480,7 +4480,7 @@ static void HandleTurnActionSelectionState(void)
// Check to see if any gimmicks need to be prepared.
if (gBattleResources->bufferB[battler][2] & RET_GIMMICK)
gBattleStruct->gimmick.toActivate |= gBitTable[battler];
gBattleStruct->gimmick.toActivate |= 1u << battler;
// Max Move check
if (GetActiveGimmick(battler) == GIMMICK_DYNAMAX || IsGimmickSelected(battler, GIMMICK_DYNAMAX))
@ -4559,11 +4559,11 @@ static void HandleTurnActionSelectionState(void)
}
break;
case STATE_WAIT_ACTION_CONFIRMED_STANDBY:
if (!(gBattleControllerExecFlags & ((gBitTable[battler])
if (!(gBattleControllerExecFlags & ((1u << battler)
| (0xF << 28)
| (gBitTable[battler] << 4)
| (gBitTable[battler] << 8)
| (gBitTable[battler] << 12))))
| (1u << (battler + 4))
| (1u << (battler + 8))
| (1u << (battler + 12)))))
{
if (AllAtActionConfirmed())
i = TRUE;
@ -4572,7 +4572,7 @@ static void HandleTurnActionSelectionState(void)
if (((gBattleTypeFlags & BATTLE_TYPE_MULTI) || !IsDoubleBattle())
|| (position & BIT_FLANK) != B_FLANK_LEFT
|| (*(&gBattleStruct->absentBattlerFlags) & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(position))]))
|| (*(&gBattleStruct->absentBattlerFlags) & (1u << GetBattlerAtPosition(BATTLE_PARTNER(position)))))
{
BtlController_EmitLinkStandbyMsg(battler, BUFFER_A, LINK_STANDBY_MSG_STOP_BOUNCE, i);
}
@ -4585,7 +4585,7 @@ static void HandleTurnActionSelectionState(void)
}
break;
case STATE_WAIT_ACTION_CONFIRMED:
if (!(gBattleControllerExecFlags & ((gBitTable[battler]) | (0xF << 28) | (gBitTable[battler] << 4) | (gBitTable[battler] << 8) | (gBitTable[battler] << 12))))
if (!(gBattleControllerExecFlags & ((1u << battler) | (0xF << 28) | (1u << (battler + 4)) | (1u << (battler + 8)) | (1u << (battler + 12)))))
{
gBattleCommunication[ACTIONS_CONFIRMED_COUNT]++;
}
@ -4599,7 +4599,7 @@ static void HandleTurnActionSelectionState(void)
{
gBattlerAttacker = battler;
gBattlescriptCurrInstr = gSelectionBattleScripts[battler];
if (!(gBattleControllerExecFlags & ((gBitTable[battler]) | (0xF << 28) | (gBitTable[battler] << 4) | (gBitTable[battler] << 8) | (gBitTable[battler] << 12))))
if (!(gBattleControllerExecFlags & ((1u << battler) | (0xF << 28) | (1u << (battler + 4)) | (1u << (battler + 8)) | (1u << (battler + 12)))))
{
gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]]();
}
@ -4607,7 +4607,7 @@ static void HandleTurnActionSelectionState(void)
}
break;
case STATE_WAIT_SET_BEFORE_ACTION:
if (!(gBattleControllerExecFlags & ((gBitTable[battler]) | (0xF << 28) | (gBitTable[battler] << 4) | (gBitTable[battler] << 8) | (gBitTable[battler] << 12))))
if (!(gBattleControllerExecFlags & ((1u << battler) | (0xF << 28) | (1u << (battler + 4)) | (1u << (battler + 8)) | (1u << (battler + 12)))))
{
gBattleCommunication[battler] = STATE_BEFORE_ACTION_CHOSEN;
}
@ -4631,7 +4631,7 @@ static void HandleTurnActionSelectionState(void)
{
gBattlerAttacker = battler;
gBattlescriptCurrInstr = gSelectionBattleScripts[battler];
if (!(gBattleControllerExecFlags & ((gBitTable[battler]) | (0xF << 28) | (gBitTable[battler] << 4) | (gBitTable[battler] << 8) | (gBitTable[battler] << 12))))
if (!(gBattleControllerExecFlags & ((1u << battler) | (0xF << 28) | (1u << (battler + 4)) | (1u << (battler + 8)) | (1u << (battler + 12)))))
{
gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]]();
}
@ -5154,10 +5154,10 @@ static bool32 TryDoGimmicksBeforeMoves(void)
for (i = 0; i < gBattlersCount; i++)
{
// Search through each battler and activate their gimmick if they have one prepared.
if ((gBattleStruct->gimmick.toActivate & gBitTable[order[i]]) && !(gProtectStructs[order[i]].noValidMoves))
if ((gBattleStruct->gimmick.toActivate & (1u << order[i])) && !(gProtectStructs[order[i]].noValidMoves))
{
battler = gBattlerAttacker = gBattleScripting.battler = order[i];
gBattleStruct->gimmick.toActivate &= ~(gBitTable[battler]);
gBattleStruct->gimmick.toActivate &= ~(1u << battler);
if (gGimmicksInfo[gBattleStruct->gimmick.usableGimmick[battler]].ActivateGimmick != NULL)
{
gGimmicksInfo[gBattleStruct->gimmick.usableGimmick[battler]].ActivateGimmick(battler);
@ -5183,12 +5183,12 @@ static bool32 TryDoMoveEffectsBeforeMoves(void)
SortBattlersBySpeed(battlers, FALSE);
for (i = 0; i < gBattlersCount; i++)
{
if (!(gBattleStruct->focusPunchBattlers & gBitTable[battlers[i]])
if (!(gBattleStruct->focusPunchBattlers & (1u << battlers[i]))
&& !(gBattleMons[battlers[i]].status1 & STATUS1_SLEEP)
&& !(gDisableStructs[battlers[i]].truantCounter)
&& !(gProtectStructs[battlers[i]].noValidMoves))
{
gBattleStruct->focusPunchBattlers |= gBitTable[battlers[i]];
gBattleStruct->focusPunchBattlers |= 1u << battlers[i];
gBattlerAttacker = battlers[i];
switch (gChosenMoveByBattler[gBattlerAttacker])
{
@ -5560,7 +5560,7 @@ static void HandleEndTurn_FinishBattle(void)
bool8 changedForm = FALSE;
// Appeared in battle and didn't faint
if ((gBattleStruct->appearedInBattle & gBitTable[i]) && GetMonData(&gPlayerParty[i], MON_DATA_HP, NULL) != 0)
if ((gBattleStruct->appearedInBattle & (1u << i)) && GetMonData(&gPlayerParty[i], MON_DATA_HP, NULL) != 0)
changedForm = TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_END_BATTLE_TERRAIN);
if (!changedForm)
@ -5635,15 +5635,15 @@ static void TryEvolvePokemon(void)
for (i = 0; i < PARTY_SIZE; i++)
{
if (!(sTriedEvolving & gBitTable[i]))
if (!(sTriedEvolving & (1u << i)))
{
u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i, NULL);
bool32 evoModeNormal = TRUE;
sTriedEvolving |= gBitTable[i];
sTriedEvolving |= 1u << i;
if (species == SPECIES_NONE && (gLeveledUpInBattle & gBitTable[i]))
if (species == SPECIES_NONE && (gLeveledUpInBattle & (1u << i)))
{
gLeveledUpInBattle &= ~(gBitTable[i]);
gLeveledUpInBattle &= ~(1u << i);
species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_ONLY, gLeveledUpInBattle, NULL);
}

View file

@ -1081,7 +1081,7 @@ static void ShowPostBattleHintText(void)
textIndex = sPyramidFloorTemplates[id].numTrainers;
for (i = 0; i < MAX_PYRAMID_TRAINERS; i++)
{
if (gBitTable[i] & gSaveBlock2Ptr->frontier.pyramidTrainerFlags)
if ((1u << i) & gSaveBlock2Ptr->frontier.pyramidTrainerFlags)
textIndex--;
}
i = 1;
@ -1317,7 +1317,7 @@ u16 LocalIdToPyramidTrainerId(u8 localId)
bool8 GetBattlePyramidTrainerFlag(u8 eventId)
{
return gSaveBlock2Ptr->frontier.pyramidTrainerFlags & gBitTable[gObjectEvents[eventId].localId - 1];
return gSaveBlock2Ptr->frontier.pyramidTrainerFlags & ((1u << gObjectEvents[eventId].localId) - 1);
}
void MarkApproachingPyramidTrainersAsBattled(void)
@ -1337,7 +1337,7 @@ static void MarkPyramidTrainerAsBattled(u16 trainerId)
for (i = 0; i < MAX_PYRAMID_TRAINERS; i++)
{
if (gSaveBlock2Ptr->frontier.trainerIds[i] == trainerId)
gSaveBlock2Ptr->frontier.pyramidTrainerFlags |= gBitTable[i];
gSaveBlock2Ptr->frontier.pyramidTrainerFlags |= 1u << i;
}
gObjectEvents[gSelectedObjectEvent].movementType = MOVEMENT_TYPE_WANDER_AROUND;
@ -1893,12 +1893,12 @@ static void SetPyramidObjectPositionsUniformly(u8 objType)
{
if (bits & 1)
{
if (!(gBitTable[squareId] & gSaveBlock2Ptr->frontier.pyramidRandoms[3]))
if (!((1u << squareId) & gSaveBlock2Ptr->frontier.pyramidRandoms[3]))
bits |= 2;
}
else
{
if (gBitTable[squareId] & gSaveBlock2Ptr->frontier.pyramidRandoms[3])
if ((1u << squareId) & gSaveBlock2Ptr->frontier.pyramidRandoms[3])
bits |= 2;
}
if (++squareId >= NUM_PYRAMID_FLOOR_SQUARES)

View file

@ -1173,7 +1173,7 @@ bool32 ProteanTryChangeType(u32 battler, u32 ability, u32 move, u32 moveType)
bool32 ShouldTeraShellDistortTypeMatchups(u32 move, u32 battlerDef)
{
if (!(gBattleStruct->distortedTypeMatchups & gBitTable[battlerDef])
if (!(gBattleStruct->distortedTypeMatchups & (1u << battlerDef))
&& GetBattlerAbility(battlerDef) == ABILITY_TERA_SHELL
&& gBattleMons[battlerDef].species == SPECIES_TERAPAGOS_TERASTAL
&& !IS_MOVE_STATUS(move)
@ -1242,7 +1242,7 @@ static void Cmd_attackcanceler(void)
if (gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_OFF
&& GetBattlerAbility(gBattlerAttacker) == ABILITY_PARENTAL_BOND
&& IsMoveAffectedByParentalBond(gCurrentMove, gBattlerAttacker)
&& !(gAbsentBattlerFlags & gBitTable[gBattlerTarget])
&& !(gAbsentBattlerFlags & (1u << gBattlerTarget))
&& GetActiveGimmick(gBattlerAttacker) != GIMMICK_Z_MOVE)
{
gSpecialStatuses[gBattlerAttacker].parentalBondState = PARENTAL_BOND_1ST_HIT;
@ -1847,7 +1847,7 @@ static void Cmd_ppreduce(void)
if (ShouldTeraShellDistortTypeMatchups(gCurrentMove, gBattlerTarget))
{
gBattleStruct->distortedTypeMatchups |= gBitTable[gBattlerTarget];
gBattleStruct->distortedTypeMatchups |= 1u << gBattlerTarget;
gBattlerAbility = gBattlerTarget;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_TeraShellDistortingTypeMatchups;
@ -1987,7 +1987,7 @@ static void Cmd_adjustdamage(void)
goto END;
if (DoesDisguiseBlockMove(gBattlerTarget, gCurrentMove))
{
gBattleStruct->enduredDamage |= gBitTable[gBattlerTarget];
gBattleStruct->enduredDamage |= 1u << gBattlerTarget;
goto END;
}
if (GetBattlerAbility(gBattlerTarget) == ABILITY_ICE_FACE && IS_MOVE_PHYSICAL(gCurrentMove) && gBattleMons[gBattlerTarget].species == SPECIES_EISCUE)
@ -2041,7 +2041,7 @@ static void Cmd_adjustdamage(void)
// Handle reducing the dmg to 1 hp.
gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1;
gBattleStruct->enduredDamage |= gBitTable[gBattlerTarget];
gBattleStruct->enduredDamage |= 1u << gBattlerTarget;
if (gProtectStructs[gBattlerTarget].endured)
{
@ -2069,7 +2069,7 @@ END:
gBattlescriptCurrInstr = cmd->nextInstr;
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleMoveDamage >= 1)
gSpecialStatuses[gBattlerAttacker].damagedMons |= gBitTable[gBattlerTarget];
gSpecialStatuses[gBattlerAttacker].damagedMons |= (1 << (gBattlerTarget));
// Check gems and damage reducing berries.
if (gSpecialStatuses[gBattlerTarget].berryReduced
@ -2144,7 +2144,7 @@ static void Cmd_multihitresultmessage(void)
if (gSpecialStatuses[gBattlerTarget].berryReduced
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
{
gBattleStruct->ateBerry[gBattlerTarget & BIT_SIDE] |= gBitTable[gBattlerPartyIndexes[gBattlerTarget]];
gBattleStruct->ateBerry[gBattlerTarget & BIT_SIDE] |= 1u << gBattlerPartyIndexes[gBattlerTarget];
gSpecialStatuses[gBattlerTarget].berryReduced = FALSE;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString;
@ -2605,7 +2605,7 @@ static void Cmd_resultmessage(void)
if (gSpecialStatuses[gBattlerTarget].berryReduced
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
{
gBattleStruct->ateBerry[gBattlerTarget & BIT_SIDE] |= gBitTable[gBattlerPartyIndexes[gBattlerTarget]];
gBattleStruct->ateBerry[gBattlerTarget & BIT_SIDE] |= 1u << gBattlerPartyIndexes[gBattlerTarget];
gSpecialStatuses[gBattlerTarget].berryReduced = FALSE;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString;
@ -3530,7 +3530,7 @@ void SetMoveEffect(bool32 primary, bool32 certain)
{
bool32 byTwo = FALSE;
gBattleStruct->stolenStats[0] |= gBitTable[i];
gBattleStruct->stolenStats[0] |= (1 << (i));
// Store by how many stages to raise the stat.
gBattleStruct->stolenStats[i] = gBattleMons[gBattlerTarget].statStages[i] - DEFAULT_STAT_STAGE;
while (gBattleMons[gBattlerAttacker].statStages[i] + gBattleStruct->stolenStats[i] > MAX_STAT_STAGE)
@ -3945,7 +3945,7 @@ static void Cmd_tryfaintmon(void)
destinyBondBattler = gBattlerAttacker;
faintScript = BattleScript_FaintTarget;
}
if (!(gAbsentBattlerFlags & gBitTable[battler])
if (!(gAbsentBattlerFlags & (1u << battler))
&& !IsBattlerAlive(battler))
{
gHitMarker |= HITMARKER_FAINTED(battler);
@ -4243,7 +4243,7 @@ static void Cmd_getexp(void)
else
{
gBattleScripting.getexpState++;
gBattleStruct->givenExpMons |= gBitTable[gBattlerPartyIndexes[gBattlerFainted]];
gBattleStruct->givenExpMons |= (1u << gBattlerPartyIndexes[gBattlerFainted]);
}
break;
case 1: // calculate experience points to redistribute
@ -4260,25 +4260,25 @@ static void Cmd_getexp(void)
{
if (!IsValidForBattle(&gPlayerParty[i]))
continue;
if (gBitTable[i] & sentInBits)
if ((1u << i) & sentInBits)
viaSentIn++;
holdEffect = GetMonHoldEffect(&gPlayerParty[i]);
if (holdEffect == HOLD_EFFECT_EXP_SHARE || IsGen6ExpShareEnabled())
{
expShareBits |= gBitTable[i];
expShareBits |= 1u << i;
viaExpShare++;
}
}
// Get order of mons getting exp: 1. all mons via sent in, 2. all mons via exp share
for (i = 0; i < PARTY_SIZE; i++)
{
if (gBitTable[i] & sentInBits)
if ((1u << i) & sentInBits)
gBattleStruct->expGettersOrder[orderId++] = i;
}
for (i = 0; i < PARTY_SIZE; i++)
{
if (!(gBitTable[i] & sentInBits) && gBitTable[i] & expShareBits)
if (!((1u << i) & sentInBits) && (1u << i) & expShareBits)
gBattleStruct->expGettersOrder[orderId++] = i;
}
if (orderId < PARTY_SIZE)
@ -4330,7 +4330,7 @@ static void Cmd_getexp(void)
case 2: // set exp value to the poke in expgetter_id and print message
if (gBattleControllerExecFlags == 0)
{
bool32 wasSentOut = ((gBattleStruct->expSentInMons & gBitTable[*expMonId]) != 0);
bool32 wasSentOut = (gBattleStruct->expSentInMons & (1u << *expMonId)) != 0;
holdEffect = GetMonHoldEffect(&gPlayerParty[*expMonId]);
if ((holdEffect != HOLD_EFFECT_EXP_SHARE && !wasSentOut && !IsGen6ExpShareEnabled())
@ -4404,11 +4404,11 @@ static void Cmd_getexp(void)
// get exp getter battler
if (IsDoubleBattle())
{
if (gBattlerPartyIndexes[2] == *expMonId && !(gAbsentBattlerFlags & gBitTable[2]))
if (gBattlerPartyIndexes[2] == *expMonId && !(gAbsentBattlerFlags & 4))
gBattleStruct->expGetterBattlerId = 2;
else
{
if (!(gAbsentBattlerFlags & gBitTable[0]))
if (!(gAbsentBattlerFlags & 1))
gBattleStruct->expGetterBattlerId = 0;
else
gBattleStruct->expGetterBattlerId = 2;
@ -4474,7 +4474,7 @@ static void Cmd_getexp(void)
PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff2, 3, GetMonData(&gPlayerParty[*expMonId], MON_DATA_LEVEL));
BattleScriptPushCursor();
gLeveledUpInBattle |= gBitTable[*expMonId];
gLeveledUpInBattle |= 1 << *expMonId;
gBattlescriptCurrInstr = BattleScript_LevelUp;
gBattleMoveDamage = T1_READ_32(&gBattleResources->bufferB[expBattler][2]);
AdjustFriendship(&gPlayerParty[*expMonId], FRIENDSHIP_EVENT_GROW_LEVEL);
@ -4547,7 +4547,7 @@ bool32 NoAliveMonsForPlayer(void)
for (i = 0; i < maxI; i++)
{
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)
&& (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostPlayerMons & gBitTable[i])))
&& (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostPlayerMons & (1u << i))))
{
HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP);
}
@ -4565,7 +4565,7 @@ static bool32 NoAliveMonsForOpponent(void)
for (i = 0; i < PARTY_SIZE; i++)
{
if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES) && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG)
&& (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostOpponentMons & gBitTable[i])))
&& (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostOpponentMons & (1u << i))))
{
HP_count += GetMonData(&gEnemyParty[i], MON_DATA_HP);
}
@ -5338,7 +5338,7 @@ static bool32 TryKnockOffBattleScript(u32 battlerDef)
}
else
{
gWishFutureKnock.knockedOffMons[side] |= gBitTable[gBattlerPartyIndexes[battlerDef]];
gWishFutureKnock.knockedOffMons[side] |= 1u << gBattlerPartyIndexes[battlerDef];
}
BattleScriptPushCursor();
@ -5366,7 +5366,7 @@ static u32 GetNextTarget(u32 moveTarget, bool32 excludeCurrent)
if (i != gBattlerAttacker
&& !(excludeCurrent && i == gBattlerTarget)
&& IsBattlerAlive(i)
&& !(gBattleStruct->targetsDone[gBattlerAttacker] & gBitTable[i])
&& !(gBattleStruct->targetsDone[gBattlerAttacker] & (1u << i))
&& (GetBattlerSide(i) != GetBattlerSide(gBattlerAttacker) || moveTarget == MOVE_TARGET_FOES_AND_ALLY))
break;
}
@ -5816,9 +5816,9 @@ static void Cmd_moveend(void)
if ((gMoveResultFlags & (MOVE_RESULT_FAILED | MOVE_RESULT_DOESNT_AFFECT_FOE))
|| (gBattleMons[gBattlerAttacker].status2 & (STATUS2_FLINCHED))
|| gProtectStructs[gBattlerAttacker].prlzImmobility)
gBattleStruct->lastMoveFailed |= gBitTable[gBattlerAttacker];
gBattleStruct->lastMoveFailed |= 1u << gBattlerAttacker;
else
gBattleStruct->lastMoveFailed &= ~(gBitTable[gBattlerAttacker]);
gBattleStruct->lastMoveFailed &= ~(1u << gBattlerAttacker);
// Set ShellTrap to activate after the attacker's turn if target was hit by a physical move.
if (gMovesInfo[gChosenMoveByBattler[gBattlerTarget]].effect == EFFECT_SHELL_TRAP
@ -5844,7 +5844,7 @@ static void Cmd_moveend(void)
}
if (!gSpecialStatuses[gBattlerAttacker].dancerUsedMove)
{
gDisableStructs[gBattlerAttacker].usedMoves |= gBitTable[gCurrMovePos];
gDisableStructs[gBattlerAttacker].usedMoves |= 1u << gCurrMovePos;
gBattleStruct->lastMoveTarget[gBattlerAttacker] = gBattlerTarget;
if (gHitMarker & HITMARKER_ATTACKSTRING_PRINTED)
{
@ -5854,8 +5854,8 @@ static void Cmd_moveend(void)
gBattleStruct->dynamax.lastUsedBaseMove = gBattleStruct->dynamax.baseMoves[gBattlerAttacker];
}
}
if (!(gAbsentBattlerFlags & gBitTable[gBattlerAttacker])
&& !(gBattleStruct->absentBattlerFlags & gBitTable[gBattlerAttacker])
if (!(gAbsentBattlerFlags & (1u << gBattlerAttacker))
&& !(gBattleStruct->absentBattlerFlags & (1u << gBattlerAttacker))
&& gMovesInfo[originallyUsedMove].effect != EFFECT_BATON_PASS
&& gMovesInfo[originallyUsedMove].effect != EFFECT_HEALING_WISH)
{
@ -5897,8 +5897,8 @@ static void Cmd_moveend(void)
gBattleScripting.moveendState++;
break;
case MOVEEND_MIRROR_MOVE: // mirror move
if (!(gAbsentBattlerFlags & gBitTable[gBattlerAttacker])
&& !(gBattleStruct->absentBattlerFlags & gBitTable[gBattlerAttacker])
if (!(gAbsentBattlerFlags & (1u << gBattlerAttacker))
&& !(gBattleStruct->absentBattlerFlags & (1u << gBattlerAttacker))
&& !gMovesInfo[originallyUsedMove].mirrorMoveBanned
&& gHitMarker & HITMARKER_OBEYS
&& gBattlerAttacker != gBattlerTarget
@ -5918,7 +5918,7 @@ static void Cmd_moveend(void)
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
gProtectStructs[gBattlerAttacker].targetAffected = TRUE;
gBattleStruct->targetsDone[gBattlerAttacker] |= gBitTable[gBattlerTarget];
gBattleStruct->targetsDone[gBattlerAttacker] |= 1u << gBattlerTarget;
if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE)
&& IsDoubleBattle()
&& !gProtectStructs[gBattlerAttacker].chargingTurn
@ -5949,7 +5949,7 @@ static void Cmd_moveend(void)
u8 originalBounceTarget = gBattlerAttacker;
gBattleStruct->bouncedMoveIsUsed = FALSE;
gBattlerAttacker = gBattleStruct->attackerBeforeBounce;
gBattleStruct->targetsDone[gBattlerAttacker] |= gBitTable[originalBounceTarget];
gBattleStruct->targetsDone[gBattlerAttacker] |= 1u << originalBounceTarget;
gBattleStruct->targetsDone[originalBounceTarget] = 0;
nextTarget = GetNextTarget(moveTarget, FALSE);
@ -6052,7 +6052,7 @@ static void Cmd_moveend(void)
&& TARGET_TURN_DAMAGED
&& CanStealItem(gBattlerAttacker, gBattlerTarget, gBattleMons[gBattlerTarget].item)
&& !gSpecialStatuses[gBattlerAttacker].gemBoost // In base game, gems are consumed after magician would activate.
&& !(gWishFutureKnock.knockedOffMons[GetBattlerSide(gBattlerTarget)] & gBitTable[gBattlerPartyIndexes[gBattlerTarget]])
&& !(gWishFutureKnock.knockedOffMons[GetBattlerSide(gBattlerTarget)] & (1u << gBattlerPartyIndexes[gBattlerTarget]))
&& !DoesSubstituteBlockMove(gBattlerAttacker, gBattlerTarget, gCurrentMove)
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& (GetBattlerAbility(gBattlerTarget) != ABILITY_STICKY_HOLD || !IsBattlerAlive(gBattlerTarget)))
@ -6076,9 +6076,9 @@ static void Cmd_moveend(void)
u32 holdEffect;
holdEffect = GetBattlerHoldEffect(i, TRUE);
if (holdEffect == HOLD_EFFECT_EJECT_BUTTON)
ejectButtonBattlers |= gBitTable[i];
ejectButtonBattlers |= 1u << i;
else if (holdEffect == HOLD_EFFECT_EJECT_PACK)
ejectPackBattlers |= gBitTable[i];
ejectPackBattlers |= 1u << i;
}
if (ejectButtonBattlers || ejectPackBattlers)
{
@ -6089,7 +6089,7 @@ static void Cmd_moveend(void)
{
u32 battler = battlers[i];
if (battler != gBattlerAttacker && ejectButtonBattlers & gBitTable[battler])
if (battler != gBattlerAttacker && ejectButtonBattlers & (1u << battler))
{
if (TestIfSheerForceAffected(gBattlerAttacker, gCurrentMove)) // Apparently Sheer Force blocks Eject Button, but not Eject Pack
continue;
@ -6098,7 +6098,7 @@ static void Cmd_moveend(void)
if (!BATTLER_TURN_DAMAGED(battler))
continue;
}
else if (ejectPackBattlers & gBitTable[battler])
else if (ejectPackBattlers & (1u << battler))
{
if (!gProtectStructs[battler].statFell || gProtectStructs[battler].disableEjectPack)
continue;
@ -6120,7 +6120,7 @@ static void Cmd_moveend(void)
gBattlescriptCurrInstr = BattleScript_MoveEnd; // Prevent user switch-in selection
effect = TRUE;
BattleScriptPushCursor();
if (ejectButtonBattlers & gBitTable[battler])
if (ejectButtonBattlers & (1u << battler))
{
gBattlescriptCurrInstr = BattleScript_EjectButtonActivates;
}
@ -6159,7 +6159,7 @@ static void Cmd_moveend(void)
if (i == gBattlerAttacker)
continue;
if (GetBattlerHoldEffect(i, TRUE) == HOLD_EFFECT_RED_CARD)
redCardBattlers |= gBitTable[i];
redCardBattlers |= (1u << i);
}
if (redCardBattlers
&& (gMovesInfo[gCurrentMove].effect != EFFECT_HIT_SWITCH_TARGET || gBattleStruct->hitSwitchTargetFailed)
@ -6176,7 +6176,7 @@ static void Cmd_moveend(void)
u32 battler = battlers[i];
// Search for fastest hit pokemon with a red card
// Attacker is the one to be switched out, battler is one with red card
if (redCardBattlers & gBitTable[battler]
if (redCardBattlers & (1u << battler)
&& IsBattlerAlive(battler)
&& !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove)
&& BATTLER_TURN_DAMAGED(battler)
@ -6207,7 +6207,7 @@ static void Cmd_moveend(void)
case MOVEEND_PICKPOCKET:
if (IsBattlerAlive(gBattlerAttacker)
&& gBattleMons[gBattlerAttacker].item != ITEM_NONE // Attacker must be holding an item
&& !(gWishFutureKnock.knockedOffMons[GetBattlerSide(gBattlerAttacker)] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]]) // But not knocked off
&& !(gWishFutureKnock.knockedOffMons[GetBattlerSide(gBattlerAttacker)] & (1u << gBattlerPartyIndexes[gBattlerAttacker])) // But not knocked off
&& !(TestIfSheerForceAffected(gBattlerAttacker, gCurrentMove)) // Pickpocket doesn't activate for sheer force
&& IsMoveMakingContact(gCurrentMove, gBattlerAttacker) // Pickpocket requires contact
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) // Obviously attack needs to have worked
@ -6451,7 +6451,7 @@ static void Cmd_getswitchedmondata(void)
gBattlerPartyIndexes[battler] = gBattleStruct->monToSwitchIntoId[battler];
BtlController_EmitGetMonData(battler, BUFFER_A, REQUEST_ALL_BATTLE, gBitTable[gBattlerPartyIndexes[battler]]);
BtlController_EmitGetMonData(battler, BUFFER_A, REQUEST_ALL_BATTLE, 1u << gBattlerPartyIndexes[battler]);
MarkBattlerForControllerExec(battler);
gBattlescriptCurrInstr = cmd->nextInstr;
@ -6497,7 +6497,7 @@ static void Cmd_switchindataupdate(void)
if (i != PARTY_SIZE)
{
gBattlerPartyIndexes[battler] = gBattleStruct->monToSwitchIntoId[battler] = i;
BtlController_EmitGetMonData(battler, BUFFER_A, REQUEST_ALL_BATTLE, gBitTable[gBattlerPartyIndexes[battler]]);
BtlController_EmitGetMonData(battler, BUFFER_A, REQUEST_ALL_BATTLE, 1u << gBattlerPartyIndexes[battler]);
MarkBattlerForControllerExec(battler);
return;
}
@ -6520,7 +6520,7 @@ static void Cmd_switchindataupdate(void)
// check knocked off item
i = GetBattlerSide(battler);
if (gWishFutureKnock.knockedOffMons[i] & gBitTable[gBattlerPartyIndexes[battler]])
if (gWishFutureKnock.knockedOffMons[i] & (1u << gBattlerPartyIndexes[battler]))
{
gBattleMons[battler].item = ITEM_NONE;
}
@ -6541,7 +6541,7 @@ static void Cmd_switchindataupdate(void)
&& IsBattlerAlive(battler)
&& !(gBattleMons[battler].status1 & STATUS1_SLEEP))
{
gBattleStruct->palaceFlags |= gBitTable[battler];
gBattleStruct->palaceFlags |= 1u << battler;
}
gBattleScripting.battler = battler;
@ -6570,7 +6570,7 @@ static void Cmd_switchinanim(void)
| BATTLE_TYPE_FRONTIER)))
HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[battler].species), FLAG_SET_SEEN, gBattleMons[battler].personality);
gAbsentBattlerFlags &= ~(gBitTable[battler]);
gAbsentBattlerFlags &= ~(1u << battler);
BtlController_EmitSwitchInAnim(battler, BUFFER_A, gBattlerPartyIndexes[battler], cmd->dontClearSubstitute);
MarkBattlerForControllerExec(battler);
@ -6749,7 +6749,7 @@ static void ChooseMonToSendOut(u32 battler, u8 slotId)
{
gBattleStruct->battlerPartyIndexes[battler] = gBattlerPartyIndexes[battler];
gBattleStruct->monToSwitchIntoId[battler] = PARTY_SIZE;
gBattleStruct->field_93 &= ~(gBitTable[battler]);
gBattleStruct->field_93 &= ~(1u << battler);
BtlController_EmitChoosePokemon(battler, BUFFER_A, PARTY_ACTION_SEND_OUT, slotId, ABILITY_NONE, gBattleStruct->battlerPartyOrders[battler]);
MarkBattlerForControllerExec(battler);
@ -6774,7 +6774,7 @@ static void Cmd_openpartyscreen(void)
{
if (HasNoMonsToSwitch(battler, PARTY_SIZE, PARTY_SIZE))
{
gAbsentBattlerFlags |= gBitTable[battler];
gAbsentBattlerFlags |= 1u << battler;
gHitMarker &= ~HITMARKER_FAINTED(battler);
BtlController_EmitLinkStandbyMsg(battler, BUFFER_A, LINK_STANDBY_MSG_ONLY, FALSE);
MarkBattlerForControllerExec(battler);
@ -6798,12 +6798,12 @@ static void Cmd_openpartyscreen(void)
hitmarkerFaintBits = gHitMarker >> 28;
if (gBitTable[0] & hitmarkerFaintBits)
if (1u & hitmarkerFaintBits)
{
battler = 0;
if (HasNoMonsToSwitch(battler, PARTY_SIZE, PARTY_SIZE))
{
gAbsentBattlerFlags |= gBitTable[battler];
gAbsentBattlerFlags |= 1u << battler;
gHitMarker &= ~HITMARKER_FAINTED(battler);
BtlController_EmitCantSwitch(battler, BUFFER_A);
MarkBattlerForControllerExec(battler);
@ -6820,12 +6820,12 @@ static void Cmd_openpartyscreen(void)
flags |= 1;
}
}
if (gBitTable[2] & hitmarkerFaintBits && !(gBitTable[0] & hitmarkerFaintBits))
if (4u & hitmarkerFaintBits && !(1u & hitmarkerFaintBits))
{
battler = 2;
if (HasNoMonsToSwitch(battler, PARTY_SIZE, PARTY_SIZE))
{
gAbsentBattlerFlags |= gBitTable[battler];
gAbsentBattlerFlags |= 1u << battler;
gHitMarker &= ~HITMARKER_FAINTED(battler);
BtlController_EmitCantSwitch(battler, BUFFER_A);
MarkBattlerForControllerExec(battler);
@ -6841,12 +6841,12 @@ static void Cmd_openpartyscreen(void)
MarkBattlerForControllerExec(battler);
}
}
if (gBitTable[1] & hitmarkerFaintBits)
if (2 & hitmarkerFaintBits)
{
battler = 1;
if (HasNoMonsToSwitch(battler, PARTY_SIZE, PARTY_SIZE))
{
gAbsentBattlerFlags |= gBitTable[battler];
gAbsentBattlerFlags |= 1u << battler;
gHitMarker &= ~HITMARKER_FAINTED(battler);
BtlController_EmitCantSwitch(battler, BUFFER_A);
MarkBattlerForControllerExec(battler);
@ -6863,12 +6863,12 @@ static void Cmd_openpartyscreen(void)
flags |= 2;
}
}
if (gBitTable[3] & hitmarkerFaintBits && !(gBitTable[1] & hitmarkerFaintBits))
if (8 & hitmarkerFaintBits && !(2 & hitmarkerFaintBits))
{
battler = 3;
if (HasNoMonsToSwitch(battler, PARTY_SIZE, PARTY_SIZE))
{
gAbsentBattlerFlags |= gBitTable[battler];
gAbsentBattlerFlags |= 1u << battler;
gHitMarker &= ~HITMARKER_FAINTED(battler);
BtlController_EmitCantSwitch(battler, BUFFER_A);
MarkBattlerForControllerExec(battler);
@ -6891,7 +6891,7 @@ static void Cmd_openpartyscreen(void)
hasReplacement_2 = gSpecialStatuses[2].faintedHasReplacement;
if (!hasReplacement_2 && hitmarkerFaintBits != 0)
{
if (gAbsentBattlerFlags & gBitTable[0])
if (gAbsentBattlerFlags & 1)
battler = 2;
else
battler = 0;
@ -6907,7 +6907,7 @@ static void Cmd_openpartyscreen(void)
hasReplacement_3 = gSpecialStatuses[3].faintedHasReplacement;
if (!hasReplacement_3 && hitmarkerFaintBits != 0)
{
if (gAbsentBattlerFlags & gBitTable[1])
if (gAbsentBattlerFlags & 2)
battler = 3;
else
battler = 1;
@ -6926,12 +6926,12 @@ static void Cmd_openpartyscreen(void)
if (IsDoubleBattle())
{
hitmarkerFaintBits = gHitMarker >> 28;
if (gBitTable[2] & hitmarkerFaintBits && gBitTable[0] & hitmarkerFaintBits)
if (4 & hitmarkerFaintBits && 1 & hitmarkerFaintBits)
{
battler = 2;
if (HasNoMonsToSwitch(battler, gBattleResources->bufferB[0][1], PARTY_SIZE))
{
gAbsentBattlerFlags |= gBitTable[battler];
gAbsentBattlerFlags |= 1u << battler;
gHitMarker &= ~HITMARKER_FAINTED(battler);
BtlController_EmitCantSwitch(battler, BUFFER_A);
MarkBattlerForControllerExec(battler);
@ -6942,12 +6942,12 @@ static void Cmd_openpartyscreen(void)
gSpecialStatuses[battler].faintedHasReplacement = TRUE;
}
}
if (gBitTable[3] & hitmarkerFaintBits && hitmarkerFaintBits & gBitTable[1])
if (8u & hitmarkerFaintBits && hitmarkerFaintBits & 2u)
{
battler = 3;
if (HasNoMonsToSwitch(battler, gBattleResources->bufferB[1][1], PARTY_SIZE))
{
gAbsentBattlerFlags |= gBitTable[battler];
gAbsentBattlerFlags |= 1u << battler;
gHitMarker &= ~HITMARKER_FAINTED(battler);
BtlController_EmitCantSwitch(battler, BUFFER_A);
MarkBattlerForControllerExec(battler);
@ -6975,7 +6975,7 @@ static void Cmd_openpartyscreen(void)
hitmarkerFaintBits = gHitMarker >> 28;
gBattlerFainted = 0;
while (!(gBitTable[gBattlerFainted] & hitmarkerFaintBits)
while (!((1u << gBattlerFainted) & hitmarkerFaintBits)
&& gBattlerFainted < gBattlersCount)
gBattlerFainted++;
@ -6996,7 +6996,7 @@ static void Cmd_openpartyscreen(void)
}
else if (HasNoMonsToSwitch(battler, PARTY_SIZE, PARTY_SIZE))
{
gAbsentBattlerFlags |= gBitTable[battler];
gAbsentBattlerFlags |= 1u << battler;
gHitMarker &= ~HITMARKER_FAINTED(battler);
gBattlescriptCurrInstr = failInstr;
}
@ -7004,7 +7004,7 @@ static void Cmd_openpartyscreen(void)
{
*(gBattleStruct->battlerPartyIndexes + battler) = gBattlerPartyIndexes[battler];
*(gBattleStruct->monToSwitchIntoId + battler) = PARTY_SIZE;
gBattleStruct->field_93 &= ~(gBitTable[battler]);
gBattleStruct->field_93 &= ~(1u << battler);
BtlController_EmitChoosePokemon(battler, BUFFER_A, hitmarkerFaintBits, *(gBattleStruct->monToSwitchIntoId + BATTLE_PARTNER(battler)), ABILITY_NONE, gBattleStruct->battlerPartyOrders[battler]);
MarkBattlerForControllerExec(battler);
@ -7028,7 +7028,7 @@ static void Cmd_openpartyscreen(void)
else
{
u32 battlerOpposite = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerPosition(battler)));
if (gAbsentBattlerFlags & gBitTable[battlerOpposite])
if (gAbsentBattlerFlags & (1u << battlerOpposite))
battlerOpposite ^= BIT_FLANK;
// Make sure we're checking a valid battler. In edge case scenarios - battler could be absent and battlerOpposite would become a non-existent one softlocking the game.
@ -7060,10 +7060,10 @@ static void Cmd_switchhandleorder(void)
if (gBattleResources->bufferB[i][0] == CONTROLLER_CHOSENMONRETURNVALUE)
{
*(gBattleStruct->monToSwitchIntoId + i) = gBattleResources->bufferB[i][1];
if (!(gBattleStruct->field_93 & gBitTable[i]))
if (!(gBattleStruct->field_93 & (1u << i)))
{
RecordedBattle_SetBattlerAction(i, gBattleResources->bufferB[i][1]);
gBattleStruct->field_93 |= gBitTable[i];
gBattleStruct->field_93 |= 1u << i;
}
}
}
@ -7073,10 +7073,10 @@ static void Cmd_switchhandleorder(void)
SwitchPartyOrder(battler);
break;
case 2:
if (!(gBattleStruct->field_93 & gBitTable[battler]))
if (!(gBattleStruct->field_93 & (1u << battler)))
{
RecordedBattle_SetBattlerAction(battler, gBattleResources->bufferB[battler][1]);
gBattleStruct->field_93 |= gBitTable[battler];
gBattleStruct->field_93 |= 1u << battler;
}
// fall through
case 3:
@ -7144,7 +7144,7 @@ static void UpdateSentMonFlags(u32 battler)
gSpecialStatuses[battler].faintedHasReplacement = FALSE;
if (!BattlerHasAi(battler))
gBattleStruct->appearedInBattle |= gBitTable[gBattlerPartyIndexes[battler]];
gBattleStruct->appearedInBattle |= 1u << gBattlerPartyIndexes[battler];
}
static bool32 DoSwitchInEffectsForBattler(u32 battler)
@ -7161,20 +7161,20 @@ static bool32 DoSwitchInEffectsForBattler(u32 battler)
}
// Healing Wish activates before hazards.
// Starting from Gen8 - it heals only pokemon which can be healed. In gens 5,6,7 the effect activates anyways.
else if (((gBattleStruct->storedHealingWish & gBitTable[battler]) || (gBattleStruct->storedLunarDance & gBitTable[battler]))
else if (((gBattleStruct->storedHealingWish & (1u << battler)) || (gBattleStruct->storedLunarDance & (1u << battler)))
&& (gBattleMons[battler].hp != gBattleMons[battler].maxHP || gBattleMons[battler].status1 != 0 || B_HEALING_WISH_SWITCH < GEN_8))
{
if (gBattleStruct->storedHealingWish & gBitTable[battler])
if (gBattleStruct->storedHealingWish & (1u << battler))
{
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_HealingWishActivates;
gBattleStruct->storedHealingWish &= ~(gBitTable[battler]);
gBattleStruct->storedHealingWish &= ~(1u << battler);
}
else // Lunar Dance
{
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_LunarDanceActivates;
gBattleStruct->storedLunarDance &= ~(gBitTable[battler]);
gBattleStruct->storedLunarDance &= ~(1u << battler);
}
}
else if (!(gDisableStructs[battler].spikesDone)
@ -7308,7 +7308,7 @@ static bool32 DoSwitchInEffectsForBattler(u32 battler)
gBattleStruct->hpOnSwitchout[GetBattlerSide(i)] = gBattleMons[i].hp;
}
gBattleStruct->forcedSwitch &= ~(gBitTable[battler]);
gBattleStruct->forcedSwitch &= ~(1u << battler);
return FALSE;
}
@ -7324,7 +7324,7 @@ static void Cmd_switchineffects(void)
{
// Multiple mons fainted and are being switched-in. Their abilities/hazards will play according to speed ties.
case BS_FAINTED_MULTIPLE_1: // Saves the battlers.
gBattleStruct->multipleSwitchInBattlers |= gBitTable[battler];
gBattleStruct->multipleSwitchInBattlers |= 1 << battler;
UpdateSentMonFlags(battler);
// Increment fainted battler.
@ -7333,7 +7333,7 @@ static void Cmd_switchineffects(void)
gBattlerFainted++;
if (gBattlerFainted >= gBattlersCount)
break;
if (gHitMarker & HITMARKER_FAINTED(gBattlerFainted) && !(gAbsentBattlerFlags & gBitTable[gBattlerFainted]))
if (gHitMarker & HITMARKER_FAINTED(gBattlerFainted) && !(gAbsentBattlerFlags & (1u << gBattlerFainted)))
break;
} while (1);
@ -7353,7 +7353,7 @@ static void Cmd_switchineffects(void)
for (; gBattleStruct->multipleSwitchInCursor < gBattlersCount; gBattleStruct->multipleSwitchInCursor++)
{
gBattlerFainted = gBattleStruct->multipleSwitchInSortedBattlers[gBattleStruct->multipleSwitchInCursor];
if (gBattleStruct->multipleSwitchInBattlers & gBitTable[gBattlerFainted])
if (gBattleStruct->multipleSwitchInBattlers & (1 << (gBattlerFainted)))
{
if (DoSwitchInEffectsForBattler(gBattlerFainted))
return;
@ -7982,7 +7982,7 @@ static bool32 TryCheekPouch(u32 battler, u32 itemId)
if (ItemId_GetPocket(itemId) == POCKET_BERRIES
&& GetBattlerAbility(battler) == ABILITY_CHEEK_POUCH
&& !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)
&& gBattleStruct->ateBerry[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]]
&& gBattleStruct->ateBerry[GetBattlerSide(battler)] & (1u << gBattlerPartyIndexes[battler])
&& !BATTLER_MAX_HP(battler))
{
gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / 3;
@ -8515,7 +8515,7 @@ bool32 CanUseLastResort(u8 battler)
{
if (gBattleMons[battler].moves[i] != MOVE_NONE)
knownMovesCount++;
if (i != gCurrMovePos && gDisableStructs[battler].usedMoves & gBitTable[i]) // Increment used move count for all moves except current Last Resort.
if (i != gCurrMovePos && gDisableStructs[battler].usedMoves & (1u << i)) // Increment used move count for all moves except current Last Resort.
usedMovesCount++;
}
@ -8847,7 +8847,7 @@ static void HandleScriptMegaPrimalBurst(u32 caseId, u32 battler, u32 type)
PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[battler].species);
BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_SPECIES_BATTLE, gBitTable[gBattlerPartyIndexes[battler]], sizeof(gBattleMons[battler].species), &gBattleMons[battler].species);
BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_SPECIES_BATTLE, 1u << gBattlerPartyIndexes[battler], sizeof(gBattleMons[battler].species), &gBattleMons[battler].species);
MarkBattlerForControllerExec(battler);
}
// Update healthbox and elevation and play cry.
@ -9165,9 +9165,9 @@ static void Cmd_various(void)
// Raise stats
for (i = STAT_ATK; i < NUM_BATTLE_STATS; i++)
{
if (gBattleStruct->stolenStats[0] & gBitTable[i])
if (gBattleStruct->stolenStats[0] & (1u << i))
{
gBattleStruct->stolenStats[0] &= ~(gBitTable[i]);
gBattleStruct->stolenStats[0] &= ~(1u << i);
SET_STATCHANGER(i, gBattleStruct->stolenStats[i], FALSE);
if (ChangeStatBuffs(GET_STAT_BUFF_VALUE_WITH_SIGN(gBattleScripting.statChanger), i, MOVE_EFFECT_CERTAIN | MOVE_EFFECT_AFFECTS_USER, NULL) == STAT_CHANGE_WORKED)
{
@ -9192,7 +9192,7 @@ static void Cmd_various(void)
for (i = STAT_ATK; i < NUM_BATTLE_STATS; i++)
{
if (CompareStat(battler, i, MAX_STAT_STAGE, CMP_LESS_THAN))
bits |= gBitTable[i];
bits |= 1u << i;
}
if (bits)
{
@ -9200,7 +9200,7 @@ static void Cmd_various(void)
do
{
statId = (Random() % (NUM_BATTLE_STATS - 1)) + 1;
} while (!(bits & gBitTable[statId]));
} while (!(bits & (1u << statId)));
SET_STATCHANGER(statId, 2, FALSE);
gBattlescriptCurrInstr = cmd->nextInstr;
@ -9300,12 +9300,12 @@ static void Cmd_various(void)
// Try and print end-of-turn Battle Palace flavor text (e.g. "A glint appears in mon's eyes")
gBattleCommunication[0] = FALSE; // whether or not msg should be printed
gBattleScripting.battler = battler = gBattleCommunication[1];
if (!(gBattleStruct->palaceFlags & gBitTable[battler])
if (!(gBattleStruct->palaceFlags & (1u << battler))
&& gBattleMons[battler].maxHP / 2 >= gBattleMons[battler].hp
&& IsBattlerAlive(battler)
&& !(gBattleMons[battler].status1 & STATUS1_SLEEP))
{
gBattleStruct->palaceFlags |= gBitTable[battler];
gBattleStruct->palaceFlags |= 1u << battler;
gBattleCommunication[0] = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = gNaturesInfo[GetNatureFromPersonality(gBattleMons[battler].personality)].battlePalaceFlavorText;
}
@ -9330,7 +9330,7 @@ static void Cmd_various(void)
VARIOUS_ARGS();
gBattleMons[1].hp = 0;
gHitMarker |= HITMARKER_FAINTED(1);
gBattleStruct->arenaLostOpponentMons |= gBitTable[gBattlerPartyIndexes[1]];
gBattleStruct->arenaLostOpponentMons |= 1u << gBattlerPartyIndexes[1];
gDisableStructs[1].truantSwitchInHack = 1;
break;
}
@ -9340,7 +9340,7 @@ static void Cmd_various(void)
gBattleMons[0].hp = 0;
gHitMarker |= HITMARKER_FAINTED(0);
gHitMarker |= HITMARKER_PLAYER_FAINTED;
gBattleStruct->arenaLostPlayerMons |= gBitTable[gBattlerPartyIndexes[0]];
gBattleStruct->arenaLostPlayerMons |= 1u << gBattlerPartyIndexes[0];
gDisableStructs[0].truantSwitchInHack = 1;
break;
}
@ -9352,8 +9352,8 @@ static void Cmd_various(void)
gHitMarker |= HITMARKER_FAINTED(0);
gHitMarker |= HITMARKER_FAINTED(1);
gHitMarker |= HITMARKER_PLAYER_FAINTED;
gBattleStruct->arenaLostPlayerMons |= gBitTable[gBattlerPartyIndexes[0]];
gBattleStruct->arenaLostOpponentMons |= gBitTable[gBattlerPartyIndexes[1]];
gBattleStruct->arenaLostPlayerMons |= 1u << gBattlerPartyIndexes[0];
gBattleStruct->arenaLostOpponentMons |= 1u << gBattlerPartyIndexes[1];
gDisableStructs[0].truantSwitchInHack = 1;
gDisableStructs[1].truantSwitchInHack = 1;
break;
@ -9438,7 +9438,7 @@ static void Cmd_various(void)
case VARIOUS_SET_ALREADY_STATUS_MOVE_ATTEMPT:
{
VARIOUS_ARGS();
gBattleStruct->alreadyStatusedMoveAttempt |= gBitTable[battler];
gBattleStruct->alreadyStatusedMoveAttempt |= 1u << battler;
break;
}
case VARIOUS_PALACE_TRY_ESCAPE_STATUS:
@ -9455,7 +9455,7 @@ static void Cmd_various(void)
// and its partner is still alive.
if (GetBattlerSide(battler) == B_SIDE_OPPONENT && IsBattlerAlive(BATTLE_PARTNER(battler)))
{
gAbsentBattlerFlags |= gBitTable[battler];
gAbsentBattlerFlags |= 1u << battler;
gHitMarker |= HITMARKER_FAINTED(battler);
gBattleMons[battler].hp = 0;
SetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_HP, &gBattleMons[battler].hp);
@ -9830,7 +9830,7 @@ static void Cmd_various(void)
if (!gBattleTextBuff1)
PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[battler].species);
*/
BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_SPECIES_BATTLE, gBitTable[gBattlerPartyIndexes[battler]], sizeof(gBattleMons[battler].species), &gBattleMons[battler].species);
BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_SPECIES_BATTLE, 1u << gBattlerPartyIndexes[battler], sizeof(gBattleMons[battler].species), &gBattleMons[battler].species);
MarkBattlerForControllerExec(battler);
}
// Change stats.
@ -10034,7 +10034,7 @@ static void Cmd_various(void)
|| gBattleMons[gBattlerTarget].item != ITEM_NONE
|| !CanBattlerGetOrLoseItem(gBattlerAttacker, gBattleMons[gBattlerAttacker].item)
|| !CanBattlerGetOrLoseItem(gBattlerTarget, gBattleMons[gBattlerAttacker].item)
|| gWishFutureKnock.knockedOffMons[GetBattlerSide(gBattlerTarget)] & gBitTable[gBattlerPartyIndexes[gBattlerTarget]])
|| gWishFutureKnock.knockedOffMons[GetBattlerSide(gBattlerTarget)] & (1u << gBattlerPartyIndexes[gBattlerTarget]))
{
gBattlescriptCurrInstr = cmd->failInstr;
}
@ -10279,7 +10279,7 @@ static void Cmd_various(void)
ConvertIntToDecimalStringN(gBattleTextBuff2, ppToDeduct, STR_CONV_MODE_LEFT_ALIGN, 1);
PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff2, 1, ppToDeduct)
gBattleMons[battler].pp[i] -= ppToDeduct;
if (!(gDisableStructs[battler].mimickedMoves & gBitTable[i])
if (!(gDisableStructs[battler].mimickedMoves & (1u << i))
&& !(gBattleMons[battler].status2 & STATUS2_TRANSFORMED))
{
BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_PPMOVE1_BATTLE + i, 0, sizeof(gBattleMons[battler].pp[i]), &gBattleMons[battler].pp[i]);
@ -10518,9 +10518,9 @@ static void Cmd_various(void)
if (gBattleMons[gBattlerAttacker].species == SPECIES_GRENINJA_BATTLE_BOND
&& HasAttackerFaintedTarget()
&& CalculateBattlerPartyCount(gBattlerTarget) > 1
&& !(gBattleStruct->battleBondTransformed[GetBattlerSide(gBattlerAttacker)] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]]))
&& !(gBattleStruct->battleBondTransformed[GetBattlerSide(gBattlerAttacker)] & (1u << gBattlerPartyIndexes[gBattlerAttacker])))
{
gBattleStruct->battleBondTransformed[GetBattlerSide(gBattlerAttacker)] |= gBitTable[gBattlerPartyIndexes[gBattlerAttacker]];
gBattleStruct->battleBondTransformed[GetBattlerSide(gBattlerAttacker)] |= 1u << gBattlerPartyIndexes[gBattlerAttacker];
PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].species);
gBattleStruct->changedSpecies[GetBattlerSide(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]] = gBattleMons[gBattlerAttacker].species;
gBattleMons[gBattlerAttacker].species = SPECIES_GRENINJA_ASH;
@ -10542,7 +10542,7 @@ static void Cmd_various(void)
if (cmd->fromBattler)
gLastUsedItem = gBattleMons[battler].item;
gBattleStruct->ateBerry[battler & BIT_SIDE] |= gBitTable[gBattlerPartyIndexes[battler]];
gBattleStruct->ateBerry[battler & BIT_SIDE] |= 1u << gBattlerPartyIndexes[battler];
gBattleScripting.battler = gEffectBattler = gBattlerTarget = battler; // Cover all berry effect battler cases. e.g. ChangeStatBuffs uses target ID
if (ItemBattleEffects(ITEMEFFECT_USE_LAST_ITEM, battler, FALSE))
return;
@ -10882,9 +10882,9 @@ static void Cmd_various(void)
{
VARIOUS_ARGS();
if (gCurrentMove == MOVE_LUNAR_DANCE)
gBattleStruct->storedLunarDance |= gBitTable[battler];
gBattleStruct->storedLunarDance |= 1u << battler;
else
gBattleStruct->storedHealingWish |= gBitTable[battler];
gBattleStruct->storedHealingWish |= 1u << battler;
break;
}
case VARIOUS_HIT_SWITCH_TARGET_FAILED:
@ -10913,7 +10913,7 @@ static void Cmd_various(void)
struct Pokemon *party = GetSideParty(side);
u16 hp = GetMonData(&party[gSelectedMonPartyId], MON_DATA_MAX_HP) / 2;
BtlController_EmitSetMonData(gBattlerAttacker, BUFFER_A, REQUEST_HP_BATTLE, gBitTable[gSelectedMonPartyId], sizeof(hp), &hp);
BtlController_EmitSetMonData(gBattlerAttacker, BUFFER_A, REQUEST_HP_BATTLE, 1u << gSelectedMonPartyId, sizeof(hp), &hp);
MarkBattlerForControllerExec(gBattlerAttacker);
PREPARE_SPECIES_BUFFER(gBattleTextBuff1, GetMonData(&party[gSelectedMonPartyId], MON_DATA_SPECIES));
@ -12136,7 +12136,7 @@ static void Cmd_forcerandomswitch(void)
{
*(gBattleStruct->battlerPartyIndexes + gBattlerTarget) = gBattlerPartyIndexes[gBattlerTarget];
gBattlescriptCurrInstr = BattleScript_RoarSuccessSwitch;
gBattleStruct->forcedSwitch |= gBitTable[gBattlerTarget];
gBattleStruct->forcedSwitch |= 1u << gBattlerTarget;
*(gBattleStruct->monToSwitchIntoId + gBattlerTarget) = validMons[RandomUniform(RNG_FORCE_RANDOM_SWITCH, 0, validMonsCount - 1)];
if (!IsMultiBattle())
@ -12464,7 +12464,7 @@ static void Cmd_updatestatusicon(void)
else
{
battler = gBattlerAttacker;
if (!(gAbsentBattlerFlags & gBitTable[battler]))
if (!(gAbsentBattlerFlags & (1u << battler)))
{
BtlController_EmitStatusIconUpdate(battler, BUFFER_A, gBattleMons[battler].status1, gBattleMons[battler].status2);
MarkBattlerForControllerExec(battler);
@ -12472,7 +12472,7 @@ static void Cmd_updatestatusicon(void)
if ((IsDoubleBattle()))
{
battler = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker)));
if (!(gAbsentBattlerFlags & gBitTable[battler]))
if (!(gAbsentBattlerFlags & (1u << battler)))
{
BtlController_EmitStatusIconUpdate(battler, BUFFER_A, gBattleMons[battler].status1, gBattleMons[battler].status2);
MarkBattlerForControllerExec(battler);
@ -12506,8 +12506,8 @@ static void Cmd_setfocusenergy(void)
CMD_ARGS(u8 battler);
u8 battler = GetBattlerForBattleScript(cmd->battler);
if ((gMovesInfo[gCurrentMove].effect == EFFECT_DRAGON_CHEER && (!(IsDoubleBattle()) || (gAbsentBattlerFlags & gBitTable[battler])))
|| gBattleMons[battler].status2 & STATUS2_FOCUS_ENERGY_ANY)
if ((gMovesInfo[gCurrentMove].effect == EFFECT_DRAGON_CHEER && (!(IsDoubleBattle()) || (gAbsentBattlerFlags & (1u << battler))))
|| gBattleMons[battler].status2 & STATUS2_FOCUS_ENERGY_ANY)
{
gMoveResultFlags |= MOVE_RESULT_FAILED;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_FOCUS_ENERGY_FAILED;
@ -12650,7 +12650,7 @@ static void Cmd_mimicattackcopy(void)
PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBattlerTarget])
gDisableStructs[gBattlerAttacker].mimickedMoves |= gBitTable[gCurrMovePos];
gDisableStructs[gBattlerAttacker].mimickedMoves |= 1u << gCurrMovePos;
gBattlescriptCurrInstr = cmd->nextInstr;
}
else
@ -12906,7 +12906,7 @@ static void Cmd_settypetorandomresistance(void)
{
case UQ_4_12(0):
case UQ_4_12(0.5):
resistTypes |= gBitTable[i];
resistTypes |= 1u << i;
break;
}
}
@ -12914,11 +12914,11 @@ static void Cmd_settypetorandomresistance(void)
while (resistTypes != 0)
{
i = Random() % NUMBER_OF_MON_TYPES;
if (resistTypes & gBitTable[i])
if (resistTypes & (1u << i))
{
if (IS_BATTLER_OF_TYPE(gBattlerAttacker, i))
{
resistTypes &= ~(gBitTable[i]); // Type resists, but the user is already of this type.
resistTypes &= ~(1u << i); // Type resists, but the user is already of this type.
}
else
{
@ -13008,7 +13008,7 @@ static void Cmd_trychoosesleeptalkmove(void)
if (gMovesInfo[gBattleMons[gBattlerAttacker].moves[i]].sleepTalkBanned
|| gBattleMoveEffects[gMovesInfo[gBattleMons[gBattlerAttacker].moves[i]].effect].twoTurnEffect)
{
unusableMovesBits |= gBitTable[i];
unusableMovesBits |= (1 << (i));
}
}
@ -13020,11 +13020,11 @@ static void Cmd_trychoosesleeptalkmove(void)
else // at least one move can be chosen
{
// Set Sleep Talk as used move, so it works with Last Resort.
gDisableStructs[gBattlerAttacker].usedMoves |= gBitTable[gCurrMovePos];
gDisableStructs[gBattlerAttacker].usedMoves |= 1u << gCurrMovePos;
do
{
movePosition = MOD(Random(), MAX_MON_MOVES);
} while ((gBitTable[movePosition] & unusableMovesBits));
} while ((1u << movePosition) & unusableMovesBits);
if (GetActiveGimmick(gBattlerAttacker) == GIMMICK_Z_MOVE && !IS_MOVE_STATUS(gBattleMons[gBattlerAttacker].moves[movePosition]))
{
@ -13135,7 +13135,7 @@ static void Cmd_tryspiteppreduce(void)
gBattleMons[gBattlerTarget].pp[i] -= ppToDeduct;
// if (MOVE_IS_PERMANENT(gBattlerTarget, i)), but backwards
if (!(gDisableStructs[gBattlerTarget].mimickedMoves & gBitTable[i])
if (!(gDisableStructs[gBattlerTarget].mimickedMoves & (1u << i))
&& !(gBattleMons[gBattlerTarget].status2 & STATUS2_TRANSFORMED))
{
BtlController_EmitSetMonData(gBattlerTarget, BUFFER_A, REQUEST_PPMOVE1_BATTLE + i, 0, sizeof(gBattleMons[gBattlerTarget].pp[i]), &gBattleMons[gBattlerTarget].pp[i]);
@ -13250,7 +13250,7 @@ static void Cmd_healpartystatus(void)
gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE;
if (IsDoubleBattle()
&& !(gAbsentBattlerFlags & gBitTable[partner]))
&& !(gAbsentBattlerFlags & (1u <<partner)))
{
gBattleMons[partner].status1 = 0;
gBattleMons[partner].status2 &= ~STATUS2_NIGHTMARE;
@ -13541,7 +13541,7 @@ static void Cmd_magnitudedamagecalculation(void)
{
if (gBattlerTarget == gBattlerAttacker)
continue;
if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget])) // A valid target was found.
if (!(gAbsentBattlerFlags & (1u << gBattlerTarget))) // A valid target was found.
break;
}
@ -14093,7 +14093,7 @@ static void Cmd_trysethelpinghand(void)
gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker)));
if (IsDoubleBattle()
&& !(gAbsentBattlerFlags & gBitTable[gBattlerTarget])
&& !(gAbsentBattlerFlags & (1u << gBattlerTarget))
&& !gProtectStructs[gBattlerAttacker].helpingHand
&& !gProtectStructs[gBattlerTarget].helpingHand)
{
@ -14135,8 +14135,8 @@ static void Cmd_tryswapitems(void)
| BATTLE_TYPE_FRONTIER
| BATTLE_TYPE_SECRET_BASE
| BATTLE_TYPE_RECORDED_LINK))
&& (gWishFutureKnock.knockedOffMons[sideAttacker] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]]
|| gWishFutureKnock.knockedOffMons[sideTarget] & gBitTable[gBattlerPartyIndexes[gBattlerTarget]]))
&& (gWishFutureKnock.knockedOffMons[sideAttacker] & (1u << gBattlerPartyIndexes[gBattlerAttacker])
|| gWishFutureKnock.knockedOffMons[sideTarget] & (1u << gBattlerPartyIndexes[gBattlerTarget])))
{
gBattlescriptCurrInstr = cmd->failInstr;
}
@ -14619,7 +14619,7 @@ static void Cmd_switchoutabilities(void)
case ABILITY_NATURAL_CURE:
gBattleMons[battler].status1 = 0;
BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_STATUS_BATTLE,
gBitTable[*(gBattleStruct->battlerPartyIndexes + battler)],
1u << *(gBattleStruct->battlerPartyIndexes + battler),
sizeof(gBattleMons[battler].status1),
&gBattleMons[battler].status1);
MarkBattlerForControllerExec(battler);
@ -14630,7 +14630,7 @@ static void Cmd_switchoutabilities(void)
if (gBattleMoveDamage > gBattleMons[battler].maxHP)
gBattleMoveDamage = gBattleMons[battler].maxHP;
BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_HP_BATTLE,
gBitTable[*(gBattleStruct->battlerPartyIndexes + battler)],
1u << *(gBattleStruct->battlerPartyIndexes + battler),
sizeof(gBattleMoveDamage),
&gBattleMoveDamage);
MarkBattlerForControllerExec(battler);
@ -14915,7 +14915,7 @@ static void Cmd_pursuitdoubles(void)
u32 battler = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker)));
if (IsDoubleBattle()
&& !(gAbsentBattlerFlags & gBitTable[battler])
&& !(gAbsentBattlerFlags & (1u << battler))
&& gChosenActionByBattler[battler] == B_ACTION_USE_MOVE
&& gMovesInfo[gChosenMoveByBattler[battler]].effect == EFFECT_PURSUIT)
{
@ -16206,7 +16206,7 @@ void BS_ItemRestoreHP(void)
// Revived battlers on the field need to be brought back.
if (IsDoubleBattle() && battler != MAX_BATTLERS_COUNT)
{
gAbsentBattlerFlags &= ~gBitTable[battler];
gAbsentBattlerFlags &= ~(1u << battler);
gBattleMons[battler].hp = hp;
gBattleCommunication[MULTIUSE_STATE] = TRUE;
}

View file

@ -114,14 +114,14 @@ u32 GetBattlerTeraType(u32 battler)
void ExpendTypeStellarBoost(u32 battler, u32 type)
{
if (type < 32 && gBattleMons[battler].species != SPECIES_TERAPAGOS_STELLAR) // avoid OOB access
gBattleStruct->stellarBoostFlags[GetBattlerSide(battler)] |= gBitTable[type];
gBattleStruct->stellarBoostFlags[GetBattlerSide(battler)] |= 1u << type;
}
// Checks whether a type's Stellar boost has been expended.
bool32 IsTypeStellarBoosted(u32 battler, u32 type)
{
if (type < 32) // avoid OOB access
return !(gBattleStruct->stellarBoostFlags[GetBattlerSide(battler)] & gBitTable[type]);
return !(gBattleStruct->stellarBoostFlags[GetBattlerSide(battler)] & (1u << type));
else
return FALSE;
}

View file

@ -130,7 +130,7 @@ void HandleAction_UseMove(void)
u16 moveTarget;
gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber];
if (gBattleStruct->absentBattlerFlags & gBitTable[gBattlerAttacker] || !IsBattlerAlive(gBattlerAttacker))
if (gBattleStruct->absentBattlerFlags & (1u << gBattlerAttacker) || !IsBattlerAlive(gBattlerAttacker))
{
gCurrentActionFuncId = B_ACTION_FINISHED;
return;
@ -322,7 +322,7 @@ void HandleAction_UseMove(void)
gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
}
if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]
if (gAbsentBattlerFlags & (1u << gBattlerTarget)
&& GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget))
{
gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget)));
@ -964,29 +964,29 @@ static void UNUSED MarkAllBattlersForControllerExec(void)
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
for (i = 0; i < gBattlersCount; i++)
gBattleControllerExecFlags |= gBitTable[i] << (32 - MAX_BATTLERS_COUNT);
gBattleControllerExecFlags |= 1u << (i + 32 - MAX_BATTLERS_COUNT);
}
else
{
for (i = 0; i < gBattlersCount; i++)
gBattleControllerExecFlags |= gBitTable[i];
gBattleControllerExecFlags |= 1 << i;
}
}
bool32 IsBattlerMarkedForControllerExec(u32 battler)
{
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
return (gBattleControllerExecFlags & (gBitTable[battler] << 0x1C)) != 0;
return (gBattleControllerExecFlags & (1 << (battler + 28))) != 0;
else
return (gBattleControllerExecFlags & (gBitTable[battler])) != 0;
return (gBattleControllerExecFlags & (1 << battler)) != 0;
}
void MarkBattlerForControllerExec(u32 battler)
{
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
gBattleControllerExecFlags |= gBitTable[battler] << (32 - MAX_BATTLERS_COUNT);
gBattleControllerExecFlags |= 1u << (32 - MAX_BATTLERS_COUNT);
else
gBattleControllerExecFlags |= gBitTable[battler];
gBattleControllerExecFlags |= 1u << battler;
}
void MarkBattlerReceivedLinkData(u32 battler)
@ -994,9 +994,9 @@ void MarkBattlerReceivedLinkData(u32 battler)
s32 i;
for (i = 0; i < GetLinkPlayerCount(); i++)
gBattleControllerExecFlags |= gBitTable[battler] << (i << 2);
gBattleControllerExecFlags |= 1u << (battler + (i << 2));
gBattleControllerExecFlags &= ~((1 << 28) << battler);
gBattleControllerExecFlags &= ~(1u << (28 + battler));
}
const u8* CancelMultiTurnMoves(u32 battler)
@ -1172,7 +1172,7 @@ void ResetSentPokesToOpponentValue(void)
gSentPokesToOpponent[1] = 0;
for (i = 0; i < gBattlersCount; i += 2)
bits |= gBitTable[gBattlerPartyIndexes[i]];
bits |= 1u << gBattlerPartyIndexes[i];
for (i = 1; i < gBattlersCount; i += 2)
gSentPokesToOpponent[(i & BIT_FLANK) >> 1] = bits;
@ -1190,8 +1190,8 @@ void OpponentSwitchInResetSentPokesToOpponentValue(u32 battler)
for (i = 0; i < gBattlersCount; i += 2)
{
if (!(gAbsentBattlerFlags & gBitTable[i]))
bits |= gBitTable[gBattlerPartyIndexes[i]];
if (!(gAbsentBattlerFlags & (1u << i)))
bits |= 1u << gBattlerPartyIndexes[i];
}
gSentPokesToOpponent[flank] = bits;
}
@ -1207,7 +1207,7 @@ void UpdateSentPokesToOpponentValue(u32 battler)
{
s32 i;
for (i = 1; i < gBattlersCount; i++)
gSentPokesToOpponent[(i & BIT_FLANK) >> 1] |= gBitTable[gBattlerPartyIndexes[battler]];
gSentPokesToOpponent[(i & BIT_FLANK) >> 1] |= 1u << gBattlerPartyIndexes[battler];
}
}
@ -1248,7 +1248,7 @@ bool32 IsBelchPreventingMove(u32 battler, u32 move)
if (gMovesInfo[move].effect != EFFECT_BELCH)
return FALSE;
return !(gBattleStruct->ateBerry[battler & BIT_SIDE] & gBitTable[gBattlerPartyIndexes[battler]]);
return !(gBattleStruct->ateBerry[battler & BIT_SIDE] & (1u << gBattlerPartyIndexes[battler]));
}
// Dynamax bypasses all selection prevention except Taunt and Assault Vest.
@ -1513,55 +1513,55 @@ u8 CheckMoveLimitations(u32 battler, u8 unusableMoves, u16 check)
moveEffect = gMovesInfo[move].effect;
// No move
if (check & MOVE_LIMITATION_ZEROMOVE && move == MOVE_NONE)
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// No PP
else if (check & MOVE_LIMITATION_PP && gBattleMons[battler].pp[i] == 0)
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Placeholder
else if (check & MOVE_LIMITATION_PLACEHOLDER && moveEffect == EFFECT_PLACEHOLDER)
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Disable
else if (check & MOVE_LIMITATION_DISABLED && move == gDisableStructs[battler].disabledMove)
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Torment
else if (check & MOVE_LIMITATION_TORMENTED && move == gLastMoves[battler] && gBattleMons[battler].status2 & STATUS2_TORMENT)
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Taunt
else if (check & MOVE_LIMITATION_TAUNT && gDisableStructs[battler].tauntTimer && IS_MOVE_STATUS(move))
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Imprison
else if (check & MOVE_LIMITATION_IMPRISON && GetImprisonedMovesCount(battler, move))
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Encore
else if (check & MOVE_LIMITATION_ENCORE && gDisableStructs[battler].encoreTimer && gDisableStructs[battler].encoredMove != move)
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Choice Items
else if (check & MOVE_LIMITATION_CHOICE_ITEM && HOLD_EFFECT_CHOICE(holdEffect) && *choicedMove != MOVE_NONE && *choicedMove != MOVE_UNAVAILABLE && *choicedMove != move)
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Assault Vest
else if (check & MOVE_LIMITATION_ASSAULT_VEST && holdEffect == HOLD_EFFECT_ASSAULT_VEST && IS_MOVE_STATUS(move) && gMovesInfo[move].effect != EFFECT_ME_FIRST)
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Gravity
else if (check & MOVE_LIMITATION_GRAVITY && IsGravityPreventingMove(move))
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Heal Block
else if (check & MOVE_LIMITATION_HEAL_BLOCK && IsHealBlockPreventingMove(battler, move))
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Belch
else if (check & MOVE_LIMITATION_BELCH && IsBelchPreventingMove(battler, move))
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Throat Chop
else if (check & MOVE_LIMITATION_THROAT_CHOP && gDisableStructs[battler].throatChopTimer && gMovesInfo[move].soundMove)
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Stuff Cheeks
else if (check & MOVE_LIMITATION_STUFF_CHEEKS && moveEffect == EFFECT_STUFF_CHEEKS && ItemId_GetPocket(gBattleMons[battler].item) != POCKET_BERRIES)
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Gorilla Tactics
else if (check & MOVE_LIMITATION_CHOICE_ITEM && GetBattlerAbility(battler) == ABILITY_GORILLA_TACTICS && *choicedMove != MOVE_NONE && *choicedMove != MOVE_UNAVAILABLE && *choicedMove != move)
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
// Can't Use Twice flag
else if (check & MOVE_LIMITATION_CANT_USE_TWICE && gMovesInfo[move].cantUseTwice && move == gLastResultingMoves[battler])
unusableMoves |= gBitTable[i];
unusableMoves |= 1u << i;
}
return unusableMoves;
}
@ -1703,10 +1703,10 @@ u8 DoFieldEndTurnEffects(void)
{
u8 effect = 0;
for (gBattlerAttacker = 0; gBattlerAttacker < gBattlersCount && gAbsentBattlerFlags & gBitTable[gBattlerAttacker]; gBattlerAttacker++)
for (gBattlerAttacker = 0; gBattlerAttacker < gBattlersCount && gAbsentBattlerFlags & (1u << gBattlerAttacker); gBattlerAttacker++)
{
}
for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount && gAbsentBattlerFlags & gBitTable[gBattlerTarget]; gBattlerTarget++)
for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount && gAbsentBattlerFlags & (1u << gBattlerTarget); gBattlerTarget++)
{
}
@ -2370,7 +2370,7 @@ u8 DoBattlerEndTurnEffects(void)
while (gBattleStruct->turnEffectsBattlerId < gBattlersCount && gBattleStruct->turnEffectsTracker <= ENDTURN_BATTLER_COUNT)
{
battler = gBattlerAttacker = gBattlerByTurnOrder[gBattleStruct->turnEffectsBattlerId];
if (gAbsentBattlerFlags & gBitTable[battler])
if (gAbsentBattlerFlags & (1u << battler))
{
gBattleStruct->turnEffectsBattlerId++;
continue;
@ -3032,7 +3032,7 @@ bool32 HandleWishPerishSongOnTurnEnd(void)
if (gWishFutureKnock.futureSightCounter[battler] != 0
&& --gWishFutureKnock.futureSightCounter[battler] == 0
&& !(gAbsentBattlerFlags & gBitTable[battler]))
&& !(gAbsentBattlerFlags & (1u << battler)))
{
struct Pokemon *party;
@ -3073,7 +3073,7 @@ bool32 HandleWishPerishSongOnTurnEnd(void)
while (gBattleStruct->wishPerishSongBattlerId < gBattlersCount)
{
battler = gBattlerAttacker = gBattlerByTurnOrder[gBattleStruct->wishPerishSongBattlerId];
if (gAbsentBattlerFlags & gBitTable[battler])
if (gAbsentBattlerFlags & (1u << battler))
{
gBattleStruct->wishPerishSongBattlerId++;
continue;
@ -3139,8 +3139,8 @@ bool32 HandleFaintedMonActions(void)
gBattleStruct->faintedActionsState++;
for (i = 0; i < gBattlersCount; i++)
{
if (gAbsentBattlerFlags & gBitTable[i] && !HasNoMonsToSwitch(i, PARTY_SIZE, PARTY_SIZE))
gAbsentBattlerFlags &= ~(gBitTable[i]);
if (gAbsentBattlerFlags & (1u << i) && !HasNoMonsToSwitch(i, PARTY_SIZE, PARTY_SIZE))
gAbsentBattlerFlags &= ~(1u << i);
}
// fall through
case 1:
@ -3148,8 +3148,8 @@ bool32 HandleFaintedMonActions(void)
{
gBattlerFainted = gBattlerTarget = gBattleStruct->faintedActionsBattlerId;
if (gBattleMons[gBattleStruct->faintedActionsBattlerId].hp == 0
&& !(gBattleStruct->givenExpMons & gBitTable[gBattlerPartyIndexes[gBattleStruct->faintedActionsBattlerId]])
&& !(gAbsentBattlerFlags & gBitTable[gBattleStruct->faintedActionsBattlerId]))
&& !(gBattleStruct->givenExpMons & (1u << gBattlerPartyIndexes[gBattleStruct->faintedActionsBattlerId]))
&& !(gAbsentBattlerFlags & (1u << gBattleStruct->faintedActionsBattlerId)))
{
BattleScriptExecute(BattleScript_GiveExp);
gBattleStruct->faintedActionsState = 2;
@ -3170,7 +3170,7 @@ bool32 HandleFaintedMonActions(void)
&& !NoAliveMonsForEitherParty()
&& gCurrentTurnActionNumber != gBattlersCount)
{
gAbsentBattlerFlags |= gBitTable[gBattlerFainted];
gAbsentBattlerFlags |= 1u << gBattlerFainted;
if (gBattleStruct->faintedActionsState != 1)
return FALSE;
}
@ -3192,7 +3192,7 @@ bool32 HandleFaintedMonActions(void)
{
gBattlerFainted = gBattlerTarget = gBattleStruct->faintedActionsBattlerId;
if (gBattleMons[gBattleStruct->faintedActionsBattlerId].hp == 0
&& !(gAbsentBattlerFlags & gBitTable[gBattleStruct->faintedActionsBattlerId]))
&& !(gAbsentBattlerFlags & (1u << gBattleStruct->faintedActionsBattlerId)))
{
BattleScriptExecute(BattleScript_HandleFaintedMon);
gBattleStruct->faintedActionsState = 5;
@ -3498,7 +3498,7 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType)
gCurrentMove = MOVE_BIDE;
gBattleScripting.bideDmg = gBideDmg[gBattlerAttacker] * 2;
gBattlerTarget = gBideTarget[gBattlerAttacker];
if (gAbsentBattlerFlags & gBitTable[gBattlerTarget])
if (gAbsentBattlerFlags & (1u << gBattlerTarget))
gBattlerTarget = GetMoveTarget(MOVE_BIDE, MOVE_TARGET_SELECTED + 1);
gBattlescriptCurrInstr = BattleScript_BideAttack;
}
@ -4731,11 +4731,11 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
break;
case ABILITY_SUPERSWEET_SYRUP:
if (!gSpecialStatuses[battler].switchInAbilityDone
&& !(gBattleStruct->supersweetSyrup[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]]))
&& !(gBattleStruct->supersweetSyrup[GetBattlerSide(battler)] & (1u << gBattlerPartyIndexes[battler])))
{
gBattlerAttacker = battler;
gSpecialStatuses[battler].switchInAbilityDone = TRUE;
gBattleStruct->supersweetSyrup[GetBattlerSide(battler)] |= gBitTable[gBattlerPartyIndexes[battler]];
gBattleStruct->supersweetSyrup[GetBattlerSide(battler)] |= (1u << gBattlerPartyIndexes[battler]);
BattleScriptPushCursorAndCallback(BattleScript_SupersweetSyrupActivates);
effect++;
}
@ -4772,12 +4772,12 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
break;
case ABILITY_INTREPID_SWORD:
if (!gSpecialStatuses[battler].switchInAbilityDone && CompareStat(battler, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN)
&& !(gBattleStruct->intrepidSwordBoost[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]]))
&& !(gBattleStruct->intrepidSwordBoost[GetBattlerSide(battler)] & (1u << gBattlerPartyIndexes[battler])))
{
gBattleScripting.savedBattler = gBattlerAttacker;
gBattlerAttacker = battler;
if (B_INTREPID_SWORD == GEN_9)
gBattleStruct->intrepidSwordBoost[GetBattlerSide(battler)] |= gBitTable[gBattlerPartyIndexes[battler]];
gBattleStruct->intrepidSwordBoost[GetBattlerSide(battler)] |= 1u << gBattlerPartyIndexes[battler];
gSpecialStatuses[battler].switchInAbilityDone = TRUE;
SET_STATCHANGER(STAT_ATK, 1, FALSE);
BattleScriptPushCursorAndCallback(BattleScript_BattlerAbilityStatRaiseOnSwitchIn);
@ -4786,12 +4786,12 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
break;
case ABILITY_DAUNTLESS_SHIELD:
if (!gSpecialStatuses[battler].switchInAbilityDone && CompareStat(battler, STAT_DEF, MAX_STAT_STAGE, CMP_LESS_THAN)
&& !(gBattleStruct->dauntlessShieldBoost[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]]))
&& !(gBattleStruct->dauntlessShieldBoost[GetBattlerSide(battler)] & (1u << gBattlerPartyIndexes[battler])))
{
gBattleScripting.savedBattler = gBattlerAttacker;
gBattlerAttacker = battler;
if (B_DAUNTLESS_SHIELD == GEN_9)
gBattleStruct->dauntlessShieldBoost[GetBattlerSide(battler)] |= gBitTable[gBattlerPartyIndexes[battler]];
gBattleStruct->dauntlessShieldBoost[GetBattlerSide(battler)] |= 1u << gBattlerPartyIndexes[battler];
gSpecialStatuses[battler].switchInAbilityDone = TRUE;
SET_STATCHANGER(STAT_DEF, 1, FALSE);
BattleScriptPushCursorAndCallback(BattleScript_BattlerAbilityStatRaiseOnSwitchIn);
@ -4895,11 +4895,11 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
if (!gSpecialStatuses[battler].switchInAbilityDone
&& GetMonData(mon, MON_DATA_SPECIES) == SPECIES_PALAFIN_HERO
&& !(gBattleStruct->transformZeroToHero[side] & gBitTable[gBattlerPartyIndexes[battler]]))
&& !(gBattleStruct->transformZeroToHero[side] & (1u << gBattlerPartyIndexes[battler])))
{
gSpecialStatuses[battler].switchInAbilityDone = TRUE;
gBattlerAttacker = battler;
gBattleStruct->transformZeroToHero[side] |= gBitTable[gBattlerPartyIndexes[battler]];
gBattleStruct->transformZeroToHero[side] |= 1u << gBattlerPartyIndexes[battler];
BattleScriptPushCursorAndCallback(BattleScript_ZeroToHeroActivates);
effect++;
}
@ -5046,9 +5046,9 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
for (i = STAT_ATK; i < statsNum; i++)
{
if (CompareStat(battler, i, MIN_STAT_STAGE, CMP_GREATER_THAN))
validToLower |= gBitTable[i];
validToLower |= 1u << i;
if (CompareStat(battler, i, MAX_STAT_STAGE, CMP_LESS_THAN))
validToRaise |= gBitTable[i];
validToRaise |= 1u << i;
}
if (validToLower != 0 || validToRaise != 0) // Can lower one stat, or can raise one stat
@ -5059,16 +5059,16 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
do
{
i = (Random() % statsNum) + STAT_ATK;
} while (!(validToRaise & gBitTable[i]));
} while (!(validToRaise & (1u << i)));
SET_STATCHANGER(i, 2, FALSE);
validToLower &= ~(gBitTable[i]); // Can't lower the same stat as raising.
validToLower &= ~(1u << i); // Can't lower the same stat as raising.
}
if (validToLower != 0) // Find stat to lower
{
do
{
i = (Random() % statsNum) + STAT_ATK;
} while (!(validToLower & gBitTable[i]));
} while (!(validToLower & (1u << i)));
SET_STATCHANGER2(gBattleScripting.savedStatChanger, i, 1, TRUE);
}
BattleScriptPushCursorAndCallback(BattleScript_MoodyActivates);
@ -7560,13 +7560,13 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
effect = TryConsumeMirrorHerb(battler, TRUE);
break;
case HOLD_EFFECT_BOOSTER_ENERGY:
if (!(gBattleStruct->boosterEnergyActivates & gBitTable[battler])
if (!(gBattleStruct->boosterEnergyActivates & (1u << battler))
&& (((GetBattlerAbility(battler) == ABILITY_PROTOSYNTHESIS) && !(gBattleWeather & B_WEATHER_SUN))
|| ((GetBattlerAbility(battler) == ABILITY_QUARK_DRIVE) && !(gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN))))
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, GetHighestStatId(battler));
gBattleScripting.battler = battler;
gBattleStruct->boosterEnergyActivates |= gBitTable[battler];
gBattleStruct->boosterEnergyActivates |= 1u << battler;
BattleScriptExecute(BattleScript_BoosterEnergyEnd2);
effect = ITEM_EFFECT_OTHER;
}
@ -7827,13 +7827,13 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
effect = TryConsumeMirrorHerb(battler, TRUE);
break;
case HOLD_EFFECT_BOOSTER_ENERGY:
if (!(gBattleStruct->boosterEnergyActivates & gBitTable[battler])
if (!(gBattleStruct->boosterEnergyActivates & (1u << battler))
&& (((GetBattlerAbility(battler) == ABILITY_PROTOSYNTHESIS) && !(gBattleWeather & B_WEATHER_SUN))
|| ((GetBattlerAbility(battler) == ABILITY_QUARK_DRIVE) && !(gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN))))
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, GetHighestStatId(battler));
gBattlerAbility = gBattleScripting.battler = battler;
gBattleStruct->boosterEnergyActivates |= gBitTable[battler];
gBattleStruct->boosterEnergyActivates |= 1u << battler;
BattleScriptExecute(BattleScript_BoosterEnergyEnd2);
effect = ITEM_EFFECT_OTHER;
}
@ -8210,7 +8210,7 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
// Berry was successfully used on a Pokemon.
if (effect && (gLastUsedItem >= FIRST_BERRY_INDEX && gLastUsedItem <= LAST_BERRY_INDEX))
gBattleStruct->ateBerry[battler & BIT_SIDE] |= gBitTable[gBattlerPartyIndexes[battler]];
gBattleStruct->ateBerry[battler & BIT_SIDE] |= 1u << gBattlerPartyIndexes[battler];
return effect;
}
@ -8401,7 +8401,7 @@ u8 IsMonDisobedient(void)
calc = (levelReferenced + obedienceLevel) * rnd >> 8;
if (calc < obedienceLevel)
{
calc = CheckMoveLimitations(gBattlerAttacker, gBitTable[gCurrMovePos], MOVE_LIMITATIONS_ALL);
calc = CheckMoveLimitations(gBattlerAttacker, 1u << gCurrMovePos, MOVE_LIMITATIONS_ALL);
if (calc == ALL_MOVES_MASK) // all moves cannot be used
{
// Randomly select, then print a disobedient string
@ -8415,7 +8415,7 @@ u8 IsMonDisobedient(void)
do
{
gCurrMovePos = gChosenMovePos = MOD(Random(), MAX_MON_MOVES);
} while (gBitTable[gCurrMovePos] & calc);
} while ((1u << gCurrMovePos) & calc);
gCalledMove = gBattleMons[gBattlerAttacker].moves[gCurrMovePos];
SetAtkCancellerForCalledMove();
@ -8630,7 +8630,7 @@ bool32 IsBattlerAlive(u32 battler)
return FALSE;
else if (battler >= gBattlersCount)
return FALSE;
else if (gAbsentBattlerFlags & gBitTable[battler])
else if (gAbsentBattlerFlags & (1u << battler))
return FALSE;
else
return TRUE;
@ -8703,12 +8703,12 @@ u32 GetMoveTargetCount(u32 move, u32 battlerAtk, u32 battlerDef)
switch (GetBattlerMoveTargetType(gBattlerAttacker, move))
{
case MOVE_TARGET_BOTH:
return !(gAbsentBattlerFlags & gBitTable[battlerDef])
+ !(gAbsentBattlerFlags & gBitTable[BATTLE_PARTNER(battlerDef)]);
return !(gAbsentBattlerFlags & (1u << battlerDef))
+ !(gAbsentBattlerFlags & (1u << BATTLE_PARTNER(battlerDef)));
case MOVE_TARGET_FOES_AND_ALLY:
return !(gAbsentBattlerFlags & gBitTable[battlerDef])
+ !(gAbsentBattlerFlags & gBitTable[BATTLE_PARTNER(battlerDef)])
+ !(gAbsentBattlerFlags & gBitTable[BATTLE_PARTNER(battlerAtk)]);
return !(gAbsentBattlerFlags & (1u << battlerDef))
+ !(gAbsentBattlerFlags & (1u << BATTLE_PARTNER(battlerDef)))
+ !(gAbsentBattlerFlags & (1u << BATTLE_PARTNER(battlerAtk)));
case MOVE_TARGET_OPPONENTS_FIELD:
return 1;
case MOVE_TARGET_DEPENDS:
@ -9126,7 +9126,7 @@ static inline u32 CalcMoveBasePowerAfterModifiers(u32 move, u32 battlerAtk, u32
modifier = uq4_12_multiply(modifier, UQ_4_12(0.5));
break;
case EFFECT_STOMPING_TANTRUM:
if (gBattleStruct->lastMoveFailed & gBitTable[battlerAtk])
if (gBattleStruct->lastMoveFailed & (1u << battlerAtk))
modifier = uq4_12_multiply(modifier, UQ_4_12(2.0));
break;
case EFFECT_MAGNITUDE:
@ -9281,7 +9281,7 @@ static inline u32 CalcMoveBasePowerAfterModifiers(u32 move, u32 battlerAtk, u32
case ABILITY_PROTOSYNTHESIS:
{
u8 atkHighestStat = GetHighestStatId(battlerAtk);
if ((weather & B_WEATHER_SUN || gBattleStruct->boosterEnergyActivates & gBitTable[battlerAtk])
if ((weather & B_WEATHER_SUN || gBattleStruct->boosterEnergyActivates & (1u << battlerAtk))
&& ((IS_MOVE_PHYSICAL(move) && atkHighestStat == STAT_ATK) || (IS_MOVE_SPECIAL(move) && atkHighestStat == STAT_SPATK)))
modifier = uq4_12_multiply(modifier, UQ_4_12(1.3));
}
@ -9289,7 +9289,7 @@ static inline u32 CalcMoveBasePowerAfterModifiers(u32 move, u32 battlerAtk, u32
case ABILITY_QUARK_DRIVE:
{
u8 atkHighestStat = GetHighestStatId(battlerAtk);
if ((gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN || gBattleStruct->boosterEnergyActivates & gBitTable[battlerAtk])
if ((gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN || gBattleStruct->boosterEnergyActivates & (1u << battlerAtk))
&& ((IS_MOVE_PHYSICAL(move) && atkHighestStat == STAT_ATK) || (IS_MOVE_SPECIAL(move) && atkHighestStat == STAT_SPATK)))
modifier = uq4_12_multiply(modifier, UQ_4_12(1.3));
}
@ -9359,7 +9359,7 @@ static inline u32 CalcMoveBasePowerAfterModifiers(u32 move, u32 battlerAtk, u32
case ABILITY_PROTOSYNTHESIS:
{
u8 defHighestStat = GetHighestStatId(battlerDef);
if ((weather & B_WEATHER_SUN || gBattleStruct->boosterEnergyActivates & gBitTable[battlerDef])
if ((weather & B_WEATHER_SUN || gBattleStruct->boosterEnergyActivates & (1u << battlerDef))
&& ((IS_MOVE_PHYSICAL(move) && defHighestStat == STAT_DEF) || (IS_MOVE_SPECIAL(move) && defHighestStat == STAT_SPDEF)))
modifier = uq4_12_multiply(modifier, UQ_4_12(0.7));
}
@ -9367,7 +9367,7 @@ static inline u32 CalcMoveBasePowerAfterModifiers(u32 move, u32 battlerAtk, u32
case ABILITY_QUARK_DRIVE:
{
u8 defHighestStat = GetHighestStatId(battlerDef);
if ((gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN || gBattleStruct->boosterEnergyActivates & gBitTable[battlerDef])
if ((gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN || gBattleStruct->boosterEnergyActivates & (1u << battlerDef))
&& ((IS_MOVE_PHYSICAL(move) && defHighestStat == STAT_DEF) || (IS_MOVE_SPECIAL(move) && defHighestStat == STAT_SPDEF)))
modifier = uq4_12_multiply(modifier, UQ_4_12(0.7));
}
@ -10335,7 +10335,7 @@ static inline void MulByTypeEffectiveness(uq4_12_t *modifier, u32 move, u32 move
mod = UQ_4_12(1.0);
}
if (gBattleStruct->distortedTypeMatchups & gBitTable[battlerDef] || (gBattleStruct->aiCalcInProgress && ShouldTeraShellDistortTypeMatchups(move, battlerDef)))
if (gBattleStruct->distortedTypeMatchups & (1u << battlerDef) || (gBattleStruct->aiCalcInProgress && ShouldTeraShellDistortTypeMatchups(move, battlerDef)))
{
mod = UQ_4_12(0.5);
if (recordAbilities)
@ -11245,7 +11245,7 @@ bool32 CanStealItem(u32 battlerStealing, u32 battlerItem, u16 item)
| BATTLE_TYPE_LINK
| BATTLE_TYPE_RECORDED_LINK
| BATTLE_TYPE_SECRET_BASE))
&& (gWishFutureKnock.knockedOffMons[stealerSide] & gBitTable[gBattlerPartyIndexes[battlerStealing]]))
&& (gWishFutureKnock.knockedOffMons[stealerSide] & (1u << gBattlerPartyIndexes[battlerStealing])))
{
return FALSE;
}

View file

@ -209,13 +209,13 @@ void AssignUsableZMoves(u32 battler, u16 *moves)
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i] != MOVE_NONE && IsViableZMove(battler, moves[i]))
gBattleStruct->zmove.possibleZMoves[battler] |= gBitTable[i];
gBattleStruct->zmove.possibleZMoves[battler] |= 1u << i;
}
}
bool32 TryChangeZTrigger(u32 battler, u32 moveIndex)
{
bool32 viableZMove = (gBattleStruct->zmove.possibleZMoves[battler] & gBitTable[moveIndex]) != 0;
bool32 viableZMove = (gBattleStruct->zmove.possibleZMoves[battler] & (1u << moveIndex)) != 0;
if (gBattleStruct->zmove.viable && !viableZMove)
HideGimmickTriggerSprite(); // Was a viable z move, now is not -> slide out

View file

@ -2080,14 +2080,14 @@ u8 CountAliveMonsInBattle(u8 caseId, u32 battler)
case BATTLE_ALIVE_EXCEPT_BATTLER:
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (i != battler && !(gAbsentBattlerFlags & gBitTable[i]))
if (i != battler && !(gAbsentBattlerFlags & (1u << i)))
retVal++;
}
break;
case BATTLE_ALIVE_SIDE:
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (GetBattlerSide(i) == GetBattlerSide(battler) && !(gAbsentBattlerFlags & gBitTable[i]))
if (GetBattlerSide(i) == GetBattlerSide(battler) && !(gAbsentBattlerFlags & (1u << i)))
retVal++;
}
break;
@ -2115,7 +2115,7 @@ u8 GetDefaultMoveTarget(u8 battlerId)
}
else
{
if ((gAbsentBattlerFlags & gBitTable[opposing]))
if ((gAbsentBattlerFlags & (1u << opposing)))
return GetBattlerAtPosition(BATTLE_PARTNER(opposing));
else
return GetBattlerAtPosition(opposing);
@ -2691,7 +2691,7 @@ u32 GetBoxMonData3(struct BoxPokemon *boxMon, s32 field, u8 *data)
|| substruct1->move2 == move
|| substruct1->move3 == move
|| substruct1->move4 == move)
retVal |= gBitTable[i];
retVal |= (1u << i);
i++;
}
}
@ -5316,7 +5316,7 @@ void RandomlyGivePartyPokerus(struct Pokemon *party)
}
while (!GetMonData(mon, MON_DATA_SPECIES, 0) || GetMonData(mon, MON_DATA_IS_EGG, 0));
if (!(CheckPartyHasHadPokerus(party, gBitTable[rnd])))
if (!(CheckPartyHasHadPokerus(party, 1u << rnd)))
{
u8 rnd2;
@ -6651,9 +6651,9 @@ void TrySpecialOverworldEvo(void)
for (i = 0; i < PARTY_SIZE; i++)
{
u16 targetSpecies = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_OVERWORLD_SPECIAL, evoMethod, SPECIES_NONE);
if (targetSpecies != SPECIES_NONE && !(sTriedEvolving & gBitTable[i]))
if (targetSpecies != SPECIES_NONE && !(sTriedEvolving & (1u << i)))
{
sTriedEvolving |= gBitTable[i];
sTriedEvolving |= 1u << i;
if(gMain.callback2 == TrySpecialOverworldEvo) // This fixes small graphics glitches.
EvolutionScene(&gPlayerParty[i], targetSpecies, canStopEvo, i);
else

View file

@ -741,7 +741,7 @@ void RecordedBattle_CheckMovesetChanges(u8 mode)
movePp.moves[j] = gBattleMons[battlerId].moves[moveSlots[j]];
movePp.currentPp[j] = gBattleMons[battlerId].pp[moveSlots[j]];
movePp.maxPp[j] = ppBonuses[moveSlots[j]];
mimickedMoveSlots[j] = (gDisableStructs[battlerId].mimickedMoves & gBitTable[j]) >> j;
mimickedMoveSlots[j] = (gDisableStructs[battlerId].mimickedMoves & (1u << j)) >> j;
}
for (j = 0; j < MAX_MON_MOVES; j++)
{

View file

@ -142,19 +142,19 @@ static void LoadObjectEventIdFromMovementScript(u8 taskId, u8 moveScrId, u8 *obj
static void ClearMovementScriptFinished(u8 taskId, u8 moveScrId)
{
u16 mask = ~gBitTable[moveScrId];
u16 mask = ~(1u << moveScrId);
gTasks[taskId].data[0] &= mask;
}
static void SetMovementScriptFinished(u8 taskId, u8 moveScrId)
{
gTasks[taskId].data[0] |= gBitTable[moveScrId];
gTasks[taskId].data[0] |= (1u << moveScrId);
}
static bool8 IsMovementScriptFinished(u8 taskId, u8 moveScrId)
{
u16 moveScriptFinished = (u16)gTasks[taskId].data[0] & gBitTable[moveScrId];
u16 moveScriptFinished = (u16)gTasks[taskId].data[0] & (1u << moveScrId);
if (moveScriptFinished != 0)
return TRUE;

View file

@ -852,7 +852,7 @@ bool8 GetHillTrainerFlag(u8 objectEventId)
u32 trainerIndexStart = GetFloorId() * HILL_TRAINERS_PER_FLOOR;
u8 bitId = gObjectEvents[objectEventId].localId - 1 + trainerIndexStart;
return gSaveBlock2Ptr->frontier.trainerFlags & gBitTable[bitId];
return gSaveBlock2Ptr->frontier.trainerFlags & (1u << bitId);
}
void SetHillTrainerFlag(void)
@ -864,7 +864,7 @@ void SetHillTrainerFlag(void)
{
if (gSaveBlock2Ptr->frontier.trainerIds[i] == gTrainerBattleOpponent_A)
{
gSaveBlock2Ptr->frontier.trainerFlags |= gBitTable[trainerIndexStart + i];
gSaveBlock2Ptr->frontier.trainerFlags |= 1u << (trainerIndexStart + i);
break;
}
}
@ -875,7 +875,7 @@ void SetHillTrainerFlag(void)
{
if (gSaveBlock2Ptr->frontier.trainerIds[i] == gTrainerBattleOpponent_B)
{
gSaveBlock2Ptr->frontier.trainerFlags |= gBitTable[trainerIndexStart + i];
gSaveBlock2Ptr->frontier.trainerFlags |= 1u << (trainerIndexStart + i);
break;
}
}

View file

@ -4,42 +4,6 @@
#include "palette.h"
#include "constants/rgb.h"
const u32 gBitTable[] =
{
1 << 0,
1 << 1,
1 << 2,
1 << 3,
1 << 4,
1 << 5,
1 << 6,
1 << 7,
1 << 8,
1 << 9,
1 << 10,
1 << 11,
1 << 12,
1 << 13,
1 << 14,
1 << 15,
1 << 16,
1 << 17,
1 << 18,
1 << 19,
1 << 20,
1 << 21,
1 << 22,
1 << 23,
1 << 24,
1 << 25,
1 << 26,
1 << 27,
1 << 28,
1 << 29,
1 << 30,
1 << 31,
};
static const struct SpriteTemplate sInvisibleSpriteTemplate =
{
.tileTag = 0,

View file

@ -769,7 +769,7 @@ static u32 CountAiExpectMoves(struct ExpectedAIAction *expectedAction, u32 battl
u32 i, countExpected = 0;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (gBitTable[i] & expectedAction->moveSlots)
if ((1u << i) & expectedAction->moveSlots)
{
if (printLog)
PrintAiMoveLog(battlerId, i, gBattleMons[battlerId].moves[i], gBattleStruct->aiFinalScore[battlerId][expectedAction->target][i]);
@ -801,7 +801,7 @@ void TestRunner_Battle_CheckChosenMove(u32 battlerId, u32 moveId, u32 target)
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (gBitTable[i] & expectedAction->moveSlots)
if ((1u << i) & expectedAction->moveSlots)
{
expectedMoveId = gBattleMons[battlerId].moves[i];
if (!expectedAction->notMove)
@ -917,8 +917,8 @@ static void CheckIfMaxScoreEqualExpectMove(u32 battlerId, s32 target, struct Exp
// We expect move 'i', but it has the same best score as another move that we didn't expect.
if (scores[i] == scores[bestScoreId]
&& !aiAction->notMove
&& (aiAction->moveSlots & gBitTable[i])
&& !(aiAction->moveSlots & gBitTable[bestScoreId]))
&& (aiAction->moveSlots & (1u << i))
&& !(aiAction->moveSlots & (1u << bestScoreId)))
{
Test_ExitWithResult(TEST_RESULT_FAIL, SourceLine(0), ":L%s:%d: EXPECT_MOVE %S has the same best score(%d) as not expected MOVE %S", filename,
aiAction->sourceLine, GetMoveName(moves[i]), scores[i], GetMoveName(moves[bestScoreId]));
@ -926,8 +926,8 @@ static void CheckIfMaxScoreEqualExpectMove(u32 battlerId, s32 target, struct Exp
// We DO NOT expect move 'i', but it has the same best score as another move.
if (scores[i] == scores[bestScoreId]
&& aiAction->notMove
&& (aiAction->moveSlots & gBitTable[i])
&& !(aiAction->moveSlots & gBitTable[bestScoreId]))
&& (aiAction->moveSlots & (1u << i))
&& !(aiAction->moveSlots & (1u << bestScoreId)))
{
Test_ExitWithResult(TEST_RESULT_FAIL, SourceLine(0), ":L%s:%d: NOT_EXPECT_MOVE %S has the same best score(%d) as MOVE %S", filename,
aiAction->sourceLine, GetMoveName(moves[i]), scores[i], GetMoveName(moves[bestScoreId]));
@ -940,9 +940,9 @@ static void PrintAiMoveLog(u32 battlerId, u32 moveSlot, u32 moveId, s32 totalSco
s32 i, scoreFromLogs = 0;
if (!DATA.logAI) return;
if (DATA.aiLogPrintedForMove[battlerId] & gBitTable[moveSlot]) return;
if (DATA.aiLogPrintedForMove[battlerId] & (1u << moveSlot)) return;
DATA.aiLogPrintedForMove[battlerId] |= gBitTable[moveSlot];
DATA.aiLogPrintedForMove[battlerId] |= 1u << moveSlot;
Test_MgbaPrintf("Score Log for move %S:\n", GetMoveName(moveId));
for (i = 0; i < MAX_AI_LOG_LINES; i++)
{
@ -2187,7 +2187,7 @@ static void TryMarkExpectMove(u32 sourceLine, struct BattlePokemon *battler, str
id = DATA.expectedAiActionIndex[battlerId];
DATA.expectedAiActions[battlerId][id].type = B_ACTION_USE_MOVE;
DATA.expectedAiActions[battlerId][id].moveSlots |= gBitTable[moveSlot];
DATA.expectedAiActions[battlerId][id].moveSlots |= 1 << moveSlot;
DATA.expectedAiActions[battlerId][id].target = target;
DATA.expectedAiActions[battlerId][id].explicitTarget = ctx->explicitTarget;
DATA.expectedAiActions[battlerId][id].sourceLine = sourceLine;