diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index c14fdeab..a76b1ec3 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -20694,7 +20694,7 @@ fn_80378230 = .text:0x80378230; // type:function size:0x4C fn_80378280 = .text:0x80378280; // type:function size:0x8 fn_80378290 = .text:0x80378290; // type:function size:0x68 fn_80378300 = .text:0x80378300; // type:function size:0x270 -fn_80378570 = .text:0x80378570; // type:function size:0x95C +loadCallbacks__14dSndBgmSound_cFUl = .text:0x80378570; // type:function size:0x95C fn_80378ED0 = .text:0x80378ED0; // type:function size:0xD4 fn_80378FB0 = .text:0x80378FB0; // type:function size:0x144 fn_80379100 = .text:0x80379100; // type:function size:0x19C @@ -20712,7 +20712,7 @@ fn_80379760 = .text:0x80379760; // type:function size:0xF4 fn_80379860 = .text:0x80379860; // type:function size:0x120 fn_80379980 = .text:0x80379980; // type:function size:0x158 fn_80379AE0 = .text:0x80379AE0; // type:function size:0x40 -fn_80379B20 = .text:0x80379B20; // type:function size:0x200 +loadCallbacks__20dSndBgmBattleSound_cFUl = .text:0x80379B20; // type:function size:0x200 __ct__14dSndBgmSound_cFv = .text:0x80379D20; // type:function size:0xF8 __dt__21dSndBgmSoundHarpMgr_cFv = .text:0x80379E20; // type:function size:0x58 init__14dSndBgmSound_cFRQ34nw4r3snd14SoundStartablel = .text:0x80379E80; // type:function size:0xC @@ -20750,17 +20750,17 @@ fn_8037B450 = .text:0x8037B450; // type:function size:0x18 fn_8037B470 = .text:0x8037B470; // type:function size:0x18 fn_8037B490 = .text:0x8037B490; // type:function size:0x18 fn_8037B4B0 = .text:0x8037B4B0; // type:function size:0x18 -fn_8037B4D0 = .text:0x8037B4D0; // type:function size:0x8 +isBattleBgmSound__14dSndBgmSound_cCFv = .text:0x8037B4D0; // type:function size:0x8 __ct__20dSndBgmBattleSound_cFv = .text:0x8037B4E0; // type:function size:0x58 -fn_8037B540 = .text:0x8037B540; // type:function size:0x44 -fn_8037B590 = .text:0x8037B590; // type:function size:0x7C -fn_8037B610 = .text:0x8037B610; // type:function size:0xAC +cancel__20dSndBgmBattleSound_cFv = .text:0x8037B540; // type:function size:0x44 +loadSeqConfig__20dSndBgmBattleSound_cFUl = .text:0x8037B590; // type:function size:0x7C +fadeIn__20dSndBgmBattleSound_cFUll = .text:0x8037B610; // type:function size:0xAC fn_8037B6C0 = .text:0x8037B6C0; // type:function size:0x18 fn_8037B6E0 = .text:0x8037B6E0; // type:function size:0x18 fn_8037B700 = .text:0x8037B700; // type:function size:0xB0 -fn_8037B7B0 = .text:0x8037B7B0; // type:function size:0x134 -fn_8037B8F0 = .text:0x8037B8F0; // type:function size:0x10 -fn_8037B900 = .text:0x8037B900; // type:function size:0x8 +calcSeqPlaySamplePosition__20dSndBgmBattleSound_cFv = .text:0x8037B7B0; // type:function size:0x134 +postCalc__20dSndBgmBattleSound_cFv = .text:0x8037B8F0; // type:function size:0x10 +isBattleBgmSound__20dSndBgmBattleSound_cCFv = .text:0x8037B900; // type:function size:0x8 __ct__21dSndBgmSoundHarpMgr_cFv = .text:0x8037B910; // type:function size:0x54 setSoundId__21dSndBgmSoundHarpMgr_cFUl = .text:0x8037B970; // type:function size:0x8 setLoaded__21dSndBgmSoundHarpMgr_cFv = .text:0x8037B980; // type:function size:0xC @@ -38040,7 +38040,7 @@ lbl_80549068 = .data:0x80549068; // type:object size:0x10 lbl_80549078 = .data:0x80549078; // type:object size:0x10 lbl_80549088 = .data:0x80549088; // type:object size:0x34 __vt__14dSndBgmSound_c = .data:0x805490BC; // type:object size:0x44 -lbl_80549100 = .data:0x80549100; // type:object size:0x48 +__vt__20dSndBgmBattleSound_c = .data:0x80549100; // type:object size:0x48 __vt__37SndMgrDisposer<19dSndBgmSeqDataMgr_c> = .data:0x80549148; // type:object size:0xC scope:weak __vt__18dSndBgmMmlParser_c = .data:0x80549158; // type:object size:0x10 lbl_80549168 = .data:0x80549168; // type:object size:0x10 diff --git a/include/d/snd/d_snd_bgm_sound battle.h b/include/d/snd/d_snd_bgm_sound battle.h deleted file mode 100644 index ad67643c..00000000 --- a/include/d/snd/d_snd_bgm_sound battle.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef D_SND_BGM_SOUND_BATTLE_H -#define D_SND_BGM_SOUND_BATTLE_H - -#include "d/snd/d_snd_bgm_sound.h" - -class dSndBgmBattleSound_c : public dSndBgmSound_c { -public: - dSndBgmBattleSound_c(); -}; - -#endif diff --git a/include/d/snd/d_snd_bgm_sound.h b/include/d/snd/d_snd_bgm_sound.h index 0f01dcb7..4e76137c 100644 --- a/include/d/snd/d_snd_bgm_sound.h +++ b/include/d/snd/d_snd_bgm_sound.h @@ -32,12 +32,14 @@ public: virtual void pause(bool pauseFlag, s32 fadeFrames) override; // vt 0x24 virtual void init(nw4r::snd::SoundStartable &startable, s32 idx); // vt 0x28 - virtual void vt_0x2C(); // vt 0x2C - virtual void pause(s32 fadeFrames); // vt 0x30 - virtual void loadSeqConfig(u32 soundId); // vt 0x34 - virtual void postCalc() {} // vt 0x38 - virtual void calcSeqPlaySamplePosition(); // vt 0x3C - virtual void loadCallbacks(u32 soundId); // vt 0x40 + virtual bool isBattleBgmSound() const { + return false; + } // vt 0x2C + virtual void pause(s32 fadeFrames); // vt 0x30 + virtual void loadSeqConfig(u32 soundId); // vt 0x34 + virtual void postCalc() {} // vt 0x38 + virtual void calcSeqPlaySamplePosition(); // vt 0x3C + virtual void loadCallbacks(u32 soundId); // vt 0x40 nw4r::snd::SoundStartable::StartResult startBgmSound(u32 soundId, s32 fadeFrames, u32 startOffset); @@ -58,7 +60,7 @@ public: u32 getStrmPlaySamplePosition(); u32 getWavePlaySamplePosition(); -private: +protected: void getHarpData(u32 soundId); bool loadNewHarpData(u32 soundId); diff --git a/include/d/snd/d_snd_bgm_sound_battle.h b/include/d/snd/d_snd_bgm_sound_battle.h new file mode 100644 index 00000000..047832e5 --- /dev/null +++ b/include/d/snd/d_snd_bgm_sound_battle.h @@ -0,0 +1,31 @@ +#ifndef D_SND_BGM_SOUND_BATTLE_H +#define D_SND_BGM_SOUND_BATTLE_H + +#include "d/snd/d_snd_bgm_sound.h" +#include "d/snd/d_snd_types.h" + +class dSndBgmBattleSound_c : public dSndBgmSound_c { +public: + dSndBgmBattleSound_c(); + + virtual void cancel() override; // vt 0x08 + virtual void fadeIn(u32 id, s32 fadeFrames) override; // vt 0x10 + virtual bool isBattleBgmSound() const override { + return true; + } // vt 0x2C + virtual void loadSeqConfig(u32 soundId) override; // vt 0x34 + virtual void postCalc() override { + calcSeqPlaySamplePosition(); + } // vt 0x38 + virtual void calcSeqPlaySamplePosition() override; // vt 0x3C + virtual void loadCallbacks(u32 soundId) override; // vt 0x40 + +private: + /* 0x184 */ const dSndBgmBattleConfig *mpBgmBattleConfig; + /* 0x188 */ u32 mMuteApplyStateMask; + /* 0x18C */ u32 mTickRelated; + /* 0x190 */ u8 field_0x190; + /* 0x191 */ u8 field_0x191; +}; + +#endif diff --git a/include/d/snd/d_snd_types.h b/include/d/snd/d_snd_types.h index 2533df67..901074b6 100644 --- a/include/d/snd/d_snd_types.h +++ b/include/d/snd/d_snd_types.h @@ -24,5 +24,6 @@ class dSndBgmBattleSound_c; class dSndBgmSoundHarpMgr_c; class dSndBgmSeqConfig; +class dSndBgmBattleConfig; #endif diff --git a/src/d/snd/d_snd_bgm_sound_battle.cpp b/src/d/snd/d_snd_bgm_sound_battle.cpp new file mode 100644 index 00000000..d3b604c5 --- /dev/null +++ b/src/d/snd/d_snd_bgm_sound_battle.cpp @@ -0,0 +1,46 @@ +#include "d/snd/d_snd_bgm_sound_battle.h" + +#include "common.h" +#include "d/snd/d_snd_bgm_seq_config.h" +#include "d/snd/d_snd_bgm_sound.h" +#include "d/snd/d_snd_mgr.h" +#include "d/snd/d_snd_wzsound.h" + +dSndBgmBattleSound_c::dSndBgmBattleSound_c() + : mpBgmBattleConfig(nullptr), mMuteApplyStateMask(0), mTickRelated(0), field_0x190(0), field_0x191(1) {} + +void dSndBgmBattleSound_c::cancel() { + dSndBgmSound_c::cancel(); + mMuteApplyStateMask = 0; + mTickRelated = 0; + field_0x190 = 0; + field_0x191 = 1; +} + +void dSndBgmBattleSound_c::loadSeqConfig(u32 soundId) { + if (dSndMgr_c::GetInstance()->getArchive()->GetSoundType(soundId) == nw4r::snd::SoundArchive::SOUND_TYPE_SEQ) { + if (soundId == BGM_BATTLE2) { + mpSeqConfig = dSndBgmSeqConfig::getConfig(soundId, 0); + } + + if (mpSeqConfig == nullptr) { + mpSeqConfig = dSndBgmSeqConfig::getConfig(soundId, 1); + } + } +} + +void dSndBgmBattleSound_c::fadeIn(u32 id, s32 fadeFrames) { + if (id == -1) { + return; + } + + // TODO - hmmm + mpBgmBattleConfig = nullptr; + mpBgmBattleConfig = dSndBgmBattleConfig::getConfig(GetId()); + + dSndBgmSound_c::fadeIn(id, fadeFrames); + + if (GetId() != BGM_BATTLE2) { + field_0x191 = 0; + } +}