From 882f7000d251d9bd60376547a2346fe03db25b1d Mon Sep 17 00:00:00 2001 From: TheRedDaemon <66257843+TheRedDaemon@users.noreply.github.com> Date: Sat, 11 Jul 2026 01:43:03 +0200 Subject: [PATCH 1/2] reimplement: SHC_3BB0A8C1_0x00449B30 --- src/OpenSHC/Audio/SFX/SFXState.func.hpp | 4 +- src/OpenSHC/Audio/SFX/SFXState.hpp | 2 +- .../Audio/SFX/SFXState/loadWavSounds.cpp | 56 +++++++++++++++++++ src/OpenSHC/Audio/SFX/SoundStructure1.hpp | 2 +- .../Globals/DAT_LoadingBarProgress.hpp | 2 +- 5 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 src/OpenSHC/Audio/SFX/SFXState/loadWavSounds.cpp diff --git a/src/OpenSHC/Audio/SFX/SFXState.func.hpp b/src/OpenSHC/Audio/SFX/SFXState.func.hpp index 57931aaf..781821ff 100644 --- a/src/OpenSHC/Audio/SFX/SFXState.func.hpp +++ b/src/OpenSHC/Audio/SFX/SFXState.func.hpp @@ -23,8 +23,8 @@ namespace Audio { void (SFXState::*)(int), false, Address::SHC_3BB0A8C1_0x00449B20, &SFXState::freeMemoryAt) freeMemoryAt; - MACRO_FUNCTION_RESOLVER( - void (SFXState::*)(char*), false, Address::SHC_3BB0A8C1_0x00449B30, &SFXState::loadWavSounds) + MACRO_FUNCTION_RESOLVER(void (SFXState::*)(char[270][8][1000]), false, Address::SHC_3BB0A8C1_0x00449B30, + &SFXState::loadWavSounds) loadWavSounds; MACRO_FUNCTION_RESOLVER(void (SFXState::*)(SoundEffectID), false, Address::SHC_3BB0A8C1_0x00449C40, diff --git a/src/OpenSHC/Audio/SFX/SFXState.hpp b/src/OpenSHC/Audio/SFX/SFXState.hpp index 2f4f7a7e..ed9ec629 100644 --- a/src/OpenSHC/Audio/SFX/SFXState.hpp +++ b/src/OpenSHC/Audio/SFX/SFXState.hpp @@ -56,7 +56,7 @@ namespace Audio { void freeMemoryAt(int param_1); - void loadWavSounds(char* param_1); + void loadWavSounds(char(param_1)[270][8][1000]); void setUpSFXToPlayUnk(SoundEffectID sfxOffsetInArray); diff --git a/src/OpenSHC/Audio/SFX/SFXState/loadWavSounds.cpp b/src/OpenSHC/Audio/SFX/SFXState/loadWavSounds.cpp new file mode 100644 index 00000000..cea57847 --- /dev/null +++ b/src/OpenSHC/Audio/SFX/SFXState/loadWavSounds.cpp @@ -0,0 +1,56 @@ +#include "../SFXState.func.hpp" + +#include "OpenSHC/Audio/mss/SoundSystem.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_LoadingBarProgress.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace Audio { + namespace SFX { + + // FUNCTION: STRONGHOLDCRUSADER 0x00449B30 + void SFXState::loadWavSounds(char(param_1)[270][8][1000]) + { + for (int soundStructure2Index = 0; soundStructure2Index < 270; ++soundStructure2Index) { + this->DAT_SoundStructures2[soundStructure2Index].soundID = 0; + this->DAT_SoundStructures2[soundStructure2Index].field1_0x4 = 0; + this->DAT_SoundStructures2[soundStructure2Index].variationCount = 0; + this->DAT_SoundStructures2[soundStructure2Index].variationCounter = 0; + + for (int unknownIndex = 0; unknownIndex < 8; ++unknownIndex) { + if (!strcmp(param_1[soundStructure2Index][unknownIndex], s_Null_wav_005a4cf8)) { + break; + } + ++this->DAT_SoundStructures2[soundStructure2Index].field1_0x4; + } + for (int unknownIndex = 0; unknownIndex < 8; ++unknownIndex) { + if (!strcmp(param_1[soundStructure2Index][unknownIndex], s_Null_wav_005a4cf8)) { + break; + } + int const _soundStructureID = MACRO_CALL_MEMBER(MSS::SoundSystem_Func::meth_0x479c20, + DAT_SoundSystemState::ptr)(param_1[soundStructure2Index][unknownIndex]); + if (_soundStructureID < 0) { + break; + } + ++this->DAT_SoundStructures2[soundStructure2Index].variationCount; + if (this->DAT_SoundStructures2[soundStructure2Index].soundID == 0) { + this->DAT_SoundStructures2[soundStructure2Index].soundID = _soundStructureID; + } + this->DAT_SoundStructures[_soundStructureID].pointerToFilename + = param_1[soundStructure2Index][unknownIndex]; + } + IO::Graphics::GmID const currentGmId + = (IO::Graphics::GmID)(DAT_LoadingBarProgress::instance + ((soundStructure2Index + 1) * 80 / 270)); + int const barLengthUnk = DAT_LoadingBarProgress::instance + 180; + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::drawLoadingBarUnk, + DAT_TextureRenderCoreObject::ptr)(currentGmId, barLengthUnk); + }; + } + + } +} +} diff --git a/src/OpenSHC/Audio/SFX/SoundStructure1.hpp b/src/OpenSHC/Audio/SFX/SoundStructure1.hpp index a962d45f..e57af9dc 100644 --- a/src/OpenSHC/Audio/SFX/SoundStructure1.hpp +++ b/src/OpenSHC/Audio/SFX/SoundStructure1.hpp @@ -21,7 +21,7 @@ namespace Audio { int scheduledPlayCounter; // 0x00000008 length: 4 int field3_0xc; // 0x0000000C length: 4 int baseVolumePercentageUnk; // 0x00000010 length: 4 - pointer* pointerToFilename; // 0x00000014 length: 4 + char* pointerToFilename; // 0x00000014 length: 4 } SoundStructure1; #pragma pack(pop) diff --git a/src/OpenSHC/Globals/DAT_LoadingBarProgress.hpp b/src/OpenSHC/Globals/DAT_LoadingBarProgress.hpp index 4eb86fec..e708495b 100644 --- a/src/OpenSHC/Globals/DAT_LoadingBarProgress.hpp +++ b/src/OpenSHC/Globals/DAT_LoadingBarProgress.hpp @@ -9,7 +9,7 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00D7D2D0 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { From 7c1506913d882055469685575f16b9fa460baecc Mon Sep 17 00:00:00 2001 From: TheRedDaemon <66257843+TheRedDaemon@users.noreply.github.com> Date: Sun, 12 Jul 2026 20:17:21 +0200 Subject: [PATCH 2/2] reimplement: SHC_3BB0A8C1_0x00449B30 100% --- src/OpenSHC/Audio/SFX/SFXState.func.hpp | 4 +- src/OpenSHC/Audio/SFX/SFXState.hpp | 2 +- .../Audio/SFX/SFXState/loadWavSounds.cpp | 60 ++++++++++++------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 4 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/OpenSHC/Audio/SFX/SFXState.func.hpp b/src/OpenSHC/Audio/SFX/SFXState.func.hpp index 781821ff..57931aaf 100644 --- a/src/OpenSHC/Audio/SFX/SFXState.func.hpp +++ b/src/OpenSHC/Audio/SFX/SFXState.func.hpp @@ -23,8 +23,8 @@ namespace Audio { void (SFXState::*)(int), false, Address::SHC_3BB0A8C1_0x00449B20, &SFXState::freeMemoryAt) freeMemoryAt; - MACRO_FUNCTION_RESOLVER(void (SFXState::*)(char[270][8][1000]), false, Address::SHC_3BB0A8C1_0x00449B30, - &SFXState::loadWavSounds) + MACRO_FUNCTION_RESOLVER( + void (SFXState::*)(char*), false, Address::SHC_3BB0A8C1_0x00449B30, &SFXState::loadWavSounds) loadWavSounds; MACRO_FUNCTION_RESOLVER(void (SFXState::*)(SoundEffectID), false, Address::SHC_3BB0A8C1_0x00449C40, diff --git a/src/OpenSHC/Audio/SFX/SFXState.hpp b/src/OpenSHC/Audio/SFX/SFXState.hpp index ed9ec629..2f4f7a7e 100644 --- a/src/OpenSHC/Audio/SFX/SFXState.hpp +++ b/src/OpenSHC/Audio/SFX/SFXState.hpp @@ -56,7 +56,7 @@ namespace Audio { void freeMemoryAt(int param_1); - void loadWavSounds(char(param_1)[270][8][1000]); + void loadWavSounds(char* param_1); void setUpSFXToPlayUnk(SoundEffectID sfxOffsetInArray); diff --git a/src/OpenSHC/Audio/SFX/SFXState/loadWavSounds.cpp b/src/OpenSHC/Audio/SFX/SFXState/loadWavSounds.cpp index cea57847..735c4fb9 100644 --- a/src/OpenSHC/Audio/SFX/SFXState/loadWavSounds.cpp +++ b/src/OpenSHC/Audio/SFX/SFXState/loadWavSounds.cpp @@ -13,42 +13,58 @@ namespace Audio { namespace SFX { // FUNCTION: STRONGHOLDCRUSADER 0x00449B30 - void SFXState::loadWavSounds(char(param_1)[270][8][1000]) + void SFXState::loadWavSounds(char* param_1) { - for (int soundStructure2Index = 0; soundStructure2Index < 270; ++soundStructure2Index) { + // Might have arrived in a different format, maybe it was void, or an char(param_1)[270][8][1000] and they + // casted it to perform arithmetic? + char* soundNames = param_1; + int soundStructure2Index = 0; + while (soundStructure2Index < 270) { this->DAT_SoundStructures2[soundStructure2Index].soundID = 0; this->DAT_SoundStructures2[soundStructure2Index].field1_0x4 = 0; this->DAT_SoundStructures2[soundStructure2Index].variationCount = 0; this->DAT_SoundStructures2[soundStructure2Index].variationCounter = 0; - for (int unknownIndex = 0; unknownIndex < 8; ++unknownIndex) { - if (!strcmp(param_1[soundStructure2Index][unknownIndex], s_Null_wav_005a4cf8)) { + char* variation = soundNames; + for (int i = 0; i < 8; ++i) { + if (!strcmp(variation, s_Null_wav_005a4cf8)) break; - } + ++this->DAT_SoundStructures2[soundStructure2Index].field1_0x4; + variation += sizeof(char[1000]); } - for (int unknownIndex = 0; unknownIndex < 8; ++unknownIndex) { - if (!strcmp(param_1[soundStructure2Index][unknownIndex], s_Null_wav_005a4cf8)) { + + variation = soundNames; + for (int i = 0; i < 8; ++i) { + if (!strcmp(variation, s_Null_wav_005a4cf8)) break; - } - int const _soundStructureID = MACRO_CALL_MEMBER(MSS::SoundSystem_Func::meth_0x479c20, - DAT_SoundSystemState::ptr)(param_1[soundStructure2Index][unknownIndex]); - if (_soundStructureID < 0) { + + int soundID + = MACRO_CALL_MEMBER(MSS::SoundSystem_Func::meth_0x479c20, DAT_SoundSystemState::ptr)(variation); + + if (soundID < 0) break; - } + ++this->DAT_SoundStructures2[soundStructure2Index].variationCount; - if (this->DAT_SoundStructures2[soundStructure2Index].soundID == 0) { - this->DAT_SoundStructures2[soundStructure2Index].soundID = _soundStructureID; - } - this->DAT_SoundStructures[_soundStructureID].pointerToFilename - = param_1[soundStructure2Index][unknownIndex]; + + if (this->DAT_SoundStructures2[soundStructure2Index].soundID == 0) + this->DAT_SoundStructures2[soundStructure2Index].soundID = soundID; + + this->DAT_SoundStructures[soundID].pointerToFilename = variation; + + variation += sizeof(char[1000]); } - IO::Graphics::GmID const currentGmId - = (IO::Graphics::GmID)(DAT_LoadingBarProgress::instance + ((soundStructure2Index + 1) * 80 / 270)); - int const barLengthUnk = DAT_LoadingBarProgress::instance + 180; + soundNames += sizeof(char[8][1000]); + + ++soundStructure2Index; + int loadingBar = soundStructure2Index * 80; + + IO::Graphics::GmID currentGmId + = (IO::Graphics::GmID)(loadingBar / 270 + DAT_LoadingBarProgress::instance); + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::drawLoadingBarUnk, - DAT_TextureRenderCoreObject::ptr)(currentGmId, barLengthUnk); - }; + DAT_TextureRenderCoreObject::ptr)(currentGmId, DAT_LoadingBarProgress::instance + 180); + } } } diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 9896e695..27b78c50 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -8123,7 +8123,7 @@ SHC_3BB0A8C1_0x00449B08 | 0.0% | Pending SHC_3BB0A8C1_0x00449B0C | 0.0% | Pending SHC_3BB0A8C1_0x00449B10 | 0.0% | Pending SHC_3BB0A8C1_0x00449B20 | 0.0% | Pending -SHC_3BB0A8C1_0x00449B30 | 0.0% | Pending +SHC_3BB0A8C1_0x00449B30 | 100.0% | Pending SHC_3BB0A8C1_0x00449C40 | 0.0% | Pending SHC_3BB0A8C1_0x00449CC0 | 0.0% | Pending SHC_3BB0A8C1_0x00449D50 | 0.0% | Pending