diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2025-11-27 21:19:33 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-27 21:19:33 -0800 |
| commit | 6f96e665186c87f15acb6f5cb8d27665afee3130 (patch) | |
| tree | 3ea70fe7d635a0f55aae44b1a386814766a46597 /src/Z2AudioLib/Z2SoundObject.cpp | |
| parent | 767caeecc3e374779cccc9960b6546b74e7a9e50 (diff) | |
various Z2Audio / JAudio debug cleanup (#2876)
* some JAudio work
* audio cleanup checkpoint
* checkpoint more audio cleanup
* fix symbols
* more z2 cleanup
* fix regression
* fix build
* some fixes
Diffstat (limited to 'src/Z2AudioLib/Z2SoundObject.cpp')
| -rw-r--r-- | src/Z2AudioLib/Z2SoundObject.cpp | 587 |
1 files changed, 326 insertions, 261 deletions
diff --git a/src/Z2AudioLib/Z2SoundObject.cpp b/src/Z2AudioLib/Z2SoundObject.cpp index e4422c37e5..308ef9e78e 100644 --- a/src/Z2AudioLib/Z2SoundObject.cpp +++ b/src/Z2AudioLib/Z2SoundObject.cpp @@ -1,61 +1,71 @@ -// -// Generated By: dol2asm -// Translation Unit: Z2SoundObject -// - #include "Z2AudioLib/Z2SoundObject.h" +#include "Z2AudioLib/Z2SoundObjMgr.h" #include "Z2AudioLib/Z2Calc.h" #include "Z2AudioLib/Z2SeMgr.h" #include "Z2AudioLib/Z2SoundInfo.h" #include "Z2AudioLib/Z2SoundMgr.h" #include "Z2AudioLib/Z2SoundStarter.h" +#include "Z2AudioLib/Z2SceneMgr.h" #include "Z2AudioLib/Z2Audience.h" #include "JSystem/JAudio2/JAUSoundAnimator.h" -Z2SoundObjBase::Z2SoundObjBase() { - //! @note initializer list doesn't work since fields were initialized out of - //! structure layout order, indicating original code didn't use initializer list. - mSoundPos = NULL; - mIsInitialized = false; - mSoundStarter = JASGlobalInstance<Z2SoundStarter>::getInstance(); // sInstance +#if PLATFORM_WII || PLATFORM_SHIELD +#include "Z2AudioLib/Z2AudioCS.h" +#endif + +Z2SoundObjBase::Z2SoundObjBase() +#if VERSION == VERSION_SHIELD_DEBUG +: JSULink<Z2SoundObjBase>(this) +#endif +{ + pos_ = NULL; + alive_ = false; + soundStarter_ = Z2GetSoundStarter(); field_0x1c = 0; - field_0x1e = 0; + reverb_ = 0; } Z2SoundObjBase::~Z2SoundObjBase() { deleteObject(); } -void Z2SoundObjBase::init(Vec* pSoundPos, u8 pNumHandles) { - initHandlesPool(pNumHandles); - mSoundPos = (JGeometry::TVec3<f32>*)pSoundPos; - mIsInitialized = true; +void Z2SoundObjBase::init(Vec* posPtr, u8 handleNum) { + #if VERSION == VERSION_SHIELD_DEBUG + Z2GetSoundObjMgr()->getAllList()->append(this); + #endif + + initHandlesPool(handleNum); + pos_ = (JGeometry::TVec3<f32>*)posPtr; + alive_ = true; } /* 802BDFF8-802BE038 2B8938 0040+00 1/1 8/8 61/61 .text deleteObject__14Z2SoundObjBaseFv */ void Z2SoundObjBase::deleteObject() { + #if VERSION == VERSION_SHIELD_DEBUG + Z2GetSoundObjMgr()->getAllList()->remove(this); + #endif + dispose(); deleteHandlesPool(); } -void Z2SoundObjBase::framework(u32 p1, s8 reverb) { - if (mIsInitialized) { - field_0x1c = p1; - field_0x1e = reverb; - setPos(*mSoundPos); +void Z2SoundObjBase::framework(u32 param_0, s8 reverb) { + if (alive_) { + field_0x1c = param_0; + reverb_ = reverb; + setPos(*pos_); } } /* 802BE070-802BE104 2B89B0 0094+00 5/0 3/0 0/0 .text dispose__14Z2SoundObjBaseFv */ void Z2SoundObjBase::dispose() { JAISoundHandle* handle; - JSULink<Z2SoundHandlePool>* link; - for (link = getFirst(); link != NULL; link = link->getNext()) { - handle = link->getObject(); - if (handle != NULL && (bool)*handle) { - u32 swBit = JASGlobalInstance<Z2SoundInfo>::sInstance->getSwBit((*handle)->getID()); - if ((swBit & 0x8000) != 0) { + JSULink<Z2SoundHandlePool>* i; + for (i = getFirst(); i != NULL; i = i->getNext()) { + handle = i->getObject(); + if (handle != NULL && *handle) { + if ((Z2GetSoundInfo()->getSwBit((*handle)->getID()) & 0x8000) != 0) { handle->releaseSound(); } else { (*handle)->stop(); @@ -63,84 +73,122 @@ void Z2SoundObjBase::dispose() { } } - mIsInitialized = false; + alive_ = false; } /* 802BE104-802BE144 2B8A44 0040+00 5/0 3/0 0/0 .text * stopOK__14Z2SoundObjBaseFR17Z2SoundHandlePool */ -bool Z2SoundObjBase::stopOK(Z2SoundHandlePool& pSoundHandlePool) { - return !(JASGlobalInstance<Z2SoundInfo>::sInstance-> - getSwBit(pSoundHandlePool->getID()) & 0x8000); +bool Z2SoundObjBase::stopOK(Z2SoundHandlePool& handlePool) { + if ((Z2GetSoundInfo()->getSwBit(handlePool->getID()) & 0x8000) != 0) { + return false; + } else { + return true; + } } /* 802BE144-802BE2D4 2B8A84 0190+00 5/3 3/1 0/0 .text * startSound__14Z2SoundObjBaseF10JAISoundIDUlSc */ -Z2SoundHandlePool* Z2SoundObjBase::startSound(JAISoundID pSoundId, u32 param_1, s8 param_2) { - if (!mIsInitialized) { +Z2SoundHandlePool* Z2SoundObjBase::startSound(JAISoundID soundID, u32 mapinfo, s8 reverb) { + if (!alive_) { return NULL; } - if (JASGlobalInstance<Z2SeMgr>::getInstance()->isSoundCulling(pSoundId)) { + + if (Z2GetSeMgr()->isSoundCulling(soundID)) { return NULL; } - if (param_1 == 0) { - param_1 = (u32)field_0x1c; + + if (mapinfo == 0) { + mapinfo = (u32)field_0x1c; } - if (param_2 < 0) { - param_2 = field_0x1e; + + if (reverb < 0) { + reverb = reverb_; } - f32 local_0 = (f32)param_2 / 127.0f; - Z2SoundHandlePool* handle = getHandleSoundID(pSoundId); + + f32 fxMix = (f32)reverb / 127.0f; + + Z2SoundHandlePool* handle = getHandleSoundID(soundID); if (handle != NULL) { - if ((JASGlobalInstance<Z2SoundInfo>::getInstance()->getSwBit(pSoundId) & 0x4000) != 0) { + if ((Z2GetSoundInfo()->getSwBit(soundID) & 0x4000) != 0) { handle = NULL; } else { return NULL; } } + if (handle == NULL) { handle = getFreeHandle(); } + if (handle == NULL) { - handle = getLowPrioSound(pSoundId); + handle = getLowPrioSound(soundID); } + if (handle != NULL) { - mSoundStarter->startSound(pSoundId, handle, mSoundPos, param_1, local_0, + soundStarter_->startSound(soundID, handle, pos_, mapinfo, fxMix, 1.0f, 1.0f, -1.0f, -1.0f, 0); } + return handle; } /* 802BE2D4-802BE4A4 2B8C14 01D0+00 4/2 3/0 0/0 .text * startLevelSound__14Z2SoundObjBaseF10JAISoundIDUlSc */ -Z2SoundHandlePool* Z2SoundObjBase::startLevelSound(JAISoundID pSoundId, u32 param_1, s8 param_2) { - if (!mIsInitialized) { +Z2SoundHandlePool* Z2SoundObjBase::startLevelSound(JAISoundID soundID, u32 mapinfo, s8 reverb) { + if (!alive_) { return NULL; } - if (param_1 == 0) { - param_1 = (u32)field_0x1c; + + if (mapinfo == 0) { + mapinfo = (u32)field_0x1c; } - if (param_2 < 0) { - param_2 = field_0x1e; + + if (reverb < 0) { + reverb = reverb_; } - f32 local_0 = (f32)param_2 / 127.0f; - Z2SoundHandlePool* handle = getHandleSoundID(pSoundId); + + f32 fxMix = (f32)reverb / 127.0f; + + Z2SoundHandlePool* handle = getHandleSoundID(soundID); if (handle != NULL) { - handle->getSound()->updateLifeTime(1); - mSoundStarter->setPortData(handle, 6, (u16)param_1, -1); - handle->getSound()->getAuxiliary().moveFxMix(local_0, 0); + JUT_ASSERT_MSG(218, *handle, "handle exist, but (*handle) is not exist!!\n"); + (*handle)->updateLifeTime(1); + soundStarter_->setPortData(handle, 6, (u16)mapinfo, -1); + (*handle)->getAuxiliary().moveFxMix(fxMix, 0); } else { - if (JASGlobalInstance<Z2SeMgr>::getInstance()->isSoundCulling(pSoundId)) { + if (Z2GetSeMgr()->isSoundCulling(soundID)) { return NULL; } + handle = getFreeHandle(); if (handle == NULL) { - handle = getLowPrioSound(pSoundId); + handle = getLowPrioSound(soundID); } + if (handle != NULL) { - mSoundStarter->startSound(pSoundId, handle, mSoundPos, param_1, local_0, + soundStarter_->startSound(soundID, handle, pos_, mapinfo, fxMix, 1.0f, 1.0f, -1.0f, -1.0f, 0); - if (handle != NULL && handle->getSound() != NULL) { - handle->getSound()->setLifeTime(1, false); + if (handle != NULL && (*handle) != NULL) { + (*handle)->setLifeTime(1, false); + + #if PLATFORM_WII || PLATFORM_SHIELD + if (Z2GetSceneMgr()->isSceneExist()) { + switch (soundID) { + case Z2SE_BOOM_POWER_RESUME: + Z2AudioCS::start(0x12, 0); + break; + case Z2SE_BOOM_TORNADO: + Z2AudioCS::start(0x13, 0); + break; + case Z2SE_AL_SPINNER_RAIL: + Z2AudioCS::start(0x3C, 0); + break; + case Z2SE_WOLFATTACK_WIND_RUSH: + Z2AudioCS::start(0x58, 0); + break; + } + } + #endif } } } @@ -149,31 +197,35 @@ Z2SoundHandlePool* Z2SoundObjBase::startLevelSound(JAISoundID pSoundId, u32 para /* 802BE4A4-802BE5A0 2B8DE4 00FC+00 0/0 5/5 21/21 .text * startCollisionSE__14Z2SoundObjBaseFUlUlP14Z2SoundObjBase */ -Z2SoundHandlePool* Z2SoundObjBase::startCollisionSE(u32 pId, u32 pUserData, Z2SoundObjBase* pOther) { - if (pOther != NULL) { - return pOther->startCollisionSE(pId, pUserData, NULL); - } - if (53 < pUserData) { - pUserData = 0; - } - for (JSULink<JAISe>* link = - Z2GetSoundMgr()->getSeMgr()->getCategory(4)->getSeList()->getFirst(); - link != NULL; link = link->getNext()) { - if (pId == link->getObject()->getID() && pUserData == link->getObject()->getUserData()) { - link->getObject()->stop(); +Z2SoundHandlePool* Z2SoundObjBase::startCollisionSE(u32 hitID, u32 mapinfo, Z2SoundObjBase* other) { + if (other != NULL) { + return other->startCollisionSE(hitID, mapinfo, NULL); + } + + if (53 < mapinfo) { + JUT_WARN_DEVICE(297, 1, "%s", "mapinfo > 53\n"); + OS_REPORT("startCollisionSE Invalid MAPINFO:%d hitID:%08x\n", mapinfo, hitID); + mapinfo = 0; + } + + for (JSULink<JAISe>* i = Z2GetSoundMgr()->getSeMgr()->getCategory(4)->getSeList()->getFirst(); i != NULL; i = i->getNext()) { + JAISe* se = i->getObject(); + if (hitID == se->getID() && mapinfo == se->getUserData()) { + se->stop(); } } - Z2SoundHandlePool* handle = Z2SoundObjBase::startSound(JAISoundID(pId), pUserData, -1); - if (handle != NULL && handle->getSound() != NULL) { - handle->getSound()->setUserData(pUserData); - if (30 <= pUserData && pUserData <= 52) { - Z2Audible* audible = (Z2Audible*)handle->getSound()->getAudible(); + + Z2SoundHandlePool* handle = Z2SoundObjBase::startSound(JAISoundID(hitID), mapinfo, -1); + if (handle != NULL && (*handle) != NULL) { + (*handle)->setUserData(mapinfo); + if (30 <= mapinfo && mapinfo <= 52) { + Z2Audible* audible = (Z2Audible*)(*handle)->getAudible(); if (audible != NULL) { - JAUAudibleParam* param = audible->getAudibleParam(); - param->field_0x0.bytes.b1_2_7 = 8; + audible->getAudibleParam()->field_0x0.bytes.b1_2_7 = 8; } } } + return handle; } @@ -187,106 +239,107 @@ Z2DopplerSoundObjBase::Z2DopplerSoundObjBase() : Z2SoundObjBase() { Z2DopplerSoundObjBase::~Z2DopplerSoundObjBase() {} /* 802BE65C-802BE6B8 2B8F9C 005C+00 1/0 0/0 0/0 .text init__21Z2DopplerSoundObjBaseFP3VecUc */ -void Z2DopplerSoundObjBase::init(Vec* param_0, u8 param_1) { - Z2SoundObjBase::init(param_0, param_1); - if (mSoundPos != NULL) { - // field_0x20 = *mSoundPos; - JGeometry::setTVec3f(&mSoundPos->x, &field_0x20.x); - // field_0x2c = *mSoundPos; - JGeometry::setTVec3f(&mSoundPos->x, &field_0x2c.x); +void Z2DopplerSoundObjBase::init(Vec* posPtr, u8 handleNum) { + Z2SoundObjBase::init(posPtr, handleNum); + if (pos_ != NULL) { + field_0x20 = *pos_; + field_0x2c = *pos_; } } /* 802BE6B8-802BE714 2B8FF8 005C+00 2/0 0/0 0/0 .text framework__21Z2DopplerSoundObjBaseFUlSc */ -void Z2DopplerSoundObjBase::framework(u32 param_0, s8 param_1) { - Z2SoundObjBase::framework(param_0, param_1); - if (mSoundPos != NULL) { - // field_0x20 = field_0x2c; - JGeometry::setTVec3f(&field_0x2c.x, &field_0x20.x); - // field_0x2c = *mSoundPos; - JGeometry::setTVec3f(&mSoundPos->x, &field_0x2c.x); +void Z2DopplerSoundObjBase::framework(u32 param_0, s8 reverb) { + Z2SoundObjBase::framework(param_0, reverb); + if (pos_ != NULL) { + field_0x20 = field_0x2c; + field_0x2c = *pos_; } } /* 802BE714-802BE7AC 2B9054 0098+00 2/0 0/0 0/0 .text * startSound__21Z2DopplerSoundObjBaseF10JAISoundIDUlSc */ -Z2SoundHandlePool* Z2DopplerSoundObjBase::startSound(JAISoundID pSoundId, u32 param_1, s8 param_2) { - JGeometry::TVec3<f32>* pos = mSoundPos; - mSoundPos = NULL; - Z2SoundHandlePool* handle = Z2SoundObjBase::startSound(pSoundId, param_1, param_2); - if (pos != NULL && handle != NULL && handle->getSound() != NULL) { - if (handle->getSound()->acceptsNewAudible()) { - handle->getSound()->newAudible(*pos, &field_0x20, 0, NULL); +Z2SoundHandlePool* Z2DopplerSoundObjBase::startSound(JAISoundID soundID, u32 mapinfo, s8 reverb) { + JGeometry::TVec3<f32>* pos = pos_; + pos_ = NULL; + + Z2SoundHandlePool* handle = Z2SoundObjBase::startSound(soundID, mapinfo, reverb); + if (pos != NULL && handle != NULL && (*handle) != NULL) { + if ((*handle)->acceptsNewAudible()) { + (*handle)->newAudible(*pos, &field_0x20, 0, NULL); } } - mSoundPos = pos; + + pos_ = pos; return handle; } /* 802BE7AC-802BE844 2B90EC 0098+00 2/0 0/0 0/0 .text * startLevelSound__21Z2DopplerSoundObjBaseF10JAISoundIDUlSc */ -Z2SoundHandlePool* Z2DopplerSoundObjBase::startLevelSound(JAISoundID pSoundId, - u32 param_1, s8 param_2) { - JGeometry::TVec3<f32>* pos = mSoundPos; - mSoundPos = NULL; - Z2SoundHandlePool* handle = Z2SoundObjBase::startLevelSound(pSoundId, param_1, param_2); - if (pos != NULL && handle != NULL && handle->getSound() != NULL) { - if (handle->getSound()->acceptsNewAudible()) { - handle->getSound()->newAudible(*pos, &field_0x20, 0, NULL); +Z2SoundHandlePool* Z2DopplerSoundObjBase::startLevelSound(JAISoundID soundID, u32 mapinfo, s8 reverb) { + JGeometry::TVec3<f32>* pos = pos_; + pos_ = NULL; + + Z2SoundHandlePool* handle = Z2SoundObjBase::startLevelSound(soundID, mapinfo, reverb); + if (pos != NULL && handle != NULL && (*handle) != NULL) { + if ((*handle)->acceptsNewAudible()) { + (*handle)->newAudible(*pos, &field_0x20, 0, NULL); } } - mSoundPos = pos; + + pos_ = pos; return handle; } /* 802BE844-802BE880 2B9184 003C+00 0/0 8/8 65/65 .text __ct__16Z2SoundObjSimpleFv */ Z2SoundObjSimple::Z2SoundObjSimple() : Z2SoundObjBase() {} -void Z2SoundObjSimple::init(Vec* pSoundPos, u8 pNumHandles) { - Z2SoundObjBase::init(pSoundPos, pNumHandles); +void Z2SoundObjSimple::init(Vec* posPtr, u8 handleNum) { + Z2SoundObjBase::init(posPtr, handleNum); } /* 802BE8A0-802BE9B0 2B91E0 0110+00 1/0 0/0 0/0 .text * startSound__16Z2SoundObjSimpleF10JAISoundIDUlSc */ -Z2SoundHandlePool* Z2SoundObjSimple::startSound(JAISoundID pSoundId, u32 param_1, s8 param_2) { - Z2SoundHandlePool* handle = Z2SoundObjBase::startSound(pSoundId, param_1, param_2); - if (pSoundId == 0x200c7 && handle != NULL && handle->getSound() != NULL) { - f32 local_0 = Z2Calc::getParamByExp((f32)param_1, 0.0f, 127.0f, 0.2f, 0.4f, 1.0f, - Z2Calc::CURVE_SIGN_1); - f32 local_1 = Z2Calc::getParamByExp((f32)param_1, 0.0f, 127.0f, 0.2f, 0.6f, 1.2f, - Z2Calc::CURVE_SIGN_1); - handle->getSound()->getAuxiliary().movePitch(local_1, 0); - handle->getSound()->getAuxiliary().moveVolume(local_0, 0); +Z2SoundHandlePool* Z2SoundObjSimple::startSound(JAISoundID soundID, u32 mapinfo, s8 reverb) { + Z2SoundHandlePool* handle = Z2SoundObjBase::startSound(soundID, mapinfo, reverb); + + if (soundID == Z2SE_AL_UKI_POKOPOKO && handle != NULL && (*handle) != NULL) { + f32 volume = Z2Calc::getParamByExp((f32)mapinfo, 0.0f, 127.0f, 0.2f, 0.4f, 1.0f, Z2Calc::CURVE_POSITIVE); + f32 pitch = Z2Calc::getParamByExp((f32)mapinfo, 0.0f, 127.0f, 0.2f, 0.6f, 1.2f, Z2Calc::CURVE_POSITIVE); + (*handle)->getAuxiliary().movePitch(pitch, 0); + (*handle)->getAuxiliary().moveVolume(volume, 0); } + return handle; } /* 802BE9B0-802BEB38 2B92F0 0188+00 1/0 0/0 0/0 .text * startLevelSound__16Z2SoundObjSimpleF10JAISoundIDUlSc */ -Z2SoundHandlePool* Z2SoundObjSimple::startLevelSound(JAISoundID pSoundId, u32 param_1, s8 param_2) { - Z2SoundHandlePool* handle = Z2SoundObjBase::startLevelSound(pSoundId, param_1, param_2); - if (handle != NULL && handle->getSound() != NULL) { - f32 local_0 = 1.0f; - f32 local_1 = 1.0f; - switch (pSoundId) { - case 0x200c6: - local_1 = Z2Calc::getParamByExp((f32)param_1, 0.0f, 127.0f, 0.2f, 0.4f, 1.0f, - Z2Calc::CURVE_SIGN_1); - local_0 = Z2Calc::getParamByExp((f32)param_1, 0.0f, 127.0f, 0.2f, 0.6f, 1.2f, - Z2Calc::CURVE_SIGN_1); +Z2SoundHandlePool* Z2SoundObjSimple::startLevelSound(JAISoundID soundID, u32 mapinfo, s8 reverb) { + Z2SoundHandlePool* handle = Z2SoundObjBase::startLevelSound(soundID, mapinfo, reverb); + + if (handle != NULL && (*handle) != NULL) { + f32 pitch = 1.0f; + f32 volume = 1.0f; + switch (soundID) { + case Z2SE_AL_UKI_KURUKURU_LOOP: + volume = Z2Calc::getParamByExp((f32)mapinfo, 0.0f, 127.0f, 0.2f, 0.4f, 1.0f, Z2Calc::CURVE_POSITIVE); + pitch = Z2Calc::getParamByExp((f32)mapinfo, 0.0f, 127.0f, 0.2f, 0.6f, 1.2f, Z2Calc::CURVE_POSITIVE); break; - case 0x8025c: - if (param_1 > 100) { - local_0 = 2.0f; - } else if (param_1 > 21) { - local_0 = Z2Calc::getParamByExp((f32)param_1, 22.0f, 50.0f, 0.4f, 1.0f, 1.5f, - Z2Calc::CURVE_SIGN_0); + case Z2SE_OBJ_FLR_FALLING: + if (mapinfo > 100) { + pitch = 2.0f; + } else if (mapinfo > 21) { + pitch = Z2Calc::getParamByExp((f32)mapinfo, 22.0f, 50.0f, 0.4f, 1.0f, 1.5f, Z2Calc::CURVE_NEGATIVE); + } else { + pitch = 1.0f; } break; } - handle->getSound()->getAuxiliary().movePitch(local_0, 0); - handle->getSound()->getAuxiliary().moveVolume(local_1, 0); + + (*handle)->getAuxiliary().movePitch(pitch, 0); + (*handle)->getAuxiliary().moveVolume(volume, 0); } + return handle; } @@ -294,42 +347,44 @@ Z2SoundHandlePool* Z2SoundObjSimple::startLevelSound(JAISoundID pSoundId, u32 pa Z2SoundObjArrow::Z2SoundObjArrow() : Z2DopplerSoundObjBase() {} /* 802BEB74-802BEB94 2B94B4 0020+00 1/0 0/0 0/0 .text init__15Z2SoundObjArrowFP3VecUc */ -void Z2SoundObjArrow::init(Vec* param_0, u8 param_1) { - Z2SoundObjBase::init(param_0, param_1); +void Z2SoundObjArrow::init(Vec* posPtr, u8 handleNum) { + Z2SoundObjBase::init(posPtr, handleNum); } /* 802BEB94-802BEBDC 2B94D4 0048+00 0/0 2/2 0/0 .text __ct__15Z2SoundObjAnimeFv */ Z2SoundObjAnime::Z2SoundObjAnime() : Z2SoundObjBase() { - mpAnimation = NULL; - mReverse = false; + animation_ = NULL; + reverse_ = false; } /* 802BEBDC-802BEBFC 2B951C 0020+00 1/0 1/0 0/0 .text init__15Z2SoundObjAnimeFP3VecUc */ -void Z2SoundObjAnime::init(Vec* param_0, u8 param_1) { - Z2SoundObjBase::init(param_0, param_1); +void Z2SoundObjAnime::init(Vec* posPtr, u8 handleNum) { + Z2SoundObjBase::init(posPtr, handleNum); } /* 802BEBFC-802BED68 2B953C 016C+00 0/0 2/2 0/0 .text initAnime__15Z2SoundObjAnimeFPvbff */ -void Z2SoundObjAnime::initAnime(void* param_0, bool param_1, f32 param_2, f32 param_3) { +void Z2SoundObjAnime::initAnime(void* animation, bool param_1, f32 startFrame, f32 param_3) { ageSounds_(); - mpAnimation = (JAUSoundAnimation*)param_0; - if (mpAnimation != NULL) { - mReverse = !param_1; + animation_ = (JAUSoundAnimation*)animation; + if (animation_ != NULL) { + reverse_ = !param_1; field_0x3c = 0; - if (mReverse) { - mCurSoundIndex = mpAnimation->getNumSounds() - 1; - mCurSoundFrame = FLT_MAX; - setLoopFrame(0.0f, param_2); + + if (reverse_) { + curSoundIndex_ = animation_->getNumSounds() - 1; + curSoundFrame_ = FLT_MAX; + setLoopFrame(0.0f, startFrame); } else { - mCurSoundIndex = 0; - mCurSoundFrame = 0.0f; - setLoopFrame(param_2, 0.0f); + curSoundIndex_ = 0; + curSoundFrame_ = 0.0f; + setLoopFrame(startFrame, 0.0f); } - mCurSoundFrame = param_3; - mCurSoundIndex = mpAnimation->getStartSoundIndex(param_3); - if (mReverse && mCurSoundIndex > 0) { - mCurSoundIndex--; + + curSoundFrame_ = param_3; + curSoundIndex_ = animation_->getStartSoundIndex(param_3); + if (reverse_ && curSoundIndex_ > 0) { + curSoundIndex_--; } } } @@ -337,25 +392,24 @@ void Z2SoundObjAnime::initAnime(void* param_0, bool param_1, f32 param_2, f32 pa /* 802BED68-802BEED4 2B96A8 016C+00 1/1 0/0 0/0 .text ageSounds___15Z2SoundObjAnimeFv */ void Z2SoundObjAnime::ageSounds_() { for (int i = 0; i < getNumHandles(); i++) { - if (getHandle(i)->getSound() != NULL) { - switch (getHandle(i)->getSound()->getAnimationState()) { - case 0: - break; - case 1: - if (getHandle(i)->getSound()->hasLifeTime()) { - getHandle(i)->getSound()->stop(); + if ((*getHandle(i))) { + switch ((*getHandle(i))->getAnimationState()) { + case 0: + break; + case 1: + if ((*getHandle(i))->hasLifeTime()) { + (*getHandle(i))->stop(); + } else { + JAUSoundAnimationSound* animationSound = (JAUSoundAnimationSound*)(*getHandle(i))->getUserData(); + if (animationSound->stopsWhenAnimationChanges()) { + (*getHandle(i))->stop(); } else { - JAUSoundAnimationSound* sound = - (JAUSoundAnimationSound*)getHandle(i)->getSound()->getUserData(); - if (sound->stopsWhenAnimationChanges()) { - getHandle(i)->getSound()->stop(); - } else { - getHandle(i)->getSound()->setAnimationState(2); - } + (*getHandle(i))->setAnimationState(2); } - break; - case 2: - break; + } + break; + case 2: + break; } } } @@ -365,90 +419,93 @@ void Z2SoundObjAnime::ageSounds_() { */ void Z2SoundObjAnime::updateAnime(f32 param_0, f32 param_1) { for (int i = 0; i < getNumHandles(); i++) { - if (getHandle(i)->getSound() != NULL && getHandle(i)->getSound()->isAnimated()) { - getHandle(i)->getSound()->setPos(*mSoundPos); + if ((*getHandle(i)) && (*getHandle(i))->isAnimated()) { + (*getHandle(i))->setPos(*pos_); } } - if (mpAnimation == NULL || mpAnimation->getNumSounds() == 0) { + if (animation_ == NULL || animation_->getNumSounds() == 0) { return; } - if (!mReverse) { - if (param_0 < mCurSoundFrame) { - while (mCurSoundIndex < mEndSoundIndex) { - startSoundInner(*mSoundPos, param_1, mSoundStarter, field_0x1c, field_0x1e); + if (!reverse_) { + if (param_0 < curSoundFrame_) { + while (curSoundIndex_ < endSoundIndex_) { + startSoundInner(*pos_, param_1, soundStarter_, field_0x1c, reverb_); } - mCurSoundIndex = mStartSoundIndex; - mCurSoundFrame = param_0; - if (field_0x3c < 0xffff) { + curSoundIndex_ = startSoundIndex_; + curSoundFrame_ = param_0; + if (field_0x3c < 0xFFFF) { field_0x3c++; } } + updateSoundLifeTime_(param_0, param_1); - while (mCurSoundIndex < mpAnimation->getNumSounds() && - mpAnimation->getSound(mCurSoundIndex)->isNotingOn(param_0, false)) { - startSoundInner(*mSoundPos, param_1, mSoundStarter, field_0x1c, field_0x1e); + + while (curSoundIndex_ < animation_->getNumSounds() && animation_->getSound(curSoundIndex_)->isNotingOn(param_0, false)) { + startSoundInner(*pos_, param_1, soundStarter_, field_0x1c, reverb_); } } else { - if (param_0 > mCurSoundFrame) { - while (mCurSoundIndex >= mStartSoundIndex) { - startSoundInner(*mSoundPos, param_1, mSoundStarter, field_0x1c, field_0x1e); + if (param_0 > curSoundFrame_) { + while (curSoundIndex_ >= startSoundIndex_) { + startSoundInner(*pos_, param_1, soundStarter_, field_0x1c, reverb_); } - mCurSoundIndex = mEndSoundIndex - 1; - mCurSoundFrame = param_0; - if (field_0x3c < 0xffff) { + curSoundIndex_ = endSoundIndex_ - 1; + curSoundFrame_ = param_0; + if (field_0x3c < 0xFFFF) { field_0x3c++; } } + updateSoundLifeTime_(param_0, param_1); - while (mCurSoundIndex >= 0 && - mpAnimation->getSound(mCurSoundIndex)->isNotingOn(param_0, true)) { - startSoundInner(*mSoundPos, param_1, mSoundStarter, field_0x1c, field_0x1e); + + while (curSoundIndex_ >= 0 && animation_->getSound(curSoundIndex_)->isNotingOn(param_0, true)) { + startSoundInner(*pos_, param_1, soundStarter_, field_0x1c, reverb_); } } - mCurSoundFrame = param_0; + curSoundFrame_ = param_0; } /* 802BF304-802BF660 2B9C44 035C+00 1/1 0/0 0/0 .text updateSoundLifeTime___15Z2SoundObjAnimeFff */ void Z2SoundObjAnime::updateSoundLifeTime_(f32 param_0, f32 param_1) { - if (mpAnimation == NULL) { + if (animation_ == NULL) { return; } + for (int i = 0; i < getNumHandles(); i++) { - if (getHandle(i)->getSound() != NULL) { - switch (getHandle(i)->getSound()->getAnimationState()) { - case 0: - break; - case 1: { - JAUSoundAnimationSound* sound = - (JAUSoundAnimationSound*)getHandle(i)->getSound()->getUserData(); - bool bvar1 = param_1 == 0.0f && sound->stopsWhenSpeedIsZero(); - if (sound->setsLifeTime()) { - if (bvar1) { - getHandle(i)->getSound()->pause(true); - } else { - if (sound->isNoting(param_0)) { - getHandle(i)->getSound()->updateLifeTime(1); - getHandle(i)->getSound()->pause(false); - } else { - getHandle(i)->getSound()->stop(); - } - } + if ((*getHandle(i))) { + switch ((*getHandle(i))->getAnimationState()) { + case 0: + break; + case 1: { + JAUSoundAnimationSound* animationSound = (JAUSoundAnimationSound*)(*getHandle(i))->getUserData(); + JUT_ASSERT(696, animationSound); + + bool bvar1 = param_1 == 0.0f && animationSound->stopsWhenSpeedIsZero(); + if (animationSound->setsLifeTime()) { + if (bvar1) { + (*getHandle(i))->pause(true); } else { - if (bvar1) { - getHandle(i)->getSound()->stop(); - } else if (sound->stopsWhenNoteOff() && - sound->isNotingOff(param_0, mReverse)) { - getHandle(i)->getSound()->stop(); + if (animationSound->isNoting(param_0)) { + (*getHandle(i))->updateLifeTime(1); + (*getHandle(i))->pause(false); + } else { + (*getHandle(i))->stop(); } } - break; + } else { + if (bvar1) { + (*getHandle(i))->stop(); + } else if (animationSound->stopsWhenNoteOff() && animationSound->isNotingOff(param_0, reverse_)) { + (*getHandle(i))->stop(); + } } - case 2: - break; + break; + } + case 2: + break; } } } @@ -456,38 +513,44 @@ void Z2SoundObjAnime::updateSoundLifeTime_(f32 param_0, f32 param_1) { /* 802BF660-802BF890 2B9FA0 0230+00 1/1 0/0 0/0 .text * startSoundInner__15Z2SoundObjAnimeFRCQ29JGeometry8TVec3<f>fP14Z2SoundStarterUlSc */ -void Z2SoundObjAnime::startSoundInner(JGeometry::TVec3<f32> const& param_0, f32 param_1, - Z2SoundStarter* param_2, u32 param_3, s8 param_4) { - const JAUSoundAnimationSound* sound = mpAnimation->getSound(mCurSoundIndex); - u32 user_data = (u32)sound; - if (mReverse) { - mCurSoundIndex--; +void Z2SoundObjAnime::startSoundInner(const JGeometry::TVec3<f32>& pos, f32 param_1, + Z2SoundStarter* soundStarter, u32 mapinfo, s8 reverb) { + JUT_ASSERT(746, curSoundIndex_ >= 0); + JUT_ASSERT(747, curSoundIndex_ < animation_->getNumSounds()); + + const JAUSoundAnimationSound* animationSound = animation_->getSound(curSoundIndex_); + u32 user_data = (u32)animationSound; + if (reverse_) { + curSoundIndex_--; } else { - mCurSoundIndex++; + curSoundIndex_++; } - if (sound->field_0x1a > 0) { - param_3 = sound->field_0x1a; + + if (animationSound->field_0x1a > 0) { + mapinfo = animationSound->field_0x1a; } - if (playsSound(sound, param_0, param_1)) { - u32 id = getSoundID(sound, param_0, param_1); + + if (playsSound(animationSound, pos, param_1)) { + u32 id = getSoundID(animationSound, pos, param_1); if (!Z2GetSeMgr()->isSoundCulling(id)) { JAISoundHandle* handle = getHandleUserData(user_data); - if (handle != NULL && handle->getSound() != NULL && - handle->getSound()->getAnimationState() != 1) { + if (handle != NULL && (*handle) != NULL && (*handle)->getAnimationState() != 1) { handle = NULL; } + if (handle == NULL) { handle = getFreeHandle(); } + if (handle != NULL) { - param_2->startSound(id, handle, ¶m_0, param_3, (f32)param_4 / 127.0f, - sound->field_0x0c, (f32)sound->field_0x14 / 127.0f, - -1.0f, -1.0f, 0); - if (handle->getSound() != NULL) { - handle->getSound()->setAnimationState(1); - handle->getSound()->setUserData(user_data); - if (sound->setsLifeTime()) { - handle->getSound()->setLifeTime(1, false); + bool result = soundStarter->startSound(id, handle, &pos, mapinfo, (f32)reverb / 127.0f, + animationSound->field_0x0c, (f32)animationSound->field_0x14 / 127.0f, + -1.0f, -1.0f, 0); + if ((*handle) != NULL) { + (*handle)->setAnimationState(1); + (*handle)->setUserData(user_data); + if (animationSound->setsLifeTime()) { + (*handle)->setLifeTime(1, false); } } } @@ -497,32 +560,34 @@ void Z2SoundObjAnime::startSoundInner(JGeometry::TVec3<f32> const& param_0, f32 /* 802BF890-802BF898 2BA1D0 0008+00 1/1 0/0 0/0 .text * getSoundID__15Z2SoundObjAnimeFPC22JAUSoundAnimationSoundRCQ29JGeometry8TVec3<f>f */ -u32 Z2SoundObjAnime::getSoundID(JAUSoundAnimationSound const* i_sound, - JGeometry::TVec3<f32> const& param_1, f32 param_2) { - return i_sound->mSoundId; +u32 Z2SoundObjAnime::getSoundID(const JAUSoundAnimationSound* animationSound, + const JGeometry::TVec3<f32>& param_1, f32 param_2) { + return animationSound->mSoundId; } /* 802BF898-802BF920 2BA1D8 0088+00 1/1 0/0 0/0 .text * playsSound__15Z2SoundObjAnimeFPC22JAUSoundAnimationSoundRCQ29JGeometry8TVec3<f>f */ -bool Z2SoundObjAnime::playsSound(JAUSoundAnimationSound const* i_sound, - JGeometry::TVec3<f32> const& param_1, f32 param_2) { - if (i_sound->playsOnlyOnce()) { - if (field_0x3c != i_sound->field_0x16) { +bool Z2SoundObjAnime::playsSound(const JAUSoundAnimationSound* animationSound, + const JGeometry::TVec3<f32>& param_1, f32 param_2) { + (void)param_1; + (void)param_2; + + if (animationSound->playsOnlyOnce()) { + if (field_0x3c != animationSound->field_0x16) { return false; } } else { - if (i_sound->playsAtIntervals() && - i_sound->field_0x16 != field_0x3c % i_sound->field_0x19) { + if (animationSound->playsAtIntervals() && animationSound->field_0x16 != field_0x3c % animationSound->field_0x19) { return false; } } - if (mReverse) { - if (i_sound->playsOnlyForward()) { + if (reverse_) { + if (animationSound->playsOnlyForward()) { return false; } } else { - if (i_sound->playsOnlyReverse()) { + if (animationSound->playsOnlyReverse()) { return false; } } |
