From 88b59fe172be985f312493c6f4f65719fccb1fce Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 22 Oct 2023 21:18:22 -0700 Subject: [PATCH] Start CSfxManager Former-commit-id: 9368bb11c0c1fb8bc9ed2f66b556da35adfa4856 --- config/GM8E01_00/symbols.txt | 30 +- config/GM8E01_01/symbols.txt | 30 +- include/Kyoto/Audio/CAudioSys.hpp | 41 ++- include/Kyoto/Audio/CSfxHandle.hpp | 2 +- include/Kyoto/Audio/CSfxManager.hpp | 239 ++++++++++---- .../ScriptObjects/CScriptRoomAcoustics.hpp | 32 +- src/Kyoto/Audio/CSfxManager.cpp | 295 ++++++++++++++++++ .../ScriptObjects/CScriptDock.cpp | 21 ++ .../ScriptObjects/CScriptRoomAcoustics.cpp | 26 +- 9 files changed, 584 insertions(+), 132 deletions(-) create mode 100644 src/Kyoto/Audio/CSfxManager.cpp create mode 100644 src/MetroidPrime/ScriptObjects/CScriptDock.cpp diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index e70c4ba8..0d524dba 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -12740,7 +12740,7 @@ IsTime__20CPreAdvanceIndicatorCFv = .text:0x802E7864; // type:function size:0x8 __ct__10CSfxHandleFUi = .text:0x802E786C; // type:function size:0x1C scope:global __dt__Q211CSfxManager11CSfxWrapperFv = .text:0x802E7888; // type:function size:0x5C scope:global FAudioTranslationTableFactory__FRC10SObjectTagR12CInputStreamRC15CVParamTransfer = .text:0x802E78E4; // type:function size:0xE8 scope:global -fn_802E79CC = .text:0x802E79CC; // type:function size:0x100 +__ct>__16CFactoryFnReturnFPQ24rstl36vector = .text:0x802E79CC; // type:function size:0x100 __dt__71TObjOwnerDerivedFromIObj>Fv = .text:0x802E7ACC; // type:function size:0xDC scope:global GetIObjObjectFor__53TToken>FRCQ24rstl55auto_ptr> = .text:0x802E7BA8; // type:function size:0x2C scope:global GetNewDerivedObject__71TObjOwnerDerivedFromIObj>FRCQ24rstl55auto_ptr> = .text:0x802E7BD4; // type:function size:0x9C scope:global @@ -12755,14 +12755,14 @@ GetReverbAmount__11CSfxManagerFv = .text:0x802E8410; // type:function size:0x20 IsAuxProcessingEnabled__11CSfxManagerFv = .text:0x802E8430; // type:function size:0x8 scope:global DisableAuxProcessing__11CSfxManagerFv = .text:0x802E8438; // type:function size:0x14 scope:global AllocateCSfxWrapper__11CSfxManagerFRCQ211CSfxManager11CSfxWrapper = .text:0x802E844C; // type:function size:0x188 scope:global -fn_802E85D4 = .text:0x802E85D4; // type:function size:0x170 -fn_802E8744 = .text:0x802E8744; // type:function size:0x48 -fn_802E878C = .text:0x802E878C; // type:function size:0x28 -fn_802E87B4 = .text:0x802E87B4; // type:function size:0xEC +AllocateCSfxEmitterWrapper__11CSfxManagerFRCQ211CSfxManager18CSfxEmitterWrapper = .text:0x802E85D4; // type:function size:0x170 +push_back__Q24rstl55reserved_vectorFRCQ211CSfxManager18CSfxEmitterWrapper = .text:0x802E8744; // type:function size:0x48 +construct__4rstlFPvRCQ211CSfxManager18CSfxEmitterWrapper = .text:0x802E878C; // type:function size:0x28 +__ct__Q211CSfxManager18CSfxEmitterWrapperFRCQ211CSfxManager18CSfxEmitterWrapper = .text:0x802E87B4; // type:function size:0xEC SetActiveAreas__11CSfxManagerFRCQ24rstl21reserved_vector = .text:0x802E88A0; // type:function size:0x110 scope:global TranslateSFXID__11CSfxManagerFUs = .text:0x802E89B0; // type:function size:0x4C scope:global LoadTranslationTable__11CSfxManagerFP11CSimplePoolPC10SObjectTag = .text:0x802E89FC; // type:function size:0x194 scope:global -fn_802E8B90 = .text:0x802E8B90; // type:function size:0x64 +__dt__Q24rstl17auto_ptr<6CToken>Fv = .text:0x802E8B90; // type:function size:0x64 GetRank__11CSfxManagerFPQ211CSfxManager15CBaseSfxWrapper = .text:0x802E8BF4; // type:function size:0x140 scope:global IsHandleValid__11CSfxManagerF10CSfxHandle = .text:0x802E8D34; // type:function size:0xA0 scope:global IsPlaying__11CSfxManagerF10CSfxHandle = .text:0x802E8DD4; // type:function size:0xD8 scope:global @@ -12797,7 +12797,7 @@ GetAudible__Q211CSfxManager11CSfxWrapperFRC9CVector3f = .text:0x802EA77C; // typ Ready__Q211CSfxManager11CSfxWrapperFv = .text:0x802EA784; // type:function size:0x60 scope:global IsPlaying__Q211CSfxManager11CSfxWrapperCFv = .text:0x802EA7E4; // type:function size:0x5C scope:global Stop__Q211CSfxManager11CSfxWrapperFv = .text:0x802EA840; // type:function size:0x5C scope:global -GetSFXId__Q211CSfxManager11CSfxWrapperCFv = .text:0x802EA89C; // type:function size:0x8 scope:global +GetSfxId__Q211CSfxManager11CSfxWrapperFv = .text:0x802EA89C; // type:function size:0x8 scope:global Play__Q211CSfxManager11CSfxWrapperFv = .text:0x802EA8A4; // type:function size:0xB8 scope:global SetReverb__Q211CSfxManager11CSfxWrapperFc = .text:0x802EA95C; // type:function size:0x6C scope:global __ct__Q211CSfxManager11CSfxWrapperFbsUsss10CSfxHandlebi = .text:0x802EA9C8; // type:function size:0x94 scope:global @@ -12836,7 +12836,7 @@ reserve__Q24rstl36vectorFi = .text:0x802EB068; // __sinit_CSfxManager_cpp = .text:0x802EB154; // type:function size:0xC0 scope:local __dt__Q24rstl49reserved_vectorFv = .text:0x802EB214; // type:function size:0x9C scope:global __dt__Q24rstl56reserved_vectorFv = .text:0x802EB2B0; // type:function size:0x9C scope:global -__arraydtor$2309 = .text:0x802EB34C; // type:function size:0x38 scope:global +__arraydtor$147 = .text:0x802EB34C; // type:function size:0x38 scope:global __dt__Q211CSfxManager11CSfxChannelFv = .text:0x802EB384; // type:function size:0x9C scope:global __ct__Q211CSfxManager11CSfxChannelFv = .text:0x802EB420; // type:function size:0xDC scope:global Blend__18CAdvancementDeltasFRC18CAdvancementDeltasRC18CAdvancementDeltasf = .text:0x802EB4FC; // type:function size:0xC8 scope:global @@ -18671,10 +18671,10 @@ lbl_803ECDA8 = .data:0x803ECDA8; // type:object size:0x18 lbl_803ECDC0 = .data:0x803ECDC0; // type:object size:0x18 lbl_803ECDD8 = .data:0x803ECDD8; // type:object size:0x18 lbl_803ECDF0 = .data:0x803ECDF0; // type:object size:0x20 -lbl_803ECE10 = .data:0x803ECE10; // type:object size:0x64 -lbl_803ECE74 = .data:0x803ECE74; // type:object size:0xC -lbl_803ECE80 = .data:0x803ECE80; // type:object size:0x64 -lbl_803ECEE4 = .data:0x803ECEE4; // type:object size:0x64 +__vt__Q211CSfxManager11CSfxWrapper = .data:0x803ECE10; // type:object size:0x64 +__vt__71TObjOwnerDerivedFromIObj> = .data:0x803ECE74; // type:object size:0xC +__vt__Q211CSfxManager18CSfxEmitterWrapper = .data:0x803ECE80; // type:object size:0x64 +__vt__Q211CSfxManager15CBaseSfxWrapper = .data:0x803ECEE4; // type:object size:0x64 lbl_803ECF48 = .data:0x803ECF48; // type:object size:0x10 lbl_803ECF58 = .data:0x803ECF58; // type:object size:0x68 lbl_803ECFC0 = .data:0x803ECFC0; // type:object size:0x24 @@ -21846,11 +21846,11 @@ lbl_805A92AC = .sbss:0x805A92AC; // type:object size:0x1 data:byte lbl_805A92B0 = .sbss:0x805A92B0; // type:object size:0x1 data:byte lbl_805A92B4 = .sbss:0x805A92B4; // type:object size:0x1 data:byte mRefCount__10CSfxHandle = .sbss:0x805A92B8; // type:object size:0x4 scope:global data:4byte -lbl_805A92C0 = .sbss:0x805A92C0; // type:object size:0x4 data:4byte +mCurrentChannel__11CSfxManager = .sbss:0x805A92C0; // type:object size:0x4 data:4byte lbl_805A92C4 = .sbss:0x805A92C4; // type:object size:0x1 data:byte -lbl_805A92C8 = .sbss:0x805A92C8; // type:object size:0x4 data:4byte +mTranslationTable__11CSfxManager = .sbss:0x805A92C8; // type:object size:0x4 data:4byte lbl_805A92CC = .sbss:0x805A92CC; // type:object size:0x1 data:byte -lbl_805A92D0 = .sbss:0x805A92D0; // type:object size:0x8 data:byte +mTranslationTableTok__11CSfxManager = .sbss:0x805A92D0; // type:object size:0x8 data:byte lbl_805A92D8 = .sbss:0x805A92D8; // type:object size:0x8 data:byte lbl_805A92E0 = .sbss:0x805A92E0; // type:object size:0x1 data:byte lbl_805A92E4 = .sbss:0x805A92E4; // type:object size:0x1 data:byte diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index 905893fa..a716ac4a 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -12755,7 +12755,7 @@ IsTime__20CPreAdvanceIndicatorCFv = .text:0x802E7944; // type:function size:0x8 __ct__10CSfxHandleFUi = .text:0x802E794C; // type:function size:0x1C scope:global __dt__Q211CSfxManager11CSfxWrapperFv = .text:0x802E7968; // type:function size:0x5C scope:global FAudioTranslationTableFactory__FRC10SObjectTagR12CInputStreamRC15CVParamTransfer = .text:0x802E79C4; // type:function size:0xE8 scope:global -fn_802E79CC = .text:0x802E7AAC; // type:function size:0x100 scope:global +__ct>__16CFactoryFnReturnFPQ24rstl36vector = .text:0x802E7AAC; // type:function size:0x100 scope:global __dt__71TObjOwnerDerivedFromIObj>Fv = .text:0x802E7BAC; // type:function size:0xDC scope:global GetIObjObjectFor__53TToken>FRCQ24rstl55auto_ptr> = .text:0x802E7C88; // type:function size:0x2C scope:global GetNewDerivedObject__71TObjOwnerDerivedFromIObj>FRCQ24rstl55auto_ptr> = .text:0x802E7CB4; // type:function size:0x9C scope:global @@ -12770,14 +12770,14 @@ GetReverbAmount__11CSfxManagerFv = .text:0x802E84F0; // type:function size:0x20 IsAuxProcessingEnabled__11CSfxManagerFv = .text:0x802E8510; // type:function size:0x8 scope:global DisableAuxProcessing__11CSfxManagerFv = .text:0x802E8518; // type:function size:0x14 scope:global AllocateCSfxWrapper__11CSfxManagerFRCQ211CSfxManager11CSfxWrapper = .text:0x802E852C; // type:function size:0x188 scope:global -fn_802E85D4 = .text:0x802E86B4; // type:function size:0x170 scope:global -fn_802E8744 = .text:0x802E8824; // type:function size:0x48 scope:global -fn_802E878C = .text:0x802E886C; // type:function size:0x28 scope:global -fn_802E87B4 = .text:0x802E8894; // type:function size:0xEC scope:global +AllocateCSfxEmitterWrapper__11CSfxManagerFRCQ211CSfxManager18CSfxEmitterWrapper = .text:0x802E86B4; // type:function size:0x170 scope:global +push_back__Q24rstl55reserved_vectorFRCQ211CSfxManager18CSfxEmitterWrapper = .text:0x802E8824; // type:function size:0x48 scope:global +construct__4rstlFPvRCQ211CSfxManager18CSfxEmitterWrapper = .text:0x802E886C; // type:function size:0x28 scope:global +__ct__Q211CSfxManager18CSfxEmitterWrapperFRCQ211CSfxManager18CSfxEmitterWrapper = .text:0x802E8894; // type:function size:0xEC scope:global SetActiveAreas__11CSfxManagerFRCQ24rstl21reserved_vector = .text:0x802E8980; // type:function size:0x110 scope:global TranslateSFXID__11CSfxManagerFUs = .text:0x802E8A90; // type:function size:0x4C scope:global LoadTranslationTable__11CSfxManagerFP11CSimplePoolPC10SObjectTag = .text:0x802E8ADC; // type:function size:0x194 scope:global -fn_802E8B90 = .text:0x802E8C70; // type:function size:0x64 scope:global +__dt__Q24rstl17auto_ptr<6CToken>Fv = .text:0x802E8C70; // type:function size:0x64 scope:global GetRank__11CSfxManagerFPQ211CSfxManager15CBaseSfxWrapper = .text:0x802E8CD4; // type:function size:0x140 scope:global IsHandleValid__11CSfxManagerF10CSfxHandle = .text:0x802E8E14; // type:function size:0xA0 scope:global IsPlaying__11CSfxManagerF10CSfxHandle = .text:0x802E8EB4; // type:function size:0xD8 scope:global @@ -12812,7 +12812,7 @@ GetAudible__Q211CSfxManager11CSfxWrapperFRC9CVector3f = .text:0x802EA85C; // typ Ready__Q211CSfxManager11CSfxWrapperFv = .text:0x802EA864; // type:function size:0x60 scope:global IsPlaying__Q211CSfxManager11CSfxWrapperCFv = .text:0x802EA8C4; // type:function size:0x5C scope:global Stop__Q211CSfxManager11CSfxWrapperFv = .text:0x802EA920; // type:function size:0x5C scope:global -GetSFXId__Q211CSfxManager11CSfxWrapperCFv = .text:0x802EA97C; // type:function size:0x8 scope:global +GetSfxId__Q211CSfxManager11CSfxWrapperFv = .text:0x802EA97C; // type:function size:0x8 scope:global Play__Q211CSfxManager11CSfxWrapperFv = .text:0x802EA984; // type:function size:0xB8 scope:global SetReverb__Q211CSfxManager11CSfxWrapperFc = .text:0x802EAA3C; // type:function size:0x6C scope:global __ct__Q211CSfxManager11CSfxWrapperFbsUsss10CSfxHandlebi = .text:0x802EAAA8; // type:function size:0x94 scope:global @@ -12851,7 +12851,7 @@ reserve__Q24rstl36vectorFi = .text:0x802EB148; // __sinit_CSfxManager_cpp = .text:0x802EB234; // type:function size:0xC0 scope:global __dt__Q24rstl49reserved_vectorFv = .text:0x802EB2F4; // type:function size:0x9C scope:global __dt__Q24rstl56reserved_vectorFv = .text:0x802EB390; // type:function size:0x9C scope:global -__arraydtor$2309 = .text:0x802EB42C; // type:function size:0x38 scope:global +__arraydtor$147 = .text:0x802EB42C; // type:function size:0x38 scope:local __dt__Q211CSfxManager11CSfxChannelFv = .text:0x802EB464; // type:function size:0x9C scope:global __ct__Q211CSfxManager11CSfxChannelFv = .text:0x802EB500; // type:function size:0xDC scope:global Blend__18CAdvancementDeltasFRC18CAdvancementDeltasRC18CAdvancementDeltasf = .text:0x802EB5DC; // type:function size:0xC8 scope:global @@ -18722,10 +18722,10 @@ lbl_803ECDA8 = .data:0x803ECF88; // type:object size:0x18 scope:global lbl_803ECDC0 = .data:0x803ECFA0; // type:object size:0x18 scope:global lbl_803ECDD8 = .data:0x803ECFB8; // type:object size:0x18 scope:global lbl_803ECDF0 = .data:0x803ECFD0; // type:object size:0x20 scope:global -lbl_803ECE10 = .data:0x803ECFF0; // type:object size:0x64 scope:global -lbl_803ECE74 = .data:0x803ED054; // type:object size:0xC scope:global -lbl_803ECE80 = .data:0x803ED060; // type:object size:0x64 scope:global -lbl_803ECEE4 = .data:0x803ED0C4; // type:object size:0x64 scope:global +__vt__Q211CSfxManager11CSfxWrapper = .data:0x803ECFF0; // type:object size:0x64 scope:global +__vt__71TObjOwnerDerivedFromIObj> = .data:0x803ED054; // type:object size:0xC scope:global +__vt__Q211CSfxManager18CSfxEmitterWrapper = .data:0x803ED060; // type:object size:0x64 scope:global +__vt__Q211CSfxManager15CBaseSfxWrapper = .data:0x803ED0C4; // type:object size:0x64 scope:global lbl_803ECF48 = .data:0x803ED128; // type:object size:0x10 scope:global lbl_803ECF58 = .data:0x803ED138; // type:object size:0x68 scope:global lbl_803ECFC0 = .data:0x803ED1A0; // type:object size:0x24 scope:global @@ -21891,11 +21891,11 @@ lbl_805A92AC = .sbss:0x805A948C; // type:object size:0x1 scope:global data:byte lbl_805A92B0 = .sbss:0x805A9490; // type:object size:0x1 scope:global data:byte lbl_805A92B4 = .sbss:0x805A9494; // type:object size:0x1 scope:global data:byte mRefCount__10CSfxHandle = .sbss:0x805A9498; // type:object size:0x4 scope:global data:4byte -lbl_805A92C0 = .sbss:0x805A94A0; // type:object size:0x4 scope:global data:4byte +mCurrentChannel__11CSfxManager = .sbss:0x805A94A0; // type:object size:0x4 scope:global data:4byte lbl_805A92C4 = .sbss:0x805A94A4; // type:object size:0x1 scope:global data:byte -lbl_805A92C8 = .sbss:0x805A94A8; // type:object size:0x4 scope:global data:4byte +mTranslationTable__11CSfxManager = .sbss:0x805A94A8; // type:object size:0x4 scope:global data:4byte lbl_805A92CC = .sbss:0x805A94AC; // type:object size:0x1 scope:global data:byte -lbl_805A92D0 = .sbss:0x805A94B0; // type:object size:0x8 scope:global data:byte +mTranslationTableTok__11CSfxManager = .sbss:0x805A94B0; // type:object size:0x8 scope:global data:byte lbl_805A92D8 = .sbss:0x805A94B8; // type:object size:0x8 scope:global data:byte lbl_805A92E0 = .sbss:0x805A94C0; // type:object size:0x1 scope:global data:byte lbl_805A92E4 = .sbss:0x805A94C4; // type:object size:0x1 scope:global data:byte diff --git a/include/Kyoto/Audio/CAudioSys.hpp b/include/Kyoto/Audio/CAudioSys.hpp index 14193f45..075be56a 100644 --- a/include/Kyoto/Audio/CAudioSys.hpp +++ b/include/Kyoto/Audio/CAudioSys.hpp @@ -1,6 +1,7 @@ #ifndef _CAUDIOSYS #define _CAUDIOSYS +#include "musyx/musyx.h" #include "types.h" #include "rstl/map.hpp" @@ -39,19 +40,16 @@ public: }; struct C3DEmitterParmData { - C3DEmitterParmData(const CVector3f& pos, const CVector3f& dir, float maxDist, float distComp, - uint flags, ushort sfxId, float maxVol, float minVol, bool important, - uchar prio) - : x0_pos(pos) - , xc_dir(dir) - , x18_maxDist(maxDist) + C3DEmitterParmData(const float maxDist = 150.f, const float distComp = 0.1f, + const uint flags = 1, const uchar maxVol = 127, const uchar minVol = 0) + : x18_maxDist(maxDist) , x1c_distComp(distComp) , x20_flags(flags) - , x24_sfxId(sfxId) + , x24_sfxId(0) , x26_maxVol(maxVol) , x27_minVol(minVol) - , x28_important(important) - , x29_prio(prio) {} + , x28_important(false) + , x29_prio(127) {} CVector3f x0_pos; CVector3f xc_dir; @@ -59,8 +57,8 @@ public: float x1c_distComp; uint x20_flags; ushort x24_sfxId; - float x26_maxVol; - float x27_minVol; + char x26_maxVol; + char x27_minVol; bool x28_important; // Can't be allocated over, regardless of priority uchar x29_prio; }; @@ -81,6 +79,27 @@ public: static short GetDefaultVolumeScale(); static bool GetVerbose(); + static SND_VOICEID SfxStart(const SND_FXID, const uchar, const uchar, const uchar); + static void SfxStop(SND_VOICEID handle); + static void SfxCtrl(SND_VOICEID handle, uchar ctrl, uchar val); + static SND_VOICEID SfxCheck(SND_VOICEID handle); + static void SfxVolume(SND_VOICEID handle, u8 vol); + static uint S3dAddEmitterParaEx(const C3DEmitterParmData& params, short handle, + SND_PARAMETER_INFO* paraInfo); + static void S3dUpdateEmitter(uint, const CVector3f&, const CVector3f&, uchar); + static void S3dRemoveEmitter(uint handle); + static const bool S3dCheckEmitter(uint handle); + static uint S3dEmitterVoiceID(uint handle); + + static void S3dAddListener(const CVector3f& pos, const CVector3f& dir, const CVector3f& vec1, + const CVector3f& vec2, const float f1, const float f2, const float f3, + const uint w1, const uchar maxVolume); + static void S3dUpdateListener(const CVector3f& pos, const CVector3f& dir, const CVector3f& vec1, + const CVector3f& vec2, const uchar maxVolume); + + static void S3dAddEmitter(SND_FXID fxid, const CVector3f& pos, const CVector3f& dir, + const bool b1, const bool b2, short, int); + static bool mInitialized; static bool mIsListenerActive; static bool mVerbose; diff --git a/include/Kyoto/Audio/CSfxHandle.hpp b/include/Kyoto/Audio/CSfxHandle.hpp index 772a3790..aeebb27c 100644 --- a/include/Kyoto/Audio/CSfxHandle.hpp +++ b/include/Kyoto/Audio/CSfxHandle.hpp @@ -8,7 +8,7 @@ public: CSfxHandle() : mID(0) {} CSfxHandle(uint value); - uint GetIndex() const { return mID & 0xFFF; } + uint GetIndex() const { return mID & 0xFF; } static CSfxHandle NullHandle() { return CSfxHandle(); } void operator=(const CSfxHandle& other) { mID = other.mID; } bool operator==(const CSfxHandle& other) { return mID == other.mID; } diff --git a/include/Kyoto/Audio/CSfxManager.hpp b/include/Kyoto/Audio/CSfxManager.hpp index d27b0fcd..f8b8da8e 100644 --- a/include/Kyoto/Audio/CSfxManager.hpp +++ b/include/Kyoto/Audio/CSfxManager.hpp @@ -1,74 +1,180 @@ #ifndef _CSFXMANAGER #define _CSFXMANAGER +#include "rstl/optional_object.hpp" #include "types.h" #include "Kyoto/Audio/CAudioSys.hpp" #include "Kyoto/Audio/CSfxHandle.hpp" -struct _SND_REVSTD_DELAYLINE { - int inPoint; - int outPoint; - int length; - float* inputs; - float lastOutput; -}; +#include +#include +#include -struct _SND_REVSTD_WORK { - struct _SND_REVSTD_DELAYLINE AP[6]; - struct _SND_REVSTD_DELAYLINE C[6]; - float allPassCoef; - float combCoef[6]; - float lpLastout[3]; - float level; - float damping; - int preDelayTime; - float* preDelayLine[3]; - float* preDelayPtr[3]; -}; +#include -struct SND_AUX_REVERBHI { - uchar pad0[0x1c4]; - bool hiDis; - float damping; - float crosstalk; - float coloration; - float time; - float mix; - float preDelay; -}; -struct SND_AUX_CHORUS { - uchar pad[144]; - uint baseDelay; - uint variation; - uint period; -}; -struct SND_AUX_REVERBSTD { - _SND_REVSTD_WORK rv; - bool tempDisableFX; - float damping; - float preDelay; - float coloration; - float time; - float mix; -}; -struct SND_AUX_DELAY { - uint currentSize[3]; - uint currentPos[3]; - uint currentFeedback[3]; - uint currentOutput[3]; - uint* left; - uint* right; - uint* sur; - uint delay[3]; // delay buffer length in ms per channel - uint feedback[3]; // feedback volume in % per channel - uint output[3]; // output volume in % per channel -}; +#include class CVector3f; class CSfxManager { public: - enum ESfxChannels { kSC_Invalid = -1, kSC_Default = 0, kSC_Game, kSC_PauseScreen }; + enum ESfxChannels { + kSC_Invalid = -1, + kSC_Default = 0, + kSC_Game, + kSC_PauseScreen, + }; + + enum ESfxAudibility { + kSA_Aud0, + kSA_Aud1, + kSA_Aud2, + kSA_Aud3, + }; + + enum EAuxEffect { + kAE_None = -1, + kAE_ReverbHi = 0, + kAE_Chorus, + kAE_ReverbStd, + kAE_Delay, + }; + + class CBaseSfxWrapper { + public: + CBaseSfxWrapper(const bool looped, const short prio, const CSfxHandle handle, + const bool useAcoustics, const int area); + virtual ~CBaseSfxWrapper(){}; + virtual void SetActive(bool v); + virtual void SetPlaying(bool v); + virtual void SetRank(short v); + virtual void SetInArea(bool v); + virtual const bool IsLooped() const; + virtual bool IsPlaying() const; + virtual const bool IsActive() const; + virtual const bool IsInArea() const; + virtual const bool UseAcoustics() const; + virtual const short GetRank() const; + virtual const short GetPriority() const; + virtual const int GetArea() const; + virtual const CSfxHandle GetSfxHandle() const; + virtual void Play() = 0; + virtual void Stop() = 0; + virtual const bool Ready() = 0; + virtual short GetAudible(const CVector3f&) = 0; + virtual const SND_VOICEID GetVoice() const = 0; + virtual const SND_FXID GetSfxId() = 0; + virtual void UpdateEmitterSilent() = 0; + virtual void UpdateEmitter() = 0; + virtual void SetReverb(const char rev) = 0; + const bool Available() const; + void Release(); + const float GetTimeRemaining(); + void SetTimeRemaining(float t); + + private: + float x4_timeRemaining; + short x8_rank; + short xa_prio; + CSfxHandle xc_handle; + int x10_area; + bool x14_24_isActive : 1; + bool x14_25_isPlaying : 1; + bool x14_26_looped : 1; + bool x14_27_inArea : 1; + bool x14_28_isReleased : 1; + bool x14_29_useAcoustics : 1; + }; + + class CSfxEmitterWrapper : public CBaseSfxWrapper { + public: + CSfxEmitterWrapper(const bool looped, const short prio, + CAudioSys::C3DEmitterParmData& emitterData, const CSfxHandle handle, + const bool useAcoustics, const int area); + ~CSfxEmitterWrapper(); + bool IsPlaying() const override; + void Play() override; + void Stop() override; + const bool Ready() override; + short GetAudible(const CVector3f&) override; + const SND_VOICEID GetVoice() const override; + const SND_FXID GetSfxId() override; + void UpdateEmitterSilent() override; + void UpdateEmitter() override; + void SetReverb(const char rev) override; + const CAudioSys::C3DEmitterParmData& GetEmitter(); + const SND_VOICEID GetHandle() const; + + private: + SND_PARAMETER x18_para; + SND_PARAMETER_INFO x1c_parameterInfo; + CAudioSys::C3DEmitterParmData x24_emitterData; + SND_VOICEID x50_emitterHandle; + bool x54_ready; + char x55_cachedMaxVol; + }; + + class CSfxWrapper : public CBaseSfxWrapper { + public: + CSfxWrapper(const bool looped, const short prio, const ushort sfxId, const short vol, + const short pan, const CSfxHandle handle, const bool useAcoustics, const int area); + ~CSfxWrapper(); // {} + + bool IsPlaying() const override; + void Play() override; + void Stop() override; + const bool Ready() override; + short GetAudible(const CVector3f&) override; + const SND_VOICEID GetVoice() const override; + const SND_FXID GetSfxId() override; + void UpdateEmitterSilent() override; + void UpdateEmitter() override; + void SetReverb(const char rev) override; + void SetVolume(short vol); + + private: + SND_FXID x18_sfxId; + SND_VOICEID x1c_voiceHandle; + short x20_vol; + short x22_pan; + bool x24_ready; + }; + class CSfxListener { + public: + explicit CSfxListener(const CVector3f pos = CVector3f::Zero(), + const CVector3f dir = CVector3f::Zero(), + const CVector3f vec1 = CVector3f::Zero(), + const CVector3f vec2 = CVector3f::Zero(), const float f1 = 0.f, + const float f2 = 0.f, const float f3 = 0.f, const uint w1 = 0, + const uchar maxVolume = 0) + : x0_(pos) + , xc_(dir) + , x18_(vec1) + , x24_(vec2) + , x30_(f1) + , x34_(f2) + , x38_(f3) + , x3c_(w1) + , x40_(maxVolume) {} + + CVector3f x0_; + CVector3f xc_; + CVector3f x18_; + CVector3f x24_; + float x30_; + float x34_; + float x38_; + int x3c_; + char x40_; + }; + + class CSfxChannel { + public: + CSfxChannel() : x44_(false) {} + CSfxListener x0_listener; + bool x44_; + rstl::reserved_vector< CBaseSfxWrapper*, 72 > x48_; + }; static void Update(float dt); static void RemoveEmitter(CSfxHandle handle); @@ -81,28 +187,32 @@ public: static const short kMedPriority; // 0x7F static const ushort kInternalInvalidSfxId; // 0xFFFF static const int kAllAreas; // 0xFFFFFFFF - static CSfxHandle AddEmitter(const ushort id, const CVector3f& pos, const CVector3f& dir, + static CSfxHandle AddEmitter(const SND_FXID id, const CVector3f& pos, const CVector3f& dir, const bool useAcoustics, const bool looped, const short prio = kMedPriority, const int areaId = kAllAreas); - static CSfxHandle AddEmitter(const ushort id, const CVector3f& pos, const CVector3f& dir, - uchar vol, const bool useAcoustics, const bool looped, + static CSfxHandle AddEmitter(const SND_FXID id, const CVector3f& pos, const CVector3f& dir, + const uchar vol, const bool useAcoustics, const bool looped, const short prio = kMedPriority, const int areaId = kAllAreas); static CSfxHandle AddEmitter(CAudioSys::C3DEmitterParmData& parmData, bool useAcoustics, const short prio = kMedPriority, const bool looped = false, - int areaId = kAllAreas); + const int areaId = kAllAreas); static void AddListener(ESfxChannels channel, const CVector3f& pos, const CVector3f& dir, const CVector3f& vec1, const CVector3f& vec2, float f1, float f2, float f3, uint w1, const uchar maxVolume); + static void Shutdown(); + static void StopAndRemoveAllEmitters(); static ushort TranslateSFXID(ushort); static void PitchBend(CSfxHandle handle, int pitch); + static ushort GetReverbAmount(); static CSfxHandle SfxStart(ushort id, short vol, short pan, bool useAcoustics, short prio = kMaxPriority, bool looped = false, int areaId = kAllAreas); static void SfxSpan(CSfxHandle, uchar); + static bool IsPlaying(const CSfxHandle& handle); static void SetChannel(ESfxChannels); @@ -110,6 +220,7 @@ public: static void TurnOnChannel(ESfxChannels); static void TurnOffChannel(ESfxChannels); + static const bool IsAuxProcessingEnabled(); static void DisableAuxCallback(); static void EnableAuxCallback(); static void PrepareDelayCallback(const SND_AUX_DELAY& info); @@ -117,6 +228,12 @@ public: static void PrepareChorusCallback(const SND_AUX_CHORUS& info); static void PrepareReverbHiCallback(const SND_AUX_REVERBHI& info); static void DisableAuxProcessing(); + static CSfxChannel mChannels[4]; + static ESfxChannels mCurrentChannel; + static rstl::vector< short >* mTranslationTable; + static rstl::auto_ptr< CToken > mTranslationTableTok; + static rstl::reserved_vector< CSfxEmitterWrapper, 64 > mEmitterWrapperPool; + static rstl::reserved_vector< CSfxWrapper, 64 > mWrapperPool; }; #endif // _CSFXMANAGER diff --git a/include/MetroidPrime/ScriptObjects/CScriptRoomAcoustics.hpp b/include/MetroidPrime/ScriptObjects/CScriptRoomAcoustics.hpp index 6fa5e01f..509d5bc6 100644 --- a/include/MetroidPrime/ScriptObjects/CScriptRoomAcoustics.hpp +++ b/include/MetroidPrime/ScriptObjects/CScriptRoomAcoustics.hpp @@ -6,23 +6,23 @@ #include "Kyoto/Audio/CSfxManager.hpp" struct EffectReverbHiInfo { + float time; /**< [0.01, 10.0] time in seconds for reflection decay */ + float preDelay; /**< [0.0, 0.1] time in seconds before initial reflection heard */ + float damping; /**< [0.0, 1.0] damping factor influencing low-pass filter of reflections */ float coloration; /**< [0.0, 1.0] influences filter coefficients to define surface characteristics of a room */ - float mix; /**< [0.0, 1.0] dry/wet mix factor of reverb effect */ - float time; /**< [0.01, 10.0] time in seconds for reflection decay */ - float damping; /**< [0.0, 1.0] damping factor influencing low-pass filter of reflections */ - float preDelay; /**< [0.0, 0.1] time in seconds before initial reflection heard */ float crosstalk; /**< [0.0, 1.0] factor defining how much reflections are allowed to bleed to other channels */ + float mix; /**< [0.0, 1.0] dry/wet mix factor of reverb effect */ - EffectReverbHiInfo(float coloration, float mix, float time, float damping, float preDelay, - float crosstalk) - : coloration(coloration) - , mix(mix) - , time(time) - , damping(damping) + EffectReverbHiInfo(float time, float preDelay, float damping, float coloration, float crosstalk, + float mix) + : time(time) , preDelay(preDelay) - , crosstalk(crosstalk) {} + , damping(damping) + , coloration(coloration) + , crosstalk(crosstalk) + , mix(mix) {} }; struct EffectChorusInfo { float baseDelay; @@ -33,15 +33,15 @@ struct EffectChorusInfo { : baseDelay(baseDelay), variation(variation), period(period) {} }; struct EffectReverbStdInfo { + float time; /**< [0.01, 10.0] time in seconds for reflection decay */ + float preDelay; /**< [0.0, 0.1] time in seconds before initial reflection heard */ + float damping; /**< [0.0, 1.0] damping factor influencing low-pass filter of reflections */ float coloration; /**< [0.0, 1.0] influences filter coefficients to define surface characteristics of a room */ float mix; /**< [0.0, 1.0] dry/wet mix factor of reverb effect */ - float time; /**< [0.01, 10.0] time in seconds for reflection decay */ - float damping; /**< [0.0, 1.0] damping factor influencing low-pass filter of reflections */ - float preDelay; /**< [0.0, 0.1] time in seconds before initial reflection heard */ - EffectReverbStdInfo(float coloration, float mix, float time, float damping, float preDelay) - : coloration(coloration), mix(mix), time(time), damping(damping), preDelay(preDelay) {} + EffectReverbStdInfo(float time, float preDelay, float damping, float coloration, float mix) + : time(time), preDelay(preDelay), damping(damping), coloration(coloration), mix(mix) {} }; struct EffectDelayInfo { int delayL; diff --git a/src/Kyoto/Audio/CSfxManager.cpp b/src/Kyoto/Audio/CSfxManager.cpp new file mode 100644 index 00000000..17eb7e76 --- /dev/null +++ b/src/Kyoto/Audio/CSfxManager.cpp @@ -0,0 +1,295 @@ +#include "Kyoto/Alloc/CMemory.hpp" +#include "Kyoto/Audio/CAudioSys.hpp" +#include "Kyoto/Audio/CSfxHandle.hpp" +#include "musyx/musyx.h" +#include "rstl/vector.hpp" +#include + +static int lbl_805A8770 = -1; +static int lbl_805A8774 = -1; + +CSfxManager::CSfxChannel CSfxManager::mChannels[4]; +CSfxManager::ESfxChannels CSfxManager::mCurrentChannel = kSC_Default; + +rstl::vector< short >* CSfxManager::mTranslationTable; +rstl::auto_ptr< CToken > CSfxManager::mTranslationTableTok; +rstl::reserved_vector< CSfxManager::CSfxEmitterWrapper, 64 > CSfxManager::mEmitterWrapperPool; +rstl::reserved_vector< CSfxManager::CSfxWrapper, 64 > CSfxManager::mWrapperPool; + +CSfxManager::CBaseSfxWrapper::CBaseSfxWrapper(const bool looped, const short prio, + const CSfxHandle handle, const bool useAcoustics, + const int area) +: x4_timeRemaining(15.f) +, x8_rank(0) +, xa_prio(prio) +, xc_handle(handle) +, x10_area(area) +, x14_24_isActive(true) +, x14_25_isPlaying(false) +, x14_26_looped(looped) +, x14_27_inArea(true) +, x14_28_isReleased(false) +, x14_29_useAcoustics(useAcoustics) {} + +const bool CSfxManager::CBaseSfxWrapper::Available() const { return x14_28_isReleased; } + +void CSfxManager::CBaseSfxWrapper::Release() { + x14_28_isReleased = true; + x4_timeRemaining = 15.f; +} + +const float CSfxManager::CBaseSfxWrapper::GetTimeRemaining() { return x4_timeRemaining; } + +void CSfxManager::CBaseSfxWrapper::SetTimeRemaining(float t) { x4_timeRemaining = t; } + +void CSfxManager::CBaseSfxWrapper::SetActive(bool v) { x14_24_isActive = v; } + +void CSfxManager::CBaseSfxWrapper::SetPlaying(bool v) { x14_25_isPlaying = v; } + +void CSfxManager::CBaseSfxWrapper::SetInArea(bool v) { x14_27_inArea = v; } + +void CSfxManager::CBaseSfxWrapper::SetRank(short v) { x8_rank = v; } + +const bool CSfxManager::CBaseSfxWrapper::IsLooped() const { return x14_26_looped; } + +const bool CSfxManager::CBaseSfxWrapper::IsInArea() const { return x14_27_inArea; } + +bool CSfxManager::CBaseSfxWrapper::IsPlaying() const { return x14_25_isPlaying; } + +const bool CSfxManager::CBaseSfxWrapper::IsActive() const { return x14_24_isActive; } + +const bool CSfxManager::CBaseSfxWrapper::UseAcoustics() const { return x14_29_useAcoustics; } + +const short CSfxManager::CBaseSfxWrapper::GetRank() const { return x8_rank; } + +const short CSfxManager::CBaseSfxWrapper::GetPriority() const { return xa_prio; } + +const CSfxHandle CSfxManager::CBaseSfxWrapper::GetSfxHandle() const { return xc_handle; } + +const int CSfxManager::CBaseSfxWrapper::GetArea() const { return x10_area; } + +CSfxManager::CSfxEmitterWrapper::CSfxEmitterWrapper(const bool looped, const short prio, + CAudioSys::C3DEmitterParmData& emitterData, + const CSfxHandle handle, + const bool useAcoustics, const int area) +: CBaseSfxWrapper(looped, prio, handle, useAcoustics, area) +, x24_emitterData(emitterData) +, x50_emitterHandle(SND_ID_ERROR) +, x54_ready(true) {} + +void CSfxManager::CSfxEmitterWrapper::SetReverb(const char rev) { + if (CSfxManager::IsAuxProcessingEnabled() && UseAcoustics()) { + x18_para.paraData.value7 = rev; + } +} + +void CSfxManager::CSfxEmitterWrapper::Play() { + x1c_parameterInfo.numPara = 1; + x1c_parameterInfo.paraArray = &x18_para; + x18_para.ctrl = SND_MIDICTRL_REVERB; + + if (CSfxManager::IsAuxProcessingEnabled() && UseAcoustics()) { + x18_para.paraData.value7 = CSfxManager::GetReverbAmount(); + } else { + x18_para.paraData.value7 = 0; + } + + x50_emitterHandle = CAudioSys::S3dAddEmitterParaEx(x24_emitterData, GetSfxHandle().GetIndex(), + &x1c_parameterInfo); + if (x50_emitterHandle != SND_ID_ERROR) { + SetPlaying(true); + } + x54_ready = false; +} + +const SND_FXID CSfxManager::CSfxEmitterWrapper::GetSfxId() { return x24_emitterData.x24_sfxId; } + +void CSfxManager::CSfxEmitterWrapper::Stop() { + if (x50_emitterHandle != SND_ID_ERROR) { + CAudioSys::S3dRemoveEmitter(x50_emitterHandle); + SetPlaying(false); + x50_emitterHandle = SND_ID_ERROR; + } +} + +const CAudioSys::C3DEmitterParmData& CSfxManager::CSfxEmitterWrapper::GetEmitter() { + return x24_emitterData; +} + +const SND_VOICEID CSfxManager::CSfxEmitterWrapper::GetHandle() const { return x50_emitterHandle; } + +bool CSfxManager::CSfxEmitterWrapper::IsPlaying() const { + if (!IsLooped()) { + bool ret = false; + if (CBaseSfxWrapper::IsPlaying() && CAudioSys::S3dCheckEmitter(x50_emitterHandle)) { + ret = true; + } + + return ret; + } + + return CBaseSfxWrapper::IsPlaying(); +} + +const bool CSfxManager::CSfxEmitterWrapper::Ready() { return IsLooped() || x54_ready; } + +short CSfxManager::CSfxEmitterWrapper::GetAudible(const CVector3f& vec) { + float magSq = (x24_emitterData.x0_pos - vec).MagSquared(); + float maxDist = x24_emitterData.x18_maxDist * x24_emitterData.x18_maxDist; + if (magSq < maxDist * 0.25f) + return kSA_Aud3; + else if (magSq < maxDist * 0.5f) + return kSA_Aud2; + else if (magSq < maxDist) + return kSA_Aud1; + return kSA_Aud0; +} + +const SND_VOICEID CSfxManager::CSfxEmitterWrapper::GetVoice() const { + return IsPlaying() ? CAudioSys::S3dEmitterVoiceID(x50_emitterHandle) : SND_ID_ERROR; +} + +void CSfxManager::CSfxEmitterWrapper::UpdateEmitterSilent() { + x55_cachedMaxVol = x24_emitterData.x26_maxVol; + CAudioSys::S3dUpdateEmitter(x50_emitterHandle, x24_emitterData.x0_pos, x24_emitterData.xc_dir, 1); +} + +void CSfxManager::CSfxEmitterWrapper::UpdateEmitter() { + CAudioSys::S3dUpdateEmitter(x50_emitterHandle, x24_emitterData.x0_pos, x24_emitterData.xc_dir, + x55_cachedMaxVol); +} + +CSfxManager::CSfxWrapper::CSfxWrapper(const bool looped, const short prio, const ushort sfxId, + const short vol, const short pan, const CSfxHandle handle, + const bool useAcoustics, const int area) +: CBaseSfxWrapper(looped, prio, handle, useAcoustics, area) +, x18_sfxId(sfxId) +, x1c_voiceHandle(SND_ID_ERROR) +, x20_vol(vol) +, x22_pan(pan) +, x24_ready(true) {} + +void CSfxManager::CSfxWrapper::SetReverb(const char rev) { + if (CSfxManager::IsAuxProcessingEnabled() && UseAcoustics()) { + CAudioSys::SfxCtrl(x1c_voiceHandle, SND_MIDICTRL_REVERB, rev); + } +} + +void CSfxManager::CSfxWrapper::Play() { + x1c_voiceHandle = CAudioSys::SfxStart(x18_sfxId, x20_vol, x22_pan, 0); + if (x1c_voiceHandle != SND_ID_ERROR) { + if (CSfxManager::IsAuxProcessingEnabled() && UseAcoustics()) { + CAudioSys::SfxCtrl(x1c_voiceHandle, SND_MIDICTRL_REVERB, CSfxManager::GetReverbAmount()); + } + + SetPlaying(true); + } + + x24_ready = false; +} + +const SND_FXID CSfxManager::CSfxWrapper::GetSfxId() { return x18_sfxId; } + +void CSfxManager::CSfxWrapper::Stop() { + if (x1c_voiceHandle != SND_ID_ERROR) { + CAudioSys::SfxStop(x1c_voiceHandle); + SetPlaying(false); + x1c_voiceHandle = SND_ID_ERROR; + } +} + +bool CSfxManager::CSfxWrapper::IsPlaying() const { + return CBaseSfxWrapper::IsPlaying() && CAudioSys::SfxCheck(x1c_voiceHandle) != SND_ID_ERROR; +} + +const bool CSfxManager::CSfxWrapper::Ready() { return IsLooped() || x24_ready; } + +short CSfxManager::CSfxWrapper::GetAudible(const CVector3f&) { return kSA_Aud3; } + +const SND_VOICEID CSfxManager::CSfxWrapper::GetVoice() const { return x1c_voiceHandle; } + +void CSfxManager::CSfxWrapper::SetVolume(short vol) { x20_vol = vol; } + +void CSfxManager::CSfxWrapper::UpdateEmitterSilent() { CAudioSys::SfxVolume(x1c_voiceHandle, 1); } + +void CSfxManager::CSfxWrapper::UpdateEmitter() { CAudioSys::SfxVolume(x1c_voiceHandle, x20_vol); } + +CSfxManager::CSfxEmitterWrapper::~CSfxEmitterWrapper() {} + +void CSfxManager::Shutdown() { + delete mTranslationTable; + mTranslationTable = nullptr; + StopAndRemoveAllEmitters(); + + if (lbl_805A8770 != -1) { + DisableAuxCallback(); + } +} + +void CSfxManager::StopAndRemoveAllEmitters() { + for (int i = 0; i < 4; ++i) { + CSfxChannel* channel = &mChannels[i]; + for (int j = 0; j < channel->x48_.size(); ++j) { + if (channel->x48_[j] != nullptr) { + if (channel->x48_[j]->IsPlaying()) { + channel->x48_[j]->Stop(); + } + channel->x48_[j]->Release(); + channel->x48_[j] = nullptr; + } + } + } +} + +void CSfxManager::AddListener(ESfxChannels channel, const CVector3f& pos, const CVector3f& dir, + const CVector3f& vec1, const CVector3f& vec2, const float f1, + const float f2, const float f3, const uint w1, + const uchar maxVolume) { + CSfxChannel* chan = &mChannels[channel]; + chan->x0_listener = CSfxListener(pos, dir, vec1, vec2, f1, f2, f3, w1, maxVolume); + chan->x44_ = true; + CAudioSys::S3dAddListener(pos, dir, vec1, vec2, f1, f2, f3, w1, maxVolume); +} + +void CSfxManager::UpdateListener(const CVector3f& pos, const CVector3f& dir, const CVector3f& vec1, + const CVector3f& vec2, const uchar maxVolume) { + CSfxChannel* chan = &mChannels[mCurrentChannel]; + chan->x0_listener.x0_ = pos; + chan->x0_listener.xc_ = dir; + chan->x0_listener.x18_ = vec1; + chan->x0_listener.x24_ = vec2; + chan->x0_listener.x40_ = maxVolume; + chan->x44_ = true; + CAudioSys::S3dUpdateListener(pos, dir, vec1, vec2, maxVolume); +} + +CSfxHandle CSfxManager::AddEmitter(const SND_FXID id, const CVector3f& pos, const CVector3f& dir, + const bool useAcoustics, const bool looped, const short prio, const int areaId) { + CAudioSys::C3DEmitterParmData emitterParm; + emitterParm.x24_sfxId = id; + emitterParm.x29_prio = prio; + emitterParm.x0_pos = pos; + emitterParm.xc_dir = dir; + return AddEmitter(emitterParm, useAcoustics, prio, looped, areaId); +} + +CSfxHandle CSfxManager::AddEmitter(const SND_FXID id, const CVector3f& pos, const CVector3f& dir, + const uchar vol, const bool useAcoustics, const bool looped, const short prio, + const int areaId) { + CAudioSys::C3DEmitterParmData emitterParm(150.f, 0.1f, 1, vol > 20 ? vol : 21); + emitterParm.x0_pos = pos; + emitterParm.xc_dir = dir; + emitterParm.x24_sfxId = id; + return AddEmitter(emitterParm, useAcoustics, looped, prio, areaId); +} + +CSfxHandle CSfxManager::AddEmitter(CAudioSys::C3DEmitterParmData& parmData, const bool useAcoustics, + const short prio, const bool looped, const int areaId) {} + +#pragma inline_max_size(250) +CFactoryFnReturn FAudioTranslationTableFactory(const SObjectTag& obj, CInputStream& in, + const CVParamTransfer& xfer) { + return rs_new rstl::vector< short >(in); +} + +CSfxManager::CSfxWrapper::~CSfxWrapper() {} diff --git a/src/MetroidPrime/ScriptObjects/CScriptDock.cpp b/src/MetroidPrime/ScriptObjects/CScriptDock.cpp new file mode 100644 index 00000000..b274e63a --- /dev/null +++ b/src/MetroidPrime/ScriptObjects/CScriptDock.cpp @@ -0,0 +1,21 @@ +#include +#include + +CScriptDock::CScriptDock(TUniqueId uid, const rstl::string& name, const CEntityInfo& info, + const CVector3f& position, const CVector3f& extent, int dock, TAreaId area, + bool active, int dockReferenceCount, bool loadConnected) +: CPhysicsActor( + uid, active, name, info, CTransform4f::Translate(position), CModelData::CModelDataNull(), + CMaterialList(kMT_Trigger, kMT_Immovable, kMT_AIBlock), CAABox(-(0.5f * extent), 0.5f * extent), + SMoverData(1.f), CActorParameters::None(), 0.3, 0.1f) +, x258_dockReferenceCount(dockReferenceCount) +, x25c_dock(dock) +, x260_area(area) +, x264_dockState(kDS_InNextRoom) +, x268_24_dockReferenced(false) +, x268_25_loadConnected(loadConnected) +, x268_26_areaPostConstructed(false) {} + +CScriptDock::~CScriptDock() { + +} diff --git a/src/MetroidPrime/ScriptObjects/CScriptRoomAcoustics.cpp b/src/MetroidPrime/ScriptObjects/CScriptRoomAcoustics.cpp index 68eb0d01..8df96d4a 100644 --- a/src/MetroidPrime/ScriptObjects/CScriptRoomAcoustics.cpp +++ b/src/MetroidPrime/ScriptObjects/CScriptRoomAcoustics.cpp @@ -6,22 +6,22 @@ static TAreaId s_ActiveAcousticsAreaId = kInvalidAreaId; CScriptRoomAcoustics::CScriptRoomAcoustics( TUniqueId uid, const rstl::string& name, const CEntityInfo& info, bool active, uint volScale, - bool revHi, bool revHiDis, float revHiColoration, float revHiMix, float revHiTime, - float revHiDamping, float revHiPreDelay, float revHiCrosstalk, bool chorus, float baseDelay, - float variation, float period, bool revStd, bool revStdDis, float revStdColoration, - float revStdMix, float revStdTime, float revStdDamping, float revStdPreDelay, bool delay, + bool revHi, bool revHiDis, float revHiTime, float revHiPreDelay, float revHiDamping, + float revHiColoration, float revHiCrosstalk, float revHiMix, bool chorus, float baseDelay, + float variation, float period, bool revStd, bool revStdDis, float revStdTime, + float revStdPreDelay, float revStdDamping, float revStdColoration, float revStdMix, bool delay, int delayL, int delayR, int delayS, int feedbackL, int feedbackR, int feedbackS, int outputL, int outputR, int outputS) : CEntity(uid, info, active, name) , x34_volumeScale(volScale) , x38_revHi(revHi) , x39_revHiDis(revHiDis) -, x3c_revHiInfo(revHiColoration, revHiMix, revHiTime, revHiDamping, revHiPreDelay, revHiCrosstalk) +, x3c_revHiInfo(revHiTime, revHiPreDelay, revHiDamping, revHiColoration, revHiCrosstalk, revHiMix) , x54_chorus(chorus) , x58_chorusInfo(baseDelay, variation, period) , x64_revStd(revStd) , x65_revStdDis(revStdDis) -, x68_revStdInfo(revStdColoration, revStdMix, revStdTime, revStdDamping, revStdPreDelay) +, x68_revStdInfo(revStdTime, revStdPreDelay, revStdDamping, revStdColoration, revStdMix) , x7c_delay(delay) , x80_delayInfo(delayL, delayR, delayS, feedbackL, feedbackR, feedbackS, outputL, outputR, outputS) {} @@ -63,13 +63,13 @@ void CScriptRoomAcoustics::EnableAuxCallbacks() { if (x38_revHi && applied <= 0) { SND_AUX_REVERBHI reverb; - reverb.hiDis = x39_revHiDis; - reverb.coloration = x3c_revHiInfo.coloration; - reverb.mix = x3c_revHiInfo.mix; + reverb.tempDisableFX = x39_revHiDis; reverb.time = x3c_revHiInfo.time; - reverb.damping = x3c_revHiInfo.damping; reverb.preDelay = x3c_revHiInfo.preDelay; + reverb.damping = x3c_revHiInfo.damping; + reverb.coloration = x3c_revHiInfo.coloration; reverb.crosstalk = x3c_revHiInfo.crosstalk; + reverb.mix = x3c_revHiInfo.mix; applied++; CSfxManager::PrepareReverbHiCallback(reverb); } @@ -84,11 +84,11 @@ void CScriptRoomAcoustics::EnableAuxCallbacks() { if (x64_revStd && applied < 1) { SND_AUX_REVERBSTD reverbStd; reverbStd.tempDisableFX = x65_revStdDis; + reverbStd.time = x68_revStdInfo.time; + reverbStd.preDelay = x68_revStdInfo.preDelay; + reverbStd.damping = x68_revStdInfo.damping; reverbStd.coloration = x68_revStdInfo.coloration; reverbStd.mix = x68_revStdInfo.mix; - reverbStd.time = x68_revStdInfo.time; - reverbStd.damping = x68_revStdInfo.damping; - reverbStd.preDelay = x68_revStdInfo.preDelay; applied++; CSfxManager::PrepareReverbStdCallback(reverbStd); }