Skip to content

Commit

Permalink
JAudio2 and Z2AudioLib work (#2223)
Browse files Browse the repository at this point in the history
* JAudio2 and Z2AudioLib work

* check1stDynamicWave matched
  • Loading branch information
randomsalience authored Oct 23, 2024
1 parent c44ea21 commit 5650c7f
Show file tree
Hide file tree
Showing 94 changed files with 3,787 additions and 7,238 deletions.
28 changes: 14 additions & 14 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,29 +774,29 @@ def MatchingFor(*versions):
Object(Matching, "JSystem/JAudio2/JASSeqReader.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASAramStream.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASBank.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASBasicBank.cpp"),
Object(Matching, "JSystem/JAudio2/JASBasicBank.cpp", extra_cflags=['-pragma "nosyminline off"']),
Object(Matching, "JSystem/JAudio2/JASVoiceBank.cpp"),
Object(Matching, "JSystem/JAudio2/JASBasicInst.cpp", extra_cflags=['-pragma "nosyminline off"']),
Object(Matching, "JSystem/JAudio2/JASDrumSet.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASBasicWaveBank.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASSimpleWaveBank.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASWSParser.cpp"),
Object(Matching, "JSystem/JAudio2/JASSimpleWaveBank.cpp"),
Object(Matching, "JSystem/JAudio2/JASWSParser.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASBNKParser.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASWaveArcLoader.cpp"),
Object(Matching, "JSystem/JAudio2/JASWaveArcLoader.cpp", extra_cflags=['-pragma "nosyminline off"']),
Object(NonMatching, "JSystem/JAudio2/JASChannel.cpp"),
Object(Matching, "JSystem/JAudio2/JASLfo.cpp"),
Object(Matching, "JSystem/JAudio2/JASOscillator.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASAiCtrl.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASAudioThread.cpp"),
Object(Matching, "JSystem/JAudio2/JASAudioReseter.cpp"),
Object(Matching, "JSystem/JAudio2/JASDSPChannel.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASDSPInterface.cpp"),
Object(Matching, "JSystem/JAudio2/JASDSPInterface.cpp"),
Object(Matching, "JSystem/JAudio2/JASDriverIF.cpp"),
Object(Matching, "JSystem/JAudio2/JASSoundParams.cpp"),
Object(NonMatching, "JSystem/JAudio2/dspproc.cpp"),
Object(NonMatching, "JSystem/JAudio2/dsptask.cpp"),
Object(NonMatching, "JSystem/JAudio2/osdsp.cpp"),
Object(NonMatching, "JSystem/JAudio2/osdsp_task.cpp"),
Object(Matching, "JSystem/JAudio2/dspproc.cpp", extra_cflags=["-O4", "-func_align 32"]),
Object(Matching, "JSystem/JAudio2/dsptask.cpp", extra_cflags=["-O4", "-func_align 32"]),
Object(Matching, "JSystem/JAudio2/osdsp.cpp", extra_cflags=["-O4", "-func_align 32", "-str nopool"]),
Object(Matching, "JSystem/JAudio2/osdsp_task.cpp", extra_cflags=["-O4", "-func_align 32"]),
Object(Matching, "JSystem/JAudio2/JAIAudible.cpp"),
Object(Matching, "JSystem/JAudio2/JAIAudience.cpp"),
Object(Matching, "JSystem/JAudio2/JAISe.cpp"),
Expand All @@ -810,7 +810,7 @@ def MatchingFor(*versions):
Object(Matching, "JSystem/JAudio2/JAISoundInfo.cpp"),
Object(Matching, "JSystem/JAudio2/JAISoundParams.cpp"),
Object(Matching, "JSystem/JAudio2/JAISoundStarter.cpp"),
Object(NonMatching, "JSystem/JAudio2/JAIStream.cpp"),
Object(NonMatching, "JSystem/JAudio2/JAIStream.cpp", extra_cflags=["-sym off"]),
Object(Matching, "JSystem/JAudio2/JAIStreamDataMgr.cpp"),
Object(NonMatching, "JSystem/JAudio2/JAIStreamMgr.cpp"),
Object(Matching, "JSystem/JAudio2/JAUAudioArcInterpreter.cpp"),
Expand Down Expand Up @@ -854,12 +854,12 @@ def MatchingFor(*versions):
Object(NonMatching, "Z2AudioLib/Z2SeqMgr.cpp"),
Object(Matching, "Z2AudioLib/Z2StatusMgr.cpp"),
Object(NonMatching, "Z2AudioLib/Z2SceneMgr.cpp"),
Object(NonMatching, "Z2AudioLib/Z2FxLineMgr.cpp"),
Object(NonMatching, "Z2AudioLib/Z2SoundInfo.cpp"),
Object(Matching, "Z2AudioLib/Z2FxLineMgr.cpp"),
Object(Matching, "Z2AudioLib/Z2SoundInfo.cpp"),
Object(NonMatching, "Z2AudioLib/Z2Audience.cpp"),
Object(Matching, "Z2AudioLib/Z2SoundObject.cpp"),
Object(NonMatching, "Z2AudioLib/Z2SoundObjMgr.cpp"),
Object(NonMatching, "Z2AudioLib/Z2Creature.cpp"),
Object(Matching, "Z2AudioLib/Z2SoundObjMgr.cpp"),
Object(Matching, "Z2AudioLib/Z2Creature.cpp"),
Object(NonMatching, "Z2AudioLib/Z2LinkMgr.cpp"),
Object(NonMatching, "Z2AudioLib/Z2EnvSeMgr.cpp"),
Object(Matching, "Z2AudioLib/Z2WolfHowlMgr.cpp"),
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/JAudio2/JAISe.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class JAISeMgr;
* @ingroup jsystem-jaudio
*
*/
class JAISe : public JSULink<JAISe>, public JAISound {
class JAISe : public JSULink<JAISe>, public JASPoolAllocObject<JAISe>, public JAISound {
public:
class TInner {
public:
Expand Down
5 changes: 3 additions & 2 deletions include/JSystem/JAudio2/JAISeMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class JAISeCategoryMgr : public JAISeqDataUser {
public:
/* 8029F9C4 */ void JAISeMgr_calc_();
/* 8029FB30 */ void JAISeMgr_freeDeadSe_();
/* 8029FC88 */ u32 JAISeMgr_acceptsNewSe_(u32) const;
/* 8029FC88 */ bool JAISeMgr_acceptsNewSe_(u32) const;
/* 8029FD40 */ void sortByPriority_();
/* 8029FDE0 */ void stop(u32);
/* 8029FE34 */ void stop();
Expand All @@ -65,6 +65,7 @@ class JAISeCategoryMgr : public JAISeqDataUser {
JSUList<JAISe>* getSeList() { return &mSeList; }
int getNumSe() const { return mSeList.getNumLinks(); }
JAIAudience* getAudience() { return (JAIAudience*)field_0x4.field_0x0; }
void JAISeMgr_appendSe_(JAISe* se) { mSeList.append(se); }

/* 0x04 */ JASNonCopyable field_0x4;
/* 0x08 */ JAISoundParamsMove mParams;
Expand Down Expand Up @@ -113,7 +114,7 @@ class JAISeMgr : public JASGlobalInstance<JAISeMgr>,
private:
/* 0x008 */ JAIAudience* mAudience;
/* 0x00C */ JAISeqDataMgr* mSeqDataMgr;
/* 0x010 */ int field_0x10;
/* 0x010 */ JAISoundStrategyMgr<JAISe>* mStrategyMgr;
/* 0x014 */ JAISeCategoryMgr mCategoryMgrs[16];
/* 0x6D4 */ JAISoundParamsMove mParams;
}; // Size: 0x724
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/JAudio2/JAISeqMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class JAISeqMgr : public JASGlobalInstance<JAISeqMgr>, public JAISeqDataUser {
}
JAISoundParamsMove* getParams() { return &mMove; }
bool isActive() { return mSeqList.getNumLinks() != 0; }
int getNumActiveSeqs() { return mSeqList.getNumLinks(); }
int getNumActiveSeqs() const { return mSeqList.getNumLinks(); }
void pause(bool i_pause) { mActivity.field_0x0.flags.flag2 = i_pause; }

private:
Expand Down
3 changes: 2 additions & 1 deletion include/JSystem/JAudio2/JAISoundChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#define JAISOUNDCHILD_H

#include "JSystem/JAudio2/JAISoundParams.h"
#include "JSystem/JAudio2/JASHeapCtrl.h"

struct JASTrack;

/**
* @ingroup jsystem-jaudio
*
*/
struct JAISoundChild {
struct JAISoundChild : JASPoolAllocObject<JAISoundChild> {
/* 802A2AB0 */ void init();
/* 802A2B28 */ void mixOut(JASTrack*);
/* 802A2B7C */ void calc();
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/JAudio2/JAIStreamDataMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct JAIStreamDataMgr {
*/
struct JAIStreamAramMgr {
virtual void* newStreamAram(u32*) = 0;
virtual void deleteStreamAram(u32) = 0;
virtual bool deleteStreamAram(u32) = 0;
virtual ~JAIStreamAramMgr();
};

Expand Down
3 changes: 2 additions & 1 deletion include/JSystem/JAudio2/JAIStreamMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ class JAIStreamMgr : public JASGlobalInstance<JAIStreamMgr> {
/* 802A40B8 */ void stopSoundID(JAISoundID);
/* 802A4118 */ void mixOut();
/* 802A4174 */ JAIStream* newStream_();
/* 802B9978 */ bool isActive() const;
/* 802B9978 */ bool isActive() const { return mStreamList.getNumLinks() != 0; }

JAISoundParamsMove* getParams() { return &mParams; }
JAIStreamAramMgr* getStreamAramMgr() { return mStreamAramMgr; }
JSUList<JAIStream>* getStreamList() { return &mStreamList; }
void setStreamDataMgr(JAIStreamDataMgr* param_0) {
JUT_ASSERT(139, !isActive());
streamDataMgr_ = param_0;
Expand Down
63 changes: 53 additions & 10 deletions include/JSystem/JAudio2/JASBNKParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,71 @@ class JASBasicBank;
class JKRHeap;

namespace JASBNKParser {
struct TFileHeader {
/* 0x0 */ u8 _00[4];
/* 0x4 */ u32 mSize;
/* 0x8 */ u8 _08[4];
/* 0xC */ u32 mVersion;
};

namespace Ver1 {
/* 80299600 */ void findChunk(void const*, u32);
/* 8029963C */ void createBasicBank(void const*, JKRHeap*);
struct TOsc {
/* 0x00 */ u8 _00[4];
/* 0x04 */ u8 mTarget;
/* 0x08 */ f32 _08;
/* 0x0C */ u32 mTableOffset;
/* 0x10 */ u32 _10;
/* 0x14 */ f32 mScale;
/* 0x18 */ f32 _18;
};

struct TPercData {
/* 0x00 */ f32 mVolume;
/* 0x04 */ f32 mPitch;
/* 0x08 */ u8 mPan;
/* 0x0A */ u16 mRelease;
/* 0x0C */ u32 field_0xc;
};

struct TChunk {
/* 0x0 */ u32 mID;
/* 0x4 */ u32 mSize;
};

struct TEnvtChunk : TChunk {
/* 0x8 */ u8 mData[0];
};

struct TOscChunk : TChunk {
/* 0x8 */ u32 mCount;
/* 0xC */ TOsc mOsc[0];
};

struct TListChunk : TChunk {
/* 0x8 */ u32 mCount;
/* 0xC */ u32 mOffsets[0];
};

/* 80299600 */ static TChunk* findChunk(void const*, u32);
/* 8029963C */ static JASBasicBank* createBasicBank(void const*, JKRHeap*);
};

namespace Ver0 {
struct THeader {};

struct TOsc {};

/* 80299A3C */ void createBasicBank(void const*, JKRHeap*);
/* 80299E68 */ void findOscPtr(JASBasicBank*, JASBNKParser::Ver0::THeader const*,
JASBNKParser::Ver0::TOsc const*);
/* 80299F8C */ void getOscTableEndPtr(JASOscillator::Point const*);
/* 80299A3C */ static JASBasicBank* createBasicBank(void const*, JKRHeap*);
/* 80299E68 */ static void findOscPtr(JASBasicBank*, THeader const*, TOsc const*);
/* 80299F8C */ static void getOscTableEndPtr(JASOscillator::Point const*);
};

/* 80299538 */ JASBank* createBank(void const*, JKRHeap*);
/* 80299558 */ JASBasicBank* createBasicBank(void const*, JKRHeap*);
/* 80299538 */ static JASBank* createBank(void const*, JKRHeap*);
/* 80299558 */ static JASBasicBank* createBasicBank(void const*, JKRHeap*);

inline u32 getBankNumber(const void* param_0) { return ((u32*)param_0)[2]; }
inline static u32 getBankNumber(const void* param_0) { return ((u32*)param_0)[2]; }

extern u8 sUsedHeapSize[4];
extern u32 sUsedHeapSize;
};


Expand Down
18 changes: 17 additions & 1 deletion include/JSystem/JAudio2/JASBasicBank.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
#ifndef JASBASICBANK_H
#define JASBASICBANK_H

#include "dolphin/types.h"
#include "JSystem/JAudio2/JASBank.h"
#include "JSystem/JAudio2/JASBasicInst.h"
#include "JSystem/JKernel/JKRHeap.h"

class JASBasicBank : public JASBank {
public:
/* 80297D78 */ JASBasicBank();
/* 80297DA4 */ void newInstTable(u8, JKRHeap*);
/* 80297E00 */ bool getInstParam(int, int, int, JASInstParam*) const;
/* 80297E68 */ void setInst(int, JASInst*);
/* 80297E80 */ JASInst* getInst(int) const;
/* 80297F0C */ ~JASBasicBank() {}
/* 80297F68 */ u32 getType() const { return 'BSIC'; }

/* 0x8 */ JASInst** mInstTable;
/* 0xC */ u8 mInstNumMax;
};

#endif /* JASBASICBANK_H */
26 changes: 15 additions & 11 deletions include/JSystem/JAudio2/JASBasicInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ struct JASInst {
struct JASBasicInst : public JASInst {
struct TKeymap {
/* 80298250 */ ~TKeymap();
/* 802982D4 */ TKeymap() { field_0x0 = -1; }
/* 802982D4 */ TKeymap() { mHighKey = -1; }
void setHighKey(int key) { mHighKey = key; }

s32 field_0x0;
u16 field_0x4;
u16 field_0x6;
f32 field_0x8;
f32 field_0xc;
/* 0x0 */ s32 mHighKey;
/* 0x4 */ u16 field_0x4;
/* 0x6 */ u16 field_0x6;
/* 0x8 */ f32 field_0x8;
/* 0xC */ f32 field_0xc;
};

/* 80298014 */ JASBasicInst();
Expand All @@ -63,11 +64,14 @@ struct JASBasicInst : public JASInst {
/* 802980F8 */ virtual bool getParam(int, int, JASInstParam*) const;
/* 802982E0 */ virtual u32 getType() const { return 'BSIC'; };

f32 mVolume;
f32 mPitch;
JASOscillator::Data const* field_0xc[2];
u32 mKeymapCount;
TKeymap* mKeymap;
void setVolume(f32 volume) { mVolume = volume; }
void setPitch(f32 pitch) { mPitch = pitch; }

/* 0x04 */ f32 mVolume;
/* 0x08 */ f32 mPitch;
/* 0x0C */ JASOscillator::Data const* field_0xc[2];
/* 0x10 */ u32 mKeymapCount;
/* 0x14 */ TKeymap* mKeymap;
};


Expand Down
25 changes: 10 additions & 15 deletions include/JSystem/JAudio2/JASBasicWaveBank.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
*/
class JASWaveHandle {
public:
/* virtual */ ~JASWaveHandle() {};
//virtual const JASWaveInfo* getWaveInfo() const = 0;
//virtual int getWavePtr() const = 0;

void* vtable;
virtual ~JASWaveHandle() {};
virtual const JASWaveInfo* getWaveInfo() const = 0;
virtual int getWavePtr() const = 0;
};

/**
Expand All @@ -23,12 +21,10 @@ class JASWaveHandle {
*/
class JASWaveBank {
public:
/* 80298B88 */ /* virtual */ ~JASWaveBank() {};
//virtual JASWaveHandle* getWaveHandle(u32) const = 0;
//virtual JASWaveArc* getWaveArc(u32) = 0;
//virtual u32 getArcCount() const = 0;

void* vtable;
/* 80298B88 */ virtual ~JASWaveBank() {};
virtual JASWaveHandle* getWaveHandle(u32) const = 0;
virtual JASWaveArc* getWaveArc(u32) = 0;
virtual u32 getArcCount() const = 0;
};

/**
Expand All @@ -37,7 +33,7 @@ class JASWaveBank {
*/
struct JASBasicWaveBank : public JASWaveBank {
struct TWaveHandle : public JASWaveHandle {
/* 802985E4 */ ~TWaveHandle();
/* 802985E4 */ ~TWaveHandle() {}
/* 80298B64 */ int getWavePtr() const;
/* 80298C18 */ TWaveHandle() { mHeap = NULL; }
/* 80298C64 */ const JASWaveInfo* getWaveInfo() const { return &field_0x4; }
Expand All @@ -57,15 +53,14 @@ struct JASBasicWaveBank : public JASWaveBank {
/* 0x04 */ int field_0x4;
};

struct TWaveGroup {
struct TWaveGroup : JASWaveArc {
/* 802989C0 */ TWaveGroup();
/* 80298A0C */ ~TWaveGroup();
/* 80298A84 */ void setWaveCount(u32, JKRHeap*);
/* 80298B04 */ void onLoadDone();
/* 80298B2C */ void onEraseDone();
/* 80298B54 */ u32 getWaveID(int) const;

/* 0x00 */ JASWaveArc base;
/* 0x74 */ JASBasicWaveBank* mBank;
/* 0x78 */ TGroupWaveInfo* mCtrlWaveArray;
/* 0x7C */ u16 mWaveCount;
Expand All @@ -82,7 +77,7 @@ struct JASBasicWaveBank : public JASWaveBank {
/* 8029883C */ void decWaveTable(JASBasicWaveBank::TWaveGroup const*);
/* 802988DC */ JASWaveHandle* getWaveHandle(u32) const;
/* 80298910 */ void setWaveInfo(JASBasicWaveBank::TWaveGroup*, int, u16, JASWaveInfo const&);
/* 80298C6C */ JASWaveArc* getWaveArc(u32 param_0); // { return getWaveGroup(param_0); }
/* 80298C6C */ JASWaveArc* getWaveArc(u32 param_0) { return getWaveGroup(param_0); }
/* 80298C8C */ u32 getArcCount() const { return mGroupCount; }

/* 0x04 */ OSMutex field_0x4;
Expand Down
2 changes: 2 additions & 0 deletions include/JSystem/JAudio2/JASDSPInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,6 @@ namespace JASDsp {
extern f32 sDSPVolume;
};

u16 DSP_CreateMap2(u32 msg);

#endif /* JASDSPINTERFACE_H */
Loading

0 comments on commit 5650c7f

Please sign in to comment.