d_snd_mgr OK

This commit is contained in:
robojumper
2025-07-10 23:21:46 +02:00
parent 84538b4ce0
commit ba3092ca92
25 changed files with 347 additions and 116 deletions
+2 -2
View File
@@ -9,8 +9,8 @@
#include "d/d_lyt_hio.h"
#include "d/lyt/d_textbox.h"
#include "d/lyt/msg_window/d_lyt_msg_window.h"
#include "d/snd/d_snd_fi_vocal_mgr.h"
#include "m/m_vec.h"
#include "toBeSorted/other_sound_stuff.h"
TextWindowUnk::TextWindowUnk(dTagProcessor_c *c) {
mpTagProcessor = c;
@@ -45,7 +45,7 @@ bool TextWindowUnk::fn_800B2130(const char *label, dTextBox_c *textBox, dLytMsgW
mpTextBox, mRawTextBuffer, mUnkBuffer, field_0x1458, &field_0x1478, mpCharacterData
);
if (mpTagProcessor->getMsgWindowSubtype() == dLytMsgWindow_c::MSG_WINDOW_SWORD_FI) {
fn_803996B0(lbl_80575DE0, field_0x1402, field_0x1478, mpTagProcessor->getField_0x824());
dSndFiVocalMgr_c::GetInstance()->fiSpeak(field_0x1402, field_0x1478, mpTagProcessor->getField_0x824());
}
}
+4 -2
View File
@@ -28,6 +28,7 @@
// clang-format on
#include "d/d_gfx.h"
#include "d/snd/d_snd_fi_vocal_mgr.h"
#include "d/snd/d_snd_player_mgr.h"
#include "d/snd/d_snd_small_effect_mgr.h"
#include "f/f_base.h"
@@ -38,7 +39,6 @@
#include "toBeSorted/d_d3d.h"
#include "toBeSorted/event_manager.h"
#include "toBeSorted/fi_context.h"
#include "toBeSorted/other_sound_stuff.h"
#include <cstring>
@@ -309,7 +309,9 @@ void dLytMsgWindow_c::executeState_OutputText() {
if (mpTagProcessor->getMsgWindowSubtype() >= MSG_WINDOW_SWORD_FI &&
mpTagProcessor->getMsgWindowSubtype() < MSG_WINDOW_SWORD_FI + 3) {
fn_803998A0(lbl_80575DE0, mpMsgWindowUnk->getField_0x147A(), mpMsgWindowUnk->getField_0x147C());
dSndFiVocalMgr_c::GetInstance()->executeOutputText(
mpMsgWindowUnk->getField_0x147A(), mpMsgWindowUnk->getField_0x147C()
);
} else if (mpTagProcessor->getMsgWindowSubtype() <= MSG_WINDOW_1 && oldValue != mpMsgWindowUnk->getField_0x147A()) {
u16 a = mpMsgWindowUnk->getField_0x147C();
f32 b = (dTagProcessor_c::fn_800B8040(0, 0) * 100.0f);
+1 -1
View File
@@ -23,7 +23,7 @@ u32 dSndBgmSeqDataMgr_c::getDataPrefixLength() {
return std::strlen(getDataPrefix());
}
void dSndBgmSeqDataMgr_c::initialize() {
void dSndBgmSeqDataMgr_c::setup() {
// no-op
}
+1 -1
View File
@@ -19,7 +19,7 @@ dSndDistantSoundActorPool_c::dSndDistantSoundActorPool_c() {
sParam.reset(INFINITY);
}
void dSndDistantSoundActorPool_c::initialize() {
void dSndDistantSoundActorPool_c::setup() {
field_0x4210 = 0;
for (int i = 0; i < POOL_SIZE; i++) {
mSounds[i].loadDefaultParam();
+7
View File
@@ -0,0 +1,7 @@
#include "d/snd/d_snd_fi_vocal_mgr.h"
#include "d/snd/d_snd_util.h"
SND_DISPOSER_DEFINE(dSndFiVocalMgr_c);
dSndFiVocalMgr_c::dSndFiVocalMgr_c() {}
+7
View File
@@ -0,0 +1,7 @@
#include "d/snd/d_snd_harp_song_mgr.h"
#include "d/snd/d_snd_util.h"
SND_DISPOSER_DEFINE(dSndHarpSongMgr_c);
dSndHarpSongMgr_c::dSndHarpSongMgr_c() {}
+48 -8
View File
@@ -1,11 +1,14 @@
#include "d/snd/d_snd_mgr.h"
#include "common.h"
#include "d/snd/d_snd_3d_manager.h"
#include "d/snd/d_snd_area_sound_effect_mgr.h"
#include "d/snd/d_snd_bgm_mgr.h"
#include "d/snd/d_snd_bgm_seq_data_mgr.h"
#include "d/snd/d_snd_control_player_mgr.h"
#include "d/snd/d_snd_distant_sound_actor_pool.h"
#include "d/snd/d_snd_fi_vocal_mgr.h"
#include "d/snd/d_snd_harp_song_mgr.h"
#include "d/snd/d_snd_player_mgr.h"
#include "d/snd/d_snd_rng_mgr.h"
#include "d/snd/d_snd_se_sound_pool.h"
@@ -14,13 +17,11 @@
#include "d/snd/d_snd_state_mgr.h"
#include "egg/audio/eggAudioRmtSpeakerMgr.h"
#include "egg/audio/eggAudioUtility.h"
extern "C" void fn_8037F940();
extern "C" void fn_80399600();
#include "nw4r/snd/snd_SoundSystem.h"
dSndMgr_c *dSndMgr_c::sInstance;
dSndMgr_c::dSndMgr_c() : field_0x6CC(0) {
dSndMgr_c::dSndMgr_c() : mIsInitialized(false) {
sInstance = this;
dSndPlayerMgr_c::create();
dSndControlPlayerMgr_c::create();
@@ -33,24 +34,63 @@ dSndMgr_c::dSndMgr_c() : field_0x6CC(0) {
dSndSourceMgr_c::create();
dSndDistantSoundActorPool_c::create();
dSndSeSoundPool_c::create();
fn_8037F940();
fn_80399600();
dSndHarpSongMgr_c::create();
dSndFiVocalMgr_c::create();
dSndRngMgr_c::create();
initHbm(9);
}
void dSndMgr_c::initialize(EGG::Heap *heap, u32 size) {}
void dSndMgr_c::setup(EGG::Heap *heap, u32 size) {
if (mIsInitialized) {
return;
}
SimpleAudioMgrArg arg;
arg.heap = heap;
arg.soundFileName = dSndPlayerMgr_c::GetInstance()->getSoundArchivePath();
// TODO - how is this calculated?
arg.field_0x1C = size + 0x1400;
arg.blocks = 2;
initialize(&arg);
mOutputMode = nw4r::snd::SoundSystem::GetOutputMode();
dSndPlayerMgr_c::GetInstance()->setup();
dSndStateMgr_c::GetInstance()->setup(heap);
dSndBgmMgr_c::GetInstance()->setup(heap);
dSndBgmSeqDataMgr_c::GetInstance()->setup();
dSndDistantSoundActorPool_c::GetInstance()->setup();
dSndHarpSongMgr_c::GetInstance()->setup();
dSndSourceMgr_c::GetInstance()->setup();
EGG::AudioRmtSpeakerMgr::setup(0, nullptr);
mIsInitialized = true;
}
void dSndMgr_c::initHbm(u32 frame) {
EGG::AudioUtility::HBM::init(this, restoreEffectsCallback, frame);
}
void dSndMgr_c::calc() {
if (field_0x6CC) {
if (mIsInitialized) {
EGG::SimpleAudioMgr::calc();
EGG::AudioRmtSpeakerMgr::calc();
dSndPlayerMgr_c::GetInstance()->calc();
if (dSndPlayerMgr_c::GetInstance()->isInit()) {
dSndSmallEffectMgr_c::GetInstance()->calcTimer();
if (!dSndPlayerMgr_c::GetInstance()->checkFlag(dSndPlayerMgr_c::MGR_HBM)) {
dSndControlPlayerMgr_c::GetInstance()->calc();
if (!dSndPlayerMgr_c::GetInstance()->checkFlag(dSndPlayerMgr_c::MGR_CAUTION)) {
dSndStateMgr_c::GetInstance()->calc();
dSndPlayerMgr_c::GetInstance()->calcActive();
dSnd3DManager_c::GetInstance()->calc();
dSndSmallEffectMgr_c::GetInstance()->calc();
dSndBgmMgr_c::GetInstance()->calc();
dSndAreaSoundEffectMgr_c::GetInstance()->calc();
dSndHarpSongMgr_c::GetInstance()->calc();
dSndSeSoundPool_c::GetInstance()->calc();
}
}
}
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ void dSndSourceObj_c::postSetup() {
}
if ((isName("TDoor") || isName("Wind") || isName("Flag")) &&
dSndStateMgr_c::GetInstance()->getField_0x058() >= 13) {
dSndStateMgr_c::GetInstance()->getLayer() >= 13) {
setVolumeFade(0.0f, 0);
}
}
+101 -11
View File
@@ -1,6 +1,7 @@
#include "d/snd/d_snd_state_mgr.h"
#include "common.h"
#include "d/a/d_a_player.h"
#include "d/d_camera.h"
#include "d/d_sc_game.h"
#include "d/snd/d_snd_area_sound_effect_mgr.h"
@@ -10,9 +11,11 @@
#include "d/snd/d_snd_event.h"
#include "d/snd/d_snd_mgr.h"
#include "d/snd/d_snd_player_mgr.h"
#include "d/snd/d_snd_small_effect_mgr.h"
#include "d/snd/d_snd_source_mgr.h"
#include "d/snd/d_snd_stage_data.h"
#include "d/snd/d_snd_util.h"
#include "d/snd/d_snd_wzsound.h"
#include "egg/core/eggHeap.h"
#include "nw4r/snd/snd_FxReverbStdDpl2.h"
#include "nw4r/snd/snd_SeqSoundHandle.h"
@@ -34,8 +37,8 @@ dSndStateMgr_c::dSndStateMgr_c()
mStageId(0xAC),
mPreviousStageId(0xAC),
field_0x054(0),
field_0x058(0),
mLayer(-1),
mLayer(0),
mRoomId(-1),
field_0x060(0),
field_0x064(0),
field_0x065(false),
@@ -53,7 +56,7 @@ dSndStateMgr_c::dSndStateMgr_c()
mSoundEventId(SND_EVENT_0x89),
mCameraCutCounter(0),
mEventFlags(0),
field_0x118(nullptr),
mpStbEventName(nullptr),
mFrameCounter(0),
mCameraCutFrameCounter(0),
mMsgFrameCounter(0),
@@ -243,12 +246,12 @@ void dSndStateMgr_c::setEvent(const char *eventName) {
field_0x238 = -1;
if (streq(mEventName, "STB")) {
if (field_0x118 != nullptr) {
mEventName = field_0x118;
if (mpStbEventName != nullptr) {
mEventName = mpStbEventName;
}
onEventFlag(EVENT_DEMO);
} else {
field_0x118 = nullptr;
mpStbEventName = nullptr;
}
if (!checkFlag0x10(0x04)) {
@@ -273,13 +276,13 @@ void dSndStateMgr_c::setEvent(const char *eventName) {
s32 i3 = 0;
SizedString<64> eventLabel;
if (mSoundEventId == SND_EVENT_JMAP) {
s32 roomId = EventManager::getCurrentEventRoomId();
s32 eventRoomId = EventManager::getCurrentEventRoomId();
// UB: Cannot pass object of non-POD type 'SizedString<32>' through variadic method
eventLabel.sprintf("%s_R%d_JMAP_%d", mStageName, mLayer, roomId);
eventLabel.sprintf("%s_R%d_JMAP_%d", mStageName, mRoomId, eventRoomId);
} else if (mSoundEventId == SND_EVENT_JMAPAllMove) {
s32 roomId = EventManager::getCurrentEventRoomId();
s32 eventRoomId = EventManager::getCurrentEventRoomId();
// UB: Cannot pass object of non-POD type 'SizedString<32>' through variadic method
eventLabel.sprintf("%s_R%d_JMAPAllMove_%d", mStageName, mLayer, roomId);
eventLabel.sprintf("%s_R%d_JMAPAllMove_%d", mStageName, mRoomId, eventRoomId);
} else {
eventLabel.sprintf("%s", &mEventName);
}
@@ -418,7 +421,8 @@ bool dSndStateMgr_c::finalizeEvent(bool skipped) {
SoundStopperIfParamFlag20 stopper;
p->ForEachSound(stopper, false);
}
// TODO ...
// ...
return false;
}
@@ -490,6 +494,92 @@ void dSndStateMgr_c::onMsgWaitEnd() {
doLabelSuffix(label);
}
void dSndStateMgr_c::onLinkDie() {
if (!checkFlag0x10(0x8)) {
onFlag0x10(0x8);
dSndBgmMgr_c::GetInstance()->stopAllBgm(15);
dSndSmallEffectMgr_c::GetInstance()->stopAllSoundExceptEffectOrLink(15);
if (field_0x065 == 0) {
dSndBgmMgr_c::GetInstance()->prepareFanSound(FAN_GAMEOVER);
}
}
}
void dSndStateMgr_c::setStbEventName(const char *eventName) {
mpStbEventName = eventName;
}
void dSndStateMgr_c::calcRoomId() {
if (checkFlag0x10(4)) {
if (field_0x060 > 0) {
field_0x060--;
} else {
if (mRoomId == -1) {
field_0x060 = 30;
}
s32 newRoom = dSndSourceMgr_c::GetInstance()->getPlayerSourceRoomId();
if (mRoomId != newRoom) {
setRoomId(newRoom);
} else if (newRoom != -1 && !checkFlag0x10(0x10)) {
setRoomId(newRoom);
}
}
}
}
void dSndStateMgr_c::setRoomId(s32 roomId) {
// ...
}
void dSndStateMgr_c::calcTgSnd() {
// ...
}
void dSndStateMgr_c::calcFilters() {
dCamera_c *cam = dScGame_c::getCamera(0);
if (cam != nullptr && !checkFlag0x258(0x2)) {
if (cam->isUnderwater()) {
if (!checkFlag0x258(0x1)) {
resetFlag0x258();
onFlag0x258(1);
setFiltersIfUnderwater();
}
f32 depth = cam->getUnderwaterDepth();
dSndAreaSoundEffectMgr_c::GetInstance()->holdInWaterLvSound(depth);
f32 maxDepth = isInStage("F103") ? 5000.0f : 1000.0f;
f32 unk = isInStage("F103") ? 0.5f : 0.3f;
if (depth < maxDepth) {
f32 tmp = (1.0f - unk);
f32 tmp2 = (depth / maxDepth);
unk = 1.0f - tmp2 * tmp;
}
dSndBgmMgr_c::GetInstance()->updateField_0x2F4(unk);
} else {
if (checkFlag0x258(0x1)) {
offFlag0x258(1);
resetLpfAndFxSend();
}
if (dAcPy_c::GetLink()->checkActionFlagsCont(0x400000)) {
if (!checkFlag0x258(0x4)) {
resetFlag0x258();
onFlag0x258(0x4);
setBgmAndStageEffectLpf();
dSndBgmMgr_c::GetInstance()->setField_0x307(0);
}
} else {
if (checkFlag0x258(0x4)) {
offFlag0x258(0x4);
resetBgmAndStageEffectLpf();
if (dSndBgmMgr_c::GetInstance()->getField_0x308() != 0) {
dSndBgmMgr_c::GetInstance()->setField_0x307(1);
}
}
}
}
}
}
void dSndStateMgr_c::setFiltersIfUnderwater() {
dCamera_c *cam = dScGame_c::getCamera(0);
if (cam == nullptr || cam->isUnderwater()) {