Match sub_8159308

This commit is contained in:
ultima-soul 2019-04-07 18:36:10 -07:00 committed by huderlem
parent 92851ba4e6
commit 2c432c314a
3 changed files with 14 additions and 61 deletions

View File

@ -62,7 +62,7 @@ void MoveBattlerSpriteToBG(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible)
bool8 IsContest(void); bool8 IsContest(void);
s8 BattleAnimAdjustPanning(s8 pan); s8 BattleAnimAdjustPanning(s8 pan);
s8 BattleAnimAdjustPanning2(s8 pan); s8 BattleAnimAdjustPanning2(s8 pan);
s16 KeepPanInRange(s16 a); s16 KeepPanInRange(s16 a, int oldPan);
s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan); s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan);
void sub_80A4720(u16 a, u16 *b, u32 c, u8 d); void sub_80A4720(u16 a, u16 *b, u32 c, u8 d);
void sub_80A477C(bool8); void sub_80A477C(bool8);

View File

@ -2936,7 +2936,7 @@ s8 BattleAnimAdjustPanning2(s8 pan)
return pan; return pan;
} }
s16 KeepPanInRange(s16 panArg) s16 KeepPanInRange(s16 panArg, int oldPan)
{ {
s16 pan = panArg; s16 pan = panArg;

View File

@ -53,7 +53,7 @@ static void sub_8158B98(u8 taskId)
PlaySE12WithPanning(gTasks[taskId].data[0], pan); PlaySE12WithPanning(gTasks[taskId].data[0], pan);
} }
pan += panIncrement; pan += panIncrement;
gTasks[taskId].data[2] = KeepPanInRange(pan); gTasks[taskId].data[2] = KeepPanInRange(pan, panIncrement);
} }
} }
@ -116,9 +116,12 @@ static void sub_8158D08(u8 taskId)
if (gTasks[taskId].data[10]++ == gTasks[taskId].data[5]) if (gTasks[taskId].data[10]++ == gTasks[taskId].data[5])
{ {
u16 dPan, oldPan;
gTasks[taskId].data[10] = 0; gTasks[taskId].data[10] = 0;
gTasks[taskId].data[11] += gTasks[taskId].data[3]; dPan = gTasks[taskId].data[3];
gTasks[taskId].data[11] = KeepPanInRange(gTasks[taskId].data[11]); oldPan = gTasks[taskId].data[11] ;
gTasks[taskId].data[11] = dPan + oldPan;
gTasks[taskId].data[11] = KeepPanInRange(gTasks[taskId].data[11], oldPan);
} }
} }
// task end // task end
@ -368,71 +371,21 @@ void sub_8159278(u8 taskId)
sub_8159308(taskId); sub_8159308(taskId);
} }
#ifdef NONMATCHING
void sub_8159308(u8 taskId) void sub_8159308(u8 taskId)
{ {
s16 panIncrement = gTasks[taskId].data[3]; u16 panIncrement = gTasks[taskId].data[3];
if (gTasks[taskId].data[10]++ == gTasks[taskId].data[5]) if (gTasks[taskId].data[10]++ == gTasks[taskId].data[5])
{ {
u16 oldPan;
gTasks[taskId].data[10] = 0; gTasks[taskId].data[10] = 0;
oldPan = gTasks[taskId].data[11];
gTasks[taskId].data[11] += panIncrement; gTasks[taskId].data[11] = panIncrement + oldPan;
gTasks[taskId].data[11] = KeepPanInRange(gTasks[taskId].data[11]); gTasks[taskId].data[11] = KeepPanInRange(gTasks[taskId].data[11], oldPan);
} }
gUnknown_02038440 = gTasks[taskId].data[11]; gUnknown_02038440 = gTasks[taskId].data[11];
if (gTasks[taskId].data[11] == gTasks[taskId].data[2]) if (gTasks[taskId].data[11] == gTasks[taskId].data[2])
DestroyAnimVisualTask(taskId); DestroyAnimVisualTask(taskId);
} }
#else
NAKED
void sub_8159308(u8 taskId)
{
asm_unified(" push {r4,r5,lr}\n\
lsls r0, 24\n\
lsrs r0, 24\n\
adds r5, r0, 0\n\
ldr r1, =gTasks\n\
lsls r0, r5, 2\n\
adds r0, r5\n\
lsls r0, 3\n\
adds r4, r0, r1\n\
ldrh r2, [r4, 0xE]\n\
ldrh r0, [r4, 0x1C]\n\
adds r1, r0, 0x1\n\
strh r1, [r4, 0x1C]\n\
lsls r0, 16\n\
asrs r0, 16\n\
movs r3, 0x12\n\
ldrsh r1, [r4, r3]\n\
cmp r0, r1\n\
bne _08159342\n\
movs r0, 0\n\
strh r0, [r4, 0x1C]\n\
ldrh r1, [r4, 0x1E]\n\
adds r0, r2, r1\n\
strh r0, [r4, 0x1E]\n\
movs r2, 0x1E\n\
ldrsh r0, [r4, r2]\n\
bl KeepPanInRange\n\
strh r0, [r4, 0x1E]\n\
_08159342:\n\
ldr r1, =gUnknown_02038440\n\
ldrh r0, [r4, 0x1E]\n\
strb r0, [r1]\n\
movs r3, 0x1E\n\
ldrsh r1, [r4, r3]\n\
movs r2, 0xC\n\
ldrsh r0, [r4, r2]\n\
cmp r1, r0\n\
bne _0815935A\n\
adds r0, r5, 0\n\
bl DestroyAnimVisualTask\n\
_0815935A:\n\
pop {r4,r5}\n\
pop {r0}\n\
bx r0\n\
.pool");
}
#endif