mirror of
https://github.com/zeldaret/ss
synced 2026-08-25 07:44:40 -04:00
d_snd_id_mappers OK
This commit is contained in:
@@ -140,7 +140,7 @@ bool dSndBgmMgr_c::beginBgmBattleRoom() {
|
||||
return false;
|
||||
}
|
||||
|
||||
return playBattleBgm(BGM_BATTLE_ROOM_MAIN, 5);
|
||||
return playBattleBgm(BGM_BATTLE_ROOM_MAIN, true);
|
||||
}
|
||||
|
||||
bool dSndBgmMgr_c::endBgmBattleRoom() {
|
||||
@@ -462,6 +462,28 @@ void dSndBgmMgr_c::stopFanSounds(s32 fadeFrames) {
|
||||
}
|
||||
}
|
||||
|
||||
void dSndBgmMgr_c::calcStopOldBgmSounds() {
|
||||
s32 numPlayingSounds = 0;
|
||||
|
||||
dSndBgmSound_c *it;
|
||||
for (it = getFirstInBgmSoundList(BGM_LIST_PLAYING); it != nullptr;
|
||||
it = getNextInBgmSoundList(BGM_LIST_PLAYING, it)) {
|
||||
if (!it->isPaused() && it->isStrmSound()) {
|
||||
numPlayingSounds++;
|
||||
}
|
||||
}
|
||||
|
||||
// If more than one strm sound is playing, stop all but the first one
|
||||
if (numPlayingSounds >= 2) {
|
||||
for (it = getFirstInBgmSoundList(BGM_LIST_PLAYING); it != nullptr;
|
||||
it = getNextInBgmSoundList(BGM_LIST_PLAYING, it)) {
|
||||
if (!it->isPaused() && it->isStrmSound() && it != getFirstInBgmSoundList(BGM_LIST_PLAYING)) {
|
||||
it->stop(15);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dSndBgmMgr_c::registSound(dSndSound_c *sound) {
|
||||
if (sound == nullptr) {
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
#include "d/snd/d_snd_id_mappers.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "d/snd/d_snd_mgr.h"
|
||||
#include "d/snd/d_snd_player_mgr.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"
|
||||
#include "sized_string.h"
|
||||
|
||||
const char *getBaseVariant(const char *name) {
|
||||
const ActorBaseNamePair *pair = sActorBaseNamePairs;
|
||||
for (int i = 0; i < sNumActorBaseNamePairs; i++) {
|
||||
if (streq(name, sActorBaseNamePairs[i].variant)) {
|
||||
return sActorBaseNamePairs[i].base;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
u32 getGrpId(s32 unk, const char *name) {
|
||||
if (name == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
if (unk < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (unk >= 0x3C) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SizedString<64> label;
|
||||
label.sprintf("GRP_%s", name);
|
||||
u32 id = dSndMgr_c::GetInstance()->getArchive()->ConvertLabelStringToGroupId(label);
|
||||
if (id != -1) {
|
||||
return id;
|
||||
}
|
||||
const char *base = getBaseVariant(name);
|
||||
if (base != nullptr) {
|
||||
label.sprintf("GRP_%s", base);
|
||||
id = dSndMgr_c::GetInstance()->getArchive()->ConvertLabelStringToGroupId(label);
|
||||
return id;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
u32 getGrpId(dSndSourceGroup_c *pGroup) {
|
||||
if (pGroup == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
u32 id = getGrpId(pGroup->getField_0x10(), pGroup->getName());
|
||||
if (id == -1 && pGroup->getOrigName() != nullptr) {
|
||||
id = getGrpId(pGroup->getField_0x10(), pGroup->getOrigName());
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
u32 getBnkSeId(s32 unk, const char *name) {
|
||||
if (name == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
if (unk < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (unk >= 0x3C) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SizedString<64> label;
|
||||
label.sprintf("BNK_SE_%s", name);
|
||||
u32 id = dSndMgr_c::GetInstance()->getArchive()->ConvertLabelStringToBankId(label);
|
||||
if (id != -1) {
|
||||
return id;
|
||||
}
|
||||
const char *base = getBaseVariant(name);
|
||||
if (base != nullptr) {
|
||||
label.sprintf("BNK_SE_%s", base);
|
||||
id = dSndMgr_c::GetInstance()->getArchive()->ConvertLabelStringToBankId(label);
|
||||
return id;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
u32 getBnkSeId(dSndSourceGroup_c *pGroup) {
|
||||
if (pGroup == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
u32 id = getBnkSeId(pGroup->getField_0x10(), pGroup->getName());
|
||||
if (id == -1 && pGroup->getOrigName() != nullptr) {
|
||||
id = getBnkSeId(pGroup->getField_0x10(), pGroup->getOrigName());
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
u32 getSeId(s32 unk, const char *name) {
|
||||
if (name == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
if (unk < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (unk >= 0x3C) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SizedString<64> label;
|
||||
label.sprintf("SE_%s", name);
|
||||
u32 id = dSndPlayerMgr_c::GetInstance()->convertLabelStringToSoundId(label);
|
||||
if (id != -1) {
|
||||
return id;
|
||||
}
|
||||
const char *base = getBaseVariant(name);
|
||||
if (base != nullptr) {
|
||||
label.sprintf("SE_%s", base);
|
||||
id = dSndPlayerMgr_c::GetInstance()->convertLabelStringToSoundId(label);
|
||||
return id;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
u32 getSeId(dSndSourceGroup_c *pGroup) {
|
||||
if (pGroup == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
u32 id = getSeId(pGroup->getField_0x10(), pGroup->getName());
|
||||
if (id == -1 && pGroup->getOrigName() != nullptr) {
|
||||
id = getSeId(pGroup->getField_0x10(), pGroup->getOrigName());
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma readonly_strings on
|
||||
// TODO could be yet another file
|
||||
const char *sSndHitEffects[] = {
|
||||
"TUTI", "ROCK", "SAND", "GRASS", "TREE", "LAVA", "WATER", "STONE", "LOTUS",
|
||||
"METAL", "NUMA", "TUTA", "LIFE", "CARPET", "QSAND", "WOOD", "DEATH",
|
||||
};
|
||||
|
||||
#pragma pop
|
||||
|
||||
const char *getHitEffectName(u32 polyAttr0) {
|
||||
if (polyAttr0 >= 1 && polyAttr0 < SND_MAT_MAX) {
|
||||
polyAttr0 -= 1;
|
||||
return sSndHitEffects[polyAttr0];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
#include "d/snd/d_snd_id_mappers_data.h"
|
||||
|
||||
#pragma push
|
||||
#pragma readonly_strings on
|
||||
|
||||
const ActorBaseNamePair sActorBaseNamePairs[] = {
|
||||
{ "KinokoA", "Kinoko"},
|
||||
{ "KinokoB", "Kinoko"},
|
||||
{ "KinokoC", "Kinoko"},
|
||||
{ "KinokoD", "Kinoko"},
|
||||
{ "SKinoko", "Kinoko"},
|
||||
{ "Tbox", "TBox"},
|
||||
{ "LBmaker", "LBird"},
|
||||
{ "TansuA", "chest"},
|
||||
{ "TansuB", "chest"},
|
||||
{ "TansuC", "chest"},
|
||||
{ "BbsRock", "RolRock"},
|
||||
{ "NpcRvlR", "NpcBRvl"},
|
||||
{ "NpcMWNi", "NpcSalS_A2"},
|
||||
{ "NpcMHNi", "NpcSalS_A8"},
|
||||
{ "NpcIcgK", "NpcKbn2"},
|
||||
{ "NpcKb2N", "NpcKbn2"},
|
||||
{ "NpcDoNi", "NpcSalS_A1"},
|
||||
{ "NpcJkNi", "NpcSalS_A4"},
|
||||
{ "NpcAzNi", "NpcSalS_A5"},
|
||||
{ "NpcPcs", "NpcCbFd"},
|
||||
{ "NpcAkuH", "NpcAkum"},
|
||||
{ "NpcJkML", "NpcJkMo"},
|
||||
{ "NpcDoML", "NpcDoMo"},
|
||||
{ "NpcSAML", "NpcSAMo"},
|
||||
{"NpcResc_A3", "NpcResc"},
|
||||
{"NpcResc_A4", "NpcResc_A1"},
|
||||
{"NpcResc_A5", "NpcResc_A2"},
|
||||
{ "NpcGrb", "NpcGra"},
|
||||
{ "NpcGrc", "NpcGra"},
|
||||
{ "NpcGrd", "NpcGra"},
|
||||
{ "OcGrsL", "OctGrs"},
|
||||
{ "NpcOkyu", "Npckyu"},
|
||||
{ "Npckyu1", "Npckyu"},
|
||||
{ "Npckyu2", "Npckyu"},
|
||||
{ "Npckyu3", "Npckyu"},
|
||||
{ "Npckyu4", "Npckyu"},
|
||||
{ "NpcSlKy", "Npckyu"},
|
||||
{ "rpiller", "rpillar"},
|
||||
{ "EOc", "EBc"},
|
||||
{ "EBce", "EBc"},
|
||||
{ "CupA00", "tware"},
|
||||
{ "CupA01", "tware"},
|
||||
{ "CupA02", "tware"},
|
||||
{ "CupB00", "tware"},
|
||||
{ "CupB01", "tware"},
|
||||
{ "CupB02", "tware"},
|
||||
{ "PltA00", "tware"},
|
||||
{ "PltA01", "tware"},
|
||||
{ "PltA02", "tware"},
|
||||
{ "PltB00", "tware"},
|
||||
{ "PltB01", "tware"},
|
||||
{ "PltB02", "tware"},
|
||||
{ "FlvsA", "tware"},
|
||||
{ "FlvsB", "tware"},
|
||||
{ "FlvsC", "tware"},
|
||||
{ "PlntA00", "tware"},
|
||||
{ "PlntA01", "tware"},
|
||||
{ "PlntB", "tware"},
|
||||
{ "PlntC00", "tware"},
|
||||
{ "PlntC01", "tware"},
|
||||
{ "ERupGue", "EGue"},
|
||||
{ "BirdNpc", "BirdCommon"},
|
||||
{ "BirdKA", "BirdCommon"},
|
||||
{ "BirdKB", "BirdCommon"},
|
||||
{ "BirdT", "BirdCommon"},
|
||||
{ "NpcBdsw", "BirdCommon"},
|
||||
{ "DbidNpc", "BirdCommon"},
|
||||
{ "KndBird", "BirdCommon"},
|
||||
{ "BrdMob", "BirdCommon"},
|
||||
{ "NpcBdz", "BirdZT"},
|
||||
{ "InsctTg", "Insect"},
|
||||
{ "Ladybug", "Insect"},
|
||||
{ "Drgnfly", "Insect"},
|
||||
{ "Beetle", "Insect"},
|
||||
{ "Kuwagat", "Insect"},
|
||||
{ "Grshpr", "Insect"},
|
||||
{ "Cicada", "Insect"},
|
||||
{ "Ant", "Insect"},
|
||||
{ "Butrfly", "Insect"},
|
||||
{ "Mantis", "Insect"},
|
||||
{ "Scarab", "Insect"},
|
||||
{ "Firefly", "Insect"},
|
||||
{ "BcAlArr", "BcArrow"},
|
||||
{ "FShutte", "FenceIr"},
|
||||
{ "BBigBo2", "BBigBos"},
|
||||
{ "BBigBo3", "BBigBos"},
|
||||
{ "NusiNpc", "Nusi"},
|
||||
{ "NusiB", "Nusi"},
|
||||
{ "NpcMoN2", "NpcMoN"},
|
||||
{ "NpcMoEN", "NpcMole"},
|
||||
{ "NpcMoS", "NpcMoEl"},
|
||||
{ "NpcMoT2", "NpcMoT"},
|
||||
{ "BGh2", "BGh"},
|
||||
{ "BGh3Fst", "BGh3"},
|
||||
{ "BGh3Snd", "BGh3"},
|
||||
{ "BGh3Trd", "BGh3"},
|
||||
{ "NpcSlb2", "NpcSlrb"},
|
||||
{ "NpcSlFB", "NpcSlrb"},
|
||||
{ "NpcSlRp", "NpcSlrb"},
|
||||
{ "NpcSlFl", "NpcSlrb"},
|
||||
{ "FlySlrb", "NpcSlrb"},
|
||||
{ "NpcKenT", "NpcKen"},
|
||||
{ "GuardLg", "SliceLg"},
|
||||
{ "SlicePt", "SliceLg"},
|
||||
{ "TrShtCs", "trlshut"},
|
||||
{ "Fmaker", "Fish"},
|
||||
{ "TgTw", "TWeed"},
|
||||
{ "BltObsT", "Obstacl"},
|
||||
{ "Item_A44", "Item_A43"},
|
||||
{ "Item_A45", "Item_A43"},
|
||||
{ "Item_A46", "Item_A43"},
|
||||
{ "PmpknBd", "Pumpkin"},
|
||||
{ "MgPmpkn", "Pumpkin"},
|
||||
{ "CmCloud", "CumlClud"},
|
||||
{ "IslTreB", "RockSkB"},
|
||||
{ "WnLeafA", "wnleaf"},
|
||||
{ "WnLeafB", "wnleaf"},
|
||||
{ "WnLeafC", "wnleaf"},
|
||||
{ "WnLeafD", "wnleaf"},
|
||||
{ "EOrCann", "EOr"},
|
||||
};
|
||||
|
||||
const s32 sNumActorBaseNamePairs = ARRAY_LENGTH(sActorBaseNamePairs);
|
||||
|
||||
#pragma pop
|
||||
@@ -73,7 +73,7 @@ dSndSourceGroup_c::dSndSourceGroup_c()
|
||||
mIsActive(false),
|
||||
field_0x1D(0),
|
||||
mName(""),
|
||||
field_0x40(0),
|
||||
mpOrigName(nullptr),
|
||||
mpCachedClosestSourceToListener(nullptr),
|
||||
mpCachedClosestSourceToPlayer(nullptr),
|
||||
mCalculatedClosestToListener(false),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "common.h"
|
||||
#include "d/a/d_a_base.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"
|
||||
#include "d/snd/d_snd_small_effect_mgr.h"
|
||||
#include "d/snd/d_snd_source.h"
|
||||
@@ -42,14 +43,6 @@
|
||||
// dSndAnimSound_c are reversed compared to their natural vtable order,
|
||||
// and the overridden `SetupSound` function seems to be immune to reordering
|
||||
|
||||
// TODO move
|
||||
struct ActorBaseNamePair {
|
||||
const char *variant;
|
||||
const char *base;
|
||||
};
|
||||
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:
|
||||
@@ -199,10 +192,10 @@ dSoundSourceIf_c *dSndSourceMgr_c::createSource(s32 sourceType, dAcBase_c *actor
|
||||
}
|
||||
|
||||
if (sourceType == SND_SOURCE_NPC_51) {
|
||||
const ActorBaseNamePair *pair = Actor_BaseActorName_Pairs;
|
||||
for (int i = 0; i < lbl_8057E394; i++) {
|
||||
if (streq(nameStr, Actor_BaseActorName_Pairs[i].variant)) {
|
||||
nameStr = Actor_BaseActorName_Pairs[i].base;
|
||||
const ActorBaseNamePair *pair = sActorBaseNamePairs;
|
||||
for (int i = 0; i < sNumActorBaseNamePairs; i++) {
|
||||
if (streq(nameStr, sActorBaseNamePairs[i].variant)) {
|
||||
nameStr = sActorBaseNamePairs[i].base;
|
||||
isModified = true;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user