diff --git a/LEGO1/legosoundmanager.cpp b/LEGO1/legosoundmanager.cpp index a74ca419..e98aa0f4 100644 --- a/LEGO1/legosoundmanager.cpp +++ b/LEGO1/legosoundmanager.cpp @@ -18,7 +18,7 @@ LegoSoundManager::~LegoSoundManager() void LegoSoundManager::Init() { m_unk0x40 = 0; - m_unk0x3c = 0; + m_listener = NULL; } // STUB: LEGO1 0x100299b0 @@ -26,10 +26,43 @@ void LegoSoundManager::Destroy(MxBool p_fromDestructor) { } -// STUB: LEGO1 0x100299f0 +// FUNCTION: LEGO1 0x100299f0 MxResult LegoSoundManager::Create(MxU32 p_frequencyMS, MxBool p_createThread) { - return FAILURE; + MxBool locked = FALSE; + MxResult result = FAILURE; + if (MxSoundManager::Create(10, FALSE) == SUCCESS) { + m_criticalSection.Enter(); + locked = TRUE; + if (MxOmni::IsSound3D()) { + if (m_dsBuffer->QueryInterface(IID_IDirectSound3DListener, (LPVOID*) &m_listener) == S_OK) { + MxOmni* omni = MxOmni::GetInstance(); + IDirectSound* sound; + if (omni && omni->GetSoundManager() && (sound = omni->GetSoundManager()->GetDirectSound())) { + DSCAPS caps; + memset(&caps, 0, sizeof(DSCAPS)); + caps.dwSize = sizeof(DSCAPS); + + if (sound->GetCaps(&caps) == S_OK && caps.dwMaxHw3DAllBuffers == 0) { + m_listener->SetDistanceFactor(0.026315790f, 0); + m_listener->SetRolloffFactor(10, 0); + } + } + } + } + + // todo + result = SUCCESS; + } + + if (result != SUCCESS) { + Destroy(); + } + + if (locked) { + m_criticalSection.Leave(); + } + return result; } // FUNCTION: LEGO1 0x1002a390 diff --git a/LEGO1/legosoundmanager.h b/LEGO1/legosoundmanager.h index 2caef869..5f39f4c4 100644 --- a/LEGO1/legosoundmanager.h +++ b/LEGO1/legosoundmanager.h @@ -18,7 +18,7 @@ class LegoSoundManager : public MxSoundManager { void Init(); void Destroy(MxBool p_fromDestructor); - undefined4 m_unk0x3c; + IDirectSound3DListener* m_listener; undefined4 m_unk0x40; }; diff --git a/LEGO1/mxsoundmanager.h b/LEGO1/mxsoundmanager.h index 5131e1e2..1d897fe4 100644 --- a/LEGO1/mxsoundmanager.h +++ b/LEGO1/mxsoundmanager.h @@ -24,7 +24,7 @@ class MxSoundManager : public MxAudioManager { MxS32 FUN_100aecf0(MxU32 p_undefined); -private: +protected: void Init(); void Destroy(MxBool p_fromDestructor); MxPresenter* FUN_100aebd0(const MxAtomId& p_atomId, MxU32 p_objectId);