summaryrefslogtreecommitdiff
path: root/src/koopatlas/core.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/koopatlas/core.cpp')
-rw-r--r--src/koopatlas/core.cpp62
1 files changed, 4 insertions, 58 deletions
diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp
index 5734300..fd6eace 100644
--- a/src/koopatlas/core.cpp
+++ b/src/koopatlas/core.cpp
@@ -1,7 +1,6 @@
#include "koopatlas/core.h"
#include "koopatlas/camera.h"
#include "koopatlas/player.h"
-#include "koopatlas/subplayer.h"
#include "music.h"
extern "C" void LoadMapScene();
@@ -194,7 +193,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;
@@ -253,12 +252,6 @@ bool WMInit_SetupExtra(void *ptr) {
wm->player->modelHandler->mdlClass->setPowerup(Player_Powerup[0]);
wm->player->modelHandler->mdlClass->startAnimation(0, 1.2f, 10.0f, 0.0f);
- for (int i = 0; i < 3; i++) {
- wm->subPlayer[i] = (daWMSubPlayer_c*)CreateParentedObject(WM_SUBPLAYER, wm, i+1, 2);
- wm->subPlayer[i]->modelHandler->mdlClass->setPowerup(Player_Powerup[i+1]);
- wm->subPlayer[i]->modelHandler->mdlClass->startAnimation(0, 1.2f, 10.0f, 0.0f);
- }
-
// since we've got all the resources, set up the path data too
SpammyReport("preparing path manager\n");
wm->pathManager.setup();
@@ -266,8 +259,6 @@ bool WMInit_SetupExtra(void *ptr) {
// and put the player into position
dKPNode_s *cNode = wm->pathManager.currentNode;
wm->player->pos = (Vec){cNode->x, -cNode->y, wm->player->pos.z};
- for (int i = 0; i < 3; i++)
- wm->subPlayer[i]->pos = (Vec){cNode->x, -cNode->y, wm->subPlayer[i]->pos.z};
// is last param correct? must check :/
SpammyReport("creating MAP\n");
@@ -421,52 +412,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 +454,7 @@ bool dScKoopatlas_c::mapIsRunning() {
int dScKoopatlas_c::onExecute() {
+ dKPMusic::execute();
if (!canDoStuff()) return true;
//SpammyReport("Executing state: %s\n", state.getCurrentState()->getName());
@@ -751,9 +700,6 @@ void dScKoopatlas_c::executeState_PowerupsWait() {
if (!STKI_SHOW(this->stockItem)) {
player->modelHandler->mdlClass->setPowerup(Player_Powerup[0]);
- for (int i = 0; i < 3; i++)
- subPlayer[i]->modelHandler->mdlClass->setPowerup(Player_Powerup[i+1]);
-
state.setState(&StateID_Normal);
}