diff options
author | Colin Noga <Tempus@chronometry.ca> | 2012-11-25 15:35:13 -0600 |
---|---|---|
committer | Colin Noga <Tempus@chronometry.ca> | 2012-11-25 15:35:13 -0600 |
commit | db34c0af338b8cf04f50b4ade98668869fd303e1 (patch) | |
tree | e373abe027205c0e8414cf6146ded59112b0ab72 /src/koopatlas | |
parent | 72b9b71b5b7fb5757849d19af3dfae21d0ab9c92 (diff) | |
parent | 1609b49c5c1777e663909b1936b2f8921677f230 (diff) | |
download | kamek-db34c0af338b8cf04f50b4ade98668869fd303e1.tar.gz kamek-db34c0af338b8cf04f50b4ade98668869fd303e1.zip |
Merge branch 'level-select' of ssh://treeki.rustedlogic.net:30000/Kamek into level-select
Diffstat (limited to 'src/koopatlas')
-rw-r--r-- | src/koopatlas/core.cpp | 62 | ||||
-rw-r--r-- | src/koopatlas/core.h | 9 | ||||
-rw-r--r-- | src/koopatlas/map.cpp | 8 | ||||
-rw-r--r-- | src/koopatlas/mapmusic.cpp | 146 | ||||
-rw-r--r-- | src/koopatlas/mapmusic.h | 11 | ||||
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 35 | ||||
-rw-r--r-- | src/koopatlas/player.cpp | 69 | ||||
-rw-r--r-- | src/koopatlas/player.h | 18 | ||||
-rw-r--r-- | src/koopatlas/subplayer.cpp | 116 | ||||
-rw-r--r-- | src/koopatlas/subplayer.h | 38 |
10 files changed, 189 insertions, 323 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); } diff --git a/src/koopatlas/core.h b/src/koopatlas/core.h index 3f795cc..651b628 100644 --- a/src/koopatlas/core.h +++ b/src/koopatlas/core.h @@ -16,6 +16,7 @@ #include "koopatlas/starcoin.h" #include "koopatlas/hud.h" #include "koopatlas/pathmanager.h" +#include "koopatlas/mapmusic.h" #define WM_DEBUGGING //#define WM_SPAMMY_DEBUGGING @@ -39,7 +40,6 @@ void NewerMapDrawFunc(); #define WM_STARCOIN WM_GHOST class daWMPlayer_c; -class daWMSubPlayer_c; class dWMMap_c; class dWMHud_c; class dWMShop_c; @@ -100,7 +100,6 @@ class dScKoopatlas_c : public dScene_c { daWMPlayer_c *player; - daWMSubPlayer_c *subPlayer[3]; dWMHud_c *hud; dWMMap_c *map; dWMShop_c *shop; @@ -117,8 +116,6 @@ 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(); @@ -126,9 +123,7 @@ class dScKoopatlas_c : public dScene_c { void showSaveWindow(); - void playBGM(); - void setBGMTrack(int trackID); - int currentBGMTrack; + bool keepMusicPlaying; }; extern void *_8042A788; diff --git a/src/koopatlas/map.cpp b/src/koopatlas/map.cpp index ff28e19..c2cb13e 100644 --- a/src/koopatlas/map.cpp +++ b/src/koopatlas/map.cpp @@ -114,14 +114,20 @@ void dWMMap_c::renderer_c::drawXlu() { void dWMMap_c::renderer_c::drawLayers() { - dKPMapData_c *dataCls = &dScKoopatlas_c::instance->mapData; + dScKoopatlas_c *wm = dScKoopatlas_c::instance; + dKPMapData_c *dataCls = &wm->mapData; dKPMapFile_s *data = dataCls->data; baseZ = -100.0f - (2 * data->layerCount); + bool skipFirstLayer = (wm->currentMapID == 0) && !(wm->settings & 0x80000000); + beginRendering(); for (int iLayer = data->layerCount - 1; iLayer >= 0; iLayer--) { + if (skipFirstLayer && iLayer == 0) + continue; + dKPLayer_s *layer = data->layers[iLayer]; renderMtx[2][3] += 2.0f; diff --git a/src/koopatlas/mapmusic.cpp b/src/koopatlas/mapmusic.cpp new file mode 100644 index 0000000..1ccd775 --- /dev/null +++ b/src/koopatlas/mapmusic.cpp @@ -0,0 +1,146 @@ +#include <game.h> +#include "koopatlas/mapmusic.h" +#include "music.h" + +extern "C" void PlaySoundWithFunctionB4(void *spc, nw4r::snd::SoundHandle *handle, int id, int unk); + +static nw4r::snd::StrmSoundHandle s_handle; +static bool s_playing = false; +static int s_song = -1; +static int s_nextSong = -1; + +static int s_countdownToSwitch = -1; +static int s_countdownToFadeIn = -1; + +static dDvdLoader_c s_adpcmInfoLoader; +static bool s_adpcmInfoLoaded = false; + +#define FADE_OUT_LEN 30 +#define FADE_IN_LEN 30 +#define BUFFER_CLEAR_DELAY 60 + +u8 hijackMusicWithSongName(const char *songName, int themeID, bool hasFast, int channelCount, int trackCount, int *wantRealStreamID); + +void dKPMusic::play(int id) { + if (s_playing) { + // Switch track + OSReport("Trying to switch to song %d (Current one is %d)...\n", id, s_song); + if (s_song == id || s_nextSong == id) + return; + if (s_countdownToSwitch >= 0 || s_countdownToFadeIn >= 0) + return; + OSReport("Will switch; Fading out current track 2 over %d frames\n", FADE_OUT_LEN); + + s_handle.SetTrackVolume(1<<1, FADE_OUT_LEN, 0.0f); + s_nextSong = id; + s_countdownToSwitch = FADE_OUT_LEN; + + } else { + // New track + OSReport("Playing song %d from the start.\n", id); + + int realStreamID; + char brstmName[8]; + sprintf(brstmName, "map%d", id); + hijackMusicWithSongName(brstmName, -1, false, 4, 2, &realStreamID); + + PlaySoundWithFunctionB4(SoundRelatedClass, &s_handle, realStreamID, 1); + + s_playing = true; + s_song = id; + } +} + +// crap. +#include "fileload.h" + +extern "C" void DVDCancel(void *crap); + +extern "C" void AxVoice_SetADPCM(void *axVoice, void *adpcm); +extern "C" void Voice_SetADPCMLoop(void *voice, int channel, void *adpcmLoop); + +void dKPMusic::execute() { + if (!s_adpcmInfoLoaded) { + if (s_adpcmInfoLoader.load("/NewerRes/MapADPCMInfo.bin")) + s_adpcmInfoLoaded = true; + } + + if (!s_playing) + return; + + if (s_countdownToSwitch >= 0) { + s_countdownToSwitch--; + if (s_countdownToSwitch == 0) { + OSReport("Switching brstm files to song %d.\n", s_nextSong); + + s_countdownToFadeIn = BUFFER_CLEAR_DELAY; + + char brstmPath[48]; + sprintf(brstmPath, "/Sound/new/map%d.er", s_nextSong); + + u8 *sound = (u8*)(s_handle.GetSound()); + u8 *player = sound+0x110; + u8 **fileStreamPointer = (u8**)(player+0x808); + u8 *fileStream = *fileStreamPointer; + DVDHandle *fileInfo = (DVDHandle*)(fileStream+0x28); + DVDCancel(fileInfo); + bool result = DVDFastOpen(DVDConvertPathToEntrynum(brstmPath), fileInfo); + + OSReport("StrmSound is at %p, StrmPlayer is at %p, FileStream pointer is at %p, FileStream is at %p, FileInfo is at %p\n", sound, player, fileStreamPointer, fileStream, fileInfo); + OSReport("Changed to name %s. FastOpen returned: %d\n", brstmPath, result); + + u8 *trackArray = player+0xB58; + u8 *track = (trackArray + (0x38 * 1)); + u8 **voicePointer = (u8**)(track+4); + u8 *voice = *voicePointer; + OSReport("Track Array: %p; Track: %p; Voice Pointer: %p; Voice: %p\n", trackArray, track, voicePointer, voice); + + for (int i = 0; i < 2; i++) { + int sourceBlockID = (s_nextSong*2)+i; + u8 *sourceData = ((u8*)(s_adpcmInfoLoader.buffer)) + (0x30*sourceBlockID); + OSReport("Using ADPCM data for channel %d from block %d, data at %p\n", i, sourceBlockID, sourceData); + + Voice_SetADPCMLoop(voice, i, sourceData+0x28); + + // loop through all axVoices + for (int j = 0; j < 4; j++) { + int axVoiceID = (i*4) + j; + u8 **axVoicePointer = (u8**)(voice + 0xC + (axVoiceID*4)); + u8 *axVoice = *axVoicePointer; + OSReport("Setting AxVoice ID %d, with pointer at %p, located at %p\n", axVoiceID, axVoicePointer, axVoice); + + if (axVoice) + AxVoice_SetADPCM(axVoice, sourceData); + } + } + + OSReport("All done\n"); + + s_song = s_nextSong; + s_nextSong = -1; + } + + } else if (s_countdownToFadeIn >= 0) { + s_countdownToFadeIn--; + if (s_countdownToFadeIn == 0) { + OSReport("Going to fade in the second track now!\n"); + s_handle.SetTrackVolume(1<<1, FADE_IN_LEN, 1.0f); + } + } +} + +void dKPMusic::stop() { + if (!s_playing) + return; + + OSReport("Stopping song\n"); + + s_playing = false; + s_song = -1; + s_nextSong = -1; + s_countdownToSwitch = -1; + s_countdownToFadeIn = -1; + + if (s_handle.Exists()) + s_handle.Stop(30); +} diff --git a/src/koopatlas/mapmusic.h b/src/koopatlas/mapmusic.h new file mode 100644 index 0000000..785f870 --- /dev/null +++ b/src/koopatlas/mapmusic.h @@ -0,0 +1,11 @@ +#ifndef MAPMUSIC_H +#define MAPMUSIC_H + +class dKPMusic { + public: + static void play(int id); + static void execute(); + static void stop(); +}; + +#endif /* MAPMUSIC_H */ diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 002b400..a5e4294 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -10,6 +10,8 @@ extern "C" void PlaySoundWithFunctionB4(void *spc, nw4r::snd::SoundHandle *handl static u8 MaybeFinishingLevel[2] = {0xFF,0xFF}; void dWMPathManager_c::setup() { + dScKoopatlas_c *wm = dScKoopatlas_c::instance; + isMoving = false; isJumping = false; scaleAnimProgress = -1; @@ -17,7 +19,7 @@ void dWMPathManager_c::setup() { currentPath = 0; reverseThroughPath = false; - pathLayer = dScKoopatlas_c::instance->mapData.pathLayer; + pathLayer = wm->mapData.pathLayer; SpammyReport("setting up PathManager\n"); SaveBlock *save = GetSaveFile()->GetBlock(-1); @@ -29,11 +31,6 @@ void dWMPathManager_c::setup() { levelStartWait = -1; unlockPaths(); - if (!countdownToFadeIn) - waitAtStart = 50; - else - waitAtStart = -1; - waitForAfterDeathAnim = -1; mustPlayAfterDeathAnim = false; if (LastPowerupStoreType == LOSE_LEVEL) { @@ -45,9 +42,9 @@ void dWMPathManager_c::setup() { SpammyReport("done\n"); // Figure out what path node to start at - if (dScKoopatlas_c::instance->settings & 0x10000000) { + if (wm->settings & 0x10000000) { // Start off from a "Change" - u8 changeID = (dScKoopatlas_c::instance->settings >> 20) & 0xFF; + u8 changeID = (wm->settings >> 20) & 0xFF; SpammyReport("entering at Change ID %d\n", changeID); SpammyReport("Path layer: %p\n", pathLayer); SpammyReport("Node count: %d\n", pathLayer->nodeCount); @@ -112,7 +109,16 @@ void dWMPathManager_c::setup() { mustComplainToMapCreator = true; } + waitAtStart = -1; } else { + if (!countdownToFadeIn) + waitAtStart = 50; + else + waitAtStart = -1; + + if (wm->currentMapID == 0 && wm->settings & 0x80000000) + waitAtStart = 280; + SpammyReport("saved path node: %d\n", save->current_path_node); if (save->current_path_node >= pathLayer->nodeCount) { SpammyReport("out of bounds (%d), using node 0\n", pathLayer->nodeCount); @@ -232,7 +238,6 @@ void dWMPathManager_c::unlockPaths() { if (node->type == node->LEVEL && node->isUnlocked() && node->levelNumber[1] != 99) { save->completions[node->levelNumber[0]-1][node->levelNumber[1]-1] |= COND_UNLOCKED; - OSReport("beets: %d-%d\n", node->levelNumber[0], node->levelNumber[1]); } } @@ -590,13 +595,11 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) { if (Animations[id].initialEffect) { SpawnEffect(Animations[id].initialEffect, 0, &player->pos, 0, &player->scale); - daWMPlayer_c::instance->nextNowEffect = Animations[id].initialEffect; } if (Animations[id].initialSound != SE_NULL) { nw4r::snd::SoundHandle something; PlaySoundWithFunctionB4(SoundRelatedClass, &something, Animations[id].initialSound, 1); - daWMPlayer_c::instance->nextNowSound = Animations[id].initialSound; if (Animations[id].initialSound == SE_PLY_JUMP) { nw4r::snd::SoundHandle something2; @@ -735,10 +738,12 @@ void dWMPathManager_c::moveThroughPath() { if (visiblyChange && dWMHud_c::instance) dWMHud_c::instance->showFooter(); - dScKoopatlas_c::instance->setBGMTrack(world->trackID); + dKPMusic::play(world->trackID); } else if (to->worldID == 0) { OSReport("No world\n"); + save->currentMapMusic = 0; + dKPMusic::play(0); save->newerWorldName[0] = 0; if (dWMHud_c::instance) dWMHud_c::instance->hideFooter(); @@ -765,6 +770,7 @@ void dWMPathManager_c::moveThroughPath() { SpammyReport("Change to map ID %d (%s), entrance ID %d\n", save->current_world, to->destMap, to->foreignID); + dScKoopatlas_c::instance->keepMusicPlaying = true; ActivateWipe(to->transition); DoSceneChange(WORLD_MAP, 0x10000000 | (to->foreignID << 20), 0); @@ -828,10 +834,7 @@ void dWMPathManager_c::activatePoint() { levelStartWait = 40; enteredLevel = dLevelInfo_c::s_info.searchBySlot(w, l); - if (dScKoopatlas_c::instance->bgm.Exists()) { - dScKoopatlas_c::instance->bgm.Stop(50); - dScKoopatlas_c::instance->bgm.DetachSound(); - } + dKPMusic::stop(); } } diff --git a/src/koopatlas/player.cpp b/src/koopatlas/player.cpp index 3a736b4..abfb329 100644 --- a/src/koopatlas/player.cpp +++ b/src/koopatlas/player.cpp @@ -1,5 +1,4 @@ #include "koopatlas/player.h" -#include "koopatlas/subplayer.h" daWMPlayer_c *daWMPlayer_c::instance; @@ -42,38 +41,6 @@ int daWMPlayer_c::onExecute() { dScKoopatlas_c::instance->pathManager.execute(); - // work out the Z positions first of all - struct ySortThing_s { - float y; int id; - }; - ySortThing_s sorts[4]; - sorts[0].y = pos.y; - sorts[0].id = 0; - for (int i = 1; i < 4; i++) { - sorts[i].y = stateHistory[i * SUBPLAYER_DISTANCE].pos.y; - sorts[i].id = i; - } - - // bubble sort it with an algorithm from wikipedia - bool swapped; - do { - swapped = false; - for (int i = 1; i < 4; i++) { - if (sorts[i-1].y > sorts[i].y) { - ySortThing_s forSwap = sorts[i-1]; - sorts[i-1] = sorts[i]; - sorts[i] = forSwap; - swapped = true; - } - } - } while (swapped); - - // then put together the positions - float chosenZPositions[4]; - for (int i = 0; i < 4; i++) - chosenZPositions[sorts[i].id] = 3100.0f - (i * 25.0f); - pos.z = chosenZPositions[0]; - this->modelHandler->update(); mMtx myMatrix; @@ -101,42 +68,6 @@ int daWMPlayer_c::onExecute() { if (timer > 12) { timer = 0; } } - if (stateHistoryBuilt) { - for (int i = STATE_COUNT - 1; i >= 1; i--) - stateHistory[i] = stateHistory[i - 1]; - } - - state_s *st = &stateHistory[0]; - st->pos = pos; - st->scale = scale; - st->rot = rot; - st->repeatedEffect = (hasEffect ? effectName : 0); - st->nowEffect = nextNowEffect; - st->repeatedSound = (hasSound ? soundName : 0); - st->nowSound = nextNowSound; - st->jumpOffset = jumpOffset; - st->anim = currentAnim; - st->animFrame = currentFrame; - st->animUnk = currentUnk; - st->animUpdateRate = currentUpdateRate; - - if (!stateHistoryBuilt) { - for (int i = 1; i < STATE_COUNT; i++) - stateHistory[i] = stateHistory[0]; - stateHistoryBuilt = true; - } - - nextNowEffect = 0; - nextNowSound = 0; - - for (int i = 0; i < 3; i++) { - daWMSubPlayer_c *sp = dScKoopatlas_c::instance->subPlayer[i]; - - state_s *st = &stateHistory[(i+1) * SUBPLAYER_DISTANCE]; - st->pos.z = chosenZPositions[i+1]; - sp->update(st); - } - return true; } diff --git a/src/koopatlas/player.h b/src/koopatlas/player.h index 70d6bf5..db9b16a 100644 --- a/src/koopatlas/player.h +++ b/src/koopatlas/player.h @@ -37,24 +37,6 @@ class daWMPlayer_c : public dActor_c { static daWMPlayer_c *build(); static daWMPlayer_c *instance; - - struct state_s { - Vec pos, scale; - S16Vec rot; - const char *repeatedEffect, *nowEffect; - int repeatedSound, nowSound; - int anim; - float animFrame, animUnk, animUpdateRate; - float jumpOffset; - }; - - bool stateHistoryBuilt; - static const int SUBPLAYER_DISTANCE = 15; - static const int STATE_COUNT = (SUBPLAYER_DISTANCE * 3) + 1; - state_s stateHistory[STATE_COUNT]; - - int nextNowSound; - const char *nextNowEffect; }; #endif diff --git a/src/koopatlas/subplayer.cpp b/src/koopatlas/subplayer.cpp deleted file mode 100644 index 8f70299..0000000 --- a/src/koopatlas/subplayer.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "koopatlas/player.h" -#include "koopatlas/subplayer.h" - -daWMSubPlayer_c *daWMSubPlayer_c::instance; - -int daWMSubPlayer_c::onCreate() { - - this->modelHandler = new dPlayerModelHandler_c(settings); - // loadModel(u8 player_id, int powerup_id, int unk); - this->modelHandler->loadModel(settings, 3, 2); - this->modelHandler->mdlClass->startAnimation(0, 1.2, 10.0, 0.0); - this->modelHandler->setSRT((Vec){0.0,100.0,-100.0}, (S16Vec){0,0,0}, (Vec){2.0,2.0,2.0}); - this->modelHandler->draw(); - - hammerSuit.setup(this->modelHandler); - - pos = (Vec){0.0f,0.0f,3000.0f}; - rot = (S16Vec){0x1800,0,0}; - scale = (Vec){1.6f,1.6f,1.6f}; - - step = false; - timer = 0; - - return true; -} - -int daWMSubPlayer_c::onDelete() { - delete modelHandler; - - return true; -} - - -void daWMSubPlayer_c::update(daWMPlayer_c::state_s *st) { - this->modelHandler->update(); - - startAnimation(st->anim, st->animFrame, st->animUnk, st->animUpdateRate); - - pos = st->pos; - scale = st->scale; - rot = st->rot; - - mMtx myMatrix; - myMatrix.scale(scale.x, scale.y, scale.z); - myMatrix.applyTranslation(pos.x, pos.y + st->jumpOffset, pos.z); - myMatrix.applyRotationX(&rot.x); - myMatrix.applyRotationY(&rot.y); - // Z is unused for now - modelHandler->setMatrix(myMatrix); - - if (st->repeatedEffect) { - Vec effPos = {pos.x, pos.y, 3300.0f}; - effect.spawn(st->repeatedEffect, 0, &effPos, &rot, &scale); - } - - if (st->repeatedSound) { - timer++; - - if (timer == 12) { - if (step) { MapSoundPlayer(SoundRelatedClass, st->repeatedSound, 1); step = false; } - else { MapSoundPlayer(SoundRelatedClass, st->repeatedSound+1, 1); step = true; } - timer = 0; - } - - if (timer > 12) { timer = 0; } - } - - if (st->nowEffect) { - SpawnEffect(st->nowEffect, 0, &pos, 0, &scale); - } - - if (st->nowSound != SE_NULL) { - nw4r::snd::SoundHandle something; - PlaySoundWithFunctionB4(SoundRelatedClass, &something, st->nowSound, 1); - - if (st->nowSound == SE_PLY_JUMP) { - nw4r::snd::SoundHandle something2; - PlaySoundWithFunctionB4(SoundRelatedClass, &something2, SE_VOC_MA_CS_JUMP, 1); - } - } -} - -int daWMSubPlayer_c::onDraw() { - if (!visible) - return true; - - this->modelHandler->draw(); - hammerSuit.draw(); - - return true; -} - - -void daWMSubPlayer_c::startAnimation(int id, float frame, float unk, float updateRate) { - if (id == currentAnim && frame == currentFrame && unk == currentUnk && updateRate == currentUpdateRate) - return; - - currentAnim = id; - currentFrame = frame; - currentUnk = unk; - currentUpdateRate = updateRate; - this->modelHandler->mdlClass->startAnimation(id, frame, unk, updateRate); -} - - - -daWMSubPlayer_c *daWMSubPlayer_c::build() { - - void *buffer = AllocFromGameHeap1(sizeof(daWMSubPlayer_c)); - daWMSubPlayer_c *c = new(buffer) daWMSubPlayer_c; - - - instance = c; - return c; -} - diff --git a/src/koopatlas/subplayer.h b/src/koopatlas/subplayer.h deleted file mode 100644 index d9b1b20..0000000 --- a/src/koopatlas/subplayer.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __KOOPATLAS_SUBPLAYER_H -#define __KOOPATLAS_SUBPLAYER_H - -#include "koopatlas/core.h" -#include "poweruphax.h" -#include <playerAnim.h> - - -class daWMSubPlayer_c : public dActor_c { - public: - dPlayerModelHandler_c *modelHandler; - - int onCreate(); - int onDelete(); - int onDraw(); - - void update(daWMPlayer_c::state_s *st); - - int currentAnim; - float currentFrame; - float currentUnk; - float currentUpdateRate; - - bool step; - - int timer; - - mEf::es2 effect; - dHammerSuitRenderer_c hammerSuit; - - void startAnimation(int id, float frame, float unk, float updateRate); - - static daWMSubPlayer_c *build(); - static daWMSubPlayer_c *instance; -}; - -#endif - |