diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index f588b4e1..72bc4f64 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2743,13 +2743,17 @@ d/snd/d_snd_small_effect_mgr.cpp: .sdata2 start:0x8057DA80 end:0x8057DAD0 d/snd/d_snd_harp_song_mgr.cpp: - .text start:0x8037F8C0 end:0x80382150 align:16 - .rodata start:0x804F38C8 end:0x804F38E0 + .text start:0x8037F8C0 end:0x80381868 align:16 .data start:0x805491D0 end:0x805491E0 .sdata start:0x80574308 end:0x80574310 .sbss start:0x80575DA0 end:0x80575DA8 .sdata2 start:0x8057DAD0 end:0x8057DB48 +d/snd/d_snd_harp_song_data.cpp: + .text start:0x80381870 end:0x80382150 align:16 + .rodata start:0x804F38C8 end:0x804F38E0 + .sdata2 start:0x8057DB48 end:0x8057DB50 + d/snd/d_snd_anim_sound.cpp: .text start:0x80382150 end:0x8038240C align:16 .sdata2 start:0x8057DB50 end:0x8057DB68 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 129fafb9..5ec9f24f 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -20815,10 +20815,10 @@ parseData__22dSndBgmMmlParserHarp_cFPCcUlUl = .text:0x8037D090; // type:function parseData__22dSndBgmMmlParserHarp_cFUlUl = .text:0x8037D180; // type:function size:0x84 CommandProc__22dSndBgmMmlParserHarp_cCFUliUlll = .text:0x8037D210; // type:function size:0x38 NoteOnCommandProc__22dSndBgmMmlParserHarp_cCFUliiil = .text:0x8037D250; // type:function size:0x20 -fn_8037D270 = .text:0x8037D270; // type:function size:0x58 -fn_8037D2D0 = .text:0x8037D2D0; // type:function size:0x68 -fn_8037D340 = .text:0x8037D340; // type:function size:0x4 -fn_8037D350 = .text:0x8037D350; // type:function size:0x50 +__ct__26dSndBgmMmlParserHarpSong_cFv = .text:0x8037D270; // type:function size:0x58 +parseData__26dSndBgmMmlParserHarpSong_cFUlP18dSndHarpSongData_c = .text:0x8037D2D0; // type:function size:0x68 +CommandProc__26dSndBgmMmlParserHarpSong_cCFUliUlll = .text:0x8037D340; // type:function size:0x4 +NoteOnCommandProc__26dSndBgmMmlParserHarpSong_cCFUliiil = .text:0x8037D350; // type:function size:0x50 fn_8037D3A0 = .text:0x8037D3A0; // type:function size:0x5C fn_8037D400 = .text:0x8037D400; // type:function size:0xB0 fn_8037D4B0 = .text:0x8037D4B0; // type:function size:0x34 @@ -20883,11 +20883,11 @@ __dt__35SndMgrDisposer<17dSndHarpSongMgr_c>Fv = .text:0x8037F8C0; // type:functi create__35SndMgrDisposer<17dSndHarpSongMgr_c>Fv = .text:0x8037F940; // type:function size:0x48 remove__35SndMgrDisposer<17dSndHarpSongMgr_c>Fv = .text:0x8037F990; // type:function size:0x10 __ct__17dSndHarpSongMgr_cFv = .text:0x8037F9A0; // type:function size:0x144 -fn_8037FAF0 = .text:0x8037FAF0; // type:function size:0x80 -fn_8037FB70 = .text:0x8037FB70; // type:function size:0x58 -fn_8037FBD0 = .text:0x8037FBD0; // type:function size:0x58 +__dt__18dSndHarpSongData_cFv = .text:0x8037FAF0; // type:function size:0x80 +__dt__20dSndHarpSongEntry1_cFv = .text:0x8037FB70; // type:function size:0x58 +__dt__20dSndHarpSongEntry2_cFv = .text:0x8037FBD0; // type:function size:0x58 setup__17dSndHarpSongMgr_cFv = .text:0x8037FC30; // type:function size:0x4 -fn_8037FC40 = .text:0x8037FC40; // type:function size:0xA8 +setupState0__17dSndHarpSongMgr_cFv = .text:0x8037FC40; // type:function size:0xA8 fn_8037FCF0 = .text:0x8037FCF0; // type:function size:0x6C putHarpAway = .text:0x8037FD60; // type:function size:0x74 fn_8037FDE0 = .text:0x8037FDE0; // type:function size:0x58 @@ -20915,23 +20915,23 @@ fn_80381560 = .text:0x80381560; // type:function size:0x14 fn_80381580 = .text:0x80381580; // type:function size:0x78 fn_80381600 = .text:0x80381600; // type:function size:0xA0 fn_803816A0 = .text:0x803816A0; // type:function size:0xC0 -fn_80381760 = .text:0x80381760; // type:function size:0x60 -fn_803817C0 = .text:0x803817C0; // type:function size:0x80 +resetFloatArr1__17dSndHarpSongMgr_cFv = .text:0x80381760; // type:function size:0x60 +resetFloatArr2__17dSndHarpSongMgr_cFv = .text:0x803817C0; // type:function size:0x80 fn_80381840 = .text:0x80381840; // type:function size:0x28 -fn_80381870 = .text:0x80381870; // type:function size:0x48 -fn_803818C0 = .text:0x803818C0; // type:function size:0x58 -fn_80381920 = .text:0x80381920; // type:function size:0x30 -fn_80381950 = .text:0x80381950; // type:function size:0x38 -fn_80381990 = .text:0x80381990; // type:function size:0x24 -fn_803819C0 = .text:0x803819C0; // type:function size:0xA4 -fn_80381A70 = .text:0x80381A70; // type:function size:0x84 -fn_80381B00 = .text:0x80381B00; // type:function size:0x20 -fn_80381B20 = .text:0x80381B20; // type:function size:0x80 -fn_80381BA0 = .text:0x80381BA0; // type:function size:0x38 -fn_80381BE0 = .text:0x80381BE0; // type:function size:0xD0 -fn_80381CB0 = .text:0x80381CB0; // type:function size:0x74 -fn_80381D30 = .text:0x80381D30; // type:function size:0x1BC -fn_80381EF0 = .text:0x80381EF0; // type:function size:0x150 +__ct__23dSndHarpSongEntryBase_cFss = .text:0x80381870; // type:function size:0x48 +__dt__23dSndHarpSongEntryBase_cFv = .text:0x803818C0; // type:function size:0x58 +reset__23dSndHarpSongEntryBase_cFv = .text:0x80381920; // type:function size:0x30 +insert__23dSndHarpSongEntryBase_cFUls = .text:0x80381950; // type:function size:0x38 +get__23dSndHarpSongEntryBase_cCFUl = .text:0x80381990; // type:function size:0x24 +__ct__20dSndHarpSongEntry1_cFv = .text:0x803819C0; // type:function size:0xA4 +loadStaticData__20dSndHarpSongEntry1_cFlUll = .text:0x80381A70; // type:function size:0x84 +getStaticDatum__20dSndHarpSongEntry1_cCFUl = .text:0x80381B00; // type:function size:0x20 +__ct__18dSndHarpSongData_cFv = .text:0x80381B20; // type:function size:0x80 +__ct__20dSndHarpSongEntry2_cFv = .text:0x80381BA0; // type:function size:0x38 +init__18dSndHarpSongData_cFUl = .text:0x80381BE0; // type:function size:0xD0 +loadStaticValues__18dSndHarpSongData_cFv = .text:0x80381CB0; // type:function size:0x74 +insert2__18dSndHarpSongData_cFUlsl = .text:0x80381D30; // type:function size:0x1BC +insert1__18dSndHarpSongData_cFUls = .text:0x80381EF0; // type:function size:0x150 fn_80382040 = .text:0x80382040; // type:function size:0x48 fn_80382090 = .text:0x80382090; // type:function size:0x3C fn_803820D0 = .text:0x803820D0; // type:function size:0x40 @@ -21617,8 +21617,8 @@ remove__34SndMgrDisposer<16dSndFiVocalMgr_c>Fv = .text:0x80399650; // type:funct __ct__16dSndFiVocalMgr_cFv = .text:0x80399660; // type:function size:0x44 fiSpeak__16dSndFiVocalMgr_cFPCcUsl = .text:0x803996B0; // type:function size:0x1EC executeOutputText__16dSndFiVocalMgr_cFUsUs = .text:0x803998A0; // type:function size:0x4 -fn_803998B0 = .text:0x803998B0; // type:function size:0x120 -fn_803999D0 = .text:0x803999D0; // type:function size:0x6C +startFiVocal__16dSndFiVocalMgr_cFss = .text:0x803998B0; // type:function size:0x120 +getStaticSongValue__16dSndFiVocalMgr_cFlUlll = .text:0x803999D0; // type:function size:0x6C __ct__9dSndRng_cFv = .text:0x80399A40; // type:function size:0x50 init__9dSndRng_cFv = .text:0x80399A90; // type:function size:0x44 rndInt__9dSndRng_cFl = .text:0x80399AE0; // type:function size:0x5C @@ -29031,7 +29031,7 @@ lbl_804F37E8 = .rodata:0x804F37E8; // type:object size:0x30 data:2byte lbl_804F3818 = .rodata:0x804F3818; // type:object size:0x40 sBattleConfigs = .rodata:0x804F3858; // type:object size:0x30 scope:local data:4byte sBgmConfigs = .rodata:0x804F3888; // type:object size:0x40 scope:local -lbl_804F38C8 = .rodata:0x804F38C8; // type:object size:0x18 +sUnkSongVals = .rodata:0x804F38C8; // type:object size:0x18 lbl_804F38E0 = .rodata:0x804F38E0; // type:object size:0x10 sFlowSoundDefs = .rodata:0x804F38F0; // type:object size:0x80 scope:local grp4 = .rodata:0x804F3970; // type:object size:0x9 scope:local @@ -38046,7 +38046,7 @@ __vt__18dSndBgmMmlParser_c = .data:0x80549158; // type:object size:0x10 lbl_80549168 = .data:0x80549168; // type:object size:0x10 lbl_80549178 = .data:0x80549178; // type:object size:0x10 lbl_80549188 = .data:0x80549188; // type:object size:0x10 -lbl_80549198 = .data:0x80549198; // type:object size:0x10 +__vt__26dSndBgmMmlParserHarpSong_c = .data:0x80549198; // type:object size:0x10 __vt__22dSndBgmMmlParserHarp_c = .data:0x805491A8; // type:object size:0x10 __vt__12SoundStopper = .data:0x805491B8; // type:object size:0xC __vt__38SndMgrDisposer<20dSndSmallEffectMgr_c> = .data:0x805491C4; // type:object size:0xC @@ -41097,7 +41097,7 @@ lbl_805742D8 = .sdata:0x805742D8; // type:object size:0x8 lbl_805742E0 = .sdata:0x805742E0; // type:object size:0x8 lbl_805742E8 = .sdata:0x805742E8; // type:object size:0x8 @7580 = .sdata:0x805742F0; // type:object size:0x6 scope:local data:string -lbl_805742F8 = .sdata:0x805742F8; // type:object size:0x8 +lbl_805742F8 = .sdata:0x805742F8; // type:object size:0x5 data:string lbl_80574300 = .sdata:0x80574300; // type:object size:0x8 data:string lbl_80574308 = .sdata:0x80574308; // type:object size:0x8 lbl_80574310 = .sdata:0x80574310; // type:object size:0x4 @@ -49115,7 +49115,7 @@ lbl_8057DB34 = .sdata2:0x8057DB34; // type:object size:0x4 align:4 data:float lbl_8057DB38 = .sdata2:0x8057DB38; // type:object size:0x4 align:4 data:float lbl_8057DB3C = .sdata2:0x8057DB3C; // type:object size:0x4 align:4 data:float lbl_8057DB40 = .sdata2:0x8057DB40; // type:object size:0x4 align:4 data:float -lbl_8057DB48 = .sdata2:0x8057DB48; // type:object size:0x4 data:4byte +sNumHarpSongs__18dSndHarpSongData_c = .sdata2:0x8057DB48; // type:object size:0x4 data:4byte lbl_8057DB4C = .sdata2:0x8057DB4C; // type:object size:0x4 align:4 data:float @2557 = .sdata2:0x8057DB50; // type:object size:0x4 scope:local align:4 data:float @2558 = .sdata2:0x8057DB54; // type:object size:0x4 scope:local align:4 data:float diff --git a/configure.py b/configure.py index 65f972d8..e8f43b36 100644 --- a/configure.py +++ b/configure.py @@ -767,6 +767,7 @@ config.libs = [ Object(NonMatching, "d/snd/d_snd_bgm_mml_parsers.cpp"), Object(NonMatching, "d/snd/d_snd_small_effect_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_harp_song_mgr.cpp"), + Object(NonMatching, "d/snd/d_snd_harp_song_data.cpp"), Object(Matching, "d/snd/d_snd_anim_sound.cpp"), Object(NonMatching, "d/snd/d_snd_source_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_source_group.cpp"), diff --git a/include/d/snd/d_snd_bgm_mml_parsers.h b/include/d/snd/d_snd_bgm_mml_parsers.h index 52873832..0cff96f5 100644 --- a/include/d/snd/d_snd_bgm_mml_parsers.h +++ b/include/d/snd/d_snd_bgm_mml_parsers.h @@ -19,4 +19,17 @@ private: /* 0x298 */ dSndBgmSoundHarpMgr_c *field_0x298; }; +class dSndBgmMmlParserHarpSong_c : dSndBgmMmlParser_c { +public: + dSndBgmMmlParserHarpSong_c(); + + virtual void CommandProc(u32 trackNo, int wait, u32 command, s32 commandArg1, s32 commandArg2) const override; + virtual void NoteOnCommandProc(u32 trackNo, int wait, int key, int velocity, s32 length) const override; + + bool parseData(u32 soundId, dSndHarpSongData_c *pData); + +private: + /* 0x294 */ dSndHarpSongData_c *field_0x294; +}; + #endif diff --git a/include/d/snd/d_snd_fi_vocal_mgr.h b/include/d/snd/d_snd_fi_vocal_mgr.h index a918d990..19f743d0 100644 --- a/include/d/snd/d_snd_fi_vocal_mgr.h +++ b/include/d/snd/d_snd_fi_vocal_mgr.h @@ -14,9 +14,13 @@ public: void fiSpeak(const char *, u16, s32); void executeOutputText(u16, u16); + /** The bank argument affects what Fi is singing */ + bool startFiVocal(s16 pitch, s16 bank); + + s16 getStaticSongValue(s32, u32, s32, s32); private: - /* 0x10 */ nw4r::snd::SoundHandle mHandle; + /* 0x10 */ nw4r::snd::SoundHandle mSpeechHandle; }; #endif diff --git a/include/d/snd/d_snd_harp_song_data.h b/include/d/snd/d_snd_harp_song_data.h new file mode 100644 index 00000000..9ca29b0e --- /dev/null +++ b/include/d/snd/d_snd_harp_song_data.h @@ -0,0 +1,69 @@ +#ifndef D_SND_HARP_SONG_DATA_H +#define D_SND_HARP_SONG_DATA_H + +#include "common.h" + +class dSndHarpSongEntryBase_c { +public: + dSndHarpSongEntryBase_c(s16 count, s16 stride); + ~dSndHarpSongEntryBase_c(); + + void insert(u32 idx, s16 value); + s32 get(u32 idx) const; + + void reset(); + +private: + /* 0x00 */ s16 *mpData; + /* 0x04 */ u16 mCount; + /* 0x06 */ u16 mStride; +}; + +class dSndHarpSongEntry1_c : public dSndHarpSongEntryBase_c { + static const s32 NUM_ENTRIES_TYPE_1 = 24; + +public: + dSndHarpSongEntry1_c(); + void loadStaticData(s32 i1, u32 i2, s32 i3); + s16 getStaticDatum(u32 idx) const; + +private: + /* 0x08 */ s16 mStaticValues[24]; +}; + +class dSndHarpSongEntry2_c : public dSndHarpSongEntryBase_c { + static const s32 NUM_ENTRIES_TYPE_2 = 12; + +public: + dSndHarpSongEntry2_c() : dSndHarpSongEntryBase_c(NUM_ENTRIES_TYPE_2, NUM_ENTRIES_TYPE_2 * 2) {} + +private: +}; + +class dSndHarpSongData_c { +public: + dSndHarpSongData_c(); + + void init(u32 idx); + void loadStaticValues(); + + void insert2(u32 key, s16 value, s32); + void insert1(u32 key, s16 value); + + static const s32 sNumHarpSongs; + + void setSoundId(u32 id) { + mSoundId = id; + } + +private: + /* 0x00 */ u32 mSoundId; + /* 0x04 */ u32 mIndex; + /* 0x08 */ UNKWORD field_0x08; + /* 0x0C */ f32 field_0x0C; + /* 0x10 */ dSndHarpSongEntry2_c mEntries2[4][2][2]; + /* 0x90 */ UNKWORD field_0x90[4][2]; + /* 0xB0 */ dSndHarpSongEntry1_c mEntries1[4][2]; +}; + +#endif diff --git a/include/d/snd/d_snd_harp_song_mgr.h b/include/d/snd/d_snd_harp_song_mgr.h index 9b01bfc7..2ffca321 100644 --- a/include/d/snd/d_snd_harp_song_mgr.h +++ b/include/d/snd/d_snd_harp_song_mgr.h @@ -1,7 +1,10 @@ #ifndef D_SND_HARP_SONG_MGR_H #define D_SND_HARP_SONG_MGR_H +#include "common.h" #include "d/snd/d_snd_util.h" +#include "d/snd/d_snd_types.h" +#include "nw4r/snd/snd_SoundHandle.h" SND_DISPOSER_FORWARD_DECL(dSndHarpSongMgr_c); @@ -12,9 +15,63 @@ public: dSndHarpSongMgr_c(); void setup(); + void setupState0(); + void calc(); + nw4r::snd::SoundHandle &getFiSingHandle() { + return mFiSingHandle; + } + private: + + void resetFloatArr1(); + void resetFloatArr2(); + + /* 0x010 */ u8 field_0x010; + /* 0x011 */ u8 field_0x011; + /* 0x012 */ bool mDataLoaded; + /* 0x014 */ UNKWORD field_0x014; + /* 0x018 */ UNKWORD field_0x018; + /* 0x01C */ UNKWORD field_0x01C; + /* 0x020 */ UNKWORD field_0x020; + /* 0x024 */ UNKWORD field_0x024; + /* 0x028 */ UNKWORD field_0x028; + /* 0x02C */ UNKWORD field_0x02C; + /* 0x030 */ UNKWORD field_0x030; + /* 0x034 */ UNKWORD field_0x034; + /* 0x038 */ f32 field_0x038; + /* 0x03C */ f32 field_0x03C; + /* 0x040 */ u8 field_0x040; + /* 0x041 */ u8 field_0x041; + /* 0x042 */ u8 field_0x042; + /* 0x043 */ u8 field_0x043; + /* 0x044 */ u8 field_0x044; + /* 0x048 */ UNKWORD field_0x048; + /* 0x04C */ UNKWORD field_0x04C; + /* 0x050 */ UNKWORD field_0x050; + /* 0x054 */ UNKWORD field_0x054; + /* 0x058 */ UNKWORD field_0x058; + /* 0x05C */ UNKWORD field_0x05C; + /* 0x060 */ UNKWORD field_0x060; + /* 0x064 */ UNKWORD field_0x064; + /* 0x068 */ UNKWORD field_0x068; + /* 0x06C */ UNKWORD field_0x06C; + /* 0x070 */ f32 field_0x070; + /* 0x074 */ u8 _0x074[0x078 - 0x074]; + /* 0x078 */ u8 field_0x078; + /* 0x07C */ f32 field_0x07C[300]; + /* 0x52C */ f32 field_0x52C[30]; + + /* 0x5A4 */ dSndHarpSongData_c *mpData; + /* 0x5A8 */ dSndHarpSongData_c *mpTmpData; + /* 0x5AC */ UNKWORD field_0x5AC; + /* 0x5B0 */ nw4r::snd::SoundHandle mFiSingHandle; + /* 0x5B4 */ UNKWORD field_0x5B4; + /* 0x5B8 */ UNKWORD field_0x5B8; + /* 0x5BC */ u8 field_0x5BC; + /* 0x5C0 */ UNKWORD field_0x5C0; + /* 0x5C4 */ UNKWORD field_0x5C4; }; #endif diff --git a/include/d/snd/d_snd_state_mgr.h b/include/d/snd/d_snd_state_mgr.h index 4511ed2c..7ad4dbe2 100644 --- a/include/d/snd/d_snd_state_mgr.h +++ b/include/d/snd/d_snd_state_mgr.h @@ -189,6 +189,8 @@ public: void onCameraCut(s32 cutIdx); + static void clearExecuteCallback(); + private: void resetOverrides(); void initializeEventCallbacks(const char *name); diff --git a/include/d/snd/d_snd_types.h b/include/d/snd/d_snd_types.h index 901074b6..2edec499 100644 --- a/include/d/snd/d_snd_types.h +++ b/include/d/snd/d_snd_types.h @@ -26,4 +26,6 @@ class dSndBgmSoundHarpMgr_c; class dSndBgmSeqConfig; class dSndBgmBattleConfig; +class dSndHarpSongData_c; + #endif diff --git a/src/d/snd/d_snd_bgm_mml_parsers.cpp b/src/d/snd/d_snd_bgm_mml_parsers.cpp index 8e996ed6..c39624fe 100644 --- a/src/d/snd/d_snd_bgm_mml_parsers.cpp +++ b/src/d/snd/d_snd_bgm_mml_parsers.cpp @@ -3,6 +3,7 @@ #include "common.h" #include "d/snd/d_snd_bgm_seq_data_mgr.h" #include "d/snd/d_snd_bgm_sound_harp_mgr.h" +#include "d/snd/d_snd_harp_song_data.h" #include "d/snd/d_snd_mgr.h" #include "d/snd/d_snd_player_mgr.h" #include "nw4r/snd/snd_SoundArchive.h" @@ -68,3 +69,40 @@ void dSndBgmMmlParserHarp_c::NoteOnCommandProc(u32 trackNo, int wait, int key, i default: break; } } + +dSndBgmMmlParserHarpSong_c::dSndBgmMmlParserHarpSong_c() + : dSndBgmMmlParser_c(&dSndMgr_c::GetInstance()->getPlayer(), dSndMgr_c::GetInstance()->getArchive()) { + field_0x294 = nullptr; +} + +bool dSndBgmMmlParserHarpSong_c::parseData(u32 soundId, dSndHarpSongData_c *pData) { + if (soundId == -1) { + return false; + } + if (pData == nullptr) { + return false; + } + + field_0x294 = pData; + bool ok = loadAndParse(soundId, 0xFFFF, true); + field_0x294 = nullptr; + + return ok; +} + +void dSndBgmMmlParserHarpSong_c::CommandProc(u32 trackNo, int wait, u32 command, s32 commandArg1, s32 commandArg2) + const { + // no-op +} + +void dSndBgmMmlParserHarpSong_c::NoteOnCommandProc(u32 trackNo, int wait, int key, int velocity, s32 length) const { + if (trackNo >= 0 && trackNo < 2) { + if (field_0x294 != nullptr) { + field_0x294->insert2(wait, key, trackNo); + } + } else if (trackNo == 15) { + if (field_0x294 != nullptr) { + field_0x294->insert1(wait, key); + } + } +} diff --git a/src/d/snd/d_snd_fi_vocal_mgr.cpp b/src/d/snd/d_snd_fi_vocal_mgr.cpp index 1b841ded..de77016b 100644 --- a/src/d/snd/d_snd_fi_vocal_mgr.cpp +++ b/src/d/snd/d_snd_fi_vocal_mgr.cpp @@ -1,7 +1,42 @@ #include "d/snd/d_snd_fi_vocal_mgr.h" +#include "d/snd/d_snd_harp_song_mgr.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "d/snd/d_snd_util.h" +#include "d/snd/d_snd_wzsound.h" +#include "nw4r/snd/snd_SeqSoundHandle.h" +#include "nw4r/snd/snd_SoundHandle.h" SND_DISPOSER_DEFINE(dSndFiVocalMgr_c); dSndFiVocalMgr_c::dSndFiVocalMgr_c() {} + +void dSndFiVocalMgr_c::executeOutputText(u16, u16) { + // no-op +} + +bool dSndFiVocalMgr_c::startFiVocal(s16 pitch, s16 bank) { + nw4r::snd::SoundHandle &handle = dSndHarpSongMgr_c::GetInstance()->getFiSingHandle(); + handle.Stop(3); + mSpeechHandle.Stop(3); + + if (pitch < 0x39 || pitch > 0x4C) { + return false; + } + + if (bank < 0 || bank >= 9) { + return false; + } + + // Already stopped above, but again doesn't hurt + mSpeechHandle.Stop(3); + + bool ok = dSndSmallEffectMgr_c::GetInstance()->playSoundInternalChecked(SE_NpcKen_VOCAL, &handle); + if (ok) { + nw4r::snd::SeqSoundHandle seqHandle(&handle); + seqHandle.WriteVariable(0, pitch - 0x30); + seqHandle.WriteVariable(2, bank + 0x1F); + } + + return ok; +} diff --git a/src/d/snd/d_snd_harp_song_data.cpp b/src/d/snd/d_snd_harp_song_data.cpp new file mode 100644 index 00000000..b5ad90c6 --- /dev/null +++ b/src/d/snd/d_snd_harp_song_data.cpp @@ -0,0 +1,113 @@ +#include "d/snd/d_snd_harp_song_data.h" + +#include "common.h" +#include "d/snd/d_snd_fi_vocal_mgr.h" + +const s32 dSndHarpSongData_c::sNumHarpSongs = 6; +static const f32 sUnkSongVals[] = { + 40.0f, + 40.0f, + 40.0f, + 40.0f, + 40.0f, + 40.0f, +}; + +dSndHarpSongEntryBase_c::dSndHarpSongEntryBase_c(s16 count, s16 stride) : mCount(count), mStride(stride) { + mpData = new s16[count]; + reset(); +} + +dSndHarpSongEntryBase_c::~dSndHarpSongEntryBase_c() { + delete[] mpData; +} + +void dSndHarpSongEntryBase_c::reset() { + for (int i = 0; i < mCount; i++) { + mpData[i] = -1; + } +} + +void dSndHarpSongEntryBase_c::insert(u32 idx, s16 value) { + // TODO - magic number + if (idx > 0x120) { + return; + } + + u32 insert = 0; + while (mStride <= idx) { + insert++; + idx -= mStride; + } + mpData[insert] = value; +} + +s32 dSndHarpSongEntryBase_c::get(u32 idx) const { + if (idx >= mCount) { + return -1; + } + return mpData[idx]; +} + +dSndHarpSongEntry1_c::dSndHarpSongEntry1_c() : dSndHarpSongEntryBase_c(NUM_ENTRIES_TYPE_1, NUM_ENTRIES_TYPE_1 / 2) { + reset(); + for (s32 i = 0; i < NUM_ENTRIES_TYPE_1; i++) { + mStaticValues[i] = 0; + } +} + +void dSndHarpSongEntry1_c::loadStaticData(s32 i1, u32 i2, s32 i3) { + for (s32 i = 0; i < NUM_ENTRIES_TYPE_1; i++) { + if (get(i) > 0) { + mStaticValues[i] = dSndFiVocalMgr_c::GetInstance()->getStaticSongValue(i1, i2, i3, i); + } + } +} + +s16 dSndHarpSongEntry1_c::getStaticDatum(u32 idx) const { + if (idx >= NUM_ENTRIES_TYPE_1) { + return -1; + } + return mStaticValues[idx]; +} + +dSndHarpSongData_c::dSndHarpSongData_c() : field_0x0C(30.0f) { + init(0); +} + +void dSndHarpSongData_c::init(u32 idx) { + if (idx >= sNumHarpSongs) { + return; + } + mIndex = idx; + mSoundId = -1; + field_0x08 = 0; + + for (s32 i1 = 0; i1 < 4; i1++) { + for (u32 i2 = 0; i2 < 2; i2++) { + for (s32 i3 = 0; i3 < 2; i3++) { + mEntries2[i1][i2][i3].reset(); + } + field_0x90[i1][i2] = 0; + } + } + + field_0x0C = sUnkSongVals[mIndex]; + loadStaticValues(); +} + +void dSndHarpSongData_c::loadStaticValues() { + for (s32 i1 = 0; i1 < 4; i1++) { + for (u32 i2 = 0; i2 < 2; i2++) { + mEntries1[i1][i2].loadStaticData(mIndex, i1, i2); + } + } +} + +void dSndHarpSongData_c::insert2(u32 key, s16 value, s32) { + // TODO +} + +void dSndHarpSongData_c::insert1(u32 key, s16 value) { + // TODO +} diff --git a/src/d/snd/d_snd_harp_song_mgr.cpp b/src/d/snd/d_snd_harp_song_mgr.cpp index 15b066df..54598591 100644 --- a/src/d/snd/d_snd_harp_song_mgr.cpp +++ b/src/d/snd/d_snd_harp_song_mgr.cpp @@ -1,7 +1,86 @@ #include "d/snd/d_snd_harp_song_mgr.h" +#include "common.h" +#include "d/snd/d_snd_bgm_mml_parsers.h" +#include "d/snd/d_snd_harp_song_data.h" #include "d/snd/d_snd_util.h" +#include "d/snd/d_snd_wzsound.h" SND_DISPOSER_DEFINE(dSndHarpSongMgr_c); -dSndHarpSongMgr_c::dSndHarpSongMgr_c() {} +dSndHarpSongMgr_c::dSndHarpSongMgr_c() + : field_0x010(0), + field_0x011(0), + mDataLoaded(false), + field_0x014(0), + field_0x018(0), + field_0x01C(0), + field_0x020(0), + field_0x024(0), + field_0x028(0), + field_0x02C(0), + field_0x030(0), + field_0x034(0), + field_0x038(0.0f), + field_0x03C(1.0f), + field_0x040(0), + field_0x041(0), + field_0x042(0), + field_0x043(0), + field_0x044(1), + field_0x048(0), + field_0x04C(3), + field_0x050(3), + field_0x054(3), + field_0x064(0), + field_0x068(0), + field_0x070(0), + field_0x078(0), + mpTmpData(nullptr), + field_0x5AC(0), + field_0x5B4(0), + field_0x5B8(0), + field_0x5BC(0), + field_0x5C0(4), + field_0x5C4(4) { + resetFloatArr1(); + resetFloatArr2(); + + field_0x058 = 3; + field_0x05C = 3; + field_0x060 = 3; + mpData = new dSndHarpSongData_c[dSndHarpSongData_c::sNumHarpSongs]; +} + +void dSndHarpSongMgr_c::setup() { + // no-op +} + +void dSndHarpSongMgr_c::setupState0() { + if (mDataLoaded) { + return; + } + + dSndBgmMmlParserHarpSong_c parser; + for (int i = 0; i < dSndHarpSongData_c::sNumHarpSongs; i++) { + mpData[i].init(i); + u32 soundId = LABEL_HARP_TONE_RAW_START + 1 + i; + parser.parseData(soundId, mpData + i); + mpData[i].setSoundId(soundId); + mpData[i].loadStaticValues(); + } + + mDataLoaded = true; +} + +void dSndHarpSongMgr_c::resetFloatArr1() { + for (int i = 0; i < 300; i++) { + field_0x07C[i] = 0.0f; + } +} + +void dSndHarpSongMgr_c::resetFloatArr2() { + for (int i = 0; i < 30; i++) { + field_0x52C[i] = 0.0f; + } +} diff --git a/src/d/snd/d_snd_state_mgr.cpp b/src/d/snd/d_snd_state_mgr.cpp index 01f44897..4efc4a21 100644 --- a/src/d/snd/d_snd_state_mgr.cpp +++ b/src/d/snd/d_snd_state_mgr.cpp @@ -386,6 +386,10 @@ u32 dSndStateMgr_c::getSeCameraId() { return convertSeLabelToSoundId(label); } +void dSndStateMgr_c::clearExecuteCallback() { + sEventExecuteCallback = nullptr; +} + void dSndStateMgr_c::handleSeLv() { SizedString<0x40> name = mSeName; name += "_LV"; @@ -480,7 +484,7 @@ void dSndStateMgr_c::onMsgWaitStart() { } SizedString<64> label; - label.sprintf("_%M_WS%d", mMsgCounter, mMsgWaitSelectCounter); + label.sprintf("_M%d_WS%d", mMsgCounter, mMsgWaitSelectCounter); doLabelSuffix(label); } @@ -490,7 +494,7 @@ void dSndStateMgr_c::onMsgWaitEnd() { } SizedString<64> label; - label.sprintf("_%M_WE%d", mMsgCounter, mMsgWaitSelectCounter); + label.sprintf("_M%d_WE%d", mMsgCounter, mMsgWaitSelectCounter); doLabelSuffix(label); }