se sound pool

This commit is contained in:
robojumper
2025-06-14 00:35:04 +02:00
parent 05c7eb29c9
commit baa9c8e5de
11 changed files with 210 additions and 38 deletions
+1
View File
@@ -2758,6 +2758,7 @@ d/snd/d_snd_se_sound_2.cpp:
d/snd/d_snd_se_sound_pool.cpp:
.text start:0x803947B0 end:0x80394DD4 align:16
.data start:0x8054D4B8 end:0x8054D4C8
.sbss start:0x80575DD8 end:0x80575DE0
d/snd/d_snd_sound_link_body_callbacks.cpp:
.text start:0x80394DE0 end:0x803957B8 align:16
+21 -21
View File
@@ -20876,7 +20876,7 @@ playButtonPressSoundWhenAdvancingTextBoxes__20dSndSmallEffectMgr_cFf = .text:0x8
resetButtonPressSound__20dSndSmallEffectMgr_cFv = .text:0x8037F0E0; // type:function size:0xC
setButtonPressSound__20dSndSmallEffectMgr_cFP14dSoundSource_c = .text:0x8037F0F0; // type:function size:0x60
fn_8037F150 = .text:0x8037F150; // type:function size:0x6D0
d_s_vt_0x17C__14dSoundSource_cFv = .text:0x8037F820; // type:function size:0x8
getName__14dSoundSource_cCFv = .text:0x8037F820; // type:function size:0x8
vt_0x18__14dSoundSource_cFv = .text:0x8037F830; // type:function size:0x8
fn_8037F840 = .text:0x8037F840; // type:function size:0x74
fn_8037F8C0 = .text:0x8037F8C0; // type:function size:0x78
@@ -21026,7 +21026,7 @@ load__14dSoundSource_cFPvPCc = .text:0x80385A50; // type:function size:0x4
isReadyMaybe__14dSoundSource_cFv = .text:0x80385A60; // type:function size:0x8
vt_0xF0__14dSoundSource_cFv = .text:0x80385A70; // type:function size:0x4
d_s_vt_0x1CC__14dSoundSource_cFv = .text:0x80385A80; // type:function size:0x4
d_s_vt_0x1C0__14dSoundSource_cFv = .text:0x80385A90; // type:function size:0x34
hasDistantSounds__14dSoundSource_cCFv = .text:0x80385A90; // type:function size:0x34
vt_0xE8__14dSoundSource_cFv = .text:0x80385AD0; // type:function size:0x8
vt_0xEC__14dSoundSource_cFv = .text:0x80385AE0; // type:function size:0x8
vt_0xE0__14dSoundSource_cFv = .text:0x80385AF0; // type:function size:0x4
@@ -21201,8 +21201,8 @@ d_s_vt_0x194__14dSoundSource_cFv = .text:0x8038B380; // type:function size:0x8
d_vt_0x58__14dSoundSource_cFv = .text:0x8038B390; // type:function size:0x4
d_s_vt_0x1A0__14dSoundSource_cFv = .text:0x8038B3A0; // type:function size:0x8
d_vt_0x5C__14dSoundSource_cFv = .text:0x8038B3B0; // type:function size:0x4
attachDistantSound__14dSoundSource_cFP18dSndDistantSound_c = .text:0x8038B3C0; // type:function size:0x54
detachDistantSound__14dSoundSource_cFP18dSndDistantSound_c = .text:0x8038B420; // type:function size:0x60
attachDistantSound__14dSoundSource_cFP23dSndDistantSoundActor_c = .text:0x8038B3C0; // type:function size:0x54
detachDistantSound__14dSoundSource_cFP23dSndDistantSoundActor_c = .text:0x8038B420; // type:function size:0x60
detachAllDistantSounds__14dSoundSource_cFv = .text:0x8038B480; // type:function size:0x74
pauseAllDistantSounds__14dSoundSource_cFbi = .text:0x8038B500; // type:function size:0x84
fn_8038B590 = .text:0x8038B590; // type:function size:0x24
@@ -21458,7 +21458,7 @@ fn_80393AE0 = .text:0x80393AE0; // type:function size:0xA4
fn_80393B90 = .text:0x80393B90; // type:function size:0x90
fn_80393C20 = .text:0x80393C20; // type:function size:0x98
fn_80393CC0 = .text:0x80393CC0; // type:function size:0x98
fn_80393D60 = .text:0x80393D60; // type:function size:0x60
onChangeStage__27dSndDistantSoundActorPool_cFv = .text:0x80393D60; // type:function size:0x60
__sinit_\d_snd_distant_sound_actor_pool_cpp = .text:0x80393DC0; // type:function size:0x34 scope:local
__ct__23dSndDistantSoundActor_cFv = .text:0x80393E00; // type:function size:0x74
getSourceParam__27dSndDistantSoundActorPool_cFv = .text:0x80393E80; // type:function size:0xC
@@ -21491,19 +21491,19 @@ setSource__14dSndSeSound1_cFP14dSoundSource_cUl = .text:0x803946C0; // type:func
__ct__14dSndSeSound2_cFv = .text:0x803946D0; // type:function size:0x54
setSource__14dSndSeSound2_cFP14dSoundSource_cUl = .text:0x80394730; // type:function size:0x3C
calcTimer__14dSndSeSound2_cFv = .text:0x80394770; // type:function size:0x3C
fn_803947B0 = .text:0x803947B0; // type:function size:0x78
fn_80394830 = .text:0x80394830; // type:function size:0x4C
fn_80394880 = .text:0x80394880; // type:function size:0x10
fn_80394890 = .text:0x80394890; // type:function size:0xFC
fn_80394990 = .text:0x80394990; // type:function size:0x58
fn_803949F0 = .text:0x803949F0; // type:function size:0x58
fn_80394A50 = .text:0x80394A50; // type:function size:0x98
fn_80394AF0 = .text:0x80394AF0; // type:function size:0xCC
fn_80394BC0 = .text:0x80394BC0; // type:function size:0xCC
fn_80394C90 = .text:0x80394C90; // type:function size:0x9C
fn_80394D30 = .text:0x80394D30; // type:function size:0x68
fn_80394DA0 = .text:0x80394DA0; // type:function size:0x14
fn_80394DC0 = .text:0x80394DC0; // type:function size:0x14
__dt__35SndMgrDisposer<17dSndSeSoundPool_c>Fv = .text:0x803947B0; // type:function size:0x78 scope:weak
create__35SndMgrDisposer<17dSndSeSoundPool_c>Fv = .text:0x80394830; // type:function size:0x4C scope:weak
remove__35SndMgrDisposer<17dSndSeSoundPool_c>Fv = .text:0x80394880; // type:function size:0x10 scope:weak
__ct__17dSndSeSoundPool_cFv = .text:0x80394890; // type:function size:0xFC
__dt__14dSndSeSound1_cFv = .text:0x80394990; // type:function size:0x58 scope:weak
__dt__14dSndSeSound2_cFv = .text:0x803949F0; // type:function size:0x58 scope:weak
calc__17dSndSeSoundPool_cFv = .text:0x80394A50; // type:function size:0x98
acquireSoundType1__17dSndSeSoundPool_cFP14dSoundSource_cUl = .text:0x80394AF0; // type:function size:0xCC
acquireSoundType2__17dSndSeSoundPool_cFP14dSoundSource_cUl = .text:0x80394BC0; // type:function size:0xCC
releaseSoundType1__17dSndSeSoundPool_cFP14dSndSeSound1_cb = .text:0x80394C90; // type:function size:0x9C
releaseSoundType2__17dSndSeSoundPool_cFP14dSndSeSound2_c = .text:0x80394D30; // type:function size:0x68
removeSoundType1__17dSndSeSoundPool_cFP14dSndSeSound1_c = .text:0x80394DA0; // type:function size:0x14
removeSoundType2__17dSndSeSoundPool_cFP14dSndSeSound2_c = .text:0x80394DC0; // type:function size:0x14
fn_80394DE0 = .text:0x80394DE0; // type:function size:0xD0
fn_80394EB0 = .text:0x80394EB0; // type:function size:0xF8
fn_80394FB0 = .text:0x80394FB0; // type:function size:0x1A8
@@ -38097,7 +38097,7 @@ __vt__23dSndDistantSoundActor_c = .data:0x8054D410; // type:object size:0x60
__vt__13dSndSeSound_c = .data:0x8054D470; // type:object size:0x14
__vt__14dSndSeSound1_c = .data:0x8054D488; // type:object size:0x14
__vt__14dSndSeSound2_c = .data:0x8054D4A0; // type:object size:0x14
lbl_8054D4B8 = .data:0x8054D4B8; // type:object size:0x10
__vt__35SndMgrDisposer<17dSndSeSoundPool_c> = .data:0x8054D4B8; // type:object size:0xC scope:weak
lbl_8054D4C8 = .data:0x8054D4C8; // type:object size:0x58
lbl_8054D520 = .data:0x8054D520; // type:object size:0x10 data:string
lbl_8054D530 = .data:0x8054D530; // type:object size:0x10
@@ -42298,8 +42298,8 @@ lbl_80575DC8 = .sbss:0x80575DC8; // type:object size:0x4 data:4byte
lbl_80575DCC = .sbss:0x80575DCC; // type:object size:0x4 data:4byte
sInstance__27dSndDistantSoundActorPool_c = .sbss:0x80575DD0; // type:object size:0x4 data:4byte
sDisposer__27dSndDistantSoundActorPool_c = .sbss:0x80575DD4; // type:object size:0x4 data:4byte
lbl_80575DD8 = .sbss:0x80575DD8; // type:object size:0x4 data:4byte
lbl_80575DDC = .sbss:0x80575DDC; // type:object size:0x4 data:4byte
sInstance__17dSndSeSoundPool_c = .sbss:0x80575DD8; // type:object size:0x4 data:4byte
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
+1 -1
View File
@@ -774,7 +774,7 @@ config.libs = [
Object(Matching, "d/snd/d_snd_se_sound.cpp"),
Object(Matching, "d/snd/d_snd_se_sound_1.cpp"),
Object(Matching, "d/snd/d_snd_se_sound_2.cpp"),
Object(NonMatching, "d/snd/d_snd_se_sound_pool.cpp"),
Object(Matching, "d/snd/d_snd_se_sound_pool.cpp"),
Object(NonMatching, "d/snd/d_snd_sound_link_body_callbacks.cpp"),
Object(NonMatching, "d/snd/d_snd_sound_enemy_callbacks.cpp"),
Object(NonMatching, "d/snd/d_snd_sound_object_callbacks.cpp"),
+2 -3
View File
@@ -3,7 +3,6 @@
#include "common.h"
#include "d/snd/d_snd_3d_actor.h"
#include "m/m_vec.h"
#include "nw4r/math/math_types.h"
#include "nw4r/snd/snd_SoundHandle.h"
#include "nw4r/ut/ut_list.h"
@@ -40,8 +39,8 @@ public:
}
private:
/* 0x0E4 */ nw4r::ut::Node mDistantLink;
/* 0x0EC */ u8 _0x0EC[0x0F4 - 0x0EC];
/* 0x0E4 */ nw4r::ut::Node mPoolLink; // sound actor pool link
/* 0x0EC */ nw4r::ut::Node mSourceLink; // sound source link
/* 0x0F4 */ UNKWORD field_0x0F4;
/* 0x0F8 */ dSoundSource_c *mpSoundSource;
/* 0x0FC */ nw4r::snd::SoundHandle mSoundHandle;
@@ -2,9 +2,9 @@
#define D_SND_DISTANT_SOUND_ACTOR_POOL_H
#include "common.h"
#include "d/snd/d_snd_distant_sound_actor.h"
#include "d/snd/d_snd_misc.h"
#include "d/snd/d_snd_util.h"
#include "d/snd/d_snd_distant_sound_actor.h"
#include "nw4r/ut/ut_list.h"
SND_DISPOSER_FORWARD_DECL(dSndDistantSoundActorPool_c);
@@ -17,15 +17,19 @@ SND_DISPOSER_FORWARD_DECL(dSndDistantSoundActorPool_c);
class dSndDistantSoundActorPool_c {
SND_DISPOSER_MEMBERS(dSndDistantSoundActorPool_c);
static const s32 POOL_SIZE = 64;
public:
dSndDistantSoundActorPool_c();
static dSndSourceParam& getSourceParam() {
static dSndSourceParam &getSourceParam() {
return sParam;
}
void onChangeStage();
private:
/* 0x0010 */ dSndDistantSoundActor_c mSounds[64];
/* 0x0010 */ dSndDistantSoundActor_c mSounds[POOL_SIZE];
/* 0x4210 */ UNKWORD field_0x4210;
/* 0x4214 */ nw4r::ut::List mList;
+13 -6
View File
@@ -32,17 +32,24 @@ public:
/* vt 0x10 */ virtual void onCalc(dSoundSource_c *source);
void calc(dSoundSource_c *source);
void clear();
// not sure what this does
void shiftPair(const UnkSeSoundStruct *p);
void shiftValue(f32 value);
typedef void Callback(dSndSeSound_c *sound, dSoundSource_c *source, nw4r::snd::SoundHandle &handle);
protected:
void clear();
/* 0x004 */ u8 _0x004[0x00C - 0x004];
typedef void Callback(dSndSeSound_c *sound, dSoundSource_c *source, nw4r::snd::SoundHandle &handle);
void stop(s32 fadeFrames) {
mpSoundHandle->Stop(fadeFrames);
}
bool isAttachedSound() const {
return mpSoundHandle->IsAttachedSound();
}
protected:
/* 0x004 */ nw4r::ut::Node mSourceLink;
/* 0x00C */ nw4r::ut::Node mPoolLink;
/* 0x014 */ UNKWORD field_0x014;
/* 0x018 */ dSndSound_c mSound;
+40
View File
@@ -0,0 +1,40 @@
#ifndef D_SND_SE_SOUND_POOL_H
#define D_SND_SE_SOUND_POOL_H
#include "common.h"
#include "d/snd/d_snd_se_sound_1.h"
#include "d/snd/d_snd_se_sound_2.h"
#include "d/snd/d_snd_util.h"
#include "nw4r/ut/ut_list.h"
class dSoundSource_c;
SND_DISPOSER_FORWARD_DECL(dSndSeSoundPool_c);
class dSndSeSoundPool_c {
SND_DISPOSER_MEMBERS(dSndSeSoundPool_c)
static const u32 POOL_SIZE = 64;
public:
dSndSeSoundPool_c();
void calc();
dSndSeSound1_c *acquireSoundType1(dSoundSource_c *source, u32 soundId);
dSndSeSound2_c *acquireSoundType2(dSoundSource_c *source, u32 soundId);
void releaseSoundType1(dSndSeSound1_c *sound, bool arg);
void releaseSoundType2(dSndSeSound2_c *sound);
private:
void removeSoundType1(dSndSeSound1_c *sound);
void removeSoundType2(dSndSeSound2_c *sound);
/* 0x0010 */ nw4r::ut::List mFreeType1List;
/* 0x001C */ nw4r::ut::List mActiveType1List;
/* 0x0028 */ nw4r::ut::List mFreeType2List;
/* 0x0034 */ dSndSeSound1_c mSoundsType1[POOL_SIZE];
/* 0x4A34 */ dSndSeSound2_c mSoundsType2[POOL_SIZE];
};
#endif
+2 -2
View File
@@ -106,8 +106,8 @@ private:
/* 0x10C */ UNKWORD field_0x10C;
/* 0x110 */ nw4r::ut::List mDistantSoundList; // node offset 0xEC -> dSndDistantSoundActor_c
/* 0x11C */ UNKWORD field_0x11C;
/* 0x120 */ nw4r::ut::List field_0x120; // node offset 0x4
/* 0x12C */ nw4r::ut::List field_0x12C; // node offset 0x4
/* 0x120 */ nw4r::ut::List field_0x120; // node offset 0x4 -> dSndSeSound_c
/* 0x12C */ nw4r::ut::List field_0x12C; // node offset 0x4 -> dSndSeSound_c
/* 0x138 */ nw4r::ut::Node mGroupLink; // node for list in dSndSourceGroup_c
/* 0x140 */ dSndSourceGroup_c *mpOwnerGroup;
/* 0x144 */ u8 _0x144[0x154 - 0x144];
@@ -1,5 +1,6 @@
#include "d/snd/d_snd_distant_sound_actor_pool.h"
#include "m/m_vec.h"
#include "nw4r/ut/ut_list.h"
#include <cmath>
@@ -15,3 +16,11 @@ dSndDistantSoundActorPool_c::dSndDistantSoundActorPool_c() {
nw4r::ut::List_Init(&mList, 0xE4);
sParam.reset(INFINITY);
}
void dSndDistantSoundActorPool_c::onChangeStage() {
mVec3_c v(INFINITY, INFINITY, INFINITY);
for (int i = 0; i < POOL_SIZE; i++) {
mSounds[i].SetPosition(v);
}
}
+2 -2
View File
@@ -6,6 +6,7 @@
#include "d/snd/d_snd_control_player_mgr.h"
#include "d/snd/d_snd_distant_sound_actor_pool.h"
#include "d/snd/d_snd_player_mgr.h"
#include "d/snd/d_snd_se_sound_pool.h"
#include "d/snd/d_snd_small_effect_mgr.h"
#include "d/snd/d_snd_source_mgr.h"
#include "d/snd/d_snd_state_mgr.h"
@@ -13,7 +14,6 @@
#include "egg/audio/eggAudioUtility.h"
extern "C" void initSomeUnusedSoundMgr();
extern "C" void fn_80394830();
extern "C" void fn_8037F940();
extern "C" void fn_80399600();
extern "C" void fn_80399C20();
@@ -32,7 +32,7 @@ dSndMgr_c::dSndMgr_c() : field_0x6CC(0) {
dSndAreaSoundEffectMgr_c::create();
dSndSourceMgr_c::create();
dSndDistantSoundActorPool_c::create();
fn_80394830();
dSndSeSoundPool_c::create();
fn_8037F940();
fn_80399600();
fn_80399C20();
+112
View File
@@ -0,0 +1,112 @@
#include "d/snd/d_snd_se_sound_pool.h"
#include "common.h"
#include "d/snd/d_snd_se_sound_1.h"
#include "d/snd/d_snd_util.h"
#include "nw4r/ut/ut_list.h"
SND_DISPOSER_DEFINE(dSndSeSoundPool_c);
dSndSeSoundPool_c::dSndSeSoundPool_c() {
// TODO offsetof
nw4r::ut::List_Init(&mFreeType1List, 0x0C);
nw4r::ut::List_Init(&mActiveType1List, 0x0C);
nw4r::ut::List_Init(&mFreeType2List, 0x0C);
for (dSndSeSound1_c *sound = mSoundsType1; sound < &mSoundsType1[POOL_SIZE]; sound++) {
releaseSoundType1(sound, true);
}
for (dSndSeSound2_c *sound = mSoundsType2; sound < &mSoundsType2[POOL_SIZE]; sound++) {
releaseSoundType2(sound);
}
}
void dSndSeSoundPool_c::calc() {
dSndSeSound1_c *it, *next;
for (it = static_cast<dSndSeSound1_c *>(nw4r::ut::List_GetFirst(&mActiveType1List)); it != nullptr; it = next) {
next = static_cast<dSndSeSound1_c *>(nw4r::ut::List_GetNext(&mActiveType1List, it));
if (!it->isAttachedSound()) {
it->clear();
nw4r::ut::List_Remove(&mActiveType1List, it);
nw4r::ut::List_Append(&mFreeType1List, it);
}
}
}
dSndSeSound1_c *dSndSeSoundPool_c::acquireSoundType1(dSoundSource_c *source, u32 soundId) {
if (soundId == -1) {
return nullptr;
}
for (dSndSeSound1_c *it = static_cast<dSndSeSound1_c *>(nw4r::ut::List_GetFirst(&mFreeType1List)); it != nullptr;
it = static_cast<dSndSeSound1_c *>(nw4r::ut::List_GetNext(&mFreeType1List, it))) {
if (!it->isAttachedSound()) {
it->setSource(source, soundId);
removeSoundType1(it);
return it;
}
}
return nullptr;
}
dSndSeSound2_c *dSndSeSoundPool_c::acquireSoundType2(dSoundSource_c *source, u32 soundId) {
if (soundId == -1) {
return nullptr;
}
for (dSndSeSound2_c *it = static_cast<dSndSeSound2_c *>(nw4r::ut::List_GetFirst(&mFreeType2List)); it != nullptr;
it = static_cast<dSndSeSound2_c *>(nw4r::ut::List_GetNext(&mFreeType2List, it))) {
if (!it->isAttachedSound()) {
it->setSource(source, soundId);
removeSoundType2(it);
return it;
}
}
return nullptr;
}
void dSndSeSoundPool_c::releaseSoundType1(dSndSeSound1_c *sound, bool arg) {
if (sound == nullptr) {
return;
}
if (sound->isAttachedSound()) {
if (arg) {
sound->stop(0);
sound->clear();
nw4r::ut::List_Append(&mFreeType1List, sound);
} else {
nw4r::ut::List_Append(&mActiveType1List, sound);
}
} else {
sound->clear();
nw4r::ut::List_Append(&mFreeType1List, sound);
}
}
void dSndSeSoundPool_c::releaseSoundType2(dSndSeSound2_c *sound) {
if (sound == nullptr) {
return;
}
sound->stop(0);
sound->clear();
nw4r::ut::List_Append(&mFreeType2List, sound);
}
void dSndSeSoundPool_c::removeSoundType1(dSndSeSound1_c *sound) {
if (sound == nullptr) {
return;
}
nw4r::ut::List_Remove(&mFreeType1List, sound);
}
void dSndSeSoundPool_c::removeSoundType2(dSndSeSound2_c *sound) {
if (sound == nullptr) {
return;
}
nw4r::ut::List_Remove(&mFreeType2List, sound);
}