Create Macros and refactor

This commit is contained in:
PokeCodec 2020-08-20 10:49:53 -04:00 committed by PokeCodec
parent aa841047a3
commit 608da287c1
3 changed files with 52 additions and 65 deletions

View file

@ -5003,11 +5003,11 @@ void AnimTask_GetReturnPowerLevel(u8 taskId)
void AnimTask_SnatchOpposingMonMove(u8 taskId)
{
u8 spriteId, spriteId2;
int personality;
int otId;
u32 personality;
u32 otId;
u16 species;
u8 subpriority;
u8 isBackPic;
bool8 isBackPic;
s16 x;
switch (gTasks[taskId].data[0])
@ -5035,37 +5035,34 @@ void AnimTask_SnatchOpposingMonMove(u8 taskId)
otId = gContestResources->moveAnim->otId;
species = gContestResources->moveAnim->species;
subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker);
isBackPic = 0;
isBackPic = FALSE;
x = -32;
}
else if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER)
{
personality = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_PERSONALITY);
otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_OT_ID);
if (gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies == SPECIES_NONE)
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES);
else
species = gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies;
subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_TARGET)].subpriority + 1;
isBackPic = FALSE;
x = 272;
}
else
{
if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER)
{
personality = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_PERSONALITY);
otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_OT_ID);
if (gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies == SPECIES_NONE)
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES);
else
species = gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies;
subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_TARGET)].subpriority + 1;
isBackPic = 0;
x = 272;
}
personality = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_PERSONALITY);
otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_OT_ID);
if (gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies == SPECIES_NONE)
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES);
else
{
personality = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_PERSONALITY);
otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_OT_ID);
if (gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies == SPECIES_NONE)
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES);
else
species = gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies;
species = gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies;
subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_TARGET)].subpriority - 1;
isBackPic = 1;
x = -32;
}
subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_TARGET)].subpriority - 1;
isBackPic = TRUE;
x = -32;
}
spriteId2 = sub_80A8394(species, isBackPic, 0, x, GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y), subpriority, personality, otId, gBattleAnimAttacker, 0);
@ -5092,7 +5089,7 @@ void AnimTask_SnatchOpposingMonMove(u8 taskId)
if (x < GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X))
{
gTasks[taskId].data[14]++;
gBattleAnimArgs[7] = 0xFFFF;
gBattleAnimArgs[7] = -1;
}
}
else
@ -5100,7 +5097,7 @@ void AnimTask_SnatchOpposingMonMove(u8 taskId)
if (x > GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X))
{
gTasks[taskId].data[14]++;
gBattleAnimArgs[7] = 0xFFFF;
gBattleAnimArgs[7] = -1;
}
}
}
@ -5138,7 +5135,7 @@ void AnimTask_SnatchOpposingMonMove(u8 taskId)
gSprites[spriteId].pos2.x = 0;
}
gTasks[taskId].data[1] = (u8)gTasks[taskId].data[1];
gTasks[taskId].data[1] &= 0xFF;
if (gSprites[spriteId].pos2.x == 0)
DestroyAnimVisualTask(taskId);
break;

View file

@ -563,14 +563,23 @@ struct FeatherDanceData
u16 unkE_1:15;
};
#define ANIM_SWITCH(sprite) \
{ \
(sprite)->hFlip ^= 1; \
(sprite)->animNum = (sprite)->hFlip; \
(sprite)->animBeginning = TRUE; \
(sprite)->animEnded = FALSE; \
}
static void AnimFallingFeather(struct Sprite *sprite)
{
u8 battler, matrixNum, sinIndex;
u8 battler, sinIndex;
u32 matrixNum;
s16 sinVal;
struct FeatherDanceData *data = (struct FeatherDanceData *)sprite->data;
battler = (gBattleAnimArgs[7] & 0x100) ? gBattleAnimAttacker : gBattleAnimTarget;
battler = (gBattleAnimArgs[7] & 0x100) ? gBattleAnimAttacker : gBattleAnimTarget;
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
gBattleAnimArgs[0] = -gBattleAnimArgs[0];
@ -583,12 +592,12 @@ static void AnimFallingFeather(struct Sprite *sprite)
data->unkE_1 = (u16)(sinVal + gBattleAnimArgs[6]);
data->unk0_0c = 1;
data->unk2 = (u16)(gBattleAnimArgs[2] & 0xFF);
data->unkA = (u16)((gBattleAnimArgs[2] >> 8) & 0xFF) ;
data->unkA = (u16)gBattleAnimArgs[2] >> 8;
data->unk4 = gBattleAnimArgs[3];
data->unk6 = (u16)gBattleAnimArgs[4];
*(u16*)(data->unkC) = (u16)gBattleAnimArgs[5];
*(u16 *)(data->unkC) = (u16)gBattleAnimArgs[5];
if (data->unk2 >= 64 && data->unk2 <= 191)
if (data->unk2 >= 64 && data->unk2 < 192)
{
if (!IsContest())
sprite->oam.priority = GetBattlerSpriteBGPriority(battler) + 1;
@ -599,11 +608,7 @@ static void AnimFallingFeather(struct Sprite *sprite)
if (!(data->unk4 & 0x8000))
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
sprite->animBeginning = 1;
sprite->animEnded = 0;
ANIM_SWITCH(sprite);
}
}
else
@ -613,15 +618,11 @@ static void AnimFallingFeather(struct Sprite *sprite)
if (data->unk4 & 0x8000)
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
sprite->animBeginning = 1;
sprite->animEnded = 0;
ANIM_SWITCH(sprite);
}
}
data->unk0_1 = data->unk2/64;
data->unk0_1 = data->unk2 / 64;
sprite->pos2.x = (gSineTable[data->unk2] * (s32)data->unkC[0]) >> 8;
matrixNum = sprite->oam.matrixNum;
@ -637,7 +638,8 @@ static void AnimFallingFeather(struct Sprite *sprite)
static void sub_810E520(struct Sprite *sprite)
{
u8 matrixNum, sinIndex;
u8 sinIndex;
u32 matrixNum;
s16 sinVal = 0;
struct FeatherDanceData *data = (struct FeatherDanceData *)sprite->data;
if (data->unk0_0a)
@ -667,10 +669,7 @@ static void sub_810E520(struct Sprite *sprite)
}
else if (data->unk0_0d)
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
ANIM_SWITCH(sprite);
if (data->unk0_0c)
{
if (!IsContest())
@ -718,10 +717,7 @@ static void sub_810E520(struct Sprite *sprite)
}
else if (data->unk0_0d)
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
ANIM_SWITCH(sprite);
if (data->unk0_0c)
{
if (!IsContest())
@ -769,10 +765,7 @@ static void sub_810E520(struct Sprite *sprite)
}
else if (data->unk0_0d)
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
ANIM_SWITCH(sprite);
if (data->unk0_0c)
{
if (!IsContest())
@ -819,10 +812,7 @@ static void sub_810E520(struct Sprite *sprite)
}
else if (data->unk0_0d)
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
ANIM_SWITCH(sprite);
if (data->unk0_0c)
{
if (!IsContest())

View file

@ -1774,7 +1774,7 @@ static int GetNumOwnedBadges(void)
static bool32 sub_8196D74(int matchCallId)
{
int dayCount;
int otId;
u32 otId;
u16 easyChatWord;
int numRematchTrainersFought;
int var0, var1, var2;