more constant usage

This commit is contained in:
GriffinR 2019-09-08 12:21:24 -04:00 committed by huderlem
parent 85d97542cd
commit b46c4b6703
9 changed files with 21 additions and 19 deletions

View File

@ -1,17 +1,19 @@
#ifndef POKEEMERALD_MON_MARKINGS_H
#define POKEEMERALD_MON_MARKINGS_H
#define NUM_MON_MARKINGS 4
struct PokemonMarkMenu
{
/*0x0000*/ u16 baseTileTag;
/*0x0002*/ u16 basePaletteTag;
/*0x0004*/ u8 markings; // bit flags
/*0x0005*/ s8 cursorPos;
/*0x0006*/ bool8 markingsArray[4];
/*0x0006*/ bool8 markingsArray[NUM_MON_MARKINGS];
/*0x000A*/ u8 cursorBaseY;
/*0x000B*/ bool8 spriteSheetLoadRequired;
/*0x000C*/ struct Sprite *menuWindowSprites[2]; // upper and lower halves of menu window
/*0x0014*/ struct Sprite *menuMarkingSprites[4];
/*0x0014*/ struct Sprite *menuMarkingSprites[NUM_MON_MARKINGS];
/*0x0024*/ struct Sprite *unkSprite;
/*0x0028*/ struct Sprite *menuTextSprite;
/*0x002C*/ const u8 *frameTiles;

View File

@ -298,7 +298,7 @@ void BattleAI_HandleItemUseBeforeAISetup(u8 defaultScoreMoves)
)
)
{
for (i = 0; i < 4; i++)
for (i = 0; i < MAX_TRAINER_ITEMS; i++)
{
if (gTrainers[gTrainerBattleOpponent_A].items[i] != 0)
{

View File

@ -820,7 +820,7 @@ static bool8 ShouldUseItem(void)
}
}
for (i = 0; i < 4; i++)
for (i = 0; i < MAX_TRAINER_ITEMS; i++)
{
u16 item;
const u8 *itemEffects;

View File

@ -1790,9 +1790,9 @@ static void CB2_HandleStartMultiBattle(void)
gBattleCommunication[SPRITES_INIT_STATE2] = 0;
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
for (id = 0; id < 4 && (gLinkPlayers[id].version & 0xFF) == 3; id++);
for (id = 0; id < MAX_LINK_PLAYERS && (gLinkPlayers[id].version & 0xFF) == VERSION_EMERALD; id++);
if (id == 4)
if (id == MAX_LINK_PLAYERS)
gBattleCommunication[MULTIUSE_STATE] = 8;
else
gBattleCommunication[MULTIUSE_STATE] = 10;
@ -4244,7 +4244,7 @@ static void HandleTurnActionSelectionState(void)
moveInfo.monType1 = gBattleMons[gActiveBattler].type1;
moveInfo.monType2 = gBattleMons[gActiveBattler].type2;
for (i = 0; i < 4; i++)
for (i = 0; i < MAX_MON_MOVES; i++)
{
moveInfo.moves[i] = gBattleMons[gActiveBattler].moves[i];
moveInfo.currentPp[i] = gBattleMons[gActiveBattler].pp[i];

View File

@ -10184,7 +10184,7 @@ static void atkEF_handleballthrow(void)
gBattlescriptCurrInstr = BattleScript_SuccessBallThrow;
SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem);
if (CalculatePlayerPartyCount() == 6)
if (CalculatePlayerPartyCount() == PARTY_SIZE)
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
else
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
@ -10196,7 +10196,7 @@ static void atkEF_handleballthrow(void)
odds = Sqrt(Sqrt(16711680 / odds));
odds = 1048560 / odds;
for (shakes = 0; shakes < 4 && Random() < odds; shakes++);
for (shakes = 0; shakes < BALL_3_SHAKES_SUCCESS && Random() < odds; shakes++);
if (gLastUsedItem == ITEM_MASTER_BALL)
shakes = BALL_3_SHAKES_SUCCESS; // why calculate the shakes before that check?
@ -10209,7 +10209,7 @@ static void atkEF_handleballthrow(void)
gBattlescriptCurrInstr = BattleScript_SuccessBallThrow;
SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem);
if (CalculatePlayerPartyCount() == 6)
if (CalculatePlayerPartyCount() == PARTY_SIZE)
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
else
gBattleCommunication[MULTISTRING_CHOOSER] = 1;

View File

@ -350,7 +350,7 @@ void sub_811FAA4(u8 markings, s16 x, s16 y)
u16 i;
sMenu->cursorPos = 0;
sMenu->markings = markings;
for (i = 0; i < 4; i++)
for (i = 0; i < NUM_MON_MARKINGS; i++)
sMenu->markingsArray[i] = (sMenu->markings >> i) & 1;
sub_811FC80(x, y, sMenu->baseTileTag, sMenu->basePaletteTag);
}
@ -371,7 +371,7 @@ void sub_811FAF8(void)
DestroySprite(sMenu->menuWindowSprites[i]);
sMenu->menuWindowSprites[i] = NULL;
}
for (i = 0; i < 4; i++)
for (i = 0; i < NUM_MON_MARKINGS; i++)
{
if (!sMenu->menuMarkingSprites[i])
return;
@ -422,7 +422,7 @@ bool8 sub_811FBA4(void)
{
case 4:
sMenu->markings = 0;
for (i = 0; i < 4; i++)
for (i = 0; i < NUM_MON_MARKINGS; i++)
sMenu->markings |= sMenu->markingsArray[i] << i;
return FALSE;
case 5:
@ -498,7 +498,7 @@ static void sub_811FC80(s16 x, s16 y, u16 baseTileTag, u16 basePaletteTag)
sprTemplate.callback = sub_811FF40;
sprTemplate.oam = &gUnknown_0859EE84;
for (i = 0; i < 4; i++)
for (i = 0; i < NUM_MON_MARKINGS; i++)
{
spriteId = CreateSprite(&sprTemplate, x + 32, y + 16 + 16 * i, 0);
if (spriteId != MAX_SPRITES)

View File

@ -81,7 +81,7 @@ u32 GetTrainerId(u8 *trainerId)
void CopyTrainerId(u8 *dst, u8 *src)
{
s32 i;
for (i = 0; i < 4; i++)
for (i = 0; i < TRAINER_ID_LENGTH; i++)
dst[i] = src[i];
}

View File

@ -2435,7 +2435,7 @@ static void UpdateAllLinkPlayers(u16 *keys, s32 selfId)
struct TradeRoomPlayer trainer;
s32 i;
for (i = 0; i < 4; i++)
for (i = 0; i < MAX_LINK_PLAYERS; i++)
{
u8 key = keys[i];
u16 setFacing = FACING_NONE;
@ -3026,7 +3026,7 @@ static s32 sub_80878E4(u8 linkPlayerId)
static u8 GetLinkPlayerIdAt(s16 x, s16 y)
{
u8 i;
for (i = 0; i < 4; i++)
for (i = 0; i < MAX_LINK_PLAYERS; i++)
{
if (gLinkPlayerEventObjects[i].active
&& (gLinkPlayerEventObjects[i].movementMode == 0 || gLinkPlayerEventObjects[i].movementMode == 2))

View File

@ -6683,7 +6683,7 @@ u8 sub_806EF08(u8 arg0)
var = (arg0 != 0) ? 2 : 0;
break;
}
for (i = 0; i < 4; i++)
for (i = 0; i < MAX_LINK_PLAYERS; i++)
{
if (gLinkPlayers[i].id == (s16)(var))
break;
@ -6706,7 +6706,7 @@ u8 sub_806EF84(u8 arg0, u8 arg1)
var = (arg0 != 0) ? 2 : 0;
break;
}
for (i = 0; i < 4; i++)
for (i = 0; i < MAX_LINK_PLAYERS; i++)
{
if (gLinkPlayers[i].id == (s16)(var))
break;