From 74ae5b37fd46e03ca2cd4e5d53dbd85726663a27 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 5 Nov 2026 10:55:12 +0000 Subject: [PATCH] Decompile fn_04750 (CSoundMgr::Initialize) Batch #11987 by Yommy: 0 byte-identical, 1 confirmed by peer review. - fn_04750 CSoundMgr::Initialize: logic confirmed by peer review Peer-reviewed-by: KWDev, SapitoSucio, Toshiro Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Contents/Sound/SoundMgr.cpp | 45 ++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/Source/Contents/Sound/SoundMgr.cpp b/Source/Contents/Sound/SoundMgr.cpp index b446e3b8..d0913d34 100644 --- a/Source/Contents/Sound/SoundMgr.cpp +++ b/Source/Contents/Sound/SoundMgr.cpp @@ -92,8 +92,13 @@ void CSoundMgr::StopStreams() { // OFFSET: 0x00639070 // FUNCTION: fn_04750 bool CSoundMgr::Initialize() { - std::memset(this->samples, 0, sizeof(this->samples)); - std::memset(this->samples3D, 0, sizeof(this->samples3D)); + for (int i = 0; i < 48; ++i) { + this->samples[i] = nullptr; + } + + for (int i = 0; i < 48; ++i) { + this->samples3D[i] = nullptr; + } for (int i = 0; i < 64; ++i) { this->providerNames[i] = nullptr; @@ -106,15 +111,19 @@ bool CSoundMgr::Initialize() { return true; } - if (configuration.numSampleType == 0) { + switch (configuration.numSampleType) { + case 0: this->sampleCount = 48; this->sample3DCount = 48; - } else if (configuration.numSampleType == 1) { + break; + case 1: this->sampleCount = 32; this->sample3DCount = 32; - } else { + break; + default: this->sampleCount = 16; this->sample3DCount = 16; + break; } MilesRuntime& miles = MilesRuntime::Get(); @@ -125,15 +134,33 @@ bool CSoundMgr::Initialize() { this->channels = configuration.mode == 1 ? 1 : 2; - if (configuration.digitalRateType == 0) { + switch (configuration.digitalRateType) { + case 0: this->rate = 44100; - } else if (configuration.digitalRateType == 1) { + break; + case 1: this->rate = 11025; - } else { + break; + case 2: this->rate = 8000; + break; + default: + this->rate = 8000; + break; + } + + switch (configuration.digitalBitsType) { + case 0: + this->bits = 16; + break; + case 1: + this->bits = 8; + break; + default: + this->bits = 8; + break; } - this->bits = configuration.digitalBitsType == 0 ? 16 : 8; miles.setPreference(15, configuration.preference15); this->driver = miles.openDigitalDriver(this->rate, this->bits, this->channels, 1);