diff options
Diffstat (limited to '')
-rw-r--r-- | src/koopatlas/mapmusic.cpp | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/src/koopatlas/mapmusic.cpp b/src/koopatlas/mapmusic.cpp index 1ccd775..8890df5 100644 --- a/src/koopatlas/mapmusic.cpp +++ b/src/koopatlas/mapmusic.cpp @@ -13,7 +13,6 @@ static int s_countdownToSwitch = -1; static int s_countdownToFadeIn = -1; static dDvdLoader_c s_adpcmInfoLoader; -static bool s_adpcmInfoLoaded = false; #define FADE_OUT_LEN 30 #define FADE_IN_LEN 30 @@ -25,15 +24,20 @@ void dKPMusic::play(int id) { if (s_playing) { // Switch track OSReport("Trying to switch to song %d (Current one is %d)...\n", id, s_song); - if (s_song == id || s_nextSong == id) - return; - if (s_countdownToSwitch >= 0 || s_countdownToFadeIn >= 0) - return; - OSReport("Will switch; Fading out current track 2 over %d frames\n", FADE_OUT_LEN); - - s_handle.SetTrackVolume(1<<1, FADE_OUT_LEN, 0.0f); - s_nextSong = id; - s_countdownToSwitch = FADE_OUT_LEN; + if (s_song == id || s_nextSong == id) { + OSReport("This song is already playing or is scheduled. Not gonna do that.\n"); + } else if (s_countdownToFadeIn >= 0) { + OSReport("There's already a track being faded in (CountdownToFadeIn=%d)\n", s_countdownToFadeIn); + } else if (s_countdownToSwitch >= 0) { + OSReport("We were already going to switch tracks, but the rstm hasn't been changed yet, so the next song is being changed to this one\n"); + s_nextSong = id; + } else { + OSReport("Will switch; Fading out current track 2 over %d frames\n", FADE_OUT_LEN); + + s_handle.SetTrackVolume(1<<1, FADE_OUT_LEN, 0.0f); + s_nextSong = id; + s_countdownToSwitch = FADE_OUT_LEN; + } } else { // New track @@ -59,22 +63,24 @@ extern "C" void DVDCancel(void *crap); extern "C" void AxVoice_SetADPCM(void *axVoice, void *adpcm); extern "C" void Voice_SetADPCMLoop(void *voice, int channel, void *adpcmLoop); -void dKPMusic::execute() { - if (!s_adpcmInfoLoaded) { - if (s_adpcmInfoLoader.load("/NewerRes/MapADPCMInfo.bin")) - s_adpcmInfoLoaded = true; - } +bool dKPMusic::loadInfo() { + return s_adpcmInfoLoader.load("/NewerRes/MapADPCMInfo.bin"); +} +void dKPMusic::execute() { if (!s_playing) return; + if (s_handle.GetSound() == 0) { + OSReport("SOUND IS NOT PLAYING!\n"); + return; + } + if (s_countdownToSwitch >= 0) { s_countdownToSwitch--; if (s_countdownToSwitch == 0) { OSReport("Switching brstm files to song %d.\n", s_nextSong); - s_countdownToFadeIn = BUFFER_CLEAR_DELAY; - char brstmPath[48]; sprintf(brstmPath, "/Sound/new/map%d.er", s_nextSong); @@ -83,7 +89,18 @@ void dKPMusic::execute() { u8 **fileStreamPointer = (u8**)(player+0x808); u8 *fileStream = *fileStreamPointer; DVDHandle *fileInfo = (DVDHandle*)(fileStream+0x28); + + if (fileInfo->unk4 == 1) { + OSReport("Was reading chunk, will try again next frame...\n"); + s_countdownToSwitch++; + return; + } + + if (s_nextSong > 0) + s_countdownToFadeIn = BUFFER_CLEAR_DELAY; + DVDCancel(fileInfo); + //OSReport("CANCEL successfully called!\n"); bool result = DVDFastOpen(DVDConvertPathToEntrynum(brstmPath), fileInfo); OSReport("StrmSound is at %p, StrmPlayer is at %p, FileStream pointer is at %p, FileStream is at %p, FileInfo is at %p\n", sound, player, fileStreamPointer, fileStream, fileInfo); |