diff options
| author | Erin Moon <erin@hecke.rs> | 2021-01-21 22:16:51 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-21 23:16:51 -0500 |
| commit | a072e71c33dc4f78f20f7b4ba8645346af66fd9c (patch) | |
| tree | e4caf9392e0672fceccfd11beed6eb45a10b0bac /libs/Z2AudioLib/Z2SoundObject.cpp | |
| parent | afb426c60ca87472063b9b58b1a6b6a9db4fc127 (diff) | |
Z2AudioLib misc decomp (#75)
* Z2SoundHandles: decomp portions
* start decomping: Z2SpeechMgr2, Z2SoundHandles
* Z2SoundHandles::stopAllSounds(): ok
* Z2SoundHandles::getHandleUserData(): ok
* Z2SoundInfo: header
* Z2SoundObjBase::framework(): ok
* Z2SoundObjBase::Z2SoundObjBase(), Z2SoundObjBase::init(): ok
* Z2SoundObjBase::~Z2SoundObjBase(): ok
* Z2SoundObjBase::stopOK(): ok
* Z2SoundObjBase::stopOK, incomplete Z2SoundObjBase::dispose()
* clang-format
* Z2SoundObjBase::dispose(): ok
* JAISound::operator->(): null assert
* JAIAudience: stub
* Z2SoundObject::{init, deleteObject, isAlive}: ok
* Z2SeMgr: elaborate struct (and decl JAISoundHandles to support this)
* start subclassing Z2SoundObjBase; nonmatching Z2SoundObjSimple::init()
* Z2SeMGr::{incrCrowdSize, decrCrowdSize}: ok
* Z2MultiSeMgr::resetMultiSePos(): ok
* Z2WolfHowlMgr.h: decls
* Z2SoundStarter: move to decls and fix postprocess.py symbol pass
* Z2AudioArcLoader: decls
* Z2SoundObjMgr: ok some fns
- deleteEnemyAll()
- isTwilightBattle()
- setGhostEnemyState()
additionally elaborates parts of the Z2Creature hierarchy
* delete unused .s files and add tool to find them (only runs on linux)
* run clang-format
* postprocess.py: comment out debugging
* add python step to ok-check workflow
* address review comments
* address review comments
Co-authored-by: notyourav <65437533+notyourav@users.noreply.github.com>
Co-authored-by: Pheenoh <pheenoh@gmail.com>
Co-authored-by: notyourav <65437533+notyourav@users.noreply.github.com>
Diffstat (limited to 'libs/Z2AudioLib/Z2SoundObject.cpp')
| -rw-r--r-- | libs/Z2AudioLib/Z2SoundObject.cpp | 97 |
1 files changed, 58 insertions, 39 deletions
diff --git a/libs/Z2AudioLib/Z2SoundObject.cpp b/libs/Z2AudioLib/Z2SoundObject.cpp index 531f6f3ac0..3eeb3f0b01 100644 --- a/libs/Z2AudioLib/Z2SoundObject.cpp +++ b/libs/Z2AudioLib/Z2SoundObject.cpp @@ -1,58 +1,65 @@ /* Z2SoundObject.cpp autogenerated by split.py v0.3 at 2021-01-04 23:48:52.467160 */ +#include "Z2AudioLib/Z2SoundObject/Z2SoundObject.h" #include "Z2AudioLib/Z2SeMgr/Z2SeMgr.h" -#include "global.h" +#include "Z2AudioLib/Z2SoundInfo/Z2SoundInfo.h" -extern "C" { -// __ct__14Z2SoundObjBaseFv -// Z2SoundObjBase::Z2SoundObjBase(void) -asm void Z2SoundObjBase_NS_ctor(void) { - nofralloc -#include "Z2AudioLib/Z2SoundObject/asm/func_802BDEF0.s" +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 = lbl_80450B74; + field_0x1c = 0; + field_0x1e = 0; } -// __dt__14Z2SoundObjBaseFv -// Z2SoundObjBase::~Z2SoundObjBase(void) -asm void Z2SoundObjBase_NS_dtor(void) { - nofralloc -#include "Z2AudioLib/Z2SoundObject/asm/func_802BDF48.s" +Z2SoundObjBase::~Z2SoundObjBase() { + deleteObject(); } -// init__14Z2SoundObjBaseFP3VecUc -// Z2SoundObjBase::init(Vec*, unsigned char) -asm void Z2SoundObjBase_NS_init(void) { - nofralloc -#include "Z2AudioLib/Z2SoundObject/asm/func_802BDFB0.s" +void Z2SoundObjBase::init(Vec* pSoundPos, u8 pNumHandles) { + initHandlesPool(pNumHandles); + mSoundPos = pSoundPos; + mIsInitialized = true; } -// deleteObject__14Z2SoundObjBaseFv -// Z2SoundObjBase::deleteObject(void) -asm void Z2SoundObjBase_NS_deleteObject(void) { - nofralloc -#include "Z2AudioLib/Z2SoundObject/asm/func_802BDFF8.s" +void Z2SoundObjBase::deleteObject() { + this->dispose(); + this->deleteHandlesPool(); } -// framework__14Z2SoundObjBaseFUlSc -// Z2SoundObjBase::framework(unsigned long, char) -asm void Z2SoundObjBase_NS_framework(void) { - nofralloc -#include "Z2AudioLib/Z2SoundObject/asm/func_802BE038.s" +void Z2SoundObjBase::framework(u32 p1, s8 p2) { + if (mIsInitialized) { + this->field_0x1c = p1; + this->field_0x1e = p2; + this->setPos(*(JGeometry::TVec3<f32>*)this->mSoundPos); + } } -// dispose__14Z2SoundObjBaseFv -// Z2SoundObjBase::dispose(void) -asm void func_802BE070(void) { - nofralloc -#include "Z2AudioLib/Z2SoundObject/asm/func_802BE070.s" +void Z2SoundObjBase::dispose() { + JAISoundHandle* handle; + JSULink<Z2SoundHandlePool>* link; + for (link = this->getFirst(); link != NULL; link = link->getNext()) { + handle = link->getObject(); + if (handle != NULL && (bool)*handle) { + u32 swBit = lbl_80450B4C->getSwBit((*handle)->getID()); + if ((swBit & 0x8000) != 0) { + handle->releaseSound(); + } else { + (*handle)->stop(); + } + } + } + + this->mIsInitialized = false; } -// stopOK__14Z2SoundObjBaseFR17Z2SoundHandlePool -// Z2SoundObjBase::stopOK(Z2SoundHandlePool&) -asm void func_802BE104(void) { - nofralloc -#include "Z2AudioLib/Z2SoundObject/asm/func_802BE104.s" +bool Z2SoundObjBase::stopOK(Z2SoundHandlePool& pSoundHandlePool) { + return !(lbl_80450B4C->getSwBit(pSoundHandlePool->getID()) & 0x8000); } +extern "C" { // startSound__14Z2SoundObjBaseF10JAISoundIDUlSc // Z2SoundObjBase::startSound(JAISoundID, unsigned long, char) asm void Z2SoundObjBase_NS_startSound(void) { @@ -90,7 +97,7 @@ asm void func_802BE5FC(void) { // init__21Z2DopplerSoundObjBaseFP3VecUc // Z2DopplerSoundObjBase::init(Vec*, unsigned char) -asm void func_802BE65C(void) { +asm void init__21Z2DopplerSoundObjBaseFP3VecUc(Vec* pSoundPos, u8 pNumHandles) { nofralloc #include "Z2AudioLib/Z2SoundObject/asm/func_802BE65C.s" } @@ -123,12 +130,24 @@ asm void Z2SoundObjSimple(void) { #include "Z2AudioLib/Z2SoundObject/asm/func_802BE844.s" } +#ifdef NONMATCHING // init__16Z2SoundObjSimpleFP3VecUc // Z2SoundObjSimple::init(Vec*, unsigned char) -asm void func_802BE880(void) { +void Z2SoundObjSimple::init(Vec* pSoundPos, u8 pNumHandles) { + // i would write + // Z2SoundObjBase::init(pSoundPos, pNumHandles); + // but MWCC says "illegal use of non-static member" + // was calling like this not in C++98? + + // and this doesn't match + ((Z2SoundObjBase*)this)->init(pSoundPos, pNumHandles); +} +#else +asm void Z2SoundObjSimple::init(Vec* pSoundPos, u8 pNumHandles) { nofralloc #include "Z2AudioLib/Z2SoundObject/asm/func_802BE880.s" } +#endif // startSound__16Z2SoundObjSimpleF10JAISoundIDUlSc // Z2SoundObjSimple::startSound(JAISoundID, unsigned long, char) |
