A bit of dSndSmallEffectMgr_c

This commit is contained in:
robojumper
2025-06-06 14:43:21 +02:00
parent ed0f2fed88
commit 03e518622a
13 changed files with 316 additions and 44 deletions
-18
View File
@@ -4,7 +4,6 @@
#include "common.h"
#include "nw4r/math/math_types.h"
#include "nw4r/snd/snd_Sound3DActor.h"
#include "nw4r/snd/snd_SoundHandle.h"
class dSnd3DActor_c : public nw4r::snd::Sound3DActor {
static const u32 NUM_SOUNDS = 4;
@@ -90,21 +89,4 @@ protected:
/* 0xE0 */ f32 a_field_0xE0;
};
// used at the very least when trying to finish Demise
class IsCurrentSoundIdChecker {
public:
IsCurrentSoundIdChecker(u32 id, bool *pResult) : mSoundId(id), mpResult(pResult) {}
~IsCurrentSoundIdChecker() {}
virtual void operator()(nw4r::snd::SoundHandle &pHandle) {
if (mSoundId == pHandle.GetId()) {
*mpResult = true;
}
}
private:
/* 0x04 */ u32 mSoundId;
/* 0x08 */ bool *mpResult;
};
#endif
+34
View File
@@ -70,4 +70,38 @@ private:
/* 0x24 */ u32 *mpCounter4;
};
// used at the very least when trying to finish Demise
class IsCurrentSoundIdChecker {
public:
IsCurrentSoundIdChecker(u32 id, bool *pResult) : mSoundId(id), mpResult(pResult) {}
~IsCurrentSoundIdChecker() {}
virtual void operator()(nw4r::snd::SoundHandle &pHandle) {
if (mSoundId == pHandle.GetId()) {
*mpResult = true;
}
}
private:
/* 0x04 */ u32 mSoundId;
/* 0x08 */ bool *mpResult;
};
class SoundStopper {
public:
SoundStopper(u32 id, s32 fadeFrames) : mSoundId(id), mFadeFrames(fadeFrames) {}
~SoundStopper() {}
virtual void operator()(nw4r::snd::SoundHandle &pHandle) {
if (mSoundId == pHandle.GetId()) {
pHandle.Stop(mFadeFrames);
}
}
private:
/* 0x04 */ u32 mSoundId;
/* 0x08 */ s32 mFadeFrames;
};
#endif
+1
View File
@@ -25,6 +25,7 @@ public:
void calc();
static const s32 sNumPlayers;
static const s32 sPlayerMax;
nw4r::snd::SoundPlayer *getPlayer1(u32) const;
nw4r::snd::SoundPlayer *getPlayer2(u32) const;
+31 -6
View File
@@ -1,6 +1,7 @@
#ifndef D_SND_SMALL_EFFECT_MGR_H
#define D_SND_SMALL_EFFECT_MGR_H
#include "d/snd/d_snd_source.h"
#include "d/snd/d_snd_util.h"
#include "d/snd/d_snd_wzsound.h" // IWYU pragma: export
#include "nw4r/snd/snd_SoundHandle.h"
@@ -17,15 +18,39 @@ class dSndSmallEffectMgr_c {
public:
dSndSmallEffectMgr_c();
void playSound(u32 soundId);
bool playSound(u32 soundId);
bool playSoundWithPan(u32 soundId, f32 pan);
void playSoundWithPitch(u32 soundId, f32 pitch);
void playButtonPressSoundWhenAdvancingTextBoxes(f32);
bool playButtonPressSoundWhenAdvancingTextBoxes(f32);
void resetButtonPressSound();
void setButtonPressSound(dSoundSource_c *source);
private:
/* 0x10 */ void *field_0x10;
/* 0x14 */ void *field_0x14;
/* 0x18 */ void *field_0x18;
/* 0x1C */ nw4r::snd::SoundHandle mHandles[3];
bool playSoundInternal(u32 soundId);
void stopSounds(u32 playerIdx, u32 soundId, s32 fadeFrames);
void stopSounds(u32 soundId, s32 fadeFrames);
bool isPlayingSound(u32 playerIdx, u32 soundId);
bool isPlayingSound(u32 soundId);
/* 0x10 */ nw4r::snd::SoundHandle mHandle1;
// used for most sounds
/* 0x14 */ nw4r::snd::SoundHandle mNormalSound;
/* 0x18 */ nw4r::snd::SoundHandle mHandle3;
// apparently used for shield gauge sounds, but maybe not given
// that the callers appear unreachable
/* 0x1C */ nw4r::snd::SoundHandle mShieldGaugeHandles[3];
/* 0x28 */ s32 field_0x28;
/* 0x2C */ s32 field_0x2C;
/* 0x30 */ s32 field_0x30;
/* 0x34 */ s32 field_0x34;
/* 0x38 */ u32 mTextboxAdvanceSound;
/* 0x3C */ nw4r::snd::SoundHandle mHandle4;
/* 0x40 */ u16 field_0x40;
/* 0x42 */ u16 field_0x42;
/* 0x44 */ s32 field_0x44;
};
#endif
+2 -1
View File
@@ -12,12 +12,13 @@ public:
dSoundSource_c(u8, dAcBase_c *, UNKWORD, UNKWORD);
virtual ~dSoundSource_c();
static u32 getCharacterTalkSoundId(u32 baseSoundId, dSoundSource_c* source);
u32 getRemoConSoundVariant(u32 soundId) const;
// This is where it gets a bit wild and this class starts mixing in overrides between
// new virtual functions, which causes the vtable to list these functions in exactly this
// order.
virtual void d_s_vt_0x17C();
virtual const char *d_s_vt_0x17C() const;
virtual void d_s_vt_0x180();
virtual void d_s_vt_0x184();
virtual void d_s_vt_0x188();
+5
View File
@@ -60,6 +60,11 @@ namespace nw4r { namespace snd
mSound->Pause(flag, fadeFrames);
}
void SetPan(f32 pan) {
if (IsAttachedSound())
mSound->SetPan(pan);
}
bool IsPause() const {
return IsAttachedSound() && mSound->IsPause();
}
+3
View File
@@ -26,9 +26,12 @@ extern "C" void fn_80365D20(void *);
extern "C" void fn_803624F0(void *);
extern "C" void fn_80364FD0(void *, s32);
extern "C" bool fn_80364DA0(void *);
extern "C" void fn_80365020(void *);
extern "C" void fn_80364D00(void *, s32);
// ENEMY_BGM_RELATED_MGR -> dSndSourceMgr_c
// 0x3870 = player sound source
// 0x3874 = Fi
extern "C" void *ENEMY_BGM_RELATED_MGR;
extern "C" void fn_80384570(void *, bool);
extern "C" void fn_803858D0(void *);