Merge pull request #1232 from Kurausukun/match_m4a

[LEAK INFORMED] Match FadeOutBody
This commit is contained in:
GriffinR 2020-10-18 21:41:37 -04:00 committed by GitHub
commit 585f313c64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 17 deletions

View File

@ -643,28 +643,17 @@ void FadeOutBody(struct MusicPlayerInfo *mplayInfo)
s32 i; s32 i;
struct MusicPlayerTrack *track; struct MusicPlayerTrack *track;
u16 fadeOV; u16 fadeOV;
#ifdef NONMATCHING
u16 mask;
#else
register u16 mask asm("r2");
#endif // NONMATCHING
if (mplayInfo->fadeOI == 0) if (mplayInfo->fadeOI == 0)
return; return;
if (--mplayInfo->fadeOC != 0)
mplayInfo->fadeOC--;
mask = 0xFFFF;
if (mplayInfo->fadeOC != 0)
return; return;
mplayInfo->fadeOC = mplayInfo->fadeOI; mplayInfo->fadeOC = mplayInfo->fadeOI;
if (mplayInfo->fadeOV & FADE_IN) if (mplayInfo->fadeOV & FADE_IN)
{ {
mplayInfo->fadeOV += (4 << FADE_VOL_SHIFT); if ((u16)(mplayInfo->fadeOV += (4 << FADE_VOL_SHIFT)) >= (64 << FADE_VOL_SHIFT))
if ((u16)(mplayInfo->fadeOV & mask) >= (64 << FADE_VOL_SHIFT))
{ {
mplayInfo->fadeOV = (64 << FADE_VOL_SHIFT); mplayInfo->fadeOV = (64 << FADE_VOL_SHIFT);
mplayInfo->fadeOI = 0; mplayInfo->fadeOI = 0;
@ -672,11 +661,8 @@ void FadeOutBody(struct MusicPlayerInfo *mplayInfo)
} }
else else
{ {
mplayInfo->fadeOV -= (4 << FADE_VOL_SHIFT); if ((s16)(mplayInfo->fadeOV -= (4 << FADE_VOL_SHIFT)) <= 0)
if ((s16)(mplayInfo->fadeOV & mask) <= 0)
{ {
for (i = mplayInfo->trackCount, track = mplayInfo->tracks; i > 0; i--, track++) for (i = mplayInfo->trackCount, track = mplayInfo->tracks; i > 0; i--, track++)
{ {
u32 val; u32 val;