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 | |
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 | ||||
-rw-r--r-- | src/koopatlas/core.h | 6 | ||||
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 47 |
3 files changed, 83 insertions, 22 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); diff --git a/src/koopatlas/core.h b/src/koopatlas/core.h index ee8cf8f..eddb870 100644 --- a/src/koopatlas/core.h +++ b/src/koopatlas/core.h @@ -116,12 +116,18 @@ class dScKoopatlas_c : public dScene_c { const char *getMapNameForIndex(int index); int getIndexForMapName(const char *name); + nw4r::snd::StrmSoundHandle bgm; + void startLevel(dLevelInfo_c::entry_s *level); bool canDoStuff(); bool mapIsRunning(); void showSaveWindow(); + + void playBGM(); + void setBGMTrack(int trackID); + int currentBGMTrack; }; extern void *_8042A788; diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index abcfd76..6b28d66 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -657,31 +657,36 @@ void dWMPathManager_c::moveThroughPath() { OSReport("Activating world change %d\n", to->worldID); const dKPWorldDef_s *world = dScKoopatlas_c::instance->mapData.findWorldDef(to->worldID); if (world) { + bool visiblyChange = false; if (strncmp(save->newerWorldName, world->name, 32) == 0) { - OSReport("Already here\n"); - } else { - OSReport("Found!\n"); - strncpy(save->newerWorldName, world->name, 32); - save->newerWorldName[31] = 0; - save->newerWorldID = world->worldID; - save->currentMapMusic = world->trackID; - - for (int i = 0; i < 2; i++) { - save->fsTextColours[i] = world->fsTextColours[i]; - save->fsHintColours[i] = world->fsHintColours[i]; - save->hudTextColours[i] = world->hudTextColours[i]; - } - - save->hudHintH = world->hudHintH; - save->hudHintS = world->hudHintS; - save->hudHintL = world->hudHintL; + OSReport("Already here, but setting BGM track\n"); + visiblyChange = true; + } - save->titleScreenWorld = world->titleScreenWorld; - save->titleScreenLevel = world->titleScreenLevel; + OSReport("Found!\n"); + strncpy(save->newerWorldName, world->name, 32); + save->newerWorldName[31] = 0; + save->newerWorldID = world->worldID; + save->currentMapMusic = world->trackID; - if (dWMHud_c::instance) - dWMHud_c::instance->showFooter(); + for (int i = 0; i < 2; i++) { + save->fsTextColours[i] = world->fsTextColours[i]; + save->fsHintColours[i] = world->fsHintColours[i]; + save->hudTextColours[i] = world->hudTextColours[i]; } + + save->hudHintH = world->hudHintH; + save->hudHintS = world->hudHintS; + save->hudHintL = world->hudHintL; + + save->titleScreenWorld = world->titleScreenWorld; + save->titleScreenLevel = world->titleScreenLevel; + + if (visiblyChange && dWMHud_c::instance) + dWMHud_c::instance->showFooter(); + + dScKoopatlas_c::instance->setBGMTrack(world->trackID); + } else if (to->worldID == 0) { OSReport("No world\n"); save->newerWorldName[0] = 0; |