2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-10 03:47:42 +00:00

Work on CSaveUI and CSfxManager

This commit is contained in:
Jack Andersen
2016-12-28 19:53:00 -10:00
parent e05d69376e
commit b3cae0d4d5
17 changed files with 489 additions and 184 deletions

View File

@@ -3,7 +3,6 @@
#include <vector>
#include "../RetroTypes.hpp"
#include "CSfxHandle.hpp"
#include "zeus/CVector3f.hpp"
#include "CAudioSys.hpp"
@@ -14,6 +13,8 @@ class CSfxManager
{
static std::vector<s16>* mpSfxTranslationTable;
public:
CSfxManager();
enum class ESfxChannels
{
Zero,
@@ -32,57 +33,61 @@ public:
{
};
class CBaseSfxWrapper
class CBaseSfxWrapper;
using CSfxHandle = std::shared_ptr<CBaseSfxWrapper>;
class CBaseSfxWrapper : public std::enable_shared_from_this<CBaseSfxWrapper>
{
float x4_ = 15.f;
s16 x8_rank = 0;
s16 xa_prio;
CSfxHandle xc_handle;
//CSfxHandle xc_handle;
TAreaId x10_area;
union
{
struct
{
bool x14_24_useAcoustics:1;
bool x14_25_available:1;
bool x14_26_inArea:1;
bool x14_27_looped:1;
bool x14_28_playing:1;
bool x14_29_active:1;
bool x14_24_isActive:1;
bool x14_25_isPlaying:1;
bool x14_26_looped:1;
bool x14_27_inArea:1;
bool x14_28_available:1;
bool x14_29_useAcoustics:1;
};
u16 _dummy = 0;
};
public:
virtual ~CBaseSfxWrapper() {}
virtual void SetActive(bool v) {x14_29_active = v;}
virtual void SetPlaying(bool v) {x14_28_playing = v;}
virtual void SetRank(short v) {x8_rank = v;}
virtual void SetInArea(bool v) {x14_26_inArea = v;}
virtual bool IsLooped() const {return x14_27_looped;}
virtual bool IsPlaying() const {return x14_28_playing;}
virtual bool IsActive() const {return x14_29_active;}
virtual bool IsInArea() const {return x14_26_inArea;}
virtual bool UseAcoustics() const {return x14_24_useAcoustics;}
virtual s16 GetRank() const {return x8_rank;}
virtual s16 GetPriority() const {return xa_prio;}
virtual TAreaId GetArea() const {return x10_area;}
virtual CSfxHandle GetSfxHandle() const {return xc_handle;}
virtual ~CBaseSfxWrapper() = default;
virtual void SetActive(bool v) { x14_24_isActive = v; }
virtual void SetPlaying(bool v) { x14_25_isPlaying = v; }
virtual void SetRank(short v) { x8_rank = v; }
virtual void SetInArea(bool v) { x14_27_inArea = v; }
virtual bool IsInArea() const { return x14_27_inArea; }
virtual bool IsPlaying() const { return x14_25_isPlaying; }
virtual bool UseAcoustics() const { return x14_29_useAcoustics; }
virtual bool IsLooped() const { return x14_26_looped; }
virtual bool IsActive() const { return x14_24_isActive; }
virtual s16 GetRank() const { return x8_rank; }
virtual s16 GetPriority() const { return xa_prio; }
virtual TAreaId GetArea() const { return x10_area; }
virtual CSfxHandle GetSfxHandle() { return shared_from_this(); }
virtual void Play()=0;
virtual void Stop()=0;
virtual bool Ready()=0;
virtual ESfxAudibility GetAudible(const zeus::CVector3f&)=0;
virtual const std::shared_ptr<amuse::Voice>& GetVoice() const=0;
void Release() {x14_25_available = true;}
bool Available() const {return x14_25_available;}
void Release() { x14_28_available = true; }
bool Available() const { return x14_28_available; }
CBaseSfxWrapper(bool looped, s16 prio, const CSfxHandle& handle, bool useAcoustics, TAreaId area)
: x8_rank(0), xa_prio(prio), xc_handle(handle), x10_area(area), x14_24_useAcoustics(useAcoustics),
x14_26_inArea(0), x14_27_looped(looped), x14_28_playing(0), x14_29_active(0) {}
CBaseSfxWrapper(bool looped, s16 prio, /*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area)
: x8_rank(0), xa_prio(prio), /*xc_handle(handle),*/ x10_area(area), x14_24_isActive(true), x14_25_isPlaying(false),
x14_26_looped(looped), x14_27_inArea(true), x14_28_available(false), x14_29_useAcoustics(useAcoustics) {}
};
class CSfxEmitterWrapper : public CBaseSfxWrapper
{
float x1a_reverb;
CAudioSys::C3DEmitterParmData x24_parmData;
std::shared_ptr<amuse::Emitter> x50_emitterHandle;
bool x54_ready = true;
@@ -97,47 +102,49 @@ public:
const std::shared_ptr<amuse::Emitter>& GetHandle() const { return x50_emitterHandle; }
CSfxEmitterWrapper(bool looped, s16 prio, const CAudioSys::C3DEmitterParmData& data,
const CSfxHandle& handle, bool useAcoustics, TAreaId area)
: CBaseSfxWrapper(looped, prio, handle, useAcoustics, area), x24_parmData(data) {}
/*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area)
: CBaseSfxWrapper(looped, prio, /*handle,*/ useAcoustics, area), x24_parmData(data) {}
};
class CSfxWrapper : public CBaseSfxWrapper
{
u16 x18_sfxId;
std::shared_ptr<amuse::Voice> x1c_voiceHandle;
s16 x20_vol;
s16 x22_pan;
float x20_vol;
float x22_pan;
bool x24_ready = true;
public:
bool IsPlaying() const;
void Play();
void Stop();
bool Ready();
ESfxAudibility GetAudible(const zeus::CVector3f&) {return ESfxAudibility::Aud3;}
const std::shared_ptr<amuse::Voice>& GetVoice() const {return x1c_voiceHandle;}
ESfxAudibility GetAudible(const zeus::CVector3f&) { return ESfxAudibility::Aud3; }
const std::shared_ptr<amuse::Voice>& GetVoice() const { return x1c_voiceHandle; }
void SetVolume(s16 vol) {x20_vol = vol;}
void SetVolume(s16 vol) { x20_vol = vol; }
CSfxWrapper(bool looped, s16 prio, u16 sfxId, s16 vol, s16 pan,
const CSfxHandle& handle, bool useAcoustics, TAreaId area)
: CBaseSfxWrapper(looped, prio, handle, useAcoustics, area),
CSfxWrapper(bool looped, s16 prio, u16 sfxId, float vol, float pan,
/*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area)
: CBaseSfxWrapper(looped, prio, /*handle,*/ useAcoustics, area),
x18_sfxId(sfxId), x20_vol(vol), x22_pan(pan) {}
};
static CSfxChannel m_channels[4];
static rstl::reserved_vector<CSfxEmitterWrapper, 128> m_emitterWrapperPool;
static rstl::reserved_vector<CSfxWrapper, 128> m_wrapperPool;
static rstl::reserved_vector<std::shared_ptr<CSfxEmitterWrapper>, 128> m_emitterWrapperPool;
static rstl::reserved_vector<std::shared_ptr<CSfxWrapper>, 128> m_wrapperPool;
static ESfxChannels m_currentChannel;
static bool m_doUpdate;
static void* m_usedSounds;
static bool m_muted;
static bool m_auxProcessingEnabled;
static float m_reverbAmount;
static u16 kMaxPriority;
static u16 kMedPriority;
static u16 kInternalInvalidSfxId;
static u32 kAllAreas;
static bool IsAuxProcessingEnabled() { return m_auxProcessingEnabled; }
static void SetChannel(ESfxChannels) {}
static void KillAll(ESfxChannels) {}
static void TurnOnChannel(ESfxChannels) {}
@@ -154,10 +161,17 @@ public:
static void RemoveEmitter(const CSfxHandle&) {}
static void PitchBend(const CSfxHandle&, s32) {}
static u16 TranslateSFXID(u16);
static CSfxHandle SfxStop(const CSfxHandle& handle);
static CSfxHandle SfxStart(u16 id, float vol, float pan, bool active, s16 prio, bool inArea, s32 areaId);
static void SfxStop(const CSfxHandle& handle);
static CSfxHandle SfxStart(u16 id, float vol, float pan, bool useAcoustics, s16 prio, bool looped, s32 areaId);
static void Update();
private:
static std::shared_ptr<CSfxWrapper>* AllocateCSfxWrapper();
};
using CSfxHandle = CSfxManager::CSfxHandle;
}
#endif // __URDE_CSFXMANAGER_HPP__