diff --git a/configure.py b/configure.py index d4af17b5b..2b8ce73b2 100644 --- a/configure.py +++ b/configure.py @@ -764,7 +764,7 @@ config.libs = [ Object(NonMatching, "JSystem/JAudio/JAISound.cpp"), Object(NonMatching, "JSystem/JAudio/JAISoundTable.cpp"), Object(NonMatching, "JSystem/JAudio/JAIStreamMgr.cpp"), - Object(NonMatching, "JSystem/JAudio/JAISystemInterface.cpp"), + Object(Matching, "JSystem/JAudio/JAISystemInterface.cpp"), ], ), JSystemLib( diff --git a/include/JSystem/JAudio/JAISequenceMgr.h b/include/JSystem/JAudio/JAISequenceMgr.h index 58b781a43..fe15deaf0 100644 --- a/include/JSystem/JAudio/JAISequenceMgr.h +++ b/include/JSystem/JAudio/JAISequenceMgr.h @@ -17,18 +17,20 @@ namespace JAInter { PlayerParameter(); ~PlayerParameter(); - /* 0x00 */ int field_0x0; - /* 0x04 */ int field_0x4; - /* 0x08 */ int field_0x8; - /* 0x0C */ int field_0xc; - /* 0x10 */ int field_0x10; - /* 0x14 */ int field_0x14; - /* 0x18 */ int field_0x18; - /* 0x1C */ int field_0x1c; - /* 0x20 */ int field_0x20; - /* 0x24 */ int field_0x24; - /* 0x28 */ int field_0x28; - /* 0x2C */ JASystem::Kernel::TPortCmd field_0x2c; + // fake struct to match JAInter::SystemInterface::setSeqPortargsF32 and JAInter::SystemInterface::setSeqPortargsU32 + union PortArg { + f32 f32; + u32 u32; + s16* ps16; + }; + + /* 0x00 */ JASystem::TTrack* mTrack; + // /* 0x04 */ JASystem::Kernel::TPortArgs mPortArgs; + /* 0x04 */ union { + PortArg asArray[10]; + JASystem::Kernel::TPortArgs asStruct; + } mPortArgs; + /* 0x2C */ JASystem::Kernel::TPortCmd mCommand; }; class SeqUpdateData { @@ -41,12 +43,12 @@ namespace JAInter { /* 0x03 */ u8 field_0x3; /* 0x04 */ int field_0x4; /* 0x08 */ int field_0x8; - /* 0x0C */ f32 field_0xc; - /* 0x10 */ f32 field_0x10; - /* 0x14 */ f32 field_0x14; - /* 0x18 */ f32 field_0x18; - /* 0x1C */ f32 field_0x1c; - /* 0x20 */ f32 field_0x20; + /* 0x0C */ f32 mSeqVolume; + /* 0x10 */ f32 mSeqPitch; + /* 0x14 */ f32 mSeqFxmix; + /* 0x18 */ f32 mSeqPan; + /* 0x1C */ f32 mSeqDolby; + /* 0x20 */ f32 mSeqTempo; /* 0x24 */ f32* trackVolume; /* 0x28 */ f32* trackPitch; /* 0x2C */ f32* trackFxmix; @@ -77,20 +79,21 @@ namespace JAInter { class SeqParameter { public: SeqParameter() {} - int init(); + void init() {} + JASystem::TTrack* getRootTrackPointer() { return &mTrack; } - /* 0x0000 */ MoveParaSet field_0x0; + /* 0x0000 */ MoveParaSet mTempo; /* 0x0010 */ MoveParaSet field_0x10[16]; - /* 0x0110 */ MoveParaSet field_0x110[20]; + /* 0x0110 */ MoveParaSet mVolumes[20]; /* 0x0250 */ MoveParaSet* seqPan; /* 0x0254 */ MoveParaSet* seqPitch; /* 0x0258 */ MoveParaSet* seqFxmix; /* 0x025C */ MoveParaSet* seqDolby; - /* 0x0260 */ MoveParaSet field_0x260[32]; - /* 0x0460 */ MoveParaSet field_0x460[32]; - /* 0x0660 */ MoveParaSet field_0x660[32]; - /* 0x0860 */ MoveParaSet field_0x860[32]; - /* 0x0A60 */ MoveParaSet field_0xa60[32]; + /* 0x0260 */ MoveParaSet mTrackVolumes[32]; + /* 0x0460 */ MoveParaSetInitHalf mTrackPans[32]; + /* 0x0660 */ MoveParaSet mTrackPitches[32]; + /* 0x0860 */ MoveParaSetInitZero mTrackFxmixes[32]; + /* 0x0A60 */ MoveParaSetInitZero mTrackDolbys[32]; /* 0x0C60 */ MoveParaSet field_0xc60[32]; /* 0x0E60 */ u8 field_0xe60[0x1261 - 0xe60]; /* 0x1261 */ u8 field_0x1261; @@ -106,9 +109,9 @@ namespace JAInter { /* 0x1298 */ int field_0x1298; /* 0x129C */ int field_0x129c[32]; /* 0x131C */ u8 field_0x131c[32]; - /* 0x133C */ MuteBit field_0x133c[32]; + /* 0x133C */ MuteBit mMuteBits[32]; /* 0x135C */ SeqUpdateData* field_0x135c; - /* 0x1360 */ JASystem::TTrack field_0x1360; + /* 0x1360 */ JASystem::TTrack mTrack; /* 0x16EC */ JASystem::TTrack::TOuterParam field_0x16ec; }; diff --git a/include/JSystem/JAudio/JAISound.h b/include/JSystem/JAudio/JAISound.h index daa6a02d4..6be4b0552 100644 --- a/include/JSystem/JAudio/JAISound.h +++ b/include/JSystem/JAudio/JAISound.h @@ -126,8 +126,8 @@ public: /* 0x07 */ u8 field_0x7; /* 0x08 */ u8 field_0x8; /* 0x09 */ u8 field_0x9; - /* 0x0a */ short field_0xa; - /* 0x0c */ int field_0xc; + /* 0x0a */ s16 field_0xa; + /* 0x0c */ u32 mSoundID; /* 0x10 */ int field_0x10; /* 0x14 */ u32 field_0x14; /* 0x18 */ int field_0x18; @@ -150,16 +150,16 @@ namespace JAInter { int set(f32 param_1, u32 param_2); bool move(); - void init(f32 param_1) { - field_0x4 = param_1; - field_0x0 = param_1; - field_0xc = 0; + void init(f32 value) { + mCurrentValue = value; + mTargetValue = value; + mMoveCounter = 0; } - /* 0x00 */ f32 field_0x0; - /* 0x04 */ f32 field_0x4; - /* 0x08 */ f32 field_0x8; - /* 0x0C */ int field_0xc; + /* 0x00 */ f32 mTargetValue; + /* 0x04 */ f32 mCurrentValue; + /* 0x08 */ f32 mMoveAmount; + /* 0x0C */ int mMoveCounter; }; class MoveParaSetInitHalf : public MoveParaSet { @@ -184,4 +184,11 @@ namespace JAInter { }; } +#define IsJAISoundIDInUse(id) (((id)&0x800) == 0) +#define IsJAISoundIDFree(id) (((id)&0x800) == 1) +#define JAISoundID_TypeMask 0xC0000000 +#define JAISoundID_Type_Se 0x00000000 +#define JAISoundID_Type_Sequence 0x80000000 +#define JAISoundID_Type_Stream 0xC0000000 + #endif /* JAISOUND_H */ diff --git a/include/JSystem/JAudio/JAISystemInterface.h b/include/JSystem/JAudio/JAISystemInterface.h index 7f7f82f5d..5261c4331 100644 --- a/include/JSystem/JAudio/JAISystemInterface.h +++ b/include/JSystem/JAudio/JAISystemInterface.h @@ -17,7 +17,7 @@ namespace JAInter { namespace SystemInterface { BOOL checkFileExsistence(char*); int checkSeqActiveFlag(JASystem::TTrack*); - void trackToSeqp(JAISound*, u8); + JASystem::TTrack* trackToSeqp(JAISound*, u8); void setSeqPortargsF32(JAInter::SeqUpdateData*, u32, u8, f32); void setSeqPortargsU32(JAInter::SeqUpdateData*, u32, u8, u32); void rootInit(JAInter::SeqUpdateData*); diff --git a/include/JSystem/JAudio/JASCmdStack.h b/include/JSystem/JAudio/JASCmdStack.h index f0ba1cdf9..240e2fe05 100644 --- a/include/JSystem/JAudio/JASCmdStack.h +++ b/include/JSystem/JAudio/JASCmdStack.h @@ -1,12 +1,27 @@ #ifndef JASCMDSTACK_H #define JASCMDSTACK_H +#include "JSystem/JAudio/JASTrack.h" #include "dolphin/types.h" namespace JASystem { namespace Kernel { - class TPortArgs; + class TPortArgs { + public: + /* 0x00 */ TTrack* mTrack; + /* 0x04 */ u32 mFlags; + /* 0x08 */ f32 mTrackVolume; + /* 0x0C */ f32 mTrackPitch; + /* 0x10 */ f32 mTrackPan; + /* 0x14 */ f32 mTrackFxmix; + /* 0x18 */ f32 mTrackDolby; + /* 0x1C */ f32 _1C; + /* 0x20 */ u32 _20; + /* 0x24 */ f32 mTrackTempo; + }; + class TPortCmd; + class TPortHead { public: /* 0x00 */ TPortCmd* field_0x0; diff --git a/include/JSystem/JAudio/JASTrack.h b/include/JSystem/JAudio/JASTrack.h index b4fda2884..24ac75c2e 100644 --- a/include/JSystem/JAudio/JASTrack.h +++ b/include/JSystem/JAudio/JASTrack.h @@ -10,6 +10,24 @@ #include "JSystem/JAudio/JASTrackPort.h" #include "JSystem/JUtility/JUTAssert.h" +enum JASOuterParamFlag { + OUTERPARAM_Volume = 0x01, + OUTERPARAM_Pitch = 0x02, + OUTERPARAM_Fxmix = 0x04, + OUTERPARAM_Pan = 0x08, + OUTERPARAM_Dolby = 0x10, + OUTERPARAM_Unk6 = 0x20, + OUTERPARAM_Tempo = 0x40, + OUTERPARAM_FIR8Filter = 0x80, + OUTERPARAM_IIR0 = 0x1000, + OUTERPARAM_IIR1 = 0x2000, + OUTERPARAM_IIR2 = 0x4000, + OUTERPARAM_IIR3 = 0x8000, + OUTERPARAM_Unk18 = 0x20000, + + OUTERPARAM_IIRFilter = OUTERPARAM_IIR0 | OUTERPARAM_IIR1 | OUTERPARAM_IIR2 | OUTERPARAM_IIR3, +}; + namespace JASystem { class TChannel; @@ -164,6 +182,22 @@ namespace JASystem { return mChildren[index]; } + TOuterParam* getOuterParam() { return mOuterParam; } + + void checkExport(int) const {} + void checkImport(int) const {} + void getActivity() const {} + void getRoute() const {} + void getSeq() {} + // void operator delete(void*, u32) {} + // void* operator new(size_t) {} + void pauseTrackAll() {} + void setPanPower(int, u16) {} + void setPauseStatus(u8) {} + void setTranspose(s32) {} + void setVolumeMode(u8) {} + void unPauseTrackAll() {} + /* 0x000 */ union { TSeqCtrl field_0x0; TTrack* next; @@ -181,7 +215,7 @@ namespace JASystem { /* 0x304 */ short field_0x304[12]; /* 0x31C */ TTrack* mParent; /* 0x320 */ TTrack* mChildren[MAX_CHILDREN]; - /* 0x360 */ TOuterParam* field_0x360; + /* 0x360 */ TOuterParam* mOuterParam; /* 0x364 */ f32 field_0x364; /* 0x368 */ f32 field_0x368; /* 0x36C */ int field_0x36c; diff --git a/src/JAZelAudio/JAIZelBasic.cpp b/src/JAZelAudio/JAIZelBasic.cpp index 401fdbc8c..ee24ac8ce 100644 --- a/src/JAZelAudio/JAIZelBasic.cpp +++ b/src/JAZelAudio/JAIZelBasic.cpp @@ -419,7 +419,7 @@ void JAIZelBasic::onEnemyDamage() { } } else if (mSubBgmNum == JA_BGM_BATTLE_NORM) { if (mpSubBgmSound) { - JASystem::TTrack* track = &mpSubBgmSound->getSeqParameter()->field_0x1360; + JASystem::TTrack* track = mpSubBgmSound->getSeqParameter()->getRootTrackPointer(); if (track) { track->writePortApp(0x000b0000, 1); } @@ -463,7 +463,7 @@ bool JAIZelBasic::checkBgmPlaying() { /* 802A59D8-802A59F4 .text checkPlayingMainBgmFlag__11JAIZelBasicFv */ int JAIZelBasic::checkPlayingMainBgmFlag() { if (mpMainBgmSound) { - return mpMainBgmSound->field_0xc; + return mpMainBgmSound->mSoundID; } else { return -1; } @@ -481,7 +481,7 @@ BOOL JAIZelBasic::checkSubBgmPlaying() { /* 802A5A04-802A5A20 .text checkPlayingSubBgmFlag__11JAIZelBasicFv */ int JAIZelBasic::checkPlayingSubBgmFlag() { if (mpSubBgmSound) { - return mpSubBgmSound->field_0xc; + return mpSubBgmSound->mSoundID; } else { return -1; } @@ -493,7 +493,7 @@ int JAIZelBasic::checkPlayingStreamBgmFlag() { if (temp->field_0x14 == NULL) { return -1; } else { - return temp->field_0x14->field_0xc; + return temp->field_0x14->mSoundID; } } @@ -507,7 +507,7 @@ void JAIZelBasic::changeBgmStatus(s32 param_0) { /* 802A5A78-802A5AC0 .text changeSubBgmStatus__11JAIZelBasicFl */ void JAIZelBasic::changeSubBgmStatus(s32 param_1) { if (mpSubBgmSound) { - JASystem::TTrack* track = &mpSubBgmSound->getSeqParameter()->field_0x1360; + JASystem::TTrack* track = mpSubBgmSound->getSeqParameter()->getRootTrackPointer(); track->writePortApp(0x00090000, param_1); } } diff --git a/src/JSystem/JAudio/JAISequenceMgr.cpp b/src/JSystem/JAudio/JAISequenceMgr.cpp index 8cf9f9ca1..509ff6c80 100644 --- a/src/JSystem/JAudio/JAISequenceMgr.cpp +++ b/src/JSystem/JAudio/JAISequenceMgr.cpp @@ -42,12 +42,12 @@ void JAInter::SequenceMgr::init() { for (int i = 0; i < JAIGlobalParameter::getParamSeqPlayTrackMax(); i++) { FixSeqBufPointer[i] = 0; SeqUpdateData* update = &seqTrackInfo[i]; - update->field_0xc = 1.0f; - update->field_0x18 = 0.5f; - update->field_0x10 = 1.0f; - update->field_0x14 = 0.0f; - update->field_0x1c = 0.0f; - update->field_0x20 = 1.0f; + update->mSeqVolume = 1.0f; + update->mSeqPitch = 0.5f; + update->mSeqFxmix = 1.0f; + update->mSeqPan = 0.0f; + update->mSeqDolby = 0.0f; + update->mSeqTempo = 1.0f; for (int j = 0; j < JAIGlobalParameter::getParamSeqTrackMax(); j++) { update->trackVolume[j] = 1.0f; update->trackPan[j] = 64.0f; @@ -200,8 +200,3 @@ JAInter::MuteBit::MuteBit() { flag1 = 0; flag3 = 0; } - -/* 80298334-8029859C .text init__Q27JAInter12SeqParameterFv */ -int JAInter::SeqParameter::init() { - /* Nonmatching */ -} diff --git a/src/JSystem/JAudio/JAISound.cpp b/src/JSystem/JAudio/JAISound.cpp index 33245bb48..6cf99f110 100644 --- a/src/JSystem/JAudio/JAISound.cpp +++ b/src/JSystem/JAudio/JAISound.cpp @@ -22,7 +22,7 @@ JAISound::JAISound() { /* 802985C4-802985E8 .text getSeCategoryNumber__8JAISoundFv */ u8 JAISound::getSeCategoryNumber() { - return JAInter::SeMgr::changeIDToCategory(this->field_0xc); + return JAInter::SeMgr::changeIDToCategory(this->mSoundID); } /* 802985E8-802985F4 .text getSwBit__8JAISoundFv */ @@ -61,7 +61,7 @@ void JAISound::stop(u32 param_1) { /* 802986B8-8029878C .text setVolume__8JAISoundFfUlUc */ void JAISound::setVolume(f32 param_1, u32 param_2, u8 param_3) { - switch(field_0xc & 0xc0000000) { + switch(mSoundID & 0xc0000000) { case 0x80000000: setSeqInterVolume(param_3, param_1, param_2); break; @@ -82,7 +82,7 @@ static void dummy1() { /* 8029878C-80298864 .text setPan__8JAISoundFfUlUc */ void JAISound::setPan(f32 param_1, u32 param_2, u8 param_3) { - switch(field_0xc & 0xc0000000) { + switch(mSoundID & 0xc0000000) { case 0x80000000: setSeqInterPan(param_3, param_1, param_2); break; @@ -103,7 +103,7 @@ static void dummy2() { /* 80298864-8029893C .text setPitch__8JAISoundFfUlUc */ void JAISound::setPitch(f32 param_1, u32 param_2, u8 param_3) { - switch(field_0xc & 0xc0000000) { + switch(mSoundID & 0xc0000000) { case 0x80000000: setSeqInterPitch(param_3, param_1, param_2); break; @@ -124,7 +124,7 @@ static void dummy3() { /* 8029893C-80298A04 .text setFxmix__8JAISoundFfUlUc */ void JAISound::setFxmix(f32 param_1, u32 param_2, u8 param_3) { - switch(field_0xc & 0xc0000000) { + switch(mSoundID & 0xc0000000) { case 0x80000000: setSeqInterFxmix(param_3, param_1, param_2); break; @@ -144,7 +144,7 @@ static void dummy4() { /* 80298A04-80298ACC .text setDolby__8JAISoundFfUlUc */ void JAISound::setDolby(f32 param_1, u32 param_2, u8 param_3) { - switch(field_0xc & 0xc0000000) { + switch(mSoundID & 0xc0000000) { case 0x80000000: setSeqInterDolby(param_3, param_1, param_2); break; @@ -164,7 +164,7 @@ static void dummy5() { /* 80298ACC-80298B74 .text setTempoProportion__8JAISoundFfUl */ void JAISound::setTempoProportion(f32 param_1, u32 param_2) { - switch(field_0xc & 0xc0000000) { + switch(mSoundID & 0xc0000000) { case 0x80000000: setSeqTempoProportion(param_1, param_2); break; @@ -179,7 +179,7 @@ void JAISound::setTempoProportion(f32 param_1, u32 param_2) { /* 80298B74-80298C28 .text setPortData__8JAISoundFUcUs */ void JAISound::setPortData(u8 param_1, u16 param_2) { - switch(field_0xc & 0xc0000000) { + switch(mSoundID & 0xc0000000) { case 0x80000000: setSeqPortData(param_1, param_2, 0); break; @@ -195,7 +195,7 @@ void JAISound::setPortData(u8 param_1, u16 param_2) { /* 80298C28-80298CD8 .text setPrepareFlag__8JAISoundFUc */ void JAISound::setPrepareFlag(u8 param_1) { - switch(field_0xc & 0xc0000000) { + switch(mSoundID & 0xc0000000) { case 0x80000000: setSeqPrepareFlag(param_1); break; @@ -259,13 +259,13 @@ f32 JAISound::setPositionDopplarCommon(u32) { /* 80299178-8029925C .text setSeqInterVolume__8JAISoundFUcfUl */ void JAISound::setSeqInterVolume(u8 line_, f32 param_2, u32 param_3) { - if ((field_0xc & 0xC0000000) != 0x80000000) { + if ((mSoundID & 0xC0000000) != 0x80000000) { return; } if (!getSeqParameter()) { return; } - int r31 = getSeqParameter()->field_0x110[line_].set(param_2, param_3); + int r31 = getSeqParameter()->mVolumes[line_].set(param_2, param_3); if (r31 == 1) { getSeqParameter()->field_0x126c |= 1 << line_; } @@ -280,7 +280,7 @@ static void dummy6() { /* 8029925C-802993AC .text setSeqInterPan__8JAISoundFUcfUl */ void JAISound::setSeqInterPan(u8 line_, f32 param_2, u32 param_3) { - if ((field_0xc & 0xC0000000) != 0x80000000) { + if ((mSoundID & 0xC0000000) != 0x80000000) { return; } if (!getSeqParameter()) { @@ -298,7 +298,7 @@ void JAISound::setSeqInterPan(u8 line_, f32 param_2, u32 param_3) { /* 802993AC-802994FC .text setSeqInterPitch__8JAISoundFUcfUl */ void JAISound::setSeqInterPitch(u8 line_, f32 param_2, u32 param_3) { - if ((field_0xc & 0xC0000000) != 0x80000000) { + if ((mSoundID & 0xC0000000) != 0x80000000) { return; } if (!getSeqParameter()) { @@ -316,7 +316,7 @@ void JAISound::setSeqInterPitch(u8 line_, f32 param_2, u32 param_3) { /* 802994FC-8029964C .text setSeqInterFxmix__8JAISoundFUcfUl */ void JAISound::setSeqInterFxmix(u8 line_, f32 param_2, u32 param_3) { - if ((field_0xc & 0xC0000000) != 0x80000000) { + if ((mSoundID & 0xC0000000) != 0x80000000) { return; } if (!getSeqParameter()) { @@ -334,7 +334,7 @@ void JAISound::setSeqInterFxmix(u8 line_, f32 param_2, u32 param_3) { /* 8029964C-802997E4 .text setSeqInterDolby__8JAISoundFUcfUl */ void JAISound::setSeqInterDolby(u8 line_, f32 param_2, u32 param_3) { - if ((field_0xc & 0xC0000000) != 0x80000000) { + if ((mSoundID & 0xC0000000) != 0x80000000) { return; } if (!getSeqParameter()) { @@ -342,7 +342,7 @@ void JAISound::setSeqInterDolby(u8 line_, f32 param_2, u32 param_3) { } JUT_ASSERT_MSG(714, line_field_0xd != 2) { - if (getSeqParameter()->seqDolby[line_].field_0x4 != 0.0f) { + if (getSeqParameter()->seqDolby[line_].mCurrentValue != 0.0f) { param_2 = 0.0f; } else { return; @@ -359,13 +359,13 @@ void JAISound::setSeqInterDolby(u8 line_, f32 param_2, u32 param_3) { /* 802997E4-80299884 .text setSeqTempoProportion__8JAISoundFfUl */ void JAISound::setSeqTempoProportion(f32 param_1, u32 param_2) { - if ((field_0xc & 0xC0000000) != 0x80000000) { + if ((mSoundID & 0xC0000000) != 0x80000000) { return; } if (!getSeqParameter()) { return; } - getSeqParameter()->field_0x0.set(param_1, param_2); + getSeqParameter()->mTempo.set(param_1, param_2); if (getSeqParameter()->field_0x135c) { getSeqParameter()->field_0x135c->field_0x8 |= 4; } @@ -374,17 +374,17 @@ void JAISound::setSeqTempoProportion(f32 param_1, u32 param_2) { /* 80299884-802999F4 .text setSeqPortData__8JAISoundFUcUsUl */ void JAISound::setSeqPortData(u8 line_, u16 param_2, u32 param_3) { /* Nonmatching */ - if ((field_0xc & 0xC0000000) != 0x80000000) { + if ((mSoundID & 0xC0000000) != 0x80000000) { return; } if (!getSeqParameter()) { return; } - if (getSeqParameter()->field_0x10[line_].field_0x4 == 0.0f && field_0x5 >= 3) { + if (getSeqParameter()->field_0x10[line_].mCurrentValue == 0.0f && field_0x5 >= 3) { u16 local_38; - JASystem::TTrack* track = &getSeqParameter()->field_0x1360; + JASystem::TTrack* track = getSeqParameter()->getRootTrackPointer(); track->readPortApp(line_ << 16, &local_38); - getSeqParameter()->field_0x10[line_].field_0x4 = local_38; + getSeqParameter()->field_0x10[line_].mCurrentValue = local_38; } int r29 = getSeqParameter()->field_0x10[line_].set(param_2, param_3); if (r29 == 1) { @@ -397,7 +397,7 @@ void JAISound::setSeqPortData(u8 line_, u16 param_2, u32 param_3) { /* 802999F4-80299B14 .text setTrackVolume__8JAISoundFUcfUl */ void JAISound::setTrackVolume(u8 line_, f32 param_2, u32 param_3) { - if ((field_0xc & 0xC0000000) != 0x80000000) { + if ((mSoundID & 0xC0000000) != 0x80000000) { return; } if (!getSeqParameter()) { @@ -409,7 +409,7 @@ void JAISound::setTrackVolume(u8 line_, f32 param_2, u32 param_3) { if (param_3 == 0) { param_3++; } - int r30 = getSeqParameter()->field_0x260[line_].set(param_2, param_3); + int r30 = getSeqParameter()->mTrackVolumes[line_].set(param_2, param_3); if (r30 == 1) { getSeqParameter()->field_0x1280 |= 1 << line_; } @@ -420,7 +420,7 @@ void JAISound::setTrackVolume(u8 line_, f32 param_2, u32 param_3) { /* 80299B14-80299BAC .text setTrackInterruptSwitch__8JAISoundFUcUc */ void JAISound::setTrackInterruptSwitch(u8 param_1, u8 param_2) { - if ((field_0xc & 0xC0000000) != 0x80000000) { + if ((mSoundID & 0xC0000000) != 0x80000000) { return; } if (!getSeqParameter()) { @@ -533,7 +533,7 @@ void JAISound::setStreamPrepareFlag(u8) { /* 8029AA84-8029ACF0 .text setPauseMode__8JAISoundFUcUc */ void JAISound::setPauseMode(u8 param_1, u8 param_2) { /* Nonmatching */ - switch (field_0xc & 0xC0000000) { + switch (mSoundID & 0xC0000000) { case 0x80000000: if (!getSeqParameter()) { return; @@ -547,7 +547,7 @@ void JAISound::setPauseMode(u8 param_1, u8 param_2) { setSeqInterVolume(11, param_2 / 127.0f, 1); break; case 2: - JASystem::TTrack* track = &getSeqParameter()->field_0x1360; + JASystem::TTrack* track = getSeqParameter()->getRootTrackPointer(); track->pause(true, true); break; } @@ -558,7 +558,7 @@ void JAISound::setPauseMode(u8 param_1, u8 param_2) { setSeqInterVolume(11, 1.0f, 1); break; case 2: - JASystem::TTrack* track = &getSeqParameter()->field_0x1360; + JASystem::TTrack* track = getSeqParameter()->getRootTrackPointer(); track->pause(false, true); break; } diff --git a/src/JSystem/JAudio/JAISystemInterface.cpp b/src/JSystem/JAudio/JAISystemInterface.cpp index 8e013ec32..0ad4cd46a 100644 --- a/src/JSystem/JAudio/JAISystemInterface.cpp +++ b/src/JSystem/JAudio/JAISystemInterface.cpp @@ -5,6 +5,8 @@ #include "JSystem/JAudio/JAISystemInterface.h" #include "JSystem/JAudio/JASTrack.h" +#include "JSystem/JAudio/JAISequenceMgr.h" +#include "JSystem/JAudio/JAIGlobalParameter.h" #include "dolphin/dvd/dvd.h" JASystem::Kernel::TPortCmd JAInter::SystemInterface::systemPortCmd; @@ -33,41 +35,130 @@ int JAInter::SystemInterface::checkSeqActiveFlag(JASystem::TTrack* param_1) { } /* 8029E2A0-8029E478 .text trackToSeqp__Q27JAInter15SystemInterfaceFP8JAISoundUc */ -void JAInter::SystemInterface::trackToSeqp(JAISound*, u8) { - /* Nonmatching */ +JASystem::TTrack* JAInter::SystemInterface::trackToSeqp(JAISound* seq, u8 trackNo) { + JASystem::TTrack* result = NULL; + if (!IsJAISoundIDInUse(seq->mSoundID)) { + JASystem::TTrack* rootTrack = seq->getSeqParameter()->getRootTrackPointer(); + JASystem::TTrack* childTrack = rootTrack->getChild(trackNo >> 4); + if (childTrack != NULL) { + result = childTrack->getChild(trackNo & 0xF); + } + } else { + result = seq->getSeqParameter()->getRootTrackPointer()->getChild(trackNo & 0xF); + } + return result; } /* 8029E478-8029E494 .text setSeqPortargsF32__Q27JAInter15SystemInterfaceFPQ27JAInter13SeqUpdateDataUlUcf */ -void JAInter::SystemInterface::setSeqPortargsF32(JAInter::SeqUpdateData*, u32, u8, f32) { - /* Nonmatching */ +void JAInter::SystemInterface::setSeqPortargsF32(JAInter::SeqUpdateData* updateData, u32 playerParameterIndex, u8 portArgIndex, f32 value) { + updateData->systemTrackParameter[playerParameterIndex].mPortArgs.asArray[portArgIndex].f32 = value; } /* 8029E494-8029E4B0 .text setSeqPortargsU32__Q27JAInter15SystemInterfaceFPQ27JAInter13SeqUpdateDataUlUcUl */ -void JAInter::SystemInterface::setSeqPortargsU32(JAInter::SeqUpdateData*, u32, u8, u32) { - /* Nonmatching */ +void JAInter::SystemInterface::setSeqPortargsU32(JAInter::SeqUpdateData* updateData, u32 playerParameterIndex, u8 portArgIndex, u32 value) { + updateData->systemTrackParameter[playerParameterIndex].mPortArgs.asArray[portArgIndex].u32 = value; } /* 8029E4B0-8029E518 .text rootInit__Q27JAInter15SystemInterfaceFPQ27JAInter13SeqUpdateData */ -void JAInter::SystemInterface::rootInit(JAInter::SeqUpdateData*) { - /* Nonmatching */ +void JAInter::SystemInterface::rootInit(JAInter::SeqUpdateData* updateData) { + JAISound* r30 = updateData->field_0x48; + JASystem::TTrack* track = r30->getSeqParameter()->getRootTrackPointer(); + outerInit(updateData, track, JAIGlobalParameter::getParamSeqTrackMax(), 0xFFFF, 0); + r30->getSeqParameter(); } /* 8029E518-8029E5B4 .text trackInit__Q27JAInter15SystemInterfaceFPQ27JAInter13SeqUpdateData */ -void JAInter::SystemInterface::trackInit(JAInter::SeqUpdateData*) { - /* Nonmatching */ +void JAInter::SystemInterface::trackInit(JAInter::SeqUpdateData* updateData) { + JAISound* seq = updateData->field_0x48; + u32 max = 16; + if (!IsJAISoundIDInUse(seq->mSoundID)) { + max = JAIGlobalParameter::getParamSeqTrackMax(); + } + for (u32 i = 0; i < max; i++) { + if ((updateData->field_0x4 & 1 << i) == 0) { + outerInit(updateData, trackToSeqp(seq, i), i, 0xFFFF, 0); + } + } } /* 8029E5B4-8029E7B8 .text outerInit__Q27JAInter15SystemInterfaceFPQ27JAInter13SeqUpdateDataPvUlUsUc */ -void JAInter::SystemInterface::outerInit(JAInter::SeqUpdateData*, void*, u32, u16, u8) { - /* Nonmatching */ +void JAInter::SystemInterface::outerInit(JAInter::SeqUpdateData* updateData, void* track, u32 trackNo, u16 paramFlags, u8 p5) { + if (track == NULL) { + return; + } + JASystem::Kernel::TPortArgs* portArgs = &updateData->systemTrackParameter[trackNo].mPortArgs.asStruct; + JASystem::TTrack* seqP = (JASystem::TTrack*)track; + updateData->systemTrackParameter[trackNo].mTrack = seqP; + portArgs->mTrack = (JASystem::TTrack*)track; + updateData->systemTrackParameter[trackNo].mCommand.setPortCmd(setSePortParameter, portArgs); + JASystem::TTrack::TOuterParam* outerParam = seqP->getOuterParam(); + if (trackNo == JAIGlobalParameter::getParamSeqTrackMax()) { + portArgs->mTrackVolume = updateData->mSeqVolume; + portArgs->mTrackPitch = updateData->mSeqPitch; + portArgs->mTrackFxmix = updateData->mSeqFxmix; + portArgs->mTrackPan = updateData->mSeqPan; + portArgs->mTrackDolby = updateData->mSeqDolby; + portArgs->mTrackTempo = updateData->mSeqTempo; + portArgs->mFlags = 0xFF; + outerParam->onSwitch(OUTERPARAM_Tempo); + } else { + JAInter::SeqParameter* seqParam = updateData->field_0x48->getSeqParameter(); + portArgs->mTrackVolume = seqParam->mTrackVolumes[trackNo].mCurrentValue; + portArgs->mTrackPitch = seqParam->mTrackPitches[trackNo].mCurrentValue; + portArgs->mTrackFxmix = seqParam->mTrackFxmixes[trackNo].mCurrentValue; + portArgs->mTrackPan = seqParam->mTrackPans[trackNo].mCurrentValue; + portArgs->mTrackDolby = seqParam->mTrackDolbys[trackNo].mCurrentValue; + portArgs->_20 = 0; + portArgs->mFlags = 0x7F; + seqP->muteTrack(seqParam->mMuteBits[trackNo].flag1); + } + + outerParam->onSwitch(OUTERPARAM_Volume); + outerParam->onSwitch(OUTERPARAM_Pitch); + outerParam->onSwitch(OUTERPARAM_Fxmix); + outerParam->onSwitch(OUTERPARAM_Pan); + outerParam->onSwitch(OUTERPARAM_Dolby); + if (!(paramFlags & OUTERPARAM_Volume)) { + outerParam->setParam(OUTERPARAM_Volume, 0.0f); + } + if (!(paramFlags & OUTERPARAM_Pitch)) { + outerParam->setParam(OUTERPARAM_Pitch, 0.0f); + } + if (!(paramFlags & OUTERPARAM_Fxmix)) { + outerParam->setParam(OUTERPARAM_Fxmix, 0.0f); + } + if (!(paramFlags & OUTERPARAM_Pan)) { + outerParam->setParam(OUTERPARAM_Pan, 0.0f); + } + if (!(paramFlags & OUTERPARAM_Dolby)) { + outerParam->setParam(OUTERPARAM_Dolby, 0.0f); + } + updateData->systemTrackParameter[trackNo].mCommand.addPortCmdOnce(); } /* 8029E7B8-8029E820 .text setPortParameter__Q27JAInter15SystemInterfaceFPQ38JASystem6Kernel9TPortArgsPQ28JASystem6TTrackUlUl */ -void JAInter::SystemInterface::setPortParameter(JASystem::Kernel::TPortArgs*, JASystem::TTrack*, u32, u32) { - /* Nonmatching */ +void JAInter::SystemInterface::setPortParameter(JASystem::Kernel::TPortArgs* args, JASystem::TTrack* seqP, u32 r5, u32 paramFlag) { + u32 r31 = 1 << (r5 - 2); + if ((args->mFlags & r31) != 0) { + f32 f1 = ((f32*)&args->mTrackVolume)[r5 - 2]; + seqP->getOuterParam()->setParam(paramFlag, f1); + args->mFlags = args->mFlags ^ r31; + } } /* 8029E820-8029E8F4 .text setSePortParameter__Q27JAInter15SystemInterfaceFPQ38JASystem6Kernel9TPortArgs */ -void JAInter::SystemInterface::setSePortParameter(JASystem::Kernel::TPortArgs*) { - /* Nonmatching */ +void JAInter::SystemInterface::setSePortParameter(JASystem::Kernel::TPortArgs* args) { + JASystem::TTrack* track = args->mTrack; + if (track == NULL) { + return; + } + setPortParameter(args, track, 0x02, OUTERPARAM_Volume); + setPortParameter(args, track, 0x03, OUTERPARAM_Pitch); + setPortParameter(args, track, 0x04, OUTERPARAM_Pan); + setPortParameter(args, track, 0x05, OUTERPARAM_Fxmix); + setPortParameter(args, track, 0x09, OUTERPARAM_Tempo); + setPortParameter(args, track, 0x06, OUTERPARAM_Dolby); + if ((args->mFlags & 0x40) != 0 && args->_20 != 0) { + track->setInterrupt(5); + } } diff --git a/src/JSystem/JAudio/JASSeqParser.cpp b/src/JSystem/JAudio/JASSeqParser.cpp index 7e4280bdb..39419367d 100644 --- a/src/JSystem/JAudio/JASSeqParser.cpp +++ b/src/JSystem/JAudio/JASSeqParser.cpp @@ -202,7 +202,7 @@ int JASystem::TSeqParser::cmdCloseTrack(TTrack* track, u32* params) { /* 8027EFD8-8027F02C .text cmdOutSwitch__Q28JASystem10TSeqParserFPQ28JASystem6TTrackPUl */ int JASystem::TSeqParser::cmdOutSwitch(TTrack* track, u32* params) { - TTrack::TOuterParam* outer = track->field_0x360; + TTrack::TOuterParam* outer = track->getOuterParam(); if (outer) { outer->setOuterSwitch(params[0]); outer->setOuterUpdate(0xffff); diff --git a/src/JSystem/JAudio/JASTrack.cpp b/src/JSystem/JAudio/JASTrack.cpp index 4ce8e3844..6e264cc8d 100644 --- a/src/JSystem/JAudio/JASTrack.cpp +++ b/src/JSystem/JAudio/JASTrack.cpp @@ -61,8 +61,8 @@ void JASystem::TTrack::init() { for (int i = 0; i < 16; i++) { mChildren[i] = NULL; } - if (field_0x360) { - field_0x360->initExtBuffer(); + if (mOuterParam) { + mOuterParam->initExtBuffer(); } field_0x364 = 0.0f; field_0x368 = 1.0f; @@ -183,7 +183,7 @@ bool JASystem::TTrack::tryInterrupt() { /* 80281004-8028100C .text assignExtBuffer__Q28JASystem6TTrackFPQ38JASystem6TTrack11TOuterParam */ void JASystem::TTrack::assignExtBuffer(TOuterParam* param_1) { - field_0x360 = param_1; + mOuterParam = param_1; } /* 8028100C-80281050 .text releaseChannelAll__Q28JASystem6TTrackFv */