More player control

This commit is contained in:
robojumper
2025-06-03 23:28:57 +02:00
parent 0cf6b64538
commit 4e75ae59f5
12 changed files with 273 additions and 99 deletions
+3 -57
View File
@@ -1,66 +1,12 @@
#include "d/snd/d_snd_actor.h"
#include "common.h"
#include "d/snd/d_snd_checkers.h"
#include "nw4r/snd/snd_BasicSound.h"
#include "nw4r/snd/snd_SoundArchivePlayer.h"
#include "nw4r/snd/snd_SoundHandle.h"
#include "toBeSorted/music_mgrs.h"
dSndActor_c::dSndActor_c(nw4r::snd::SoundArchivePlayer &rStartable) : nw4r::snd::SoundActor(rStartable) {}
void d_snd_actor_SoundHandle_dtor() {
nw4r::snd::SoundHandle handle[2];
}
void SoundPropertiesChecker::operator()(nw4r::snd::SoundHandle &pHandle) {
if (mSoundId != -1 && mSoundId != pHandle.GetId()) {
return;
}
if (mpPlayCounter != nullptr) {
(*mpPlayCounter)++;
} else {
mPlayCounter++;
}
if (pHandle.IsPause()) {
if (mpPauseCounter != nullptr) {
(*mpPauseCounter)++;
} else {
mPauseCounter++;
}
return;
}
if (fn_803721F0(FANFARE_SOUND_MGR, pHandle.GetId())) {
if (mpCounter3 != nullptr) {
(*mpCounter3)++;
} else {
mCounter3++;
}
return;
}
if (fn_803720E0(FANFARE_SOUND_MGR, pHandle.GetId())) {
if (mpCounter3 != nullptr) {
(*mpCounter3)++;
} else {
mCounter3++;
}
return;
}
if (fn_80372070(FANFARE_SOUND_MGR, pHandle.GetId())) {
if (mpCounter4 != nullptr) {
(*mpCounter4)++;
} else {
mCounter4++;
}
return;
}
if (fn_803734C0(FANFARE_SOUND_MGR, pHandle.GetId()) && !fn_80373550(FANFARE_SOUND_MGR, pHandle.GetId())) {
mCounter3++;
}
void dSndActor_c::doesSomethingWithForeachSound() {
SoundPropertiesChecker checker;
ForEachSound(checker, false);
}
+3 -6
View File
@@ -1,6 +1,7 @@
#include "d/snd/d_snd_control_player.h"
#include "common.h"
#include "d/snd/d_snd_control_player_mgr.h"
#include "d/snd/d_snd_sound.h"
#include "nw4r/snd/snd_SoundPlayer.h"
#include "nw4r/snd/snd_global.h"
@@ -15,17 +16,13 @@ void dSndControlPlayer_c::reset() {
apply();
}
extern "C" void *lbl_80575D4C;
extern "C" nw4r::snd::SoundPlayer *fn_803600B0(void *, s32);
extern "C" nw4r::snd::SoundPlayer *fn_80360120(void *, s32);
void dSndControlPlayer_c::setIndex1(s32 idx) {
mpPlayer = fn_803600B0(lbl_80575D4C, idx);
mpPlayer = dSndControlPlayerMgr_c::GetInstance()->getPlayer1(idx);
mIndex = idx;
}
void dSndControlPlayer_c::setIndex2(s32 idx) {
mpPlayer = fn_80360120(lbl_80575D4C, idx);
mpPlayer = dSndControlPlayerMgr_c::GetInstance()->getPlayer2(idx);
mIndex = idx;
}
+104
View File
@@ -0,0 +1,104 @@
#include "d/snd/d_snd_control_player_mgr.h"
#include "common.h"
#include "d/snd/d_snd_control_player.h"
#include "nw4r/ut/ut_list.h"
template class SndMgrDisposer<dSndControlPlayerMgr_c>;
dSndControlPlayerMgr_c::dSndControlPlayerMgr_c() : mControlMask(0) {
// TODO offsetof
nw4r::ut::List_Init(&mActiveControls, 0x24);
mpCtrls[CTRL_VOLUME] = new dSndControlPlayerVolume_c[sNumPlayers]();
mpCtrls[CTRL_LPF_FREQ] = new dSndControlPlayerLpfFreq_c[sNumPlayers]();
mpCtrls[CTRL_FX_SEND] = new dSndControlPlayerFxSend_c[sNumPlayers]();
field_0x28 = new f32[sNumPlayers];
field_0x1C = new f32[sNumPlayers];
field_0x20 = new f32[sNumPlayers];
field_0x24 = new f32[sNumPlayers];
}
void dSndControlPlayerMgr_c::calc() {}
void dSndControlPlayerMgr_c::executeControls() {
dSndControlPlayer_c *next;
dSndControlPlayer_c *iter = static_cast<dSndControlPlayer_c *>(nw4r::ut::List_GetNext(&mActiveControls, nullptr));
while (iter != nullptr) {
next = static_cast<dSndControlPlayer_c *>(nw4r::ut::List_GetNext(&mActiveControls, iter));
iter->calc();
iter->apply();
if (iter->isFinished()) {
unlinkCtrl(iter);
}
iter = next;
}
}
void dSndControlPlayerMgr_c::linkCtrl(dSndControlPlayer_c *ctrl) {
if (ctrl == nullptr) {
return;
}
if (ctrl->isLinked()) {
return;
}
ctrl->setLinked(true);
nw4r::ut::List_Append(&mActiveControls, ctrl);
}
void dSndControlPlayerMgr_c::unlinkCtrl(dSndControlPlayer_c *ctrl) {
if (ctrl == nullptr) {
return;
}
if (!ctrl->isLinked()) {
return;
}
ctrl->setLinked(false);
nw4r::ut::List_Remove(&mActiveControls, ctrl);
}
void dSndControlPlayerMgr_c::setLpfFreq(u32 playerIdx, f32 value, s32 frames) {
if (playerIdx < sNumPlayers) {
setControlValue(CTRL_LPF_FREQ, playerIdx, value, frames);
}
}
void dSndControlPlayerMgr_c::setFxSend(u32 playerIdx, f32 value, s32 frames) {
if (playerIdx < sNumPlayers) {
setControlValue(CTRL_FX_SEND, playerIdx, value, frames);
}
}
void dSndControlPlayerMgr_c::setControlValue(PlayerCtrl_e ctrlType, u32 playerIdx, f32 value, s32 frames) {
if (ctrlType < CTRL_MAX && playerIdx < sNumPlayers) {
dSndControlPlayer_c *ctrl = &mpCtrls[ctrlType][playerIdx];
ctrl->set(value, frames);
if (ctrl->isFinished()) {
unlinkCtrl(ctrl);
} else {
linkCtrl(ctrl);
}
ctrl->apply();
}
}
void dSndControlPlayerMgr_c::resetControls() {
for (s32 i = 0; i < sNumPlayers; i++) {
for (s32 ty = 0; ty < CTRL_MAX; ty++) {
mpCtrls[ty][i].reset();
}
field_0x28[i] = 1.0f;
}
mControlMask = 0;
}
f32 dSndControlPlayerMgr_c::getTargetValue(PlayerCtrl_e ctrlType, u32 playerIdx) const {
if (ctrlType >= CTRL_MAX) {
return 1.0f;
}
if (playerIdx >= sNumPlayers) {
return 1.0f;
}
return mpCtrls[ctrlType][playerIdx].getTargetValue();
}
+2 -2
View File
@@ -1,12 +1,12 @@
#include "d/snd/d_snd_mgr.h"
#include "d/snd/d_snd_3d_manager.h"
#include "d/snd/d_snd_control_player_mgr.h"
#include "d/snd/d_snd_player_mgr.h"
#include "d/snd/d_snd_util.h"
#include "egg/audio/eggAudioRmtSpeakerMgr.h"
#include "egg/audio/eggAudioUtility.h"
extern "C" void fn_8035F120();
extern "C" void initEnemySoundMgr();
extern "C" void initFanfareSoundMgr();
extern "C" void initSomeUnusedSoundMgr();
@@ -24,7 +24,7 @@ dSndMgr_c *dSndMgr_c::sInstance;
dSndMgr_c::dSndMgr_c(): field_0x6CC(0) {
sInstance = this;
SndMgrDisposer<dSndPlayerMgr_c>::create();
fn_8035F120();
SndMgrDisposer<dSndControlPlayerMgr_c>::create();
initEnemySoundMgr();
SndMgrDisposer<dSnd3DManager_c>::create();
initFanfareSoundMgr();