diff options
author | Treeki <treeki@gmail.com> | 2012-10-23 05:44:25 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-10-23 05:45:50 +0200 |
commit | 20aa16033547f5a1f0b5032f0c17acf32cbbc7f5 (patch) | |
tree | 8a6056465b7245aa73941ba51bce8e068b20ad23 /src/koopatlas/core.cpp | |
parent | eea011371eee3bd9e6d9660b5f43b80b1a0c336d (diff) | |
download | kamek-20aa16033547f5a1f0b5032f0c17acf32cbbc7f5.tar.gz kamek-20aa16033547f5a1f0b5032f0c17acf32cbbc7f5.zip |
musics and things
Diffstat (limited to '')
-rw-r--r-- | src/koopatlas/core.cpp | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp index b635ba0..252d9a6 100644 --- a/src/koopatlas/core.cpp +++ b/src/koopatlas/core.cpp @@ -68,7 +68,7 @@ ChainedFunc initFunctions[] = { }; dScKoopatlas_c::dScKoopatlas_c() : state(this) { - initChain.setup(initFunctions, 8); + initChain.setup(initFunctions, 9); setInitChain(initChain); } @@ -292,6 +292,9 @@ bool WMInit_SetupWipe(void *ptr) { } SpammyReport("WMInit_SetupWipe returning true\n"); + + wm->playBGM(); + return true; } @@ -404,7 +407,54 @@ int dScKoopatlas_c::onCreate() { return true; } +u8 hijackMusicWithSongName(const char *songName, int themeID, bool hasFast, bool useDrums, int *wantRealStreamID); +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, false, &realStreamID); + OSReport("Real Stream ID: %d\n", realStreamID); + PlaySoundWithFunctionB4(SoundRelatedClass, &bgm, realStreamID, 1); + + currentBGMTrack = GetSaveFile()->GetBlock(-1)->currentMapMusic; + 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; + + 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(5); + FreeScene(0); FreeScene(1); |