diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index a54fff63..04be5689 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -10617,14 +10617,14 @@ finalizeState_ReadStageLayerRes__11dStageMgr_cFv = .text:0x8019AD00; // type:fun initializeState_ReadLayerObjectRes__11dStageMgr_cFv = .text:0x8019AD10; // type:function size:0x19C executeState_ReadLayerObjectRes__11dStageMgr_cFv = .text:0x8019AEB0; // type:function size:0x68 finalizeState_ReadLayerObjectRes__11dStageMgr_cFv = .text:0x8019AF20; // type:function size:0x98 -fn_8019AFC0 = .text:0x8019AFC0; // type:function size:0x28 +soundCallback__FPv = .text:0x8019AFC0; // type:function size:0x28 initializeState_SoundLoadSceneData__11dStageMgr_cFv = .text:0x8019AFF0; // type:function size:0x44 executeState_SoundLoadSceneData__11dStageMgr_cFv = .text:0x8019B040; // type:function size:0x34 finalizeState_SoundLoadSceneData__11dStageMgr_cFv = .text:0x8019B080; // type:function size:0x38 initializeState_CreateObject__11dStageMgr_cFv = .text:0x8019B0C0; // type:function size:0x684 executeState_CreateObject__11dStageMgr_cFv = .text:0x8019B750; // type:function size:0x50 finalizeState_CreateObject__11dStageMgr_cFv = .text:0x8019B7A0; // type:function size:0x4 -fn_8019B7B0 = .text:0x8019B7B0; // type:function size:0x28 +soundCallback2__FPv = .text:0x8019B7B0; // type:function size:0x28 initializeState_ReadObjectSound__11dStageMgr_cFv = .text:0x8019B7E0; // type:function size:0x3C executeState_ReadObjectSound__11dStageMgr_cFv = .text:0x8019B820; // type:function size:0x7C finalizeState_ReadObjectSound__11dStageMgr_cFv = .text:0x8019B8A0; // type:function size:0x4C @@ -10644,8 +10644,8 @@ fn_8019BEC0 = .text:0x8019BEC0; // type:function size:0x10 fn_8019BED0 = .text:0x8019BED0; // type:function size:0x98 fn_8019BF70 = .text:0x8019BF70; // type:function size:0x10 addArcnToStage = .text:0x8019BF80; // type:function size:0x17C -ArcnObjnManager__doLoad = .text:0x8019C100; // type:function size:0x64 -ArcnObjnManager__checkLoaded = .text:0x8019C170; // type:function size:0x44 +doLoad__10RelObjCtrlFv = .text:0x8019C100; // type:function size:0x64 +isLoaded__10RelObjCtrlCFv = .text:0x8019C170; // type:function size:0x44 fn_8019C1C0 = .text:0x8019C1C0; // type:function size:0x44 getNumStep__Q23EGG16DrawPathLightMapCFv = .text:0x8019C210; // type:function size:0x8 scope:weak fn_8019C220 = .text:0x8019C220; // type:function size:0x4 @@ -11191,7 +11191,7 @@ set__14LinkReloadInfoFUcRC7mVec3_c4mAngUl = .text:0x801BB380; // type:function s isCurrentStage__9dScGame_cFPCc = .text:0x801BB3C0; // type:function size:0x10 isStageSkyloftLayer20__9dScGame_cFv = .text:0x801BB3D0; // type:function size:0x54 isInCredits = .text:0x801BB430; // type:function size:0x54 -isStateLayerWithSeekerStoneHintMenu = .text:0x801BB490; // type:function size:0x78 +isStateLayerWithSeekerStoneHintMenu__9dScGame_cFv = .text:0x801BB490; // type:function size:0x78 copySpawnNextToCurrent__9dScGame_cFv = .text:0x801BB510; // type:function size:0xBC actuallyTriggerEntrance__9dScGame_cFPCcUcUcUciiUcUsSc = .text:0x801BB5D0; // type:function size:0x104 setCamera = .text:0x801BB6E0; // type:function size:0x10 @@ -19979,7 +19979,7 @@ convertLabelStringToSoundId__15dSndPlayerMgr_cCFPCc = .text:0x8035ED00; // type: getSoundArchivePlayerForType__15dSndPlayerMgr_cFl = .text:0x8035ED40; // type:function size:0x44 shouldUseDemoPlayer__15dSndPlayerMgr_cCFl = .text:0x8035ED90; // type:function size:0x5C loadDemoArchive__15dSndPlayerMgr_cFPCc = .text:0x8035EDF0; // type:function size:0x198 -shutdown__15dSndPlayerMgr_cFv = .text:0x8035EF90; // type:function size:0x38 +shutdownDemo__15dSndPlayerMgr_cFv = .text:0x8035EF90; // type:function size:0x38 calc__15dSndPlayerMgr_cFv = .text:0x8035EFD0; // type:function size:0x40 fn_8035F010 = .text:0x8035F010; // type:function size:0x20 isBgmPlayerId__15dSndPlayerMgr_cFUl = .text:0x8035F030; // type:function size:0x1C @@ -19995,9 +19995,9 @@ __dt__25dSndControlPlayerVolume_cFv = .text:0x8035F360; // type:function size:0x __dt__26dSndControlPlayerLpfFreq_cFv = .text:0x8035F3A0; // type:function size:0x40 __dt__25dSndControlPlayerFxSend_cFv = .text:0x8035F3E0; // type:function size:0x40 fn_8035F420 = .text:0x8035F420; // type:function size:0xC8 -fn_8035F4F0 = .text:0x8035F4F0; // type:function size:0x118 -fn_8035F610 = .text:0x8035F610; // type:function size:0x158 -fn_8035F770 = .text:0x8035F770; // type:function size:0xDC +setupPlayerControlsStage__22dSndControlPlayerMgr_cFv = .text:0x8035F4F0; // type:function size:0x118 +setupPlayerControlsStageBgm__22dSndControlPlayerMgr_cFv = .text:0x8035F610; // type:function size:0x158 +setupPlayerControlsDemo__22dSndControlPlayerMgr_cFv = .text:0x8035F770; // type:function size:0xDC calc__22dSndControlPlayerMgr_cFv = .text:0x8035F850; // type:function size:0x3C executeControls__22dSndControlPlayerMgr_cFv = .text:0x8035F890; // type:function size:0xAC calcVolumes__22dSndControlPlayerMgr_cFv = .text:0x8035F940; // type:function size:0x168 @@ -20057,7 +20057,7 @@ getStageTypeFlags__14dSndStateMgr_cCFPCc = .text:0x80361CD0; // type:function si isVolcanicDungeon__14dSndStateMgr_cFUl = .text:0x80361FD0; // type:function size:0x44 isSeekerStoneStage__14dSndStateMgr_cFPCcl = .text:0x80362020; // type:function size:0x84 isActiveDemoMaybe__14dSndStateMgr_cCFl = .text:0x803620B0; // type:function size:0x5C -fn_80362110 = .text:0x80362110; // type:function size:0x34 +isSomeSkyloftRoom__14dSndStateMgr_cCFv = .text:0x80362110; // type:function size:0x34 fn_80362150 = .text:0x80362150; // type:function size:0xB0 fn_80362200 = .text:0x80362200; // type:function size:0xFC fn_80362300 = .text:0x80362300; // type:function size:0x84 @@ -20069,45 +20069,45 @@ isInStage__14dSndStateMgr_cFPCc = .text:0x80362440; // type:function size:0x34 fn_80362480 = .text:0x80362480; // type:function size:0x6C fn_803624F0 = .text:0x803624F0; // type:function size:0xF4 fn_803625F0 = .text:0x803625F0; // type:function size:0x140 -fn_80362730 = .text:0x80362730; // type:function size:0x8 -fn_80362740 = .text:0x80362740; // type:function size:0x59C +loadStageSound__14dSndStateMgr_cFv = .text:0x80362730; // type:function size:0x8 +loadStageSound__14dSndStateMgr_cFb = .text:0x80362740; // type:function size:0x59C calc__14dSndStateMgr_cFv = .text:0x80362CE0; // type:function size:0xFC -EnemySoundMgr__enemyMusicRelated = .text:0x80362DE0; // type:function size:0x154 +calcEvent__14dSndStateMgr_cFv = .text:0x80362DE0; // type:function size:0x154 setEvent__14dSndStateMgr_cFPCc = .text:0x80362F40; // type:function size:0x770 initializeEventCallbacks__14dSndStateMgr_cFPCc = .text:0x803636B0; // type:function size:0xCC convertSeLabelToSoundId__14dSndStateMgr_cFPCc = .text:0x80363780; // type:function size:0xCC -fn_80363850 = .text:0x80363850; // type:function size:0xA8 -fn_80363900 = .text:0x80363900; // type:function size:0xA8 +convertBgmLabelToSoundId__14dSndStateMgr_cFPCc = .text:0x80363850; // type:function size:0xA8 +convertCmdLabelToSoundId__14dSndStateMgr_cFPCc = .text:0x80363900; // type:function size:0xA8 doLabelSuffix__14dSndStateMgr_cFPCc = .text:0x803639B0; // type:function size:0xA8 getSeCameraId__14dSndStateMgr_cFv = .text:0x80363A60; // type:function size:0x5C -fn_80363AC0 = .text:0x80363AC0; // type:function size:0x60 -fn_80363B20 = .text:0x80363B20; // type:function size:0x54 -fn_80363B80 = .text:0x80363B80; // type:function size:0x5C -fn_80363BE0 = .text:0x80363BE0; // type:function size:0x60 -fn_80363C40 = .text:0x80363C40; // type:function size:0x54 -fn_80363CA0 = .text:0x80363CA0; // type:function size:0x5C -fn_80363D00 = .text:0x80363D00; // type:function size:0x60 -fn_80363D60 = .text:0x80363D60; // type:function size:0x54 -fn_80363DC0 = .text:0x80363DC0; // type:function size:0xC -fn_80363DD0 = .text:0x80363DD0; // type:function size:0x1AC +getSeMsgWaitId__14dSndStateMgr_cFv = .text:0x80363AC0; // type:function size:0x60 +getSeFrameCountId__14dSndStateMgr_cFv = .text:0x80363B20; // type:function size:0x54 +getBgmCameraId__14dSndStateMgr_cFv = .text:0x80363B80; // type:function size:0x5C +getBgmMsgWaitId__14dSndStateMgr_cFv = .text:0x80363BE0; // type:function size:0x60 +getBgmFrameCountId__14dSndStateMgr_cFv = .text:0x80363C40; // type:function size:0x54 +getCmdCameraId__14dSndStateMgr_cFv = .text:0x80363CA0; // type:function size:0x5C +getCmdMsgWaitId__14dSndStateMgr_cFv = .text:0x80363D00; // type:function size:0x60 +getCmdFrameCountId__14dSndStateMgr_cFv = .text:0x80363D60; // type:function size:0x54 +clearEventExecuteCallback__14dSndStateMgr_cFv = .text:0x80363DC0; // type:function size:0xC +playSe__14dSndStateMgr_cFUl = .text:0x80363DD0; // type:function size:0x1AC doSe__14dSndStateMgr_cFPCc = .text:0x80363F80; // type:function size:0x48 fn_80363FD0 = .text:0x80363FD0; // type:function size:0x24C fn_80364220 = .text:0x80364220; // type:function size:0x9C playFanOrBgm__14dSndStateMgr_cFUl = .text:0x803642C0; // type:function size:0x84 doBgm__14dSndStateMgr_cFPCc = .text:0x80364350; // type:function size:0x48 -fn_803643A0 = .text:0x803643A0; // type:function size:0x130 +playCmd__14dSndStateMgr_cFUl = .text:0x803643A0; // type:function size:0x130 doCmd__14dSndStateMgr_cFPCc = .text:0x803644D0; // type:function size:0x40 -fn_80364510 = .text:0x80364510; // type:function size:0x60 +calcSe__14dSndStateMgr_cFv = .text:0x80364510; // type:function size:0x60 handleSe__14dSndStateMgr_cFv = .text:0x80364570; // type:function size:0x8 handleSeLv__14dSndStateMgr_cFv = .text:0x80364580; // type:function size:0x1C4 -fn_80364750 = .text:0x80364750; // type:function size:0x84 +calcBgm__14dSndStateMgr_cFv = .text:0x80364750; // type:function size:0x84 getBgmLabelSoundId__14dSndStateMgr_cFv = .text:0x803647E0; // type:function size:0x8 handleFan__14dSndStateMgr_cFv = .text:0x803647F0; // type:function size:0x44 -fn_80364840 = .text:0x80364840; // type:function size:0x60 +calcCmd__14dSndStateMgr_cFv = .text:0x80364840; // type:function size:0x60 handleCmd__14dSndStateMgr_cFv = .text:0x803648A0; // type:function size:0x8 finalizeEvent__14dSndStateMgr_cFb = .text:0x803648B0; // type:function size:0x190 __cl__25SoundStopperIfParamFlag20FRQ34nw4r3snd11SoundHandle = .text:0x80364A40; // type:function size:0x9C -fn_80364AE0 = .text:0x80364AE0; // type:function size:0x8C +endEvent__14dSndStateMgr_cFb = .text:0x80364AE0; // type:function size:0x8C fn_80364B70 = .text:0x80364B70; // type:function size:0xD0 resetEventVars__14dSndStateMgr_cFv = .text:0x80364C40; // type:function size:0xBC onCameraCut__14dSndStateMgr_cFl = .text:0x80364D00; // type:function size:0x94 @@ -20142,7 +20142,7 @@ restoreEffects__14dSndStateMgr_cFv = .text:0x80365AD0; // type:function size:0xA fn_80365B80 = .text:0x80365B80; // type:function size:0x5C getUserParamVolume__14dSndStateMgr_cFUl = .text:0x80365BE0; // type:function size:0x70 fn_80365C50 = .text:0x80365C50; // type:function size:0xC8 -fn_80365D20 = .text:0x80365D20; // type:function size:0x3C +loadObjectSound__14dSndStateMgr_cFv = .text:0x80365D20; // type:function size:0x3C getStageName__14dSndStateMgr_cFl = .text:0x80365D60; // type:function size:0x24 getStageName4__14dSndStateMgr_cFl = .text:0x80365D90; // type:function size:0x44 getCurrentStageName4__14dSndStateMgr_cFv = .text:0x80365DE0; // type:function size:0x1C @@ -20344,7 +20344,7 @@ calc__24dSndAreaSoundEffectMgr_cFv = .text:0x8036A580; // type:function size:0x7 calcPlayerVolume__24dSndAreaSoundEffectMgr_cFv = .text:0x8036A600; // type:function size:0x88 calcActorVolume__24dSndAreaSoundEffectMgr_cFv = .text:0x8036A690; // type:function size:0x9C startSound__24dSndAreaSoundEffectMgr_cFUlUl = .text:0x8036A730; // type:function size:0xEC -fn_8036A820 = .text:0x8036A820; // type:function size:0x328 +loadStageSound__24dSndAreaSoundEffectMgr_cFPf = .text:0x8036A820; // type:function size:0x328 fn_8036AB50 = .text:0x8036AB50; // type:function size:0x20 onEventStart__24dSndAreaSoundEffectMgr_cFv = .text:0x8036AB70; // type:function size:0x4 onEventEnd__24dSndAreaSoundEffectMgr_cFv = .text:0x8036AB80; // type:function size:0x4 @@ -20419,7 +20419,7 @@ fn_8036CDE0 = .text:0x8036CDE0; // type:function size:0xFC fn_8036CEE0 = .text:0x8036CEE0; // type:function size:0x12C restoreEffects__12dSndBgmMgr_cFv = .text:0x8036D010; // type:function size:0x98 fn_8036D0B0 = .text:0x8036D0B0; // type:function size:0x11C -fn_8036D1D0 = .text:0x8036D1D0; // type:function size:0x208 +loadStageSound__12dSndBgmMgr_cFv = .text:0x8036D1D0; // type:function size:0x208 playBgm__12dSndBgmMgr_cFUllb = .text:0x8036D3E0; // type:function size:0x170 fn_8036D550 = .text:0x8036D550; // type:function size:0x174 fn_8036D6D0 = .text:0x8036D6D0; // type:function size:0x60 @@ -20494,7 +20494,7 @@ fn_80370E50 = .text:0x80370E50; // type:function size:0x6C setBgmHandleIdxVolume__12dSndBgmMgr_cFUlfl = .text:0x80370EC0; // type:function size:0x70 fn_80370F30 = .text:0x80370F30; // type:function size:0x6C onEventStart__12dSndBgmMgr_cFPCcll = .text:0x80370FA0; // type:function size:0xA0 -fn_80371040 = .text:0x80371040; // type:function size:0x138 +onEventFinalize__12dSndBgmMgr_cFPCcUlb = .text:0x80371040; // type:function size:0x138 fn_80371180 = .text:0x80371180; // type:function size:0x1A8 fn_80371330 = .text:0x80371330; // type:function size:0x48 fn_80371380 = .text:0x80371380; // type:function size:0x48 diff --git a/include/d/snd/d_snd_area_sound_effect_mgr.h b/include/d/snd/d_snd_area_sound_effect_mgr.h index 69696810..288c40ad 100644 --- a/include/d/snd/d_snd_area_sound_effect_mgr.h +++ b/include/d/snd/d_snd_area_sound_effect_mgr.h @@ -21,6 +21,8 @@ class dSndAreaSoundEffectMgr_c { public: dSndAreaSoundEffectMgr_c(); + void loadStageSound(f32 *pOutVolume); + bool startSound(u32 soundId, u32 handleIdx); void calc(); void stopSounds(s32 fadeFrames); diff --git a/include/d/snd/d_snd_bgm_mgr.h b/include/d/snd/d_snd_bgm_mgr.h index a6e8b80f..688e7065 100644 --- a/include/d/snd/d_snd_bgm_mgr.h +++ b/include/d/snd/d_snd_bgm_mgr.h @@ -39,9 +39,11 @@ public: void pauseAllBgm(); void stopAllBgm(s32 fadeFrames); + void loadStageSound(); void setBgmToPlayOnEventEnd(u32 soundId); bool onEventEnd(); void onEventStart(const char *eventName, s32 soundEventId, s32 unk); + bool onEventFinalize(const char *eventName, u32 soundEventId, bool skipped); void prepareBgm(); dSndBgmSound_c *getSoundHandleForBgm(u32 soundId, u32 startOffset); diff --git a/include/d/snd/d_snd_control_player_mgr.h b/include/d/snd/d_snd_control_player_mgr.h index e5cfed54..cab2cfd3 100644 --- a/include/d/snd/d_snd_control_player_mgr.h +++ b/include/d/snd/d_snd_control_player_mgr.h @@ -25,6 +25,7 @@ public: void setupPlayerControlsGlobal(); void setupPlayerControlsStage(); void setupPlayerControlsStageBgm(); + void setupPlayerControlsDemo(); void calc(); diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h index f7b74a4f..da94dfd1 100644 --- a/include/d/snd/d_snd_player_mgr.h +++ b/include/d/snd/d_snd_player_mgr.h @@ -30,7 +30,7 @@ public: void shutdown(s32 channel); void setup(); - void shutdown(); + void shutdownDemo(); void calc(); void calcActive(); diff --git a/include/d/snd/d_snd_stage_data.h b/include/d/snd/d_snd_stage_data.h index ada97ea3..082a4bb9 100644 --- a/include/d/snd/d_snd_stage_data.h +++ b/include/d/snd/d_snd_stage_data.h @@ -9,7 +9,7 @@ struct dSndStageInfo { /* 0x08 */ u32 unk1; /* 0x0C */ u32 unk2; /* 0x10 */ u32 unk3; - /* 0x14 */ u32 unk4; + /* 0x14 */ s32 unk4; /* 0x18 */ const char *demoName; static const s32 sNumStageInfos; diff --git a/include/d/snd/d_snd_state_mgr.h b/include/d/snd/d_snd_state_mgr.h index 7ad4dbe2..cdb32434 100644 --- a/include/d/snd/d_snd_state_mgr.h +++ b/include/d/snd/d_snd_state_mgr.h @@ -81,10 +81,24 @@ public: return field_0x49C; } + + void resetEventName() { mEventName = "EVENT_NONE"; } + const char *getCameraFmt() { + return "%s_C%d_%d"; + } + + const char *getMsgWaitFmt() { + return "%s_M%d_W%d_%d"; + } + + const char *getFrameFmt() { + return "%s_%d"; + } + bool checkFlag0x18(u32 mask); bool checkFlag0x258(u32 mask) { @@ -103,6 +117,10 @@ public: field_0x258 &= ~mask; } + bool checkStageTypeFlag(u32 mask) { + return mStageTypeFlags & mask; + } + bool checkFlag0x10(u32 mask) { return field_0x010 & mask; } @@ -131,7 +149,8 @@ public: const char *getCurrentStageMusicDemoName() const; bool isInDemo() const { - return getCurrentStageMusicDemoName() != nullptr; + // implicit conversion required for regalloc in loadStageSound + return getCurrentStageMusicDemoName(); } void setStbEventName(const char *eventName); @@ -153,6 +172,9 @@ public: f32 getUserParamVolume(u32 userParam); void onStageOrLayerUpdate(); + void onStageLoad(); + void loadStageSound(); + void loadObjectSound(); // TODO better names static const char *getStageName(s32 id); @@ -189,37 +211,62 @@ public: void onCameraCut(s32 cutIdx); - static void clearExecuteCallback(); + static void clearEventExecuteCallback(); private: + void loadStageSound(bool force); + void resetOverrides(); void initializeEventCallbacks(const char *name); bool handleGlobalEvent(const char *name); bool handleStageEvent(const char *name); void handleDemoEvent(const char *name); + void calcEvent(); void calcRoomId(); void setRoomId(s32 roomId); void calcTgSnd(); void calcFilters(); + u32 getBgmLabelSoundId(); + void doLabelSuffix(const char *suffix); + u32 convertSeLabelToSoundId(const char *label); u32 convertBgmLabelToSoundId(const char *label); - - u32 getBgmLabelSoundId(); - bool playFanOrBgm(u32 soundId); + u32 convertCmdLabelToSoundId(const char *label); void doBgm(const char *label); void doSe(const char *label); void doCmd(const char *label); - void doLabelSuffix(const char *suffix); u32 getSeCameraId(); + u32 getSeMsgWaitId(); + u32 getSeFrameCountId(); + + u32 getBgmCameraId(); + u32 getBgmMsgWaitId(); + u32 getBgmFrameCountId(); + + u32 getCmdCameraId(); + u32 getCmdMsgWaitId(); + u32 getCmdFrameCountId(); + + void calcSe(); + bool calcBgm(); + void calcCmd(); + + bool playSe(u32 soundId); + bool playFanOrBgm(u32 soundId); + bool playCmd(u32 soundId); void handleFan(); void handleSe(); void handleCmd(); void handleSeLv(); + + /** Called when no event is running anymore */ + void endEvent(bool skipped); + /** Called when an event stops */ bool finalizeEvent(bool skipped); void resetEventVars(); @@ -235,6 +282,7 @@ private: // Checks if the given stage + layer is the stage you're transported // to when viewing hint movies. static bool isSeekerStoneStage(const char *stageName, s32 layer); + bool isSomeSkyloftRoom() const; void setCallbacksForStage(); @@ -247,12 +295,12 @@ private: /* 0x014 */ UNKWORD field_0x014; /* 0x018 */ UNKWORD field_0x018; /* 0x01C */ SizedString<32> mStageName; - /* 0x03C */ UNKWORD field_0x03C; + /* 0x03C */ s32 field_0x03C; /* 0x040 */ s32 mStageId; /* 0x044 */ UNKWORD field_0x044; /* 0x048 */ u8 _0x048[0x050 - 0x048]; /* 0x050 */ s32 mPreviousStageId; - /* 0x054 */ UNKWORD field_0x054; + /* 0x054 */ u32 mStageTypeFlags; /* 0x058 */ s32 mLayer; /* 0x05C */ s32 mRoomId; /* 0x060 */ UNKWORD field_0x060; @@ -303,9 +351,9 @@ private: /* 0x498 */ f32 field_0x498; /* 0x49C */ f32 field_0x49C; /* 0x4A0 */ f32 field_0x4A0; - /* 0x4A4 */ UNKWORD field_0x4A4; + /* 0x4A4 */ u32 field_0x4A4; /* 0x4A8 */ u8 field_0x4A8; - /* 0x4A9 */ bool needsGroupsReload; + /* 0x4A9 */ bool mNeedsGroupsReload; }; #endif diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index d0a9ca56..34c40a68 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -19,10 +19,5 @@ extern "C" void fn_8035E310(dSndPlayerMgr_c *); #define ENEMY_SOUND_MGR (dSndStateMgr_c::GetInstance()) extern "C" void fn_80362150(dSndStateMgr_c *, u16); extern "C" void fn_803625F0(dSndStateMgr_c *, u16); -extern "C" void fn_803618F0(dSndStateMgr_c *); -extern "C" void fn_80362730(dSndStateMgr_c *); -extern "C" void fn_80365D20(dSndStateMgr_c *); -extern "C" void fn_803624F0(dSndStateMgr_c *); -extern "C" void fn_80365020(dSndStateMgr_c *); #endif diff --git a/src/d/d_stage_mgr.cpp b/src/d/d_stage_mgr.cpp index 678848e0..e461ab37 100644 --- a/src/d/d_stage_mgr.cpp +++ b/src/d/d_stage_mgr.cpp @@ -9,13 +9,14 @@ #include "d/d_stage_parse.h" #include "d/d_sys.h" #include "d/flag/flag_managers.h" -#include "egg/core/eggHeap.h" +#include "d/snd/d_snd_state_mgr.h" #include "f/f_base.h" #include "f/f_profile_name.h" #include "m/m_dvd.h" #include "toBeSorted/arc_managers/current_stage_arc_manager.h" #include "toBeSorted/arc_managers/layout_arc_manager.h" #include "toBeSorted/arc_managers/oarc_manager.h" +#include "toBeSorted/d_particle.h" #include "toBeSorted/music_mgrs.h" SPECIAL_BASE_PROFILE(STAGE_MANAGER, dStageMgr_c, fProfile::STAGE_MANAGER, 0X5, 1536); @@ -56,7 +57,7 @@ void dStageMgr_c::finalizeState_ReadStageRes() { parseStageBzs(-1, stageBzs); parseRoomStageBzs(-1, stageBzs); } - fn_803618F0(ENEMY_SOUND_MGR); + dSndStateMgr_c::GetInstance()->onStageOrLayerUpdate(); } void dStageMgr_c::initializeState_ReadRoomRes() {} @@ -147,27 +148,24 @@ void dStageMgr_c::executeState_ReadLayerObjectRes() { } } -extern "C" void fn_800C85D0(void *, EGG::Heap *heap, bool, void *jpc, void *jpn); -extern "C" void *FOR_LOADED_PARTICLES; - void dStageMgr_c::finalizeState_ReadLayerObjectRes() { if (mDemoName.len() != 0) { const char *name = mDemoName; void *jpc = OarcManager::GetInstance()->getSubEntryData(name, "dat/jparticle.jpc"); if (jpc != nullptr) { - void *jpn = OarcManager::GetInstance()->getSubEntryData(name, "dat/jparticle.jpn"); - fn_800C85D0(FOR_LOADED_PARTICLES, dHeap::work2Heap.heap, true, jpc, jpn); + void *jpn = OarcManager::GetInstance()->getData(name, "dat/jparticle.jpn"); + dParticle::mgr_c::GetInstance()->createResource(dHeap::work2Heap.heap, true, jpc, jpn); } } } static void *soundCallback(void *arg) { - fn_80362730(ENEMY_SOUND_MGR); + dSndStateMgr_c::GetInstance()->loadStageSound(); return reinterpret_cast(true); } void dStageMgr_c::initializeState_SoundLoadSceneData() { - fn_803624F0(ENEMY_SOUND_MGR); + dSndStateMgr_c::GetInstance()->onStageLoad(); mpDvdCallback = mDvd_callback_c::createOrDie(soundCallback, nullptr); } @@ -195,7 +193,7 @@ void dStageMgr_c::executeState_CreateObject() { void dStageMgr_c::finalizeState_CreateObject() {} static void *soundCallback2(void *arg) { - fn_80365D20(ENEMY_SOUND_MGR); + dSndStateMgr_c::GetInstance()->loadObjectSound(); return reinterpret_cast(true); } diff --git a/src/d/snd/d_snd_3d_manager.cpp b/src/d/snd/d_snd_3d_manager.cpp index cf4e6a37..1cf5610b 100644 --- a/src/d/snd/d_snd_3d_manager.cpp +++ b/src/d/snd/d_snd_3d_manager.cpp @@ -8,7 +8,6 @@ #include "nw4r/math/math_arithmetic.h" #include "nw4r/math/math_types.h" #include "nw4r/snd/snd_SoundArchive.h" -#include "toBeSorted/music_mgrs.h" SND_DISPOSER_DEFINE(dSnd3DManager_c); diff --git a/src/d/snd/d_snd_bgm_sound.cpp b/src/d/snd/d_snd_bgm_sound.cpp index 138c0e40..cfd488a7 100644 --- a/src/d/snd/d_snd_bgm_sound.cpp +++ b/src/d/snd/d_snd_bgm_sound.cpp @@ -16,8 +16,6 @@ #include "nw4r/snd/snd_SoundStartable.h" #include "nw4r/snd/snd_StrmSoundHandle.h" #include "nw4r/snd/snd_WaveSoundHandle.h" -#include "toBeSorted/music_mgrs.h" - dSndBgmSoundHarpMgr_c *dSndBgmSound_c::spGlobalHarpMgr; diff --git a/src/d/snd/d_snd_player_mgr.cpp b/src/d/snd/d_snd_player_mgr.cpp index 9e1cd08f..20de1ed6 100644 --- a/src/d/snd/d_snd_player_mgr.cpp +++ b/src/d/snd/d_snd_player_mgr.cpp @@ -366,7 +366,7 @@ bool dSndPlayerMgr_c::loadDemoArchive(const char *demoArchiveName) { return ok; } -void dSndPlayerMgr_c::shutdown() { +void dSndPlayerMgr_c::shutdownDemo() { mDemoSoundArchivePlayer.Shutdown(); mDemoSoundArchive.Shutdown(); } diff --git a/src/d/snd/d_snd_sound.cpp b/src/d/snd/d_snd_sound.cpp index 41246acb..ffbfa3ce 100644 --- a/src/d/snd/d_snd_sound.cpp +++ b/src/d/snd/d_snd_sound.cpp @@ -8,7 +8,6 @@ #include "nw4r/snd/snd_SoundArchive.h" #include "nw4r/snd/snd_SoundStartable.h" #include "nw4r/ut/ut_list.h" -#include "toBeSorted/music_mgrs.h" dSndSound_c::dSndSound_c() : mPrevStartOffset(0), mIsPreparing(false), mPauseFlag(false), mIsRunning(false), mIsFadingOut(false) { diff --git a/src/d/snd/d_snd_state_mgr.cpp b/src/d/snd/d_snd_state_mgr.cpp index 4efc4a21..c2dceeea 100644 --- a/src/d/snd/d_snd_state_mgr.cpp +++ b/src/d/snd/d_snd_state_mgr.cpp @@ -36,7 +36,7 @@ dSndStateMgr_c::dSndStateMgr_c() field_0x03C(0), mStageId(0xAC), mPreviousStageId(0xAC), - field_0x054(0), + mStageTypeFlags(0), mLayer(0), mRoomId(-1), field_0x060(0), @@ -81,7 +81,7 @@ dSndStateMgr_c::dSndStateMgr_c() field_0x4A0(0.02f), field_0x4A4(-1), field_0x4A8(0), - needsGroupsReload(false) {} + mNeedsGroupsReload(false) {} extern "C" void fn_803665B0(nw4r::snd::detail::FxReverbStdParam &, int); @@ -112,12 +112,12 @@ void dSndStateMgr_c::onStageOrLayerUpdate() { field_0x064 = 0; if (!streq(mStageName, dScGame_c::currentSpawnInfo.getStageName())) { - needsGroupsReload = true; + mNeedsGroupsReload = true; mStageName = dScGame_c::currentSpawnInfo.getStageName(); } - if (!needsGroupsReload && dScGame_c::currentSpawnInfo.layer != mLayer) { - needsGroupsReload = true; + if (!mNeedsGroupsReload && dScGame_c::currentSpawnInfo.layer != mLayer) { + mNeedsGroupsReload = true; } mLayer = dScGame_c::currentSpawnInfo.layer; @@ -210,6 +210,241 @@ bool dSndStateMgr_c::isSeekerStoneStage(const char *stageName, s32 layer) { return false; } +bool dSndStateMgr_c::isSomeSkyloftRoom() const { + switch (field_0x044) { + case SND_STAGE_F001r: + case SND_STAGE_F002r: + case SND_STAGE_F011r: + case SND_STAGE_F005r: + case SND_STAGE_F006r: + case SND_STAGE_F007r: + case SND_STAGE_F013r: + case SND_STAGE_F014r: + case SND_STAGE_F015r: + case SND_STAGE_F016r: + case SND_STAGE_F017r: + case SND_STAGE_F018r: return true; + default: return false; + } +} + +void dSndStateMgr_c::loadStageSound() { + loadStageSound(false); +} + +void dSndStateMgr_c::loadStageSound(bool force) { + if (!force && !mNeedsGroupsReload) { + return; + } + + bool demo = isInDemo(); + if (!checkFlag0x18(0x40)) { + for (int i = 0; i < dSndControlPlayerMgr_c::sNumPlayers; i++) { + dSndControlPlayerMgr_c::GetInstance()->setLpfFreq(i, 0.0f, 0); + dSndControlPlayerMgr_c::GetInstance()->setFxSend(i, 0.0f, 0); + } + } + + if (checkEventFlag(EVENT_0x800)) { + if (!dSndBgmMgr_c::GetInstance()->isPlayingBgmSound()) { + dSndControlPlayerMgr_c::GetInstance()->setupPlayerControlsStage(); + offEventFlag(EVENT_0x800); + } else { + dSndControlPlayerMgr_c::GetInstance()->setupPlayerControlsStageBgm(); + } + } else { + if (dSndBgmMgr_c::GetInstance()->isPlayingBgmSound()) { + dSndControlPlayerMgr_c::GetInstance()->setupPlayerControlsStageBgm(); + onEventFlag(EVENT_0x800); + } else { + dSndControlPlayerMgr_c::GetInstance()->setupPlayerControlsStage(); + } + } + + dSndControlPlayerMgr_c::GetInstance()->muteScenePlayers(0); + dSndPlayerMgr_c::GetInstance()->shutdownDemo(); + field_0x4A8 = 1; + bool bHasState1 = false; + + if (isSomeSkyloftRoom()) { + u32 id = dSndMgr_c::GetInstance()->getArchive()->ConvertLabelStringToGroupId("GRP_FAN_TIMECHANGE"); + if (dSndMgr_c::GetInstance()->getPlayer().IsLoadedGroup(id)) { + bHasState1 = true; + } else { + dSndPlayerMgr_c::GetInstance()->popToState0(); + if (dSndMgr_c::GetInstance()->loadGroup(id, nullptr, 0)) { + dSndPlayerMgr_c::GetInstance()->saveState1(); + bHasState1 = true; + } + } + } + + const dSndStageInfo *info = &dSndStageInfo::sInfos[mStageId]; + + u32 id = -1; + int round = 1; + + bool b1 = false; + SizedString<64> label; + + if (info->unk4 == mStageId) { + const char *stageName = getStageName(info->unk4); + label.sprintf("GRP_A_%s_L%d", stageName, mLayer); + round = 2; + } else { + const char *stageName = getCurrentStageName4(); + label.sprintf("GRP_A_%s", stageName); + } + + for (; round > 0; round--) { + id = dSndMgr_c::GetInstance()->getArchive()->ConvertLabelStringToGroupId(label); + if (field_0x4A4 == id && field_0x4A4 != -1) { + b1 = true; + break; + } + + if (id != -1) { + if (bHasState1) { + dSndPlayerMgr_c::GetInstance()->popToState1(); + } else { + dSndPlayerMgr_c::GetInstance()->popToState0(); + } + if (dSndMgr_c::GetInstance()->loadGroup(id, nullptr, 0)) { + field_0x4A4 = id; + dSndPlayerMgr_c::GetInstance()->saveState2(); + break; + } + } + + if (round == 2) { + // we tried layer variant, now try variant without layer + const char *stageName = getCurrentStageName4(); + label.sprintf("GRP_A_%s", stageName); + } + } + + if (b1) { + dSndPlayerMgr_c::GetInstance()->popToState2(); + } else if (id == -1) { + if (bHasState1) { + dSndPlayerMgr_c::GetInstance()->popToState1(); + } else { + dSndPlayerMgr_c::GetInstance()->popToState0(); + } + dSndPlayerMgr_c::GetInstance()->saveState2(); + field_0x4A4 = -1; + } + + if (!demo && (field_0x03C != 2 || field_0x065)) { + if (field_0x065) { + id = GRP_SIREN; + } else if (checkStageTypeFlag(STAGE_ROOM)) { + id = GRP_INDOOR; + } else if (checkStageTypeFlag(STAGE_FIELD)) { + id = GRP_FIELD; + } else if (checkStageTypeFlag(STAGE_DUNGEON)) { + if (isVolcanicDungeon(mStageId)) { + id = GRP_DUNGEON_BATTLE_ROOM; + } else { + id = GRP_DUNGEON; + } + } else if (checkStageTypeFlag(STAGE_BOSS)) { + id = GRP_BOSS; + } else { + id = GRP_DEFAULT; + } + + if (id != -1) { + dSndMgr_c::GetInstance()->loadGroup(id, nullptr, 0); + } + } + + if (!field_0x065) { + id = -1; + if (!demo) { + if (field_0x03C == 2) { + id = GRP_SKY; + } else if (checkStageTypeFlag(STAGE_FOREST)) { + id = GRP_FOREST; + } else if (checkStageTypeFlag(STAGE_MOUNTAIN)) { + id = GRP_MOUNTAIN; + } else if (checkStageTypeFlag(STAGE_DESERT)) { + id = GRP_DESERT; + } + + if (id != -1) { + dSndMgr_c::GetInstance()->loadGroup(id, nullptr, 0); + } + } + + SizedString<64> label; + label.sprintf("GRP_%s_L%d", &mStageName, mLayer); + id = dSndMgr_c::GetInstance()->getArchive()->ConvertLabelStringToGroupId(label); + if (id == -1) { + label.sprintf("GRP_%s", &mStageName); + id = dSndMgr_c::GetInstance()->getArchive()->ConvertLabelStringToGroupId(label); + } + + if (id != -1) { + dSndMgr_c::GetInstance()->loadGroup(id, nullptr, 0); + } + + if (demo) { + // REGSWAP + if (dSndPlayerMgr_c::GetInstance()->loadDemoArchive(getCurrentStageMusicDemoName())) { + for (u32 i = dSndPlayerMgr_c::PLAYER_LINK_BODY; i <= dSndPlayerMgr_c::PLAYER_EVENT; i++) { + dSndControlPlayerMgr_c::GetInstance()->getPlayer1(i)->StopAllSound(0); + } + dSndControlPlayerMgr_c::GetInstance()->setupPlayerControlsDemo(); + } + } + } + + field_0x4A8 = 0; + dSndBgmMgr_c::GetInstance()->loadStageSound(); + f32 volume = -1.0f; + dSndAreaSoundEffectMgr_c::GetInstance()->loadStageSound(&volume); + if (volume > 0.0f) { + field_0x490 = volume; + } +} + +void dSndStateMgr_c::calcEvent() { + if (!isInEvent()) { + return; + } + + bool b = false; + if (dSndPlayerMgr_c::GetInstance()->checkFlag(dSndPlayerMgr_c::MGR_CAUTION) || + dSndPlayerMgr_c::GetInstance()->checkFlag(dSndPlayerMgr_c::MGR_MAP) || + dSndPlayerMgr_c::GetInstance()->checkFlag(dSndPlayerMgr_c::MGR_MSG_WAIT)) { + b = true; + } + + if (mpSoundEventDef != nullptr && sEventExecuteCallback != nullptr) { + (sEventExecuteCallback)(); + } + + if (!b) { + if (EventManager::getCurrentEventName() == nullptr) { + if (!checkEventFlag(EVENT_0x800)) { + endEvent(false); + } + } else { + if (mSeLvSoundId != -1) { + dSndMgr_c::GetInstance()->holdSound(&mSeLvSoundHandle, mSeLvSoundId); + } + calcBgm(); + calcSe(); + calcCmd(); + mFrameCounter++; + mCameraCutFrameCounter++; + mMsgFrameCounter++; + nw4r::snd::SeqSoundHandle::WriteGlobalVariable(2, mCameraCutFrameCounter); + } + } +} + void dSndStateMgr_c::setEvent(const char *eventName) { if (eventName == nullptr) { return; @@ -382,14 +617,80 @@ void dSndStateMgr_c::doLabelSuffix(const char *suffix) { u32 dSndStateMgr_c::getSeCameraId() { SizedString<64> label; - label.sprintf("%s_C%d_%d", &mSeName, mCameraCutCounter, mCameraCutFrameCounter); + label.sprintf(getCameraFmt(), &mSeName, mCameraCutCounter, mCameraCutFrameCounter); return convertSeLabelToSoundId(label); } -void dSndStateMgr_c::clearExecuteCallback() { +u32 dSndStateMgr_c::getSeMsgWaitId() { + SizedString<64> label; + label.sprintf(getMsgWaitFmt(), &mSeName, mMsgCounter, mMsgWaitSelectCounter, mMsgFrameCounter); + return convertSeLabelToSoundId(label); +} + +u32 dSndStateMgr_c::getSeFrameCountId() { + SizedString<64> label; + label.sprintf(getFrameFmt(), &mSeName, mFrameCounter); + return convertSeLabelToSoundId(label); +} + +u32 dSndStateMgr_c::getBgmCameraId() { + SizedString<64> label; + label.sprintf(getCameraFmt(), &mBgmName, mCameraCutCounter, mCameraCutFrameCounter); + return convertBgmLabelToSoundId(label); +} + +u32 dSndStateMgr_c::getBgmMsgWaitId() { + SizedString<64> label; + label.sprintf(getMsgWaitFmt(), &mBgmName, mMsgCounter, mMsgWaitSelectCounter, mMsgFrameCounter); + return convertBgmLabelToSoundId(label); +} + +u32 dSndStateMgr_c::getBgmFrameCountId() { + SizedString<64> label; + label.sprintf(getFrameFmt(), &mBgmName, mFrameCounter); + return convertBgmLabelToSoundId(label); +} + +u32 dSndStateMgr_c::getCmdCameraId() { + SizedString<64> label; + label.sprintf(getCameraFmt(), &mCmdName, mCameraCutCounter, mCameraCutFrameCounter); + return convertCmdLabelToSoundId(label); +} + +u32 dSndStateMgr_c::getCmdMsgWaitId() { + SizedString<64> label; + label.sprintf(getMsgWaitFmt(), &mCmdName, mMsgCounter, mMsgWaitSelectCounter, mMsgFrameCounter); + return convertCmdLabelToSoundId(label); +} + +u32 dSndStateMgr_c::getCmdFrameCountId() { + SizedString<64> label; + label.sprintf(getFrameFmt(), &mCmdName, mFrameCounter); + return convertCmdLabelToSoundId(label); +} + +void dSndStateMgr_c::clearEventExecuteCallback() { sEventExecuteCallback = nullptr; } +bool dSndStateMgr_c::calcBgm() { + bool ok = playFanOrBgm(getBgmCameraId()); + if (!ok) { + ok = playFanOrBgm(getBgmMsgWaitId()); + } + if (!ok) { + // @bug (?) shouldn't this assign to ok? Maybe a shadowing redeclaration... + (void)playFanOrBgm(getBgmFrameCountId()); + } + return ok; +} + +void dSndStateMgr_c::calcSe() { + playSe(getSeCameraId()); + playSe(getSeMsgWaitId()); + playSe(getSeFrameCountId()); +} + void dSndStateMgr_c::handleSeLv() { SizedString<0x40> name = mSeName; name += "_LV"; @@ -407,6 +708,12 @@ void dSndStateMgr_c::handleSeLv() { } } +void dSndStateMgr_c::calcCmd() { + playCmd(getCmdCameraId()); + playCmd(getCmdMsgWaitId()); + playCmd(getCmdFrameCountId()); +} + bool dSndStateMgr_c::finalizeEvent(bool skipped) { dSndPlayerMgr_c *mgr = dSndPlayerMgr_c::GetInstance(); if (mgr->checkFlag(dSndPlayerMgr_c::MGR_CAUTION)) { @@ -426,9 +733,15 @@ bool dSndStateMgr_c::finalizeEvent(bool skipped) { p->ForEachSound(stopper, false); } - // ... + SizedString<64> label; + label.sprintf("%s_FIN", &mSeName); + playSe(dSndPlayerMgr_c::GetInstance()->convertLabelStringToSoundId(label)); + label.sprintf("%s_FIN", &mBgmName); + doBgm(label); + label.sprintf("%s_FIN", &mCmdName); + doCmd(label); - return false; + return dSndBgmMgr_c::GetInstance()->onEventFinalize(mEventName, mSoundEventId, skipped); } // TODO - the whole "camera cut" thing seems plausible but I haven't confirmed it yet @@ -482,7 +795,7 @@ void dSndStateMgr_c::onMsgWaitStart() { if (mpSoundEventDef != nullptr && mpSoundEventDef->msgWaitStartCb != nullptr) { mpSoundEventDef->msgWaitStartCb(mMsgWaitSelectCounter); } - + SizedString<64> label; label.sprintf("_M%d_WS%d", mMsgCounter, mMsgWaitSelectCounter); doLabelSuffix(label); @@ -492,7 +805,7 @@ void dSndStateMgr_c::onMsgWaitEnd() { if (mpSoundEventDef != nullptr && mpSoundEventDef->msgWaitEndCb != nullptr) { mpSoundEventDef->msgWaitEndCb(mMsgWaitSelectCounter); } - + SizedString<64> label; label.sprintf("_M%d_WE%d", mMsgCounter, mMsgWaitSelectCounter); doLabelSuffix(label);