From f7f56dcda839fec2ad69013d2898791f2140b875 Mon Sep 17 00:00:00 2001 From: escape209 Date: Fri, 11 Oct 2024 19:07:01 +0100 Subject: [PATCH] Match zMusicUnpause --- src/SB/Game/zMusic.cpp | 59 +++++++++++++++++++++++------------------- src/SB/Game/zMusic.h | 2 +- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/SB/Game/zMusic.cpp b/src/SB/Game/zMusic.cpp index 12122893..e9b15660 100644 --- a/src/SB/Game/zMusic.cpp +++ b/src/SB/Game/zMusic.cpp @@ -114,7 +114,6 @@ void zMusicInit() volume_reset(); } -// Correct, but won't work due to the switch case jump table (messes with offsets) S32 getCurrLevelMusicEnum() { S32 snd_enum; @@ -247,40 +246,46 @@ void zMusicPause() } } -// WIP. -#if 0 -// Only thing that doesn't compile correctly is the function call to xSndPlay, in which a bunch of stuff is in the wrong order it looks like. void zMusicUnpause(S32 kill) { - if (sMusicPaused != 0) + if (sMusicPaused == 0) { - for (S32 i = 0; i < 2; i++) + return; + } + for (S32 i = 0; i < 2; i++) + { + zMusicTrackInfo* track = &sMusicTrack[i]; + U32 prioBase = 0x800 * i; + if (track->snd_id == 0) { - zMusicTrackInfo* track = &sMusicTrack[i]; - U32 prioBase = 0x800 * i; - if (track->snd_id != 0) - { - if (kill != 0) - { - track->snd_id = 0; - } - else - { - U32 res = - xSndPlay(track->assetID, track->lastVol, lbl_803CDD48, 0xff, - prioBase | (int)(-track->loop | track->loop) >> 0x1f & 0x8000U | - 0x10000 | 0x20000, - 0, SND_CAT_MUSIC, lbl_803CDD48); - track->snd_id = res; - } - } + continue; + } + if (kill != 0) + { + track->snd_id = 0; + } + else + { + prioBase |= (track->loop ? 0x8000 : 0) | 0x10000; + prioBase |= 0x20000; + + track->snd_id = + xSndPlay + ( + track->assetID, + track->lastVol, + 0.0f, + 0xff, + prioBase, + 0, + SND_CAT_MUSIC, + 0.0f + ); } - sMusicPaused = 0; } + sMusicPaused = 0; } -#endif - // WIP. #if 0 // Not sure what's wrong with this one. Doesn't match in the slightest. diff --git a/src/SB/Game/zMusic.h b/src/SB/Game/zMusic.h index b7d235dc..42871b80 100644 --- a/src/SB/Game/zMusic.h +++ b/src/SB/Game/zMusic.h @@ -38,7 +38,7 @@ struct zMusicTrackInfo void volume_reset(); void zMusicRefreshVolume(); -S32 getCurrLevelMusicEnum(); +static S32 getCurrLevelMusicEnum(); void zMusicNotify(S32 situation); void zMusicSetVolume(F32 vol, F32 delay); void zMusicKill();