diff options
Diffstat (limited to '')
-rw-r--r-- | src/koopatlas/core.cpp | 6 | ||||
-rw-r--r-- | src/koopatlas/mapmusic.cpp | 51 | ||||
-rw-r--r-- | src/koopatlas/mapmusic.h | 1 |
3 files changed, 41 insertions, 17 deletions
diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp index 03b8dae..71122e5 100644 --- a/src/koopatlas/core.cpp +++ b/src/koopatlas/core.cpp @@ -47,6 +47,7 @@ dScKoopatlas_c *dScKoopatlas_c::build() { } bool WMInit_StartLoading(void*); +bool WMInit_LoadStaticFiles(void*); bool StockWMInit_LoadEffects(void*); bool WMInit_LoadSIAnims(void*); bool WMInit_EndLoading(void*); @@ -58,6 +59,7 @@ bool WMInit_SetupWipe(void*); ChainedFunc initFunctions[] = { WMInit_StartLoading, + WMInit_LoadStaticFiles, StockWMInit_LoadEffects, WMInit_LoadSIAnims, WMInit_EndLoading, @@ -135,6 +137,10 @@ bool WMInit_StartLoading(void *ptr) { return true; } +bool WMInit_LoadStaticFiles(void *ptr) { + return dKPMusic::loadInfo(); +} + bool WMInit_LoadSIAnims(void *ptr) { SpammyReport("WMInit_LoadSIAnims called\n"); 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); diff --git a/src/koopatlas/mapmusic.h b/src/koopatlas/mapmusic.h index 785f870..e5d69f2 100644 --- a/src/koopatlas/mapmusic.h +++ b/src/koopatlas/mapmusic.h @@ -3,6 +3,7 @@ class dKPMusic { public: + static bool loadInfo(); static void play(int id); static void execute(); static void stop(); |