summaryrefslogtreecommitdiff
path: root/libs/Z2AudioLib/Z2SoundObject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/Z2AudioLib/Z2SoundObject.cpp')
-rw-r--r--libs/Z2AudioLib/Z2SoundObject.cpp97
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)