More funcs

This commit is contained in:
robojumper
2025-07-06 00:02:11 +02:00
parent 413e170796
commit 4003e257ac
9 changed files with 182 additions and 53 deletions
+15 -15
View File
@@ -19965,13 +19965,13 @@ shutdown__15dSndPlayerMgr_cFl = .text:0x8035E8B0; // type:function size:0xC
startSound__15dSndPlayerMgr_cFPQ34nw4r3snd11SoundHandleUlPCQ44nw4r3snd14SoundStartable9StartInfo = .text:0x8035E8C0; // type:function size:0x90
startSound__15dSndPlayerMgr_cFPQ34nw4r3snd11SoundHandlePCcPCQ44nw4r3snd14SoundStartable9StartInfo = .text:0x8035E950; // type:function size:0x6C
fn_8035E9C0 = .text:0x8035E9C0; // type:function size:0x80
fn_8035EA40 = .text:0x8035EA40; // type:function size:0x64
fn_8035EAB0 = .text:0x8035EAB0; // type:function size:0x28
fn_8035EAE0 = .text:0x8035EAE0; // type:function size:0xC
fn_8035EAF0 = .text:0x8035EAF0; // type:function size:0xC
fn_8035EB00 = .text:0x8035EB00; // type:function size:0x3C
fn_8035EB40 = .text:0x8035EB40; // type:function size:0xC
fn_8035EB50 = .text:0x8035EB50; // type:function size:0x3C
loadGroup__15dSndPlayerMgr_cFUl = .text:0x8035EA40; // type:function size:0x64
loadFileForSound__15dSndPlayerMgr_cFUl = .text:0x8035EAB0; // type:function size:0x28
isLoadedFileForSound__15dSndPlayerMgr_cFUl = .text:0x8035EAE0; // type:function size:0xC
isLoadedFileForBank__15dSndPlayerMgr_cFUl = .text:0x8035EAF0; // type:function size:0xC
isLoadedBnkSeForGroup__15dSndPlayerMgr_cFP17dSndSourceGroup_c = .text:0x8035EB00; // type:function size:0x3C
isLoadedFileAndWaveForSound__15dSndPlayerMgr_cFUl = .text:0x8035EB40; // type:function size:0xC
isLoadedSeFileAndWaveForGroup__15dSndPlayerMgr_cFP17dSndSourceGroup_c = .text:0x8035EB50; // type:function size:0x3C
getSomeUserParam__15dSndPlayerMgr_cCFUl = .text:0x8035EB90; // type:function size:0x80
getRemoConSoundVariant__15dSndPlayerMgr_cCFUl = .text:0x8035EC10; // type:function size:0x5C
getRemoConSoundVariantDemo__15dSndPlayerMgr_cCFUl = .text:0x8035EC70; // type:function size:0x84
@@ -20457,7 +20457,7 @@ fn_8036ECD0 = .text:0x8036ECD0; // type:function size:0x64
startAdditionalBgm__12dSndBgmMgr_cFUl = .text:0x8036ED40; // type:function size:0x58
fn_8036EDA0 = .text:0x8036EDA0; // type:function size:0x3F8
fn_8036F1A0 = .text:0x8036F1A0; // type:function size:0x58
fn_8036F200 = .text:0x8036F200; // type:function size:0x100
prepareBossBgm__12dSndBgmMgr_cFPCc = .text:0x8036F200; // type:function size:0x100
fn_8036F300 = .text:0x8036F300; // type:function size:0xA8
musicForStageRelated = .text:0x8036F3B0; // type:function size:0x9EC
fn_8036FDA0 = .text:0x8036FDA0; // type:function size:0x2C
@@ -20984,7 +20984,7 @@ getActiveGroupForName__15dSndSourceMgr_cFPCc = .text:0x80384820; // type:functio
fn_803848B0 = .text:0x803848B0; // type:function size:0xAC
fn_80384960 = .text:0x80384960; // type:function size:0x8C
getInactiveGroup__15dSndSourceMgr_cFv = .text:0x803849F0; // type:function size:0xC
fn_80384A00 = .text:0x80384A00; // type:function size:0x174
addGroupToLoading__15dSndSourceMgr_cFP17dSndSourceGroup_c = .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
isCertainEnemyType__15dSndSourceMgr_cFP14dSoundSource_c = .text:0x80384D10; // type:function size:0x78
@@ -21111,15 +21111,15 @@ __sinit_\d_snd_source_mgr_cpp = .text:0x803862E0; // type:function size:0x4 scop
@4@postStartSound__14dSoundSource_cFRQ34nw4r3snd11SoundHandleP13dSndSeSound_cUl = .text:0x803864A0; // type:function size:0x8
@4@setPause__23dSndSourceHarpRelated_cFbi = .text:0x803864B0; // type:function size:0x8
@4@__dt__18dSndSourceHarpTg_cFv = .text:0x803864C0; // type:function size:0x8
set__17dSndSourceGroup_cFlPCc = .text:0x803864D0; // type:function size:0x164
setParam__17dSndSourceGroup_cFlPCc = .text:0x803864D0; // type:function size:0x164
resetSoundSourceParam__17dSndSourceGroup_cFv = .text:0x80386640; // type:function size:0x2C
__ct__17dSndSourceGroup_cFv = .text:0x80386670; // type:function size:0x118
fn_80386790 = .text:0x80386790; // type:function size:0x120
__ct__17dSndSourceGroup_cFlPCcPCcl = .text:0x80386790; // type:function size:0x120
__dt__17dSndSourceGroup_cFv = .text:0x803868B0; // type:function size:0x54
fn_80386910 = .text:0x80386910; // type:function size:0xEC
fn_80386A00 = .text:0x80386A00; // type:function size:0xB0
fn_80386AB0 = .text:0x80386AB0; // type:function size:0xBC
fn_80386B70 = .text:0x80386B70; // type:function size:0xBC
set__17dSndSourceGroup_cFlPCcPCcl = .text:0x80386910; // type:function size:0xEC
setTemp__17dSndSourceGroup_cFlPCcl = .text:0x80386A00; // type:function size:0xB0
clear__17dSndSourceGroup_cFv = .text:0x80386AB0; // type:function size:0xBC
clearTemp__17dSndSourceGroup_cFv = .text:0x80386B70; // type:function size:0xBC
calc__17dSndSourceGroup_cFv = .text:0x80386C30; // type:function size:0x10
getNumSources__17dSndSourceGroup_cCFv = .text:0x80386C40; // type:function size:0x8
registerSource__17dSndSourceGroup_cFP14dSoundSource_c = .text:0x80386C50; // type:function size:0x14
+2
View File
@@ -60,6 +60,8 @@ public:
dSndBgmSound_c *getBgmSoundByIndex(u32 idx);
bool prepareBossBgm(const char *name);
/**
* E.g. Lizalfos fight in ET. Note that in the ET case, this is only called when triggering
* the fight without a cutscene, the cutscene code runs through "ELizarufos_c_opening"
+9
View File
@@ -2,6 +2,7 @@
#define D_SND_PLAYER_MGR_H
#include "d/snd/d_snd_mgr.h"
#include "d/snd/d_snd_types.h"
#include "d/snd/d_snd_util.h"
#include "nw4r/snd/snd_MemorySoundArchive.h"
#include "nw4r/snd/snd_SoundArchivePlayer.h"
@@ -65,6 +66,14 @@ public:
void saveState2();
void popToState2();
bool loadGroup(u32 groupId);
bool loadFileForSound(u32 soundId);
bool isLoadedFileForSound(u32 soundId);
bool isLoadedFileForBank(u32 bankId);
bool isLoadedBnkSeForGroup(dSndSourceGroup_c *group);
bool isLoadedFileAndWaveForSound(u32 soundId);
bool isLoadedSeFileAndWaveForGroup(dSndSourceGroup_c *group);
u32 getFreeSize();
bool loadDemoArchive(const char *demoArchiveName);
const char *getSoundArchivePath();
+13 -7
View File
@@ -4,6 +4,7 @@
#include "common.h"
#include "d/snd/d_snd_misc.h"
#include "d/snd/d_snd_types.h"
#include "d/snd/d_snd_util.h"
#include "nw4r/ut/ut_list.h"
#include "sized_string.h"
@@ -20,9 +21,12 @@
class dSndSourceGroup_c {
public:
dSndSourceGroup_c();
dSndSourceGroup_c(s32 sourceType, const char *, u32, s32 mSubtype);
dSndSourceGroup_c(s32 sourceType, const char *name, const char *origName, s32 subtype);
~dSndSourceGroup_c();
void set(s32 sourceType, const char *name, const char *origName, s32 subtype);
void setTemp(s32 sourceType, const char *name, s32 subtype);
void registerSource(dSoundSource_c *);
void unregisterSource(dSoundSource_c *);
@@ -34,8 +38,10 @@ public:
dSoundSource_c *getSourceClosestToPlayer();
s32 getNumSources() const;
void set(s32 type, const char *name);
void setParam(s32 type, const char *name);
void calc();
void clear();
void clearTemp();
const char *getName() const {
return mName;
@@ -45,8 +51,8 @@ public:
return mpOrigName;
}
s32 getField_0x10() const {
return field_0x10;
s32 getSourceType() const {
return mSourceType;
}
bool isActive() const {
@@ -64,14 +70,14 @@ private:
/* 0x00 */ nw4r::ut::Node mNode1;
/* 0x08 */ nw4r::ut::Node mNode2;
/* 0x10 */ s32 field_0x10;
/* 0x10 */ s32 mSourceType;
/* 0x14 */ s32 mSourceCategory;
/* 0x18 */ s32 mSubtype;
/* 0x1C */ bool mIsActive;
/* 0x1D */ u8 field_0x1D;
/* 0x1D */ bool field_0x1D;
/* 0x1E */ SizedString<32> mName;
/* 0x40 */ const char *mpOrigName;
/* 0x44 */ nw4r::ut::List mSourceList;
/* 0x44 */ LIST_MEMBER(dSoundSource_c, SubSource);
/* 0x50 */ dSndSourceParam mParam;
/* 0x64 */ dSoundSource_c *mpCachedClosestSourceToListener;
/* 0x68 */ dSoundSource_c *mpCachedClosestSourceToPlayer;
+1
View File
@@ -78,6 +78,7 @@ private:
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);
bool addGroupToLoading(dSndSourceGroup_c *group);
void activateGroup(dSndSourceGroup_c *group);
bool isActiveGroup(dSndSourceGroup_c *group) const;
+16 -15
View File
@@ -3,6 +3,7 @@
#include "common.h"
#include "d/snd/d_snd_mgr.h"
#include "d/snd/d_snd_player_mgr.h"
#include "d/snd/d_snd_source_enums.h"
#include "d/snd/d_snd_source_group.h"
#include "d/snd/d_snd_util.h"
#include "d/snd/d_snd_id_mappers_data.h"
@@ -18,15 +19,15 @@ const char *getBaseVariant(const char *name) {
return nullptr;
}
u32 getGrpId(s32 unk, const char *name) {
u32 getGrpId(s32 sourceType, const char *name) {
if (name == nullptr) {
return -1;
}
if (unk < 0) {
if (sourceType < 0) {
return -1;
}
if (unk >= 0x3C) {
if (sourceType >= SND_SOURCE_59 + 1) {
return -1;
}
@@ -49,22 +50,22 @@ u32 getGrpId(dSndSourceGroup_c *pGroup) {
if (pGroup == nullptr) {
return -1;
}
u32 id = getGrpId(pGroup->getField_0x10(), pGroup->getName());
u32 id = getGrpId(pGroup->getSourceType(), pGroup->getName());
if (id == -1 && pGroup->getOrigName() != nullptr) {
id = getGrpId(pGroup->getField_0x10(), pGroup->getOrigName());
id = getGrpId(pGroup->getSourceType(), pGroup->getOrigName());
}
return id;
}
u32 getBnkSeId(s32 unk, const char *name) {
u32 getBnkSeId(s32 sourceType, const char *name) {
if (name == nullptr) {
return -1;
}
if (unk < 0) {
if (sourceType < 0) {
return -1;
}
if (unk >= 0x3C) {
if (sourceType >= SND_SOURCE_59 + 1) {
return -1;
}
@@ -87,22 +88,22 @@ u32 getBnkSeId(dSndSourceGroup_c *pGroup) {
if (pGroup == nullptr) {
return -1;
}
u32 id = getBnkSeId(pGroup->getField_0x10(), pGroup->getName());
u32 id = getBnkSeId(pGroup->getSourceType(), pGroup->getName());
if (id == -1 && pGroup->getOrigName() != nullptr) {
id = getBnkSeId(pGroup->getField_0x10(), pGroup->getOrigName());
id = getBnkSeId(pGroup->getSourceType(), pGroup->getOrigName());
}
return id;
}
u32 getSeId(s32 unk, const char *name) {
u32 getSeId(s32 sourceType, const char *name) {
if (name == nullptr) {
return -1;
}
if (unk < 0) {
if (sourceType < 0) {
return -1;
}
if (unk >= 0x3C) {
if (sourceType >= SND_SOURCE_59 + 1) {
return -1;
}
@@ -125,9 +126,9 @@ u32 getSeId(dSndSourceGroup_c *pGroup) {
if (pGroup == nullptr) {
return -1;
}
u32 id = getSeId(pGroup->getField_0x10(), pGroup->getName());
u32 id = getSeId(pGroup->getSourceType(), pGroup->getName());
if (id == -1 && pGroup->getOrigName() != nullptr) {
id = getSeId(pGroup->getField_0x10(), pGroup->getOrigName());
id = getSeId(pGroup->getSourceType(), pGroup->getOrigName());
}
return id;
}
+39
View File
@@ -7,6 +7,7 @@
#include "d/snd/d_snd_bgm_mgr.h"
#include "d/snd/d_snd_control_player_mgr.h"
#include "d/snd/d_snd_file_mgr.h"
#include "d/snd/d_snd_id_mappers.h"
#include "d/snd/d_snd_mgr.h"
#include "d/snd/d_snd_small_effect_mgr.h"
#include "d/snd/d_snd_source.h"
@@ -257,6 +258,44 @@ nw4r::snd::SoundStartable::StartResult dSndPlayerMgr_c::startSound(
return startSound(pHandle, id, pStartInfo);
}
bool dSndPlayerMgr_c::loadGroup(u32 groupId) {
if (dSndMgr_c::getPlayer().IsLoadedGroup(groupId)) {
// TODO - true would probably make more sense if the return value
// was checked at all...
return false;
}
return dSndMgr_c::GetInstance()->loadGroup(groupId, nullptr, 0);
}
bool dSndPlayerMgr_c::loadFileForSound(u32 soundId) {
if (soundId == -1) {
return false;
}
return dSndFileManager::loadFileForSound(
*dSndMgr_c::GetInstance()->getArchive(), soundId, dSndMgr_c::GetInstance()->getSoundHeap()
);
}
bool dSndPlayerMgr_c::isLoadedFileForSound(u32 soundId) {
return dSndFileManager::isLoadedFileForSound(&dSndMgr_c::getPlayer(), soundId);
}
bool dSndPlayerMgr_c::isLoadedFileForBank(u32 bankId) {
return dSndFileManager::isLoadedFileAndWaveForBank(&dSndMgr_c::getPlayer(), bankId);
}
bool dSndPlayerMgr_c::isLoadedBnkSeForGroup(dSndSourceGroup_c *group) {
return isLoadedFileForBank(getBnkSeId(group));
}
bool dSndPlayerMgr_c::isLoadedFileAndWaveForSound(u32 soundId) {
return dSndFileManager::isLoadedFileAndWaveForSound(&dSndMgr_c::getPlayer(), soundId);
}
bool dSndPlayerMgr_c::isLoadedSeFileAndWaveForGroup(dSndSourceGroup_c *group) {
return isLoadedFileAndWaveForSound(getSeId(group));
}
u32 dSndPlayerMgr_c::getRemoConSoundVariant(u32 soundId) const {
const char *label = dSndMgr_c::getSoundLabelString(soundId);
SizedString<64> variant;
+63 -15
View File
@@ -4,12 +4,13 @@
#include "common.h"
#include "d/snd/d_snd_source.h"
#include "d/snd/d_snd_source_enums.h"
#include "d/snd/d_snd_source_mgr.h"
#include "d/snd/d_snd_state_mgr.h"
#include "nw4r/ut/ut_list.h"
#include <cmath>
void dSndSourceGroup_c::set(s32 sourceType, const char *name) {
void dSndSourceGroup_c::setParam(s32 sourceType, const char *name) {
resetSoundSourceParam();
bool assignedParam = false;
@@ -71,7 +72,7 @@ void dSndSourceGroup_c::resetSoundSourceParam() {
dSndSourceGroup_c::dSndSourceGroup_c()
: mSubtype(0),
mIsActive(false),
field_0x1D(0),
field_0x1D(false),
mName(""),
mpOrigName(nullptr),
mpCachedClosestSourceToListener(nullptr),
@@ -79,14 +80,61 @@ dSndSourceGroup_c::dSndSourceGroup_c()
mCalculatedClosestToListener(false),
mCalculatedClosestToPlayer(false) {
// TODO offsetof
nw4r::ut::List_Init(&mSourceList, 0x138);
nw4r::ut::List_Init(&mSubSourceList, 0x138);
resetSoundSourceParam();
}
dSndSourceGroup_c::dSndSourceGroup_c(s32 sourceType, const char *name, const char *origName, s32 subtype)
: mSourceCategory(-1),
mSubtype(subtype),
mIsActive(false),
field_0x1D(false),
mName(name),
mpOrigName(origName),
mpCachedClosestSourceToListener(nullptr),
mpCachedClosestSourceToPlayer(nullptr),
mCalculatedClosestToListener(false),
mCalculatedClosestToPlayer(false) {
nw4r::ut::List_Init(&mSubSourceList, 0x138);
setParam(sourceType, name);
}
void dSndSourceGroup_c::set(s32 sourceType, const char *name, const char *origName, s32 subtype) {
mSourceCategory = dSndSourceMgr_c::getSourceCategoryForSourceType(sourceType, name);
setParam(sourceType, name);
mSourceType = sourceType;
mName = name;
mSubtype = subtype;
mpCachedClosestSourceToPlayer = nullptr;
mpCachedClosestSourceToListener = nullptr;
mCalculatedClosestToPlayer = false;
mCalculatedClosestToListener = false;
mpOrigName = origName;
}
void dSndSourceGroup_c::setTemp(s32 sourceType, const char *name, s32 subtype) {
mSourceType = sourceType;
mName = name;
mSubtype = subtype;
}
dSndSourceGroup_c::~dSndSourceGroup_c() {
clearList();
}
void dSndSourceGroup_c::clear() {
clearList();
mIsActive = false;
field_0x1D = false;
mName = "";
}
void dSndSourceGroup_c::clearTemp() {
mIsActive = false;
field_0x1D = false;
mName = "";
}
void dSndSourceGroup_c::calc() {
// Reset freshness flags, computed on-demand
mCalculatedClosestToPlayer = false;
@@ -94,26 +142,26 @@ void dSndSourceGroup_c::calc() {
}
s32 dSndSourceGroup_c::getNumSources() const {
return nw4r::ut::List_GetSize(&mSourceList);
return nw4r::ut::List_GetSize(&mSubSourceList);
}
void dSndSourceGroup_c::registerSource(dSoundSource_c *source) {
if (source != nullptr) {
nw4r::ut::List_Append(&mSourceList, source);
appendSubSource(source);
}
}
void dSndSourceGroup_c::unregisterSource(dSoundSource_c *source) {
if (source != nullptr) {
nw4r::ut::List_Remove(&mSourceList, source);
removeSubSource(source);
}
}
void dSndSourceGroup_c::clearList() {
dSoundSource_c *source = static_cast<dSoundSource_c *>(nw4r::ut::List_GetFirst(&mSourceList));
dSoundSource_c *source = getSubSourceFirst();
while (source != nullptr) {
nw4r::ut::List_Remove(&mSourceList, source);
source = static_cast<dSoundSource_c *>(nw4r::ut::List_GetFirst(&mSourceList));
removeSubSource(source);
source = getSubSourceFirst();
}
}
@@ -124,8 +172,8 @@ dSoundSource_c *dSndSourceGroup_c::getSourceClosestToListener() {
mpCachedClosestSourceToListener = nullptr;
f32 closest = INFINITY;
for (dSoundSource_c *source = static_cast<dSoundSource_c *>(nw4r::ut::List_GetFirst(&mSourceList));
source != nullptr; source = static_cast<dSoundSource_c *>(nw4r::ut::List_GetNext(&mSourceList, source))) {
for (dSoundSource_c *source = getSubSourceFirst();
source != nullptr; source = getSubSourceNext(source)) {
if (source->getSourceType() != SND_SOURCE_PLAYER_HEAD && source->getSourceType() != SND_SOURCE_NPC_HEAD) {
f32 dist = source->getDistanceToListener();
if (dist < closest) {
@@ -143,14 +191,14 @@ dSoundSource_c *dSndSourceGroup_c::getSourceClosestToPlayer() {
return mpCachedClosestSourceToPlayer;
}
if ((s32)nw4r::ut::List_GetSize(&mSourceList) <= 1) {
return static_cast<dSoundSource_c *>(nw4r::ut::List_GetFirst(&mSourceList));
if ((s32)nw4r::ut::List_GetSize(&mSubSourceList) <= 1) {
return getSubSourceFirst();
}
mpCachedClosestSourceToPlayer = nullptr;
f32 closest = INFINITY;
for (dSoundSource_c *source = static_cast<dSoundSource_c *>(nw4r::ut::List_GetFirst(&mSourceList));
source != nullptr; source = static_cast<dSoundSource_c *>(nw4r::ut::List_GetNext(&mSourceList, source))) {
for (dSoundSource_c *source = getSubSourceFirst();
source != nullptr; source = getSubSourceNext(source)) {
if (source->getSourceType() != 1 && source->getSourceType() != 48) {
f32 dist = source->getDistanceToPlayer();
if (dist < closest) {
+24 -1
View File
@@ -2,6 +2,7 @@
#include "common.h"
#include "d/a/d_a_base.h"
#include "d/snd/d_snd_bgm_mgr.h"
#include "d/snd/d_snd_control_player_mgr.h"
#include "d/snd/d_snd_id_mappers_data.h"
#include "d/snd/d_snd_player_mgr.h"
@@ -372,7 +373,7 @@ dSndSourceMgr_c::dSndSourceMgr_c()
nw4r::ut::List_Init(&field_0x3848, 0x15C);
nw4r::ut::List_Init(&mHarpRelatedList, 0x160);
mpDefaultGroup = new dSndSourceGroup_c(-1, "Default", 0, 0);
mpDefaultGroup = new dSndSourceGroup_c(-1, "Default", nullptr, 0);
for (dSndSourceGroup_c *group = &mGroups[0]; group < &mGroups[NUM_GROUPS]; group++) {
nw4r::ut::List_Append(&mGroup2List, group);
@@ -393,6 +394,24 @@ void dSndSourceMgr_c::calcEnemyObjVolume() {
}
}
dSndSourceGroup_c *dSndSourceMgr_c::getGroup(s32 sourceType, dAcBase_c *actor, const char *name, const char *origName, u8 subtype) {
dSndSourceGroup_c *group = getActiveGroupForName(name);
if (group != nullptr) {
return group;
}
group = getInactiveGroup();
if (group != nullptr) {
group->set(sourceType, name, origName, subtype);
activateGroup(group);
addGroupToLoading(group);
dSndBgmMgr_c::GetInstance()->prepareBossBgm(name);
return group;
}
return nullptr;
}
dSndSourceGroup_c *dSndSourceMgr_c::getActiveGroupForName(const char *name) {
for (dSndSourceGroup_c *it = getGroup1First(); it != nullptr; it = getGroup1Next(it)) {
if (streq(it->getName(), name)) {
@@ -406,6 +425,10 @@ dSndSourceGroup_c *dSndSourceMgr_c::getInactiveGroup() {
return getGroup2First();
}
bool dSndSourceMgr_c::addGroupToLoading(dSndSourceGroup_c *source) {
}
void dSndSourceMgr_c::registerSource(dSoundSource_c *source) {
if (source != nullptr) {
nw4r::ut::List_Append(&mAllSourcesList, source);