Remove fakematch

This commit is contained in:
PokeCodec 2020-08-09 17:09:55 -04:00
parent 8b95e1964b
commit ceac2d547c

View File

@ -536,17 +536,16 @@ static void AnimFlyBallAttack_Step(struct Sprite *sprite)
void DestroyAnimSpriteAfterTimer(struct Sprite *sprite) void DestroyAnimSpriteAfterTimer(struct Sprite *sprite)
{ {
if (sprite->data[0]-- <= 0) if (sprite->data[0]-- > 0)
return;
if (sprite->oam.affineMode & ST_OAM_AFFINE_ON_MASK)
{ {
if (sprite->oam.affineMode & ST_OAM_AFFINE_ON_MASK) FreeOamMatrix(sprite->oam.matrixNum);
{ sprite->oam.affineMode = ST_OAM_AFFINE_OFF;
FreeOamMatrix(sprite->oam.matrixNum);
sprite->oam.affineMode = ST_OAM_AFFINE_OFF;
}
DestroySprite(sprite);
gAnimVisualTaskCount--;
} }
DestroySprite(sprite);
gAnimVisualTaskCount--;
} }
struct FeatherDanceData struct FeatherDanceData
@ -570,30 +569,27 @@ struct FeatherDanceData
static void AnimFallingFeather(struct Sprite *sprite) static void AnimFallingFeather(struct Sprite *sprite)
{ {
u8 battler, matrixNum, sinIndex; u8 battler, matrixNum, sinIndex;
s16 spriteCoord, sinVal; s16 sinVal;
struct FeatherDanceData *data = (struct FeatherDanceData *)sprite->data; struct FeatherDanceData *data = (struct FeatherDanceData *)sprite->data;
if (gBattleAnimArgs[7] & 0x100) battler = (gBattleAnimArgs[7] & 0x100) ? gBattleAnimAttacker : gBattleAnimTarget;
battler = gBattleAnimAttacker;
else
battler = gBattleAnimTarget;
if (GetBattlerSide(battler) == B_SIDE_PLAYER) if (GetBattlerSide(battler) == B_SIDE_PLAYER)
gBattleAnimArgs[0] = -gBattleAnimArgs[0]; gBattleAnimArgs[0] = -gBattleAnimArgs[0];
sprite->pos1.x = GetBattlerSpriteCoord(battler, BATTLER_COORD_ATTR_HEIGHT) + gBattleAnimArgs[0]; sprite->pos1.x = GetBattlerSpriteCoord(battler, BATTLER_COORD_ATTR_HEIGHT) + gBattleAnimArgs[0];
spriteCoord = GetBattlerSpriteCoord(battler, BATTLER_COORD_ATTR_WIDTH); sinVal = GetBattlerSpriteCoord(battler, BATTLER_COORD_ATTR_WIDTH);
sprite->pos1.y = spriteCoord + gBattleAnimArgs[1]; sprite->pos1.y = sinVal + gBattleAnimArgs[1];
data->unk8 = sprite->pos1.y << 8; data->unk8 = (u16)(sprite->pos1.y) << 8;
data->unkE_1 = spriteCoord + gBattleAnimArgs[6]; data->unkE_1 = (u16)(sinVal + gBattleAnimArgs[6]);
data->unk0_0c = 1; data->unk0_0c = 1;
data->unk2 = gBattleAnimArgs[2] & 0xFF; data->unk2 = (u16)(gBattleAnimArgs[2] & 0xFF);
data->unkA = (gBattleAnimArgs[2] >> 8) & 0xFF; data->unkA = (u16)((gBattleAnimArgs[2] >> 8) & 0xFF) ;
data->unk4 = gBattleAnimArgs[3]; data->unk4 = gBattleAnimArgs[3];
data->unk6 = gBattleAnimArgs[4]; data->unk6 = (u16)gBattleAnimArgs[4];
*(u16*)(data->unkC) = gBattleAnimArgs[5]; *(u16*)(data->unkC) = (u16)gBattleAnimArgs[5];
if (data->unk2 >= 64 && data->unk2 <= 191) if (data->unk2 >= 64 && data->unk2 <= 191)
{ {
@ -628,27 +624,16 @@ static void AnimFallingFeather(struct Sprite *sprite)
} }
} }
data->unk0_1 = data->unk2 >> 6; data->unk0_1 = data->unk2/64;
sprite->pos2.x = (gSineTable[data->unk2] * data->unkC[0]) >> 8; sprite->pos2.x = (gSineTable[data->unk2] * (s32)data->unkC[0]) >> 8;
matrixNum = sprite->oam.matrixNum; matrixNum = sprite->oam.matrixNum;
sinIndex = (-sprite->pos2.x >> 1) + data->unkA; sinIndex = (-sprite->pos2.x >> 1) + data->unkA;
sinVal = gSineTable[sinIndex]; sinVal = gSineTable[sinIndex];
gOamMatrices[matrixNum].a = gOamMatrices[matrixNum].d = gSineTable[sinIndex + 64]; gOamMatrices[matrixNum].a = gOamMatrices[matrixNum].d = gSineTable[sinIndex + 64];
// The comparison below is completely pointless. 'sprite' is sure to be a valid pointer and gOamMatrices[matrixNum].b = sinVal;
// both the 'if' and 'else' parts are exactly the same. gOamMatrices[matrixNum].c = -sinVal;
// The only reason for this is making sure the compiler generates the exact ASM.
if (sprite)
{
gOamMatrices[matrixNum].b = sinVal;
gOamMatrices[matrixNum].c = -sinVal;
}
else
{
gOamMatrices[matrixNum].b = sinVal;
gOamMatrices[matrixNum].c = -sinVal;
}
sprite->callback = sub_810E520; sprite->callback = sub_810E520;
} }
@ -665,242 +650,239 @@ static void sub_810E520(struct Sprite *sprite)
data->unk0_0a = 0; data->unk0_0a = 0;
data->unk1 = 0; data->unk1 = 0;
} }
return;
} }
else
switch (data->unk2 / 64)
{ {
switch (data->unk2 / 64) case 0:
if ((u8)data->unk0_1 == 1) // this must be cast to u8
{ {
case 0: data->unk0_0d = 1;
if (data->unk0_1 << 24 >> 24 == 1) // the shifts have to be here data->unk0_0a = 1;
{ data->unk1 = 0;
data->unk0_0d = 1;
data->unk0_0a = 1;
data->unk1 = 0;
}
else if (data->unk0_1 << 24 >> 24 == 3)
{
data->unk0_0b ^= 1;
data->unk0_0a = 1;
data->unk1 = 0;
}
else if (data->unk0_0d)
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
if (data->unk0_0c)
{
if (!IsContest())
{
if (!data->unkE_0)
{
sprite->oam.priority--;
data->unkE_0 ^= 1;
}
else
{
sprite->oam.priority++;
data->unkE_0 ^= 1;
}
}
else
{
if (!data->unkE_0)
{
sprite->subpriority -= 12;
data->unkE_0 ^= 1;
}
else
{
sprite->subpriority += 12;
data->unkE_0 ^= 1;
}
}
}
data->unk0_0d = 0;
data->unk2;
}
data->unk0_1 = 0;
break;
case 1:
if (data->unk0_1 << 24 >> 24 == 0)
{
data->unk0_0d = 1;
data->unk0_0a = 1;
data->unk1 = 0;
}
else if (data->unk0_1 << 24 >> 24 == 2)
{
data->unk0_0a = 1;
data->unk1 = 0;
}
else if (data->unk0_0d)
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
if (data->unk0_0c)
{
if (!IsContest())
{
if (!data->unkE_0)
{
sprite->oam.priority--;
data->unkE_0 ^= 1;
}
else
{
sprite->oam.priority++;
data->unkE_0 ^= 1;
}
}
else
{
if (!data->unkE_0)
{
sprite->subpriority -= 12;
data->unkE_0 ^= 1;
}
else
{
sprite->subpriority += 12;
data->unkE_0 ^= 1;
}
}
}
data->unk0_0d = 0;
}
data->unk0_1 = 1;
break;
case 2:
if (data->unk0_1 << 24 >> 24 == 3)
{
data->unk0_0d = 1;
data->unk0_0a = 1;
data->unk1 = 0;
}
else if (data->unk0_1 << 24 >> 24 == 1)
{
data->unk0_0a = 1;
data->unk1 = 0;
}
else if (data->unk0_0d)
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
if (data->unk0_0c)
{
if (!IsContest())
{
if (!data->unkE_0)
{
sprite->oam.priority--;
data->unkE_0 ^= 1;
}
else
{
sprite->oam.priority++;
data->unkE_0 ^= 1;
}
}
else
{
if (!data->unkE_0)
{
sprite->subpriority -= 12;
data->unkE_0 ^= 1;
}
else
{
sprite->subpriority += 12;
data->unkE_0 ^= 1;
}
}
}
data->unk0_0d = 0;
}
data->unk0_1 = 2;
break;
case 3:
if (data->unk0_1 << 24 >> 24 == 2)
{
data->unk0_0d = 1;
}
else if (data->unk0_1 << 24 >> 24 == 0)
{
data->unk0_0b ^= 1;
data->unk0_0a = 1;
data->unk1 = 0;
}
else if (data->unk0_0d)
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
if (data->unk0_0c)
{
if (!IsContest())
{
if (!data->unkE_0)
{
sprite->oam.priority--;
data->unkE_0 ^= 1;
}
else
{
sprite->oam.priority++;
data->unkE_0 ^= 1;
}
}
else
{
if (!data->unkE_0)
{
sprite->subpriority -= 12;
data->unkE_0 ^= 1;
}
else
{
sprite->subpriority += 12;
data->unkE_0 ^= 1;
}
}
}
data->unk0_0d = 0;
}
data->unk0_1 = 3;
break;
} }
#ifndef NONMATCHING else if ((u8)data->unk0_1 == 3)
asm("":::"r8");
#endif
sprite->pos2.x = (data->unkC[data->unk0_0b] * gSineTable[data->unk2]) >> 8;
matrixNum = sprite->oam.matrixNum;
sinIndex = (-sprite->pos2.x >> 1) + data->unkA;
sinVal = gSineTable[sinIndex];
gOamMatrices[matrixNum].a = gOamMatrices[matrixNum].d = gSineTable[sinIndex + 64];
gOamMatrices[matrixNum].b = sinVal;
gOamMatrices[matrixNum].c = -sinVal;
data->unk8 += data->unk6;
sprite->pos1.y = data->unk8 >> 8;
if (data->unk4 & 0x8000)
data->unk2 = (data->unk2 - (data->unk4 & 0x7FFF)) & 0xFF;
else
data->unk2 = (data->unk2 + (data->unk4 & 0x7FFF)) & 0xFF;
if (sprite->pos1.y + sprite->pos2.y >= data->unkE_1)
{ {
sprite->data[0] = 0; data->unk0_0b ^= 1;
sprite->callback = DestroyAnimSpriteAfterTimer; data->unk0_0a = 1;
data->unk1 = 0;
} }
else if (data->unk0_0d)
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
if (data->unk0_0c)
{
if (!IsContest())
{
if (!data->unkE_0)
{
sprite->oam.priority--;
data->unkE_0 ^= 1;
}
else
{
sprite->oam.priority++;
data->unkE_0 ^= 1;
}
}
else
{
if (!data->unkE_0)
{
sprite->subpriority -= 12;
data->unkE_0 ^= 1;
}
else
{
sprite->subpriority += 12;
data->unkE_0 ^= 1;
}
}
}
data->unk0_0d = 0;
data->unk2;
}
data->unk0_1 = 0;
break;
case 1:
if ((u8)data->unk0_1 == 0)
{
data->unk0_0d = 1;
data->unk0_0a = 1;
data->unk1 = 0;
}
else if ((u8)data->unk0_1 == 2)
{
data->unk0_0a = 1;
data->unk1 = 0;
}
else if (data->unk0_0d)
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
if (data->unk0_0c)
{
if (!IsContest())
{
if (!data->unkE_0)
{
sprite->oam.priority--;
data->unkE_0 ^= 1;
}
else
{
sprite->oam.priority++;
data->unkE_0 ^= 1;
}
}
else
{
if (!data->unkE_0)
{
sprite->subpriority -= 12;
data->unkE_0 ^= 1;
}
else
{
sprite->subpriority += 12;
data->unkE_0 ^= 1;
}
}
}
data->unk0_0d = 0;
}
data->unk0_1 = 1;
break;
case 2:
if ((u8)data->unk0_1 == 3)
{
data->unk0_0d = 1;
data->unk0_0a = 1;
data->unk1 = 0;
}
else if ((u8)data->unk0_1 == 1)
{
data->unk0_0a = 1;
data->unk1 = 0;
}
else if (data->unk0_0d)
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
if (data->unk0_0c)
{
if (!IsContest())
{
if (!data->unkE_0)
{
sprite->oam.priority--;
data->unkE_0 ^= 1;
}
else
{
sprite->oam.priority++;
data->unkE_0 ^= 1;
}
}
else
{
if (!data->unkE_0)
{
sprite->subpriority -= 12;
data->unkE_0 ^= 1;
}
else
{
sprite->subpriority += 12;
data->unkE_0 ^= 1;
}
}
}
data->unk0_0d = 0;
}
data->unk0_1 = 2;
break;
case 3:
if ((u8)data->unk0_1 == 2)
{
data->unk0_0d = 1;
}
else if ((u8)data->unk0_1 == 0)
{
data->unk0_0b ^= 1;
data->unk0_0a = 1;
data->unk1 = 0;
}
else if (data->unk0_0d)
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
if (data->unk0_0c)
{
if (!IsContest())
{
if (!data->unkE_0)
{
sprite->oam.priority--;
data->unkE_0 ^= 1;
}
else
{
sprite->oam.priority++;
data->unkE_0 ^= 1;
}
}
else
{
if (!data->unkE_0)
{
sprite->subpriority -= 12;
data->unkE_0 ^= 1;
}
else
{
sprite->subpriority += 12;
data->unkE_0 ^= 1;
}
}
}
data->unk0_0d = 0;
}
data->unk0_1 = 3;
break;
}
sprite->pos2.x = ((s32)(data->unkC[data->unk0_0b]) * gSineTable[data->unk2]) >> 8;
matrixNum = sprite->oam.matrixNum;
sinIndex = ((-sprite->pos2.x >> 1) + data->unkA);
sinVal = gSineTable[sinIndex];
gOamMatrices[matrixNum].a = gOamMatrices[matrixNum].d = gSineTable[sinIndex + 64];
gOamMatrices[matrixNum].b = sinVal;
gOamMatrices[matrixNum].c = -sinVal;
data->unk8 += data->unk6;
sprite->pos1.y = (s16)(data->unk8 >> 8);
if (data->unk4 & 0x8000)
data->unk2 = (data->unk2 - (data->unk4 & 0x7FFF)) & 0xFF;
else
data->unk2 = (data->unk2 + (data->unk4 & 0x7FFF)) & 0xFF;
if (sprite->pos1.y + sprite->pos2.y >= data->unkE_1)
{
sprite->data[0] = 0;
sprite->callback = DestroyAnimSpriteAfterTimer;
} }
} }
@ -944,20 +926,20 @@ static void sub_810EB40(struct Sprite *sprite)
{ {
sprite->pos2.x += sprite->data[1] >> 8; sprite->pos2.x += sprite->data[1] >> 8;
if (++sprite->data[0] == 6) if (sprite->data[0]++ == 5)
{ {
sprite->data[0] = 0; sprite->data[0] = 0;
sprite->pos2.x = 0; sprite->pos2.x = 0;
StartSpriteAnim(sprite, 0); StartSpriteAnim(sprite, 0);
} }
if (--sprite->data[7] == -1) if (sprite->data[7]-- == 0)
DestroyAnimSprite(sprite); DestroyAnimSprite(sprite);
} }
void AnimTask_DrillPeckHitSplats(u8 task) void AnimTask_DrillPeckHitSplats(u8 task)
{ {
if (!(gTasks[task].data[0] % 32)) if ((gTasks[task].data[0] % 32) == 0)
{ {
gAnimVisualTaskCount++; gAnimVisualTaskCount++;
@ -1060,8 +1042,8 @@ static void AnimDiveBall_Step2(struct Sprite *sprite)
static void AnimDiveWaterSplash(struct Sprite *sprite) static void AnimDiveWaterSplash(struct Sprite *sprite)
{ {
u32 matrixNum; u8 matrixNum;
int t1, t2; s32 t1, t2;
switch (sprite->data[0]) switch (sprite->data[0])
{ {
@ -1083,7 +1065,7 @@ static void AnimDiveWaterSplash(struct Sprite *sprite)
sprite->data[0]++; sprite->data[0]++;
break; break;
case 1: case 1:
if (sprite->data[2] <= 11) if (sprite->data[2] < 12)
sprite->data[1] -= 40; sprite->data[1] -= 40;
else else
sprite->data[1] += 40; sprite->data[1] += 40;
@ -1091,7 +1073,7 @@ static void AnimDiveWaterSplash(struct Sprite *sprite)
sprite->data[2]++; sprite->data[2]++;
TrySetSpriteRotScale(sprite, 0, 256, sprite->data[1], 0); TrySetSpriteRotScale(sprite, 0, 256, sprite->data[1], 0);
matrixNum = sprite->oam.matrixNum; matrixNum = sprite->oam.matrixNum;
t1 = 15616; t1 = 15616;
@ -1115,8 +1097,8 @@ static void AnimDiveWaterSplash(struct Sprite *sprite)
// Launches a water droplet away from the specified battler. Used by Astonish and Dive // Launches a water droplet away from the specified battler. Used by Astonish and Dive
static void AnimSprayWaterDroplet(struct Sprite *sprite) static void AnimSprayWaterDroplet(struct Sprite *sprite)
{ {
int v1 = 0x1ff & Random2(); const u16 v1 = Random2() & 0x1ff;
int v2 = 0x7f & Random2(); const u16 v2 = Random2() & 0x07f;
if (v1 % 2) if (v1 % 2)
sprite->data[0] = 736 + v1; sprite->data[0] = 736 + v1;
@ -1160,13 +1142,13 @@ static void AnimSprayWaterDroplet_Step(struct Sprite *sprite)
sprite->pos2.y -= sprite->data[1] >> 8; sprite->pos2.y -= sprite->data[1] >> 8;
} }
sprite->data[0] = sprite->data[0]; sprite->data[0] -= 0; // Needed to Match
sprite->data[1] -= 32; sprite->data[1] -= 32;
if (sprite->data[0] < 0) if (sprite->data[0] < 0)
sprite->data[0] = 0; sprite->data[0] = 0;
if (++sprite->data[3] == 31) if (sprite->data[3]++ == 30)
DestroyAnimSprite(sprite); DestroyAnimSprite(sprite);
} }
@ -1212,7 +1194,7 @@ static void AnimSkyAttackBird(struct Sprite *sprite)
sprite->data[7] = ((posy - sprite->pos1.y) << 4) / 12; sprite->data[7] = ((posy - sprite->pos1.y) << 4) / 12;
rotation = ArcTan2Neg(posx - sprite->pos1.x, posy - sprite->pos1.y); rotation = ArcTan2Neg(posx - sprite->pos1.x, posy - sprite->pos1.y);
rotation += 49152; rotation -= 16384;
TrySetSpriteRotScale(sprite, 1, 0x100, 0x100, rotation); TrySetSpriteRotScale(sprite, 1, 0x100, 0x100, rotation);
@ -1236,12 +1218,12 @@ void unref_sub_810F184(u8 taskId)
{ {
if (gBattleAnimArgs[0] == 0) if (gBattleAnimArgs[0] == 0)
{ {
u8 spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER); const u8 spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER);
gSprites[spriteId].invisible = TRUE; gSprites[spriteId].invisible = TRUE;
} }
else else
{ {
u8 spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER); const u8 spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER);
gSprites[spriteId].invisible = FALSE; gSprites[spriteId].invisible = FALSE;
} }
DestroyAnimVisualTask(taskId); DestroyAnimVisualTask(taskId);