Separate MxCore counter (#663)

This commit is contained in:
MS 2024-03-12 14:59:39 -04:00 committed by GitHub
parent 62a3f50287
commit dcc3946a08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 28 additions and 21 deletions

View file

@ -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";

View file

@ -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;

View file

@ -38,6 +38,7 @@ class MxCore {
// MxCore::`scalar deleting destructor'
private:
static MxU32 g_nextCoreId;
MxU32 m_id; // 0x04
};

View file

@ -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();

View file

@ -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

View file

@ -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);
}

View file

@ -1,12 +1,15 @@
#include "mxcore.h"
#include "define.h"
#include <assert.h>
// 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;
}