Z2AudioLib work (#2339)

* Z2LinkMgr work, Z2AudioArcLoader matching

* Z2SeMgr matching

* Z2SpeechMgr2 almost done, Z2SoundHandles matching
This commit is contained in:
Caroline Madsen
2025-03-22 02:03:43 -04:00
committed by GitHub
parent cf87a207b6
commit 5a7b9f62d6
43 changed files with 1832 additions and 1194 deletions
+6 -1
View File
@@ -49,7 +49,12 @@ public:
/* 8029FE78 */ void stopSoundID(JAISoundID);
/* 8029FEEC */ void pause(bool);
/* 8029FF18 */ void JAISeMgr_mixOut_(JAISoundParamsMove const&, JAISoundActivity);
/* 802A0994 */ JAISeCategoryMgr();
/* 802A0994 */ JAISeCategoryMgr() {
mParams.init();
mMaxActiveSe = 0;
mMaxInactiveSe = 0;
field_0x4.field_0x0 = 0;
}
/* 800078DC */ virtual ~JAISeCategoryMgr() {}
/* 8029F8B0 */ virtual bool isUsingSeqData(JAISeqDataRegion const&);
+4 -4
View File
@@ -241,23 +241,23 @@ template <typename T>
class JASPoolAllocObject {
public:
static void* operator new(size_t n) {
JASMemPool<T>* memPool = getMemPool();
JASMemPool<T>* memPool = getMemPool_();
return memPool->alloc(sizeof(T));
}
static void* operator new(size_t n, void* ptr) {
return ptr;
}
static void operator delete(void* ptr, size_t n) {
JASMemPool<T>* memPool_ = getMemPool();
JASMemPool<T>* memPool_ = getMemPool_();
memPool_->free(ptr, sizeof(T));
}
static void newMemPool(int param_0) {
JASMemPool<T>* memPool_ = getMemPool();
JASMemPool<T>* memPool_ = getMemPool_();
memPool_->newMemPool(param_0);
}
private:
static JASMemPool<T>* getMemPool() {
static JASMemPool<T>* getMemPool_() {
static JASMemPool<T> memPool_;
return &memPool_;
}
+11 -1
View File
@@ -169,7 +169,17 @@ struct JASTrack : public JASPoolAllocObject_MultiThreaded<JASTrack> {
/* 0x000 */ JASSeqCtrl mSeqCtrl;
/* 0x05C */ JASTrackPort mTrackPort;
/* 0x080 */ JASRegisterParam mRegisterParam;
/* 0x09C */ MoveParam_ mMoveParam[6]; // volume, pitch, fxmix, pan, dolby, distFilter
/* 0x09C */ union {
struct {
MoveParam_ volume;
MoveParam_ pitch;
MoveParam_ fxmix;
MoveParam_ pan;
MoveParam_ dolby;
MoveParam_ distFilter;
} params;
MoveParam_ array[6];
} mMoveParam;
/* 0x0e4 */ JASOscillator::Data mOscParam[2];
/* 0x114 */ JASOscillator::Point mOscPoint[4];
/* 0x12C */ JASTrack* mParent;
+3
View File
@@ -22,7 +22,9 @@ public:
struct TNodeLinkList {
struct iterator {
iterator() { node = NULL; }
explicit iterator(TLinkListNode* pNode) { node = pNode; }
iterator& operator=(const iterator& other) { node = other.node; return *this; }
iterator& operator++() { node = node->getNext(); return *this; }
iterator& operator--() { node = node->getPrev(); return *this; }
@@ -117,6 +119,7 @@ struct TLinkList : public TNodeLinkList {
TLinkList() : TNodeLinkList() {}
struct iterator {
iterator() {}
explicit iterator(TNodeLinkList::iterator iter) : base(iter) {}
iterator& operator++() {
+6 -1
View File
@@ -238,6 +238,11 @@ inline bool JKRRemoveResource(void* resource, JKRFileLoader* fileLoader) {
return JKRFileLoader::removeResource(resource, fileLoader);
}
inline JKRArchive* JKRMountArchive(void* ptr, JKRHeap* heap,
JKRArchive::EMountDirection mountDirection) {
return JKRArchive::mount(ptr, heap, mountDirection);
}
inline void JKRUnmountArchive(JKRArchive* arc) {
arc->unmount();
}
@@ -246,4 +251,4 @@ inline void JKRReadIdxResource(void* param_1, u32 param_2, u32 param_3, JKRArchi
param_4->readIdxResource(param_1, param_2, param_3);
}
#endif
#endif
+1 -1
View File
@@ -12,7 +12,7 @@ void JMAVECScaleAdd(register const Vec* vec1, register const Vec* vec2, register
register f32 scale);
inline int JMAAbs(int value) {
return (value >> 0x1f ^ value) - (value >> 0x1f);
return value > 0 ? value : -value;
}
inline f32 JMAFastReciprocal(f32 value) {
+1 -1
View File
@@ -20,7 +20,7 @@ struct TRandom_fast_ {
u32 get_bit32(void) { return this->get(); }
s8 get_uint8(u8 param_0) {
u8 get_uint8(u8 param_0) {
return get_ufloat_1() * param_0;
}
-117
View File
@@ -1,7 +1,6 @@
#ifndef Z2CREATURE_H
#define Z2CREATURE_H
#include "SSystem/SComponent/c_xyz.h"
#include "Z2AudioLib/Z2SoundObject.h"
#include "Z2AudioLib/Z2SoundStarter.h"
@@ -35,122 +34,6 @@ public:
/* 0x70 */ Z2SoundObjSimple mSoundObjSimple2;
}; // Size: 0x90
struct Z2LinkSoundStarter : public Z2SoundStarter {
Z2LinkSoundStarter();
inline virtual ~Z2LinkSoundStarter();
virtual bool startSound(JAISoundID, JAISoundHandle*, JGeometry::TVec3<f32> const*, u32, f32,
f32, f32, f32, f32, u32);
};
class Z2CreatureLink : public Z2Creature, public Z2LinkSoundStarter {
public:
Z2CreatureLink();
~Z2CreatureLink();
void setLinkState(u8);
void setLinkGroupInfo(u8);
void setLinkHp(s32, s32);
void setLinkSwordType(s32, s32);
void setLinkShieldType(s32, s32);
void setLinkBootsType(s32);
virtual void deleteObject();
void init(Vec*, Vec*, Vec*);
void initKantera(Vec*);
void deleteKantera(void);
void setKanteraState(u8);
virtual void framework(u32, s8);
void setSinkDepth(s8);
void setRiding(bool);
void setMagnetized(bool);
void setWolfEyeOpen(bool);
Z2SoundHandlePool* startLinkSound(JAISoundID, u32, s8);
JAISoundHandle* startLinkSoundLevel(JAISoundID, u32, s8);
void startLinkVoice(JAISoundID, s8);
void startLinkVoiceLevel(JAISoundID, s8);
void startLinkSwordSound(JAISoundID, u32, s8);
virtual Z2SoundHandlePool* startCollisionSE(u32, u32);
int startHitItemSE(u32, u32, Z2SoundObjBase*, float);
void setResumeAttack(bool);
void setInWater(bool status) { mInWater = status; }
bool isInWater() { return mInWater; }
u8 getLinkState() const { return mLinkState; }
u8 getMoveSpeed() const { return mMoveSpeed; }
bool isRiding() const { return mRiding; }
void i_setLinkState(u8 i_state) { mLinkState = i_state; }
Z2SoundObjSimple& getKantera() { return mKantera; }
u8 getLinkHp() const { return mLinkHp; }
u8 getMovingTime() { return mMovingTime; }
u8 isWolfSmellOpen() const { return mWolfEyeOpen; }
void setUsingIronBall(bool i_using) { mUsingIronBall = i_using; }
void setMarkState(u8 i_state) { mMarkState = i_state; }
static Z2CreatureLink* mLinkPtr;
private:
/* 0x90 Z2LinkSoundStarter */
/* 0x94 */ Z2SoundObjSimple mKantera;
/* 0xB4 */ cXyz field_0xb4;
/* 0xC0 */ u8 mLinkState;
/* 0xC1 */ u8 field_0xc1;
/* 0xC2 */ u8 mMarkState;
/* 0xC3 */ u8 mLinkHp;
/* 0xC4 */ u8 mLinkBootsType;
/* 0xC5 */ u8 mKanteraState;
/* 0xC6 */ u8 mLinkSwordType;
/* 0xC7 */ u8 mLinkShieldType;
/* 0xC8 */ u8 mMoveSpeed;
/* 0xC9 */ u8 mMovingTime;
/* 0xCA */ s8 mSinkDepth;
/* 0xCB */ bool mWolfEyeOpen : 1;
/* 0xCB */ bool mInWater : 1;
/* 0xCB */ bool mResumeAttack : 1;
/* 0xCB */ bool mFlag3 : 1;
/* 0xCB */ bool mFlag4 : 1;
/* 0xCB */ bool mFlag5 : 1;
/* 0xCB */ bool mRiding : 1;
/* 0xCB */ bool mMagnetized : 1;
/* 0xCC */ bool mFlag8 : 1;
/* 0xCC */ bool mUsingIronBall : 1;
/* 0xCC */ bool mFlag10 : 1;
/* 0xCC */ bool mFlag11 : 1;
/* 0xCC */ bool mFlag12 : 1;
/* 0xCC */ bool mFlag13 : 1;
/* 0xCC */ bool mFlag14 : 1;
/* 0xCC */ bool mFlag15 : 1;
}; // Size: 0xD0
inline Z2CreatureLink* Z2GetLink() {
return Z2CreatureLink::mLinkPtr;
}
class Z2CreatureRide;
struct Z2RideSoundStarter : public Z2SoundStarter {
/* 802C5234 */ Z2RideSoundStarter(Z2CreatureRide*);
/* 802C5078 */ inline virtual ~Z2RideSoundStarter();
/* 802C5284 */ virtual bool startSound(JAISoundID, JAISoundHandle*,
JGeometry::TVec3<f32> const*, u32, f32, f32, f32, f32,
f32, u32);
/* 0x4 */ Z2CreatureRide* mRide;
};
class Z2CreatureRide : public Z2Creature, public Z2RideSoundStarter {
public:
Z2CreatureRide();
~Z2CreatureRide();
void init(Vec*, Vec*, u8, u8);
void setLinkRiding(bool);
virtual void deleteObject();
private:
/* 0x90 */ // Z2RideSoundStarter mSoundStarter;
/* 0x98 */ bool mLinkRiding;
}; // Size: 0x9C
class Z2CreatureEnemy : public Z2Creature, public JSULink<Z2CreatureEnemy> {
public:
/* 802C0F64 */ Z2CreatureEnemy();
+136
View File
@@ -1,5 +1,141 @@
#ifndef Z2LINKMGR_H
#define Z2LINKMGR_H
#include "SSystem/SComponent/c_xyz.h"
#include "Z2AudioLib/Z2Creature.h"
class Z2LinkSoundStarter : public Z2SoundStarter {
public:
Z2LinkSoundStarter();
inline virtual ~Z2LinkSoundStarter();
virtual bool startSound(JAISoundID, JAISoundHandle*, JGeometry::TVec3<f32> const*, u32, f32,
f32, f32, f32, f32, u32);
};
class Z2CreatureLink : public Z2Creature, public Z2LinkSoundStarter {
public:
Z2CreatureLink();
~Z2CreatureLink();
void setLinkState(u8);
void setLinkGroupInfo(u8);
void setLinkHp(s32, s32);
void setLinkSwordType(s32, s32);
void setLinkShieldType(s32, s32);
void setLinkBootsType(s32);
virtual void deleteObject();
void init(Vec*, Vec*, Vec*);
void initKantera(Vec*);
void deleteKantera(void);
void setKanteraState(u8);
virtual void framework(u32, s8);
void setSinkDepth(s8);
void setRiding(bool);
void setMagnetized(bool);
void setWolfEyeOpen(bool);
Z2SoundHandlePool* startLinkSound(JAISoundID, u32, s8);
JAISoundHandle* startLinkSoundLevel(JAISoundID, u32, s8);
Z2SoundHandlePool* startLinkVoice(JAISoundID, s8);
Z2SoundHandlePool* startLinkVoiceLevel(JAISoundID, s8);
void startLinkSwordSound(JAISoundID, u32, s8);
virtual Z2SoundHandlePool* startCollisionSE(u32, u32);
Z2SoundHandlePool* startHitItemSE(u32, u32, Z2SoundObjBase*, float);
void setResumeAttack(bool);
void setInWater(bool status) { mInWater = status; }
bool isInWater() { return mInWater; }
u8 getLinkState() const { return mLinkState; }
u8 getMoveSpeed() const { return mMoveSpeed; }
bool isRiding() const { return mRiding; }
void i_setLinkState(u8 i_state) { mLinkState = i_state; }
Z2SoundObjSimple& getKantera() { return mKantera; }
u8 getLinkHp() const { return mLinkHp; }
u8 getMovingTime() { return mMovingTime; }
u8 isWolfSmellOpen() const { return mWolfEyeOpen; }
void setUsingIronBall(bool i_using) { mUsingIronBall = i_using; }
void setMarkState(u8 i_state) { mMarkState = i_state; }
static Z2CreatureLink* mLinkPtr;
friend class Z2LinkSoundStarter;
friend class Z2RideSoundStarter;
private:
/* 0x90 Z2LinkSoundStarter */
/* 0x94 */ Z2SoundObjSimple mKantera;
/* 0xB4 */ cXyz field_0xb4;
/* 0xC0 */ u8 mLinkState;
/* 0xC1 */ u8 field_0xc1;
/* 0xC2 */ u8 mMarkState;
/* 0xC3 */ u8 mLinkHp;
/* 0xC4 */ u8 mLinkBootsType;
/* 0xC5 */ u8 mKanteraState;
/* 0xC6 */ u8 mLinkSwordType;
/* 0xC7 */ u8 mLinkShieldType;
/* 0xC8 */ u8 mMoveSpeed;
/* 0xC9 */ u8 mMovingTime;
/* 0xCA */ s8 mSinkDepth;
/* 0xCB */ bool mWolfEyeOpen : 1;
/* 0xCB */ bool mInWater : 1;
/* 0xCB */ bool mResumeAttack : 1;
/* 0xCB */ bool mFlag3 : 1;
/* 0xCB */ bool mFlag4 : 1;
/* 0xCB */ bool mFlag5 : 1;
/* 0xCB */ bool mRiding : 1;
/* 0xCB */ bool mMagnetized : 1;
/* 0xCC */ bool mFlag8 : 1;
/* 0xCC */ bool mUsingIronBall : 1;
/* 0xCC */ bool mFlag10 : 1;
/* 0xCC */ bool mFlag11 : 1;
/* 0xCC */ bool mFlag12 : 1;
/* 0xCC */ bool mFlag13 : 1;
/* 0xCC */ bool mFlag14 : 1;
/* 0xCC */ bool mFlag15 : 1;
}; // Size: 0xD0
inline Z2CreatureLink* Z2GetLink() {
return Z2CreatureLink::mLinkPtr;
}
class Z2CreatureRide;
struct Z2RideSoundStarter : public Z2SoundStarter {
/* 802C5234 */ Z2RideSoundStarter(Z2CreatureRide*);
/* 802C5078 */ virtual ~Z2RideSoundStarter() {}
/* 802C5284 */ virtual bool startSound(JAISoundID, JAISoundHandle*,
JGeometry::TVec3<f32> const*, u32, f32, f32, f32, f32,
f32, u32);
/* 0x4 */ Z2CreatureRide* mRide;
};
class Z2CreatureRide : public Z2Creature, public Z2RideSoundStarter {
public:
Z2CreatureRide();
~Z2CreatureRide();
void init(Vec*, Vec*, u8, u8);
void setLinkRiding(bool);
bool isLinkRiding() { return mLinkRiding; }
virtual void deleteObject();
private:
/* 0x90 */ // Z2RideSoundStarter mSoundStarter;
/* 0x98 */ bool mLinkRiding;
}; // Size: 0x9C
class Z2SoundObjCoach : public Z2SoundObjBase {
public:
/* 802C54B8 */ Z2SoundObjCoach();
/* 802C54FC */ void init(Vec*, u8);
/* 802C551C */ Z2SoundHandlePool* startWheelSound(f32);
/* 802C56C0 */ Z2SoundHandlePool* startFireSound(u16);
/* 802C57C0 */ Z2SoundHandlePool* startSound(JAISoundID, u32, s8);
private:
/* 0x20 */ f32 field_0x20;
};
#endif /* Z2LINKMGR_H */
+1
View File
@@ -40,6 +40,7 @@ public:
bool isMovieDemo() { return sceneNum == 2 || sceneNum == 8 || sceneNum == 9; }
s32 getSeLoadStatus(u32 wave) { return getWaveLoadStatus(wave, 0); }
s32 getBgmLoadStatus(u32 wave) { return getWaveLoadStatus(wave, 1); }
u8 getDemoSeWaveNum() { return loadedDemoWave; }
private:
/* 0x00 */ JAISoundID BGM_ID;
+1 -5
View File
@@ -4,13 +4,9 @@
#include "JSystem/JAudio2/JAISoundHandles.h"
#include "JSystem/JAudio2/JASHeapCtrl.h"
// This should inherit JASPoolAllocObject (without which some functions in Z2SoundHandles.cpp badly mismatch)
// but this inheritance causes the memPool_ to be generated in the first file that includes this header.
// Perhaps this class definition should belong to a different header.
class Z2SoundHandlePool : public JAISoundHandle, public JSULink<Z2SoundHandlePool> { // , public JASPoolAllocObject<Z2SoundHandlePool> {
class Z2SoundHandlePool : public JAISoundHandle, public JSULink<Z2SoundHandlePool>, public JASPoolAllocObject<Z2SoundHandlePool> {
public:
Z2SoundHandlePool() : JAISoundHandle(), JSULink<Z2SoundHandlePool>(this) {}
~Z2SoundHandlePool() {}
};
class Z2SoundHandles : protected JSUList<Z2SoundHandlePool> {
+1
View File
@@ -93,6 +93,7 @@ public:
bool removeEnemy(JSULink<Z2CreatureEnemy>*);
u8 isTwilightBattle();
u8 getEnemyNumNear() { return mEnemyNumNear; }
u8 getEnemyNumVeryFar() { return mEnemyNumVeryFar; }
bool isForceBattle() { return mForceBattle; }
JSUList<Z2CreatureEnemy>* getEnemyList() { return this; }
+5 -5
View File
@@ -35,11 +35,11 @@ struct Z2SpeechMgr2 : public JASGlobalInstance<Z2SpeechMgr2> {
/* 0x004 */ JAISoundHandle field_0x4;
/* 0x008 */ JMath::TRandom_fast_ random;
/* 0x00C */ Z2SpeechStarter mSpeech;
/* 0x010 */ u16 field_0x10[500];
/* 0x3F8 */ s16 field_0x3f8;
/* 0x3FA */ s16 field_0x3fa;
/* 0x3FC */ u16 field_0x3fc;
/* 0x3FE */ u8 field_0x3fe;
/* 0x010 */ u16 mText[500];
/* 0x3F8 */ s16 mTextNum;
/* 0x3FA */ s16 mTextCount;
/* 0x3FC */ u16 mMood;
/* 0x3FE */ u8 mVoice;
/* 0x3FF */ u8 field_0x3ff;
/* 0x400 */ u8 field_0x400;
/* 0x401 */ u8 field_0x401;
+1 -1
View File
@@ -3,7 +3,7 @@
#include "Z2AudioLib/Z2AudioMgr.h"
#include "Z2AudioLib/Z2EnvSeMgr.h"
#include "Z2AudioLib/Z2Creature.h"
#include "Z2AudioLib/Z2LinkMgr.h"
class mDoAud_zelAudio_c : public Z2AudioMgr {
public: