d_snd_sound OK

This commit is contained in:
robojumper
2025-06-01 21:10:48 +02:00
parent fa1d4c3f57
commit 1fa755181b
10 changed files with 399 additions and 72 deletions
+67 -15
View File
@@ -4,6 +4,7 @@
#include "common.h"
#include "nw4r/snd/snd_SeqTrack.h"
#include "nw4r/snd/snd_SoundHandle.h"
#include "nw4r/snd/snd_SoundStartable.h"
#include "nw4r/ut/ut_list.h"
class dSndSound_c;
@@ -42,6 +43,10 @@ public:
return mCurrValue;
}
bool isFinished() const {
return mTimer >= mDuration;
}
protected:
/* 0x04 */ f32 mResetValue;
/* 0x08 */ f32 mMax;
@@ -90,9 +95,9 @@ private:
/* 0x30 */ dSndControlSound_c *mpOtherControl;
};
class dSndControlSoundSeqTrackTempoRatio_c : public dSndControlSound_c {
class dSndControlSoundSeqTempoRatio_c : public dSndControlSound_c {
public:
dSndControlSoundSeqTrackTempoRatio_c() : dSndControlSound_c(1.0f, 0.25f, 4.0f) {}
dSndControlSoundSeqTempoRatio_c() : dSndControlSound_c(1.0f, 0.25f, 4.0f) {}
virtual void apply(dSndSound_c *pHandle) override;
};
@@ -127,18 +132,36 @@ public:
dSndSound_c();
~dSndSound_c();
virtual void vt_0x08(); // 0x08
virtual void vt_0x0C(); // 0x0C
virtual void fadeIn(u32 id, int fadeFrames); // 0x10
virtual void cancel(); // 0x08
virtual void executeCtrls(); // 0x0C
virtual void fadeIn(u32 id, s32 fadeFrames); // 0x10
virtual nw4r::snd::SoundStartable::StartResult prepareSound(u32 soundId, u32 startOffset); // 0x14
virtual nw4r::snd::SoundStartable::StartResult prepareSound(const char *label, u32 startOffset); // 0x18
virtual void onPreparing(u32 soundId, u32 startOffset); // 0x1C
virtual void stop(s32 fadeFrames); // 0x20
virtual void pause(bool pauseFlag, s32 fadeFrames); // 0x24
bool isStrmSound();
bool isWaveSound();
bool isSeqSound();
void setPitchRelated(f32 pitch, s32 frames);
f32 getCurrentStrmTrackVolume(u32 index) const;
void setVolume(f32 volume, s32 frames);
void setPitchRelated(f32 pitch, s32 frames);
void setLinearPitch(f32 pitch, s32 frames);
void setTrackVolume(u32 trackFlags, f32 volume, s32 frames);
void setStrmTrackVolume(u32 trackFlags, f32 volume, s32 frames);
void setSingleSeqTrackVolume(u16 index, f32 volume, s32 frames);
void setSingleStrmTrackVolume(u16 index, f32 volume, s32 frames);
// why f32 frames?
void setEachSeqTrackVolume(u32 trackFlags, f32 frames);
void setEachStrmTrackVolume(u32 trackFlags, f32 frames);
void setSeqTempoRatio(f32 ratio, s32 frames);
void setSeqTrackMute(u32 trackFlags, nw4r::snd::SeqMute mute);
void stop();
void forceStop();
s16 readSeqTrackVariable(int varNo);
void writeSeqTrackVariable(int varNo, s16 value);
@@ -147,22 +170,51 @@ public:
void unlinkCtrl(dSndControlSound_c *);
private:
void reset();
bool cannotStart() const {
return mIsRunning && !mIsFadingOut && IsAttachedSound();
}
bool isRunning() const {
return mIsRunning && IsAttachedSound();
}
bool isPreparing() const {
return mIsPreparing && !mIsRunning;
}
bool canCancel() const {
return mIsRunning || mIsPreparing || IsAttachedSound();
}
bool isPreparingSoundId(u32 soundId) const {
bool ret = mIsPreparing;
if (ret) {
ret = !mIsRunning;
}
if (ret) {
ret = GetId() == soundId;
}
return ret;
}
void resetControls();
void resetTrackVolumes();
void setControlValue(dSndControlSound_c *ctrl, f32 value, s32 frames);
/* 0x08 */ u8 _0x08[0x10 - 0x08];
/* 0x10 */ UNKWORD field_0x10;
/* 0x14 */ u8 field_0x14;
/* 0x15 */ u8 field_0x15;
/* 0x16 */ u8 field_0x16;
/* 0x17 */ u8 field_0x17;
/* 0x10 */ u32 mPrevStartOffset;
/* 0x14 */ bool mIsPreparing;
/* 0x15 */ bool mPauseFlag;
/* 0x16 */ bool mIsRunning;
/* 0x17 */ bool mIsFadingOut;
/* 0x18 */ dSndControlSoundVolume_c mCtrlVolume;
/* 0x48 */ dSndControlSoundPitch_c mCtrlPitch;
/* 0x78 */ dSndControlSoundPitchLinear_c mCtrlUnk;
/* 0x78 */ dSndControlSoundPitchLinear_c mLinearPitch;
/* 0xAC */ dSndControlSoundSeqTrackVolume_c *mpCtrlSeqTrackVolume;
/* 0xB0 */ dSndControlSoundStrmTrackVolume_c *mpCtrlStrmTrackVolume;
/* 0xB4 */ dSndControlSoundSeqTrackTempoRatio_c mpCtrlSeqTrackTempoRatio;
/* 0xB4 */ dSndControlSoundSeqTempoRatio_c mpCtrlSeqTempoRatio;
/* 0xE4 */ nw4r::ut::List mList;
};
+7 -2
View File
@@ -50,9 +50,14 @@ namespace nw4r { namespace snd
mSound->SetPitch(volume);
}
void Stop() {
void Stop(int fadeFrames) {
if (IsAttachedSound())
mSound->Stop(0);
mSound->Stop(fadeFrames);
}
void Pause(bool flag, int fadeFrames) {
if (IsAttachedSound())
mSound->Pause(flag, fadeFrames);
}
bool IsPause() const {
+2
View File
@@ -54,6 +54,7 @@ namespace nw4r { namespace snd
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x27291
struct StartInfo
{
StartInfo() : enableFlag(0) {}
// enums
public:
enum EnableFlag
@@ -76,6 +77,7 @@ namespace nw4r { namespace snd
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x27208
struct SeqSoundInfo
{
SeqSoundInfo() : seqDataAddress(NULL), startLocationLabel(NULL) {}
void *seqDataAddress; // size 0x04, offset 0x00
char const *startLocationLabel; // size 0x04, offset 0x04
}; // size 0x08
+7 -1
View File
@@ -5,6 +5,9 @@
#include "d/snd/d_snd_player_mgr.h"
class dSndPlayerMgr_c;
class dSndSound_c;
// A lot of these names are and were guesses that are probably wrong in a lot of ways.
#define BGM_MGR (dSndPlayerMgr_c::GetInstance())
extern "C" void fn_8035E000();
@@ -24,7 +27,7 @@ extern "C" void fn_80365D20(void *);
extern "C" void fn_803624F0(void *);
extern "C" void fn_80364FD0(void *, s32);
extern "C" bool fn_80364DA0(void *);
extern "C" void fn_80364D00(void*, s32);
extern "C" void fn_80364D00(void *, s32);
extern "C" void *ENEMY_BGM_RELATED_MGR;
extern "C" void fn_80384570(void *, bool);
@@ -37,5 +40,8 @@ extern "C" bool fn_803720E0(void *, u32);
extern "C" bool fn_80372070(void *, u32);
extern "C" bool fn_803734C0(void *, u32);
extern "C" bool fn_80373550(void *, u32);
extern "C" void fn_80372920(void *);
extern "C" void fn_803738B0(void *, dSndSound_c *sound);
extern "C" void fn_80373900(void *, dSndSound_c *sound);
#endif