summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2025-06-15 21:22:07 +0200
committerrobojumper <robojumper@gmail.com>2025-09-13 10:51:36 +0200
commitf6e5303ea2b8f0b8aa78d03492575c072af65aca (patch)
tree8ac8f51148886aec69bac1ba191c338ac4624071 /include
parent6cb7f3bfdc8b4f69e2443fad99fb7d807cf9ea7c (diff)
d_snd_anim_sound OK
Diffstat (limited to 'include')
-rw-r--r--include/d/snd/d_snd_anim_sound.h30
-rw-r--r--include/d/snd/d_snd_small_effect_mgr.h19
-rw-r--r--include/d/snd/d_snd_source.h4
-rw-r--r--include/d/snd/d_snd_source_mgr.h3
-rw-r--r--include/d/snd/d_snd_state_mgr.h9
-rw-r--r--include/nw4r/snd/snd_AnimSound.h67
6 files changed, 122 insertions, 10 deletions
diff --git a/include/d/snd/d_snd_anim_sound.h b/include/d/snd/d_snd_anim_sound.h
new file mode 100644
index 00000000..c54a49e9
--- /dev/null
+++ b/include/d/snd/d_snd_anim_sound.h
@@ -0,0 +1,30 @@
+#ifndef D_SND_ANIM_SOUND_H
+#define D_SND_ANIM_SOUND_H
+
+#include "d/snd/d_snd_types.h"
+#include "nw4r/snd/snd_AnimSound.h"
+
+// Could also inherit from AnimSound
+class dSndAnimSound_c {
+public:
+ dSndAnimSound_c(dSoundSource_c *source);
+ void setData(const void *data);
+ void setFrame(f32 frame);
+ void resetFrame(f32 frame);
+ void setRate(f32 rate);
+
+ void setCallback(dSoundSource_c *source);
+ void setCallback(nw4r::snd::AnimSound::Callback cb, void *userData);
+
+private:
+ static void animCallback(int, s32, const char *, UNKWORD, void *userData);
+
+ /* 0x00 */ nw4r::snd::AnimSound mSound;
+ /* 0x90 */ const void *mpData;
+ /* 0x94 */ f32 field_0x94;
+ /* 0x98 */ f32 field_0x98;
+ /* 0x9C */ bool mNeedFrameReset;
+ /* 0xA0 */ nw4r::snd::AnimSound::PlayDirection mDirection;
+};
+
+#endif
diff --git a/include/d/snd/d_snd_small_effect_mgr.h b/include/d/snd/d_snd_small_effect_mgr.h
index b77ec967..cb40ed80 100644
--- a/include/d/snd/d_snd_small_effect_mgr.h
+++ b/include/d/snd/d_snd_small_effect_mgr.h
@@ -29,7 +29,14 @@ public:
dSndSmallEffectMgr_c();
+ void initialize();
void calc();
+ void calcTimer();
+
+ void stopAllSound(s32 fadeFrames);
+ void stopAllSoundDemoRelated(s32 fadeFrames); // TODO: better name
+ void stopAllSoundExceptEvent(s32 fadeFrames);
+ void stopAllSoundExceptEffectOrLink(s32 fadeFrames);
bool playSound(u32 soundId);
// used for clawshots cursor, pan depends on where on the screen
@@ -47,7 +54,17 @@ public:
bool playDowsingPingSound(f32 volume, f32 pitch);
bool holdDowsingNearestSound();
-
+
+ bool playSirenCountdownSound(s32 timer);
+ bool playMinigameCountdownSound();
+ bool playMinigameTimeUpSound(s32 timer);
+ bool playMinigameStartSound();
+ bool playMinigameFinishSound();
+ bool playMinigameFinishWhistleSound();
+ bool playMinigameScoreUpSound(s32 param);
+ bool playMinigameScoreDownSound();
+ bool playMinigameMusasabiSound(s32 count);
+
bool playSkbSound(u32 soundId);
bool playButtonPressSoundWhenAdvancingTextBoxes(f32);
diff --git a/include/d/snd/d_snd_source.h b/include/d/snd/d_snd_source.h
index a2851e76..68429f14 100644
--- a/include/d/snd/d_snd_source.h
+++ b/include/d/snd/d_snd_source.h
@@ -63,7 +63,9 @@ public:
virtual void d_s_vt_0x1D4();
virtual void d_s_vt_0x1D8();
virtual void d_s_vt_0x1DC();
- virtual void d_s_vt_0x1E0();
+ virtual void onAnimSoundEvent(UNKWORD arg) {
+ field_0x154 = arg;
+ }
virtual void d_s_vt_0x1E4();
virtual u32 d_s_vt_0x1E8(u32 soundId);
diff --git a/include/d/snd/d_snd_source_mgr.h b/include/d/snd/d_snd_source_mgr.h
index 272c75a2..fa890401 100644
--- a/include/d/snd/d_snd_source_mgr.h
+++ b/include/d/snd/d_snd_source_mgr.h
@@ -26,6 +26,9 @@ public:
return GetInstance()->mpBoomerangSource;
}
+ void stopAllSound();
+ void stopAllNonPlayerSound();
+
private:
static bool isCertainEnemyType(dSoundSource_c *source);
void removeSourceFromList(dSoundSource_c *source, nw4r::ut::List *list);
diff --git a/include/d/snd/d_snd_state_mgr.h b/include/d/snd/d_snd_state_mgr.h
index 7a5356a4..bb068732 100644
--- a/include/d/snd/d_snd_state_mgr.h
+++ b/include/d/snd/d_snd_state_mgr.h
@@ -36,6 +36,10 @@ public:
static bool isInStage(const char *stageName);
+ s32 getStageId_0x044() const {
+ return field_0x044;
+ }
+
u32 getField_0x11C() const {
return field_0x11C;
}
@@ -62,6 +66,11 @@ public:
void setFlowEvent(u32 eventId);
+ const char *getCurrentStageMusicDemoName() const;
+ bool isInDemo() const {
+ return getCurrentStageMusicDemoName() != nullptr;
+ }
+
private:
u32 getStageTypeFlags(const char *stageName) const;
// ET, FS, or corresponding Sky Keep rooms
diff --git a/include/nw4r/snd/snd_AnimSound.h b/include/nw4r/snd/snd_AnimSound.h
index 37d66c2f..e8c6627b 100644
--- a/include/nw4r/snd/snd_AnimSound.h
+++ b/include/nw4r/snd/snd_AnimSound.h
@@ -91,7 +91,7 @@ public:
bool Setup(const void *data);
void Shutdown();
- void ResetFrame(f32, int);
+ void ResetFrame(f32, int cycle);
void UpdateFrame(f32 frame, PlayDirection dir);
void UpdateForward(f32 frame);
void UpdateBackward(f32 frame);
@@ -103,27 +103,78 @@ public:
void StartEvent(const AnimEvent *, bool);
void HoldEvent(const AnimEvent *, bool);
void StopEvent(const AnimEvent *);
- bool IsPlayableLoopCount(const nw4r::snd::detail::AnimEventFrameInfo&);
+ bool IsPlayableLoopCount(const nw4r::snd::detail::AnimEventFrameInfo &);
+ typedef void (*Callback)(int, s32, const char *, UNKWORD, void *userData);
- typedef void (*Callback)(int, s32, const char *, UNKWORD, UNKWORD);
+ void SetCallback(Callback cb, void *userData) {
+ mCallback = cb;
+ mUserData = userData;
+ }
+
+ u32 GetAnimDuration() const {
+ return mReader.GetAnimDuration();
+ }
private:
/* 0x00 */ SoundStartable &mStartable;
/* 0x04 */ AnimSoundFileReader mReader;
- /* 0x0C */ f32 field_0x0C;
+ /* 0x0C */ f32 mCurrentFrame;
/* 0x10 */ AnimEventPlayer *mpSounds;
/* 0x14 */ int mNumSounds;
/* 0x18 */ bool mIsActive;
- /* 0x19 */ u8 field_0x19;
- /* 0x1A */ u8 field_0x1A;
- /* 0x1C */ UNKWORD field_0x1C;
+ /* 0x19 */ bool mNeedFrameReset;
+ /* 0x1A */ bool mNeedTriggerEventsAtCurrentFrame;
+ /* 0x1C */ int mCycleCounter;
/* 0x20 */ Callback mCallback;
- /* 0x24 */ UNKWORD field_0x24;
+ /* 0x24 */ void *mUserData;
/* 0x28 */ f32 field_0x28;
/* 0x2C */ f32 mVariableValue;
};
} // namespace detail
+
+// Not sure about this one but it appears game code isn't meant to access the "detail"
+// namespace so I guess some way for game code to use the above things need to exist
+class AnimSound {
+public:
+ AnimSound(SoundStartable &startable) : mImpl(startable, mPlayers, 8) {}
+
+ enum PlayDirection {
+ FORWARD,
+ BACKWARD,
+ };
+
+ typedef void (*Callback)(int, s32, const char *, UNKWORD, void *userData);
+
+ bool Setup(const void *data) {
+ return mImpl.Setup(data);
+ }
+
+ void UpdateFrame(f32 frame, PlayDirection dir) {
+ mImpl.UpdateFrame(frame, (detail::AnimSoundImpl::PlayDirection)dir);
+ }
+
+ void ResetFrame(f32 frame, int cycle) {
+ mImpl.ResetFrame(frame, cycle);
+ }
+
+ void Shutdown() {
+ mImpl.Shutdown();
+ }
+
+ void SetCallback(Callback cb, void *userData) {
+ mImpl.SetCallback(cb, userData);
+ }
+
+ u32 GetAnimDuration() const {
+ return mImpl.GetAnimDuration();
+ }
+
+private:
+ /* 0x00 */ detail::AnimSoundImpl mImpl;
+ /* 0x30 */ detail::AnimEventPlayer mPlayers[8];
+};
+
} // namespace snd
} // namespace nw4r