diff options
Diffstat (limited to '')
-rw-r--r-- | src/koopatlas/core.cpp | 50 |
1 files changed, 4 insertions, 46 deletions
diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp index 5734300..89f315a 100644 --- a/src/koopatlas/core.cpp +++ b/src/koopatlas/core.cpp @@ -194,7 +194,7 @@ bool WMInit_LoadResources2(void *ptr) { } if (wm->mapData.load(wm->mapPath)) { - wm->playBGM(); + dKPMusic::play(GetSaveFile()->GetBlock(-1)->currentMapMusic); return true; } else return false; @@ -421,52 +421,9 @@ int dScKoopatlas_c::onCreate() { extern "C" void PlaySoundWithFunctionB4(void *spc, nw4r::snd::SoundHandle *handle, int id, int unk); -void dScKoopatlas_c::playBGM() { - char cleanName[40]; - // find the end - const char *mapPathEnd = mapPath; - while (*mapPathEnd) - mapPathEnd++; - - // it now points to the zero - const char *findSlash = mapPathEnd; - while (findSlash > mapPath && *findSlash != '/') - findSlash--; - - // it now points to the slash - strcpy(cleanName, "Map_"); - strncpy(&cleanName[4], findSlash+1, 36); - - // nuke everything up to the point - for (int i = 4; i < 40; i++) - if (cleanName[i] == '.') - cleanName[i] = 0; - - int realStreamID; - OSReport("I'm going to play %s!\n", cleanName); - hijackMusicWithSongName(cleanName, -1, false, 16, 8, &realStreamID); - OSReport("Real Stream ID: %d\n", realStreamID); - PlaySoundWithFunctionB4(SoundRelatedClass, &bgm, realStreamID, 1); - - currentBGMTrack = GetSaveFile()->GetBlock(-1)->currentMapMusic; - OSReport("Enabling track %d by setting bitfield 0x%x to volume 1.0f and bitfield 0x%x to volume 0.0f; both over 0 frames\n", currentBGMTrack, 1 << currentBGMTrack, 0xFF ^ (1 << currentBGMTrack)); - bgm.SetTrackVolume(0xFF ^ (1 << currentBGMTrack), 0, 0.0f); - bgm.SetTrackVolume(1 << currentBGMTrack, 0, 1.0f); -} - -void dScKoopatlas_c::setBGMTrack(int trackID) { - if (currentBGMTrack == trackID) - return; - - OSReport("Enabling track %d and disabling track %d by setting bitfield 0x%x to volume 1.0f and bitfield 0x%x to volume 0.0f; both over 30 frames\n", trackID, currentBGMTrack, 1 << trackID, 1 << currentBGMTrack); - bgm.SetTrackVolume(1 << currentBGMTrack, 30, 0.0f); - bgm.SetTrackVolume(1 << trackID, 30, 1.0f); - currentBGMTrack = trackID; -} - int dScKoopatlas_c::onDelete() { - if (bgm.Exists()) - bgm.Stop(0); + if (!keepMusicPlaying) + dKPMusic::stop(); FreeScene(0); FreeScene(1); @@ -506,6 +463,7 @@ bool dScKoopatlas_c::mapIsRunning() { int dScKoopatlas_c::onExecute() { + dKPMusic::execute(); if (!canDoStuff()) return true; //SpammyReport("Executing state: %s\n", state.getCurrentState()->getName()); |