diff options
| author | robojumper <robojumper@gmail.com> | 2025-06-13 11:21:04 +0200 |
|---|---|---|
| committer | robojumper <robojumper@gmail.com> | 2025-09-13 10:49:03 +0200 |
| commit | f9e95f9bb03b9474bbee85b03121c9b4e158aea4 (patch) | |
| tree | a99cd7311da8ceb83c86e850120ce780a9af3bc1 /src | |
| parent | a30123ac3d0f998fdc62027092fa63e256b2e163 (diff) | |
More d/snd
Diffstat (limited to 'src')
| -rw-r--r-- | src/d/d_message.cpp | 8 | ||||
| -rw-r--r-- | src/d/lyt/d_lyt_game_over.cpp | 3 | ||||
| -rw-r--r-- | src/d/snd/d_snd_3d_manager.cpp | 3 | ||||
| -rw-r--r-- | src/d/snd/d_snd_area_sound_effect_mgr.cpp | 2 | ||||
| -rw-r--r-- | src/d/snd/d_snd_bgm_mgr.cpp | 482 | ||||
| -rw-r--r-- | src/d/snd/d_snd_control_player.cpp | 5 | ||||
| -rw-r--r-- | src/d/snd/d_snd_control_player_mgr.cpp | 5 | ||||
| -rw-r--r-- | src/d/snd/d_snd_player_mgr.cpp | 14 | ||||
| -rw-r--r-- | src/d/snd/d_snd_sound.cpp | 13 | ||||
| -rw-r--r-- | src/d/snd/d_snd_source.cpp | 9 | ||||
| -rw-r--r-- | src/d/snd/d_snd_source_group.cpp | 9 | ||||
| -rw-r--r-- | src/d/snd/d_snd_source_mgr.cpp | 10 | ||||
| -rw-r--r-- | src/d/snd/d_snd_stage_data.cpp | 358 | ||||
| -rw-r--r-- | src/d/snd/d_snd_state_mgr.cpp | 204 | ||||
| -rw-r--r-- | src/toBeSorted/actor_info.cpp | 2 |
15 files changed, 1098 insertions, 29 deletions
diff --git a/src/d/d_message.cpp b/src/d/d_message.cpp index 0d56a9f8..764b066a 100644 --- a/src/d/d_message.cpp +++ b/src/d/d_message.cpp @@ -23,8 +23,10 @@ #include "d/lyt/d_lyt_mini_game.h" #include "d/lyt/meter/d_lyt_meter.h" #include "d/lyt/msg_window/d_lyt_msg_window.h" +#include "d/snd/d_snd_bgm_mgr.h" #include "d/snd/d_snd_small_effect_mgr.h" #include "d/snd/d_snd_source_mgr.h" +#include "d/snd/d_snd_state_mgr.h" #include "egg/core/eggHeap.h" #include "f/f_base.h" #include "f/f_profile.h" @@ -39,7 +41,6 @@ #include "toBeSorted/fi_context.h" #include "toBeSorted/file_manager.h" #include "toBeSorted/minigame_mgr.h" -#include "toBeSorted/music_mgrs.h" #include "toBeSorted/unk_save_time.h" #include "rvl/OS.h" @@ -47,7 +48,6 @@ #include <cstring> #include <stdio.h> - s32 dFlow_c::sExitId = -1; dFlow_c::dFlow_c() { @@ -196,7 +196,7 @@ static const FlowSoundDef sSoundDefs[] = { void dFlow_c::playSound(u32 params) { if (params >= 1000) { - fn_80364FD0(ENEMY_SOUND_MGR, params); + dSndStateMgr_c::GetInstance()->setFlowEvent(params); return; } if (params >= 100) { @@ -217,7 +217,7 @@ void dFlow_c::playSound(u32 params) { } switch (sSoundDefs[idx].mSoundMgr) { - case 0: AnotherSoundMgr__playSound(FANFARE_SOUND_MGR, sSoundDefs[idx].mSoundId); break; + case 0: dSndBgmMgr_c::GetInstance()->playFanSound(sSoundDefs[idx].mSoundId); break; case 1: dSndSmallEffectMgr_c::GetInstance()->playSound(sSoundDefs[idx].mSoundId); break; } } diff --git a/src/d/lyt/d_lyt_game_over.cpp b/src/d/lyt/d_lyt_game_over.cpp index d443bfef..8bb3a264 100644 --- a/src/d/lyt/d_lyt_game_over.cpp +++ b/src/d/lyt/d_lyt_game_over.cpp @@ -10,6 +10,7 @@ #include "d/flag/sceneflag_manager.h" #include "d/lyt/d2d.h" #include "d/lyt/d_window.h" +#include "d/snd/d_snd_bgm_mgr.h" #include "d/snd/d_snd_wzsound.h" #include "f/f_base.h" #include "nw4r/lyt/lyt_group.h" @@ -407,7 +408,7 @@ void dLytGameOverMgr_c::executeState_FadeOut() { if (mMain.requestIn("SYS_GAMEOVER_01", 0, 0)) { mMain.setField_0x1338(true); mStateMgr.changeState(StateID_Select); - AnotherSoundMgr__playSound(FANFARE_SOUND_MGR, FAN_GAMEOVER); + dSndBgmMgr_c::GetInstance()->playFanSound(FAN_GAMEOVER); } } } diff --git a/src/d/snd/d_snd_3d_manager.cpp b/src/d/snd/d_snd_3d_manager.cpp index ec1d91ce..bc204ce8 100644 --- a/src/d/snd/d_snd_3d_manager.cpp +++ b/src/d/snd/d_snd_3d_manager.cpp @@ -2,6 +2,7 @@ #include "d/snd/d_snd_3d_engine.h" #include "d/snd/d_snd_mgr.h" +#include "d/snd/d_snd_state_mgr.h" #include "egg/math/eggMatrix.h" #include "egg/math/eggVector.h" #include "nw4r/math/math_arithmetic.h" @@ -80,7 +81,7 @@ void dSnd3DManager_c::updateFromCamera(EGG::LookAtCamera &camera) { f32 prevCameraPosSqVelocity = mCameraPosSqVelocity; mCameraAtSqVelocity = VECSquareDistance(camera.mAt, mCamera.mAt); mCameraPosSqVelocity = VECSquareDistance(camera.mPos, mCamera.mPos); - if (((u32 *)ENEMY_SOUND_MGR)[71] > 30) { + if (dSndStateMgr_c::GetInstance()->getField_0x11C() > 30) { bool bigMovement = false; bool hugeMovement = false; if (mTimer > 0) { diff --git a/src/d/snd/d_snd_area_sound_effect_mgr.cpp b/src/d/snd/d_snd_area_sound_effect_mgr.cpp index 95114462..bd0c7ef0 100644 --- a/src/d/snd/d_snd_area_sound_effect_mgr.cpp +++ b/src/d/snd/d_snd_area_sound_effect_mgr.cpp @@ -13,7 +13,7 @@ dSndAreaSoundEffectMgr_c::dSndAreaSoundEffectMgr_c() : field_0x328(0), field_0x32C(1.0f), field_0x330(1.0f), - mActor(*dSndMgr_c::GetInstance()->getPlayer()), + mActor(dSndMgr_c::GetInstance()->getPlayer()), field_0x388(1.0f) {} void dSndAreaSoundEffectMgr_c::calc() { diff --git a/src/d/snd/d_snd_bgm_mgr.cpp b/src/d/snd/d_snd_bgm_mgr.cpp new file mode 100644 index 00000000..9305808f --- /dev/null +++ b/src/d/snd/d_snd_bgm_mgr.cpp @@ -0,0 +1,482 @@ +#include "d/snd/d_snd_bgm_mgr.h" + +#include "common.h" +#include "d/snd/d_snd_bgm_sound.h" +#include "d/snd/d_snd_mgr.h" +#include "d/snd/d_snd_player_mgr.h" +#include "d/snd/d_snd_sound.h" +#include "d/snd/d_snd_util.h" +#include "d/snd/d_snd_wzsound.h" +#include "nw4r/snd/snd_SoundArchive.h" +#include "nw4r/ut/ut_list.h" + +SND_DISPOSER_DEFINE(dSndBgmMgr_c); + +dSndBgmMgr_c::dSndBgmMgr_c() + : field_0x240(2), + field_0x244(0), + field_0x248(0), + mScheduledSoundId(-1), + mScheduledSoundDelay(0), + field_0x274(0), + field_0x29C(0), + mSoundActor(dSndMgr_c::GetInstance()->getPlayer()), + field_0x2F4(1.0f), + field_0x2F8(-1), + field_0x2FC(0), + field_0x300(-1), + field_0x304(0), + field_0x305(0), + field_0x306(0), + field_0x307(0), + field_0x308(0), + field_0x333(0), + field_0x340(0) { + for (int i = 0; i < BGM_LIST_MAX; i++) { + // TODO offsetof + nw4r::ut::List_Init(&mBgmSoundLists[i], 0xF0); + } + + for (int i = 0; i < 7; i++) { + if (i == 4) { + mBgmSounds[i] = new dSndBgmBattleSound_c(); + } else { + mBgmSounds[i] = new dSndBgmSound_c(); + } + mBgmSounds[i]->init(mSoundActor, i); + } + + field_0x270 = new dSndBgmSound_c(); + field_0x270->init(dSndMgr_c::GetInstance()->getPlayer(), 8); + + for (int i = 0; i < 3; i++) { + mFanSounds[i] = new dSndSound_c(); + } + + nw4r::ut::List_Init(&mAllSounds, 8); + + for (int i = 0; i < 3; i++) { + field_0x30C[i] = 0; + field_0x318[i] = 0; + field_0x324[i] = 0; + field_0x330[i] = 0; + } +} + +void dSndBgmMgr_c::calcLists() { + // TODO ... + + + dSndBgmSound_c *next, *it; + for (it = getFirstInBgmSoundList(BGM_LIST_PLAYING); it != nullptr; it = next) { + next = getNextInBgmSoundList(BGM_LIST_PLAYING, it); + it->calc(); + } + + for (it = getFirstInBgmSoundList(BGM_LIST_STOPPED); it != nullptr; it = next) { + next = getNextInBgmSoundList(BGM_LIST_STOPPED, it); + it->calc(); + } + + for (it = getFirstInBgmSoundList(BGM_LIST_PREPARING); it != nullptr; it = next) { + next = getNextInBgmSoundList(BGM_LIST_PREPARING, it); + if (!it->IsAttachedSound()) { + it->cancel(); + removeFromAllBgmSoundLists(it); + } + } + + { + dSndSound_c *it, *next; + for (it = static_cast<dSndSound_c *>(nw4r::ut::List_GetFirst(&mAllSounds)); it != nullptr; it = next) { + next = static_cast<dSndSound_c *>(nw4r::ut::List_GetNext(&mAllSounds, it)); + if (!it->IsAttachedSound()) { + unregistSound(it); + } + } + } +} + +bool dSndBgmMgr_c::prepareBgm(u32 soundId, u32 startOffset) { + if (isPlayingBgmSoundId(soundId)) { + return false; + } + dSndBgmSound_c *handle = getSoundHandleForBgm(soundId, startOffset); + bool ret = false; + if (handle != nullptr) { + ret = prepareBgmSound(soundId, handle, startOffset); + } + startAdditionalBgm(soundId); + return ret; +} + +void dSndBgmMgr_c::stopAllBgm(s32 fadeFrames) { + for (int i = 0; i < 7; i++) { + stopBgmSound(mBgmSounds[i], fadeFrames); + } + cancelDelayedBgm(); +} + +bool dSndBgmMgr_c::stopBgmSound(dSndBgmSound_c *sound, s32 fadeFrames) { + u32 oldId = sound->GetId(); + if (oldId != -1) { + sound->stop(fadeFrames); + checkForPrepareStoppedBgmSound(oldId); + return true; + } + + return false; +} + +void dSndBgmMgr_c::checkForPrepareStoppedBgmSound(u32 stoppedSoundId) { + // TODO ??? + u32 id = stoppedSoundId == BGM_SKYFIELD ? BGM_SKYFIELD : -1; + if (id != -1) { + prepareBgm(id, 0); + } +} + +bool dSndBgmMgr_c::beginBgmBattleRoom() { + if (isBgmHandleIdxPlayingSoundId(4, BGM_BATTLE_ROOM_MAIN)) { + return false; + } + + return playBattleBgm(BGM_BATTLE_ROOM_MAIN, 5); +} + +bool dSndBgmMgr_c::endBgmBattleRoom() { + if (!isBgmHandleIdxPlayingSoundId(4, BGM_BATTLE_ROOM_MAIN)) { + return false; + } + + stopBgmHandleIdx(4, 5); + return playFanSound(BGM_BATTLE_ROOM_OUTRO); +} + +void dSndBgmMgr_c::playDelayedSound(u32 soundId, s32 delay) { + if (soundId == -1) { + return; + } + nw4r::snd::SoundArchive::SoundInfo info; + u32 playerId; + if (!dSndMgr_c::GetInstance()->getArchive()->ReadSoundInfo(soundId, &info)) { + playerId = -1; + } else { + playerId = info.playerId; + } + + switch (playerId) { + case dSndPlayerMgr_c::PLAYER_BGM: + case dSndPlayerMgr_c::PLAYER_BGM_BATTLE: + if (delay == 0) { + playBgm(soundId, 0, false); + return; + } + prepareBgm(soundId, 0); + break; + case dSndPlayerMgr_c::PLAYER_FAN: + if (delay == 0) { + playFanSound(soundId); + return; + } + prepareFanSound(soundId); + break; + default: return; + } + mScheduledSoundId = soundId; + mScheduledSoundDelay = delay; +} + +void dSndBgmMgr_c::cancelDelayedSound() { + mScheduledSoundId = -1; + mScheduledSoundDelay = 0; +} + +void dSndBgmMgr_c::cancelDelayedBgm() { + if (mScheduledSoundId == -1) { + return; + } + + nw4r::snd::SoundArchive::SoundInfo info; + u32 playerId; + if (!dSndMgr_c::GetInstance()->getArchive()->ReadSoundInfo(mScheduledSoundId, &info)) { + playerId = -1; + } else { + playerId = info.playerId; + } + + if (dSndPlayerMgr_c::isBgmPlayerId(playerId)) { + cancelDelayedSound(); + } +} + +bool dSndBgmMgr_c::startDelayedSound() { + if (mScheduledSoundId == -1) { + return false; + } + + bool ok = false; + + nw4r::snd::SoundArchive::SoundInfo info; + u32 playerId; + if (!dSndMgr_c::GetInstance()->getArchive()->ReadSoundInfo(mScheduledSoundId, &info)) { + playerId = -1; + } else { + playerId = info.playerId; + } + switch (playerId) { + case dSndPlayerMgr_c::PLAYER_BGM: + case dSndPlayerMgr_c::PLAYER_BGM_BATTLE: ok = playBgm(mScheduledSoundId, 0, false); break; + case dSndPlayerMgr_c::PLAYER_FAN: ok = playFanSound(mScheduledSoundId); break; + default: break; + } + + cancelDelayedSound(); + return ok; +} + +void dSndBgmMgr_c::calcDelayedSound() { + if (mScheduledSoundId == -1) { + return; + } + + mScheduledSoundDelay--; + if (mScheduledSoundDelay == 0) { + startDelayedSound(); + } +} + +// 8036e980 - plays additional music for some reason. +// e.g. Sandship (BGM_D301 / 0x1607) also prepares BGM_D301_INSIDE / 0x1608 + +void dSndBgmMgr_c::setBgmHandleIdxVolume(u32 handleIdx, f32 volume, s32 fadeFrames) { + // Using the getter to check validity but then not using the result is a bit weird + if (getBgmSoundByIndex(handleIdx) != nullptr) { + mBgmSounds[handleIdx]->setVolume(volume, fadeFrames); + } +} + +bool dSndBgmMgr_c::isPlayingBgmSoundId(u32 soundId) const { + for (int i = 0; i < 7; i++) { + if (mBgmSounds[i]->isPlayingSoundId(soundId)) { + return true; + } + } + return false; +} + +bool dSndBgmMgr_c::isFadingOutBgmSoundId(u32 soundId) const { + for (int i = 0; i < 7; i++) { + if (mBgmSounds[i]->GetId() == soundId && mBgmSounds[i]->isFadingOutSoundId(soundId)) { + return true; + } + } + return false; +} + +bool dSndBgmMgr_c::isPreparingBgmSoundId(u32 soundId) const { + for (int i = 0; i < 7; i++) { + if (mBgmSounds[i]->isPreparingSoundId(soundId)) { + return true; + } + } + return false; +} + +bool dSndBgmMgr_c::isPreparingBgmSoundIdWithStartOffset(u32 soundId, u32 startOffset) const { + for (int i = 0; i < 7; i++) { + if (mBgmSounds[i]->isPreparingSoundIdWithStartOffset(soundId, startOffset)) { + return true; + } + } + return false; +} + +bool dSndBgmMgr_c::isPreparedBgmSoundId(u32 soundId) const { + for (int i = 0; i < 7; i++) { + if (mBgmSounds[i]->isPreparedSoundId(soundId)) { + return true; + } + } + return false; +} + +dSndBgmSound_c *dSndBgmMgr_c::getBgmSoundByIndex(u32 idx) { + if (idx >= 7) { + return nullptr; + } + return mBgmSounds[idx]; +} + +dSndBgmSound_c *dSndBgmMgr_c::getBgmSoundHandleForId(u32 soundId) const { + for (int i = 0; i < 7; i++) { + dSndBgmSound_c *snd = mBgmSounds[i]; + if (snd->isPlayingSoundId(soundId)) { + return snd; + } + } + return nullptr; +} + +dSndBgmSound_c *dSndBgmMgr_c::findIdleBgmSoundHandle() { + for (int i = 0; i < 4; i++) { + dSndBgmSound_c *snd = mBgmSounds[i]; + if (!snd->hasState()) { + return snd; + } + } + return nullptr; +} + +void dSndBgmMgr_c::addToBgmSoundList(BgmSoundList_e list, dSndBgmSound_c *sound) { + if (list < BGM_LIST_MAX && sound != nullptr) { + removeFromAllBgmSoundLists(sound); + nw4r::ut::List_Prepend(&mBgmSoundLists[list], sound); + } +} + +void dSndBgmMgr_c::appendToBgmSoundList(BgmSoundList_e list, dSndBgmSound_c *sound) { + if (list < BGM_LIST_MAX && sound != nullptr) { + removeFromAllBgmSoundLists(sound); + nw4r::ut::List_Append(&mBgmSoundLists[list], sound); + } +} + +void dSndBgmMgr_c::removeFromBgmSoundList(BgmSoundList_e list, dSndBgmSound_c *sound) { + if (list < BGM_LIST_MAX && sound != nullptr) { + if (isInBgmSoundList(list, sound)) { + nw4r::ut::List_Remove(&mBgmSoundLists[list], sound); + } + } +} + +void dSndBgmMgr_c::removeFromAllBgmSoundLists(dSndBgmSound_c *sound) { + for (int i = 0; i < BGM_LIST_MAX; i++) { + removeFromBgmSoundList(static_cast<BgmSoundList_e>(i), sound); + } +} + +bool dSndBgmMgr_c::isInBgmSoundList(BgmSoundList_e list, dSndBgmSound_c *sound) { + if (list >= BGM_LIST_MAX) { + return false; + } + + if (sound == nullptr) { + return false; + } + + for (dSndBgmSound_c *it = getFirstInBgmSoundList(list); it != nullptr; it = getNextInBgmSoundList(list, it)) { + if (it == sound) { + return true; + } + } + return false; +} + +dSndBgmSound_c *dSndBgmMgr_c::getFirstInBgmSoundList(BgmSoundList_e list) { + if (list >= BGM_LIST_MAX) { + return nullptr; + } + return static_cast<dSndBgmSound_c *>(nw4r::ut::List_GetFirst(&mBgmSoundLists[list])); +} + +dSndBgmSound_c *dSndBgmMgr_c::getNextInBgmSoundList(BgmSoundList_e list, dSndBgmSound_c *sound) { + if (list >= BGM_LIST_MAX) { + return nullptr; + } + return static_cast<dSndBgmSound_c *>(nw4r::ut::List_GetNext(&mBgmSoundLists[list], sound)); +} + +dSndBgmSound_c *dSndBgmMgr_c::getLastInBgmSoundList(BgmSoundList_e list) { + if (list >= BGM_LIST_MAX) { + return nullptr; + } + return static_cast<dSndBgmSound_c *>(nw4r::ut::List_GetLast(&mBgmSoundLists[list])); +} + +dSndSound_c *dSndBgmMgr_c::getFreeFanSoundHandle() { + for (int i = 0; i < 3; i++) { + if (!mFanSounds[i]->IsAttachedSound()) { + return mFanSounds[i]; + } + } + return nullptr; +} + +dSndSound_c *dSndBgmMgr_c::getFanSoundHandleForFan(u32 soundId) { + for (int i = 0; i < 3; i++) { + if (mFanSounds[i]->GetId() == soundId) { + return mFanSounds[i]; + } + } + return nullptr; +} + +dSndSound_c *dSndBgmMgr_c::getSoundHandleCurrentlyPlayingFanSound(u32 soundId) { + for (int i = 0; i < 3; i++) { + if (mFanSounds[i]->isPlayingSoundId(soundId)) { + return mFanSounds[i]; + } + } + return nullptr; +} + +dSndSound_c *dSndBgmMgr_c::getFanSoundHandleForFan2(u32 soundId) { + for (int i = 0; i < 3; i++) { + if (mFanSounds[i]->GetId() == soundId) { + return mFanSounds[i]; + } + } + return nullptr; +} + +bool dSndBgmMgr_c::isCurrentlyPlayingFanSound(u32 soundId) const { + for (int i = 0; i < 3; i++) { + if (mFanSounds[i]->isPlayingSoundId(soundId)) { + return true; + } + } + return false; +} + +bool dSndBgmMgr_c::hasPlayingFanSounds() const { + for (int i = 0; i < 3; i++) { + if (mFanSounds[i]->isPlaying()) { + return true; + } + } + return false; +} + +void dSndBgmMgr_c::stopFanSounds(s32 fadeFrames) { + for (int i = 0; i < 3; i++) { + mFanSounds[i]->stop(fadeFrames); + } +} + +void dSndBgmMgr_c::registSound(dSndSound_c *sound) { + if (sound == nullptr) { + return; + } + unregistSound(sound); + nw4r::ut::List_Append(&mAllSounds, sound); +} + +void dSndBgmMgr_c::unregistSound(dSndSound_c *sound) { + if (isSoundRegist(sound)) { + nw4r::ut::List_Remove(&mAllSounds, sound); + } +} + +bool dSndBgmMgr_c::isSoundRegist(dSndSound_c *sound) { + if (sound == nullptr) { + return false; + } + for (dSndSound_c *it = static_cast<dSndSound_c *>(nw4r::ut::List_GetFirst(&mAllSounds)); it != nullptr; + it = static_cast<dSndSound_c *>(nw4r::ut::List_GetNext(&mAllSounds, it))) { + if (it == sound) { + return true; + } + } + return false; +} diff --git a/src/d/snd/d_snd_control_player.cpp b/src/d/snd/d_snd_control_player.cpp index 824f327a..fe0d9e4b 100644 --- a/src/d/snd/d_snd_control_player.cpp +++ b/src/d/snd/d_snd_control_player.cpp @@ -2,6 +2,7 @@ #include "common.h" #include "d/snd/d_snd_control_player_mgr.h" +#include "d/snd/d_snd_player_mgr.h" #include "d/snd/d_snd_sound.h" #include "nw4r/snd/snd_SoundPlayer.h" #include "nw4r/snd/snd_global.h" @@ -57,11 +58,9 @@ void dSndControlPlayerFxSend_c::apply() { mpPlayer->SetFxSend(nw4r::snd::AUX_B, mCurrValue); } -extern "C" bool fn_8035F030(s32); - f32 dSndControlPlayerFxSend_c::getAppliedValue() { int auxBus = nw4r::snd::AUX_A; - if (fn_8035F030(mIndex)) { + if (dSndPlayerMgr_c::isBgmPlayerId(mIndex)) { auxBus = nw4r::snd::AUX_B; } return mpPlayer->GetFxSend(auxBus); diff --git a/src/d/snd/d_snd_control_player_mgr.cpp b/src/d/snd/d_snd_control_player_mgr.cpp index 22223c98..afdc8e1d 100644 --- a/src/d/snd/d_snd_control_player_mgr.cpp +++ b/src/d/snd/d_snd_control_player_mgr.cpp @@ -1,6 +1,7 @@ #include "d/snd/d_snd_control_player_mgr.h" #include "common.h" +#include "d/snd/d_snd_bgm_mgr.h" #include "d/snd/d_snd_control_player.h" #include "d/snd/d_snd_mgr.h" #include "d/snd/d_snd_player_mgr.h" @@ -14,7 +15,7 @@ struct FanfareMuteFlagsApplier { // The logic here is inverted compared to the others - Fanfares seem to // mute things by default unless otherwise speciefied u32 id = handle.GetId(); - if (fn_803733B0(FANFARE_SOUND_MGR, id)) { + if (dSndBgmMgr_c::GetInstance()->getSoundHandleCurrentlyPlayingFanSound(handle.GetId())) { u32 userParam = dSndMgr_c::GetInstance()->getArchive()->GetSoundUserParam(id); if (!(userParam & dSndPlayerMgr_c::FANFARE_UNMUTE_BGM)) { dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( @@ -369,7 +370,7 @@ void dSndControlPlayerMgr_c::setPlayerVolumeInternal(u32 playerIdx, f32 volume) } void dSndControlPlayerMgr_c::setBgmMuteVolume(f32 volume) { - for (u32 i = dSndPlayerMgr_c::PLAYER_BGM; i < dSndPlayerMgr_c::PLAYER_BGM_BOSS + 1; i++) { + for (u32 i = dSndPlayerMgr_c::PLAYER_BGM; i < dSndPlayerMgr_c::PLAYER_BGM_BATTLE + 1; i++) { setPlayerVolumeInternal(i, volume); } } diff --git a/src/d/snd/d_snd_player_mgr.cpp b/src/d/snd/d_snd_player_mgr.cpp index 981f2150..df8b414d 100644 --- a/src/d/snd/d_snd_player_mgr.cpp +++ b/src/d/snd/d_snd_player_mgr.cpp @@ -94,9 +94,9 @@ nw4r::snd::SoundStartable::StartResult dSndPlayerMgr_c::startSound( } nw4r::snd::SoundStartable::StartResult res; if (pStartInfo != nullptr) { - res = dSndMgr_c::getPlayer()->detail_StartSound(pHandle, soundId, pStartInfo); + res = dSndMgr_c::getPlayer().detail_StartSound(pHandle, soundId, pStartInfo); } else { - res = dSndMgr_c::getPlayer()->detail_StartSound(pHandle, soundId, nullptr); + res = dSndMgr_c::getPlayer().detail_StartSound(pHandle, soundId, nullptr); } return res; } @@ -116,7 +116,7 @@ nw4r::snd::SoundArchivePlayer &dSndPlayerMgr_c::getSoundArchivePlayerForType(u8 if (canUseThisPlayer(sourceType)) { return mSoundArchivePlayer; } - return *dSndMgr_c::getPlayer(); + return dSndMgr_c::getPlayer(); } bool dSndPlayerMgr_c::canUseThisPlayer(u8 sourceType) const { @@ -175,3 +175,11 @@ void dSndPlayerMgr_c::calc() { mSoundArchivePlayer.Update(); } } + +bool dSndPlayerMgr_c::isBgmPlayerId(u32 id) { + switch (id) { + case PLAYER_BGM: + case PLAYER_BGM_BATTLE: return true; + default: return false; + } +} diff --git a/src/d/snd/d_snd_sound.cpp b/src/d/snd/d_snd_sound.cpp index 39354783..2a6ecda0 100644 --- a/src/d/snd/d_snd_sound.cpp +++ b/src/d/snd/d_snd_sound.cpp @@ -1,6 +1,7 @@ #include "d/snd/d_snd_sound.h" #include "common.h" +#include "d/snd/d_snd_bgm_mgr.h" #include "d/snd/d_snd_mgr.h" #include "d/snd/d_snd_player_mgr.h" #include "nw4r/snd/snd_SeqSoundHandle.h" @@ -38,13 +39,13 @@ dSndSound_c::~dSndSound_c() { } void dSndSound_c::cancel() { - if (canCancel()) { + if (hasState()) { resetControls(); mIsRunning = false; mIsFadingOut = false; mIsPreparing = false; mPrevStartOffset = 0; - fn_80373900(FANFARE_SOUND_MGR, this); + dSndBgmMgr_c::GetInstance()->unregistSound(this); } } @@ -328,7 +329,7 @@ nw4r::snd::SoundStartable::StartResult dSndSound_c::prepareSound(u32 soundId, u3 return nw4r::snd::SoundStartable::START_ERR_USER; } - if (cannotStart()) { + if (isPlaying()) { return nw4r::snd::SoundStartable::START_ERR_USER; } @@ -347,13 +348,13 @@ nw4r::snd::SoundStartable::StartResult dSndSound_c::prepareSound(u32 soundId, u3 nw4r::snd::SoundStartable::StartResult res; if (startOffset == 0) { - res = dSndMgr_c::GetInstance()->getPlayer()->detail_PrepareSound(this, soundId, nullptr); + res = dSndMgr_c::GetInstance()->getPlayer().detail_PrepareSound(this, soundId, nullptr); } else { nw4r::snd::SoundStartable::StartInfo info; info.enableFlag |= nw4r::snd::SoundStartable::StartInfo::ENABLE_START_OFFSET; info.startOffsetType = nw4r::snd::SoundStartable::StartInfo::START_OFFSET_TYPE_MILLISEC; info.startOffset = startOffset; - res = dSndMgr_c::GetInstance()->getPlayer()->detail_PrepareSound(this, soundId, &info); + res = dSndMgr_c::GetInstance()->getPlayer().detail_PrepareSound(this, soundId, &info); } if (res == nw4r::snd::SoundStartable::START_SUCCESS) { @@ -375,7 +376,7 @@ void dSndSound_c::onPreparing(u32 soundId, u32 startOffset) { cancel(); mPrevStartOffset = startOffset; mIsPreparing = true; - fn_803738B0(FANFARE_SOUND_MGR, this); + dSndBgmMgr_c::GetInstance()->registSound(this); } } diff --git a/src/d/snd/d_snd_source.cpp b/src/d/snd/d_snd_source.cpp index 5ed288b8..76a25b44 100644 --- a/src/d/snd/d_snd_source.cpp +++ b/src/d/snd/d_snd_source.cpp @@ -1,6 +1,7 @@ #include "d/snd/d_snd_source.h" #include "common.h" +#include "d/a/d_a_base.h" #include "d/snd/d_snd_3d_actor.h" #include "d/snd/d_snd_3d_manager.h" #include "d/snd/d_snd_mgr.h" @@ -24,11 +25,11 @@ const char *help_i_need_data() { return "%s_%s_%d"; } -dSoundSource_c::dSoundSource_c(u8 sourceType, dAcBase_c *player, const char *name, dSndSourceGroup_c *pOwnerGroup) +dSoundSource_c::dSoundSource_c(u8 sourceType, dAcBase_c *actor, const char *name, dSndSourceGroup_c *pOwnerGroup) : dSnd3DActor_c(pOwnerGroup->getAmbientParam(), sourceType), mpName(name), field_0x0F4(0), - mpPlayer(player), + mpActor(actor), mSourceType(sourceType), field_0x0FE(0), field_0x0FF(0), @@ -87,6 +88,10 @@ void dSoundSource_c::d_vt_0x38(bool flag, int fadeFrames) { } } +s32 dSoundSource_c::getRoomId() const { + return mpActor->roomid; +} + nw4r::snd::SoundStartable::StartResult dSoundSource_c::SetupSound(nw4r::snd::SoundHandle *pHandle, u32 soundId, const StartInfo *pStartInfo, void *) { // TODO diff --git a/src/d/snd/d_snd_source_group.cpp b/src/d/snd/d_snd_source_group.cpp index d973deaa..31b27fb6 100644 --- a/src/d/snd/d_snd_source_group.cpp +++ b/src/d/snd/d_snd_source_group.cpp @@ -4,12 +4,11 @@ #include "common.h" #include "d/snd/d_snd_source.h" #include "d/snd/d_snd_source_enums.h" +#include "d/snd/d_snd_state_mgr.h" #include "nw4r/ut/ut_list.h" #include <cmath> -extern "C" bool isInStage(const char *stageName); - void dSndSourceGroup_c::set(s32 sourceType, const char *name) { resetSoundSourceParam(); bool assignedParam = false; @@ -47,10 +46,10 @@ void dSndSourceGroup_c::set(s32 sourceType, const char *name) { break; } case SND_SOURCE_NPC_48: { - if (isInStage("F401")) { + if (dSndStateMgr_c::isInStage("F401")) { mParam.field_0x00 = 500.0f; mParam.field_0x04 = 4000.0; - } else if (isInStage("F402")) { + } else if (dSndStateMgr_c::isInStage("F402")) { mParam.field_0x00 = 400.0f; mParam.field_0x04 = 3500.0; } else { @@ -164,7 +163,7 @@ dSoundSource_c *dSndSourceGroup_c::getSourceClosestToPlayer() { return mpCachedClosestSourceToPlayer; } -bool dSndSourceGroup_c::setParamFromName(const char*) { +bool dSndSourceGroup_c::setParamFromName(const char *) { // TODO return false; } diff --git a/src/d/snd/d_snd_source_mgr.cpp b/src/d/snd/d_snd_source_mgr.cpp index 0e5eb9ae..fdd0b816 100644 --- a/src/d/snd/d_snd_source_mgr.cpp +++ b/src/d/snd/d_snd_source_mgr.cpp @@ -180,3 +180,13 @@ void dSndSourceMgr_c::clearSourceList(nw4r::ut::List *list) { } } } + +s32 dSndSourceMgr_c::getPlayerSourceRoomId() const { + if (mpPlayerSource == nullptr) { + return -1; + } + if (getBoomerangSource() != nullptr) { + return getBoomerangSource()->getRoomId(); + } + return mpPlayerSource->getRoomId(); +} diff --git a/src/d/snd/d_snd_stage_data.cpp b/src/d/snd/d_snd_stage_data.cpp new file mode 100644 index 00000000..1977039d --- /dev/null +++ b/src/d/snd/d_snd_stage_data.cpp @@ -0,0 +1,358 @@ +#include "d/snd/d_snd_stage_data.h" + +#include "common.h" + + +#pragma push +#pragma readonly_strings on + +const dSndStageInfo dSndStageInfo::sInfos[] = { + /* SND_STAGE_F100 */ + { "F100", -1, SND_STAGE_F100, SND_STAGE_F100, SND_STAGE_F100, SND_STAGE_F100, nullptr}, + /* SND_STAGE_F101 */ + { "F101", -1, SND_STAGE_F101, SND_STAGE_F101, SND_STAGE_F100, SND_STAGE_F100, nullptr}, + /* SND_STAGE_F102 */ + { "F102", -1, SND_STAGE_F102, SND_STAGE_F102, SND_STAGE_F102, SND_STAGE_F102, nullptr}, + /* SND_STAGE_F102_1 */ + {"F102_1", -1, SND_STAGE_F102_1, SND_STAGE_F102_1, SND_STAGE_F102, SND_STAGE_F102, nullptr}, + /* SND_STAGE_F103_L13 */ + { "F103", 13, SND_STAGE_F103_L13, SND_STAGE_F103, SND_STAGE_F103_L13, SND_STAGE_F103_L13, "Demo64_03"}, + /* SND_STAGE_F103 */ + { "F103", -1, SND_STAGE_F103, SND_STAGE_F103, SND_STAGE_F103, SND_STAGE_F103, nullptr}, + /* SND_STAGE_F200 */ + { "F200", -1, SND_STAGE_F200, SND_STAGE_F200, SND_STAGE_F200, SND_STAGE_F200, nullptr}, + /* SND_STAGE_F201_1 */ + {"F201_1", -1, SND_STAGE_F201_1, SND_STAGE_F201_1, SND_STAGE_F201_1, SND_STAGE_F201_1, nullptr}, + /* SND_STAGE_F201_2 */ + {"F201_2", -1, SND_STAGE_F201_2, SND_STAGE_F201_2, SND_STAGE_F201_2, SND_STAGE_F201_2, nullptr}, + /* SND_STAGE_F201_3 */ + {"F201_3", -1, SND_STAGE_F201_3, SND_STAGE_F201_3, SND_STAGE_F201_1, SND_STAGE_F201_3, nullptr}, + /* SND_STAGE_F201_4 */ + {"F201_4", -1, SND_STAGE_F201_4, SND_STAGE_F201_4, SND_STAGE_F201_4, SND_STAGE_F201_4, nullptr}, + /* SND_STAGE_F202 */ + { "F202", -1, SND_STAGE_F202, SND_STAGE_F202, SND_STAGE_F202, SND_STAGE_F202, nullptr}, + /* SND_STAGE_F300 */ + { "F300", -1, SND_STAGE_F300, SND_STAGE_F300, SND_STAGE_F300, SND_STAGE_F300, nullptr}, + /* SND_STAGE_F300_1 */ + {"F300_1", -1, SND_STAGE_F300_1, SND_STAGE_F300_1, SND_STAGE_F300, SND_STAGE_F300, nullptr}, + /* SND_STAGE_F300_4_L13 */ + {"F300_4", 13, SND_STAGE_F300_4_L13, SND_STAGE_F300_4, SND_STAGE_F300_4_L13, SND_STAGE_F300_4_L13, "Demo36_01"}, + /* SND_STAGE_F300_4 */ + {"F300_4", -1, SND_STAGE_F300_4, SND_STAGE_F300_4, SND_STAGE_F300, SND_STAGE_F300, nullptr}, + /* SND_STAGE_F301 */ + { "F301", -1, SND_STAGE_F301, SND_STAGE_F301, SND_STAGE_F301, SND_STAGE_F301, nullptr}, + /* SND_STAGE_F301_1 */ + {"F301_1", -1, SND_STAGE_F301_1, SND_STAGE_F301_1, SND_STAGE_F301_1, SND_STAGE_F301_1, nullptr}, + /* SND_STAGE_F301_2 */ + {"F301_2", -1, SND_STAGE_F301_2, SND_STAGE_F301_2, SND_STAGE_F301_2, SND_STAGE_F301, nullptr}, + /* SND_STAGE_F301_3 */ + {"F301_3", -1, SND_STAGE_F301_3, SND_STAGE_F301_3, SND_STAGE_F301_3, SND_STAGE_F301, nullptr}, + /* SND_STAGE_F301_4_L2 */ + {"F301_4", 2, SND_STAGE_F301_4_L2, SND_STAGE_F301_4, SND_STAGE_F301_4_L2, SND_STAGE_F301, nullptr}, + /* SND_STAGE_F301_4 */ + {"F301_4", -1, SND_STAGE_F301_4, SND_STAGE_F301_4, SND_STAGE_F301_4, SND_STAGE_F301, nullptr}, + /* SND_STAGE_F301_6 */ + {"F301_6", -1, SND_STAGE_F301_6, SND_STAGE_F301_6, SND_STAGE_F301, SND_STAGE_F301, nullptr}, + /* SND_STAGE_F301_7 */ + {"F301_7", -1, SND_STAGE_F301_7, SND_STAGE_F301_7, SND_STAGE_F301_7, SND_STAGE_F301, nullptr}, + /* SND_STAGE_F302_L13 */ + { "F302", 13, SND_STAGE_F302_L13, SND_STAGE_F302, SND_STAGE_F302_L13, SND_STAGE_F302_L13, "Demo64_05"}, + /* SND_STAGE_F302 */ + { "F302", -1, SND_STAGE_F302, SND_STAGE_F302, SND_STAGE_F302, SND_STAGE_F302, nullptr}, + /* SND_STAGE_F400_L13 */ + { "F400", 13, SND_STAGE_F400_L13, SND_STAGE_F400, SND_STAGE_F400_L13, SND_STAGE_F400_L13, "Demo38_01"}, + /* SND_STAGE_F400 */ + { "F400", -1, SND_STAGE_F400, SND_STAGE_F400, SND_STAGE_F400, SND_STAGE_F400, nullptr}, + /* SND_STAGE_F401_L2 */ + { "F401", 2, SND_STAGE_F401_L2, SND_STAGE_F401, SND_STAGE_F401_L2, SND_STAGE_F401_L2, nullptr}, + /* SND_STAGE_F401_L3 */ + { "F401", 3, SND_STAGE_F401_L3, SND_STAGE_F401, SND_STAGE_F401_L3, SND_STAGE_F401_L3, nullptr}, + /* SND_STAGE_F401_L4 */ + { "F401", 4, SND_STAGE_F401_L4, SND_STAGE_F401, SND_STAGE_F401_L4, SND_STAGE_F401_L4, nullptr}, + /* SND_STAGE_F401_L13 */ + { "F401", 13, SND_STAGE_F401_L13, SND_STAGE_F401, SND_STAGE_F401_L13, SND_STAGE_F401_L13, "Demo17_01"}, + /* SND_STAGE_F401_L14 */ + { "F401", 14, SND_STAGE_F401_L14, SND_STAGE_F401, SND_STAGE_F401_L14, SND_STAGE_F401_L14, "Demo43_01"}, + /* SND_STAGE_F401_L15 */ + { "F401", 15, SND_STAGE_F401_L15, SND_STAGE_F401, SND_STAGE_F401_L15, SND_STAGE_F401_L15, "Demo69_02"}, + /* SND_STAGE_F401 */ + { "F401", -1, SND_STAGE_F401, SND_STAGE_F401, SND_STAGE_F401, SND_STAGE_F401, nullptr}, + /* SND_STAGE_F403_L13 */ + { "F403", 13, SND_STAGE_F403_L13, SND_STAGE_F403, SND_STAGE_F403_L13, SND_STAGE_F403_L13, "Demo72_01"}, + /* SND_STAGE_F403_L14 */ + { "F403", 14, SND_STAGE_F403_L14, SND_STAGE_F403, SND_STAGE_F403_L14, SND_STAGE_F403_L14, "Demo73_01"}, + /* SND_STAGE_F403_L15 */ + { "F403", 15, SND_STAGE_F403_L15, SND_STAGE_F403, SND_STAGE_F403_L15, SND_STAGE_F403_L15, "Demo75_01"}, + /* SND_STAGE_F403_L16 */ + { "F403", 16, SND_STAGE_F403_L16, SND_STAGE_F403, SND_STAGE_F403_L16, SND_STAGE_F403_L16, "Demo75_02"}, + /* SND_STAGE_F403 */ + { "F403", -1, SND_STAGE_F403, SND_STAGE_F403, SND_STAGE_F403, SND_STAGE_F403, nullptr}, + /* SND_STAGE_F405 */ + { "F405", -1, SND_STAGE_F405, SND_STAGE_F405, SND_STAGE_F405, SND_STAGE_F405, "Demo02_01"}, + /* SND_STAGE_F406_L13 */ + { "F406", 13, SND_STAGE_F406_L13, SND_STAGE_F406, SND_STAGE_F406_L13, SND_STAGE_F406_L13, "Demo79_02"}, + /* SND_STAGE_F406_L14 */ + { "F406", 14, SND_STAGE_F406_L14, SND_STAGE_F406, SND_STAGE_F406_L14, SND_STAGE_F406_L14, "Demo69_03"}, + /* SND_STAGE_F406 */ + { "F406", -1, SND_STAGE_F406, SND_STAGE_F406, SND_STAGE_F406, SND_STAGE_F406, nullptr}, + /* SND_STAGE_D301 */ + { "D301", -1, SND_STAGE_D301, SND_STAGE_D301, SND_STAGE_D301, SND_STAGE_D301, nullptr}, + /* SND_STAGE_D301_1 */ + {"D301_1", -1, SND_STAGE_D301_1, SND_STAGE_D301_1, SND_STAGE_D301_1, SND_STAGE_D301, nullptr}, + /* SND_STAGE_D000 */ + { "D000", -1, SND_STAGE_D000, SND_STAGE_D000, SND_STAGE_D000, SND_STAGE_D000, nullptr}, + /* SND_STAGE_D100 */ + { "D100", -1, SND_STAGE_D100, SND_STAGE_D100, SND_STAGE_D100, SND_STAGE_D100, nullptr}, + /* SND_STAGE_D101 */ + { "D101", -1, SND_STAGE_D101, SND_STAGE_D101, SND_STAGE_D101, SND_STAGE_D101, nullptr}, + /* SND_STAGE_D200 */ + { "D200", -1, SND_STAGE_D200, SND_STAGE_D200, SND_STAGE_D200, SND_STAGE_D200, nullptr}, + /* SND_STAGE_D201 */ + { "D201", -1, SND_STAGE_D201, SND_STAGE_D201, SND_STAGE_D201, SND_STAGE_D201, nullptr}, + /* SND_STAGE_D201_1 */ + {"D201_1", -1, SND_STAGE_D201_1, SND_STAGE_D201_1, SND_STAGE_D201, SND_STAGE_D201, nullptr}, + /* SND_STAGE_D300 */ + { "D300", -1, SND_STAGE_D300, SND_STAGE_D300, SND_STAGE_D300, SND_STAGE_D300, nullptr}, + /* SND_STAGE_D300_1 */ + {"D300_1", -1, SND_STAGE_D300_1, SND_STAGE_D300_1, SND_STAGE_D300, SND_STAGE_D300, nullptr}, + /* SND_STAGE_D003_0 */ + {"D003_0", -1, SND_STAGE_D003_0, SND_STAGE_D003_0, SND_STAGE_D003_0, SND_STAGE_D003_0, nullptr}, + /* SND_STAGE_D003_1 */ + {"D003_1", -1, SND_STAGE_D003_1, SND_STAGE_D003_1, SND_STAGE_D003_1, SND_STAGE_D003_1, nullptr}, + /* SND_STAGE_D003_2 */ + {"D003_2", -1, SND_STAGE_D003_2, SND_STAGE_D003_2, SND_STAGE_D003_2, SND_STAGE_D003_2, nullptr}, + /* SND_STAGE_D003_3 */ + {"D003_3", -1, SND_STAGE_D003_3, SND_STAGE_D003_3, SND_STAGE_D003_3, SND_STAGE_D003_3, nullptr}, + /* SND_STAGE_D003_4 */ + {"D003_4", -1, SND_STAGE_D003_4, SND_STAGE_D003_4, SND_STAGE_D003_4, SND_STAGE_D003_4, nullptr}, + /* SND_STAGE_D003_5 */ + {"D003_5", -1, SND_STAGE_D003_5, SND_STAGE_D003_5, SND_STAGE_D003_5, SND_STAGE_D003_5, nullptr}, + /* SND_STAGE_D003_6 */ + {"D003_6", -1, SND_STAGE_D003_6, SND_STAGE_D003_6, SND_STAGE_D003_6, SND_STAGE_D003_6, nullptr}, + /* SND_STAGE_D003_7 */ + {"D003_7", -1, SND_STAGE_D003_7, SND_STAGE_D003_7, SND_STAGE_D003_7, SND_STAGE_D003_7, nullptr}, + /* SND_STAGE_D003_8 */ + {"D003_8", -1, SND_STAGE_D003_8, SND_STAGE_D003_8, SND_STAGE_D003_8, SND_STAGE_D003_8, nullptr}, + /* SND_STAGE_B100_L13 */ + { "B100", 13, SND_STAGE_B100_L13, SND_STAGE_B100, SND_STAGE_B100_L13, SND_STAGE_B100_L13, "Demo21_01"}, + /* SND_STAGE_B100 */ + { "B100", -1, SND_STAGE_B100, SND_STAGE_B100, SND_STAGE_B100, SND_STAGE_B100, nullptr}, + /* SND_STAGE_B100_1_L13 */ + {"B100_1", 13, SND_STAGE_B100_1_L13, SND_STAGE_B100_1, SND_STAGE_B100_1_L13, SND_STAGE_B100_1_L13, "Demo23_01"}, + /* SND_STAGE_B100_1 */ + {"B100_1", -1, SND_STAGE_B100_1, SND_STAGE_B100_1, SND_STAGE_B100_1, SND_STAGE_B100_1, nullptr}, + /* SND_STAGE_B101 */ + { "B101", -1, SND_STAGE_B101, SND_STAGE_B101, SND_STAGE_B101, SND_STAGE_B101, nullptr}, + /* SND_STAGE_B101_1_L13 */ + {"B101_1", 13, SND_STAGE_B101_1_L13, SND_STAGE_B101_1, SND_STAGE_B101_1_L13, SND_STAGE_B101_1_L13, "Demo47_01"}, + /* SND_STAGE_B101_1 */ + {"B101_1", -1, SND_STAGE_B101_1, SND_STAGE_B101_1, SND_STAGE_B101_1, SND_STAGE_B101_1, nullptr}, + /* SND_STAGE_B200_L1 */ + { "B200", 1, SND_STAGE_B200_L1, SND_STAGE_B200, SND_STAGE_B200_L1, SND_STAGE_D200, nullptr}, + /* SND_STAGE_B200_L2 */ + { "B200", 2, SND_STAGE_B200_L2, SND_STAGE_B200, SND_STAGE_B200_L2, SND_STAGE_D200, nullptr}, + /* SND_STAGE_B200_L3 */ + { "B200", 3, SND_STAGE_B200_L3, SND_STAGE_B200, SND_STAGE_B200_L3, SND_STAGE_D200, nullptr}, + /* SND_STAGE_B200 */ + { "B200", -1, SND_STAGE_B200, SND_STAGE_B200, SND_STAGE_B200, SND_STAGE_D200, nullptr}, + /* SND_STAGE_B210_L13 */ + { "B210", 13, SND_STAGE_B210_L13, SND_STAGE_B210, SND_STAGE_B210_L13, SND_STAGE_B210_L13, "Demo29_01"}, + /* SND_STAGE_B210_L14 */ + { "B210", 14, SND_STAGE_B210_L14, SND_STAGE_B210, SND_STAGE_B210_L14, SND_STAGE_B210_L14, "Demo31_01"}, + /* SND_STAGE_B210 */ + { "B210", -1, SND_STAGE_B210, SND_STAGE_B210, SND_STAGE_B210, SND_STAGE_B210, nullptr}, + /* SND_STAGE_B201_L13 */ + { "B201", 13, SND_STAGE_B201_L13, SND_STAGE_B201, SND_STAGE_B201_L13, SND_STAGE_B201_L13, "Demo51_01"}, + /* SND_STAGE_B201 */ + { "B201", -1, SND_STAGE_B201, SND_STAGE_B201, SND_STAGE_B201, SND_STAGE_B201, nullptr}, + /* SND_STAGE_B201_1_L13 */ + {"B201_1", 13, SND_STAGE_B201_1_L13, SND_STAGE_B201_1, SND_STAGE_B201_1_L13, SND_STAGE_B201_1_L13, "Demo52_01"}, + /* SND_STAGE_B201_1 */ + {"B201_1", -1, SND_STAGE_B201_1, SND_STAGE_B201_1, SND_STAGE_B201_1, SND_STAGE_B201_1, nullptr}, + /* SND_STAGE_B300 */ + { "B300", -1, SND_STAGE_B300, SND_STAGE_B300, SND_STAGE_B300, SND_STAGE_B300, nullptr}, + /* SND_STAGE_B301_L13 */ + { "B301", 13, SND_STAGE_B301_L13, SND_STAGE_B301, SND_STAGE_B301_L13, SND_STAGE_B301_L13, "Demo49_01"}, + /* SND_STAGE_B301 */ + { "B301", -1, SND_STAGE_B301, SND_STAGE_B301, SND_STAGE_B301, SND_STAGE_B301, nullptr}, + /* SND_STAGE_B003 */ + { "B003", -1, SND_STAGE_B003, SND_STAGE_B003, SND_STAGE_B003, SND_STAGE_B003, nullptr}, + /* SND_STAGE_B400_L13 */ + { "B400", 13, SND_STAGE_B400_L13, SND_STAGE_B400, SND_STAGE_B400_L13, SND_STAGE_B400_L13, "Demo75_04"}, + /* SND_STAGE_B400_L14 */ + { "B400", 14, SND_STAGE_B400_L14, SND_STAGE_B400, SND_STAGE_B400_L14, SND_STAGE_B400_L14, "Demo76_01"}, + /* SND_STAGE_B400 */ + { "B400", -1, SND_STAGE_B400, SND_STAGE_B400, SND_STAGE_B400, SND_STAGE_B400, nullptr}, + /* SND_STAGE_F100_1 */ + {"F100_1", -1, SND_STAGE_F100_1, SND_STAGE_F100_1, SND_STAGE_F100_1, SND_STAGE_F100_1, nullptr}, + /* SND_STAGE_F100_2 */ + {"F100_2", -1, SND_STAGE_F100_2, SND_STAGE_F100_2, SND_STAGE_F100_2, SND_STAGE_F100_2, nullptr}, + /* SND_STAGE_F102_2 */ + {"F102_2", -1, SND_STAGE_F102_2, SND_STAGE_F102_2, SND_STAGE_F102, SND_STAGE_F102, nullptr}, + /* SND_STAGE_F103_1_L13 */ + {"F103_1", 13, SND_STAGE_F103_1_L13, SND_STAGE_F103_1, SND_STAGE_F103_1_L13, SND_STAGE_F103_1_L13, "Demo64_02"}, + /* SND_STAGE_F103_1_L14 */ + {"F103_1", 14, SND_STAGE_F103_1_L14, SND_STAGE_F103_1, SND_STAGE_F103_1_L14, SND_STAGE_F103_1_L14, "Demo64_04"}, + /* SND_STAGE_F103_1 */ + {"F103_1", -1, SND_STAGE_F103_1, SND_STAGE_F103_1, SND_STAGE_F103_1, SND_STAGE_F103, nullptr}, + /* SND_STAGE_F210 */ + { "F210", -1, SND_STAGE_F210, SND_STAGE_F210, SND_STAGE_F210, SND_STAGE_F210, nullptr}, + /* SND_STAGE_F211 */ + { "F211", -1, SND_STAGE_F211, SND_STAGE_F211, SND_STAGE_F211, SND_STAGE_F211, nullptr}, + /* SND_STAGE_F221_L13 */ + { "F221", 13, SND_STAGE_F221_L13, SND_STAGE_F221, SND_STAGE_F221_L13, SND_STAGE_F221_L13, "Demo64_01"}, + /* SND_STAGE_F221 */ + { "F221", -1, SND_STAGE_F221, SND_STAGE_F221, SND_STAGE_F221, SND_STAGE_F221, nullptr}, + /* SND_STAGE_F202_1 */ + {"F202_1", -1, SND_STAGE_F202_1, SND_STAGE_F202_1, SND_STAGE_F202_1, SND_STAGE_D200, nullptr}, + /* SND_STAGE_F202_2 */ + {"F202_2", -1, SND_STAGE_F202_2, SND_STAGE_F202_2, SND_STAGE_F202_2, SND_STAGE_D200, nullptr}, + /* SND_STAGE_F202_3 */ + {"F202_3", -1, SND_STAGE_F202_3, SND_STAGE_F202_3, SND_STAGE_F202_3, SND_STAGE_D200, nullptr}, + /* SND_STAGE_F202_4 */ + {"F202_4", -1, SND_STAGE_F202_4, SND_STAGE_F202_4, SND_STAGE_F202_4, SND_STAGE_D200, nullptr}, + /* SND_STAGE_F300_2 */ + {"F300_2", -1, SND_STAGE_F300_2, SND_STAGE_F300_2, SND_STAGE_F300, SND_STAGE_F300, nullptr}, + /* SND_STAGE_F300_3 */ + {"F300_3", -1, SND_STAGE_F300_3, SND_STAGE_F300_3, SND_STAGE_F300, SND_STAGE_F300, nullptr}, + /* SND_STAGE_F300_5 */ + {"F300_5", -1, SND_STAGE_F300_5, SND_STAGE_F300_5, SND_STAGE_F300_5, SND_STAGE_F300_5, nullptr}, + /* SND_STAGE_F303 */ + { "F303", -1, SND_STAGE_F303, SND_STAGE_F303, SND_STAGE_F303, SND_STAGE_F303, nullptr}, + /* SND_STAGE_S000 */ + { "S000", -1, SND_STAGE_S000, SND_STAGE_S000, SND_STAGE_S000, SND_STAGE_S000, nullptr}, + /* SND_STAGE_S100 */ + { "S100", -1, SND_STAGE_S100, SND_STAGE_S100, SND_STAGE_S100, SND_STAGE_S100, nullptr}, + /* SND_STAGE_S200 */ + { "S200", -1, SND_STAGE_S200, SND_STAGE_S200, SND_STAGE_S200, SND_STAGE_S200, nullptr}, + /* SND_STAGE_S300 */ + { "S300", -1, SND_STAGE_S300, SND_STAGE_S300, SND_STAGE_S300, SND_STAGE_S300, nullptr}, + /* SND_STAGE_F020_L3 */ + { "F020", 3, SND_STAGE_F020_L3, SND_STAGE_F020, SND_STAGE_F020_L3, SND_STAGE_F000, nullptr}, + /* SND_STAGE_F020 */ + { "F020", -1, SND_STAGE_F020, SND_STAGE_F020, SND_STAGE_F020, SND_STAGE_F000, nullptr}, + /* SND_STAGE_F021_L13 */ + { "F021", 13, SND_STAGE_F021_L13, SND_STAGE_F021, SND_STAGE_F021_L13, SND_STAGE_F021_L13, "Demo12_02"}, + /* SND_STAGE_F021 */ + { "F021", -1, SND_STAGE_F021, SND_STAGE_F021, SND_STAGE_F021, SND_STAGE_F021, nullptr}, + /* SND_STAGE_F023_L14 */ + { "F023", 14, SND_STAGE_F023_L14, SND_STAGE_F023, SND_STAGE_F023_L14, SND_STAGE_F023_L14, "Demo64_06"}, + /* SND_STAGE_F023 */ + { "F023", -1, SND_STAGE_F023, SND_STAGE_F023, SND_STAGE_F023, SND_STAGE_F023, nullptr}, + /* SND_STAGE_F000_L13 */ + { "F000", 13, SND_STAGE_F000_L13, SND_STAGE_F000, SND_STAGE_F000_L13, SND_STAGE_F000_L13, "Demo04_01"}, + /* SND_STAGE_F000_L14 */ + { "F000", 14, SND_STAGE_F000_L14, SND_STAGE_F000, SND_STAGE_F000_L14, SND_STAGE_F000_L14, "Demo12_01"}, + /* SND_STAGE_F000_L15 */ + { "F000", 15, SND_STAGE_F000_L15, SND_STAGE_F000, SND_STAGE_F000_L15, SND_STAGE_F000_L15, "Demo05_01"}, + /* SND_STAGE_F000_L16 */ + { "F000", 16, SND_STAGE_F000_L16, SND_STAGE_F000, SND_STAGE_F000_L16, SND_STAGE_F000_L16, "Demo08_01"}, + /* SND_STAGE_F000_L17 */ + { "F000", 17, SND_STAGE_F000_L17, SND_STAGE_F000, SND_STAGE_F000_L17, SND_STAGE_F000_L17, "Demo11_01"}, + /* SND_STAGE_F000_L18 */ + { "F000", 18, SND_STAGE_F000_L18, SND_STAGE_F000, SND_STAGE_F000_L18, SND_STAGE_F000_L18, "Demo68_01"}, + /* SND_STAGE_F000_L19 */ + { "F000", 19, SND_STAGE_F000_L19, SND_STAGE_F000, SND_STAGE_F000_L19, SND_STAGE_F000_L19, "Demo69_01"}, + /* SND_STAGE_F000_L20 */ + { "F000", 20, SND_STAGE_F000_L20, SND_STAGE_F000, SND_STAGE_F000_L20, SND_STAGE_F000_L20, "Demo03_01"}, + /* SND_STAGE_F000_L21 */ + { "F000", 21, SND_STAGE_F000_L21, SND_STAGE_F000, SND_STAGE_F000_L21, SND_STAGE_F000_L21, "Demo03_02"}, + /* SND_STAGE_F000_L26 */ + { "F000", 26, SND_STAGE_F000_L26, SND_STAGE_F000, SND_STAGE_F000_L26, SND_STAGE_F000_L26, "Demo01_01"}, + /* SND_STAGE_F000_L27 */ + { "F000", 27, SND_STAGE_F000_L27, SND_STAGE_F000, SND_STAGE_F000_L27, SND_STAGE_F000_L27, "Demo01_02"}, + /* SND_STAGE_F000 */ + { "F000", -1, SND_STAGE_F000, SND_STAGE_F000, SND_STAGE_F000, SND_STAGE_F000, nullptr}, + /* SND_STAGE_F301_5 */ + {"F301_5", -1, SND_STAGE_F301_5, SND_STAGE_F301_5, SND_STAGE_F301_3, SND_STAGE_F301, nullptr}, + /* SND_STAGE_F001r_L13 */ + { "F001r", 13, SND_STAGE_F001r_L13, SND_STAGE_F001r, SND_STAGE_F001r_L13, SND_STAGE_F001r_L13, "Demo13_01"}, + /* SND_STAGE_F001r_L14 */ + { "F001r", 14, SND_STAGE_F001r_L14, SND_STAGE_F001r, SND_STAGE_F001r_L14, SND_STAGE_F001r_L14, "Demo15_04"}, + /* SND_STAGE_F001r_L15 */ + { "F001r", 15, SND_STAGE_F001r_L15, SND_STAGE_F001r, SND_STAGE_F001r_L15, SND_STAGE_F001r_L15, "Demo03_03"}, + /* SND_STAGE_F001r */ + { "F001r", -1, SND_STAGE_F001r, SND_STAGE_F001r, SND_STAGE_F001r, SND_STAGE_F001r, nullptr}, + /* SND_STAGE_F002r */ + { "F002r", -1, SND_STAGE_F002r, SND_STAGE_F002r, SND_STAGE_F002r, SND_STAGE_F002r, nullptr}, + /* SND_STAGE_F004r */ + { "F004r", -1, SND_STAGE_F004r, SND_STAGE_F004r, SND_STAGE_F004r, SND_STAGE_F004r, nullptr}, + /* SND_STAGE_F009r */ + { "F009r", -1, SND_STAGE_F009r, SND_STAGE_F009r, SND_STAGE_F009r, SND_STAGE_F009r, nullptr}, + /* SND_STAGE_F011r */ + { "F011r", -1, SND_STAGE_F011r, SND_STAGE_F011r, SND_STAGE_F011r, SND_STAGE_F011r, nullptr}, + /* SND_STAGE_F012r */ + { "F012r", -1, SND_STAGE_F012r, SND_STAGE_F012r, SND_STAGE_F012r, SND_STAGE_F012r, nullptr}, + /* SND_STAGE_F019r */ + { "F019r", -1, SND_STAGE_F019r, SND_STAGE_F019r, SND_STAGE_F019r, SND_STAGE_F019r, nullptr}, + /* SND_STAGE_F005r */ + { "F005r", -1, SND_STAGE_F005r, SND_STAGE_F005r, SND_STAGE_F005r, SND_STAGE_F005r, nullptr}, + /* SND_STAGE_F006r */ + { "F006r", -1, SND_STAGE_F006r, SND_STAGE_F006r, SND_STAGE_F006r, SND_STAGE_F006r, nullptr}, + /* SND_STAGE_F007r */ + { "F007r", -1, SND_STAGE_F007r, SND_STAGE_F007r, SND_STAGE_F007r, SND_STAGE_F007r, nullptr}, + /* SND_STAGE_F013r */ + { "F013r", -1, SND_STAGE_F013r, SND_STAGE_F013r, SND_STAGE_F013r, SND_STAGE_F013r, nullptr}, + /* SND_STAGE_F014r */ + { "F014r", -1, SND_STAGE_F014r, SND_STAGE_F014r, SND_STAGE_F014r, SND_STAGE_F014r, nullptr}, + /* SND_STAGE_F015r */ + { "F015r", -1, SND_STAGE_F015r, SND_STAGE_F015r, SND_STAGE_F015r, SND_STAGE_F015r, nullptr}, + /* SND_STAGE_F016r */ + { "F016r", -1, SND_STAGE_F016r, SND_STAGE_F016r, SND_STAGE_F016r, SND_STAGE_F016r, nullptr}, + /* SND_STAGE_F017r */ + { "F017r", -1, SND_STAGE_F017r, SND_STAGE_F017r, SND_STAGE_F017r, SND_STAGE_F017r, nullptr}, + /* SND_STAGE_F018r */ + { "F018r", -1, SND_STAGE_F018r, SND_STAGE_F018r, SND_STAGE_F018r, SND_STAGE_F018r, nullptr}, + /* SND_STAGE_F402_L2 */ + { "F402", 2, SND_STAGE_F402_L2, SND_STAGE_F402, SND_STAGE_F402_L2, SND_STAGE_F402_L2, nullptr}, + /* SND_STAGE_F402_L3 */ + { "F402", 3, SND_STAGE_F402_L3, SND_STAGE_F402, SND_STAGE_F402_L3, SND_STAGE_F402_L3, nullptr}, + /* SND_STAGE_F402_L5 */ + { "F402", 5, SND_STAGE_F402_L5, SND_STAGE_F402, SND_STAGE_F402_L5, SND_STAGE_F402_L5, nullptr}, + /* SND_STAGE_F402_L13 */ + { "F402", 13, SND_STAGE_F402_L13, SND_STAGE_F402, SND_STAGE_F402_L13, SND_STAGE_F402_L13, "Demo41_01"}, + /* SND_STAGE_F402_L18 */ + { "F402", 18, SND_STAGE_F402_L18, SND_STAGE_F402, SND_STAGE_F402_L18, SND_STAGE_F402_L18, "Demo43_02"}, + /* SND_STAGE_F402_L19 */ + { "F402", 19, SND_STAGE_F402_L19, SND_STAGE_F402, SND_STAGE_F402_L19, SND_STAGE_F402_L19, "Demo79_01"}, + /* SND_STAGE_F402 */ + { "F402", -1, SND_STAGE_F402, SND_STAGE_F402, SND_STAGE_F402, SND_STAGE_F402, nullptr}, + /* SND_STAGE_F404_L13 */ + { "F404", 13, SND_STAGE_F404_L13, SND_STAGE_F404, SND_STAGE_F404_L13, SND_STAGE_F404_L13, "Demo62_01"}, + /* SND_STAGE_F404_L14 */ + { "F404", 14, SND_STAGE_F404_L14, SND_STAGE_F404, SND_STAGE_F404_L14, SND_STAGE_F404_L14, "Demo77_01"}, + /* SND_STAGE_F404 */ + { "F404", -1, SND_STAGE_F404, SND_STAGE_F404, SND_STAGE_F404, SND_STAGE_F404, nullptr}, + /* SND_STAGE_F407_L13 */ + { "F407", 13, SND_STAGE_F407_L13, SND_STAGE_F407, SND_STAGE_F407_L13, SND_STAGE_F407_L13, "Demo59_01"}, + /* SND_STAGE_F407_L14 */ + { "F407", 14, SND_STAGE_F407_L14, SND_STAGE_F407, SND_STAGE_F407_L14, SND_STAGE_F407_L14, "Demo70_01"}, + /* SND_STAGE_F407_L15 */ + { "F407", 15, SND_STAGE_F407_L15, SND_STAGE_F407, SND_STAGE_F407_L15, SND_STAGE_F407_L15, "Demo70_02"}, + /* SND_STAGE_F407 */ + { "F407", -1, SND_STAGE_F407, SND_STAGE_F407, SND_STAGE_F407, SND_STAGE_F407, nullptr}, + /* SND_STAGE_F008r_L13 */ + { "F008r", 13, SND_STAGE_F008r_L13, SND_STAGE_F008r, SND_STAGE_F008r_L13, SND_STAGE_F008r_L13, "Demo15_01"}, + /* SND_STAGE_F008r_L14 */ + { "F008r", 14, SND_STAGE_F008r_L14, SND_STAGE_F008r, SND_STAGE_F008r_L14, SND_STAGE_F008r_L14, "Demo15_02"}, + /* SND_STAGE_F008r_L15 */ + { "F008r", 15, SND_STAGE_F008r_L15, SND_STAGE_F008r, SND_STAGE_F008r_L15, SND_STAGE_F008r_L15, "Demo15_03"}, + /* SND_STAGE_F008r */ + { "F008r", -1, SND_STAGE_F008r, SND_STAGE_F008r, SND_STAGE_F008r, SND_STAGE_F008r, nullptr}, + /* SND_STAGE_F010r_L13 */ + { "F010r", 13, SND_STAGE_F010r_L13, SND_STAGE_F010r, SND_STAGE_F010r_L13, SND_STAGE_F010r_L13, "Demo44_01"}, + /* SND_STAGE_F010r_L14 */ + { "F010r", 14, SND_STAGE_F010r_L14, SND_STAGE_F010r, SND_STAGE_F010r_L14, SND_STAGE_F010r_L14, "Demo48_01"}, + /* SND_STAGE_F010r_L15 */ + { "F010r", 15, SND_STAGE_F010r_L15, SND_STAGE_F010r, SND_STAGE_F010r_L15, SND_STAGE_F010r_L15, "Demo50_01"}, + /* SND_STAGE_F010r */ + { "F010r", -1, SND_STAGE_F010r, SND_STAGE_F010r, SND_STAGE_F010r, SND_STAGE_F010r, nullptr}, + /* SND_STAGE_Demo_L13 */ + { "Demo", 13, SND_STAGE_Demo_L13, SND_STAGE_Demo, SND_STAGE_Demo_L13, SND_STAGE_Demo_L13, "Demo78_01"}, + /* SND_STAGE_Demo */ + { "Demo", -1, SND_STAGE_Demo, SND_STAGE_Demo, SND_STAGE_Demo, SND_STAGE_Demo, nullptr}, +}; + +#pragma pop + +const s32 dSndStageInfo::sNumStageInfos = ARRAY_LENGTH(dSndStageInfo::sInfos); diff --git a/src/d/snd/d_snd_state_mgr.cpp b/src/d/snd/d_snd_state_mgr.cpp new file mode 100644 index 00000000..5f7909ab --- /dev/null +++ b/src/d/snd/d_snd_state_mgr.cpp @@ -0,0 +1,204 @@ +#include "d/snd/d_snd_state_mgr.h" + +#include "common.h" +#include "d/d_sc_game.h" +#include "d/snd/d_snd_player_mgr.h" +#include "d/snd/d_snd_stage_data.h" +#include "egg/core/eggHeap.h" +#include "nw4r/snd/snd_FxReverbStdDpl2.h" + +#include <cstring> + +SND_DISPOSER_DEFINE(dSndStateMgr_c); + +dSndStateMgr_c::dSndStateMgr_c() + : field_0x010(0), + field_0x014(0), + field_0x018(0), + field_0x03C(0), + mStageId(0xAC), + mPreviousStageId(0xAC), + field_0x054(0), + field_0x058(0), + mLayer(-1), + field_0x060(0), + field_0x064(0), + field_0x065(false), + field_0x066(0), + field_0x067(0), + field_0x068(-1), + field_0x06C(-1), + field_0x070(0), + field_0x074(0), + field_0x078(0), + field_0x07C(0), + field_0x080(0), + field_0x084(0), + field_0x088(0), + field_0x08C(0x89), + field_0x090(0), + field_0x094(0), + field_0x118(nullptr), + field_0x11C(0), + field_0x120(0), + field_0x124(0), + field_0x128(-1), + field_0x22C(0), + field_0x230(0), + field_0x234(0), + field_0x238(-1), + field_0x23C(0), + field_0x23D(0), + field_0x240(0), + field_0x244(0), + field_0x248(0), + field_0x24C(-1), + field_0x250(0), + field_0x254(0), + field_0x258(0), + field_0x48C(0), + field_0x490(0.02f), + field_0x494(-1.0f), + field_0x498(-1.0f), + field_0x49C(0.02f), + field_0x4A0(0.02f), + field_0x4A4(-1), + field_0x4A8(0), + needsGroupsReload(false) {} + +extern "C" void fn_803665B0(nw4r::snd::detail::FxReverbStdParam &, int); + +void dSndStateMgr_c::setup(EGG::Heap *pHeap) { + u32 max = 0; + for (int i = 0; i < 5; i++) { + nw4r::snd::detail::FxReverbStdParam param; + fn_803665B0(param, i); + mFx.SetParam(param); + u32 thisSize = mFx.GetRequiredMemSize(); + if (max < thisSize) { + max = thisSize; + } + } + void *mem = pHeap->alloc(max, 4); + mFx.AssignWorkBuffer(mem, max); + resetStageName(); +} + +inline bool streq(const char *stageName, const char *name) { + return !std::strcmp(stageName, name); +} + +void dSndStateMgr_c::onStageOrLayerUpdate() { + if (dSndPlayerMgr_c::GetInstance()->checkFlag(dSndPlayerMgr_c::MGR_UNK_0x80)) { + dSndPlayerMgr_c::GetInstance()->stopAllSound(); + } + + bool unk_0x065 = field_0x065; + + onFlag0x10(0x2); + field_0x064 = 0; + + if (!streq(field_0x098, dScGame_c::currentSpawnInfo.getStageName())) { + needsGroupsReload = true; + field_0x01C = dScGame_c::currentSpawnInfo.getStageName(); + } + + if (!needsGroupsReload && dScGame_c::currentSpawnInfo.layer != mLayer) { + needsGroupsReload = true; + } + + mLayer = dScGame_c::currentSpawnInfo.layer; + u32 newStageId = getStageId(dScGame_c::currentSpawnInfo.getStageName(), dScGame_c::currentSpawnInfo.layer); + mPreviousStageId = mStageId; + field_0x044 = getStageUnk2(newStageId); + mStageId = newStageId; + + if (unk_0x065) { + setCallbacksForStage(); + } +} + +inline bool checkStagePrefix(const char *stageName, const char *prefix) { + return !std::strncmp(prefix, stageName, 2); +} + +u32 dSndStateMgr_c::getStageTypeFlags(const char *stageName) const { + u32 flags = 0; + if (checkStagePrefix(stageName, "F0")) { + flags |= STAGE_SKY | STAGE_FIELD; + } else if (checkStagePrefix(stageName, "D0")) { + flags |= STAGE_SKY | STAGE_DUNGEON; + } else if (checkStagePrefix(stageName, "B0")) { + flags |= STAGE_SKY | STAGE_BOSS; + } else if (checkStagePrefix(stageName, "S0")) { + flags |= STAGE_SKY | STAGE_SILENT_REALM; + } else if (checkStagePrefix(stageName, "F1")) { + flags |= STAGE_FOREST | STAGE_FIELD; + } else if (checkStagePrefix(stageName, "D1")) { + flags |= STAGE_FOREST | STAGE_DUNGEON; + } else if (checkStagePrefix(stageName, "B1")) { + flags |= STAGE_FOREST | STAGE_BOSS; + } else if (checkStagePrefix(stageName, "S1")) { + flags |= STAGE_FOREST | STAGE_SILENT_REALM; + } else if (checkStagePrefix(stageName, "F2")) { + flags |= STAGE_MOUNTAIN | STAGE_FIELD; + } else if (checkStagePrefix(stageName, "D2")) { + flags |= STAGE_MOUNTAIN | STAGE_DUNGEON; + } else if (checkStagePrefix(stageName, "B2")) { + flags |= STAGE_MOUNTAIN | STAGE_BOSS; + } else if (checkStagePrefix(stageName, "S2")) { + flags |= STAGE_MOUNTAIN | STAGE_SILENT_REALM; + } else if (checkStagePrefix(stageName, "F3")) { + flags |= STAGE_DESERT | STAGE_FIELD; + } else if (checkStagePrefix(stageName, "D3")) { + flags |= STAGE_DESERT | STAGE_DUNGEON; + } else if (checkStagePrefix(stageName, "B3")) { + flags |= STAGE_DESERT | STAGE_BOSS; + } else if (checkStagePrefix(stageName, "S3")) { + flags |= STAGE_DESERT | STAGE_SILENT_REALM; + } else if (checkStagePrefix(stageName, "F4")) { + flags |= STAGE_SILENT_GROUNDS | STAGE_FIELD; + } else if (checkStagePrefix(stageName, "D4")) { + flags |= STAGE_SILENT_GROUNDS | STAGE_DUNGEON; + } else if (checkStagePrefix(stageName, "B4")) { + flags |= STAGE_SILENT_GROUNDS | STAGE_BOSS; + } + + if ((flags & STAGE_SKY) != 0 && std::strstr(stageName, "r") != nullptr) { + flags |= STAGE_ROOM; + } + + return flags; +} + +bool dSndStateMgr_c::isVolcanicDungeon(u32 stageId) { + u32 base = getStageUnk2(stageId); + switch (base) { + case SND_STAGE_D200: + case SND_STAGE_D201: + case SND_STAGE_D201_1: + case SND_STAGE_D003_0: + case SND_STAGE_D003_1: + return true; + default: + return false; + } +} + +bool dSndStateMgr_c::isSeekerStoneStage(const char *stageName, s32 layer) { + if (streq(stageName, "F000") && layer == 22) { + // Skyloft hint stone + return true; + } + + if (streq(stageName, "F202") && layer == 10) { + // Boko base hint stone + return true; + } + + return false; +} + +bool isInStage(const char *stageName) { + return !std::strcmp(dScGame_c::currentSpawnInfo.getStageName(), stageName); +} diff --git a/src/toBeSorted/actor_info.cpp b/src/toBeSorted/actor_info.cpp index 341d7775..98e829e2 100644 --- a/src/toBeSorted/actor_info.cpp +++ b/src/toBeSorted/actor_info.cpp @@ -271,7 +271,7 @@ static const ActorInfo sInfos[] = { { "ESiren", fProfile::E_SIREN, fProfile::E_SIREN, 0xFFFF, 18, 0}, { "ESktl", fProfile::E_SKYTAIL, fProfile::E_SKYTAIL, 2, 10, 0}, { "ESm", fProfile::E_SM, fProfile::E_SM, 59, 11, 0}, - { "ESpark", fProfile::E_SPARK, fProfile::E_SPARK, 67, 17, 0}, + { "ESpark", fProfile::E_SPARK, fProfile::E_SPARK, 67, SND_SOURCE_SPARK, 0}, { "ESyako", fProfile::E_SYAKOMAITO, fProfile::E_SYAKOMAITO, 68, 10, 0}, { "EWs", fProfile::E_WS, fProfile::E_WS, 6, 15, 0}, { "Eel", fProfile::EEL, fProfile::EEL, 0xFFFF, 0xFF, 0}, |
