diff options
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); |