summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjdflyer <jdflyer10@gmail.com>2022-12-24 12:47:48 -0700
committerjdflyer <jdflyer10@gmail.com>2022-12-24 12:47:48 -0700
commitae040aa688d6937ded96ea46e5ab804019d1ee85 (patch)
treed8bf6182e5dfb244218215fdd3352433b5382842
parente0c23673db94cae6729ec0827a67219d5b114814 (diff)
Old JAudio changes
-rw-r--r--Makefile5
-rw-r--r--include/JSystem/JAudio2/JAIAudible.h3
-rw-r--r--include/JSystem/JAudio2/JAIAudience.h4
-rw-r--r--include/JSystem/JAudio2/JAISound.h126
-rw-r--r--include/JSystem/JAudio2/JAISoundParams.h6
-rw-r--r--include/JSystem/JAudio2/JASAudioReseter.h9
-rw-r--r--include/JSystem/JAudio2/JASAudioThread.h12
-rw-r--r--include/JSystem/JAudio2/JASGadget.h13
-rw-r--r--include/JSystem/JAudio2/JASReport.h2
-rw-r--r--include/JSystem/JAudio2/dspproc.h1
-rw-r--r--include/Z2AudioLib/Z2Audience.h4
-rw-r--r--include/dolphin/dsp/dsp.h6
-rw-r--r--include/m_Do/m_Do_audio.h12
-rw-r--r--libs/JSystem/JAudio2/JAISound.cpp167
-rw-r--r--libs/JSystem/JAudio2/JASAudioReseter.cpp78
-rw-r--r--libs/JSystem/JAudio2/JASAudioThread.cpp12
-rw-r--r--libs/JSystem/JAudio2/dspproc.cpp61
-rw-r--r--libs/Z2AudioLib/Z2Audience.cpp4
-rw-r--r--libs/Z2AudioLib/Z2SceneMgr.cpp14
-rw-r--r--src/m_Do/m_Do_main.cpp3
20 files changed, 365 insertions, 177 deletions
diff --git a/Makefile b/Makefile
index 29a4813924..1929850be5 100644
--- a/Makefile
+++ b/Makefile
@@ -45,11 +45,13 @@ include obj_files.mk
MWCC_VERSION := 2.7
# Programs
+ifeq ($(WINE),) #if WINE varible is unset (wine can be replaced with a less bloated translation layer such as wibo if needed)
ifeq ($(WINDOWS),1)
WINE :=
else
WINE := wine
endif
+endif
# Hack for OSX
ifeq ($(UNAME_S),Darwin)
@@ -168,7 +170,8 @@ $(DOL_SHIFT): $(ELF_SHIFT) | tools
shift: dirs $(DOL_SHIFT)
-game: | shift rels
+game: shift
+ $(MAKE) rels
@mkdir -p game
@$(PYTHON) tools/package_game_assets.py game $(BUILD_DIR)
diff --git a/include/JSystem/JAudio2/JAIAudible.h b/include/JSystem/JAudio2/JAIAudible.h
index d42029bec9..047b913295 100644
--- a/include/JSystem/JAudio2/JAIAudible.h
+++ b/include/JSystem/JAudio2/JAIAudible.h
@@ -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;
};
diff --git a/include/JSystem/JAudio2/JAIAudience.h b/include/JSystem/JAudio2/JAIAudience.h
index 2f2586bf2d..1621386ad8 100644
--- a/include/JSystem/JAudio2/JAIAudience.h
+++ b/include/JSystem/JAudio2/JAIAudience.h
@@ -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;
};
diff --git a/include/JSystem/JAudio2/JAISound.h b/include/JSystem/JAudio2/JAISound.h
index 61bac44a42..1fd0f4f9c9 100644
--- a/include/JSystem/JAudio2/JAISound.h
+++ b/include/JSystem/JAudio2/JAISound.h
@@ -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();
+ }
+ inline void forceOut() {
+ mIntensity = 0.0f;
+ mTransition.zero();
+ }
+ inline void fadeOut(u32 fadeCount) {
+ if (fadeCount!=0) {
+ mTransition.set(0.0f,mIntensity,fadeCount);
+ }else{
+ forceOut();
+ }
+ }
+ inline 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; }
+ inline void removeLifeTime_() {
+ status_.field_0x1.flags.flag1 = false;
+ }
+ inline void stop_JAISound_() {
+ status_.state.flags.flag5 = 0;
+ status_.state.flags.flag1 = 1;
+ }
+ inline 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
diff --git a/include/JSystem/JAudio2/JAISoundParams.h b/include/JSystem/JAudio2/JAISoundParams.h
index 6984c0a912..f9befe83e0 100644
--- a/include/JSystem/JAudio2/JAISoundParams.h
+++ b/include/JSystem/JAudio2/JAISoundParams.h
@@ -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;
}
diff --git a/include/JSystem/JAudio2/JASAudioReseter.h b/include/JSystem/JAudio2/JASAudioReseter.h
index 25e6af4a33..66d466f3f5 100644
--- a/include/JSystem/JAudio2/JASAudioReseter.h
+++ b/include/JSystem/JAudio2/JASAudioReseter.h
@@ -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;
diff --git a/include/JSystem/JAudio2/JASAudioThread.h b/include/JSystem/JAudio2/JASAudioThread.h
index 2ed9d02f54..e8da1c883b 100644
--- a/include/JSystem/JAudio2/JASAudioThread.h
+++ b/include/JSystem/JAudio2/JASAudioThread.h
@@ -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 */
diff --git a/include/JSystem/JAudio2/JASGadget.h b/include/JSystem/JAudio2/JASGadget.h
index 6edcf6961a..811aeacb3b 100644
--- a/include/JSystem/JAudio2/JASGadget.h
+++ b/include/JSystem/JAudio2/JASGadget.h
@@ -6,9 +6,18 @@
template <class T>
class JASGlobalInstance {
public:
- // T* getInstance() { return sInstance; }
+ T* getInstance() { return sInstance; }
- // static T* sInstance;
+ JASGlobalInstance(bool param) {
+ if (param) {
+ ASSERT(sInstance == 0);
+ if (this!=NULL) {
+ sInstance = this - sizeof(T);
+ }
+ }
+ }
+
+ static T* sInstance;
};
#endif /* JASGADGET_H */
diff --git a/include/JSystem/JAudio2/JASReport.h b/include/JSystem/JAudio2/JASReport.h
index 6f0c1a0fae..86b0944e83 100644
--- a/include/JSystem/JAudio2/JASReport.h
+++ b/include/JSystem/JAudio2/JASReport.h
@@ -3,4 +3,6 @@
#include "dolphin/types.h"
+void JASReport(const char* message, ...);
+
#endif /* JASREPORT_H */
diff --git a/include/JSystem/JAudio2/dspproc.h b/include/JSystem/JAudio2/dspproc.h
index e624638ec3..5f1c530495 100644
--- a/include/JSystem/JAudio2/dspproc.h
+++ b/include/JSystem/JAudio2/dspproc.h
@@ -2,5 +2,6 @@
#define DSPPROC_H
#include "dolphin/types.h"
+#include "dolphin/dsp/dsp.h"
#endif /* DSPPROC_H */
diff --git a/include/Z2AudioLib/Z2Audience.h b/include/Z2AudioLib/Z2Audience.h
index d3ea344af8..a3af8c114d 100644
--- a/include/Z2AudioLib/Z2Audience.h
+++ b/include/Z2AudioLib/Z2Audience.h
@@ -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;
diff --git a/include/dolphin/dsp/dsp.h b/include/dolphin/dsp/dsp.h
index f7cb94b291..65c0061489 100644
--- a/include/dolphin/dsp/dsp.h
+++ b/include/dolphin/dsp/dsp.h
@@ -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 */
diff --git a/include/m_Do/m_Do_audio.h b/include/m_Do/m_Do_audio.h
index 3cc4b62160..898f834489 100644
--- a/include/m_Do/m_Do_audio.h
+++ b/include/m_Do/m_Do_audio.h
@@ -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:
diff --git a/libs/JSystem/JAudio2/JAISound.cpp b/libs/JSystem/JAudio2/JAISound.cpp
index 2f943947c1..9f9e3162d1 100644
--- a/libs/JSystem/JAudio2/JAISound.cpp
+++ b/libs/JSystem/JAudio2/JAISound.cpp
@@ -6,6 +6,7 @@
#include "JSystem/JAudio2/JAISound.h"
#include "dol2asm.h"
#include "dolphin/types.h"
+#include "JSystem/JAudio2/JASReport.h"
//
// Forward References:
@@ -79,8 +80,8 @@ void JAISound::attachHandle(JAISoundHandle* handle) {
/* 802A2220-802A2244 29CB60 0024+00 0/0 2/2 0/0 .text lockWhenPrepared__15JAISoundStatus_Fv */
s32 JAISoundStatus_::lockWhenPrepared() {
- if (state[0] == 0) {
- state[0] = 1;
+ if (state.unk == 0) {
+ state.unk = 1;
return 1;
}
return 0;
@@ -89,12 +90,12 @@ s32 JAISoundStatus_::lockWhenPrepared() {
/* 802A2244-802A2280 29CB84 003C+00 0/0 2/2 0/0 .text unlockIfLocked__15JAISoundStatus_Fv
*/
s32 JAISoundStatus_::unlockIfLocked() {
- if (state[0] == 3) {
- state[0] = 4;
+ if (state.unk == 3) {
+ state.unk = 4;
return 1;
}
- if (state[0] == 1) {
- state[0] = 0;
+ if (state.unk == 1) {
+ state.unk = 0;
return 1;
}
return 0;
@@ -171,11 +172,10 @@ void JAISound::start_JAISound_(JAISoundID param_0, JGeometry::TVec3<f32> const*
prepareCount = 0;
mCount = 0;
- if (param_1 == NULL || audience_ == NULL) {
- audible_ = NULL;
+ if (param_1 != 0 && audience_ != NULL) {
+ audible_ = audience_->newAudible(*param_1, soundID, NULL, 0);
} else {
- JAISoundID sound = soundID;
- audible_ = audience_->newAudible(*param_1, sound, NULL, 0);
+ audible_ = NULL;
}
field_0x34 = 0;
}
@@ -194,7 +194,7 @@ asm void JAISound::start_JAISound_(JAISoundID param_0, JGeometry::TVec3<f32> con
/* 802A244C-802A2474 29CD8C 0028+00 0/0 2/2 0/0 .text acceptsNewAudible__8JAISoundCFv */
bool JAISound::acceptsNewAudible() const {
bool accepts = false;
- if (audible_ == NULL && !(status_.state[1] >> 6 & 1)) {
+ if (audible_ == NULL && status_.state.flags.flag2==0) {
accepts = true;
}
return accepts;
@@ -202,7 +202,6 @@ bool JAISound::acceptsNewAudible() const {
/* 802A2474-802A24DC 29CDB4 0068+00 0/0 2/2 0/0 .text
/* * newAudible__8JAISoundFRCQ29JGeometry8TVec3<f>PCQ29JGeometry8TVec3<f>UlP11JAIAudience */
-#ifdef NONMATCHING
void JAISound::newAudible(JGeometry::TVec3<f32> const& param_0,
JGeometry::TVec3<f32> const* param_1, u32 param_2, JAIAudience* param_3) {
if (param_3 != NULL) {
@@ -211,24 +210,27 @@ void JAISound::newAudible(JGeometry::TVec3<f32> const& param_0,
JAISoundID sound = soundID;
audible_ = audience_->newAudible(param_0, sound, param_1, param_2);
}
-#else
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JAISound::newAudible(JGeometry::TVec3<f32> const& param_0,
- JGeometry::TVec3<f32> const* param_1, u32 param_2,
- JAIAudience* param_3) {
- nofralloc
-#include "asm/JSystem/JAudio2/JAISound/func_802A2474.s"
-}
-#pragma pop
-#endif
/* ############################################################################################## */
/* 804557C8-804557D0 003DC8 0008+00 1/1 0/0 0/0 .sdata2 @766 */
SECTION_SDATA2 static f64 lit_766 = 4503599627370496.0 /* cast u32 to float */;
/* 802A24DC-802A2598 29CE1C 00BC+00 0/0 24/24 0/0 .text stop__8JAISoundFUl */
+#ifdef NONMATCHING
+void JAISound::stop(u32 fadeCount) {
+ ASSERT(status_.isAlive());
+ if (fadeCount==0) {
+ stop();
+ return;
+ }else{
+ fader.fadeOut(fadeCount);
+ removeLifeTime_();
+ status_.field_0x1.flags.flag2 = 0;
+ status_.state.flags.flag5 = 1;
+ status_.state.flags.flag1 = 1;
+ }
+}
+#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
@@ -237,16 +239,13 @@ asm void JAISound::stop(u32 param_0) {
#include "asm/JSystem/JAudio2/JAISound/stop__8JAISoundFUl.s"
}
#pragma pop
+#endif
/* 802A2598-802A25D8 29CED8 0040+00 2/2 21/21 0/0 .text stop__8JAISoundFv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JAISound::stop() {
- nofralloc
-#include "asm/JSystem/JAudio2/JAISound/stop__8JAISoundFv.s"
+void JAISound::stop() {
+ stop_JAISound_();
+ releaseHandle();
}
-#pragma pop
/* 802A25D8-802A25E0 29CF18 0008+00 1/0 2/0 0/0 .text asSe__8JAISoundFv */
bool JAISound::asSe() {
@@ -264,6 +263,18 @@ bool JAISound::asStream() {
}
/* 802A25F0-802A266C 29CF30 007C+00 0/0 3/3 0/0 .text die_JAISound___8JAISoundFv */
+#ifdef NONMATCHING
+void JAISound::die_JAISound_() {
+ if (audible_!=NULL){
+ audience_->deleteAudible(audible_);
+ audible_ = NULL;
+ audience_ = NULL;
+ }
+ fader.forceOut();
+ releaseHandle();
+ status_.state.unk = 6;
+}
+#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
@@ -272,28 +283,15 @@ asm void JAISound::die_JAISound_() {
#include "asm/JSystem/JAudio2/JAISound/die_JAISound___8JAISoundFv.s"
}
#pragma pop
-
-/* ############################################################################################## */
-/* 8039B910-8039B910 027F70 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
-#pragma push
-#pragma force_active on
-SECTION_DEAD static char const* const stringBase_8039B910 =
- "It cost %d steps to prepare Sound(ID:%08x, Addre"
- "ss%08x).\n";
-/* @stringBase0 padding */
-SECTION_DEAD static char const* const pad_8039B94A = "\0\0\0\0\0";
-#pragma pop
+#endif
/* 802A266C-802A26B8 29CFAC 004C+00 0/0 3/3 0/0 .text increasePrepareCount_JAISound___8JAISoundFv
*/
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JAISound::increasePrepareCount_JAISound_() {
- nofralloc
-#include "asm/JSystem/JAudio2/JAISound/increasePrepareCount_JAISound___8JAISoundFv.s"
+void JAISound::increasePrepareCount_JAISound_() {
+ if((++prepareCount&0xFF) == 0) {
+ JASReport("It cost %d steps to prepare Sound(ID:%08x, Address%08x).\n",prepareCount,(u32)soundID,this);
+ }
}
-#pragma pop
/* ############################################################################################## */
/* 804557D0-804557D8 003DD0 0004+04 1/1 0/0 0/0 .sdata2 @887 */
@@ -304,23 +302,74 @@ SECTION_SDATA2 static f32 lit_887[1 + 1 /* padding */] = {
};
/* 802A26B8-802A29DC 29CFF8 0324+00 0/0 3/3 0/0 .text calc_JAISound___8JAISoundFv */
+#ifdef NONMATCHING
+bool JAISound::calc_JAISound_() {
+ status_.state.flags.flag2 = 1;
+ if(isStopping()&&JAISound_tryDie_()) {
+ return false;
+ }
+ ASSERT(status_.isAlive());
+ bool isPlaying = status_.isPlaying();
+ if(isPlaying) {
+ mCount++;
+ }
+ bool isPaused = status_.isPaused();
+ if(isPaused==false) {
+ fader.calc();
+ }
+ bool playing = isPlaying&&isPaused == false;
+ if (playing) {
+ params.mMove.calc();
+ if (audible_!=NULL) {
+ audible_->calc();
+ }
+ if(status_.field_0x1.flags.flag2!=0) {
+ if(lifeTime==0) {
+ stop_JAISound_();
+ }else{
+ lifeTime--;
+ }
+ }
+ }
+ if(audience_!=NULL&&audible_!=NULL) {
+ u32 priority = audience_->calcPriority(audible_);
+ mPriority = priority;
+ if (priority==0xFFFFFFFF&&status_.field_0x1.flags.flag1==0) {
+ stop_JAISound_();
+ }
+ }else{
+ mPriority = 0;
+ }
+
+ return playing;
+}
+#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
-asm void JAISound::calc_JAISound_() {
+asm bool JAISound::calc_JAISound_() {
nofralloc
#include "asm/JSystem/JAudio2/JAISound/calc_JAISound___8JAISoundFv.s"
}
#pragma pop
+#endif
/* 802A29DC-802A2AB0 29D31C 00D4+00 0/0 2/2 0/0 .text initTrack_JAISound___8JAISoundFP8JASTrack */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JAISound::initTrack_JAISound_(JASTrack* param_0) {
- nofralloc
-#include "asm/JSystem/JAudio2/JAISound/initTrack_JAISound___8JAISoundFP8JASTrack.s"
+void JAISound::initTrack_JAISound_(JASTrack* track) {
+ JASSoundParams* soundParams[8];
+ ASSERT(audience_);
+ ASSERT(audible_);
+ int numChannels = 0;
+ for (int i = 0; i<audience_->getMaxChannels(); i++) {
+ JASSoundParams* currentParams = audible_->getOuterParams(i);
+ if (currentParams!=NULL) {
+ soundParams[numChannels] = currentParams;
+ numChannels++;
+ }
+ }
+ ASSERT(numChannels >= 1)
+ track->setChannelMgrCount(numChannels);
+ for (size_t i = 0; i<track->getChannelMgrCount(); i++) {
+ track->assignExtBuffer(i,soundParams[i]);
+ }
}
-#pragma pop
-
-/* 8039B910-8039B910 027F70 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
diff --git a/libs/JSystem/JAudio2/JASAudioReseter.cpp b/libs/JSystem/JAudio2/JASAudioReseter.cpp
index 3ed33e6dd3..b253f6c3f2 100644
--- a/libs/JSystem/JAudio2/JASAudioReseter.cpp
+++ b/libs/JSystem/JAudio2/JASAudioReseter.cpp
@@ -7,6 +7,9 @@
#include "dol2asm.h"
#include "dolphin/os/OS.h"
#include "dolphin/types.h"
+#include "JSystem/JAudio2/JAISoundHandles.h"
+#include "JSystem/JAudio2/JASGadget.h"
+#include "JSystem/JAudio2/JASAudioThread.h"
//
// Types:
@@ -14,11 +17,10 @@
struct JASDSPChannel {
/* 8029D340 */ void drop();
- /* 8029D948 */ void getHandle(u32);
-};
+ /* 8029D948 */ static JASDSPChannel* getHandle(u32);
-struct JASAudioThread {
- /* 8029CDC0 */ void stop();
+ inline u32 getStatus() {return mStatus;}
+ u32 mStatus;
};
//
@@ -44,7 +46,7 @@ extern "C" void setDSPLevel__9JASDriverFf();
extern "C" void getDSPLevel__9JASDriverFv();
extern "C" void registerDspSyncCallback__9JASDriverFPFPv_lPv();
extern "C" void __dl__FPv();
-extern "C" extern u8 data_80450B8C[4];
+extern "C" extern JASAudioThread* data_80450B8C;
//
// Declarations:
@@ -62,38 +64,21 @@ JASAudioReseter::JASAudioReseter() {
JASAudioReseter::~JASAudioReseter() {}
/* 8029D138-8029D1D4 297A78 009C+00 0/0 1/1 0/0 .text start__15JASAudioReseterFUlb */
-#ifdef NONMATCHING
bool JASAudioReseter::start(u32 param_0, bool param_1) {
- u32 interrupt_status;
-
if (mIsDone == false) {
return false;
+ }
+ field_0xc = param_1;
+ JASCriticalSection critical;
+ if (!JASDriver::registerDspSyncCallback(callback, this)) {
+ return false;
} else {
- field_0xc = param_1;
- interrupt_status = OSDisableInterrupts();
-
- if (!JASDriver::registerDspSyncCallback(callback, (void*)param_0)) {
- OSRestoreInterrupts(interrupt_status);
- return false;
- } else {
- mDSPLevel = JASDriver::getDSPLevel();
- field_0x0 = param_0;
- mIsDone = false;
- OSRestoreInterrupts(interrupt_status);
- return true;
- }
+ mDSPLevel = JASDriver::getDSPLevel();
+ field_0x0 = param_0;
+ mIsDone = false;
+ return true;
}
}
-#else
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm bool JASAudioReseter::start(u32 param_0, bool param_1) {
- nofralloc
-#include "asm/JSystem/JAudio2/JASAudioReseter/start__15JASAudioReseterFUlb.s"
-}
-#pragma pop
-#endif
/* 8029D1D4-8029D1F8 297B14 0024+00 0/0 1/1 0/0 .text resume__15JASAudioReseterFv */
void JASAudioReseter::resume() {
@@ -105,21 +90,30 @@ s32 JASAudioReseter::checkDone() const {
return mIsDone;
}
-/* ############################################################################################## */
-/* 80455740-80455748 003D40 0008+00 1/1 0/0 0/0 .sdata2 @156 */
-SECTION_SDATA2 static f64 lit_156 = 4503599627370496.0 /* cast u32 to float */;
/* 8029D200-8029D2D4 297B40 00D4+00 1/1 0/0 0/0 .text calc__15JASAudioReseterFv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm s32 JASAudioReseter::calc() {
- nofralloc
-#include "asm/JSystem/JAudio2/JASAudioReseter/calc__15JASAudioReseterFv.s"
+s32 JASAudioReseter::calc() {
+ if(field_0x0==0) {
+ for(size_t i = 0; i<64; i++) {
+ JASDSPChannel* handle = JASDSPChannel::getHandle(i);
+ if ((handle->getStatus()&0xFF)==0) {
+ handle->drop();
+ }
+ }
+ if(field_0xc!=false) {
+ data_80450B8C->stop();//JASGlobalInstance<JASAudioThread>::sInstance->stop();
+ }
+ mIsDone = 1;
+ return -1;
+ }
+ field_0x0--;
+ u32 unk = field_0x0;
+ float dspLevel = JASDriver::getDSPLevel();
+ JASDriver::setDSPLevel(((float)unk*dspLevel)/(float)(unk+1));
+ return 0;
}
-#pragma pop
/* 8029D2D4-8029D2F4 297C14 0020+00 1/1 0/0 0/0 .text callback__15JASAudioReseterFPv */
s32 JASAudioReseter::callback(void* param_0) {
- return calc();
+ return ((JASAudioReseter*)param_0)->calc();
}
diff --git a/libs/JSystem/JAudio2/JASAudioThread.cpp b/libs/JSystem/JAudio2/JASAudioThread.cpp
index 0667bfb0cc..415d62b23d 100644
--- a/libs/JSystem/JAudio2/JASAudioThread.cpp
+++ b/libs/JSystem/JAudio2/JASAudioThread.cpp
@@ -58,18 +58,6 @@ struct JASDSPChannel {
/* 8029D3C8 */ void initAll();
};
-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 */];
-};
-
//
// Forward References:
//
diff --git a/libs/JSystem/JAudio2/dspproc.cpp b/libs/JSystem/JAudio2/dspproc.cpp
index f91c6ff13e..e034a347bd 100644
--- a/libs/JSystem/JAudio2/dspproc.cpp
+++ b/libs/JSystem/JAudio2/dspproc.cpp
@@ -29,7 +29,19 @@ extern "C" void DSPSendCommands2__FPUlUlPFUs_v();
// Declarations:
//
+//Different compiler version for this TU? Something to note is that JAudio 1 is 32 byte aligned like this file
+
+#pragma function_align 32
+
/* 8029E4E0-8029E528 298E20 0048+00 0/0 1/1 0/0 .text DSPReleaseHalt2__FUl */
+#ifdef NONMATCHING
+void DSPReleaseHalt2(u32 msg) {
+ u32 msgs[2];
+ msgs[0] = (msg<<16) | DSP_CreateMap2(msg);
+
+ DSPSendCommands2(msgs,0,NULL);
+}
+#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
@@ -39,23 +51,32 @@ asm void DSPReleaseHalt2(u32 param_0) {
#include "asm/JSystem/JAudio2/dspproc/DSPReleaseHalt2__FUl.s"
}
#pragma pop
+#endif
/* ############################################################################################## */
/* 804512F8-80451300 0007F8 0004+04 2/2 0/0 0/0 .sbss flag */
-static u8 flag[4 + 4 /* padding */];
+static u32 flag;
/* 8029E540-8029E54C 298E80 000C+00 1/1 0/0 0/0 .text setup_callback__FUs */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-#pragma function_align 32
-static asm void setup_callback(u16 param_0) {
- nofralloc
-#include "asm/JSystem/JAudio2/dspproc/setup_callback__FUs.s"
+static void setup_callback(u16 param_0) {
+ flag = 0;
}
-#pragma pop
/* 8029E560-8029E5C4 298EA0 0064+00 0/0 1/1 0/0 .text DsetupTable__FUlUlUlUlUl */
+#ifdef NONMATCHING
+void DsetupTable(u32 param_0, u32 param_1, u32 param_2, u32 param_3, u32 param_4) {
+ u32 r8 = 1;
+ void(*callback_func)(u16) = setup_callback;
+ u32 table[5] = {param_0&0xFFFF,param_1,param_2,param_3,param_4};
+ flag = r8;
+ DSPSendCommands2(table,5,callback_func);
+ while (true) {
+ if (flag==0) {
+ return;
+ }
+ }
+}
+#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
@@ -65,16 +86,22 @@ asm void DsetupTable(u32 param_0, u32 param_1, u32 param_2, u32 param_3, u32 par
#include "asm/JSystem/JAudio2/dspproc/DsetupTable__FUlUlUlUlUl.s"
}
#pragma pop
+#endif
/* ############################################################################################## */
/* 804507C8-804507D0 000248 0002+06 3/3 0/0 0/0 .sdata DSP_MIXERLEVEL */
-SECTION_SDATA static u16 DSP_MIXERLEVEL[1 + 3 /* padding */] = {
- 0x4000,
- /* padding */
- 0x0000,
- 0x0000,
- 0x0000,
-};
+static u16 DSP_MIXERLEVEL = 0x4000;
+
+/* 8029E5E0-8029E604 298F20 0024+00 0/0 1/1 0/0 .text DsetMixerLevel__Ff */
+#ifdef NONMATCHING
+void DsetMixerLevel(f32 level) {
+ DSP_MIXERLEVEL = 4096.0f*level;
+}
+#else
+#pragma push
+#pragma optimization_level 0
+#pragma optimizewithasm off
+#pragma function_align 32
/* 80455770-80455778 003D70 0004+04 1/1 0/0 0/0 .sdata2 @333 */
SECTION_SDATA2 static f32 lit_333[1 + 1 /* padding */] = {
@@ -83,7 +110,6 @@ SECTION_SDATA2 static f32 lit_333[1 + 1 /* padding */] = {
0.0f,
};
-/* 8029E5E0-8029E604 298F20 0024+00 0/0 1/1 0/0 .text DsetMixerLevel__Ff */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
@@ -93,6 +119,7 @@ asm void DsetMixerLevel(f32 param_0) {
#include "asm/JSystem/JAudio2/dspproc/DsetMixerLevel__Ff.s"
}
#pragma pop
+#endif
/* 8029E620-8029E674 298F60 0054+00 0/0 1/1 0/0 .text DsyncFrame2ch__FUlUlUl */
#pragma push
diff --git a/libs/Z2AudioLib/Z2Audience.cpp b/libs/Z2AudioLib/Z2Audience.cpp
index 4bf359b0d5..a38aeb5753 100644
--- a/libs/Z2AudioLib/Z2Audience.cpp
+++ b/libs/Z2AudioLib/Z2Audience.cpp
@@ -739,7 +739,7 @@ asm Z2Audible::~Z2Audible() {
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
-asm void Z2Audience::calcPriority(JAIAudible* param_0) {
+asm u32 Z2Audience::calcPriority(JAIAudible* param_0) {
nofralloc
#include "asm/Z2AudioLib/Z2Audience/calcPriority__10Z2AudienceFP10JAIAudible.s"
}
@@ -882,7 +882,7 @@ asm void Z2Audience::calcPitch_(Z2AudibleChannel* param_0, Z2Audible const* para
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
-asm void Z2Audience::getMaxChannels() {
+asm int Z2Audience::getMaxChannels() {
nofralloc
#include "asm/Z2AudioLib/Z2Audience/getMaxChannels__10Z2AudienceFv.s"
}
diff --git a/libs/Z2AudioLib/Z2SceneMgr.cpp b/libs/Z2AudioLib/Z2SceneMgr.cpp
index c139fc4120..4f0a62b583 100644
--- a/libs/Z2AudioLib/Z2SceneMgr.cpp
+++ b/libs/Z2AudioLib/Z2SceneMgr.cpp
@@ -79,7 +79,7 @@ extern "C" void setSceneExist__10Z2SceneMgrFb();
extern "C" void setFadeOutStart__10Z2SceneMgrFUc();
extern "C" void setFadeInStart__10Z2SceneMgrFUc();
extern "C" void setSceneName__10Z2SceneMgrFPcll();
-extern "C" void __ct__10JAISoundIDFRC10JAISoundID();
+extern "C" void __ct__10JAISoundIDFRC10JAISoundID(JAISoundID* this_, JAISoundID const& soundIdToSet);
extern "C" void setFieldBgmPlay__8Z2SeqMgrFb();
extern "C" void isActive__12JAIStreamMgrCFv();
extern "C" void getID__8JAISoundCFv();
@@ -87,12 +87,11 @@ extern "C" void func_802B9994(void* _this);
extern "C" static void dComIfGs_getStartPoint__Fv();
extern "C" void unMuteSceneBgm__8Z2SeqMgrFUl();
extern "C" void muteSceneBgm__8Z2SeqMgrFUlf();
-extern "C" void __as__10JAISoundIDFRC10JAISoundID();
extern "C" static void dComIfGs_isSaveSwitch__Fi();
extern "C" void resetCrowdSize__7Z2SeMgrFv();
extern "C" void setTwilightGateVol__8Z2SeqMgrFf();
extern "C" void setWindStoneVol__8Z2SeqMgrFfUl();
-extern "C" void __ct__10JAISoundIDFUl(void* param_0, u32 param_1);
+extern "C" void __as__10JAISoundIDFRC10JAISoundID(JAISoundID* this_, JAISoundID const& param_0);
extern "C" void sceneChange__10Z2SceneMgrF10JAISoundIDUcUcUcUcUcb();
extern "C" void framework__10Z2SceneMgrFv();
extern "C" void load1stDynamicWave__10Z2SceneMgrFv();
@@ -108,6 +107,7 @@ extern "C" void eraseBgmWave__10Z2SceneMgrFUl();
extern "C" void getWaveLoadStatus__10Z2SceneMgrFUlUl();
extern "C" void loadSeWave__10Z2SceneMgrFUl();
extern "C" void loadBgmWave__10Z2SceneMgrFUl();
+extern "C" void __ct__10JAISoundIDFUl(void* param_0, u32 param_1);
extern "C" extern char const* const Z2SceneMgr__stringBase0;
//
@@ -707,9 +707,9 @@ asm void Z2SceneMgr::setSceneName(char* param_0, s32 param_1, s32 param_2) {
}
#pragma pop
-//! @meme this looks to be non-inlined here because @ref setSceneName is too large
-JAISoundID::JAISoundID(JAISoundID const& soundIdToSet) {
- mId = soundIdToSet.mId;
+//! @meme this looks to be non-inlined here because @ref setSceneName is too large*
+extern "C" void __ct__10JAISoundIDFRC10JAISoundID(JAISoundID* this_, JAISoundID const& soundIdToSet) {
+ *this_ = soundIdToSet;
}
/* 802B9968-802B9978 2B42A8 0010+00 1/1 0/0 0/0 .text setFieldBgmPlay__8Z2SeqMgrFb */
@@ -795,7 +795,7 @@ asm void Z2SeqMgr::muteSceneBgm(u32 param_0, f32 param_1) {
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
-asm void JAISoundID::operator=(JAISoundID const& param_0) {
+extern "C" asm void __as__10JAISoundIDFRC10JAISoundID(JAISoundID* this_, JAISoundID const& param_0) {
nofralloc
#include "asm/Z2AudioLib/Z2SceneMgr/__as__10JAISoundIDFRC10JAISoundID.s"
}
diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp
index 5cd9a893aa..fe03c66910 100644
--- a/src/m_Do/m_Do_main.cpp
+++ b/src/m_Do/m_Do_main.cpp
@@ -20,6 +20,8 @@
#include "m_Do/m_Do_dvd_thread.h"
#include "m_Do/m_Do_graphic.h"
#include "m_Do/m_Do_machine.h"
+#include "JSystem/JAudio2/JASGadget.h"
+#include "JSystem/JAudio2/JASAudioThread.h"
//
// Forward References:
@@ -735,6 +737,7 @@ u8 data_80450B88[4];
* sInstance__35JASGlobalInstance<14JASAudioThread> */
extern u8 data_80450B8C[4];
u8 data_80450B8C[4];
+//JASAudioThread* JASGlobalInstance<JASAudioThread>::sInstance;
/* 80450B90-80450B98 000090 0004+04 0/0 4/4 0/0 .sbss
* sInstance__40JASGlobalInstance<19JASDefaultBankTable> */