diff --git a/asm/MetroidPrime/CAudioStateWin.s b/asm/MetroidPrime/CAudioStateWin.s index 297aacfa..afb7f089 100644 --- a/asm/MetroidPrime/CAudioStateWin.s +++ b/asm/MetroidPrime/CAudioStateWin.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803E02A8 -lbl_803E02A8: +.global __vt__14CAudioStateWin +__vt__14CAudioStateWin: # ROM: 0x3DD2A8 .4byte 0 .4byte 0 @@ -27,9 +27,9 @@ __dt__14CAudioStateWinFv: /* 80111CE0 0010EC40 93 C1 00 08 */ stw r30, 8(r1) /* 80111CE4 0010EC44 7C 7E 1B 79 */ or. r30, r3, r3 /* 80111CE8 0010EC48 41 82 00 28 */ beq lbl_80111D10 -/* 80111CEC 0010EC4C 3C A0 80 3E */ lis r5, lbl_803E02A8@ha +/* 80111CEC 0010EC4C 3C A0 80 3E */ lis r5, __vt__14CAudioStateWin@ha /* 80111CF0 0010EC50 38 80 00 00 */ li r4, 0 -/* 80111CF4 0010EC54 38 05 02 A8 */ addi r0, r5, lbl_803E02A8@l +/* 80111CF4 0010EC54 38 05 02 A8 */ addi r0, r5, __vt__14CAudioStateWin@l /* 80111CF8 0010EC58 90 1E 00 00 */ stw r0, 0(r30) /* 80111CFC 0010EC5C 4B F4 0E A9 */ bl __dt__6CIOWinFv /* 80111D00 0010EC60 7F E0 07 35 */ extsh. r0, r31 @@ -107,9 +107,9 @@ __ct__14CAudioStateWinFv: /* 80111DF0 0010ED50 4B F4 0E 1D */ bl "__ct__6CIOWinFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>" /* 80111DF4 0010ED54 38 61 00 08 */ addi r3, r1, 8 /* 80111DF8 0010ED58 48 22 BC E9 */ bl "internal_dereference__Q24rstl66basic_string,Q24rstl17rmemory_allocator>Fv" -/* 80111DFC 0010ED5C 3C 80 80 3E */ lis r4, lbl_803E02A8@ha +/* 80111DFC 0010ED5C 3C 80 80 3E */ lis r4, __vt__14CAudioStateWin@ha /* 80111E00 0010ED60 7F E3 FB 78 */ mr r3, r31 -/* 80111E04 0010ED64 38 04 02 A8 */ addi r0, r4, lbl_803E02A8@l +/* 80111E04 0010ED64 38 04 02 A8 */ addi r0, r4, __vt__14CAudioStateWin@l /* 80111E08 0010ED68 90 1F 00 00 */ stw r0, 0(r31) /* 80111E0C 0010ED6C 83 E1 00 1C */ lwz r31, 0x1c(r1) /* 80111E10 0010ED70 80 01 00 24 */ lwz r0, 0x24(r1) @@ -124,4 +124,3 @@ lbl_803CF200: # ROM: 0x3CC200 .asciz "CAudioStateWin" .balign 4 - diff --git a/include/Kyoto/Audio/CSfxManager.hpp b/include/Kyoto/Audio/CSfxManager.hpp index 6e0171b3..a164c1c0 100644 --- a/include/Kyoto/Audio/CSfxManager.hpp +++ b/include/Kyoto/Audio/CSfxManager.hpp @@ -8,6 +8,8 @@ class CVector3f; class CSfxManager { public: + enum ESfxChannels { kSC_Invalid = -1, kSC_Default = 0, kSC_Game, kSC_PauseScreen }; + static void Update(float dt); static void RemoveEmitter(CSfxHandle handle); static void UpdateEmitter(CSfxHandle handle, const CVector3f& pos, const CVector3f& dir, @@ -31,6 +33,11 @@ public: static CSfxHandle SfxStart(ushort id, uchar vol, uchar pan, bool useAcoustics, short prio, bool looped, int areaId); static bool IsPlaying(const CSfxHandle& handle); + + static void SetChannel(ESfxChannels); + static void KillAll(ESfxChannels); + static void TurnOnChannel(ESfxChannels); + static void TurnOffChannel(ESfxChannels); }; #endif // _CSFXMANAGER diff --git a/include/MetroidPrime/CMain.hpp b/include/MetroidPrime/CMain.hpp index e369f02f..2b8851a9 100644 --- a/include/MetroidPrime/CMain.hpp +++ b/include/MetroidPrime/CMain.hpp @@ -78,6 +78,7 @@ public: bool CheckReset(); void OpenWindow(); void SetRestartMode(ERestartMode s) { x12c_restartMode = s; } + ERestartMode GetRestartMode() const { return x12c_restartMode; } void SetCardBusy(bool v) { x160_31_cardBusy = v; } void SetMaxSpeed(bool v) { diff --git a/include/MetroidPrime/Player/CGameState.hpp b/include/MetroidPrime/Player/CGameState.hpp index 8e0d5adb..9c778414 100644 --- a/include/MetroidPrime/Player/CGameState.hpp +++ b/include/MetroidPrime/Player/CGameState.hpp @@ -41,6 +41,7 @@ public: void SetFileIdx(u32 idx) { x20c_saveIdx = idx; } void SetCardSerial(u64 serial) { x210_cardSerial = serial; } u64 GetCardSerial() const { return x210_cardSerial; } + rstl::rc_ptr< CWorldTransManager >& WorldTransitionManager(); // { return x9c_transManager.GetPtr(); } struct GameFileStateInfo { double x0_playTime; diff --git a/include/MetroidPrime/Player/CWorldTransManager.hpp b/include/MetroidPrime/Player/CWorldTransManager.hpp index 83b956b5..f14f18a0 100644 --- a/include/MetroidPrime/Player/CWorldTransManager.hpp +++ b/include/MetroidPrime/Player/CWorldTransManager.hpp @@ -5,8 +5,14 @@ class CWorldTransManager { public: + enum ETransType { kTT_Disabled, kTT_Enabled, kTT_Text }; + + ETransType GetTransType() const { return x30_transType; } + private: - uchar pad[0x48]; + uchar x0_pad[0x30]; + ETransType x30_transType; + uchar x34_pad[0x14]; }; #endif // _CWORLDTRANSMANAGER diff --git a/src/MetroidPrime/CAudioStateWin.cpp b/src/MetroidPrime/CAudioStateWin.cpp new file mode 100644 index 00000000..e6dfab71 --- /dev/null +++ b/src/MetroidPrime/CAudioStateWin.cpp @@ -0,0 +1,30 @@ +#include "MetroidPrime/CAudioStateWin.hpp" + +#include "MetroidPrime/CMain.hpp" + +#include "Kyoto/Audio/CSfxManager.hpp" + +CAudioStateWin::CAudioStateWin() : CIOWin(rstl::string_l("CAudioStateWin")) {} + +CAudioStateWin::~CAudioStateWin(){}; + +CIOWin::EMessageReturn CAudioStateWin::OnMessage(const CArchitectureMessage& msg, + CArchitectureQueue&) { + const EArchMsgType msgType = msg.GetType(); + switch (msgType) { + case kAM_SetGameState: + CSfxManager::KillAll(CSfxManager::kSC_Game); + CSfxManager::SetChannel(CSfxManager::kSC_Game); + break; + + case kAM_QuitGameplay: + if (gpGameState->WorldTransitionManager()->GetTransType() == CWorldTransManager::kTT_Disabled || + gpMain->GetRestartMode() != CMain::kRM_None) { + CSfxManager::SetChannel(CSfxManager::kSC_Default); + CSfxManager::KillAll(CSfxManager::kSC_Game); + } + break; + } + + return CIOWin::kMR_Normal; +}