diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 867717db..450d7d23 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2803,8 +2803,17 @@ d/snd/d_snd_mgr_unk_17.cpp: d/snd/d_snd_fi_vocal_mgr.cpp: .text start:0x80399580 end:0x80399A3C align:16 +d/snd/d_snd_rng.cpp: + .text start:0x80399A40 end:0x80399BA0 align:16 + .data start:0x8054D7A8 end:0x8054D7B8 + +d/snd/d_snd_rng_mgr.cpp: + .text start:0x80399BA0 end:0x80399D60 align:16 + .data start:0x8054D7B8 end:0x8054D7D0 + .sbss start:0x80575DE8 end:0x80575DF0 + d/snd/d_snd_mgr_unk_11.cpp: - .text start:0x80399A40 end:0x8039A848 align:16 + .text start:0x80399D60 end:0x8039A848 align:16 .ctors start:0x804DB934 end:0x804DB938 d/snd/d_snd_calc_pitch.cpp: diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 9a03474b..41df78bf 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -21266,7 +21266,7 @@ fn_8038D540 = .text:0x8038D540; // type:function size:0x8 linkSoundRelated = .text:0x8038D550; // type:function size:0x7C fn_8038D5D0 = .text:0x8038D5D0; // type:function size:0x40 fn_8038D610 = .text:0x8038D610; // type:function size:0x40 -fn_8038D650 = .text:0x8038D650; // type:function size:0x40 +__dt__9dSndRng_cFv = .text:0x8038D650; // type:function size:0x40 fn_8038D690 = .text:0x8038D690; // type:function size:0x74 fn_8038D710 = .text:0x8038D710; // type:function size:0x8 actuallyPlaysLinkSound = .text:0x8038D720; // type:function size:0x334 @@ -21619,15 +21619,15 @@ fn_803996B0 = .text:0x803996B0; // type:function size:0x1EC fn_803998A0 = .text:0x803998A0; // type:function size:0x4 fn_803998B0 = .text:0x803998B0; // type:function size:0x120 fn_803999D0 = .text:0x803999D0; // type:function size:0x6C -fn_80399A40 = .text:0x80399A40; // type:function size:0x50 -fn_80399A90 = .text:0x80399A90; // type:function size:0x44 -fn_80399AE0 = .text:0x80399AE0; // type:function size:0x5C -fn_80399B40 = .text:0x80399B40; // type:function size:0x60 -__dt__32SndMgrDisposer<14SndMgr80399c20>Fv = .text:0x80399BA0; // type:function size:0x78 -create__32SndMgrDisposer<14SndMgr80399c20>Fv = .text:0x80399C20; // type:function size:0x84 -remove__32SndMgrDisposer<14SndMgr80399c20>Fv = .text:0x80399CB0; // type:function size:0x10 -fn_80399CC0 = .text:0x80399CC0; // type:function size:0x34 -__dt__14SndMgr80399c20Fv = .text:0x80399D00; // type:function size:0x5C +__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 +rndBool__9dSndRng_cFl = .text:0x80399B40; // type:function size:0x60 +__dt__30SndMgrDisposer<12dSndRngMgr_c>Fv = .text:0x80399BA0; // type:function size:0x78 scope:weak +create__30SndMgrDisposer<12dSndRngMgr_c>Fv = .text:0x80399C20; // type:function size:0x84 scope:weak +remove__30SndMgrDisposer<12dSndRngMgr_c>Fv = .text:0x80399CB0; // type:function size:0x10 scope:weak +rndIntRange__12dSndRngMgr_cFll = .text:0x80399CC0; // type:function size:0x34 +__dt__12dSndRngMgr_cFv = .text:0x80399D00; // type:function size:0x5C scope:weak fn_80399D60 = .text:0x80399D60; // type:function size:0x44 fn_80399DB0 = .text:0x80399DB0; // type:function size:0x34 fn_80399DF0 = .text:0x80399DF0; // type:function size:0x15C @@ -38107,9 +38107,9 @@ lbl_8054D740 = .data:0x8054D740; // type:object size:0x20 lbl_8054D760 = .data:0x8054D760; // type:object size:0xC jumptable_8054D76C = .data:0x8054D76C; // type:object size:0x30 scope:local lbl_8054D79C = .data:0x8054D79C; // type:object size:0xC -lbl_8054D7A8 = .data:0x8054D7A8; // type:object size:0x10 -lbl_8054D7B8 = .data:0x8054D7B8; // type:object size:0xC -lbl_8054D7C4 = .data:0x8054D7C4; // type:object size:0xC +__vt__9dSndRng_c = .data:0x8054D7A8; // type:object size:0x10 +__vt__12dSndRngMgr_c = .data:0x8054D7B8; // type:object size:0xC scope:weak +__vt__30SndMgrDisposer<12dSndRngMgr_c> = .data:0x8054D7C4; // type:object size:0xC scope:weak lbl_8054D7D0 = .data:0x8054D7D0; // type:object size:0x10 lbl_8054D7E0 = .data:0x8054D7E0; // type:object size:0x30 lbl_8054D810 = .data:0x8054D810; // type:object size:0x48 @@ -42302,8 +42302,8 @@ sInstance__17dSndSeSoundPool_c = .sbss:0x80575DD8; // type:object size:0x4 data: sDisposer__17dSndSeSoundPool_c = .sbss:0x80575DDC; // type:object size:0x4 data:4byte lbl_80575DE0 = .sbss:0x80575DE0; // type:object size:0x4 data:4byte lbl_80575DE4 = .sbss:0x80575DE4; // type:object size:0x4 data:4byte -lbl_80575DE8 = .sbss:0x80575DE8; // type:object size:0x4 data:4byte -lbl_80575DEC = .sbss:0x80575DEC; // type:object size:0x4 data:4byte +sInstance__12dSndRngMgr_c = .sbss:0x80575DE8; // type:object size:0x4 data:4byte +sDisposer__12dSndRngMgr_c = .sbss:0x80575DEC; // type:object size:0x4 data:4byte kprProcDeadKeysFP = .sbss:0x80575DF0; // type:object size:0x4 data:4byte kprProcRomajiFP = .sbss:0x80575DF4; // type:object size:0x4 data:4byte @LOCAL@KPRInitQueue__FP9_KPRQueue@once = .sbss:0x80575DF8; // type:object size:0x8 data:byte diff --git a/configure.py b/configure.py index a6af268e..0b361040 100644 --- a/configure.py +++ b/configure.py @@ -788,6 +788,9 @@ config.libs = [ Object(NonMatching, "d/snd/d_snd_sound_tgsound_callbacks.cpp"), Object(NonMatching, "d/snd/d_snd_mgr_unk_17.cpp"), Object(NonMatching, "d/snd/d_snd_fi_vocal_mgr.cpp"), + Object(NonMatching, "d/snd/d_snd_rng.cpp"), + Object(Matching, "d/snd/d_snd_rng_mgr.cpp"), + # more rng related Object(NonMatching, "d/snd/d_snd_mgr_unk_11.cpp"), Object(NonMatching, "d/snd/d_snd_calc_pitch.cpp"), ], diff --git a/include/d/snd/d_snd_rng.h b/include/d/snd/d_snd_rng.h new file mode 100644 index 00000000..28f9ffd4 --- /dev/null +++ b/include/d/snd/d_snd_rng.h @@ -0,0 +1,21 @@ +#ifndef D_SND_RNG_H +#define D_SND_RNG_H + +#include "common.h" + +class dSndRng_c { +public: + dSndRng_c(); + virtual ~dSndRng_c() {} + + bool rndBool(s32 chance); + u32 rndInt(s32 max); + +private: + void init(); + + /* 0x08 */ u64 field_0x08; + /* 0x10 */ u64 field_0x10; +}; + +#endif diff --git a/include/d/snd/d_snd_rng_mgr.h b/include/d/snd/d_snd_rng_mgr.h new file mode 100644 index 00000000..9ef8adab --- /dev/null +++ b/include/d/snd/d_snd_rng_mgr.h @@ -0,0 +1,19 @@ +#ifndef D_SND_RNG_MGR_H +#define D_SND_RNG_MGR_H + +#include "d/snd/d_snd_rng.h" +#include "d/snd/d_snd_util.h" + +SND_DISPOSER_FORWARD_DECL(dSndRngMgr_c) + +class dSndRngMgr_c : public dSndRng_c { +public: + SND_DISPOSER_MEMBERS(dSndRngMgr_c) + + u32 rndIntRange(s32 min, s32 max); + +public: + dSndRngMgr_c() {} +}; + +#endif diff --git a/src/d/snd/d_snd_mgr_unk_11.cpp b/src/d/snd/d_snd_mgr_unk_11.cpp deleted file mode 100644 index 5ad3cddc..00000000 --- a/src/d/snd/d_snd_mgr_unk_11.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -#include "d/snd/d_snd_util.h" - -class SndClass80399a40 { -public: - SndClass80399a40(); - virtual ~SndClass80399a40() {} - - /* 0x04 */ u8 _0x04[0x18 - 0x04]; -}; - -// This is a test for SndMgrDisposer, since this -// class has the disposer at 0x18, which is interesting - -class SndMgr80399c20; - -extern template class SndMgrDisposer; - -class SndMgr80399c20 : SndClass80399a40 { -public: - SndMgrDisposer *GetDisposer() { - return &mDisposer; - } - - static SndMgr80399c20 *GetInstance() { - return sInstance; - } - - static SndMgr80399c20 *sInstance; - static SndMgrDisposer *sDisposer; - -private: - SndMgrDisposer mDisposer; -}; - -template class SndMgrDisposer; diff --git a/src/d/snd/d_snd_rng.cpp b/src/d/snd/d_snd_rng.cpp new file mode 100644 index 00000000..b1a5994e --- /dev/null +++ b/src/d/snd/d_snd_rng.cpp @@ -0,0 +1,42 @@ +#include "d/snd/d_snd_rng.h" + +#include "rvl/OS/OSTime.h" + +dSndRng_c::dSndRng_c() : field_0x08(0), field_0x10(0) { + init(); +} + +void dSndRng_c::init() { + u32 tick = OSGetTick(); + field_0x08 = ((tick << 0x10) & 0xFFF0000) | tick >> 0x10; + field_0x10 = field_0x08; +} + +u32 dSndRng_c::rndInt(s32 max) { + // TODO + return 0; +/* + s32 temp_r0; + s32 temp_r11; + + temp_r11 = this->unkC; + this->unkC = (temp_r11 * 0xB2E3D431) + 0x508EBD; + temp_r0 = MULTU_HI(temp_r11, 0xB2E3D431) + (this->unk8 * 0xB2E3D431) + (temp_r11 * 0x690379B2) + M2C_CARRY; + this->unk8 = temp_r0; + return MULTU_HI(temp_r0, arg0) + (0 * arg0); +=> + + lo_1 = (lo_0 * 0xB2E3D431) + 0x508EBD; + hi_1 = MULTU_HI(lo_0, 0xB2E3D431) + (hi_0 * 0xB2E3D431) + (lo_0 * 0x690379B2) + M2C_CARRY; + return MULTU_HI(hi_1, arg0) + (0 * arg0); +*/ +} + +bool dSndRng_c::rndBool(s32 chance) { + if (chance >= 100) { + return true; + } else if (chance <= 0) { + return false; + } + return rndInt(100) < chance; +} diff --git a/src/d/snd/d_snd_rng_mgr.cpp b/src/d/snd/d_snd_rng_mgr.cpp new file mode 100644 index 00000000..5c31fbd4 --- /dev/null +++ b/src/d/snd/d_snd_rng_mgr.cpp @@ -0,0 +1,10 @@ + +#include "d/snd/d_snd_rng_mgr.h" + +#include "d/snd/d_snd_util.h" + +SND_DISPOSER_DEFINE(dSndRngMgr_c) + +u32 dSndRngMgr_c::rndIntRange(s32 min, s32 max) { + return min + rndInt(max - min); +}