diff --git a/config/HAFE/splits.txt b/config/HAFE/splits.txt index 27c79464..d06660eb 100644 --- a/config/HAFE/splits.txt +++ b/config/HAFE/splits.txt @@ -302,7 +302,7 @@ SimpleGlobe.cpp: .ctors start:0x80179290 end:0x80179294 .rodata start:0x8018F730 end:0x8018F7B0 .data start:0x8019C630 end:0x8019C640 - .bss start:0x801F76A0 end:0x801F76C4 + .bss start:0x801F76A0 end:0x801F76C8 .sdata start:0x803301E0 end:0x803301E8 .sbss start:0x80330C28 end:0x80330C34 .sdata2 start:0x80332098 end:0x80332130 @@ -310,15 +310,15 @@ SimpleGlobe.cpp: Sound.cpp: .text start:0x80041704 end:0x80041884 .ctors start:0x80179294 end:0x80179298 - .bss start:0x801F76C4 end:0x801F76E8 + .bss start:0x801F76C8 end:0x801F76E8 -sound_manager.cpp: +SoundManager.cpp: .text start:0x80041884 end:0x80044AAC .ctors start:0x80179298 end:0x8017929C .data start:0x8019C640 end:0x801B3C80 .bss start:0x801F76E8 end:0x801F7740 .sdata start:0x803301E8 end:0x803301F0 - .sbss start:0x80330C34 end:0x80330C88 + .sbss start:0x80330C38 end:0x80330C88 .sdata2 start:0x80332130 end:0x80332150 revolution/CNT/cnt.c: diff --git a/config/HAFE/symbols.txt b/config/HAFE/symbols.txt index 873c3b20..b1945d9c 100644 --- a/config/HAFE/symbols.txt +++ b/config/HAFE/symbols.txt @@ -975,20 +975,20 @@ PlayRotateSound__11SimpleGlobeFUl = .text:0x800410A4; // type:function size:0x11 UpdateWater__11SimpleGlobeFv = .text:0x800411B4; // type:function size:0x4BC __sinit_\SimpleGlobe_cpp = .text:0x80041670; // type:function size:0x94 scope:local __ct__5SoundFPCcPv = .text:0x80041704; // type:function size:0x80 -fn_80041784 = .text:0x80041784; // type:function size:0x8 +DefaultSoundAlloc__FUl = .text:0x80041784; // type:function size:0x8 __dt__5SoundFv = .text:0x8004178C; // type:function size:0x70 UpdateSound__Fv = .text:0x800417FC; // type:function size:0x4 CalcSound__Fv = .text:0x80041800; // type:function size:0x4 __sinit_\Sound_cpp = .text:0x80041804; // type:function size:0x58 scope:local -fn_8004185C = .text:0x8004185C; // type:function size:0xC -fn_80041868 = .text:0x80041868; // type:function size:0x1C -fn_80041884 = .text:0x80041884; // type:function size:0x24 -fn_800418A8 = .text:0x800418A8; // type:function size:0x390 -fn_80041C38 = .text:0x80041C38; // type:function size:0x260 +__ct__Q34nw4r3snd11SoundHandleFv = .text:0x8004185C; // type:function size:0xC +__arraydtor$8191 = .text:0x80041868; // type:function size:0x1C +fn_80041884__FPvPvPFUl_PvPFPv_v = .text:0x80041884; // type:function size:0x24 +fn_800418A8__FUcPvPCcPvUlPFUl_PvPFPv_v = .text:0x800418A8; // type:function size:0x390 +fn_80041C38__Fv = .text:0x80041C38; // type:function size:0x260 fn_80041E98 = .text:0x80041E98; // type:function size:0x40 __dt__Q34nw4r3snd10FxReverbHiFv = .text:0x80041ED8; // type:function size:0x7C scope:weak -fn_80041F54 = .text:0x80041F54; // type:function size:0x190 -fn_800420E4 = .text:0x800420E4; // type:function size:0x4C +fn_80041F54__Fv = .text:0x80041F54; // type:function size:0x190 +fn_800420E4__FUc = .text:0x800420E4; // type:function size:0x4C fn_80042130 = .text:0x80042130; // type:function size:0x224 fn_80042354 = .text:0x80042354; // type:function size:0x1CC PlaySE__Fl = .text:0x80042520; // type:function size:0x120 @@ -8584,7 +8584,7 @@ lbl_801F76A0 = .bss:0x801F76A0; // type:object size:0xC lbl_801F76AC = .bss:0x801F76AC; // type:object size:0xC lbl_801F76B8 = .bss:0x801F76B8; // type:object size:0xC lbl_801F76C8 = .bss:0x801F76C8; // type:object size:0xC -gAmbientSounds = .bss:0x801F76D4; // type:object size:0x10 +gAmbientSounds = .bss:0x801F76D4; // type:object size:0x14 lbl_801F76E8 = .bss:0x801F76E8; // type:object size:0x30 align:4 data:float lbl_801F7718 = .bss:0x801F7718; // type:object size:0x28 data:byte VFipdm_disk_set = .bss:0x801F7740; // type:object size:0xB64 scope:global data:2byte @@ -9785,13 +9785,13 @@ gRotateSoundHandle = .sbss:0x80330C2C; // type:object size:0x4 data:4byte gGlobeLightColor = .sbss:0x80330C30; // type:object size:0x4 data:byte lbl_80330C38 = .sbss:0x80330C38; // type:object size:0x1 data:byte lbl_80330C39 = .sbss:0x80330C39; // type:object size:0x1 data:byte -lbl_80330C3C = .sbss:0x80330C3C; // type:object size:0x4 data:4byte -lbl_80330C40 = .sbss:0x80330C40; // type:object size:0x4 data:4byte -lbl_80330C44 = .sbss:0x80330C44; // type:object size:0x4 data:4byte -lbl_80330C48 = .sbss:0x80330C48; // type:object size:0x4 data:4byte +gAllocFunc = .sbss:0x80330C3C; // type:object size:0x4 data:4byte +gMemFunc = .sbss:0x80330C40; // type:object size:0x4 data:4byte +gMemSoundArchive = .sbss:0x80330C44; // type:object size:0x4 data:4byte +gArchivePlayer = .sbss:0x80330C48; // type:object size:0x4 data:4byte lbl_80330C4C = .sbss:0x80330C4C; // type:object size:0x4 data:4byte -lbl_80330C50 = .sbss:0x80330C50; // type:object size:0x4 data:4byte -lbl_80330C54 = .sbss:0x80330C54; // type:object size:0x4 data:4byte +gSoundHeap = .sbss:0x80330C50; // type:object size:0x4 data:4byte +gFxReverb = .sbss:0x80330C54; // type:object size:0x4 data:4byte lbl_80330C58 = .sbss:0x80330C58; // type:object size:0x4 data:4byte lbl_80330C5C = .sbss:0x80330C5C; // type:object size:0x4 data:4byte lbl_80330C60 = .sbss:0x80330C60; // type:object size:0x4 data:4byte diff --git a/configure.py b/configure.py index a96183f2..b9ea27bc 100755 --- a/configure.py +++ b/configure.py @@ -825,6 +825,7 @@ def MatchingFor(*versions): "lib": "MSL_C", "mw_version": "GC/3.0a3", "cflags": [*cflags_msl, "-Cpp_exceptions off"], + "progress_category": "mslc", "objects": [ Object(Matching, "MSL_C/MSL_Common_Embedded/Math/Double_precision/e_acos.c"), Object(Matching, "MSL_C/MSL_Common_Embedded/Math/Double_precision/e_asin.c"), @@ -1104,6 +1105,7 @@ def MatchingFor(*versions): Object(Matching, "main.cpp"), Object(Matching, "DrawUtil.cpp"), Object(Matching, "GlobeDots.cpp"), + Object(NonMatching, "GlobeDotsTable.cpp"), Object(Matching, "WiiConnect24.cpp"), Object(Matching, "WeatherUtil.cpp"), Object(Matching, "ChannelMathData.cpp"), @@ -1121,7 +1123,8 @@ def MatchingFor(*versions): Object(Matching, "GlobeView.cpp"), Object(Matching, "SceneBase.cpp", extra_cflags=["-ipa file"]), Object(Matching, "SimpleGlobe.cpp", extra_cflags=["-ipa file"]), - Object(NonMatching, "GlobeDotsTable.cpp"), + Object(NonMatching, "Sound.cpp"), + Object(NonMatching, "SoundManager.cpp"), ], }, { diff --git a/include/channel/Sound.h b/include/channel/Sound.h index 43748224..fedec4fc 100644 --- a/include/channel/Sound.h +++ b/include/channel/Sound.h @@ -17,6 +17,9 @@ class Sound { void* mHeap; // at 0x4 }; +void UpdateSound(); +void CalcSound(); + void StartSound(nw4r::snd::SoundHandle* handle, u32 id); void StopSound(nw4r::snd::SoundHandle* handle, s32 fadeFrames); void SetSoundVolume(nw4r::snd::SoundHandle* handle, f32 volume); diff --git a/include/channel/SoundManager.h b/include/channel/SoundManager.h new file mode 100644 index 00000000..514114ca --- /dev/null +++ b/include/channel/SoundManager.h @@ -0,0 +1,10 @@ +#include "types.h" + +void fn_80041884(void* data, void* heap, void *(*alloc_func)(u32), void (*mem_func)(void *)); +void fn_800418A8(u32 arg1, void* data, u32 arg3, void* heap, u32 arg5, void* (*alloc_func)(u32), void (*mem_func)(void*)); +void fn_80041C38(); +void fn_80041F54(); +void fn_800420E4(u8 sound_mode); + +typedef void *(*SoundAllocFunc)(u32); +typedef void (*SoundMemFunc)(void*); diff --git a/include/nw4r/snd/snd_SoundArchivePlayer.h b/include/nw4r/snd/snd_SoundArchivePlayer.h index 0e9d3773..cedccbe3 100644 --- a/include/nw4r/snd/snd_SoundArchivePlayer.h +++ b/include/nw4r/snd/snd_SoundArchivePlayer.h @@ -1,5 +1,6 @@ #ifndef NW4R_SND_SOUND_ARCHIVE_PLAYER_H #define NW4R_SND_SOUND_ARCHIVE_PLAYER_H +#include "nw4r/snd/snd_SoundArchiveLoader.h" #include #include diff --git a/src/SceneBase.cpp b/src/SceneBase.cpp index 896a4ee2..c8a34528 100644 --- a/src/SceneBase.cpp +++ b/src/SceneBase.cpp @@ -40,8 +40,6 @@ struct DragScroll { void PlaySE(s32 id); -void UpdateSound(); -void CalcSound(); extern "C" void HBMStartBlackOut(void); static const u32 sGlyphTextureIds[89] = { diff --git a/src/Sound.cpp b/src/Sound.cpp new file mode 100644 index 00000000..47cf1aaa --- /dev/null +++ b/src/Sound.cpp @@ -0,0 +1,37 @@ +#include "Sound.h" +#include "System.h" +#include "SoundManager.h" +#include "nw4r/snd/snd_SoundHandle.h" +#include "revolution/SC/scapi.h" + +void *DefaultSoundAlloc(u32 size); + +nw4r::snd::SoundHandle gAmbientSounds[5]; + +Sound::Sound(const char* path, void* heap) { + this->mData = LoadContentFile(gUnk80330B64, path, 0x20, NULL, gMEM2Heap); + this->mHeap = heap; + + if (this->mData) { + fn_80041884(this->mData, this->mHeap, DefaultSoundAlloc, MEM2Free); + fn_800420E4(SCGetSoundMode()); + } +} + +void *DefaultSoundAlloc(u32 size) { + return MEM2Alloc(size, 0x20); +} + +Sound::~Sound() { + if (this->mData) { + fn_80041C38(); + MEM2Free(this->mData); + this->mData = NULL; + } +} + +void UpdateSound() {} + +void CalcSound() { + fn_80041F54(); +} diff --git a/src/SoundManager.cpp b/src/SoundManager.cpp new file mode 100644 index 00000000..df1b7f54 --- /dev/null +++ b/src/SoundManager.cpp @@ -0,0 +1,61 @@ +#include "SoundManager.h" + +#include "nw4r/snd/snd_DvdSoundArchive.h" +#include "nw4r/snd/snd_FxReverbHi.h" +#include "nw4r/snd/snd_MemorySoundArchive.h" +#include "nw4r/snd/snd_SoundArchivePlayer.h" +#include "nw4r/snd/snd_SoundHeap.h" +#include "nw4r/snd/snd_SoundSystem.h" + +u8 lbl_80330C38 = 0; +u8 lbl_80330C39 = 0; +SoundAllocFunc gAllocFunc = 0; // 0x3C +SoundMemFunc gMemFunc = 0; // 0x40 +void *gMemSoundArchive = NULL; // 0x44 +nw4r::snd::SoundArchivePlayer *gArchivePlayer = NULL; // 0x48 +u32 *lbl_80330C4C = NULL; // 0x4C, something that inherits SoundArchive... +nw4r::snd::SoundHeap *gSoundHeap = NULL; // 0x50 +nw4r::snd::FxReverbHi *gFxReverb = NULL; // 0x6C + +void fn_80041884(void* data, void* heap, void* (*alloc_func)(u32), void (*mem_func)(void*)) { + fn_800418A8(1, data, 0, heap, 0, alloc_func, mem_func); +} + + +void fn_800418A8(u8 arg1, void* data, const char *arg3, void* heap, u32 arg5, void* (*alloc_func)(u32), void (*mem_func)(void*)) { + if (lbl_80330C39 != 0) return; + + lbl_80330C39 = 1; + lbl_80330C38 = arg1; + gAllocFunc = alloc_func; + gMemFunc = mem_func; + + nw4r::snd::MemorySoundArchive *mem_sound_archive = NULL; + nw4r::snd::DvdSoundArchive *dvd_sound_archive = NULL; + if (arg1 != 0) { + gMemSoundArchive = mem_sound_archive = new nw4r::snd::MemorySoundArchive(); + } else { + gMemSoundArchive = dvd_sound_archive = new nw4r::snd::DvdSoundArchive(); + } + + gSoundHeap = new nw4r::snd::SoundHeap(); + gArchivePlayer = new nw4r::snd::SoundArchivePlayer(); + lbl_80330C4C = new u32(0); + gFxReverb = new nw4r::snd::FxReverbHi(); + + if (!AICheckInit()) { + AIInit(NULL); + AXInit(); + } + + nw4r::snd::SoundSystem::InitSoundSystem(4, 3); + + if (lbl_80330C38 != 0) { + mem_sound_archive->Setup(data); + } else { + if (!dvd_sound_archive->Open(arg3)) { + // __LINE__ + OSPanic("sound_manager.cpp", 0x19D, "Cannot open Sound Archive File"); + } + } +}