diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2025-11-27 21:19:33 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-27 21:19:33 -0800 |
| commit | 6f96e665186c87f15acb6f5cb8d27665afee3130 (patch) | |
| tree | 3ea70fe7d635a0f55aae44b1a386814766a46597 /src/Z2AudioLib/Z2SoundInfo.cpp | |
| parent | 767caeecc3e374779cccc9960b6546b74e7a9e50 (diff) | |
various Z2Audio / JAudio debug cleanup (#2876)
* some JAudio work
* audio cleanup checkpoint
* checkpoint more audio cleanup
* fix symbols
* more z2 cleanup
* fix regression
* fix build
* some fixes
Diffstat (limited to 'src/Z2AudioLib/Z2SoundInfo.cpp')
| -rw-r--r-- | src/Z2AudioLib/Z2SoundInfo.cpp | 271 |
1 files changed, 144 insertions, 127 deletions
diff --git a/src/Z2AudioLib/Z2SoundInfo.cpp b/src/Z2AudioLib/Z2SoundInfo.cpp index 1dda9961a4..eba28a7d08 100644 --- a/src/Z2AudioLib/Z2SoundInfo.cpp +++ b/src/Z2AudioLib/Z2SoundInfo.cpp @@ -1,8 +1,3 @@ -// -// Generated By: dol2asm -// Translation Unit: Z2SoundInfo -// - #include "Z2AudioLib/Z2SoundInfo.h" #include "JSystem/JAudio2/JAISeq.h" #include "JSystem/JAudio2/JAISe.h" @@ -11,7 +6,6 @@ #include "JSystem/JAudio2/JAUSoundTable.h" #include "JSystem/JUtility/JUTAssert.h" #include "Z2AudioLib/Z2Calc.h" -#include "dolphin/dvd.h" struct JAUStdSoundTableType { static const u32 STRM_CH_SHIFT; @@ -24,23 +18,24 @@ struct JAUStdSoundTableType { /* 802BB00C-802BB090 2B594C 0084+00 2/1 0/0 0/0 .text * getBgmSeqResourceID__11Z2SoundInfoCF10JAISoundID */ -u16 Z2SoundInfo::getBgmSeqResourceID(JAISoundID param_0) const { +u16 Z2SoundInfo::getBgmSeqResourceID(JAISoundID soundID) const { JUT_ASSERT(20, isValid()); - JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(param_0); - u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_0); + JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(soundID); + u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(soundID); if (data != NULL) { switch ((typeID & 0xf0)) { case 0x60: - return data->mResourceId; + return (u16)data->mResourceId; } } + return 0xffff; } /* 802BB090-802BB0D8 2B59D0 0048+00 1/0 0/0 0/0 .text getSoundType__11Z2SoundInfoCF10JAISoundID */ -int Z2SoundInfo::getSoundType(JAISoundID param_0) const { - switch (param_0.mId.mBytes.b0) { +int Z2SoundInfo::getSoundType(JAISoundID soundID) const { + switch (soundID.id_.info.type.parts.sectionID) { case 0: return 0; case 1: @@ -48,178 +43,194 @@ int Z2SoundInfo::getSoundType(JAISoundID param_0) const { case 2: return 2; } + return -1; } /* 802BB0D8-802BB0E0 2B5A18 0008+00 1/0 0/0 0/0 .text getCategory__11Z2SoundInfoCF10JAISoundID */ -int Z2SoundInfo::getCategory(JAISoundID param_0) const { - return param_0.mId.mBytes.b1; +int Z2SoundInfo::getCategory(JAISoundID soundID) const { + return soundID.id_.info.type.parts.groupID; } /* 802BB0E0-802BB158 2B5A20 0078+00 1/0 0/0 0/0 .text getPriority__11Z2SoundInfoCF10JAISoundID */ -u32 Z2SoundInfo::getPriority(JAISoundID param_0) const { +u32 Z2SoundInfo::getPriority(JAISoundID soundID) const { JUT_ASSERT(63, isValid()); - JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(param_0); - u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_0); + JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(soundID); + u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(soundID); if (data != NULL && (typeID & 0x40) != 0) { return data->mPriority; } + return 0; } /* 802BB158-802BB448 2B5A98 02F0+00 0/0 1/1 0/0 .text getAudibleSwFull__11Z2SoundInfoF10JAISoundID */ -JAUAudibleParam Z2SoundInfo::getAudibleSwFull(JAISoundID param_0) { - JAUAudibleParam local_28; +JAUAudibleParam Z2SoundInfo::getAudibleSwFull(JAISoundID soundID) { + JAUAudibleParam audibleParam; JUT_ASSERT(82, isValid()); int iVar1, uVar7; - switch (JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_0)) { + + u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(soundID); + switch (typeID) { case 81: - local_28.field_0x0.bytes.b0_0 = (u32)getSwBit(param_0) >> 8; - if ((getSwBit(param_0) & 1) != 0) { - local_28.field_0x0.bytes.b0_4 = 0; + audibleParam.field_0x0.bytes.b0_0 = (u32)getSwBit(soundID) >> 8; + if ((getSwBit(soundID) & 1) != 0) { + audibleParam.field_0x0.bytes.b0_4 = 0; } else { - local_28.field_0x0.bytes.b0_4 = 1; + audibleParam.field_0x0.bytes.b0_4 = 1; } - if ((getSwBit(param_0) & 2) != 0) { - local_28.field_0x0.bytes.b0_5 = 0; + + if ((getSwBit(soundID) & 2) != 0) { + audibleParam.field_0x0.bytes.b0_5 = 0; } else { - local_28.field_0x0.bytes.b0_5 = 1; + audibleParam.field_0x0.bytes.b0_5 = 1; } - if ((getSwBit(param_0) & 4) != 0) { - local_28.field_0x0.bytes.b0_6 = 0; + + if ((getSwBit(soundID) & 4) != 0) { + audibleParam.field_0x0.bytes.b0_6 = 0; } else { - local_28.field_0x0.bytes.b0_6 = 1; + audibleParam.field_0x0.bytes.b0_6 = 1; } - if ((getSwBit(param_0) & 0x800000) != 0) { - local_28.field_0x0.bytes.b0_7 = 1; + + if ((getSwBit(soundID) & 0x800000) != 0) { + audibleParam.field_0x0.bytes.b0_7 = 1; } else { - local_28.field_0x0.bytes.b0_7 = 0; + audibleParam.field_0x0.bytes.b0_7 = 0; } - if ((getSwBit(param_0) & 0x1000) != 0) { - local_28.field_0x0.bytes.b1_0 = 0; + + if ((getSwBit(soundID) & 0x1000) != 0) { + audibleParam.field_0x0.bytes.b1_0 = 0; } else { - local_28.field_0x0.bytes.b1_0 = 1; + audibleParam.field_0x0.bytes.b1_0 = 1; } - if ((getSwBit(param_0) & 0x2000) != 0) { - local_28.field_0x0.bytes.b1_1 = 0; + + if ((getSwBit(soundID) & 0x2000) != 0) { + audibleParam.field_0x0.bytes.b1_1 = 0; } else { - local_28.field_0x0.bytes.b1_1 = 1; + audibleParam.field_0x0.bytes.b1_1 = 1; } uVar7 = 0; - if ((getSwBit(param_0) & 0x80000) != 0) { + if ((getSwBit(soundID) & 0x80000) != 0) { uVar7 = 8; } - iVar1 = (getSwBit(param_0) >> 16) & 0x7; - iVar1 += (getSwBit(param_0) >> 16) & 0x70; - iVar1 += (getSwBit(param_0) >> 16) & 0xf00; - local_28.field_0x0.bytes.b1_2_7 = uVar7; - local_28.field_0x0.half.f1 = iVar1; + iVar1 = (getSwBit(soundID) >> 16) & 0x7; + iVar1 += (getSwBit(soundID) >> 16) & 0x70; + iVar1 += (getSwBit(soundID) >> 16) & 0xf00; + audibleParam.field_0x0.bytes.b1_2_7 = uVar7; + audibleParam.field_0x0.half.f1 = iVar1; break; default: - local_28.field_0x0.bytes.b0_0 = 0; - local_28.field_0x0.bytes.b0_4 = 1; - local_28.field_0x0.bytes.b0_5 = 1; - local_28.field_0x0.bytes.b0_6 = 1; - local_28.field_0x0.bytes.b0_7 = 0; - local_28.field_0x0.bytes.b1_0 = 1; - local_28.field_0x0.bytes.b1_1 = 1; - local_28.field_0x0.bytes.b1_2_7 = 0; - local_28.field_0x0.half.f1 = 0; + audibleParam.field_0x0.bytes.b0_0 = 0; + audibleParam.field_0x0.bytes.b0_4 = 1; + audibleParam.field_0x0.bytes.b0_5 = 1; + audibleParam.field_0x0.bytes.b0_6 = 1; + audibleParam.field_0x0.bytes.b0_7 = 0; + audibleParam.field_0x0.bytes.b1_0 = 1; + audibleParam.field_0x0.bytes.b1_1 = 1; + audibleParam.field_0x0.bytes.b1_2_7 = 0; + audibleParam.field_0x0.half.f1 = 0; break; } - return local_28; + + return audibleParam; } /* 802BB448-802BB6DC 2B5D88 0294+00 2/1 0/0 0/0 .text getAudibleSw__11Z2SoundInfoCF10JAISoundID */ -u16 Z2SoundInfo::getAudibleSw(JAISoundID param_0) const { - JAUAudibleParam local_28; +u16 Z2SoundInfo::getAudibleSw(JAISoundID soundID) const { + JAUAudibleParam audibleParam; JUT_ASSERT(184, isValid()); int iVar1, uVar7; - switch (JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_0)) { + + u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(soundID); + switch (typeID) { case 81: - local_28.field_0x0.bytes.b0_0 = (u32)getSwBit(param_0) >> 8; - if ((getSwBit(param_0) & 1) != 0) { - local_28.field_0x0.bytes.b0_4 = 0; + audibleParam.field_0x0.bytes.b0_0 = (u32)getSwBit(soundID) >> 8; + if ((getSwBit(soundID) & 1) != 0) { + audibleParam.field_0x0.bytes.b0_4 = 0; } else { - local_28.field_0x0.bytes.b0_4 = 1; + audibleParam.field_0x0.bytes.b0_4 = 1; } - if ((getSwBit(param_0) & 2) != 0) { - local_28.field_0x0.bytes.b0_5 = 0; + + if ((getSwBit(soundID) & 2) != 0) { + audibleParam.field_0x0.bytes.b0_5 = 0; } else { - local_28.field_0x0.bytes.b0_5 = 1; + audibleParam.field_0x0.bytes.b0_5 = 1; } - if ((getSwBit(param_0) & 4) != 0) { - local_28.field_0x0.bytes.b0_6 = 0; + + if ((getSwBit(soundID) & 4) != 0) { + audibleParam.field_0x0.bytes.b0_6 = 0; } else { - local_28.field_0x0.bytes.b0_6 = 1; + audibleParam.field_0x0.bytes.b0_6 = 1; } - if ((getSwBit(param_0) & 0x800000) != 0) { - local_28.field_0x0.bytes.b0_7 = 1; + + if ((getSwBit(soundID) & 0x800000) != 0) { + audibleParam.field_0x0.bytes.b0_7 = 1; } else { - local_28.field_0x0.bytes.b0_7 = 0; + audibleParam.field_0x0.bytes.b0_7 = 0; } - if ((getSwBit(param_0) & 0x1000) != 0) { - local_28.field_0x0.bytes.b1_0 = 0; + + if ((getSwBit(soundID) & 0x1000) != 0) { + audibleParam.field_0x0.bytes.b1_0 = 0; } else { - local_28.field_0x0.bytes.b1_0 = 1; + audibleParam.field_0x0.bytes.b1_0 = 1; } - if ((getSwBit(param_0) & 0x2000) != 0) { - local_28.field_0x0.bytes.b1_1 = 0; + + if ((getSwBit(soundID) & 0x2000) != 0) { + audibleParam.field_0x0.bytes.b1_1 = 0; } else { - local_28.field_0x0.bytes.b1_1 = 1; + audibleParam.field_0x0.bytes.b1_1 = 1; } uVar7 = 0; - if ((getSwBit(param_0) & 0x80000) != 0) { + if ((getSwBit(soundID) & 0x80000) != 0) { uVar7 = 8; } - iVar1 = (getSwBit(param_0) >> 16) & 0x7; - iVar1 += (getSwBit(param_0) >> 16) & 0x70; - iVar1 += (getSwBit(param_0) >> 16) & 0xf00; - local_28.field_0x0.bytes.b1_2_7 = uVar7; - local_28.field_0x0.half.f1 = iVar1; + iVar1 = (getSwBit(soundID) >> 16) & 0x7; + iVar1 += (getSwBit(soundID) >> 16) & 0x70; + iVar1 += (getSwBit(soundID) >> 16) & 0xf00; + audibleParam.field_0x0.bytes.b1_2_7 = uVar7; + audibleParam.field_0x0.half.f1 = iVar1; break; default: - local_28.field_0x0.half.f0 = 0xffff; - local_28.field_0x0.half.f1 = 0xffff; + audibleParam.field_0x0.half.f0 = 0xffff; + audibleParam.field_0x0.half.f1 = 0xffff; break; } - return local_28.field_0x0.half.f0; + + return audibleParam.field_0x0.half.f0; } /* 802BB6DC-802BB8B4 2B601C 01D8+00 1/0 0/0 0/0 .text * getSeInfo__11Z2SoundInfoCF10JAISoundIDP5JAISe */ -void Z2SoundInfo::getSeInfo(JAISoundID param_1, JAISe* param_2) const { - getSoundInfo_(param_1, param_2); +void Z2SoundInfo::getSeInfo(JAISoundID soundID, JAISe* sePtr) const { + getSoundInfo_(soundID, sePtr); JUT_ASSERT(292, isValid()); - JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(param_1); - u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_1); + + JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(soundID); + u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(soundID); if (data == NULL) { return; } + switch(typeID) { case 81: - param_2->getProperty().field_0x8 *= data->field_0x8; - u32 uStack_6c = (getSwBit(param_1) & 0xf0) >> 4; + sePtr->getProperty().field_0x8 *= data->field_0x8; + u32 uStack_6c = (getSwBit(soundID) & 0xf0) >> 4; if (uStack_6c > 8) { - f32 dVar18 = Z2Calc::getRandom_0_1(); - f32 dVar19 = Z2Calc::linearTransform(uStack_6c, 8.0f, 15.0f, 16.0f, 24.0f, true); - dVar19 = dVar19 / 48.0f * dVar18; - param_2->getProperty().field_0x8 += dVar19; + sePtr->getProperty().field_0x8 += Z2Calc::linearTransform(uStack_6c, 8.0f, 15.0f, 16.0f, 24.0f, true) / 48.0f * Z2Calc::getRandom_0_1(); } else { - f32 dVar18 = Z2Calc::getRandom_0_1(); - dVar18 = (uStack_6c / 48.0f) * dVar18; - param_2->getProperty().field_0x8 += dVar18; + sePtr->getProperty().field_0x8 += (uStack_6c / 48.0f) * Z2Calc::getRandom_0_1(); } - u32 uVar1 = (u32)getSwBit(param_1) >> 0x1c; + + u32 uVar1 = (u32)getSwBit(soundID) >> 0x1c; if (uVar1 != 0) { f32 dVar18 = (uVar1 / 15.0f) * Z2Calc::getRandom_0_1(); - param_2->getProperty().field_0x0 -= dVar18 < 0.0f ? 0.0f : (dVar18 > 1.0f ? 1.0f : dVar18); + sePtr->getProperty().field_0x0 -= dVar18 < 0.0f ? 0.0f : (dVar18 > 1.0f ? 1.0f : dVar18); } break; } @@ -227,43 +238,46 @@ void Z2SoundInfo::getSeInfo(JAISoundID param_1, JAISe* param_2) const { /* 802BB8B4-802BB8E0 2B61F4 002C+00 1/0 0/0 0/0 .text * getSeqInfo__11Z2SoundInfoCF10JAISoundIDP6JAISeq */ -void Z2SoundInfo::getSeqInfo(JAISoundID param_0, JAISeq* param_1) const { - getSoundInfo_(param_0, param_1); +void Z2SoundInfo::getSeqInfo(JAISoundID soundID, JAISeq* seqPtr) const { + getSoundInfo_(soundID, seqPtr); } /* 80455A90-80455A94 004090 0004+00 1/1 0/0 0/0 .sdata2 STRM_CH_SHIFT__20JAUStdSoundTableType */ -u32 const JAUStdSoundTableType::STRM_CH_SHIFT = 2; +const u32 JAUStdSoundTableType::STRM_CH_SHIFT = 2; /* 802BB8E0-802BBA10 2B6220 0130+00 1/0 0/0 0/0 .text * getStreamInfo__11Z2SoundInfoCF10JAISoundIDP9JAIStream */ -void Z2SoundInfo::getStreamInfo(JAISoundID param_1, JAIStream* param_2) const { +void Z2SoundInfo::getStreamInfo(JAISoundID soundID, JAIStream* streamPtr) const { int numChild; JAUSoundTableItem* data; - getSoundInfo_(param_1, param_2); + getSoundInfo_(soundID, streamPtr); JUT_ASSERT(349, isValid()); - switch (JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_1) & 0xf0) { + + u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(soundID); + switch (typeID & 0xf0) { case 0x70: u16 uVar1; s32 iVar4; - data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(param_1); + data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(soundID); JUT_ASSERT(356, data); + uVar1 = data->mResourceId; - numChild = param_2->getNumChild(); + numChild = streamPtr->getNumChild(); iVar4 = 0; for (; iVar4 < numChild && uVar1 != 0; uVar1 >>= JAUStdSoundTableType::STRM_CH_SHIFT, iVar4++) { u32 uVar2 = uVar1 & 3; if (uVar2 != 0) { - JAISoundChild* child = param_2->getChild(iVar4); + JAISoundChild* child = streamPtr->getChild(iVar4); if (child != NULL) { switch (uVar2) { case 1: - child->mMove.mParams.mPan = 0.5f; + child->mMove.params_.mPan = 0.5f; break; case 2: - child->mMove.mParams.mPan = 0.0f; + child->mMove.params_.mPan = 0.0f; break; case 3: - child->mMove.mParams.mPan = 1.0f; + child->mMove.params_.mPan = 1.0f; break; } } @@ -274,51 +288,54 @@ void Z2SoundInfo::getStreamInfo(JAISoundID param_1, JAIStream* param_2) const { /* 802BBA10-802BBA88 2B6350 0078+00 1/1 0/0 0/0 .text * getStreamFilePath__11Z2SoundInfoF10JAISoundID */ -const char* Z2SoundInfo::getStreamFilePath(JAISoundID param_1) { +const char* Z2SoundInfo::getStreamFilePath(JAISoundID soundID) { JUT_ASSERT(387, isValid()); JAUSoundTableItem* data; const void* resource; - switch (JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_1) & 0xf0) { + + switch (JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(soundID) & 0xf0) { case 0x70: - data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(param_1); + data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(soundID); JUT_ASSERT(394, data); resource = JASGlobalInstance<JAUSoundTable>::getInstance()->getResource(); JUT_ASSERT(398, resource); return JAUStdSoundTableType::StringOffset::getString(resource, data->field_0x4); default: return NULL; - break; } } /* 802BBA88-802BBAC8 2B63C8 0040+00 2/1 0/0 0/0 .text * getStreamFileEntry__11Z2SoundInfoF10JAISoundID */ -s32 Z2SoundInfo::getStreamFileEntry(JAISoundID param_0) { - const char* path = getStreamFilePath(param_0); +s32 Z2SoundInfo::getStreamFileEntry(JAISoundID soundID) { + const char* path = getStreamFilePath(soundID); return !path ? -1 : DVDConvertPathToEntrynum(path); } /* 802BBAC8-802BBB48 2B6408 0080+00 3/3 4/4 0/0 .text getSwBit__11Z2SoundInfoCF10JAISoundID */ -int Z2SoundInfo::getSwBit(JAISoundID param_1) const { +int Z2SoundInfo::getSwBit(JAISoundID soundID) const { JUT_ASSERT(418, isValid()); - JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(param_1); - u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_1); + JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(soundID); + + u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(soundID); if (data != NULL) { switch(typeID) { case 81: return data->field_0x4; } } - return 0xffffffff; + + return 0xFFFFFFFF; } /* 802BBB48-802BBBE0 2B6488 0098+00 3/3 0/0 0/0 .text * getSoundInfo___11Z2SoundInfoCF10JAISoundIDP8JAISound */ -void Z2SoundInfo::getSoundInfo_(JAISoundID param_1, JAISound* param_2) const { +void Z2SoundInfo::getSoundInfo_(JAISoundID soundID, JAISound* soundPtr) const { JUT_ASSERT(440, isValid()); - JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(param_1); - u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_1); + JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(soundID); + + u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(soundID); if (data != NULL && (typeID & 0x40) != 0) { - param_2->getProperty().field_0x0 = (1.0f / 127.0f) * data->field_0x1; + soundPtr->getProperty().field_0x0 = (1.0f / 127.0f) * data->field_0x1; } } |
