Getting somewhere

This commit is contained in:
robojumper
2025-06-14 16:40:55 +02:00
parent f730fa8286
commit cb8c482c3b
31 changed files with 884 additions and 123 deletions
+2
View File
@@ -2706,6 +2706,8 @@ d/snd/d_snd_source.cpp:
.text start:0x803889C0 end:0x8038C408 align:16
.ctors start:0x804DB920 end:0x804DB924
.data start:0x8054A7D0 end:0x8054AAE8
.sdata start:0x80574708 end:0x80574718
.sdata2 start:0x8057DCB0 end:0x8057DCD0
d/snd/d_snd_mgr_unk_7.cpp:
.text start:0x8038C410 end:0x8038EBF0 align:16
+43 -43
View File
@@ -19864,7 +19864,7 @@ hasPlayingSounds__13dSnd3DActor_cCFv = .text:0x8035B840; // type:function size:0
isPlayingSound__13dSnd3DActor_cFUl = .text:0x8035B8A0; // type:function size:0xCC
__cl__23IsCurrentSoundIdCheckerFRQ34nw4r3snd11SoundHandle = .text:0x8035B970; // type:function size:0x34
fn_8035B9B0 = .text:0x8035B9B0; // type:function size:0x74
fn_8035BA30 = .text:0x8035BA30; // type:function size:0x20
getSomeUserParam__13dSnd3DActor_cCFUl = .text:0x8035BA30; // type:function size:0x20
soundLabelToSoundId__13dSnd3DActor_cCFPCc = .text:0x8035BA50; // type:function size:0x8
soundIdToSoundLabel__13dSnd3DActor_cCFUl = .text:0x8035BA60; // type:function size:0x58
__dt__13dSnd3DActor_cFv = .text:0x8035BAC0; // type:function size:0x58
@@ -19972,7 +19972,7 @@ fn_8035EAF0 = .text:0x8035EAF0; // type:function size:0xC
fn_8035EB00 = .text:0x8035EB00; // type:function size:0x3C
fn_8035EB40 = .text:0x8035EB40; // type:function size:0xC
fn_8035EB50 = .text:0x8035EB50; // type:function size:0x3C
fn_8035EB90 = .text:0x8035EB90; // type:function size:0x80
getSomeUserParam__15dSndPlayerMgr_cCFUl = .text:0x8035EB90; // type:function size:0x80
fn_8035EC10 = .text:0x8035EC10; // type:function size:0x5C
fn_8035EC70 = .text:0x8035EC70; // type:function size:0x84
convertLabelStringToSoundId__15dSndPlayerMgr_cCFPCc = .text:0x8035ED00; // type:function size:0x3C
@@ -20065,7 +20065,7 @@ fn_80362390 = .text:0x80362390; // type:function size:0x6C
fn_80362400 = .text:0x80362400; // type:function size:0x10
fn_80362410 = .text:0x80362410; // type:function size:0xC
fn_80362420 = .text:0x80362420; // type:function size:0x18
isInStage__FPCc = .text:0x80362440; // type:function size:0x34
isInStage__14dSndStateMgr_cFPCc = .text:0x80362440; // type:function size:0x34
fn_80362480 = .text:0x80362480; // type:function size:0x6C
fn_803624F0 = .text:0x803624F0; // type:function size:0xF4
fn_803625F0 = .text:0x803625F0; // type:function size:0x140
@@ -21150,8 +21150,8 @@ vt_0x58__14dSoundSource_cFv = .text:0x803890E0; // type:function size:0x1C
fn_80389100 = .text:0x80389100; // type:function size:0x60
d_s_vt_0x190__14dSoundSource_cFv = .text:0x80389160; // type:function size:0x40
setPause__14dSoundSource_cFbi = .text:0x803891A0; // type:function size:0xB0
vt_0x60__14dSoundSource_cFv = .text:0x80389250; // type:function size:0x30
vt_0x70__14dSoundSource_cFv = .text:0x80389280; // type:function size:0x48
startSound__14dSoundSource_cFUl = .text:0x80389250; // type:function size:0x30
startSound__14dSoundSource_cFPCc = .text:0x80389280; // type:function size:0x48
vt_0x64__14dSoundSource_cFv = .text:0x803892D0; // type:function size:0x64
vt_0x74__14dSoundSource_cFv = .text:0x80389340; // type:function size:0x58
vt_0x68__14dSoundSource_cFv = .text:0x803893A0; // type:function size:0x60
@@ -21159,9 +21159,9 @@ vt_0x78__14dSoundSource_cFv = .text:0x80389400; // type:function size:0x58
vt_0x6C__14dSoundSource_cFv = .text:0x80389460; // type:function size:0x88
vt_0x7C__14dSoundSource_cFv = .text:0x803894F0; // type:function size:0x68
vt_0xA0__14dSoundSource_cFv = .text:0x80389560; // type:function size:0x94
fn_80389600 = .text:0x80389600; // type:function size:0x74
fn_80389680 = .text:0x80389680; // type:function size:0x40
fn_803896C0 = .text:0x803896C0; // type:function size:0x1A8
startRemoConSound__14dSoundSource_cFUl = .text:0x80389600; // type:function size:0x74
startSound__14dSoundSource_cFUlPQ34nw4r3snd11SoundHandle = .text:0x80389680; // type:function size:0x40
startSound__14dSoundSource_cFUlPQ34nw4r3snd11SoundHandlePPQ34nw4r3snd11SoundHandle = .text:0x803896C0; // type:function size:0x1A8
vt_0x80__14dSoundSource_cFv = .text:0x80389870; // type:function size:0x11C
vt_0x8C__14dSoundSource_cFv = .text:0x80389990; // type:function size:0x58
vt_0x84__14dSoundSource_cFv = .text:0x803899F0; // type:function size:0x184
@@ -21170,33 +21170,33 @@ vt_0x88__14dSoundSource_cFv = .text:0x80389BF0; // type:function size:0x160
vt_0x94__14dSoundSource_cFv = .text:0x80389D50; // type:function size:0x78
vt_0x98__14dSoundSource_cFv = .text:0x80389DD0; // type:function size:0x11C
vt_0x9C__14dSoundSource_cFv = .text:0x80389EF0; // type:function size:0x58
fn_80389F50 = .text:0x80389F50; // type:function size:0x208
startSoundAtPosition__14dSoundSource_cFUlPCQ34nw4r4math4VEC3PQ34nw4r3snd11SoundHandle = .text:0x80389F50; // type:function size:0x208
d_s_vt_0x19C__14dSoundSource_cFv = .text:0x8038A160; // type:function size:0x6C
fn_8038A1D0 = .text:0x8038A1D0; // type:function size:0xD8
vt_0xD8__14dSoundSource_cFv = .text:0x8038A2B0; // type:function size:0x48
getRoomId__14dSoundSource_cCFv = .text:0x8038A300; // type:function size:0x10
vt_0xA4__14dSoundSource_cFv = .text:0x8038A310; // type:function size:0xB8
vt_0xA8__14dSoundSource_cFv = .text:0x8038A3D0; // type:function size:0x58
vt_0xAC__14dSoundSource_cFv = .text:0x8038A430; // type:function size:0x30
vt_0xBC__14dSoundSource_cFv = .text:0x8038A460; // type:function size:0x48
stopSounds__14dSoundSource_cFUll = .text:0x8038A310; // type:function size:0xB8
stopSounds__14dSoundSource_cFPCcl = .text:0x8038A3D0; // type:function size:0x58
holdSound__14dSoundSource_cFUl = .text:0x8038A430; // type:function size:0x30
holdSound__14dSoundSource_cFPCc = .text:0x8038A460; // type:function size:0x48
vt_0xB0__14dSoundSource_cFv = .text:0x8038A4B0; // type:function size:0x64
vt_0xC0__14dSoundSource_cFv = .text:0x8038A520; // type:function size:0x58
vt_0xB4__14dSoundSource_cFv = .text:0x8038A580; // type:function size:0x60
vt_0xC4__14dSoundSource_cFv = .text:0x8038A5E0; // type:function size:0x58
vt_0xB8__14dSoundSource_cFv = .text:0x8038A640; // type:function size:0x88
vt_0xC8__14dSoundSource_cFv = .text:0x8038A6D0; // type:function size:0x68
fn_8038A740 = .text:0x8038A740; // type:function size:0x1E8
fn_8038A930 = .text:0x8038A930; // type:function size:0x1D0
holdSound__14dSoundSource_cFUlPQ34nw4r3snd11SoundHandle = .text:0x8038A740; // type:function size:0x1E8
continueHoldingSound__14dSoundSource_cFP14dSndSeSound2_cUlP23dSndDistantSoundActor_cPCQ34nw4r4math4VEC3 = .text:0x8038A930; // type:function size:0x1D0
vt_0xCC__14dSoundSource_cFv = .text:0x8038AB00; // type:function size:0x258
vt_0xD0__14dSoundSource_cFv = .text:0x8038AD60; // type:function size:0x58
SetupSound__14dSoundSource_cFPQ34nw4r3snd11SoundHandleUlPCQ44nw4r3snd14SoundStartable9StartInfoPv = .text:0x8038ADC0; // type:function size:0xAC
d_s_vt_0x1AC__14dSoundSource_cFv = .text:0x8038AE70; // type:function size:0x98
d_s_vt_0x1B0__14dSoundSource_cFv = .text:0x8038AF10; // type:function size:0x254
getVolumePercentMaybe = .text:0x8038B170; // type:function size:0x78
fn_8038B1F0 = .text:0x8038B1F0; // type:function size:0x90
fn_8038B280 = .text:0x8038B280; // type:function size:0x94
setupSound__14dSoundSource_cFPQ34nw4r3snd11SoundHandleUlPCQ44nw4r3snd14SoundStartable9StartInfoPvb = .text:0x8038AF10; // type:function size:0x254
getBaseSoundVolume__14dSoundSource_cFUlUl = .text:0x8038B170; // type:function size:0x78
startBaseSound__14dSoundSource_cFUlf = .text:0x8038B1F0; // type:function size:0x90
startBaseSound__14dSoundSource_cFUlPCQ34nw4r4math4VEC3f = .text:0x8038B280; // type:function size:0x94
d_s_vt_0x1C8__14dSoundSource_cFv = .text:0x8038B320; // type:function size:0x24
fn_8038B350 = .text:0x8038B350; // type:function size:0x30
onSetupError__14dSoundSource_cFv = .text:0x8038B350; // type:function size:0x30
d_s_vt_0x194__14dSoundSource_cFv = .text:0x8038B380; // type:function size:0x8
d_vt_0x58__14dSoundSource_cFv = .text:0x8038B390; // type:function size:0x4
d_s_vt_0x1A0__14dSoundSource_cFv = .text:0x8038B3A0; // type:function size:0x8
@@ -21205,27 +21205,27 @@ attachDistantSound__14dSoundSource_cFP23dSndDistantSoundActor_c = .text:0x8038B3
detachDistantSound__14dSoundSource_cFP23dSndDistantSoundActor_c = .text:0x8038B420; // type:function size:0x60
detachAllDistantSounds__14dSoundSource_cFv = .text:0x8038B480; // type:function size:0x74
pauseAllDistantSounds__14dSoundSource_cFbi = .text:0x8038B500; // type:function size:0x84
fn_8038B590 = .text:0x8038B590; // type:function size:0x24
fn_8038B5C0 = .text:0x8038B5C0; // type:function size:0x24
fn_8038B5F0 = .text:0x8038B5F0; // type:function size:0x60
fn_8038B650 = .text:0x8038B650; // type:function size:0x50
fn_8038B6A0 = .text:0x8038B6A0; // type:function size:0x34
fn_8038B6E0 = .text:0x8038B6E0; // type:function size:0x7C
fn_8038B760 = .text:0x8038B760; // type:function size:0x5C
fn_8038B7C0 = .text:0x8038B7C0; // type:function size:0x34
fn_8038B800 = .text:0x8038B800; // type:function size:0x98
fn_8038B8A0 = .text:0x8038B8A0; // type:function size:0xD4
fn_8038B980 = .text:0x8038B980; // type:function size:0x90
fn_8038BA10 = .text:0x8038BA10; // type:function size:0x6C
fn_8038BA80 = .text:0x8038BA80; // type:function size:0x90
addSeHandleType1__14dSoundSource_cFP14dSndSeSound1_c = .text:0x8038B590; // type:function size:0x24
addSeHandleType2__14dSoundSource_cFP14dSndSeSound2_c = .text:0x8038B5C0; // type:function size:0x24
removeSeHandleType1__14dSoundSource_cFP14dSndSeSound1_cb = .text:0x8038B5F0; // type:function size:0x60
removeSeHandleType2__14dSoundSource_cFP14dSndSeSound2_c = .text:0x8038B650; // type:function size:0x50
removeAllSeHandles__14dSoundSource_cFv = .text:0x8038B6A0; // type:function size:0x34
removeAllSeHandlesType1__14dSoundSource_cFv = .text:0x8038B6E0; // type:function size:0x7C
removeAllSeHandlesType2__14dSoundSource_cFv = .text:0x8038B760; // type:function size:0x5C
calcHandles__14dSoundSource_cFv = .text:0x8038B7C0; // type:function size:0x34
calcHandlesType1__14dSoundSource_cFv = .text:0x8038B800; // type:function size:0x98
calcHandlesType2__14dSoundSource_cFv = .text:0x8038B8A0; // type:function size:0xD4
getHandleType1ForSoundId__14dSoundSource_cFUl = .text:0x8038B980; // type:function size:0x90
getHandleType1ForSoundHandle__14dSoundSource_cFPQ34nw4r3snd11SoundHandle = .text:0x8038BA10; // type:function size:0x6C
getHandleType2ForSoundId__14dSoundSource_cFUl = .text:0x8038BA80; // type:function size:0x90
fn_8038BB10 = .text:0x8038BB10; // type:function size:0x6C
fn_8038BB80 = .text:0x8038BB80; // type:function size:0x6C
fn_8038BBF0 = .text:0x8038BBF0; // type:function size:0x144
stopSoundHandles__14dSoundSource_cFUll = .text:0x8038BBF0; // type:function size:0x144
vt_0xFC__14dSoundSource_cFv = .text:0x8038BD40; // type:function size:0x20
vt_0x110__14dSoundSource_cFv = .text:0x8038BD60; // type:function size:0xC
d_s_vt_0x1E4__14dSoundSource_cFv = .text:0x8038BD70; // type:function size:0x4
fn_8038BD80 = .text:0x8038BD80; // type:function size:0xB8
getCharacterTalkSoundId__14dSoundSource_cFUlP14dSoundSource_c = .text:0x8038BE40; // type:function size:0xC4
modifySoundId__14dSoundSource_cFUl = .text:0x8038BD80; // type:function size:0xB8
modifySoundId__14dSoundSource_cFUlP14dSoundSource_c = .text:0x8038BE40; // type:function size:0xC4
fn_8038BF10 = .text:0x8038BF10; // type:function size:0x104
d_s_vt_0x1E8__14dSoundSource_cFv = .text:0x8038C020; // type:function size:0x8
getRemoConSoundVariant__14dSoundSource_cCFUl = .text:0x8038C030; // type:function size:0x58
@@ -21449,8 +21449,8 @@ __ct__27dSndDistantSoundActorPool_cFv = .text:0x80393590; // type:function size:
__dt__23dSndDistantSoundActor_cFv = .text:0x80393630; // type:function size:0x70
fn_803936A0 = .text:0x803936A0; // type:function size:0x7C
fn_80393720 = .text:0x80393720; // type:function size:0xBC
fn_803937E0 = .text:0x803937E0; // type:function size:0x158
fn_80393940 = .text:0x80393940; // type:function size:0x4C
acquireActor__27dSndDistantSoundActorPool_cFUlPCQ34nw4r4math4VEC3P14dSoundSource_c = .text:0x803937E0; // type:function size:0x158
addToActiveList__27dSndDistantSoundActorPool_cFP23dSndDistantSoundActor_cUl = .text:0x80393940; // type:function size:0x4C
fn_80393990 = .text:0x80393990; // type:function size:0x4C
fn_803939E0 = .text:0x803939E0; // type:function size:0x5C
fn_80393A40 = .text:0x80393A40; // type:function size:0xA0
@@ -21465,8 +21465,8 @@ getSourceParam__27dSndDistantSoundActorPool_cFv = .text:0x80393E80; // type:func
initSource__23dSndDistantSoundActor_cFP14dSoundSource_c = .text:0x80393E90; // type:function size:0x54
setSourceDirectly__23dSndDistantSoundActor_cFP14dSoundSource_c = .text:0x80393EF0; // type:function size:0x18
updatePosition__23dSndDistantSoundActor_cFv = .text:0x80393F10; // type:function size:0x28
fn_80393F40 = .text:0x80393F40; // type:function size:0x20
fn_80393F60 = .text:0x80393F60; // type:function size:0x20
d_vt_0x58__23dSndDistantSoundActor_cFRQ34nw4r3snd11SoundHandleP13dSndSeSound_cUl = .text:0x80393F40; // type:function size:0x20
d_vt_0x5C__23dSndDistantSoundActor_cFRQ34nw4r3snd11SoundHandleP13dSndSeSound_cUli = .text:0x80393F60; // type:function size:0x20
startSound__23dSndDistantSoundActor_cFUlRCQ34nw4r4math4VEC3PQ34nw4r3snd11SoundHandle = .text:0x80393F80; // type:function size:0x98
holdSound__23dSndDistantSoundActor_cFUlRCQ34nw4r4math4VEC3PQ34nw4r3snd11SoundHandle = .text:0x80394020; // type:function size:0x90
loadDefaultParam__23dSndDistantSoundActor_cFv = .text:0x803940B0; // type:function size:0x38
@@ -41216,8 +41216,8 @@ lbl_805746E8 = .sdata:0x805746E8; // type:object size:0x8
lbl_805746F0 = .sdata:0x805746F0; // type:object size:0x8
lbl_805746F8 = .sdata:0x805746F8; // type:object size:0x8
lbl_80574700 = .sdata:0x80574700; // type:object size:0x8
lbl_80574708 = .sdata:0x80574708; // type:object size:0x8
lbl_80574710 = .sdata:0x80574710; // type:object size:0x8
lbl_80574708 = .sdata:0x80574708; // type:object size:0x6 data:string
lbl_80574710 = .sdata:0x80574710; // type:object size:0x6 data:string
lbl_80574718 = .sdata:0x80574718; // type:object size:0x8
lbl_80574720 = .sdata:0x80574720; // type:object size:0x8
lbl_80574728 = .sdata:0x80574728; // type:object size:0x8
@@ -42292,7 +42292,7 @@ lbl_80575DA4 = .sbss:0x80575DA4; // type:object size:0x4 data:4byte
sInstance__15dSndSourceMgr_c = .sbss:0x80575DA8; // type:object size:0x4 data:4byte
sDisposer__15dSndSourceMgr_c = .sbss:0x80575DAC; // type:object size:0x4 data:4byte
lbl_80575DB0 = .sbss:0x80575DB0; // type:object size:0x8 data:4byte
lbl_80575DB8 = .sbss:0x80575DB8; // type:object size:0x8 data:byte
sIsStartingBaseSound__14dSoundSource_c = .sbss:0x80575DB8; // type:object size:0x8 data:byte
lbl_80575DC0 = .sbss:0x80575DC0; // type:object size:0x8 data:4byte
lbl_80575DC8 = .sbss:0x80575DC8; // type:object size:0x4 data:4byte
lbl_80575DCC = .sbss:0x80575DCC; // type:object size:0x4 data:4byte
+18 -2
View File
@@ -3,8 +3,10 @@
#include "common.h"
#include "d/snd/d_snd_misc.h"
#include "d/snd/d_snd_types.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 {
public:
@@ -36,8 +38,8 @@ public:
virtual f32 getDistanceToPlayer(); // vt 0x4C
virtual void updatePositionRelativeToPlayer(); // vt 0x50
virtual void updateDistanceToPlayer(); // vt 0x54
virtual void d_vt_0x58() = 0;
virtual void d_vt_0x5C() = 0;
virtual void d_vt_0x58(nw4r::snd::SoundHandle &handle, dSndSeSound_c *pSound, u32 id) = 0;
virtual void d_vt_0x5C(nw4r::snd::SoundHandle &handle, dSndSeSound_c *pSound, u32 id, UNKWORD) = 0;
void resetCachedRelativePositions();
@@ -50,6 +52,20 @@ public:
void updatePositionRelativeToListener();
void updateDistanceToListener();
void updateListenerParameters() {
calculatePositionRelativeToListener();
mDistanceToListener = VECMag(mPositionRelativeToListener);
setFlag(0x1 | 0x2);
}
void updateCameraTargetParameters() {
calculatePositionRelativeToCameraTarget();
mDistanceToCameraTarget = VECMag(mPositionRelativeToCameraTarget);
setFlag(0x4 | 0x8);
}
u32 getSomeUserParam(u32 soundId) const;
bool checkFlag(u16 flag) const {
return (mFlags & flag);
}
+4 -7
View File
@@ -4,15 +4,13 @@
#include "common.h"
#include "d/snd/d_snd_actor.h"
#include "d/snd/d_snd_sound.h"
#include "d/snd/d_snd_types.h"
#include "d/snd/d_snd_util.h"
#include "nw4r/snd/snd_FxReverbStdDpl2.h"
#include "nw4r/ut/ut_list.h"
SND_DISPOSER_FORWARD_DECL(dSndBgmMgr_c);
class dSndBgmSound_c;
class dSndBgmBattleSound_c;
// Previous Ghidra name: FanfareSoundMgr
class dSndBgmMgr_c {
public:
@@ -78,7 +76,7 @@ private:
/** Used to mute other BGM when battle music is playing */
void setBgmHandleIdxVolume(u32 handleIdx, f32 volume, s32 fadeFrames);
bool isBgmHandleIdxPlayingSoundId(u32 handleIdx, u32 soundId);
bool stopBgmHandleIdx(u32 handleIdx, s32 fadeFrames);
@@ -95,13 +93,12 @@ private:
bool startDelayedSound();
void calcDelayedSound();
dSndBgmSound_c *getBgmSoundHandleForId(u32 soundId) const;
dSndSound_c *getFreeFanSoundHandle();
dSndSound_c *getFanSoundHandleForFan(u32 soundId);
void stopFanSounds(s32 fadeFrames);
bool isSoundRegist(dSndSound_c *sound);
+1 -1
View File
@@ -93,7 +93,7 @@ private:
class SoundStopper {
public:
SoundStopper(u32 id, s32 fadeFrames) : mSoundId(id), mFadeFrames(fadeFrames) {}
~SoundStopper() {}
// ~SoundStopper() {}
virtual void operator()(nw4r::snd::SoundHandle &pHandle) {
if (mSoundId == pHandle.GetId()) {
+24 -5
View File
@@ -3,12 +3,11 @@
#include "common.h"
#include "d/snd/d_snd_3d_actor.h"
#include "d/snd/d_snd_types.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.
@@ -21,8 +20,8 @@ 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;
virtual void d_vt_0x58(nw4r::snd::SoundHandle &handle, dSndSeSound_c *pSound, u32 id) override;
virtual void d_vt_0x5C(nw4r::snd::SoundHandle &handle, dSndSeSound_c *pSound, u32 id, UNKWORD) override;
void initSource(dSoundSource_c *pSource);
void setSourceDirectly(dSoundSource_c *pSource);
@@ -38,6 +37,26 @@ public:
return mpSoundSource == source;
}
nw4r::snd::SoundHandle *getHandle() {
return mpSoundHandle;
}
void setSource(dSoundSource_c *source) {
mpSoundSource = source;
}
bool isActive() const {
return mIsActive;
}
void setActive(bool value) {
mIsActive = value;
}
void setUseSourcePosition(bool value) {
mUseSourcePosition = true;
}
private:
/* 0x0E4 */ nw4r::ut::Node mPoolLink; // sound actor pool link
/* 0x0EC */ nw4r::ut::Node mSourceLink; // sound source link
@@ -45,7 +64,7 @@ private:
/* 0x0F8 */ dSoundSource_c *mpSoundSource;
/* 0x0FC */ nw4r::snd::SoundHandle mSoundHandle;
/* 0x100 */ nw4r::snd::SoundHandle *mpSoundHandle;
/* 0x104 */ u8 field_0x104;
/* 0x104 */ bool mIsActive;
/* 0x105 */ bool mUseSourcePosition;
};
@@ -4,9 +4,12 @@
#include "common.h"
#include "d/snd/d_snd_distant_sound_actor.h"
#include "d/snd/d_snd_misc.h"
#include "d/snd/d_snd_types.h"
#include "d/snd/d_snd_util.h"
#include "nw4r/math/math_types.h"
#include "nw4r/ut/ut_list.h"
SND_DISPOSER_FORWARD_DECL(dSndDistantSoundActorPool_c);
/**
@@ -28,10 +31,14 @@ public:
void onChangeStage();
dSndDistantSoundActor_c *acquireActor(u32 soundId, const nw4r::math::VEC3 *position, dSoundSource_c *source);
private:
void addToActiveList(dSndDistantSoundActor_c *actor, u32 id);
/* 0x0010 */ dSndDistantSoundActor_c mSounds[POOL_SIZE];
/* 0x4210 */ UNKWORD field_0x4210;
/* 0x4214 */ nw4r::ut::List mList;
/* 0x4214 */ nw4r::ut::List mActiveActors;
static dSndSourceParam sParam;
};
+1
View File
@@ -52,6 +52,7 @@ public:
const char *getSoundArchivePath();
u32 convertLabelStringToSoundId(const char *label) const;
static bool isBgmPlayerId(u32 id);
u32 getSomeUserParam(u32 soundId) const;
nw4r::snd::SoundArchivePlayer &getSoundArchivePlayerForType(u8 sourceType);
bool canUseThisPlayer(u8 sourceType) const;
+44 -5
View File
@@ -3,11 +3,10 @@
#include "common.h"
#include "d/snd/d_snd_sound.h"
#include "d/snd/d_snd_types.h"
#include "nw4r/snd/snd_SoundHandle.h"
#include "nw4r/ut/ut_list.h"
class dSoundSource_c;
struct UnkSeSoundStruct {
UnkSeSoundStruct() : field_0x00(0), field_0x04(0.0f) {}
~UnkSeSoundStruct() {}
@@ -28,6 +27,7 @@ public:
// vtable at 0x000
/* vt 0x08 */ virtual void setSource(dSoundSource_c *source, u32 soundId);
// TODO these names are probably wrong
/* vt 0x0C */ virtual void onStart(dSoundSource_c *source);
/* vt 0x10 */ virtual void onCalc(dSoundSource_c *source);
@@ -44,16 +44,55 @@ public:
mpSoundHandle->Stop(fadeFrames);
}
bool isAttachedSound() const {
// cannot be const...
bool isAttachedSound() {
return mpSoundHandle->IsAttachedSound();
}
nw4r::snd::SoundHandle *getHandle() {
return mpSoundHandle;
}
void setHandle(nw4r::snd::SoundHandle *handle) {
if (handle != nullptr) {
mpSoundHandle = handle;
field_0x11C = 0;
} else {
mpSoundHandle = &mSound;
field_0x11C = 1;
}
}
void attachSource(dSoundSource_c *source) {
mpSource = source;
}
bool isAttachedSource() const {
return mpSource != nullptr;
}
bool unkRemovalCheck() const {
return !field_0x11D && !field_0x11E;
}
bool isSoundId(u32 id) const {
return mSoundId == id;
}
void setAcquiredMaybe(bool value) {
field_0x11D = value;
}
void setInUseMaybe(bool value) {
field_0x11E = value;
}
protected:
/* 0x004 */ nw4r::ut::Node mSourceLink;
/* 0x00C */ nw4r::ut::Node mPoolLink;
/* 0x014 */ UNKWORD field_0x014;
/* 0x014 */ dSoundSource_c *mpSource;
/* 0x018 */ dSndSound_c mSound;
/* 0x108 */ dSndSound_c *mpSoundHandle;
/* 0x108 */ nw4r::snd::SoundHandle *mpSoundHandle;
/* 0x10C */ Type_e mHandleType;
/* 0x110 */ u32 mSoundId;
/* 0x114 */ s32 field_0x114;
+4
View File
@@ -13,6 +13,10 @@ public:
bool calcTimer();
void setField0x130(u8 val) {
field_0x130 = val;
}
private:
/* 0x128 */ u32 field_0x128;
/* 0x12C */ u32 field_0x12C;
+1 -3
View File
@@ -7,8 +7,6 @@
#include "d/snd/d_snd_util.h"
#include "nw4r/ut/ut_list.h"
class dSoundSource_c;
SND_DISPOSER_FORWARD_DECL(dSndSeSoundPool_c);
class dSndSeSoundPool_c {
@@ -23,7 +21,7 @@ public:
dSndSeSound1_c *acquireSoundType1(dSoundSource_c *source, u32 soundId);
dSndSeSound2_c *acquireSoundType2(dSoundSource_c *source, u32 soundId);
void releaseSoundType1(dSndSeSound1_c *sound, bool arg);
void releaseSoundType1(dSndSeSound1_c *sound, bool stop);
void releaseSoundType2(dSndSeSound2_c *sound);
private:
+1 -2
View File
@@ -2,13 +2,12 @@
#define D_SND_SOUND_H
#include "common.h"
#include "d/snd/d_snd_types.h"
#include "nw4r/snd/snd_SeqTrack.h"
#include "nw4r/snd/snd_SoundHandle.h"
#include "nw4r/snd/snd_SoundStartable.h"
#include "nw4r/ut/ut_list.h"
class dSndSound_c;
// Not sure, handles a bunch of floats, exists in a ton of variants
class dSndControl_c {
public:
+76 -16
View File
@@ -4,13 +4,14 @@
#include "common.h"
#include "d/snd/d_snd_3d_actor.h"
#include "d/snd/d_snd_source_if.h"
#include "d/snd/d_snd_types.h"
#include "nw4r/math/math_types.h"
#include "nw4r/snd/snd_SoundHandle.h"
#include "nw4r/snd/snd_SoundStartable.h"
#include "nw4r/ut/ut_list.h"
#include <cstring>
class dSndSourceGroup_c;
class dSndDistantSoundActor_c;
/** Manages sound relating to a particular actor. */
/** Size: probably 0x15C */
class dSoundSource_c : public dSoundSourceIf_c, public dSnd3DActor_c {
@@ -18,7 +19,8 @@ public:
dSoundSource_c(u8 sourceType, dAcBase_c *, const char *name, dSndSourceGroup_c *pOwnerGroup);
virtual ~dSoundSource_c();
static u32 getCharacterTalkSoundId(u32 baseSoundId, dSoundSource_c *source);
u32 modifySoundId(u32 baseSoundId);
static u32 modifySoundId(u32 baseSoundId, dSoundSource_c *source);
u32 getRemoConSoundVariant(u32 soundId) const;
s32 getRoomId() const;
@@ -34,19 +36,20 @@ public:
virtual void d_s_vt_0x188();
virtual void d_s_vt_0x18C();
virtual void d_s_vt_0x190();
virtual void d_s_vt_0x194();
virtual u32 d_s_vt_0x194(u32 soundId);
virtual void d_vt_0x58() override;
virtual void d_vt_0x58(nw4r::snd::SoundHandle &handle, dSndSeSound_c *pSound, u32 id) override;
virtual void d_s_vt_0x19C();
virtual void d_s_vt_0x1A0();
virtual u32 d_s_vt_0x1A0(u32 soundId, UNKWORD);
virtual void d_vt_0x5C() override;
virtual void d_vt_0x5C(nw4r::snd::SoundHandle &handle, dSndSeSound_c *pSound, u32 id, UNKWORD) override;
virtual StartResult
SetupSound(nw4r::snd::SoundHandle *pHandle, u32 soundId, const StartInfo *pStartInfo, void *) override;
virtual void d_s_vt_0x1AC();
virtual void d_s_vt_0x1B0();
virtual bool d_s_vt_0x1AC(u32 soundId);
virtual StartResult
setupSound(nw4r::snd::SoundHandle *pHandle, u32 soundId, const StartInfo *pStartInfo, void *arg, bool holdFlag);
virtual void attachDistantSound(dSndDistantSoundActor_c *);
virtual void detachDistantSound(dSndDistantSoundActor_c *);
virtual void detachAllDistantSounds();
@@ -55,7 +58,7 @@ public:
}
virtual void pauseAllDistantSounds(bool flag, int fadeFrames);
virtual void d_s_vt_0x1C8();
virtual void d_s_vt_0x1CC();
virtual void d_s_vt_0x1CC(u32 playingId, u32 requestedId, dSndSeSound_c *seSound);
virtual void setPause(bool flag, int fadeFrames) override;
@@ -64,7 +67,13 @@ public:
virtual void d_s_vt_0x1DC();
virtual void d_s_vt_0x1E0();
virtual void d_s_vt_0x1E4();
virtual void d_s_vt_0x1E8();
virtual u32 d_s_vt_0x1E8(u32 soundId);
bool startRemoConSound(u32 soundId);
nw4r::snd::SoundHandle *startSound(u32 soundId, nw4r::snd::SoundHandle *handle);
dSndDistantSoundActor_c *
startSoundAtPosition(u32 soundId, const nw4r::math::VEC3 *position, nw4r::snd::SoundHandle *handle);
nw4r::snd::SoundHandle *holdSound(u32 soundId, nw4r::snd::SoundHandle *handle);
// Overrides of dSoundSourceIf_c - always in the first section of
// the vtable, so the order is not certain. May have to reorder for weak
@@ -78,6 +87,14 @@ public:
virtual bool isPlayingSound(u32 soundId) override; // 0x4C
virtual bool isPlayingSound(const char *soundId) override; // 0x50
virtual bool startSound(u32 soundId) override; // 0x60
virtual bool startSound(const char *label) override; // 0x70
virtual void stopSounds(u32 soundId, s32 fadeFrames) override; // 0x0A4
virtual void stopSounds(const char *label, s32 fadeFrames) override; // 0x0A8
virtual bool holdSound(u32 soundId) override; // 0x0AC
virtual bool holdSound(const char *label) override; // 0x0BC
virtual bool isReadyMaybe() override {
return false;
} // 0x100
@@ -86,6 +103,49 @@ public:
virtual void setRate(f32 frame) override {} // 0x10C
private:
/**
* Sound sources can cause other sounds to be started. E.g when
* walking, Link will produce a walk sound, but an additional sound
* will be played, a different one per surface material.
*
* If this flag isn't set, the code will find the correct variant for
* a base sound, play the variant, and then play the base sound with this
* flag set so that we don't attempt to find and play the variant again.
*/
static bool sIsStartingBaseSound;
f32 getBaseSoundVolume(u32 variantSoundId, u32 baseSoundId);
dSndDistantSoundActor_c *startBaseSoundAtPosition(u32 baseSoundId, const nw4r::math::VEC3 *position, f32 volume);
nw4r::snd::SoundHandle *startBaseSound(u32 baseSoundId, f32 volume);
nw4r::snd::SoundStartable::StartResult onSetupError();
nw4r::snd::SoundStartable::StartResult
startSound(u32 soundId, nw4r::snd::SoundHandle *handle, nw4r::snd::SoundHandle **pOutHandle);
nw4r::snd::SoundHandle *continueHoldingSound(
dSndSeSound2_c *seHandle, u32 soundId, dSndDistantSoundActor_c *distant, const nw4r::math::VEC3 *position
);
void addSeHandleType1(dSndSeSound1_c *handle);
void addSeHandleType2(dSndSeSound2_c *handle);
void removeSeHandleType1(dSndSeSound1_c *handle, bool stop);
void removeSeHandleType2(dSndSeSound2_c *handle);
void removeAllSeHandles();
void removeAllSeHandlesType1();
void removeAllSeHandlesType2();
void stopSoundHandles(u32 soundId, s32 fadeFrames);
void calcHandles();
void calcHandlesType1();
void calcHandlesType2();
dSndSeSound1_c *getHandleType1ForSoundId(u32 soundId);
dSndSeSound1_c *getHandleType1ForSoundHandle(nw4r::snd::SoundHandle *handle);
dSndSeSound2_c *getHandleType2ForSoundId(u32 soundId);
// at 0x00: dSoundSourceIf_c vtable
// at 0x04: dSnd3DActor_c sub-object
// at 0x58: thunk-vtable
@@ -103,12 +163,12 @@ private:
/* 0x102 */ u8 field_0x102;
/* 0x104 */ UNKWORD field_0x104;
/* 0x108 */ UNKWORD field_0x108;
/* 0x10C */ UNKWORD field_0x10C;
/* 0x10C */ UnkSeSoundStruct *mpUnkSe;
/* 0x110 */ nw4r::ut::List mDistantSoundList; // node offset 0xEC -> dSndDistantSoundActor_c
/* 0x11C */ UNKWORD field_0x11C;
/* 0x120 */ nw4r::ut::List field_0x120; // node offset 0x4 -> dSndSeSound_c
/* 0x12C */ nw4r::ut::List field_0x12C; // node offset 0x4 -> dSndSeSound_c
/* 0x138 */ nw4r::ut::Node mGroupLink; // node for list in dSndSourceGroup_c
/* 0x120 */ nw4r::ut::List mHandleType1List; // node offset 0x4 -> dSndSeSound_c
/* 0x12C */ nw4r::ut::List mHandleType2List; // node offset 0x4 -> dSndSeSound_c
/* 0x138 */ nw4r::ut::Node mGroupLink; // node for list in dSndSourceGroup_c
/* 0x140 */ dSndSourceGroup_c *mpOwnerGroup;
/* 0x144 */ u8 _0x144[0x154 - 0x144];
/* 0x154 */ UNKWORD field_0x154;
+4 -5
View File
@@ -3,11 +3,10 @@
#include "common.h"
#include "d/snd/d_snd_misc.h"
#include "d/snd/d_snd_types.h"
#include "nw4r/ut/ut_list.h"
#include "sized_string.h"
class dSoundSource_c;
/**
* All similar dSoundSource_c's are put in a group. The game can then find the closest
* source for a given type by name/id, for example for changing things about the music
@@ -21,13 +20,13 @@ class dSoundSource_c;
class dSndSourceGroup_c {
public:
dSndSourceGroup_c();
dSndSourceGroup_c(s32 sourceType, const char*, u32, s32 mSubtype);
dSndSourceGroup_c(s32 sourceType, const char *, u32, s32 mSubtype);
~dSndSourceGroup_c();
void registerSource(dSoundSource_c *);
void unregisterSource(dSoundSource_c *);
dSndSourceParam* getAmbientParam() {
dSndSourceParam *getAmbientParam() {
return &mParam;
}
@@ -37,7 +36,7 @@ public:
s32 getNumSources() const;
void set(s32 type, const char *name);
void calc();
private:
bool setParamFromName(const char *name);
void resetSoundSourceParam();
+6 -6
View File
@@ -33,11 +33,11 @@ public:
SOUNDSOURCE_VIRTUAL(0x54);
SOUNDSOURCE_VIRTUAL(0x58);
SOUNDSOURCE_VIRTUAL(0x5C);
SOUNDSOURCE_VIRTUAL(0x60);
virtual bool startSound(u32 soundId) = 0; // 0x60
SOUNDSOURCE_VIRTUAL(0x64);
SOUNDSOURCE_VIRTUAL(0x68);
SOUNDSOURCE_VIRTUAL(0x6C);
SOUNDSOURCE_VIRTUAL(0x70);
virtual bool startSound(const char *label) = 0; // 0x70
SOUNDSOURCE_VIRTUAL(0x74);
SOUNDSOURCE_VIRTUAL(0x78);
SOUNDSOURCE_VIRTUAL(0x7C);
@@ -50,13 +50,13 @@ public:
SOUNDSOURCE_VIRTUAL(0x98);
SOUNDSOURCE_VIRTUAL(0x9C);
SOUNDSOURCE_VIRTUAL(0xA0);
SOUNDSOURCE_VIRTUAL(0xA4);
SOUNDSOURCE_VIRTUAL(0xA8);
SOUNDSOURCE_VIRTUAL(0xAC);
virtual void stopSounds(u32 soundId, s32 fadeFrames) = 0; // 0x0A4
virtual void stopSounds(const char *label, s32 fadeFrames) = 0; // 0x0A4
virtual bool holdSound(u32 soundId) = 0; // 0xAC
SOUNDSOURCE_VIRTUAL(0xB0);
SOUNDSOURCE_VIRTUAL(0xB4);
SOUNDSOURCE_VIRTUAL(0xB8);
SOUNDSOURCE_VIRTUAL(0xBC);
virtual bool holdSound(const char *label) = 0; // 0xBC
SOUNDSOURCE_VIRTUAL(0xC0);
SOUNDSOURCE_VIRTUAL(0xC4);
SOUNDSOURCE_VIRTUAL(0xC8);
+21
View File
@@ -0,0 +1,21 @@
#ifndef D_SND_TYPES_H
#define D_SND_TYPES_H
// Forward declarations for d/snd to break circular header dependencies
class dSoundSource_c;
class dSndSourceGroup_c;
class dSndDistantSoundActor_c;
class dSndSound_c;
class UnkSeSoundStruct;
class dSndSeSound_c;
class dSndSeSound1_c;
class dSndSeSound2_c;
class dSndBgmSound_c;
class dSndBgmBattleSound_c;
#endif
+4
View File
@@ -34,6 +34,10 @@ namespace nw4r { namespace snd
const detail::BasicSound *detail_GetAttachedSound() const { return mSound; }
void DetachSound();
void SetOutputLineFlag(int outputLineFlag) {
if (IsAttachedSound())
mSound->SetOutputLineFlag(outputLineFlag);
}
void FadeIn(int fadeFrames) {
if (IsAttachedSound())
+8
View File
@@ -28,6 +28,14 @@
namespace nw4r { namespace snd
{
enum OutputLineFlag {
OUTPUT_LINE_MAIN = 0x1,
OUTPUT_LINE_REMOTE_1 = 0x2,
OUTPUT_LINE_REMOTE_2 = 0x4,
OUTPUT_LINE_REMOTE_3 = 0x8,
OUTPUT_LINE_REMOTE_4 = 0x16,
};
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x26bd0
enum AuxBus
{
+1
View File
@@ -66,6 +66,7 @@ dSndBgmMgr_c::dSndBgmMgr_c()
void dSndBgmMgr_c::calcLists() {
// TODO ...
// TODO: Weird declaration order required for regswaps
dSndBgmSound_c *next, *it;
for (it = getFirstInBgmSoundList(BGM_LIST_PLAYING); it != nullptr; it = next) {
+13 -1
View File
@@ -13,7 +13,7 @@ dSndDistantSoundActor_c::dSndDistantSoundActor_c()
field_0x0F4(0),
mpSoundSource(nullptr),
mpSoundHandle(&mSoundHandle),
field_0x104(0),
mIsActive(false),
mUseSourcePosition(false) {}
void dSndDistantSoundActor_c::initSource(dSoundSource_c *pSource) {
@@ -38,6 +38,18 @@ void dSndDistantSoundActor_c::updatePosition() {
}
}
void dSndDistantSoundActor_c::d_vt_0x58(nw4r::snd::SoundHandle &handle, dSndSeSound_c *pSound, u32 id) {
if (mpSoundSource != nullptr) {
mpSoundSource->d_vt_0x58(handle, pSound, id);
}
}
void dSndDistantSoundActor_c::d_vt_0x5C(nw4r::snd::SoundHandle &handle, dSndSeSound_c *pSound, u32 id, UNKWORD arg) {
if (mpSoundSource != nullptr) {
mpSoundSource->d_vt_0x5C(handle, pSound, id, arg);
}
}
bool dSndDistantSoundActor_c::startSound(
u32 soundId, const nw4r::math::VEC3 &position, nw4r::snd::SoundHandle *pHandle
) {
+56 -2
View File
@@ -1,11 +1,13 @@
#include "d/snd/d_snd_distant_sound_actor_pool.h"
#include "common.h"
#include "d/snd/d_snd_distant_sound_actor.h"
#include "d/snd/d_snd_source.h"
#include "m/m_vec.h"
#include "nw4r/ut/ut_list.h"
#include <cmath>
SND_DISPOSER_DEFINE(dSndDistantSoundActorPool_c);
dSndSourceParam dSndDistantSoundActorPool_c::sParam;
@@ -13,10 +15,62 @@ dSndSourceParam dSndDistantSoundActorPool_c::sParam;
dSndDistantSoundActorPool_c::dSndDistantSoundActorPool_c() {
field_0x4210 = 0;
// TODO offsetof
nw4r::ut::List_Init(&mList, 0xE4);
nw4r::ut::List_Init(&mActiveActors, 0xE4);
sParam.reset(INFINITY);
}
dSndDistantSoundActor_c *
dSndDistantSoundActorPool_c::acquireActor(u32 soundId, const nw4r::math::VEC3 *position, dSoundSource_c *source) {
if (soundId == -1) {
return nullptr;
}
dSndDistantSoundActor_c *ac = nullptr;
int i = 0;
while (ac == nullptr) {
ac = &mSounds[field_0x4210];
field_0x4210++;
if (field_0x4210 >= POOL_SIZE) {
field_0x4210 = 0;
}
if (ac->isActive()) {
i++;
ac = nullptr;
if (i >= POOL_SIZE) {
break;
}
}
}
if (ac != nullptr) {
if (source != nullptr) {
ac->initSource(source);
source->attachDistantSound(ac);
} else {
ac->loadDefaultParam();
ac->setSource(nullptr);
}
ac->SetPosition(*position);
ac->updateListenerParameters();
ac->updateCameraTargetParameters();
addToActiveList(ac, soundId);
return ac;
}
return nullptr;
}
void dSndDistantSoundActorPool_c::addToActiveList(dSndDistantSoundActor_c *actor, u32 id) {
if (actor == nullptr) {
return;
}
if (actor->isActive()) {
return;
}
nw4r::ut::List_Append(&mActiveActors, actor);
actor->setActive(true);
}
void dSndDistantSoundActorPool_c::onChangeStage() {
mVec3_c v(INFINITY, INFINITY, INFINITY);
+2 -2
View File
@@ -4,7 +4,7 @@
#include "d/snd/d_snd_source.h"
dSndSeSound_c::dSndSeSound_c()
: field_0x014(0),
: mpSource(nullptr),
mpSoundHandle(&mSound),
mHandleType(SE_HANDLE_TYPE_1),
mSoundId(-1),
@@ -40,7 +40,7 @@ void dSndSeSound_c::setSource(dSoundSource_c *source, u32 soundId) {
void dSndSeSound_c::clear() {
field_0x114 = -1;
field_0x014 = 0;
mpSource = nullptr;
mpCalcCallback = nullptr;
mpStartCallback = nullptr;
mpSoundHandle = &mSound;
+2 -2
View File
@@ -66,13 +66,13 @@ dSndSeSound2_c *dSndSeSoundPool_c::acquireSoundType2(dSoundSource_c *source, u32
return nullptr;
}
void dSndSeSoundPool_c::releaseSoundType1(dSndSeSound1_c *sound, bool arg) {
void dSndSeSoundPool_c::releaseSoundType1(dSndSeSound1_c *sound, bool stop) {
if (sound == nullptr) {
return;
}
if (sound->isAttachedSound()) {
if (arg) {
if (stop) {
sound->stop(0);
sound->clear();
nw4r::ut::List_Append(&mFreeType1List, sound);
+1 -1
View File
@@ -185,7 +185,7 @@ void dSndSmallEffectMgr_c::resetButtonPressSound() {
void dSndSmallEffectMgr_c::setButtonPressSound(dSoundSource_c *source) {
resetButtonPressSound();
if (source != nullptr) {
mTextboxAdvanceSound = dSoundSource_c::getCharacterTalkSoundId(SE_S_TALK_CHAR, source);
mTextboxAdvanceSound = dSoundSource_c::modifySoundId(SE_S_TALK_CHAR, source);
if (mTextboxAdvanceSound == SE_S_TALK_CHAR) {
resetButtonPressSound();
}
+531 -11
View File
@@ -4,12 +4,18 @@
#include "d/a/d_a_base.h"
#include "d/snd/d_snd_3d_actor.h"
#include "d/snd/d_snd_3d_manager.h"
#include "d/snd/d_snd_checkers.h"
#include "d/snd/d_snd_distant_sound_actor.h"
#include "d/snd/d_snd_distant_sound_actor_pool.h"
#include "d/snd/d_snd_mgr.h"
#include "d/snd/d_snd_player_mgr.h"
#include "d/snd/d_snd_se_sound_pool.h"
#include "d/snd/d_snd_source_group.h"
#include "d/snd/d_snd_source_mgr.h"
#include "egg/audio/eggAudioRmtSpeakerMgr.h"
#include "nw4r/snd/snd_SoundHandle.h"
#include "nw4r/snd/snd_SoundStartable.h"
#include "nw4r/snd/snd_global.h"
#include "nw4r/ut/ut_list.h"
#include "sized_string.h"
@@ -39,7 +45,7 @@ dSoundSource_c::dSoundSource_c(u8 sourceType, dAcBase_c *actor, const char *name
field_0x102(0),
field_0x104(0),
field_0x108(0),
field_0x10C(0),
mpUnkSe(nullptr),
field_0x11C(0),
mpOwnerGroup(pOwnerGroup),
field_0x154(0),
@@ -48,14 +54,15 @@ dSoundSource_c::dSoundSource_c(u8 sourceType, dAcBase_c *actor, const char *name
mSourceCategory = dSndSourceMgr_c::getSourceCategoryForSourceType(sourceType, name);
// TODO: Offsetof
nw4r::ut::List_Init(&mDistantSoundList, 0xEC);
nw4r::ut::List_Init(&field_0x120, 0x04);
nw4r::ut::List_Init(&field_0x12C, 0x04);
nw4r::ut::List_Init(&mHandleType1List, 0x04);
nw4r::ut::List_Init(&mHandleType2List, 0x04);
pOwnerGroup->registerSource(this);
}
dSoundSource_c::~dSoundSource_c() {
SetUserParam(0);
vt_0x44();
removeAllSeHandles();
detachAllDistantSounds();
dSndSourceMgr_c::GetInstance()->unregisterSource(this);
mpOwnerGroup->unregisterSource(this);
@@ -89,21 +96,347 @@ void dSoundSource_c::setPause(bool flag, int fadeFrames) {
}
}
bool dSoundSource_c::startSound(u32 soundId) {
return startSound(soundId, nullptr);
}
bool dSoundSource_c::startSound(const char *label) {
return startSound(soundLabelToSoundId(label));
}
bool dSoundSource_c::startRemoConSound(u32 soundId) {
nw4r::snd::SoundHandle *outHandle = nullptr;
StartResult result = startSound(soundId, nullptr, &outHandle);
if (result == START_SUCCESS && EGG::AudioRmtSpeakerMgr::getWpadVolume() != 0) {
outHandle->SetOutputLineFlag(nw4r::snd::OUTPUT_LINE_REMOTE_1);
}
return result == START_SUCCESS;
}
nw4r::snd::SoundHandle *dSoundSource_c::startSound(u32 soundId, nw4r::snd::SoundHandle *handle) {
nw4r::snd::SoundHandle *outHandle = nullptr;
StartResult result = startSound(soundId, handle, &outHandle);
if (result == START_SUCCESS) {
return outHandle;
}
return nullptr;
}
nw4r::snd::SoundStartable::StartResult
dSoundSource_c::startSound(u32 soundId, nw4r::snd::SoundHandle *handle, nw4r::snd::SoundHandle **pOutHandle) {
StartResult result;
dSndSeSound1_c *seHandle = dSndSeSoundPool_c::GetInstance()->acquireSoundType1(this, soundId);
if (seHandle == nullptr) {
d_s_vt_0x1C8();
return START_ERR_USER;
}
seHandle->shiftPair(mpUnkSe);
if (handle != nullptr) {
seHandle->setHandle(handle);
} else {
handle = seHandle->getHandle();
}
field_0x11C |= 0x80000000;
result = detail_StartSound(handle, soundId, nullptr);
if (result == START_SUCCESS) {
addSeHandleType1(seHandle);
d_vt_0x58(*handle, seHandle, soundId);
d_s_vt_0x1CC(handle->GetId(), soundId, seHandle);
seHandle->onStart(this);
seHandle->onCalc(this);
} else {
dSndSeSoundPool_c::GetInstance()->releaseSoundType1(seHandle, true);
handle = nullptr;
}
d_s_vt_0x1C8();
if (pOutHandle != nullptr) {
*pOutHandle = handle;
}
return result;
}
dSndDistantSoundActor_c *
dSoundSource_c::startSoundAtPosition(u32 soundId, const nw4r::math::VEC3 *position, nw4r::snd::SoundHandle *handle) {
if (position == nullptr) {
position = &GetPosition();
}
dSndSeSound1_c *seHandle = nullptr;
if (handle != nullptr) {
seHandle = getHandleType1ForSoundHandle(handle);
}
if (seHandle == nullptr) {
seHandle = dSndSeSoundPool_c::GetInstance()->acquireSoundType1(this, soundId);
if (seHandle == nullptr) {
d_s_vt_0x1C8();
return nullptr;
}
}
dSndDistantSoundActor_c *ac = dSndDistantSoundActorPool_c::GetInstance()->acquireActor(soundId, position, this);
if (ac == nullptr) {
d_s_vt_0x1C8();
return nullptr;
}
seHandle->setAcquiredMaybe(true);
seHandle->shiftPair(mpUnkSe);
if (handle != nullptr) {
seHandle->setHandle(handle);
} else {
handle = seHandle->getHandle();
}
if (ac->startSound(soundId, *position, handle)) {
addSeHandleType1(seHandle);
seHandle->setInUseMaybe(true);
ac->d_vt_0x58(*handle, seHandle, soundId);
d_s_vt_0x1CC(handle->GetId(), soundId, seHandle);
seHandle->onStart(this);
seHandle->onCalc(this);
} else {
dSndSeSoundPool_c::GetInstance()->releaseSoundType1(seHandle, true);
ac = nullptr;
}
d_s_vt_0x1C8();
return ac;
}
s32 dSoundSource_c::getRoomId() const {
return mpActor->roomid;
}
nw4r::snd::SoundStartable::StartResult
dSoundSource_c::SetupSound(nw4r::snd::SoundHandle *pHandle, u32 soundId, const StartInfo *pStartInfo, void *) {
// TODO
return START_SUCCESS;
void dSoundSource_c::stopSounds(u32 soundId, s32 fadeFrames) {
SoundStopper handler(soundId, fadeFrames);
ForEachSound(handler, false);
}
void dSoundSource_c::d_vt_0x58() {
void dSoundSource_c::stopSounds(const char *label, s32 fadeFrames) {
stopSounds(soundLabelToSoundId(label), fadeFrames);
}
bool dSoundSource_c::holdSound(u32 soundId) {
return holdSound(soundId, nullptr);
}
bool dSoundSource_c::holdSound(const char *label) {
return holdSound(soundLabelToSoundId(label));
}
nw4r::snd::SoundHandle *dSoundSource_c::holdSound(u32 soundId, nw4r::snd::SoundHandle *handle) {
if (soundId == -1) {
return nullptr;
}
dSndSeSound2_c *seHandle = getHandleType2ForSoundId(soundId);
if (seHandle == nullptr) {
seHandle = dSndSeSoundPool_c::GetInstance()->acquireSoundType2(this, soundId);
if (seHandle == nullptr) {
d_s_vt_0x1C8();
return nullptr;
}
seHandle->shiftPair(mpUnkSe);
if (handle != nullptr) {
seHandle->setHandle(handle);
} else {
handle = seHandle->getHandle();
}
field_0x11C |= 0x80000000;
if (HoldSound(handle, soundId)) {
addSeHandleType2(seHandle);
d_vt_0x5C(*handle, seHandle, soundId, 0);
d_s_vt_0x1CC(handle->GetId(), soundId, seHandle);
seHandle->onStart(this);
seHandle->onCalc(this);
} else {
dSndSeSoundPool_c::GetInstance()->releaseSoundType2(seHandle);
handle = nullptr;
}
} else {
handle = continueHoldingSound(seHandle, soundId, nullptr, nullptr);
}
d_s_vt_0x1C8();
return handle;
}
nw4r::snd::SoundHandle *dSoundSource_c::continueHoldingSound(
dSndSeSound2_c *seHandle, u32 soundId, dSndDistantSoundActor_c *distant, const nw4r::math::VEC3 *position
) {
if (!d_s_vt_0x1AC(soundId)) {
d_s_vt_0x1C8();
return nullptr;
}
u32 actualSoundId = soundId;
if (!sIsStartingBaseSound) {
actualSoundId = d_s_vt_0x1A0(soundId, 0);
if (actualSoundId == -1) {
d_s_vt_0x1C8();
return nullptr;
}
actualSoundId = d_s_vt_0x1E8(actualSoundId);
if (actualSoundId == -1) {
d_s_vt_0x1C8();
return nullptr;
}
}
nw4r::snd::SoundHandle *handle = seHandle->getHandle();
seHandle->shiftPair(mpUnkSe);
field_0x11C |= 0x80000000;
bool ok;
if (distant != nullptr && position != nullptr) {
// not sure why we're using the original ID here
ok = distant->holdSound(soundId, *position, handle);
} else {
ok = HoldSound(handle, actualSoundId);
}
field_0x11C = 0;
field_0x154 = 0;
if (ok) {
seHandle->setField0x130(1);
d_vt_0x5C(*handle, seHandle, soundId, 0);
} else {
handle = nullptr;
}
d_s_vt_0x1C8();
return handle;
}
nw4r::snd::SoundStartable::StartResult
dSoundSource_c::SetupSound(nw4r::snd::SoundHandle *pHandle, u32 soundId, const StartInfo *pStartInfo, void *arg) {
bool holdFlag = *(bool *)arg;
if (!d_s_vt_0x1AC(soundId)) {
return onSetupError();
} else if ((field_0x11C & 0x80000000) != 0) {
return setupSound(pHandle, soundId, pStartInfo, arg, holdFlag);
} else {
return onSetupError();
}
}
nw4r::snd::SoundStartable::StartResult dSoundSource_c::setupSound(
nw4r::snd::SoundHandle *pHandle, u32 soundId, const StartInfo *pStartInfo, void *arg, bool holdFlag
) {
u32 userParam = getSomeUserParam(soundId);
if (userParam & 0x2) {
// maybe a flag for not allowing duplicates
if (getHandleType1ForSoundId(soundId) != nullptr) {
return onSetupError();
}
} else if (userParam & 0x1) {
// maybe a flag for stopping other copies
stopSoundHandles(soundId, 2);
}
u32 variantSoundId = soundId;
if (!sIsStartingBaseSound) {
u32 anotherSoundId;
if (holdFlag) {
anotherSoundId = d_s_vt_0x1A0(soundId, 1);
} else {
anotherSoundId = d_s_vt_0x194(soundId);
}
if (anotherSoundId == -1) {
return onSetupError();
}
if (userParam & 0x800) {
anotherSoundId = modifySoundId(anotherSoundId);
if (anotherSoundId == -1) {
return onSetupError();
}
}
variantSoundId = d_s_vt_0x1E8(anotherSoundId);
if (variantSoundId == -1) {
return onSetupError();
}
}
if (!holdFlag && (userParam & 0x1C000000) != 0) {
dSndDistantSoundActor_c *ac = startSoundAtPosition(variantSoundId, &GetPosition(), nullptr);
f32 volume = 0.0f;
if (ac != nullptr) {
if ((userParam & 0x10000000) != 0 && (userParam & 0xC000000) == 0) {
ac->setUseSourcePosition(true);
}
// unnecessary double check
if (!holdFlag) {
volume = getBaseSoundVolume(variantSoundId, soundId);
}
}
startBaseSoundAtPosition(soundId, &GetPosition(), volume);
d_s_vt_0x1C8();
return onSetupError();
} else {
StartResult result = dSnd3DActor_c::SetupSound(pHandle, variantSoundId, pStartInfo, arg);
if (result == START_SUCCESS && !holdFlag) {
f32 volume = getBaseSoundVolume(variantSoundId, soundId);
startBaseSound(soundId, volume);
}
d_s_vt_0x1C8();
return result;
}
}
f32 dSoundSource_c::getBaseSoundVolume(u32 variantSoundId, u32 baseSoundId) {
if (variantSoundId == baseSoundId) {
return 0.0f;
} else if (sIsStartingBaseSound) {
return 0.0f;
}
u32 volume = (dSndPlayerMgr_c::GetInstance()->getSomeUserParam(variantSoundId) >> 16) & 0xFF;
if (volume > 100) {
volume = 100;
}
return volume / 100.0f;
}
nw4r::snd::SoundHandle *dSoundSource_c::startBaseSound(u32 baseSoundId, f32 volume) {
if (volume <= 0.0f) {
return nullptr;
}
sIsStartingBaseSound = true;
nw4r::snd::SoundHandle *handle = startSound(baseSoundId, nullptr);
sIsStartingBaseSound = false;
if (handle != nullptr) {
handle->SetVolume(volume, 0);
}
return handle;
}
dSndDistantSoundActor_c *
dSoundSource_c::startBaseSoundAtPosition(u32 baseSoundId, const nw4r::math::VEC3 *position, f32 volume) {
if (volume <= 0.0f) {
return nullptr;
}
sIsStartingBaseSound = true;
dSndDistantSoundActor_c *handle = startSoundAtPosition(baseSoundId, position, nullptr);
sIsStartingBaseSound = false;
if (handle != nullptr) {
handle->getHandle()->SetVolume(volume, 0);
}
return handle;
}
nw4r::snd::SoundStartable::StartResult dSoundSource_c::onSetupError() {
d_s_vt_0x1C8();
return START_ERR_USER;
}
void dSoundSource_c::d_vt_0x58(nw4r::snd::SoundHandle &handle, dSndSeSound_c *pSound, u32 id) {
// noop
}
void dSoundSource_c::d_vt_0x5C() {
void dSoundSource_c::d_vt_0x5C(nw4r::snd::SoundHandle &handle, dSndSeSound_c *pSound, u32 id, UNKWORD) {
// noop
}
@@ -131,13 +464,200 @@ void dSoundSource_c::detachAllDistantSounds() {
}
void dSoundSource_c::pauseAllDistantSounds(bool flag, int fadeFrames) {
for (dSndDistantSoundActor_c *it = static_cast<dSndDistantSoundActor_c *>(nw4r::ut::List_GetFirst(&mDistantSoundList));
for (dSndDistantSoundActor_c *it =
static_cast<dSndDistantSoundActor_c *>(nw4r::ut::List_GetFirst(&mDistantSoundList));
it != nullptr; it = static_cast<dSndDistantSoundActor_c *>(nw4r::ut::List_GetNext(&mDistantSoundList, it))) {
it->PauseAllSound(flag, fadeFrames);
}
}
u32 dSoundSource_c::getCharacterTalkSoundId(u32 baseSoundId, dSoundSource_c *source) {
void dSoundSource_c::addSeHandleType1(dSndSeSound1_c *handle) {
if (handle == nullptr) {
return;
}
if (handle->isAttachedSource()) {
return;
}
handle->attachSource(this);
nw4r::ut::List_Append(&mHandleType1List, handle);
}
void dSoundSource_c::addSeHandleType2(dSndSeSound2_c *handle) {
if (handle == nullptr) {
return;
}
if (handle->isAttachedSource()) {
return;
}
handle->attachSource(this);
nw4r::ut::List_Append(&mHandleType2List, handle);
}
void dSoundSource_c::removeSeHandleType1(dSndSeSound1_c *handle, bool stop) {
if (handle == nullptr) {
return;
}
if (!handle->isAttachedSource()) {
return;
}
nw4r::ut::List_Remove(&mHandleType1List, handle);
dSndSeSoundPool_c::GetInstance()->releaseSoundType1(handle, stop);
}
void dSoundSource_c::removeSeHandleType2(dSndSeSound2_c *handle) {
if (handle == nullptr) {
return;
}
if (!handle->isAttachedSource()) {
return;
}
nw4r::ut::List_Remove(&mHandleType2List, handle);
dSndSeSoundPool_c::GetInstance()->releaseSoundType2(handle);
}
void dSoundSource_c::removeAllSeHandles() {
removeAllSeHandlesType1();
removeAllSeHandlesType2();
}
void dSoundSource_c::removeAllSeHandlesType1() {
dSndSeSound1_c *sound = static_cast<dSndSeSound1_c *>(nw4r::ut::List_GetFirst(&mHandleType1List));
while (sound != nullptr) {
removeSeHandleType1(sound, sound->unkRemovalCheck());
sound = static_cast<dSndSeSound1_c *>(nw4r::ut::List_GetFirst(&mHandleType1List));
}
}
void dSoundSource_c::removeAllSeHandlesType2() {
dSndSeSound2_c *sound = static_cast<dSndSeSound2_c *>(nw4r::ut::List_GetFirst(&mHandleType2List));
while (sound != nullptr) {
removeSeHandleType2(sound);
sound = static_cast<dSndSeSound2_c *>(nw4r::ut::List_GetFirst(&mHandleType2List));
}
}
void dSoundSource_c::calcHandles() {
calcHandlesType1();
calcHandlesType2();
}
void dSoundSource_c::calcHandlesType1() {
dSndSeSound1_c *next, *it;
it = static_cast<dSndSeSound1_c *>(nw4r::ut::List_GetFirst(&mHandleType1List));
while (it != nullptr) {
next = static_cast<dSndSeSound1_c *>(nw4r::ut::List_GetNext(&mHandleType1List, it));
if (it->isAttachedSound()) {
it->calc(this);
} else {
removeSeHandleType1(it, true);
}
it = next;
}
}
void dSoundSource_c::calcHandlesType2() {
dSndSeSound2_c *next, *it;
it = static_cast<dSndSeSound2_c *>(nw4r::ut::List_GetFirst(&mHandleType2List));
while (it != nullptr) {
next = static_cast<dSndSeSound2_c *>(nw4r::ut::List_GetNext(&mHandleType2List, it));
if (it->isAttachedSound()) {
if (it->calcTimer()) {
continueHoldingSound(it, it->getHandle()->GetId(), nullptr, nullptr);
}
it->calc(this);
} else {
removeSeHandleType2(it);
}
it = next;
}
}
dSndSeSound1_c *dSoundSource_c::getHandleType1ForSoundId(u32 soundId) {
dSndSeSound1_c *sound = static_cast<dSndSeSound1_c *>(nw4r::ut::List_GetFirst(&mHandleType1List));
while (sound != nullptr) {
if (sound->isSoundId(soundId) || sound->getHandle()->GetId() == soundId) {
return sound;
}
sound = static_cast<dSndSeSound1_c *>(nw4r::ut::List_GetNext(&mHandleType1List, sound));
}
return nullptr;
}
dSndSeSound1_c *dSoundSource_c::getHandleType1ForSoundHandle(nw4r::snd::SoundHandle *handle) {
dSndSeSound1_c *sound = static_cast<dSndSeSound1_c *>(nw4r::ut::List_GetFirst(&mHandleType1List));
while (sound != nullptr) {
if (sound->getHandle() == handle) {
return sound;
}
sound = static_cast<dSndSeSound1_c *>(nw4r::ut::List_GetNext(&mHandleType1List, sound));
}
return nullptr;
}
dSndSeSound2_c *dSoundSource_c::getHandleType2ForSoundId(u32 soundId) {
dSndSeSound2_c *sound = static_cast<dSndSeSound2_c *>(nw4r::ut::List_GetFirst(&mHandleType2List));
while (sound != nullptr) {
if (sound->isSoundId(soundId) || sound->getHandle()->GetId() == soundId) {
return sound;
}
sound = static_cast<dSndSeSound2_c *>(nw4r::ut::List_GetNext(&mHandleType2List, sound));
}
return nullptr;
}
void dSoundSource_c::stopSoundHandles(u32 soundId, s32 fadeFrames) {
// TODO: Weird declaration order required for regswaps
{
dSndSeSound1_c *next, *it;
it = static_cast<dSndSeSound1_c *>(nw4r::ut::List_GetFirst(&mHandleType1List));
while (it != nullptr) {
next = static_cast<dSndSeSound1_c *>(nw4r::ut::List_GetNext(&mHandleType1List, it));
if (it->isSoundId(soundId) || it->getHandle()->GetId() == soundId) {
it->getHandle()->Stop(fadeFrames);
removeSeHandleType1(it, true);
}
it = next;
}
}
{
dSndSeSound2_c *it, *next;
it = static_cast<dSndSeSound2_c *>(nw4r::ut::List_GetFirst(&mHandleType2List));
while (it != nullptr) {
next = static_cast<dSndSeSound2_c *>(nw4r::ut::List_GetNext(&mHandleType2List, it));
if (it->isSoundId(soundId) || it->getHandle()->GetId() == soundId) {
it->getHandle()->Stop(fadeFrames);
removeSeHandleType2(it);
}
it = next;
}
}
}
u32 dSoundSource_c::modifySoundId(u32 baseSoundId) {
if (baseSoundId != -1) {
SizedString<64> label;
// maybe an inline
const char *baseLabel = nullptr;
if (dSndMgr_c::GetInstance()->getArchive() != nullptr) {
baseLabel = dSndMgr_c::GetInstance()->getArchive()->GetSoundLabelString(baseSoundId);
}
const char *charLabel = getName();
label.sprintf("%s_%s", baseLabel, charLabel);
u32 newLabel = dSndPlayerMgr_c::GetInstance()->convertLabelStringToSoundId(label);
if (newLabel != -1) {
return newLabel;
}
}
return baseSoundId;
}
u32 dSoundSource_c::modifySoundId(u32 baseSoundId, dSoundSource_c *source) {
if (baseSoundId != -1 && source != nullptr) {
SizedString<64> label;
+1 -1
View File
@@ -199,6 +199,6 @@ bool dSndStateMgr_c::isSeekerStoneStage(const char *stageName, s32 layer) {
return false;
}
bool isInStage(const char *stageName) {
bool dSndStateMgr_c::isInStage(const char *stageName) {
return !std::strcmp(dScGame_c::currentSpawnInfo.getStageName(), stageName);
}
+1 -1
View File
@@ -32,7 +32,7 @@ void PlayerParamSet::Init()
biquadType = 0;
biquadValue = 0.0f;
remoteFilter = 0;
outputLineFlag = 1;
outputLineFlag = OUTPUT_LINE_MAIN;
mainOutVolume = 1.0f;
mainSend = 0.0f;
panMode = PAN_MODE_DUAL;
+1 -1
View File
@@ -100,7 +100,7 @@ void BasicSound::InitParam()
mLpfFreq = 0.0f;
mBiquadFilterType = 0;
mBiquadFilterValue = 0.0f;
mOutputLineFlag = mSoundPlayer ? mSoundPlayer->GetDefaultOutputLine() : 1;
mOutputLineFlag = mSoundPlayer ? mSoundPlayer->GetDefaultOutputLine() : OUTPUT_LINE_MAIN;
mMainOutVolume = 1.0f;
mMainSend = 0.0f;
// clang-format on
+1 -1
View File
@@ -143,7 +143,7 @@ void Channel::InitParam(Callback *callback, u32 callbackData)
mBiquadType = 0;
mBiquadValue = 0.0f;
mRemoteFilter = 0;
mOutputLineFlag = 1;
mOutputLineFlag = OUTPUT_LINE_MAIN;
mMainOutVolume = 1.0f;
mMainSend = 0.0f;
+1 -1
View File
@@ -34,7 +34,7 @@ SoundPlayer::SoundPlayer() :
mPlayableLimit (INT_MAX),
mVolume (1.0f),
mLpfFreq (0.0f),
mOutputLineFlag (1),
mOutputLineFlag (OUTPUT_LINE_MAIN),
mMainOutVolume (1.0f),
mBiquadType (0),
mBiquadValue (0.0f),
+3 -3
View File
@@ -129,7 +129,7 @@ void Voice::InitParam(int channelCount, int voiceOutCount, Callback *callback,
mBiquadValue = 0.0f;
mPan = 0.0f;
mSurroundPan = 0.0f;
mOutputLineFlag = 1;
mOutputLineFlag = OUTPUT_LINE_MAIN;
mMainOutVolume = 1.0f;
mMainSend = 1.0f;
@@ -873,7 +873,7 @@ bool Voice::CalcAxMix()
CalcMixParam(channelIndex, voiceOutIndex, &mix, &rmtmix);
nextUpdateFlag |= axVoice->SetMix(mix);
if (mOutputLineFlag == 0 || mOutputLineFlag == 1) {
if (mOutputLineFlag == 0 || mOutputLineFlag == OUTPUT_LINE_MAIN) {
axVoice->EnableRemote(false);
} else {
axVoice->EnableRemote(true);
@@ -1077,7 +1077,7 @@ void Voice::CalcMixParam(int channelIndex, int voiceOutIndex,
f32 fxSendB = 0.0f;
f32 fxSendC = 0.0f;
if (mOutputLineFlag & 1) // OUTPUT_LINE_MAIN
if (mOutputLineFlag & OUTPUT_LINE_MAIN)
{
mainVolume = mMainOutVolume;
mainSend = mMainSend;