diff --git a/src/OpenSHC/Audio/mss/SoundSystem/setupVolumeAndSoundID.cpp b/src/OpenSHC/Audio/mss/SoundSystem/setupVolumeAndSoundID.cpp index ed8bdd2..679555e 100644 --- a/src/OpenSHC/Audio/mss/SoundSystem/setupVolumeAndSoundID.cpp +++ b/src/OpenSHC/Audio/mss/SoundSystem/setupVolumeAndSoundID.cpp @@ -14,10 +14,12 @@ namespace Audio { // FUNCTION: STRONGHOLDCRUSADER 0x0047A1B0 void SoundSystem::setupVolumeAndSoundID(eMusicIDsInt soundID) { - // NOTE: Is this certain that these ids fit to the original game? + // Indicator to handle as mission sound (?) if (soundID == DE::SHCDE::MUSIC_TUNE_NARR1) { // missionNumber1to20 might be unsigned, but found signs inconclusive if (DAT_GameCore::ptr->missionNumber1to20 - 1U <= 19) { + // This makes the soundID "missionNumber1to20 + 46", which would use the enums 47 to 66. + // These are only filled by 4 enums for 4 mission intros, so this space could be made for 20. soundID = DAT_GameCore::ptr->missionNumber1to20 + 46; } else { soundID = DE::SHCDE::MUSIC_TUNE_OFF; @@ -30,6 +32,7 @@ namespace Audio { this->currentSoundID_0x3278 = soundID; int const fileVolume = MACRO_CALL_MEMBER(SFX::SFXState_Func::getSoundVolumeForFilename, DAT_SFXState::ptr)( DAT_SFXDefinedData::ptr->DAT_SFX_Pointers[soundID].musicFile); + // 0x7f is the maximum volume of the MSS32 volume API. this->currentSoundIDVolumeUnk_0x327c = (fileVolume * 100) / 0x7f; this->mbr_0x3280 = 0; } diff --git a/src/OpenSHC/Audio/mss/SoundSystem/setupVolumeAndSoundIDWithMultiplier.cpp b/src/OpenSHC/Audio/mss/SoundSystem/setupVolumeAndSoundIDWithMultiplier.cpp new file mode 100644 index 0000000..521caf8 --- /dev/null +++ b/src/OpenSHC/Audio/mss/SoundSystem/setupVolumeAndSoundIDWithMultiplier.cpp @@ -0,0 +1,42 @@ +#include "../SoundSystem.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/DE/SHCDE/eMusicIDs.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_SFXDefinedData.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" + +namespace OpenSHC { +namespace Audio { + namespace MSS { + + // FUNCTION: STRONGHOLDCRUSADER 0x0047A220 + void SoundSystem::setupVolumeAndSoundIDWithMultiplier(eMusicIDsInt soundID, int soundMultiplier) + { + // Indicator to handle as mission sound (?) + if (soundID == DE::SHCDE::MUSIC_TUNE_NARR1) { + // missionNumber1to20 might be unsigned, but found signs inconclusive + if (DAT_GameCore::ptr->missionNumber1to20 - 1U <= 19) { + // This makes the soundID "missionNumber1to20 + 46", which would use the enums 47 to 66. + // These are only filled by 4 enums for 4 mission intros, so this space could be made for 20. + soundID = DAT_GameCore::ptr->missionNumber1to20 + 46; + } else { + soundID = DE::SHCDE::MUSIC_TUNE_OFF; + } + } + + if (soundID == this->currentSoundID_0x3278) { + return; + } + this->currentSoundID_0x3278 = soundID; + int const fileVolume = MACRO_CALL_MEMBER(SFX::SFXState_Func::getSoundVolumeForFilename, DAT_SFXState::ptr)( + DAT_SFXDefinedData::ptr->DAT_SFX_Pointers[soundID].musicFile); + // 0x7f is the maximum volume of the MSS32 volume API. + this->currentSoundIDVolumeUnk_0x327c = (fileVolume * soundMultiplier) / 0x7f; + this->mbr_0x3280 = 0; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index d812552..8127ead 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -10896,7 +10896,7 @@ SHC_3BB0A8C1_0x00479FC0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0047A080 | 0.0% | Pending SHC_3BB0A8C1_0x0047A130 | 0.0% | Pending SHC_3BB0A8C1_0x0047A1B0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0047A220 | 0.0% | Pending +SHC_3BB0A8C1_0x0047A220 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0047A290 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0047A2A0 | 0.0% | Pending SHC_3BB0A8C1_0x0047A310 | 0.0% | Pending