Z2AudioLib debug (#3016)

This commit is contained in:
Jcw87 2026-01-05 03:54:00 -08:00 committed by GitHub
parent 1d2a0d9568
commit 767e3ba17e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 790 additions and 714 deletions

View File

@ -13,6 +13,7 @@ struct JASSoundParams;
*/
struct JASNonCopyable {
JASNonCopyable() {}
~JASNonCopyable() {}
/* 0x0 */ int field_0x0;
}; // Size: 0x4

View File

@ -349,7 +349,7 @@ public:
return audible_ != NULL;
}
JAISoundFader& getFader() { return fader_; }
JAISoundFader* getFader() const { return (JAISoundFader*)&fader_; }
void fadeIn(u32 maxSteps) { fader_.fadeInFromOut(maxSteps); }
void fadeOut(u32 maxSteps) { fader_.fadeOut(maxSteps); }

View File

@ -47,6 +47,10 @@ struct Z2Param {
static u8 BGM_CROSS_FADEOUT_TIME;
static u8 BATTLE_BGM_WAIT_TIME;
static f32 ENEMY_NEARBY_DIST;
static f32 BATTLE_FADEIN_DIST;
static f32 BATTLE_FADEOUT_DIST;
static u8 FOUND_TRACK_FI_TIME;
static u8 FOUND_TRACK_FO_TIME;
static u8 CLOSE_BATTLE_TRACK_FI_TIME;
@ -60,6 +64,10 @@ struct Z2Param {
static u8 DARK_SE_FILTER_ON;
static u8 DARK_SE_LOW_PASS_FILTER_SETTING;
static u8 SYSTEM_SE_USE_DARK_SE_SETTING;
static f32 AUDIBLE_DELTA_RANGE_VOLUME;
static f32 AUDIBLE_DELTA_RANGE_PAN;
static f32 AUDIBLE_DELTA_RANGE_DOLBY;
};
extern u8 data_8045086C;

View File

@ -45,7 +45,7 @@ struct Z2SoundFader {
fadeIn(fadeTime);
}
u32 getCount() {
u32 getCount() const {
return transition_.remainingSteps_;
}
@ -53,12 +53,8 @@ struct Z2SoundFader {
return intensity_;
}
f32 getDest() {
if (getCount() != 0) {
return transition_.targetValue_;
} else {
return intensity_;
}
f32 getDest() const {
return getCount() != 0 ? transition_.targetValue_ : getIntensity();
}
void calc() {

View File

@ -9,6 +9,12 @@ u16 seqCallback(JASTrack* track, u16 command);
class Z2SoundMgr : public JASGlobalInstance<Z2SoundMgr> {
public:
#if PLATFORM_GCN
static const int MAX_CATEGORIES = 9;
#else
static const int MAX_CATEGORIES = 10;
#endif
Z2SoundMgr();
void calc();
void setIIR(JAISound* sound, const s16* iir);

View File

@ -96,7 +96,7 @@ public:
u8 isTwilightBattle();
u8 getEnemyNumNear() const { return enemuNumNear_; }
u8 getEnemyNumVeryFar() { return enemuNumVeryFar_; }
u8 getEnemyNumVeryFar() const { return enemuNumVeryFar_; }
bool isForceBattle() { return forceBattle_; }
JSUList<Z2CreatureEnemy>* getEnemyList() { return this; }

View File

@ -37,7 +37,7 @@ struct Z2StatusMgr : public JASGlobalInstance<Z2StatusMgr> {
/* 0x01 */ u8 mMinute;
/* 0x02 */ u8 mWeekday;
/* 0x03 */ u8 field_0x03;
/* 0x04 */ s16 mTime;
/* 0x04 */ u16 mTime;
/* 0x08 */ void* mEventBit;
/* 0x0C */ u8 mPauseFlag;
/* 0x10 */ u32 mCameraMapInfo;

View File

@ -24,53 +24,57 @@ bool Z2AudioArcLoader::readCommandMore(u32 command) {
}
void Z2AudioArcLoader::readBFCA(const void* addr) {
JUT_ASSERT(76, addr);
{
JUT_ASSERT(76, addr);
JKRHeap* heap = JAUSectionHeap::getInstance()->getHeap();
JUT_ASSERT(78, heap);
JUT_ASSERT(79, Z2GetFxLineMgr());
JKRHeap* heap = JAUSectionHeap::getInstance()->getHeap();
JUT_ASSERT(78, heap);
JUT_ASSERT(79, Z2GetFxLineMgr());
JKRArchive* archive = JKRMountArchive((void*)addr, JKRGetCurrentHeap(), JKRArchive::MOUNT_DIRECTION_TAIL);
Z2GetFxLineMgr()->initDataArc(archive, heap);
JKRUnmountArchive(archive);
JKRArchive* archive = JKRMountArchive((void*)addr, JKRGetCurrentHeap(), JKRArchive::MOUNT_DIRECTION_TAIL);
Z2GetFxLineMgr()->initDataArc(archive, heap);
JKRUnmountArchive(archive);
}
}
void Z2AudioArcLoader::readBSTN(const void* addr, u32 param_1) {
#if VERSION == VERSION_SHIELD_DEBUG
JAUSectionHeap* sectionHeap = JASGlobalInstance<JAUSectionHeap>::getInstance();
JUT_ASSERT(97, sectionHeap);
{
JAUSectionHeap* sectionHeap = JASGlobalInstance<JAUSectionHeap>::getInstance();
JUT_ASSERT(97, sectionHeap);
JUT_ASSERT(99, sectionHeap->isOpen());
JUT_ASSERT(100, sectionHeap->isBuilding());
JUT_ASSERT(101, addr);
JUT_ASSERT(99, sectionHeap->isOpen());
JUT_ASSERT(100, sectionHeap->isBuilding());
JUT_ASSERT(101, addr);
JUT_ASSERT(103, sectionHeap->getSectionHeapData().soundNameTable == 0);
JUT_ASSERT(103, sectionHeap->getSectionHeapData().soundNameTable == 0);
JKRHeap* heap = JKRHeap::getCurrentHeap();
JKRHeap* gameHeap = (JKRHeap*)mDoExt_getGameHeap();
JKRSetCurrentHeap(gameHeap);
JKRHeap* heap = JKRHeap::getCurrentHeap();
JKRHeap* gameHeap = (JKRHeap*)mDoExt_getGameHeap();
JKRSetCurrentHeap(gameHeap);
u8* bstnDst = (u8*)addr;
if (param_1 != 0) {
bstnDst = new (gameHeap, 4) u8[param_1];
if (bstnDst != NULL) {
memcpy(bstnDst, addr, param_1);
u8* bstnDst = (u8*)addr;
if (param_1 != 0) {
bstnDst = new (gameHeap, 4) u8[param_1];
if (bstnDst != NULL) {
memcpy(bstnDst, addr, param_1);
}
JUT_ASSERT(122, bstnDst);
}
JUT_ASSERT(122, bstnDst);
JAUSoundNameTable* soundNameTable = new (gameHeap, 0) JAUSoundNameTable(true);
JUT_ASSERT(125, soundNameTable);
soundNameTable->init(bstnDst);
JAUSectionHeap::TSectionHeapData& sectionHeapData = (JAUSectionHeap::TSectionHeapData&)sectionHeap->getSectionHeapData();
sectionHeapData.soundNameTable = soundNameTable;
JAUSection::TSectionData& sectionData = (JAUSection::TSectionData&)sectionHeap->getSectionData();
sectionData.mBstnDst = bstnDst;
JKRSetCurrentHeap(heap);
}
JAUSoundNameTable* soundNameTable = new (gameHeap, 0) JAUSoundNameTable(true);
JUT_ASSERT(125, soundNameTable);
soundNameTable->init(bstnDst);
JAUSectionHeap::TSectionHeapData& sectionHeapData = (JAUSectionHeap::TSectionHeapData&)sectionHeap->getSectionHeapData();
sectionHeapData.soundNameTable = soundNameTable;
JAUSection::TSectionData& sectionData = (JAUSection::TSectionData&)sectionHeap->getSectionData();
sectionData.mBstnDst = bstnDst;
JKRSetCurrentHeap(heap);
#endif
}

View File

@ -46,7 +46,7 @@ f32 Z2Calc::getRandom(f32 magnitude, f32 exponent, f32 bias) {
f32 negBias = (1.0f - bias) * -2.0f;
magnitude *= Z2Calc::getRandom_0_1() < bias ? posBias : negBias;
f32 exprnd = pow(Z2Calc::getRandom_0_1(), exponent);
f32 exprnd = powf(Z2Calc::getRandom_0_1(), exponent);
return exprnd * magnitude;
}

View File

@ -80,7 +80,13 @@ u8 Z2Param::BGM_CROSS_FADEIN_TIME = 60;
u8 Z2Param::BGM_CROSS_FADEOUT_TIME = 60;
u8 Z2Param::BATTLE_BGM_WAIT_TIME = 30;
#if DEBUG
f32 Z2Param::ENEMY_NEARBY_DIST = 700.0f;
f32 Z2Param::BATTLE_FADEIN_DIST = 1100.0f;
f32 Z2Param::BATTLE_FADEOUT_DIST = 1500.0f;
#endif
u8 Z2Param::FOUND_TRACK_FI_TIME = 20;
u8 Z2Param::FOUND_TRACK_FO_TIME = 30;
@ -98,7 +104,13 @@ u8 Z2Param::ENDING_BLOW_VOL_LOWER_RECOVER_TIME = 30;
u8 Z2Param::ENDING_BLOW_MIN_FINISH_TIME = 20;
u8 data_8045086C = 1;
#if DEBUG
f32 Z2Param::AUDIBLE_DELTA_RANGE_VOLUME = 0.25f;
f32 Z2Param::AUDIBLE_DELTA_RANGE_PAN = 0.15f;
f32 Z2Param::AUDIBLE_DELTA_RANGE_DOLBY = 0.15f;
#endif
f32 Z2Param::MIN_DISTANCE_VOLUME;
f32 Z2Param::ENEMY_LASTHIT_MUTE_VOLUME;

View File

@ -77,7 +77,7 @@ void Z2SeMgr::modHeightAtCamera(const Vec** param_0) {
for (i = 0; i < 8; i++) {
if (mModY[i] == NULL) {
idx = i;
mModY[i] = *param_0;
mModY[idx] = *param_0;
break;
}
}
@ -752,71 +752,77 @@ void Z2SeMgr::messageSePlay(u16 param_0, Vec* param_1, s8 param_2) {
}
void Z2SeMgr::talkInSe() {
if (Z2GetSceneMgr()->isInGame()) {
if (Z2GetStatusMgr()->getDemoStatus() == 13) {
seMoveVolumeAll(0.0f, 0);
}
if (!Z2GetSceneMgr()->isInGame()) {
return;
}
JAISeMgr* seMgr = Z2GetSoundMgr()->getSeMgr();
seMgr->getCategory(0)->getParams()->moveVolume(Z2Param::VOL_SE_SYSTEM_TALKING, 2);
seMgr->getCategory(1)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_VOICE_TALKING, 2);
seMgr->getCategory(2)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_MOTION_TALKING, 2);
seMgr->getCategory(3)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_FOOTNOTE_TALKING, 2);
seMgr->getCategory(4)->getParams()->moveVolume(Z2Param::VOL_SE_OBJECT_TALKING, 2);
seMgr->getCategory(5)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_VOICE_TALKING, 2);
seMgr->getCategory(6)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_MOVE_TALKING, 2);
seMgr->getCategory(7)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_VOICE_TALKING, 2);
seMgr->getCategory(8)->getParams()->moveVolume(Z2Param::VOL_SE_OBJECT_TALKING, 2);
if (Z2GetStatusMgr()->getDemoStatus() == 13) {
seMoveVolumeAll(0.0f, 0);
}
if (Z2GetStatusMgr()->getDemoStatus() != 12) {
seMgr->getCategory(9)->getParams()->moveVolume(Z2Param::VOL_SE_ATMOSPHERE_TALKING, 2);
}
JAISeMgr* seMgr = Z2GetSoundMgr()->getSeMgr();
seMgr->getCategory(0)->getParams()->moveVolume(Z2Param::VOL_SE_SYSTEM_TALKING, 2);
seMgr->getCategory(1)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_VOICE_TALKING, 2);
seMgr->getCategory(2)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_MOTION_TALKING, 2);
seMgr->getCategory(3)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_FOOTNOTE_TALKING, 2);
seMgr->getCategory(4)->getParams()->moveVolume(Z2Param::VOL_SE_OBJECT_TALKING, 2);
seMgr->getCategory(5)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_VOICE_TALKING, 2);
seMgr->getCategory(6)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_MOVE_TALKING, 2);
seMgr->getCategory(7)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_VOICE_TALKING, 2);
seMgr->getCategory(8)->getParams()->moveVolume(Z2Param::VOL_SE_OBJECT_TALKING, 2);
if (Z2GetStatusMgr()->getDemoStatus() != 12) {
seMgr->getCategory(9)->getParams()->moveVolume(Z2Param::VOL_SE_ATMOSPHERE_TALKING, 2);
}
}
void Z2SeMgr::talkOutSe() {
if (Z2GetSceneMgr()->isInGame()) {
if (Z2GetStatusMgr()->getDemoStatus() == 13) {
seMoveVolumeAll(0.0f, 0);
}
if (!Z2GetSceneMgr()->isInGame()) {
return;
}
JAISeMgr* seMgr = Z2GetSoundMgr()->getSeMgr();
seMgr->getCategory(0)->getParams()->moveVolume(Z2Param::VOL_SE_SYSTEM_DEFAULT, 2);
seMgr->getCategory(1)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_VOICE_DEFAULT, 2);
seMgr->getCategory(2)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_MOTION_DEFAULT, 2);
seMgr->getCategory(3)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_FOOTNOTE_DEFAULT, 2);
seMgr->getCategory(4)->getParams()->moveVolume(Z2Param::VOL_SE_OBJECT_DEFAULT, 2);
seMgr->getCategory(5)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_VOICE_DEFAULT, 2);
seMgr->getCategory(6)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_MOVE_DEFAULT, 2);
seMgr->getCategory(7)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_VOICE_DEFAULT, 2);
seMgr->getCategory(8)->getParams()->moveVolume(Z2Param::VOL_SE_OBJECT_DEFAULT, 2);
if (Z2GetStatusMgr()->getDemoStatus() == 13) {
seMoveVolumeAll(0.0f, 0);
}
if (Z2GetStatusMgr()->getDemoStatus() != 12) {
seMgr->getCategory(9)->getParams()->moveVolume(Z2Param::VOL_SE_ATMOSPHERE_DEFAULT, 2);
}
JAISeMgr* seMgr = Z2GetSoundMgr()->getSeMgr();
seMgr->getCategory(0)->getParams()->moveVolume(Z2Param::VOL_SE_SYSTEM_DEFAULT, 2);
seMgr->getCategory(1)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_VOICE_DEFAULT, 2);
seMgr->getCategory(2)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_MOTION_DEFAULT, 2);
seMgr->getCategory(3)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_FOOTNOTE_DEFAULT, 2);
seMgr->getCategory(4)->getParams()->moveVolume(Z2Param::VOL_SE_OBJECT_DEFAULT, 2);
seMgr->getCategory(5)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_VOICE_DEFAULT, 2);
seMgr->getCategory(6)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_MOVE_DEFAULT, 2);
seMgr->getCategory(7)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_VOICE_DEFAULT, 2);
seMgr->getCategory(8)->getParams()->moveVolume(Z2Param::VOL_SE_OBJECT_DEFAULT, 2);
if (Z2GetStatusMgr()->getDemoStatus() != 12) {
seMgr->getCategory(9)->getParams()->moveVolume(Z2Param::VOL_SE_ATMOSPHERE_DEFAULT, 2);
}
}
void Z2SeMgr::menuInSe() {
if (Z2GetSceneMgr()->isInGame()) {
if (Z2GetStatusMgr()->getDemoStatus() == 13) {
seMoveVolumeAll(0.0f, 0);
}
if (!Z2GetSceneMgr()->isInGame()) {
return;
}
JAISeMgr* seMgr = Z2GetSoundMgr()->getSeMgr();
seMgr->getCategory(0)->getParams()->moveVolume(Z2Param::VOL_SE_SYSTEM_PAUSING, 2);
seMgr->getCategory(1)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_VOICE_PAUSING, 2);
seMgr->getCategory(2)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_MOTION_PAUSING, 2);
seMgr->getCategory(3)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_FOOTNOTE_PAUSING, 2);
seMgr->getCategory(4)->getParams()->moveVolume(Z2Param::VOL_SE_OBJECT_PAUSING, 2);
seMgr->getCategory(5)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_VOICE_PAUSING, 2);
seMgr->getCategory(6)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_MOVE_PAUSING, 2);
seMgr->getCategory(7)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_VOICE_PAUSING, 2);
seMgr->getCategory(8)->getParams()->moveVolume(Z2Param::VOL_SE_OBJECT_PAUSING, 2);
if (Z2GetStatusMgr()->getDemoStatus() == 13) {
seMoveVolumeAll(0.0f, 0);
}
if (Z2GetStatusMgr()->getDemoStatus() != 12) {
seMgr->getCategory(9)->getParams()->moveVolume(Z2Param::VOL_SE_ATMOSPHERE_PAUSING, 2);
}
JAISeMgr* seMgr = Z2GetSoundMgr()->getSeMgr();
seMgr->getCategory(0)->getParams()->moveVolume(Z2Param::VOL_SE_SYSTEM_PAUSING, 2);
seMgr->getCategory(1)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_VOICE_PAUSING, 2);
seMgr->getCategory(2)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_MOTION_PAUSING, 2);
seMgr->getCategory(3)->getParams()->moveVolume(Z2Param::VOL_SE_LINK_FOOTNOTE_PAUSING, 2);
seMgr->getCategory(4)->getParams()->moveVolume(Z2Param::VOL_SE_OBJECT_PAUSING, 2);
seMgr->getCategory(5)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_VOICE_PAUSING, 2);
seMgr->getCategory(6)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_MOVE_PAUSING, 2);
seMgr->getCategory(7)->getParams()->moveVolume(Z2Param::VOL_SE_CHAR_VOICE_PAUSING, 2);
seMgr->getCategory(8)->getParams()->moveVolume(Z2Param::VOL_SE_OBJECT_PAUSING, 2);
if (Z2GetStatusMgr()->getDemoStatus() != 12) {
seMgr->getCategory(9)->getParams()->moveVolume(Z2Param::VOL_SE_ATMOSPHERE_PAUSING, 2);
}
}
@ -1231,25 +1237,9 @@ void Z2MultiSeMgr::resetMultiSePos() {
}
f32 Z2MultiSeMgr::getPanPower() {
f32 pow_r = getMaxPowR();
f32 pow_l = getMaxPowL();
if (pow_l + pow_r > 0.0f) {
f32 pow_r = getMaxPowR();
f32 pow_l = getMaxPowL();
return getMaxPowR() / (pow_l + pow_r);
} else {
return 0.5f;
}
return getMaxPowL() + getMaxPowR() > 0.0f ? getMaxPowR() / (getMaxPowL() + getMaxPowR()) : 0.5f;
}
f32 Z2MultiSeMgr::getDolbyPower() {
f32 pow_b = getMaxPowB();
f32 pow_f = getMaxPowF();
if (pow_f + pow_b > 0.0f) {
f32 pow_b = getMaxPowB();
f32 pow_f = getMaxPowF();
return getMaxPowB() / (pow_f + pow_b);
} else {
return 0.5f;
}
return getMaxPowF() + getMaxPowB() > 0.0f ? getMaxPowB() / (getMaxPowF() + getMaxPowB()) : 0.5f;
}

File diff suppressed because it is too large Load Diff

View File

@ -120,8 +120,7 @@ void Z2SoundHandles::stopAllSounds(u32 fadeTime) {
}
bool Z2SoundHandles::isActive() const {
JSULink<Z2SoundHandlePool>* i;
for (i = getFirst(); i != NULL; i = i->getNext()) {
for (JSULink<Z2SoundHandlePool>*i = getFirst(); i != NULL; i = i->getNext()) {
if (i->getObject()->isSoundAttached()) {
return true;
}

View File

@ -14,6 +14,10 @@
#include "Z2AudioLib/Z2AudioCS.h"
#endif
static void dummy() {
OS_REPORT("seqCallBack!!!!!\n");
}
u16 seqCallback(JASTrack* track, u16 command) {
switch (command) {
case 0x1000:
@ -246,7 +250,7 @@ void Z2SoundMgr::resetFilterAll() {
i = 0;
}
for (; i < 9; i++) {
for (; i < MAX_CATEGORIES; i++) {
JAISeCategoryMgr* category = seMgr_.getCategory(i);
int se_count = category->getMaxActiveSe();
if (se_count > 0) {
@ -274,7 +278,7 @@ void Z2SoundMgr::mixOut() {
i = 0;
}
for (; i < 9; i++) {
for (; i < MAX_CATEGORIES; i++) {
JAISeCategoryMgr* category = seMgr_.getCategory(i);
int se_count = category->getMaxActiveSe();
if (se_count > 0) {