diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index fa59aed5..e6d865bf 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -19928,7 +19928,7 @@ setup__15dSndPlayerMgr_cFv = .text:0x8035DC00; // type:function size:0x44 initialize__15dSndPlayerMgr_cFv = .text:0x8035DC50; // type:function size:0x8C createFileManager__15dSndPlayerMgr_cFv = .text:0x8035DCE0; // type:function size:0x38 calcActive__15dSndPlayerMgr_cFv = .text:0x8035DD20; // type:function size:0x4 -fn_8035DD30 = .text:0x8035DD30; // type:function size:0x10 +clearTempStates__15dSndPlayerMgr_cFv = .text:0x8035DD30; // type:function size:0x10 setupState0__15dSndPlayerMgr_cFv = .text:0x8035DD40; // type:function size:0xC0 popToState0__15dSndPlayerMgr_cFv = .text:0x8035DE00; // type:function size:0x54 saveState1__15dSndPlayerMgr_cFv = .text:0x8035DE60; // type:function size:0x38 @@ -19936,14 +19936,14 @@ popToState1__15dSndPlayerMgr_cFv = .text:0x8035DEA0; // type:function size:0x50 saveState2__15dSndPlayerMgr_cFv = .text:0x8035DEF0; // type:function size:0x38 popToState2__15dSndPlayerMgr_cFv = .text:0x8035DF30; // type:function size:0x24 getFreeSize__15dSndPlayerMgr_cFv = .text:0x8035DF60; // type:function size:0x54 -fn_8035DFC0 = .text:0x8035DFC0; // type:function size:0x3C +stopAllSound__15dSndPlayerMgr_cFl = .text:0x8035DFC0; // type:function size:0x3C fn_8035E000 = .text:0x8035E000; // type:function size:0xD4 fn_8035E0E0 = .text:0x8035E0E0; // type:function size:0xCC -fn_8035E1B0__15dSndPlayerMgr_cFUs = .text:0x8035E1B0; // type:function size:0x68 -fn_8035E220__15dSndPlayerMgr_cFv = .text:0x8035E220; // type:function size:0x2C -fn_8035E250__15dSndPlayerMgr_cFUs = .text:0x8035E250; // type:function size:0x8C -fn_8035E2E0__15dSndPlayerMgr_cFv = .text:0x8035E2E0; // type:function size:0x2C -fn_8035E310__15dSndPlayerMgr_cFv = .text:0x8035E310; // type:function size:0x50 +shutdown__15dSndPlayerMgr_cFl = .text:0x8035E1B0; // type:function size:0x68 +isShutdown__15dSndPlayerMgr_cFv = .text:0x8035E220; // type:function size:0x2C +reset__15dSndPlayerMgr_cFl = .text:0x8035E250; // type:function size:0x8C +isReset__15dSndPlayerMgr_cFv = .text:0x8035E2E0; // type:function size:0x2C +recoverReset__15dSndPlayerMgr_cFv = .text:0x8035E310; // type:function size:0x50 enterPauseState__15dSndPlayerMgr_cFv = .text:0x8035E360; // type:function size:0x70 leavePauseState__15dSndPlayerMgr_cFv = .text:0x8035E3D0; // type:function size:0x70 enterMenu__15dSndPlayerMgr_cFv = .text:0x8035E440; // type:function size:0x2C @@ -19960,8 +19960,8 @@ setMsgActor__15dSndPlayerMgr_cFlP9dAcBase_c = .text:0x8035E790; // type:function unsetMsgActor__15dSndPlayerMgr_cFv = .text:0x8035E820; // type:function size:0x38 enterMsgWait__15dSndPlayerMgr_cFv = .text:0x8035E860; // type:function size:0x14 leaveMsgWait__15dSndPlayerMgr_cFv = .text:0x8035E880; // type:function size:0x14 -setup__15dSndPlayerMgr_cFl = .text:0x8035E8A0; // type:function size:0xC -shutdown__15dSndPlayerMgr_cFl = .text:0x8035E8B0; // type:function size:0xC +setupRmtSpeaker__15dSndPlayerMgr_cFl = .text:0x8035E8A0; // type:function size:0xC +shutdownRmtSpeaker__15dSndPlayerMgr_cFl = .text:0x8035E8B0; // type:function size:0xC startSound__15dSndPlayerMgr_cFPQ34nw4r3snd11SoundHandleUlPCQ44nw4r3snd14SoundStartable9StartInfo = .text:0x8035E8C0; // type:function size:0x90 startSound__15dSndPlayerMgr_cFPQ34nw4r3snd11SoundHandlePCcPCQ44nw4r3snd14SoundStartable9StartInfo = .text:0x8035E950; // type:function size:0x6C startDemoSound__15dSndPlayerMgr_cFPQ34nw4r3snd11SoundHandleUlPCQ44nw4r3snd14SoundStartable9StartInfo = .text:0x8035E9C0; // type:function size:0x80 @@ -26858,9 +26858,9 @@ exit__Q33EGG12AudioUtility3HBMFb = .text:0x804B70E0; // type:function size:0x120 __sinit_\eggAudioUtility_cpp = .text:0x804B7200; // type:function size:0xC scope:local __ct__Q23EGG11AudioSystemFv = .text:0x804B7210; // type:function size:0x1C __dt__Q23EGG11AudioSystemFv = .text:0x804B7230; // type:function size:0x40 -fn_804B7270__Q23EGG11AudioSystemFl = .text:0x804B7270; // type:function size:0xF8 -fn_804B7370__Q23EGG11AudioSystemFv = .text:0x804B7370; // type:function size:0x60 -fn_804B73D0__Q23EGG11AudioSystemFl = .text:0x804B73D0; // type:function size:0x78 +reset__Q23EGG11AudioSystemFl = .text:0x804B7270; // type:function size:0xF8 +recoverReset__Q23EGG11AudioSystemFv = .text:0x804B7370; // type:function size:0x60 +shutdown__Q23EGG11AudioSystemFl = .text:0x804B73D0; // type:function size:0x78 calc__Q23EGG11AudioSystemFv = .text:0x804B7450; // type:function size:0xF4 ExceptionWaitTime__Q23EGG9ExceptionFUl = .text:0x804B7550; // type:function size:0x78 ExceptionCallback__Q23EGG9ExceptionFPQ44nw4r2db6detail11ConsoleHeadPv = .text:0x804B75D0; // type:function size:0x58 diff --git a/include/d/snd/d_snd_bgm_mgr.h b/include/d/snd/d_snd_bgm_mgr.h index 604524c3..ff8a31d7 100644 --- a/include/d/snd/d_snd_bgm_mgr.h +++ b/include/d/snd/d_snd_bgm_mgr.h @@ -112,6 +112,10 @@ public: field_0x306 = val; } + void setField_0x300(s32 v) { + field_0x300 = v; + } + void setField_0x307(u8 val) { field_0x307 = val; } diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h index 9b90a233..67ba6eb4 100644 --- a/include/d/snd/d_snd_player_mgr.h +++ b/include/d/snd/d_snd_player_mgr.h @@ -26,8 +26,16 @@ public: public: dSndPlayerMgr_c(); - void setup(s32 channel); - void shutdown(s32 channel); + void shutdown(s32 frames); + bool isShutdown(); + void reset(s32 frames); + bool isReset(); + void recoverReset(); + + void setupRmtSpeaker(s32 channel); + void shutdownRmtSpeaker(s32 channel); + + void clearTempStates(); void setup(); void shutdownDemo(); @@ -92,7 +100,7 @@ public: enum PlayerMgrFlag_e { MGR_HBM = 0x1, - MGR_UNK_0x2 = 0x2, + MGR_SHUTDOWN_RESET = 0x2, MGR_PAUSE = 0x4, MGR_MAP = 0x8, MGR_HELP = 0x10, @@ -206,12 +214,15 @@ public: private: /* 0x010 */ u8 field_0x010; - /* 0x011 */ u8 field_0x011; + /* 0x011 */ bool mIsSetup; /* 0x014 */ s32 mState0; /* 0x018 */ s32 mState1; /* 0x01C */ s32 mState2; /* 0x020 */ u32 mFlags; + void stopAllSound(s32 frames); + void fn_8035E0E0(); + // system menu, inventory, map void enterPauseState(); void leavePauseState(); diff --git a/include/egg/audio/eggAudioMgr.h b/include/egg/audio/eggAudioMgr.h index ffc6e9a4..e2a064b2 100644 --- a/include/egg/audio/eggAudioMgr.h +++ b/include/egg/audio/eggAudioMgr.h @@ -14,7 +14,7 @@ public: virtual StartResult detail_SetupSound(nw4r::snd::SoundHandle *pHandle, u32 id, bool hold, const StartInfo *pStartInfo) override { if (AudioSystem::sInstanse != nullptr && - (AudioSystem::sInstanse->field0x08NotZero() || AudioSystem::sInstanse->field0x04NotZero())) { + (AudioSystem::sInstanse->isShuttingDown() || AudioSystem::sInstanse->isResetting())) { return START_ERR_USER; } return nw4r::snd::SoundArchivePlayer::detail_SetupSound(pHandle, id, hold, pStartInfo); diff --git a/include/egg/audio/eggAudioSystem.h b/include/egg/audio/eggAudioSystem.h index 69791333..80f4ea73 100644 --- a/include/egg/audio/eggAudioSystem.h +++ b/include/egg/audio/eggAudioSystem.h @@ -10,29 +10,34 @@ public: AudioSystem(); ~AudioSystem(); - void fn_804B7270(s32 frame); - void fn_804B7370(); - void fn_804B73D0(s32 frame); + void reset(s32 ms); + void recoverReset(); + void shutdown(s32 ms); void calc(); - bool isField0x04Eq2() { - return field_0x04 == 2; + // Non-official inline names + bool isReset() { + return mResetStatus == 2; } - bool field0x08NotZero() { - return field_0x08 != 0; + bool isShutdown() { + return mShutdownStatus == 2; } - bool field0x04NotZero() { - return field_0x04 != 0; + bool isShuttingDown() { + return mShutdownStatus != 0; + } + + bool isResetting() { + return mResetStatus != 0; } static AudioSystem *sInstanse; ///< sic private: - f32 field_0x00; - s32 field_0x04; - s32 field_0x08; + /* 0x00 */ f32 mSavedMasterVolume; + /* 0x04 */ s32 mResetStatus; + /* 0x08 */ s32 mShutdownStatus; }; } // namespace EGG diff --git a/include/rvl/AX/AXComp.h b/include/rvl/AX/AXComp.h index b389fde8..8cc2552f 100644 --- a/include/rvl/AX/AXComp.h +++ b/include/rvl/AX/AXComp.h @@ -6,6 +6,7 @@ extern "C" { #endif extern u16 __AXCompressorTable[]; +void AXSetCompressor(BOOL); #ifdef __cplusplus } diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h deleted file mode 100644 index c0d9be19..00000000 --- a/include/toBeSorted/music_mgrs.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef MUSIC_MGRS_H -#define MUSIC_MGRS_H - -#include "common.h" -#include "d/snd/d_snd_player_mgr.h" - -// A lot of these names are and were guesses that are probably wrong in a lot of ways. - -#define BGM_MGR (dSndPlayerMgr_c::GetInstance()) -extern "C" void fn_8035E000(); -extern "C" void fn_8035E860(dSndPlayerMgr_c *); -extern "C" void fn_8035E820(dSndPlayerMgr_c *); -extern "C" void fn_8035E880(dSndPlayerMgr_c *); -extern "C" void fn_8035E310(dSndPlayerMgr_c *); - -#endif diff --git a/src/d/d_pad.cpp b/src/d/d_pad.cpp index 0508dbaf..efc067d1 100644 --- a/src/d/d_pad.cpp +++ b/src/d/d_pad.cpp @@ -299,12 +299,12 @@ void endPad_BR() { void connectCallback(const EGG::CoreControllerConnectArg &rArg) { switch (rArg.result) { case WPAD_ERR_OK: { - dSndPlayerMgr_c::GetInstance()->setup(rArg.chan); + dSndPlayerMgr_c::GetInstance()->setupRmtSpeaker(rArg.chan); ex_c::m_ex[rArg.chan].mDidConnect = true; break; } case WPAD_ERR_NO_CONTROLLER: { - dSndPlayerMgr_c::GetInstance()->shutdown(rArg.chan); + dSndPlayerMgr_c::GetInstance()->shutdownRmtSpeaker(rArg.chan); ex_c::m_ex[rArg.chan].mDidDisconnect = true; break; } diff --git a/src/d/d_reset.cpp b/src/d/d_reset.cpp index 457b8ac1..536eb4c5 100644 --- a/src/d/d_reset.cpp +++ b/src/d/d_reset.cpp @@ -116,7 +116,7 @@ void Manage_c::BootComplete(bool complete) { bool Manage_c::CanExecSoftReset() const { return mMode == SoftReset && mpFader->getStatus() == EGG::Fader::STATUS_PREPARE_IN && field_0x60 == 0 && dHbm::Manage_c::GetInstance()->getState() != dHbm::Manage_c::HBM_MANAGE_ACTIVE && - dSndPlayerMgr_c::GetInstance()->fn_8035E2E0() && FileManager::GetInstance()->getField_0xA84D() != 1; + dSndPlayerMgr_c::GetInstance()->isReset() && FileManager::GetInstance()->getField_0xA84D() != 1; } void Manage_c::SetSoftResetFinish() { @@ -306,15 +306,15 @@ void Manage_c::ModeInit_SoftReset() { mpFader->setFrame(30); mpFader->fadeOut(); field_0x66 = true; - dSndPlayerMgr_c::GetInstance()->fn_8035E250(30); + dSndPlayerMgr_c::GetInstance()->reset(30); } else { field_0x60 = 0; if (dTitleMgr_c::GetInstance()) { if (dTitleMgr_c::GetInstance()->getField_0xBC() == 0) { - dSndPlayerMgr_c::GetInstance()->fn_8035E250(30); + dSndPlayerMgr_c::GetInstance()->reset(30); } } else { - dSndPlayerMgr_c::GetInstance()->fn_8035E250(30); + dSndPlayerMgr_c::GetInstance()->reset(30); } THPPlayerSetVolume(0, 60); mpFader->setFrame(30); @@ -332,7 +332,7 @@ void Manage_c::ModeProc_SoftReset() { dScBoot_c::GetInstance()->setField_0x5E4(false); mpFader->setStatus(EGG::ColorFader::STATUS_PREPARE_OUT); ModeRequest(Normal); - dSndPlayerMgr_c::GetInstance()->fn_8035E310(); + dSndPlayerMgr_c::GetInstance()->recoverReset(); } else { if (field_0x66) { dScBoot_c::GetInstance()->setField_0x5E3(true); @@ -476,14 +476,14 @@ void Manage_c::ModeProc_FatalError() {} void Manage_c::ModeInit_SafetyWait() { DebugPrintMode("SafetyWait"); - dSndPlayerMgr_c::GetInstance()->fn_8035E1B0(30); + dSndPlayerMgr_c::GetInstance()->shutdown(30); mpFader->setFrame(30); mpFader->fadeOut(); } void Manage_c::ModeProc_SafetyWait() { if (mpFader->getStatus() == EGG::Fader::STATUS_PREPARE_IN) { - bool b = dSndPlayerMgr_c::GetInstance()->fn_8035E220() && !FileManager::GetInstance()->getField_0xA84D(); + bool b = dSndPlayerMgr_c::GetInstance()->isShutdown() && !FileManager::GetInstance()->getField_0xA84D(); if (b) { ExecProcPre(); fn_80068070(); diff --git a/src/d/d_sc_title.cpp b/src/d/d_sc_title.cpp index 653e3c22..7d261e9f 100644 --- a/src/d/d_sc_title.cpp +++ b/src/d/d_sc_title.cpp @@ -9,6 +9,7 @@ #include "d/d_reset.h" #include "d/d_sc_game.h" #include "d/d_sys.h" +#include "d/snd/d_snd_player_mgr.h" #include "d/snd/d_snd_state_mgr.h" #include "f/f_base.h" #include "f/f_profile_name.h" @@ -18,7 +19,6 @@ #include "sized_string.h" #include "toBeSorted/arc_managers/layout_arc_manager.h" #include "toBeSorted/file_manager.h" -#include "toBeSorted/music_mgrs.h" #include "toBeSorted/save_related.h" #include "toBeSorted/unk_save_time.h" @@ -97,7 +97,7 @@ int dScTitle_c::create() { SizedString<128> fntPath; fntPath.sprintf("/US/Font/%s/%s", dMessage_c::getLanguageIdentifier(), "normal_02.brfnt"); mDvd_toMainRam_normal_c::create2(&mpSkbFont, fntPath, 0, dHeap::work2Heap.heap); - BGM_MGR->fn_8035E310(); + dSndPlayerMgr_c::GetInstance()->recoverReset(); } return ret; diff --git a/src/d/lyt/d_lyt_game_over.cpp b/src/d/lyt/d_lyt_game_over.cpp index 8bb3a264..8adc393c 100644 --- a/src/d/lyt/d_lyt_game_over.cpp +++ b/src/d/lyt/d_lyt_game_over.cpp @@ -18,7 +18,6 @@ #include "toBeSorted/file_manager.h" #include "toBeSorted/minigame_mgr.h" #include "toBeSorted/misc_actor.h" -#include "toBeSorted/music_mgrs.h" STATE_DEFINE(dLytGameOver_c, Init); STATE_DEFINE(dLytGameOver_c, In); diff --git a/src/d/snd/d_snd_player_mgr.cpp b/src/d/snd/d_snd_player_mgr.cpp index 20de1ed6..893e684e 100644 --- a/src/d/snd/d_snd_player_mgr.cpp +++ b/src/d/snd/d_snd_player_mgr.cpp @@ -5,8 +5,10 @@ #include "d/a/d_a_base.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_file_mgr.h" +#include "d/snd/d_snd_harp_song_mgr.h" #include "d/snd/d_snd_id_mappers.h" #include "d/snd/d_snd_mgr.h" #include "d/snd/d_snd_small_effect_mgr.h" @@ -19,6 +21,8 @@ #include "egg/core/eggDvdRipper.h" #include "nw4r/snd/snd_SoundHandle.h" #include "nw4r/snd/snd_SoundStartable.h" +#include "nw4r/snd/snd_SoundSystem.h" +#include "rvl/AX/AXComp.h" #include "sized_string.h" const char *dSndPlayerMgr_c::getSoundArchivePath() { @@ -27,14 +31,13 @@ const char *dSndPlayerMgr_c::getSoundArchivePath() { SND_DISPOSER_DEFINE(dSndPlayerMgr_c); -dSndPlayerMgr_c::dSndPlayerMgr_c() : field_0x010(0), field_0x011(0), mState0(-1), mState1(-1), mState2(-1), mFlags(0) {} +dSndPlayerMgr_c::dSndPlayerMgr_c() : field_0x010(0), mIsSetup(false), mState0(-1), mState1(-1), mState2(-1), mFlags(0) {} -void dSndPlayerMgr_c::enterPauseState() { - dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_FAN, 0.3f, 5); - dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_AREA, 0.3f, 5); - dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_AREA_IN_WATER_LV, 0.3f, 5); - // has other effects, such as reducing BGM volume - onFlag(MGR_PAUSE); +void dSndPlayerMgr_c::setup() { + if (!mIsSetup) { + AXSetCompressor(FALSE); + mIsSetup = true; + } } void dSndPlayerMgr_c::createFileManager() { @@ -43,6 +46,14 @@ void dSndPlayerMgr_c::createFileManager() { ); } +void dSndPlayerMgr_c::calcActive() { + // no-op +} + +void dSndPlayerMgr_c::clearTempStates() { + offFlag(MGR_PAUSE | MGR_MAP | MGR_HELP | MGR_SYSTEM | MGR_MSG_WAIT); +} + void dSndPlayerMgr_c::setupState0() { if (mState0 > 0) { return; @@ -54,9 +65,11 @@ void dSndPlayerMgr_c::setupState0() { mState0 = dSndMgr_c::GetInstance()->saveState(); s32 tmpState = dSndMgr_c::GetInstance()->saveState(); - dSndMgr_c::GetInstance()->loadGroup((unsigned int)GRP_BGM_PLAY_DATA_STATIC, nullptr, 0); - // TODO - loading static play data + // This state is discarded, since all relevant data is parsed and copied out + dSndMgr_c::GetInstance()->loadGroup((unsigned int)GRP_BGM_PLAY_DATA_STATIC, nullptr, 0); + dSndBgmSeqDataMgr_c::GetInstance()->setupState0(); + dSndHarpSongMgr_c::GetInstance()->setupState0(); dSndMgr_c::GetInstance()->loadState(tmpState); } @@ -97,6 +110,61 @@ u32 dSndPlayerMgr_c::getFreeSize() { return dSndMgr_c::GetInstance()->getSoundHeap()->GetFreeSize(); } +void dSndPlayerMgr_c::stopAllSound(s32 frames) { + dSndBgmMgr_c::GetInstance()->stopAllBgm(frames); + dSndSmallEffectMgr_c::GetInstance()->stopAllSound(frames); +} + + +void dSndPlayerMgr_c::shutdown(s32 frames) { + if (mState0 >= 0) { + dSndMgr_c::GetInstance()->shutdown(frames * 2); + stopAllSound(frames); + onFlag(MGR_SHUTDOWN_RESET); + } +} + +bool dSndPlayerMgr_c::isShutdown() { + if (mState0 < 0) { + return true; + } + return dSndMgr_c::GetInstance()->isShutdown(); +} + +void dSndPlayerMgr_c::reset(s32 frames) { + if (mState0 >= 0) { + nw4r::snd::SoundSystem::SetMasterVolume(1.0f, 0); + dSndMgr_c::GetInstance()->reset(frames * 2); + stopAllSound(frames); + dSndBgmMgr_c::GetInstance()->cancelDelayedSound(); + dSndBgmMgr_c::GetInstance()->setField_0x300(-1); + onFlag(MGR_SHUTDOWN_RESET); + } +} + +bool dSndPlayerMgr_c::isReset() { + if (mState0 < 0) { + return true; + } + return dSndMgr_c::GetInstance()->isReset(); +} + +void dSndPlayerMgr_c::recoverReset() { + if (checkFlag(MGR_HBM)) { + fn_8035E0E0(); + } + dSndMgr_c::GetInstance()->recoverReset(); + offFlag(MGR_SHUTDOWN_RESET); +} + +void dSndPlayerMgr_c::enterPauseState() { + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_FAN, 0.3f, 5); + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_AREA, 0.3f, 5); + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_AREA_IN_WATER_LV, 0.3f, 5); + // has other effects, such as reducing BGM volume + onFlag(MGR_PAUSE); +} + void dSndPlayerMgr_c::leavePauseState() { dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_FAN, 1.0f, 5); dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_AREA, 1.0f, 5); @@ -136,14 +204,6 @@ void dSndPlayerMgr_c::leaveHelp() { dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_HELP_OUT); } -void dSndPlayerMgr_c::setup(s32 channel) { - EGG::AudioRmtSpeakerMgr::setup(channel, nullptr); -} - -void dSndPlayerMgr_c::shutdown(s32 channel) { - EGG::AudioRmtSpeakerMgr::shutdown(channel, nullptr); -} - void dSndPlayerMgr_c::enterSystemMenu() { if (checkFlag(MGR_CAUTION)) { return; @@ -230,10 +290,18 @@ void dSndPlayerMgr_c::leaveMsgWait() { dSndStateMgr_c::GetInstance()->onMsgWaitEnd(); } +void dSndPlayerMgr_c::setupRmtSpeaker(s32 channel) { + EGG::AudioRmtSpeakerMgr::setup(channel, nullptr); +} + +void dSndPlayerMgr_c::shutdownRmtSpeaker(s32 channel) { + EGG::AudioRmtSpeakerMgr::shutdown(channel, nullptr); +} + nw4r::snd::SoundStartable::StartResult dSndPlayerMgr_c::startSound( nw4r::snd::SoundHandle *pHandle, u32 soundId, const nw4r::snd::SoundStartable::StartInfo *pStartInfo ) { - if (checkFlag(MGR_UNK_0x2)) { + if (checkFlag(MGR_SHUTDOWN_RESET)) { return nw4r::snd::SoundStartable::START_ERR_USER; } diff --git a/src/egg/audio/eggAudioMgr.cpp b/src/egg/audio/eggAudioMgr.cpp index 9c98a801..6dd7350e 100644 --- a/src/egg/audio/eggAudioMgr.cpp +++ b/src/egg/audio/eggAudioMgr.cpp @@ -62,7 +62,7 @@ void SimpleAudioMgr::initialize(EGG::IAudioMgr::Arg *arg) { void SimpleAudioMgr::calc() { AudioSystem::calc(); - if (AudioSystem::isField0x04Eq2()) { + if (AudioSystem::isReset()) { ArcPlayer::stopAllSound(); } ArcPlayer::calc(); diff --git a/src/egg/audio/eggAudioSystem.cpp b/src/egg/audio/eggAudioSystem.cpp index 8687eb62..4bc05c1d 100644 --- a/src/egg/audio/eggAudioSystem.cpp +++ b/src/egg/audio/eggAudioSystem.cpp @@ -8,47 +8,47 @@ namespace EGG { AudioSystem *AudioSystem::sInstanse; AudioSystem::AudioSystem() { - field_0x00 = 1.0f; - field_0x08 = 0; - field_0x04 = 0; + mSavedMasterVolume = 1.0f; + mShutdownStatus = 0; + mResetStatus = 0; sInstanse = this; } AudioSystem::~AudioSystem() {} -void AudioSystem::fn_804B7270(s32 frame) { - if (field_0x08 == 0 && field_0x04 == 0) { - field_0x00 = nw4r::snd::SoundSystem::GetMasterVolume(); - nw4r::snd::SoundSystem::SetMasterVolume(0.0f, frame * 16.666667f); - field_0x04 = 1; +void AudioSystem::reset(s32 ms) { + if (mShutdownStatus == 0 && mResetStatus == 0) { + mSavedMasterVolume = nw4r::snd::SoundSystem::GetMasterVolume(); + nw4r::snd::SoundSystem::SetMasterVolume(0.0f, ms * 16.666667f); + mResetStatus = 1; } } -void AudioSystem::fn_804B7370() { - if (field_0x08 == 0) { - nw4r::snd::SoundSystem::SetMasterVolume(field_0x00, 0); - field_0x04 = 0; +void AudioSystem::recoverReset() { + if (mShutdownStatus == 0) { + nw4r::snd::SoundSystem::SetMasterVolume(mSavedMasterVolume, 0); + mResetStatus = 0; } } -void AudioSystem::fn_804B73D0(s32 frame) { - if (field_0x08 == 0) { - field_0x08 = 1; - nw4r::snd::SoundSystem::SetMasterVolume(0.0f, frame * 16.666667f); +void AudioSystem::shutdown(s32 ms) { + if (mShutdownStatus == 0) { + mShutdownStatus = 1; + nw4r::snd::SoundSystem::SetMasterVolume(0.0f, ms * 16.666667f); } } void AudioSystem::calc() { f32 masterVolume = nw4r::snd::SoundSystem::GetMasterVolume(); - if (field_0x08 == 1 && masterVolume == 0.0f) { + if (mShutdownStatus == 1 && masterVolume == 0.0f) { nw4r::snd::SoundSystem::PrepareReset(); nw4r::snd::SoundSystem::WaitForResetReady(); - field_0x08 = 2; + mShutdownStatus = 2; } - if (field_0x08 != 2 && field_0x04 == 1 && masterVolume == 0.0f) { - field_0x04 = 2; + if (mShutdownStatus != 2 && mResetStatus == 1 && masterVolume == 0.0f) { + mResetStatus = 2; } }