A few more funcs

This commit is contained in:
robojumper
2025-06-28 15:07:05 +02:00
parent ba0f29f410
commit c5a36f88b7
12 changed files with 201 additions and 36 deletions
+1
View File
@@ -2706,6 +2706,7 @@ d/snd/d_snd_anim_sound.cpp:
d/snd/d_snd_source_mgr.cpp:
.text start:0x80382410 end:0x803864C8 align:16
.ctors start:0x804DB91C end:0x804DB920
.rodata start:0x804F38E0 end:0x804F3970
.data start:0x805491E0 end:0x8054A680
.sdata start:0x80574310 end:0x805743D0
.sbss start:0x80575DA8 end:0x80575DB0
+6 -6
View File
@@ -20968,7 +20968,7 @@ fn_80383C50 = .text:0x80383C50; // type:function size:0x78
fn_80383CD0 = .text:0x80383CD0; // type:function size:0x4C
fn_80383D20 = .text:0x80383D20; // type:function size:0x44
fn_80383D70 = .text:0x80383D70; // type:function size:0x44
fn_80383DC0 = .text:0x80383DC0; // type:function size:0x84
calcEnemyObjVolume__15dSndSourceMgr_cFv = .text:0x80383DC0; // type:function size:0x84
EnemyBgmRelatedMgr__actuallyHandleEnemyMusic = .text:0x80383E50; // type:function size:0x354
fn_803841B0 = .text:0x803841B0; // type:function size:0x13C
fn_803842F0 = .text:0x803842F0; // type:function size:0x64
@@ -20980,10 +20980,10 @@ fn_80384570 = .text:0x80384570; // type:function size:0xC0
fn_80384630 = .text:0x80384630; // type:function size:0x94
fn_803846D0 = .text:0x803846D0; // type:function size:0xA0
getGroup__15dSndSourceMgr_cFlP9dAcBase_cPCcPCcUc = .text:0x80384770; // type:function size:0xAC
fn_80384820 = .text:0x80384820; // type:function size:0x8C
getActiveGroupForName__15dSndSourceMgr_cFPCc = .text:0x80384820; // type:function size:0x8C
fn_803848B0 = .text:0x803848B0; // type:function size:0xAC
fn_80384960 = .text:0x80384960; // type:function size:0x8C
fn_803849F0 = .text:0x803849F0; // type:function size:0xC
getInactiveGroup__15dSndSourceMgr_cFv = .text:0x803849F0; // type:function size:0xC
fn_80384A00 = .text:0x80384A00; // type:function size:0x174
registerSource__15dSndSourceMgr_cFP14dSoundSource_c = .text:0x80384B80; // type:function size:0x178
getCategory__14dSoundSource_cCFv = .text:0x80384D00; // type:function size:0x8
@@ -20993,8 +20993,8 @@ unregisterSource__15dSndSourceMgr_cFP14dSoundSource_c = .text:0x80384E30; // typ
removeSourceFromList__15dSndSourceMgr_cFP14dSoundSource_cPQ34nw4r2ut4List = .text:0x80384EF0; // type:function size:0xAC
onShutdownSource__15dSndSourceMgr_cFP14dSoundSource_c = .text:0x80384FA0; // type:function size:0x14
clearSourceLists__15dSndSourceMgr_cFv = .text:0x80384FC0; // type:function size:0x50
fn_80385010 = .text:0x80385010; // type:function size:0x60
fn_80385070 = .text:0x80385070; // type:function size:0x18
activateGroup__15dSndSourceMgr_cFP17dSndSourceGroup_c = .text:0x80385010; // type:function size:0x60
isActiveGroup__15dSndSourceMgr_cCFP17dSndSourceGroup_c = .text:0x80385070; // type:function size:0x18
fn_80385090 = .text:0x80385090; // type:function size:0x18
fn_803850B0 = .text:0x803850B0; // type:function size:0x108
fn_803851C0 = .text:0x803851C0; // type:function size:0x74
@@ -29022,7 +29022,7 @@ lbl_804F3858 = .rodata:0x804F3858; // type:object size:0x30 data:4byte
lbl_804F3888 = .rodata:0x804F3888; // type:object size:0x40
lbl_804F38C8 = .rodata:0x804F38C8; // type:object size:0x18
lbl_804F38E0 = .rodata:0x804F38E0; // type:object size:0x10
lbl_804F38F0 = .rodata:0x804F38F0; // type:object size:0x80
sFlowSoundDefs = .rodata:0x804F38F0; // type:object size:0x80 scope:local
grp4 = .rodata:0x804F3970; // type:object size:0x9 scope:local
grp6 = .rodata:0x804F397C; // type:object size:0x9 scope:local
grp9 = .rodata:0x804F3988; // type:object size:0x9 scope:local
+1 -2
View File
@@ -64,14 +64,13 @@ public:
void setBgmVolumeDecreaseSpeed(f32 speed);
void setStageEffectsVolume(f32 volume, s32 fadeFrames);
private:
void setBgmMuteVolume(f32 volume);
void setStageEffectsMuteVolume(f32 volume);
void setEnemyMuteVolume(f32 volume);
void setObjectMuteVolume(f32 volume);
void setPlayerVolumeInternal(u32 playerIdx, f32 volume);
private:
void resetControls();
void calcVolumes();
void calcMuteFlags();
+2 -1
View File
@@ -72,9 +72,10 @@ public:
void setButtonPressSound(dSoundSource_c *source);
bool playBattleHitSound(BattleHitSound_e type, dSoundSource_c *source);
bool playSoundInternalChecked(u32 soundId, nw4r::snd::SoundHandle *handle);
private:
bool playSoundInternal(u32 soundId, nw4r::snd::SoundHandle *handle);
bool playSoundInternalChecked(u32 soundId, nw4r::snd::SoundHandle *handle);
bool playSoundInternal(u32 soundId);
void stopSounds(u32 playerIdx, u32 soundId, s32 fadeFrames);
void stopSounds(u32 soundId, s32 fadeFrames);
+4
View File
@@ -21,9 +21,12 @@ enum SoundSourceType_e {
SND_SOURCE_ENEMY_10 = 10,
SND_SOURCE_MAGUPPO = 12,
SND_SOURCE_LIZARUFOS = 13,
SND_SOURCE_ENEMY_14 = 14,
SND_SOURCE_BC_Z = 16,
SND_SOURCE_SPARK = 17,
SND_SOURCE_BIGBOSS = 20,
SND_SOURCE_BOSS_MG = 21,
SND_SOURCE_BOSS_KR = 22,
SND_SOURCE_BOSS_NUSI = 23,
SND_SOURCE_GIRAHUMU_3 = 24,
SND_SOURCE_ENEMY_28 = 28,
@@ -49,6 +52,7 @@ enum SoundSourceType_e {
SND_SOURCE_KENSEI = 44,
SND_SOURCE_PLAYER_BIRD = 45,
SND_SOURCE_NPC_NUSI = 46,
SND_SOURCE_NPC_47 = 47,
SND_SOURCE_NPC_HEAD = 48,
SND_SOURCE_INSECT = 49,
SND_SOURCE_NPC_50 = 50,
+9 -1
View File
@@ -41,6 +41,14 @@ public:
return mName;
}
bool isActive() const {
return mIsActive;
}
void setIsActive(bool active) {
mIsActive = active;
}
private:
bool setParamFromName(const char *name);
void resetSoundSourceParam();
@@ -51,7 +59,7 @@ private:
/* 0x10 */ UNKWORD field_0x10;
/* 0x14 */ s32 mSourceCategory;
/* 0x18 */ s32 mSubtype;
/* 0x1C */ u8 field_0x1C;
/* 0x1C */ bool mIsActive;
/* 0x1D */ u8 field_0x1D;
/* 0x1E */ SizedString<32> mName;
/* 0x40 */ UNKWORD field_0x40;
+13 -6
View File
@@ -58,6 +58,8 @@ public:
}
private:
void calcEnemyObjVolume();
static bool isCertainEnemyType(dSoundSource_c *source);
static bool isAnimSoundSource(s32 sourceType, const char *name);
static bool isMultiSoundSource(s32 sourceType, const char *name);
@@ -66,24 +68,29 @@ private:
void clearSourceLists();
void clearSourceList(nw4r::ut::List *list);
dSndSourceGroup_c *getActiveGroupForName(const char *name);
dSndSourceGroup_c *getInactiveGroup();
dSndSourceGroup_c *getGroup(s32 sourceType, dAcBase_c *actor, const char *name, const char *origName, u8 subtype);
bool fn_803846D0(s32 sourceType, const char *name, u8 subtype);
void activateGroup(dSndSourceGroup_c *group);
bool isActiveGroup(dSndSourceGroup_c *group) const;
/* 0x0010 */ u8 field_0x0010;
/* 0x0011 */ u8 field_0x0011;
/* 0x0012 */ u8 field_0x0012;
/* 0x0013 */ u8 field_0x0013;
/* 0x0014 */ dSndSourceGroup_c *mpDefaultGroup;
/* 0x0018 */ nw4r::ut::List mGroupList1;
/* 0x0024 */ nw4r::ut::List mGroupList2;
/* 0x0030 */ nw4r::ut::List mGroupList3;
/* 0x0018 */ LIST_MEMBER(dSndSourceGroup_c, Group1);
/* 0x0024 */ LIST_MEMBER(dSndSourceGroup_c, Group2);
/* 0x0030 */ LIST_MEMBER(dSndSourceGroup_c, Group3);
/* 0x003C */ dSndSourceGroup_c mGroups[NUM_GROUPS];
// Not sure what these are for
/* 0x383C */ nw4r::ut::List mAllSources; // node offset 0xE8, -> dSoundSource::mMgrLink
/* 0x3848 */ nw4r::ut::List field_0x3848; // node offset 0x15C, -> dSndSourceEnemy_c::mMgrEnemyLink
/* 0x3854 */ nw4r::ut::List field_0x3854; // node offset 0x160
/* 0x383C */ LIST_MEMBER(dSoundSource_c, AllSources); // node offset 0xE8, -> dSoundSource_c::mMgrLink
/* 0x3848 */ nw4r::ut::List field_0x3848; // node offset 0x15C, -> dSndSourceEnemy_c::mMgrEnemyLink
/* 0x3854 */ LIST_MEMBER(dSndSourceHarpRelated_c, HarpRelated); // node offset 0x160, -> dSndSourceHarpRelated_c
/* 0x3860 */ UNKWORD field_0x3860;
/* 0x3864 */ UNKWORD field_0x3864;
+4
View File
@@ -77,6 +77,10 @@ public:
field_0x010 &= ~mask;
}
bool checkFlag0x94(u32 mask) const {
return field_0x094 & mask;
}
void setFlowEvent(u32 eventId);
const char *getCurrentStageMusicDemoName() const;
+1
View File
@@ -9,6 +9,7 @@ class dSndSourceGroup_c;
class dSndDistantSoundActor_c;
class dSndSourceEnemy_c;
class dSndSourceHarpRelated_c;
class dSndSound_c;
+1 -1
View File
@@ -70,7 +70,7 @@ void dSndSourceGroup_c::resetSoundSourceParam() {
dSndSourceGroup_c::dSndSourceGroup_c()
: mSubtype(0),
field_0x1C(0),
mIsActive(false),
field_0x1D(0),
mName(""),
field_0x40(0),
+157 -17
View File
@@ -2,7 +2,9 @@
#include "common.h"
#include "d/a/d_a_base.h"
#include "d/snd/d_snd_control_player_mgr.h"
#include "d/snd/d_snd_player_mgr.h"
#include "d/snd/d_snd_small_effect_mgr.h"
#include "d/snd/d_snd_source.h"
// clang-format off
@@ -29,6 +31,7 @@
#include "d/snd/d_snd_state_mgr.h"
#include "d/snd/d_snd_util.h"
#include "d/snd/d_snd_wzsound.h"
#include "nw4r/ut/ut_list.h"
#include "sized_string.h"
@@ -47,6 +50,52 @@ struct ActorBaseNamePair {
extern "C" const ActorBaseNamePair Actor_BaseActorName_Pairs[];
extern "C" const s32 lbl_8057E394;
bool dSndSourceMgr_c::isAnimSoundSource(s32 sourceType, const char *name) {
switch (getSourceCategoryForSourceType(sourceType, name)) {
case SND_SOURCE_CATEGORY_PLAYER:
switch (sourceType) {
case SND_SOURCE_PLAYER: return true;
}
break;
case SND_SOURCE_CATEGORY_ENEMY:
if (sourceType < 0x19) {
return sourceType != SND_SOURCE_ENEMY_14;
}
return false;
case SND_SOURCE_CATEGORY_NPC:
return sourceType != SND_SOURCE_NPC_47 && sourceType != SND_SOURCE_NPC_HEAD &&
sourceType != SND_SOURCE_INSECT;
case SND_SOURCE_CATEGORY_OBJECT:
if (sourceType >= SND_SOURCE_OBJECT_42) {
return true;
}
break;
case 58:
// TODO - what is category 58???
return true;
}
return false;
}
bool dSndSourceMgr_c::isMultiSoundSource(s32 sourceType, const char *name) {
switch (sourceType) {
case SND_SOURCE_BIGBOSS:
case SND_SOURCE_BOSS_MG:
case SND_SOURCE_BOSS_KR:
case SND_SOURCE_BOSS_NUSI:
case SND_SOURCE_NPC_NUSI: return true;
}
return false;
}
bool dSndSourceMgr_c::isSwOrEOc(const char *name) {
if (streq(name, "Sw") || streq(name, "SwWall") || streq(name, "wnut") || streq(name, "EOc")) {
return true;
}
return false;
}
s32 dSndSourceMgr_c::getSourceCategoryForSourceType(s32 sourceType, const char *name) {
// This might be a full-on switch statement but I don't want to write out
// all the unknown entries yet and this matches anyway
@@ -140,7 +189,7 @@ dSoundSourceIf_c *dSndSourceMgr_c::createSource(s32 sourceType, dAcBase_c *actor
subtype = 0;
isModified = true;
} else if (strneq(name, "NpcMoS", 6)) {
nameStr = "NpcMoE1";
nameStr = "NpcMoEl";
isModified = true;
}
@@ -263,9 +312,7 @@ dSoundSourceIf_c *dSndSourceMgr_c::createSource(s32 sourceType, dAcBase_c *actor
case SND_SOURCE_TG_HARP:
newSource = new dSndSourceHarpTg_c(sourceType, actor, actualName, group);
break;
default:
newSource = new dSndSourceHarpRelated_c(sourceType, actor, actualName, group);
break;
default: newSource = new dSndSourceHarpRelated_c(sourceType, actor, actualName, group); break;
}
break;
case SND_SOURCE_CATEGORY_7: newSource = new dSndSourceDemo_c(sourceType, actor, actualName, group); break;
@@ -297,7 +344,8 @@ dSoundSourceIf_c *dSndSourceMgr_c::createSource(s32 sourceType, dAcBase_c *actor
}
}
if (existingSource != nullptr && existingSource != newSource && sourceType != SND_SOURCE_NPC_HEAD && existingSource->isMultiSource()) {
if (existingSource != nullptr && existingSource != newSource && sourceType != SND_SOURCE_NPC_HEAD &&
existingSource->isMultiSource()) {
existingSource->registerAdditionalSource(static_cast<dSoundSource_c *>(newSource));
}
@@ -322,25 +370,52 @@ dSndSourceMgr_c::dSndSourceMgr_c()
field_0x3880(nullptr),
field_0x3884(nullptr) {
// TODO offsetof
nw4r::ut::List_Init(&mGroupList1, 0);
nw4r::ut::List_Init(&mGroupList2, 0);
nw4r::ut::List_Init(&mGroup1List, 0);
nw4r::ut::List_Init(&mGroup2List, 0);
// TODO figure out what these are for
nw4r::ut::List_Init(&mGroupList3, 8);
nw4r::ut::List_Init(&mAllSources, 0xE8);
nw4r::ut::List_Init(&mGroup3List, 8);
nw4r::ut::List_Init(&mAllSourcesList, 0xE8);
nw4r::ut::List_Init(&field_0x3848, 0x15C);
nw4r::ut::List_Init(&field_0x3854, 0x160);
nw4r::ut::List_Init(&mHarpRelatedList, 0x160);
mpDefaultGroup = new dSndSourceGroup_c(-1, "Default", 0, 0);
for (dSndSourceGroup_c *group = &mGroups[0]; group < &mGroups[NUM_GROUPS]; group++) {
nw4r::ut::List_Append(&mGroupList2, group);
nw4r::ut::List_Append(&mGroup2List, group);
}
}
void dSndSourceMgr_c::calcEnemyObjVolume() {
if (dSndStateMgr_c::GetInstance()->checkFlag0x94(0x100)) {
dSndControlPlayerMgr_c::GetInstance()->setEnemyMuteVolume(0.0f);
} else if (dSndStateMgr_c::GetInstance()->checkFlag0x94(0x80)) {
dSndControlPlayerMgr_c::GetInstance()->setEnemyMuteVolume(0.3f);
}
if (dSndStateMgr_c::GetInstance()->checkFlag0x94(0x400)) {
dSndControlPlayerMgr_c::GetInstance()->setObjectMuteVolume(0.0f);
} else if (dSndStateMgr_c::GetInstance()->checkFlag0x94(0x200)) {
dSndControlPlayerMgr_c::GetInstance()->setObjectMuteVolume(0.3f);
}
}
dSndSourceGroup_c *dSndSourceMgr_c::getActiveGroupForName(const char *name) {
for (dSndSourceGroup_c *it = getGroup1First(); it != nullptr; it = getGroup1Next(it)) {
if (streq(it->getName(), name)) {
return it;
}
}
return nullptr;
}
dSndSourceGroup_c *dSndSourceMgr_c::getInactiveGroup() {
return getGroup2First();
}
void dSndSourceMgr_c::registerSource(dSoundSource_c *source) {
if (source != nullptr) {
nw4r::ut::List_Append(&mAllSources, source);
nw4r::ut::List_Append(&mAllSourcesList, source);
switch (source->getCategory()) {
case SND_SOURCE_CATEGORY_PLAYER: {
if (source->getSourceType() == SND_SOURCE_PLAYER && mpPlayerSource == nullptr) {
@@ -361,7 +436,7 @@ void dSndSourceMgr_c::registerSource(dSoundSource_c *source) {
break;
}
case SND_SOURCE_CATEGORY_HARP_RELATED: {
nw4r::ut::List_Append(&field_0x3854, source);
nw4r::ut::List_Append(&mHarpRelatedList, source);
break;
}
case SND_SOURCE_CATEGORY_OBJECT: {
@@ -382,9 +457,9 @@ void dSndSourceMgr_c::registerSource(dSoundSource_c *source) {
void dSndSourceMgr_c::unregisterSource(dSoundSource_c *source) {
if (source != nullptr) {
removeSourceFromList(source, &mAllSources);
removeSourceFromList(source, &mAllSourcesList);
removeSourceFromList(source, &field_0x3848);
removeSourceFromList(source, &field_0x3854);
removeSourceFromList(source, &mHarpRelatedList);
if (source == mpPlayerSource) {
mpPlayerSource = nullptr;
} else if (source == mpKenseiSource) {
@@ -427,12 +502,27 @@ void dSndSourceMgr_c::onShutdownSource(dSoundSource_c *source) {
}
void dSndSourceMgr_c::clearSourceLists() {
clearSourceList(&mAllSources);
clearSourceList(&mAllSourcesList);
clearSourceList(&field_0x3848);
clearSourceList(&field_0x3854);
clearSourceList(&mHarpRelatedList);
mpPlayerSource = nullptr;
}
void dSndSourceMgr_c::activateGroup(dSndSourceGroup_c *group) {
if (!isActiveGroup(group)) {
removeGroup2(group);
appendGroup1(group);
group->setIsActive(true);
}
}
bool dSndSourceMgr_c::isActiveGroup(dSndSourceGroup_c *group) const {
if (group != nullptr) {
return group->isActive();
}
return false;
}
void dSndSourceMgr_c::clearSourceList(nw4r::ut::List *list) {
if (list != nullptr) {
dSoundSource_c *sourceIter = static_cast<dSoundSource_c *>(nw4r::ut::List_GetFirst(list));
@@ -453,6 +543,56 @@ s32 dSndSourceMgr_c::getPlayerSourceRoomId() const {
return mpPlayerSource->getRoomId();
}
struct FlowSoundDef {
const char *groupName;
u32 soundId;
};
extern "C" const char sLinkHead[] = "LinkHead";
static const FlowSoundDef sFlowSoundDefs[] = {
{ "Door_A7", SE_DoorB00_OPEN_SHORT},
{"TgSound_A4", SE_TgSound_A4_TOILET_WATER},
{ nullptr, SE_Door_W_KEY_OPEN},
{ nullptr, SE_NpcDskN_BATH_SPLASH},
{ "NpcSenb", SE_NpcSenb_OPEN_LETTER},
{"TgSound_A4", SE_NV_001_NpcGost},
{"TgSound_A4", SE_NV_003_NpcGost},
{ nullptr, SE_EVENT_GIRL_SCREAM},
{ nullptr, SE_NpcPma_COOKING},
{ nullptr, SE_N_GET_LETTER},
{ nullptr, SE_NV_021_NpcOim},
{ nullptr, SE_NV_020_NpcOim},
{ nullptr, SE_F000_L3_RACE_CALL},
{ nullptr, SE_F000_L3_RACE_START},
{ nullptr, SE_S_TALK_CHAR_NpcSlrb_ONE},
{ nullptr, SE_LV_DRINK_MSG},
};
void dSndSourceMgr_c::playFlowSound(u32 id) {
if (id < 100) {
return;
}
id -= 100;
// @bug should be >=
if (id > ARRAY_LENGTH(sFlowSoundDefs)) {
return;
}
if (sFlowSoundDefs[id].groupName != nullptr) {
dSndSourceGroup_c *grp = getActiveGroupForName(sFlowSoundDefs[id].groupName);
if (grp != nullptr) {
dSoundSource_c *src = grp->getSourceClosestToListener();
if (src != nullptr) {
src->startSound(sFlowSoundDefs[id].soundId);
}
}
} else {
dSndSmallEffectMgr_c::GetInstance()->playSoundInternalChecked(sFlowSoundDefs[id].soundId, nullptr);
}
}
struct dSndSourceMgrEmptySinit {
dSndSourceMgrEmptySinit() {}
};
+2 -2
View File
@@ -110,11 +110,11 @@ static const ActorInfo sInfos[] = {
{"BGh3Snd", fProfile::B_GIRAHIMU3_SECOND, fProfile::B_GIRAHIMU3_SECOND, 89, SND_SOURCE_GIRAHUMU_3, 0},
{"BGh3Trd", fProfile::B_GIRAHIMU3_THIRD, fProfile::B_GIRAHIMU3_THIRD, 90, SND_SOURCE_GIRAHUMU_3, 0},
{ "BGhB", fProfile::B_GIRAHIMU_BASE, fProfile::B_GIRAHIMU_BASE, 0xFFFF, 0xFF, 0},
{ "BKr", fProfile::B_KR, fProfile::B_KR, 77, 22, 0},
{ "BKr", fProfile::B_KR, fProfile::B_KR, 77, SND_SOURCE_BOSS_KR, 0},
{ "BKrA", fProfile::B_KRA, fProfile::B_KRA, 77, 15, 0},
{ "BKrH", fProfile::B_KRH, fProfile::B_KRH, 77, 15, 0},
{"BLasBos", fProfile::B_LASTBOSS, fProfile::B_LASTBOSS, 0xFFFF, 19, 0},
{ "BMg", fProfile::B_MG, fProfile::B_MG, 10, 21, 0},
{ "BMg", fProfile::B_MG, fProfile::B_MG, 10, SND_SOURCE_BOSS_MG, 0},
{ "BSpUp", fProfile::OBJ_BIRD_SP_UP, fProfile::OBJ_BIRD_SP_UP, 0xFFFF, SND_SOURCE_OBJECT, 0},
{ "Bamboo", fProfile::OBJ_BAMBOO, fProfile::OBJ_BAMBOO, 533, SND_SOURCE_BAMBOO, 0},
{"BarPsTg", fProfile::TAG_BARREL_POS, fProfile::TAG_BARREL_POS, 0xFFFF, 0xFF, 0},