JAudio2 Work (#228)

This commit is contained in:
jdflyer
2022-12-30 16:19:57 -07:00
committed by GitHub
parent 19b70300d3
commit aa099b6f13
30 changed files with 429 additions and 441 deletions
+2 -1
View File
@@ -2,10 +2,11 @@
#define JAIAUDIBLE_H
#include "dolphin/types.h"
#include "JSystem/JAudio2/JASSoundParams.h"
struct JAIAudible {
virtual ~JAIAudible();
virtual void getOuterParams(int) = 0;
virtual JASSoundParams* getOuterParams(int) = 0;
virtual void calc() = 0;
};
+2 -2
View File
@@ -13,9 +13,9 @@ struct JAIAudience {
virtual ~JAIAudience();
virtual JAIAudible* newAudible(JGeometry::TVec3<f32> const&, JAISoundID,
JGeometry::TVec3<f32> const*, u32) = 0;
virtual void getMaxChannels() = 0;
virtual int getMaxChannels() = 0;
virtual void deleteAudible(JAIAudible*) = 0;
virtual void calcPriority(JAIAudible*) = 0;
virtual u32 calcPriority(JAIAudible*) = 0;
virtual void mixChannelOut(JASSoundParams const&, JAIAudible*, int) = 0;
};
+110 -16
View File
@@ -11,11 +11,11 @@
class JAISoundID {
public:
operator u32() const { return this->mId; }
void operator=(JAISoundID const&);
void operator=(JAISoundID const& other) {mId = other.mId;};
JAISoundID(u32 pId) { mId = pId; };
JAISoundID(JAISoundID const& other);
JAISoundID(JAISoundID const& other) {mId = other.mId;};
JAISoundID() {}
@@ -29,6 +29,13 @@ struct JASTrack {
/* 80291C30 */ void openChild(u32);
/* 80292918 */ void writePort(u32, u16);
/* 8029297C */ void readPort(u32);
inline int getChannelMgrCount() {
return channelMgrCount;
}
/* 0x0 */u8 field_0x0[0x1d0];
/* 0x1d0 */ int channelMgrCount;
};
struct JAISoundStatus_ {
@@ -36,26 +43,92 @@ struct JAISoundStatus_ {
/* 802A2244 */ s32 unlockIfLocked();
void init() {
field_0x0 = 0;
field_0x1 = 0;
*((u16*)(this) + 2) = 0;
field_0x0.value = 0;
field_0x1.value = 0;
*((u16*)&state) = 0;
user_data = 0;
}
/* 0x0 */ u8 field_0x0;
/* 0x1 */ u8 field_0x1;
/* 0x2 */ u8 state[2]; // debug accesses like "state.flags.calcedOnce"
bool isAlive(); //used in assert
inline bool isPlaying() {
return state.unk==5;
}
inline bool isPaused() {
return field_0x0.flags.paused;
}
/* 0x0 */ union {
u8 value;
struct{
u8 flag1:1;
u8 paused:1;
u8 flag3:1;
u8 flag4:1;
u8 flag5:1;
u8 flag6:1;
u8 flag7:1;
u8 flag8:1;
}flags;
}field_0x0;
/* 0x1 */ union {
u8 value;
struct{
u8 flag1:1;
u8 flag2:1;
u8 flag3:1;
u8 flag4:1;
u8 flag5:1;
u8 flag6:1;
u8 flag7:1;
u8 flag8:1;
}flags;
}field_0x1;
/* 0x2 */ struct {
u8 unk;
struct {
u8 flag1:1;
u8 flag2:1;
u8 flag3:1;
u8 flag4:1;
u8 flag5:1;
u8 flag6:1;
u8 flag7:1;
u8 flag8:1;
}flags;
} state;
/* 0x4 */ u32 user_data;
}; // Size: 0x6
struct JAISoundFader {
void forceIn() {
mIntensity = 1.0f;
field_0x4.zero();
mTransition.zero();
}
void forceOut() {
mIntensity = 0.0f;
mTransition.zero();
}
void fadeOut(u32 fadeCount) {
if (fadeCount!=0) {
mTransition.set(0.0f,mIntensity,fadeCount);
}else{
forceOut();
}
}
bool isOut() {
if(mTransition.mCount != 0 || mIntensity < 0.01f) {
return true;
}
return false;
}
inline void calc() {
mIntensity = mTransition.apply(mIntensity);
}
/* 0x00 */ f32 mIntensity;
/* 0x04 */ JAISoundParamsTransition::TTransition field_0x4;
/* 0x04 */ JAISoundParamsTransition::TTransition mTransition;
}; // Size: 0x10
template <typename A0>
@@ -88,29 +161,50 @@ public:
JAIAudience*);
/* 802A2598 */ void stop();
/* 802A24DC */ void stop(u32 fadeout);
/* 802A25D8 */ bool asSe();
/* 802A25E0 */ bool asSeq();
/* 802A25E8 */ bool asStream();
/* 802A25F0 */ void die_JAISound_();
/* 802A266C */ void increasePrepareCount_JAISound_();
/* 802A26B8 */ void calc_JAISound_();
/* 802A26B8 */ bool calc_JAISound_();
/* 802A29DC */ void initTrack_JAISound_(JASTrack*);
virtual void getNumChild() = 0;
virtual void getChild() = 0;
virtual void releaseChild() = 0;
/* 802A25D8 */ virtual bool asSe();
/* 802A25E0 */ virtual bool asSeq();
/* 802A25E8 */ virtual bool asStream();
virtual void getTrack() = 0;
virtual void getChildTrack() = 0;
virtual void getTempoMgr() = 0;
virtual bool JAISound_tryDie_() = 0;
JAISoundID getID() const;
u32 getUserData() const { return status_.user_data; }
bool isHandleAttached() const { return handle_ != NULL; }
void removeLifeTime_() {
status_.field_0x1.flags.flag1 = false;
}
void stop_JAISound_() {
status_.state.flags.flag5 = 0;
status_.state.flags.flag1 = 1;
}
bool isStopping() {
bool isStopping = false;
if(status_.state.flags.flag1) {
isStopping = status_.state.flags.flag5 ? fader.isOut() : true;
}
return isStopping;
}
/* 0x04 */ JAISoundHandle* handle_;
/* 0x08 */ JAIAudible* audible_;
/* 0x0C */ JAIAudience* audience_;
/* 0x10 */ s32 lifeTime;
/* 0x10 */ u32 lifeTime;
/* 0x14 */ s32 prepareCount;
/* 0x18 */ JAISoundID soundID;
/* 0x1C */ JAISoundStatus_ status_;
/* 0x24 */ JAISoundFader fader;
/* 0x34 */ s32 field_0x34;
/* 0x34 */ s32 mPriority;
/* 0x38 */ s32 mCount;
/* 0x3C */ JAISoundParams params;
}; // Size: 0x98
+1 -1
View File
@@ -10,7 +10,7 @@ class JAISoundID;
class JAISoundHandle {
public:
JAISoundHandle();
JAISoundHandle() {sound_ = NULL;};
~JAISoundHandle() {}
bool isSoundAttached() const { return sound_ != NULL; }
+3 -3
View File
@@ -24,9 +24,9 @@ struct JAISoundParamsTransition {
field_0x4 = 0.0f;
}
void set(f32 newValue, f32 param_1, u32 param_2) {
mCount = param_2;
field_0x0 = (newValue - param_1) / mCount;
void set(f32 newValue, f32 intensity, u32 fadeCount) {
mCount = fadeCount;
field_0x0 = (newValue - intensity) / mCount;
field_0x4 = newValue;
}
+8 -1
View File
@@ -3,6 +3,13 @@
#include "JSystem/JAudio2/JASDriverIF.h"
#include "dolphin/types.h"
#include "dolphin/os/OS.h"
struct JASCriticalSection {
inline JASCriticalSection() {mInterruptState = OSDisableInterrupts();};
inline ~JASCriticalSection() {OSRestoreInterrupts(mInterruptState);};
u32 mInterruptState;
};
struct JASAudioReseter {
/* 8029D0B4 */ JASAudioReseter();
@@ -10,7 +17,7 @@ struct JASAudioReseter {
/* 8029D138 */ bool start(u32, bool);
/* 8029D1D4 */ void resume();
/* 8029D1F8 */ s32 checkDone() const;
/* 8029D200 */ static s32 calc();
/* 8029D200 */ s32 calc();
/* 8029D2D4 */ static s32 callback(void*);
/* 0x0 */ u32 field_0x0;
+12
View File
@@ -3,4 +3,16 @@
#include "dolphin/types.h"
struct JASAudioThread {
/* 8029CCDC */ JASAudioThread(int, int, u32);
/* 8029CD4C */ void create(s32);
/* 8029CDC0 */ void stop();
/* 8029CDEC */ void run();
/* 8029CF68 */ void DMACallback();
/* 8029CFBC */ void DSPCallback(void*);
/* 8029D028 */ ~JASAudioThread();
static u8 snIntCount[4 + 4 /* padding */];
};
#endif /* JASAUDIOTHREAD_H */
+12 -2
View File
@@ -6,9 +6,19 @@
template <class T>
class JASGlobalInstance {
public:
// T* getInstance() { return sInstance; }
inline T* getInstance() { return sInstance; }
// static T* sInstance;
inline JASGlobalInstance(bool param) {
if (param) {
ASSERT(sInstance == 0);
//if (this!=NULL) {
sInstance = (T*)this;
//We need a better way to compute the location of sInstance
//sInstance = (T*)((char*)this-(char*)&(((T*)NULL)->JASGlobalInstance<T>));
//}
}
}
static T* sInstance;
};
#endif /* JASGADGET_H */
+2
View File
@@ -3,4 +3,6 @@
#include "dolphin/types.h"
void JASReport(const char* message, ...);
#endif /* JASREPORT_H */
+1
View File
@@ -2,5 +2,6 @@
#define DSPPROC_H
#include "dolphin/types.h"
#include "dolphin/dsp/dsp.h"
#endif /* DSPPROC_H */
+2 -2
View File
@@ -121,9 +121,9 @@ struct Z2Audience : public JAIAudience {
/* 802BD1FC */ virtual ~Z2Audience();
/* 802BD338 */ virtual JAIAudible* newAudible(JGeometry::TVec3<f32> const&, JAISoundID,
JGeometry::TVec3<f32> const*, u32);
/* 802BDED4 */ virtual void getMaxChannels();
/* 802BDED4 */ virtual int getMaxChannels();
/* 802BD4D4 */ virtual void deleteAudible(JAIAudible*);
/* 802BD5B8 */ virtual void calcPriority(JAIAudible*);
/* 802BD5B8 */ virtual u32 calcPriority(JAIAudible*);
/* 802BD71C */ virtual void mixChannelOut(JASSoundParams const&, JAIAudible*, int);
/* 0x004 */ f32 field_0x4;
+14 -31
View File
@@ -1,8 +1,9 @@
#ifndef Z2WOLFHOWLMGR_H
#define Z2WOLFHOWLMGR_H
#include "Z2AudioLib/Z2SoundObject.h"
#include "dolphin/types.h"
#include "Z2AudioLib/Z2SoundObject.h"
#include "JSystem/JAudio2/JASGadget.h"
/*
* Z2WolfHowlData
@@ -17,7 +18,7 @@ struct Z2WolfHowlData {
u16* mSongData;
};
class Z2WolfHowlMgr {
class Z2WolfHowlMgr : public JASGlobalInstance<Z2WolfHowlMgr> {
public:
Z2WolfHowlMgr();
@@ -36,10 +37,11 @@ public:
void startGuideMelody(bool);
void skipCorrectDemo();
private:
/* 0x00 */ JAISoundHandle* field_0x00;
/* 0x04 */ JAISoundHandle* field_0x04;
/* 0x08 */ JAISoundHandle* field_0x08;
/* 0x00 */ JAISoundHandle field_0x00;
/* 0x04 */ JAISoundHandle field_0x04;
/* 0x08 */ JAISoundHandle field_0x08;
/* 0x0C */ Z2WolfHowlData* mpCurSong;
/* 0x10 */ Z2WolfHowlData** mpSongList;
/* 0x14 */ f32 mNowInputValue;
@@ -51,37 +53,18 @@ private:
/* 0x2C */ u8 field_0x2c[4];
/* 0x30 */ f32 field_0x30;
/* 0x34 */ f32 field_0x34;
/* 0x38 */ f32 field_0x38;
/* 0x3C */ f32 field_0x3c;
/* 0x40 */ f32 field_0x40;
/* 0x44 */ f32 field_0x44;
/* 0x48 */ f32 field_0x48;
/* 0x4C */ f32 field_0x4c;
/* 0x50 */ f32 field_0x50;
/* 0x54 */ f32 field_0x54;
/* 0x58 */ f32 field_0x58;
/* 0x5C */ f32 field_0x5c;
/* 0x60 */ f32 field_0x60;
/* 0x64 */ f32 field_0x64;
/* 0x68 */ f32 field_0x68;
/* 0x6C */ f32 field_0x6c;
/* 0x70 */ f32 field_0x70;
/* 0x74 */ f32 field_0x74;
/* 0x78 */ f32 field_0x78;
/* 0x7C */ f32 field_0x7c;
/* 0x80 */ f32 field_0x80;
/* 0x84 */ f32 field_0x84;
/* 0x38 */ f32 field_0x38[10];
/* 0x60 */ f32 field_0x60[10];
/* 0x88 */ void* mTimer;
/* 0x8C */ u8 mReleaseTimer;
/* 0x8D */ u8 field_0x8d;
/* 0x8E */ u8 mCorrectCurveID;
/* 0x8E */ s8 mCorrectCurveID;
/* 0x8F */ u8 field_0x8f;
/* 0x90 */ s16 field_0x90;
/* 0x92 */ u8 field_0x92[20];
/* 0xA6 */ u8 field_0xa6[0x14];
/* 0xBA */ u8 field_0xba;
/* 0xBB */ u8 field_0xbb;
/* 0xBC */ u8 field_0xbc;
/* 0x92 */ u16 field_0x92[20];
/* 0xBA */ s8 field_0xba;
/* 0xBB */ s8 field_0xbb;
/* 0xBC */ s8 field_0xbc;
};
#endif /* Z2WOLFHOWLMGR_H */
+6
View File
@@ -3,4 +3,10 @@
#include "dolphin/types.h"
void DSPReleaseHalt2(u32 msg);
u16 DSP_CreateMap2(u32 msg);
void DSPSendCommands2(u32* msgs, u32 param_1, void (*param_2)(u16));
void DsetupTable(u32 param_0, u32 param_1, u32 param_2, u32 param_3, u32 param_4);
void DsetMixerLevel(f32 level);
#endif /* DSP_H */
+2 -10
View File
@@ -1,18 +1,10 @@
#ifndef M_DO_M_DO_AUDIO_H
#define M_DO_M_DO_AUDIO_H
#include "dolphin/types.h"
#include "JSystem/JAudio2/JASGadget.h"
#include "Z2AudioLib/Z2AudioMgr.h"
#include "Z2AudioLib/Z2EnvSeMgr.h"
#include "dolphin/types.h"
// move/fix later
template <typename T>
class JASGlobalInstance {
public:
T* getInstance() { return sInstance; };
static T* sInstance;
};
class mDoAud_zelAudio_c {
public: