mirror of
https://github.com/zeldaret/ss
synced 2026-08-30 09:11:14 -04:00
A few funcs
This commit is contained in:
@@ -340,6 +340,30 @@ f32 dSndControlPlayerMgr_c::getControlTarget(PlayerCtrl_e ctrlType, u32 playerId
|
||||
return mpCtrls[ctrlType][playerIdx].getTargetValue();
|
||||
}
|
||||
|
||||
// TODO - not sure what this actually does
|
||||
void dSndControlPlayerMgr_c::unmutePlayer(u32 idx, s32 frames) {
|
||||
if (idx >= sNumPlayers) {
|
||||
return;
|
||||
}
|
||||
|
||||
restoreVolume(idx, 0);
|
||||
overrideVolume(idx, 0.0f, 0);
|
||||
restoreVolume(idx, frames);
|
||||
}
|
||||
|
||||
|
||||
void dSndControlPlayerMgr_c::unmuteScenePlayers(s32 frames) {
|
||||
for (u32 i = dSndPlayerMgr_c::PLAYER_ENEMY; i < dSndPlayerMgr_c::PLAYER_AREA; i++) {
|
||||
unmutePlayer(i, frames);
|
||||
}
|
||||
}
|
||||
|
||||
void dSndControlPlayerMgr_c::muteScenePlayers(s32 frames) {
|
||||
for (u32 i = dSndPlayerMgr_c::PLAYER_ENEMY; i < dSndPlayerMgr_c::PLAYER_AREA; i++) {
|
||||
overrideVolume(i, 0.0f, frames);
|
||||
}
|
||||
}
|
||||
|
||||
void dSndControlPlayerMgr_c::setGroupVolumeFlag(VolumeControlGroup group, MuteLevel level) {
|
||||
if (group >= CTRL_GROUP_MAX) {
|
||||
return;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "d/snd/d_snd_area_sound_effect_mgr.h"
|
||||
#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_mgr.h"
|
||||
#include "d/snd/d_snd_small_effect_mgr.h"
|
||||
#include "d/snd/d_snd_source.h"
|
||||
@@ -26,8 +27,7 @@ const char *dSndPlayerMgr_c::getSoundArchivePath() {
|
||||
|
||||
SND_DISPOSER_DEFINE(dSndPlayerMgr_c);
|
||||
|
||||
dSndPlayerMgr_c::dSndPlayerMgr_c()
|
||||
: field_0x010(0), field_0x011(0), field_0x014(-1), field_0x018(-1), field_0x01C(-1), mFlags(0) {}
|
||||
dSndPlayerMgr_c::dSndPlayerMgr_c() : field_0x010(0), field_0x011(0), mState0(-1), mState1(-1), mState2(-1), mFlags(0) {}
|
||||
|
||||
void dSndPlayerMgr_c::enterPauseState() {
|
||||
dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_FAN, 0.3f, 5);
|
||||
@@ -37,6 +37,62 @@ void dSndPlayerMgr_c::enterPauseState() {
|
||||
onFlag(MGR_PAUSE);
|
||||
}
|
||||
|
||||
void dSndPlayerMgr_c::createFileManager() {
|
||||
dSndMgr_c::getPlayer().detail_SetFileManager(
|
||||
dSndFileManager::create(dSndMgr_c::GetInstance()->getArchive(), dSndMgr_c::GetInstance()->getSoundHeap())
|
||||
);
|
||||
}
|
||||
|
||||
void dSndPlayerMgr_c::setupState0() {
|
||||
if (mState0 > 0) {
|
||||
return;
|
||||
}
|
||||
initialize();
|
||||
|
||||
// TODO: Ugh, maybe convert the enums to unsigned ints?
|
||||
dSndMgr_c::GetInstance()->loadGroup((unsigned int)GRP_STATIC, nullptr, 0);
|
||||
mState0 = dSndMgr_c::GetInstance()->saveState();
|
||||
|
||||
s32 tmpState = dSndMgr_c::GetInstance()->saveState();
|
||||
dSndMgr_c::GetInstance()->loadGroup((unsigned int)GRP_BGM_PLAY_DATA_STATIC, nullptr, 0);
|
||||
|
||||
// TODO - loading static play data
|
||||
|
||||
dSndMgr_c::GetInstance()->loadState(tmpState);
|
||||
}
|
||||
|
||||
void dSndPlayerMgr_c::popToState0() {
|
||||
if (mState0 < 0) {
|
||||
return;
|
||||
}
|
||||
dSndMgr_c::GetInstance()->loadState(mState0);
|
||||
mState1 = -1;
|
||||
mState2 = -1;
|
||||
}
|
||||
|
||||
void dSndPlayerMgr_c::saveState1() {
|
||||
mState1 = dSndMgr_c::GetInstance()->saveState();
|
||||
}
|
||||
|
||||
void dSndPlayerMgr_c::popToState1() {
|
||||
if (mState1 < 0) {
|
||||
return;
|
||||
}
|
||||
dSndMgr_c::GetInstance()->loadState(mState1);
|
||||
mState2 = -1;
|
||||
}
|
||||
|
||||
void dSndPlayerMgr_c::saveState2() {
|
||||
mState2 = dSndMgr_c::GetInstance()->saveState();
|
||||
}
|
||||
|
||||
void dSndPlayerMgr_c::popToState2() {
|
||||
if (mState2 < 0) {
|
||||
return;
|
||||
}
|
||||
dSndMgr_c::GetInstance()->loadState(mState2);
|
||||
}
|
||||
|
||||
u32 dSndPlayerMgr_c::getFreeSize() {
|
||||
return dSndMgr_c::GetInstance()->getSoundHeap()->GetFreeSize();
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
#include "d/snd/d_snd_event.h"
|
||||
#include "d/snd/d_snd_player_mgr.h"
|
||||
#include "d/snd/d_snd_stage_data.h"
|
||||
#include "d/snd/d_snd_util.h"
|
||||
#include "egg/core/eggHeap.h"
|
||||
#include "nw4r/snd/snd_FxReverbStdDpl2.h"
|
||||
#include "sized_string.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@@ -110,7 +112,7 @@ void dSndStateMgr_c::onStageOrLayerUpdate() {
|
||||
mPreviousStageId = mStageId;
|
||||
field_0x044 = getStageUnk2(newStageId);
|
||||
mStageId = newStageId;
|
||||
|
||||
|
||||
if (unk_0x065) {
|
||||
setCallbacksForStage();
|
||||
}
|
||||
@@ -176,10 +178,8 @@ bool dSndStateMgr_c::isVolcanicDungeon(u32 stageId) {
|
||||
case SND_STAGE_D201:
|
||||
case SND_STAGE_D201_1:
|
||||
case SND_STAGE_D003_0:
|
||||
case SND_STAGE_D003_1:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case SND_STAGE_D003_1: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,3 +232,164 @@ void dSndStateMgr_c::initializeEventCallbacks(const char *name) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char *dSndStateMgr_c::getStageName(s32 id) {
|
||||
if (id >= SND_STAGE_MAX) {
|
||||
return "NULL";
|
||||
}
|
||||
return dSndStageInfo::sInfos[id].stageName;
|
||||
}
|
||||
|
||||
const char *dSndStateMgr_c::getStageName4(s32 id) {
|
||||
if (id >= SND_STAGE_MAX) {
|
||||
return "NULL";
|
||||
}
|
||||
return dSndStageInfo::sInfos[getSndStageId4(id)].stageName;
|
||||
}
|
||||
|
||||
const char *dSndStateMgr_c::getCurrentStageName4() {
|
||||
return getStageName(dSndStageInfo::sInfos[mStageId].unk4);
|
||||
}
|
||||
|
||||
s32 dSndStateMgr_c::getSndStageId(const char *stageName, s32 layer) {
|
||||
if (stageName != nullptr) {
|
||||
for (s32 idx = 0; idx < dSndStageInfo::sNumStageInfos; idx++) {
|
||||
if (streq(stageName, dSndStageInfo::sInfos[idx].stageName)) {
|
||||
if (dSndStageInfo::sInfos[idx].layer == -1) {
|
||||
return dSndStageInfo::sInfos[idx].unk1;
|
||||
}
|
||||
if (dSndStageInfo::sInfos[idx].layer == layer) {
|
||||
return dSndStageInfo::sInfos[idx].unk1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SND_STAGE_MAX;
|
||||
}
|
||||
|
||||
s32 dSndStateMgr_c::getSndStageId3(const char *stageName, s32 layer) {
|
||||
if (stageName != nullptr) {
|
||||
for (s32 idx = 0; idx < dSndStageInfo::sNumStageInfos; idx++) {
|
||||
if (streq(stageName, dSndStageInfo::sInfos[idx].stageName)) {
|
||||
if (dSndStageInfo::sInfos[idx].layer == -1 || dSndStageInfo::sInfos[idx].layer == layer) {
|
||||
return dSndStageInfo::sInfos[idx].unk3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SND_STAGE_MAX;
|
||||
}
|
||||
|
||||
s32 dSndStateMgr_c::getSndStageId4(const char *stageName, s32 layer) {
|
||||
if (stageName != nullptr) {
|
||||
for (s32 idx = 0; idx < dSndStageInfo::sNumStageInfos; idx++) {
|
||||
if (streq(stageName, dSndStageInfo::sInfos[idx].stageName)) {
|
||||
if (dSndStageInfo::sInfos[idx].layer == -1 || dSndStageInfo::sInfos[idx].layer == layer) {
|
||||
return dSndStageInfo::sInfos[idx].unk4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SND_STAGE_MAX;
|
||||
}
|
||||
|
||||
s32 dSndStateMgr_c::getSndStageId2(s32 id) {
|
||||
if (id >= SND_STAGE_MAX) {
|
||||
return SND_STAGE_MAX;
|
||||
}
|
||||
return dSndStageInfo::sInfos[id].unk2;
|
||||
}
|
||||
|
||||
s32 dSndStateMgr_c::getSndStageId4(s32 id) {
|
||||
if (id >= SND_STAGE_MAX) {
|
||||
return SND_STAGE_MAX;
|
||||
}
|
||||
return dSndStageInfo::sInfos[id].unk4;
|
||||
}
|
||||
|
||||
s32 dSndStateMgr_c::getNextSndStageId(s32 id) {
|
||||
return getSndStageId(dScGame_c::nextSpawnInfo.getStageName(), dScGame_c::nextSpawnInfo.layer);
|
||||
}
|
||||
|
||||
bool dSndStateMgr_c::specialLayerVersionExists(const char *stageName, s32 layer) {
|
||||
if (stageName != nullptr && layer > 0) {
|
||||
return getSndStageId(stageName, layer) != getSndStageId(stageName, 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 dSndStateMgr_c::getSoundIdForStageAndLayer(SoundIdLookup_e lookup, const char *stageName, s32 layer, s32 stageId) {
|
||||
// Ternary causes regswaps...
|
||||
const char *prefix = "BGM_";
|
||||
if (lookup == LOOKUP_SE_A) {
|
||||
prefix = "SE_A_";
|
||||
}
|
||||
SizedString<64> label;
|
||||
|
||||
u32 soundId = -1;
|
||||
s32 round = 3;
|
||||
|
||||
bool hasSpecialLayerVersion = false;
|
||||
if (layer > 0) {
|
||||
hasSpecialLayerVersion = specialLayerVersionExists(stageName, layer);
|
||||
}
|
||||
|
||||
if (hasSpecialLayerVersion) {
|
||||
label.sprintf("%s%s_L%d", prefix, stageName, layer);
|
||||
} else if (layer > 0) {
|
||||
label.sprintf("%s%s_L%d", prefix, stageName, layer);
|
||||
} else {
|
||||
label.sprintf("%s%s", prefix, stageName);
|
||||
// We didn't bother with a _L layer variant, so we're going
|
||||
// in with the base variant
|
||||
round = 2;
|
||||
}
|
||||
|
||||
while (round > 0) {
|
||||
if (lookup == LOOKUP_BGM_MAIN) {
|
||||
label += "_MAIN";
|
||||
}
|
||||
|
||||
soundId = dSndPlayerMgr_c::GetInstance()->convertLabelStringToSoundId(label);
|
||||
if (soundId != -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (round == 3) {
|
||||
// If _L layer variant didn't exist, try the one without a layer...
|
||||
label.sprintf("%s%s", prefix, stageName);
|
||||
} else if (round == 2) {
|
||||
if (lookup == LOOKUP_BGM) {
|
||||
// If the one without a layer doesn't exist, continue with the one referenced
|
||||
// in field 3, unless it's the same as the original one
|
||||
s32 otherStageId = getSndStageId3(stageName, layer);
|
||||
if (stageId != otherStageId) {
|
||||
label.sprintf("%s%s", prefix, getStageName(otherStageId));
|
||||
} else {
|
||||
// break to prevent infinite loop
|
||||
round = 0;
|
||||
}
|
||||
} else if (lookup == LOOKUP_SE_A) {
|
||||
// If the one without a layer doesn't exist, continue with the one referenced
|
||||
// in field 4, unless it's the same as the original one
|
||||
s32 otherStageId = getSndStageId4(stageName, layer);
|
||||
if (stageId != otherStageId) {
|
||||
label.sprintf("%s%s", prefix, getStageName(otherStageId));
|
||||
} else {
|
||||
// break to prevent infinite loop
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
round--;
|
||||
}
|
||||
|
||||
return soundId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user