mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-08-26 23:07:31 -04:00
BST SE/STREAM replacement support
No SEQ yet since idk how I wanna handle it.
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
|
||||
#include "JSystem/JGeometry.h"
|
||||
|
||||
namespace dusk::mods::svc::audio_res::bst {
|
||||
struct SoundTableReplacementSlot;
|
||||
}
|
||||
|
||||
class JAIAudible;
|
||||
class JAISoundID;
|
||||
struct JASSoundParams;
|
||||
@@ -14,7 +18,8 @@ struct JASSoundParams;
|
||||
struct JAIAudience {
|
||||
virtual ~JAIAudience();
|
||||
virtual JAIAudible* newAudible(JGeometry::TVec3<f32> const&, JAISoundID,
|
||||
JGeometry::TVec3<f32> const*, u32) = 0;
|
||||
JGeometry::TVec3<f32> const*, u32
|
||||
IF_DUSK_ARG(dusk::mods::svc::audio_res::bst::SoundTableReplacementSlot const*)) = 0;
|
||||
virtual int getMaxChannels() = 0;
|
||||
virtual void deleteAudible(JAIAudible*) = 0;
|
||||
virtual u32 calcPriority(JAIAudible*) = 0;
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
void startTrack_(const JASSoundParams& params);
|
||||
void JAISeCategoryMgr_mixOut_(bool, const JASSoundParams& params, JAISoundActivity activity);
|
||||
void JAISeCategoryMgr_calc_();
|
||||
void JAISeMgr_startID_(JAISoundID id, const JGeometry::TVec3<f32>* posPtr, JAIAudience* audience);
|
||||
void JAISeMgr_startID_(JAISoundID id, const JGeometry::TVec3<f32>* posPtr, JAIAudience* audience IF_DUSK_ARG(std::shared_ptr<SoundEffectReplacementSlot> replacement));
|
||||
bool prepare_getSeqData_();
|
||||
void prepare_();
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
JAISe* newSe_(int category, u32 priority);
|
||||
void calc();
|
||||
void mixOut();
|
||||
bool startSound(JAISoundID id, JAISoundHandle* handle, const JGeometry::TVec3<f32>* posPtr);
|
||||
bool startSound(JAISoundID id, JAISoundHandle* handle, const JGeometry::TVec3<f32>* posPtr IF_DUSK_ARG(std::shared_ptr<dusk::mods::svc::audio_res::bst::SoundEffectReplacementSlot> replacement));
|
||||
int getNumActiveSe() const;
|
||||
|
||||
/* 0x004 */ JAISoundActivity mSoundActivity;
|
||||
|
||||
@@ -6,7 +6,16 @@
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
#include "global.h"
|
||||
#include "helpers/endian.h"
|
||||
#include <cstdint>
|
||||
|
||||
#if TARGET_PC
|
||||
#include <memory>
|
||||
|
||||
namespace dusk::mods::svc::audio_res::bst {
|
||||
struct SoundTableReplacementSlot;
|
||||
struct SoundEffectReplacementSlot;
|
||||
struct StreamReplacementSlot;
|
||||
}
|
||||
#endif
|
||||
|
||||
class JAISound;
|
||||
|
||||
@@ -271,10 +280,16 @@ class JAITempoMgr;
|
||||
*/
|
||||
class JAISound {
|
||||
public:
|
||||
#if TARGET_PC
|
||||
using SoundTableReplacementSlot = dusk::mods::svc::audio_res::bst::SoundTableReplacementSlot;
|
||||
using SoundEffectReplacementSlot = dusk::mods::svc::audio_res::bst::SoundEffectReplacementSlot;
|
||||
using StreamReplacementSlot = dusk::mods::svc::audio_res::bst::StreamReplacementSlot;
|
||||
#endif
|
||||
|
||||
void releaseHandle();
|
||||
void attachHandle(JAISoundHandle* handle);
|
||||
JAISound();
|
||||
void start_JAISound_(JAISoundID id, const JGeometry::TVec3<f32>* posPtr, JAIAudience* audience);
|
||||
void start_JAISound_(JAISoundID id, const JGeometry::TVec3<f32>* posPtr, JAIAudience* audience IF_DUSK_ARG(std::shared_ptr<SoundTableReplacementSlot> replacement));
|
||||
bool acceptsNewAudible() const;
|
||||
void newAudible(const JGeometry::TVec3<f32>&, JGeometry::TVec3<f32> const*, u32,
|
||||
JAIAudience*);
|
||||
@@ -297,6 +312,11 @@ public:
|
||||
virtual bool JAISound_tryDie_() = 0;
|
||||
|
||||
JAISoundID getID() const { return soundID_; }
|
||||
#if TARGET_PC
|
||||
SoundTableReplacementSlot* getReplacement() const {
|
||||
return replacement.get();
|
||||
}
|
||||
#endif
|
||||
u32 getAnimationState() const { return status_.state.flags.animationState; }
|
||||
bool isAnimated() const { return getAnimationState() != 0; }
|
||||
void setAnimationState(u32 state) {
|
||||
@@ -380,6 +400,9 @@ public:
|
||||
/* 0x34 */ u32 priority_;
|
||||
/* 0x38 */ s32 count_;
|
||||
/* 0x3C */ JAISoundParams params_;
|
||||
#if TARGET_PC
|
||||
std::shared_ptr<SoundTableReplacementSlot> replacement;
|
||||
#endif
|
||||
}; // Size: 0x98
|
||||
|
||||
STATIC_ASSERT(sizeof(JAISound) == 0x98);
|
||||
|
||||
@@ -9,13 +9,17 @@
|
||||
*
|
||||
*/
|
||||
struct JAISoundInfo : public JASGlobalInstance<JAISoundInfo> {
|
||||
IF_DUSK(using SoundTableReplacementSlot = dusk::mods::svc::audio_res::bst::SoundTableReplacementSlot);
|
||||
IF_DUSK(using SoundEffectReplacementSlot = dusk::mods::svc::audio_res::bst::SoundEffectReplacementSlot);
|
||||
IF_DUSK(using StreamReplacementSlot = dusk::mods::svc::audio_res::bst::StreamReplacementSlot);
|
||||
|
||||
JAISoundInfo(bool);
|
||||
virtual int getSoundType(JAISoundID) const = 0;
|
||||
virtual int getCategory(JAISoundID) const = 0;
|
||||
virtual u32 getPriority(JAISoundID) const = 0;
|
||||
virtual void getSeInfo(JAISoundID, JAISe*) const = 0;
|
||||
virtual u32 getPriority(JAISoundID IF_DUSK_ARG(SoundTableReplacementSlot const* replacement)) const = 0;
|
||||
virtual void getSeInfo(JAISoundID, JAISe* IF_DUSK_ARG(SoundEffectReplacementSlot const* replacement)) const = 0;
|
||||
virtual void getSeqInfo(JAISoundID, JAISeq*) const = 0;
|
||||
virtual void getStreamInfo(JAISoundID, JAIStream*) const = 0;
|
||||
virtual void getStreamInfo(JAISoundID, JAIStream* IF_DUSK_ARG(StreamReplacementSlot const* replacement)) const = 0;
|
||||
virtual ~JAISoundInfo();
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
JAIStream(JAIStreamMgr* streamMgr, JAISoundStrategyMgr<JAIStream>* soundStrategyMgr);
|
||||
void JAIStreamMgr_startID_(JAISoundID id, s32 streamFileEntry,
|
||||
const JGeometry::TVec3<f32>* posPtr, JAIAudience* audience,
|
||||
int category);
|
||||
int category IF_DUSK_ARG(std::shared_ptr<StreamReplacementSlot> replacement));
|
||||
bool prepare_prepareStream_();
|
||||
void prepare_();
|
||||
void prepare_startStream_();
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
*
|
||||
*/
|
||||
struct JAIStreamDataMgr {
|
||||
virtual s32 getStreamFileEntry(JAISoundID) = 0;
|
||||
IF_DUSK(using StreamReplacementSlot2 = dusk::mods::svc::audio_res::bst::StreamReplacementSlot);
|
||||
|
||||
virtual s32 getStreamFileEntry(JAISoundID IF_DUSK_ARG(StreamReplacementSlot2 const*)) = 0;
|
||||
virtual ~JAIStreamDataMgr();
|
||||
};
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ struct JAIStreamDataMgr;
|
||||
class JAIStreamMgr : public JASGlobalInstance<JAIStreamMgr> {
|
||||
public:
|
||||
JAIStreamMgr(bool setInstance);
|
||||
bool startSound(JAISoundID id, JAISoundHandle* handle, const JGeometry::TVec3<f32>* posPtr);
|
||||
bool startSound(JAISoundID id, JAISoundHandle* handle, const JGeometry::TVec3<f32>* posPtr IF_DUSK_ARG(std::shared_ptr<dusk::mods::svc::audio_res::bst::StreamReplacementSlot> replacement));
|
||||
void freeDeadStream_();
|
||||
void calc();
|
||||
void stop();
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
*/
|
||||
class JAUSoundInfo : public JASGlobalInstance<JAUSoundInfo> {
|
||||
public:
|
||||
IF_DUSK(using SoundTableReplacementSlot2 = dusk::mods::svc::audio_res::bst::SoundTableReplacementSlot);
|
||||
|
||||
JAUSoundInfo(bool param_0) : JASGlobalInstance<JAUSoundInfo>(param_0) {}
|
||||
virtual u16 getAudibleSw(JAISoundID) const = 0;
|
||||
virtual u16 getAudibleSw(JAISoundID IF_DUSK_ARG(SoundTableReplacementSlot2 const*)) const = 0;
|
||||
virtual u16 getBgmSeqResourceID(JAISoundID) const = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -51,6 +51,11 @@
|
||||
*/
|
||||
#define SOUND_SW_IGNORE_FX_MIX 0x0000'0004
|
||||
|
||||
/**
|
||||
* Mute all BGM sequences while this sound is playing.
|
||||
*/
|
||||
#define SOUND_SW_MUTE_BGM 0x0000'0008
|
||||
|
||||
/**
|
||||
* Offset to shift to access @see SOUND_SW_RANDOM_PITCH_MASK
|
||||
*/
|
||||
@@ -82,10 +87,21 @@
|
||||
*/
|
||||
#define SOUND_SW_IGNORE_DOLBY 0x0000'2000
|
||||
|
||||
/**
|
||||
* Unsure. Relates to Z2 pooling of sound handles.
|
||||
*/
|
||||
#define SOUND_SW_POOL_FLAG_1 0x0000'4000
|
||||
|
||||
/**
|
||||
* Unsure. Relates to Z2 pooling of sound handles.
|
||||
*/
|
||||
#define SOUND_SW_POOL_FLAG_2 0x0000'8000
|
||||
|
||||
/**
|
||||
* 3-bit mask used to select a volume distance/falloff class for this sound.
|
||||
*/
|
||||
#define SOUND_SW_VOL_DIST_BIT_MASK 0x0007'0000
|
||||
#define SOUND_SW_VOL_DIST_BIT_OFFSET 16
|
||||
|
||||
/**
|
||||
* Limit minimum volume of this sound (after distance falloff) to 0.2.
|
||||
@@ -97,6 +113,7 @@
|
||||
* @see SOUND_SW_VOL_DIST_BIT_MASK must be zero for this to work.
|
||||
*/
|
||||
#define SOUND_SW_VOL_DIST_BIT_2_MASK 0x0070'0000
|
||||
#define SOUND_SW_VOL_DIST_BIT_2_OFFSET 20
|
||||
|
||||
/**
|
||||
* Mark sound as "far away" or "culled" when at max distance (selected by distance class).
|
||||
@@ -290,13 +307,17 @@ struct JAUSoundTableGroup {
|
||||
*
|
||||
*/
|
||||
struct JAUSoundTable : public JASGlobalInstance<JAUSoundTable> {
|
||||
#if TARGET_PC
|
||||
using SoundTableReplacementSlot = dusk::mods::svc::audio_res::bst::SoundTableReplacementSlot;
|
||||
#endif
|
||||
|
||||
JAUSoundTable(bool setInstance) : JASGlobalInstance<JAUSoundTable>(setInstance) {
|
||||
}
|
||||
~JAUSoundTable() {}
|
||||
|
||||
void init(void const*);
|
||||
u8 getTypeID(JAISoundID) const;
|
||||
JAUSoundTableItem* getData(JAISoundID) const;
|
||||
u8 getTypeID(JAISoundID IF_DUSK_ARG(SoundTableReplacementSlot const*)) const;
|
||||
JAUSoundTableItem DUSK_CONST* getData(JAISoundID IF_DUSK_ARG(SoundTableReplacementSlot const*)) const;
|
||||
int getNumGroups_inSection(u8) const;
|
||||
int getNumItems_inGroup(u8, u8) const;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ struct JAUStreamFileTable {
|
||||
*
|
||||
*/
|
||||
struct JAUStreamDataMgr_StreamFileTable : public JAIStreamDataMgr, JAUStreamFileTable {
|
||||
virtual s32 getStreamFileEntry(JAISoundID);
|
||||
virtual s32 getStreamFileEntry(JAISoundID IF_DUSK_ARG(StreamReplacementSlot2 const*));
|
||||
virtual ~JAUStreamDataMgr_StreamFileTable() {}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user