mirror of https://github.com/zeldaret/tp.git
325 lines
11 KiB
C++
325 lines
11 KiB
C++
//
|
|
// Generated By: dol2asm
|
|
// Translation Unit: Z2SoundInfo
|
|
//
|
|
|
|
#include "Z2AudioLib/Z2SoundInfo.h"
|
|
#include "JSystem/JAudio2/JAISeq.h"
|
|
#include "JSystem/JAudio2/JAISe.h"
|
|
#include "JSystem/JAudio2/JAISoundChild.h"
|
|
#include "JSystem/JAudio2/JAIStream.h"
|
|
#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;
|
|
struct StringOffset {
|
|
static inline const char* getString(const void* addr, u32 offset) {
|
|
return (const char*)addr + offset;
|
|
}
|
|
};
|
|
};
|
|
|
|
/* 802BB00C-802BB090 2B594C 0084+00 2/1 0/0 0/0 .text
|
|
* getBgmSeqResourceID__11Z2SoundInfoCF10JAISoundID */
|
|
u16 Z2SoundInfo::getBgmSeqResourceID(JAISoundID param_0) const {
|
|
JUT_ASSERT(20, isValid());
|
|
JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(param_0);
|
|
u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_0);
|
|
|
|
if (data != NULL) {
|
|
switch ((typeID & 0xf0)) {
|
|
case 0x60:
|
|
return 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) {
|
|
case 0:
|
|
return 0;
|
|
case 1:
|
|
return 1;
|
|
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;
|
|
}
|
|
|
|
/* 802BB0E0-802BB158 2B5A20 0078+00 1/0 0/0 0/0 .text getPriority__11Z2SoundInfoCF10JAISoundID */
|
|
u32 Z2SoundInfo::getPriority(JAISoundID param_0) const {
|
|
JUT_ASSERT(63, isValid());
|
|
JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(param_0);
|
|
u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_0);
|
|
|
|
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;
|
|
JUT_ASSERT(82, isValid());
|
|
int iVar1, uVar7;
|
|
switch (JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_0)) {
|
|
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;
|
|
} else {
|
|
local_28.field_0x0.bytes.b0_4 = 1;
|
|
}
|
|
if ((getSwBit(param_0) & 2) != 0) {
|
|
local_28.field_0x0.bytes.b0_5 = 0;
|
|
} else {
|
|
local_28.field_0x0.bytes.b0_5 = 1;
|
|
}
|
|
if ((getSwBit(param_0) & 4) != 0) {
|
|
local_28.field_0x0.bytes.b0_6 = 0;
|
|
} else {
|
|
local_28.field_0x0.bytes.b0_6 = 1;
|
|
}
|
|
if ((getSwBit(param_0) & 0x800000) != 0) {
|
|
local_28.field_0x0.bytes.b0_7 = 1;
|
|
} else {
|
|
local_28.field_0x0.bytes.b0_7 = 0;
|
|
}
|
|
if ((getSwBit(param_0) & 0x1000) != 0) {
|
|
local_28.field_0x0.bytes.b1_0 = 0;
|
|
} else {
|
|
local_28.field_0x0.bytes.b1_0 = 1;
|
|
}
|
|
if ((getSwBit(param_0) & 0x2000) != 0) {
|
|
local_28.field_0x0.bytes.b1_1 = 0;
|
|
} else {
|
|
local_28.field_0x0.bytes.b1_1 = 1;
|
|
}
|
|
|
|
uVar7 = 0;
|
|
if ((getSwBit(param_0) & 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;
|
|
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;
|
|
break;
|
|
}
|
|
return local_28;
|
|
}
|
|
|
|
/* 802BB448-802BB6DC 2B5D88 0294+00 2/1 0/0 0/0 .text getAudibleSw__11Z2SoundInfoCF10JAISoundID */
|
|
u16 Z2SoundInfo::getAudibleSw(JAISoundID param_0) const {
|
|
JAUAudibleParam local_28;
|
|
JUT_ASSERT(184, isValid());
|
|
int iVar1, uVar7;
|
|
switch (JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_0)) {
|
|
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;
|
|
} else {
|
|
local_28.field_0x0.bytes.b0_4 = 1;
|
|
}
|
|
if ((getSwBit(param_0) & 2) != 0) {
|
|
local_28.field_0x0.bytes.b0_5 = 0;
|
|
} else {
|
|
local_28.field_0x0.bytes.b0_5 = 1;
|
|
}
|
|
if ((getSwBit(param_0) & 4) != 0) {
|
|
local_28.field_0x0.bytes.b0_6 = 0;
|
|
} else {
|
|
local_28.field_0x0.bytes.b0_6 = 1;
|
|
}
|
|
if ((getSwBit(param_0) & 0x800000) != 0) {
|
|
local_28.field_0x0.bytes.b0_7 = 1;
|
|
} else {
|
|
local_28.field_0x0.bytes.b0_7 = 0;
|
|
}
|
|
if ((getSwBit(param_0) & 0x1000) != 0) {
|
|
local_28.field_0x0.bytes.b1_0 = 0;
|
|
} else {
|
|
local_28.field_0x0.bytes.b1_0 = 1;
|
|
}
|
|
if ((getSwBit(param_0) & 0x2000) != 0) {
|
|
local_28.field_0x0.bytes.b1_1 = 0;
|
|
} else {
|
|
local_28.field_0x0.bytes.b1_1 = 1;
|
|
}
|
|
|
|
uVar7 = 0;
|
|
if ((getSwBit(param_0) & 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;
|
|
break;
|
|
default:
|
|
local_28.field_0x0.half.f0 = 0xffff;
|
|
local_28.field_0x0.half.f1 = 0xffff;
|
|
break;
|
|
}
|
|
return local_28.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);
|
|
JUT_ASSERT(292, isValid());
|
|
JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(param_1);
|
|
u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_1);
|
|
if (data == NULL) {
|
|
return;
|
|
}
|
|
switch(typeID) {
|
|
case 81:
|
|
param_2->getProperty().field_0x8 *= data->field_0x8;
|
|
u32 uStack_6c = (getSwBit(param_1) & 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;
|
|
} else {
|
|
f32 dVar18 = Z2Calc::getRandom_0_1();
|
|
dVar18 = (uStack_6c / 48.0f) * dVar18;
|
|
param_2->getProperty().field_0x8 += dVar18;
|
|
}
|
|
u32 uVar1 = (u32)getSwBit(param_1) >> 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);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
/* 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);
|
|
}
|
|
|
|
/* 80455A90-80455A94 004090 0004+00 1/1 0/0 0/0 .sdata2 STRM_CH_SHIFT__20JAUStdSoundTableType */
|
|
u32 const 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 {
|
|
int numChild;
|
|
JAUSoundTableItem* data;
|
|
getSoundInfo_(param_1, param_2);
|
|
JUT_ASSERT(349, isValid());
|
|
switch (JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_1) & 0xf0) {
|
|
case 0x70:
|
|
u16 uVar1;
|
|
s32 iVar4;
|
|
data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(param_1);
|
|
JUT_ASSERT(356, data);
|
|
uVar1 = data->mResourceId;
|
|
numChild = param_2->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);
|
|
if (child != NULL) {
|
|
switch (uVar2) {
|
|
case 1:
|
|
child->mMove.mParams.mPan = 0.5f;
|
|
break;
|
|
case 2:
|
|
child->mMove.mParams.mPan = 0.0f;
|
|
break;
|
|
case 3:
|
|
child->mMove.mParams.mPan = 1.0f;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* 802BBA10-802BBA88 2B6350 0078+00 1/1 0/0 0/0 .text
|
|
* getStreamFilePath__11Z2SoundInfoF10JAISoundID */
|
|
const char* Z2SoundInfo::getStreamFilePath(JAISoundID param_1) {
|
|
JUT_ASSERT(387, isValid());
|
|
JAUSoundTableItem* data;
|
|
const void* resource;
|
|
switch (JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_1) & 0xf0) {
|
|
case 0x70:
|
|
data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(param_1);
|
|
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);
|
|
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 {
|
|
JUT_ASSERT(418, isValid());
|
|
JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(param_1);
|
|
u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_1);
|
|
if (data != NULL) {
|
|
switch(typeID) {
|
|
case 81:
|
|
return data->field_0x4;
|
|
}
|
|
}
|
|
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 {
|
|
JUT_ASSERT(440, isValid());
|
|
JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::getInstance()->getData(param_1);
|
|
u8 typeID = JASGlobalInstance<JAUSoundTable>::getInstance()->getTypeID(param_1);
|
|
if (data != NULL && (typeID & 0x40) != 0) {
|
|
param_2->getProperty().field_0x0 = (1.0f / 127.0f) * data->field_0x1;
|
|
}
|
|
}
|