diff options
| author | robojumper <robojumper@gmail.com> | 2025-07-05 12:27:21 +0200 |
|---|---|---|
| committer | robojumper <robojumper@gmail.com> | 2025-09-13 10:59:40 +0200 |
| commit | 794c7e35b6e4e89b2779916b8d67420532d65b7d (patch) | |
| tree | 91f4db906d47b6e5a33dce3e52a928ed10ef38d7 /src | |
| parent | 35b3d2a787d05b152d14c71f20baa444493cb3c4 (diff) | |
d_snd_id_mappers OK
Diffstat (limited to 'src')
| -rw-r--r-- | src/d/snd/d_snd_bgm_mgr.cpp | 24 | ||||
| -rw-r--r-- | src/d/snd/d_snd_id_mappers.cpp | 151 | ||||
| -rw-r--r-- | src/d/snd/d_snd_id_mappers_data.cpp | 131 | ||||
| -rw-r--r-- | src/d/snd/d_snd_source_group.cpp | 2 | ||||
| -rw-r--r-- | src/d/snd/d_snd_source_mgr.cpp | 17 |
5 files changed, 311 insertions, 14 deletions
diff --git a/src/d/snd/d_snd_bgm_mgr.cpp b/src/d/snd/d_snd_bgm_mgr.cpp index 84608cfa..597be71f 100644 --- a/src/d/snd/d_snd_bgm_mgr.cpp +++ b/src/d/snd/d_snd_bgm_mgr.cpp @@ -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; diff --git a/src/d/snd/d_snd_id_mappers.cpp b/src/d/snd/d_snd_id_mappers.cpp new file mode 100644 index 00000000..374827cc --- /dev/null +++ b/src/d/snd/d_snd_id_mappers.cpp @@ -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 ""; +} diff --git a/src/d/snd/d_snd_id_mappers_data.cpp b/src/d/snd/d_snd_id_mappers_data.cpp new file mode 100644 index 00000000..84a8f0ea --- /dev/null +++ b/src/d/snd/d_snd_id_mappers_data.cpp @@ -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 diff --git a/src/d/snd/d_snd_source_group.cpp b/src/d/snd/d_snd_source_group.cpp index 6beda14f..67880c52 100644 --- a/src/d/snd/d_snd_source_group.cpp +++ b/src/d/snd/d_snd_source_group.cpp @@ -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), diff --git a/src/d/snd/d_snd_source_mgr.cpp b/src/d/snd/d_snd_source_mgr.cpp index b587d07f..90cafbc6 100644 --- a/src/d/snd/d_snd_source_mgr.cpp +++ b/src/d/snd/d_snd_source_mgr.cpp @@ -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; } |
