diff options
| author | robojumper <robojumper@gmail.com> | 2025-06-13 16:20:06 +0200 |
|---|---|---|
| committer | robojumper <robojumper@gmail.com> | 2025-09-13 10:49:06 +0200 |
| commit | f56b72a2e0a938f95e2a5c3a14767bdfd0e2d54a (patch) | |
| tree | de4bf641ecaa7cba55d3cbea7f797a6e81c10493 /include/d | |
| parent | f9e95f9bb03b9474bbee85b03121c9b4e158aea4 (diff) | |
let's go with the distant sound name for now
Diffstat (limited to 'include/d')
| -rw-r--r-- | include/d/snd/d_snd_3d_actor.h | 11 | ||||
| -rw-r--r-- | include/d/snd/d_snd_distant_sound_actor.h | 53 | ||||
| -rw-r--r-- | include/d/snd/d_snd_distant_sound_actor_pool.h | 35 | ||||
| -rw-r--r-- | include/d/snd/d_snd_misc.h | 4 | ||||
| -rw-r--r-- | include/d/snd/d_snd_source.h | 17 | ||||
| -rw-r--r-- | include/d/snd/d_snd_source_enums.h | 3 | ||||
| -rw-r--r-- | include/d/snd/d_snd_state_mgr.h | 4 |
7 files changed, 115 insertions, 12 deletions
diff --git a/include/d/snd/d_snd_3d_actor.h b/include/d/snd/d_snd_3d_actor.h index 6f3ad6d4..8f00235d 100644 --- a/include/d/snd/d_snd_3d_actor.h +++ b/include/d/snd/d_snd_3d_actor.h @@ -16,9 +16,9 @@ public: return true; } - virtual void d_vt_0x34(const nw4r::math::VEC3 &); + virtual void setPosition(const nw4r::math::VEC3 &); - virtual void d_vt_0x38(bool flag, int fadeFrames) = 0; + virtual void setPause(bool flag, int fadeFrames) = 0; virtual UNKWORD d_vt_0x3C() { return 0; @@ -63,6 +63,11 @@ public: return mDistanceToListener; } + const dSndSourceParam *getSourceParam() const { + return mpSourceParam; + } + void setSourceParam(const dSndSourceParam *param); + bool hasPlayingSounds() const; bool isPlayingSound(u32 id); @@ -74,7 +79,7 @@ protected: /* 0x7D */ u8 a_field_0x7D; /* 0x7E */ u8 a_field_0x7E; /* 0x7F */ u8 a_field_0x7F; - /* 0x80 */ u8 a_field_0x80; + /* 0x80 */ u8 mIsPaused; /* 0x84 */ f32 a_field_0x84; /* 0x88 */ f32 a_field_0x88; /* 0x8C */ f32 a_field_0x8C; diff --git a/include/d/snd/d_snd_distant_sound_actor.h b/include/d/snd/d_snd_distant_sound_actor.h new file mode 100644 index 00000000..ee805f7f --- /dev/null +++ b/include/d/snd/d_snd_distant_sound_actor.h @@ -0,0 +1,53 @@ +#ifndef D_SND_DISTANT_SOUND_ACTOR_H +#define D_SND_DISTANT_SOUND_ACTOR_H + +#include "common.h" +#include "d/snd/d_snd_3d_actor.h" +#include "m/m_vec.h" +#include "nw4r/math/math_types.h" +#include "nw4r/snd/snd_SoundHandle.h" +#include "nw4r/ut/ut_list.h" + +class dSoundSource_c; + +/** + * A sound actor to be borrowed by sound sources when they want to play + * sounds at a specific position. + * + * Sound sources correspond to actors, but e.g. projectile hit effects, grass + * cutting sounds, sword hit effects, ... have to be played where the hit occurred. + * This pool allows sound sources to borrow sound actors for these purposes. + */ +class dSndDistantSoundActor_c : public dSnd3DActor_c { +public: + dSndDistantSoundActor_c(); + virtual void setPause(bool flag, int fadeFrames) override; + virtual void d_vt_0x58() override; + virtual void d_vt_0x5C() override; + + void initSource(dSoundSource_c *pSource); + void setSourceDirectly(dSoundSource_c *pSource); + void loadDefaultParam(); + void detachFromSource(); + + void updatePosition(); + + bool startSound(u32 soundId, const nw4r::math::VEC3 &position, nw4r::snd::SoundHandle *pHandle); + bool holdSound(u32 soundId, const nw4r::math::VEC3 &position, nw4r::snd::SoundHandle *pHandle); + + bool isAttachedSource(dSoundSource_c *source) const { + return mpSoundSource == source; + } + +private: + /* 0x0E4 */ nw4r::ut::Node mDistantLink; + /* 0x0EC */ u8 _0x0EC[0x0F4 - 0x0EC]; + /* 0x0F4 */ UNKWORD field_0x0F4; + /* 0x0F8 */ dSoundSource_c *mpSoundSource; + /* 0x0FC */ nw4r::snd::SoundHandle mSoundHandle; + /* 0x100 */ nw4r::snd::SoundHandle *mpSoundHandle; + /* 0x104 */ u8 field_0x104; + /* 0x105 */ bool mUseSourcePosition; +}; + +#endif diff --git a/include/d/snd/d_snd_distant_sound_actor_pool.h b/include/d/snd/d_snd_distant_sound_actor_pool.h new file mode 100644 index 00000000..303740b4 --- /dev/null +++ b/include/d/snd/d_snd_distant_sound_actor_pool.h @@ -0,0 +1,35 @@ +#ifndef D_SND_DISTANT_SOUND_ACTOR_POOL_H +#define D_SND_DISTANT_SOUND_ACTOR_POOL_H + +#include "common.h" +#include "d/snd/d_snd_misc.h" +#include "d/snd/d_snd_util.h" +#include "d/snd/d_snd_distant_sound_actor.h" +#include "nw4r/ut/ut_list.h" + +SND_DISPOSER_FORWARD_DECL(dSndDistantSoundActorPool_c); + +/** + * A pool for distant sounds actors. Sound sources will borrow + * actors from this pool when they want to play a sound + * at a specific position. + */ +class dSndDistantSoundActorPool_c { + SND_DISPOSER_MEMBERS(dSndDistantSoundActorPool_c); + +public: + dSndDistantSoundActorPool_c(); + + static dSndSourceParam& getSourceParam() { + return sParam; + } + +private: + /* 0x0010 */ dSndDistantSoundActor_c mSounds[64]; + /* 0x4210 */ UNKWORD field_0x4210; + /* 0x4214 */ nw4r::ut::List mList; + + static dSndSourceParam sParam; +}; + +#endif diff --git a/include/d/snd/d_snd_misc.h b/include/d/snd/d_snd_misc.h index f5bfaa7f..3df7709a 100644 --- a/include/d/snd/d_snd_misc.h +++ b/include/d/snd/d_snd_misc.h @@ -11,12 +11,12 @@ struct dSndSourceParam { reset(); } - void reset() { + void reset(f32 value_0x10 = 5000.0f) { field_0x00 = 300.0; field_0x04 = 1000.0f; field_0x08 = 100.0f; field_0x0C = 400.0f; - field_0x10 = 5000.0f; + field_0x10 = value_0x10; } /* 0x00 */ f32 field_0x00; diff --git a/include/d/snd/d_snd_source.h b/include/d/snd/d_snd_source.h index d2db73d0..25d9f5a1 100644 --- a/include/d/snd/d_snd_source.h +++ b/include/d/snd/d_snd_source.h @@ -9,6 +9,7 @@ #include <cstring> class dSndSourceGroup_c; +class dSndDistantSoundActor_c; /** Manages sound relating to a particular actor. */ /** Size: probably 0x15C */ @@ -46,15 +47,17 @@ public: virtual void d_s_vt_0x1AC(); virtual void d_s_vt_0x1B0(); - virtual void d_s_vt_0x1B4(); - virtual void d_s_vt_0x1B8(); - virtual void d_s_vt_0x1BC(); - virtual void d_s_vt_0x1C0(); - virtual void d_s_vt_0x1C4(bool flag, int fadeFrames); + virtual void attachDistantSound(dSndDistantSoundActor_c *); + virtual void detachDistantSound(dSndDistantSoundActor_c *); + virtual void detachAllDistantSounds(); + virtual bool hasDistantSounds() const { + return nw4r::ut::List_GetFirstConst(&mDistantSoundList) != nullptr; + } + virtual void pauseAllDistantSounds(bool flag, int fadeFrames); virtual void d_s_vt_0x1C8(); virtual void d_s_vt_0x1CC(); - virtual void d_vt_0x38(bool flag, int fadeFrames) override; + virtual void setPause(bool flag, int fadeFrames) override; virtual void d_s_vt_0x1D4(); virtual void d_s_vt_0x1D8(); @@ -101,7 +104,7 @@ private: /* 0x104 */ UNKWORD field_0x104; /* 0x108 */ UNKWORD field_0x108; /* 0x10C */ UNKWORD field_0x10C; - /* 0x110 */ nw4r::ut::List field_0x110; // node offset 0xEC + /* 0x110 */ nw4r::ut::List mDistantSoundList; // node offset 0xEC -> dSndDistantSoundActor_c /* 0x11C */ UNKWORD field_0x11C; /* 0x120 */ nw4r::ut::List field_0x120; // node offset 0x4 /* 0x12C */ nw4r::ut::List field_0x12C; // node offset 0x4 diff --git a/include/d/snd/d_snd_source_enums.h b/include/d/snd/d_snd_source_enums.h index 8ce423dc..d1f29cc8 100644 --- a/include/d/snd/d_snd_source_enums.h +++ b/include/d/snd/d_snd_source_enums.h @@ -58,6 +58,9 @@ enum SoundSourceType_e { // 59: ? (9) SND_SOURCE_59 = 59, + + // dSndDistantSoundActor_c, not a real sound source type + SND_SOURCE_DISTANT = 61, }; enum SoundSourceCategory_e { diff --git a/include/d/snd/d_snd_state_mgr.h b/include/d/snd/d_snd_state_mgr.h index d2c54446..7a5356a4 100644 --- a/include/d/snd/d_snd_state_mgr.h +++ b/include/d/snd/d_snd_state_mgr.h @@ -40,6 +40,10 @@ public: return field_0x11C; } + f32 getField_0x49C() const { + return field_0x49C; + } + void resetStageName() { field_0x098 = "EVENT_NONE"; } |
