Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeepPanInRange has one arg #2054

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/battle_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void MoveBattlerSpriteToBG(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible)
bool8 IsContest(void);
s8 BattleAnimAdjustPanning(s8 pan);
s8 BattleAnimAdjustPanning2(s8 pan);
s16 KeepPanInRange(s16 panArg, int oldPan);
s16 KeepPanInRange(s16 pan);
s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan);
void RelocateBattleBgPal(u16 paletteNum, u16 *dest, u32 offset, bool8 largeScreen);
void ResetBattleAnimBg(bool8);
Expand Down
8 changes: 3 additions & 5 deletions src/battle_anim.c
Original file line number Diff line number Diff line change
Expand Up @@ -1319,10 +1319,8 @@ s8 BattleAnimAdjustPanning2(s8 pan)
return pan;
}

s16 KeepPanInRange(s16 panArg, int oldPan)
s16 KeepPanInRange(s16 pan)
{
s16 pan = panArg;

if (pan > SOUND_PAN_TARGET)
pan = SOUND_PAN_TARGET;
else if (pan < SOUND_PAN_ATTACKER)
Expand All @@ -1336,9 +1334,9 @@ s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan)
s16 ret;

if (sourcePan < targetPan)
ret = ((incrementPan < 0) ? -incrementPan : incrementPan);
ret = abs(incrementPan);
else if (sourcePan > targetPan)
ret = -((incrementPan < 0) ? -incrementPan : incrementPan);
ret = -abs(incrementPan);
else
ret = 0;

Expand Down
27 changes: 13 additions & 14 deletions src/battle_anim_sound_tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static void SoundTask_FireBlast_Step1(u8 taskId)
PlaySE12WithPanning(gTasks[taskId].data[0], pan);
}
pan += panIncrement;
gTasks[taskId].data[2] = KeepPanInRange(pan, panIncrement);
gTasks[taskId].data[2] = KeepPanInRange(pan);
}
}

Expand All @@ -78,13 +78,14 @@ static void SoundTask_FireBlast_Step2(u8 taskId)
void SoundTask_LoopSEAdjustPanning(u8 taskId)
{
u16 songId = gBattleAnimArgs[0];
s8 sourcePan = gBattleAnimArgs[1];
s8 targetPan = gBattleAnimArgs[2];
s8 panIncrement = gBattleAnimArgs[3];
u8 r10 = gBattleAnimArgs[4];
u8 r7 = gBattleAnimArgs[5];
u8 r9 = gBattleAnimArgs[6];
s8 sourcePan = BattleAnimAdjustPanning(gBattleAnimArgs[1]);

sourcePan = BattleAnimAdjustPanning(sourcePan);
targetPan = BattleAnimAdjustPanning(targetPan);
panIncrement = CalculatePanIncrement(sourcePan, targetPan, panIncrement);

Expand All @@ -105,6 +106,8 @@ void SoundTask_LoopSEAdjustPanning(u8 taskId)

static void SoundTask_LoopSEAdjustPanning_Step(u8 taskId)
{
s8 unusedVar = gTasks[taskId].data[3];

if (gTasks[taskId].data[12]++ == gTasks[taskId].data[6])
{
gTasks[taskId].data[12] = 0;
Expand All @@ -118,12 +121,9 @@ static void SoundTask_LoopSEAdjustPanning_Step(u8 taskId)

if (gTasks[taskId].data[10]++ == gTasks[taskId].data[5])
{
u16 dPan, oldPan;
gTasks[taskId].data[10] = 0;
dPan = gTasks[taskId].data[3];
oldPan = gTasks[taskId].data[11];
gTasks[taskId].data[11] = dPan + oldPan;
gTasks[taskId].data[11] = KeepPanInRange(gTasks[taskId].data[11], oldPan);
gTasks[taskId].data[11] += gTasks[taskId].data[3];
gTasks[taskId].data[11] = KeepPanInRange(gTasks[taskId].data[11]);
}
}

Expand Down Expand Up @@ -369,11 +369,12 @@ void SoundTask_PlaySE2WithPanning(u8 taskId)
// Used by Confuse Ray and Will-O-Wisp (see uses of gAnimCustomPanning)
void SoundTask_AdjustPanningVar(u8 taskId)
{
s8 sourcePan = gBattleAnimArgs[0];
s8 targetPan = gBattleAnimArgs[1];
s8 panIncrement = gBattleAnimArgs[2];
u16 r9 = gBattleAnimArgs[3];
s8 sourcePan = BattleAnimAdjustPanning(gBattleAnimArgs[0]);
s16 r9 = gBattleAnimArgs[3];

sourcePan = BattleAnimAdjustPanning(sourcePan);
targetPan = BattleAnimAdjustPanning(targetPan);
panIncrement = CalculatePanIncrement(sourcePan, targetPan, panIncrement);

Expand All @@ -390,15 +391,13 @@ void SoundTask_AdjustPanningVar(u8 taskId)

static void SoundTask_AdjustPanningVar_Step(u8 taskId)
{
u16 panIncrement = gTasks[taskId].data[3];
s8 unusedVar = gTasks[taskId].data[3];

if (gTasks[taskId].data[10]++ == gTasks[taskId].data[5])
{
u16 oldPan;
gTasks[taskId].data[10] = 0;
oldPan = gTasks[taskId].data[11];
gTasks[taskId].data[11] = panIncrement + oldPan;
gTasks[taskId].data[11] = KeepPanInRange(gTasks[taskId].data[11], oldPan);
gTasks[taskId].data[11] += gTasks[taskId].data[3];
gTasks[taskId].data[11] = KeepPanInRange(gTasks[taskId].data[11]);
}

gAnimCustomPanning = gTasks[taskId].data[11];
Expand Down