NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
snd_AnimSound.h
1/* Only implemented to the extent necessary to match data sections. */
2
3#include "nw4r/snd/snd_AnimSoundReader.h"
4#include "nw4r/snd/snd_BasicSound.h"
5#include "nw4r/snd/snd_SoundHandle.h"
6#include "nw4r/snd/snd_SoundStartable.h"
7
8// Class and non-inlined function names from InazumaWii
9// Names of automatically inlined functions from BBA
10
11namespace nw4r {
12namespace snd {
13namespace detail {
14
15class AnimEventPlayer {
16public:
17 AnimEventPlayer();
18 ~AnimEventPlayer();
19
20 SoundHandle *GetHandle() {
21 return &mHandle;
22 }
23
24 bool IsAttachedSound() const {
25 return mHandle.IsAttachedSound();
26 }
27
28 bool IsCurrentEvent(const AnimEvent *event) const {
29 return event == mpEvent;
30 }
31
32 int GetPriority() const {
33 if (!IsAttachedSound()) {
34 return 0;
35 }
36 return mHandle.detail_GetAttachedSound()->GetPriority();
37 }
38
39 bool IsRunning() const {
40 return mIsRunning;
41 }
42
43 void UpdateFrame();
44
45 void ForceStop();
46
47 void StopEvent(const AnimEvent *event) {
48 if (mpEvent == event) {
49 ForceStop();
50 }
51 }
52
53 void SetVolume(f32 volume) {
54 if (IsAttachedSound()) {
55 mHandle.detail_GetAttachedSound()->SetVolume(volume, 0);
56 }
57 }
58
59 void SetPitch(f32 pitch) {
60 if (IsAttachedSound()) {
61 mHandle.detail_GetAttachedSound()->SetPitch(pitch);
62 }
63 }
64
65 void StartEvent(const AnimEvent *event, SoundStartable *startable, bool b);
66 void HoldEvent(const AnimEvent *event, SoundStartable *startable, bool b);
67
68 // Not sure about these, this could be related to
69 // InitParam__Q44nw4r3snd6detail15AnimEventPlayerFPCQ44nw4r3snd6detail9AnimEventb
70 // from BBA, but SetVariable is almost certainly an inline (duplicated code)
71 // but the float argument is read from AnimSoundImpl so something seems to have
72 // changed.
73 void SetVolumePitch(const AnimEvent *event, bool b);
74 void SetVariable(const AnimEvent *event, ulong varNo, f32 f);
75
76private:
77 SoundHandle mHandle; // at 0x00
78 const AnimEvent *mpEvent; // at 0x04
79 bool mIsRunning; // at 0x08
80};
81
82class AnimSoundImpl {
83public:
84 enum PlayDirection {
85 FORWARD,
86 BACKWARD,
87 };
88
89 AnimSoundImpl(SoundStartable &startable, AnimEventPlayer *player, int);
90 ~AnimSoundImpl();
91
92 bool Setup(const void *data);
93 void Shutdown();
94 void ResetFrame(f32, int);
95 void UpdateFrame(f32 frame, PlayDirection dir);
96 void UpdateForward(f32 frame);
97 void UpdateBackward(f32 frame);
98 void UpdateOneFrame(s32 duration, PlayDirection direction);
99 void UpdateTrigger(const AnimEventRef *, s32, PlayDirection);
100 void UpdateForwardRange(const AnimEventRef *, s32);
101 void UpdateBackwardRange(const AnimEventRef *, s32);
102
103 void StartEvent(const AnimEvent *, bool);
104 void HoldEvent(const AnimEvent *, bool);
105 void StopEvent(const AnimEvent *);
106 bool IsPlayableLoopCount(const nw4r::snd::detail::AnimEventFrameInfo&);
107
108
109 typedef void (*Callback)(int, s32, const char *, UNKWORD, UNKWORD);
110
111private:
112 /* 0x00 */ SoundStartable &mStartable;
113 /* 0x04 */ AnimSoundFileReader mReader;
114 /* 0x0C */ f32 field_0x0C;
115 /* 0x10 */ AnimEventPlayer *mpSounds;
116 /* 0x14 */ int mNumSounds;
117 /* 0x18 */ bool mIsActive;
118 /* 0x19 */ u8 field_0x19;
119 /* 0x1A */ u8 field_0x1A;
120 /* 0x1C */ UNKWORD field_0x1C;
121 /* 0x20 */ Callback mCallback;
122 /* 0x24 */ UNKWORD field_0x24;
123 /* 0x28 */ f32 field_0x28;
124 /* 0x2C */ f32 mVariableValue;
125};
126
127} // namespace detail
128} // namespace snd
129} // namespace nw4r