diff options
author | Colin Noga <Tempus@chronometry.ca> | 2012-12-08 14:13:53 -0600 |
---|---|---|
committer | Colin Noga <Tempus@chronometry.ca> | 2012-12-08 14:13:53 -0600 |
commit | da3aa8b641e21a766b4212385e434ff2f9927e98 (patch) | |
tree | 16ed9a79f04bbc4bfdc0bb6b1b4d551df044c812 /src/koopatlas/mapmusic.cpp | |
parent | 16d563a330e1a3190b6212a0bca2a4c80e2b5cff (diff) | |
parent | 3e1eddbcca15042a7a63f29f5db3ce66237355b9 (diff) | |
download | kamek-da3aa8b641e21a766b4212385e434ff2f9927e98.tar.gz kamek-da3aa8b641e21a766b4212385e434ff2f9927e98.zip |
Merge branch 'level-select' of ssh://treeki.rustedlogic.net:30000/Kamek into level-select
Diffstat (limited to 'src/koopatlas/mapmusic.cpp')
-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); |