diff options
author | Treeki <treeki@gmail.com> | 2012-11-22 23:12:30 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-11-22 23:12:30 +0100 |
commit | 996c43b8e327a2d63f99c4f5a2d820dbaf1be8f3 (patch) | |
tree | f2b2b38cff295beaa4244f5605f84fac616812f4 /src/koopatlas/core.cpp | |
parent | 53880784ce5dced94bd3d98a240bcf84041c3ad5 (diff) | |
download | kamek-996c43b8e327a2d63f99c4f5a2d820dbaf1be8f3.tar.gz kamek-996c43b8e327a2d63f99c4f5a2d820dbaf1be8f3.zip |
new map music system
Diffstat (limited to 'src/koopatlas/core.cpp')
-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()); |