From 83456a9cd8a15b6c27d29f09c72ad1f09bc2ed60 Mon Sep 17 00:00:00 2001 From: robojumper Date: Fri, 30 May 2025 22:21:49 +0200 Subject: [PATCH 01/22] start matching some d/snd things --- config/SOUE01/splits.txt | 32 +- config/SOUE01/symbols.txt | 386 +++++++++--------- configure.py | 14 +- include/d/a/d_a_base.h | 83 +--- include/d/snd/d_snd_3d_actor.h | 94 +++++ include/d/snd/d_snd_3d_engine.h | 18 + include/d/snd/d_snd_3d_manager.h | 66 +++ include/d/snd/d_snd_actor.h | 12 + include/d/snd/d_snd_checkers.h | 22 + include/d/snd/d_snd_mgr.h | 32 ++ include/d/snd/d_snd_player_mgr.h | 61 +++ include/d/snd/d_snd_source.h | 167 ++++++++ include/d/snd/d_snd_util.h | 42 ++ include/egg/audio/eggAudioArcPlayerMgr.h | 31 +- include/egg/audio/eggAudioHeapMgr.h | 39 +- include/egg/audio/eggAudioUtility.h | 2 +- include/egg/core/eggDvdRipper.h | 24 +- include/egg/gfx/eggCamera.h | 19 +- include/egg/math/eggMatrix.h | 9 + include/nw4r/lyt/lyt_layout.h | 2 +- include/nw4r/snd/snd_BasicSound.h | 62 +-- include/nw4r/snd/snd_Sound3DActor.h | 7 + include/nw4r/snd/snd_Sound3DEngine.h | 2 +- include/nw4r/snd/snd_Sound3DManager.h | 8 + include/nw4r/snd/snd_SoundHandle.h | 4 + include/sized_string.h | 1 + include/sound_mgrs/sound_audio_manager.h | 13 - include/toBeSorted/d_d3d.h | 4 +- include/toBeSorted/music_mgrs.h | 23 +- .../MSL/MSL_C/MSL_Common/Include/cmath | 7 + src/REL/d/t/d_t_sound_area.cpp | 12 +- src/d/a/d_a_base.cpp | 6 +- src/d/d_player_mdl.cpp | 6 +- src/d/snd/d_snd_3d_actor.cpp | 96 +++++ src/d/snd/d_snd_3d_engine.cpp | 56 +++ src/d/snd/d_snd_3d_manager.cpp | 135 ++++++ src/d/snd/d_snd_actor.cpp | 66 +++ src/d/snd/d_snd_mgr.cpp | 58 +++ src/d/snd/d_snd_player_mgr.cpp | 86 ++++ src/d/snd/d_snd_source.cpp | 94 +++++ src/d/snd/mgr/d_snd_mgr_unk_11.cpp | 36 ++ src/toBeSorted/d_d3d.cpp | 6 +- src/toBeSorted/sound_info.cpp | 2 +- 43 files changed, 1561 insertions(+), 384 deletions(-) create mode 100644 include/d/snd/d_snd_3d_actor.h create mode 100644 include/d/snd/d_snd_3d_engine.h create mode 100644 include/d/snd/d_snd_3d_manager.h create mode 100644 include/d/snd/d_snd_actor.h create mode 100644 include/d/snd/d_snd_checkers.h create mode 100644 include/d/snd/d_snd_mgr.h create mode 100644 include/d/snd/d_snd_player_mgr.h create mode 100644 include/d/snd/d_snd_source.h create mode 100644 include/d/snd/d_snd_util.h delete mode 100644 include/sound_mgrs/sound_audio_manager.h create mode 100644 src/d/snd/d_snd_3d_actor.cpp create mode 100644 src/d/snd/d_snd_3d_engine.cpp create mode 100644 src/d/snd/d_snd_3d_manager.cpp create mode 100644 src/d/snd/d_snd_actor.cpp create mode 100644 src/d/snd/d_snd_mgr.cpp create mode 100644 src/d/snd/d_snd_player_mgr.cpp create mode 100644 src/d/snd/d_snd_source.cpp create mode 100644 src/d/snd/mgr/d_snd_mgr_unk_11.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 773fb936..fbff92a4 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2346,27 +2346,40 @@ toBeSorted/col/cc/misc_unks.cpp: .text start:0x803598D0 end:0x80359D20 align:16 .sbss start:0x80575D28 end:0x80575D30 -d/snd/d_snd.cpp: +d/snd/d_snd_mgr.cpp: .text start:0x80359D20 end:0x8035A558 align:16 + .data start:0x805485D0 end:0x80548678 + .sbss start:0x80575D30 end:0x80575D38 d/snd/d_snd_actor.cpp: - .text start:0x8035A560 end:0x8035BB78 align:16 + .text start:0x8035A560 end:0x8035A898 align:16 + .data start:0x80548678 end:0x805486A0 -d/snd/d_snd_engine.cpp: +d/snd/d_snd_3d_actor.cpp: + .text start:0x8035A8A0 end:0x8035BB78 align:16 + .data start:0x805486B0 end:0x80548710 + .sdata2 start:0x8057D2C0 end:0x8057D308 + +d/snd/d_snd_3d_engine.cpp: .text start:0x8035BB80 end:0x8035C3F0 align:16 + .data start:0x80548710 end:0x80548730 + .sdata2 start:0x8057D308 end:0x8057D368 d/snd/d_snd_unk_component_1.cpp: .text start:0x8035C3F0 end:0x8035DA88 align:16 -d/snd/mgr/d_snd_mgr_bgm.cpp: +d/snd/d_snd_player_mgr.cpp: .text start:0x8035DA90 end:0x8035F010 align:16 + .data start:0x80548758 end:0x805487A0 d/snd/mgr/d_snd_mgr_unk1.cpp: .text start:0x8035F010 end:0x80360C28 align:16 .ctors start:0x804DB914 end:0x804DB918 -d/snd/mgr/d_snd_mgr_unk3.cpp: +d/snd/d_snd_3d_manager.cpp: .text start:0x80360C30 end:0x8036145C align:16 + .data start:0x805487D0 end:0x805487E0 + .sdata2 start:0x8057D3B8 end:0x8057D3F8 d/snd/mgr/d_snd_mgr_enemy.cpp: .text start:0x80361460 end:0x8036642C align:16 @@ -2382,9 +2395,14 @@ d/snd/mgr/d_snd_mgr_unk_5.cpp: .text start:0x8037F8C0 end:0x803864C8 align:16 .ctors start:0x804DB91C end:0x804DB920 -d/snd/mgr/d_snd_mgr_unk_6.cpp: - .text start:0x803864D0 end:0x8038C408 align:16 +d/snd/mgr/d_snd_mgr_unk_13.cpp: + .text start:0x803864D0 end:0x803889BC align:16 + .data start:0x8054A680 end:0x8054A7D0 + +d/snd/d_snd_source.cpp: + .text start:0x803889C0 end:0x8038C408 align:16 .ctors start:0x804DB920 end:0x804DB924 + .data start:0x8054A7D0 end:0x8054AAE8 d/snd/mgr/d_snd_mgr_unk_7.cpp: .text start:0x8038C410 end:0x8038EBF0 align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index b51f8ce4..ec4c9298 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -1022,7 +1022,7 @@ fn_8002C010 = .text:0x8002C010; // type:function size:0x58 fn_8002C070 = .text:0x8002C070; // type:function size:0x58 fn_8002C0D0 = .text:0x8002C0D0; // type:function size:0x58 fn_8002C130 = .text:0x8002C130; // type:function size:0x24 -fn_8002C160 = .text:0x8002C160; // type:function size:0x40 +__dt__16dSoundSourceIf_cFv = .text:0x8002C160; // type:function size:0x40 fn_8002C1A0 = .text:0x8002C1A0; // type:function size:0xB0 fn_8002C250 = .text:0x8002C250; // type:function size:0xB8 fn_8002C310 = .text:0x8002C310; // type:function size:0x90 @@ -19805,11 +19805,11 @@ fn_80359BC0 = .text:0x80359BC0; // type:function size:0x84 fn_80359C50 = .text:0x80359C50; // type:function size:0x1C fn_80359C70 = .text:0x80359C70; // type:function size:0x8 fn_80359C80 = .text:0x80359C80; // type:function size:0xA0 -SndAudioMgr____ct = .text:0x80359D20; // type:function size:0x9C -SndAudioMgr__initialize = .text:0x80359DC0; // type:function size:0xEC -fn_80359EB0 = .text:0x80359EB0; // type:function size:0x10 -SndAudioMgr__calc = .text:0x80359EC0; // type:function size:0xB8 -fn_80359F80 = .text:0x80359F80; // type:function size:0x2C +__ct__9dSndMgr_cFv = .text:0x80359D20; // type:function size:0x9C +initialize__9dSndMgr_cFPQ23EGG4HeapUl = .text:0x80359DC0; // type:function size:0xEC +initHbm__9dSndMgr_cFUl = .text:0x80359EB0; // type:function size:0x10 +calc__9dSndMgr_cFv = .text:0x80359EC0; // type:function size:0xB8 +restoreEffectsCallback__9dSndMgr_cFv = .text:0x80359F80; // type:function size:0x2C stateProc__Q23EGG12SoundHeapMgrFv = .text:0x80359FB0; // type:function size:0xD4 loadState__Q23EGG12SoundHeapMgrFl = .text:0x8035A090; // type:function size:0x8C getCurrentLevel__Q23EGG12SoundHeapMgrFv = .text:0x8035A120; // type:function size:0x54 @@ -19823,8 +19823,8 @@ startSound__Q23EGG9ArcPlayerFPQ34nw4r3snd11SoundHandleUl = .text:0x8035A360; // startSound__Q23EGG9ArcPlayerFPQ34nw4r3snd11SoundHandleUi = .text:0x8035A3A0; // type:function size:0x34 startSound__Q23EGG9ArcPlayerFPQ34nw4r3snd11SoundHandlePCc = .text:0x8035A3E0; // type:function size:0x70 setupMemoryArchive__Q23EGG9ArcPlayerFPCvPQ34nw4r3snd9SoundHeapl = .text:0x8035A450; // type:function size:0x10 -fn_8035A460 = .text:0x8035A460; // type:function size:0x58 -fn_8035A4C0 = .text:0x8035A4C0; // type:function size:0x8 +__dt__9dSndMgr_cFv = .text:0x8035A460; // type:function size:0x58 +@248@calc__9dSndMgr_cFv = .text:0x8035A4C0; // type:function size:0x8 @248@loadGroup__Q23EGG14SimpleAudioMgrFUiPQ34nw4r3snd9SoundHeapUl = .text:0x8035A4D0; // type:function size:0x8 @248@loadGroup__Q23EGG14SimpleAudioMgrFiPQ34nw4r3snd9SoundHeapUl = .text:0x8035A4E0; // type:function size:0x8 @248@loadGroup__Q23EGG14SimpleAudioMgrFUlPQ34nw4r3snd9SoundHeapUl = .text:0x8035A4F0; // type:function size:0x8 @@ -19833,13 +19833,13 @@ fn_8035A4C0 = .text:0x8035A4C0; // type:function size:0x8 @248@setupMemoryArchive__Q23EGG14SimpleAudioMgrFPCvPQ34nw4r3snd9SoundHeap = .text:0x8035A520; // type:function size:0x8 @248@openNandArchive__Q23EGG14SimpleAudioMgrFPCcPQ34nw4r3snd9SoundHeap = .text:0x8035A530; // type:function size:0x8 @248@openDvdArchive__Q23EGG14SimpleAudioMgrFPCcPQ34nw4r3snd9SoundHeap = .text:0x8035A540; // type:function size:0x8 -fn_8035A550 = .text:0x8035A550; // type:function size:0x8 -fn_8035A560 = .text:0x8035A560; // type:function size:0x3C -fn_8035A5A0 = .text:0x8035A5A0; // type:function size:0x54 -fn_8035A600 = .text:0x8035A600; // type:function size:0x240 -fn_8035A840 = .text:0x8035A840; // type:function size:0x58 -fn_8035A8A0 = .text:0x8035A8A0; // type:function size:0xE8 -fn_8035A990 = .text:0x8035A990; // type:function size:0x40 +@248@__dt__9dSndMgr_cFv = .text:0x8035A550; // type:function size:0x8 +__ct__11dSndActor_cFRQ34nw4r3snd18SoundArchivePlayer = .text:0x8035A560; // type:function size:0x3C +__dt__Q34nw4r3snd11SoundHandleFv = .text:0x8035A5A0; // type:function size:0x54 scope:weak +__cl__22SoundPropertiesCheckerFRQ34nw4r3snd11SoundHandle = .text:0x8035A600; // type:function size:0x240 +__dt__11dSndActor_cFv = .text:0x8035A840; // type:function size:0x58 scope:weak +__ct__13dSnd3DActor_cFPvUc = .text:0x8035A8A0; // type:function size:0xE8 +d_vt_0x34__13dSnd3DActor_cFRCQ34nw4r4math4VEC3 = .text:0x8035A990; // type:function size:0x40 fn_8035A9D0 = .text:0x8035A9D0; // type:function size:0x2C fn_8035AA00 = .text:0x8035AA00; // type:function size:0x30 fn_8035AA30 = .text:0x8035AA30; // type:function size:0x44 @@ -19850,37 +19850,37 @@ fn_8035AB60 = .text:0x8035AB60; // type:function size:0x78 fn_8035ABE0 = .text:0x8035ABE0; // type:function size:0x44 fn_8035AC30 = .text:0x8035AC30; // type:function size:0x28 fn_8035AC60 = .text:0x8035AC60; // type:function size:0x50 -fn_8035ACB0 = .text:0x8035ACB0; // type:function size:0xBC -fn_8035AD70 = .text:0x8035AD70; // type:function size:0x3C -fn_8035ADB0 = .text:0x8035ADB0; // type:function size:0xFC -fn_8035AEB0 = .text:0x8035AEB0; // type:function size:0x3C +updatePositionRelativeToPlayer__13dSnd3DActor_cFv = .text:0x8035ACB0; // type:function size:0xBC +getPositionRelativeToPlayer__13dSnd3DActor_cFv = .text:0x8035AD70; // type:function size:0x3C +updateDistanceToPlayer__13dSnd3DActor_cFv = .text:0x8035ADB0; // type:function size:0xFC +getDistanceToPlayer__13dSnd3DActor_cFv = .text:0x8035AEB0; // type:function size:0x3C fn_8035AEF0 = .text:0x8035AEF0; // type:function size:0xE0 fn_8035AFD0 = .text:0x8035AFD0; // type:function size:0x124 fn_8035B100 = .text:0x8035B100; // type:function size:0xB4 fn_8035B1C0 = .text:0x8035B1C0; // type:function size:0x330 fn_8035B4F0 = .text:0x8035B4F0; // type:function size:0x144 fn_8035B640 = .text:0x8035B640; // type:function size:0x1FC -fn_8035B840 = .text:0x8035B840; // type:function size:0x60 -fn_8035B8A0 = .text:0x8035B8A0; // type:function size:0xCC -fn_8035B970 = .text:0x8035B970; // type:function size:0x34 +hasPlayingSounds__13dSnd3DActor_cCFv = .text:0x8035B840; // type:function size:0x60 +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 -fn_8035BA50 = .text:0x8035BA50; // type:function size:0x8 -fn_8035BA60 = .text:0x8035BA60; // type:function size:0x58 -fn_8035BAC0 = .text:0x8035BAC0; // type:function size:0x58 -fn_8035BB20 = .text:0x8035BB20; // type:function size:0x8 -fn_8035BB30 = .text:0x8035BB30; // type:function size:0x8 -fn_8035BB40 = .text:0x8035BB40; // type:function size:0x8 -fn_8035BB50 = .text:0x8035BB50; // type:function size:0x8 +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 +d_vt_0x44__13dSnd3DActor_cFv = .text:0x8035BB20; // type:function size:0x8 +d_vt_0x40__13dSnd3DActor_cFv = .text:0x8035BB30; // type:function size:0x8 +d_vt_0x3C__13dSnd3DActor_cFv = .text:0x8035BB40; // type:function size:0x8 +d_vt_0x30__13dSnd3DActor_cFv = .text:0x8035BB50; // type:function size:0x8 @84@at_0x0c__Q34nw4r3snd12Sound3DActorFPvPQ44nw4r3snd6detail10BasicSound = .text:0x8035BB60; // type:function size:0x8 -fn_8035BB70 = .text:0x8035BB70; // type:function size:0x8 -fn_8035BB80 = .text:0x8035BB80; // type:function size:0x3C +@84@__dt__13dSnd3DActor_cFv = .text:0x8035BB70; // type:function size:0x8 +__ct__14dSnd3DEngine_cFv = .text:0x8035BB80; // type:function size:0x3C __dt__Q34nw4r3snd13Sound3DEngineFv = .text:0x8035BBC0; // type:function size:0x40 -fn_8035BC00 = .text:0x8035BC00; // type:function size:0x428 -fn_8035C030 = .text:0x8035C030; // type:function size:0x188 +UpdateAmbientParam__14dSnd3DEngine_cFPCQ34nw4r3snd14Sound3DManagerPCQ34nw4r3snd12Sound3DParamUlUlPQ34nw4r3snd17SoundAmbientParam = .text:0x8035BC00; // type:function size:0x428 +CalcPitch__FPCQ34nw4r4math4VEC3fRCQ34nw4r3snd14Sound3DManagerRCQ34nw4r3snd15Sound3DListenerRCQ34nw4r3snd12Sound3DParamPf = .text:0x8035C030; // type:function size:0x188 fn_8035C1C0 = .text:0x8035C1C0; // type:function size:0xDC fn_8035C2A0 = .text:0x8035C2A0; // type:function size:0x110 -fn_8035C3B0 = .text:0x8035C3B0; // type:function size:0x40 +__dt__14dSnd3DEngine_cFv = .text:0x8035C3B0; // type:function size:0x40 fn_8035C3F0 = .text:0x8035C3F0; // type:function size:0x2F8 fn_8035C6F0 = .text:0x8035C6F0; // type:function size:0x44 fn_8035C740 = .text:0x8035C740; // type:function size:0x44 @@ -19919,11 +19919,11 @@ fn_8035D940 = .text:0x8035D940; // type:function size:0x58 fn_8035D9A0 = .text:0x8035D9A0; // type:function size:0x68 fn_8035DA10 = .text:0x8035DA10; // type:function size:0x4C fn_8035DA60 = .text:0x8035DA60; // type:function size:0x28 -getSoundArchivePath = .text:0x8035DA90; // type:function size:0xC -BgmManager__dtor = .text:0x8035DAA0; // type:function size:0x78 -initBgmMgr = .text:0x8035DB20; // type:function size:0x48 -BgmMgr__deref = .text:0x8035DB70; // type:function size:0x10 -BgmManager__ctor = .text:0x8035DB80; // type:function size:0x78 +getSoundArchivePath__15dSndPlayerMgr_cFv = .text:0x8035DA90; // type:function size:0xC +__dt__33SndMgrDisposer<15dSndPlayerMgr_c>Fv = .text:0x8035DAA0; // type:function size:0x78 +create__33SndMgrDisposer<15dSndPlayerMgr_c>Fv = .text:0x8035DB20; // type:function size:0x48 +remove__33SndMgrDisposer<15dSndPlayerMgr_c>Fv = .text:0x8035DB70; // type:function size:0x10 +__ct__15dSndPlayerMgr_cFv = .text:0x8035DB80; // type:function size:0x78 fn_8035DC00 = .text:0x8035DC00; // type:function size:0x44 fn_8035DC50 = .text:0x8035DC50; // type:function size:0x8C fn_8035DCE0 = .text:0x8035DCE0; // type:function size:0x38 @@ -19935,7 +19935,7 @@ fn_8035DE60 = .text:0x8035DE60; // type:function size:0x38 fn_8035DEA0 = .text:0x8035DEA0; // type:function size:0x50 fn_8035DEF0 = .text:0x8035DEF0; // type:function size:0x38 fn_8035DF30 = .text:0x8035DF30; // type:function size:0x24 -fn_8035DF60 = .text:0x8035DF60; // type:function size:0x54 +getFreeSize__15dSndPlayerMgr_cFv = .text:0x8035DF60; // type:function size:0x54 fn_8035DFC0 = .text:0x8035DFC0; // type:function size:0x3C fn_8035E000 = .text:0x8035E000; // type:function size:0xD4 fn_8035E0E0 = .text:0x8035E0E0; // type:function size:0xCC @@ -19962,8 +19962,8 @@ fn_8035E860 = .text:0x8035E860; // type:function size:0x14 fn_8035E880 = .text:0x8035E880; // type:function size:0x14 fn_8035E8A0 = .text:0x8035E8A0; // type:function size:0xC fn_8035E8B0 = .text:0x8035E8B0; // type:function size:0xC -fn_8035E8C0 = .text:0x8035E8C0; // type:function size:0x90 -fn_8035E950 = .text:0x8035E950; // type:function size:0x6C +startSound__15dSndPlayerMgr_cFPQ34nw4r3snd11SoundHandleUlPCQ44nw4r3snd14SoundStartable9StartInfo = .text:0x8035E8C0; // type:function size:0x90 +startSound__15dSndPlayerMgr_cFPQ34nw4r3snd11SoundHandlePCcPCQ44nw4r3snd14SoundStartable9StartInfo = .text:0x8035E950; // type:function size:0x6C fn_8035E9C0 = .text:0x8035E9C0; // type:function size:0x80 fn_8035EA40 = .text:0x8035EA40; // type:function size:0x64 fn_8035EAB0 = .text:0x8035EAB0; // type:function size:0x28 @@ -19975,12 +19975,12 @@ fn_8035EB50 = .text:0x8035EB50; // type:function size:0x3C fn_8035EB90 = .text:0x8035EB90; // type:function size:0x80 fn_8035EC10 = .text:0x8035EC10; // type:function size:0x5C fn_8035EC70 = .text:0x8035EC70; // type:function size:0x84 -playSomeSound = .text:0x8035ED00; // type:function size:0x3C -fn_8035ED40 = .text:0x8035ED40; // type:function size:0x44 +convertLabelStringToSoundId__15dSndPlayerMgr_cCFPCc = .text:0x8035ED00; // type:function size:0x3C +getSoundArchivePlayerForType__15dSndPlayerMgr_cFUc = .text:0x8035ED40; // type:function size:0x44 fn_8035ED90 = .text:0x8035ED90; // type:function size:0x5C -fn_8035EDF0 = .text:0x8035EDF0; // type:function size:0x198 +loadDemoArchive__15dSndPlayerMgr_cFPCc = .text:0x8035EDF0; // type:function size:0x198 fn_8035EF90 = .text:0x8035EF90; // type:function size:0x38 -fn_8035EFD0 = .text:0x8035EFD0; // type:function size:0x40 +calc__15dSndPlayerMgr_cFv = .text:0x8035EFD0; // type:function size:0x40 fn_8035F010 = .text:0x8035F010; // type:function size:0x20 fn_8035F030 = .text:0x8035F030; // type:function size:0x1C fn_8035F050 = .text:0x8035F050; // type:function size:0x50 @@ -20034,18 +20034,18 @@ fn_80360AD0 = .text:0x80360AD0; // type:function size:0x5C fn_80360B30 = .text:0x80360B30; // type:function size:0x5C fn_80360B90 = .text:0x80360B90; // type:function size:0x64 fn_80360C00 = .text:0x80360C00; // type:function size:0x28 -fn_80360C30 = .text:0x80360C30; // type:function size:0x78 -fn_80360CB0 = .text:0x80360CB0; // type:function size:0x48 -fn_80360D00 = .text:0x80360D00; // type:function size:0x10 -fn_80360D10 = .text:0x80360D10; // type:function size:0xE4 -__dt__Q34nw4r3snd14Sound3DManagerFv = .text:0x80360E00; // type:function size:0x60 -fn_80360E60 = .text:0x80360E60; // type:function size:0x118 -fn_80360F80 = .text:0x80360F80; // type:function size:0xC -fn_80360F90 = .text:0x80360F90; // type:function size:0x20 -fn_80360FB0 = .text:0x80360FB0; // type:function size:0xC -fn_80360FC0 = .text:0x80360FC0; // type:function size:0x18 -fn_80360FE0 = .text:0x80360FE0; // type:function size:0x390 -fn_80361370 = .text:0x80361370; // type:function size:0xEC +__dt__33SndMgrDisposer<15dSnd3DManager_c>Fv = .text:0x80360C30; // type:function size:0x78 scope:weak +create__33SndMgrDisposer<15dSnd3DManager_c>Fv = .text:0x80360CB0; // type:function size:0x48 scope:weak +remove__33SndMgrDisposer<15dSnd3DManager_c>Fv = .text:0x80360D00; // type:function size:0x10 scope:weak +__ct__15dSnd3DManager_cFv = .text:0x80360D10; // type:function size:0xE4 +__dt__Q34nw4r3snd14Sound3DManagerFv = .text:0x80360E00; // type:function size:0x60 scope:weak +setup__15dSnd3DManager_cFv = .text:0x80360E60; // type:function size:0x118 +resetCamDistance__15dSnd3DManager_cFv = .text:0x80360F80; // type:function size:0xC +setCamDistance__15dSnd3DManager_cFf = .text:0x80360F90; // type:function size:0x20 +calc__15dSnd3DManager_cFv = .text:0x80360FB0; // type:function size:0xC +clearState__15dSnd3DManager_cFv = .text:0x80360FC0; // type:function size:0x18 +updateFromCamera__15dSnd3DManager_cFRQ23EGG12LookAtCamera = .text:0x80360FE0; // type:function size:0x390 +updateListenerPos__15dSnd3DManager_cFf = .text:0x80361370; // type:function size:0xEC EnemySoundMgr__dtor = .text:0x80361460; // type:function size:0x78 initEnemySoundMgr = .text:0x803614E0; // type:function size:0x48 EnemySoundMgr__deref = .text:0x80361530; // type:function size:0x10 @@ -20876,7 +20876,7 @@ playButtonPressSoundWhenAdvancingTextBoxes__17SmallSoundManagerFf = .text:0x8037 fn_8037F0E0 = .text:0x8037F0E0; // type:function size:0xC fn_8037F0F0 = .text:0x8037F0F0; // type:function size:0x60 fn_8037F150 = .text:0x8037F150; // type:function size:0x6D0 -fn_8037F820 = .text:0x8037F820; // type:function size:0x8 +d_s_vt_0x17C__14dSoundSource_cFv = .text:0x8037F820; // type:function size:0x8 fn_8037F830 = .text:0x8037F830; // type:function size:0x8 fn_8037F840 = .text:0x8037F840; // type:function size:0x74 fn_8037F8C0 = .text:0x8037F8C0; // type:function size:0x78 @@ -20942,7 +20942,7 @@ fn_80382210 = .text:0x80382210; // type:function size:0xE8 fn_80382300 = .text:0x80382300; // type:function size:0x28 fn_80382330 = .text:0x80382330; // type:function size:0x7C fn_803823B0 = .text:0x803823B0; // type:function size:0x18 -fn_803823D0 = .text:0x803823D0; // type:function size:0x8 +d_s_vt_0x1E0__14dSoundSource_cFv = .text:0x803823D0; // type:function size:0x8 fn_803823E0 = .text:0x803823E0; // type:function size:0x14 fn_80382400 = .text:0x80382400; // type:function size:0xC fn_80382410 = .text:0x80382410; // type:function size:0xC0 @@ -20957,9 +20957,9 @@ fn_803837C0 = .text:0x803837C0; // type:function size:0x9C fn_80383860 = .text:0x80383860; // type:function size:0x94 fn_80383900 = .text:0x80383900; // type:function size:0x58 fn_80383960 = .text:0x80383960; // type:function size:0x9C -fn_80383A00 = .text:0x80383A00; // type:function size:0x8 -fn_80383A10 = .text:0x80383A10; // type:function size:0x8 -fn_80383A20 = .text:0x80383A20; // type:function size:0x4 +d_s_vt_0x180__14dSoundSource_cFv = .text:0x80383A00; // type:function size:0x8 +d_s_vt_0x1DC__14dSoundSource_cFv = .text:0x80383A10; // type:function size:0x8 +d_s_vt_0x1D8__14dSoundSource_cFv = .text:0x80383A20; // type:function size:0x4 fn_80383A30 = .text:0x80383A30; // type:function size:0x78 initEnemyBgmRelatedMgr = .text:0x80383AB0; // type:function size:0x48 fn_80383B00 = .text:0x80383B00; // type:function size:0x10 @@ -21019,14 +21019,14 @@ fn_803858D0 = .text:0x803858D0; // type:function size:0xA0 fn_80385970 = .text:0x80385970; // type:function size:0x90 fn_80385A00 = .text:0x80385A00; // type:function size:0x8 fn_80385A10 = .text:0x80385A10; // type:function size:0x4 -fn_80385A20 = .text:0x80385A20; // type:function size:0x8 +d_s_vt_0x1D4__14dSoundSource_cFv = .text:0x80385A20; // type:function size:0x8 fn_80385A30 = .text:0x80385A30; // type:function size:0x4 fn_80385A40 = .text:0x80385A40; // type:function size:0x4 fn_80385A50 = .text:0x80385A50; // type:function size:0x4 fn_80385A60 = .text:0x80385A60; // type:function size:0x8 fn_80385A70 = .text:0x80385A70; // type:function size:0x4 -fn_80385A80 = .text:0x80385A80; // type:function size:0x4 -fn_80385A90 = .text:0x80385A90; // type:function size:0x34 +d_s_vt_0x1CC__14dSoundSource_cFv = .text:0x80385A80; // type:function size:0x4 +d_s_vt_0x1C0__14dSoundSource_cFv = .text:0x80385A90; // type:function size:0x34 fn_80385AD0 = .text:0x80385AD0; // type:function size:0x8 fn_80385AE0 = .text:0x80385AE0; // type:function size:0x8 fn_80385AF0 = .text:0x80385AF0; // type:function size:0x4 @@ -21038,7 +21038,7 @@ fn_80385B40 = .text:0x80385B40; // type:function size:0x8 fn_80385B50 = .text:0x80385B50; // type:function size:0x10 fn_80385B60 = .text:0x80385B60; // type:function size:0x10 fn_80385B70 = .text:0x80385B70; // type:function size:0x8 -fn_80385B80 = .text:0x80385B80; // type:function size:0x4 +d_s_vt_0x188__14dSoundSource_cFv = .text:0x80385B80; // type:function size:0x4 fn_80385B90 = .text:0x80385B90; // type:function size:0x4 fn_80385BA0 = .text:0x80385BA0; // type:function size:0x8 fn_80385BB0 = .text:0x80385BB0; // type:function size:0x14 @@ -21103,12 +21103,12 @@ fn_80386410 = .text:0x80386410; // type:function size:0x8 fn_80386420 = .text:0x80386420; // type:function size:0x8 fn_80386430 = .text:0x80386430; // type:function size:0x8 fn_80386440 = .text:0x80386440; // type:function size:0x8 -fn_80386450 = .text:0x80386450; // type:function size:0x8 +@4@d_vt_0x38__14dSoundSource_cFbi = .text:0x80386450; // type:function size:0x8 fn_80386460 = .text:0x80386460; // type:function size:0x8 fn_80386470 = .text:0x80386470; // type:function size:0x8 -fn_80386480 = .text:0x80386480; // type:function size:0x8 -fn_80386490 = .text:0x80386490; // type:function size:0x8 -fn_803864A0 = .text:0x803864A0; // type:function size:0x8 +@4@SetupSound__14dSoundSource_cFPQ34nw4r3snd11SoundHandleUlPCQ44nw4r3snd14SoundStartable9StartInfoPv = .text:0x80386480; // type:function size:0x8 +@4@d_vt_0x5C__14dSoundSource_cFv = .text:0x80386490; // type:function size:0x8 +@4@d_vt_0x58__14dSoundSource_cFv = .text:0x803864A0; // type:function size:0x8 fn_803864B0 = .text:0x803864B0; // type:function size:0x8 fn_803864C0 = .text:0x803864C0; // type:function size:0x8 fn_803864D0 = .text:0x803864D0; // type:function size:0x164 @@ -21130,16 +21130,16 @@ fn_80386DE0 = .text:0x80386DE0; // type:function size:0x110 fn_80386EF0 = .text:0x80386EF0; // type:function size:0x80 fn_80386F70 = .text:0x80386F70; // type:function size:0x1A4C soundForActorInitRelated_803889c0 = .text:0x803889C0; // type:function size:0x4 -fn_803889D0 = .text:0x803889D0; // type:function size:0x108 -fn_80388AE0 = .text:0x80388AE0; // type:function size:0xC4 +__ct__14dSoundSource_cFUcP9dAcBase_cii = .text:0x803889D0; // type:function size:0x108 +__dt__14dSoundSource_cFv = .text:0x80388AE0; // type:function size:0xC4 fn_80388BB0 = .text:0x80388BB0; // type:function size:0x118 fn_80388CD0 = .text:0x80388CD0; // type:function size:0x9C fn_80388D70 = .text:0x80388D70; // type:function size:0x80 fn_80388DF0 = .text:0x80388DF0; // type:function size:0xC fn_80388E00 = .text:0x80388E00; // type:function size:0x88 -fn_80388E90 = .text:0x80388E90; // type:function size:0x84 -fn_80388F20 = .text:0x80388F20; // type:function size:0x4 -fn_80388F30 = .text:0x80388F30; // type:function size:0x8 +d_s_vt_0x184__14dSoundSource_cFv = .text:0x80388E90; // type:function size:0x84 +d_s_vt_0x18C__14dSoundSource_cFv = .text:0x80388F20; // type:function size:0x4 +hasPlayingSounds__14dSoundSource_cCFv = .text:0x80388F30; // type:function size:0x8 fn_80388F40 = .text:0x80388F40; // type:function size:0x8 fn_80388F50 = .text:0x80388F50; // type:function size:0x48 fn_80388FA0 = .text:0x80388FA0; // type:function size:0x14 @@ -21148,8 +21148,8 @@ fn_80389050 = .text:0x80389050; // type:function size:0x68 fn_803890C0 = .text:0x803890C0; // type:function size:0x18 fn_803890E0 = .text:0x803890E0; // type:function size:0x1C fn_80389100 = .text:0x80389100; // type:function size:0x60 -fn_80389160 = .text:0x80389160; // type:function size:0x40 -fn_803891A0 = .text:0x803891A0; // type:function size:0xB0 +d_s_vt_0x190__14dSoundSource_cFv = .text:0x80389160; // type:function size:0x40 +d_vt_0x38__14dSoundSource_cFbi = .text:0x803891A0; // type:function size:0xB0 fn_80389250 = .text:0x80389250; // type:function size:0x30 fn_80389280 = .text:0x80389280; // type:function size:0x48 fn_803892D0 = .text:0x803892D0; // type:function size:0x64 @@ -21171,7 +21171,7 @@ fn_80389D50 = .text:0x80389D50; // type:function size:0x78 fn_80389DD0 = .text:0x80389DD0; // type:function size:0x11C fn_80389EF0 = .text:0x80389EF0; // type:function size:0x58 fn_80389F50 = .text:0x80389F50; // type:function size:0x208 -fn_8038A160 = .text:0x8038A160; // type:function size:0x6C +d_s_vt_0x19C__14dSoundSource_cFv = .text:0x8038A160; // type:function size:0x6C fn_8038A1D0 = .text:0x8038A1D0; // type:function size:0xD8 fn_8038A2B0 = .text:0x8038A2B0; // type:function size:0x48 fn_8038A300 = .text:0x8038A300; // type:function size:0x10 @@ -21189,22 +21189,22 @@ fn_8038A740 = .text:0x8038A740; // type:function size:0x1E8 fn_8038A930 = .text:0x8038A930; // type:function size:0x1D0 fn_8038AB00 = .text:0x8038AB00; // type:function size:0x258 fn_8038AD60 = .text:0x8038AD60; // type:function size:0x58 -fn_8038ADC0 = .text:0x8038ADC0; // type:function size:0xAC -fn_8038AE70 = .text:0x8038AE70; // type:function size:0x98 -fn_8038AF10 = .text:0x8038AF10; // type:function size:0x254 +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 -fn_8038B320 = .text:0x8038B320; // type:function size:0x24 +d_s_vt_0x1C8__14dSoundSource_cFv = .text:0x8038B320; // type:function size:0x24 fn_8038B350 = .text:0x8038B350; // type:function size:0x30 -fn_8038B380 = .text:0x8038B380; // type:function size:0x8 -fn_8038B390 = .text:0x8038B390; // type:function size:0x4 -fn_8038B3A0 = .text:0x8038B3A0; // type:function size:0x8 -fn_8038B3B0 = .text:0x8038B3B0; // type:function size:0x4 -fn_8038B3C0 = .text:0x8038B3C0; // type:function size:0x54 -fn_8038B420 = .text:0x8038B420; // type:function size:0x60 -fn_8038B480 = .text:0x8038B480; // type:function size:0x74 -fn_8038B500 = .text:0x8038B500; // type:function size:0x84 +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 +d_vt_0x5C__14dSoundSource_cFv = .text:0x8038B3B0; // type:function size:0x4 +d_s_vt_0x1B4__14dSoundSource_cFv = .text:0x8038B3C0; // type:function size:0x54 +d_s_vt_0x1B8__14dSoundSource_cFv = .text:0x8038B420; // type:function size:0x60 +d_s_vt_0x1BC__14dSoundSource_cFv = .text:0x8038B480; // type:function size:0x74 +d_s_vt_0x1C4__14dSoundSource_cFv = .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 @@ -21223,17 +21223,17 @@ fn_8038BB80 = .text:0x8038BB80; // type:function size:0x6C fn_8038BBF0 = .text:0x8038BBF0; // type:function size:0x144 fn_8038BD40 = .text:0x8038BD40; // type:function size:0x20 fn_8038BD60 = .text:0x8038BD60; // type:function size:0xC -fn_8038BD70 = .text:0x8038BD70; // type:function size:0x4 +d_s_vt_0x1E4__14dSoundSource_cFv = .text:0x8038BD70; // type:function size:0x4 fn_8038BD80 = .text:0x8038BD80; // type:function size:0xB8 fn_8038BE40 = .text:0x8038BE40; // type:function size:0xC4 fn_8038BF10 = .text:0x8038BF10; // type:function size:0x104 -fn_8038C020 = .text:0x8038C020; // type:function size:0x8 -fn_8038C030 = .text:0x8038C030; // type:function size:0x58 +d_s_vt_0x1E8__14dSoundSource_cFv = .text:0x8038C020; // type:function size:0x8 +getRemoConSoundVariant__14dSoundSource_cCFUl = .text:0x8038C030; // type:function size:0x58 fn_8038C090 = .text:0x8038C090; // type:function size:0xBC fn_8038C150 = .text:0x8038C150; // type:function size:0x280 -fn_8038C3D0 = .text:0x8038C3D0; // type:function size:0x18 -fn_8038C3F0 = .text:0x8038C3F0; // type:function size:0x8 -fn_8038C400 = .text:0x8038C400; // type:function size:0x8 +__sinit_\d_snd_source_cpp = .text:0x8038C3D0; // type:function size:0x18 +@88@__dt__14dSoundSource_cFv = .text:0x8038C3F0; // type:function size:0x8 +@4@__dt__14dSoundSource_cFv = .text:0x8038C400; // type:function size:0x8 fn_8038C410 = .text:0x8038C410; // type:function size:0xEC fn_8038C500 = .text:0x8038C500; // type:function size:0xC4 fn_8038C5D0 = .text:0x8038C5D0; // type:function size:0x3D0 @@ -21623,9 +21623,9 @@ fn_80399A40 = .text:0x80399A40; // type:function size:0x50 fn_80399A90 = .text:0x80399A90; // type:function size:0x44 fn_80399AE0 = .text:0x80399AE0; // type:function size:0x5C fn_80399B40 = .text:0x80399B40; // type:function size:0x60 -fn_80399BA0 = .text:0x80399BA0; // type:function size:0x78 -fn_80399C20 = .text:0x80399C20; // type:function size:0x84 -fn_80399CB0 = .text:0x80399CB0; // type:function size:0x10 +__dt__32SndMgrDisposer<14SndMgr80399c20>Fv = .text:0x80399BA0; // type:function size:0x78 +create__32SndMgrDisposer<14SndMgr80399c20>Fv = .text:0x80399C20; // type:function size:0x84 +remove__32SndMgrDisposer<14SndMgr80399c20>Fv = .text:0x80399CB0; // type:function size:0x10 fn_80399CC0 = .text:0x80399CC0; // type:function size:0x34 fn_80399D00 = .text:0x80399D00; // type:function size:0x5C fn_80399D60 = .text:0x80399D60; // type:function size:0x44 @@ -21672,7 +21672,7 @@ AIRegisterDMACallback = .text:0x8039AF80; // type:function size:0x44 AIInitDMA = .text:0x8039AFD0; // type:function size:0x7C AIStartDMA = .text:0x8039B050; // type:function size:0x14 AIStopDMA = .text:0x8039B070; // type:function size:0x14 -fn_8039B090 = .text:0x8039B090; // type:function size:0x10 +AIGetDMABytesLeft = .text:0x8039B090; // type:function size:0x10 fn_8039B0A0 = .text:0x8039B0A0; // type:function size:0x18 fn_8039B0C0 = .text:0x8039B0C0; // type:function size:0x10 AICheckInit = .text:0x8039B0D0; // type:function size:0x8 @@ -21695,60 +21695,60 @@ ARCOpenDir = .text:0x8039BE10; // type:function size:0x7C ARCReadDir = .text:0x8039BE90; // type:function size:0xBC ARCCloseDir = .text:0x8039BF50; // type:function size:0x8 AXInit = .text:0x8039BF60; // type:function size:0x54 -fn_8039BFC0 = .text:0x8039BFC0; // type:function size:0x8 -fn_8039BFD0 = .text:0x8039BFD0; // type:function size:0x14 -fn_8039BFF0 = .text:0x8039BFF0; // type:function size:0xAC -fn_8039C0A0 = .text:0x8039C0A0; // type:function size:0xB0 -fn_8039C150 = .text:0x8039C150; // type:function size:0x1C -fn_8039C170 = .text:0x8039C170; // type:function size:0x10 -fn_8039C180 = .text:0x8039C180; // type:function size:0x84 +AXIsInit = .text:0x8039BFC0; // type:function size:0x8 +__AXGetStackHead = .text:0x8039BFD0; // type:function size:0x14 +__AXServiceCallbackStack = .text:0x8039BFF0; // type:function size:0xAC +__AXAllocInit = .text:0x8039C0A0; // type:function size:0xB0 +__AXPushFreeStack = .text:0x8039C150; // type:function size:0x1C +__AXPushCallbackStack = .text:0x8039C170; // type:function size:0x10 +__AXRemoveFromStack = .text:0x8039C180; // type:function size:0x84 AXFreeVoice = .text:0x8039C210; // type:function size:0x7C AXAcquireVoice = .text:0x8039C290; // type:function size:0x184 AXSetVoicePriority = .text:0x8039C420; // type:function size:0x9C -fn_8039C4C0 = .text:0x8039C4C0; // type:function size:0x114 -fn_8039C5E0 = .text:0x8039C5E0; // type:function size:0x34 -fn_8039C620 = .text:0x8039C620; // type:function size:0x1C +__AXAuxInit = .text:0x8039C4C0; // type:function size:0x114 +__AXGetAuxAInput = .text:0x8039C5E0; // type:function size:0x34 +__AXGetAuxAOutput = .text:0x8039C620; // type:function size:0x1C fn_8039C640 = .text:0x8039C640; // type:function size:0x20 fn_8039C660 = .text:0x8039C660; // type:function size:0x20 fn_8039C680 = .text:0x8039C680; // type:function size:0x20 fn_8039C6A0 = .text:0x8039C6A0; // type:function size:0x20 -fn_8039C6C0 = .text:0x8039C6C0; // type:function size:0x34 -fn_8039C700 = .text:0x8039C700; // type:function size:0x1C +__AXGetAuxBInput = .text:0x8039C6C0; // type:function size:0x34 +__AXGetAuxBOutput = .text:0x8039C700; // type:function size:0x1C fn_8039C720 = .text:0x8039C720; // type:function size:0x20 fn_8039C740 = .text:0x8039C740; // type:function size:0x20 fn_8039C760 = .text:0x8039C760; // type:function size:0x20 fn_8039C780 = .text:0x8039C780; // type:function size:0x20 -fn_8039C7A0 = .text:0x8039C7A0; // type:function size:0x34 -fn_8039C7E0 = .text:0x8039C7E0; // type:function size:0x1C -fn_8039C800 = .text:0x8039C800; // type:function size:0x3AC +__AXGetAuxCInput = .text:0x8039C7A0; // type:function size:0x34 +__AXGetAuxCOutput = .text:0x8039C7E0; // type:function size:0x1C +__AXProcessAux = .text:0x8039C800; // type:function size:0x3AC AXRegisterAuxACallback = .text:0x8039CBB0; // type:function size:0x64 AXRegisterAuxBCallback = .text:0x8039CC20; // type:function size:0x64 AXRegisterAuxCCallback = .text:0x8039CC90; // type:function size:0x64 AXGetAuxACallback = .text:0x8039CD00; // type:function size:0x14 AXGetAuxBCallback = .text:0x8039CD20; // type:function size:0x14 AXGetAuxCCallback = .text:0x8039CD40; // type:function size:0x14 -fn_8039CD60 = .text:0x8039CD60; // type:function size:0x8 -fn_8039CD70 = .text:0x8039CD70; // type:function size:0x30 -fn_8039CDA0 = .text:0x8039CDA0; // type:function size:0x9BC -fn_8039D760 = .text:0x8039D760; // type:function size:0x50 +__AXGetCommandListCycles = .text:0x8039CD60; // type:function size:0x8 +__AXGetCommandListAddress = .text:0x8039CD70; // type:function size:0x30 +__AXNextFrame = .text:0x8039CDA0; // type:function size:0x9BC +__AXClInit = .text:0x8039D760; // type:function size:0x50 AXSetMode = .text:0x8039D7B0; // type:function size:0x8 -fn_8039D7C0 = .text:0x8039D7C0; // type:function size:0x8 +AXGetMode = .text:0x8039D7C0; // type:function size:0x8 fn_8039D7D0 = .text:0x8039D7D0; // type:function size:0x8 -fn_8039D7E0 = .text:0x8039D7E0; // type:function size:0x8 -fn_8039D7F0 = .text:0x8039D7F0; // type:function size:0x8 -fn_8039D800 = .text:0x8039D800; // type:function size:0x8 +AXGetAuxAReturnVolume = .text:0x8039D7E0; // type:function size:0x8 +AXGetAuxBReturnVolume = .text:0x8039D7F0; // type:function size:0x8 +AXGetAuxCReturnVolume = .text:0x8039D800; // type:function size:0x8 AXSetMasterVolume = .text:0x8039D810; // type:function size:0x18 AXSetAuxAReturnVolume = .text:0x8039D830; // type:function size:0x8 AXSetAuxBReturnVolume = .text:0x8039D840; // type:function size:0x8 AXSetAuxCReturnVolume = .text:0x8039D850; // type:function size:0x8 -fn_8039D860 = .text:0x8039D860; // type:function size:0x260 -fn_8039DAC0 = .text:0x8039DAC0; // type:function size:0xB0 +__AXOutNewFrame = .text:0x8039D860; // type:function size:0x260 +__AXOutAiCallback = .text:0x8039DAC0; // type:function size:0xB0 fn_8039DB70 = .text:0x8039DB70; // type:function size:0xC fn_8039DB80 = .text:0x8039DB80; // type:function size:0x54 -fn_8039DBE0 = .text:0x8039DBE0; // type:function size:0x10 +__AXDSPDoneCallback = .text:0x8039DBE0; // type:function size:0x10 fn_8039DBF0 = .text:0x8039DBF0; // type:function size:0x4 -fn_8039DC00 = .text:0x8039DC00; // type:function size:0xEC -fn_8039DCF0 = .text:0x8039DCF0; // type:function size:0x1F8 +__AXOutInitDSP = .text:0x8039DC00; // type:function size:0xEC +__AXOutInit = .text:0x8039DCF0; // type:function size:0x1F8 AXRegisterCallback = .text:0x8039DEF0; // type:function size:0x44 AXRmtGetSamplesLeft = .text:0x8039DF40; // type:function size:0x2C AXRmtGetSamples = .text:0x8039DF70; // type:function size:0xC4 @@ -21756,12 +21756,12 @@ AXRmtAdvancePtr = .text:0x8039E040; // type:function size:0x58 fn_8039E0A0 = .text:0x8039E0A0; // type:function size:0xC fn_8039E0B0 = .text:0x8039E0B0; // type:function size:0x6C fn_8039E120 = .text:0x8039E120; // type:function size:0x6C -fn_8039E190 = .text:0x8039E190; // type:function size:0x178 +__AXPrintStudio = .text:0x8039E190; // type:function size:0x178 fn_8039E310 = .text:0x8039E310; // type:function size:0x58 fn_8039E370 = .text:0x8039E370; // type:function size:0x15C fn_8039E4D0 = .text:0x8039E4D0; // type:function size:0x8 fn_8039E4E0 = .text:0x8039E4E0; // type:function size:0x550 -fn_8039EA30 = .text:0x8039EA30; // type:function size:0x310 +__AXSyncPBs = .text:0x8039EA30; // type:function size:0x310 fn_8039ED40 = .text:0x8039ED40; // type:function size:0x8 fn_8039ED50 = .text:0x8039ED50; // type:function size:0x40 fn_8039ED90 = .text:0x8039ED90; // type:function size:0x30 @@ -21771,16 +21771,16 @@ AXSetVoiceAddr = .text:0x8039F0C0; // type:function size:0xE8 AXGetLpfCoefs = .text:0x8039F1B0; // type:function size:0xBC AXSetMaxDspCycles = .text:0x8039F270; // type:function size:0x8 AXGetMaxVoices = .text:0x8039F280; // type:function size:0x8 -fn_8039F290 = .text:0x8039F290; // type:function size:0x40 -fn_8039F2D0 = .text:0x8039F2D0; // type:function size:0x64 -fn_8039F340 = .text:0x8039F340; // type:function size:0x24 -fn_8039F370 = .text:0x8039F370; // type:function size:0x4 -fn_8039F380 = .text:0x8039F380; // type:function size:0x19C -fn_8039F520 = .text:0x8039F520; // type:function size:0x54 -fn_8039F580 = .text:0x8039F580; // type:function size:0x524 -__AllocDelayLine = .text:0x8039FAB0; // type:function size:0x174 -__BzeroDelayLines = .text:0x8039FC30; // type:function size:0x124 -__FreeDelayLine = .text:0x8039FD60; // type:function size:0x114 +__AXGetCurrentProfile = .text:0x8039F290; // type:function size:0x40 scope:local +AXFXReverbHiInit = .text:0x8039F2D0; // type:function size:0x64 +AXFXReverbHiShutdown = .text:0x8039F340; // type:function size:0x24 +AXFXReverbHiCallback = .text:0x8039F370; // type:function size:0x4 +AXFXReverbHiExpInit = .text:0x8039F380; // type:function size:0x19C +AXFXReverbHiExpShutdown = .text:0x8039F520; // type:function size:0x54 +AXFXReverbHiExpCallback = .text:0x8039F580; // type:function size:0x524 +__AllocDelayLine = .text:0x8039FAB0; // type:function size:0x174 scope:local +__BzeroDelayLines = .text:0x8039FC30; // type:function size:0x124 scope:local +__FreeDelayLine = .text:0x8039FD60; // type:function size:0x114 scope:local fn_8039FE80 = .text:0x8039FE80; // type:function size:0x324 AXFXReverbStdExpGetMemSize = .text:0x803A01B0; // type:function size:0x60 AXFXReverbStdExpInit = .text:0x803A0210; // type:function size:0x17C @@ -21788,22 +21788,22 @@ AXFXReverbStdExpSettings = .text:0x803A0390; // type:function size:0xD0 AXFXReverbStdExpSettingsUpdate = .text:0x803A0460; // type:function size:0xB4 AXFXReverbStdExpShutdown = .text:0x803A0520; // type:function size:0x54 AXFXReverbStdExpCallback = .text:0x803A0580; // type:function size:0x36C -fn_803A08F0 = .text:0x803A08F0; // type:function size:0x144 -fn_803A0A40 = .text:0x803A0A40; // type:function size:0x100 -fn_803A0B40 = .text:0x803A0B40; // type:function size:0xF0 -fn_803A0C30 = .text:0x803A0C30; // type:function size:0x2AC +__AllocDelayLine = .text:0x803A08F0; // type:function size:0x144 scope:local +__BzeroDelayLines = .text:0x803A0A40; // type:function size:0x100 scope:local +__FreeDelayLine = .text:0x803A0B40; // type:function size:0xF0 scope:local +__InitParams = .text:0x803A0C30; // type:function size:0x2AC scope:local AXFXReverbStdExpGetMemSizeDpl2 = .text:0x803A0EE0; // type:function size:0x60 AXFXReverbStdExpInitDpl2 = .text:0x803A0F40; // type:function size:0x198 AXFXReverbStdExpSettingsDpl2 = .text:0x803A10E0; // type:function size:0xD0 AXFXReverbStdExpSettingsUpdateDpl2 = .text:0x803A11B0; // type:function size:0xB4 AXFXReverbStdExpShutdownDpl2 = .text:0x803A1270; // type:function size:0x54 AXFXReverbStdExpCallbackDpl2 = .text:0x803A12D0; // type:function size:0x384 -fn_803A1660 = .text:0x803A1660; // type:function size:0x144 -fn_803A17B0 = .text:0x803A17B0; // type:function size:0x100 -fn_803A18B0 = .text:0x803A18B0; // type:function size:0xF0 -fn_803A19A0 = .text:0x803A19A0; // type:function size:0x2B0 -fn_803A1C50 = .text:0x803A1C50; // type:function size:0xC -fn_803A1C60 = .text:0x803A1C60; // type:function size:0xC +__AllocDelayLine = .text:0x803A1660; // type:function size:0x144 scope:local +__BzeroDelayLines = .text:0x803A17B0; // type:function size:0x100 scope:local +__FreeDelayLine = .text:0x803A18B0; // type:function size:0xF0 scope:local +__InitParams = .text:0x803A19A0; // type:function size:0x2B0 scope:local +__AXFXAllocFunction = .text:0x803A1C50; // type:function size:0xC scope:local +__AXFXFreeFunction = .text:0x803A1C60; // type:function size:0xC scope:local AXFXSetHooks = .text:0x803A1C70; // type:function size:0xC AXFXGetHooks = .text:0x803A1C80; // type:function size:0x14 PPCMfmsr = .text:0x803A1CA0; // type:function size:0x8 scope:global @@ -22597,18 +22597,18 @@ fn_803CDC00 = .text:0x803CDC00; // type:function size:0x18 fn_803CDC20 = .text:0x803CDC20; // type:function size:0x70 fn_803CDC90 = .text:0x803CDC90; // type:function size:0x6C MEMGetNextListObject = .text:0x803CDD00; // type:function size:0x20 -dsp__DSPCheckMailToDSP = .text:0x803CDD20; // type:function size:0x10 -dsp__DSPCheckMailFromDSP = .text:0x803CDD30; // type:function size:0x10 -dsp__DSPReadMailFromDSP = .text:0x803CDD40; // type:function size:0x14 -dsp__DSPSendMailToDSP = .text:0x803CDD60; // type:function size:0x14 -dsp__DSPInit = .text:0x803CDD80; // type:function size:0xC0 +DSPCheckMailToDSP = .text:0x803CDD20; // type:function size:0x10 +DSPCheckMailFromDSP = .text:0x803CDD30; // type:function size:0x10 +DSPReadMailFromDSP = .text:0x803CDD40; // type:function size:0x14 +DSPSendMailToDSP = .text:0x803CDD60; // type:function size:0x14 +DSPInit = .text:0x803CDD80; // type:function size:0xC0 fn_803CDE40 = .text:0x803CDE40; // type:function size:0x8 -fn_803CDE50 = .text:0x803CDE50; // type:function size:0x70 +DSPAddTask = .text:0x803CDE50; // type:function size:0x70 fn_803CDEC0 = .text:0x803CDEC0; // type:function size:0xBC -dsp____DSP_debug_printf = .text:0x803CDF80; // type:function size:0x50 +__DSP_debug_printf = .text:0x803CDF80; // type:function size:0x50 fn_803CDFD0 = .text:0x803CDFD0; // type:function size:0x42C -dsp____DSP_exec_task = .text:0x803CE400; // type:function size:0x1A4 -dsp____DSP_boot_task = .text:0x803CE5B0; // type:function size:0x18C +__DSP_exec_task = .text:0x803CE400; // type:function size:0x1A4 +__DSP_boot_task = .text:0x803CE5B0; // type:function size:0x18C fn_803CE740 = .text:0x803CE740; // type:function size:0xA0 fn_803CE7E0 = .text:0x803CE7E0; // type:function size:0x88 ESP_InitLib = .text:0x803CE870; // type:function size:0x54 scope:global @@ -37630,22 +37630,22 @@ __vt__12dCcMassS_Obj = .data:0x80548598; // type:object size:0xC __vt__4dCcS = .data:0x805485A8; // type:object size:0xC lbl_805485B8 = .data:0x805485B8; // type:object size:0xC lbl_805485C4 = .data:0x805485C4; // type:object size:0xC -lbl_805485D0 = .data:0x805485D0; // type:object size:0xA8 -lbl_80548678 = .data:0x80548678; // type:object size:0xC -lbl_80548684 = .data:0x80548684; // type:object size:0x1C -lbl_805486A0 = .data:0x805486A0; // type:object size:0x10 -lbl_805486B0 = .data:0x805486B0; // type:object size:0x60 -lbl_80548710 = .data:0x80548710; // type:object size:0x20 +__vt__9dSndMgr_c = .data:0x805485D0; // type:object size:0xA8 +__vt__22SoundPropertiesChecker = .data:0x80548678; // type:object size:0xC +__vt__11dSndActor_c = .data:0x80548684; // type:object size:0x1C scope:weak +__vt__23IsCurrentSoundIdChecker = .data:0x805486A0; // type:object size:0x10 +__vt__13dSnd3DActor_c = .data:0x805486B0; // type:object size:0x60 +__vt__14dSnd3DEngine_c = .data:0x80548710; // type:object size:0x20 lbl_80548730 = .data:0x80548730; // type:object size:0x28 lbl_80548758 = .data:0x80548758; // type:object size:0x14 data:string lbl_8054876C = .data:0x8054876C; // type:object size:0x14 data:string -lbl_80548780 = .data:0x80548780; // type:object size:0x10 -lbl_80548790 = .data:0x80548790; // type:object size:0x10 +__vt__15dSndPlayerMgr_c = .data:0x80548780; // type:object size:0x10 +__vt__33SndMgrDisposer<15dSndPlayerMgr_c> = .data:0x80548790; // type:object size:0xC lbl_805487A0 = .data:0x805487A0; // type:object size:0xC lbl_805487AC = .data:0x805487AC; // type:object size:0xC lbl_805487B8 = .data:0x805487B8; // type:object size:0xC lbl_805487C4 = .data:0x805487C4; // type:object size:0xC -lbl_805487D0 = .data:0x805487D0; // type:object size:0x10 +__vt__33SndMgrDisposer<15dSnd3DManager_c> = .data:0x805487D0; // type:object size:0xC scope:weak lbl_805487E0 = .data:0x805487E0; // type:object size:0xAC lbl_8054888C = .data:0x8054888C; // type:object size:0xC lbl_80548898 = .data:0x80548898; // type:object size:0xC @@ -37753,8 +37753,8 @@ lbl_8054A488 = .data:0x8054A488; // type:object size:0x1EC lbl_8054A674 = .data:0x8054A674; // type:object size:0xC lbl_8054A680 = .data:0x8054A680; // type:object size:0x150 lbl_8054A7D0 = .data:0x8054A7D0; // type:object size:0xC -lbl_8054A7DC = .data:0x8054A7DC; // type:object size:0x1EC -lbl_8054A9C8 = .data:0x8054A9C8; // type:object size:0x120 +__vt__14dSoundSource_c = .data:0x8054A7DC; // type:object size:0x1EC +__vt__16dSoundSourceIf_c = .data:0x8054A9C8; // type:object size:0x120 lbl_8054AAE8 = .data:0x8054AAE8; // type:object size:0x38 lbl_8054AB20 = .data:0x8054AB20; // type:object size:0x3F8 jumptable_8054AF18 = .data:0x8054AF18; // type:object size:0xA8 scope:local @@ -41887,16 +41887,16 @@ l_start = .sbss:0x80575D18; // type:object size:0x4 data:4byte l_wcsbuf_num = .sbss:0x80575D1C; // type:object size:0x4 data:4byte sInstance__4dCcS = .sbss:0x80575D20; // type:object size:0x4 data:4byte lbl_80575D28 = .sbss:0x80575D28; // type:object size:0x8 data:4byte -lbl_80575D30 = .sbss:0x80575D30; // type:object size:0x8 data:4byte -BGM_MGR = .sbss:0x80575D38; // type:object size:0x4 data:4byte -BGM_MGR_source = .sbss:0x80575D3C; // type:object size:0x4 data:4byte +sInstance__9dSndMgr_c = .sbss:0x80575D30; // type:object size:0x8 data:4byte +sInstance__15dSndPlayerMgr_c = .sbss:0x80575D38; // type:object size:0x4 data:4byte +sDisposer__15dSndPlayerMgr_c = .sbss:0x80575D3C; // type:object size:0x4 data:4byte lbl_80575D40 = .sbss:0x80575D40; // type:object size:0x4 data:4byte lbl_80575D44 = .sbss:0x80575D44; // type:object size:0x4 data:4byte lbl_80575D48 = .sbss:0x80575D48; // type:object size:0x4 data:4byte lbl_80575D4C = .sbss:0x80575D4C; // type:object size:0x4 data:4byte lbl_80575D50 = .sbss:0x80575D50; // type:object size:0x8 data:4byte -lbl_80575D58 = .sbss:0x80575D58; // type:object size:0x4 data:4byte -lbl_80575D5C = .sbss:0x80575D5C; // type:object size:0x4 data:4byte +sInstance__15dSnd3DManager_c = .sbss:0x80575D58; // type:object size:0x4 data:4byte +sDisposer__15dSnd3DManager_c = .sbss:0x80575D5C; // type:object size:0x4 data:4byte lbl_80575D60 = .sbss:0x80575D60; // type:object size:0x4 data:4byte lbl_80575D64 = .sbss:0x80575D64; // type:object size:0x4 data:4byte lbl_80575D68 = .sbss:0x80575D68; // type:object size:0x4 data:4byte @@ -48389,22 +48389,22 @@ lbl_8057D3A4 = .sdata2:0x8057D3A4; // type:object size:0x4 align:4 data:float lbl_8057D3A8 = .sdata2:0x8057D3A8; // type:object size:0x4 align:4 data:float lbl_8057D3AC = .sdata2:0x8057D3AC; // type:object size:0x4 align:4 data:float lbl_8057D3B0 = .sdata2:0x8057D3B0; // type:object size:0x4 align:4 data:float -lbl_8057D3B8 = .sdata2:0x8057D3B8; // type:object size:0x4 align:4 data:float -lbl_8057D3BC = .sdata2:0x8057D3BC; // type:object size:0x4 align:4 data:float -lbl_8057D3C0 = .sdata2:0x8057D3C0; // type:object size:0x4 align:4 data:float -lbl_8057D3C4 = .sdata2:0x8057D3C4; // type:object size:0x4 align:4 data:float -lbl_8057D3C8 = .sdata2:0x8057D3C8; // type:object size:0x4 align:4 data:float -lbl_8057D3CC = .sdata2:0x8057D3CC; // type:object size:0x4 align:4 data:float -lbl_8057D3D0 = .sdata2:0x8057D3D0; // type:object size:0x4 align:4 data:float -lbl_8057D3D4 = .sdata2:0x8057D3D4; // type:object size:0x4 align:4 data:float -lbl_8057D3D8 = .sdata2:0x8057D3D8; // type:object size:0x4 align:4 data:float -lbl_8057D3DC = .sdata2:0x8057D3DC; // type:object size:0x4 align:4 data:float -lbl_8057D3E0 = .sdata2:0x8057D3E0; // type:object size:0x4 align:4 data:float -lbl_8057D3E4 = .sdata2:0x8057D3E4; // type:object size:0x4 align:4 data:float -lbl_8057D3E8 = .sdata2:0x8057D3E8; // type:object size:0x4 align:4 data:float -lbl_8057D3EC = .sdata2:0x8057D3EC; // type:object size:0x4 align:4 data:float -lbl_8057D3F0 = .sdata2:0x8057D3F0; // type:object size:0x4 align:4 data:float -lbl_8057D3F4 = .sdata2:0x8057D3F4; // type:object size:0x4 align:4 data:float +@8273 = .sdata2:0x8057D3B8; // type:object size:0x4 scope:local align:4 data:float +@8274 = .sdata2:0x8057D3BC; // type:object size:0x4 scope:local align:4 data:float +@8275 = .sdata2:0x8057D3C0; // type:object size:0x4 scope:local align:4 data:float +@8276 = .sdata2:0x8057D3C4; // type:object size:0x4 scope:local align:4 data:float +@8344 = .sdata2:0x8057D3C8; // type:object size:0x4 scope:local align:4 data:float +@8345 = .sdata2:0x8057D3CC; // type:object size:0x4 scope:local align:4 data:float +@8346 = .sdata2:0x8057D3D0; // type:object size:0x4 scope:local align:4 data:float +@8347 = .sdata2:0x8057D3D4; // type:object size:0x4 scope:local align:4 data:float +@8348 = .sdata2:0x8057D3D8; // type:object size:0x4 scope:local align:4 data:float +@8349 = .sdata2:0x8057D3DC; // type:object size:0x4 scope:local align:4 data:float +@8364 = .sdata2:0x8057D3E0; // type:object size:0x4 scope:local align:4 data:float +@8365 = .sdata2:0x8057D3E4; // type:object size:0x4 scope:local align:4 data:float +@8485 = .sdata2:0x8057D3E8; // type:object size:0x4 scope:local align:4 data:float +@8486 = .sdata2:0x8057D3EC; // type:object size:0x4 scope:local align:4 data:float +@8487 = .sdata2:0x8057D3F0; // type:object size:0x4 scope:local align:4 data:float +@8488 = .sdata2:0x8057D3F4; // type:object size:0x4 scope:local align:4 data:float lbl_8057D3F8 = .sdata2:0x8057D3F8; // type:object size:0x4 align:4 data:float lbl_8057D3FC = .sdata2:0x8057D3FC; // type:object size:0x4 align:4 data:float lbl_8057D400 = .sdata2:0x8057D400; // type:object size:0x4 align:4 data:float @@ -50394,7 +50394,7 @@ sRumblePreset7__9dRumble_c = .bss:0x805A07CC; // type:object size:0xC data:4byte sRumblePreset8__9dRumble_c = .bss:0x805A07D8; // type:object size:0xC data:4byte sRumblePreset9__9dRumble_c = .bss:0x805A07E4; // type:object size:0xC data:4byte sRumblePreset10__9dRumble_c = .bss:0x805A07F0; // type:object size:0xC data:4byte -@LOCAL@play__9dRumble_cFv@rumble_strings = .bss:0x805A07FC; // type:object size:0x42 scope:local data:byte +@LOCAL@execute__9dRumble_cFv@rumble_strings = .bss:0x805A07FC; // type:object size:0x42 scope:local data:byte @LOCAL@start__9dRumble_cFRC14dRumbleEntry_cUl@rumble_string = .bss:0x805A0840; // type:object size:0x21 scope:local data:byte @LOCAL@getCurrentStageDirectory__22CurrentStageArcManagerFv@sStageDirTmp = .bss:0x805A0868; // type:object size:0x40 scope:local data:byte s_roomArcTmp = .bss:0x805A08A8; // type:object size:0x20 scope:local data:byte diff --git a/configure.py b/configure.py index 43acfd3a..448b5746 100644 --- a/configure.py +++ b/configure.py @@ -702,18 +702,20 @@ config.libs = [ "objects": [ # These are very low quality splits since nobody has figured # out enough detail. Need to look into nw4r::snd first - Object(NonMatching, "d/snd/d_snd.cpp"), - Object(NonMatching, "d/snd/d_snd_actor.cpp"), - Object(NonMatching, "d/snd/d_snd_engine.cpp"), + Object(NonMatching, "d/snd/d_snd_mgr.cpp"), + Object(Matching, "d/snd/d_snd_actor.cpp"), + Object(NonMatching, "d/snd/d_snd_3d_actor.cpp"), + Object(NonMatching, "d/snd/d_snd_3d_engine.cpp"), Object(NonMatching, "d/snd/d_snd_unk_component_1.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_bgm.cpp"), + Object(NonMatching, "d/snd/d_snd_player_mgr.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk1.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk3.cpp"), + Object(Matching, "d/snd/d_snd_3d_manager.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_enemy.cpp"), Object(NonMatching, "d/snd/d_snd_unk_component_2.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_effect.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_5.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_6.cpp"), + Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_13.cpp"), + Object(NonMatching, "d/snd/d_snd_source.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_7.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_8.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_9.cpp"), diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h index e293b927..b223b88a 100644 --- a/include/d/a/d_a_base.h +++ b/include/d/a/d_a_base.h @@ -4,6 +4,7 @@ #include "UnknownTypeBelongings.h" #include "common.h" #include "d/d_base.h" +#include "d/snd/d_snd_source.h" #include "m/m_allocator.h" #include "m/m_angle.h" #include "m/m_vec.h" @@ -13,83 +14,9 @@ class dAcBase_c; struct cBgS_PolyInfo; -struct SoundSource { - virtual ~SoundSource() {} -// TODO there's probably multiple inheritance involved and stuff -#define SOUNDSOURCE_VIRTUAL(offset) virtual void vt_##offset(); - - SOUNDSOURCE_VIRTUAL(0x0C); - SOUNDSOURCE_VIRTUAL(0x10); - SOUNDSOURCE_VIRTUAL(0x14); - SOUNDSOURCE_VIRTUAL(0x18); - SOUNDSOURCE_VIRTUAL(0x1C); - SOUNDSOURCE_VIRTUAL(0x20); - SOUNDSOURCE_VIRTUAL(0x24); - SOUNDSOURCE_VIRTUAL(0x28); - SOUNDSOURCE_VIRTUAL(0x2C); - SOUNDSOURCE_VIRTUAL(0x30); - SOUNDSOURCE_VIRTUAL(0x34); - SOUNDSOURCE_VIRTUAL(0x38); - SOUNDSOURCE_VIRTUAL(0x3C); - SOUNDSOURCE_VIRTUAL(0x40); - SOUNDSOURCE_VIRTUAL(0x44); - virtual bool shutdown(); // 0x48 - SOUNDSOURCE_VIRTUAL(0x4C); - SOUNDSOURCE_VIRTUAL(0x50); - SOUNDSOURCE_VIRTUAL(0x54); - SOUNDSOURCE_VIRTUAL(0x58); - SOUNDSOURCE_VIRTUAL(0x5C); - SOUNDSOURCE_VIRTUAL(0x60); - SOUNDSOURCE_VIRTUAL(0x64); - SOUNDSOURCE_VIRTUAL(0x68); - SOUNDSOURCE_VIRTUAL(0x6C); - SOUNDSOURCE_VIRTUAL(0x70); - SOUNDSOURCE_VIRTUAL(0x74); - SOUNDSOURCE_VIRTUAL(0x78); - SOUNDSOURCE_VIRTUAL(0x7C); - SOUNDSOURCE_VIRTUAL(0x80); - SOUNDSOURCE_VIRTUAL(0x84); - SOUNDSOURCE_VIRTUAL(0x88); - SOUNDSOURCE_VIRTUAL(0x8C); - SOUNDSOURCE_VIRTUAL(0x90); - SOUNDSOURCE_VIRTUAL(0x94); - SOUNDSOURCE_VIRTUAL(0x98); - SOUNDSOURCE_VIRTUAL(0x9C); - SOUNDSOURCE_VIRTUAL(0xA0); - SOUNDSOURCE_VIRTUAL(0xA4); - SOUNDSOURCE_VIRTUAL(0xA8); - SOUNDSOURCE_VIRTUAL(0xAC); - SOUNDSOURCE_VIRTUAL(0xB0); - SOUNDSOURCE_VIRTUAL(0xB4); - SOUNDSOURCE_VIRTUAL(0xB8); - SOUNDSOURCE_VIRTUAL(0xBC); - SOUNDSOURCE_VIRTUAL(0xC0); - SOUNDSOURCE_VIRTUAL(0xC4); - SOUNDSOURCE_VIRTUAL(0xC8); - SOUNDSOURCE_VIRTUAL(0xCC); - SOUNDSOURCE_VIRTUAL(0xD0); - SOUNDSOURCE_VIRTUAL(0xD4); - SOUNDSOURCE_VIRTUAL(0xD8); - SOUNDSOURCE_VIRTUAL(0xDC); - SOUNDSOURCE_VIRTUAL(0xE0); - SOUNDSOURCE_VIRTUAL(0xE4); - SOUNDSOURCE_VIRTUAL(0xE8); - SOUNDSOURCE_VIRTUAL(0xEC); - SOUNDSOURCE_VIRTUAL(0xF0); - SOUNDSOURCE_VIRTUAL(0xF4); - SOUNDSOURCE_VIRTUAL(0xF8); - SOUNDSOURCE_VIRTUAL(0xFC); - - virtual bool isReadyMaybe(); // 0x100 - virtual bool load(void *data, const char *name); // 0x104 - virtual void setFrame(f32 frame); // 0x108 - virtual void setRate(f32 frame); // 0x10C - virtual void set_0x164(UNKWORD val); // 0x114 -}; - struct SoundInfo { dAcBase_c *actor; - SoundSource *sound_source; + dSoundSourceIf_c *sound_source; mVec3_c *obj_pos; TListNode mLink; }; @@ -143,7 +70,7 @@ public: /* 0x68 */ mHeapAllocator_c heap_allocator; /* 0x84 */ ObjInfo *obj_info; /* 0x88 */ TList sound_list; - /* 0x94 */ RaiiPtr sound_source; + /* 0x94 */ RaiiPtr sound_source; /* 0x98 */ mVec3_c *obj_pos; /* 0x9C */ mVec3_c pos_copy; /* 0xA8 */ u32 params2; @@ -252,7 +179,7 @@ public: s8 viewClipIdx, ObjInfo *objInfo ); - /* 8002c690 */ SoundSource *FUN_8002c690(); + /* 8002c690 */ dSoundSourceIf_c *FUN_8002c690(); /* 8002c710 */ int initAllocatorWork1Heap(int size, char *name, int align); /* 8002c720 */ int initAllocator(int size, char *name, EGG::Heap *heap, int align); /* 8002c7b0 */ bool addActorToRoom(s32 roomId); @@ -301,7 +228,7 @@ public: /* 8002d810 */ void FUN_8002d810(); /* 8002d830 */ void FUN_8002d830(); /* 8002d860 */ void FUN_8002d860(UNKWORD val); - /* 8002d880 */ SoundSource *getSoundSource(); + /* 8002d880 */ dSoundSourceIf_c *getSoundSource(); // End of SoundSource stuff /* 8002d890 */ void removeSoundInfo(SoundInfo *); diff --git a/include/d/snd/d_snd_3d_actor.h b/include/d/snd/d_snd_3d_actor.h new file mode 100644 index 00000000..6fa7fafa --- /dev/null +++ b/include/d/snd/d_snd_3d_actor.h @@ -0,0 +1,94 @@ +#ifndef D_SND_ACTOR_H +#define D_SND_ACTOR_H + +#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; + +public: + dSnd3DActor_c(UNKTYPE *, u8); + + virtual ~dSnd3DActor_c() {} + + virtual bool d_vt_0x30() { + return true; + } + + virtual void d_vt_0x34(const nw4r::math::VEC3 &); + + virtual void d_vt_0x38(bool flag, int fadeFrames) = 0; + + virtual UNKWORD d_vt_0x3C() { + return 0; + } + + virtual UNKWORD d_vt_0x40() { + return 0; + } + + virtual UNKWORD d_vt_0x44() { + return 0; + } + + virtual const nw4r::math::VEC3 &getPositionRelativeToPlayer(); + 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; + + void resetFloats(); + + bool checkFlag(u16 flag) const { + return (mFlags & flag); + } + + bool hasPlayingSounds() const; + bool isPlayingSound(u32 id); + + const char *soundIdToSoundLabel(u32 soundId) const; + u32 soundLabelToSoundId(const char *soundLabel) const; + +protected: + // a_ prefix to prevent multiple inheritance clashes + /* 0x7D */ u8 a_field_0x7D; + /* 0x7E */ u8 a_field_0x7E; + /* 0x7F */ u8 a_field_0x7F; + /* 0x80 */ u8 a_field_0x80; + /* 0x84 */ f32 a_field_0x84; + /* 0x88 */ f32 a_field_0x88; + /* 0x8C */ f32 a_field_0x8C; + /* 0x90 */ f32 a_field_0x90; + /* 0x94 */ f32 a_field_0x94; + /* 0x98 */ f32 a_field_0x98; + /* 0x9C */ f32 a_field_0x9C; + /* 0xA0 */ u8 a_0xA0[0xC8 - 0xA0]; + /* 0xC8 */ UNKTYPE *a_field_0xC8; + /* 0xCC */ u16 mFlags; + /* 0xD0 */ nw4r::math::VEC3 mPositionRelativeToPlayer; + /* 0xDC */ f32 mDistanceToPlayer; + /* 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 diff --git a/include/d/snd/d_snd_3d_engine.h b/include/d/snd/d_snd_3d_engine.h new file mode 100644 index 00000000..309f169a --- /dev/null +++ b/include/d/snd/d_snd_3d_engine.h @@ -0,0 +1,18 @@ +#ifndef D_SND_3D_ENGINE +#define D_SND_3D_ENGINE + +#include "nw4r/snd/snd_BasicSound.h" +#include "nw4r/snd/snd_Sound3DEngine.h" +#include "nw4r/snd/snd_Sound3DManager.h" + +class dSnd3DEngine_c : public nw4r::snd::Sound3DEngine { +public: + dSnd3DEngine_c(); + + virtual void UpdateAmbientParam( + const nw4r::snd::Sound3DManager *mgr, const nw4r::snd::Sound3DParam *param3d, u32 unk, u32 flags, + nw4r::snd::SoundAmbientParam *paramAmb + ) override; +}; + +#endif diff --git a/include/d/snd/d_snd_3d_manager.h b/include/d/snd/d_snd_3d_manager.h new file mode 100644 index 00000000..b0a86b90 --- /dev/null +++ b/include/d/snd/d_snd_3d_manager.h @@ -0,0 +1,66 @@ +#ifndef D_SND_3D_MANAGER_H +#define D_SND_3D_MANAGER_H + +#include "d/snd/d_snd_3d_engine.h" +#include "d/snd/d_snd_util.h" +#include "egg/gfx/eggCamera.h" +#include "m/m_vec.h" +#include "nw4r/math/math_types.h" +#include "nw4r/snd/snd_Sound3DListener.h" +#include "nw4r/snd/snd_Sound3DManager.h" + +class dSnd3DManager_c; +extern template class SndMgrDisposer; + +class dSnd3DManager_c { +public: + SndMgrDisposer *GetDisposer() { + return &mDisposer; + } + + static dSnd3DManager_c *GetInstance() { + return sInstance; + } + + static dSnd3DManager_c *sInstance; + static SndMgrDisposer *sDisposer; + +private: + SndMgrDisposer mDisposer; + +public: + dSnd3DManager_c(); + + void setup(); + void updateFromCamera(EGG::LookAtCamera &camera); + void setCamDistance(f32 value); + void resetCamDistance(); + void calc(); + void clearState(); + + nw4r::snd::Sound3DManager& getManager() { + return mManager; + } + + const mVec3_c &getListenerPos() const { + return mSoundListenerPosition; + } + +private: + + void updateListenerPos(f32); + /* 0x10 */ bool mIsSetup; + /* 0x11 */ u8 field_0x11; + /* 0x14 */ dSnd3DEngine_c *mpEngine; + /* 0x18 */ nw4r::snd::Sound3DManager mManager; + /* 0x44 */ nw4r::snd::Sound3DListener mListener; + /* 0xB0 */ EGG::LookAtCamera mCamera; + /* 0x138 */ mVec3_c field_0x138; + /* 0x144 */ mVec3_c mSoundListenerPosition; + /* 0x150 */ f32 mCameraPosSqVelocity; + /* 0x154 */ f32 mCameraAtSqVelocity; + /* 0x158 */ f32 mCamDistance; + /* 0x15C */ s16 mTimer; +}; + +#endif diff --git a/include/d/snd/d_snd_actor.h b/include/d/snd/d_snd_actor.h new file mode 100644 index 00000000..5fc2480c --- /dev/null +++ b/include/d/snd/d_snd_actor.h @@ -0,0 +1,12 @@ +#ifndef D_SND_3D_ACTOR_H +#define D_SND_3D_ACTOR_H + +#include "nw4r/snd/snd_SoundActor.h" +#include "nw4r/snd/snd_SoundHandle.h" + +class dSndActor_c : public nw4r::snd::SoundActor { +public: + dSndActor_c(nw4r::snd::SoundArchivePlayer &rPlayer); +}; + +#endif diff --git a/include/d/snd/d_snd_checkers.h b/include/d/snd/d_snd_checkers.h new file mode 100644 index 00000000..c34f881b --- /dev/null +++ b/include/d/snd/d_snd_checkers.h @@ -0,0 +1,22 @@ +#ifndef D_SND_CHECKERS_H +#define D_SND_CHECKERS_H + +#include "nw4r/snd/snd_SoundHandle.h" + +class SoundPropertiesChecker { +public: + virtual void operator()(nw4r::snd::SoundHandle &pHandle); + +private: + /* 0x04 */ u32 mSoundId; + /* 0x08 */ u32 mPlayCounter; + /* 0x0C */ u32 mPauseCounter; + /* 0x10 */ u32 mCounter3; + /* 0x14 */ u32 mCounter4; + /* 0x18 */ u32 *mpPlayCounter; + /* 0x1C */ u32 *mpPauseCounter; + /* 0x20 */ u32 *mpCounter3; + /* 0x24 */ u32 *mpCounter4; +}; + +#endif diff --git a/include/d/snd/d_snd_mgr.h b/include/d/snd/d_snd_mgr.h new file mode 100644 index 00000000..d5606784 --- /dev/null +++ b/include/d/snd/d_snd_mgr.h @@ -0,0 +1,32 @@ +#ifndef D_SND_MGR_H +#define D_SND_MGR_H + +#include "egg/audio/eggAudioMgr.h" +#include "nw4r/snd/snd_SoundArchivePlayer.h" + +class dSndMgr_c : public EGG::SimpleAudioMgr { +public: + dSndMgr_c(); + + virtual void calc() override; + void initialize(EGG::Heap *heap, u32 size); + void initHbm(u32 frame); + + static void restoreEffectsCallback(); + + static dSndMgr_c *GetInstance() { + return sInstance; + } + + static nw4r::snd::SoundArchivePlayer* getPlayer() { + return sInstance->ArcPlayer::getPlayer(); + } + +private: + static dSndMgr_c *sInstance; + + /* 0x6C8 */ u8 _0x6C8[0x6CC - 0x6C8]; + /* 0x6CC */ u8 field_0x6CC; +}; + +#endif diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h new file mode 100644 index 00000000..2578fcb4 --- /dev/null +++ b/include/d/snd/d_snd_player_mgr.h @@ -0,0 +1,61 @@ +#ifndef D_SND_PLAYER_MGR_H +#define D_SND_PLAYER_MGR_H + +#include "d/snd/d_snd_util.h" +#include "nw4r/snd/snd_MemorySoundArchive.h" +#include "nw4r/snd/snd_SoundArchivePlayer.h" +#include "nw4r/snd/snd_SoundHandle.h" +#include "nw4r/snd/snd_SoundStartable.h" + +class dSndPlayerMgr_c; +extern template class SndMgrDisposer; + +class dSndPlayerMgr_c { +public: + SndMgrDisposer *GetDisposer() { + return &mDisposer; + } + + static dSndPlayerMgr_c *GetInstance() { + return sInstance; + } + + static dSndPlayerMgr_c *sInstance; + static SndMgrDisposer *sDisposer; + +private: + SndMgrDisposer mDisposer; + +public: + dSndPlayerMgr_c(); + + void calc(); + + u32 getFreeSize(); + bool loadDemoArchive(const char *demoArchiveName); + const char *getSoundArchivePath(); + u32 convertLabelStringToSoundId(const char *label) const; + nw4r::snd::SoundArchivePlayer &getSoundArchivePlayerForType(u8 type); + + bool checkFlag(u32 mask) const { + return mFlags & mask; + } + +private: + /* 0x010 */ u8 field_0x010; + /* 0x011 */ u8 field_0x011; + /* 0x014 */ s32 field_0x014; + /* 0x018 */ s32 field_0x018; + /* 0x01C */ s32 field_0x01C; + /* 0x020 */ u32 mFlags; + + virtual nw4r::snd::SoundStartable::StartResult + startSound(nw4r::snd::SoundHandle *pHandle, u32 soundId, const nw4r::snd::SoundStartable::StartInfo *pStartInfo); + virtual nw4r::snd::SoundStartable::StartResult + startSound(nw4r::snd::SoundHandle *pHandle, const char *soundLabel, const nw4r::snd::SoundStartable::StartInfo *pStartInfo); + + /* 0x028 */ nw4r::snd::MemorySoundArchive mSoundArchive; + /* 0x178 */ nw4r::snd::SoundArchivePlayer mSoundArchivePlayer; +}; + +#endif diff --git a/include/d/snd/d_snd_source.h b/include/d/snd/d_snd_source.h new file mode 100644 index 00000000..65d8be13 --- /dev/null +++ b/include/d/snd/d_snd_source.h @@ -0,0 +1,167 @@ +#ifndef D_SOUND_SOURCE_H +#define D_SOUND_SOURCE_H + +#include "common.h" +#include "d/snd/d_snd_3d_actor.h" +#include "nw4r/ut/ut_list.h" + + +class dAcBase_c; + +class dSoundSourceIf_c { +public: + virtual ~dSoundSourceIf_c() {} +#define SOUNDSOURCE_VIRTUAL(offset) virtual void vt_##offset() = 0; + SOUNDSOURCE_VIRTUAL(0x0C); + SOUNDSOURCE_VIRTUAL(0x10); + SOUNDSOURCE_VIRTUAL(0x14); + SOUNDSOURCE_VIRTUAL(0x18); + SOUNDSOURCE_VIRTUAL(0x1C); + SOUNDSOURCE_VIRTUAL(0x20); + SOUNDSOURCE_VIRTUAL(0x24); + SOUNDSOURCE_VIRTUAL(0x28); + SOUNDSOURCE_VIRTUAL(0x2C); + SOUNDSOURCE_VIRTUAL(0x30); + SOUNDSOURCE_VIRTUAL(0x34); + SOUNDSOURCE_VIRTUAL(0x38); + SOUNDSOURCE_VIRTUAL(0x3C); + SOUNDSOURCE_VIRTUAL(0x40); + SOUNDSOURCE_VIRTUAL(0x44); + virtual bool hasPlayingSounds() const = 0; // 0x48 + SOUNDSOURCE_VIRTUAL(0x4C); + SOUNDSOURCE_VIRTUAL(0x50); + SOUNDSOURCE_VIRTUAL(0x54); + SOUNDSOURCE_VIRTUAL(0x58); + SOUNDSOURCE_VIRTUAL(0x5C); + SOUNDSOURCE_VIRTUAL(0x60); + SOUNDSOURCE_VIRTUAL(0x64); + SOUNDSOURCE_VIRTUAL(0x68); + SOUNDSOURCE_VIRTUAL(0x6C); + SOUNDSOURCE_VIRTUAL(0x70); + SOUNDSOURCE_VIRTUAL(0x74); + SOUNDSOURCE_VIRTUAL(0x78); + SOUNDSOURCE_VIRTUAL(0x7C); + SOUNDSOURCE_VIRTUAL(0x80); + SOUNDSOURCE_VIRTUAL(0x84); + SOUNDSOURCE_VIRTUAL(0x88); + SOUNDSOURCE_VIRTUAL(0x8C); + SOUNDSOURCE_VIRTUAL(0x90); + SOUNDSOURCE_VIRTUAL(0x94); + SOUNDSOURCE_VIRTUAL(0x98); + SOUNDSOURCE_VIRTUAL(0x9C); + SOUNDSOURCE_VIRTUAL(0xA0); + SOUNDSOURCE_VIRTUAL(0xA4); + SOUNDSOURCE_VIRTUAL(0xA8); + SOUNDSOURCE_VIRTUAL(0xAC); + SOUNDSOURCE_VIRTUAL(0xB0); + SOUNDSOURCE_VIRTUAL(0xB4); + SOUNDSOURCE_VIRTUAL(0xB8); + SOUNDSOURCE_VIRTUAL(0xBC); + SOUNDSOURCE_VIRTUAL(0xC0); + SOUNDSOURCE_VIRTUAL(0xC4); + SOUNDSOURCE_VIRTUAL(0xC8); + SOUNDSOURCE_VIRTUAL(0xCC); + SOUNDSOURCE_VIRTUAL(0xD0); + SOUNDSOURCE_VIRTUAL(0xD4); + SOUNDSOURCE_VIRTUAL(0xD8); + SOUNDSOURCE_VIRTUAL(0xDC); + SOUNDSOURCE_VIRTUAL(0xE0); + SOUNDSOURCE_VIRTUAL(0xE4); + SOUNDSOURCE_VIRTUAL(0xE8); + SOUNDSOURCE_VIRTUAL(0xEC); + SOUNDSOURCE_VIRTUAL(0xF0); + SOUNDSOURCE_VIRTUAL(0xF4); + SOUNDSOURCE_VIRTUAL(0xF8); + SOUNDSOURCE_VIRTUAL(0xFC); + + virtual bool isReadyMaybe() = 0; // 0x100 + virtual bool load(void *data, const char *name) = 0; // 0x104 + virtual void setFrame(f32 frame) = 0; // 0x108 + virtual void setRate(f32 frame) = 0; // 0x10C + virtual void set_0x164(UNKWORD val) = 0; // 0x114 + + SOUNDSOURCE_VIRTUAL(0x118); + SOUNDSOURCE_VIRTUAL(0x11C); +}; + +class dSoundSource_c : public dSoundSourceIf_c, public dSnd3DActor_c { +public: + dSoundSource_c(u8, dAcBase_c *, UNKWORD, UNKWORD); + virtual ~dSoundSource_c(); + + 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 void d_s_vt_0x180(); + virtual void d_s_vt_0x184(); + 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 void d_vt_0x58() override; + + virtual void d_s_vt_0x19C(); + virtual void d_s_vt_0x1A0(); + + virtual void d_vt_0x5C() 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 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 d_s_vt_0x1C8(); + virtual void d_s_vt_0x1CC(); + + virtual void d_vt_0x38(bool flag, int fadeFrames) override; + + 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 d_s_vt_0x1E4(); + virtual void d_s_vt_0x1E8(); + + // Overrides of dSoundSourceIf_c + virtual bool hasPlayingSounds() const override; + +private: + // at 0x00: dSoundSourceIf_c vtable + // at 0x04: dSnd3DActor_c sub-object + // at 0x58: thunk-vtable + /* 0xE8 */ u8 field_0xE8[0xF0 - 0xE8]; + + /* 0x0F0 */ UNKWORD field_0x0F0; + /* 0x0F4 */ UNKWORD field_0x0F4; + /* 0x0F8 */ dAcBase_c *mpPlayer; + /* 0x0FC */ u8 field_0x0FC; + /* 0x0FD */ u8 field_0x0FD; + /* 0x0FE */ u8 field_0x0FE; + /* 0x0FF */ u8 field_0x0FF; + /* 0x100 */ u8 field_0x100; + /* 0x101 */ u8 field_0x101; + /* 0x102 */ u8 field_0x102; + /* 0x104 */ UNKWORD field_0x104; + /* 0x108 */ UNKWORD field_0x108; + /* 0x10C */ UNKWORD field_0x10C; + /* 0x110 */ nw4r::ut::List field_0x110; // node offset 0xEC + /* 0x11C */ UNKWORD field_0x11C; + /* 0x120 */ nw4r::ut::List field_0x120; // node offset 0x4 + /* 0x12C */ nw4r::ut::List field_0x12C; // node offset 0x4 + /* 0x138 */ nw4r::ut::Node mNode; + /* 0x140 */ UNKWORD field_0x140; + /* 0x144 */ u8 _0x144[0x154 - 0x144]; + /* 0x154 */ UNKWORD field_0x154; + /* 0x158 */ s16 field_0x158; + /* 0x15A */ s16 field_0x15A; +}; + +#endif diff --git a/include/d/snd/d_snd_util.h b/include/d/snd/d_snd_util.h new file mode 100644 index 00000000..164ae3df --- /dev/null +++ b/include/d/snd/d_snd_util.h @@ -0,0 +1,42 @@ +#ifndef D_SND_UTIL_H +#define D_SND_UTIL_H + +#include "common.h" +#include "egg/core/eggDisposer.h" + +// This setup is only inferred. d/snd uses it all over the place. +// This works for dSndPlayerMgr_c, which has a vtable of its own but the Disposer at offset 0. +// It also works for the factory at 0x80399c20, which calls a base class ctor, +// an inline ctor, and has the Disposer at offset 0x18 + +template +struct SndMgrDisposer : public EGG::Disposer { + virtual ~SndMgrDisposer(); + + static T *create(); + static void remove(); +}; + +template +SndMgrDisposer::~SndMgrDisposer() { + if (this == T::sDisposer) { + remove(); + } +} + +template +T *SndMgrDisposer::create() { + if (T::sInstance == nullptr) { + T::sInstance = new T(); + T::sDisposer = T::sInstance->GetDisposer(); + } + return T::sInstance; +} + +template +void SndMgrDisposer::remove() { + T::sInstance = nullptr; + T::sDisposer = nullptr; +} + +#endif diff --git a/include/egg/audio/eggAudioArcPlayerMgr.h b/include/egg/audio/eggAudioArcPlayerMgr.h index 49673250..f9b982c0 100644 --- a/include/egg/audio/eggAudioArcPlayerMgr.h +++ b/include/egg/audio/eggAudioArcPlayerMgr.h @@ -26,12 +26,20 @@ public: void stopAllSound(); u32 changeNameToId(const char *name) { - return mOpenSndArchive->ConvertLabelStringToSoundId(name); + u32 id = -1; + if (mOpenSndArchive != nullptr) { + id = mOpenSndArchive->ConvertLabelStringToSoundId(name); + } + return id; } nw4r::snd::SoundArchivePlayer *getPlayer() { return mActiveSndArchivePlayer; } + nw4r::snd::SoundArchive *getArchive() { + return mOpenSndArchive; + } + void setLoadStringLabels(bool bLoad) { mLoadLabelStringData = bLoad; } @@ -65,12 +73,7 @@ public: virtual bool startSound(nw4r::snd::SoundHandle *handle, const char *name) // at 0x40 { - u32 id = -1; - if (mOpenSndArchive) { - id = changeNameToId(name); - } - - return ArcPlayer::startSound(handle, id); + return ArcPlayer::startSound(handle, changeNameToId(name)); } virtual bool prepareSound(nw4r::snd::SoundHandle *handle, u32 id) // at 0x44 @@ -85,12 +88,7 @@ public: virtual bool prepareSound(nw4r::snd::SoundHandle *handle, const char *name) // at 0x4C { - u32 id = -1; - if (mOpenSndArchive) { - id = changeNameToId(name); - } - - return ArcPlayer::prepareSound(handle, id); + return ArcPlayer::prepareSound(handle, changeNameToId(name)); } virtual bool holdSound(nw4r::snd::SoundHandle *handle, u32 id) // at 0x50 @@ -105,12 +103,7 @@ public: virtual bool holdSound(nw4r::snd::SoundHandle *handle, const char *name) // at 0x58 { - u32 id = -1; - if (mOpenSndArchive) { - id = changeNameToId(name); - } - - return ArcPlayer::holdSound(handle, id); + return ArcPlayer::holdSound(handle, changeNameToId(name)); } private: diff --git a/include/egg/audio/eggAudioHeapMgr.h b/include/egg/audio/eggAudioHeapMgr.h index fa8ef361..9fd269cc 100644 --- a/include/egg/audio/eggAudioHeapMgr.h +++ b/include/egg/audio/eggAudioHeapMgr.h @@ -21,9 +21,38 @@ public: ~SoundHeapMgr() { destroySoundHeap(); } - virtual bool loadState(s32 id) {} - virtual int getCurrentLevel() {} - virtual void stateProc() {} + int saveState() { + return mSoundHeap.SaveState(); + } + virtual bool loadState(s32 id) { + s32 level = mSoundHeap.GetCurrentLevel(); + if (id > 0 && level >= id) { + mSoundHeap.LoadState(id); + return true; + } else { + return false; + } + } + virtual int getCurrentLevel() { + return mSoundHeap.GetCurrentLevel(); + } + virtual void stateProc() { + OSMessage msg; + if (OSReceiveMessage(&mQueue1.mQueue, &msg, 0)) { + bool ok = loadState((s32)msg); + OSSendMessage(&mQueue3.mQueue, (OSMessage)ok, 0); + } + + if (OSReceiveMessage(&mQueue2.mQueue, &msg, 0)) { + int ok = mSoundHeap.SaveState(); + OSSendMessage(&mQueue3.mQueue, (OSMessage)ok, 0); + } + + if (OSReceiveMessage(&mQueue, &msg, 0)) { + int level = getCurrentLevel(); + OSSendMessage(&mQueue3.mQueue, (OSMessage)level, 0); + } + } void createSoundHeap(Allocator *allocator, u32 size); void destroySoundHeap(); @@ -34,7 +63,9 @@ public: private: nw4r::snd::SoundHeap mSoundHeap; - u8 unk[0x68 - 0x38]; + // I guess we're not initializing this queue? + OSMessageQueue mQueue; + OSMessage mBuffer[4]; SoundMessageQueue mQueue1; SoundMessageQueue mQueue2; SoundMessageQueue mQueue3; diff --git a/include/egg/audio/eggAudioUtility.h b/include/egg/audio/eggAudioUtility.h index 6a56ea66..7abb95b9 100644 --- a/include/egg/audio/eggAudioUtility.h +++ b/include/egg/audio/eggAudioUtility.h @@ -12,7 +12,7 @@ namespace EGG { struct MultiArcSimpleAudioMgr { u8 field_0x000[0x0FC - 0x000]; s32 field_0x0FC; - ArcPlayer players[]; + ArcPlayer players[1]; nw4r::snd::SoundArchivePlayer *getPlayer(int i) { return players[i].getPlayer(); diff --git a/include/egg/core/eggDvdRipper.h b/include/egg/core/eggDvdRipper.h index 82fd09b2..8f4b4b48 100644 --- a/include/egg/core/eggDvdRipper.h +++ b/include/egg/core/eggDvdRipper.h @@ -6,7 +6,6 @@ #include "egg/core/eggHeap.h" #include "egg/core/eggStreamDecomp.h" - namespace EGG { class DvdRipper { @@ -28,6 +27,29 @@ public: typedef void (*UnkCallback)(void *); public: + // Not sure + struct Arg { + Arg(const char *path, u8 *pOut, Heap *pHeap, EAllocDirection allocDir, u32 offset, u32 *pRead, u32 *fileSize) + : path(path), + pOut(pOut), + pHeap(pHeap), + allocDir(allocDir), + offset(offset), + pRead(pRead), + fileSize(fileSize) {} + const char *path; + u8 *pOut; + Heap *pHeap; + EAllocDirection allocDir; + u32 offset; + u32 *pRead; + u32 *fileSize; + }; + + static u8 *loadToMainRAM(Arg &arg) { + return loadToMainRAM(arg.path, arg.pOut, arg.pHeap, arg.allocDir, arg.offset, arg.pRead, arg.fileSize); + } + static u8 * loadToMainRAM(s32 entryNum, u8 *pOut, Heap *pHeap, EAllocDirection allocDir, u32 offset, u32 *pRead, u32 *fileSize); diff --git a/include/egg/gfx/eggCamera.h b/include/egg/gfx/eggCamera.h index c3104fb7..67c3853d 100644 --- a/include/egg/gfx/eggCamera.h +++ b/include/egg/gfx/eggCamera.h @@ -35,6 +35,15 @@ protected: class LookAtCamera : public BaseCamera { public: LookAtCamera() : mPos(0.0f, 10.0f, 0.0f), mAt(0.0f, 0.0f, 0.0f), mUp(0.0f, 1.0f, 0.0f) {} + + LookAtCamera& operator=(const LookAtCamera &other) { + mViewMtx.copyFrom(other.mViewMtx); + mOtherMtx.copyFrom(other.mOtherMtx); + mPos = other.mPos; + mAt = other.mAt; + mUp = other.mUp; + return *this; + } // Which way around? virtual Matrix34f &getViewMatrix() override { return mViewMtx; @@ -53,7 +62,15 @@ public: virtual void doDraw() override; virtual Matrix34f &getViewMatrixOld() override; -protected: + Vector3f getDirection() const { + return mAt - mPos; + } + + Vector3f getOtherDirection() const { + return mPos - mAt; + } + +public: /* 0x64 */ Vector3f mPos; /* 0x70 */ Vector3f mAt; /* 0x7C */ Vector3f mUp; diff --git a/include/egg/math/eggMatrix.h b/include/egg/math/eggMatrix.h index a99a0698..d16f2865 100644 --- a/include/egg/math/eggMatrix.h +++ b/include/egg/math/eggMatrix.h @@ -4,6 +4,7 @@ #include "common.h" #include "egg/math/eggQuat.h" #include "egg/math/eggVector.h" +#include "nw4r/math/math_types.h" namespace EGG { @@ -55,6 +56,14 @@ struct Matrix34f { void multiplyTo(const Matrix34f &m2, Matrix34f &to) const; void dump(); + operator nw4r::math::MTX34 *() { + return (nw4r::math::MTX34 *)this; + } + + operator const nw4r::math::MTX34 *() const { + return (nw4r::math::MTX34 *)this; + } + public: void concat(const Matrix34f &, Matrix34f &) const; void rotate(const Vector3f &rpy) const; diff --git a/include/nw4r/lyt/lyt_layout.h b/include/nw4r/lyt/lyt_layout.h index dd988c4b..543065fb 100644 --- a/include/nw4r/lyt/lyt_layout.h +++ b/include/nw4r/lyt/lyt_layout.h @@ -2,11 +2,11 @@ #define NW4R_LYT_LAYOUT_H #include "common.h" -#include "new.h" #include "nw4r/lyt/lyt_animation.h" #include "nw4r/lyt/lyt_types.h" #include "rvl/MEM/mem_allocator.h" +#include namespace nw4r { namespace lyt { diff --git a/include/nw4r/snd/snd_BasicSound.h b/include/nw4r/snd/snd_BasicSound.h index 8fc57508..b3629b19 100644 --- a/include/nw4r/snd/snd_BasicSound.h +++ b/include/nw4r/snd/snd_BasicSound.h @@ -327,40 +327,40 @@ namespace nw4r { namespace snd { namespace detail ExternalSoundPlayer *mExtSoundPlayer; // size 0x04, offset 0x18 AmbientInfo mAmbientInfo; // size 0x14, offset 0x1c SoundParam mAmbientParam; // size 0x24, offset 0x30 - SoundActorParam mActorParam; // size 0x0c, offset 0x54 - MoveValue mFadeVolume; // size 0x10, offset 0x60 - MoveValue mPauseFadeVolume; // size 0x10, offset 0x70 - bool mStartFlag; // size 0x01, offset 0x80 - bool mStartedFlag; // size 0x01, offset 0x81 - bool mAutoStopFlag; // size 0x01, offset 0x82 - bool mFadeOutFlag; // size 0x01, offset 0x83 - PauseState mPauseState; // size 0x04, offset 0x84 - bool mUnPauseFlag; // size 0x01, offset 0x88 + SoundActorParam mActorParam; // size 0x0c, offset 0x58 + MoveValue mFadeVolume; // size 0x10, offset 0x64 + MoveValue mPauseFadeVolume; // size 0x10, offset 0x74 + bool mStartFlag; // size 0x01, offset 0x84 + bool mStartedFlag; // size 0x01, offset 0x85 + bool mAutoStopFlag; // size 0x01, offset 0x86 + bool mFadeOutFlag; // size 0x01, offset 0x87 + PauseState mPauseState; // size 0x04, offset 0x88 + bool mUnPauseFlag; // size 0x01, offset 0x8c /* 3 bytes padding */ - s32 mAutoStopCounter; // size 0x04, offset 0x8c - u32 mUpdateCounter; // size 0x04, offset 0x90 - u8 mPriority; // size 0x01, offset 0x94 - u8 mVoiceOutCount; // size 0x01, offset 0x95 - u8 mBiquadFilterType; // size 0x01, offset 0x96 + s32 mAutoStopCounter; // size 0x04, offset 0x90 + u32 mUpdateCounter; // size 0x04, offset 0x94 + u8 mPriority; // size 0x01, offset 0x98 + u8 mVoiceOutCount; // size 0x01, offset 0x99 + u8 mBiquadFilterType; // size 0x01, offset 0x9a /* 1 byte padding */ - u32 mId; // size 0x04, offset 0x98 - MoveValue mExtMoveVolume; // size 0x10, offset 0x9c - f32 mInitVolume; // size 0x04, offset 0xac - f32 mExtPan; // size 0x04, offset 0xb0 - f32 mExtSurroundPan; // size 0x04, offset 0xb4 - f32 mExtPitch; // size 0x04, offset 0xb8 - f32 mLpfFreq; // size 0x04, offset 0xbc - f32 mBiquadFilterValue; // size 0x04, offset 0xc0 - int mOutputLineFlag; // size 0x04, offset 0xc4 - f32 mMainOutVolume; // size 0x04, offset 0xc8 - f32 mMainSend; // size 0x04, offset 0xcc - f32 mFxSend[AUX_BUS_NUM]; // size 0x0c, offset 0xd0 - f32 mRemoteOutVolume[4]; // size 0x10, offset 0xdc + u32 mId; // size 0x04, offset 0x9c + MoveValue mExtMoveVolume; // size 0x10, offset 0xa0 + f32 mInitVolume; // size 0x04, offset 0xb0 + f32 mExtPan; // size 0x04, offset 0xb4 + f32 mExtSurroundPan; // size 0x04, offset 0xb8 + f32 mExtPitch; // size 0x04, offset 0xbc + f32 mLpfFreq; // size 0x04, offset 0xc0 + f32 mBiquadFilterValue; // size 0x04, offset 0xc4 + int mOutputLineFlag; // size 0x04, offset 0xc8 + f32 mMainOutVolume; // size 0x04, offset 0xcc + f32 mMainSend; // size 0x04, offset 0xd0 + f32 mFxSend[AUX_BUS_NUM]; // size 0x0c, offset 0xd4 + f32 mRemoteOutVolume[4]; // size 0x10, offset 0xe0 public: - ut::LinkListNode mPriorityLink; // size 0x08, offset 0xe0 - ut::LinkListNode mSoundPlayerPlayLink; // size 0x08, offset 0xe8 - ut::LinkListNode mSoundPlayerPriorityLink; // size 0x08, offset 0xf0 - ut::LinkListNode mExtSoundPlayerPlayLink; // size 0x08, offset 0xf8 + ut::LinkListNode mPriorityLink; // size 0x08, offset 0xf0 + ut::LinkListNode mSoundPlayerPlayLink; // size 0x08, offset 0xf8 + ut::LinkListNode mSoundPlayerPriorityLink; // size 0x08, offset 0x100 + ut::LinkListNode mExtSoundPlayerPlayLink; // size 0x08, offset 0x108 // friends private: diff --git a/include/nw4r/snd/snd_Sound3DActor.h b/include/nw4r/snd/snd_Sound3DActor.h index a748bddd..168fafa6 100644 --- a/include/nw4r/snd/snd_Sound3DActor.h +++ b/include/nw4r/snd/snd_Sound3DActor.h @@ -21,8 +21,15 @@ public: // AmbientArgUpdateCallback virtual void at_0x0c(void *arg, detail::BasicSound* sound) override; + const nw4r::math::VEC3 &GetPosition() const { + return mPosition; + } void SetPosition(const math::VEC3 &rPosition); + void SetUserParam(u32 userParam) { + mUserParam = userParam; + } + private: static void ClearUpdateCallback(SoundHandle &rHandle); diff --git a/include/nw4r/snd/snd_Sound3DEngine.h b/include/nw4r/snd/snd_Sound3DEngine.h index e643d5f5..abab43f6 100644 --- a/include/nw4r/snd/snd_Sound3DEngine.h +++ b/include/nw4r/snd/snd_Sound3DEngine.h @@ -19,7 +19,7 @@ public: virtual void UpdateAmbientParam(const Sound3DManager*, const Sound3DParam*, u32, int, SoundAmbientParam*); virtual s32 GetAmbientPriority(const Sound3DManager*, const Sound3DParam*, u32); virtual s32 GetRequiredVoiceOutCount(const Sound3DManager*, const Sound3DParam*, u32); - virtual void UpdateAmbientParam(const Sound3DManager*, const Sound3DParam*, u32, u32, SoundAmbientParam*); + virtual void UpdateAmbientParam(const Sound3DManager*, const Sound3DParam*, u32, u32 flags, SoundAmbientParam*); private: Sound3DCalculator::CalcPanParam mPanParam; // at 0x04 diff --git a/include/nw4r/snd/snd_Sound3DManager.h b/include/nw4r/snd/snd_Sound3DManager.h index 9bfa470c..1c370eef 100644 --- a/include/nw4r/snd/snd_Sound3DManager.h +++ b/include/nw4r/snd/snd_Sound3DManager.h @@ -68,10 +68,18 @@ public: return field_0x20; } + void SetField0x20(f32 value) { + field_0x20 = value; + } + f32 GetField0x24() const { return field_0x24; } + void SetField0x24(f32 value) { + field_0x24 = value; + } + void SetEngine(Sound3DEngine *engine); enum ParamDecayCurve { diff --git a/include/nw4r/snd/snd_SoundHandle.h b/include/nw4r/snd/snd_SoundHandle.h index e400a441..cf1ed317 100644 --- a/include/nw4r/snd/snd_SoundHandle.h +++ b/include/nw4r/snd/snd_SoundHandle.h @@ -39,6 +39,10 @@ namespace nw4r { namespace snd mSound->Stop(0); } + bool IsPause() const { + return IsAttachedSound() && mSound->IsPause(); + } + u32 GetId() const { if (IsAttachedSound()) diff --git a/include/sized_string.h b/include/sized_string.h index dc711238..44e26ebe 100644 --- a/include/sized_string.h +++ b/include/sized_string.h @@ -5,6 +5,7 @@ #include "common.h" #include "string.h" #include "wstring.h" +#include "printf.h" extern "C" bool strequals(const char *a, const char *b); diff --git a/include/sound_mgrs/sound_audio_manager.h b/include/sound_mgrs/sound_audio_manager.h deleted file mode 100644 index 1bfe885c..00000000 --- a/include/sound_mgrs/sound_audio_manager.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef SOUND_AUDIO_MANAGER_H -#define SOUND_AUDIO_MANAGER_H - -#include "common.h" -#include "egg/audio/eggAudioMgr.h" - - -// Size: 0x6d0 -class SndAudioMgr : public EGG::SimpleAudioMgr { -public: -}; - -#endif diff --git a/include/toBeSorted/d_d3d.h b/include/toBeSorted/d_d3d.h index 07e9505d..76cbd010 100644 --- a/include/toBeSorted/d_d3d.h +++ b/include/toBeSorted/d_d3d.h @@ -91,14 +91,14 @@ public: return create2(ac, mdlFile, mdlName, anmName, callback, bufferOption); } - void setSoundSource(SoundSource *pSource); + void setSoundSource(dSoundSourceIf_c *pSource); protected: bool loadSounds(const char *name); void syncAnmFrame(); void setSoundRate(f32 rate); - /* 0x68 */ SoundSource *mpSoundSource; + /* 0x68 */ dSoundSourceIf_c *mpSoundSource; /* 0x6C */ void *mpSoundData; }; diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index 476c1293..aad42969 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -2,16 +2,18 @@ #define MUSIC_MGRS_H #include "common.h" +#include "d/snd/d_snd_player_mgr.h" -class BgmMgr; +class dSndPlayerMgr_c; -extern "C" BgmMgr *BGM_MGR; +#define BGM_MGR (dSndPlayerMgr_c::GetInstance()) extern "C" void fn_8035E000(); -extern "C" void fn_8035E860(BgmMgr *); -extern "C" void fn_8035E310(BgmMgr *); -extern "C" void fn_8035E820(BgmMgr *); -extern "C" void fn_8035E880(BgmMgr *); -extern "C" void fn_8035E790(BgmMgr *, UNKWORD, void *); +extern "C" void fn_8035E860(dSndPlayerMgr_c *); +extern "C" void fn_8035E310(dSndPlayerMgr_c *); +extern "C" void fn_8035E820(dSndPlayerMgr_c *); +extern "C" void fn_8035E880(dSndPlayerMgr_c *); +extern "C" void fn_8035E790(dSndPlayerMgr_c *, UNKWORD, void *); +extern "C" bool fn_8035ED90(dSndPlayerMgr_c *, u8); extern "C" void *ENEMY_SOUND_MGR; extern "C" void fn_80362150(void *, u16); @@ -21,6 +23,8 @@ extern "C" void fn_80362730(void *); 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_80364D00(void*, s32); extern "C" void *ENEMY_BGM_RELATED_MGR; extern "C" void fn_80384570(void *, bool); @@ -28,5 +32,10 @@ extern "C" void fn_803858D0(void *); extern "C" void *FANFARE_SOUND_MGR; extern "C" void AnotherSoundMgr__playSound(void *, s32); +extern "C" bool fn_803721F0(void *, u32); +extern "C" bool fn_803720E0(void *, u32); +extern "C" bool fn_80372070(void *, u32); +extern "C" bool fn_803734C0(void *, u32); +extern "C" bool fn_80373550(void *, u32); #endif diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath index d6685a2a..acb717c7 100644 --- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath +++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath @@ -66,5 +66,12 @@ inline float sqrtf(float x) { } // namespace std +#define _HUGE_ENUF 1e+300 +#define INFINITY ((float)(_HUGE_ENUF * _HUGE_ENUF)) +#define HUGE_VAL ((double)INFINITY) +#define HUGE_VALL ((long double)INFINITY) + +#define DOUBLE_INF HUGE_VAL + #endif #endif diff --git a/src/REL/d/t/d_t_sound_area.cpp b/src/REL/d/t/d_t_sound_area.cpp index ca60e02f..46112c97 100644 --- a/src/REL/d/t/d_t_sound_area.cpp +++ b/src/REL/d/t/d_t_sound_area.cpp @@ -3,6 +3,7 @@ #include "d/a/d_a_player.h" #include "d/a/obj/d_a_obj_base.h" #include "d/col/c/c_m3d_g_cps.h" +#include "d/snd/d_snd_3d_manager.h" #include "d/t/d_t_sound_area_mgr.h" #include "rvl/MTX.h" // IWYU pragma: export @@ -45,20 +46,13 @@ int dTgSndAr_c::doDelete() { return SUCCEEDED; } -struct Unk { - u8 unk[0x144]; - mVec3_c v; -}; - -extern Unk *lbl_80575D58; - int dTgSndAr_c::actorExecute() { dAcBase_c *link = dAcPy_c::LINK; if (link != nullptr && checkPosInArea(link->position)) { link->setBit_field_0xE8(params & 0xFF); } - if (lbl_80575D58 != nullptr) { - mVec3_c pos = lbl_80575D58->v; + if (dSnd3DManager_c::GetInstance() != nullptr) { + mVec3_c pos = dSnd3DManager_c::GetInstance()->getListenerPos(); if (checkPosInArea(pos) && dTgSndMg_c::GetInstance() != nullptr) { dTgSndMg_c::GetInstance()->setBgmFlag(params & 0xFF); } diff --git a/src/d/a/d_a_base.cpp b/src/d/a/d_a_base.cpp index ff47e669..3bd8cca9 100644 --- a/src/d/a/d_a_base.cpp +++ b/src/d/a/d_a_base.cpp @@ -39,7 +39,7 @@ u8 dAcBase_c::s_Create_Subtype; extern "C" ObjInfo *getObjByActorIdAndSubtype_unkNamespace(ProfileName, u8); extern "C" ObjInfo *getObjByActorName_unkNamespace(char *name); extern "C" char *getObjectName_8006a730(ObjInfo *); -extern "C" SoundSource *soundForActorInitRelated_803889c0(s8, fBase_c *, char *, u8); +extern "C" dSoundSourceIf_c *soundForActorInitRelated_803889c0(s8, fBase_c *, char *, u8); bool dAcBase_c::createHeap() { return true; @@ -113,7 +113,7 @@ void dAcBase_c::setTempCreateParams( } // has regswap -SoundSource *dAcBase_c::FUN_8002c690() { +dSoundSourceIf_c *dAcBase_c::FUN_8002c690() { if (obj_info == nullptr) { return nullptr; } @@ -515,7 +515,7 @@ void dAcBase_c::FUN_8002d830() {} void dAcBase_c::FUN_8002d860(UNKWORD) {} // 8002d880 -SoundSource *dAcBase_c::getSoundSource() { +dSoundSourceIf_c *dAcBase_c::getSoundSource() { return sound_source.get(); } // End of SoundSource stuff diff --git a/src/d/d_player_mdl.cpp b/src/d/d_player_mdl.cpp index a994eebb..c5c45ba3 100644 --- a/src/d/d_player_mdl.cpp +++ b/src/d/d_player_mdl.cpp @@ -631,7 +631,7 @@ bool daPlBaseMdl_c::create( field_0x58 = 0; mpSoundData = nullptr; field_0x5A = 0xFFFF; - SoundSource *sound = player->getSoundSource(); + dSoundSourceIf_c *sound = player->getSoundSource(); if (sound->isReadyMaybe()) { sound->load(nullptr, ""); } @@ -1772,7 +1772,7 @@ void daPlayerModelBase_c::removeAnmChr(s32 childIdx) { } void daPlayerModelBase_c::loadSound(nw4r::g3d::ResFile &file, const char *name, s32 childIdx) { - SoundSource *s = getSoundSource(); + dSoundSourceIf_c *s = getSoundSource(); mCurrentAnmChrIdx = childIdx; SizedString<64> path; path.sprintf("%s.brasd", name); @@ -1785,7 +1785,7 @@ void daPlayerModelBase_c::loadSound(nw4r::g3d::ResFile &file, const char *name, } void daPlayerModelBase_c::loadSoundForAnim(s32 childIdx) { - SoundSource *s = getSoundSource(); + dSoundSourceIf_c *s = getSoundSource(); s32 anim = mAnimations[childIdx]; mCurrentAnmChrIdx = childIdx; if (anim != mMainMdl.getField_0x5A()) { diff --git a/src/d/snd/d_snd_3d_actor.cpp b/src/d/snd/d_snd_3d_actor.cpp new file mode 100644 index 00000000..4ca49c4b --- /dev/null +++ b/src/d/snd/d_snd_3d_actor.cpp @@ -0,0 +1,96 @@ +#include "d/snd/d_snd_3d_actor.h" + +#include "common.h" +#include "d/a/d_a_player.h" +#include "d/snd/d_snd_3d_manager.h" +#include "nw4r/math/math_types.h" +#include "toBeSorted/music_mgrs.h" + +#include + +dSnd3DActor_c::dSnd3DActor_c(UNKTYPE *a1, u8 a2) + : nw4r::snd::Sound3DActor( + dSndPlayerMgr_c::GetInstance()->getSoundArchivePlayerForType(a2), dSnd3DManager_c::GetInstance()->getManager() + ), + a_field_0x7D(0), + a_field_0x7E(0), + a_field_0x7F(0), + a_field_0x80(0), + a_field_0x84(0.0f), + a_field_0x88(0.0f), + a_field_0x8C(0.0f), + a_field_0x90(INFINITY), + a_field_0x94(INFINITY), + a_field_0x98(0.0f), + a_field_0x9C(0.0f), + a_field_0xC8(a1), + mFlags(0), + mDistanceToPlayer(INFINITY), + a_field_0xE0(0.0f) { + resetFloats(); + // Portability hazard + SetUserParam(reinterpret_cast(this)); + if (fn_8035ED90(BGM_MGR, a2)) { + a_field_0x7F = 1; + } +} + +void dSnd3DActor_c::d_vt_0x34(const nw4r::math::VEC3 &rPosition) { + SetPosition(rPosition); + // TODO - 0xE0 + mFlags = 0; +} + +void dSnd3DActor_c::updatePositionRelativeToPlayer() { + if (!checkFlag(0x40)) { + nw4r::math::VEC3 linkTranslation = dAcPy_c::GetLink()->getCenterTranslation(); + nw4r::math::VEC3 pos = GetPosition(); + nw4r::math::VEC3Sub(&mPositionRelativeToPlayer, &pos, &linkTranslation); + + mFlags |= 0x40; + } +} + +const nw4r::math::VEC3 &dSnd3DActor_c::getPositionRelativeToPlayer() { + updatePositionRelativeToPlayer(); + return mPositionRelativeToPlayer; +} + +void dSnd3DActor_c::updateDistanceToPlayer() { + if (!checkFlag(0x80)) { + updatePositionRelativeToPlayer(); + nw4r::math::VEC3 linkTranslation = dAcPy_c::GetLink()->getCenterTranslation(); + nw4r::math::VEC3 pos = GetPosition(); + if ((linkTranslation.x == 0.0f && linkTranslation.y == 0.0f && linkTranslation.z == 0.0f) || + (pos.x == 0.0f && pos.y == 0.0f && pos.z == 0.0f)) { + // Don't bother if we received dummy values + mDistanceToPlayer = INFINITY; + } else { + mDistanceToPlayer = nw4r::math::VEC3Len(&mPositionRelativeToPlayer); + } + mFlags |= 0x80; + } +} + +f32 dSnd3DActor_c::getDistanceToPlayer() { + updateDistanceToPlayer(); + return mDistanceToPlayer; +} + +bool dSnd3DActor_c::hasPlayingSounds() const { + for (int i = 0; i < ACTOR_PLAYER_COUNT; i++) { + if (GetPlayingSoundCount(i) > 0) { + return true; + } + } + return false; +} + +bool dSnd3DActor_c::isPlayingSound(u32 id) { + bool result = false; + + IsCurrentSoundIdChecker handler(id, &result); + ForEachSound(handler, false); + + return result; +} diff --git a/src/d/snd/d_snd_3d_engine.cpp b/src/d/snd/d_snd_3d_engine.cpp new file mode 100644 index 00000000..59605476 --- /dev/null +++ b/src/d/snd/d_snd_3d_engine.cpp @@ -0,0 +1,56 @@ +#include "d/snd/d_snd_3d_engine.h" + +#include "common.h" +#include "nw4r/snd/snd_Sound3DListener.h" + +dSnd3DEngine_c::dSnd3DEngine_c() {} + +static void CalcPitch( + const nw4r::math::VEC3 *vec, f32 mag, const nw4r::snd::Sound3DManager &mgr, + const nw4r::snd::Sound3DListener &listener, const nw4r::snd::Sound3DParam ¶m, f32 *pPitch +); + +void dSnd3DEngine_c::UpdateAmbientParam( + const nw4r::snd::Sound3DManager *mgr, const nw4r::snd::Sound3DParam *param3d, u32 unk, u32 flags, + nw4r::snd::SoundAmbientParam *paramAmb +) { + f32 pitch; + CalcPitch(nullptr, 0.0f, *mgr, mgr->GetListenerList().GetFront(), *param3d, &pitch); +} + +// Largely copied from Sound3DCalculator::CalcPitch +static void CalcPitch( + const nw4r::math::VEC3 *vec, f32 mag, const nw4r::snd::Sound3DManager &mgr, + const nw4r::snd::Sound3DListener &listener, const nw4r::snd::Sound3DParam ¶m, f32 *pPitch +) { + f32 f0 = mgr.GetField0x24(); + if (f0 == 0.0f) { + *pPitch = 1.0f; + return; + } + + nw4r::math::VEC3 relativePos(*vec); + if (mag > 0.0f) { + relativePos /= mag; + } + f32 f3 = param.field_0x1E / 32.0f; + f32 f1, f2; + if (mag > 0.0f) { + f1 = -nw4r::math::VEC3Dot(&relativePos, ¶m.velocity); + f2 = -nw4r::math::VEC3Dot(&relativePos, &listener.GetVelocity()); + } else { + f1 = -nw4r::math::VEC3Len(¶m.velocity); + f2 = nw4r::math::VEC3Len(&listener.GetVelocity()); + } + f32 pitch; + f1 *= f3; + f2 *= f3; + if (f2 > f0) { + pitch = 0.0f; + } else if (f1 >= f0) { + pitch = 65535.0f; + } else { + pitch = (f0 - f2) / (f0 - f1); + } + *pPitch = pitch; +} diff --git a/src/d/snd/d_snd_3d_manager.cpp b/src/d/snd/d_snd_3d_manager.cpp new file mode 100644 index 00000000..39e18a63 --- /dev/null +++ b/src/d/snd/d_snd_3d_manager.cpp @@ -0,0 +1,135 @@ +#include "d/snd/d_snd_3d_manager.h" + +#include "d/snd/d_snd_3d_engine.h" +#include "d/snd/d_snd_mgr.h" +#include "egg/math/eggMatrix.h" +#include "egg/math/eggVector.h" +#include "nw4r/math/math_arithmetic.h" +#include "nw4r/math/math_types.h" +#include "nw4r/snd/snd_SoundArchive.h" +#include "toBeSorted/music_mgrs.h" + +template class SndMgrDisposer; + +dSnd3DManager_c::dSnd3DManager_c() : mIsSetup(false), field_0x11(0) { + mCameraPosSqVelocity = 0.0f; + mCameraAtSqVelocity = 0.0f; + mCamDistance = 0.9f; + mTimer = 0; + mpEngine = new dSnd3DEngine_c(); + field_0x138.x = 0.0f; + field_0x138.y = 0.0f; + field_0x138.z = 1.0f; +} + +void dSnd3DManager_c::setup() { + if (mIsSetup) { + return; + } + + nw4r::snd::SoundArchive *archive = dSndMgr_c::GetInstance()->getArchive(); + u32 requiredSize = mManager.GetRequiredMemSize(archive); + void *buf = dSndMgr_c::GetInstance()->getSoundHeap()->Alloc(requiredSize); + mManager.Setup(archive, buf, requiredSize); + mManager.SetEngine(mpEngine); + mManager.SetMaxPriorityReduction(32); + mManager.SetField0x20(0.9f); + mManager.SetField0x24(3400.0f / 3.0f); + mListener.SetMaxVolumeDistance(300.0f); + mListener.SetUnitDistance(1000.0f); + mListener.SetInteriorSize(400.0f); + mManager.SetBiquadFilterType(3); + mListener.SetUnitBiquadFilterMax(0.5f); + mListener.SetUnitBiquadFilterValue(0.2f); + mManager.GetListenerList().Insert(mManager.GetListenerList().GetEndIter(), &mListener); + mIsSetup = true; +} + +void dSnd3DManager_c::resetCamDistance() { + mCamDistance = 0.9f; +} + +void dSnd3DManager_c::setCamDistance(f32 value) { + // @bug ? not actually clamped + nw4r::ut::Clamp(value, -1.0f, 2.0f); + mCamDistance = value; +} + +void dSnd3DManager_c::calc() { + field_0x11 = 0; +} + +void dSnd3DManager_c::clearState() { + mCameraPosSqVelocity = 0.0f; + mCameraAtSqVelocity = 0.0f; + mTimer = 0; +} + + +void dSnd3DManager_c::updateFromCamera(EGG::LookAtCamera &camera) { + if (field_0x11) { + return; + } + + f32 dist = 0.5f; + if (fn_80364DA0(ENEMY_SOUND_MGR)) { + dist = mCamDistance; + f32 prevCameraAtSqVelocity = mCameraAtSqVelocity; + f32 prevCameraPosSqVelocity = mCameraPosSqVelocity; + mCameraAtSqVelocity = VECSquareDistance(camera.mAt, mCamera.mAt); + mCameraPosSqVelocity = VECSquareDistance(camera.mPos, mCamera.mPos); + if (((u32 *)ENEMY_SOUND_MGR)[71] > 30) { + bool bigMovement = false; + bool hugeMovement = false; + if (mTimer > 0) { + mTimer--; + } else { + f32 atAccel = prevCameraAtSqVelocity - mCameraAtSqVelocity; + f32 atAccelAbs = nw4r::math::FAbs(atAccel); + if (mCameraAtSqVelocity > 490000.0f) { + bigMovement = true; + hugeMovement = true; + } else if (atAccelAbs > 10000.0f) { + bigMovement = true; + } + if (!hugeMovement) { + f32 posAccel = prevCameraPosSqVelocity - mCameraPosSqVelocity; + f32 posAccelAbs = nw4r::math::FAbs(posAccel); + if (mCameraPosSqVelocity > 490000.0f) { + bigMovement = true; + hugeMovement = true; + } else if (posAccelAbs > 10000.0f) { + bigMovement = true; + } + if (bigMovement && !hugeMovement && nw4r::math::FAbs(atAccelAbs - posAccelAbs) < 22500.0f) { + nw4r::math::VEC3 myDir = mCamera.getOtherDirection(); + nw4r::math::VEC3 camDir = camera.getOtherDirection(); + VECNormalize(myDir, myDir); + VECNormalize(camDir, camDir); + if (nw4r::math::VEC3Dot(&myDir, &camDir) > 0.99f) { + bigMovement = false; + } + } + } + + if (bigMovement) { + fn_80364D00(ENEMY_SOUND_MGR, -1); + mTimer = 30; + } + } + } + } + + mCamera = camera; + updateListenerPos(dist); + field_0x11 = 1; +} + +void dSnd3DManager_c::updateListenerPos(f32 f) { + const EGG::Matrix34f &mtx = mCamera.getViewMatrix(); + mListener.SetMatrix(*mtx); + EGG::Vector3f dir = mCamera.getDirection(); + VECNormalize(dir, field_0x138); + dir *= f; + mSoundListenerPosition = mCamera.mPos + dir; +} diff --git a/src/d/snd/d_snd_actor.cpp b/src/d/snd/d_snd_actor.cpp new file mode 100644 index 00000000..db456ecf --- /dev/null +++ b/src/d/snd/d_snd_actor.cpp @@ -0,0 +1,66 @@ +#include "d/snd/d_snd_actor.h" + +#include "common.h" +#include "d/snd/d_snd_checkers.h" +#include "nw4r/snd/snd_BasicSound.h" +#include "nw4r/snd/snd_SoundArchivePlayer.h" +#include "nw4r/snd/snd_SoundHandle.h" +#include "toBeSorted/music_mgrs.h" + +dSndActor_c::dSndActor_c(nw4r::snd::SoundArchivePlayer &rStartable) : nw4r::snd::SoundActor(rStartable) {} + +void d_snd_actor_SoundHandle_dtor() { + nw4r::snd::SoundHandle handle[2]; +} + +void SoundPropertiesChecker::operator()(nw4r::snd::SoundHandle &pHandle) { + if (mSoundId != -1 && mSoundId != pHandle.GetId()) { + return; + } + + if (mpPlayCounter != nullptr) { + (*mpPlayCounter)++; + } else { + mPlayCounter++; + } + + if (pHandle.IsPause()) { + if (mpPauseCounter != nullptr) { + (*mpPauseCounter)++; + } else { + mPauseCounter++; + } + return; + } + + if (fn_803721F0(FANFARE_SOUND_MGR, pHandle.GetId())) { + if (mpCounter3 != nullptr) { + (*mpCounter3)++; + } else { + mCounter3++; + } + return; + } + + if (fn_803720E0(FANFARE_SOUND_MGR, pHandle.GetId())) { + if (mpCounter3 != nullptr) { + (*mpCounter3)++; + } else { + mCounter3++; + } + return; + } + + if (fn_80372070(FANFARE_SOUND_MGR, pHandle.GetId())) { + if (mpCounter4 != nullptr) { + (*mpCounter4)++; + } else { + mCounter4++; + } + return; + } + + if (fn_803734C0(FANFARE_SOUND_MGR, pHandle.GetId()) && !fn_80373550(FANFARE_SOUND_MGR, pHandle.GetId())) { + mCounter3++; + } +} diff --git a/src/d/snd/d_snd_mgr.cpp b/src/d/snd/d_snd_mgr.cpp new file mode 100644 index 00000000..6604fcae --- /dev/null +++ b/src/d/snd/d_snd_mgr.cpp @@ -0,0 +1,58 @@ +#include "d/snd/d_snd_mgr.h" + +#include "d/snd/d_snd_3d_manager.h" +#include "d/snd/d_snd_player_mgr.h" +#include "d/snd/d_snd_util.h" +#include "egg/audio/eggAudioRmtSpeakerMgr.h" +#include "egg/audio/eggAudioUtility.h" + +extern "C" void fn_8035F120(); +extern "C" void initEnemySoundMgr(); +extern "C" void initFanfareSoundMgr(); +extern "C" void initSomeUnusedSoundMgr(); +extern "C" void initSoundEffectSoundMgr(); +extern "C" void fn_8036A430(); +extern "C" void initEnemyBgmRelatedMgr(); +extern "C" void fn_80393530(); +extern "C" void fn_80394830(); +extern "C" void fn_8037F940(); +extern "C" void fn_80399600(); +extern "C" void fn_80399C20(); + +dSndMgr_c *dSndMgr_c::sInstance; + +dSndMgr_c::dSndMgr_c(): field_0x6CC(0) { + sInstance = this; + SndMgrDisposer::create(); + fn_8035F120(); + initEnemySoundMgr(); + SndMgrDisposer::create(); + initFanfareSoundMgr(); + initSomeUnusedSoundMgr(); + initSoundEffectSoundMgr(); + fn_8036A430(); + initEnemyBgmRelatedMgr(); + fn_80393530(); + fn_80394830(); + fn_8037F940(); + fn_80399600(); + fn_80399C20(); + + initHbm(9); +} + +void dSndMgr_c::initialize(EGG::Heap *heap, u32 size) {} + +void dSndMgr_c::initHbm(u32 frame) { + EGG::AudioUtility::HBM::init(this, restoreEffectsCallback, frame); +} + +void dSndMgr_c::calc() { + if (field_0x6CC) { + EGG::SimpleAudioMgr::calc(); + EGG::AudioRmtSpeakerMgr::calc(); + dSndPlayerMgr_c::GetInstance()->calc(); + } +} + +void dSndMgr_c::restoreEffectsCallback() {} diff --git a/src/d/snd/d_snd_player_mgr.cpp b/src/d/snd/d_snd_player_mgr.cpp new file mode 100644 index 00000000..0edee554 --- /dev/null +++ b/src/d/snd/d_snd_player_mgr.cpp @@ -0,0 +1,86 @@ + +#include "d/snd/d_snd_player_mgr.h" + +#include "common.h" +#include "d/snd/d_snd_mgr.h" +#include "egg/core/eggDvdRipper.h" +#include "nw4r/snd/snd_SoundHandle.h" +#include "nw4r/snd/snd_SoundStartable.h" +#include "sized_string.h" + +const char *dSndPlayerMgr_c::getSoundArchivePath() { + return "Sound/WZSound.brsar"; +} + +template class SndMgrDisposer; + +dSndPlayerMgr_c::dSndPlayerMgr_c() + : field_0x010(0), field_0x011(0), field_0x014(-1), field_0x018(-1), field_0x01C(-1), mFlags(0) {} + +u32 dSndPlayerMgr_c::getFreeSize() { + return dSndMgr_c::GetInstance()->getSoundHeap()->GetFreeSize(); +} + +nw4r::snd::SoundStartable::StartResult dSndPlayerMgr_c::startSound( + nw4r::snd::SoundHandle *pHandle, u32 soundId, const nw4r::snd::SoundStartable::StartInfo *pStartInfo +) { + if (mFlags & 0x2) { + return nw4r::snd::SoundStartable::START_ERR_USER; + } + + nw4r::snd::SoundHandle handle; + if (pHandle == nullptr) { + pHandle = &handle; + } + nw4r::snd::SoundStartable::StartResult res; + if (pStartInfo != nullptr) { + res = dSndMgr_c::getPlayer()->detail_StartSound(pHandle, soundId, pStartInfo); + } else { + res = dSndMgr_c::getPlayer()->detail_StartSound(pHandle, soundId, nullptr); + } + return res; +} + +nw4r::snd::SoundStartable::StartResult dSndPlayerMgr_c::startSound( + nw4r::snd::SoundHandle *pHandle, const char *soundLabel, const nw4r::snd::SoundStartable::StartInfo *pStartInfo +) { + u32 id = dSndPlayerMgr_c::GetInstance()->convertLabelStringToSoundId(soundLabel); + return startSound(pHandle, id, pStartInfo); +} + +u32 dSndPlayerMgr_c::convertLabelStringToSoundId(const char *label) const { + return dSndMgr_c::GetInstance()->changeNameToId(label); +} + +bool dSndPlayerMgr_c::loadDemoArchive(const char *demoArchiveName) { + if (demoArchiveName == nullptr) { + return false; + } + + int stateId = dSndMgr_c::GetInstance()->saveState(); + SizedString<64> path; + path.sprintf("Sound/demo/%s.brsar", demoArchiveName); + void *buf = dSndMgr_c::GetInstance()->getSoundHeap()->Alloc(getFreeSize() - 0x40000); + if (buf == nullptr) { + return false; + } + bool ok = false; + u32 amountRead = 0; + u32 fileSize = 0; + EGG::DvdRipper::Arg arg(path, (u8 *)buf, nullptr, EGG::DvdRipper::ALLOC_DIR_TOP, 0, &amountRead, &fileSize); + void *ptr = EGG::DvdRipper::loadToMainRAM(arg); + if (ptr != nullptr) { + ok = mSoundArchive.Setup(ptr); + if (ok) { + u32 size = mSoundArchivePlayer.GetRequiredMemSize(&mSoundArchive); + void *buf2 = dSndMgr_c::GetInstance()->getSoundHeap()->Alloc(size); + if (buf2 != nullptr) { + ok = mSoundArchivePlayer.Setup(&mSoundArchive, buf2, size, nullptr, 0); + } + } + } + if (!ok) { + dSndMgr_c::GetInstance()->loadState(stateId); + } + return ok; +} diff --git a/src/d/snd/d_snd_source.cpp b/src/d/snd/d_snd_source.cpp new file mode 100644 index 00000000..68a312bb --- /dev/null +++ b/src/d/snd/d_snd_source.cpp @@ -0,0 +1,94 @@ +#include "d/snd/d_snd_source.h" + +#include "common.h" +#include "d/snd/d_snd_3d_actor.h" +#include "nw4r/snd/snd_SoundStartable.h" +#include "nw4r/ut/ut_list.h" +#include "sized_string.h" + +extern "C" u8 fn_80382590(u8, UNKWORD); +extern "C" void fn_80386C50(UNKWORD, dSoundSource_c *); +extern "C" void fn_80386C70(dSoundSource_c *); + +struct d_snd_mgr_unk_6_sinit { + d_snd_mgr_unk_6_sinit() : field_0x00(0), field_0x04(0.0f) {} + + u32 field_0x00; + f32 field_0x04; +}; + +d_snd_mgr_unk_6_sinit d_snd_mgr_unk_6_sinit_instance; + +const char *help_i_need_data() { + return "%s_%s_%d"; +} + +dSoundSource_c::dSoundSource_c(u8 a1, dAcBase_c *player, UNKWORD a3, UNKWORD a4) + : dSnd3DActor_c(((char *)a4) + 0x50, a1), + field_0x0F0(a3), + field_0x0F4(0), + mpPlayer(player), + field_0x0FD(a1), + field_0x0FE(0), + field_0x0FF(0), + field_0x100(0), + field_0x101(0), + field_0x102(0), + field_0x104(0), + field_0x108(0), + field_0x10C(0), + field_0x11C(0), + field_0x140(a4), + field_0x154(0), + field_0x158(-1), + field_0x15A(-1) { + field_0x0FC = fn_80382590(a1, a3); + // TODO: Offsetof + nw4r::ut::List_Init(&field_0x110, 0xEC); + nw4r::ut::List_Init(&field_0x120, 0x04); + nw4r::ut::List_Init(&field_0x12C, 0x04); + fn_80386C50(a4, this); +} + +dSoundSource_c::~dSoundSource_c() { + SetUserParam(0); + vt_0x44(); + fn_80386C70(this); +} + +bool dSoundSource_c::hasPlayingSounds() const { + return dSnd3DActor_c::hasPlayingSounds(); +} + +void dSoundSource_c::d_vt_0x38(bool flag, int fadeFrames) { + if (flag == 0) { + PauseAllSound(flag, fadeFrames); + d_s_vt_0x1C4(flag, fadeFrames); + a_field_0x80 = 0; + } else if (a_field_0x7E == 0) { + PauseAllSound(flag, fadeFrames); + d_s_vt_0x1C4(flag, fadeFrames); + a_field_0x80 = 1; + } +} + +nw4r::snd::SoundStartable::StartResult +dSoundSource_c::SetupSound(nw4r::snd::SoundHandle *pHandle, u32 soundId, const StartInfo *pStartInfo, void *) { + // TODO + return START_SUCCESS; +} + +void dSoundSource_c::d_vt_0x58() { + // noop +} + +void dSoundSource_c::d_vt_0x5C() { + // noop +} + +u32 dSoundSource_c::getRemoConSoundVariant(u32 soundId) const { + const char *label = soundIdToSoundLabel(soundId); + SizedString<64> str; + str.sprintf("%s_RC", label); + return soundLabelToSoundId(str); +} diff --git a/src/d/snd/mgr/d_snd_mgr_unk_11.cpp b/src/d/snd/mgr/d_snd_mgr_unk_11.cpp new file mode 100644 index 00000000..5ad3cddc --- /dev/null +++ b/src/d/snd/mgr/d_snd_mgr_unk_11.cpp @@ -0,0 +1,36 @@ + +#include "d/snd/d_snd_util.h" + +class SndClass80399a40 { +public: + SndClass80399a40(); + virtual ~SndClass80399a40() {} + + /* 0x04 */ u8 _0x04[0x18 - 0x04]; +}; + +// This is a test for SndMgrDisposer, since this +// class has the disposer at 0x18, which is interesting + +class SndMgr80399c20; + +extern template class SndMgrDisposer; + +class SndMgr80399c20 : SndClass80399a40 { +public: + SndMgrDisposer *GetDisposer() { + return &mDisposer; + } + + static SndMgr80399c20 *GetInstance() { + return sInstance; + } + + static SndMgr80399c20 *sInstance; + static SndMgrDisposer *sDisposer; + +private: + SndMgrDisposer mDisposer; +}; + +template class SndMgrDisposer; diff --git a/src/toBeSorted/d_d3d.cpp b/src/toBeSorted/d_d3d.cpp index 8f62c595..964211b1 100644 --- a/src/toBeSorted/d_d3d.cpp +++ b/src/toBeSorted/d_d3d.cpp @@ -31,10 +31,10 @@ AnmMdlWrapper::AnmMdlWrapper() : mpSoundSource(nullptr), mpSoundData(nullptr) {} AnmMdlWrapper::~AnmMdlWrapper() { if (mpSoundSource != nullptr) { - if (mpSoundSource->shutdown()) { + if (mpSoundSource->hasPlayingSounds()) { do { VIWaitForRetrace(); - } while (mpSoundSource->shutdown()); + } while (mpSoundSource->hasPlayingSounds()); } } } @@ -119,7 +119,7 @@ void AnmMdlWrapper::setRate(f32 rate) { setSoundRate(rate); } -void AnmMdlWrapper::setSoundSource(SoundSource *pSource) { +void AnmMdlWrapper::setSoundSource(dSoundSourceIf_c *pSource) { mpSoundSource = pSource; } diff --git a/src/toBeSorted/sound_info.cpp b/src/toBeSorted/sound_info.cpp index 585f35ce..98f7c6ea 100644 --- a/src/toBeSorted/sound_info.cpp +++ b/src/toBeSorted/sound_info.cpp @@ -1,6 +1,6 @@ #include "d/a/d_a_base.h" -extern "C" SoundSource *soundForActorInitRelated_803889c0(int, fBase_c *, char *, u8); +extern "C" dSoundSourceIf_c *soundForActorInitRelated_803889c0(int, fBase_c *, char *, u8); extern "C" bool fn_8002C250(SoundInfo *p1, int someNum, char *name, mVec3_c *position) { p1->sound_source = soundForActorInitRelated_803889c0(someNum, p1->actor, name, 0); From 74a603be5fc18fd82dca9190c5192fafbb802c1a Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 31 May 2025 21:25:26 +0200 Subject: [PATCH 02/22] Fix missed symbols update --- config/SOUE01/symbols.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index ec4c9298..e6b43ec2 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -572,7 +572,7 @@ play__Q23d3d13AnmMdlWrapperFv = .text:0x80016F20; // type:function size:0x34 setFrame__Q23d3d13AnmMdlWrapperFf = .text:0x80016F60; // type:function size:0x34 setAnm__Q23d3d13AnmMdlWrapperFPCcQ23m3d10playMode_ef = .text:0x80016FA0; // type:function size:0x54 setRate__Q23d3d13AnmMdlWrapperFf = .text:0x80017000; // type:function size:0x44 -setSoundSource__Q23d3d13AnmMdlWrapperFP11SoundSource = .text:0x80017050; // type:function size:0x8 +setSoundSource__Q23d3d13AnmMdlWrapperFP16dSoundSourceIf_c = .text:0x80017050; // type:function size:0x8 loadSounds__Q23d3d13AnmMdlWrapperFPCc = .text:0x80017060; // type:function size:0xCC setSoundRate__Q23d3d13AnmMdlWrapperFf = .text:0x80017130; // type:function size:0x20 syncAnmFrame__Q23d3d13AnmMdlWrapperFv = .text:0x80017150; // type:function size:0x50 From fa1d4c3f5765568bfc9798bc1c909166792aad13 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 1 Jun 2025 16:27:19 +0200 Subject: [PATCH 03/22] Some dSound_c / dSoundControl_c --- config/SOUE01/splits.txt | 22 +- config/SOUE01/symbols.txt | 268 ++++++++++++------------- configure.py | 7 +- include/d/a/d_a_base.h | 2 +- include/d/snd/d_snd_3d_actor.h | 14 +- include/d/snd/d_snd_3d_manager.h | 14 +- include/d/snd/d_snd_calc_pitch.h | 10 + include/d/snd/d_snd_control_player.h | 53 +++++ include/d/snd/d_snd_player_mgr.h | 3 + include/d/snd/d_snd_sound.h | 169 ++++++++++++++++ include/d/snd/d_snd_source.h | 94 ++------- include/d/snd/d_snd_source_if.h | 85 ++++++++ include/nw4r/snd/snd_SeqSoundHandle.h | 22 ++ include/nw4r/snd/snd_SoundHandle.h | 16 ++ include/nw4r/snd/snd_StrmSoundHandle.h | 7 + src/REL/d/t/d_t_sound_area.cpp | 2 +- src/d/snd/d_snd_3d_actor.cpp | 27 ++- src/d/snd/d_snd_3d_manager.cpp | 22 +- src/d/snd/d_snd_control_player.cpp | 71 +++++++ src/d/snd/d_snd_control_sound.cpp | 100 +++++++++ src/d/snd/d_snd_player_mgr.cpp | 32 +++ src/d/snd/d_snd_sound.cpp | 135 +++++++++++++ src/d/snd/d_snd_source.cpp | 13 ++ src/nw4r/snd/snd_AnimSound.cpp | 1 - 24 files changed, 946 insertions(+), 243 deletions(-) create mode 100644 include/d/snd/d_snd_calc_pitch.h create mode 100644 include/d/snd/d_snd_control_player.h create mode 100644 include/d/snd/d_snd_sound.h create mode 100644 include/d/snd/d_snd_source_if.h create mode 100644 src/d/snd/d_snd_control_player.cpp create mode 100644 src/d/snd/d_snd_control_sound.cpp create mode 100644 src/d/snd/d_snd_sound.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index fbff92a4..4ef4740f 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2365,8 +2365,9 @@ d/snd/d_snd_3d_engine.cpp: .data start:0x80548710 end:0x80548730 .sdata2 start:0x8057D308 end:0x8057D368 -d/snd/d_snd_unk_component_1.cpp: +d/snd/d_snd_sound.cpp: .text start:0x8035C3F0 end:0x8035DA88 align:16 + .sdata2 start:0x8057D368 end:0x8057D380 d/snd/d_snd_player_mgr.cpp: .text start:0x8035DA90 end:0x8035F010 align:16 @@ -2386,10 +2387,23 @@ d/snd/mgr/d_snd_mgr_enemy.cpp: .ctors start:0x804DB918 end:0x804DB91C d/snd/d_snd_unk_component_2.cpp: - .text start:0x80366430 end:0x8037D800 align:16 + .text start:0x80366430 end:0x8036B8D0 align:16 + +d/snd/d_snd_sound_ex.cpp: + .text start:0x8036B8D0 end:0x8036C090 align:16 + +d/snd/d_snd_control_sound.cpp: + .text start:0x8036C090 end:0x8036C444 align:16 + .data start:0x80548B78 end:0x80548C38 + .sdata2 start:0x8057D920 end:0x8057D938 + +d/snd/d_snd_control_player.cpp: + .text start:0x8036C450 end:0x8036C6A8 align:16 + .data start:0x80548C38 end:0x80548CC8 + .sdata2 start:0x8057D938 end:0x8057D940 d/snd/mgr/d_snd_mgr_effect.cpp: - .text start:0x8037D800 end:0x8037F8B4 align:16 + .text start:0x8036C6B0 end:0x8037F8B4 align:16 d/snd/mgr/d_snd_mgr_unk_5.cpp: .text start:0x8037F8C0 end:0x803864C8 align:16 @@ -2424,7 +2438,7 @@ d/snd/mgr/d_snd_mgr_unk_11.cpp: .text start:0x80393E00 end:0x8039A848 align:16 .ctors start:0x804DB934 end:0x804DB938 -d/snd/mgr/d_snd_mgr_unk_12.cpp: +d/snd/d_snd_calc_pitch.cpp: .text start:0x8039A850 end:0x8039A960 align:16 RVL_SDK/kpr/KPR.c: diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index e6b43ec2..143697b6 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -19842,9 +19842,9 @@ __ct__13dSnd3DActor_cFPvUc = .text:0x8035A8A0; // type:function size:0xE8 d_vt_0x34__13dSnd3DActor_cFRCQ34nw4r4math4VEC3 = .text:0x8035A990; // type:function size:0x40 fn_8035A9D0 = .text:0x8035A9D0; // type:function size:0x2C fn_8035AA00 = .text:0x8035AA00; // type:function size:0x30 -fn_8035AA30 = .text:0x8035AA30; // type:function size:0x44 -fn_8035AA80 = .text:0x8035AA80; // type:function size:0x28 -fn_8035AAB0 = .text:0x8035AAB0; // type:function size:0x50 +updatePositionRelativeToListener__13dSnd3DActor_cFv = .text:0x8035AA30; // type:function size:0x44 +calculatePositionRelativeToListener__13dSnd3DActor_cFv = .text:0x8035AA80; // type:function size:0x28 +updateDistanceToListener__13dSnd3DActor_cFv = .text:0x8035AAB0; // type:function size:0x50 fn_8035AB00 = .text:0x8035AB00; // type:function size:0x54 fn_8035AB60 = .text:0x8035AB60; // type:function size:0x78 fn_8035ABE0 = .text:0x8035ABE0; // type:function size:0x44 @@ -19881,30 +19881,30 @@ CalcPitch__FPCQ34nw4r4math4VEC3fRCQ34nw4r3snd14Sound3DManagerRCQ34nw4r3snd15Soun fn_8035C1C0 = .text:0x8035C1C0; // type:function size:0xDC fn_8035C2A0 = .text:0x8035C2A0; // type:function size:0x110 __dt__14dSnd3DEngine_cFv = .text:0x8035C3B0; // type:function size:0x40 -fn_8035C3F0 = .text:0x8035C3F0; // type:function size:0x2F8 -fn_8035C6F0 = .text:0x8035C6F0; // type:function size:0x44 -fn_8035C740 = .text:0x8035C740; // type:function size:0x44 -fn_8035C790 = .text:0x8035C790; // type:function size:0x40 -fn_8035C7D0 = .text:0x8035C7D0; // type:function size:0x40 -fn_8035C810 = .text:0x8035C810; // type:function size:0xA0 +__ct__11dSndSound_cFv = .text:0x8035C3F0; // type:function size:0x2F8 +__ct__32dSndControlSoundSeqTrackVolume_cFv = .text:0x8035C6F0; // type:function size:0x44 +__ct__33dSndControlSoundStrmTrackVolume_cFv = .text:0x8035C740; // type:function size:0x44 +__dt__32dSndControlSoundSeqTrackVolume_cFv = .text:0x8035C790; // type:function size:0x40 +__dt__33dSndControlSoundStrmTrackVolume_cFv = .text:0x8035C7D0; // type:function size:0x40 +__dt__11dSndSound_cFv = .text:0x8035C810; // type:function size:0xA0 fn_8035C8B0 = .text:0x8035C8B0; // type:function size:0x84 -fn_8035C940 = .text:0x8035C940; // type:function size:0xE8 +reset__11dSndSound_cFv = .text:0x8035C940; // type:function size:0xE8 fn_8035CA30 = .text:0x8035CA30; // type:function size:0xD8 -fn_8035CB10 = .text:0x8035CB10; // type:function size:0x6C +fadeIn__11dSndSound_cFUli = .text:0x8035CB10; // type:function size:0x6C fn_8035CB80 = .text:0x8035CB80; // type:function size:0xD4 fn_8035CC60 = .text:0x8035CC60; // type:function size:0xCC -fn_8035CD30 = .text:0x8035CD30; // type:function size:0x58 -fn_8035CD90 = .text:0x8035CD90; // type:function size:0x58 -fn_8035CDF0 = .text:0x8035CDF0; // type:function size:0x58 +isStrmSound__11dSndSound_cFv = .text:0x8035CD30; // type:function size:0x58 +isWaveSound__11dSndSound_cFv = .text:0x8035CD90; // type:function size:0x58 +isSeqSound__11dSndSound_cFv = .text:0x8035CDF0; // type:function size:0x58 fn_8035CE50 = .text:0x8035CE50; // type:function size:0x28 fn_8035CE80 = .text:0x8035CE80; // type:function size:0x28 -fn_8035CEB0 = .text:0x8035CEB0; // type:function size:0x84 -fn_8035CF40 = .text:0x8035CF40; // type:function size:0x78 +readSeqTrackVariable__11dSndSound_cFi = .text:0x8035CEB0; // type:function size:0x84 +writeSeqTrackVariable__11dSndSound_cFis = .text:0x8035CF40; // type:function size:0x78 fn_8035CFC0 = .text:0x8035CFC0; // type:function size:0x90 fn_8035D050 = .text:0x8035D050; // type:function size:0x1C -fn_8035D070 = .text:0x8035D070; // type:function size:0x1C +setPitchRelated__11dSndSound_cFfl = .text:0x8035D070; // type:function size:0x1C fn_8035D090 = .text:0x8035D090; // type:function size:0x1C -fn_8035D0B0 = .text:0x8035D0B0; // type:function size:0xE8 +resetTrackVolumes__11dSndSound_cFv = .text:0x8035D0B0; // type:function size:0xE8 fn_8035D1A0 = .text:0x8035D1A0; // type:function size:0x114 fn_8035D2C0 = .text:0x8035D2C0; // type:function size:0xC0 fn_8035D380 = .text:0x8035D380; // type:function size:0xA0 @@ -19913,12 +19913,12 @@ fn_8035D4C0 = .text:0x8035D4C0; // type:function size:0xB8 fn_8035D580 = .text:0x8035D580; // type:function size:0xB8 fn_8035D640 = .text:0x8035D640; // type:function size:0x24 fn_8035D670 = .text:0x8035D670; // type:function size:0x60 -fn_8035D6D0 = .text:0x8035D6D0; // type:function size:0x78 +setSeqTrackMute__11dSndSound_cFUlQ34nw4r3snd7SeqMute = .text:0x8035D6D0; // type:function size:0x78 fn_8035D750 = .text:0x8035D750; // type:function size:0x1E8 fn_8035D940 = .text:0x8035D940; // type:function size:0x58 fn_8035D9A0 = .text:0x8035D9A0; // type:function size:0x68 -fn_8035DA10 = .text:0x8035DA10; // type:function size:0x4C -fn_8035DA60 = .text:0x8035DA60; // type:function size:0x28 +stop__11dSndSound_cFv = .text:0x8035DA10; // type:function size:0x4C +configure__13dSndControl_cFfff = .text:0x8035DA60; // type:function size:0x28 getSoundArchivePath__15dSndPlayerMgr_cFv = .text:0x8035DA90; // type:function size:0xC __dt__33SndMgrDisposer<15dSndPlayerMgr_c>Fv = .text:0x8035DAA0; // type:function size:0x78 create__33SndMgrDisposer<15dSndPlayerMgr_c>Fv = .text:0x8035DB20; // type:function size:0x48 @@ -19977,9 +19977,9 @@ 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 getSoundArchivePlayerForType__15dSndPlayerMgr_cFUc = .text:0x8035ED40; // type:function size:0x44 -fn_8035ED90 = .text:0x8035ED90; // type:function size:0x5C +canUseThisPlayer__15dSndPlayerMgr_cCFUc = .text:0x8035ED90; // type:function size:0x5C loadDemoArchive__15dSndPlayerMgr_cFPCc = .text:0x8035EDF0; // type:function size:0x198 -fn_8035EF90 = .text:0x8035EF90; // type:function size:0x38 +shutdown__15dSndPlayerMgr_cFv = .text:0x8035EF90; // type:function size:0x38 calc__15dSndPlayerMgr_cFv = .text:0x8035EFD0; // type:function size:0x40 fn_8035F010 = .text:0x8035F010; // type:function size:0x20 fn_8035F030 = .text:0x8035F030; // type:function size:0x1C @@ -20381,29 +20381,29 @@ fn_8036BDB0 = .text:0x8036BDB0; // type:function size:0x30 fn_8036BDE0 = .text:0x8036BDE0; // type:function size:0xA8 fn_8036BE90 = .text:0x8036BE90; // type:function size:0x158 fn_8036BFF0 = .text:0x8036BFF0; // type:function size:0xA0 -fn_8036C090 = .text:0x8036C090; // type:function size:0x20 -fn_8036C0B0 = .text:0x8036C0B0; // type:function size:0x1C -fn_8036C0D0 = .text:0x8036C0D0; // type:function size:0xA8 -fn_8036C180 = .text:0x8036C180; // type:function size:0x84 -fn_8036C210 = .text:0x8036C210; // type:function size:0x20 -fn_8036C230 = .text:0x8036C230; // type:function size:0x1C -fn_8036C250 = .text:0x8036C250; // type:function size:0x48 -fn_8036C2A0 = .text:0x8036C2A0; // type:function size:0x70 -fn_8036C310 = .text:0x8036C310; // type:function size:0x3C -fn_8036C350 = .text:0x8036C350; // type:function size:0x4C -fn_8036C3A0 = .text:0x8036C3A0; // type:function size:0x50 -fn_8036C3F0 = .text:0x8036C3F0; // type:function size:0x54 -fn_8036C450 = .text:0x8036C450; // type:function size:0x48 -fn_8036C4A0 = .text:0x8036C4A0; // type:function size:0x40 -fn_8036C4E0 = .text:0x8036C4E0; // type:function size:0x44 -fn_8036C530 = .text:0x8036C530; // type:function size:0x44 -fn_8036C580 = .text:0x8036C580; // type:function size:0x44 -fn_8036C5D0 = .text:0x8036C5D0; // type:function size:0x10 -fn_8036C5E0 = .text:0x8036C5E0; // type:function size:0xC -fn_8036C5F0 = .text:0x8036C5F0; // type:function size:0x10 -fn_8036C600 = .text:0x8036C600; // type:function size:0xC -fn_8036C610 = .text:0x8036C610; // type:function size:0x40 -fn_8036C650 = .text:0x8036C650; // type:function size:0x58 +reset__13dSndControl_cFv = .text:0x8036C090; // type:function size:0x20 +stop__13dSndControl_cFv = .text:0x8036C0B0; // type:function size:0x1C +set__13dSndControl_cFfl = .text:0x8036C0D0; // type:function size:0xA8 +calc__13dSndControl_cFv = .text:0x8036C180; // type:function size:0x84 +apply__24dSndControlSoundVolume_cFP11dSndSound_c = .text:0x8036C210; // type:function size:0x20 +apply__23dSndControlSoundPitch_cFP11dSndSound_c = .text:0x8036C230; // type:function size:0x1C +__ct__29dSndControlSoundPitchLinear_cFv = .text:0x8036C250; // type:function size:0x48 +set__29dSndControlSoundPitchLinear_cFfl = .text:0x8036C2A0; // type:function size:0x70 +apply__29dSndControlSoundPitchLinear_cFP11dSndSound_c = .text:0x8036C310; // type:function size:0x3C +apply__36dSndControlSoundSeqTrackTempoRatio_cFP11dSndSound_c = .text:0x8036C350; // type:function size:0x4C +apply__32dSndControlSoundSeqTrackVolume_cFP11dSndSound_c = .text:0x8036C3A0; // type:function size:0x50 +apply__33dSndControlSoundStrmTrackVolume_cFP11dSndSound_c = .text:0x8036C3F0; // type:function size:0x54 +__ct__29dSndControlPlayerVolumeBase_cFv = .text:0x8036C450; // type:function size:0x48 +reset__19dSndControlPlayer_cFv = .text:0x8036C4A0; // type:function size:0x40 +setIndex1__19dSndControlPlayer_cFl = .text:0x8036C4E0; // type:function size:0x44 +setIndex2__19dSndControlPlayer_cFl = .text:0x8036C530; // type:function size:0x44 +stop__19dSndControlPlayer_cFv = .text:0x8036C580; // type:function size:0x44 +apply__25dSndControlPlayerVolume_cFv = .text:0x8036C5D0; // type:function size:0x10 +getAppliedValue__25dSndControlPlayerVolume_cFv = .text:0x8036C5E0; // type:function size:0xC +apply__26dSndControlPlayerLpfFreq_cFv = .text:0x8036C5F0; // type:function size:0x10 +getAppliedValue__26dSndControlPlayerLpfFreq_cFv = .text:0x8036C600; // type:function size:0xC +apply__25dSndControlPlayerFxSend_cFv = .text:0x8036C610; // type:function size:0x40 +getAppliedValue__25dSndControlPlayerFxSend_cFv = .text:0x8036C650; // type:function size:0x58 fn_8036C6B0 = .text:0x8036C6B0; // type:function size:0x64 isInvalidSoundId = .text:0x8036C720; // type:function size:0x10 FanfareSoundMgr__dtor = .text:0x8036C730; // type:function size:0x78 @@ -20550,7 +20550,7 @@ fn_80372E30 = .text:0x80372E30; // type:function size:0x40 fn_80372E70 = .text:0x80372E70; // type:function size:0xB0 fn_80372F20 = .text:0x80372F20; // type:function size:0x6C AnotherSoundMgr__playSound = .text:0x80372F90; // type:function size:0x264 -fn_80373200 = .text:0x80373200; // type:function size:0x8 +vt_0xF4__14dSoundSource_cFv = .text:0x80373200; // type:function size:0x8 fn_80373210 = .text:0x80373210; // type:function size:0xB4 fn_803732D0 = .text:0x803732D0; // type:function size:0x44 fn_80373320 = .text:0x80373320; // type:function size:0x8C @@ -20591,8 +20591,8 @@ fn_80374DB0 = .text:0x80374DB0; // type:function size:0x24 fn_80374DE0 = .text:0x80374DE0; // type:function size:0x58 fn_80374E40 = .text:0x80374E40; // type:function size:0x10 fn_80374E50 = .text:0x80374E50; // type:function size:0x330 -fn_80375180 = .text:0x80375180; // type:function size:0x28 -fn_803751B0 = .text:0x803751B0; // type:function size:0x10 +vt_0x38__14dSoundSource_cFv = .text:0x80375180; // type:function size:0x28 +vt_0x3C__14dSoundSource_cFv = .text:0x803751B0; // type:function size:0x10 fn_803751C0 = .text:0x803751C0; // type:function size:0x70 fn_80375230 = .text:0x80375230; // type:function size:0xA4 fn_803752E0 = .text:0x803752E0; // type:function size:0xC8 @@ -20877,7 +20877,7 @@ fn_8037F0E0 = .text:0x8037F0E0; // type:function size:0xC fn_8037F0F0 = .text:0x8037F0F0; // type:function size:0x60 fn_8037F150 = .text:0x8037F150; // type:function size:0x6D0 d_s_vt_0x17C__14dSoundSource_cFv = .text:0x8037F820; // type:function size:0x8 -fn_8037F830 = .text:0x8037F830; // type:function size:0x8 +vt_0x18__14dSoundSource_cFv = .text:0x8037F830; // type:function size:0x8 fn_8037F840 = .text:0x8037F840; // type:function size:0x74 fn_8037F8C0 = .text:0x8037F8C0; // type:function size:0x78 fn_8037F940 = .text:0x8037F940; // type:function size:0x48 @@ -20986,7 +20986,7 @@ fn_80384960 = .text:0x80384960; // type:function size:0x8C fn_803849F0 = .text:0x803849F0; // type:function size:0xC fn_80384A00 = .text:0x80384A00; // type:function size:0x174 fn_80384B80 = .text:0x80384B80; // type:function size:0x178 -fn_80384D00 = .text:0x80384D00; // type:function size:0x8 +vt_0x10__14dSoundSource_cFv = .text:0x80384D00; // type:function size:0x8 fn_80384D10 = .text:0x80384D10; // type:function size:0x78 fn_80384D90 = .text:0x80384D90; // type:function size:0x98 fn_80384E30 = .text:0x80384E30; // type:function size:0xBC @@ -21017,32 +21017,32 @@ fn_80385830 = .text:0x80385830; // type:function size:0x44 fn_80385880 = .text:0x80385880; // type:function size:0x50 fn_803858D0 = .text:0x803858D0; // type:function size:0xA0 fn_80385970 = .text:0x80385970; // type:function size:0x90 -fn_80385A00 = .text:0x80385A00; // type:function size:0x8 -fn_80385A10 = .text:0x80385A10; // type:function size:0x4 +vt_0x118__14dSoundSource_cFv = .text:0x80385A00; // type:function size:0x8 +vt_0x114__14dSoundSource_cFv = .text:0x80385A10; // type:function size:0x4 d_s_vt_0x1D4__14dSoundSource_cFv = .text:0x80385A20; // type:function size:0x8 -fn_80385A30 = .text:0x80385A30; // type:function size:0x4 -fn_80385A40 = .text:0x80385A40; // type:function size:0x4 -fn_80385A50 = .text:0x80385A50; // type:function size:0x4 -fn_80385A60 = .text:0x80385A60; // type:function size:0x8 -fn_80385A70 = .text:0x80385A70; // type:function size:0x4 +setRate__14dSoundSource_cFf = .text:0x80385A30; // type:function size:0x4 +setFrame__14dSoundSource_cFf = .text:0x80385A40; // type:function size:0x4 +load__14dSoundSource_cFPvPCc = .text:0x80385A50; // type:function size:0x4 +isReadyMaybe__14dSoundSource_cFv = .text:0x80385A60; // type:function size:0x8 +vt_0xF0__14dSoundSource_cFv = .text:0x80385A70; // type:function size:0x4 d_s_vt_0x1CC__14dSoundSource_cFv = .text:0x80385A80; // type:function size:0x4 d_s_vt_0x1C0__14dSoundSource_cFv = .text:0x80385A90; // type:function size:0x34 -fn_80385AD0 = .text:0x80385AD0; // type:function size:0x8 -fn_80385AE0 = .text:0x80385AE0; // type:function size:0x8 -fn_80385AF0 = .text:0x80385AF0; // type:function size:0x4 -fn_80385B00 = .text:0x80385B00; // type:function size:0x4 -fn_80385B10 = .text:0x80385B10; // type:function size:0x8 -fn_80385B20 = .text:0x80385B20; // type:function size:0x8 -fn_80385B30 = .text:0x80385B30; // type:function size:0x8 -fn_80385B40 = .text:0x80385B40; // type:function size:0x8 -fn_80385B50 = .text:0x80385B50; // type:function size:0x10 -fn_80385B60 = .text:0x80385B60; // type:function size:0x10 -fn_80385B70 = .text:0x80385B70; // type:function size:0x8 +vt_0xE8__14dSoundSource_cFv = .text:0x80385AD0; // type:function size:0x8 +vt_0xEC__14dSoundSource_cFv = .text:0x80385AE0; // type:function size:0x8 +vt_0xE0__14dSoundSource_cFv = .text:0x80385AF0; // type:function size:0x4 +vt_0xE4__14dSoundSource_cFv = .text:0x80385B00; // type:function size:0x4 +vt_0xDC__14dSoundSource_cFv = .text:0x80385B10; // type:function size:0x8 +vt_0xD4__14dSoundSource_cFv = .text:0x80385B20; // type:function size:0x8 +vt_0x54__14dSoundSource_cFv = .text:0x80385B30; // type:function size:0x8 +vt_0x40__14dSoundSource_cFv = .text:0x80385B40; // type:function size:0x8 +vt_0x34__14dSoundSource_cFv = .text:0x80385B50; // type:function size:0x10 +vt_0x30__14dSoundSource_cFv = .text:0x80385B60; // type:function size:0x10 +vt_0xF8__14dSoundSource_cFv = .text:0x80385B70; // type:function size:0x8 d_s_vt_0x188__14dSoundSource_cFv = .text:0x80385B80; // type:function size:0x4 -fn_80385B90 = .text:0x80385B90; // type:function size:0x4 -fn_80385BA0 = .text:0x80385BA0; // type:function size:0x8 -fn_80385BB0 = .text:0x80385BB0; // type:function size:0x14 -fn_80385BD0 = .text:0x80385BD0; // type:function size:0x14 +vt_0x20__14dSoundSource_cFv = .text:0x80385B90; // type:function size:0x4 +vt_0x24__14dSoundSource_cFv = .text:0x80385BA0; // type:function size:0x8 +vt_0x1C__14dSoundSource_cFv = .text:0x80385BB0; // type:function size:0x14 +vt_0x14__14dSoundSource_cFv = .text:0x80385BD0; // type:function size:0x14 fn_80385BF0 = .text:0x80385BF0; // type:function size:0xC fn_80385C00 = .text:0x80385C00; // type:function size:0xC fn_80385C10 = .text:0x80385C10; // type:function size:0xC @@ -21132,63 +21132,63 @@ fn_80386F70 = .text:0x80386F70; // type:function size:0x1A4C soundForActorInitRelated_803889c0 = .text:0x803889C0; // type:function size:0x4 __ct__14dSoundSource_cFUcP9dAcBase_cii = .text:0x803889D0; // type:function size:0x108 __dt__14dSoundSource_cFv = .text:0x80388AE0; // type:function size:0xC4 -fn_80388BB0 = .text:0x80388BB0; // type:function size:0x118 -fn_80388CD0 = .text:0x80388CD0; // type:function size:0x9C +vt_0x0C__14dSoundSource_cFv = .text:0x80388BB0; // type:function size:0x118 +vt_0x44__14dSoundSource_cFv = .text:0x80388CD0; // type:function size:0x9C fn_80388D70 = .text:0x80388D70; // type:function size:0x80 -fn_80388DF0 = .text:0x80388DF0; // type:function size:0xC -fn_80388E00 = .text:0x80388E00; // type:function size:0x88 +getListenerPosition__14dSoundSource_cCFv = .text:0x80388DF0; // type:function size:0xC +vt_0x2C__14dSoundSource_cFv = .text:0x80388E00; // type:function size:0x88 d_s_vt_0x184__14dSoundSource_cFv = .text:0x80388E90; // type:function size:0x84 d_s_vt_0x18C__14dSoundSource_cFv = .text:0x80388F20; // type:function size:0x4 hasPlayingSounds__14dSoundSource_cCFv = .text:0x80388F30; // type:function size:0x8 -fn_80388F40 = .text:0x80388F40; // type:function size:0x8 -fn_80388F50 = .text:0x80388F50; // type:function size:0x48 +isPlayingSound__14dSoundSource_cFUl = .text:0x80388F40; // type:function size:0x8 +isPlayingSound__14dSoundSource_cFPCc = .text:0x80388F50; // type:function size:0x48 fn_80388FA0 = .text:0x80388FA0; // type:function size:0x14 fn_80388FC0 = .text:0x80388FC0; // type:function size:0x84 fn_80389050 = .text:0x80389050; // type:function size:0x68 -fn_803890C0 = .text:0x803890C0; // type:function size:0x18 -fn_803890E0 = .text:0x803890E0; // type:function size:0x1C +vt_0x5C__14dSoundSource_cFv = .text:0x803890C0; // type:function size:0x18 +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 d_vt_0x38__14dSoundSource_cFbi = .text:0x803891A0; // type:function size:0xB0 -fn_80389250 = .text:0x80389250; // type:function size:0x30 -fn_80389280 = .text:0x80389280; // type:function size:0x48 -fn_803892D0 = .text:0x803892D0; // type:function size:0x64 -fn_80389340 = .text:0x80389340; // type:function size:0x58 -fn_803893A0 = .text:0x803893A0; // type:function size:0x60 -fn_80389400 = .text:0x80389400; // type:function size:0x58 -fn_80389460 = .text:0x80389460; // type:function size:0x88 -fn_803894F0 = .text:0x803894F0; // type:function size:0x68 -fn_80389560 = .text:0x80389560; // type:function size:0x94 +vt_0x60__14dSoundSource_cFv = .text:0x80389250; // type:function size:0x30 +vt_0x70__14dSoundSource_cFv = .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 +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 -fn_80389870 = .text:0x80389870; // type:function size:0x11C -fn_80389990 = .text:0x80389990; // type:function size:0x58 -fn_803899F0 = .text:0x803899F0; // type:function size:0x184 -fn_80389B80 = .text:0x80389B80; // type:function size:0x68 -fn_80389BF0 = .text:0x80389BF0; // type:function size:0x160 -fn_80389D50 = .text:0x80389D50; // type:function size:0x78 -fn_80389DD0 = .text:0x80389DD0; // type:function size:0x11C -fn_80389EF0 = .text:0x80389EF0; // type:function size:0x58 +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 +vt_0x90__14dSoundSource_cFv = .text:0x80389B80; // type:function size:0x68 +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 d_s_vt_0x19C__14dSoundSource_cFv = .text:0x8038A160; // type:function size:0x6C fn_8038A1D0 = .text:0x8038A1D0; // type:function size:0xD8 -fn_8038A2B0 = .text:0x8038A2B0; // type:function size:0x48 +vt_0xD8__14dSoundSource_cFv = .text:0x8038A2B0; // type:function size:0x48 fn_8038A300 = .text:0x8038A300; // type:function size:0x10 -fn_8038A310 = .text:0x8038A310; // type:function size:0xB8 -fn_8038A3D0 = .text:0x8038A3D0; // type:function size:0x58 -fn_8038A430 = .text:0x8038A430; // type:function size:0x30 -fn_8038A460 = .text:0x8038A460; // type:function size:0x48 -fn_8038A4B0 = .text:0x8038A4B0; // type:function size:0x64 -fn_8038A520 = .text:0x8038A520; // type:function size:0x58 -fn_8038A580 = .text:0x8038A580; // type:function size:0x60 -fn_8038A5E0 = .text:0x8038A5E0; // type:function size:0x58 -fn_8038A640 = .text:0x8038A640; // type:function size:0x88 -fn_8038A6D0 = .text:0x8038A6D0; // type:function size:0x68 +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 +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 -fn_8038AB00 = .text:0x8038AB00; // type:function size:0x258 -fn_8038AD60 = .text:0x8038AD60; // type:function size:0x58 +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 @@ -21221,8 +21221,8 @@ fn_8038BA80 = .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 -fn_8038BD40 = .text:0x8038BD40; // type:function size:0x20 -fn_8038BD60 = .text:0x8038BD60; // type:function size:0xC +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 fn_8038BE40 = .text:0x8038BE40; // type:function size:0xC4 @@ -21627,7 +21627,7 @@ __dt__32SndMgrDisposer<14SndMgr80399c20>Fv = .text:0x80399BA0; // type:function create__32SndMgrDisposer<14SndMgr80399c20>Fv = .text:0x80399C20; // type:function size:0x84 remove__32SndMgrDisposer<14SndMgr80399c20>Fv = .text:0x80399CB0; // type:function size:0x10 fn_80399CC0 = .text:0x80399CC0; // type:function size:0x34 -fn_80399D00 = .text:0x80399D00; // type:function size:0x5C +__dt__14SndMgr80399c20Fv = .text:0x80399D00; // type:function size:0x5C fn_80399D60 = .text:0x80399D60; // type:function size:0x44 fn_80399DB0 = .text:0x80399DB0; // type:function size:0x34 fn_80399DF0 = .text:0x80399DF0; // type:function size:0x15C @@ -21656,9 +21656,9 @@ fn_8039A7E0 = .text:0x8039A7E0; // type:function size:0x38 fn_8039A820 = .text:0x8039A820; // type:function size:0x8 fn_8039A830 = .text:0x8039A830; // type:function size:0x8 fn_8039A840 = .text:0x8039A840; // type:function size:0x8 -fn_8039A850 = .text:0x8039A850; // type:function size:0x2C -fn_8039A880 = .text:0x8039A880; // type:function size:0x58 -fn_8039A8E0 = .text:0x8039A8E0; // type:function size:0x80 +pitchScaleForPitchIdx = .text:0x8039A850; // type:function size:0x2C +pitchScaleForPitchIdxTenths__Ff = .text:0x8039A880; // type:function size:0x58 +pitchIdxTenthsForPitchScale__Ff = .text:0x8039A8E0; // type:function size:0x80 fn_8039A960 = .text:0x8039A960; // type:function size:0x10 fn_8039A970 = .text:0x8039A970; // type:function size:0x5C fn_8039A9D0 = .text:0x8039A9D0; // type:function size:0x14 @@ -37636,7 +37636,7 @@ __vt__11dSndActor_c = .data:0x80548684; // type:object size:0x1C scope:weak __vt__23IsCurrentSoundIdChecker = .data:0x805486A0; // type:object size:0x10 __vt__13dSnd3DActor_c = .data:0x805486B0; // type:object size:0x60 __vt__14dSnd3DEngine_c = .data:0x80548710; // type:object size:0x20 -lbl_80548730 = .data:0x80548730; // type:object size:0x28 +__vt__11dSndSound_c = .data:0x80548730; // type:object size:0x28 lbl_80548758 = .data:0x80548758; // type:object size:0x14 data:string lbl_8054876C = .data:0x8054876C; // type:object size:0x14 data:string __vt__15dSndPlayerMgr_c = .data:0x80548780; // type:object size:0x10 @@ -37696,16 +37696,16 @@ lbl_80548B1C = .data:0x80548B1C; // type:object size:0x10 lbl_80548B2C = .data:0x80548B2C; // type:object size:0xC lbl_80548B38 = .data:0x80548B38; // type:object size:0x10 lbl_80548B48 = .data:0x80548B48; // type:object size:0x30 -lbl_80548B78 = .data:0x80548B78; // type:object size:0x20 -lbl_80548B98 = .data:0x80548B98; // type:object size:0x20 -lbl_80548BB8 = .data:0x80548BB8; // type:object size:0x20 -lbl_80548BD8 = .data:0x80548BD8; // type:object size:0x20 -lbl_80548BF8 = .data:0x80548BF8; // type:object size:0x20 -lbl_80548C18 = .data:0x80548C18; // type:object size:0x20 -lbl_80548C38 = .data:0x80548C38; // type:object size:0x24 -lbl_80548C5C = .data:0x80548C5C; // type:object size:0x24 -lbl_80548C80 = .data:0x80548C80; // type:object size:0x24 -lbl_80548CA4 = .data:0x80548CA4; // type:object size:0x24 +__vt__33dSndControlSoundStrmTrackVolume_c = .data:0x80548B78; // type:object size:0x20 +__vt__32dSndControlSoundSeqTrackVolume_c = .data:0x80548B98; // type:object size:0x20 +__vt__36dSndControlSoundSeqTrackTempoRatio_c = .data:0x80548BB8; // type:object size:0x20 +__vt__29dSndControlSoundPitchLinear_c = .data:0x80548BD8; // type:object size:0x20 +__vt__23dSndControlSoundPitch_c = .data:0x80548BF8; // type:object size:0x20 +__vt__24dSndControlSoundVolume_c = .data:0x80548C18; // type:object size:0x20 +__vt__25dSndControlPlayerFxSend_c = .data:0x80548C38; // type:object size:0x24 +__vt__26dSndControlPlayerLpfFreq_c = .data:0x80548C5C; // type:object size:0x24 +__vt__25dSndControlPlayerVolume_c = .data:0x80548C80; // type:object size:0x24 +__vt__29dSndControlPlayerVolumeBase_c = .data:0x80548CA4; // type:object size:0x24 scope:weak jumptable_80548CC8 = .data:0x80548CC8; // type:object size:0x34 scope:local jumptable_80548CFC = .data:0x80548CFC; // type:object size:0x284 scope:local lbl_80548F80 = .data:0x80548F80; // type:object size:0xC @@ -48608,12 +48608,12 @@ lbl_8057D90C = .sdata2:0x8057D90C; // type:object size:0x4 align:4 data:float lbl_8057D910 = .sdata2:0x8057D910; // type:object size:0x4 align:4 data:float lbl_8057D914 = .sdata2:0x8057D914; // type:object size:0x4 align:4 data:float lbl_8057D918 = .sdata2:0x8057D918; // type:object size:0x4 align:4 data:float -lbl_8057D920 = .sdata2:0x8057D920; // type:object size:0x8 align:8 data:double -lbl_8057D928 = .sdata2:0x8057D928; // type:object size:0x4 align:4 data:float -lbl_8057D92C = .sdata2:0x8057D92C; // type:object size:0x4 align:4 data:float -lbl_8057D930 = .sdata2:0x8057D930; // type:object size:0x4 align:4 data:float -lbl_8057D938 = .sdata2:0x8057D938; // type:object size:0x4 align:4 data:float -lbl_8057D93C = .sdata2:0x8057D93C; // type:object size:0x4 align:4 data:float +@2743 = .sdata2:0x8057D920; // type:object size:0x8 scope:local align:8 data:double +@2762 = .sdata2:0x8057D928; // type:object size:0x4 scope:local align:4 data:float +@2763 = .sdata2:0x8057D92C; // type:object size:0x4 scope:local align:4 data:float +@2767 = .sdata2:0x8057D930; // type:object size:0x4 scope:local align:4 data:float +@1614 = .sdata2:0x8057D938; // type:object size:0x4 scope:local align:4 data:float +@1615 = .sdata2:0x8057D93C; // type:object size:0x4 scope:local align:4 data:float lbl_8057D940 = .sdata2:0x8057D940; // type:object size:0x4 align:4 data:float lbl_8057D944 = .sdata2:0x8057D944; // type:object size:0x4 align:4 data:float lbl_8057D948 = .sdata2:0x8057D948; // type:object size:0x4 align:4 data:float diff --git a/configure.py b/configure.py index 448b5746..ec055e44 100644 --- a/configure.py +++ b/configure.py @@ -706,12 +706,15 @@ config.libs = [ Object(Matching, "d/snd/d_snd_actor.cpp"), Object(NonMatching, "d/snd/d_snd_3d_actor.cpp"), Object(NonMatching, "d/snd/d_snd_3d_engine.cpp"), - Object(NonMatching, "d/snd/d_snd_unk_component_1.cpp"), + Object(NonMatching, "d/snd/d_snd_sound.cpp"), Object(NonMatching, "d/snd/d_snd_player_mgr.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk1.cpp"), Object(Matching, "d/snd/d_snd_3d_manager.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_enemy.cpp"), Object(NonMatching, "d/snd/d_snd_unk_component_2.cpp"), + Object(NonMatching, "d/snd/d_snd_sound_ex.cpp"), + Object(Matching, "d/snd/d_snd_control_sound.cpp"), + Object(Matching, "d/snd/d_snd_control_player.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_effect.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_5.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_13.cpp"), @@ -721,7 +724,7 @@ config.libs = [ Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_9.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_10.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_11.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_12.cpp"), + Object(NonMatching, "d/snd/d_snd_calc_pitch.cpp"), ], }, { diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h index b223b88a..51944c33 100644 --- a/include/d/a/d_a_base.h +++ b/include/d/a/d_a_base.h @@ -4,7 +4,7 @@ #include "UnknownTypeBelongings.h" #include "common.h" #include "d/d_base.h" -#include "d/snd/d_snd_source.h" +#include "d/snd/d_snd_source_if.h" #include "m/m_allocator.h" #include "m/m_angle.h" #include "m/m_vec.h" diff --git a/include/d/snd/d_snd_3d_actor.h b/include/d/snd/d_snd_3d_actor.h index 6fa7fafa..5136d7be 100644 --- a/include/d/snd/d_snd_3d_actor.h +++ b/include/d/snd/d_snd_3d_actor.h @@ -41,12 +41,20 @@ public: virtual void d_vt_0x58() = 0; virtual void d_vt_0x5C() = 0; + void calculatePositionRelativeToListener(); + void updatePositionRelativeToListener(); + void updateDistanceToListener(); + void resetFloats(); bool checkFlag(u16 flag) const { return (mFlags & flag); } + void setFlag(u16 flag) { + mFlags |= flag; + } + bool hasPlayingSounds() const; bool isPlayingSound(u32 id); @@ -63,10 +71,12 @@ protected: /* 0x88 */ f32 a_field_0x88; /* 0x8C */ f32 a_field_0x8C; /* 0x90 */ f32 a_field_0x90; - /* 0x94 */ f32 a_field_0x94; + /* 0x94 */ f32 mDistanceToListener; /* 0x98 */ f32 a_field_0x98; /* 0x9C */ f32 a_field_0x9C; - /* 0xA0 */ u8 a_0xA0[0xC8 - 0xA0]; + /* 0xA0 */ nw4r::math::VEC3 mPositionRelativeToListener; + /* 0xAC */ nw4r::math::VEC3 mPositionTransformedByListener; + /* 0xB8 */ u8 a_0xB8[0xC8 - 0xB8]; /* 0xC8 */ UNKTYPE *a_field_0xC8; /* 0xCC */ u16 mFlags; /* 0xD0 */ nw4r::math::VEC3 mPositionRelativeToPlayer; diff --git a/include/d/snd/d_snd_3d_manager.h b/include/d/snd/d_snd_3d_manager.h index b0a86b90..eb09988b 100644 --- a/include/d/snd/d_snd_3d_manager.h +++ b/include/d/snd/d_snd_3d_manager.h @@ -42,21 +42,25 @@ public: return mManager; } - const mVec3_c &getListenerPos() const { - return mSoundListenerPosition; + const mVec3_c &getCameraTargetPos() const { + return mCameraTargetPosition; + } + + const nw4r::math::VEC3 &getSndListenerPos() const { + return mListener.GetPosition(); } private: void updateListenerPos(f32); /* 0x10 */ bool mIsSetup; - /* 0x11 */ u8 field_0x11; + /* 0x11 */ bool mCalculationsFresh; /* 0x14 */ dSnd3DEngine_c *mpEngine; /* 0x18 */ nw4r::snd::Sound3DManager mManager; /* 0x44 */ nw4r::snd::Sound3DListener mListener; /* 0xB0 */ EGG::LookAtCamera mCamera; - /* 0x138 */ mVec3_c field_0x138; - /* 0x144 */ mVec3_c mSoundListenerPosition; + /* 0x138 */ mVec3_c mCameraDirectionNormalized; + /* 0x144 */ mVec3_c mCameraTargetPosition; /* 0x150 */ f32 mCameraPosSqVelocity; /* 0x154 */ f32 mCameraAtSqVelocity; /* 0x158 */ f32 mCamDistance; diff --git a/include/d/snd/d_snd_calc_pitch.h b/include/d/snd/d_snd_calc_pitch.h new file mode 100644 index 00000000..5365e1e3 --- /dev/null +++ b/include/d/snd/d_snd_calc_pitch.h @@ -0,0 +1,10 @@ +#ifndef D_SND_CALC_PITCH_H +#define D_SND_CALC_PITCH_H + +#include "common.h" + +f32 pitchScaleForPitchIdx(s32 idx); +f32 pitchScaleForPitchIdxTenths(f32 idx); +f32 pitchIdxTenthsForPitchScale(f32 scale); + +#endif diff --git a/include/d/snd/d_snd_control_player.h b/include/d/snd/d_snd_control_player.h new file mode 100644 index 00000000..fc0096ef --- /dev/null +++ b/include/d/snd/d_snd_control_player.h @@ -0,0 +1,53 @@ +#ifndef D_SND_CONTROL_PLAYER_H +#define D_SND_CONTROL_PLAYER_H + +#include "d/snd/d_snd_sound.h" +#include "nw4r/snd/snd_SoundPlayer.h" + +class dSndControlPlayer_c : public dSndControl_c { +public: + dSndControlPlayer_c(f32 value, f32 min, f32 max) : dSndControl_c(value, min, max) {} + virtual void reset() override; // vt 0x0C + + virtual void stop() override; // vt 0x18 + virtual void apply() = 0; // vt 0x1C + virtual f32 getAppliedValue() = 0; // vt 0x20 + + void setIndex1(s32 idx); + void setIndex2(s32 idx); + +protected: + /* 0x30 */ nw4r::snd::SoundPlayer *mpPlayer; + /* 0x34 */ s32 mIndex; +}; + +class dSndControlPlayerVolumeBase_c : public dSndControlPlayer_c { +public: + dSndControlPlayerVolumeBase_c(); +}; + +class dSndControlPlayerVolume_c : public dSndControlPlayerVolumeBase_c { +public: + dSndControlPlayerVolume_c() {} + + virtual void apply() override; // vt 0x1C + virtual f32 getAppliedValue() override; // vt 0x20 +}; + +class dSndControlPlayerLpfFreq_c : public dSndControlPlayer_c { +public: + dSndControlPlayerLpfFreq_c() : dSndControlPlayer_c(0.0f, -1.0f, 0.0f) {} + + virtual void apply() override; // vt 0x1C + virtual f32 getAppliedValue() override; // vt 0x20 +}; + +class dSndControlPlayerFxSend_c : public dSndControlPlayer_c { +public: + dSndControlPlayerFxSend_c() : dSndControlPlayer_c(0.0f, -1.0f, 0.0f) {} + + virtual void apply() override; // vt 0x1C + virtual f32 getAppliedValue() override; // vt 0x20 +}; + +#endif diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h index 2578fcb4..26026b10 100644 --- a/include/d/snd/d_snd_player_mgr.h +++ b/include/d/snd/d_snd_player_mgr.h @@ -29,13 +29,16 @@ private: public: dSndPlayerMgr_c(); + void shutdown(); void calc(); u32 getFreeSize(); bool loadDemoArchive(const char *demoArchiveName); const char *getSoundArchivePath(); u32 convertLabelStringToSoundId(const char *label) const; + nw4r::snd::SoundArchivePlayer &getSoundArchivePlayerForType(u8 type); + bool canUseThisPlayer(u8 type) const; bool checkFlag(u32 mask) const { return mFlags & mask; diff --git a/include/d/snd/d_snd_sound.h b/include/d/snd/d_snd_sound.h new file mode 100644 index 00000000..3f4f9fd9 --- /dev/null +++ b/include/d/snd/d_snd_sound.h @@ -0,0 +1,169 @@ +#ifndef D_SND_SOUND_H +#define D_SND_SOUND_H + +#include "common.h" +#include "nw4r/snd/snd_SeqTrack.h" +#include "nw4r/snd/snd_SoundHandle.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: + dSndControl_c(f32 value, f32 min, f32 max) + : mResetValue(value), + mMax(max), + mMin(min), + mCurrValue(value), + mStartValue(value), + mTargetValue(value), + mDuration(0), + mTimer(0), + mIsLinked(false) {} + + ~dSndControl_c() {} + + virtual void configure(f32 value, f32 min, f32 max); // vt 0x08 + virtual void reset(); // vt 0x0C + virtual void set(f32 value, s32 frames); // vt 0x10 + virtual void calc(); // vt 0x14 + virtual void stop(); // vt 0x18 + + bool isLinked() const { + return mIsLinked; + } + + void setLinked(bool linked) { + mIsLinked = linked; + } + + f32 getCurrentValue() const { + return mCurrValue; + } + +protected: + /* 0x04 */ f32 mResetValue; + /* 0x08 */ f32 mMax; + /* 0x0C */ f32 mMin; + /* 0x10 */ f32 mCurrValue; + /* 0x14 */ f32 mStartValue; + /* 0x18 */ f32 mTargetValue; + /* 0x1C */ s32 mDuration; + /* 0x20 */ s32 mTimer; + /* 0x24 */ nw4r::ut::Node mNode; + /* 0x2C */ bool mIsLinked; +}; + +class dSndControlSound_c : public dSndControl_c { +public: + dSndControlSound_c(f32 value, f32 min, f32 max) : dSndControl_c(value, min, max) {} + virtual void apply(dSndSound_c *pHandle) = 0; // vt 0x1C + +private: +}; + +class dSndControlSoundVolume_c : public dSndControlSound_c { +public: + dSndControlSoundVolume_c() : dSndControlSound_c(1.0f, 0.0f, 2.0f) {} + virtual void apply(dSndSound_c *pHandle) override; +}; + +class dSndControlSoundPitch_c : public dSndControlSound_c { +public: + dSndControlSoundPitch_c() : dSndControlSound_c(1.0f, 0.25f, 4.0f) {} + virtual void apply(dSndSound_c *pHandle) override; +}; + +/** Stores pitch as a value from -24 to 24, exponentially scaling it to 0.25-4.0 */ +class dSndControlSoundPitchLinear_c : public dSndControlSound_c { +public: + dSndControlSoundPitchLinear_c(); + virtual void apply(dSndSound_c *pHandle) override; + virtual void set(f32 value, s32 frames) override; + + void setControl(dSndControlSound_c *ctrl) { + mpOtherControl = ctrl; + } + +private: + /* 0x30 */ dSndControlSound_c *mpOtherControl; +}; + +class dSndControlSoundSeqTrackTempoRatio_c : public dSndControlSound_c { +public: + dSndControlSoundSeqTrackTempoRatio_c() : dSndControlSound_c(1.0f, 0.25f, 4.0f) {} + virtual void apply(dSndSound_c *pHandle) override; +}; + +class dSndControlSoundSeqTrackVolume_c : public dSndControlSound_c { +public: + dSndControlSoundSeqTrackVolume_c() : dSndControlSound_c(1.0f, 0.0f, 2.0f) {} + virtual void apply(dSndSound_c *pHandle) override; + + void setMask(u16 mask) { + mMask = mask; + } + +private: + /* 0x2E */ u16 mMask; +}; + +class dSndControlSoundStrmTrackVolume_c : public dSndControlSound_c { +public: + dSndControlSoundStrmTrackVolume_c() : dSndControlSound_c(1.0f, 0.0f, 2.0f) {} + virtual void apply(dSndSound_c *pHandle) override; + + void setMask(u16 mask) { + mMask = mask; + } + +private: + /* 0x2E */ u16 mMask; +}; + +class dSndSound_c : public nw4r::snd::SoundHandle { +public: + dSndSound_c(); + ~dSndSound_c(); + + virtual void vt_0x08(); // 0x08 + virtual void vt_0x0C(); // 0x0C + virtual void fadeIn(u32 id, int fadeFrames); // 0x10 + + bool isStrmSound(); + bool isWaveSound(); + bool isSeqSound(); + + void setPitchRelated(f32 pitch, s32 frames); + + void setSeqTrackMute(u32 trackFlags, nw4r::snd::SeqMute mute); + void stop(); + + s16 readSeqTrackVariable(int varNo); + void writeSeqTrackVariable(int varNo, s16 value); + + void linkCtrl(dSndControlSound_c *); + void unlinkCtrl(dSndControlSound_c *); + +private: + void reset(); + void resetTrackVolumes(); + + /* 0x08 */ u8 _0x08[0x10 - 0x08]; + + /* 0x10 */ UNKWORD field_0x10; + /* 0x14 */ u8 field_0x14; + /* 0x15 */ u8 field_0x15; + /* 0x16 */ u8 field_0x16; + /* 0x17 */ u8 field_0x17; + /* 0x18 */ dSndControlSoundVolume_c mCtrlVolume; + /* 0x48 */ dSndControlSoundPitch_c mCtrlPitch; + /* 0x78 */ dSndControlSoundPitchLinear_c mCtrlUnk; + /* 0xAC */ dSndControlSoundSeqTrackVolume_c *mpCtrlSeqTrackVolume; + /* 0xB0 */ dSndControlSoundStrmTrackVolume_c *mpCtrlStrmTrackVolume; + /* 0xB4 */ dSndControlSoundSeqTrackTempoRatio_c mpCtrlSeqTrackTempoRatio; + /* 0xE4 */ nw4r::ut::List mList; +}; + +#endif diff --git a/include/d/snd/d_snd_source.h b/include/d/snd/d_snd_source.h index 65d8be13..64a3eaad 100644 --- a/include/d/snd/d_snd_source.h +++ b/include/d/snd/d_snd_source.h @@ -3,87 +3,9 @@ #include "common.h" #include "d/snd/d_snd_3d_actor.h" +#include "d/snd/d_snd_source_if.h" #include "nw4r/ut/ut_list.h" - -class dAcBase_c; - -class dSoundSourceIf_c { -public: - virtual ~dSoundSourceIf_c() {} -#define SOUNDSOURCE_VIRTUAL(offset) virtual void vt_##offset() = 0; - SOUNDSOURCE_VIRTUAL(0x0C); - SOUNDSOURCE_VIRTUAL(0x10); - SOUNDSOURCE_VIRTUAL(0x14); - SOUNDSOURCE_VIRTUAL(0x18); - SOUNDSOURCE_VIRTUAL(0x1C); - SOUNDSOURCE_VIRTUAL(0x20); - SOUNDSOURCE_VIRTUAL(0x24); - SOUNDSOURCE_VIRTUAL(0x28); - SOUNDSOURCE_VIRTUAL(0x2C); - SOUNDSOURCE_VIRTUAL(0x30); - SOUNDSOURCE_VIRTUAL(0x34); - SOUNDSOURCE_VIRTUAL(0x38); - SOUNDSOURCE_VIRTUAL(0x3C); - SOUNDSOURCE_VIRTUAL(0x40); - SOUNDSOURCE_VIRTUAL(0x44); - virtual bool hasPlayingSounds() const = 0; // 0x48 - SOUNDSOURCE_VIRTUAL(0x4C); - SOUNDSOURCE_VIRTUAL(0x50); - SOUNDSOURCE_VIRTUAL(0x54); - SOUNDSOURCE_VIRTUAL(0x58); - SOUNDSOURCE_VIRTUAL(0x5C); - SOUNDSOURCE_VIRTUAL(0x60); - SOUNDSOURCE_VIRTUAL(0x64); - SOUNDSOURCE_VIRTUAL(0x68); - SOUNDSOURCE_VIRTUAL(0x6C); - SOUNDSOURCE_VIRTUAL(0x70); - SOUNDSOURCE_VIRTUAL(0x74); - SOUNDSOURCE_VIRTUAL(0x78); - SOUNDSOURCE_VIRTUAL(0x7C); - SOUNDSOURCE_VIRTUAL(0x80); - SOUNDSOURCE_VIRTUAL(0x84); - SOUNDSOURCE_VIRTUAL(0x88); - SOUNDSOURCE_VIRTUAL(0x8C); - SOUNDSOURCE_VIRTUAL(0x90); - SOUNDSOURCE_VIRTUAL(0x94); - SOUNDSOURCE_VIRTUAL(0x98); - SOUNDSOURCE_VIRTUAL(0x9C); - SOUNDSOURCE_VIRTUAL(0xA0); - SOUNDSOURCE_VIRTUAL(0xA4); - SOUNDSOURCE_VIRTUAL(0xA8); - SOUNDSOURCE_VIRTUAL(0xAC); - SOUNDSOURCE_VIRTUAL(0xB0); - SOUNDSOURCE_VIRTUAL(0xB4); - SOUNDSOURCE_VIRTUAL(0xB8); - SOUNDSOURCE_VIRTUAL(0xBC); - SOUNDSOURCE_VIRTUAL(0xC0); - SOUNDSOURCE_VIRTUAL(0xC4); - SOUNDSOURCE_VIRTUAL(0xC8); - SOUNDSOURCE_VIRTUAL(0xCC); - SOUNDSOURCE_VIRTUAL(0xD0); - SOUNDSOURCE_VIRTUAL(0xD4); - SOUNDSOURCE_VIRTUAL(0xD8); - SOUNDSOURCE_VIRTUAL(0xDC); - SOUNDSOURCE_VIRTUAL(0xE0); - SOUNDSOURCE_VIRTUAL(0xE4); - SOUNDSOURCE_VIRTUAL(0xE8); - SOUNDSOURCE_VIRTUAL(0xEC); - SOUNDSOURCE_VIRTUAL(0xF0); - SOUNDSOURCE_VIRTUAL(0xF4); - SOUNDSOURCE_VIRTUAL(0xF8); - SOUNDSOURCE_VIRTUAL(0xFC); - - virtual bool isReadyMaybe() = 0; // 0x100 - virtual bool load(void *data, const char *name) = 0; // 0x104 - virtual void setFrame(f32 frame) = 0; // 0x108 - virtual void setRate(f32 frame) = 0; // 0x10C - virtual void set_0x164(UNKWORD val) = 0; // 0x114 - - SOUNDSOURCE_VIRTUAL(0x118); - SOUNDSOURCE_VIRTUAL(0x11C); -}; - class dSoundSource_c : public dSoundSourceIf_c, public dSnd3DActor_c { public: dSoundSource_c(u8, dAcBase_c *, UNKWORD, UNKWORD); @@ -131,7 +53,19 @@ public: virtual void d_s_vt_0x1E8(); // Overrides of dSoundSourceIf_c - virtual bool hasPlayingSounds() const override; + + virtual const nw4r::math::VEC3 &getListenerPosition() const override; + + virtual bool hasPlayingSounds() const override; // 0x48 + virtual bool isPlayingSound(u32 soundId) override; // 0x4C + virtual bool isPlayingSound(const char *soundId) override; // 0x50 + + virtual bool isReadyMaybe() override { + return false; + } // 0x100 + virtual void load(void *data, const char *name) override {} // 0x104 + virtual void setFrame(f32 frame) override {} // 0x108 + virtual void setRate(f32 frame) override {} // 0x10C private: // at 0x00: dSoundSourceIf_c vtable diff --git a/include/d/snd/d_snd_source_if.h b/include/d/snd/d_snd_source_if.h new file mode 100644 index 00000000..32973df0 --- /dev/null +++ b/include/d/snd/d_snd_source_if.h @@ -0,0 +1,85 @@ +#ifndef D_SOUND_SOURCE_IF_H +#define D_SOUND_SOURCE_IF_H + +#include "common.h" +#include "nw4r/math/math_types.h" + +class dAcBase_c; + +class dSoundSourceIf_c { +public: + virtual ~dSoundSourceIf_c() {} +#define SOUNDSOURCE_VIRTUAL(offset) virtual void vt_##offset() = 0; + SOUNDSOURCE_VIRTUAL(0x0C); + SOUNDSOURCE_VIRTUAL(0x10); + SOUNDSOURCE_VIRTUAL(0x14); + SOUNDSOURCE_VIRTUAL(0x18); + SOUNDSOURCE_VIRTUAL(0x1C); + SOUNDSOURCE_VIRTUAL(0x20); + SOUNDSOURCE_VIRTUAL(0x24); + virtual const nw4r::math::VEC3 &getListenerPosition() const = 0; // 0x28 + SOUNDSOURCE_VIRTUAL(0x2C); + SOUNDSOURCE_VIRTUAL(0x30); + SOUNDSOURCE_VIRTUAL(0x34); + SOUNDSOURCE_VIRTUAL(0x38); + SOUNDSOURCE_VIRTUAL(0x3C); + SOUNDSOURCE_VIRTUAL(0x40); + SOUNDSOURCE_VIRTUAL(0x44); + virtual bool hasPlayingSounds() const = 0; // 0x48 + virtual bool isPlayingSound(u32 soundId) = 0; // 0x4C + virtual bool isPlayingSound(const char *soundId) = 0; // 0x50 + SOUNDSOURCE_VIRTUAL(0x54); + SOUNDSOURCE_VIRTUAL(0x58); + SOUNDSOURCE_VIRTUAL(0x5C); + SOUNDSOURCE_VIRTUAL(0x60); + SOUNDSOURCE_VIRTUAL(0x64); + SOUNDSOURCE_VIRTUAL(0x68); + SOUNDSOURCE_VIRTUAL(0x6C); + SOUNDSOURCE_VIRTUAL(0x70); + SOUNDSOURCE_VIRTUAL(0x74); + SOUNDSOURCE_VIRTUAL(0x78); + SOUNDSOURCE_VIRTUAL(0x7C); + SOUNDSOURCE_VIRTUAL(0x80); + SOUNDSOURCE_VIRTUAL(0x84); + SOUNDSOURCE_VIRTUAL(0x88); + SOUNDSOURCE_VIRTUAL(0x8C); + SOUNDSOURCE_VIRTUAL(0x90); + SOUNDSOURCE_VIRTUAL(0x94); + SOUNDSOURCE_VIRTUAL(0x98); + SOUNDSOURCE_VIRTUAL(0x9C); + SOUNDSOURCE_VIRTUAL(0xA0); + SOUNDSOURCE_VIRTUAL(0xA4); + SOUNDSOURCE_VIRTUAL(0xA8); + SOUNDSOURCE_VIRTUAL(0xAC); + SOUNDSOURCE_VIRTUAL(0xB0); + SOUNDSOURCE_VIRTUAL(0xB4); + SOUNDSOURCE_VIRTUAL(0xB8); + SOUNDSOURCE_VIRTUAL(0xBC); + SOUNDSOURCE_VIRTUAL(0xC0); + SOUNDSOURCE_VIRTUAL(0xC4); + SOUNDSOURCE_VIRTUAL(0xC8); + SOUNDSOURCE_VIRTUAL(0xCC); + SOUNDSOURCE_VIRTUAL(0xD0); + SOUNDSOURCE_VIRTUAL(0xD4); + SOUNDSOURCE_VIRTUAL(0xD8); + SOUNDSOURCE_VIRTUAL(0xDC); + SOUNDSOURCE_VIRTUAL(0xE0); + SOUNDSOURCE_VIRTUAL(0xE4); + SOUNDSOURCE_VIRTUAL(0xE8); + SOUNDSOURCE_VIRTUAL(0xEC); + SOUNDSOURCE_VIRTUAL(0xF0); + SOUNDSOURCE_VIRTUAL(0xF4); + SOUNDSOURCE_VIRTUAL(0xF8); + SOUNDSOURCE_VIRTUAL(0xFC); + + virtual bool isReadyMaybe() = 0; // 0x100 + virtual void load(void *data, const char *name) = 0; // 0x104 + virtual void setFrame(f32 frame) = 0; // 0x108 + virtual void setRate(f32 frame) = 0; // 0x10C + + SOUNDSOURCE_VIRTUAL(0x110); + SOUNDSOURCE_VIRTUAL(0x114); + SOUNDSOURCE_VIRTUAL(0x118); +}; + +#endif diff --git a/include/nw4r/snd/snd_SeqSoundHandle.h b/include/nw4r/snd/snd_SeqSoundHandle.h index 709701ed..374a966c 100644 --- a/include/nw4r/snd/snd_SeqSoundHandle.h +++ b/include/nw4r/snd/snd_SeqSoundHandle.h @@ -8,6 +8,7 @@ #include "common.h" // nullptr #include "nw4r/snd/snd_SeqSound.h" +#include "nw4r/snd/snd_SeqTrack.h" #include "nw4r/ut/ut_NonCopyable.h" // ut::NonCopyable /******************************************************************************* @@ -29,6 +30,7 @@ namespace nw4r { namespace snd // methods public: SeqSoundHandle(SoundHandle*); + ~SeqSoundHandle() { DetachSound(); } // methods bool IsAttachedSound() const { return mSound != nullptr; } @@ -39,6 +41,26 @@ namespace nw4r { namespace snd mSound->WriteVariable(varNo, value); } + void ReadVariable(int varNo, s16 *value) { + if (IsAttachedSound()) + mSound->ReadVariable(varNo, value); + } + + void SetTrackMute(u32 trackFlags, SeqMute mute) { + if (IsAttachedSound()) + mSound->SetTrackMute(trackFlags, mute); + } + + void SetTempoRatio(f32 tempoRatio) { + if (IsAttachedSound()) + mSound->SetTempoRatio(tempoRatio); + } + + void SetVolume(u32 trackFlags, f32 volume) { + if (IsAttachedSound()) + mSound->SetTrackVolume(trackFlags, volume); + } + // members private: /* base ut::NonCopyable */ // size 0x00, offset 0x00 diff --git a/include/nw4r/snd/snd_SoundHandle.h b/include/nw4r/snd/snd_SoundHandle.h index cf1ed317..e8d1a3c0 100644 --- a/include/nw4r/snd/snd_SoundHandle.h +++ b/include/nw4r/snd/snd_SoundHandle.h @@ -34,6 +34,22 @@ namespace nw4r { namespace snd const detail::BasicSound *detail_GetAttachedSound() const { return mSound; } void DetachSound(); + + void FadeIn(int fadeFrames) { + if (IsAttachedSound()) + mSound->FadeIn(fadeFrames); + } + + void SetVolume(f32 volume, int frames) { + if (IsAttachedSound()) + mSound->SetVolume(volume, frames); + } + + void SetPitch(f32 volume) { + if (IsAttachedSound()) + mSound->SetPitch(volume); + } + void Stop() { if (IsAttachedSound()) mSound->Stop(0); diff --git a/include/nw4r/snd/snd_StrmSoundHandle.h b/include/nw4r/snd/snd_StrmSoundHandle.h index 3e92331c..e377ed9a 100644 --- a/include/nw4r/snd/snd_StrmSoundHandle.h +++ b/include/nw4r/snd/snd_StrmSoundHandle.h @@ -8,6 +8,7 @@ #include "common.h" // nullptr #include "nw4r/snd/snd_SoundHandle.h" +#include "nw4r/snd/snd_StrmSound.h" #include "nw4r/ut/ut_NonCopyable.h" // ut::NonCopyable /******************************************************************************* @@ -30,10 +31,16 @@ namespace nw4r { namespace snd public: // methods StrmSoundHandle(SoundHandle*); + ~StrmSoundHandle() { DetachSound(); } bool IsAttachedSound() const { return mSound != nullptr; } void DetachSound(); + void SetVolume(u32 trackFlags, f32 volume, int fadeFrames) { + if (IsAttachedSound()) + mSound->SetTrackVolume(trackFlags, volume, fadeFrames); + } + // members private: /* base NonCopyable */ // size 0x00, offset 0x00 diff --git a/src/REL/d/t/d_t_sound_area.cpp b/src/REL/d/t/d_t_sound_area.cpp index 46112c97..655caa73 100644 --- a/src/REL/d/t/d_t_sound_area.cpp +++ b/src/REL/d/t/d_t_sound_area.cpp @@ -52,7 +52,7 @@ int dTgSndAr_c::actorExecute() { link->setBit_field_0xE8(params & 0xFF); } if (dSnd3DManager_c::GetInstance() != nullptr) { - mVec3_c pos = dSnd3DManager_c::GetInstance()->getListenerPos(); + mVec3_c pos = dSnd3DManager_c::GetInstance()->getCameraTargetPos(); if (checkPosInArea(pos) && dTgSndMg_c::GetInstance() != nullptr) { dTgSndMg_c::GetInstance()->setBgmFlag(params & 0xFF); } diff --git a/src/d/snd/d_snd_3d_actor.cpp b/src/d/snd/d_snd_3d_actor.cpp index 4ca49c4b..b96ad650 100644 --- a/src/d/snd/d_snd_3d_actor.cpp +++ b/src/d/snd/d_snd_3d_actor.cpp @@ -20,7 +20,7 @@ dSnd3DActor_c::dSnd3DActor_c(UNKTYPE *a1, u8 a2) a_field_0x88(0.0f), a_field_0x8C(0.0f), a_field_0x90(INFINITY), - a_field_0x94(INFINITY), + mDistanceToListener(INFINITY), a_field_0x98(0.0f), a_field_0x9C(0.0f), a_field_0xC8(a1), @@ -41,13 +41,34 @@ void dSnd3DActor_c::d_vt_0x34(const nw4r::math::VEC3 &rPosition) { mFlags = 0; } +void dSnd3DActor_c::updatePositionRelativeToListener() { + if (!checkFlag(1)) { + calculatePositionRelativeToListener(); + setFlag(1); + } +} + +void dSnd3DActor_c::calculatePositionRelativeToListener() { + nw4r::math::VEC3Sub( + &mPositionRelativeToListener, &GetPosition(), &dSnd3DManager_c::GetInstance()->getSndListenerPos() + ); +} + +void dSnd3DActor_c::updateDistanceToListener() { + if (!checkFlag(2)) { + updatePositionRelativeToListener(); + mDistanceToListener = VEC3Len(&mPositionRelativeToListener); + setFlag(2); + } +} + void dSnd3DActor_c::updatePositionRelativeToPlayer() { if (!checkFlag(0x40)) { nw4r::math::VEC3 linkTranslation = dAcPy_c::GetLink()->getCenterTranslation(); nw4r::math::VEC3 pos = GetPosition(); nw4r::math::VEC3Sub(&mPositionRelativeToPlayer, &pos, &linkTranslation); - mFlags |= 0x40; + setFlag(0x40); } } @@ -68,7 +89,7 @@ void dSnd3DActor_c::updateDistanceToPlayer() { } else { mDistanceToPlayer = nw4r::math::VEC3Len(&mPositionRelativeToPlayer); } - mFlags |= 0x80; + setFlag(0x80); } } diff --git a/src/d/snd/d_snd_3d_manager.cpp b/src/d/snd/d_snd_3d_manager.cpp index 39e18a63..1bbf9717 100644 --- a/src/d/snd/d_snd_3d_manager.cpp +++ b/src/d/snd/d_snd_3d_manager.cpp @@ -11,15 +11,15 @@ template class SndMgrDisposer; -dSnd3DManager_c::dSnd3DManager_c() : mIsSetup(false), field_0x11(0) { +dSnd3DManager_c::dSnd3DManager_c() : mIsSetup(false), mCalculationsFresh(0) { mCameraPosSqVelocity = 0.0f; mCameraAtSqVelocity = 0.0f; mCamDistance = 0.9f; mTimer = 0; mpEngine = new dSnd3DEngine_c(); - field_0x138.x = 0.0f; - field_0x138.y = 0.0f; - field_0x138.z = 1.0f; + mCameraDirectionNormalized.x = 0.0f; + mCameraDirectionNormalized.y = 0.0f; + mCameraDirectionNormalized.z = 1.0f; } void dSnd3DManager_c::setup() { @@ -51,12 +51,14 @@ void dSnd3DManager_c::resetCamDistance() { void dSnd3DManager_c::setCamDistance(f32 value) { // @bug ? not actually clamped - nw4r::ut::Clamp(value, -1.0f, 2.0f); + (void)nw4r::ut::Clamp(value, -1.0f, 2.0f); mCamDistance = value; } void dSnd3DManager_c::calc() { - field_0x11 = 0; + // Don't actually calculate anything, + // but allow re-calculations this frame. + mCalculationsFresh = false; } void dSnd3DManager_c::clearState() { @@ -67,7 +69,7 @@ void dSnd3DManager_c::clearState() { void dSnd3DManager_c::updateFromCamera(EGG::LookAtCamera &camera) { - if (field_0x11) { + if (mCalculationsFresh) { return; } @@ -122,14 +124,14 @@ void dSnd3DManager_c::updateFromCamera(EGG::LookAtCamera &camera) { mCamera = camera; updateListenerPos(dist); - field_0x11 = 1; + mCalculationsFresh = true; } void dSnd3DManager_c::updateListenerPos(f32 f) { const EGG::Matrix34f &mtx = mCamera.getViewMatrix(); mListener.SetMatrix(*mtx); EGG::Vector3f dir = mCamera.getDirection(); - VECNormalize(dir, field_0x138); + VECNormalize(dir, mCameraDirectionNormalized); dir *= f; - mSoundListenerPosition = mCamera.mPos + dir; + mCameraTargetPosition = mCamera.mPos + dir; } diff --git a/src/d/snd/d_snd_control_player.cpp b/src/d/snd/d_snd_control_player.cpp new file mode 100644 index 00000000..d82931f7 --- /dev/null +++ b/src/d/snd/d_snd_control_player.cpp @@ -0,0 +1,71 @@ +#include "d/snd/d_snd_control_player.h" + +#include "common.h" +#include "d/snd/d_snd_sound.h" +#include "nw4r/snd/snd_SoundPlayer.h" +#include "nw4r/snd/snd_global.h" + +dSndControlPlayerVolumeBase_c::dSndControlPlayerVolumeBase_c() : dSndControlPlayer_c(1.0f, 0.0f, 1.0f) { + mpPlayer = nullptr; + mIndex = 0; +} + +void dSndControlPlayer_c::reset() { + dSndControl_c::reset(); + apply(); +} + +extern "C" void *lbl_80575D4C; +extern "C" nw4r::snd::SoundPlayer *fn_803600B0(void *, s32); +extern "C" nw4r::snd::SoundPlayer *fn_80360120(void *, s32); + +void dSndControlPlayer_c::setIndex1(s32 idx) { + mpPlayer = fn_803600B0(lbl_80575D4C, idx); + mIndex = idx; +} + +void dSndControlPlayer_c::setIndex2(s32 idx) { + mpPlayer = fn_80360120(lbl_80575D4C, idx); + mIndex = idx; +} + +void dSndControlPlayer_c::stop() { + mCurrValue = getAppliedValue(); + dSndControl_c::stop(); +} + +void dSndControlPlayerVolume_c::apply() { + mpPlayer->SetVolume(mCurrValue); +} + +f32 dSndControlPlayerVolume_c::getAppliedValue() { + return mpPlayer->GetVolume(); +} + +void dSndControlPlayerLpfFreq_c::apply() { + mpPlayer->SetLpfFreq(mCurrValue); +} + +f32 dSndControlPlayerLpfFreq_c::getAppliedValue() { + return mpPlayer->GetLpfFreq(); +} + +void dSndControlPlayerFxSend_c::apply() { + if (mCurrValue < mMin) { + mCurrValue = mMin; + } + if (mCurrValue >= mMax) { + mCurrValue = mMax; + } + mpPlayer->SetFxSend(nw4r::snd::AUX_B, mCurrValue); +} + +extern "C" bool fn_8035F030(s32); + +f32 dSndControlPlayerFxSend_c::getAppliedValue() { + int auxBus = nw4r::snd::AUX_A; + if (fn_8035F030(mIndex)) { + auxBus = nw4r::snd::AUX_B; + } + return mpPlayer->GetFxSend(auxBus); +} diff --git a/src/d/snd/d_snd_control_sound.cpp b/src/d/snd/d_snd_control_sound.cpp new file mode 100644 index 00000000..cdffeaf1 --- /dev/null +++ b/src/d/snd/d_snd_control_sound.cpp @@ -0,0 +1,100 @@ + +#include "common.h" +#include "d/snd/d_snd_calc_pitch.h" +#include "d/snd/d_snd_sound.h" +#include "nw4r/snd/snd_SeqSoundHandle.h" +#include "nw4r/snd/snd_StrmSoundHandle.h" + +// I'm not super happy with these base class function in a separate file, +// but either we add another intermediate class or this is ok. It's weird +// that d_snd_sound has dSndControl_c::stop though + +void dSndControl_c::reset() { + mCurrValue = mResetValue; + mStartValue = mResetValue; + mTargetValue = mResetValue; + mDuration = 0; + mTimer = 0; +} + +void dSndControl_c::stop() { + // field_0x10 = field_0x04; + mStartValue = mCurrValue; + mTargetValue = mCurrValue; + mDuration = 0; + mTimer = 0; +} + +void dSndControl_c::set(f32 value, s32 frames) { + stop(); + f32 clamped = value; + if (clamped > mMax) { + clamped = mMax; + } else if (clamped < mMin) { + clamped = mMin; + } + if (clamped != mCurrValue) { + mTargetValue = clamped; + if (frames == 0) { + mCurrValue = clamped; + } else { + mDuration = frames; + mTimer = 0; + } + } +} + +void dSndControl_c::calc() { + if (mTimer < mDuration) { + mTimer++; + if (mTimer == mDuration) { + mCurrValue = mTargetValue; + } else { + mCurrValue = mStartValue + (mTimer * (mTargetValue - mStartValue) / mDuration); + } + } +} + +void dSndControlSoundVolume_c::apply(dSndSound_c *sound) { + sound->SetVolume(mCurrValue, 0); +} + +void dSndControlSoundPitch_c::apply(dSndSound_c *sound) { + sound->SetPitch(mCurrValue); +} + +void d_snd_control_sound_float_order() { + -24.0f; + 24.0f; +} + +dSndControlSoundPitchLinear_c::dSndControlSoundPitchLinear_c() : dSndControlSound_c(0.0f, -24.0f, 24.0f) { + mpOtherControl = nullptr; +} + +void dSndControlSoundPitchLinear_c::set(f32 value, s32 frames) { + if (mpOtherControl != nullptr) { + mCurrValue = pitchIdxTenthsForPitchScale(mpOtherControl->getCurrentValue()); + } + + dSndControlSound_c::set(value, frames); +} + +void dSndControlSoundPitchLinear_c::apply(dSndSound_c *pHandle) { + pHandle->setPitchRelated(pitchScaleForPitchIdxTenths(mCurrValue), 0); +} + +void dSndControlSoundSeqTrackTempoRatio_c::apply(dSndSound_c *sound) { + nw4r::snd::SeqSoundHandle handle(sound); + handle.SetTempoRatio(mCurrValue); +} + +void dSndControlSoundSeqTrackVolume_c::apply(dSndSound_c *sound) { + nw4r::snd::SeqSoundHandle handle(sound); + handle.SetVolume(mMask, mCurrValue); +} + +void dSndControlSoundStrmTrackVolume_c::apply(dSndSound_c *sound) { + nw4r::snd::StrmSoundHandle handle(sound); + handle.SetVolume(mMask, mCurrValue, 0); +} diff --git a/src/d/snd/d_snd_player_mgr.cpp b/src/d/snd/d_snd_player_mgr.cpp index 0edee554..9fdf769a 100644 --- a/src/d/snd/d_snd_player_mgr.cpp +++ b/src/d/snd/d_snd_player_mgr.cpp @@ -52,6 +52,26 @@ u32 dSndPlayerMgr_c::convertLabelStringToSoundId(const char *label) const { return dSndMgr_c::GetInstance()->changeNameToId(label); } +nw4r::snd::SoundArchivePlayer &dSndPlayerMgr_c::getSoundArchivePlayerForType(u8 type) { + if (canUseThisPlayer(type)) { + return mSoundArchivePlayer; + } + return *dSndMgr_c::getPlayer(); +} + +bool dSndPlayerMgr_c::canUseThisPlayer(u8 type) const { + if (!mSoundArchivePlayer.IsAvailable()) { + return false; + } + + int ty = type; + + if ((ty >= 0 && ty <= 1) || ty == 58) { + return true; + } + return false; +} + bool dSndPlayerMgr_c::loadDemoArchive(const char *demoArchiveName) { if (demoArchiveName == nullptr) { return false; @@ -84,3 +104,15 @@ bool dSndPlayerMgr_c::loadDemoArchive(const char *demoArchiveName) { } return ok; } + +void dSndPlayerMgr_c::shutdown() { + mSoundArchivePlayer.Shutdown(); + mSoundArchive.Shutdown(); +} + + +void dSndPlayerMgr_c::calc() { + if (mSoundArchivePlayer.IsAvailable()) { + mSoundArchivePlayer.Update(); + } +} diff --git a/src/d/snd/d_snd_sound.cpp b/src/d/snd/d_snd_sound.cpp new file mode 100644 index 00000000..03d3b20d --- /dev/null +++ b/src/d/snd/d_snd_sound.cpp @@ -0,0 +1,135 @@ +#include "d/snd/d_snd_sound.h" + +#include "common.h" +#include "d/snd/d_snd_mgr.h" +#include "nw4r/snd/snd_SeqSoundHandle.h" +#include "nw4r/snd/snd_SoundArchive.h" +#include "nw4r/ut/ut_list.h" + +dSndSound_c::dSndSound_c() : field_0x10(0), field_0x14(0), field_0x15(0), field_0x16(0), field_0x17(0) { + nw4r::ut::List_Init(&mList, 0x24); + + mpCtrlSeqTrackVolume = new dSndControlSoundSeqTrackVolume_c[16](); + for (int i = 0; i < 16; i++) { + mpCtrlSeqTrackVolume[i].setMask(1 << i); + } + + mpCtrlStrmTrackVolume = new dSndControlSoundStrmTrackVolume_c[3](); + // @bug should be 3, not 16 + for (int i = 0; i < 16; i++) { + mpCtrlStrmTrackVolume[i].setMask(1 << i); + } + + mCtrlUnk.setControl(&mCtrlPitch); + reset(); +} + +dSndSound_c::~dSndSound_c() { + if (mpCtrlSeqTrackVolume != nullptr) { + delete[] mpCtrlSeqTrackVolume; + } + if (mpCtrlStrmTrackVolume != nullptr) { + delete[] mpCtrlStrmTrackVolume; + } +} + +void dSndSound_c::reset() { + mCtrlVolume.reset(); + mCtrlVolume.apply(this); + mCtrlPitch.reset(); + mCtrlPitch.apply(this); + mCtrlUnk.reset(); + mCtrlUnk.apply(this); + mpCtrlSeqTrackTempoRatio.reset(); + mpCtrlSeqTrackTempoRatio.apply(this); + field_0x15 = 0; + resetTrackVolumes(); +} + +void dSndSound_c::fadeIn(u32 id, int fadeFrames) { + if (id != -1) { + if (fadeFrames != 0) { + FadeIn(fadeFrames); + } + vt_0x08(); + field_0x16 = 1; + } +} + +bool dSndSound_c::isStrmSound() { + if (!IsAttachedSound()) { + return false; + } + return dSndMgr_c::GetInstance()->getArchive()->GetSoundType(GetId()) == nw4r::snd::SoundArchive::SOUND_TYPE_STRM; +} + +bool dSndSound_c::isWaveSound() { + if (!IsAttachedSound()) { + return false; + } + return dSndMgr_c::GetInstance()->getArchive()->GetSoundType(GetId()) == nw4r::snd::SoundArchive::SOUND_TYPE_WAVE; +} + +bool dSndSound_c::isSeqSound() { + if (!IsAttachedSound()) { + return false; + } + return dSndMgr_c::GetInstance()->getArchive()->GetSoundType(GetId()) == nw4r::snd::SoundArchive::SOUND_TYPE_SEQ; +} + +s16 dSndSound_c::readSeqTrackVariable(int varNo) { + if (!isSeqSound()) { + return -1; + } + s16 val = -1; + nw4r::snd::SeqSoundHandle handle(this); + handle.ReadVariable(varNo, &val); + return val; +} + +void dSndSound_c::writeSeqTrackVariable(int varNo, s16 value) { + if (!isSeqSound()) { + return; + } + nw4r::snd::SeqSoundHandle handle(this); + handle.WriteVariable(varNo, value); +} + +void dSndSound_c::resetTrackVolumes() { + if (mpCtrlSeqTrackVolume != nullptr) { + for (int i = 0; i < 16; i++) { + mpCtrlSeqTrackVolume[i].reset(); + mpCtrlSeqTrackVolume[i].apply(this); + } + } + + if (mpCtrlStrmTrackVolume != nullptr) { + for (int i = 0; i < 3; i++) { + mpCtrlStrmTrackVolume[i].reset(); + mpCtrlStrmTrackVolume[i].apply(this); + } + } +} + +void dSndSound_c::setSeqTrackMute(u32 trackFlags, nw4r::snd::SeqMute mute) { + if (isSeqSound()) { + nw4r::snd::SeqSoundHandle handle(this); + handle.SetTrackMute(trackFlags, mute); + } +} + +void dSndSound_c::stop() { + vt_0x08(); + Stop(); +} + +// Might be a separate file +void dSndControl_c::configure(f32 value, f32 min, f32 max) { + mResetValue = value; + mMin = min; + mMax = max; + mCurrValue = value; + mStartValue = value; + mTargetValue = value; + reset(); +} diff --git a/src/d/snd/d_snd_source.cpp b/src/d/snd/d_snd_source.cpp index 68a312bb..11a1589e 100644 --- a/src/d/snd/d_snd_source.cpp +++ b/src/d/snd/d_snd_source.cpp @@ -2,6 +2,7 @@ #include "common.h" #include "d/snd/d_snd_3d_actor.h" +#include "d/snd/d_snd_3d_manager.h" #include "nw4r/snd/snd_SoundStartable.h" #include "nw4r/ut/ut_list.h" #include "sized_string.h" @@ -56,10 +57,22 @@ dSoundSource_c::~dSoundSource_c() { fn_80386C70(this); } +const nw4r::math::VEC3 &dSoundSource_c::getListenerPosition() const { + return dSnd3DManager_c::GetInstance()->getSndListenerPos(); +} + bool dSoundSource_c::hasPlayingSounds() const { return dSnd3DActor_c::hasPlayingSounds(); } +bool dSoundSource_c::isPlayingSound(u32 soundId) { + return dSnd3DActor_c::isPlayingSound(soundId); +} + +bool dSoundSource_c::isPlayingSound(const char *soundId) { + return isPlayingSound(soundLabelToSoundId(soundId)); +} + void dSoundSource_c::d_vt_0x38(bool flag, int fadeFrames) { if (flag == 0) { PauseAllSound(flag, fadeFrames); diff --git a/src/nw4r/snd/snd_AnimSound.cpp b/src/nw4r/snd/snd_AnimSound.cpp index ab8151aa..0ba0b144 100644 --- a/src/nw4r/snd/snd_AnimSound.cpp +++ b/src/nw4r/snd/snd_AnimSound.cpp @@ -426,7 +426,6 @@ void AnimEventPlayer::SetVariable(const AnimEvent *event, u32 varNo, f32 f) { SeqSoundHandle handle(GetHandle()); int iVal = f * 100.0f; handle.WriteVariable(varNo, ut::Clamp(iVal, -0x8000, 0x7FFF)); - handle.DetachSound(); } } else if (varNo < 32) { int iVal = f * 100.0f; From 1fa755181b31a8065359b0cdfa1930f23770ff9c Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 1 Jun 2025 21:10:48 +0200 Subject: [PATCH 04/22] d_snd_sound OK --- config/SOUE01/splits.txt | 1 + config/SOUE01/symbols.txt | 70 +++---- configure.py | 2 +- include/d/snd/d_snd_sound.h | 82 ++++++-- include/nw4r/snd/snd_SoundHandle.h | 9 +- include/nw4r/snd/snd_SoundStartable.h | 2 + include/toBeSorted/music_mgrs.h | 8 +- src/d/snd/d_snd_control_sound.cpp | 2 +- src/d/snd/d_snd_sound.cpp | 291 ++++++++++++++++++++++++-- src/nw4r/snd/snd_AnimSound.cpp | 4 +- 10 files changed, 399 insertions(+), 72 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 4ef4740f..f08cfacf 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2367,6 +2367,7 @@ d/snd/d_snd_3d_engine.cpp: d/snd/d_snd_sound.cpp: .text start:0x8035C3F0 end:0x8035DA88 align:16 + .data start:0x80548730 end:0x80548758 .sdata2 start:0x8057D368 end:0x8057D380 d/snd/d_snd_player_mgr.cpp: diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 143697b6..948f6ada 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -208,7 +208,7 @@ fn_80008A00 = .text:0x80008A00; // type:function size:0x24 fn_80008A30 = .text:0x80008A30; // type:function size:0x1C0 fn_80008BF0 = .text:0x80008BF0; // type:function size:0xE4 fn_80008CE0 = .text:0x80008CE0; // type:function size:0x134 -getSoundArchivePlayer = .text:0x80008E20; // type:function size:0xC +getPlayer__9dSndMgr_cFv = .text:0x80008E20; // type:function size:0xC fn_80008E30 = .text:0x80008E30; // type:function size:0x58 fn_80008E90 = .text:0x80008E90; // type:function size:0x58 fn_80008EF0 = .text:0x80008EF0; // type:function size:0xA4 @@ -19882,42 +19882,42 @@ fn_8035C1C0 = .text:0x8035C1C0; // type:function size:0xDC fn_8035C2A0 = .text:0x8035C2A0; // type:function size:0x110 __dt__14dSnd3DEngine_cFv = .text:0x8035C3B0; // type:function size:0x40 __ct__11dSndSound_cFv = .text:0x8035C3F0; // type:function size:0x2F8 -__ct__32dSndControlSoundSeqTrackVolume_cFv = .text:0x8035C6F0; // type:function size:0x44 -__ct__33dSndControlSoundStrmTrackVolume_cFv = .text:0x8035C740; // type:function size:0x44 -__dt__32dSndControlSoundSeqTrackVolume_cFv = .text:0x8035C790; // type:function size:0x40 -__dt__33dSndControlSoundStrmTrackVolume_cFv = .text:0x8035C7D0; // type:function size:0x40 +__ct__32dSndControlSoundSeqTrackVolume_cFv = .text:0x8035C6F0; // type:function size:0x44 scope:weak +__ct__33dSndControlSoundStrmTrackVolume_cFv = .text:0x8035C740; // type:function size:0x44 scope:weak +__dt__32dSndControlSoundSeqTrackVolume_cFv = .text:0x8035C790; // type:function size:0x40 scope:weak +__dt__33dSndControlSoundStrmTrackVolume_cFv = .text:0x8035C7D0; // type:function size:0x40 scope:weak __dt__11dSndSound_cFv = .text:0x8035C810; // type:function size:0xA0 -fn_8035C8B0 = .text:0x8035C8B0; // type:function size:0x84 -reset__11dSndSound_cFv = .text:0x8035C940; // type:function size:0xE8 -fn_8035CA30 = .text:0x8035CA30; // type:function size:0xD8 -fadeIn__11dSndSound_cFUli = .text:0x8035CB10; // type:function size:0x6C -fn_8035CB80 = .text:0x8035CB80; // type:function size:0xD4 -fn_8035CC60 = .text:0x8035CC60; // type:function size:0xCC +cancel__11dSndSound_cFv = .text:0x8035C8B0; // type:function size:0x84 +resetControls__11dSndSound_cFv = .text:0x8035C940; // type:function size:0xE8 +executeCtrls__11dSndSound_cFv = .text:0x8035CA30; // type:function size:0xD8 +fadeIn__11dSndSound_cFUll = .text:0x8035CB10; // type:function size:0x6C +stop__11dSndSound_cFl = .text:0x8035CB80; // type:function size:0xD4 +pause__11dSndSound_cFbl = .text:0x8035CC60; // type:function size:0xCC isStrmSound__11dSndSound_cFv = .text:0x8035CD30; // type:function size:0x58 isWaveSound__11dSndSound_cFv = .text:0x8035CD90; // type:function size:0x58 isSeqSound__11dSndSound_cFv = .text:0x8035CDF0; // type:function size:0x58 -fn_8035CE50 = .text:0x8035CE50; // type:function size:0x28 -fn_8035CE80 = .text:0x8035CE80; // type:function size:0x28 +linkCtrl__11dSndSound_cFP18dSndControlSound_c = .text:0x8035CE50; // type:function size:0x28 +unlinkCtrl__11dSndSound_cFP18dSndControlSound_c = .text:0x8035CE80; // type:function size:0x28 readSeqTrackVariable__11dSndSound_cFi = .text:0x8035CEB0; // type:function size:0x84 writeSeqTrackVariable__11dSndSound_cFis = .text:0x8035CF40; // type:function size:0x78 -fn_8035CFC0 = .text:0x8035CFC0; // type:function size:0x90 -fn_8035D050 = .text:0x8035D050; // type:function size:0x1C +setControlValue__11dSndSound_cFP18dSndControlSound_cfl = .text:0x8035CFC0; // type:function size:0x90 +setVolume__11dSndSound_cFfl = .text:0x8035D050; // type:function size:0x1C setPitchRelated__11dSndSound_cFfl = .text:0x8035D070; // type:function size:0x1C -fn_8035D090 = .text:0x8035D090; // type:function size:0x1C +setLinearPitch__11dSndSound_cFfl = .text:0x8035D090; // type:function size:0x1C resetTrackVolumes__11dSndSound_cFv = .text:0x8035D0B0; // type:function size:0xE8 -fn_8035D1A0 = .text:0x8035D1A0; // type:function size:0x114 -fn_8035D2C0 = .text:0x8035D2C0; // type:function size:0xC0 -fn_8035D380 = .text:0x8035D380; // type:function size:0xA0 -fn_8035D420 = .text:0x8035D420; // type:function size:0xA0 -fn_8035D4C0 = .text:0x8035D4C0; // type:function size:0xB8 -fn_8035D580 = .text:0x8035D580; // type:function size:0xB8 -fn_8035D640 = .text:0x8035D640; // type:function size:0x24 -fn_8035D670 = .text:0x8035D670; // type:function size:0x60 +setTrackVolume__11dSndSound_cFUlfl = .text:0x8035D1A0; // type:function size:0x114 +setStrmTrackVolume__11dSndSound_cFUlfl = .text:0x8035D2C0; // type:function size:0xC0 +setSingleSeqTrackVolume__11dSndSound_cFUsfl = .text:0x8035D380; // type:function size:0xA0 +setSingleStrmTrackVolume__11dSndSound_cFUsfl = .text:0x8035D420; // type:function size:0xA0 +setEachSeqTrackVolume__11dSndSound_cFUlf = .text:0x8035D4C0; // type:function size:0xB8 +setEachStrmTrackVolume__11dSndSound_cFUlf = .text:0x8035D580; // type:function size:0xB8 +getCurrentStrmTrackVolume__11dSndSound_cCFUl = .text:0x8035D640; // type:function size:0x24 +setSeqTempoRatio__11dSndSound_cFfl = .text:0x8035D670; // type:function size:0x60 setSeqTrackMute__11dSndSound_cFUlQ34nw4r3snd7SeqMute = .text:0x8035D6D0; // type:function size:0x78 -fn_8035D750 = .text:0x8035D750; // type:function size:0x1E8 -fn_8035D940 = .text:0x8035D940; // type:function size:0x58 -fn_8035D9A0 = .text:0x8035D9A0; // type:function size:0x68 -stop__11dSndSound_cFv = .text:0x8035DA10; // type:function size:0x4C +prepareSound__11dSndSound_cFUlUl = .text:0x8035D750; // type:function size:0x1E8 +prepareSound__11dSndSound_cFPCcUl = .text:0x8035D940; // type:function size:0x58 +onPreparing__11dSndSound_cFUlUl = .text:0x8035D9A0; // type:function size:0x68 +forceStop__11dSndSound_cFv = .text:0x8035DA10; // type:function size:0x4C configure__13dSndControl_cFfff = .text:0x8035DA60; // type:function size:0x28 getSoundArchivePath__15dSndPlayerMgr_cFv = .text:0x8035DA90; // type:function size:0xC __dt__33SndMgrDisposer<15dSndPlayerMgr_c>Fv = .text:0x8035DAA0; // type:function size:0x78 @@ -20390,7 +20390,7 @@ apply__23dSndControlSoundPitch_cFP11dSndSound_c = .text:0x8036C230; // type:func __ct__29dSndControlSoundPitchLinear_cFv = .text:0x8036C250; // type:function size:0x48 set__29dSndControlSoundPitchLinear_cFfl = .text:0x8036C2A0; // type:function size:0x70 apply__29dSndControlSoundPitchLinear_cFP11dSndSound_c = .text:0x8036C310; // type:function size:0x3C -apply__36dSndControlSoundSeqTrackTempoRatio_cFP11dSndSound_c = .text:0x8036C350; // type:function size:0x4C +apply__31dSndControlSoundSeqTempoRatio_cFP11dSndSound_c = .text:0x8036C350; // type:function size:0x4C apply__32dSndControlSoundSeqTrackVolume_cFP11dSndSound_c = .text:0x8036C3A0; // type:function size:0x50 apply__33dSndControlSoundStrmTrackVolume_cFP11dSndSound_c = .text:0x8036C3F0; // type:function size:0x54 __ct__29dSndControlPlayerVolumeBase_cFv = .text:0x8036C450; // type:function size:0x48 @@ -37698,7 +37698,7 @@ lbl_80548B38 = .data:0x80548B38; // type:object size:0x10 lbl_80548B48 = .data:0x80548B48; // type:object size:0x30 __vt__33dSndControlSoundStrmTrackVolume_c = .data:0x80548B78; // type:object size:0x20 __vt__32dSndControlSoundSeqTrackVolume_c = .data:0x80548B98; // type:object size:0x20 -__vt__36dSndControlSoundSeqTrackTempoRatio_c = .data:0x80548BB8; // type:object size:0x20 +__vt__31dSndControlSoundSeqTempoRatio_c = .data:0x80548BB8; // type:object size:0x20 __vt__29dSndControlSoundPitchLinear_c = .data:0x80548BD8; // type:object size:0x20 __vt__23dSndControlSoundPitch_c = .data:0x80548BF8; // type:object size:0x20 __vt__24dSndControlSoundVolume_c = .data:0x80548C18; // type:object size:0x20 @@ -48372,11 +48372,11 @@ lbl_8057D358 = .sdata2:0x8057D358; // type:object size:0x4 align:4 data:float lbl_8057D35C = .sdata2:0x8057D35C; // type:object size:0x4 align:4 data:float lbl_8057D360 = .sdata2:0x8057D360; // type:object size:0x4 align:4 data:float lbl_8057D364 = .sdata2:0x8057D364; // type:object size:0x4 align:4 data:float -lbl_8057D368 = .sdata2:0x8057D368; // type:object size:0x4 align:4 data:float -lbl_8057D36C = .sdata2:0x8057D36C; // type:object size:0x4 align:4 data:float -lbl_8057D370 = .sdata2:0x8057D370; // type:object size:0x4 align:4 data:float -lbl_8057D374 = .sdata2:0x8057D374; // type:object size:0x4 align:4 data:float -lbl_8057D378 = .sdata2:0x8057D378; // type:object size:0x4 align:4 data:float +@7826 = .sdata2:0x8057D368; // type:object size:0x4 scope:local align:4 data:float +@7827 = .sdata2:0x8057D36C; // type:object size:0x4 scope:local align:4 data:float +@7828 = .sdata2:0x8057D370; // type:object size:0x4 scope:local align:4 data:float +@7829 = .sdata2:0x8057D374; // type:object size:0x4 scope:local align:4 data:float +@7830 = .sdata2:0x8057D378; // type:object size:0x4 scope:local align:4 data:float lbl_8057D380 = .sdata2:0x8057D380; // type:object size:0x4 align:4 data:float lbl_8057D384 = .sdata2:0x8057D384; // type:object size:0x4 align:4 data:float lbl_8057D388 = .sdata2:0x8057D388; // type:object size:0x4 align:4 data:float diff --git a/configure.py b/configure.py index ec055e44..7c231437 100644 --- a/configure.py +++ b/configure.py @@ -706,7 +706,7 @@ config.libs = [ Object(Matching, "d/snd/d_snd_actor.cpp"), Object(NonMatching, "d/snd/d_snd_3d_actor.cpp"), Object(NonMatching, "d/snd/d_snd_3d_engine.cpp"), - Object(NonMatching, "d/snd/d_snd_sound.cpp"), + Object(Matching, "d/snd/d_snd_sound.cpp"), Object(NonMatching, "d/snd/d_snd_player_mgr.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk1.cpp"), Object(Matching, "d/snd/d_snd_3d_manager.cpp"), diff --git a/include/d/snd/d_snd_sound.h b/include/d/snd/d_snd_sound.h index 3f4f9fd9..da12e39e 100644 --- a/include/d/snd/d_snd_sound.h +++ b/include/d/snd/d_snd_sound.h @@ -4,6 +4,7 @@ #include "common.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; @@ -42,6 +43,10 @@ public: return mCurrValue; } + bool isFinished() const { + return mTimer >= mDuration; + } + protected: /* 0x04 */ f32 mResetValue; /* 0x08 */ f32 mMax; @@ -90,9 +95,9 @@ private: /* 0x30 */ dSndControlSound_c *mpOtherControl; }; -class dSndControlSoundSeqTrackTempoRatio_c : public dSndControlSound_c { +class dSndControlSoundSeqTempoRatio_c : public dSndControlSound_c { public: - dSndControlSoundSeqTrackTempoRatio_c() : dSndControlSound_c(1.0f, 0.25f, 4.0f) {} + dSndControlSoundSeqTempoRatio_c() : dSndControlSound_c(1.0f, 0.25f, 4.0f) {} virtual void apply(dSndSound_c *pHandle) override; }; @@ -127,18 +132,36 @@ public: dSndSound_c(); ~dSndSound_c(); - virtual void vt_0x08(); // 0x08 - virtual void vt_0x0C(); // 0x0C - virtual void fadeIn(u32 id, int fadeFrames); // 0x10 + virtual void cancel(); // 0x08 + virtual void executeCtrls(); // 0x0C + virtual void fadeIn(u32 id, s32 fadeFrames); // 0x10 + virtual nw4r::snd::SoundStartable::StartResult prepareSound(u32 soundId, u32 startOffset); // 0x14 + virtual nw4r::snd::SoundStartable::StartResult prepareSound(const char *label, u32 startOffset); // 0x18 + virtual void onPreparing(u32 soundId, u32 startOffset); // 0x1C + virtual void stop(s32 fadeFrames); // 0x20 + virtual void pause(bool pauseFlag, s32 fadeFrames); // 0x24 bool isStrmSound(); bool isWaveSound(); bool isSeqSound(); - void setPitchRelated(f32 pitch, s32 frames); + f32 getCurrentStrmTrackVolume(u32 index) const; + void setVolume(f32 volume, s32 frames); + void setPitchRelated(f32 pitch, s32 frames); + void setLinearPitch(f32 pitch, s32 frames); + void setTrackVolume(u32 trackFlags, f32 volume, s32 frames); + void setStrmTrackVolume(u32 trackFlags, f32 volume, s32 frames); + void setSingleSeqTrackVolume(u16 index, f32 volume, s32 frames); + void setSingleStrmTrackVolume(u16 index, f32 volume, s32 frames); + + // why f32 frames? + void setEachSeqTrackVolume(u32 trackFlags, f32 frames); + void setEachStrmTrackVolume(u32 trackFlags, f32 frames); + + void setSeqTempoRatio(f32 ratio, s32 frames); void setSeqTrackMute(u32 trackFlags, nw4r::snd::SeqMute mute); - void stop(); + void forceStop(); s16 readSeqTrackVariable(int varNo); void writeSeqTrackVariable(int varNo, s16 value); @@ -147,22 +170,51 @@ public: void unlinkCtrl(dSndControlSound_c *); private: - void reset(); + bool cannotStart() const { + return mIsRunning && !mIsFadingOut && IsAttachedSound(); + } + + bool isRunning() const { + return mIsRunning && IsAttachedSound(); + } + + bool isPreparing() const { + return mIsPreparing && !mIsRunning; + } + + bool canCancel() const { + return mIsRunning || mIsPreparing || IsAttachedSound(); + } + + bool isPreparingSoundId(u32 soundId) const { + bool ret = mIsPreparing; + if (ret) { + ret = !mIsRunning; + } + if (ret) { + ret = GetId() == soundId; + } + return ret; + } + + void resetControls(); void resetTrackVolumes(); + void setControlValue(dSndControlSound_c *ctrl, f32 value, s32 frames); + /* 0x08 */ u8 _0x08[0x10 - 0x08]; - /* 0x10 */ UNKWORD field_0x10; - /* 0x14 */ u8 field_0x14; - /* 0x15 */ u8 field_0x15; - /* 0x16 */ u8 field_0x16; - /* 0x17 */ u8 field_0x17; + /* 0x10 */ u32 mPrevStartOffset; + /* 0x14 */ bool mIsPreparing; + /* 0x15 */ bool mPauseFlag; + /* 0x16 */ bool mIsRunning; + /* 0x17 */ bool mIsFadingOut; /* 0x18 */ dSndControlSoundVolume_c mCtrlVolume; /* 0x48 */ dSndControlSoundPitch_c mCtrlPitch; - /* 0x78 */ dSndControlSoundPitchLinear_c mCtrlUnk; + /* 0x78 */ dSndControlSoundPitchLinear_c mLinearPitch; /* 0xAC */ dSndControlSoundSeqTrackVolume_c *mpCtrlSeqTrackVolume; /* 0xB0 */ dSndControlSoundStrmTrackVolume_c *mpCtrlStrmTrackVolume; - /* 0xB4 */ dSndControlSoundSeqTrackTempoRatio_c mpCtrlSeqTrackTempoRatio; + /* 0xB4 */ dSndControlSoundSeqTempoRatio_c mpCtrlSeqTempoRatio; /* 0xE4 */ nw4r::ut::List mList; }; diff --git a/include/nw4r/snd/snd_SoundHandle.h b/include/nw4r/snd/snd_SoundHandle.h index e8d1a3c0..5c969c1c 100644 --- a/include/nw4r/snd/snd_SoundHandle.h +++ b/include/nw4r/snd/snd_SoundHandle.h @@ -50,9 +50,14 @@ namespace nw4r { namespace snd mSound->SetPitch(volume); } - void Stop() { + void Stop(int fadeFrames) { if (IsAttachedSound()) - mSound->Stop(0); + mSound->Stop(fadeFrames); + } + + void Pause(bool flag, int fadeFrames) { + if (IsAttachedSound()) + mSound->Pause(flag, fadeFrames); } bool IsPause() const { diff --git a/include/nw4r/snd/snd_SoundStartable.h b/include/nw4r/snd/snd_SoundStartable.h index c672c7f3..86d62ec6 100644 --- a/include/nw4r/snd/snd_SoundStartable.h +++ b/include/nw4r/snd/snd_SoundStartable.h @@ -54,6 +54,7 @@ namespace nw4r { namespace snd // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x27291 struct StartInfo { + StartInfo() : enableFlag(0) {} // enums public: enum EnableFlag @@ -76,6 +77,7 @@ namespace nw4r { namespace snd // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x27208 struct SeqSoundInfo { + SeqSoundInfo() : seqDataAddress(NULL), startLocationLabel(NULL) {} void *seqDataAddress; // size 0x04, offset 0x00 char const *startLocationLabel; // size 0x04, offset 0x04 }; // size 0x08 diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index aad42969..4a38e498 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -5,6 +5,9 @@ #include "d/snd/d_snd_player_mgr.h" class dSndPlayerMgr_c; +class dSndSound_c; + +// A lot of these names are and were guesses that are probably wrong in a lot of ways. #define BGM_MGR (dSndPlayerMgr_c::GetInstance()) extern "C" void fn_8035E000(); @@ -24,7 +27,7 @@ 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_80364D00(void*, s32); +extern "C" void fn_80364D00(void *, s32); extern "C" void *ENEMY_BGM_RELATED_MGR; extern "C" void fn_80384570(void *, bool); @@ -37,5 +40,8 @@ extern "C" bool fn_803720E0(void *, u32); extern "C" bool fn_80372070(void *, u32); extern "C" bool fn_803734C0(void *, u32); extern "C" bool fn_80373550(void *, u32); +extern "C" void fn_80372920(void *); +extern "C" void fn_803738B0(void *, dSndSound_c *sound); +extern "C" void fn_80373900(void *, dSndSound_c *sound); #endif diff --git a/src/d/snd/d_snd_control_sound.cpp b/src/d/snd/d_snd_control_sound.cpp index cdffeaf1..aaef106f 100644 --- a/src/d/snd/d_snd_control_sound.cpp +++ b/src/d/snd/d_snd_control_sound.cpp @@ -84,7 +84,7 @@ void dSndControlSoundPitchLinear_c::apply(dSndSound_c *pHandle) { pHandle->setPitchRelated(pitchScaleForPitchIdxTenths(mCurrValue), 0); } -void dSndControlSoundSeqTrackTempoRatio_c::apply(dSndSound_c *sound) { +void dSndControlSoundSeqTempoRatio_c::apply(dSndSound_c *sound) { nw4r::snd::SeqSoundHandle handle(sound); handle.SetTempoRatio(mCurrValue); } diff --git a/src/d/snd/d_snd_sound.cpp b/src/d/snd/d_snd_sound.cpp index 03d3b20d..aa441136 100644 --- a/src/d/snd/d_snd_sound.cpp +++ b/src/d/snd/d_snd_sound.cpp @@ -2,11 +2,15 @@ #include "common.h" #include "d/snd/d_snd_mgr.h" +#include "d/snd/d_snd_player_mgr.h" #include "nw4r/snd/snd_SeqSoundHandle.h" #include "nw4r/snd/snd_SoundArchive.h" +#include "nw4r/snd/snd_SoundStartable.h" #include "nw4r/ut/ut_list.h" +#include "toBeSorted/music_mgrs.h" -dSndSound_c::dSndSound_c() : field_0x10(0), field_0x14(0), field_0x15(0), field_0x16(0), field_0x17(0) { +dSndSound_c::dSndSound_c() + : mPrevStartOffset(0), mIsPreparing(false), mPauseFlag(false), mIsRunning(false), mIsFadingOut(false) { nw4r::ut::List_Init(&mList, 0x24); mpCtrlSeqTrackVolume = new dSndControlSoundSeqTrackVolume_c[16](); @@ -20,8 +24,8 @@ dSndSound_c::dSndSound_c() : field_0x10(0), field_0x14(0), field_0x15(0), field_ mpCtrlStrmTrackVolume[i].setMask(1 << i); } - mCtrlUnk.setControl(&mCtrlPitch); - reset(); + mLinearPitch.setControl(&mCtrlPitch); + resetControls(); } dSndSound_c::~dSndSound_c() { @@ -33,26 +37,82 @@ dSndSound_c::~dSndSound_c() { } } -void dSndSound_c::reset() { +void dSndSound_c::cancel() { + if (canCancel()) { + resetControls(); + mIsRunning = false; + mIsFadingOut = false; + mIsPreparing = false; + mPrevStartOffset = 0; + fn_80373900(FANFARE_SOUND_MGR, this); + } +} + +void dSndSound_c::resetControls() { mCtrlVolume.reset(); mCtrlVolume.apply(this); mCtrlPitch.reset(); mCtrlPitch.apply(this); - mCtrlUnk.reset(); - mCtrlUnk.apply(this); - mpCtrlSeqTrackTempoRatio.reset(); - mpCtrlSeqTrackTempoRatio.apply(this); - field_0x15 = 0; + mLinearPitch.reset(); + mLinearPitch.apply(this); + mpCtrlSeqTempoRatio.reset(); + mpCtrlSeqTempoRatio.apply(this); + mPauseFlag = 0; resetTrackVolumes(); } -void dSndSound_c::fadeIn(u32 id, int fadeFrames) { +void dSndSound_c::executeCtrls() { + if (mIsRunning && !IsAttachedSound()) { + cancel(); + } + + dSndControlSound_c *next; + dSndControlSound_c *iter = static_cast(nw4r::ut::List_GetNext(&mList, nullptr)); + while (iter != nullptr) { + next = static_cast(nw4r::ut::List_GetNext(&mList, iter)); + iter->calc(); + iter->apply(this); + if (iter->isFinished()) { + unlinkCtrl(iter); + } + iter = next; + } +} + +void dSndSound_c::fadeIn(u32 id, s32 fadeFrames) { if (id != -1) { if (fadeFrames != 0) { FadeIn(fadeFrames); } - vt_0x08(); - field_0x16 = 1; + cancel(); + mIsRunning = true; + } +} + +void dSndSound_c::stop(s32 fadeFrames) { + if (isRunning()) { + Stop(fadeFrames); + + if (fadeFrames != 0) { + mIsFadingOut = true; + } else { + cancel(); + } + } else { + if (!isPreparing()) { + cancel(); + } + } +} + +void dSndSound_c::pause(bool pauseFlag, s32 fadeFrames) { + if (!IsAttachedSound()) { + return; + } + + if ((pauseFlag && !IsPause()) || (!pauseFlag && IsPause())) { + Pause(pauseFlag, fadeFrames); + mPauseFlag = pauseFlag; } } @@ -77,6 +137,28 @@ bool dSndSound_c::isSeqSound() { return dSndMgr_c::GetInstance()->getArchive()->GetSoundType(GetId()) == nw4r::snd::SoundArchive::SOUND_TYPE_SEQ; } +void dSndSound_c::linkCtrl(dSndControlSound_c *ctrl) { + if (ctrl == nullptr) { + return; + } + if (ctrl->isLinked()) { + return; + } + ctrl->setLinked(true); + nw4r::ut::List_Append(&mList, ctrl); +} + +void dSndSound_c::unlinkCtrl(dSndControlSound_c *ctrl) { + if (ctrl == nullptr) { + return; + } + if (!ctrl->isLinked()) { + return; + } + ctrl->setLinked(false); + nw4r::ut::List_Remove(&mList, ctrl); +} + s16 dSndSound_c::readSeqTrackVariable(int varNo) { if (!isSeqSound()) { return -1; @@ -95,6 +177,36 @@ void dSndSound_c::writeSeqTrackVariable(int varNo, s16 value) { handle.WriteVariable(varNo, value); } +void dSndSound_c::setControlValue(dSndControlSound_c *ctrl, f32 value, s32 frames) { + ctrl->set(value, frames); + + if (ctrl->isFinished()) { + unlinkCtrl(ctrl); + } else { + linkCtrl(ctrl); + } + + ctrl->apply(this); +} + +void dSndSound_c::setVolume(f32 volume, s32 frames) { + if (IsAttachedSound()) { + setControlValue(&mCtrlVolume, volume, frames); + } +} + +void dSndSound_c::setPitchRelated(f32 pitch, s32 frames) { + if (IsAttachedSound()) { + setControlValue(&mCtrlPitch, pitch, frames); + } +} + +void dSndSound_c::setLinearPitch(f32 pitch, s32 frames) { + if (IsAttachedSound()) { + setControlValue(&mLinearPitch, pitch, frames); + } +} + void dSndSound_c::resetTrackVolumes() { if (mpCtrlSeqTrackVolume != nullptr) { for (int i = 0; i < 16; i++) { @@ -111,6 +223,99 @@ void dSndSound_c::resetTrackVolumes() { } } +void dSndSound_c::setTrackVolume(u32 trackFlags, f32 volume, s32 frames) { + if (trackFlags != 0 && IsAttachedSound()) { + switch (dSndMgr_c::GetInstance()->getArchive()->GetSoundType(GetId())) { + case nw4r::snd::SoundArchive::SOUND_TYPE_SEQ: { + for (int i = 0; i < 16; i++) { + if ((trackFlags & (u16)(1 << i)) != 0) { + setControlValue(&mpCtrlSeqTrackVolume[i], volume, frames); + } + } + break; + } + case nw4r::snd::SoundArchive::SOUND_TYPE_STRM: { + for (int i = 0; i < 3; i++) { + if ((trackFlags & (u16)(1 << i)) != 0) { + setControlValue(&mpCtrlStrmTrackVolume[i], volume, frames); + } + } + } + default: break; + } + } +} + +void dSndSound_c::setStrmTrackVolume(u32 trackFlags, f32 volume, s32 frames) { + if (trackFlags != 0 && IsAttachedSound()) { + switch (dSndMgr_c::GetInstance()->getArchive()->GetSoundType(GetId())) { + case nw4r::snd::SoundArchive::SOUND_TYPE_STRM: { + for (int i = 0; i < 3; i++) { + if ((trackFlags & (u16)(1 << i)) != 0) { + setControlValue(&mpCtrlStrmTrackVolume[i], volume, frames); + } + } + } + default: break; + } + } +} + +void dSndSound_c::setSingleSeqTrackVolume(u16 index, f32 volume, s32 frames) { + if (IsAttachedSound() && index < 16) { + switch (dSndMgr_c::GetInstance()->getArchive()->GetSoundType(GetId())) { + case nw4r::snd::SoundArchive::SOUND_TYPE_SEQ: { + setControlValue(&mpCtrlSeqTrackVolume[index], volume, frames); + } + default: break; + } + } +} + +void dSndSound_c::setSingleStrmTrackVolume(u16 index, f32 volume, s32 frames) { + if (IsAttachedSound() && index < 3) { + switch (dSndMgr_c::GetInstance()->getArchive()->GetSoundType(GetId())) { + case nw4r::snd::SoundArchive::SOUND_TYPE_STRM: { + setControlValue(&mpCtrlStrmTrackVolume[index], volume, frames); + } + default: break; + } + } +} + +void dSndSound_c::setEachSeqTrackVolume(u32 trackFlags, f32 frames) { + for (int i = 0; i < 16; i++) { + if ((trackFlags & (u16)(1 << i)) != 0) { + setSingleSeqTrackVolume(i, 1.0f, (u32)frames); + } else { + setSingleSeqTrackVolume(i, 0.0f, (u32)frames); + } + } +} + +void dSndSound_c::setEachStrmTrackVolume(u32 trackFlags, f32 frames) { + for (int i = 0; i < 3; i++) { + if ((trackFlags & (u16)(1 << i)) != 0) { + setSingleStrmTrackVolume(i, 1.0f, (u32)frames); + } else { + setSingleStrmTrackVolume(i, 0.0f, (u32)frames); + } + } +} + +f32 dSndSound_c::getCurrentStrmTrackVolume(u32 index) const { + if (index >= 3) { + return 0.0f; + } + return mpCtrlStrmTrackVolume[index].getCurrentValue(); +} + +void dSndSound_c::setSeqTempoRatio(f32 ratio, s32 frames) { + if (isSeqSound()) { + setControlValue(&mpCtrlSeqTempoRatio, ratio, frames); + } +} + void dSndSound_c::setSeqTrackMute(u32 trackFlags, nw4r::snd::SeqMute mute) { if (isSeqSound()) { nw4r::snd::SeqSoundHandle handle(this); @@ -118,9 +323,65 @@ void dSndSound_c::setSeqTrackMute(u32 trackFlags, nw4r::snd::SeqMute mute) { } } -void dSndSound_c::stop() { - vt_0x08(); - Stop(); +nw4r::snd::SoundStartable::StartResult dSndSound_c::prepareSound(u32 soundId, u32 startOffset) { + if (soundId == -1) { + return nw4r::snd::SoundStartable::START_ERR_USER; + } + + if (cannotStart()) { + return nw4r::snd::SoundStartable::START_ERR_USER; + } + + if (isPreparingSoundId(soundId)) { + if (mPrevStartOffset == startOffset) { + return nw4r::snd::SoundStartable::START_ERR_USER; + } + forceStop(); + } else { + if (isPreparing()) { + forceStop(); + } else { + fn_80372920(FANFARE_SOUND_MGR); + } + } + + nw4r::snd::SoundStartable::StartResult res; + if (startOffset == 0) { + res = dSndMgr_c::GetInstance()->getPlayer()->detail_PrepareSound(this, soundId, nullptr); + } else { + nw4r::snd::SoundStartable::StartInfo info; + info.enableFlag |= nw4r::snd::SoundStartable::StartInfo::ENABLE_START_OFFSET; + info.startOffsetType = nw4r::snd::SoundStartable::StartInfo::START_OFFSET_TYPE_MILLISEC; + info.startOffset = startOffset; + res = dSndMgr_c::GetInstance()->getPlayer()->detail_PrepareSound(this, soundId, &info); + } + + if (res == nw4r::snd::SoundStartable::START_SUCCESS) { + onPreparing(soundId, startOffset); + } else { + cancel(); + } + + return res; +} + +nw4r::snd::SoundStartable::StartResult dSndSound_c::prepareSound(const char *label, u32 startOffset) { + u32 id = dSndPlayerMgr_c::GetInstance()->convertLabelStringToSoundId(label); + return prepareSound(id, startOffset); +} + +void dSndSound_c::onPreparing(u32 soundId, u32 startOffset) { + if (soundId != -1) { + cancel(); + mPrevStartOffset = startOffset; + mIsPreparing = true; + fn_803738B0(FANFARE_SOUND_MGR, this); + } +} + +void dSndSound_c::forceStop() { + cancel(); + Stop(0); } // Might be a separate file diff --git a/src/nw4r/snd/snd_AnimSound.cpp b/src/nw4r/snd/snd_AnimSound.cpp index 0ba0b144..91f80368 100644 --- a/src/nw4r/snd/snd_AnimSound.cpp +++ b/src/nw4r/snd/snd_AnimSound.cpp @@ -48,7 +48,7 @@ void AnimSoundImpl::Shutdown() { if (mIsActive) { for (int i = 0; i < mNumSounds; i++) { if (mpSounds[i].GetHandle()->IsAttachedSound() && mpSounds[i].IsRunning()) { - mpSounds[i].GetHandle()->Stop(); + mpSounds[i].GetHandle()->Stop(0); } } @@ -437,7 +437,7 @@ AnimEventPlayer::AnimEventPlayer() : mpEvent(NULL), mIsRunning(false) {} AnimEventPlayer::~AnimEventPlayer() { if (mHandle.IsAttachedSound() && IsRunning()) { - mHandle.Stop(); + mHandle.Stop(0); } } From df1b69b9544e7640023d140e861609e45c3bade8 Mon Sep 17 00:00:00 2001 From: robojumper Date: Mon, 2 Jun 2025 21:24:00 +0200 Subject: [PATCH 05/22] A bit more --- config/SOUE01/splits.txt | 8 ++++- config/SOUE01/symbols.txt | 12 +++---- configure.py | 2 ++ include/d/snd/d_snd_3d_actor.h | 12 +++++-- include/d/snd/d_snd_3d_manager.h | 8 +++++ include/toBeSorted/music_mgrs.h | 1 - src/d/snd/d_snd_3d_actor.cpp | 62 ++++++++++++++++++++++++++++++-- 7 files changed, 92 insertions(+), 13 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index f08cfacf..020d2582 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2407,7 +2407,13 @@ d/snd/mgr/d_snd_mgr_effect.cpp: .text start:0x8036C6B0 end:0x8037F8B4 align:16 d/snd/mgr/d_snd_mgr_unk_5.cpp: - .text start:0x8037F8C0 end:0x803864C8 align:16 + .text start:0x8037F8C0 end:0x80382150 align:16 + +d/snd/d_snd_anim_sound.cpp: + .text start:0x80382150 end:0x8038240C align:16 + +d/snd/mgr/d_snd_mgr_unk_14.cpp: + .text start:0x80382410 end:0x803864C8 align:16 .ctors start:0x804DB91C end:0x804DB920 d/snd/mgr/d_snd_mgr_unk_13.cpp: diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 948f6ada..dd464e13 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -19840,16 +19840,16 @@ __cl__22SoundPropertiesCheckerFRQ34nw4r3snd11SoundHandle = .text:0x8035A600; // __dt__11dSndActor_cFv = .text:0x8035A840; // type:function size:0x58 scope:weak __ct__13dSnd3DActor_cFPvUc = .text:0x8035A8A0; // type:function size:0xE8 d_vt_0x34__13dSnd3DActor_cFRCQ34nw4r4math4VEC3 = .text:0x8035A990; // type:function size:0x40 -fn_8035A9D0 = .text:0x8035A9D0; // type:function size:0x2C +resetCachedRelativePositions__13dSnd3DActor_cFv = .text:0x8035A9D0; // type:function size:0x2C fn_8035AA00 = .text:0x8035AA00; // type:function size:0x30 updatePositionRelativeToListener__13dSnd3DActor_cFv = .text:0x8035AA30; // type:function size:0x44 calculatePositionRelativeToListener__13dSnd3DActor_cFv = .text:0x8035AA80; // type:function size:0x28 updateDistanceToListener__13dSnd3DActor_cFv = .text:0x8035AAB0; // type:function size:0x50 -fn_8035AB00 = .text:0x8035AB00; // type:function size:0x54 -fn_8035AB60 = .text:0x8035AB60; // type:function size:0x78 -fn_8035ABE0 = .text:0x8035ABE0; // type:function size:0x44 -fn_8035AC30 = .text:0x8035AC30; // type:function size:0x28 -fn_8035AC60 = .text:0x8035AC60; // type:function size:0x50 +updatePositionTransformedByListener__13dSnd3DActor_cFv = .text:0x8035AB00; // type:function size:0x54 +updateCameraDirectionDot__13dSnd3DActor_cFv = .text:0x8035AB60; // type:function size:0x78 +updatePositionRelativeToCameraTarget__13dSnd3DActor_cFv = .text:0x8035ABE0; // type:function size:0x44 +calculatePositionRelativeToCameraTarget__13dSnd3DActor_cFv = .text:0x8035AC30; // type:function size:0x28 +updateDistanceToCameraTarget__13dSnd3DActor_cFv = .text:0x8035AC60; // type:function size:0x50 updatePositionRelativeToPlayer__13dSnd3DActor_cFv = .text:0x8035ACB0; // type:function size:0xBC getPositionRelativeToPlayer__13dSnd3DActor_cFv = .text:0x8035AD70; // type:function size:0x3C updateDistanceToPlayer__13dSnd3DActor_cFv = .text:0x8035ADB0; // type:function size:0xFC diff --git a/configure.py b/configure.py index 7c231437..ed3cbdfc 100644 --- a/configure.py +++ b/configure.py @@ -717,6 +717,8 @@ config.libs = [ Object(Matching, "d/snd/d_snd_control_player.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_effect.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_5.cpp"), + Object(NonMatching, "d/snd/d_snd_anim_sound.cpp"), + Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_14.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_13.cpp"), Object(NonMatching, "d/snd/d_snd_source.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_7.cpp"), diff --git a/include/d/snd/d_snd_3d_actor.h b/include/d/snd/d_snd_3d_actor.h index 5136d7be..dd33d42d 100644 --- a/include/d/snd/d_snd_3d_actor.h +++ b/include/d/snd/d_snd_3d_actor.h @@ -41,6 +41,13 @@ public: virtual void d_vt_0x58() = 0; virtual void d_vt_0x5C() = 0; + void resetCachedRelativePositions(); + + void updatePositionTransformedByListener(); + void updateCameraDirectionDot(); + void updatePositionRelativeToCameraTarget(); + void calculatePositionRelativeToCameraTarget(); + void updateDistanceToCameraTarget(); void calculatePositionRelativeToListener(); void updatePositionRelativeToListener(); void updateDistanceToListener(); @@ -72,11 +79,12 @@ protected: /* 0x8C */ f32 a_field_0x8C; /* 0x90 */ f32 a_field_0x90; /* 0x94 */ f32 mDistanceToListener; - /* 0x98 */ f32 a_field_0x98; + /* 0x98 */ f32 mCameraDirectionDot; /* 0x9C */ f32 a_field_0x9C; /* 0xA0 */ nw4r::math::VEC3 mPositionRelativeToListener; /* 0xAC */ nw4r::math::VEC3 mPositionTransformedByListener; - /* 0xB8 */ u8 a_0xB8[0xC8 - 0xB8]; + /* 0xB8 */ f32 mDistanceToCameraTarget; + /* 0xBC */ nw4r::math::VEC3 mPositionRelativeToCameraTarget; /* 0xC8 */ UNKTYPE *a_field_0xC8; /* 0xCC */ u16 mFlags; /* 0xD0 */ nw4r::math::VEC3 mPositionRelativeToPlayer; diff --git a/include/d/snd/d_snd_3d_manager.h b/include/d/snd/d_snd_3d_manager.h index eb09988b..09b127fb 100644 --- a/include/d/snd/d_snd_3d_manager.h +++ b/include/d/snd/d_snd_3d_manager.h @@ -46,10 +46,18 @@ public: return mCameraTargetPosition; } + const mVec3_c &getNrmCameraDirection() const { + return mCameraDirectionNormalized; + } + const nw4r::math::VEC3 &getSndListenerPos() const { return mListener.GetPosition(); } + const nw4r::math::MTX34 &getSndListenerMatrix() const { + return mListener.GetMatrix(); + } + private: void updateListenerPos(f32); diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index 4a38e498..b394ceaa 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -16,7 +16,6 @@ extern "C" void fn_8035E310(dSndPlayerMgr_c *); extern "C" void fn_8035E820(dSndPlayerMgr_c *); extern "C" void fn_8035E880(dSndPlayerMgr_c *); extern "C" void fn_8035E790(dSndPlayerMgr_c *, UNKWORD, void *); -extern "C" bool fn_8035ED90(dSndPlayerMgr_c *, u8); extern "C" void *ENEMY_SOUND_MGR; extern "C" void fn_80362150(void *, u16); diff --git a/src/d/snd/d_snd_3d_actor.cpp b/src/d/snd/d_snd_3d_actor.cpp index b96ad650..3ece873a 100644 --- a/src/d/snd/d_snd_3d_actor.cpp +++ b/src/d/snd/d_snd_3d_actor.cpp @@ -3,8 +3,8 @@ #include "common.h" #include "d/a/d_a_player.h" #include "d/snd/d_snd_3d_manager.h" +#include "d/snd/d_snd_player_mgr.h" #include "nw4r/math/math_types.h" -#include "toBeSorted/music_mgrs.h" #include @@ -21,7 +21,7 @@ dSnd3DActor_c::dSnd3DActor_c(UNKTYPE *a1, u8 a2) a_field_0x8C(0.0f), a_field_0x90(INFINITY), mDistanceToListener(INFINITY), - a_field_0x98(0.0f), + mCameraDirectionDot(0.0f), a_field_0x9C(0.0f), a_field_0xC8(a1), mFlags(0), @@ -30,7 +30,7 @@ dSnd3DActor_c::dSnd3DActor_c(UNKTYPE *a1, u8 a2) resetFloats(); // Portability hazard SetUserParam(reinterpret_cast(this)); - if (fn_8035ED90(BGM_MGR, a2)) { + if (dSndPlayerMgr_c::GetInstance()->canUseThisPlayer(a2)) { a_field_0x7F = 1; } } @@ -48,6 +48,20 @@ void dSnd3DActor_c::updatePositionRelativeToListener() { } } +void dSnd3DActor_c::resetCachedRelativePositions() { + mPositionRelativeToPlayer.x = INFINITY; + mPositionRelativeToPlayer.y = INFINITY; + mPositionRelativeToPlayer.z = INFINITY; + + mPositionRelativeToListener.x = INFINITY; + mPositionRelativeToListener.y = INFINITY; + mPositionRelativeToListener.z = INFINITY; + + mPositionTransformedByListener.x = INFINITY; + mPositionTransformedByListener.y = INFINITY; + mPositionTransformedByListener.z = INFINITY; +} + void dSnd3DActor_c::calculatePositionRelativeToListener() { nw4r::math::VEC3Sub( &mPositionRelativeToListener, &GetPosition(), &dSnd3DManager_c::GetInstance()->getSndListenerPos() @@ -62,6 +76,46 @@ void dSnd3DActor_c::updateDistanceToListener() { } } +void dSnd3DActor_c::updatePositionTransformedByListener() { + if (!checkFlag(0x10)) { + MTXMultVec( + dSnd3DManager_c::GetInstance()->getSndListenerMatrix(), GetPosition(), mPositionTransformedByListener + ); + setFlag(0x10); + } +} + +void dSnd3DActor_c::updateCameraDirectionDot() { + if (!checkFlag(0x20)) { + updatePositionRelativeToListener(); + nw4r::math::VEC3 norm; + VECNormalize(mPositionRelativeToListener, norm); + mCameraDirectionDot = nw4r::math::VEC3Dot(&norm, dSnd3DManager_c::GetInstance()->getNrmCameraDirection()); + setFlag(0x20); + } +} + +void dSnd3DActor_c::updatePositionRelativeToCameraTarget() { + if (!checkFlag(0x4)) { + calculatePositionRelativeToCameraTarget(); + setFlag(0x4); + } +} + +void dSnd3DActor_c::calculatePositionRelativeToCameraTarget() { + nw4r::math::VEC3Sub( + &mPositionRelativeToCameraTarget, &GetPosition(), dSnd3DManager_c::GetInstance()->getCameraTargetPos() + ); +} + +void dSnd3DActor_c::updateDistanceToCameraTarget() { + if (!checkFlag(8)) { + updatePositionRelativeToCameraTarget(); + mDistanceToCameraTarget = VEC3Len(&mPositionRelativeToCameraTarget); + setFlag(8); + } +} + void dSnd3DActor_c::updatePositionRelativeToPlayer() { if (!checkFlag(0x40)) { nw4r::math::VEC3 linkTranslation = dAcPy_c::GetLink()->getCenterTranslation(); @@ -98,6 +152,8 @@ f32 dSnd3DActor_c::getDistanceToPlayer() { return mDistanceToPlayer; } +// here are functions that are probably in part copied from nw4r::snd::Sound3DCalculator + bool dSnd3DActor_c::hasPlayingSounds() const { for (int i = 0; i < ACTOR_PLAYER_COUNT; i++) { if (GetPlayingSoundCount(i) > 0) { From 0cf6b64538c34cbbb1fe582421487ffd2b842f24 Mon Sep 17 00:00:00 2001 From: robojumper Date: Tue, 3 Jun 2025 00:39:44 +0200 Subject: [PATCH 06/22] Small docs --- include/d/snd/d_snd_mgr.h | 1 + include/d/snd/d_snd_player_mgr.h | 4 ++++ include/d/snd/d_snd_source.h | 5 ++++- include/d/snd/d_snd_source_if.h | 1 + include/toBeSorted/music_mgrs.h | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/d/snd/d_snd_mgr.h b/include/d/snd/d_snd_mgr.h index d5606784..305e96ea 100644 --- a/include/d/snd/d_snd_mgr.h +++ b/include/d/snd/d_snd_mgr.h @@ -4,6 +4,7 @@ #include "egg/audio/eggAudioMgr.h" #include "nw4r/snd/snd_SoundArchivePlayer.h" +/** The core audio manager used for most sounds. */ class dSndMgr_c : public EGG::SimpleAudioMgr { public: dSndMgr_c(); diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h index 26026b10..f80a07af 100644 --- a/include/d/snd/d_snd_player_mgr.h +++ b/include/d/snd/d_snd_player_mgr.h @@ -10,6 +10,10 @@ class dSndPlayerMgr_c; extern template class SndMgrDisposer; +/** + * The main interface for managing sound stuff. Will delegate to dSndMgr_c for + * most things, but handles demo (cutscene) sound effects (SE_DEMO*) by itself. + */ class dSndPlayerMgr_c { public: SndMgrDisposer *GetDisposer() { diff --git a/include/d/snd/d_snd_source.h b/include/d/snd/d_snd_source.h index 64a3eaad..d732e924 100644 --- a/include/d/snd/d_snd_source.h +++ b/include/d/snd/d_snd_source.h @@ -6,6 +6,7 @@ #include "d/snd/d_snd_source_if.h" #include "nw4r/ut/ut_list.h" +/** Manages sound relating to a particular actor. */ class dSoundSource_c : public dSoundSourceIf_c, public dSnd3DActor_c { public: dSoundSource_c(u8, dAcBase_c *, UNKWORD, UNKWORD); @@ -52,7 +53,9 @@ public: virtual void d_s_vt_0x1E4(); virtual void d_s_vt_0x1E8(); - // Overrides of dSoundSourceIf_c + // Overrides of dSoundSourceIf_c - always in the first section of + // the vtable, so the order is not certain. May have to reorder for weak + // function order. virtual const nw4r::math::VEC3 &getListenerPosition() const override; diff --git a/include/d/snd/d_snd_source_if.h b/include/d/snd/d_snd_source_if.h index 32973df0..8a77ff67 100644 --- a/include/d/snd/d_snd_source_if.h +++ b/include/d/snd/d_snd_source_if.h @@ -6,6 +6,7 @@ class dAcBase_c; +/** An abstract interface for sound relating to a particular actor. */ class dSoundSourceIf_c { public: virtual ~dSoundSourceIf_c() {} diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index b394ceaa..fd498ac8 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -28,6 +28,7 @@ extern "C" void fn_80364FD0(void *, s32); extern "C" bool fn_80364DA0(void *); extern "C" void fn_80364D00(void *, s32); +// ENEMY_BGM_RELATED_MGR -> dSndSourceMgr_c extern "C" void *ENEMY_BGM_RELATED_MGR; extern "C" void fn_80384570(void *, bool); extern "C" void fn_803858D0(void *); From 4e75ae59f58a4a43725ddae83325f21a7e89b142 Mon Sep 17 00:00:00 2001 From: robojumper Date: Tue, 3 Jun 2025 23:28:57 +0200 Subject: [PATCH 07/22] More player control --- config/SOUE01/splits.txt | 10 ++- config/SOUE01/symbols.txt | 50 +++++------ configure.py | 4 +- include/d/snd/d_snd_actor.h | 4 +- include/d/snd/d_snd_checkers.h | 53 +++++++++++- include/d/snd/d_snd_control_player.h | 2 +- include/d/snd/d_snd_control_player_mgr.h | 68 +++++++++++++++ include/d/snd/d_snd_sound.h | 4 + src/d/snd/d_snd_actor.cpp | 60 +------------ src/d/snd/d_snd_control_player.cpp | 9 +- src/d/snd/d_snd_control_player_mgr.cpp | 104 +++++++++++++++++++++++ src/d/snd/d_snd_mgr.cpp | 4 +- 12 files changed, 273 insertions(+), 99 deletions(-) create mode 100644 include/d/snd/d_snd_control_player_mgr.h create mode 100644 src/d/snd/d_snd_control_player_mgr.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 020d2582..642fbb94 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2371,12 +2371,14 @@ d/snd/d_snd_sound.cpp: .sdata2 start:0x8057D368 end:0x8057D380 d/snd/d_snd_player_mgr.cpp: - .text start:0x8035DA90 end:0x8035F010 align:16 + .text start:0x8035DA90 end:0x8035F04C align:16 .data start:0x80548758 end:0x805487A0 -d/snd/mgr/d_snd_mgr_unk1.cpp: - .text start:0x8035F010 end:0x80360C28 align:16 +d/snd/d_snd_control_player_mgr.cpp: + .text start:0x8035F050 end:0x80360C28 align:16 .ctors start:0x804DB914 end:0x804DB918 + .sbss start:0x80575D40 end:0x80575D58 + .sdata2 start:0x8057D390 end:0x8057D3B8 d/snd/d_snd_3d_manager.cpp: .text start:0x80360C30 end:0x8036145C align:16 @@ -2406,7 +2408,7 @@ d/snd/d_snd_control_player.cpp: d/snd/mgr/d_snd_mgr_effect.cpp: .text start:0x8036C6B0 end:0x8037F8B4 align:16 -d/snd/mgr/d_snd_mgr_unk_5.cpp: +d/snd/d_snd_harp_mgr.cpp: .text start:0x8037F8C0 end:0x80382150 align:16 d/snd/d_snd_anim_sound.cpp: diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index dd464e13..fbd272c6 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -19984,42 +19984,42 @@ calc__15dSndPlayerMgr_cFv = .text:0x8035EFD0; // type:function size:0x40 fn_8035F010 = .text:0x8035F010; // type:function size:0x20 fn_8035F030 = .text:0x8035F030; // type:function size:0x1C fn_8035F050 = .text:0x8035F050; // type:function size:0x50 -fn_8035F0A0 = .text:0x8035F0A0; // type:function size:0x78 -fn_8035F120 = .text:0x8035F120; // type:function size:0x48 -fn_8035F170 = .text:0x8035F170; // type:function size:0x10 -fn_8035F180 = .text:0x8035F180; // type:function size:0x114 -fn_8035F2A0 = .text:0x8035F2A0; // type:function size:0x40 -fn_8035F2E0 = .text:0x8035F2E0; // type:function size:0x40 -fn_8035F320 = .text:0x8035F320; // type:function size:0x3C -fn_8035F360 = .text:0x8035F360; // type:function size:0x40 -fn_8035F3A0 = .text:0x8035F3A0; // type:function size:0x40 -fn_8035F3E0 = .text:0x8035F3E0; // type:function size:0x40 +__dt__40SndMgrDisposer<22dSndControlPlayerMgr_c>Fv = .text:0x8035F0A0; // type:function size:0x78 +create__40SndMgrDisposer<22dSndControlPlayerMgr_c>Fv = .text:0x8035F120; // type:function size:0x48 +remove__40SndMgrDisposer<22dSndControlPlayerMgr_c>Fv = .text:0x8035F170; // type:function size:0x10 +__ct__22dSndControlPlayerMgr_cFv = .text:0x8035F180; // type:function size:0x114 +__ct__26dSndControlPlayerLpfFreq_cFv = .text:0x8035F2A0; // type:function size:0x40 +__ct__25dSndControlPlayerFxSend_cFv = .text:0x8035F2E0; // type:function size:0x40 +__ct__25dSndControlPlayerVolume_cFv = .text:0x8035F320; // type:function size:0x3C +__dt__25dSndControlPlayerVolume_cFv = .text:0x8035F360; // type:function size:0x40 +__dt__26dSndControlPlayerLpfFreq_cFv = .text:0x8035F3A0; // type:function size:0x40 +__dt__25dSndControlPlayerFxSend_cFv = .text:0x8035F3E0; // type:function size:0x40 fn_8035F420 = .text:0x8035F420; // type:function size:0xC8 fn_8035F4F0 = .text:0x8035F4F0; // type:function size:0x118 fn_8035F610 = .text:0x8035F610; // type:function size:0x158 fn_8035F770 = .text:0x8035F770; // type:function size:0xDC -fn_8035F850 = .text:0x8035F850; // type:function size:0x3C -fn_8035F890 = .text:0x8035F890; // type:function size:0xAC +calc__22dSndControlPlayerMgr_cFv = .text:0x8035F850; // type:function size:0x3C +executeControls__22dSndControlPlayerMgr_cFv = .text:0x8035F890; // type:function size:0xAC fn_8035F940 = .text:0x8035F940; // type:function size:0x168 fn_8035FAB0 = .text:0x8035FAB0; // type:function size:0x318 fn_8035FDD0 = .text:0x8035FDD0; // type:function size:0xE0 fn_8035FEB0 = .text:0x8035FEB0; // type:function size:0x11C fn_8035FFD0 = .text:0x8035FFD0; // type:function size:0xE0 -fn_803600B0 = .text:0x803600B0; // type:function size:0x70 -fn_80360120 = .text:0x80360120; // type:function size:0x34 +getPlayer1__22dSndControlPlayerMgr_cFl = .text:0x803600B0; // type:function size:0x70 +getPlayer2__22dSndControlPlayerMgr_cFl = .text:0x80360120; // type:function size:0x34 fn_80360160 = .text:0x80360160; // type:function size:0xBC -fn_80360220 = .text:0x80360220; // type:function size:0x28 -fn_80360250 = .text:0x80360250; // type:function size:0x28 +linkCtrl__22dSndControlPlayerMgr_cFP19dSndControlPlayer_c = .text:0x80360220; // type:function size:0x28 +unlinkCtrl__22dSndControlPlayerMgr_cFP19dSndControlPlayer_c = .text:0x80360250; // type:function size:0x28 fn_80360280 = .text:0x80360280; // type:function size:0x94 fn_80360320 = .text:0x80360320; // type:function size:0xC8 fn_803603F0 = .text:0x803603F0; // type:function size:0xB0 fn_803604A0 = .text:0x803604A0; // type:function size:0x48 -fn_803604F0 = .text:0x803604F0; // type:function size:0x20 -fn_80360510 = .text:0x80360510; // type:function size:0x20 +setLpfFreq__22dSndControlPlayerMgr_cFUlfl = .text:0x803604F0; // type:function size:0x20 +setFxSend__22dSndControlPlayerMgr_cFUlfl = .text:0x80360510; // type:function size:0x20 fn_80360530 = .text:0x80360530; // type:function size:0x38 -fn_80360570 = .text:0x80360570; // type:function size:0xB0 -fn_80360620 = .text:0x80360620; // type:function size:0xAC -fn_803606D0 = .text:0x803606D0; // type:function size:0x40 +setControlValue__22dSndControlPlayerMgr_cFQ222dSndControlPlayerMgr_c12PlayerCtrl_eUlfl = .text:0x80360570; // type:function size:0xB0 +resetControls__22dSndControlPlayerMgr_cFv = .text:0x80360620; // type:function size:0xAC +getTargetValue__22dSndControlPlayerMgr_cCFQ222dSndControlPlayerMgr_c12PlayerCtrl_eUl = .text:0x803606D0; // type:function size:0x40 fn_80360710 = .text:0x80360710; // type:function size:0x78 fn_80360790 = .text:0x80360790; // type:function size:0x5C fn_803607F0 = .text:0x803607F0; // type:function size:0x60 @@ -37644,7 +37644,7 @@ __vt__33SndMgrDisposer<15dSndPlayerMgr_c> = .data:0x80548790; // type:object siz lbl_805487A0 = .data:0x805487A0; // type:object size:0xC lbl_805487AC = .data:0x805487AC; // type:object size:0xC lbl_805487B8 = .data:0x805487B8; // type:object size:0xC -lbl_805487C4 = .data:0x805487C4; // type:object size:0xC +__vt__40SndMgrDisposer<22dSndControlPlayerMgr_c> = .data:0x805487C4; // type:object size:0xC __vt__33SndMgrDisposer<15dSnd3DManager_c> = .data:0x805487D0; // type:object size:0xC scope:weak lbl_805487E0 = .data:0x805487E0; // type:object size:0xAC lbl_8054888C = .data:0x8054888C; // type:object size:0xC @@ -41893,8 +41893,8 @@ sDisposer__15dSndPlayerMgr_c = .sbss:0x80575D3C; // type:object size:0x4 data:4b lbl_80575D40 = .sbss:0x80575D40; // type:object size:0x4 data:4byte lbl_80575D44 = .sbss:0x80575D44; // type:object size:0x4 data:4byte lbl_80575D48 = .sbss:0x80575D48; // type:object size:0x4 data:4byte -lbl_80575D4C = .sbss:0x80575D4C; // type:object size:0x4 data:4byte -lbl_80575D50 = .sbss:0x80575D50; // type:object size:0x8 data:4byte +sInstance__22dSndControlPlayerMgr_c = .sbss:0x80575D4C; // type:object size:0x4 data:4byte +sDisposer__22dSndControlPlayerMgr_c = .sbss:0x80575D50; // type:object size:0x8 data:4byte sInstance__15dSnd3DManager_c = .sbss:0x80575D58; // type:object size:0x4 data:4byte sDisposer__15dSnd3DManager_c = .sbss:0x80575D5C; // type:object size:0x4 data:4byte lbl_80575D60 = .sbss:0x80575D60; // type:object size:0x4 data:4byte @@ -49196,7 +49196,7 @@ lbl_8057E5B8 = .sdata2:0x8057E5B8; // type:object size:0x4 align:4 data:float lbl_8057E5BC = .sdata2:0x8057E5BC; // type:object size:0x4 align:4 data:float lbl_8057E5C0 = .sdata2:0x8057E5C0; // type:object size:0x4 data:4byte lbl_8057E5C4 = .sdata2:0x8057E5C4; // type:object size:0x4 align:4 data:float -lbl_8057E5C8 = .sdata2:0x8057E5C8; // type:object size:0x4 data:4byte +sNumPlayers__22dSndControlPlayerMgr_c = .sdata2:0x8057E5C8; // type:object size:0x4 data:4byte lbl_8057E5CC = .sdata2:0x8057E5CC; // type:object size:0x4 data:4byte lbl_8057E5D0 = .sdata2:0x8057E5D0; // type:object size:0x8 data:4byte lbl_8057E5D8 = .sdata2:0x8057E5D8; // type:object size:0x4 align:4 data:float diff --git a/configure.py b/configure.py index ed3cbdfc..1a15f5f4 100644 --- a/configure.py +++ b/configure.py @@ -708,7 +708,7 @@ config.libs = [ Object(NonMatching, "d/snd/d_snd_3d_engine.cpp"), Object(Matching, "d/snd/d_snd_sound.cpp"), Object(NonMatching, "d/snd/d_snd_player_mgr.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk1.cpp"), + Object(NonMatching, "d/snd/d_snd_control_player_mgr.cpp"), Object(Matching, "d/snd/d_snd_3d_manager.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_enemy.cpp"), Object(NonMatching, "d/snd/d_snd_unk_component_2.cpp"), @@ -716,7 +716,7 @@ config.libs = [ Object(Matching, "d/snd/d_snd_control_sound.cpp"), Object(Matching, "d/snd/d_snd_control_player.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_effect.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_5.cpp"), + Object(NonMatching, "d/snd/d_snd_harp_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_anim_sound.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_14.cpp"), Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_13.cpp"), diff --git a/include/d/snd/d_snd_actor.h b/include/d/snd/d_snd_actor.h index 5fc2480c..d07a8b5d 100644 --- a/include/d/snd/d_snd_actor.h +++ b/include/d/snd/d_snd_actor.h @@ -2,11 +2,13 @@ #define D_SND_3D_ACTOR_H #include "nw4r/snd/snd_SoundActor.h" -#include "nw4r/snd/snd_SoundHandle.h" class dSndActor_c : public nw4r::snd::SoundActor { public: dSndActor_c(nw4r::snd::SoundArchivePlayer &rPlayer); + +private: + void doesSomethingWithForeachSound(); }; #endif diff --git a/include/d/snd/d_snd_checkers.h b/include/d/snd/d_snd_checkers.h index c34f881b..7a459280 100644 --- a/include/d/snd/d_snd_checkers.h +++ b/include/d/snd/d_snd_checkers.h @@ -2,10 +2,61 @@ #define D_SND_CHECKERS_H #include "nw4r/snd/snd_SoundHandle.h" +#include "toBeSorted/music_mgrs.h" class SoundPropertiesChecker { public: - virtual void operator()(nw4r::snd::SoundHandle &pHandle); + virtual void operator()(nw4r::snd::SoundHandle &pHandle) { + if (mSoundId != -1 && mSoundId != pHandle.GetId()) { + return; + } + + if (mpPlayCounter != nullptr) { + (*mpPlayCounter)++; + } else { + mPlayCounter++; + } + + if (pHandle.IsPause()) { + if (mpPauseCounter != nullptr) { + (*mpPauseCounter)++; + } else { + mPauseCounter++; + } + return; + } + + if (fn_803721F0(FANFARE_SOUND_MGR, pHandle.GetId())) { + if (mpCounter3 != nullptr) { + (*mpCounter3)++; + } else { + mCounter3++; + } + return; + } + + if (fn_803720E0(FANFARE_SOUND_MGR, pHandle.GetId())) { + if (mpCounter3 != nullptr) { + (*mpCounter3)++; + } else { + mCounter3++; + } + return; + } + + if (fn_80372070(FANFARE_SOUND_MGR, pHandle.GetId())) { + if (mpCounter4 != nullptr) { + (*mpCounter4)++; + } else { + mCounter4++; + } + return; + } + + if (fn_803734C0(FANFARE_SOUND_MGR, pHandle.GetId()) && !fn_80373550(FANFARE_SOUND_MGR, pHandle.GetId())) { + mCounter3++; + } + } private: /* 0x04 */ u32 mSoundId; diff --git a/include/d/snd/d_snd_control_player.h b/include/d/snd/d_snd_control_player.h index fc0096ef..33f54205 100644 --- a/include/d/snd/d_snd_control_player.h +++ b/include/d/snd/d_snd_control_player.h @@ -44,7 +44,7 @@ public: class dSndControlPlayerFxSend_c : public dSndControlPlayer_c { public: - dSndControlPlayerFxSend_c() : dSndControlPlayer_c(0.0f, -1.0f, 0.0f) {} + dSndControlPlayerFxSend_c() : dSndControlPlayer_c(0.0f, 0.0f, 1.0f) {} virtual void apply() override; // vt 0x1C virtual f32 getAppliedValue() override; // vt 0x20 diff --git a/include/d/snd/d_snd_control_player_mgr.h b/include/d/snd/d_snd_control_player_mgr.h new file mode 100644 index 00000000..ef9989e1 --- /dev/null +++ b/include/d/snd/d_snd_control_player_mgr.h @@ -0,0 +1,68 @@ +#ifndef D_SND_CONTROL_PLAYER_MGR_H +#define D_SND_CONTROL_PLAYER_MGR_H + +#include "d/snd/d_snd_control_player.h" +#include "d/snd/d_snd_util.h" +#include "nw4r/snd/snd_SoundPlayer.h" +#include "nw4r/ut/ut_list.h" + +class dSndControlPlayerMgr_c; +extern template class SndMgrDisposer; + +class dSndControlPlayerMgr_c { +public: + SndMgrDisposer *GetDisposer() { + return &mDisposer; + } + + static dSndControlPlayerMgr_c *GetInstance() { + return sInstance; + } + + static dSndControlPlayerMgr_c *sInstance; + static SndMgrDisposer *sDisposer; + +private: + SndMgrDisposer mDisposer; + +public: + enum PlayerCtrl_e { + CTRL_VOLUME, + CTRL_LPF_FREQ, + CTRL_FX_SEND, + + CTRL_MAX, + }; + + dSndControlPlayerMgr_c(); + + void calc(); + + static const s32 sNumPlayers; + + nw4r::snd::SoundPlayer *getPlayer1(s32); + nw4r::snd::SoundPlayer *getPlayer2(s32); + + void setLpfFreq(u32 playerIdx, f32 value, s32 frames); + void setFxSend(u32 playerIdx, f32 value, s32 frames); + +private: + void resetControls(); + void executeControls(); + void linkCtrl(dSndControlPlayer_c *); + void unlinkCtrl(dSndControlPlayer_c *); + void setControlValue(PlayerCtrl_e ctrlType, u32 playerIdx, f32 value, s32 frames); + + f32 getTargetValue(PlayerCtrl_e ctrlType, u32 playerIdx) const; + + /* 0x10 */ dSndControlPlayer_c *mpCtrls[CTRL_MAX]; + /* 0x1C */ void *field_0x1C; + /* 0x20 */ void *field_0x20; + /* 0x24 */ void *field_0x24; + /* 0x28 */ f32 *field_0x28; + /* 0x2C */ u32 mControlMask; + /* 0x30 */ nw4r::ut::List mActiveControls; + /* 0x3C */ s16 field_0x3C[8]; +}; + +#endif diff --git a/include/d/snd/d_snd_sound.h b/include/d/snd/d_snd_sound.h index da12e39e..78d95398 100644 --- a/include/d/snd/d_snd_sound.h +++ b/include/d/snd/d_snd_sound.h @@ -43,6 +43,10 @@ public: return mCurrValue; } + f32 getTargetValue() const { + return mTargetValue; + } + bool isFinished() const { return mTimer >= mDuration; } diff --git a/src/d/snd/d_snd_actor.cpp b/src/d/snd/d_snd_actor.cpp index db456ecf..114bb03f 100644 --- a/src/d/snd/d_snd_actor.cpp +++ b/src/d/snd/d_snd_actor.cpp @@ -1,66 +1,12 @@ #include "d/snd/d_snd_actor.h" -#include "common.h" #include "d/snd/d_snd_checkers.h" #include "nw4r/snd/snd_BasicSound.h" #include "nw4r/snd/snd_SoundArchivePlayer.h" -#include "nw4r/snd/snd_SoundHandle.h" -#include "toBeSorted/music_mgrs.h" dSndActor_c::dSndActor_c(nw4r::snd::SoundArchivePlayer &rStartable) : nw4r::snd::SoundActor(rStartable) {} -void d_snd_actor_SoundHandle_dtor() { - nw4r::snd::SoundHandle handle[2]; -} - -void SoundPropertiesChecker::operator()(nw4r::snd::SoundHandle &pHandle) { - if (mSoundId != -1 && mSoundId != pHandle.GetId()) { - return; - } - - if (mpPlayCounter != nullptr) { - (*mpPlayCounter)++; - } else { - mPlayCounter++; - } - - if (pHandle.IsPause()) { - if (mpPauseCounter != nullptr) { - (*mpPauseCounter)++; - } else { - mPauseCounter++; - } - return; - } - - if (fn_803721F0(FANFARE_SOUND_MGR, pHandle.GetId())) { - if (mpCounter3 != nullptr) { - (*mpCounter3)++; - } else { - mCounter3++; - } - return; - } - - if (fn_803720E0(FANFARE_SOUND_MGR, pHandle.GetId())) { - if (mpCounter3 != nullptr) { - (*mpCounter3)++; - } else { - mCounter3++; - } - return; - } - - if (fn_80372070(FANFARE_SOUND_MGR, pHandle.GetId())) { - if (mpCounter4 != nullptr) { - (*mpCounter4)++; - } else { - mCounter4++; - } - return; - } - - if (fn_803734C0(FANFARE_SOUND_MGR, pHandle.GetId()) && !fn_80373550(FANFARE_SOUND_MGR, pHandle.GetId())) { - mCounter3++; - } +void dSndActor_c::doesSomethingWithForeachSound() { + SoundPropertiesChecker checker; + ForEachSound(checker, false); } diff --git a/src/d/snd/d_snd_control_player.cpp b/src/d/snd/d_snd_control_player.cpp index d82931f7..a9a69a04 100644 --- a/src/d/snd/d_snd_control_player.cpp +++ b/src/d/snd/d_snd_control_player.cpp @@ -1,6 +1,7 @@ #include "d/snd/d_snd_control_player.h" #include "common.h" +#include "d/snd/d_snd_control_player_mgr.h" #include "d/snd/d_snd_sound.h" #include "nw4r/snd/snd_SoundPlayer.h" #include "nw4r/snd/snd_global.h" @@ -15,17 +16,13 @@ void dSndControlPlayer_c::reset() { apply(); } -extern "C" void *lbl_80575D4C; -extern "C" nw4r::snd::SoundPlayer *fn_803600B0(void *, s32); -extern "C" nw4r::snd::SoundPlayer *fn_80360120(void *, s32); - void dSndControlPlayer_c::setIndex1(s32 idx) { - mpPlayer = fn_803600B0(lbl_80575D4C, idx); + mpPlayer = dSndControlPlayerMgr_c::GetInstance()->getPlayer1(idx); mIndex = idx; } void dSndControlPlayer_c::setIndex2(s32 idx) { - mpPlayer = fn_80360120(lbl_80575D4C, idx); + mpPlayer = dSndControlPlayerMgr_c::GetInstance()->getPlayer2(idx); mIndex = idx; } diff --git a/src/d/snd/d_snd_control_player_mgr.cpp b/src/d/snd/d_snd_control_player_mgr.cpp new file mode 100644 index 00000000..44375f93 --- /dev/null +++ b/src/d/snd/d_snd_control_player_mgr.cpp @@ -0,0 +1,104 @@ +#include "d/snd/d_snd_control_player_mgr.h" + +#include "common.h" +#include "d/snd/d_snd_control_player.h" +#include "nw4r/ut/ut_list.h" + +template class SndMgrDisposer; + +dSndControlPlayerMgr_c::dSndControlPlayerMgr_c() : mControlMask(0) { + // TODO offsetof + nw4r::ut::List_Init(&mActiveControls, 0x24); + + mpCtrls[CTRL_VOLUME] = new dSndControlPlayerVolume_c[sNumPlayers](); + mpCtrls[CTRL_LPF_FREQ] = new dSndControlPlayerLpfFreq_c[sNumPlayers](); + mpCtrls[CTRL_FX_SEND] = new dSndControlPlayerFxSend_c[sNumPlayers](); + + field_0x28 = new f32[sNumPlayers]; + field_0x1C = new f32[sNumPlayers]; + field_0x20 = new f32[sNumPlayers]; + field_0x24 = new f32[sNumPlayers]; +} + +void dSndControlPlayerMgr_c::calc() {} + +void dSndControlPlayerMgr_c::executeControls() { + dSndControlPlayer_c *next; + dSndControlPlayer_c *iter = static_cast(nw4r::ut::List_GetNext(&mActiveControls, nullptr)); + while (iter != nullptr) { + next = static_cast(nw4r::ut::List_GetNext(&mActiveControls, iter)); + iter->calc(); + iter->apply(); + if (iter->isFinished()) { + unlinkCtrl(iter); + } + iter = next; + } +} + +void dSndControlPlayerMgr_c::linkCtrl(dSndControlPlayer_c *ctrl) { + if (ctrl == nullptr) { + return; + } + if (ctrl->isLinked()) { + return; + } + ctrl->setLinked(true); + nw4r::ut::List_Append(&mActiveControls, ctrl); +} + +void dSndControlPlayerMgr_c::unlinkCtrl(dSndControlPlayer_c *ctrl) { + if (ctrl == nullptr) { + return; + } + if (!ctrl->isLinked()) { + return; + } + ctrl->setLinked(false); + nw4r::ut::List_Remove(&mActiveControls, ctrl); +} + +void dSndControlPlayerMgr_c::setLpfFreq(u32 playerIdx, f32 value, s32 frames) { + if (playerIdx < sNumPlayers) { + setControlValue(CTRL_LPF_FREQ, playerIdx, value, frames); + } +} + +void dSndControlPlayerMgr_c::setFxSend(u32 playerIdx, f32 value, s32 frames) { + if (playerIdx < sNumPlayers) { + setControlValue(CTRL_FX_SEND, playerIdx, value, frames); + } +} + +void dSndControlPlayerMgr_c::setControlValue(PlayerCtrl_e ctrlType, u32 playerIdx, f32 value, s32 frames) { + if (ctrlType < CTRL_MAX && playerIdx < sNumPlayers) { + dSndControlPlayer_c *ctrl = &mpCtrls[ctrlType][playerIdx]; + ctrl->set(value, frames); + if (ctrl->isFinished()) { + unlinkCtrl(ctrl); + } else { + linkCtrl(ctrl); + } + ctrl->apply(); + } +} + +void dSndControlPlayerMgr_c::resetControls() { + for (s32 i = 0; i < sNumPlayers; i++) { + for (s32 ty = 0; ty < CTRL_MAX; ty++) { + mpCtrls[ty][i].reset(); + } + field_0x28[i] = 1.0f; + } + mControlMask = 0; +} + +f32 dSndControlPlayerMgr_c::getTargetValue(PlayerCtrl_e ctrlType, u32 playerIdx) const { + if (ctrlType >= CTRL_MAX) { + return 1.0f; + } + if (playerIdx >= sNumPlayers) { + return 1.0f; + } + return mpCtrls[ctrlType][playerIdx].getTargetValue(); +} diff --git a/src/d/snd/d_snd_mgr.cpp b/src/d/snd/d_snd_mgr.cpp index 6604fcae..982c3fbd 100644 --- a/src/d/snd/d_snd_mgr.cpp +++ b/src/d/snd/d_snd_mgr.cpp @@ -1,12 +1,12 @@ #include "d/snd/d_snd_mgr.h" #include "d/snd/d_snd_3d_manager.h" +#include "d/snd/d_snd_control_player_mgr.h" #include "d/snd/d_snd_player_mgr.h" #include "d/snd/d_snd_util.h" #include "egg/audio/eggAudioRmtSpeakerMgr.h" #include "egg/audio/eggAudioUtility.h" -extern "C" void fn_8035F120(); extern "C" void initEnemySoundMgr(); extern "C" void initFanfareSoundMgr(); extern "C" void initSomeUnusedSoundMgr(); @@ -24,7 +24,7 @@ dSndMgr_c *dSndMgr_c::sInstance; dSndMgr_c::dSndMgr_c(): field_0x6CC(0) { sInstance = this; SndMgrDisposer::create(); - fn_8035F120(); + SndMgrDisposer::create(); initEnemySoundMgr(); SndMgrDisposer::create(); initFanfareSoundMgr(); From 87cbf6f409aa285dff286973974617597a8544f0 Mon Sep 17 00:00:00 2001 From: robojumper Date: Wed, 4 Jun 2025 10:27:56 +0200 Subject: [PATCH 08/22] More structure --- config/SOUE01/splits.txt | 1 + config/SOUE01/symbols.txt | 20 ++--- include/d/snd/d_snd_control_player.h | 6 +- include/d/snd/d_snd_control_player_mgr.h | 54 ++++++++--- src/d/snd/d_snd_control_player.cpp | 4 +- src/d/snd/d_snd_control_player_mgr.cpp | 110 ++++++++++++++++++++--- 6 files changed, 160 insertions(+), 35 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 642fbb94..918049bc 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2377,6 +2377,7 @@ d/snd/d_snd_player_mgr.cpp: d/snd/d_snd_control_player_mgr.cpp: .text start:0x8035F050 end:0x80360C28 align:16 .ctors start:0x804DB914 end:0x804DB918 + .data start:0x805487A0 end:0x805487D0 .sbss start:0x80575D40 end:0x80575D58 .sdata2 start:0x8057D390 end:0x8057D3B8 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index fbd272c6..5ec7e144 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -20000,30 +20000,30 @@ fn_8035F610 = .text:0x8035F610; // type:function size:0x158 fn_8035F770 = .text:0x8035F770; // type:function size:0xDC calc__22dSndControlPlayerMgr_cFv = .text:0x8035F850; // type:function size:0x3C executeControls__22dSndControlPlayerMgr_cFv = .text:0x8035F890; // type:function size:0xAC -fn_8035F940 = .text:0x8035F940; // type:function size:0x168 +calcVolumes__22dSndControlPlayerMgr_cFv = .text:0x8035F940; // type:function size:0x168 fn_8035FAB0 = .text:0x8035FAB0; // type:function size:0x318 fn_8035FDD0 = .text:0x8035FDD0; // type:function size:0xE0 fn_8035FEB0 = .text:0x8035FEB0; // type:function size:0x11C fn_8035FFD0 = .text:0x8035FFD0; // type:function size:0xE0 -getPlayer1__22dSndControlPlayerMgr_cFl = .text:0x803600B0; // type:function size:0x70 -getPlayer2__22dSndControlPlayerMgr_cFl = .text:0x80360120; // type:function size:0x34 +getPlayer1__22dSndControlPlayerMgr_cCFUl = .text:0x803600B0; // type:function size:0x70 +getPlayer2__22dSndControlPlayerMgr_cCFUl = .text:0x80360120; // type:function size:0x34 fn_80360160 = .text:0x80360160; // type:function size:0xBC linkCtrl__22dSndControlPlayerMgr_cFP19dSndControlPlayer_c = .text:0x80360220; // type:function size:0x28 unlinkCtrl__22dSndControlPlayerMgr_cFP19dSndControlPlayer_c = .text:0x80360250; // type:function size:0x28 -fn_80360280 = .text:0x80360280; // type:function size:0x94 +setVolume__22dSndControlPlayerMgr_cFUlfl = .text:0x80360280; // type:function size:0x94 fn_80360320 = .text:0x80360320; // type:function size:0xC8 -fn_803603F0 = .text:0x803603F0; // type:function size:0xB0 -fn_803604A0 = .text:0x803604A0; // type:function size:0x48 +overrideVolume__22dSndControlPlayerMgr_cFUlfl = .text:0x803603F0; // type:function size:0xB0 +restoreVolume__22dSndControlPlayerMgr_cFUll = .text:0x803604A0; // type:function size:0x48 setLpfFreq__22dSndControlPlayerMgr_cFUlfl = .text:0x803604F0; // type:function size:0x20 setFxSend__22dSndControlPlayerMgr_cFUlfl = .text:0x80360510; // type:function size:0x20 -fn_80360530 = .text:0x80360530; // type:function size:0x38 +getAppliedPlayerVolume__22dSndControlPlayerMgr_cCFUl = .text:0x80360530; // type:function size:0x38 setControlValue__22dSndControlPlayerMgr_cFQ222dSndControlPlayerMgr_c12PlayerCtrl_eUlfl = .text:0x80360570; // type:function size:0xB0 resetControls__22dSndControlPlayerMgr_cFv = .text:0x80360620; // type:function size:0xAC getTargetValue__22dSndControlPlayerMgr_cCFQ222dSndControlPlayerMgr_c12PlayerCtrl_eUl = .text:0x803606D0; // type:function size:0x40 fn_80360710 = .text:0x80360710; // type:function size:0x78 fn_80360790 = .text:0x80360790; // type:function size:0x5C fn_803607F0 = .text:0x803607F0; // type:function size:0x60 -fn_80360850 = .text:0x80360850; // type:function size:0x2C +setShortParameterTo5__22dSndControlPlayerMgr_cFll = .text:0x80360850; // type:function size:0x2C fn_80360880 = .text:0x80360880; // type:function size:0x64 fn_803608F0 = .text:0x803608F0; // type:function size:0x50 fn_80360940 = .text:0x80360940; // type:function size:0x5C @@ -20395,8 +20395,8 @@ apply__32dSndControlSoundSeqTrackVolume_cFP11dSndSound_c = .text:0x8036C3A0; // apply__33dSndControlSoundStrmTrackVolume_cFP11dSndSound_c = .text:0x8036C3F0; // type:function size:0x54 __ct__29dSndControlPlayerVolumeBase_cFv = .text:0x8036C450; // type:function size:0x48 reset__19dSndControlPlayer_cFv = .text:0x8036C4A0; // type:function size:0x40 -setIndex1__19dSndControlPlayer_cFl = .text:0x8036C4E0; // type:function size:0x44 -setIndex2__19dSndControlPlayer_cFl = .text:0x8036C530; // type:function size:0x44 +setIndex1__19dSndControlPlayer_cFUl = .text:0x8036C4E0; // type:function size:0x44 +setIndex2__19dSndControlPlayer_cFUl = .text:0x8036C530; // type:function size:0x44 stop__19dSndControlPlayer_cFv = .text:0x8036C580; // type:function size:0x44 apply__25dSndControlPlayerVolume_cFv = .text:0x8036C5D0; // type:function size:0x10 getAppliedValue__25dSndControlPlayerVolume_cFv = .text:0x8036C5E0; // type:function size:0xC diff --git a/include/d/snd/d_snd_control_player.h b/include/d/snd/d_snd_control_player.h index 33f54205..c4bc4fe2 100644 --- a/include/d/snd/d_snd_control_player.h +++ b/include/d/snd/d_snd_control_player.h @@ -13,12 +13,12 @@ public: virtual void apply() = 0; // vt 0x1C virtual f32 getAppliedValue() = 0; // vt 0x20 - void setIndex1(s32 idx); - void setIndex2(s32 idx); + void setIndex1(u32 idx); + void setIndex2(u32 idx); protected: /* 0x30 */ nw4r::snd::SoundPlayer *mpPlayer; - /* 0x34 */ s32 mIndex; + /* 0x34 */ u32 mIndex; }; class dSndControlPlayerVolumeBase_c : public dSndControlPlayer_c { diff --git a/include/d/snd/d_snd_control_player_mgr.h b/include/d/snd/d_snd_control_player_mgr.h index ef9989e1..057f2e81 100644 --- a/include/d/snd/d_snd_control_player_mgr.h +++ b/include/d/snd/d_snd_control_player_mgr.h @@ -6,6 +6,32 @@ #include "nw4r/snd/snd_SoundPlayer.h" #include "nw4r/ut/ut_list.h" +/* +Num players: 0x15 = 21 +Notes on player groups: +0, 1 + +9, 10, 11 + +12, 13, 14, 16, 17 + +17, 18, 19, 20 + + +0: BGM + +3: UI Sfx, confirmation, pointer reset +4: UI SFX, get fruit +5, 7: Player walk +8: Player Equipment + +12: bomb explode, refresh fruit sprout +13: environmental sound effects (wind), bomb fuse +14: enemies/bugs + +17: TgSound +*/ + class dSndControlPlayerMgr_c; extern template class SndMgrDisposer; @@ -40,29 +66,37 @@ public: static const s32 sNumPlayers; - nw4r::snd::SoundPlayer *getPlayer1(s32); - nw4r::snd::SoundPlayer *getPlayer2(s32); + nw4r::snd::SoundPlayer *getPlayer1(u32) const; + nw4r::snd::SoundPlayer *getPlayer2(u32) const; + + void setVolume(u32 playerIdx, f32 value, s32 frames); void setLpfFreq(u32 playerIdx, f32 value, s32 frames); void setFxSend(u32 playerIdx, f32 value, s32 frames); + void overrideVolume(u32 playerIdx, f32 volume, s32 frames); + void restoreVolume(u32 playerIdx, s32 frames); + + void setShortParameterTo5(s32 idx1, s32 idx2); + private: void resetControls(); + void calcVolumes(); void executeControls(); void linkCtrl(dSndControlPlayer_c *); void unlinkCtrl(dSndControlPlayer_c *); void setControlValue(PlayerCtrl_e ctrlType, u32 playerIdx, f32 value, s32 frames); - - f32 getTargetValue(PlayerCtrl_e ctrlType, u32 playerIdx) const; + f32 getAppliedPlayerVolume(u32 playerIdx) const; + f32 getControlVolumeTarget(PlayerCtrl_e ctrlType, u32 playerIdx) const; /* 0x10 */ dSndControlPlayer_c *mpCtrls[CTRL_MAX]; - /* 0x1C */ void *field_0x1C; - /* 0x20 */ void *field_0x20; - /* 0x24 */ void *field_0x24; - /* 0x28 */ f32 *field_0x28; - /* 0x2C */ u32 mControlMask; + /* 0x1C */ f32 *mpTargetVolumes; + /* 0x20 */ f32 *mpMaxVolumeDecreases; + /* 0x24 */ f32 *mpMaxVolumeIncreases; + /* 0x28 */ f32 *mpSavedVolumes; + /* 0x2C */ u32 mOverrideVolumeMask; /* 0x30 */ nw4r::ut::List mActiveControls; - /* 0x3C */ s16 field_0x3C[8]; + /* 0x3C */ s16 field_0x3C[4][2]; }; #endif diff --git a/src/d/snd/d_snd_control_player.cpp b/src/d/snd/d_snd_control_player.cpp index a9a69a04..824f327a 100644 --- a/src/d/snd/d_snd_control_player.cpp +++ b/src/d/snd/d_snd_control_player.cpp @@ -16,12 +16,12 @@ void dSndControlPlayer_c::reset() { apply(); } -void dSndControlPlayer_c::setIndex1(s32 idx) { +void dSndControlPlayer_c::setIndex1(u32 idx) { mpPlayer = dSndControlPlayerMgr_c::GetInstance()->getPlayer1(idx); mIndex = idx; } -void dSndControlPlayer_c::setIndex2(s32 idx) { +void dSndControlPlayer_c::setIndex2(u32 idx) { mpPlayer = dSndControlPlayerMgr_c::GetInstance()->getPlayer2(idx); mIndex = idx; } diff --git a/src/d/snd/d_snd_control_player_mgr.cpp b/src/d/snd/d_snd_control_player_mgr.cpp index 44375f93..1f82c696 100644 --- a/src/d/snd/d_snd_control_player_mgr.cpp +++ b/src/d/snd/d_snd_control_player_mgr.cpp @@ -6,7 +6,7 @@ template class SndMgrDisposer; -dSndControlPlayerMgr_c::dSndControlPlayerMgr_c() : mControlMask(0) { +dSndControlPlayerMgr_c::dSndControlPlayerMgr_c() : mOverrideVolumeMask(0) { // TODO offsetof nw4r::ut::List_Init(&mActiveControls, 0x24); @@ -14,10 +14,10 @@ dSndControlPlayerMgr_c::dSndControlPlayerMgr_c() : mControlMask(0) { mpCtrls[CTRL_LPF_FREQ] = new dSndControlPlayerLpfFreq_c[sNumPlayers](); mpCtrls[CTRL_FX_SEND] = new dSndControlPlayerFxSend_c[sNumPlayers](); - field_0x28 = new f32[sNumPlayers]; - field_0x1C = new f32[sNumPlayers]; - field_0x20 = new f32[sNumPlayers]; - field_0x24 = new f32[sNumPlayers]; + mpSavedVolumes = new f32[sNumPlayers]; + mpTargetVolumes = new f32[sNumPlayers]; + mpMaxVolumeDecreases = new f32[sNumPlayers]; + mpMaxVolumeIncreases = new f32[sNumPlayers]; } void dSndControlPlayerMgr_c::calc() {} @@ -36,10 +36,40 @@ void dSndControlPlayerMgr_c::executeControls() { } } +void dSndControlPlayerMgr_c::calcVolumes() { + for (int i = 0; i < sNumPlayers; i++) { + if ((mOverrideVolumeMask & (1 << i)) != 0) { + // overridden volume + mpTargetVolumes[i] = mpSavedVolumes[i]; + } else { + // not overridden. The effect of this is that + // something will set the targetValue to a specific value + f32 currentVolume = getAppliedPlayerVolume(i); + f32 targetVolume = mpTargetVolumes[i]; + f32 maxVolumeDecrease = mpMaxVolumeDecreases[i]; + f32 maxVolumeIncrease = mpMaxVolumeDecreases[i]; + + if (currentVolume != targetVolume) { + if (currentVolume - targetVolume > maxVolumeDecrease) { + targetVolume = currentVolume - maxVolumeDecrease; + } else if (targetVolume - currentVolume > maxVolumeIncrease) { + targetVolume = currentVolume + maxVolumeIncrease; + } + // @bug not actually clamped + nw4r::ut::Clamp(targetVolume, 0.0f, 2.0f); + setVolume(i, targetVolume, 0); + } + mpTargetVolumes[i] = 1.0f; + mpMaxVolumeDecreases[i] = 0.1f; + mpMaxVolumeDecreases[i] = 0.025f; + } + } +} + void dSndControlPlayerMgr_c::linkCtrl(dSndControlPlayer_c *ctrl) { if (ctrl == nullptr) { return; - } + } if (ctrl->isLinked()) { return; } @@ -50,7 +80,7 @@ void dSndControlPlayerMgr_c::linkCtrl(dSndControlPlayer_c *ctrl) { void dSndControlPlayerMgr_c::unlinkCtrl(dSndControlPlayer_c *ctrl) { if (ctrl == nullptr) { return; - } + } if (!ctrl->isLinked()) { return; } @@ -58,6 +88,47 @@ void dSndControlPlayerMgr_c::unlinkCtrl(dSndControlPlayer_c *ctrl) { nw4r::ut::List_Remove(&mActiveControls, ctrl); } +void dSndControlPlayerMgr_c::setVolume(u32 playerIdx, f32 value, s32 frames) { + if (playerIdx >= sNumPlayers) { + return; + } + + u32 mask = (1 << playerIdx); + if ((mOverrideVolumeMask & mask) != 0) { + // Volume is overridden, set saved volume as to not interrupt override + mpSavedVolumes[playerIdx] = value; + + } else { + // Volume is not overridden, set volume normally + setControlValue(CTRL_VOLUME, playerIdx, value, frames); + mpSavedVolumes[playerIdx] = getControlVolumeTarget(CTRL_VOLUME, playerIdx); + } +} + +void dSndControlPlayerMgr_c::overrideVolume(u32 playerIdx, f32 volume, s32 frames) { + if (playerIdx >= sNumPlayers) { + return; + } + u32 mask = (1 << playerIdx); + if ((mOverrideVolumeMask & mask) == 0) { + mpSavedVolumes[playerIdx] = getControlVolumeTarget(CTRL_VOLUME, playerIdx); + mOverrideVolumeMask |= mask; + } + setControlValue(CTRL_VOLUME, playerIdx, volume, frames); +} + +void dSndControlPlayerMgr_c::restoreVolume(u32 playerIdx, s32 frames) { + if (playerIdx >= sNumPlayers) { + return; + } + u32 mask = (1 << playerIdx); + if ((mOverrideVolumeMask & mask) == 0) { + return; + } + mOverrideVolumeMask &= ~mask; + setControlValue(CTRL_VOLUME, playerIdx, mpSavedVolumes[playerIdx], frames); +} + void dSndControlPlayerMgr_c::setLpfFreq(u32 playerIdx, f32 value, s32 frames) { if (playerIdx < sNumPlayers) { setControlValue(CTRL_LPF_FREQ, playerIdx, value, frames); @@ -88,12 +159,19 @@ void dSndControlPlayerMgr_c::resetControls() { for (s32 ty = 0; ty < CTRL_MAX; ty++) { mpCtrls[ty][i].reset(); } - field_0x28[i] = 1.0f; + mpSavedVolumes[i] = 1.0f; } - mControlMask = 0; + mOverrideVolumeMask = 0; } -f32 dSndControlPlayerMgr_c::getTargetValue(PlayerCtrl_e ctrlType, u32 playerIdx) const { +f32 dSndControlPlayerMgr_c::getAppliedPlayerVolume(u32 playerIdx) const { + if (playerIdx >= sNumPlayers) { + return 0.0f; + } + return getPlayer1(playerIdx)->GetVolume(); +} + +f32 dSndControlPlayerMgr_c::getControlVolumeTarget(PlayerCtrl_e ctrlType, u32 playerIdx) const { if (ctrlType >= CTRL_MAX) { return 1.0f; } @@ -102,3 +180,15 @@ f32 dSndControlPlayerMgr_c::getTargetValue(PlayerCtrl_e ctrlType, u32 playerIdx) } return mpCtrls[ctrlType][playerIdx].getTargetValue(); } + +void dSndControlPlayerMgr_c::setShortParameterTo5(s32 idx1, s32 idx2) { + if (idx1 >= 4) { + return; + } + + if (idx2 >= 2) { + return; + } + + field_0x3C[idx1][idx2] = 5; +} From 1657ceec3a697b621d654caf98cb70732591a876 Mon Sep 17 00:00:00 2001 From: robojumper Date: Wed, 4 Jun 2025 13:53:41 +0200 Subject: [PATCH 09/22] Remove /mgr path component for better overview --- config/SOUE01/splits.txt | 18 +++++++++--------- configure.py | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 918049bc..13fc1045 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2386,7 +2386,7 @@ d/snd/d_snd_3d_manager.cpp: .data start:0x805487D0 end:0x805487E0 .sdata2 start:0x8057D3B8 end:0x8057D3F8 -d/snd/mgr/d_snd_mgr_enemy.cpp: +d/snd/d_snd_mgr_enemy.cpp: .text start:0x80361460 end:0x8036642C align:16 .ctors start:0x804DB918 end:0x804DB91C @@ -2406,7 +2406,7 @@ d/snd/d_snd_control_player.cpp: .data start:0x80548C38 end:0x80548CC8 .sdata2 start:0x8057D938 end:0x8057D940 -d/snd/mgr/d_snd_mgr_effect.cpp: +d/snd/d_snd_mgr_effect.cpp: .text start:0x8036C6B0 end:0x8037F8B4 align:16 d/snd/d_snd_harp_mgr.cpp: @@ -2415,11 +2415,11 @@ d/snd/d_snd_harp_mgr.cpp: d/snd/d_snd_anim_sound.cpp: .text start:0x80382150 end:0x8038240C align:16 -d/snd/mgr/d_snd_mgr_unk_14.cpp: +d/snd/d_snd_mgr_unk_14.cpp: .text start:0x80382410 end:0x803864C8 align:16 .ctors start:0x804DB91C end:0x804DB920 -d/snd/mgr/d_snd_mgr_unk_13.cpp: +d/snd/d_snd_mgr_unk_13.cpp: .text start:0x803864D0 end:0x803889BC align:16 .data start:0x8054A680 end:0x8054A7D0 @@ -2428,23 +2428,23 @@ d/snd/d_snd_source.cpp: .ctors start:0x804DB920 end:0x804DB924 .data start:0x8054A7D0 end:0x8054AAE8 -d/snd/mgr/d_snd_mgr_unk_7.cpp: +d/snd/d_snd_mgr_unk_7.cpp: .text start:0x8038C410 end:0x8038EBF0 align:16 .ctors start:0x804DB924 end:0x804DB928 -d/snd/mgr/d_snd_mgr_unk_8.cpp: +d/snd/d_snd_mgr_unk_8.cpp: .text start:0x8038EBF0 end:0x8038FF18 align:16 .ctors start:0x804DB928 end:0x804DB92C -d/snd/mgr/d_snd_mgr_unk_9.cpp: +d/snd/d_snd_mgr_unk_9.cpp: .text start:0x8038FF20 end:0x80390A18 align:16 .ctors start:0x804DB92C end:0x804DB930 -d/snd/mgr/d_snd_mgr_unk_10.cpp: +d/snd/d_snd_mgr_unk_10.cpp: .text start:0x80390A20 end:0x80393DF4 align:16 .ctors start:0x804DB930 end:0x804DB934 -d/snd/mgr/d_snd_mgr_unk_11.cpp: +d/snd/d_snd_mgr_unk_11.cpp: .text start:0x80393E00 end:0x8039A848 align:16 .ctors start:0x804DB934 end:0x804DB938 diff --git a/configure.py b/configure.py index 1a15f5f4..eefbc18f 100644 --- a/configure.py +++ b/configure.py @@ -710,22 +710,22 @@ config.libs = [ Object(NonMatching, "d/snd/d_snd_player_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_control_player_mgr.cpp"), Object(Matching, "d/snd/d_snd_3d_manager.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_enemy.cpp"), + Object(NonMatching, "d/snd/d_snd_mgr_enemy.cpp"), Object(NonMatching, "d/snd/d_snd_unk_component_2.cpp"), Object(NonMatching, "d/snd/d_snd_sound_ex.cpp"), Object(Matching, "d/snd/d_snd_control_sound.cpp"), Object(Matching, "d/snd/d_snd_control_player.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_effect.cpp"), + Object(NonMatching, "d/snd/d_snd_mgr_effect.cpp"), Object(NonMatching, "d/snd/d_snd_harp_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_anim_sound.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_14.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_13.cpp"), + Object(NonMatching, "d/snd/d_snd_mgr_unk_14.cpp"), + Object(NonMatching, "d/snd/d_snd_mgr_unk_13.cpp"), Object(NonMatching, "d/snd/d_snd_source.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_7.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_8.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_9.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_10.cpp"), - Object(NonMatching, "d/snd/mgr/d_snd_mgr_unk_11.cpp"), + Object(NonMatching, "d/snd/d_snd_mgr_unk_7.cpp"), + Object(NonMatching, "d/snd/d_snd_mgr_unk_8.cpp"), + Object(NonMatching, "d/snd/d_snd_mgr_unk_9.cpp"), + Object(NonMatching, "d/snd/d_snd_mgr_unk_10.cpp"), + Object(NonMatching, "d/snd/d_snd_mgr_unk_11.cpp"), Object(NonMatching, "d/snd/d_snd_calc_pitch.cpp"), ], }, From e9935e62330417c89601d11c5f92d6a11bc18926 Mon Sep 17 00:00:00 2001 From: robojumper Date: Wed, 4 Jun 2025 18:02:32 +0200 Subject: [PATCH 10/22] small splits --- config/SOUE01/splits.txt | 18 +++++++++++++++--- configure.py | 3 ++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 13fc1045..89411d03 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2357,7 +2357,7 @@ d/snd/d_snd_actor.cpp: d/snd/d_snd_3d_actor.cpp: .text start:0x8035A8A0 end:0x8035BB78 align:16 - .data start:0x805486B0 end:0x80548710 + .data start:0x805486A0 end:0x80548710 .sdata2 start:0x8057D2C0 end:0x8057D308 d/snd/d_snd_3d_engine.cpp: @@ -2373,6 +2373,8 @@ d/snd/d_snd_sound.cpp: d/snd/d_snd_player_mgr.cpp: .text start:0x8035DA90 end:0x8035F04C align:16 .data start:0x80548758 end:0x805487A0 + .sbss start:0x80575D38 end:0x80575D40 + .sdata2 start:0x8057D380 end:0x8057D390 d/snd/d_snd_control_player_mgr.cpp: .text start:0x8035F050 end:0x80360C28 align:16 @@ -2406,14 +2408,24 @@ d/snd/d_snd_control_player.cpp: .data start:0x80548C38 end:0x80548CC8 .sdata2 start:0x8057D938 end:0x8057D940 -d/snd/d_snd_mgr_effect.cpp: - .text start:0x8036C6B0 end:0x8037F8B4 align:16 +d/snd/d_snd_unk_15.cpp: + .text start:0x8036C6B0 end:0x8037D800 align:16 + +d/snd/d_snd_effect_mgr.cpp: + .text start:0x8037D800 end:0x8037F8B4 align:16 + .data start:0x805491B8 end:0x805491D0 + .sbss start:0x80575D98 end:0x80575DA0 + .sdata2 start:0x8057DA80 end:0x8057DAD0 d/snd/d_snd_harp_mgr.cpp: .text start:0x8037F8C0 end:0x80382150 align:16 + .data start:0x805491D0 end:0x805491E0 + .sbss start:0x80575DA0 end:0x80575DA8 + .sdata2 start:0x8057DAD0 end:0x8057DB48 d/snd/d_snd_anim_sound.cpp: .text start:0x80382150 end:0x8038240C align:16 + .sdata2 start:0x8057DB50 end:0x8057DB68 d/snd/d_snd_mgr_unk_14.cpp: .text start:0x80382410 end:0x803864C8 align:16 diff --git a/configure.py b/configure.py index eefbc18f..cf06b3c6 100644 --- a/configure.py +++ b/configure.py @@ -715,7 +715,8 @@ config.libs = [ Object(NonMatching, "d/snd/d_snd_sound_ex.cpp"), Object(Matching, "d/snd/d_snd_control_sound.cpp"), Object(Matching, "d/snd/d_snd_control_player.cpp"), - Object(NonMatching, "d/snd/d_snd_mgr_effect.cpp"), + Object(NonMatching, "d/snd/d_snd_unk_15.cpp"), + Object(NonMatching, "d/snd/d_snd_effect_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_harp_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_anim_sound.cpp"), Object(NonMatching, "d/snd/d_snd_mgr_unk_14.cpp"), From 35ae04fdf94b0210446ccdebef2d66171095a124 Mon Sep 17 00:00:00 2001 From: robojumper Date: Wed, 4 Jun 2025 23:47:43 +0200 Subject: [PATCH 11/22] Refactoring --- config/SOUE01/splits.txt | 17 ++++- config/SOUE01/symbols.txt | 58 +++++++------- configure.py | 5 +- include/d/snd/d_snd_3d_actor.h | 2 - include/d/snd/d_snd_3d_manager.h | 23 +----- include/d/snd/d_snd_area_sound.h | 38 ++++++++++ include/d/snd/d_snd_area_sound_effect_mgr.h | 39 ++++++++++ include/d/snd/d_snd_control_player_mgr.h | 20 +---- include/d/snd/d_snd_player_mgr.h | 17 +---- include/d/snd/d_snd_small_effect_mgr.h | 31 ++++++++ include/d/snd/d_snd_sound.h | 14 ++-- include/d/snd/d_snd_util.h | 29 +++++++ .../snd/d_snd_wzsound.h} | 19 +---- include/nw4r/snd/snd_SoundHandle.h | 7 ++ src/REL/d/a/d_a_bombf.cpp | 2 +- src/REL/d/a/e/d_a_e_sm.cpp | 2 +- src/REL/d/a/obj/d_a_obj_tower_gearD101.cpp | 2 +- src/REL/d/a/obj/d_a_obj_tubo.cpp | 2 +- src/REL/d/a/obj/d_a_obj_tumble_weed.cpp | 3 +- src/REL/d/t/d_t_reaction.cpp | 8 +- src/d/a/d_a_insect.cpp | 2 +- src/d/a/obj/d_a_obj_switch.cpp | 2 +- src/d/a/obj/d_a_obj_tbox.cpp | 4 +- src/d/d_cs_game.cpp | 4 +- src/d/d_message.cpp | 4 +- src/d/lyt/d_lyt_bird_gauge.cpp | 4 +- src/d/lyt/d_lyt_common_a_btn.cpp | 6 +- src/d/lyt/d_lyt_common_arrow.cpp | 10 +-- src/d/lyt/d_lyt_do_button.cpp | 4 +- src/d/lyt/meter/d_lyt_meter.cpp | 6 +- src/d/lyt/meter/d_lyt_meter_cross_btn.cpp | 8 +- src/d/lyt/meter/d_lyt_meter_dowsing.cpp | 6 +- src/d/lyt/meter/d_lyt_meter_heart.cpp | 8 +- src/d/lyt/meter/d_lyt_meter_item_select.cpp | 16 ++-- src/d/lyt/meter/d_lyt_meter_key.cpp | 6 +- src/d/lyt/meter/d_lyt_meter_minus_btn.cpp | 8 +- src/d/lyt/meter/d_lyt_meter_plus_btn.cpp | 4 +- src/d/lyt/meter/d_lyt_meter_rupy.cpp | 12 +-- src/d/lyt/meter/d_lyt_meter_shield_gauge.cpp | 8 +- src/d/lyt/meter/d_lyt_meter_timer.cpp | 4 +- src/d/lyt/meter/d_lyt_meter_z_btn.cpp | 4 +- src/d/lyt/msg_window/d_lyt_msg_window.cpp | 4 +- .../d_lyt_msg_window_select_btn.cpp | 18 ++--- src/d/snd/d_snd_3d_actor.cpp | 2 +- src/d/snd/d_snd_3d_manager.cpp | 2 +- src/d/snd/d_snd_area_sound.cpp | 61 +++++++++++++++ src/d/snd/d_snd_area_sound_effect_mgr.cpp | 75 +++++++++++++++++++ src/d/snd/d_snd_control_player_mgr.cpp | 12 +-- src/d/snd/d_snd_mgr.cpp | 15 ++-- src/d/snd/d_snd_player_mgr.cpp | 2 +- src/d/snd/d_snd_small_effect_mgr.cpp | 8 ++ src/d/snd/d_snd_sound.cpp | 2 +- src/toBeSorted/save_manager.cpp | 4 +- 53 files changed, 455 insertions(+), 218 deletions(-) create mode 100644 include/d/snd/d_snd_area_sound.h create mode 100644 include/d/snd/d_snd_area_sound_effect_mgr.h create mode 100644 include/d/snd/d_snd_small_effect_mgr.h rename include/{toBeSorted/small_sound_mgr.h => d/snd/d_snd_wzsound.h} (99%) create mode 100644 src/d/snd/d_snd_area_sound.cpp create mode 100644 src/d/snd/d_snd_area_sound_effect_mgr.cpp create mode 100644 src/d/snd/d_snd_small_effect_mgr.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 89411d03..147dde46 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2386,6 +2386,7 @@ d/snd/d_snd_control_player_mgr.cpp: d/snd/d_snd_3d_manager.cpp: .text start:0x80360C30 end:0x8036145C align:16 .data start:0x805487D0 end:0x805487E0 + .sbss start:0x80575D58 end:0x80575D60 .sdata2 start:0x8057D3B8 end:0x8057D3F8 d/snd/d_snd_mgr_enemy.cpp: @@ -2393,10 +2394,18 @@ d/snd/d_snd_mgr_enemy.cpp: .ctors start:0x804DB918 end:0x804DB91C d/snd/d_snd_unk_component_2.cpp: - .text start:0x80366430 end:0x8036B8D0 align:16 + .text start:0x80366430 end:0x8036A3A4 align:16 -d/snd/d_snd_sound_ex.cpp: - .text start:0x8036B8D0 end:0x8036C090 align:16 +d/snd/d_snd_area_sound_effect_mgr.cpp: + .text start:0x8036A3B0 end:0x8036B8D0 + .data start:0x80548B38 end:0x80548B48 + .sbss start:0x80575D78 end:0x80575D80 + .sdata2 start:0x8057D8B0 end:0x8057D8E8 + +d/snd/d_snd_area_sound.cpp: + .text start:0x8036B8D0 end:0x8036C090 + .data start:0x80548B48 end:0x80548B78 + .sdata2 start:0x8057D8E8 end:0x8057D920 d/snd/d_snd_control_sound.cpp: .text start:0x8036C090 end:0x8036C444 align:16 @@ -2411,7 +2420,7 @@ d/snd/d_snd_control_player.cpp: d/snd/d_snd_unk_15.cpp: .text start:0x8036C6B0 end:0x8037D800 align:16 -d/snd/d_snd_effect_mgr.cpp: +d/snd/d_snd_small_effect_mgr.cpp: .text start:0x8037D800 end:0x8037F8B4 align:16 .data start:0x805491B8 end:0x805491D0 .sbss start:0x80575D98 end:0x80575DA0 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 5ec7e144..c314ebe9 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -19889,7 +19889,7 @@ __dt__33dSndControlSoundStrmTrackVolume_cFv = .text:0x8035C7D0; // type:function __dt__11dSndSound_cFv = .text:0x8035C810; // type:function size:0xA0 cancel__11dSndSound_cFv = .text:0x8035C8B0; // type:function size:0x84 resetControls__11dSndSound_cFv = .text:0x8035C940; // type:function size:0xE8 -executeCtrls__11dSndSound_cFv = .text:0x8035CA30; // type:function size:0xD8 +calc__11dSndSound_cFv = .text:0x8035CA30; // type:function size:0xD8 fadeIn__11dSndSound_cFUll = .text:0x8035CB10; // type:function size:0x6C stop__11dSndSound_cFl = .text:0x8035CB80; // type:function size:0xD4 pause__11dSndSound_cFbl = .text:0x8035CC60; // type:function size:0xCC @@ -20019,7 +20019,7 @@ setFxSend__22dSndControlPlayerMgr_cFUlfl = .text:0x80360510; // type:function si getAppliedPlayerVolume__22dSndControlPlayerMgr_cCFUl = .text:0x80360530; // type:function size:0x38 setControlValue__22dSndControlPlayerMgr_cFQ222dSndControlPlayerMgr_c12PlayerCtrl_eUlfl = .text:0x80360570; // type:function size:0xB0 resetControls__22dSndControlPlayerMgr_cFv = .text:0x80360620; // type:function size:0xAC -getTargetValue__22dSndControlPlayerMgr_cCFQ222dSndControlPlayerMgr_c12PlayerCtrl_eUl = .text:0x803606D0; // type:function size:0x40 +getControlTarget__22dSndControlPlayerMgr_cCFQ222dSndControlPlayerMgr_c12PlayerCtrl_eUl = .text:0x803606D0; // type:function size:0x40 fn_80360710 = .text:0x80360710; // type:function size:0x78 fn_80360790 = .text:0x80360790; // type:function size:0x5C fn_803607F0 = .text:0x803607F0; // type:function size:0x60 @@ -20335,24 +20335,24 @@ fn_8036A220 = .text:0x8036A220; // type:function size:0x3C fn_8036A260 = .text:0x8036A260; // type:function size:0x6C fn_8036A2D0 = .text:0x8036A2D0; // type:function size:0xB8 fn_8036A390 = .text:0x8036A390; // type:function size:0x14 -fn_8036A3B0 = .text:0x8036A3B0; // type:function size:0x78 -fn_8036A430 = .text:0x8036A430; // type:function size:0x48 -fn_8036A480 = .text:0x8036A480; // type:function size:0x10 -fn_8036A490 = .text:0x8036A490; // type:function size:0x88 -fn_8036A520 = .text:0x8036A520; // type:function size:0x58 -fn_8036A580 = .text:0x8036A580; // type:function size:0x74 +__dt__42SndMgrDisposer<24dSndAreaSoundEffectMgr_c>Fv = .text:0x8036A3B0; // type:function size:0x78 +create__42SndMgrDisposer<24dSndAreaSoundEffectMgr_c>Fv = .text:0x8036A430; // type:function size:0x48 +remove__42SndMgrDisposer<24dSndAreaSoundEffectMgr_c>Fv = .text:0x8036A480; // type:function size:0x10 +__ct__24dSndAreaSoundEffectMgr_cFv = .text:0x8036A490; // type:function size:0x88 +__dt__15dSndAreaSound_cFv = .text:0x8036A520; // type:function size:0x58 +calc__24dSndAreaSoundEffectMgr_cFv = .text:0x8036A580; // type:function size:0x74 fn_8036A600 = .text:0x8036A600; // type:function size:0x88 fn_8036A690 = .text:0x8036A690; // type:function size:0x9C -fn_8036A730 = .text:0x8036A730; // type:function size:0xEC +startSound__24dSndAreaSoundEffectMgr_cFUlUl = .text:0x8036A730; // type:function size:0xEC fn_8036A820 = .text:0x8036A820; // type:function size:0x328 fn_8036AB50 = .text:0x8036AB50; // type:function size:0x20 fn_8036AB70 = .text:0x8036AB70; // type:function size:0x4 fn_8036AB80 = .text:0x8036AB80; // type:function size:0x4 fn_8036AB90 = .text:0x8036AB90; // type:function size:0xFC -fn_8036AC90 = .text:0x8036AC90; // type:function size:0x68 +stopSounds__24dSndAreaSoundEffectMgr_cFl = .text:0x8036AC90; // type:function size:0x68 fn_8036AD00 = .text:0x8036AD00; // type:function size:0xB0 -fn_8036ADB0 = .text:0x8036ADB0; // type:function size:0x44 -fn_8036AE00 = .text:0x8036AE00; // type:function size:0x80 +isPlayingAnySound__24dSndAreaSoundEffectMgr_cCFv = .text:0x8036ADB0; // type:function size:0x44 +isPlayingSound__24dSndAreaSoundEffectMgr_cCFUl = .text:0x8036AE00; // type:function size:0x80 fn_8036AE80 = .text:0x8036AE80; // type:function size:0xF4 fn_8036AF80 = .text:0x8036AF80; // type:function size:0x2C fn_8036AFB0 = .text:0x8036AFB0; // type:function size:0x1C0 @@ -20364,12 +20364,12 @@ fn_8036B5C0 = .text:0x8036B5C0; // type:function size:0x6C fn_8036B630 = .text:0x8036B630; // type:function size:0x170 fn_8036B7A0 = .text:0x8036B7A0; // type:function size:0x110 fn_8036B8B0 = .text:0x8036B8B0; // type:function size:0x20 -fn_8036B8D0 = .text:0x8036B8D0; // type:function size:0x54 -fn_8036B930 = .text:0x8036B930; // type:function size:0x34 -fn_8036B970 = .text:0x8036B970; // type:function size:0xC4 -fn_8036BA40 = .text:0x8036BA40; // type:function size:0x50 -fn_8036BA90 = .text:0x8036BA90; // type:function size:0xBC -fn_8036BB50 = .text:0x8036BB50; // type:function size:0x74 +__ct__15dSndAreaSound_cFv = .text:0x8036B8D0; // type:function size:0x54 +cancel__15dSndAreaSound_cFv = .text:0x8036B930; // type:function size:0x34 +calc__15dSndAreaSound_cFv = .text:0x8036B970; // type:function size:0xC4 +fadeIn__15dSndAreaSound_cFUll = .text:0x8036BA40; // type:function size:0x50 +pause__15dSndAreaSound_cFl = .text:0x8036BA90; // type:function size:0xBC +unpause__15dSndAreaSound_cFl = .text:0x8036BB50; // type:function size:0x74 fn_8036BBD0 = .text:0x8036BBD0; // type:function size:0x24 fn_8036BC00 = .text:0x8036BC00; // type:function size:0x24 fn_8036BC30 = .text:0x8036BC30; // type:function size:0x24 @@ -20828,11 +20828,11 @@ fn_8037D640 = .text:0x8037D640; // type:function size:0x6C fn_8037D6B0 = .text:0x8037D6B0; // type:function size:0x5C fn_8037D710 = .text:0x8037D710; // type:function size:0x94 fn_8037D7B0 = .text:0x8037D7B0; // type:function size:0x50 -SoundEffectSoundMgr__dtor = .text:0x8037D800; // type:function size:0x78 -initSoundEffectSoundMgr = .text:0x8037D880; // type:function size:0x48 -SoundEffectSoundMgr__deref = .text:0x8037D8D0; // type:function size:0x10 -SoundEffectSoundMgr__ctor = .text:0x8037D8E0; // type:function size:0x9C -fn_8037D980 = .text:0x8037D980; // type:function size:0xC +__dt__38SndMgrDisposer<20dSndSmallEffectMgr_c>Fv = .text:0x8037D800; // type:function size:0x78 +create__38SndMgrDisposer<20dSndSmallEffectMgr_c>Fv = .text:0x8037D880; // type:function size:0x48 +remove__38SndMgrDisposer<20dSndSmallEffectMgr_c>Fv = .text:0x8037D8D0; // type:function size:0x10 +__ct__20dSndSmallEffectMgr_cFv = .text:0x8037D8E0; // type:function size:0x9C +__ct__Q34nw4r3snd11SoundHandleFv = .text:0x8037D980; // type:function size:0xC fn_8037D990 = .text:0x8037D990; // type:function size:0x4 fn_8037D9A0 = .text:0x8037D9A0; // type:function size:0xA0 fn_8037DA40 = .text:0x8037DA40; // type:function size:0x18 @@ -20842,13 +20842,13 @@ fn_8037DBB0 = .text:0x8037DBB0; // type:function size:0x98 fn_8037DC50 = .text:0x8037DC50; // type:function size:0x70 fn_8037DCC0 = .text:0x8037DCC0; // type:function size:0x48 fn_8037DD10 = .text:0x8037DD10; // type:function size:0x1BC -playSound__17SmallSoundManagerF7WZSound = .text:0x8037DED0; // type:function size:0x2D0 +playSound__20dSndSmallEffectMgr_cFUl = .text:0x8037DED0; // type:function size:0x2D0 fn_8037E1A0 = .text:0x8037E1A0; // type:function size:0x90 fn_8037E230 = .text:0x8037E230; // type:function size:0xEC fn_8037E320 = .text:0x8037E320; // type:function size:0x78 fn_8037E3A0 = .text:0x8037E3A0; // type:function size:0x158 fn_8037E500 = .text:0x8037E500; // type:function size:0x58 -playSoundWithPitch__17SmallSoundManagerF7WZSoundf = .text:0x8037E560; // type:function size:0xBC +playSoundWithPitch__20dSndSmallEffectMgr_cFUlf = .text:0x8037E560; // type:function size:0xBC fn_8037E620 = .text:0x8037E620; // type:function size:0xDC fn_8037E700 = .text:0x8037E700; // type:function size:0x8 fn_8037E710 = .text:0x8037E710; // type:function size:0x8 @@ -20872,7 +20872,7 @@ fn_8037EE40 = .text:0x8037EE40; // type:function size:0x3C fn_8037EE80 = .text:0x8037EE80; // type:function size:0x64 playSound = .text:0x8037EEF0; // type:function size:0xAC fn_8037EFA0 = .text:0x8037EFA0; // type:function size:0x80 -playButtonPressSoundWhenAdvancingTextBoxes__17SmallSoundManagerFf = .text:0x8037F020; // type:function size:0xB4 +playButtonPressSoundWhenAdvancingTextBoxes__20dSndSmallEffectMgr_cFf = .text:0x8037F020; // type:function size:0xB4 fn_8037F0E0 = .text:0x8037F0E0; // type:function size:0xC fn_8037F0F0 = .text:0x8037F0F0; // type:function size:0x60 fn_8037F150 = .text:0x8037F150; // type:function size:0x6D0 @@ -37733,7 +37733,7 @@ lbl_80549188 = .data:0x80549188; // type:object size:0x10 lbl_80549198 = .data:0x80549198; // type:object size:0x10 lbl_805491A8 = .data:0x805491A8; // type:object size:0x10 lbl_805491B8 = .data:0x805491B8; // type:object size:0xC -vtable5 = .data:0x805491C4; // type:object size:0xC +__vt__38SndMgrDisposer<20dSndSmallEffectMgr_c> = .data:0x805491C4; // type:object size:0xC lbl_805491D0 = .data:0x805491D0; // type:object size:0x10 jumptable_805491E0 = .data:0x805491E0; // type:object size:0x20 scope:local lbl_80549200 = .data:0x80549200; // type:object size:0x14 data:4byte @@ -41909,8 +41909,8 @@ FANFARE_SOUND_MGR_source = .sbss:0x80575D84; // type:object size:0x4 data:4byte lbl_80575D88 = .sbss:0x80575D88; // type:object size:0x8 data:4byte SOME_UNUSED_SOUND_MGR = .sbss:0x80575D90; // type:object size:0x4 data:4byte SOME_UNUSED_SOUND_MGR_source = .sbss:0x80575D94; // type:object size:0x4 data:4byte -sInstance__17SmallSoundManager = .sbss:0x80575D98; // type:object size:0x4 data:4byte -SOUND_EFFECT_SOUND_MGR_source = .sbss:0x80575D9C; // type:object size:0x4 data:4byte +sInstance__20dSndSmallEffectMgr_c = .sbss:0x80575D98; // type:object size:0x4 data:4byte +sDisposer__20dSndSmallEffectMgr_c = .sbss:0x80575D9C; // type:object size:0x4 data:4byte lbl_80575DA0 = .sbss:0x80575DA0; // type:object size:0x4 data:4byte lbl_80575DA4 = .sbss:0x80575DA4; // type:object size:0x4 data:4byte ENEMY_BGM_RELATED_MGR = .sbss:0x80575DA8; // type:object size:0x4 data:4byte diff --git a/configure.py b/configure.py index cf06b3c6..290e4bf4 100644 --- a/configure.py +++ b/configure.py @@ -712,11 +712,12 @@ config.libs = [ Object(Matching, "d/snd/d_snd_3d_manager.cpp"), Object(NonMatching, "d/snd/d_snd_mgr_enemy.cpp"), Object(NonMatching, "d/snd/d_snd_unk_component_2.cpp"), - Object(NonMatching, "d/snd/d_snd_sound_ex.cpp"), + Object(NonMatching, "d/snd/d_snd_area_sound_effect_mgr.cpp"), + Object(NonMatching, "d/snd/d_snd_area_sound.cpp"), Object(Matching, "d/snd/d_snd_control_sound.cpp"), Object(Matching, "d/snd/d_snd_control_player.cpp"), Object(NonMatching, "d/snd/d_snd_unk_15.cpp"), - Object(NonMatching, "d/snd/d_snd_effect_mgr.cpp"), + Object(NonMatching, "d/snd/d_snd_small_effect_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_harp_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_anim_sound.cpp"), Object(NonMatching, "d/snd/d_snd_mgr_unk_14.cpp"), diff --git a/include/d/snd/d_snd_3d_actor.h b/include/d/snd/d_snd_3d_actor.h index dd33d42d..5c8642f1 100644 --- a/include/d/snd/d_snd_3d_actor.h +++ b/include/d/snd/d_snd_3d_actor.h @@ -52,8 +52,6 @@ public: void updatePositionRelativeToListener(); void updateDistanceToListener(); - void resetFloats(); - bool checkFlag(u16 flag) const { return (mFlags & flag); } diff --git a/include/d/snd/d_snd_3d_manager.h b/include/d/snd/d_snd_3d_manager.h index 09b127fb..679e7963 100644 --- a/include/d/snd/d_snd_3d_manager.h +++ b/include/d/snd/d_snd_3d_manager.h @@ -9,24 +9,10 @@ #include "nw4r/snd/snd_Sound3DListener.h" #include "nw4r/snd/snd_Sound3DManager.h" -class dSnd3DManager_c; -extern template class SndMgrDisposer; +SND_DISPOSER_FORWARD_DECL(dSnd3DManager_c); class dSnd3DManager_c { -public: - SndMgrDisposer *GetDisposer() { - return &mDisposer; - } - - static dSnd3DManager_c *GetInstance() { - return sInstance; - } - - static dSnd3DManager_c *sInstance; - static SndMgrDisposer *sDisposer; - -private: - SndMgrDisposer mDisposer; + SND_DISPOSER_MEMBERS(dSnd3DManager_c); public: dSnd3DManager_c(); @@ -37,8 +23,8 @@ public: void resetCamDistance(); void calc(); void clearState(); - - nw4r::snd::Sound3DManager& getManager() { + + nw4r::snd::Sound3DManager &getManager() { return mManager; } @@ -59,7 +45,6 @@ public: } private: - void updateListenerPos(f32); /* 0x10 */ bool mIsSetup; /* 0x11 */ bool mCalculationsFresh; diff --git a/include/d/snd/d_snd_area_sound.h b/include/d/snd/d_snd_area_sound.h new file mode 100644 index 00000000..963fefeb --- /dev/null +++ b/include/d/snd/d_snd_area_sound.h @@ -0,0 +1,38 @@ +#ifndef D_SND_AREA_SOUND_H +#define D_SND_AREA_SOUND_H + +#include "common.h" +#include "d/snd/d_snd_sound.h" + +/** A sound class used for dSndAreaSoundEffectMgr */ +class dSndAreaSound_c : public dSndSound_c { +public: + dSndAreaSound_c(); + + virtual void cancel() override; // 0x08 + virtual void calc() override; // 0x0C + virtual void fadeIn(u32 id, s32 fadeFrames) override; // 0x10 + + virtual void initCallback(u32 id); // 0x28 + + typedef void (*Callback)(dSndAreaSound_c &sound); + + using dSndSound_c::pause; + + void pause(s32 fadeFrames); + void unpause(s32 fadeFrames); + +private: + bool isFadingOut() const { + return mIsFadingOut && IsAttachedSound(); + } + + /* 0x0F0 */ bool field_0xF0; + /* 0x0F4 */ Callback mpCalcCallback; + /* 0x0F8 */ UNKWORD field_0xF8; + /* 0x0FC */ UNKWORD field_0xFC; + /* 0x100 */ UNKWORD field_0x100; + /* 0x104 */ UNKWORD field_0x104; +}; + +#endif diff --git a/include/d/snd/d_snd_area_sound_effect_mgr.h b/include/d/snd/d_snd_area_sound_effect_mgr.h new file mode 100644 index 00000000..aa4f7f72 --- /dev/null +++ b/include/d/snd/d_snd_area_sound_effect_mgr.h @@ -0,0 +1,39 @@ +#ifndef D_SND_AREA_SOUND_EFFECT_MGR_H +#define D_SND_AREA_SOUND_EFFECT_MGR_H + +#include "common.h" +#include "d/snd/d_snd_actor.h" +#include "d/snd/d_snd_area_sound.h" +#include "d/snd/d_snd_util.h" + +SND_DISPOSER_FORWARD_DECL(dSndAreaSoundEffectMgr_c); + +/** + * A singleton sound actor for playing persistent environmental background + * sound effects. Turn this off and the Faron birds will stop singing. + * + * Plays sounds like SE_A_F100 (hence the name, not sure if it's the real meaning). + */ +class dSndAreaSoundEffectMgr_c { + SND_DISPOSER_MEMBERS(dSndAreaSoundEffectMgr_c) + +public: + dSndAreaSoundEffectMgr_c(); + + bool startSound(u32 soundId, u32 handleIdx); + void calc(); + void stopSounds(s32 fadeFrames); + +private: + bool isPlayingAnySound() const; + bool isPlayingSound(u32 soundId) const; + + /* 0x010 */ dSndAreaSound_c mSounds[3]; + /* 0x328 */ UNKWORD field_0x328; + /* 0x32C */ f32 field_0x32C; + /* 0x330 */ f32 field_0x330; + /* 0x334 */ dSndActor_c mActor; + /* 0x388 */ f32 field_0x388; +}; + +#endif diff --git a/include/d/snd/d_snd_control_player_mgr.h b/include/d/snd/d_snd_control_player_mgr.h index 057f2e81..d3b7654e 100644 --- a/include/d/snd/d_snd_control_player_mgr.h +++ b/include/d/snd/d_snd_control_player_mgr.h @@ -32,24 +32,10 @@ Notes on player groups: 17: TgSound */ -class dSndControlPlayerMgr_c; -extern template class SndMgrDisposer; +SND_DISPOSER_FORWARD_DECL(dSndControlPlayerMgr_c); class dSndControlPlayerMgr_c { -public: - SndMgrDisposer *GetDisposer() { - return &mDisposer; - } - - static dSndControlPlayerMgr_c *GetInstance() { - return sInstance; - } - - static dSndControlPlayerMgr_c *sInstance; - static SndMgrDisposer *sDisposer; - -private: - SndMgrDisposer mDisposer; + SND_DISPOSER_MEMBERS(dSndControlPlayerMgr_c); public: enum PlayerCtrl_e { @@ -87,7 +73,7 @@ private: void unlinkCtrl(dSndControlPlayer_c *); void setControlValue(PlayerCtrl_e ctrlType, u32 playerIdx, f32 value, s32 frames); f32 getAppliedPlayerVolume(u32 playerIdx) const; - f32 getControlVolumeTarget(PlayerCtrl_e ctrlType, u32 playerIdx) const; + f32 getControlTarget(PlayerCtrl_e ctrlType, u32 playerIdx) const; /* 0x10 */ dSndControlPlayer_c *mpCtrls[CTRL_MAX]; /* 0x1C */ f32 *mpTargetVolumes; diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h index f80a07af..81ea7e61 100644 --- a/include/d/snd/d_snd_player_mgr.h +++ b/include/d/snd/d_snd_player_mgr.h @@ -7,8 +7,7 @@ #include "nw4r/snd/snd_SoundHandle.h" #include "nw4r/snd/snd_SoundStartable.h" -class dSndPlayerMgr_c; -extern template class SndMgrDisposer; +SND_DISPOSER_FORWARD_DECL(dSndPlayerMgr_c); /** * The main interface for managing sound stuff. Will delegate to dSndMgr_c for @@ -16,19 +15,7 @@ extern template class SndMgrDisposer; */ class dSndPlayerMgr_c { public: - SndMgrDisposer *GetDisposer() { - return &mDisposer; - } - - static dSndPlayerMgr_c *GetInstance() { - return sInstance; - } - - static dSndPlayerMgr_c *sInstance; - static SndMgrDisposer *sDisposer; - -private: - SndMgrDisposer mDisposer; + SND_DISPOSER_MEMBERS(dSndPlayerMgr_c); public: dSndPlayerMgr_c(); diff --git a/include/d/snd/d_snd_small_effect_mgr.h b/include/d/snd/d_snd_small_effect_mgr.h new file mode 100644 index 00000000..84ebbfb1 --- /dev/null +++ b/include/d/snd/d_snd_small_effect_mgr.h @@ -0,0 +1,31 @@ +#ifndef D_SND_SMALL_EFFECT_MGR_H +#define D_SND_SMALL_EFFECT_MGR_H + +#include "d/snd/d_snd_util.h" +#include "d/snd/d_snd_wzsound.h" // IWYU pragma: export +#include "nw4r/snd/snd_SoundHandle.h" + + +SND_DISPOSER_FORWARD_DECL(dSndSmallEffectMgr_c); + +/** + * An interface for playing the SE_S ("sound effect, small"?) sounds. + */ +class dSndSmallEffectMgr_c { + SND_DISPOSER_MEMBERS(dSndSmallEffectMgr_c) + +public: + dSndSmallEffectMgr_c(); + + void playSound(u32 soundId); + void playSoundWithPitch(u32 soundId, f32 pitch); + void playButtonPressSoundWhenAdvancingTextBoxes(f32); + +private: + /* 0x10 */ void *field_0x10; + /* 0x14 */ void *field_0x14; + /* 0x18 */ void *field_0x18; + /* 0x1C */ nw4r::snd::SoundHandle mHandles[3]; +}; + +#endif diff --git a/include/d/snd/d_snd_sound.h b/include/d/snd/d_snd_sound.h index 78d95398..c2b865da 100644 --- a/include/d/snd/d_snd_sound.h +++ b/include/d/snd/d_snd_sound.h @@ -136,14 +136,14 @@ public: dSndSound_c(); ~dSndSound_c(); - virtual void cancel(); // 0x08 - virtual void executeCtrls(); // 0x0C - virtual void fadeIn(u32 id, s32 fadeFrames); // 0x10 + virtual void cancel(); // 0x08 + virtual void calc(); // 0x0C + virtual void fadeIn(u32 id, s32 fadeFrames); // 0x10 virtual nw4r::snd::SoundStartable::StartResult prepareSound(u32 soundId, u32 startOffset); // 0x14 virtual nw4r::snd::SoundStartable::StartResult prepareSound(const char *label, u32 startOffset); // 0x18 - virtual void onPreparing(u32 soundId, u32 startOffset); // 0x1C - virtual void stop(s32 fadeFrames); // 0x20 - virtual void pause(bool pauseFlag, s32 fadeFrames); // 0x24 + virtual void onPreparing(u32 soundId, u32 startOffset); // 0x1C + virtual void stop(s32 fadeFrames); // 0x20 + virtual void pause(bool pauseFlag, s32 fadeFrames); // 0x24 bool isStrmSound(); bool isWaveSound(); @@ -173,7 +173,7 @@ public: void linkCtrl(dSndControlSound_c *); void unlinkCtrl(dSndControlSound_c *); -private: +protected: bool cannotStart() const { return mIsRunning && !mIsFadingOut && IsAttachedSound(); } diff --git a/include/d/snd/d_snd_util.h b/include/d/snd/d_snd_util.h index 164ae3df..5040fa50 100644 --- a/include/d/snd/d_snd_util.h +++ b/include/d/snd/d_snd_util.h @@ -39,4 +39,33 @@ void SndMgrDisposer::remove() { T::sDisposer = nullptr; } +#define SND_DISPOSER_FORWARD_DECL(class_name) \ + class class_name; \ + extern template class SndMgrDisposer; + +#define SND_DISPOSER_DEFINE(class_name) \ + template class SndMgrDisposer; \ + class_name *class_name::sInstance; \ + SndMgrDisposer *class_name::sDisposer; + +#define SND_DISPOSER_MEMBERS(class_name) \ +public: \ + SndMgrDisposer *GetDisposer() { \ + return &mDisposer; \ + } \ + \ + static class_name *GetInstance() { \ + return sInstance; \ + } \ + \ + static void create() { \ + SndMgrDisposer::create(); \ + } \ + \ + static class_name *sInstance; \ + static SndMgrDisposer *sDisposer; \ + \ +private: \ + SndMgrDisposer mDisposer; + #endif diff --git a/include/toBeSorted/small_sound_mgr.h b/include/d/snd/d_snd_wzsound.h similarity index 99% rename from include/toBeSorted/small_sound_mgr.h rename to include/d/snd/d_snd_wzsound.h index 06978ad1..63da34c9 100644 --- a/include/toBeSorted/small_sound_mgr.h +++ b/include/d/snd/d_snd_wzsound.h @@ -1,9 +1,8 @@ -#ifndef SMALL_SOUND_MGR_H -#define SMALL_SOUND_MGR_H +#ifndef D_SND_WZSOUND_H +#define D_SND_WZSOUND_H // Thanks kiwi! https://gist.github.com/kiwi515/47bb17b07ed502bdfa7faa60bc48a3c7 -#include "common.h" enum WZSound { /* 0x0000 */ SE_L_FLIPED, /* 0x0001 */ SE_L_FS_START, @@ -6469,18 +6468,4 @@ enum WZSound { /* 0x193D */ LABEL_SOUND_END }; -class SmallSoundManager { -public: - void playSound(WZSound id); - void playSoundWithPitch(WZSound id, f32 pitch); - void playButtonPressSoundWhenAdvancingTextBoxes(f32); - - static SmallSoundManager *GetInstance() { - return sInstance; - } - -private: - static SmallSoundManager *sInstance; -}; - #endif diff --git a/include/nw4r/snd/snd_SoundHandle.h b/include/nw4r/snd/snd_SoundHandle.h index 5c969c1c..bca2c59a 100644 --- a/include/nw4r/snd/snd_SoundHandle.h +++ b/include/nw4r/snd/snd_SoundHandle.h @@ -64,6 +64,13 @@ namespace nw4r { namespace snd return IsAttachedSound() && mSound->IsPause(); } + int GetRemainingFadeFrames() const { + if (IsAttachedSound()) + return mSound->GetRemainingFadeFrames(); + + return 0; + } + u32 GetId() const { if (IsAttachedSound()) diff --git a/src/REL/d/a/d_a_bombf.cpp b/src/REL/d/a/d_a_bombf.cpp index b664ce01..72456bae 100644 --- a/src/REL/d/a/d_a_bombf.cpp +++ b/src/REL/d/a/d_a_bombf.cpp @@ -5,9 +5,9 @@ #include "d/col/bg/d_bg_s.h" #include "d/col/bg/d_bg_s_lin_chk.h" #include "d/flag/sceneflag_manager.h" +#include "d/snd/d_snd_wzsound.h" #include "m/m_mtx.h" #include "m/m_vec.h" -#include "toBeSorted/small_sound_mgr.h" #include "toBeSorted/time_area_mgr.h" SPECIAL_ACTOR_PROFILE(BOMBF, dAcBombf_c, fProfile::BOMBF, 0x129, 0, 4099); diff --git a/src/REL/d/a/e/d_a_e_sm.cpp b/src/REL/d/a/e/d_a_e_sm.cpp index 6b6e4131..ed250e13 100644 --- a/src/REL/d/a/e/d_a_e_sm.cpp +++ b/src/REL/d/a/e/d_a_e_sm.cpp @@ -20,6 +20,7 @@ #include "d/d_sc_game.h" #include "d/flag/sceneflag_manager.h" #include "d/flag/storyflag_manager.h" +#include "d/snd/d_snd_wzsound.h" #include "f/f_base.h" #include "f/f_profile_name.h" #include "m/m3d/m_fanm.h" @@ -38,7 +39,6 @@ #include "s/s_Math.h" #include "toBeSorted/blur_and_palette_manager.h" #include "toBeSorted/d_emitter.h" -#include "toBeSorted/small_sound_mgr.h" #include "toBeSorted/time_area_mgr.h" #include diff --git a/src/REL/d/a/obj/d_a_obj_tower_gearD101.cpp b/src/REL/d/a/obj/d_a_obj_tower_gearD101.cpp index 0a2200b8..cee568bd 100644 --- a/src/REL/d/a/obj/d_a_obj_tower_gearD101.cpp +++ b/src/REL/d/a/obj/d_a_obj_tower_gearD101.cpp @@ -5,12 +5,12 @@ #include "d/a/obj/d_a_obj_tower_D101.h" #include "d/col/bg/d_bg_s_wtr_chk.h" #include "d/d_stage.h" +#include "d/snd/d_snd_wzsound.h" #include "f/f_base.h" #include "f/f_manager.h" #include "f/f_profile_name.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resmdl.h" -#include "toBeSorted/small_sound_mgr.h" SPECIAL_ACTOR_PROFILE(OBJ_TOWER_GEAR_D101, dAcOTowerGearD101_c, fProfile::OBJ_TOWER_GEAR_D101, 0x17E, 0, 7); diff --git a/src/REL/d/a/obj/d_a_obj_tubo.cpp b/src/REL/d/a/obj/d_a_obj_tubo.cpp index bfcb4ba7..caa6aa53 100644 --- a/src/REL/d/a/obj/d_a_obj_tubo.cpp +++ b/src/REL/d/a/obj/d_a_obj_tubo.cpp @@ -20,6 +20,7 @@ #include "d/d_linkage.h" #include "d/flag/dungeonflag_manager.h" #include "d/flag/sceneflag_manager.h" +#include "d/snd/d_snd_wzsound.h" #include "egg/math/eggMath.h" #include "f/f_manager.h" #include "f/f_profile_name.h" @@ -34,7 +35,6 @@ #include "toBeSorted/blur_and_palette_manager.h" #include "toBeSorted/d_emitter.h" #include "toBeSorted/event_manager.h" -#include "toBeSorted/small_sound_mgr.h" #include "toBeSorted/special_item_drop_mgr.h" void float_ordering() { diff --git a/src/REL/d/a/obj/d_a_obj_tumble_weed.cpp b/src/REL/d/a/obj/d_a_obj_tumble_weed.cpp index 52890a43..0f28877d 100644 --- a/src/REL/d/a/obj/d_a_obj_tumble_weed.cpp +++ b/src/REL/d/a/obj/d_a_obj_tumble_weed.cpp @@ -10,6 +10,7 @@ #include "d/col/c/c_m3d_g_pla.h" #include "d/col/cc/d_cc_d.h" #include "d/col/cc/d_cc_s.h" +#include "d/snd/d_snd_wzsound.h" #include "egg/math/eggMath.h" #include "egg/math/eggQuat.h" #include "m/m_angle.h" @@ -20,8 +21,6 @@ #include "toBeSorted/blur_and_palette_manager.h" #include "toBeSorted/d_emitter.h" #include "toBeSorted/dowsing_target.h" -#include "toBeSorted/small_sound_mgr.h" - void float_ordering() { const f32 arr[] = {5.f, 15.f, 7.f, 0.5f, 0.1f}; diff --git a/src/REL/d/t/d_t_reaction.cpp b/src/REL/d/t/d_t_reaction.cpp index 9c8f32d1..99c50aef 100644 --- a/src/REL/d/t/d_t_reaction.cpp +++ b/src/REL/d/t/d_t_reaction.cpp @@ -9,8 +9,8 @@ #include "d/d_pouch.h" #include "d/d_sc_game.h" #include "d/flag/sceneflag_manager.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "m/m_angle.h" -#include "toBeSorted/small_sound_mgr.h" SPECIAL_ACTOR_PROFILE(TAG_REACTION, dTgReaction_c, fProfile::TAG_REACTION, 0x0151, 0, 0); @@ -172,7 +172,7 @@ void dTgReaction_c::checkForBonkItem() { if (dAcObjBase_c::create(fProfile::ITEM, roomid, newItemParms, &c2, nullptr, nullptr, 0xFFFFFFFF)) { field_0x4DD = 1; onDelete(); - SmallSoundManager::GetInstance()->playSound(SE_S_READ_RIDDLE_A); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_READ_RIDDLE_A); } } } else { @@ -194,7 +194,7 @@ void dTgReaction_c::checkForBonkItem() { pos.y += field_0x4E4; if (fn_578_DB0(pos, uVar3)) { - SmallSoundManager::GetInstance()->playSound(SE_S_READ_RIDDLE_B); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_READ_RIDDLE_B); } SceneflagManager::sInstance->setFlag(roomid, getSceneFlag()); onDelete(); @@ -228,7 +228,7 @@ void dTgReaction_c::checkForSlingBellowsItem() { mVec3_c spawnPos = position; spawnPos.y += field_0x4E4; if (fn_578_DB0(spawnPos, uVar3)) { - SmallSoundManager::GetInstance()->playSound(SE_S_READ_RIDDLE_B); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_READ_RIDDLE_B); } SceneflagManager::sInstance->setFlag(roomid, getSceneFlag()); onDelete(); diff --git a/src/d/a/d_a_insect.cpp b/src/d/a/d_a_insect.cpp index db7c66fb..b93cac0d 100644 --- a/src/d/a/d_a_insect.cpp +++ b/src/d/a/d_a_insect.cpp @@ -10,12 +10,12 @@ #include "d/col/bg/d_bg_w_base.h" #include "d/col/c/c_cc_d.h" #include "d/col/c/c_m3d_g_pla.h" +#include "d/snd/d_snd_wzsound.h" #include "m/m_angle.h" #include "m/m_mtx.h" #include "m/m_vec.h" #include "toBeSorted/attention.h" #include "toBeSorted/d_emitter.h" -#include "toBeSorted/small_sound_mgr.h" void dAcOInsect_c::kill() { dJEffManager_c::spawnEffect(PARTICLE_RESOURCE_ID_MAPPING_394_, position, nullptr, nullptr, nullptr, nullptr, 0, 0); diff --git a/src/d/a/obj/d_a_obj_switch.cpp b/src/d/a/obj/d_a_obj_switch.cpp index efb49d97..d64f90bb 100644 --- a/src/d/a/obj/d_a_obj_switch.cpp +++ b/src/d/a/obj/d_a_obj_switch.cpp @@ -6,10 +6,10 @@ #include "d/d_linkage.h" #include "d/d_rumble.h" #include "d/flag/sceneflag_manager.h" +#include "d/snd/d_snd_wzsound.h" #include "nw4r/g3d/res/g3d_resfile.h" #include "s/s_Math.h" #include "toBeSorted/d_emitter.h" -#include "toBeSorted/small_sound_mgr.h" SPECIAL_ACTOR_PROFILE(OBJ_SW, dAcOsw_c, fProfile::OBJ_SW, 0x12B, 0, 0x1002); diff --git a/src/d/a/obj/d_a_obj_tbox.cpp b/src/d/a/obj/d_a_obj_tbox.cpp index eea6e056..939a36b3 100644 --- a/src/d/a/obj/d_a_obj_tbox.cpp +++ b/src/d/a/obj/d_a_obj_tbox.cpp @@ -17,6 +17,7 @@ #include "d/flag/sceneflag_manager.h" #include "d/flag/storyflag_manager.h" #include "d/flag/tboxflag_manager.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "d/t/d_t_siren.h" #include "m/m3d/m_fanm.h" #include "m/m3d/m_scnleaf.h" @@ -35,7 +36,6 @@ #include "toBeSorted/counters/goddess_chest_counter.h" #include "toBeSorted/dowsing_target.h" #include "toBeSorted/event_manager.h" -#include "toBeSorted/small_sound_mgr.h" SPECIAL_ACTOR_PROFILE(TBOX, dAcTbox_c, fProfile::TBOX, 0x018D, 0, 6); @@ -1781,7 +1781,7 @@ void dAcTbox_c::executeState_DemoAppear() { if (isStop && mAnmMatClr1.isStop(0) && field_0x11F8 > 0x5A) { mEvent.advanceNext(); mStateMgr.changeState(StateID_WaitOpen); - SmallSoundManager::GetInstance()->playSound(SE_S_READ_RIDDLE_A); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_READ_RIDDLE_A); } } } diff --git a/src/d/d_cs_game.cpp b/src/d/d_cs_game.cpp index 5ab406a5..da22bbef 100644 --- a/src/d/d_cs_game.cpp +++ b/src/d/d_cs_game.cpp @@ -3,9 +3,9 @@ #include "d/d_cs_base.h" #include "d/d_cursor_hit_check.h" #include "d/lyt/d2d.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "f/f_base.h" #include "toBeSorted/arc_managers/layout_arc_manager.h" -#include "toBeSorted/small_sound_mgr.h" SPECIAL_BASE_PROFILE(C_GAME, dCsGame_c, fProfile::C_GAME, 0x2BF, 0x06F9); @@ -407,7 +407,7 @@ void dCsGame_c::lytItemCursor_c::lytBowCsr_c::executeState_Charge() { if (!mAnm[MAIN_ANIM_ARROW_PEAK].isEnabled()) { mAnm[MAIN_ANIM_ARROW_PEAK].setAnimEnable(true); mAnm[MAIN_ANIM_ARROW_PEAK].setFrame(0.0f); - SmallSoundManager::GetInstance()->playSound(SE_S_BW_ALIGN_SIGHT); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_BW_ALIGN_SIGHT); } mAnm[MAIN_ANIM_ARROW_KEEP].setAnimEnable(false); } else { diff --git a/src/d/d_message.cpp b/src/d/d_message.cpp index 83add314..5340403e 100644 --- a/src/d/d_message.cpp +++ b/src/d/d_message.cpp @@ -22,6 +22,7 @@ #include "d/lyt/d_lyt_mini_game.h" #include "d/lyt/meter/d_lyt_meter.h" #include "d/lyt/msg_window/d_lyt_msg_window.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "egg/core/eggHeap.h" #include "f/f_base.h" #include "f/f_profile.h" @@ -38,7 +39,6 @@ #include "toBeSorted/file_manager.h" #include "toBeSorted/minigame_mgr.h" #include "toBeSorted/music_mgrs.h" -#include "toBeSorted/small_sound_mgr.h" #include "toBeSorted/unk_save_time.h" #include "rvl/OS.h" @@ -216,7 +216,7 @@ void dFlow_c::playSound(u32 params) { switch (sSoundDefs[idx].mSoundMgr) { case 0: AnotherSoundMgr__playSound(FANFARE_SOUND_MGR, sSoundDefs[idx].mSoundId); break; - case 1: SmallSoundManager::GetInstance()->playSound(sSoundDefs[idx].mSoundId); break; + case 1: dSndSmallEffectMgr_c::GetInstance()->playSound(sSoundDefs[idx].mSoundId); break; } } diff --git a/src/d/lyt/d_lyt_bird_gauge.cpp b/src/d/lyt/d_lyt_bird_gauge.cpp index 9ed904f1..cb8f2e08 100644 --- a/src/d/lyt/d_lyt_bird_gauge.cpp +++ b/src/d/lyt/d_lyt_bird_gauge.cpp @@ -1,7 +1,7 @@ #include "d/lyt/d_lyt_bird_gauge.h" #include "common.h" -#include "toBeSorted/small_sound_mgr.h" +#include "d/snd/d_snd_small_effect_mgr.h" STATE_DEFINE(dLytBirdGaugeMain_c, ModeNone); STATE_DEFINE(dLytBirdGaugeMain_c, ModeIn); @@ -181,7 +181,7 @@ void dLytBirdGaugeMain_c::changeToRecovery() { mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_RECOVERY + mNumDisplayedDashes].setAnimEnable(true); mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_RECOVERY + mNumDisplayedDashes].setFrame(0.0f); mLyt.calc(); - SmallSoundManager::GetInstance()->playSound(SE_S_BIRD_RECOVER); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_BIRD_RECOVER); mStateMgr.changeState(StateID_ModeRecovery); mIsAnimating = false; mNumDisplayedDashes++; diff --git a/src/d/lyt/d_lyt_common_a_btn.cpp b/src/d/lyt/d_lyt_common_a_btn.cpp index f484e1e5..d32f69c3 100644 --- a/src/d/lyt/d_lyt_common_a_btn.cpp +++ b/src/d/lyt/d_lyt_common_a_btn.cpp @@ -5,7 +5,7 @@ #include "common.h" #include "d/d_sys.h" #include "d/lyt/d2d.h" -#include "toBeSorted/small_sound_mgr.h" +#include "d/snd/d_snd_small_effect_mgr.h" static const d2d::LytBrlanMapping brlanMap[] = { { "aBtn_00_in.brlan", "G_inOut_00"}, @@ -186,9 +186,9 @@ void dLytCommonABtn_c::goToStateDecideOut() { anm.setRate(1.0f); } if (mSoundVariant == VARIANT_NORMAL) { - SmallSoundManager::GetInstance()->playSound(SE_S_WINDOW_PRESS_A); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_WINDOW_PRESS_A); } else { - SmallSoundManager::GetInstance()->playSound(SE_S_TITLE_PRESS_START); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_TITLE_PRESS_START); } } } diff --git a/src/d/lyt/d_lyt_common_arrow.cpp b/src/d/lyt/d_lyt_common_arrow.cpp index 1b9d859d..393f5068 100644 --- a/src/d/lyt/d_lyt_common_arrow.cpp +++ b/src/d/lyt/d_lyt_common_arrow.cpp @@ -2,9 +2,9 @@ #include "d/d_cs_base.h" #include "d/d_cursor_hit_check.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "rvl/MTX/mtx.h" #include "toBeSorted/arc_managers/layout_arc_manager.h" -#include "toBeSorted/small_sound_mgr.h" STATE_DEFINE(dLytCommonArrow_c, None); STATE_DEFINE(dLytCommonArrow_c, In); @@ -262,9 +262,9 @@ void dLytCommonArrow_c::executeState_Wait() { if (field_0x6C0 != 2) { displayElement(field_0x6C0 + ANIM_DECIDE_OFFSET, 0.0f); if (field_0x6C0 == 0) { - SmallSoundManager::GetInstance()->playSound(SE_S_MENU_SELECT_TURN_PAGE_LEFT); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MENU_SELECT_TURN_PAGE_LEFT); } else { - SmallSoundManager::GetInstance()->playSound(SE_S_MENU_SELECT_TURN_PAGE_RIGHT); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MENU_SELECT_TURN_PAGE_RIGHT); } mTimer++; } @@ -287,9 +287,9 @@ void dLytCommonArrow_c::executeState_Wait() { if (field_0x6BC != field_0x6B8 && field_0x6B8 != 2) { if (field_0x6B8 == 0) { - SmallSoundManager::GetInstance()->playSound(SE_S_MENU_POINT_TURN_PAGE_LEFT); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MENU_POINT_TURN_PAGE_LEFT); } else { - SmallSoundManager::GetInstance()->playSound(SE_S_MENU_POINT_TURN_PAGE_RIGHT); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MENU_POINT_TURN_PAGE_RIGHT); } } } diff --git a/src/d/lyt/d_lyt_do_button.cpp b/src/d/lyt/d_lyt_do_button.cpp index 9f4fc89e..c47df16f 100644 --- a/src/d/lyt/d_lyt_do_button.cpp +++ b/src/d/lyt/d_lyt_do_button.cpp @@ -3,12 +3,12 @@ #include "common.h" #include "d/a/d_a_player.h" #include "d/lyt/meter/d_lyt_meter.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "nw4r/lyt/lyt_pane.h" #include "nw4r/lyt/lyt_types.h" #include "nw4r/math/math_types.h" #include "sized_string.h" #include "toBeSorted/event_manager.h" -#include "toBeSorted/small_sound_mgr.h" struct DoButtonClass { DoButtonClass(); @@ -639,7 +639,7 @@ void dLytDobutton_c::realize() { } if (mDoActionToShow == ACT_DO_CATCH) { - SmallSoundManager::GetInstance()->playSound(SE_S_CALL_BIRD_CATCH); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_CALL_BIRD_CATCH); } } diff --git a/src/d/lyt/meter/d_lyt_meter.cpp b/src/d/lyt/meter/d_lyt_meter.cpp index 00789d34..6a565c82 100644 --- a/src/d/lyt/meter/d_lyt_meter.cpp +++ b/src/d/lyt/meter/d_lyt_meter.cpp @@ -31,6 +31,7 @@ #include "d/lyt/d_lyt_sky_gauge.h" #include "d/lyt/msg_window/d_lyt_msg_window.h" #include "d/lyt/msg_window/d_lyt_simple_window.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "f/f_manager.h" #include "f/f_profile_name.h" #include "m/m_vec.h" @@ -40,7 +41,6 @@ #include "toBeSorted/event_manager.h" #include "toBeSorted/minigame_mgr.h" #include "toBeSorted/misc_actor.h" -#include "toBeSorted/small_sound_mgr.h" // clang-format on static dLytMeterConfiguration_c sConf; @@ -207,7 +207,7 @@ bool dLytMeter1Button_c::execute() { if (mAnm[BUTTON_1_ANIM_CALL].isEnabled()) { mAnm[BUTTON_1_ANIM_CALL].play(); if (meter->checkAllFlags(METER_BTN_1) && mCallCount < 3 && mAnm[BUTTON_1_ANIM_CALL].getFrame() == 1.0f) { - SmallSoundManager::GetInstance()->playSound(SE_S_1_BUTTON_BLINK); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_1_BUTTON_BLINK); mCallCount++; } } @@ -384,7 +384,7 @@ bool dLytMeter2Button_c::execute() { if (mAnm[BUTTON_1_ANIM_CALL].isEnabled()) { mAnm[BUTTON_1_ANIM_CALL].play(); if (meter->checkAllFlags(METER_BTN_2) && mCallCount < 3 && mAnm[BUTTON_1_ANIM_CALL].getFrame() == 1.0f) { - SmallSoundManager::GetInstance()->playSound(SE_S_2_BUTTON_BLINK); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_2_BUTTON_BLINK); mCallCount++; } } diff --git a/src/d/lyt/meter/d_lyt_meter_cross_btn.cpp b/src/d/lyt/meter/d_lyt_meter_cross_btn.cpp index c34e4d04..189c41eb 100644 --- a/src/d/lyt/meter/d_lyt_meter_cross_btn.cpp +++ b/src/d/lyt/meter/d_lyt_meter_cross_btn.cpp @@ -7,10 +7,10 @@ #include "d/lyt/d2d.h" #include "d/lyt/d_lyt_unknowns.h" #include "d/lyt/meter/d_lyt_meter.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "toBeSorted/event_manager.h" #include "toBeSorted/fi_context.h" #include "toBeSorted/misc_actor.h" -#include "toBeSorted/small_sound_mgr.h" STATE_DEFINE(dLytMeterCrossBtnParts_c, Wait); STATE_DEFINE(dLytMeterCrossBtnParts_c, On); @@ -504,7 +504,7 @@ bool dLytMeterCrossBtn_c::execute() { mAnm[CROSS_BTN_ANIM_CALL_0].play(); if (mParts[CROSS_BTN_PART_DOWN].isActive() && mCallCount0 < 3 && mAnm[CROSS_BTN_ANIM_CALL_0].getFrame() == 1.0f) { - SmallSoundManager::GetInstance()->playSound(SE_S_SG_CALL); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SG_CALL); mCallCount0++; } } @@ -525,7 +525,7 @@ bool dLytMeterCrossBtn_c::execute() { mAnm[CROSS_BTN_ANIM_CALL_1].play(); if (mParts[CROSS_BTN_PART_TOP].isActive() && mCallCount1 < 3 && mAnm[CROSS_BTN_ANIM_CALL_1].getFrame() == 1.0f) { - SmallSoundManager::GetInstance()->playSound(SE_S_CATAPULT_READY); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_CATAPULT_READY); mCallCount1++; } } @@ -546,7 +546,7 @@ bool dLytMeterCrossBtn_c::execute() { if (mAnm[CROSS_BTN_ANIM_CALL_2].isEnabled()) { mAnm[CROSS_BTN_ANIM_CALL_2].play(); if (mParts[CROSS_BTN_PART_DOWN].isActive() && mAnm[CROSS_BTN_ANIM_CALL_2].getFrame() == 1.0f) { - SmallSoundManager::GetInstance()->playSound(SE_S_BIRD_CALL); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_BIRD_CALL); } } } diff --git a/src/d/lyt/meter/d_lyt_meter_dowsing.cpp b/src/d/lyt/meter/d_lyt_meter_dowsing.cpp index 65f4905f..a7b426a4 100644 --- a/src/d/lyt/meter/d_lyt_meter_dowsing.cpp +++ b/src/d/lyt/meter/d_lyt_meter_dowsing.cpp @@ -10,6 +10,7 @@ #include "d/lyt/d_lyt_util_items.h" #include "d/lyt/d_window.h" #include "d/lyt/meter/d_lyt_meter.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "m/m_vec.h" #include "nw4r/lyt/lyt_group.h" #include "nw4r/math/math_types.h" @@ -17,7 +18,6 @@ #include "toBeSorted/d_emitter.h" #include "toBeSorted/dowsing_target.h" #include "toBeSorted/file_manager.h" -#include "toBeSorted/small_sound_mgr.h" STATE_DEFINE(dLytMeterDowsingMenuIcon_c, Wait); STATE_DEFINE(dLytMeterDowsingMenuIcon_c, On); @@ -717,7 +717,7 @@ void dLytMeterDowsing_c::executeState_DemoMove() { nw4r::math::MTX34 mtx = mpPanes[idx]->GetGlobalMtx(); mVec3_c pos(mtx._03, mtx._13, 0.0f); dJEffManager_c::spawnUIEffect(PARTICLE_RESOURCE_ID_MAPPING_970_, pos, nullptr, nullptr, nullptr, nullptr); - SmallSoundManager::GetInstance()->playSound(SE_S_DOWSING_ADD); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_DOWSING_ADD); } } else if (mDemoFrame == 16) { for (int i = 0; i < DOWSING_NUM_ITEMS; i++) { @@ -1010,7 +1010,7 @@ bool dLytMeterDowsing_c::execute() { if (mAnm[DOWSING_ANIM_CALL].isEnabled()) { mAnm[DOWSING_ANIM_CALL].play(); if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_C) && mAnm[DOWSING_ANIM_CALL].getFrame() == 1.0f) { - SmallSoundManager::GetInstance()->playSound(SE_S_C_BUTTON_BLINK); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_C_BUTTON_BLINK); } } } else if (field_0x5509 == 1) { diff --git a/src/d/lyt/meter/d_lyt_meter_heart.cpp b/src/d/lyt/meter/d_lyt_meter_heart.cpp index 96b685c2..74e5fc6e 100644 --- a/src/d/lyt/meter/d_lyt_meter_heart.cpp +++ b/src/d/lyt/meter/d_lyt_meter_heart.cpp @@ -5,11 +5,11 @@ #include "d/d_sc_game.h" #include "d/lyt/d2d.h" #include "d/lyt/d_lyt_game_over.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "nw4r/math/math_types.h" #include "toBeSorted/d_emitter.h" #include "toBeSorted/event_manager.h" #include "toBeSorted/file_manager.h" -#include "toBeSorted/small_sound_mgr.h" static const d2d::LytBrlanMapping brlanMap[] = { { "heartAll_00_heat.brlan", "G_heart_00"}, @@ -288,7 +288,7 @@ void dLytMeterHeart_c::executeInternal() { nw4r::math::MTX34 mtx = mpHeartPanes[mEffectHeartIdx]->GetGlobalMtx(); mVec3_c pos(mtx._03, mtx._13, 0.0f); dJEffManager_c::spawnUIEffect(PARTICLE_RESOURCE_ID_MAPPING_972_, pos, nullptr, nullptr, nullptr, nullptr); - SmallSoundManager::GetInstance()->playSound(SE_S_HEART_ADD); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_HEART_ADD); mEffectHeartIdx = -1; } @@ -323,14 +323,14 @@ void dLytMeterHeart_c::executeInternal() { if (mpAlphaPane->IsVisible() && mpAlphaPane->GetGlobalAlpha() != 0 && mStoredHealth % 4 == 0 && (!(dScGame_c::currentSpawnInfo.stageName == "F406") || dScGame_c::currentSpawnInfo.layer != 13) && dLytGameOver_c::GetInstance() == nullptr) { - SmallSoundManager::GetInstance()->playSound(SE_S_HP_GAUGE_UP); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_HP_GAUGE_UP); } } else { if (mStoredHealth - 1 >= current) { mStoredHealth = mStoredHealth - 1; if (EventManager::isInEvent() && !strcmp(EventManager::getCurrentEventName(), ("MoleF202Start")) && mStoredHealth % 4 == 0) { - SmallSoundManager::GetInstance()->playSound(SE_S_HP_GAUGE_DOWN); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_HP_GAUGE_DOWN); } } } diff --git a/src/d/lyt/meter/d_lyt_meter_item_select.cpp b/src/d/lyt/meter/d_lyt_meter_item_select.cpp index 159b5cd0..a8f6452b 100644 --- a/src/d/lyt/meter/d_lyt_meter_item_select.cpp +++ b/src/d/lyt/meter/d_lyt_meter_item_select.cpp @@ -13,6 +13,7 @@ #include "d/lyt/d_lyt_do_button.h" #include "d/lyt/d_lyt_unknowns.h" #include "d/lyt/meter/d_lyt_meter.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "m/m_vec.h" #include "nw4r/lyt/lyt_group.h" #include "nw4r/math/math_types.h" @@ -22,7 +23,6 @@ #include "toBeSorted/event_manager.h" #include "toBeSorted/minigame_mgr.h" #include "toBeSorted/misc_actor.h" -#include "toBeSorted/small_sound_mgr.h" STATE_DEFINE(dLytMeterItemSelectIcon_c, Wait); STATE_DEFINE(dLytMeterItemSelectIcon_c, On); @@ -1392,7 +1392,7 @@ void dLytMeterItemSelect_c::initializeState_DemoMove() { mAnm[i + ITEM_SELECT_ANIM_HAVE_OFFSET].setAnimEnable(false); } - SmallSoundManager::GetInstance()->playSound(SE_S_GET_ITEM_SET); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_GET_ITEM_SET); } void dLytMeterItemSelect_c::executeState_DemoMove() { @@ -1988,7 +1988,7 @@ bool dLytMeterItemSelect_c::execute() { if (dLytDobutton_c::getField0x47C() == dLytDobutton_c::ACT_DO_SAILCLOTH) { if (field_0x5774 == 0) { - SmallSoundManager::GetInstance()->playSound(SE_S_PARACHUTE_CALL); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_PARACHUTE_CALL); } field_0x5774++; if (field_0x5774 >= mAnm[ITEM_SELECT_ANIM_CALL].getAnimDuration() / 2.0f) { @@ -2058,11 +2058,11 @@ bool dLytMeterItemSelect_c::execute() { mAnm[ITEM_SELECT_ANIM_FULL].setFrame(0.0f); mAnm[ITEM_SELECT_ANIM_FULL].setAnimEnable(true); if (field_0x5797 == I_BOMB_BAG) { - SmallSoundManager::GetInstance()->playSound(SE_S_BM_MAX); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_BM_MAX); } else if (field_0x5797 == I_BOW) { - SmallSoundManager::GetInstance()->playSound(SE_S_AW_MAX); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_AW_MAX); } else if (field_0x5797 == I_SLINGSHOT) { - SmallSoundManager::GetInstance()->playSound(SE_S_PC_MAX); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_PC_MAX); } } field_0x57B7 = false; @@ -2094,7 +2094,7 @@ bool dLytMeterItemSelect_c::execute() { mAnm[ITEM_SELECT_ANIM_CALL].play(); if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_B) && mAnm[ITEM_SELECT_ANIM_CALL].getFrame() == 1.0f) { - SmallSoundManager::GetInstance()->playSound(SE_S_B_BUTTON_BLINK); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_B_BUTTON_BLINK); } } b2 = true; @@ -2115,7 +2115,7 @@ bool dLytMeterItemSelect_c::execute() { mAnm[ITEM_SELECT_ANIM_CALL].play(); if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_B) && mAnm[ITEM_SELECT_ANIM_CALL].getFrame() == 1.0f) { - SmallSoundManager::GetInstance()->playSound(SE_S_PARACHUTE_CALL); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_PARACHUTE_CALL); } } b2 = true; diff --git a/src/d/lyt/meter/d_lyt_meter_key.cpp b/src/d/lyt/meter/d_lyt_meter_key.cpp index 824d4f10..7cd744d4 100644 --- a/src/d/lyt/meter/d_lyt_meter_key.cpp +++ b/src/d/lyt/meter/d_lyt_meter_key.cpp @@ -5,9 +5,9 @@ #include "d/a/d_a_item.h" #include "d/d_stage_mgr.h" #include "d/lyt/d2d.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "m/m_vec.h" #include "nw4r/lyt/lyt_pane.h" -#include "toBeSorted/small_sound_mgr.h" STATE_DEFINE(dLytMeterKakeraKey_c, Wait); STATE_DEFINE(dLytMeterKakeraKey_c, On); @@ -87,9 +87,9 @@ void dLytMeterKakeraKey_c::initializeState_Increase() { mAnm[mNextKeyPieceCount - 1 + KEY_KAKERA_ANIM_NUMBER_OFFSET].setFrame(0.0f); mSavedKeyPieceCount = dAcItem_c::getKeyPieceCount(); if (mSavedKeyPieceCount == KEY_KAKERA_NUM_PIECES) { - SmallSoundManager::GetInstance()->playSound(SE_S_KEY_COMPLETE); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_KEY_COMPLETE); } else { - SmallSoundManager::GetInstance()->playSound(SE_S_KEY_PARTS); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_KEY_PARTS); } } void dLytMeterKakeraKey_c::executeState_Increase() { diff --git a/src/d/lyt/meter/d_lyt_meter_minus_btn.cpp b/src/d/lyt/meter/d_lyt_meter_minus_btn.cpp index 9b3147dd..71f7e4dd 100644 --- a/src/d/lyt/meter/d_lyt_meter_minus_btn.cpp +++ b/src/d/lyt/meter/d_lyt_meter_minus_btn.cpp @@ -7,12 +7,12 @@ #include "d/lyt/d_lyt_control_game.h" #include "d/lyt/d_lyt_util_items.h" #include "d/lyt/meter/d_lyt_meter.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "m/m_angle.h" #include "nw4r/lyt/lyt_group.h" #include "nw4r/math/math_types.h" #include "sized_string.h" #include "toBeSorted/file_manager.h" -#include "toBeSorted/small_sound_mgr.h" STATE_DEFINE(dLytMeterMinusBtnMenuIcon_c, Wait); STATE_DEFINE(dLytMeterMinusBtnMenuIcon_c, On); @@ -635,9 +635,9 @@ void dLytMeterMinusBtn_c::initializeState_DemoMove() { } if (field_0x4E8C == 0) { - SmallSoundManager::GetInstance()->playSound(SE_S_DOGU_PORCH_ADD_FIRST); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_DOGU_PORCH_ADD_FIRST); } else { - SmallSoundManager::GetInstance()->playSound(SE_S_DOGU_PORCH_ADD); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_DOGU_PORCH_ADD); } } void dLytMeterMinusBtn_c::executeState_DemoMove() { @@ -898,7 +898,7 @@ bool dLytMeterMinusBtn_c::execute() { mAnm[MINUS_BTN_ANIM_CALL].play(); if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_MINUS) && mAnm[MINUS_BTN_ANIM_CALL].getFrame() == 1.0f) { - SmallSoundManager::GetInstance()->playSound(SE_S_MINUS_BUTTON_BLINK); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MINUS_BUTTON_BLINK); } } } else if (field_0x4EBA == 1) { diff --git a/src/d/lyt/meter/d_lyt_meter_plus_btn.cpp b/src/d/lyt/meter/d_lyt_meter_plus_btn.cpp index ba9c4b7d..fc7f94c1 100644 --- a/src/d/lyt/meter/d_lyt_meter_plus_btn.cpp +++ b/src/d/lyt/meter/d_lyt_meter_plus_btn.cpp @@ -9,11 +9,11 @@ #include "d/lyt/d_lyt_unknowns.h" #include "d/lyt/d_window.h" #include "d/lyt/meter/d_lyt_meter.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "d/t/d_t_map_mark.h" #include "f/f_base.h" #include "f/f_manager.h" #include "f/f_profile_name.h" -#include "toBeSorted/small_sound_mgr.h" STATE_DEFINE(dLytMeterPlusBtn_c, Wait); STATE_DEFINE(dLytMeterPlusBtn_c, ToUse); @@ -196,7 +196,7 @@ bool dLytMeterPlusBtn_c::execute() { mAnm[PLUS_BTN_ANIM_CALL].play(); if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_PLUS) && mAnm[PLUS_BTN_ANIM_CALL].getFrame() == 1.0f && mCallCount < 3) { - SmallSoundManager::GetInstance()->playSound(SE_S_PLUS_BUTTON_BLINK); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_PLUS_BUTTON_BLINK); mCallCount++; } } diff --git a/src/d/lyt/meter/d_lyt_meter_rupy.cpp b/src/d/lyt/meter/d_lyt_meter_rupy.cpp index 889efecb..9e29ab76 100644 --- a/src/d/lyt/meter/d_lyt_meter_rupy.cpp +++ b/src/d/lyt/meter/d_lyt_meter_rupy.cpp @@ -4,8 +4,8 @@ #include "d/a/d_a_item.h" #include "d/lyt/d2d.h" #include "d/lyt/d_lyt_meter_configuration.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "nw4r/math/math_types.h" -#include "toBeSorted/small_sound_mgr.h" STATE_DEFINE(dLytMeterRupyStart_c, Wait); STATE_DEFINE(dLytMeterRupyStart_c, Start); @@ -426,9 +426,9 @@ bool dLytMeterRupy_c::updateDisplayedAmount(bool suppressSound) { b = true; if (field_0x8AB) { if (newNumDisplayed == amount) { - SmallSoundManager::GetInstance()->playSound(SE_S_RUPEE_COUNT_DOWN_END); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_RUPEE_COUNT_DOWN_END); } else { - SmallSoundManager::GetInstance()->playSound(SE_S_RUPEE_COUNT_DOWN); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_RUPEE_COUNT_DOWN); } } if (field_0x8AD) { @@ -445,13 +445,13 @@ bool dLytMeterRupy_c::updateDisplayedAmount(bool suppressSound) { b = true; if (field_0x8AB) { if (newNumDisplayed == amount) { - SmallSoundManager::GetInstance()->playSound(SE_S_RUPEE_COUNT_UP_END); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_RUPEE_COUNT_UP_END); if (field_0x8AD) { field_0x890 = 0; field_0x8AD = 0; } } else { - SmallSoundManager::GetInstance()->playSound(SE_S_RUPEE_COUNT_UP); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_RUPEE_COUNT_UP); } } } @@ -511,7 +511,7 @@ bool dLytMeterRupy_c::updateDisplayedAmount(bool suppressSound) { mPrevDigits[2] = mDisplayedDigits[2]; mPrevDigits[3] = mDisplayedDigits[3]; } else if (field_0x8AD && amount == dAcItem_c::getCurrentWalletCapacity()) { - SmallSoundManager::GetInstance()->playSound(SE_S_RUPEE_MAX); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_RUPEE_MAX); field_0x890 = 0; field_0x8AD = 0; } diff --git a/src/d/lyt/meter/d_lyt_meter_shield_gauge.cpp b/src/d/lyt/meter/d_lyt_meter_shield_gauge.cpp index f89e6188..95887258 100644 --- a/src/d/lyt/meter/d_lyt_meter_shield_gauge.cpp +++ b/src/d/lyt/meter/d_lyt_meter_shield_gauge.cpp @@ -5,8 +5,8 @@ #include "d/d_pouch.h" #include "d/lyt/d2d.h" #include "d/lyt/d_lyt_meter_configuration.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "toBeSorted/file_manager.h" -#include "toBeSorted/small_sound_mgr.h" STATE_DEFINE(dLytMeterShieldGauge_c, Normal); STATE_DEFINE(dLytMeterShieldGauge_c, Use); @@ -181,13 +181,13 @@ bool dLytMeterShieldGauge_c::execute() { if (mCurrentDurability >= mMaxDurability) { if (field_0x31E) { // Unreachable? - SmallSoundManager::GetInstance()->playSoundWithPitch(SE_S_GAUGE_SHIELD_UP_LV, 1.0f); + dSndSmallEffectMgr_c::GetInstance()->playSoundWithPitch(SE_S_GAUGE_SHIELD_UP_LV, 1.0f); } - SmallSoundManager::GetInstance()->playSound(SE_S_GAUGE_SHIELD_UP_MAX); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_GAUGE_SHIELD_UP_MAX); } else { if (field_0x31E) { // Unreachable? - SmallSoundManager::GetInstance()->playSoundWithPitch( + dSndSmallEffectMgr_c::GetInstance()->playSoundWithPitch( SE_S_GAUGE_SHIELD_UP_LV, mCurrentDurability / mMaxDurability ); } diff --git a/src/d/lyt/meter/d_lyt_meter_timer.cpp b/src/d/lyt/meter/d_lyt_meter_timer.cpp index 8362c7f7..7a2af32c 100644 --- a/src/d/lyt/meter/d_lyt_meter_timer.cpp +++ b/src/d/lyt/meter/d_lyt_meter_timer.cpp @@ -10,13 +10,13 @@ #include "d/lyt/d2d.h" #include "d/lyt/d_lyt_drop_line.h" #include "d/lyt/meter/d_lyt_meter.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "d/t/d_t_siren.h" #include "m/m_vec.h" #include "nw4r/lyt/lyt_pane.h" #include "nw4r/math/math_types.h" #include "toBeSorted/d_emitter.h" #include "toBeSorted/event_manager.h" -#include "toBeSorted/small_sound_mgr.h" #include @@ -328,7 +328,7 @@ bool LytMeterTimerPart1_c::incrementTearCount() { startNextFruitAnim(); if (!dLytMeter_c::getfn_800C9FE0()) { createEffect(mActualTearCount - 1); - SmallSoundManager::GetInstance()->playSound(SE_S_SIREN_SHIZUKU_GET_IN); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SIREN_SHIZUKU_GET_IN); } if (mActualTearCount < TIMER_01_NUM_TEARS) { diff --git a/src/d/lyt/meter/d_lyt_meter_z_btn.cpp b/src/d/lyt/meter/d_lyt_meter_z_btn.cpp index 3058e83f..935f78fe 100644 --- a/src/d/lyt/meter/d_lyt_meter_z_btn.cpp +++ b/src/d/lyt/meter/d_lyt_meter_z_btn.cpp @@ -7,8 +7,8 @@ #include "d/lyt/d_lyt_control_game.h" #include "d/lyt/d_lyt_unknowns.h" #include "d/lyt/meter/d_lyt_meter.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "toBeSorted/attention.h" -#include "toBeSorted/small_sound_mgr.h" STATE_DEFINE(dLytMeterZBtn_c, Wait); STATE_DEFINE(dLytMeterZBtn_c, On); @@ -224,7 +224,7 @@ bool dLytMeterZBtn_c::execute() { if (mAnm[Z_BTN_ANIM_CALL].isEnabled()) { mAnm[Z_BTN_ANIM_CALL].play(); if (dLytMeter_c::GetInstance()->checkAllFlags(0x800) && mAnm[Z_BTN_ANIM_CALL].getFrame() == 1.0f) { - SmallSoundManager::GetInstance()->playSound(SE_S_Z_BUTTON_BLINK); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_Z_BUTTON_BLINK); } } } else if (field_0x1C6 == 1) { diff --git a/src/d/lyt/msg_window/d_lyt_msg_window.cpp b/src/d/lyt/msg_window/d_lyt_msg_window.cpp index 3f935e28..0d3d6739 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window.cpp @@ -27,6 +27,7 @@ #include "d/lyt/d_lyt_auto_caption.h" // clang-format on +#include "d/snd/d_snd_small_effect_mgr.h" #include "f/f_base.h" #include "m/m_fader_base.h" #include "m/m_vec.h" @@ -38,7 +39,6 @@ #include "toBeSorted/lyt_related_floats.h" #include "toBeSorted/music_mgrs.h" #include "toBeSorted/other_sound_stuff.h" -#include "toBeSorted/small_sound_mgr.h" #include @@ -308,7 +308,7 @@ void dLytMsgWindow_c::executeState_OutputText() { } else if (mpTagProcessor->getMsgWindowSubtype() <= MSG_WINDOW_1 && oldValue != mpMsgWindowUnk->getField_0x147A()) { u16 a = mpMsgWindowUnk->getField_0x147C(); f32 b = (dTagProcessor_c::fn_800B8040(0, 0) * 100.0f); - SmallSoundManager::GetInstance()->playButtonPressSoundWhenAdvancingTextBoxes(a / b); + dSndSmallEffectMgr_c::GetInstance()->playButtonPressSoundWhenAdvancingTextBoxes(a / b); } if (setTextToDisplay(mpMsgWindowUnk->getProcessedText())) { diff --git a/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp b/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp index 65c97411..6ea90360 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp @@ -3,8 +3,8 @@ #include "common.h" #include "d/d_pad.h" #include "d/lyt/d2d.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "toBeSorted/music_mgrs.h" -#include "toBeSorted/small_sound_mgr.h" STATE_DEFINE(dLytMsgWindowSelectBtnParts_c, Wait); @@ -278,11 +278,11 @@ void dLytMsgWindowSelectBtn_c::initializeState_In() { } else { if (field_0x9CF != 0) { if (field_0x9A0 == 1) { - SmallSoundManager::GetInstance()->playSound(SE_S_CHOICE_START); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_CHOICE_START); } else if (field_0x9A0 == 2) { - SmallSoundManager::GetInstance()->playSound(SE_S_CHOICE_START_GAMEOVER); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_CHOICE_START_GAMEOVER); } else { - SmallSoundManager::GetInstance()->playSound(SE_S_TALK_CHOICE_START); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_TALK_CHOICE_START); } } mAnm[SELECT_BTN_ANIM_IN].setFrame(0.0f); @@ -323,7 +323,7 @@ void dLytMsgWindowSelectBtn_c::executeState_WaitSelect() { mpWindow->UpdateSize(mpSizeBox, 32.0f); } else if (v == 3) { field_0x9D1 = 1; - SmallSoundManager::GetInstance()->playSound(SE_S_POINTER_RESET); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_POINTER_RESET); mStateMgr.changeState(StateID_In); return; } @@ -334,9 +334,9 @@ void dLytMsgWindowSelectBtn_c::executeState_WaitSelect() { mStateMgr.changeState(StateID_WaitDecide); // TODO if (mpTagProcessor != nullptr) { - SmallSoundManager::GetInstance()->playSound(SE_S_TALK_CURSOR_CANCEL); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_TALK_CURSOR_CANCEL); } else { - SmallSoundManager::GetInstance()->playSound(SE_S_TALK_CURSOR_OK); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_TALK_CURSOR_OK); } fn_8035E880(BGM_MGR); } else if (dPad::checkButtonBPressed()) { @@ -347,9 +347,9 @@ void dLytMsgWindowSelectBtn_c::executeState_WaitSelect() { mStateMgr.changeState(StateID_WaitCancel); // TODO if (mpTagProcessor != nullptr) { - SmallSoundManager::GetInstance()->playSound(SE_S_TALK_CURSOR_CANCEL); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_TALK_CURSOR_CANCEL); } else { - SmallSoundManager::GetInstance()->playSound(SE_S_TALK_CURSOR_OK); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_TALK_CURSOR_OK); } fn_8035E880(BGM_MGR); } diff --git a/src/d/snd/d_snd_3d_actor.cpp b/src/d/snd/d_snd_3d_actor.cpp index 3ece873a..bf2d7799 100644 --- a/src/d/snd/d_snd_3d_actor.cpp +++ b/src/d/snd/d_snd_3d_actor.cpp @@ -27,7 +27,7 @@ dSnd3DActor_c::dSnd3DActor_c(UNKTYPE *a1, u8 a2) mFlags(0), mDistanceToPlayer(INFINITY), a_field_0xE0(0.0f) { - resetFloats(); + resetCachedRelativePositions(); // Portability hazard SetUserParam(reinterpret_cast(this)); if (dSndPlayerMgr_c::GetInstance()->canUseThisPlayer(a2)) { diff --git a/src/d/snd/d_snd_3d_manager.cpp b/src/d/snd/d_snd_3d_manager.cpp index 1bbf9717..ec1d91ce 100644 --- a/src/d/snd/d_snd_3d_manager.cpp +++ b/src/d/snd/d_snd_3d_manager.cpp @@ -9,7 +9,7 @@ #include "nw4r/snd/snd_SoundArchive.h" #include "toBeSorted/music_mgrs.h" -template class SndMgrDisposer; +SND_DISPOSER_DEFINE(dSnd3DManager_c); dSnd3DManager_c::dSnd3DManager_c() : mIsSetup(false), mCalculationsFresh(0) { mCameraPosSqVelocity = 0.0f; diff --git a/src/d/snd/d_snd_area_sound.cpp b/src/d/snd/d_snd_area_sound.cpp new file mode 100644 index 00000000..27033adf --- /dev/null +++ b/src/d/snd/d_snd_area_sound.cpp @@ -0,0 +1,61 @@ +#include "d/snd/d_snd_area_sound.h" + +#include "common.h" +#include "d/snd/d_snd_sound.h" + +dSndAreaSound_c::dSndAreaSound_c() + : field_0xF0(false), mpCalcCallback(nullptr), field_0xF8(nullptr), field_0xFC(nullptr), field_0x100(nullptr) {} + +void dSndAreaSound_c::cancel() { + dSndSound_c::cancel(); + field_0xF0 = false; +} + +void dSndAreaSound_c::calc() { + if (isFadingOut() && mPauseFlag) { + if (GetRemainingFadeFrames() <= 0) { + Stop(0); + cancel(); + } + } + + dSndSound_c::calc(); + if (mpCalcCallback != nullptr) { + (mpCalcCallback)(*this); + } +} + +void dSndAreaSound_c::fadeIn(u32 id, s32 fadeFrames) { + dSndSound_c::fadeIn(id, fadeFrames); + initCallback(id); +} + +void dSndAreaSound_c::pause(s32 fadeFrames) { + if (isRunning()) { + if (fadeFrames != 0) { + pause(true, fadeFrames); + mIsFadingOut = true; + } else { + Stop(fadeFrames); + cancel(); + } + } else { + cancel(); + } +} + +void dSndAreaSound_c::unpause(s32 fadeFrames) { + if (isFadingOut()) { + pause(false, fadeFrames); + mIsFadingOut = false; + } +} + +void dSndAreaSound_c::initCallback(u32 id) { + Callback cb = nullptr; + mpCalcCallback = nullptr; + field_0xF8 = nullptr; + field_0xFC = nullptr; + field_0x100 = nullptr; + field_0x104 = nullptr; +} diff --git a/src/d/snd/d_snd_area_sound_effect_mgr.cpp b/src/d/snd/d_snd_area_sound_effect_mgr.cpp new file mode 100644 index 00000000..95114462 --- /dev/null +++ b/src/d/snd/d_snd_area_sound_effect_mgr.cpp @@ -0,0 +1,75 @@ +#include "d/snd/d_snd_area_sound_effect_mgr.h" + +#include "common.h" +#include "d/d_sc_game.h" +#include "d/snd/d_snd_mgr.h" +#include "d/snd/d_snd_player_mgr.h" +#include "d/snd/d_snd_util.h" +#include "nw4r/snd/snd_SoundStartable.h" + +SND_DISPOSER_DEFINE(dSndAreaSoundEffectMgr_c); + +dSndAreaSoundEffectMgr_c::dSndAreaSoundEffectMgr_c() + : field_0x328(0), + field_0x32C(1.0f), + field_0x330(1.0f), + mActor(*dSndMgr_c::GetInstance()->getPlayer()), + field_0x388(1.0f) {} + +void dSndAreaSoundEffectMgr_c::calc() { + for (int i = 0; i < 3; i++) { + mSounds[i].calc(); + } +} + +bool dSndAreaSoundEffectMgr_c::startSound(u32 soundId, u32 handleIdx) { + if (dSndPlayerMgr_c::GetInstance()->checkFlag(0x2)) { + return false; + } + + if (isPlayingSound(soundId)) { + return false; + } + + if (handleIdx > 2) { + return false; + } + + if (dScGame_c::currentSpawnInfo.getTrial() == SpawnInfo::TRIAL) { + return false; + } + + dSndAreaSound_c *snd = &mSounds[handleIdx]; + nw4r::snd::SoundStartable::StartResult res = mActor.detail_StartSound(snd, soundId, nullptr); + if (res == nw4r::snd::SoundStartable::START_SUCCESS) { + snd->fadeIn(soundId, 30); + } + + // @bug should probably be `res != nw4r::snd::SoundStartable::START_SUCCESS` + // all callers seem to ignore return value though + return res; +} + +void dSndAreaSoundEffectMgr_c::stopSounds(s32 fadeFrames) { + for (u32 i = 0; i < 3; i++) { + mSounds[i].stop(fadeFrames); + } +} + +bool dSndAreaSoundEffectMgr_c::isPlayingAnySound() const { + for (int i = 0; i < 3; i++) { + if (mSounds[i].IsAttachedSound()) { + return true; + } + } + return false; +} + +bool dSndAreaSoundEffectMgr_c::isPlayingSound(u32 soundId) const { + for (int i = 0; i < 3; i++) { + if (mSounds[i].GetId() == soundId) { + return true; + } + } + return false; +} diff --git a/src/d/snd/d_snd_control_player_mgr.cpp b/src/d/snd/d_snd_control_player_mgr.cpp index 1f82c696..3f79e49c 100644 --- a/src/d/snd/d_snd_control_player_mgr.cpp +++ b/src/d/snd/d_snd_control_player_mgr.cpp @@ -4,7 +4,7 @@ #include "d/snd/d_snd_control_player.h" #include "nw4r/ut/ut_list.h" -template class SndMgrDisposer; +SND_DISPOSER_DEFINE(dSndControlPlayerMgr_c); dSndControlPlayerMgr_c::dSndControlPlayerMgr_c() : mOverrideVolumeMask(0) { // TODO offsetof @@ -47,7 +47,7 @@ void dSndControlPlayerMgr_c::calcVolumes() { f32 currentVolume = getAppliedPlayerVolume(i); f32 targetVolume = mpTargetVolumes[i]; f32 maxVolumeDecrease = mpMaxVolumeDecreases[i]; - f32 maxVolumeIncrease = mpMaxVolumeDecreases[i]; + f32 maxVolumeIncrease = mpMaxVolumeIncreases[i]; if (currentVolume != targetVolume) { if (currentVolume - targetVolume > maxVolumeDecrease) { @@ -61,7 +61,7 @@ void dSndControlPlayerMgr_c::calcVolumes() { } mpTargetVolumes[i] = 1.0f; mpMaxVolumeDecreases[i] = 0.1f; - mpMaxVolumeDecreases[i] = 0.025f; + mpMaxVolumeIncreases[i] = 0.025f; } } } @@ -101,7 +101,7 @@ void dSndControlPlayerMgr_c::setVolume(u32 playerIdx, f32 value, s32 frames) { } else { // Volume is not overridden, set volume normally setControlValue(CTRL_VOLUME, playerIdx, value, frames); - mpSavedVolumes[playerIdx] = getControlVolumeTarget(CTRL_VOLUME, playerIdx); + mpSavedVolumes[playerIdx] = getControlTarget(CTRL_VOLUME, playerIdx); } } @@ -111,7 +111,7 @@ void dSndControlPlayerMgr_c::overrideVolume(u32 playerIdx, f32 volume, s32 frame } u32 mask = (1 << playerIdx); if ((mOverrideVolumeMask & mask) == 0) { - mpSavedVolumes[playerIdx] = getControlVolumeTarget(CTRL_VOLUME, playerIdx); + mpSavedVolumes[playerIdx] = getControlTarget(CTRL_VOLUME, playerIdx); mOverrideVolumeMask |= mask; } setControlValue(CTRL_VOLUME, playerIdx, volume, frames); @@ -171,7 +171,7 @@ f32 dSndControlPlayerMgr_c::getAppliedPlayerVolume(u32 playerIdx) const { return getPlayer1(playerIdx)->GetVolume(); } -f32 dSndControlPlayerMgr_c::getControlVolumeTarget(PlayerCtrl_e ctrlType, u32 playerIdx) const { +f32 dSndControlPlayerMgr_c::getControlTarget(PlayerCtrl_e ctrlType, u32 playerIdx) const { if (ctrlType >= CTRL_MAX) { return 1.0f; } diff --git a/src/d/snd/d_snd_mgr.cpp b/src/d/snd/d_snd_mgr.cpp index 982c3fbd..95fadd70 100644 --- a/src/d/snd/d_snd_mgr.cpp +++ b/src/d/snd/d_snd_mgr.cpp @@ -1,17 +1,16 @@ #include "d/snd/d_snd_mgr.h" #include "d/snd/d_snd_3d_manager.h" +#include "d/snd/d_snd_area_sound_effect_mgr.h" #include "d/snd/d_snd_control_player_mgr.h" #include "d/snd/d_snd_player_mgr.h" -#include "d/snd/d_snd_util.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "egg/audio/eggAudioRmtSpeakerMgr.h" #include "egg/audio/eggAudioUtility.h" extern "C" void initEnemySoundMgr(); extern "C" void initFanfareSoundMgr(); extern "C" void initSomeUnusedSoundMgr(); -extern "C" void initSoundEffectSoundMgr(); -extern "C" void fn_8036A430(); extern "C" void initEnemyBgmRelatedMgr(); extern "C" void fn_80393530(); extern "C" void fn_80394830(); @@ -23,14 +22,14 @@ dSndMgr_c *dSndMgr_c::sInstance; dSndMgr_c::dSndMgr_c(): field_0x6CC(0) { sInstance = this; - SndMgrDisposer::create(); - SndMgrDisposer::create(); + dSndPlayerMgr_c::create(); + dSndControlPlayerMgr_c::create(); initEnemySoundMgr(); - SndMgrDisposer::create(); + dSnd3DManager_c::create(); initFanfareSoundMgr(); initSomeUnusedSoundMgr(); - initSoundEffectSoundMgr(); - fn_8036A430(); + dSndSmallEffectMgr_c::create(); + dSndAreaSoundEffectMgr_c::create(); initEnemyBgmRelatedMgr(); fn_80393530(); fn_80394830(); diff --git a/src/d/snd/d_snd_player_mgr.cpp b/src/d/snd/d_snd_player_mgr.cpp index 9fdf769a..b89ecdd5 100644 --- a/src/d/snd/d_snd_player_mgr.cpp +++ b/src/d/snd/d_snd_player_mgr.cpp @@ -12,7 +12,7 @@ const char *dSndPlayerMgr_c::getSoundArchivePath() { return "Sound/WZSound.brsar"; } -template class SndMgrDisposer; +SND_DISPOSER_DEFINE(dSndPlayerMgr_c); dSndPlayerMgr_c::dSndPlayerMgr_c() : field_0x010(0), field_0x011(0), field_0x014(-1), field_0x018(-1), field_0x01C(-1), mFlags(0) {} diff --git a/src/d/snd/d_snd_small_effect_mgr.cpp b/src/d/snd/d_snd_small_effect_mgr.cpp new file mode 100644 index 00000000..cab93dd2 --- /dev/null +++ b/src/d/snd/d_snd_small_effect_mgr.cpp @@ -0,0 +1,8 @@ +#include "d/snd/d_snd_small_effect_mgr.h" + +#include "d/snd/d_snd_util.h" + + +SND_DISPOSER_DEFINE(dSndSmallEffectMgr_c) + +dSndSmallEffectMgr_c::dSndSmallEffectMgr_c() {} diff --git a/src/d/snd/d_snd_sound.cpp b/src/d/snd/d_snd_sound.cpp index aa441136..ff5a55a4 100644 --- a/src/d/snd/d_snd_sound.cpp +++ b/src/d/snd/d_snd_sound.cpp @@ -61,7 +61,7 @@ void dSndSound_c::resetControls() { resetTrackVolumes(); } -void dSndSound_c::executeCtrls() { +void dSndSound_c::calc() { if (mIsRunning && !IsAttachedSound()) { cancel(); } diff --git a/src/toBeSorted/save_manager.cpp b/src/toBeSorted/save_manager.cpp index 78c2ca0c..4c9b9210 100644 --- a/src/toBeSorted/save_manager.cpp +++ b/src/toBeSorted/save_manager.cpp @@ -11,6 +11,7 @@ #include "d/d_sys.h" #include "d/lyt/d_lyt_save_msg_window.h" #include "d/lyt/d_lyt_system_window.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "egg/core/eggHeap.h" #include "m/m_pad.h" #include "toBeSorted/arc_managers/layout_arc_manager.h" @@ -18,7 +19,6 @@ #include "toBeSorted/nand_request_thread.h" #include "toBeSorted/nand_result_tracker.h" #include "toBeSorted/reload_color_fader.h" -#include "toBeSorted/small_sound_mgr.h" #include "rvl/NAND.h" #include "rvl/TPL.h" @@ -511,7 +511,7 @@ void SaveMgr::executeSaveBanner() { if (b == 1) { if (!dDvdUnk::FontUnk::GetInstance()->getField_0x28()) { - SmallSoundManager::GetInstance()->playSound(SE_S_SAVE_FINISH); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SAVE_FINISH); } mDelayTimer = 0; mStep++; From 724fefb7906ebe7194cfd9fef000b360af2b5235 Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 5 Jun 2025 00:07:09 +0200 Subject: [PATCH 12/22] Last rename --- config/SOUE01/splits.txt | 2 +- configure.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 147dde46..4ebbe039 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2389,7 +2389,7 @@ d/snd/d_snd_3d_manager.cpp: .sbss start:0x80575D58 end:0x80575D60 .sdata2 start:0x8057D3B8 end:0x8057D3F8 -d/snd/d_snd_mgr_enemy.cpp: +d/snd/d_snd_stage_mgr.cpp: .text start:0x80361460 end:0x8036642C align:16 .ctors start:0x804DB918 end:0x804DB91C diff --git a/configure.py b/configure.py index 290e4bf4..214d5ba8 100644 --- a/configure.py +++ b/configure.py @@ -710,7 +710,7 @@ config.libs = [ Object(NonMatching, "d/snd/d_snd_player_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_control_player_mgr.cpp"), Object(Matching, "d/snd/d_snd_3d_manager.cpp"), - Object(NonMatching, "d/snd/d_snd_mgr_enemy.cpp"), + Object(NonMatching, "d/snd/d_snd_stage_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_unk_component_2.cpp"), Object(NonMatching, "d/snd/d_snd_area_sound_effect_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_area_sound.cpp"), From e9c5e4c46c7b61304e6962097e0c828721f895fd Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 5 Jun 2025 17:00:05 +0200 Subject: [PATCH 13/22] A bit more --- config/SOUE01/symbols.txt | 34 ++-- include/d/snd/d_snd_control_player_mgr.h | 70 +++---- include/d/snd/d_snd_player_mgr.h | 86 ++++++++- include/nw4r/snd/snd_SoundPlayer.h | 29 +++ include/toBeSorted/music_mgrs.h | 1 + src/d/snd/d_snd_control_player_mgr.cpp | 225 ++++++++++++++++++++++- 6 files changed, 386 insertions(+), 59 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index c314ebe9..28dc2197 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -20001,10 +20001,10 @@ fn_8035F770 = .text:0x8035F770; // type:function size:0xDC calc__22dSndControlPlayerMgr_cFv = .text:0x8035F850; // type:function size:0x3C executeControls__22dSndControlPlayerMgr_cFv = .text:0x8035F890; // type:function size:0xAC calcVolumes__22dSndControlPlayerMgr_cFv = .text:0x8035F940; // type:function size:0x168 -fn_8035FAB0 = .text:0x8035FAB0; // type:function size:0x318 -fn_8035FDD0 = .text:0x8035FDD0; // type:function size:0xE0 -fn_8035FEB0 = .text:0x8035FEB0; // type:function size:0x11C -fn_8035FFD0 = .text:0x8035FFD0; // type:function size:0xE0 +calcMuteFlags__22dSndControlPlayerMgr_cFv = .text:0x8035FAB0; // type:function size:0x318 +__cl__21EventMuteFlagsApplierFRQ34nw4r3snd11SoundHandle = .text:0x8035FDD0; // type:function size:0xE0 +__cl__21SmallMuteFlagsApplierFRQ34nw4r3snd11SoundHandle = .text:0x8035FEB0; // type:function size:0x11C +__cl__23FanfareMuteFlagsApplierFRQ34nw4r3snd11SoundHandle = .text:0x8035FFD0; // type:function size:0xE0 getPlayer1__22dSndControlPlayerMgr_cCFUl = .text:0x803600B0; // type:function size:0x70 getPlayer2__22dSndControlPlayerMgr_cCFUl = .text:0x80360120; // type:function size:0x34 fn_80360160 = .text:0x80360160; // type:function size:0xBC @@ -20023,17 +20023,17 @@ getControlTarget__22dSndControlPlayerMgr_cCFQ222dSndControlPlayerMgr_c12PlayerCt fn_80360710 = .text:0x80360710; // type:function size:0x78 fn_80360790 = .text:0x80360790; // type:function size:0x5C fn_803607F0 = .text:0x803607F0; // type:function size:0x60 -setShortParameterTo5__22dSndControlPlayerMgr_cFll = .text:0x80360850; // type:function size:0x2C -fn_80360880 = .text:0x80360880; // type:function size:0x64 +setGroupVolumeFlag__22dSndControlPlayerMgr_cFQ222dSndControlPlayerMgr_c18VolumeControlGroupQ222dSndControlPlayerMgr_c9MuteLevel = .text:0x80360850; // type:function size:0x2C +setPlayerVolumeInternal__22dSndControlPlayerMgr_cFUlf = .text:0x80360880; // type:function size:0x64 fn_803608F0 = .text:0x803608F0; // type:function size:0x50 -fn_80360940 = .text:0x80360940; // type:function size:0x5C +setBgmMuteVolume__22dSndControlPlayerMgr_cFf = .text:0x80360940; // type:function size:0x5C fn_803609A0 = .text:0x803609A0; // type:function size:0x5C -fn_80360A00 = .text:0x80360A00; // type:function size:0x5C -fn_80360A60 = .text:0x80360A60; // type:function size:0x6C -fn_80360AD0 = .text:0x80360AD0; // type:function size:0x5C -fn_80360B30 = .text:0x80360B30; // type:function size:0x5C -fn_80360B90 = .text:0x80360B90; // type:function size:0x64 -fn_80360C00 = .text:0x80360C00; // type:function size:0x28 +setBgmVolumeDecreaseSpeed__22dSndControlPlayerMgr_cFf = .text:0x80360A00; // type:function size:0x5C +setStageEffectsVolume__22dSndControlPlayerMgr_cFfl = .text:0x80360A60; // type:function size:0x6C +setStageEffectsMuteVolume__22dSndControlPlayerMgr_cFf = .text:0x80360AD0; // type:function size:0x5C +setEnemyMuteVolume__22dSndControlPlayerMgr_cFf = .text:0x80360B30; // type:function size:0x5C +setObjectMuteVolume__22dSndControlPlayerMgr_cFf = .text:0x80360B90; // type:function size:0x64 +__sinit_\d_snd_control_player_mgr_cpp = .text:0x80360C00; // type:function size:0x28 __dt__33SndMgrDisposer<15dSnd3DManager_c>Fv = .text:0x80360C30; // type:function size:0x78 scope:weak create__33SndMgrDisposer<15dSnd3DManager_c>Fv = .text:0x80360CB0; // type:function size:0x48 scope:weak remove__33SndMgrDisposer<15dSnd3DManager_c>Fv = .text:0x80360D00; // type:function size:0x10 scope:weak @@ -37641,9 +37641,9 @@ lbl_80548758 = .data:0x80548758; // type:object size:0x14 data:string lbl_8054876C = .data:0x8054876C; // type:object size:0x14 data:string __vt__15dSndPlayerMgr_c = .data:0x80548780; // type:object size:0x10 __vt__33SndMgrDisposer<15dSndPlayerMgr_c> = .data:0x80548790; // type:object size:0xC -lbl_805487A0 = .data:0x805487A0; // type:object size:0xC -lbl_805487AC = .data:0x805487AC; // type:object size:0xC -lbl_805487B8 = .data:0x805487B8; // type:object size:0xC +__vt__21EventMuteFlagsApplier = .data:0x805487A0; // type:object size:0xC +__vt__21SmallMuteFlagsApplier = .data:0x805487AC; // type:object size:0xC +__vt__23FanfareMuteFlagsApplier = .data:0x805487B8; // type:object size:0xC __vt__40SndMgrDisposer<22dSndControlPlayerMgr_c> = .data:0x805487C4; // type:object size:0xC __vt__33SndMgrDisposer<15dSnd3DManager_c> = .data:0x805487D0; // type:object size:0xC scope:weak lbl_805487E0 = .data:0x805487E0; // type:object size:0xAC @@ -49198,7 +49198,7 @@ lbl_8057E5C0 = .sdata2:0x8057E5C0; // type:object size:0x4 data:4byte lbl_8057E5C4 = .sdata2:0x8057E5C4; // type:object size:0x4 align:4 data:float sNumPlayers__22dSndControlPlayerMgr_c = .sdata2:0x8057E5C8; // type:object size:0x4 data:4byte lbl_8057E5CC = .sdata2:0x8057E5CC; // type:object size:0x4 data:4byte -lbl_8057E5D0 = .sdata2:0x8057E5D0; // type:object size:0x8 data:4byte +sEventMuteFlagsMask__15dSndPlayerMgr_c = .sdata2:0x8057E5D0; // type:object size:0x8 data:4byte lbl_8057E5D8 = .sdata2:0x8057E5D8; // type:object size:0x4 align:4 data:float lbl_8057E5DC = .sdata2:0x8057E5DC; // type:object size:0x4 align:4 data:float lbl_8057E5E0 = .sdata2:0x8057E5E0; // type:object size:0x8 align:8 data:double diff --git a/include/d/snd/d_snd_control_player_mgr.h b/include/d/snd/d_snd_control_player_mgr.h index d3b7654e..d7e3097b 100644 --- a/include/d/snd/d_snd_control_player_mgr.h +++ b/include/d/snd/d_snd_control_player_mgr.h @@ -6,32 +6,6 @@ #include "nw4r/snd/snd_SoundPlayer.h" #include "nw4r/ut/ut_list.h" -/* -Num players: 0x15 = 21 -Notes on player groups: -0, 1 - -9, 10, 11 - -12, 13, 14, 16, 17 - -17, 18, 19, 20 - - -0: BGM - -3: UI Sfx, confirmation, pointer reset -4: UI SFX, get fruit -5, 7: Player walk -8: Player Equipment - -12: bomb explode, refresh fruit sprout -13: environmental sound effects (wind), bomb fuse -14: enemies/bugs - -17: TgSound -*/ - SND_DISPOSER_FORWARD_DECL(dSndControlPlayerMgr_c); class dSndControlPlayerMgr_c { @@ -39,11 +13,11 @@ class dSndControlPlayerMgr_c { public: enum PlayerCtrl_e { - CTRL_VOLUME, - CTRL_LPF_FREQ, - CTRL_FX_SEND, + CTRL_VOLUME = 0, + CTRL_LPF_FREQ = 1, + CTRL_FX_SEND = 2, - CTRL_MAX, + CTRL_MAX = 3, }; dSndControlPlayerMgr_c(); @@ -63,11 +37,43 @@ public: void overrideVolume(u32 playerIdx, f32 volume, s32 frames); void restoreVolume(u32 playerIdx, s32 frames); - void setShortParameterTo5(s32 idx1, s32 idx2); + void muteAllWorldSounds(s32 fadeFrames); + void unmuteAllWorldSounds(s32 fadeFrames); + + enum MuteLevel { + MUTE_FULL = 0, + MUTE_PARTIAL = 1, + + MUTE_MAX = 2, + }; + + enum VolumeControlGroup { + /** PLAYER_BGM, PLAYER_BGM_BOSS */ + CTRL_GROUP_BGM = 0, + /** PLAYER_TG_SOUND - PLAYER_AREA_IN_WATER_LV */ + CTRL_GROUP_STAGE_EFFECTS = 1, + /** PLAYER_ENEMY - PLAYER_ENEMY_FOOTSTEP */ + CTRL_GROUP_ENEMY = 2, + /* PLAYER_OBJECT_1 - PLAYER_TG_SOUND, but not PLAYER_NPC_VOICE */ + CTRL_GROUP_OBJECTS = 3, + + CTRL_GROUP_MAX = 4, + }; + void setGroupVolumeFlag(VolumeControlGroup group, MuteLevel level); + + void setBgmVolumeDecreaseSpeed(f32 speed); + void setStageEffectsVolume(f32 volume, s32 fadeFrames); private: + void setBgmMuteVolume(f32 volume); + void setStageEffectsMuteVolume(f32 volume); + void setEnemyMuteVolume(f32 volume); + void setObjectMuteVolume(f32 volume); + void setPlayerVolumeInternal(u32 playerIdx, f32 volume); + void resetControls(); void calcVolumes(); + void calcMuteFlags(); void executeControls(); void linkCtrl(dSndControlPlayer_c *); void unlinkCtrl(dSndControlPlayer_c *); @@ -82,7 +88,7 @@ private: /* 0x28 */ f32 *mpSavedVolumes; /* 0x2C */ u32 mOverrideVolumeMask; /* 0x30 */ nw4r::ut::List mActiveControls; - /* 0x3C */ s16 field_0x3C[4][2]; + /* 0x3C */ s16 mTimersForGroupVolume[4][2]; }; #endif diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h index 81ea7e61..d5c877eb 100644 --- a/include/d/snd/d_snd_player_mgr.h +++ b/include/d/snd/d_snd_player_mgr.h @@ -1,6 +1,7 @@ #ifndef D_SND_PLAYER_MGR_H #define D_SND_PLAYER_MGR_H +#include "d/snd/d_snd_mgr.h" #include "d/snd/d_snd_util.h" #include "nw4r/snd/snd_MemorySoundArchive.h" #include "nw4r/snd/snd_SoundArchivePlayer.h" @@ -35,6 +36,86 @@ public: return mFlags & mask; } + u32 getEventMuteMask(u32 id) { + nw4r::snd::SoundArchive *archive; + if (mSoundArchivePlayer.IsAvailable()) { + archive = &mSoundArchive; + } else { + archive = dSndMgr_c::GetInstance()->getArchive(); + } + return archive->GetSoundUserParam(id) & sEventMuteFlagsMask; + } + + enum FanfareUnmuteParam_e { + FANFARE_UNMUTE_BGM = 0x10000, + FANFARE_UNMUTE_STAGE_EFFECTS = 0x20000, + FANFARE_UNMUTE_ENEMY = 0x40000, + FANFARE_UNMUTE_OBJECTS = 0x80000, + }; + + // seem to be used for Small and Event sounds + enum UserParamEventSmall_e { + MUTE_BGM_PART = 0x10000, + MUTE_BGM_FULL = 0x20000, + MUTE_STAGE_EFFECTS_PART = 0x40000, + MUTE_STAGE_EFFECTS_FULL = 0x80000, + MUTE_ENEMY_PART = 0x100000, + MUTE_ENEMY_FULL = 0x200000, + MUTE_OBJECTS_PART = 0x400000, + MUTE_OBJECTS_FULL = 0x800000, + }; + + static const u32 sEventMuteFlagsMask; + + // For a full overview over which sounds are played by which players, + // see https://gist.github.com/robojumper/f81a55857cebed2c79cf3cf3c1ec8f04 + enum PlayerIndex_e { + /** Background music */ + PLAYER_BGM = 0, + /** Background music, boss battle */ + PLAYER_BGM_BOSS = 1, + /** "fanfare?" */ + PLAYER_FAN = 2, + /** small sound effects, only a few (UI navigation related) */ + PLAYER_SMALL_IMPORTANT = 3, + /** small sound, often UI related */ + PLAYER_SMALL_NORMAL = 4, + /** hit, roll attack, cloth, sink */ + PLAYER_LINK_BODY = 5, + /** Link voice */ + PLAYER_LINK_VOICE = 6, + /** Link footstep, swimming */ + PLAYER_LINK_FOOTSTEP = 7, + /** Sword, beetle, ... */ + PLAYER_LINK_EQUIPMENT = 8, + /** Enemy sound effects */ + PLAYER_ENEMY = 9, + /** Enemy voices */ + PLAYER_ENEMY_VOICE = 10, + /** Enemy footstep */ + PLAYER_ENEMY_FOOTSTEP = 11, + /** Misc objects */ + PLAYER_OBJECT_1 = 12, + /** Misc objects */ + PLAYER_OBJECT_2 = 13, + /** NPC footsteps */ + PLAYER_NPC_FOOTSTEP = 14, + /** NPC voices */ + PLAYER_NPC_VOICE = 15, + /** leaves, grass */ + PLAYER_FOLIAGE = 16, + /** misc TgSound environmental effects */ + PLAYER_TG_SOUND = 17, + /** area sound effects (Faron birds...) */ + PLAYER_AREA = 18, + /** not sure, only SE_A_IN_WATER_LV */ + PLAYER_AREA_IN_WATER_LV = 19, + /** event */ + PLAYER_EVENT = 20, + /** not sure */ + PLAYER_UNK_21 = 21, + }; + private: /* 0x010 */ u8 field_0x010; /* 0x011 */ u8 field_0x011; @@ -45,8 +126,9 @@ private: virtual nw4r::snd::SoundStartable::StartResult startSound(nw4r::snd::SoundHandle *pHandle, u32 soundId, const nw4r::snd::SoundStartable::StartInfo *pStartInfo); - virtual nw4r::snd::SoundStartable::StartResult - startSound(nw4r::snd::SoundHandle *pHandle, const char *soundLabel, const nw4r::snd::SoundStartable::StartInfo *pStartInfo); + virtual nw4r::snd::SoundStartable::StartResult startSound( + nw4r::snd::SoundHandle *pHandle, const char *soundLabel, const nw4r::snd::SoundStartable::StartInfo *pStartInfo + ); /* 0x028 */ nw4r::snd::MemorySoundArchive mSoundArchive; /* 0x178 */ nw4r::snd::SoundArchivePlayer mSoundArchivePlayer; diff --git a/include/nw4r/snd/snd_SoundPlayer.h b/include/nw4r/snd/snd_SoundPlayer.h index dfdcded2..90b56ed0 100644 --- a/include/nw4r/snd/snd_SoundPlayer.h +++ b/include/nw4r/snd/snd_SoundPlayer.h @@ -69,6 +69,35 @@ namespace nw4r { namespace snd void detail_FreePlayerHeap(detail::BasicSound *sound); void detail_AppendPlayerHeap(detail::PlayerHeap *heap); + // Apparently exists, needed in d/snd + template + TForEachFunc ForEachSound(TForEachFunc pFunc, bool reverse) { + if (reverse) { + detail::BasicSound::SoundPlayerPlayLinkList::ReverseIterator it = mSoundList.GetBeginReverseIter(); + + while (it != mSoundList.GetEndReverseIter()) { + detail::BasicSound::SoundPlayerPlayLinkList::ReverseIterator curr = it; + + SoundHandle handle; + handle.detail_AttachSoundAsTempHandle(&*curr); + pFunc(handle); + + if (handle.IsAttachedSound()) { + ++it; + } + } + } else { + NW4R_RANGE_FOR_NO_AUTO_INC(it, mSoundList) { + decltype(it) curItr = it++; + SoundHandle handle; + handle.detail_AttachSoundAsTempHandle(&*curItr); + pFunc(handle); + } + } + + return pFunc; + } + // members private: detail::BasicSound::SoundPlayerPlayLinkList mSoundList; // size 0x0c, offset 0x00 diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index fd498ac8..1efa7fe0 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -43,5 +43,6 @@ extern "C" bool fn_80373550(void *, u32); extern "C" void fn_80372920(void *); extern "C" void fn_803738B0(void *, dSndSound_c *sound); extern "C" void fn_80373900(void *, dSndSound_c *sound); +extern "C" bool fn_803733B0(void*, u32); #endif diff --git a/src/d/snd/d_snd_control_player_mgr.cpp b/src/d/snd/d_snd_control_player_mgr.cpp index 3f79e49c..75fa02d1 100644 --- a/src/d/snd/d_snd_control_player_mgr.cpp +++ b/src/d/snd/d_snd_control_player_mgr.cpp @@ -2,7 +2,125 @@ #include "common.h" #include "d/snd/d_snd_control_player.h" +#include "d/snd/d_snd_mgr.h" +#include "d/snd/d_snd_player_mgr.h" +#include "nw4r/snd/snd_SoundHandle.h" #include "nw4r/ut/ut_list.h" +#include "toBeSorted/music_mgrs.h" + +struct FanfareMuteFlagsApplier { + ~FanfareMuteFlagsApplier() {} + virtual void operator()(nw4r::snd::SoundHandle &handle) { + // The logic here is inverted compared to the others - Fanfares seem to + // mute things by default unless otherwise speciefied + u32 id = handle.GetId(); + if (fn_803733B0(FANFARE_SOUND_MGR, id)) { + u32 userParam = dSndMgr_c::GetInstance()->getArchive()->GetSoundUserParam(id); + if (!(userParam & dSndPlayerMgr_c::FANFARE_UNMUTE_BGM)) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_BGM, dSndControlPlayerMgr_c::MUTE_FULL + ); + dSndControlPlayerMgr_c::GetInstance()->setBgmVolumeDecreaseSpeed(0.2f); + } + + if (fn_80364DA0(ENEMY_SOUND_MGR)) { + if (!(userParam & dSndPlayerMgr_c::FANFARE_UNMUTE_STAGE_EFFECTS)) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_STAGE_EFFECTS, dSndControlPlayerMgr_c::MUTE_FULL + ); + } + if (!(userParam & dSndPlayerMgr_c::FANFARE_UNMUTE_ENEMY)) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_ENEMY, dSndControlPlayerMgr_c::MUTE_FULL + ); + } + if (!(userParam & dSndPlayerMgr_c::FANFARE_UNMUTE_OBJECTS)) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_OBJECTS, dSndControlPlayerMgr_c::MUTE_FULL + ); + } + } + } + }; +}; + +struct SmallMuteFlagsApplier { + ~SmallMuteFlagsApplier() {} + virtual void operator()(nw4r::snd::SoundHandle &handle) { + u32 userParam = dSndMgr_c::GetInstance()->getArchive()->GetSoundUserParam(handle.GetId()); + + if (userParam & dSndPlayerMgr_c::MUTE_BGM_FULL) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_BGM, dSndControlPlayerMgr_c::MUTE_FULL + ); + } else if (userParam & dSndPlayerMgr_c::MUTE_BGM_PART) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_BGM, dSndControlPlayerMgr_c::MUTE_PARTIAL + ); + } + + if (userParam & dSndPlayerMgr_c::MUTE_STAGE_EFFECTS_FULL) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_STAGE_EFFECTS, dSndControlPlayerMgr_c::MUTE_FULL + ); + } else if (userParam & dSndPlayerMgr_c::MUTE_STAGE_EFFECTS_PART) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_STAGE_EFFECTS, dSndControlPlayerMgr_c::MUTE_PARTIAL + ); + } + + if (userParam & dSndPlayerMgr_c::MUTE_ENEMY_FULL) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_ENEMY, dSndControlPlayerMgr_c::MUTE_FULL + ); + } else if (userParam & dSndPlayerMgr_c::MUTE_ENEMY_PART) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_ENEMY, dSndControlPlayerMgr_c::MUTE_PARTIAL + ); + } + + if (userParam & dSndPlayerMgr_c::MUTE_OBJECTS_FULL) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_OBJECTS, dSndControlPlayerMgr_c::MUTE_FULL + ); + } else if (userParam & dSndPlayerMgr_c::MUTE_OBJECTS_PART) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_OBJECTS, dSndControlPlayerMgr_c::MUTE_PARTIAL + ); + } + }; +}; + +struct EventMuteFlagsApplier { + ~EventMuteFlagsApplier() {} + virtual void operator()(nw4r::snd::SoundHandle &handle) { + u32 userParam = dSndPlayerMgr_c::GetInstance()->getEventMuteMask(handle.GetId()); + + if (userParam & dSndPlayerMgr_c::MUTE_BGM_FULL) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_BGM, dSndControlPlayerMgr_c::MUTE_FULL + ); + } else if (userParam & dSndPlayerMgr_c::MUTE_BGM_PART) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_BGM, dSndControlPlayerMgr_c::MUTE_PARTIAL + ); + } + + if (userParam & dSndPlayerMgr_c::MUTE_STAGE_EFFECTS_FULL) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_STAGE_EFFECTS, dSndControlPlayerMgr_c::MUTE_FULL + ); + } else if (userParam & dSndPlayerMgr_c::MUTE_STAGE_EFFECTS_PART) { + dSndControlPlayerMgr_c::GetInstance()->setGroupVolumeFlag( + dSndControlPlayerMgr_c::CTRL_GROUP_STAGE_EFFECTS, dSndControlPlayerMgr_c::MUTE_PARTIAL + ); + } + }; +}; + +static FanfareMuteFlagsApplier fanfareApplier; +static SmallMuteFlagsApplier smallApplier; +static EventMuteFlagsApplier eventApplier; SND_DISPOSER_DEFINE(dSndControlPlayerMgr_c); @@ -20,7 +138,11 @@ dSndControlPlayerMgr_c::dSndControlPlayerMgr_c() : mOverrideVolumeMask(0) { mpMaxVolumeIncreases = new f32[sNumPlayers]; } -void dSndControlPlayerMgr_c::calc() {} +void dSndControlPlayerMgr_c::calc() { + calcMuteFlags(); + calcVolumes(); + executeControls(); +} void dSndControlPlayerMgr_c::executeControls() { dSndControlPlayer_c *next; @@ -42,8 +164,7 @@ void dSndControlPlayerMgr_c::calcVolumes() { // overridden volume mpTargetVolumes[i] = mpSavedVolumes[i]; } else { - // not overridden. The effect of this is that - // something will set the targetValue to a specific value + // not overridden. f32 currentVolume = getAppliedPlayerVolume(i); f32 targetVolume = mpTargetVolumes[i]; f32 maxVolumeDecrease = mpMaxVolumeDecreases[i]; @@ -66,6 +187,43 @@ void dSndControlPlayerMgr_c::calcVolumes() { } } +void dSndControlPlayerMgr_c::calcMuteFlags() { + getPlayer1(dSndPlayerMgr_c::PLAYER_FAN)->ForEachSound(fanfareApplier, false); + getPlayer1(dSndPlayerMgr_c::PLAYER_SMALL_IMPORTANT)->ForEachSound(smallApplier, false); + getPlayer1(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL)->ForEachSound(smallApplier, false); + getPlayer1(dSndPlayerMgr_c::PLAYER_EVENT)->ForEachSound(eventApplier, false); + + f32 volumesByGroup[CTRL_GROUP_MAX]; + for (int i = 0; i < CTRL_GROUP_MAX; i++) { + volumesByGroup[i] = 1.0f; + if (mTimersForGroupVolume[i][MUTE_PARTIAL] > 0) { + mTimersForGroupVolume[i][MUTE_PARTIAL]--; + volumesByGroup[i] = 0.3f; + } + + if (mTimersForGroupVolume[i][MUTE_FULL] > 0) { + mTimersForGroupVolume[i][MUTE_FULL]--; + volumesByGroup[i] = 0.0f; + } + } + + if (volumesByGroup[CTRL_GROUP_BGM] < 1.0f) { + setBgmMuteVolume(volumesByGroup[CTRL_GROUP_BGM]); + } + + if (volumesByGroup[CTRL_GROUP_STAGE_EFFECTS] < 1.0f) { + setStageEffectsMuteVolume(volumesByGroup[CTRL_GROUP_STAGE_EFFECTS]); + } + + if (volumesByGroup[CTRL_GROUP_ENEMY] < 1.0f) { + setEnemyMuteVolume(volumesByGroup[CTRL_GROUP_ENEMY]); + } + + if (volumesByGroup[CTRL_GROUP_OBJECTS] < 1.0f) { + setObjectMuteVolume(volumesByGroup[CTRL_GROUP_OBJECTS]); + } +} + void dSndControlPlayerMgr_c::linkCtrl(dSndControlPlayer_c *ctrl) { if (ctrl == nullptr) { return; @@ -97,7 +255,7 @@ void dSndControlPlayerMgr_c::setVolume(u32 playerIdx, f32 value, s32 frames) { if ((mOverrideVolumeMask & mask) != 0) { // Volume is overridden, set saved volume as to not interrupt override mpSavedVolumes[playerIdx] = value; - + setPlayerVolumeInternal(playerIdx, value); } else { // Volume is not overridden, set volume normally setControlValue(CTRL_VOLUME, playerIdx, value, frames); @@ -181,14 +339,65 @@ f32 dSndControlPlayerMgr_c::getControlTarget(PlayerCtrl_e ctrlType, u32 playerId return mpCtrls[ctrlType][playerIdx].getTargetValue(); } -void dSndControlPlayerMgr_c::setShortParameterTo5(s32 idx1, s32 idx2) { - if (idx1 >= 4) { +void dSndControlPlayerMgr_c::setGroupVolumeFlag(VolumeControlGroup group, MuteLevel level) { + if (group >= CTRL_GROUP_MAX) { return; } - if (idx2 >= 2) { + if (level >= MUTE_MAX) { return; } - field_0x3C[idx1][idx2] = 5; + mTimersForGroupVolume[group][level] = 5; +} + +void dSndControlPlayerMgr_c::setPlayerVolumeInternal(u32 playerIdx, f32 volume) { + if (playerIdx >= sNumPlayers) { + return; + } + // @bug not actually clamped + nw4r::ut::Clamp(volume, 0.0f, 2.0f); + + if (mpTargetVolumes[playerIdx] > volume) { + mpTargetVolumes[playerIdx] = volume; + } + + u32 mask = (1 << playerIdx); + if ((mOverrideVolumeMask & mask) != 0) { + mpSavedVolumes[playerIdx] = mpTargetVolumes[playerIdx]; + } +} + +void dSndControlPlayerMgr_c::setBgmMuteVolume(f32 volume) { + for (u32 i = dSndPlayerMgr_c::PLAYER_BGM; i < dSndPlayerMgr_c::PLAYER_BGM_BOSS + 1; i++) { + setPlayerVolumeInternal(i, volume); + } +} + +void dSndControlPlayerMgr_c::setBgmVolumeDecreaseSpeed(f32 decrease) {} + +void dSndControlPlayerMgr_c::setStageEffectsVolume(f32 volume, s32 fadeFrames) { + for (u32 i = dSndPlayerMgr_c::PLAYER_TG_SOUND; i <= dSndPlayerMgr_c::PLAYER_AREA_IN_WATER_LV; i++) { + setVolume(i, volume, fadeFrames); + } +} + +void dSndControlPlayerMgr_c::setStageEffectsMuteVolume(f32 volume) { + for (u32 i = dSndPlayerMgr_c::PLAYER_TG_SOUND; i <= dSndPlayerMgr_c::PLAYER_AREA_IN_WATER_LV; i++) { + setPlayerVolumeInternal(i, volume); + } +} + +void dSndControlPlayerMgr_c::setEnemyMuteVolume(f32 volume) { + for (u32 i = dSndPlayerMgr_c::PLAYER_ENEMY; i < dSndPlayerMgr_c::PLAYER_ENEMY_FOOTSTEP + 1; i++) { + setPlayerVolumeInternal(i, volume); + } +} + +void dSndControlPlayerMgr_c::setObjectMuteVolume(f32 volume) { + for (u32 i = dSndPlayerMgr_c::PLAYER_OBJECT_1; i < dSndPlayerMgr_c::PLAYER_TG_SOUND + 1; i++) { + if (i != dSndPlayerMgr_c::PLAYER_NPC_VOICE) { + setPlayerVolumeInternal(i, volume); + } + } } From ed0f2fed88a7ab36c3b323d64f0c45a4aaa09a9b Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 5 Jun 2025 21:58:13 +0200 Subject: [PATCH 14/22] Fixes --- config/SOUE01/splits.txt | 12 +++++-- config/SOUE01/symbols.txt | 20 +++++------ configure.py | 2 ++ include/d/snd/d_snd_player_mgr.h | 32 +++++++++++++++++ include/d/snd/d_snd_source.h | 1 + include/nw4r/snd/snd_SoundPlayer.h | 1 + include/toBeSorted/music_mgrs.h | 3 ++ src/d/snd/d_snd_player_mgr.cpp | 55 ++++++++++++++++++++++++++++-- 8 files changed, 110 insertions(+), 16 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 4ebbe039..13bb72e7 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2397,13 +2397,13 @@ d/snd/d_snd_unk_component_2.cpp: .text start:0x80366430 end:0x8036A3A4 align:16 d/snd/d_snd_area_sound_effect_mgr.cpp: - .text start:0x8036A3B0 end:0x8036B8D0 + .text start:0x8036A3B0 end:0x8036B8D0 align:16 .data start:0x80548B38 end:0x80548B48 .sbss start:0x80575D78 end:0x80575D80 .sdata2 start:0x8057D8B0 end:0x8057D8E8 d/snd/d_snd_area_sound.cpp: - .text start:0x8036B8D0 end:0x8036C090 + .text start:0x8036B8D0 end:0x8036C090 align:16 .data start:0x80548B48 end:0x80548B78 .sdata2 start:0x8057D8E8 end:0x8057D920 @@ -2417,8 +2417,14 @@ d/snd/d_snd_control_player.cpp: .data start:0x80548C38 end:0x80548CC8 .sdata2 start:0x8057D938 end:0x8057D940 +d/snd/d_snd_bgm_mgr.cpp: + .text start:0x8036C6B0 end:0x803739CC align:16 + +d/snd/d_snd_bgm_sound.cpp: + .text start:0x803739D0 end:0x8037BA68 align:16 + d/snd/d_snd_unk_15.cpp: - .text start:0x8036C6B0 end:0x8037D800 align:16 + .text start:0x8037BA70 end:0x8037D800 align:16 d/snd/d_snd_small_effect_mgr.cpp: .text start:0x8037D800 end:0x8037F8B4 align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 28dc2197..9c98f249 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -19944,13 +19944,13 @@ fn_8035E220 = .text:0x8035E220; // type:function size:0x2C fn_8035E250 = .text:0x8035E250; // type:function size:0x8C fn_8035E2E0 = .text:0x8035E2E0; // type:function size:0x2C fn_8035E310 = .text:0x8035E310; // type:function size:0x50 -fn_8035E360 = .text:0x8035E360; // type:function size:0x70 -fn_8035E3D0 = .text:0x8035E3D0; // type:function size:0x70 -fn_8035E440 = .text:0x8035E440; // type:function size:0x2C -fn_8035E470 = .text:0x8035E470; // type:function size:0x2C -fn_8035E4A0 = .text:0x8035E4A0; // type:function size:0x44 -fn_8035E4F0 = .text:0x8035E4F0; // type:function size:0x44 -fn_8035E540 = .text:0x8035E540; // type:function size:0x18 +enterPauseState__15dSndPlayerMgr_cFv = .text:0x8035E360; // type:function size:0x70 +leavePauseState__15dSndPlayerMgr_cFv = .text:0x8035E3D0; // type:function size:0x70 +enterMenu__15dSndPlayerMgr_cFv = .text:0x8035E440; // type:function size:0x2C +leaveMenu__15dSndPlayerMgr_cFv = .text:0x8035E470; // type:function size:0x2C +enterMap__15dSndPlayerMgr_cFv = .text:0x8035E4A0; // type:function size:0x44 +leaveMap__15dSndPlayerMgr_cFv = .text:0x8035E4F0; // type:function size:0x44 +enterHelp__15dSndPlayerMgr_cFv = .text:0x8035E540; // type:function size:0x18 fn_8035E560 = .text:0x8035E560; // type:function size:0x18 fn_8035E580 = .text:0x8035E580; // type:function size:0x50 fn_8035E5D0 = .text:0x8035E5D0; // type:function size:0x44 @@ -37694,7 +37694,7 @@ lbl_80548AFC = .data:0x80548AFC; // type:object size:0xC lbl_80548B08 = .data:0x80548B08; // type:object size:0x14 lbl_80548B1C = .data:0x80548B1C; // type:object size:0x10 lbl_80548B2C = .data:0x80548B2C; // type:object size:0xC -lbl_80548B38 = .data:0x80548B38; // type:object size:0x10 +__vt__42SndMgrDisposer<24dSndAreaSoundEffectMgr_c> = .data:0x80548B38; // type:object size:0x10 lbl_80548B48 = .data:0x80548B48; // type:object size:0x30 __vt__33dSndControlSoundStrmTrackVolume_c = .data:0x80548B78; // type:object size:0x20 __vt__32dSndControlSoundSeqTrackVolume_c = .data:0x80548B98; // type:object size:0x20 @@ -41902,8 +41902,8 @@ lbl_80575D64 = .sbss:0x80575D64; // type:object size:0x4 data:4byte lbl_80575D68 = .sbss:0x80575D68; // type:object size:0x4 data:4byte ENEMY_SOUND_MGR = .sbss:0x80575D6C; // type:object size:0x4 data:4byte ENEMY_SOUND_MGR_source = .sbss:0x80575D70; // type:object size:0x8 data:4byte -lbl_80575D78 = .sbss:0x80575D78; // type:object size:0x4 data:4byte -lbl_80575D7C = .sbss:0x80575D7C; // type:object size:0x4 data:4byte +sInstance__24dSndAreaSoundEffectMgr_c = .sbss:0x80575D78; // type:object size:0x4 data:4byte +sDisposer__24dSndAreaSoundEffectMgr_c = .sbss:0x80575D7C; // type:object size:0x4 data:4byte FANFARE_SOUND_MGR = .sbss:0x80575D80; // type:object size:0x4 data:4byte FANFARE_SOUND_MGR_source = .sbss:0x80575D84; // type:object size:0x4 data:4byte lbl_80575D88 = .sbss:0x80575D88; // type:object size:0x8 data:4byte diff --git a/configure.py b/configure.py index 214d5ba8..b1193287 100644 --- a/configure.py +++ b/configure.py @@ -711,6 +711,8 @@ config.libs = [ Object(NonMatching, "d/snd/d_snd_control_player_mgr.cpp"), Object(Matching, "d/snd/d_snd_3d_manager.cpp"), Object(NonMatching, "d/snd/d_snd_stage_mgr.cpp"), + Object(NonMatching, "d/snd/d_snd_bgm_mgr.cpp"), + Object(NonMatching, "d/snd/d_snd_bgm_sound.cpp"), Object(NonMatching, "d/snd/d_snd_unk_component_2.cpp"), Object(NonMatching, "d/snd/d_snd_area_sound_effect_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_area_sound.cpp"), diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h index d5c877eb..d803ab70 100644 --- a/include/d/snd/d_snd_player_mgr.h +++ b/include/d/snd/d_snd_player_mgr.h @@ -13,6 +13,8 @@ SND_DISPOSER_FORWARD_DECL(dSndPlayerMgr_c); /** * The main interface for managing sound stuff. Will delegate to dSndMgr_c for * most things, but handles demo (cutscene) sound effects (SE_DEMO*) by itself. + * + * Previous Ghidra name: BgmMgr */ class dSndPlayerMgr_c { public: @@ -24,6 +26,16 @@ public: void shutdown(); void calc(); + void enterMenu(); + void leaveMenu(); + void enterMap(); + void leaveMap(); + void enterHelp(); + void leaveHelp(); + + void enterHbm(); + void leaveHbm(); + u32 getFreeSize(); bool loadDemoArchive(const char *demoArchiveName); const char *getSoundArchivePath(); @@ -32,10 +44,26 @@ public: nw4r::snd::SoundArchivePlayer &getSoundArchivePlayerForType(u8 type); bool canUseThisPlayer(u8 type) const; + enum PlayerMgrFlag_e { + MGR_HBM = 0x1, + MGR_UNK_0x2 = 0x2, + MGR_PAUSE = 0x4, + MGR_MAP = 0x8, + MGR_HELP = 0x10, + }; + bool checkFlag(u32 mask) const { return mFlags & mask; } + void onFlag(u32 mask) { + mFlags |= mask; + } + + void offFlag(u32 mask) { + mFlags &= ~mask; + } + u32 getEventMuteMask(u32 id) { nw4r::snd::SoundArchive *archive; if (mSoundArchivePlayer.IsAvailable()) { @@ -124,6 +152,10 @@ private: /* 0x01C */ s32 field_0x01C; /* 0x020 */ u32 mFlags; + // system menu, inventory, map + void enterPauseState(); + void leavePauseState(); + virtual nw4r::snd::SoundStartable::StartResult startSound(nw4r::snd::SoundHandle *pHandle, u32 soundId, const nw4r::snd::SoundStartable::StartInfo *pStartInfo); virtual nw4r::snd::SoundStartable::StartResult startSound( diff --git a/include/d/snd/d_snd_source.h b/include/d/snd/d_snd_source.h index d732e924..1b2ca525 100644 --- a/include/d/snd/d_snd_source.h +++ b/include/d/snd/d_snd_source.h @@ -99,6 +99,7 @@ private: /* 0x154 */ UNKWORD field_0x154; /* 0x158 */ s16 field_0x158; /* 0x15A */ s16 field_0x15A; + /* 0x15C */ nw4r::ut::Node mNode2; }; #endif diff --git a/include/nw4r/snd/snd_SoundPlayer.h b/include/nw4r/snd/snd_SoundPlayer.h index 90b56ed0..52382946 100644 --- a/include/nw4r/snd/snd_SoundPlayer.h +++ b/include/nw4r/snd/snd_SoundPlayer.h @@ -10,6 +10,7 @@ #include "nw4r/snd/snd_BasicSound.h" #include "nw4r/snd/snd_global.h" // AUX_BUS_NUM #include "nw4r/snd/snd_PlayerHeap.h" +#include "nw4r/snd/snd_SoundHandle.h" /******************************************************************************* * classes diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index 1efa7fe0..8d255eb8 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -33,6 +33,9 @@ extern "C" void *ENEMY_BGM_RELATED_MGR; extern "C" void fn_80384570(void *, bool); extern "C" void fn_803858D0(void *); + +// This one has a SoundActor that actually plays the BGM_ music tracks, +// including the battle BGM track. extern "C" void *FANFARE_SOUND_MGR; extern "C" void AnotherSoundMgr__playSound(void *, s32); extern "C" bool fn_803721F0(void *, u32); diff --git a/src/d/snd/d_snd_player_mgr.cpp b/src/d/snd/d_snd_player_mgr.cpp index b89ecdd5..6a25a564 100644 --- a/src/d/snd/d_snd_player_mgr.cpp +++ b/src/d/snd/d_snd_player_mgr.cpp @@ -2,7 +2,10 @@ #include "d/snd/d_snd_player_mgr.h" #include "common.h" +#include "d/snd/d_snd_control_player_mgr.h" #include "d/snd/d_snd_mgr.h" +#include "d/snd/d_snd_small_effect_mgr.h" +#include "d/snd/d_snd_wzsound.h" #include "egg/core/eggDvdRipper.h" #include "nw4r/snd/snd_SoundHandle.h" #include "nw4r/snd/snd_SoundStartable.h" @@ -17,14 +20,61 @@ SND_DISPOSER_DEFINE(dSndPlayerMgr_c); dSndPlayerMgr_c::dSndPlayerMgr_c() : field_0x010(0), field_0x011(0), field_0x014(-1), field_0x018(-1), field_0x01C(-1), mFlags(0) {} +void dSndPlayerMgr_c::enterPauseState() { + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_FAN, 0.3f, 5); + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_AREA, 0.3f, 5); + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_AREA_IN_WATER_LV, 0.3f, 5); + // has other effects, such as reducing BGM volume + onFlag(MGR_PAUSE); +} + u32 dSndPlayerMgr_c::getFreeSize() { return dSndMgr_c::GetInstance()->getSoundHeap()->GetFreeSize(); } +void dSndPlayerMgr_c::leavePauseState() { + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_FAN, 1.0f, 5); + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_AREA, 1.0f, 5); + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_AREA_IN_WATER_LV, 1.0f, 5); + offFlag(MGR_PAUSE); +} + +void dSndPlayerMgr_c::enterMenu() { + enterPauseState(); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MENU_IN); +} + +void dSndPlayerMgr_c::leaveMenu() { + leavePauseState(); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MENU_OUT); +} + +void dSndPlayerMgr_c::enterMap() { + enterPauseState(); + onFlag(MGR_MAP); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MAP_OPEN); +} + +void dSndPlayerMgr_c::leaveMap() { + leavePauseState(); + offFlag(MGR_MAP); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MAP_CLOSE); +} + +void dSndPlayerMgr_c::enterHelp() { + onFlag(MGR_HELP); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_HELP_IN); +} + +void dSndPlayerMgr_c::leaveHelp() { + offFlag(MGR_HELP); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_HELP_OUT); +} + nw4r::snd::SoundStartable::StartResult dSndPlayerMgr_c::startSound( nw4r::snd::SoundHandle *pHandle, u32 soundId, const nw4r::snd::SoundStartable::StartInfo *pStartInfo ) { - if (mFlags & 0x2) { + if (checkFlag(MGR_UNK_0x2)) { return nw4r::snd::SoundStartable::START_ERR_USER; } @@ -65,7 +115,7 @@ bool dSndPlayerMgr_c::canUseThisPlayer(u8 type) const { } int ty = type; - + if ((ty >= 0 && ty <= 1) || ty == 58) { return true; } @@ -110,7 +160,6 @@ void dSndPlayerMgr_c::shutdown() { mSoundArchive.Shutdown(); } - void dSndPlayerMgr_c::calc() { if (mSoundArchivePlayer.IsAvailable()) { mSoundArchivePlayer.Update(); From 03e518622a9b10bc45e28170a6b03aba1c09f391 Mon Sep 17 00:00:00 2001 From: robojumper Date: Fri, 6 Jun 2025 14:43:21 +0200 Subject: [PATCH 15/22] A bit of dSndSmallEffectMgr_c --- config/SOUE01/splits.txt | 13 +- config/SOUE01/symbols.txt | 24 +-- configure.py | 10 +- include/d/snd/d_snd_3d_actor.h | 18 --- include/d/snd/d_snd_checkers.h | 34 ++++ include/d/snd/d_snd_control_player_mgr.h | 1 + include/d/snd/d_snd_small_effect_mgr.h | 37 ++++- include/d/snd/d_snd_source.h | 3 +- include/nw4r/snd/snd_SoundHandle.h | 5 + include/toBeSorted/music_mgrs.h | 3 + src/d/snd/d_snd_3d_actor.cpp | 1 + src/d/snd/d_snd_small_effect_mgr.cpp | 189 ++++++++++++++++++++++- src/d/snd/d_snd_source.cpp | 22 +++ 13 files changed, 316 insertions(+), 44 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 13bb72e7..ced03afb 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2419,9 +2419,20 @@ d/snd/d_snd_control_player.cpp: d/snd/d_snd_bgm_mgr.cpp: .text start:0x8036C6B0 end:0x803739CC align:16 + .sbss start:0x80575D80 end:0x80575D88 + .sdata2 start:0x8057D940 end:0x8057D970 + +d/snd/d_snd_bgm_sound_callbacks.cpp: + .text start:0x803739D0 end:0x80378ECC align:16 + .sdata2 start:0x8057D970 end:0x8057DA50 + +d/snd/d_snd_bgm_sound_boss_callbacks.cpp: + .text start:0x80378ED0 end:0x80379D20 align:16 + .sdata2 start:0x8057DA50 end:0x8057DA58 d/snd/d_snd_bgm_sound.cpp: - .text start:0x803739D0 end:0x8037BA68 align:16 + .text start:0x80379D20 end:0x8037BA68 align:16 + .sbss start:0x80575D88 end:0x80575D90 d/snd/d_snd_unk_15.cpp: .text start:0x8037BA70 end:0x8037D800 align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 9c98f249..937bcc97 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -20843,9 +20843,9 @@ fn_8037DC50 = .text:0x8037DC50; // type:function size:0x70 fn_8037DCC0 = .text:0x8037DCC0; // type:function size:0x48 fn_8037DD10 = .text:0x8037DD10; // type:function size:0x1BC playSound__20dSndSmallEffectMgr_cFUl = .text:0x8037DED0; // type:function size:0x2D0 -fn_8037E1A0 = .text:0x8037E1A0; // type:function size:0x90 +playSoundWithPan__20dSndSmallEffectMgr_cFUlf = .text:0x8037E1A0; // type:function size:0x90 fn_8037E230 = .text:0x8037E230; // type:function size:0xEC -fn_8037E320 = .text:0x8037E320; // type:function size:0x78 +playSoundInternal__20dSndSmallEffectMgr_cFUl = .text:0x8037E320; // type:function size:0x78 fn_8037E3A0 = .text:0x8037E3A0; // type:function size:0x158 fn_8037E500 = .text:0x8037E500; // type:function size:0x58 playSoundWithPitch__20dSndSmallEffectMgr_cFUlf = .text:0x8037E560; // type:function size:0xBC @@ -20867,14 +20867,14 @@ fn_8037EC30 = .text:0x8037EC30; // type:function size:0x8 fn_8037EC40 = .text:0x8037EC40; // type:function size:0x3C fn_8037EC80 = .text:0x8037EC80; // type:function size:0xB0 fn_8037ED30 = .text:0x8037ED30; // type:function size:0x68 -fn_8037EDA0 = .text:0x8037EDA0; // type:function size:0xA0 -fn_8037EE40 = .text:0x8037EE40; // type:function size:0x3C -fn_8037EE80 = .text:0x8037EE80; // type:function size:0x64 -playSound = .text:0x8037EEF0; // type:function size:0xAC -fn_8037EFA0 = .text:0x8037EFA0; // type:function size:0x80 +stopSounds__20dSndSmallEffectMgr_cFUlUll = .text:0x8037EDA0; // type:function size:0xA0 +__cl__12SoundStopperFRQ34nw4r3snd11SoundHandle = .text:0x8037EE40; // type:function size:0x3C +stopSounds__20dSndSmallEffectMgr_cFUll = .text:0x8037EE80; // type:function size:0x64 +isPlayingSound__20dSndSmallEffectMgr_cFUlUl = .text:0x8037EEF0; // type:function size:0xAC +isPlayingSound__20dSndSmallEffectMgr_cFUl = .text:0x8037EFA0; // type:function size:0x80 playButtonPressSoundWhenAdvancingTextBoxes__20dSndSmallEffectMgr_cFf = .text:0x8037F020; // type:function size:0xB4 -fn_8037F0E0 = .text:0x8037F0E0; // type:function size:0xC -fn_8037F0F0 = .text:0x8037F0F0; // type:function size:0x60 +resetButtonPressSound__20dSndSmallEffectMgr_cFv = .text:0x8037F0E0; // type:function size:0xC +setButtonPressSound__20dSndSmallEffectMgr_cFP14dSoundSource_c = .text:0x8037F0F0; // type:function size:0x60 fn_8037F150 = .text:0x8037F150; // type:function size:0x6D0 d_s_vt_0x17C__14dSoundSource_cFv = .text:0x8037F820; // type:function size:0x8 vt_0x18__14dSoundSource_cFv = .text:0x8037F830; // type:function size:0x8 @@ -21225,7 +21225,7 @@ 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 -fn_8038BE40 = .text:0x8038BE40; // type:function size:0xC4 +getCharacterTalkSoundId__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 @@ -37732,7 +37732,7 @@ lbl_80549178 = .data:0x80549178; // type:object size:0x10 lbl_80549188 = .data:0x80549188; // type:object size:0x10 lbl_80549198 = .data:0x80549198; // type:object size:0x10 lbl_805491A8 = .data:0x805491A8; // type:object size:0x10 -lbl_805491B8 = .data:0x805491B8; // type:object size:0xC +__vt__12SoundStopper = .data:0x805491B8; // type:object size:0xC __vt__38SndMgrDisposer<20dSndSmallEffectMgr_c> = .data:0x805491C4; // type:object size:0xC lbl_805491D0 = .data:0x805491D0; // type:object size:0x10 jumptable_805491E0 = .data:0x805491E0; // type:object size:0x20 scope:local @@ -49197,7 +49197,7 @@ lbl_8057E5BC = .sdata2:0x8057E5BC; // type:object size:0x4 align:4 data:float lbl_8057E5C0 = .sdata2:0x8057E5C0; // type:object size:0x4 data:4byte lbl_8057E5C4 = .sdata2:0x8057E5C4; // type:object size:0x4 align:4 data:float sNumPlayers__22dSndControlPlayerMgr_c = .sdata2:0x8057E5C8; // type:object size:0x4 data:4byte -lbl_8057E5CC = .sdata2:0x8057E5CC; // type:object size:0x4 data:4byte +sPlayerMax__22dSndControlPlayerMgr_c = .sdata2:0x8057E5CC; // type:object size:0x4 data:4byte sEventMuteFlagsMask__15dSndPlayerMgr_c = .sdata2:0x8057E5D0; // type:object size:0x8 data:4byte lbl_8057E5D8 = .sdata2:0x8057E5D8; // type:object size:0x4 align:4 data:float lbl_8057E5DC = .sdata2:0x8057E5DC; // type:object size:0x4 align:4 data:float diff --git a/configure.py b/configure.py index b1193287..0bef48dc 100644 --- a/configure.py +++ b/configure.py @@ -700,8 +700,6 @@ config.libs = [ "progress_category": "game", "host": False, "objects": [ - # These are very low quality splits since nobody has figured - # out enough detail. Need to look into nw4r::snd first Object(NonMatching, "d/snd/d_snd_mgr.cpp"), Object(Matching, "d/snd/d_snd_actor.cpp"), Object(NonMatching, "d/snd/d_snd_3d_actor.cpp"), @@ -710,14 +708,18 @@ config.libs = [ Object(NonMatching, "d/snd/d_snd_player_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_control_player_mgr.cpp"), Object(Matching, "d/snd/d_snd_3d_manager.cpp"), + # this one is a bit weird. it deals with all the stage definitions, + # but it's not actually the bgm manager? Object(NonMatching, "d/snd/d_snd_stage_mgr.cpp"), - Object(NonMatching, "d/snd/d_snd_bgm_mgr.cpp"), - Object(NonMatching, "d/snd/d_snd_bgm_sound.cpp"), Object(NonMatching, "d/snd/d_snd_unk_component_2.cpp"), Object(NonMatching, "d/snd/d_snd_area_sound_effect_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_area_sound.cpp"), Object(Matching, "d/snd/d_snd_control_sound.cpp"), Object(Matching, "d/snd/d_snd_control_player.cpp"), + Object(NonMatching, "d/snd/d_snd_bgm_mgr.cpp"), + Object(NonMatching, "d/snd/d_snd_bgm_sound_callbacks.cpp"), + Object(NonMatching, "d/snd/d_snd_bgm_sound_boss_callbacks.cpp"), + Object(NonMatching, "d/snd/d_snd_bgm_sound.cpp"), Object(NonMatching, "d/snd/d_snd_unk_15.cpp"), Object(NonMatching, "d/snd/d_snd_small_effect_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_harp_mgr.cpp"), diff --git a/include/d/snd/d_snd_3d_actor.h b/include/d/snd/d_snd_3d_actor.h index 5c8642f1..98735baf 100644 --- a/include/d/snd/d_snd_3d_actor.h +++ b/include/d/snd/d_snd_3d_actor.h @@ -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 diff --git a/include/d/snd/d_snd_checkers.h b/include/d/snd/d_snd_checkers.h index 7a459280..d18c2777 100644 --- a/include/d/snd/d_snd_checkers.h +++ b/include/d/snd/d_snd_checkers.h @@ -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 diff --git a/include/d/snd/d_snd_control_player_mgr.h b/include/d/snd/d_snd_control_player_mgr.h index d7e3097b..541268fb 100644 --- a/include/d/snd/d_snd_control_player_mgr.h +++ b/include/d/snd/d_snd_control_player_mgr.h @@ -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; diff --git a/include/d/snd/d_snd_small_effect_mgr.h b/include/d/snd/d_snd_small_effect_mgr.h index 84ebbfb1..6504728a 100644 --- a/include/d/snd/d_snd_small_effect_mgr.h +++ b/include/d/snd/d_snd_small_effect_mgr.h @@ -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 diff --git a/include/d/snd/d_snd_source.h b/include/d/snd/d_snd_source.h index 1b2ca525..2ae4c739 100644 --- a/include/d/snd/d_snd_source.h +++ b/include/d/snd/d_snd_source.h @@ -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(); diff --git a/include/nw4r/snd/snd_SoundHandle.h b/include/nw4r/snd/snd_SoundHandle.h index bca2c59a..847f7942 100644 --- a/include/nw4r/snd/snd_SoundHandle.h +++ b/include/nw4r/snd/snd_SoundHandle.h @@ -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(); } diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index 8d255eb8..63c1ceb4 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -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 *); diff --git a/src/d/snd/d_snd_3d_actor.cpp b/src/d/snd/d_snd_3d_actor.cpp index bf2d7799..41f506aa 100644 --- a/src/d/snd/d_snd_3d_actor.cpp +++ b/src/d/snd/d_snd_3d_actor.cpp @@ -3,6 +3,7 @@ #include "common.h" #include "d/a/d_a_player.h" #include "d/snd/d_snd_3d_manager.h" +#include "d/snd/d_snd_checkers.h" #include "d/snd/d_snd_player_mgr.h" #include "nw4r/math/math_types.h" diff --git a/src/d/snd/d_snd_small_effect_mgr.cpp b/src/d/snd/d_snd_small_effect_mgr.cpp index cab93dd2..24cc3216 100644 --- a/src/d/snd/d_snd_small_effect_mgr.cpp +++ b/src/d/snd/d_snd_small_effect_mgr.cpp @@ -1,8 +1,193 @@ #include "d/snd/d_snd_small_effect_mgr.h" +#include "common.h" +#include "d/snd/d_snd_checkers.h" +#include "d/snd/d_snd_control_player_mgr.h" +#include "d/snd/d_snd_player_mgr.h" +#include "d/snd/d_snd_source.h" +#include "d/snd/d_snd_source_if.h" #include "d/snd/d_snd_util.h" - +#include "d/snd/d_snd_wzsound.h" +#include "nw4r/snd/snd_SeqSoundHandle.h" +#include "rvl/OS/OSFastCast.h" +#include "toBeSorted/music_mgrs.h" SND_DISPOSER_DEFINE(dSndSmallEffectMgr_c) -dSndSmallEffectMgr_c::dSndSmallEffectMgr_c() {} +dSndSmallEffectMgr_c::dSndSmallEffectMgr_c() : mTextboxAdvanceSound(-1), field_0x40(0), field_0x42(0), field_0x44(0) { + // probably arrays + field_0x28 = -1; + field_0x30 = 0; + field_0x2C = -1; + field_0x34 = 0; +} + +bool dSndSmallEffectMgr_c::playSound(u32 soundId) { + if (soundId >= SE_S_BUTTON_CALL_L && soundId <= SE_S_PLAY_GUIDE_BUTTON_BLINK) { + soundId = SE_S_BUTTON_CALL_L; + } else if (soundId >= SE_S_BUTTON_CALL_R && soundId <= SE_S_2_BUTTON_BLINK) { + soundId = SE_S_BUTTON_CALL_R; + } else { + switch (soundId) { + case SE_S_BOSS_KEY_TRANS: { + stopSounds(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_BOSS_KEY_TRANS_OFF, 5); + break; + } + case SE_S_BOSS_KEY_TRANS_OFF: { + stopSounds(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_BOSS_KEY_TRANS, 5); + break; + } + case SE_S_HP_GAUGE_UP: { + if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_HEART_PIECE_GET)) { + return false; + } + break; + } + case SE_S_HEART_PIECE_GET: { + if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_HP_GAUGE_UP)) { + return false; + } + break; + } + case SE_S_MAP_OPEN: + case SE_S_MENU_IN: { + stopSounds(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_HELP_OUT, 1); + break; + } + case SE_S_HELP_OUT: { + if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_MENU_IN) || + isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_MAP_OPEN)) { + return false; + } + break; + } + case SE_S_MENU_SELECT_TURN_PAGE_LEFT: { + if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_SHOP_STK_STOCK_SELECT_TURN_PAGE_LEFT)) { + return 0; + } + break; + } + case SE_S_MENU_SELECT_TURN_PAGE_RIGHT: { + if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_SHOP_STK_STOCK_SELECT_TURN_PAGE_RIGHT)) { + return 0; + } + break; + } + case SE_S_ITEM_SELECT_START: { + if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_BM_KEEP_ERROR)) { + soundId = SE_S_ITEM_SELECT_START_WAIT; + } + break; + } + case SE_S_SKIP: { + if (fn_80364DA0(ENEMY_SOUND_MGR)) { + fn_80365020(ENEMY_SOUND_MGR); + } + break; + } + case SE_S_WINDOW_PRESS_A: { + if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_IMPORTANT, SE_S_POINTER_OK)) { + return 0; + } + break; + } + case SE_S_MENU_P1_HOLD_POINTER: { + stopSounds(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_MENU_P1_POINT_ITEM, 0); + break; + } + case SE_S_MENU_P1_POINT_ITEM: { + if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_MENU_P1_HOLD_POINTER)) { + return 0; + } + break; + } + case SE_S_FIRST_PERSON_ON: + case SE_S_FIRST_PERSON_OFF: { + if (!isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_DOWSING_SELECT_START)) { + playSound(SE_S_DOWSING_SELECT_START); + } + break; + } + case 0x13EF: + if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_FIRST_PERSON_ON)) { + return 0; + } + break; + } + } + + return playSoundInternal(soundId); +} + +bool dSndSmallEffectMgr_c::playSoundWithPan(u32 soundId, f32 pan) { + bool ok = playSoundInternal(soundId); + if (ok) { + if (pan > 1.0f) { + pan = 1.0f; + } else if (pan < -1.0f) { + pan = -1.0f; + } + mNormalSound.SetPan(pan); + } + return ok; +} + +void dSndSmallEffectMgr_c::stopSounds(u32 playerIdx, u32 soundId, s32 fadeFrames) { + SoundStopper stopper(soundId, fadeFrames); + dSndControlPlayerMgr_c::GetInstance()->getPlayer1(playerIdx)->ForEachSound(stopper, false); +} + +void dSndSmallEffectMgr_c::stopSounds(u32 soundId, s32 fadeFrames) { + for (s32 playerId = dSndPlayerMgr_c::PLAYER_SMALL_IMPORTANT; playerId <= dSndControlPlayerMgr_c::sPlayerMax; + playerId++) { + stopSounds(playerId, soundId, fadeFrames); + } +} + +bool dSndSmallEffectMgr_c::isPlayingSound(u32 playerIdx, u32 soundId) { + bool isPlaying = false; + IsCurrentSoundIdChecker check(soundId, &isPlaying); + dSndControlPlayerMgr_c::GetInstance()->getPlayer1(playerIdx)->ForEachSound(check, false); + return isPlaying; +} + +bool dSndSmallEffectMgr_c::isPlayingSound(u32 soundId) { + for (s32 playerId = dSndPlayerMgr_c::PLAYER_SMALL_IMPORTANT; playerId <= dSndControlPlayerMgr_c::sPlayerMax; + playerId++) { + if (isPlayingSound(playerId, soundId)) { + return true; + } + } + return false; +} + +bool dSndSmallEffectMgr_c::playButtonPressSoundWhenAdvancingTextBoxes(f32 ratio) { + if (mTextboxAdvanceSound == -1) { + return false; + } + + bool ok = playSound(mTextboxAdvanceSound); + if (ok) { + s16 varValue; + f32 value = ratio * 100.0f; + OSf32tos16(&value, &varValue); + nw4r::snd::SeqSoundHandle handle(&mNormalSound); + handle.WriteVariable(10, varValue); + } + + return ok; +} + +void dSndSmallEffectMgr_c::resetButtonPressSound() { + mTextboxAdvanceSound = -1; +} + +void dSndSmallEffectMgr_c::setButtonPressSound(dSoundSource_c *source) { + resetButtonPressSound(); + if (source != nullptr) { + mTextboxAdvanceSound = dSoundSource_c::getCharacterTalkSoundId(SE_S_TALK_CHAR, source); + if (mTextboxAdvanceSound == SE_S_TALK_CHAR) { + resetButtonPressSound(); + } + } +} diff --git a/src/d/snd/d_snd_source.cpp b/src/d/snd/d_snd_source.cpp index 11a1589e..96b554a5 100644 --- a/src/d/snd/d_snd_source.cpp +++ b/src/d/snd/d_snd_source.cpp @@ -3,6 +3,8 @@ #include "common.h" #include "d/snd/d_snd_3d_actor.h" #include "d/snd/d_snd_3d_manager.h" +#include "d/snd/d_snd_mgr.h" +#include "d/snd/d_snd_player_mgr.h" #include "nw4r/snd/snd_SoundStartable.h" #include "nw4r/ut/ut_list.h" #include "sized_string.h" @@ -99,6 +101,26 @@ void dSoundSource_c::d_vt_0x5C() { // noop } +u32 dSoundSource_c::getCharacterTalkSoundId(u32 baseSoundId, dSoundSource_c *source) { + if (baseSoundId != -1 && source != nullptr) { + 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 = source->d_s_vt_0x17C(); + label.sprintf("%s_%s", baseLabel, charLabel); + u32 newLabel = dSndPlayerMgr_c::GetInstance()->convertLabelStringToSoundId(label); + if (newLabel != -1) { + return newLabel; + } + } + return baseSoundId; +} + u32 dSoundSource_c::getRemoConSoundVariant(u32 soundId) const { const char *label = soundIdToSoundLabel(soundId); SizedString<64> str; From 052c69fc966c5644ef491b073c32e7821e1f16b3 Mon Sep 17 00:00:00 2001 From: robojumper Date: Fri, 6 Jun 2025 23:17:03 +0200 Subject: [PATCH 16/22] setup for dSndSourceGroup_c --- config/SOUE01/splits.txt | 6 +- config/SOUE01/symbols.txt | 36 +++--- configure.py | 4 +- include/d/snd/d_snd_3d_actor.h | 10 +- include/d/snd/d_snd_misc.h | 29 +++++ include/d/snd/d_snd_source.h | 12 +- include/d/snd/d_snd_source_group.h | 62 +++++++++++ include/d/snd/d_snd_source_if.h | 2 +- include/toBeSorted/music_mgrs.h | 13 +++ src/d/snd/d_snd_3d_actor.cpp | 4 +- src/d/snd/d_snd_source.cpp | 14 +-- src/d/snd/d_snd_source_group.cpp | 169 +++++++++++++++++++++++++++++ 12 files changed, 322 insertions(+), 39 deletions(-) create mode 100644 include/d/snd/d_snd_misc.h create mode 100644 include/d/snd/d_snd_source_group.h create mode 100644 src/d/snd/d_snd_source_group.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index ced03afb..13fb8d6c 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2453,13 +2453,15 @@ d/snd/d_snd_anim_sound.cpp: .text start:0x80382150 end:0x8038240C align:16 .sdata2 start:0x8057DB50 end:0x8057DB68 -d/snd/d_snd_mgr_unk_14.cpp: +d/snd/d_snd_source_mgr.cpp: .text start:0x80382410 end:0x803864C8 align:16 .ctors start:0x804DB91C end:0x804DB920 -d/snd/d_snd_mgr_unk_13.cpp: +d/snd/d_snd_source_group.cpp: .text start:0x803864D0 end:0x803889BC align:16 .data start:0x8054A680 end:0x8054A7D0 + .sdata start:0x805743D0 end:0x80574708 + .sdata2 start:0x8057DBC0 end:0x8057DCB0 d/snd/d_snd_source.cpp: .text start:0x803889C0 end:0x8038C408 align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 937bcc97..0090fe28 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -19838,7 +19838,7 @@ __ct__11dSndActor_cFRQ34nw4r3snd18SoundArchivePlayer = .text:0x8035A560; // type __dt__Q34nw4r3snd11SoundHandleFv = .text:0x8035A5A0; // type:function size:0x54 scope:weak __cl__22SoundPropertiesCheckerFRQ34nw4r3snd11SoundHandle = .text:0x8035A600; // type:function size:0x240 __dt__11dSndActor_cFv = .text:0x8035A840; // type:function size:0x58 scope:weak -__ct__13dSnd3DActor_cFPvUc = .text:0x8035A8A0; // type:function size:0xE8 +__ct__13dSnd3DActor_cFP15dSndSourceParamUc = .text:0x8035A8A0; // type:function size:0xE8 d_vt_0x34__13dSnd3DActor_cFRCQ34nw4r4math4VEC3 = .text:0x8035A990; // type:function size:0x40 resetCachedRelativePositions__13dSnd3DActor_cFv = .text:0x8035A9D0; // type:function size:0x2C fn_8035AA00 = .text:0x8035AA00; // type:function size:0x30 @@ -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 -isNotInStage = .text:0x80362440; // type:function size:0x34 +isInStage = .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 @@ -20128,15 +20128,15 @@ fn_803651A0 = .text:0x803651A0; // type:function size:0xA0 fn_80365240 = .text:0x80365240; // type:function size:0x1F8 fn_80365440 = .text:0x80365440; // type:function size:0x10C fn_80365550 = .text:0x80365550; // type:function size:0x1A8 -fn_80365700 = .text:0x80365700; // type:function size:0xCC +setUnderwaterLpfFreq = .text:0x80365700; // type:function size:0xCC fn_803657D0 = .text:0x803657D0; // type:function size:0x78 fn_80365850 = .text:0x80365850; // type:function size:0x70 fn_803658C0 = .text:0x803658C0; // type:function size:0x5C fn_80365920 = .text:0x80365920; // type:function size:0x4C fn_80365970 = .text:0x80365970; // type:function size:0x8 fn_80365980 = .text:0x80365980; // type:function size:0x54 -fn_803659E0 = .text:0x803659E0; // type:function size:0x4C -fn_80365A30 = .text:0x80365A30; // type:function size:0x48 +resetBgmAndStageEffectLpfFreq = .text:0x803659E0; // type:function size:0x4C +resetBgmLpfFreq = .text:0x80365A30; // type:function size:0x48 fn_80365A80 = .text:0x80365A80; // type:function size:0x4C fn_80365AD0 = .text:0x80365AD0; // type:function size:0xA8 fn_80365B80 = .text:0x80365B80; // type:function size:0x5C @@ -21111,26 +21111,26 @@ fn_80386470 = .text:0x80386470; // type:function size:0x8 @4@d_vt_0x58__14dSoundSource_cFv = .text:0x803864A0; // type:function size:0x8 fn_803864B0 = .text:0x803864B0; // type:function size:0x8 fn_803864C0 = .text:0x803864C0; // type:function size:0x8 -fn_803864D0 = .text:0x803864D0; // type:function size:0x164 -fn_80386640 = .text:0x80386640; // type:function size:0x2C -fn_80386670 = .text:0x80386670; // type:function size:0x118 +set__17dSndSourceGroup_cFlPCc = .text:0x803864D0; // type:function size:0x164 +resetSoundSourceParam__17dSndSourceGroup_cFv = .text:0x80386640; // type:function size:0x2C +__ct__17dSndSourceGroup_cFv = .text:0x80386670; // type:function size:0x118 fn_80386790 = .text:0x80386790; // type:function size:0x120 -fn_803868B0 = .text:0x803868B0; // type:function size:0x54 +__dt__17dSndSourceGroup_cFv = .text:0x803868B0; // type:function size:0x54 fn_80386910 = .text:0x80386910; // type:function size:0xEC fn_80386A00 = .text:0x80386A00; // type:function size:0xB0 fn_80386AB0 = .text:0x80386AB0; // type:function size:0xBC fn_80386B70 = .text:0x80386B70; // type:function size:0xBC -fn_80386C30 = .text:0x80386C30; // type:function size:0x10 -fn_80386C40 = .text:0x80386C40; // type:function size:0x8 -fn_80386C50 = .text:0x80386C50; // type:function size:0x14 -fn_80386C70 = .text:0x80386C70; // type:function size:0x14 -fn_80386C90 = .text:0x80386C90; // type:function size:0x58 -fn_80386CF0 = .text:0x80386CF0; // type:function size:0xEC -fn_80386DE0 = .text:0x80386DE0; // type:function size:0x110 +calc__17dSndSourceGroup_cFv = .text:0x80386C30; // type:function size:0x10 +getNumSources__17dSndSourceGroup_cCFv = .text:0x80386C40; // type:function size:0x8 +registerSource__17dSndSourceGroup_cFP14dSoundSource_c = .text:0x80386C50; // type:function size:0x14 +unregisterSource__17dSndSourceGroup_cFP14dSoundSource_c = .text:0x80386C70; // type:function size:0x14 +clearList__17dSndSourceGroup_cFv = .text:0x80386C90; // type:function size:0x58 +getSourceClosestToListener__17dSndSourceGroup_cFv = .text:0x80386CF0; // type:function size:0xEC +getSourceClosestToPlayer__17dSndSourceGroup_cFv = .text:0x80386DE0; // type:function size:0x110 fn_80386EF0 = .text:0x80386EF0; // type:function size:0x80 -fn_80386F70 = .text:0x80386F70; // type:function size:0x1A4C +setParamFromName__17dSndSourceGroup_cFPCc = .text:0x80386F70; // type:function size:0x1A4C soundForActorInitRelated_803889c0 = .text:0x803889C0; // type:function size:0x4 -__ct__14dSoundSource_cFUcP9dAcBase_cii = .text:0x803889D0; // type:function size:0x108 +__ct__14dSoundSource_cFUcP9dAcBase_ciP17dSndSourceGroup_c = .text:0x803889D0; // type:function size:0x108 __dt__14dSoundSource_cFv = .text:0x80388AE0; // type:function size:0xC4 vt_0x0C__14dSoundSource_cFv = .text:0x80388BB0; // type:function size:0x118 vt_0x44__14dSoundSource_cFv = .text:0x80388CD0; // type:function size:0x9C diff --git a/configure.py b/configure.py index 0bef48dc..9491767d 100644 --- a/configure.py +++ b/configure.py @@ -724,8 +724,8 @@ config.libs = [ Object(NonMatching, "d/snd/d_snd_small_effect_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_harp_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_anim_sound.cpp"), - Object(NonMatching, "d/snd/d_snd_mgr_unk_14.cpp"), - Object(NonMatching, "d/snd/d_snd_mgr_unk_13.cpp"), + Object(NonMatching, "d/snd/d_snd_source_mgr.cpp"), + Object(NonMatching, "d/snd/d_snd_source_group.cpp"), Object(NonMatching, "d/snd/d_snd_source.cpp"), Object(NonMatching, "d/snd/d_snd_mgr_unk_7.cpp"), Object(NonMatching, "d/snd/d_snd_mgr_unk_8.cpp"), diff --git a/include/d/snd/d_snd_3d_actor.h b/include/d/snd/d_snd_3d_actor.h index 98735baf..0d9c5e95 100644 --- a/include/d/snd/d_snd_3d_actor.h +++ b/include/d/snd/d_snd_3d_actor.h @@ -2,6 +2,7 @@ #define D_SND_ACTOR_H #include "common.h" +#include "d/snd/d_snd_misc.h" #include "nw4r/math/math_types.h" #include "nw4r/snd/snd_Sound3DActor.h" @@ -9,7 +10,7 @@ class dSnd3DActor_c : public nw4r::snd::Sound3DActor { static const u32 NUM_SOUNDS = 4; public: - dSnd3DActor_c(UNKTYPE *, u8); + dSnd3DActor_c(dSndSourceParam *pAmbientParam, u8); virtual ~dSnd3DActor_c() {} @@ -59,6 +60,11 @@ public: mFlags |= flag; } + f32 getDistanceToListener() { + updateDistanceToListener(); + return mDistanceToListener; + } + bool hasPlayingSounds() const; bool isPlayingSound(u32 id); @@ -82,7 +88,7 @@ protected: /* 0xAC */ nw4r::math::VEC3 mPositionTransformedByListener; /* 0xB8 */ f32 mDistanceToCameraTarget; /* 0xBC */ nw4r::math::VEC3 mPositionRelativeToCameraTarget; - /* 0xC8 */ UNKTYPE *a_field_0xC8; + /* 0xC8 */ dSndSourceParam *mpFloatBundle; /* 0xCC */ u16 mFlags; /* 0xD0 */ nw4r::math::VEC3 mPositionRelativeToPlayer; /* 0xDC */ f32 mDistanceToPlayer; diff --git a/include/d/snd/d_snd_misc.h b/include/d/snd/d_snd_misc.h new file mode 100644 index 00000000..f5bfaa7f --- /dev/null +++ b/include/d/snd/d_snd_misc.h @@ -0,0 +1,29 @@ +#ifndef D_SND_MISC_H +#define D_SND_MISC_H + +#include "common.h" + +// This is at least accessed by dSnd3DEngine_c's functions that +// are called as part of UpdateAmbientParam. Appears to be +// related to the biquadFilterValue. +struct dSndSourceParam { + dSndSourceParam() { + reset(); + } + + void reset() { + field_0x00 = 300.0; + field_0x04 = 1000.0f; + field_0x08 = 100.0f; + field_0x0C = 400.0f; + field_0x10 = 5000.0f; + } + + /* 0x00 */ f32 field_0x00; + /* 0x04 */ f32 field_0x04; + /* 0x08 */ f32 field_0x08; + /* 0x0C */ f32 field_0x0C; + /* 0x10 */ f32 field_0x10; +}; + +#endif diff --git a/include/d/snd/d_snd_source.h b/include/d/snd/d_snd_source.h index 2ae4c739..238bbef0 100644 --- a/include/d/snd/d_snd_source.h +++ b/include/d/snd/d_snd_source.h @@ -6,13 +6,16 @@ #include "d/snd/d_snd_source_if.h" #include "nw4r/ut/ut_list.h" +class dSndSourceGroup_c; + /** Manages sound relating to a particular actor. */ +/** Size: probably 0x15C */ class dSoundSource_c : public dSoundSourceIf_c, public dSnd3DActor_c { public: - dSoundSource_c(u8, dAcBase_c *, UNKWORD, UNKWORD); + dSoundSource_c(u8, dAcBase_c *, UNKWORD, dSndSourceGroup_c *pOwnerGroup); virtual ~dSoundSource_c(); - static u32 getCharacterTalkSoundId(u32 baseSoundId, dSoundSource_c* source); + 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 @@ -94,13 +97,12 @@ private: /* 0x11C */ UNKWORD field_0x11C; /* 0x120 */ nw4r::ut::List field_0x120; // node offset 0x4 /* 0x12C */ nw4r::ut::List field_0x12C; // node offset 0x4 - /* 0x138 */ nw4r::ut::Node mNode; - /* 0x140 */ UNKWORD field_0x140; + /* 0x138 */ nw4r::ut::Node mGroupLink; // node for list in dSndSourceGroup_c + /* 0x140 */ dSndSourceGroup_c *mpOwnerGroup; /* 0x144 */ u8 _0x144[0x154 - 0x144]; /* 0x154 */ UNKWORD field_0x154; /* 0x158 */ s16 field_0x158; /* 0x15A */ s16 field_0x15A; - /* 0x15C */ nw4r::ut::Node mNode2; }; #endif diff --git a/include/d/snd/d_snd_source_group.h b/include/d/snd/d_snd_source_group.h new file mode 100644 index 00000000..273df135 --- /dev/null +++ b/include/d/snd/d_snd_source_group.h @@ -0,0 +1,62 @@ +#ifndef D_SND_SOURCE_GROUP_H +#define D_SND_SOURCE_GROUP_H + +#include "common.h" +#include "d/snd/d_snd_misc.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 + * depending on proximity to a certain object or enemy. + * + * Through its dSndSourceParam, it can also "send" parameters to all dSnd3DActors + * corresponding to these sound sources. + * + * Size: 0x70 + */ +class dSndSourceGroup_c { +public: + dSndSourceGroup_c(); + ~dSndSourceGroup_c(); + + void registerSource(dSoundSource_c *); + void unregisterSource(dSoundSource_c *); + + dSndSourceParam* getAmbientParam() { + return &mParam; + } + + dSoundSource_c *getSourceClosestToListener(); + dSoundSource_c *getSourceClosestToPlayer(); + + s32 getNumSources() const; + void set(s32 type, const char *name); + void calc(); + +private: + bool setParamFromName(const char *name); + void resetSoundSourceParam(); + void clearList(); + + /* 0x00 */ nw4r::ut::Node mNode; + /* 0x08 */ u8 _0x08[0x10 - 0x08]; + /* 0x10 */ UNKWORD field_0x10; + /* 0x14 */ UNKWORD field_0x14; + /* 0x18 */ UNKWORD field_0x18; + /* 0x1C */ u8 field_0x1C; + /* 0x1D */ u8 field_0x1D; + /* 0x1E */ SizedString<32> mName; + /* 0x40 */ UNKWORD field_0x40; + /* 0x44 */ nw4r::ut::List mSourceList; + /* 0x50 */ dSndSourceParam mParam; + /* 0x64 */ dSoundSource_c *mpCachedClosestSourceToListener; + /* 0x68 */ dSoundSource_c *mpCachedClosestSourceToPlayer; + /* 0x6C */ bool mCalculatedClosestToListener; + /* 0x6C */ bool mCalculatedClosestToPlayer; +}; + +#endif diff --git a/include/d/snd/d_snd_source_if.h b/include/d/snd/d_snd_source_if.h index 8a77ff67..e1edb145 100644 --- a/include/d/snd/d_snd_source_if.h +++ b/include/d/snd/d_snd_source_if.h @@ -14,7 +14,7 @@ public: SOUNDSOURCE_VIRTUAL(0x0C); SOUNDSOURCE_VIRTUAL(0x10); SOUNDSOURCE_VIRTUAL(0x14); - SOUNDSOURCE_VIRTUAL(0x18); + virtual s32 getActorType() const; SOUNDSOURCE_VIRTUAL(0x1C); SOUNDSOURCE_VIRTUAL(0x20); SOUNDSOURCE_VIRTUAL(0x24); diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index 63c1ceb4..97082aac 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -32,6 +32,19 @@ extern "C" void fn_80364D00(void *, s32); // ENEMY_BGM_RELATED_MGR -> dSndSourceMgr_c // 0x3870 = player sound source // 0x3874 = Fi + +// 0 - "" - Link +// ActorLink::initModels +// 0x2C - NpcKenT +// 0x20 - Door, TBox, CharE (Chair), Tubo +// 0x35 - TgSound +// 0x2D - PyBird +// 0x22 - Bamboo +// 0x23 - Item + +// 0x19 - Nusi*, BKr, BBs +// 0x1A - MgRArm, MgLArm +// 0x1B - Mgtail extern "C" void *ENEMY_BGM_RELATED_MGR; extern "C" void fn_80384570(void *, bool); extern "C" void fn_803858D0(void *); diff --git a/src/d/snd/d_snd_3d_actor.cpp b/src/d/snd/d_snd_3d_actor.cpp index 41f506aa..bf0ddd05 100644 --- a/src/d/snd/d_snd_3d_actor.cpp +++ b/src/d/snd/d_snd_3d_actor.cpp @@ -9,7 +9,7 @@ #include -dSnd3DActor_c::dSnd3DActor_c(UNKTYPE *a1, u8 a2) +dSnd3DActor_c::dSnd3DActor_c(dSndSourceParam *pFloatBundle, u8 a2) : nw4r::snd::Sound3DActor( dSndPlayerMgr_c::GetInstance()->getSoundArchivePlayerForType(a2), dSnd3DManager_c::GetInstance()->getManager() ), @@ -24,7 +24,7 @@ dSnd3DActor_c::dSnd3DActor_c(UNKTYPE *a1, u8 a2) mDistanceToListener(INFINITY), mCameraDirectionDot(0.0f), a_field_0x9C(0.0f), - a_field_0xC8(a1), + mpFloatBundle(pFloatBundle), mFlags(0), mDistanceToPlayer(INFINITY), a_field_0xE0(0.0f) { diff --git a/src/d/snd/d_snd_source.cpp b/src/d/snd/d_snd_source.cpp index 96b554a5..4e582666 100644 --- a/src/d/snd/d_snd_source.cpp +++ b/src/d/snd/d_snd_source.cpp @@ -5,13 +5,12 @@ #include "d/snd/d_snd_3d_manager.h" #include "d/snd/d_snd_mgr.h" #include "d/snd/d_snd_player_mgr.h" +#include "d/snd/d_snd_source_group.h" #include "nw4r/snd/snd_SoundStartable.h" #include "nw4r/ut/ut_list.h" #include "sized_string.h" extern "C" u8 fn_80382590(u8, UNKWORD); -extern "C" void fn_80386C50(UNKWORD, dSoundSource_c *); -extern "C" void fn_80386C70(dSoundSource_c *); struct d_snd_mgr_unk_6_sinit { d_snd_mgr_unk_6_sinit() : field_0x00(0), field_0x04(0.0f) {} @@ -26,8 +25,8 @@ const char *help_i_need_data() { return "%s_%s_%d"; } -dSoundSource_c::dSoundSource_c(u8 a1, dAcBase_c *player, UNKWORD a3, UNKWORD a4) - : dSnd3DActor_c(((char *)a4) + 0x50, a1), +dSoundSource_c::dSoundSource_c(u8 a1, dAcBase_c *player, UNKWORD a3, dSndSourceGroup_c *pOwnerGroup) + : dSnd3DActor_c(pOwnerGroup->getAmbientParam(), a1), field_0x0F0(a3), field_0x0F4(0), mpPlayer(player), @@ -41,7 +40,7 @@ dSoundSource_c::dSoundSource_c(u8 a1, dAcBase_c *player, UNKWORD a3, UNKWORD a4) field_0x108(0), field_0x10C(0), field_0x11C(0), - field_0x140(a4), + mpOwnerGroup(pOwnerGroup), field_0x154(0), field_0x158(-1), field_0x15A(-1) { @@ -50,13 +49,14 @@ dSoundSource_c::dSoundSource_c(u8 a1, dAcBase_c *player, UNKWORD a3, UNKWORD a4) nw4r::ut::List_Init(&field_0x110, 0xEC); nw4r::ut::List_Init(&field_0x120, 0x04); nw4r::ut::List_Init(&field_0x12C, 0x04); - fn_80386C50(a4, this); + pOwnerGroup->registerSource(this); } dSoundSource_c::~dSoundSource_c() { SetUserParam(0); vt_0x44(); - fn_80386C70(this); + d_s_vt_0x1BC(); + mpOwnerGroup->unregisterSource(this); } const nw4r::math::VEC3 &dSoundSource_c::getListenerPosition() const { diff --git a/src/d/snd/d_snd_source_group.cpp b/src/d/snd/d_snd_source_group.cpp new file mode 100644 index 00000000..91e2542e --- /dev/null +++ b/src/d/snd/d_snd_source_group.cpp @@ -0,0 +1,169 @@ + +#include "d/snd/d_snd_source_group.h" + +#include "common.h" +#include "d/snd/d_snd_source.h" +#include "nw4r/ut/ut_list.h" + +#include + +extern "C" bool isInStage(const char *stageName); + +void dSndSourceGroup_c::set(s32 type, const char *name) { + resetSoundSourceParam(); + bool assignedParam = false; + + switch (field_0x14) { + case 0: { + assignedParam = true; + mParam.field_0x10 = INFINITY; + break; + } + case 1: + if (type == 7) { + assignedParam = true; + mParam.field_0x00 = 1500.0f; + mParam.field_0x10 = INFINITY; + } + break; + } + + if (!assignedParam && (type == 44 || type == 58)) { + assignedParam = true; + mParam.field_0x10 = INFINITY; + } + + if (!assignedParam) { + assignedParam = setParamFromName(name); + } + + if (!assignedParam) { + switch (type) { + case 51: { + mParam.field_0x00 = 300.0f; + mParam.field_0x04 = 800.0; + mParam.field_0x10 = 2200.0; + break; + } + case 48: { + if (isInStage("F401")) { + mParam.field_0x00 = 500.0f; + mParam.field_0x04 = 4000.0; + } else if (isInStage("F402")) { + mParam.field_0x00 = 400.0f; + mParam.field_0x04 = 3500.0; + } else { + mParam.field_0x00 = 300.0f; + mParam.field_0x04 = 800.0; + mParam.field_0x10 = 2200.0; + } + + mParam.field_0x10 = INFINITY; + } + } + } +} + +void dSndSourceGroup_c::resetSoundSourceParam() { + mParam.reset(); +} + +dSndSourceGroup_c::dSndSourceGroup_c() + : field_0x18(0), + field_0x1C(0), + field_0x1D(0), + mName(""), + field_0x40(0), + mpCachedClosestSourceToListener(nullptr), + mpCachedClosestSourceToPlayer(nullptr), + mCalculatedClosestToListener(false), + mCalculatedClosestToPlayer(false) { + // TODO offsetof + nw4r::ut::List_Init(&mSourceList, 0x138); + resetSoundSourceParam(); +} + +dSndSourceGroup_c::~dSndSourceGroup_c() { + clearList(); +} + +void dSndSourceGroup_c::calc() { + // Reset freshness flags, computed on-demand + mCalculatedClosestToPlayer = false; + mCalculatedClosestToListener = false; +} + +s32 dSndSourceGroup_c::getNumSources() const { + return nw4r::ut::List_GetSize(&mSourceList); +} + +void dSndSourceGroup_c::registerSource(dSoundSource_c *source) { + if (source != nullptr) { + nw4r::ut::List_Append(&mSourceList, source); + } +} + +void dSndSourceGroup_c::unregisterSource(dSoundSource_c *source) { + if (source != nullptr) { + nw4r::ut::List_Remove(&mSourceList, source); + } +} + +void dSndSourceGroup_c::clearList() { + dSoundSource_c *source = static_cast(nw4r::ut::List_GetNext(&mSourceList, nullptr)); + while (source != nullptr) { + nw4r::ut::List_Remove(&mSourceList, source); + source = static_cast(nw4r::ut::List_GetNext(&mSourceList, nullptr)); + } +} + +dSoundSource_c *dSndSourceGroup_c::getSourceClosestToListener() { + if (mCalculatedClosestToListener) { + return mpCachedClosestSourceToListener; + } + + mpCachedClosestSourceToListener = nullptr; + f32 closest = INFINITY; + for (dSoundSource_c *source = static_cast(nw4r::ut::List_GetNext(&mSourceList, nullptr)); + source != nullptr; source = static_cast(nw4r::ut::List_GetNext(&mSourceList, source))) { + if (source->getActorType() != 1 && source->getActorType() != 48) { + f32 dist = source->getDistanceToListener(); + if (dist < closest) { + closest = dist; + mpCachedClosestSourceToListener = source; + } + } + } + mCalculatedClosestToListener = true; + return mpCachedClosestSourceToListener; +} + +dSoundSource_c *dSndSourceGroup_c::getSourceClosestToPlayer() { + if (mCalculatedClosestToPlayer) { + return mpCachedClosestSourceToPlayer; + } + + if ((s32)nw4r::ut::List_GetSize(&mSourceList) <= 1) { + return static_cast(nw4r::ut::List_GetNext(&mSourceList, nullptr)); + } + + mpCachedClosestSourceToPlayer = nullptr; + f32 closest = INFINITY; + for (dSoundSource_c *source = static_cast(nw4r::ut::List_GetNext(&mSourceList, nullptr)); + source != nullptr; source = static_cast(nw4r::ut::List_GetNext(&mSourceList, source))) { + if (source->getActorType() != 1 && source->getActorType() != 48) { + f32 dist = source->getDistanceToPlayer(); + if (dist < closest) { + closest = dist; + mpCachedClosestSourceToPlayer = source; + } + } + } + mCalculatedClosestToPlayer = true; + return mpCachedClosestSourceToPlayer; +} + +bool dSndSourceGroup_c::setParamFromName(const char*) { + // TODO + return false; +} From 5969ccb7fd2b9eb69619b012b05506e5222136b6 Mon Sep 17 00:00:00 2001 From: robojumper Date: Fri, 6 Jun 2025 23:30:01 +0200 Subject: [PATCH 17/22] Consistent names --- include/d/snd/d_snd_3d_actor.h | 4 ++-- src/d/snd/d_snd_3d_actor.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/d/snd/d_snd_3d_actor.h b/include/d/snd/d_snd_3d_actor.h index 0d9c5e95..ce5b37c7 100644 --- a/include/d/snd/d_snd_3d_actor.h +++ b/include/d/snd/d_snd_3d_actor.h @@ -10,7 +10,7 @@ class dSnd3DActor_c : public nw4r::snd::Sound3DActor { static const u32 NUM_SOUNDS = 4; public: - dSnd3DActor_c(dSndSourceParam *pAmbientParam, u8); + dSnd3DActor_c(dSndSourceParam *pSourceParam, u8); virtual ~dSnd3DActor_c() {} @@ -88,7 +88,7 @@ protected: /* 0xAC */ nw4r::math::VEC3 mPositionTransformedByListener; /* 0xB8 */ f32 mDistanceToCameraTarget; /* 0xBC */ nw4r::math::VEC3 mPositionRelativeToCameraTarget; - /* 0xC8 */ dSndSourceParam *mpFloatBundle; + /* 0xC8 */ dSndSourceParam *mpSourceParam; /* 0xCC */ u16 mFlags; /* 0xD0 */ nw4r::math::VEC3 mPositionRelativeToPlayer; /* 0xDC */ f32 mDistanceToPlayer; diff --git a/src/d/snd/d_snd_3d_actor.cpp b/src/d/snd/d_snd_3d_actor.cpp index bf0ddd05..f617fb35 100644 --- a/src/d/snd/d_snd_3d_actor.cpp +++ b/src/d/snd/d_snd_3d_actor.cpp @@ -9,7 +9,7 @@ #include -dSnd3DActor_c::dSnd3DActor_c(dSndSourceParam *pFloatBundle, u8 a2) +dSnd3DActor_c::dSnd3DActor_c(dSndSourceParam *pSourceParam, u8 a2) : nw4r::snd::Sound3DActor( dSndPlayerMgr_c::GetInstance()->getSoundArchivePlayerForType(a2), dSnd3DManager_c::GetInstance()->getManager() ), @@ -24,7 +24,7 @@ dSnd3DActor_c::dSnd3DActor_c(dSndSourceParam *pFloatBundle, u8 a2) mDistanceToListener(INFINITY), mCameraDirectionDot(0.0f), a_field_0x9C(0.0f), - mpFloatBundle(pFloatBundle), + mpSourceParam(pSourceParam), mFlags(0), mDistanceToPlayer(INFINITY), a_field_0xE0(0.0f) { From 00d7d441058b3d4465ceb23fd59fc3b0f966477a Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 7 Jun 2025 10:28:42 +0200 Subject: [PATCH 18/22] A bit of source manager maybe --- config/SOUE01/splits.txt | 2 + config/SOUE01/symbols.txt | 16 ++++---- include/d/snd/d_snd_source.h | 2 +- include/d/snd/d_snd_source_group.h | 5 ++- include/d/snd/d_snd_source_mgr.h | 64 ++++++++++++++++++++++++++++++ include/toBeSorted/music_mgrs.h | 23 ++--------- src/d/d_message.cpp | 3 +- src/d/snd/d_snd_source_mgr.cpp | 41 +++++++++++++++++++ 8 files changed, 124 insertions(+), 32 deletions(-) create mode 100644 include/d/snd/d_snd_source_mgr.h create mode 100644 src/d/snd/d_snd_source_mgr.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 13fb8d6c..16053edc 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2456,6 +2456,8 @@ d/snd/d_snd_anim_sound.cpp: d/snd/d_snd_source_mgr.cpp: .text start:0x80382410 end:0x803864C8 align:16 .ctors start:0x804DB91C end:0x804DB920 + .sbss start:0x80575DA8 end:0x80575DB0 + .sdata2 start:0x8057DB68 end:0x8057DBC0 d/snd/d_snd_source_group.cpp: .text start:0x803864D0 end:0x803889BC align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 0090fe28..b169a0e8 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -20960,10 +20960,10 @@ fn_80383960 = .text:0x80383960; // type:function size:0x9C d_s_vt_0x180__14dSoundSource_cFv = .text:0x80383A00; // type:function size:0x8 d_s_vt_0x1DC__14dSoundSource_cFv = .text:0x80383A10; // type:function size:0x8 d_s_vt_0x1D8__14dSoundSource_cFv = .text:0x80383A20; // type:function size:0x4 -fn_80383A30 = .text:0x80383A30; // type:function size:0x78 -initEnemyBgmRelatedMgr = .text:0x80383AB0; // type:function size:0x48 -fn_80383B00 = .text:0x80383B00; // type:function size:0x10 -EnemyBgmRelatedMgr__ctor = .text:0x80383B10; // type:function size:0x140 +__dt__33SndMgrDisposer<15dSndSourceMgr_c>Fv = .text:0x80383A30; // type:function size:0x78 +create__33SndMgrDisposer<15dSndSourceMgr_c>Fv = .text:0x80383AB0; // type:function size:0x48 +remove__33SndMgrDisposer<15dSndSourceMgr_c>Fv = .text:0x80383B00; // type:function size:0x10 +__ct__15dSndSourceMgr_cFv = .text:0x80383B10; // type:function size:0x140 fn_80383C50 = .text:0x80383C50; // type:function size:0x78 fn_80383CD0 = .text:0x80383CD0; // type:function size:0x4C fn_80383D20 = .text:0x80383D20; // type:function size:0x44 @@ -21015,7 +21015,7 @@ fn_803857C0 = .text:0x803857C0; // type:function size:0x5C fn_80385820 = .text:0x80385820; // type:function size:0x8 fn_80385830 = .text:0x80385830; // type:function size:0x44 fn_80385880 = .text:0x80385880; // type:function size:0x50 -fn_803858D0 = .text:0x803858D0; // type:function size:0xA0 +playFlowSound__15dSndSourceMgr_cFUl = .text:0x803858D0; // type:function size:0xA0 fn_80385970 = .text:0x80385970; // type:function size:0x90 vt_0x118__14dSoundSource_cFv = .text:0x80385A00; // type:function size:0x8 vt_0x114__14dSoundSource_cFv = .text:0x80385A10; // type:function size:0x4 @@ -37750,7 +37750,7 @@ lbl_80549EC4 = .data:0x80549EC4; // type:object size:0x1EC lbl_8054A0B0 = .data:0x8054A0B0; // type:object size:0x1EC lbl_8054A29C = .data:0x8054A29C; // type:object size:0x1EC lbl_8054A488 = .data:0x8054A488; // type:object size:0x1EC -lbl_8054A674 = .data:0x8054A674; // type:object size:0xC +__vt__33SndMgrDisposer<15dSndSourceMgr_c> = .data:0x8054A674; // type:object size:0xC lbl_8054A680 = .data:0x8054A680; // type:object size:0x150 lbl_8054A7D0 = .data:0x8054A7D0; // type:object size:0xC __vt__14dSoundSource_c = .data:0x8054A7DC; // type:object size:0x1EC @@ -41913,8 +41913,8 @@ sInstance__20dSndSmallEffectMgr_c = .sbss:0x80575D98; // type:object size:0x4 da sDisposer__20dSndSmallEffectMgr_c = .sbss:0x80575D9C; // type:object size:0x4 data:4byte lbl_80575DA0 = .sbss:0x80575DA0; // type:object size:0x4 data:4byte lbl_80575DA4 = .sbss:0x80575DA4; // type:object size:0x4 data:4byte -ENEMY_BGM_RELATED_MGR = .sbss:0x80575DA8; // type:object size:0x4 data:4byte -lbl_80575DAC = .sbss:0x80575DAC; // 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 lbl_80575DC0 = .sbss:0x80575DC0; // type:object size:0x8 data:4byte diff --git a/include/d/snd/d_snd_source.h b/include/d/snd/d_snd_source.h index 238bbef0..c19485ce 100644 --- a/include/d/snd/d_snd_source.h +++ b/include/d/snd/d_snd_source.h @@ -78,8 +78,8 @@ private: // at 0x00: dSoundSourceIf_c vtable // at 0x04: dSnd3DActor_c sub-object // at 0x58: thunk-vtable - /* 0xE8 */ u8 field_0xE8[0xF0 - 0xE8]; + /* 0xE8 */ nw4r::ut::Node mMgrLink; /* 0x0F0 */ UNKWORD field_0x0F0; /* 0x0F4 */ UNKWORD field_0x0F4; /* 0x0F8 */ dAcBase_c *mpPlayer; diff --git a/include/d/snd/d_snd_source_group.h b/include/d/snd/d_snd_source_group.h index 273df135..cabf4f82 100644 --- a/include/d/snd/d_snd_source_group.h +++ b/include/d/snd/d_snd_source_group.h @@ -21,6 +21,7 @@ class dSoundSource_c; class dSndSourceGroup_c { public: dSndSourceGroup_c(); + dSndSourceGroup_c(u32, const char*, u32, u32); ~dSndSourceGroup_c(); void registerSource(dSoundSource_c *); @@ -42,8 +43,8 @@ private: void resetSoundSourceParam(); void clearList(); - /* 0x00 */ nw4r::ut::Node mNode; - /* 0x08 */ u8 _0x08[0x10 - 0x08]; + /* 0x00 */ nw4r::ut::Node mNode1; + /* 0x08 */ nw4r::ut::Node mNode2; /* 0x10 */ UNKWORD field_0x10; /* 0x14 */ UNKWORD field_0x14; /* 0x18 */ UNKWORD field_0x18; diff --git a/include/d/snd/d_snd_source_mgr.h b/include/d/snd/d_snd_source_mgr.h new file mode 100644 index 00000000..b74b13b4 --- /dev/null +++ b/include/d/snd/d_snd_source_mgr.h @@ -0,0 +1,64 @@ +#ifndef D_SND_SOURCE_MGR_H +#define D_SND_SOURCE_MGR_H + +#include "d/snd/d_snd_source.h" +#include "d/snd/d_snd_source_group.h" +#include "d/snd/d_snd_util.h" +#include "nw4r/ut/ut_list.h" + +SND_DISPOSER_FORWARD_DECL(dSndSourceMgr_c); + +// 0 - "" - Link +// ActorLink::initModels +// 0x2C - NpcKenT +// 0x20 - Door, TBox, CharE (Chair), Tubo +// 0x35 - TgSound +// 0x2D - PyBird +// 0x22 - Bamboo +// 0x23 - Item + +// 0x19 - Nusi*, BKr, BBs +// 0x1A - MgRArm, MgLArm +// 0x1B - Mgtail + +class dSndSourceMgr_c { + SND_DISPOSER_MEMBERS(dSndSourceMgr_c); + + static const u32 NUM_GROUPS = 128; + +public: + dSndSourceMgr_c(); + + void playFlowSound(u32 id); + +private: + /* 0x0010 */ u8 field_0x0010; + /* 0x0011 */ u8 field_0x0011; + /* 0x0012 */ u8 field_0x0012; + /* 0x0013 */ u8 field_0x0013; + + /* 0x0014 */ dSndSourceGroup_c *mpDefaultGroup; + /* 0x0018 */ nw4r::ut::List mGroupList1; + /* 0x0024 */ nw4r::ut::List mGroupList2; + /* 0x0030 */ nw4r::ut::List mGroupList3; + /* 0x003C */ dSndSourceGroup_c mGroups[NUM_GROUPS]; + + // Not sure what these are for + /* 0x383C */ nw4r::ut::List mSourceList1; // node offset 0xE8, probably into dSoundSource::mMgrLink + /* 0x3848 */ nw4r::ut::List field_0x3848; // node offset 0x15C, possibly a subset of source types + /* 0x3854 */ nw4r::ut::List field_0x3854; // node offset 0x160 + + /* 0x3860 */ UNKWORD field_0x3860; + /* 0x3864 */ UNKWORD field_0x3864; + /* 0x3868 */ UNKWORD field_0x3868; + /* 0x386C */ f32 field_0x386C; + + /* 0x3870 */ dSoundSource_c *mpPlayerSource; + /* 0x3874 */ dSoundSource_c *mpFiTalkSource; + /* 0x3878 */ dSoundSource_c *field_0x3878; + /* 0x387C */ dSoundSource_c *field_0x387C; + /* 0x3880 */ dSoundSource_c *field_0x3880; // fi singing related? + /* 0x3884 */ dSoundSource_c *field_0x3884; +}; + +#endif diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index 97082aac..b7b4d884 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -3,6 +3,7 @@ #include "common.h" #include "d/snd/d_snd_player_mgr.h" +#include "d/snd/d_snd_source_mgr.h" class dSndPlayerMgr_c; class dSndSound_c; @@ -29,26 +30,8 @@ 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 - -// 0 - "" - Link -// ActorLink::initModels -// 0x2C - NpcKenT -// 0x20 - Door, TBox, CharE (Chair), Tubo -// 0x35 - TgSound -// 0x2D - PyBird -// 0x22 - Bamboo -// 0x23 - Item - -// 0x19 - Nusi*, BKr, BBs -// 0x1A - MgRArm, MgLArm -// 0x1B - Mgtail -extern "C" void *ENEMY_BGM_RELATED_MGR; -extern "C" void fn_80384570(void *, bool); -extern "C" void fn_803858D0(void *); - +#define ENEMY_BGM_RELATED_MGR (dSndSourceMgr_c::GetInstance()) +extern "C" void fn_80384570(dSndSourceMgr_c *, bool); // This one has a SoundActor that actually plays the BGM_ music tracks, // including the battle BGM track. diff --git a/src/d/d_message.cpp b/src/d/d_message.cpp index 5340403e..d8651932 100644 --- a/src/d/d_message.cpp +++ b/src/d/d_message.cpp @@ -23,6 +23,7 @@ #include "d/lyt/meter/d_lyt_meter.h" #include "d/lyt/msg_window/d_lyt_msg_window.h" #include "d/snd/d_snd_small_effect_mgr.h" +#include "d/snd/d_snd_source_mgr.h" #include "egg/core/eggHeap.h" #include "f/f_base.h" #include "f/f_profile.h" @@ -198,7 +199,7 @@ void dFlow_c::playSound(u32 params) { return; } if (params >= 100) { - fn_803858D0(ENEMY_BGM_RELATED_MGR); + dSndSourceMgr_c::GetInstance()->playFlowSound(params); return; } diff --git a/src/d/snd/d_snd_source_mgr.cpp b/src/d/snd/d_snd_source_mgr.cpp new file mode 100644 index 00000000..8cf61822 --- /dev/null +++ b/src/d/snd/d_snd_source_mgr.cpp @@ -0,0 +1,41 @@ +#include "d/snd/d_snd_source_mgr.h" + +#include "common.h" +#include "d/snd/d_snd_source.h" +#include "nw4r/ut/ut_list.h" + +#include + +SND_DISPOSER_DEFINE(dSndSourceMgr_c); + +dSndSourceMgr_c::dSndSourceMgr_c() + : field_0x0010(0), + field_0x0011(0), + field_0x0012(0), + field_0x0013(0), + field_0x3860(0), + field_0x3864(0), + field_0x3868(0), + field_0x386C(INFINITY), + mpPlayerSource(nullptr), + mpFiTalkSource(nullptr), + field_0x3878(nullptr), + field_0x387C(nullptr), + field_0x3880(nullptr), + field_0x3884(nullptr) { + // TODO offsetof + nw4r::ut::List_Init(&mGroupList1, 0); + nw4r::ut::List_Init(&mGroupList2, 0); + + // TODO figure out what these are for + nw4r::ut::List_Init(&mGroupList3, 8); + nw4r::ut::List_Init(&mSourceList1, 0xE8); + nw4r::ut::List_Init(&field_0x3848, 0x15C); + nw4r::ut::List_Init(&field_0x3854, 0x160); + + mpDefaultGroup = new dSndSourceGroup_c(-1, "Default", 0, 0); + + for (dSndSourceGroup_c *group = &mGroups[0]; group < &mGroups[NUM_GROUPS]; group++) { + nw4r::ut::List_Append(&mGroupList2, group); + } +} From 3e3bfd0baae4687abe1c38f945111fb8701c83d0 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 7 Jun 2025 22:29:27 +0200 Subject: [PATCH 19/22] A bit of source manager --- config/SOUE01/splits.txt | 1 + config/SOUE01/symbols.txt | 16 ++-- include/d/snd/d_snd_3d_actor.h | 2 - include/d/snd/d_snd_source.h | 17 ++-- include/d/snd/d_snd_source_group.h | 6 +- include/d/snd/d_snd_source_if.h | 5 +- include/d/snd/d_snd_source_mgr.h | 16 +++- src/d/snd/d_snd_control_player_mgr.cpp | 2 +- src/d/snd/d_snd_sound.cpp | 2 +- src/d/snd/d_snd_source.cpp | 16 ++-- src/d/snd/d_snd_source_group.cpp | 23 +++--- src/d/snd/d_snd_source_mgr.cpp | 107 ++++++++++++++++++++++++- 12 files changed, 165 insertions(+), 48 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 16053edc..8a4471e6 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2456,6 +2456,7 @@ d/snd/d_snd_anim_sound.cpp: d/snd/d_snd_source_mgr.cpp: .text start:0x80382410 end:0x803864C8 align:16 .ctors start:0x804DB91C end:0x804DB920 + .sdata start:0x80574310 end:0x805743D0 .sbss start:0x80575DA8 end:0x80575DB0 .sdata2 start:0x8057DB68 end:0x8057DBC0 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index b169a0e8..cc02a351 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -20985,20 +20985,20 @@ fn_803848B0 = .text:0x803848B0; // type:function size:0xAC fn_80384960 = .text:0x80384960; // type:function size:0x8C fn_803849F0 = .text:0x803849F0; // type:function size:0xC fn_80384A00 = .text:0x80384A00; // type:function size:0x174 -fn_80384B80 = .text:0x80384B80; // type:function size:0x178 -vt_0x10__14dSoundSource_cFv = .text:0x80384D00; // type:function size:0x8 -fn_80384D10 = .text:0x80384D10; // type:function size:0x78 +registerSource__15dSndSourceMgr_cFP14dSoundSource_c = .text:0x80384B80; // type:function size:0x178 +getCategory__14dSoundSource_cCFv = .text:0x80384D00; // type:function size:0x8 +isCertainEnemyType__15dSndSourceMgr_cFP14dSoundSource_c = .text:0x80384D10; // type:function size:0x78 fn_80384D90 = .text:0x80384D90; // type:function size:0x98 -fn_80384E30 = .text:0x80384E30; // type:function size:0xBC -fn_80384EF0 = .text:0x80384EF0; // type:function size:0xAC +unregisterSource__15dSndSourceMgr_cFP14dSoundSource_c = .text:0x80384E30; // type:function size:0xBC +removeSourceFromList__15dSndSourceMgr_cFP14dSoundSource_cPQ34nw4r2ut4List = .text:0x80384EF0; // type:function size:0xAC fn_80384FA0 = .text:0x80384FA0; // type:function size:0x14 -fn_80384FC0 = .text:0x80384FC0; // type:function size:0x50 +clearSourceLists__15dSndSourceMgr_cFv = .text:0x80384FC0; // type:function size:0x50 fn_80385010 = .text:0x80385010; // type:function size:0x60 fn_80385070 = .text:0x80385070; // type:function size:0x18 fn_80385090 = .text:0x80385090; // type:function size:0x18 fn_803850B0 = .text:0x803850B0; // type:function size:0x108 fn_803851C0 = .text:0x803851C0; // type:function size:0x74 -fn_80385240 = .text:0x80385240; // type:function size:0x64 +clearSourceList__15dSndSourceMgr_cFPQ34nw4r2ut4List = .text:0x80385240; // type:function size:0x64 fn_803852B0 = .text:0x803852B0; // type:function size:0x3C fn_803852F0 = .text:0x803852F0; // type:function size:0x3C fn_80385330 = .text:0x80385330; // type:function size:0x94 @@ -21130,7 +21130,7 @@ getSourceClosestToPlayer__17dSndSourceGroup_cFv = .text:0x80386DE0; // type:func fn_80386EF0 = .text:0x80386EF0; // type:function size:0x80 setParamFromName__17dSndSourceGroup_cFPCc = .text:0x80386F70; // type:function size:0x1A4C soundForActorInitRelated_803889c0 = .text:0x803889C0; // type:function size:0x4 -__ct__14dSoundSource_cFUcP9dAcBase_ciP17dSndSourceGroup_c = .text:0x803889D0; // type:function size:0x108 +__ct__14dSoundSource_cFUcP9dAcBase_cPCcP17dSndSourceGroup_c = .text:0x803889D0; // type:function size:0x108 __dt__14dSoundSource_cFv = .text:0x80388AE0; // type:function size:0xC4 vt_0x0C__14dSoundSource_cFv = .text:0x80388BB0; // type:function size:0x118 vt_0x44__14dSoundSource_cFv = .text:0x80388CD0; // type:function size:0x9C diff --git a/include/d/snd/d_snd_3d_actor.h b/include/d/snd/d_snd_3d_actor.h index ce5b37c7..dc93574d 100644 --- a/include/d/snd/d_snd_3d_actor.h +++ b/include/d/snd/d_snd_3d_actor.h @@ -7,8 +7,6 @@ #include "nw4r/snd/snd_Sound3DActor.h" class dSnd3DActor_c : public nw4r::snd::Sound3DActor { - static const u32 NUM_SOUNDS = 4; - public: dSnd3DActor_c(dSndSourceParam *pSourceParam, u8); diff --git a/include/d/snd/d_snd_source.h b/include/d/snd/d_snd_source.h index c19485ce..a304682d 100644 --- a/include/d/snd/d_snd_source.h +++ b/include/d/snd/d_snd_source.h @@ -6,13 +6,15 @@ #include "d/snd/d_snd_source_if.h" #include "nw4r/ut/ut_list.h" +#include + class dSndSourceGroup_c; /** Manages sound relating to a particular actor. */ /** Size: probably 0x15C */ class dSoundSource_c : public dSoundSourceIf_c, public dSnd3DActor_c { public: - dSoundSource_c(u8, dAcBase_c *, UNKWORD, dSndSourceGroup_c *pOwnerGroup); + dSoundSource_c(u8 sourceType, dAcBase_c *, const char *name, dSndSourceGroup_c *pOwnerGroup); virtual ~dSoundSource_c(); static u32 getCharacterTalkSoundId(u32 baseSoundId, dSoundSource_c *source); @@ -21,7 +23,10 @@ public: // 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 const char *d_s_vt_0x17C() const; + virtual const char *getName() const; + bool isName(const char *name) const { + return !std::strcmp(getName(), name); + } virtual void d_s_vt_0x180(); virtual void d_s_vt_0x184(); virtual void d_s_vt_0x188(); @@ -60,7 +65,9 @@ public: // Overrides of dSoundSourceIf_c - always in the first section of // the vtable, so the order is not certain. May have to reorder for weak // function order. - + virtual s32 getCategory() const override { + return field_0x0FC; + } virtual const nw4r::math::VEC3 &getListenerPosition() const override; virtual bool hasPlayingSounds() const override; // 0x48 @@ -80,11 +87,11 @@ private: // at 0x58: thunk-vtable /* 0xE8 */ nw4r::ut::Node mMgrLink; - /* 0x0F0 */ UNKWORD field_0x0F0; + /* 0x0F0 */ const char *mpName; /* 0x0F4 */ UNKWORD field_0x0F4; /* 0x0F8 */ dAcBase_c *mpPlayer; /* 0x0FC */ u8 field_0x0FC; - /* 0x0FD */ u8 field_0x0FD; + /* 0x0FD */ u8 mSourceType; /* 0x0FE */ u8 field_0x0FE; /* 0x0FF */ u8 field_0x0FF; /* 0x100 */ u8 field_0x100; diff --git a/include/d/snd/d_snd_source_group.h b/include/d/snd/d_snd_source_group.h index cabf4f82..2e1e8c1f 100644 --- a/include/d/snd/d_snd_source_group.h +++ b/include/d/snd/d_snd_source_group.h @@ -21,7 +21,7 @@ class dSoundSource_c; class dSndSourceGroup_c { public: dSndSourceGroup_c(); - dSndSourceGroup_c(u32, const char*, u32, u32); + dSndSourceGroup_c(s32 sourceType, const char*, u32, s32 mSubtype); ~dSndSourceGroup_c(); void registerSource(dSoundSource_c *); @@ -46,8 +46,8 @@ private: /* 0x00 */ nw4r::ut::Node mNode1; /* 0x08 */ nw4r::ut::Node mNode2; /* 0x10 */ UNKWORD field_0x10; - /* 0x14 */ UNKWORD field_0x14; - /* 0x18 */ UNKWORD field_0x18; + /* 0x14 */ s32 mSourceCategory; + /* 0x18 */ s32 mSubtype; /* 0x1C */ u8 field_0x1C; /* 0x1D */ u8 field_0x1D; /* 0x1E */ SizedString<32> mName; diff --git a/include/d/snd/d_snd_source_if.h b/include/d/snd/d_snd_source_if.h index e1edb145..fa65be05 100644 --- a/include/d/snd/d_snd_source_if.h +++ b/include/d/snd/d_snd_source_if.h @@ -11,10 +11,11 @@ class dSoundSourceIf_c { public: virtual ~dSoundSourceIf_c() {} #define SOUNDSOURCE_VIRTUAL(offset) virtual void vt_##offset() = 0; + SOUNDSOURCE_VIRTUAL(0x0C); - SOUNDSOURCE_VIRTUAL(0x10); + virtual s32 getCategory() const = 0; // 0x10 SOUNDSOURCE_VIRTUAL(0x14); - virtual s32 getActorType() const; + virtual s32 getActorType() const = 0; SOUNDSOURCE_VIRTUAL(0x1C); SOUNDSOURCE_VIRTUAL(0x20); SOUNDSOURCE_VIRTUAL(0x24); diff --git a/include/d/snd/d_snd_source_mgr.h b/include/d/snd/d_snd_source_mgr.h index b74b13b4..5a728d2c 100644 --- a/include/d/snd/d_snd_source_mgr.h +++ b/include/d/snd/d_snd_source_mgr.h @@ -29,9 +29,17 @@ class dSndSourceMgr_c { public: dSndSourceMgr_c(); + void registerSource(dSoundSource_c *source); + void unregisterSource(dSoundSource_c *source); + void playFlowSound(u32 id); private: + static bool isCertainEnemyType(dSoundSource_c *source); + void removeSourceFromList(dSoundSource_c *source, nw4r::ut::List *list); + void clearSourceLists(); + void clearSourceList(nw4r::ut::List *list); + /* 0x0010 */ u8 field_0x0010; /* 0x0011 */ u8 field_0x0011; /* 0x0012 */ u8 field_0x0012; @@ -44,7 +52,7 @@ private: /* 0x003C */ dSndSourceGroup_c mGroups[NUM_GROUPS]; // Not sure what these are for - /* 0x383C */ nw4r::ut::List mSourceList1; // node offset 0xE8, probably into dSoundSource::mMgrLink + /* 0x383C */ nw4r::ut::List mAllSources; // node offset 0xE8, probably into dSoundSource::mMgrLink /* 0x3848 */ nw4r::ut::List field_0x3848; // node offset 0x15C, possibly a subset of source types /* 0x3854 */ nw4r::ut::List field_0x3854; // node offset 0x160 @@ -54,9 +62,9 @@ private: /* 0x386C */ f32 field_0x386C; /* 0x3870 */ dSoundSource_c *mpPlayerSource; - /* 0x3874 */ dSoundSource_c *mpFiTalkSource; - /* 0x3878 */ dSoundSource_c *field_0x3878; - /* 0x387C */ dSoundSource_c *field_0x387C; + /* 0x3874 */ dSoundSource_c *mpKenseiSource; + /* 0x3878 */ dSoundSource_c *mpBoomerangSource; + /* 0x387C */ dSoundSource_c *mpTBoatSource; /* 0x3880 */ dSoundSource_c *field_0x3880; // fi singing related? /* 0x3884 */ dSoundSource_c *field_0x3884; }; diff --git a/src/d/snd/d_snd_control_player_mgr.cpp b/src/d/snd/d_snd_control_player_mgr.cpp index 75fa02d1..5bb01d0a 100644 --- a/src/d/snd/d_snd_control_player_mgr.cpp +++ b/src/d/snd/d_snd_control_player_mgr.cpp @@ -146,7 +146,7 @@ void dSndControlPlayerMgr_c::calc() { void dSndControlPlayerMgr_c::executeControls() { dSndControlPlayer_c *next; - dSndControlPlayer_c *iter = static_cast(nw4r::ut::List_GetNext(&mActiveControls, nullptr)); + dSndControlPlayer_c *iter = static_cast(nw4r::ut::List_GetFirst(&mActiveControls)); while (iter != nullptr) { next = static_cast(nw4r::ut::List_GetNext(&mActiveControls, iter)); iter->calc(); diff --git a/src/d/snd/d_snd_sound.cpp b/src/d/snd/d_snd_sound.cpp index ff5a55a4..39354783 100644 --- a/src/d/snd/d_snd_sound.cpp +++ b/src/d/snd/d_snd_sound.cpp @@ -67,7 +67,7 @@ void dSndSound_c::calc() { } dSndControlSound_c *next; - dSndControlSound_c *iter = static_cast(nw4r::ut::List_GetNext(&mList, nullptr)); + dSndControlSound_c *iter = static_cast(nw4r::ut::List_GetFirst(&mList)); while (iter != nullptr) { next = static_cast(nw4r::ut::List_GetNext(&mList, iter)); iter->calc(); diff --git a/src/d/snd/d_snd_source.cpp b/src/d/snd/d_snd_source.cpp index 4e582666..73d55433 100644 --- a/src/d/snd/d_snd_source.cpp +++ b/src/d/snd/d_snd_source.cpp @@ -6,11 +6,12 @@ #include "d/snd/d_snd_mgr.h" #include "d/snd/d_snd_player_mgr.h" #include "d/snd/d_snd_source_group.h" +#include "d/snd/d_snd_source_mgr.h" #include "nw4r/snd/snd_SoundStartable.h" #include "nw4r/ut/ut_list.h" #include "sized_string.h" -extern "C" u8 fn_80382590(u8, UNKWORD); +extern "C" u8 fn_80382590(u8, const char*); struct d_snd_mgr_unk_6_sinit { d_snd_mgr_unk_6_sinit() : field_0x00(0), field_0x04(0.0f) {} @@ -25,12 +26,12 @@ const char *help_i_need_data() { return "%s_%s_%d"; } -dSoundSource_c::dSoundSource_c(u8 a1, dAcBase_c *player, UNKWORD a3, dSndSourceGroup_c *pOwnerGroup) - : dSnd3DActor_c(pOwnerGroup->getAmbientParam(), a1), - field_0x0F0(a3), +dSoundSource_c::dSoundSource_c(u8 sourceType, dAcBase_c *player, const char *name, dSndSourceGroup_c *pOwnerGroup) + : dSnd3DActor_c(pOwnerGroup->getAmbientParam(), sourceType), + mpName(name), field_0x0F4(0), mpPlayer(player), - field_0x0FD(a1), + mSourceType(sourceType), field_0x0FE(0), field_0x0FF(0), field_0x100(0), @@ -44,7 +45,7 @@ dSoundSource_c::dSoundSource_c(u8 a1, dAcBase_c *player, UNKWORD a3, dSndSourceG field_0x154(0), field_0x158(-1), field_0x15A(-1) { - field_0x0FC = fn_80382590(a1, a3); + field_0x0FC = fn_80382590(sourceType, name); // TODO: Offsetof nw4r::ut::List_Init(&field_0x110, 0xEC); nw4r::ut::List_Init(&field_0x120, 0x04); @@ -56,6 +57,7 @@ dSoundSource_c::~dSoundSource_c() { SetUserParam(0); vt_0x44(); d_s_vt_0x1BC(); + dSndSourceMgr_c::GetInstance()->unregisterSource(this); mpOwnerGroup->unregisterSource(this); } @@ -111,7 +113,7 @@ u32 dSoundSource_c::getCharacterTalkSoundId(u32 baseSoundId, dSoundSource_c *sou baseLabel = dSndMgr_c::GetInstance()->getArchive()->GetSoundLabelString(baseSoundId); } - const char *charLabel = source->d_s_vt_0x17C(); + const char *charLabel = source->getName(); label.sprintf("%s_%s", baseLabel, charLabel); u32 newLabel = dSndPlayerMgr_c::GetInstance()->convertLabelStringToSoundId(label); if (newLabel != -1) { diff --git a/src/d/snd/d_snd_source_group.cpp b/src/d/snd/d_snd_source_group.cpp index 91e2542e..1f938fb7 100644 --- a/src/d/snd/d_snd_source_group.cpp +++ b/src/d/snd/d_snd_source_group.cpp @@ -9,18 +9,19 @@ extern "C" bool isInStage(const char *stageName); -void dSndSourceGroup_c::set(s32 type, const char *name) { +void dSndSourceGroup_c::set(s32 sourceType, const char *name) { + // TODO enums resetSoundSourceParam(); bool assignedParam = false; - switch (field_0x14) { + switch (mSourceCategory) { case 0: { assignedParam = true; mParam.field_0x10 = INFINITY; break; } case 1: - if (type == 7) { + if (sourceType == 7) { assignedParam = true; mParam.field_0x00 = 1500.0f; mParam.field_0x10 = INFINITY; @@ -28,7 +29,7 @@ void dSndSourceGroup_c::set(s32 type, const char *name) { break; } - if (!assignedParam && (type == 44 || type == 58)) { + if (!assignedParam && (sourceType == 44 || sourceType == 58)) { assignedParam = true; mParam.field_0x10 = INFINITY; } @@ -38,7 +39,7 @@ void dSndSourceGroup_c::set(s32 type, const char *name) { } if (!assignedParam) { - switch (type) { + switch (sourceType) { case 51: { mParam.field_0x00 = 300.0f; mParam.field_0x04 = 800.0; @@ -69,7 +70,7 @@ void dSndSourceGroup_c::resetSoundSourceParam() { } dSndSourceGroup_c::dSndSourceGroup_c() - : field_0x18(0), + : mSubtype(0), field_0x1C(0), field_0x1D(0), mName(""), @@ -110,10 +111,10 @@ void dSndSourceGroup_c::unregisterSource(dSoundSource_c *source) { } void dSndSourceGroup_c::clearList() { - dSoundSource_c *source = static_cast(nw4r::ut::List_GetNext(&mSourceList, nullptr)); + dSoundSource_c *source = static_cast(nw4r::ut::List_GetFirst(&mSourceList)); while (source != nullptr) { nw4r::ut::List_Remove(&mSourceList, source); - source = static_cast(nw4r::ut::List_GetNext(&mSourceList, nullptr)); + source = static_cast(nw4r::ut::List_GetFirst(&mSourceList)); } } @@ -124,7 +125,7 @@ dSoundSource_c *dSndSourceGroup_c::getSourceClosestToListener() { mpCachedClosestSourceToListener = nullptr; f32 closest = INFINITY; - for (dSoundSource_c *source = static_cast(nw4r::ut::List_GetNext(&mSourceList, nullptr)); + for (dSoundSource_c *source = static_cast(nw4r::ut::List_GetFirst(&mSourceList)); source != nullptr; source = static_cast(nw4r::ut::List_GetNext(&mSourceList, source))) { if (source->getActorType() != 1 && source->getActorType() != 48) { f32 dist = source->getDistanceToListener(); @@ -144,12 +145,12 @@ dSoundSource_c *dSndSourceGroup_c::getSourceClosestToPlayer() { } if ((s32)nw4r::ut::List_GetSize(&mSourceList) <= 1) { - return static_cast(nw4r::ut::List_GetNext(&mSourceList, nullptr)); + return static_cast(nw4r::ut::List_GetFirst(&mSourceList)); } mpCachedClosestSourceToPlayer = nullptr; f32 closest = INFINITY; - for (dSoundSource_c *source = static_cast(nw4r::ut::List_GetNext(&mSourceList, nullptr)); + for (dSoundSource_c *source = static_cast(nw4r::ut::List_GetFirst(&mSourceList)); source != nullptr; source = static_cast(nw4r::ut::List_GetNext(&mSourceList, source))) { if (source->getActorType() != 1 && source->getActorType() != 48) { f32 dist = source->getDistanceToPlayer(); diff --git a/src/d/snd/d_snd_source_mgr.cpp b/src/d/snd/d_snd_source_mgr.cpp index 8cf61822..0dcc9ed4 100644 --- a/src/d/snd/d_snd_source_mgr.cpp +++ b/src/d/snd/d_snd_source_mgr.cpp @@ -18,9 +18,9 @@ dSndSourceMgr_c::dSndSourceMgr_c() field_0x3868(0), field_0x386C(INFINITY), mpPlayerSource(nullptr), - mpFiTalkSource(nullptr), - field_0x3878(nullptr), - field_0x387C(nullptr), + mpKenseiSource(nullptr), + mpBoomerangSource(nullptr), + mpTBoatSource(nullptr), field_0x3880(nullptr), field_0x3884(nullptr) { // TODO offsetof @@ -29,7 +29,7 @@ dSndSourceMgr_c::dSndSourceMgr_c() // TODO figure out what these are for nw4r::ut::List_Init(&mGroupList3, 8); - nw4r::ut::List_Init(&mSourceList1, 0xE8); + nw4r::ut::List_Init(&mAllSources, 0xE8); nw4r::ut::List_Init(&field_0x3848, 0x15C); nw4r::ut::List_Init(&field_0x3854, 0x160); @@ -39,3 +39,102 @@ dSndSourceMgr_c::dSndSourceMgr_c() nw4r::ut::List_Append(&mGroupList2, group); } } + +void dSndSourceMgr_c::registerSource(dSoundSource_c *source) { + if (source != nullptr) { + nw4r::ut::List_Append(&mAllSources, source); + // TODO enums + switch (source->getCategory()) { + case 0: { + if (source->getActorType() == 0 && mpPlayerSource == nullptr) { + mpPlayerSource = source; + } + break; + } + case 1: { + if (source->getActorType() == 6) { + mpBoomerangSource = source; + } + break; + } + case 2: { + if (isCertainEnemyType(source)) { + nw4r::ut::List_Append(&field_0x3848, source); + } + break; + } + case 6: { + nw4r::ut::List_Append(&field_0x3854, source); + break; + } + case 3: { + if (source->isName("TBoat") && mpTBoatSource == nullptr) { + mpTBoatSource = source; + } + break; + } + case 4: { + if (source->getActorType() == 44) { + mpKenseiSource = source; + } + break; + } + } + } +} + +void dSndSourceMgr_c::unregisterSource(dSoundSource_c *source) { + if (source != nullptr) { + removeSourceFromList(source, &mAllSources); + removeSourceFromList(source, &field_0x3848); + removeSourceFromList(source, &field_0x3854); + if (source == mpPlayerSource) { + mpPlayerSource = nullptr; + } else if (source == mpKenseiSource) { + mpKenseiSource = nullptr; + } else if (source == mpBoomerangSource) { + mpBoomerangSource = nullptr; + } + + if (mpTBoatSource == source) { + mpTBoatSource = nullptr; + } + } +} + +void dSndSourceMgr_c::removeSourceFromList(dSoundSource_c *source, nw4r::ut::List *list) { + if (source != nullptr && list != nullptr) { + // This removal code appears to be needlessly defensive + dSoundSource_c *sourceIter = static_cast(nw4r::ut::List_GetFirst(list)); + while (sourceIter != nullptr) { + if (field_0x3880 == source) { + // why in here???? + field_0x3880 = nullptr; + } + + if (sourceIter == source) { + nw4r::ut::List_Remove(list, sourceIter); + sourceIter = nullptr; + } else { + sourceIter = static_cast(nw4r::ut::List_GetNext(list, sourceIter)); + } + } + } +} + +void dSndSourceMgr_c::clearSourceLists() { + clearSourceList(&mAllSources); + clearSourceList(&field_0x3848); + clearSourceList(&field_0x3854); + mpPlayerSource = nullptr; +} + +void dSndSourceMgr_c::clearSourceList(nw4r::ut::List *list) { + if (list != nullptr) { + dSoundSource_c *sourceIter = static_cast(nw4r::ut::List_GetFirst(list)); + while (sourceIter != nullptr) { + nw4r::ut::List_Remove(list, sourceIter); + sourceIter = static_cast(nw4r::ut::List_GetFirst(list)); + } + } +} From fbc58cd78a58cade843c65a1a9c90510a269eec1 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 7 Jun 2025 23:03:20 +0200 Subject: [PATCH 20/22] move and use enums --- config/SOUE01/symbols.txt | 2 +- include/d/snd/d_snd_source.h | 4 +- include/d/snd/d_snd_source_enums.h | 74 ++++++++++++++++++++++++++++++ include/d/snd/d_snd_source_mgr.h | 1 + include/toBeSorted/actor_info.h | 49 -------------------- src/d/snd/d_snd_source.cpp | 4 +- src/d/snd/d_snd_source_group.cpp | 14 +++--- src/d/snd/d_snd_source_mgr.cpp | 62 +++++++++++++++++++++---- src/toBeSorted/actor_info.cpp | 1 + 9 files changed, 139 insertions(+), 72 deletions(-) create mode 100644 include/d/snd/d_snd_source_enums.h diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 72271df2..9dda2007 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -20948,7 +20948,7 @@ fn_80382400 = .text:0x80382400; // type:function size:0xC fn_80382410 = .text:0x80382410; // type:function size:0xC0 fn_803824D0 = .text:0x803824D0; // type:function size:0x24 fn_80382500 = .text:0x80382500; // type:function size:0x90 -fn_80382590 = .text:0x80382590; // type:function size:0xB0 +getSourceCategoryForSourceType__15dSndSourceMgr_cFlPCc = .text:0x80382590; // type:function size:0xB0 soundForActorInitRelated_80382640 = .text:0x80382640; // type:function size:0xFD8 fn_80383620 = .text:0x80383620; // type:function size:0x94 fn_803836C0 = .text:0x803836C0; // type:function size:0x98 diff --git a/include/d/snd/d_snd_source.h b/include/d/snd/d_snd_source.h index a304682d..946589ea 100644 --- a/include/d/snd/d_snd_source.h +++ b/include/d/snd/d_snd_source.h @@ -66,7 +66,7 @@ public: // the vtable, so the order is not certain. May have to reorder for weak // function order. virtual s32 getCategory() const override { - return field_0x0FC; + return mSourceCategory; } virtual const nw4r::math::VEC3 &getListenerPosition() const override; @@ -90,7 +90,7 @@ private: /* 0x0F0 */ const char *mpName; /* 0x0F4 */ UNKWORD field_0x0F4; /* 0x0F8 */ dAcBase_c *mpPlayer; - /* 0x0FC */ u8 field_0x0FC; + /* 0x0FC */ u8 mSourceCategory; /* 0x0FD */ u8 mSourceType; /* 0x0FE */ u8 field_0x0FE; /* 0x0FF */ u8 field_0x0FF; diff --git a/include/d/snd/d_snd_source_enums.h b/include/d/snd/d_snd_source_enums.h new file mode 100644 index 00000000..d4ebe17c --- /dev/null +++ b/include/d/snd/d_snd_source_enums.h @@ -0,0 +1,74 @@ +#ifndef D_SND_SOURCE_ENUMS_H +#define D_SND_SOURCE_ENUMS_H + +// TODO: Expand when we figure out what the other entries have in common +enum SoundSourceType_e { + // 0-1: Player (0) + SND_SOURCE_PLAYER = 0, + SND_SOURCE_PLAYER_HEAD = 1, + + // 2-9: Equipment (1) + SND_SOURCE_NET = 2, + SND_SOURCE_BLADE = 3, + SND_SOURCE_SHIELD = 4, + SND_SOURCE_WHIP = 5, + SND_SOURCE_BOOMERANG = 6, + SND_SOURCE_ARROW = 7, + SND_SOURCE_BOMB = 8, + SND_SOURCE_HOOKSHOT = 9, + + // 10-31: Enemy? (2) + SND_SOURCE_ENEMY_10 = 10, + SND_SOURCE_BIGBOSS = 20, + SND_SOURCE_GIRAHUMU_3 = 24, + SND_SOURCE_BULLET = 29, + SND_SOURCE_ENEMY_31 = 31, + + // 32-42: Object? (3) + SND_SOURCE_OBJECT = 32, + SND_SOURCE_BAMBOO = 34, + SND_SOURCE_ITEM = 35, + SND_SOURCE_TERRY_SHOP = 36, + SND_SOURCE_TIME_STONE = 37, + SND_SOURCE_CLEF = 38, + SND_SOURCE_SHUTTER = 39, + SND_SOURCE_OBJECT_42 = 42, + + // 43-52: Npc (4) + SND_SOURCE_NPC_43 = 43, + SND_SOURCE_KENSEI = 44, + SND_SOURCE_PLAYER_BIRD = 45, + SND_SOURCE_NPC_48 = 48, + SND_SOURCE_INSECT = 49, + SND_SOURCE_NPC_NRM = 51, + SND_SOURCE_NPC_DRAGON = 52, + + // 53: TagSound (5) + SND_SOURCE_TG_SOUND = 53, + + // 54-57: Harp Related (6) + SND_SOURCE_54 = 54, + SND_SOURCE_OBJECT_WARP = 55, + SND_SOURCE_SW_HARP = 56, + SND_SOURCE_57 = 57, + + // 58: ? (7) + SND_SOURCE_58 = 58, + + // 59: ? (9) + SND_SOURCE_59 = 59, +}; + +enum SoundSourceCategory_e { + SND_SOURCE_CATEGORY_PLAYER = 0, + SND_SOURCE_CATEGORY_EQUIPMENT = 1, + SND_SOURCE_CATEGORY_ENEMY = 2, + SND_SOURCE_CATEGORY_OBJECT = 3, + SND_SOURCE_CATEGORY_NPC = 4, + SND_SOURCE_CATEGORY_TG_SOUND = 5, + SND_SOURCE_CATEGORY_6 = 6, + SND_SOURCE_CATEGORY_7 = 7, + SND_SOURCE_CATEGORY_9 = 9, +}; + +#endif diff --git a/include/d/snd/d_snd_source_mgr.h b/include/d/snd/d_snd_source_mgr.h index 5a728d2c..b1f9db06 100644 --- a/include/d/snd/d_snd_source_mgr.h +++ b/include/d/snd/d_snd_source_mgr.h @@ -33,6 +33,7 @@ public: void unregisterSource(dSoundSource_c *source); void playFlowSound(u32 id); + static s32 getSourceCategoryForSourceType(s32 sourceType, const char *name); private: static bool isCertainEnemyType(dSoundSource_c *source); diff --git a/include/toBeSorted/actor_info.h b/include/toBeSorted/actor_info.h index 6ae21f31..7a9f545e 100644 --- a/include/toBeSorted/actor_info.h +++ b/include/toBeSorted/actor_info.h @@ -3,55 +3,6 @@ #include "common.h" -// TODO: Expand when we figure out what the other entries have in common -enum SoundSourceType_e { - // 0-1: Player (0) - SND_SOURCE_PLAYER = 0, - SND_SOURCE_PLAYER_HEAD = 1, - - // 2-9: Equipment (1) - SND_SOURCE_NET = 2, - SND_SOURCE_BLADE = 3, - SND_SOURCE_SHIELD = 4, - SND_SOURCE_WHIP = 5, - SND_SOURCE_BOOMERANG = 6, - SND_SOURCE_ARROW = 7, - SND_SOURCE_BOMB = 8, - SND_SOURCE_HOOKSHOT = 9, - - // 10-31: Enemy? (2) - SND_SOURCE_BIGBOSS = 20, - SND_SOURCE_GIRAHUMU_3 = 24, - SND_SOURCE_BULLET = 29, - - // 32-42: Object? (3) - SND_SOURCE_OBJECT = 32, - SND_SOURCE_BAMBOO = 34, - SND_SOURCE_ITEM = 35, - SND_SOURCE_TERRY_SHOP = 36, - SND_SOURCE_TIME_STONE = 37, - SND_SOURCE_CLEF = 38, - SND_SOURCE_SHUTTER = 39, - - // 43-52: Npc (4) - SND_SOURCE_KENSEI = 44, - SND_SOURCE_PLAYER_BIRD = 45, - SND_SOURCE_INSECT = 49, - SND_SOURCE_NPC_NRM = 51, - SND_SOURCE_NPC_DRAGON = 52, - - // 53: TagSound (5) - SND_SOURCE_TG_SOUND = 53, - - // 54-57: Harp Related (6) - SND_SOURCE_OBJECT_WARP = 55, - SND_SOURCE_SW_HARP = 56, - - // 58: ? (7) - - // 59: ? (9) -}; - /** * profileId and profileId2 are always the same. */ diff --git a/src/d/snd/d_snd_source.cpp b/src/d/snd/d_snd_source.cpp index 73d55433..5ed288b8 100644 --- a/src/d/snd/d_snd_source.cpp +++ b/src/d/snd/d_snd_source.cpp @@ -11,8 +11,6 @@ #include "nw4r/ut/ut_list.h" #include "sized_string.h" -extern "C" u8 fn_80382590(u8, const char*); - struct d_snd_mgr_unk_6_sinit { d_snd_mgr_unk_6_sinit() : field_0x00(0), field_0x04(0.0f) {} @@ -45,7 +43,7 @@ dSoundSource_c::dSoundSource_c(u8 sourceType, dAcBase_c *player, const char *nam field_0x154(0), field_0x158(-1), field_0x15A(-1) { - field_0x0FC = fn_80382590(sourceType, name); + mSourceCategory = dSndSourceMgr_c::getSourceCategoryForSourceType(sourceType, name); // TODO: Offsetof nw4r::ut::List_Init(&field_0x110, 0xEC); nw4r::ut::List_Init(&field_0x120, 0x04); diff --git a/src/d/snd/d_snd_source_group.cpp b/src/d/snd/d_snd_source_group.cpp index 1f938fb7..951a7514 100644 --- a/src/d/snd/d_snd_source_group.cpp +++ b/src/d/snd/d_snd_source_group.cpp @@ -3,6 +3,7 @@ #include "common.h" #include "d/snd/d_snd_source.h" +#include "d/snd/d_snd_source_enums.h" #include "nw4r/ut/ut_list.h" #include @@ -10,18 +11,17 @@ extern "C" bool isInStage(const char *stageName); void dSndSourceGroup_c::set(s32 sourceType, const char *name) { - // TODO enums resetSoundSourceParam(); bool assignedParam = false; switch (mSourceCategory) { - case 0: { + case SND_SOURCE_CATEGORY_PLAYER: { assignedParam = true; mParam.field_0x10 = INFINITY; break; } - case 1: - if (sourceType == 7) { + case SND_SOURCE_CATEGORY_EQUIPMENT: + if (sourceType == SND_SOURCE_ARROW) { assignedParam = true; mParam.field_0x00 = 1500.0f; mParam.field_0x10 = INFINITY; @@ -29,7 +29,7 @@ void dSndSourceGroup_c::set(s32 sourceType, const char *name) { break; } - if (!assignedParam && (sourceType == 44 || sourceType == 58)) { + if (!assignedParam && (sourceType == SND_SOURCE_KENSEI || sourceType == SND_SOURCE_58)) { assignedParam = true; mParam.field_0x10 = INFINITY; } @@ -40,13 +40,13 @@ void dSndSourceGroup_c::set(s32 sourceType, const char *name) { if (!assignedParam) { switch (sourceType) { - case 51: { + case SND_SOURCE_NPC_NRM: { mParam.field_0x00 = 300.0f; mParam.field_0x04 = 800.0; mParam.field_0x10 = 2200.0; break; } - case 48: { + case SND_SOURCE_NPC_48: { if (isInStage("F401")) { mParam.field_0x00 = 500.0f; mParam.field_0x04 = 4000.0; diff --git a/src/d/snd/d_snd_source_mgr.cpp b/src/d/snd/d_snd_source_mgr.cpp index 0dcc9ed4..0e5eb9ae 100644 --- a/src/d/snd/d_snd_source_mgr.cpp +++ b/src/d/snd/d_snd_source_mgr.cpp @@ -2,10 +2,53 @@ #include "common.h" #include "d/snd/d_snd_source.h" +#include "d/snd/d_snd_source_enums.h" #include "nw4r/ut/ut_list.h" #include +s32 dSndSourceMgr_c::getSourceCategoryForSourceType(s32 sourceType, const char *name) { + // This might be a full-on switch statement but I don't want to write out + // all the unknown entries yet and this matches anyway + + if (sourceType >= SND_SOURCE_PLAYER && sourceType <= SND_SOURCE_PLAYER_HEAD) { + return SND_SOURCE_CATEGORY_PLAYER; + } + + if (sourceType >= SND_SOURCE_NET && sourceType <= SND_SOURCE_HOOKSHOT) { + return SND_SOURCE_CATEGORY_EQUIPMENT; + } + + if (sourceType >= SND_SOURCE_ENEMY_10 && sourceType <= SND_SOURCE_ENEMY_31) { + return SND_SOURCE_CATEGORY_ENEMY; + } + + if (sourceType >= SND_SOURCE_OBJECT && sourceType <= SND_SOURCE_OBJECT_42) { + return SND_SOURCE_CATEGORY_OBJECT; + } + + if (sourceType >= SND_SOURCE_NPC_43 && sourceType <= SND_SOURCE_NPC_DRAGON) { + return SND_SOURCE_CATEGORY_NPC; + } + + if (sourceType == SND_SOURCE_TG_SOUND) { + return SND_SOURCE_CATEGORY_TG_SOUND; + } + + if (sourceType >= SND_SOURCE_54 && sourceType <= SND_SOURCE_57) { + return SND_SOURCE_CATEGORY_6; + } + + switch (sourceType) { + case SND_SOURCE_58: + return SND_SOURCE_CATEGORY_7; + case SND_SOURCE_59: + return SND_SOURCE_CATEGORY_9; + default: + return -1; + } +} + SND_DISPOSER_DEFINE(dSndSourceMgr_c); dSndSourceMgr_c::dSndSourceMgr_c() @@ -43,38 +86,37 @@ dSndSourceMgr_c::dSndSourceMgr_c() void dSndSourceMgr_c::registerSource(dSoundSource_c *source) { if (source != nullptr) { nw4r::ut::List_Append(&mAllSources, source); - // TODO enums switch (source->getCategory()) { - case 0: { - if (source->getActorType() == 0 && mpPlayerSource == nullptr) { + case SND_SOURCE_CATEGORY_PLAYER: { + if (source->getActorType() == SND_SOURCE_PLAYER && mpPlayerSource == nullptr) { mpPlayerSource = source; } break; } - case 1: { - if (source->getActorType() == 6) { + case SND_SOURCE_CATEGORY_EQUIPMENT: { + if (source->getActorType() == SND_SOURCE_BOOMERANG) { mpBoomerangSource = source; } break; } - case 2: { + case SND_SOURCE_CATEGORY_ENEMY: { if (isCertainEnemyType(source)) { nw4r::ut::List_Append(&field_0x3848, source); } break; } - case 6: { + case SND_SOURCE_CATEGORY_6: { nw4r::ut::List_Append(&field_0x3854, source); break; } - case 3: { + case SND_SOURCE_CATEGORY_OBJECT: { if (source->isName("TBoat") && mpTBoatSource == nullptr) { mpTBoatSource = source; } break; } - case 4: { - if (source->getActorType() == 44) { + case SND_SOURCE_CATEGORY_NPC: { + if (source->getActorType() == SND_SOURCE_KENSEI) { mpKenseiSource = source; } break; diff --git a/src/toBeSorted/actor_info.cpp b/src/toBeSorted/actor_info.cpp index 830497ff..341d7775 100644 --- a/src/toBeSorted/actor_info.cpp +++ b/src/toBeSorted/actor_info.cpp @@ -1,6 +1,7 @@ #include "toBeSorted/actor_info.h" #include "common.h" +#include "d/snd/d_snd_source_enums.h" #include "f/f_profile_name.h" #include From ebc3541faa57935bebcef2daa7ef26f23a6487b9 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 8 Jun 2025 00:16:01 +0200 Subject: [PATCH 21/22] Another singleton create --- src/d/snd/d_snd_mgr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d/snd/d_snd_mgr.cpp b/src/d/snd/d_snd_mgr.cpp index 95fadd70..b2ee2279 100644 --- a/src/d/snd/d_snd_mgr.cpp +++ b/src/d/snd/d_snd_mgr.cpp @@ -5,13 +5,13 @@ #include "d/snd/d_snd_control_player_mgr.h" #include "d/snd/d_snd_player_mgr.h" #include "d/snd/d_snd_small_effect_mgr.h" +#include "d/snd/d_snd_source_mgr.h" #include "egg/audio/eggAudioRmtSpeakerMgr.h" #include "egg/audio/eggAudioUtility.h" extern "C" void initEnemySoundMgr(); extern "C" void initFanfareSoundMgr(); extern "C" void initSomeUnusedSoundMgr(); -extern "C" void initEnemyBgmRelatedMgr(); extern "C" void fn_80393530(); extern "C" void fn_80394830(); extern "C" void fn_8037F940(); @@ -30,7 +30,7 @@ dSndMgr_c::dSndMgr_c(): field_0x6CC(0) { initSomeUnusedSoundMgr(); dSndSmallEffectMgr_c::create(); dSndAreaSoundEffectMgr_c::create(); - initEnemyBgmRelatedMgr(); + dSndSourceMgr_c::create(); fn_80393530(); fn_80394830(); fn_8037F940(); From 1af832d875b1d6ba9364e0990c68cebb610a4683 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 8 Jun 2025 09:08:18 +0200 Subject: [PATCH 22/22] Review --- include/d/snd/d_snd_3d_actor.h | 2 +- include/d/snd/d_snd_3d_manager.h | 10 +++++----- include/d/snd/d_snd_player_mgr.h | 4 ++-- include/d/snd/d_snd_source_group.h | 2 +- include/d/snd/d_snd_source_mgr.h | 13 ------------- src/d/snd/d_snd_3d_actor.cpp | 18 +++++++++--------- src/d/snd/d_snd_control_player_mgr.cpp | 4 ++-- src/d/snd/d_snd_control_sound.cpp | 3 +-- src/d/snd/d_snd_player_mgr.cpp | 19 +++++++++++-------- src/d/snd/d_snd_small_effect_mgr.cpp | 12 ++++++------ src/d/snd/d_snd_source_group.cpp | 2 +- 11 files changed, 39 insertions(+), 50 deletions(-) diff --git a/include/d/snd/d_snd_3d_actor.h b/include/d/snd/d_snd_3d_actor.h index dc93574d..6f3ad6d4 100644 --- a/include/d/snd/d_snd_3d_actor.h +++ b/include/d/snd/d_snd_3d_actor.h @@ -8,7 +8,7 @@ class dSnd3DActor_c : public nw4r::snd::Sound3DActor { public: - dSnd3DActor_c(dSndSourceParam *pSourceParam, u8); + dSnd3DActor_c(dSndSourceParam *pSourceParam, u8 sourceType); virtual ~dSnd3DActor_c() {} diff --git a/include/d/snd/d_snd_3d_manager.h b/include/d/snd/d_snd_3d_manager.h index 679e7963..2ac0b062 100644 --- a/include/d/snd/d_snd_3d_manager.h +++ b/include/d/snd/d_snd_3d_manager.h @@ -46,11 +46,11 @@ public: private: void updateListenerPos(f32); - /* 0x10 */ bool mIsSetup; - /* 0x11 */ bool mCalculationsFresh; - /* 0x14 */ dSnd3DEngine_c *mpEngine; - /* 0x18 */ nw4r::snd::Sound3DManager mManager; - /* 0x44 */ nw4r::snd::Sound3DListener mListener; + /* 0x010 */ bool mIsSetup; + /* 0x011 */ bool mCalculationsFresh; + /* 0x014 */ dSnd3DEngine_c *mpEngine; + /* 0x018 */ nw4r::snd::Sound3DManager mManager; + /* 0x044 */ nw4r::snd::Sound3DListener mListener; /* 0xB0 */ EGG::LookAtCamera mCamera; /* 0x138 */ mVec3_c mCameraDirectionNormalized; /* 0x144 */ mVec3_c mCameraTargetPosition; diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h index d803ab70..7808092d 100644 --- a/include/d/snd/d_snd_player_mgr.h +++ b/include/d/snd/d_snd_player_mgr.h @@ -41,8 +41,8 @@ public: const char *getSoundArchivePath(); u32 convertLabelStringToSoundId(const char *label) const; - nw4r::snd::SoundArchivePlayer &getSoundArchivePlayerForType(u8 type); - bool canUseThisPlayer(u8 type) const; + nw4r::snd::SoundArchivePlayer &getSoundArchivePlayerForType(u8 sourceType); + bool canUseThisPlayer(u8 sourceType) const; enum PlayerMgrFlag_e { MGR_HBM = 0x1, diff --git a/include/d/snd/d_snd_source_group.h b/include/d/snd/d_snd_source_group.h index 2e1e8c1f..187b41a5 100644 --- a/include/d/snd/d_snd_source_group.h +++ b/include/d/snd/d_snd_source_group.h @@ -57,7 +57,7 @@ private: /* 0x64 */ dSoundSource_c *mpCachedClosestSourceToListener; /* 0x68 */ dSoundSource_c *mpCachedClosestSourceToPlayer; /* 0x6C */ bool mCalculatedClosestToListener; - /* 0x6C */ bool mCalculatedClosestToPlayer; + /* 0x6D */ bool mCalculatedClosestToPlayer; }; #endif diff --git a/include/d/snd/d_snd_source_mgr.h b/include/d/snd/d_snd_source_mgr.h index b1f9db06..5582b2d3 100644 --- a/include/d/snd/d_snd_source_mgr.h +++ b/include/d/snd/d_snd_source_mgr.h @@ -8,19 +8,6 @@ SND_DISPOSER_FORWARD_DECL(dSndSourceMgr_c); -// 0 - "" - Link -// ActorLink::initModels -// 0x2C - NpcKenT -// 0x20 - Door, TBox, CharE (Chair), Tubo -// 0x35 - TgSound -// 0x2D - PyBird -// 0x22 - Bamboo -// 0x23 - Item - -// 0x19 - Nusi*, BKr, BBs -// 0x1A - MgRArm, MgLArm -// 0x1B - Mgtail - class dSndSourceMgr_c { SND_DISPOSER_MEMBERS(dSndSourceMgr_c); diff --git a/src/d/snd/d_snd_3d_actor.cpp b/src/d/snd/d_snd_3d_actor.cpp index f617fb35..e304d296 100644 --- a/src/d/snd/d_snd_3d_actor.cpp +++ b/src/d/snd/d_snd_3d_actor.cpp @@ -9,9 +9,9 @@ #include -dSnd3DActor_c::dSnd3DActor_c(dSndSourceParam *pSourceParam, u8 a2) +dSnd3DActor_c::dSnd3DActor_c(dSndSourceParam *pSourceParam, u8 sourceType) : nw4r::snd::Sound3DActor( - dSndPlayerMgr_c::GetInstance()->getSoundArchivePlayerForType(a2), dSnd3DManager_c::GetInstance()->getManager() + dSndPlayerMgr_c::GetInstance()->getSoundArchivePlayerForType(sourceType), dSnd3DManager_c::GetInstance()->getManager() ), a_field_0x7D(0), a_field_0x7E(0), @@ -31,7 +31,7 @@ dSnd3DActor_c::dSnd3DActor_c(dSndSourceParam *pSourceParam, u8 a2) resetCachedRelativePositions(); // Portability hazard SetUserParam(reinterpret_cast(this)); - if (dSndPlayerMgr_c::GetInstance()->canUseThisPlayer(a2)) { + if (dSndPlayerMgr_c::GetInstance()->canUseThisPlayer(sourceType)) { a_field_0x7F = 1; } } @@ -43,9 +43,9 @@ void dSnd3DActor_c::d_vt_0x34(const nw4r::math::VEC3 &rPosition) { } void dSnd3DActor_c::updatePositionRelativeToListener() { - if (!checkFlag(1)) { + if (!checkFlag(0x1)) { calculatePositionRelativeToListener(); - setFlag(1); + setFlag(0x1); } } @@ -70,10 +70,10 @@ void dSnd3DActor_c::calculatePositionRelativeToListener() { } void dSnd3DActor_c::updateDistanceToListener() { - if (!checkFlag(2)) { + if (!checkFlag(0x2)) { updatePositionRelativeToListener(); mDistanceToListener = VEC3Len(&mPositionRelativeToListener); - setFlag(2); + setFlag(0x2); } } @@ -110,10 +110,10 @@ void dSnd3DActor_c::calculatePositionRelativeToCameraTarget() { } void dSnd3DActor_c::updateDistanceToCameraTarget() { - if (!checkFlag(8)) { + if (!checkFlag(0x8)) { updatePositionRelativeToCameraTarget(); mDistanceToCameraTarget = VEC3Len(&mPositionRelativeToCameraTarget); - setFlag(8); + setFlag(0x8); } } diff --git a/src/d/snd/d_snd_control_player_mgr.cpp b/src/d/snd/d_snd_control_player_mgr.cpp index 5bb01d0a..22223c98 100644 --- a/src/d/snd/d_snd_control_player_mgr.cpp +++ b/src/d/snd/d_snd_control_player_mgr.cpp @@ -177,7 +177,7 @@ void dSndControlPlayerMgr_c::calcVolumes() { targetVolume = currentVolume + maxVolumeIncrease; } // @bug not actually clamped - nw4r::ut::Clamp(targetVolume, 0.0f, 2.0f); + (void)nw4r::ut::Clamp(targetVolume, 0.0f, 2.0f); setVolume(i, targetVolume, 0); } mpTargetVolumes[i] = 1.0f; @@ -356,7 +356,7 @@ void dSndControlPlayerMgr_c::setPlayerVolumeInternal(u32 playerIdx, f32 volume) return; } // @bug not actually clamped - nw4r::ut::Clamp(volume, 0.0f, 2.0f); + (void)nw4r::ut::Clamp(volume, 0.0f, 2.0f); if (mpTargetVolumes[playerIdx] > volume) { mpTargetVolumes[playerIdx] = volume; diff --git a/src/d/snd/d_snd_control_sound.cpp b/src/d/snd/d_snd_control_sound.cpp index aaef106f..d6ab1bac 100644 --- a/src/d/snd/d_snd_control_sound.cpp +++ b/src/d/snd/d_snd_control_sound.cpp @@ -7,7 +7,7 @@ // I'm not super happy with these base class function in a separate file, // but either we add another intermediate class or this is ok. It's weird -// that d_snd_sound has dSndControl_c::stop though +// that d_snd_sound has dSndControl_c::configure though void dSndControl_c::reset() { mCurrValue = mResetValue; @@ -18,7 +18,6 @@ void dSndControl_c::reset() { } void dSndControl_c::stop() { - // field_0x10 = field_0x04; mStartValue = mCurrValue; mTargetValue = mCurrValue; mDuration = 0; diff --git a/src/d/snd/d_snd_player_mgr.cpp b/src/d/snd/d_snd_player_mgr.cpp index 6a25a564..4851d179 100644 --- a/src/d/snd/d_snd_player_mgr.cpp +++ b/src/d/snd/d_snd_player_mgr.cpp @@ -5,6 +5,7 @@ #include "d/snd/d_snd_control_player_mgr.h" #include "d/snd/d_snd_mgr.h" #include "d/snd/d_snd_small_effect_mgr.h" +#include "d/snd/d_snd_source_enums.h" #include "d/snd/d_snd_wzsound.h" #include "egg/core/eggDvdRipper.h" #include "nw4r/snd/snd_SoundHandle.h" @@ -102,24 +103,26 @@ u32 dSndPlayerMgr_c::convertLabelStringToSoundId(const char *label) const { return dSndMgr_c::GetInstance()->changeNameToId(label); } -nw4r::snd::SoundArchivePlayer &dSndPlayerMgr_c::getSoundArchivePlayerForType(u8 type) { - if (canUseThisPlayer(type)) { +nw4r::snd::SoundArchivePlayer &dSndPlayerMgr_c::getSoundArchivePlayerForType(u8 sourceType) { + if (canUseThisPlayer(sourceType)) { return mSoundArchivePlayer; } return *dSndMgr_c::getPlayer(); } -bool dSndPlayerMgr_c::canUseThisPlayer(u8 type) const { +bool dSndPlayerMgr_c::canUseThisPlayer(u8 sourceType) const { if (!mSoundArchivePlayer.IsAvailable()) { return false; } - int ty = type; - - if ((ty >= 0 && ty <= 1) || ty == 58) { - return true; + switch (sourceType) { + case SND_SOURCE_PLAYER: + case SND_SOURCE_PLAYER_HEAD: + case SND_SOURCE_58: + return true; + default: + return false; } - return false; } bool dSndPlayerMgr_c::loadDemoArchive(const char *demoArchiveName) { diff --git a/src/d/snd/d_snd_small_effect_mgr.cpp b/src/d/snd/d_snd_small_effect_mgr.cpp index 24cc3216..1dca1655 100644 --- a/src/d/snd/d_snd_small_effect_mgr.cpp +++ b/src/d/snd/d_snd_small_effect_mgr.cpp @@ -63,13 +63,13 @@ bool dSndSmallEffectMgr_c::playSound(u32 soundId) { } case SE_S_MENU_SELECT_TURN_PAGE_LEFT: { if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_SHOP_STK_STOCK_SELECT_TURN_PAGE_LEFT)) { - return 0; + return false; } break; } case SE_S_MENU_SELECT_TURN_PAGE_RIGHT: { if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_SHOP_STK_STOCK_SELECT_TURN_PAGE_RIGHT)) { - return 0; + return false; } break; } @@ -87,7 +87,7 @@ bool dSndSmallEffectMgr_c::playSound(u32 soundId) { } case SE_S_WINDOW_PRESS_A: { if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_IMPORTANT, SE_S_POINTER_OK)) { - return 0; + return false; } break; } @@ -97,7 +97,7 @@ bool dSndSmallEffectMgr_c::playSound(u32 soundId) { } case SE_S_MENU_P1_POINT_ITEM: { if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_MENU_P1_HOLD_POINTER)) { - return 0; + return false; } break; } @@ -108,9 +108,9 @@ bool dSndSmallEffectMgr_c::playSound(u32 soundId) { } break; } - case 0x13EF: + case SE_S_DOWSING_WAIT: if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_FIRST_PERSON_ON)) { - return 0; + return false; } break; } diff --git a/src/d/snd/d_snd_source_group.cpp b/src/d/snd/d_snd_source_group.cpp index 951a7514..d973deaa 100644 --- a/src/d/snd/d_snd_source_group.cpp +++ b/src/d/snd/d_snd_source_group.cpp @@ -127,7 +127,7 @@ dSoundSource_c *dSndSourceGroup_c::getSourceClosestToListener() { f32 closest = INFINITY; for (dSoundSource_c *source = static_cast(nw4r::ut::List_GetFirst(&mSourceList)); source != nullptr; source = static_cast(nw4r::ut::List_GetNext(&mSourceList, source))) { - if (source->getActorType() != 1 && source->getActorType() != 48) { + if (source->getActorType() != SND_SOURCE_PLAYER_HEAD && source->getActorType() != SND_SOURCE_NPC_48) { f32 dist = source->getDistanceToListener(); if (dist < closest) { closest = dist;