diff --git a/LEGO1/define.cpp b/LEGO1/define.cpp index 1e403a50..82dafb7d 100644 --- a/LEGO1/define.cpp +++ b/LEGO1/define.cpp @@ -1,15 +1,5 @@ #include "define.h" -// GLOBAL: LEGO1 0x1010141c -MxS32 g_mxcoreCount[101] = {0, -6643, -5643, -5058, -4643, -4321, -4058, -3836, -3643, -3473, -3321, -3184, -3058, - -2943, -2836, -2736, -2643, -2556, -2473, -2395, -2321, -2251, -2184, -2120, -2058, -2000, - -1943, -1888, -1836, -1785, -1736, -1689, -1643, -1599, -1556, -1514, -1473, -1434, -1395, - -1358, -1321, -1286, -1251, -1217, -1184, -1152, -1120, -1089, -1058, -1029, -1000, -971, - -943, -915, -888, -862, -836, -810, -785, -761, -736, -713, -689, -666, -643, - -621, -599, -577, -556, -535, -514, -494, -473, -454, -434, -415, -395, -377, - -358, -340, -321, -304, -286, -268, -251, -234, -217, -200, -184, -168, -152, - -136, -120, -104, -89, -74, -58, -43, -29, -14, 0}; - // GLOBAL: LEGO1 0x10102048 // STRING: LEGO1 0x10102040 const char* g_strACTION = "ACTION"; diff --git a/LEGO1/define.h b/LEGO1/define.h index d45d02c3..84400d36 100644 --- a/LEGO1/define.h +++ b/LEGO1/define.h @@ -3,7 +3,6 @@ #include "mxtypes.h" -extern MxS32 g_mxcoreCount[101]; extern const char* g_parseExtraTokens; extern const char* g_strWORLD; extern const char* g_strSOUND; diff --git a/LEGO1/omni/include/mxcore.h b/LEGO1/omni/include/mxcore.h index dc167f2b..90fdb7b1 100644 --- a/LEGO1/omni/include/mxcore.h +++ b/LEGO1/omni/include/mxcore.h @@ -38,6 +38,7 @@ class MxCore { // MxCore::`scalar deleting destructor' private: + static MxU32 g_nextCoreId; MxU32 m_id; // 0x04 }; diff --git a/LEGO1/omni/include/mxsoundmanager.h b/LEGO1/omni/include/mxsoundmanager.h index 24e7111a..8d1d573d 100644 --- a/LEGO1/omni/include/mxsoundmanager.h +++ b/LEGO1/omni/include/mxsoundmanager.h @@ -22,7 +22,7 @@ class MxSoundManager : public MxAudioManager { inline LPDIRECTSOUND GetDirectSound() { return m_directSound; } - MxS32 FUN_100aecf0(MxU32 p_undefined); + MxS32 GetAttenuation(MxU32 p_volume); protected: void Init(); diff --git a/LEGO1/omni/src/audio/mxsoundmanager.cpp b/LEGO1/omni/src/audio/mxsoundmanager.cpp index 0d9359e6..583d1dfc 100644 --- a/LEGO1/omni/src/audio/mxsoundmanager.cpp +++ b/LEGO1/omni/src/audio/mxsoundmanager.cpp @@ -1,6 +1,5 @@ #include "mxsoundmanager.h" -#include "define.h" #include "mxautolock.h" #include "mxmisc.h" #include "mxomni.h" @@ -10,6 +9,17 @@ DECOMP_SIZE_ASSERT(MxSoundManager, 0x3c); +// GLOBAL LEGO1 0x10101420 +MxS32 g_volumeAttenuation[100] = {-6643, -5643, -5058, -4643, -4321, -4058, -3836, -3643, -3473, -3321, -3184, -3058, + -2943, -2836, -2736, -2643, -2556, -2473, -2395, -2321, -2251, -2184, -2120, -2058, + -2000, -1943, -1888, -1836, -1785, -1736, -1689, -1643, -1599, -1556, -1514, -1473, + -1434, -1395, -1358, -1321, -1286, -1251, -1217, -1184, -1152, -1120, -1089, -1058, + -1029, -1000, -971, -943, -915, -888, -862, -836, -810, -785, -761, -736, + -713, -689, -666, -643, -621, -599, -577, -556, -535, -514, -494, -473, + -454, -434, -415, -395, -377, -358, -340, -321, -304, -286, -268, -251, + -234, -217, -200, -184, -168, -152, -136, -120, -104, -89, -74, -58, + -43, -29, -14, 0}; + // FUNCTION: LEGO1 0x100ae740 MxSoundManager::MxSoundManager() { @@ -184,12 +194,15 @@ MxPresenter* MxSoundManager::FUN_100aebd0(const MxAtomId& p_atomId, MxU32 p_obje } // FUNCTION: LEGO1 0x100aecf0 -MxS32 MxSoundManager::FUN_100aecf0(MxU32 p_undefined) +MxS32 MxSoundManager::GetAttenuation(MxU32 p_volume) { - if (!p_undefined) { - return -10000; + // The unit for p_volume is percent, rounded to integer. + // Convert to DSOUND attenuation units: -10000 (silent) to 0 (loudest). + if (p_volume == 0) { + return DSBVOLUME_MIN; } - return g_mxcoreCount[p_undefined]; + + return g_volumeAttenuation[p_volume - 1]; } // FUNCTION: LEGO1 0x100aed10 diff --git a/LEGO1/omni/src/audio/mxwavepresenter.cpp b/LEGO1/omni/src/audio/mxwavepresenter.cpp index bd02bf8d..defb20f6 100644 --- a/LEGO1/omni/src/audio/mxwavepresenter.cpp +++ b/LEGO1/omni/src/audio/mxwavepresenter.cpp @@ -297,7 +297,7 @@ void MxWavePresenter::SetVolume(MxS32 p_volume) m_volume = p_volume; if (m_dsBuffer != NULL) { MxS32 volume = p_volume * MxOmni::GetInstance()->GetSoundManager()->GetVolume() / 100; - MxS32 otherVolume = MxOmni::GetInstance()->GetSoundManager()->FUN_100aecf0(volume); + MxS32 otherVolume = MxOmni::GetInstance()->GetSoundManager()->GetAttenuation(volume); m_dsBuffer->SetVolume(otherVolume); } diff --git a/LEGO1/omni/src/common/mxcore.cpp b/LEGO1/omni/src/common/mxcore.cpp index 1266a1cb..c07cc51a 100644 --- a/LEGO1/omni/src/common/mxcore.cpp +++ b/LEGO1/omni/src/common/mxcore.cpp @@ -1,12 +1,15 @@ #include "mxcore.h" -#include "define.h" +#include + +// GLOBAL: LEGO1 0x1010141c +MxU32 MxCore::g_nextCoreId = 0; // FUNCTION: LEGO1 0x100ae1a0 MxCore::MxCore() { - m_id = (MxU32) g_mxcoreCount[0]; - g_mxcoreCount[0]++; + m_id = g_nextCoreId++; + assert(g_nextCoreId); } // FUNCTION: LEGO1 0x100ae1e0 @@ -17,5 +20,6 @@ MxCore::~MxCore() // FUNCTION: LEGO1 0x100ae1f0 MxLong MxCore::Notify(MxParam& p_param) { + assert(0); return 0; }