Skip to content

Commit

Permalink
KeepPanInRange has one arg
Browse files Browse the repository at this point in the history
  • Loading branch information
AreaZR committed Oct 24, 2024
1 parent e45fe13 commit 0c9ee21
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
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
4 changes: 1 addition & 3 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 Down
19 changes: 8 additions & 11 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 Down Expand Up @@ -105,6 +105,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 +120,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 @@ -390,15 +389,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

0 comments on commit 0c9ee21

Please sign in to comment.