diff options
| author | randomsalience <69010899+randomsalience@users.noreply.github.com> | 2023-10-26 08:41:03 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-26 15:41:03 +0300 |
| commit | b13ff9e3d0046fd27d918215557affce4020143d (patch) | |
| tree | 469bc85e61853c4c1ce919ce1212363d6427195e /include | |
| parent | e2d51bf9564c60435cfd5ee3fc05adddc8db04c7 (diff) | |
Z2SoundObject, JAUSoundAnimator OK, work on Z2SoundHandles (#1968)
* d_a_tag_evtarea mostly done, work on d_a_npc
* work on d_a_npc_ash
* work on Z2SoundHandles
* Z2SoundObject, JAUSoundAnimator OK
* Update Progress.md
---------
Co-authored-by: randomsalience <randomsalience@gmail.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/JSystem/JAudio2/JAISeMgr.h | 1 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAISound.h | 12 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAUAudibleParam.h | 4 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAUSoundAnimator.h | 104 | ||||
| -rw-r--r-- | include/JSystem/JGeometry.h | 10 | ||||
| -rw-r--r-- | include/JSystem/JSupport/JSUList.h | 2 | ||||
| -rw-r--r-- | include/Z2AudioLib/Z2SeMgr.h | 2 | ||||
| -rw-r--r-- | include/Z2AudioLib/Z2SoundHandles.h | 14 | ||||
| -rw-r--r-- | include/Z2AudioLib/Z2SoundObject.h | 69 |
9 files changed, 177 insertions, 41 deletions
diff --git a/include/JSystem/JAudio2/JAISeMgr.h b/include/JSystem/JAudio2/JAISeMgr.h index bc607e809e..3fe166473e 100644 --- a/include/JSystem/JAudio2/JAISeMgr.h +++ b/include/JSystem/JAudio2/JAISeMgr.h @@ -48,6 +48,7 @@ public: int getMaxActiveSe() const { return mMaxActiveSe; } void setMaxActiveSe(int se) { mMaxActiveSe = se; } void setMaxInactiveSe(int se) { mMaxInactiveSe = se; } + JSUList<JAISe>* getSeList() { return &mSeList; } int getNumSe() const { return mSeList.getNumLinks(); } JAIAudience* getAudience() { return (JAIAudience*)field_0x4.field_0x0; } diff --git a/include/JSystem/JAudio2/JAISound.h b/include/JSystem/JAudio2/JAISound.h index ff737fd885..5a60a6eae2 100644 --- a/include/JSystem/JAudio2/JAISound.h +++ b/include/JSystem/JAudio2/JAISound.h @@ -90,8 +90,7 @@ struct JAISoundStatus_ { struct { u8 flag1 : 1; u8 flag2 : 1; - u8 flag3 : 1; - u8 flag4 : 1; + u8 animationState : 2; u8 flag5 : 1; u8 flag6 : 1; u8 flag7 : 1; @@ -227,9 +226,16 @@ public: virtual bool JAISound_tryDie_() = 0; JAISoundID getID() const; + u8 getAnimationState() const { return status_.state.flags.animationState; } + bool isAnimated() const { return getAnimationState() != 0; } + void setAnimationState(u8 pState) { + status_.state.flags.animationState = pState; + } u32 getUserData() const { return status_.user_data; } + void setUserData(u32 pUserData) { status_.user_data = pUserData; } + JAIAudible* getAudible() const { return audible_; } bool isHandleAttached() const { return handle_ != NULL; } - + bool hasLifeTime() const { return status_.field_0x1.flags.flag2; } void removeLifeTime_() { status_.field_0x1.flags.flag1 = false; } void stop_JAISound_() { status_.state.flags.flag5 = 0; diff --git a/include/JSystem/JAudio2/JAUAudibleParam.h b/include/JSystem/JAudio2/JAUAudibleParam.h index b51b419c6b..079864c06e 100644 --- a/include/JSystem/JAudio2/JAUAudibleParam.h +++ b/include/JSystem/JAudio2/JAUAudibleParam.h @@ -21,7 +21,9 @@ struct JAUAudibleParam { u8 b0_5 : 1; u8 b0_6 : 1; u8 b0_7 : 1; - u8 b1; + u8 b1_0 : 1; + u8 b1_1 : 1; + u8 b1_2_7 : 6; u8 b2; u8 b3; } bytes; diff --git a/include/JSystem/JAudio2/JAUSoundAnimator.h b/include/JSystem/JAudio2/JAUSoundAnimator.h index e1b6ce08f0..b6dc7204a6 100644 --- a/include/JSystem/JAudio2/JAUSoundAnimator.h +++ b/include/JSystem/JAudio2/JAUSoundAnimator.h @@ -1,5 +1,109 @@ #ifndef JAUSOUNDANIMATOR_H #define JAUSOUNDANIMATOR_H +#include "JSystem/JAudio2/JAISound.h" +#include "dolphin/types.h" + +class JAUSoundAnimation; + +class JAUSoundAnimationSound { +public: + bool playsOnlyForward() const { return (mFlags & 1) != 0; } + bool playsOnlyReverse() const { return (mFlags & 2) != 0; } + bool stopsWhenAnimationChanges() const { return (mFlags & 4) != 0; } + bool playsOnlyOnce() const { return (mFlags & 8) != 0; } + bool stopsWhenNoteOff() const { return (mFlags & 0x10) != 0; } + bool stopsWhenSpeedIsZero() const { return (mFlags & 0x20) != 0; } + bool setsLifeTime() const { return (mFlags & 0x40) != 0; } + bool playsAtIntervals() const { return (mFlags & 0x80) != 0; } + + bool isNoting(f32 param_0) const { + if (field_0x04 == field_0x08) { + return true; + } + if (field_0x04 > field_0x08) { + if (field_0x08 <= param_0 && param_0 < field_0x04) { + return true; + } + } else { + if (field_0x04 <= param_0 && param_0 < field_0x08) { + return true; + } + } + return false; + } + + bool isNotingOn(f32 param_0, bool param_1) const { + if (setsLifeTime()) { + return isNoting(param_0); + } + if (param_1) { + return param_0 <= field_0x04; + } else { + return param_0 >= field_0x04; + } + } + + bool isNotingOff(f32 param_0, bool param_1) const { + if (setsLifeTime()) { + return !isNoting(param_0); + } + if (field_0x04 == field_0x08) { + return false; + } + if (param_1) { + return param_0 <= field_0x08; + } else { + return param_0 >= field_0x08; + } + } + + /* 0x00 */ JAISoundID mSoundId; + /* 0x04 */ f32 field_0x04; + /* 0x08 */ f32 field_0x08; + /* 0x0C */ f32 field_0x0c; + /* 0x10 */ u32 mFlags; + /* 0x14 */ u8 field_0x14; + /* 0x15 */ u8 field_0x15; + /* 0x16 */ u8 field_0x16; + /* 0x17 */ u8 field_0x17; + /* 0x18 */ u8 field_0x18; + /* 0x19 */ u8 field_0x19; + /* 0x1A */ s8 field_0x1a; + /* 0x1B */ u8 unk_0x1b[5]; +}; /* size 0x20 */ + +class JAUSoundAnimationControl { +public: + virtual ~JAUSoundAnimationControl() = 0; + virtual JAUSoundAnimationSound* getSound(const JAUSoundAnimation*, int) = 0; + virtual u16 getNumSounds(const JAUSoundAnimation*) = 0; +}; + +class JAUSoundAnimation { +public: + /* 802A6F70 */ int getStartSoundIndex(f32) const; + /* 802A7044 */ int getEndSoundIndex(f32) const; + + u16 getNumSounds() const { + if (mControl != NULL) { + return mControl->getNumSounds(this); + } else { + return mNumSounds; + } + } + + const JAUSoundAnimationSound* getSound(int i_index) const { + if (mControl != NULL) { + return mControl->getSound(this, i_index); + } else { + return &mSounds + i_index; + } + } + + /* 0x0 */ u16 mNumSounds; + /* 0x4 */ JAUSoundAnimationControl* mControl; + /* 0x8 */ JAUSoundAnimationSound mSounds; // actually an array +}; #endif /* JAUSOUNDANIMATOR_H */ diff --git a/include/JSystem/JGeometry.h b/include/JSystem/JGeometry.h index ac4857ec30..9d24942e3f 100644 --- a/include/JSystem/JGeometry.h +++ b/include/JSystem/JGeometry.h @@ -122,6 +122,16 @@ struct TVec3<f32> { }; } + inline TVec3<f32>& operator=(const Vec& b) { + setTVec3f(&b.x, &this->x); + return *this; + } + + // inline TVec3<f32>& operator=(const TVec3<f32>& b) { + // setTVec3f(&b.x, &this->x); + // return *this; + // } + inline TVec3<f32>& operator+=(const TVec3<f32>& b) { add(b); return *this; diff --git a/include/JSystem/JSupport/JSUList.h b/include/JSystem/JSupport/JSUList.h index e117824b06..2c045ef089 100644 --- a/include/JSystem/JSupport/JSUList.h +++ b/include/JSystem/JSupport/JSUList.h @@ -97,6 +97,8 @@ public: JSULink<T>* getLast() const { return (JSULink<T>*)getLastLink(); } + JSULink<T>* getNth(int index) { return (JSULink<T>*)getNthLink(index); } + JSULink<T>* getEnd() const { return NULL; } u32 getNumLinks() const { return this->JSUPtrList::getNumLinks(); } diff --git a/include/Z2AudioLib/Z2SeMgr.h b/include/Z2AudioLib/Z2SeMgr.h index d0fce310dc..d7c0ba3330 100644 --- a/include/Z2AudioLib/Z2SeMgr.h +++ b/include/Z2AudioLib/Z2SeMgr.h @@ -53,7 +53,7 @@ public: /* 802ADFF4 */ void setMultiTriggerSE(u32, Vec*, s8); /* 802AE184 */ void processSeFramework(); /* 802AE524 */ void isLevelSe(JAISoundID); - /* 802AE5B0 */ void isSoundCulling(JAISoundID); + /* 802AE5B0 */ bool isSoundCulling(JAISoundID); /* 802B9AC4 */ void resetCrowdSize(); private: diff --git a/include/Z2AudioLib/Z2SoundHandles.h b/include/Z2AudioLib/Z2SoundHandles.h index 7e1b4b91ef..4ff460bc8a 100644 --- a/include/Z2AudioLib/Z2SoundHandles.h +++ b/include/Z2AudioLib/Z2SoundHandles.h @@ -3,9 +3,14 @@ #include "JSystem/JAudio2/JAISoundHandles.h" #include "JSystem/JSupport/JSUList.h" +#include "JSystem/JAudio2/JASHeapCtrl.h" #include "dolphin/types.h" -class Z2SoundHandlePool : public JAISoundHandle, JSULink<Z2SoundHandlePool> {}; +class Z2SoundHandlePool : public JAISoundHandle, public JSULink<Z2SoundHandlePool> { // , public JASPoolAllocObject<Z2SoundHandlePool> { +public: + Z2SoundHandlePool() : JAISoundHandle(), JSULink<Z2SoundHandlePool>(this) {} + ~Z2SoundHandlePool() {} +}; class Z2SoundHandles : protected JSUList<Z2SoundHandlePool> { public: @@ -14,8 +19,8 @@ public: void initHandlesPool(u8 pNumHandles); void deleteHandlesPool(); - void getFreeHandle(); - void getLowPrioSound(JAISoundID); + JAISoundHandle* getFreeHandle(); + JAISoundHandle* getLowPrioSound(JAISoundID pSoundId); bool isActive() const; @@ -26,7 +31,8 @@ public: void setPos(const JGeometry::TVec3<f32>& pos); - u32 getNumHandles() const { return this->getNumLinks(); } + int getNumHandles() const { return getNumLinks(); } + JAISoundHandle* getHandle(int index) { return (Z2SoundHandlePool*)getNth(index); } private: /* 0xC */ u8 mNumHandles; diff --git a/include/Z2AudioLib/Z2SoundObject.h b/include/Z2AudioLib/Z2SoundObject.h index 26f2829bcc..a022ba4abc 100644 --- a/include/Z2AudioLib/Z2SoundObject.h +++ b/include/Z2AudioLib/Z2SoundObject.h @@ -2,11 +2,10 @@ #define Z2SOUNDOBJECT_H #include "Z2AudioLib/Z2SoundHandles.h" +#include "JSystem/JAudio2/JAUSoundAnimator.h" #include "dolphin/types.h" -struct Z2SoundStarter; - -struct JAUSoundAnimationSound {}; +class Z2SoundStarter; class Z2SoundObjBase : protected Z2SoundHandles { public: @@ -14,7 +13,7 @@ public: ~Z2SoundObjBase(); void deleteObject(); - void startCollisionSE(u32, u32, Z2SoundObjBase*); + JAISoundHandle* startCollisionSE(u32, u32, Z2SoundObjBase*); bool isAlive() const { return mIsInitialized; } void setSoundStarter(Z2SoundStarter* i_soundStarter) { mSoundStarter = i_soundStarter; } @@ -23,13 +22,13 @@ public: virtual void dispose(); virtual bool stopOK(Z2SoundHandlePool& pool); virtual void init(Vec* pSoundPos, u8 pNumHandles); - virtual void startSound(JAISoundID, u32, s8); - virtual void startLevelSound(JAISoundID, u32, s8); + virtual JAISoundHandle* startSound(JAISoundID, u32, s8); + virtual JAISoundHandle* startLevelSound(JAISoundID, u32, s8); /* 0x14 */ Z2SoundStarter* mSoundStarter; - /* 0x18 */ Vec* mSoundPos; + /* 0x18 */ JGeometry::TVec3<f32>* mSoundPos; /* 0x1C */ u16 field_0x1c; - /* 0x1E */ u8 field_0x1e; + /* 0x1E */ s8 field_0x1e; /* 0x1F */ bool mIsInitialized; }; @@ -38,10 +37,9 @@ public: Z2SoundObjSimple(); ~Z2SoundObjSimple(); - virtual void temp(); // temp to build OK, remove later virtual void init(Vec* pSoundPos, u8 pNumHandles); - virtual void startSound(JAISoundID, u32, s8); - virtual void startLevelSound(JAISoundID, u32, s8); + virtual JAISoundHandle* startSound(JAISoundID, u32, s8); + virtual JAISoundHandle* startLevelSound(JAISoundID, u32, s8); }; class Z2SoundObjAnime : public Z2SoundObjBase { @@ -53,42 +51,49 @@ public: /* 802BF304 */ void updateSoundLifeTime_(f32, f32); /* 802BF660 */ void startSoundInner(JGeometry::TVec3<f32> const&, f32, Z2SoundStarter*, u32, s8); - /* 802BF890 */ void getSoundID(JAUSoundAnimationSound const*, JGeometry::TVec3<f32> const&, - f32); - /* 802BF898 */ void playsSound(JAUSoundAnimationSound const*, JGeometry::TVec3<f32> const&, + /* 802BF890 */ u32 getSoundID(JAUSoundAnimationSound const*, + JGeometry::TVec3<f32> const&, f32); + /* 802BF898 */ bool playsSound(JAUSoundAnimationSound const*, JGeometry::TVec3<f32> const&, f32); /* 802BEBDC */ virtual void init(Vec*, u8); - void stopAnime() { animation_ = NULL; } - - /* 0x20 */ void* animation_; // JAUSoundAnimation* + void stopAnime() { mpAnimation = NULL; } + void setLoopStartFrame(f32 i_frame) { + mStartSoundFrame = i_frame; + mStartSoundIndex = mpAnimation->getStartSoundIndex(i_frame); + } + void setLoopEndFrame(f32 i_frame) { + mEndSoundFrame = i_frame; + mEndSoundIndex = mpAnimation->getEndSoundIndex(i_frame); + } + void setLoopFrame(f32 i_startFrame, f32 i_endFrame) { + setLoopStartFrame(i_startFrame); + setLoopEndFrame(i_endFrame); + } + + /* 0x20 */ JAUSoundAnimation* mpAnimation; /* 0x24 */ int field_0x24; - /* 0x28 */ float field_0x28; - /* 0x2C */ float field_0x2c; - /* 0x30 */ float field_0x30; - /* 0x34 */ int field_0x34; - /* 0x38 */ int field_0x38; + /* 0x28 */ f32 mCurSoundFrame; + /* 0x2C */ f32 mStartSoundFrame; + /* 0x30 */ f32 mEndSoundFrame; + /* 0x34 */ int mStartSoundIndex; + /* 0x38 */ int mEndSoundIndex; /* 0x3C */ int field_0x3c; - /* 0x40 */ int curSoundIndex_; - /* 0x44 */ bool field_0x44; + /* 0x40 */ int mCurSoundIndex; + /* 0x44 */ bool mReverse; }; -class Z2DopplerSoundObjBase : public Z2SoundHandles { +class Z2DopplerSoundObjBase : public Z2SoundObjBase { public: Z2DopplerSoundObjBase(); ~Z2DopplerSoundObjBase(); virtual void framework(u32, s8); virtual void init(Vec*, u8); - virtual void startSound(JAISoundID, u32, s8); - virtual void startLevelSound(JAISoundID, u32, s8); + virtual JAISoundHandle* startSound(JAISoundID, u32, s8); + virtual JAISoundHandle* startLevelSound(JAISoundID, u32, s8); - /* 0x14 */ Z2SoundStarter* field_0x14; - /* 0x18 */ JGeometry::TVec3<f32>* field_0x18; - /* 0x1C */ u16 field_0x1c; - /* 0x1E */ u8 field_0x1e; - /* 0x1F */ bool field_0x1f; /* 0x20 */ JGeometry::TVec3<f32> field_0x20; /* 0x2C */ JGeometry::TVec3<f32> field_0x2c; }; |
