JAudio naming/docs pass

This commit is contained in:
PJB3005
2026-07-25 15:32:02 +02:00
parent a6c4419da6
commit 6ded3ac467
11 changed files with 66 additions and 61 deletions
@@ -12,21 +12,21 @@ struct JASBasicWaveBank : public JASWaveBank {
struct TWaveHandle : public JASWaveHandle {
TWaveHandle() { mHeap = NULL; }
virtual intptr_t getWavePtr() const;
virtual const JASWaveInfo* getWaveInfo() const { return &field_0x4; }
virtual const JASWaveInfo* getWaveInfo() const { return &mWaveInfo; }
bool compareHeap(JASHeap* heap) const { return mHeap == heap;}
/* 0x04 */ JASWaveInfo field_0x4;
/* 0x04 */ JASWaveInfo mWaveInfo;
/* 0x28 */ JASHeap* mHeap;
};
struct TGroupWaveInfo {
TGroupWaveInfo() {
field_0x0 = 0xffff;
field_0x4 = -1;
waveId = 0xffff;
mOffsetStart = -1;
}
/* 0x00 */ u16 field_0x0;
/* 0x04 */ int field_0x4;
/* 0x00 */ u16 waveId;
/* 0x04 */ int mOffsetStart;
};
struct TWaveGroup : JASWaveArc {
@@ -56,7 +56,7 @@ struct JASBasicWaveBank : public JASWaveBank {
JASWaveArc* getWaveArc(u32 param_0) { return getWaveGroup(param_0); }
u32 getArcCount() const { return mGroupCount; }
/* 0x04 */ OSMutex field_0x4;
/* 0x04 */ OSMutex mWaveTableMutex;
/* 0x1C */ TWaveHandle* mWaveTable;
/* 0x20 */ TWaveGroup* mWaveGroupArray;
/* 0x24 */ u16 mHandleCount;
@@ -26,7 +26,9 @@ public:
};
struct TCtrlWave {
/* 0x0 */ BE(u32) _00;
// Wave ID in lower half.
// Upper bits appear to be group ID, which is unused by the game code.
/* 0x0 */ BE(u32) mWaveAndGroupId;
};
struct TWave {
@@ -57,13 +59,14 @@ public:
};
struct TCtrl {
/* 0x0 */ u8 _00[4];
/* 0x0 */ BE(u32) mMagic; // 'C-DF'.
/* 0x4 */ BE(u32) mWaveCount;
/* 0x8 */ TOffset<TCtrlWave> mCtrlWaveOffsets[0];
};
struct TCtrlScene {
/* 0x0 */ u8 _00[0xC];
/* 0x0 */ BE(u32) mMagic; // 'SCNE'
/* 0x4 */ u8 _00[0x8];
/* 0xC */ TOffset<TCtrl> mCtrlOffset;
};
@@ -66,7 +66,7 @@ struct JASWaveArc : JASDisposer {
};
/* 0x04 */ mutable JASHeap mHeap;
/* 0x48 */ u32 _48;
/* 0x48 */ u32 mCurrentlyLoaded;
/* 0x4C */ volatile s32 mStatus;
/* 0x50 */ int mEntryNum;
/* 0x54 */ u32 mFileLength;
@@ -17,7 +17,7 @@ struct JASWaveArc;
struct JASWaveInfo {
JASWaveInfo() {
mBaseKey = 0x3c;
field_0x20 = &one;
mpLoaded = &one;
}
/* 0x00 */ u8 mWaveFormat;
@@ -31,7 +31,7 @@ struct JASWaveInfo {
/* 0x18 */ int mSampleCount;
/* 0x1C */ s16 mpLast;
/* 0x1E */ s16 mpPenult;
/* 0x20 */ const u32* field_0x20;
/* 0x20 */ const u32* mpLoaded;
static DUSK_GAME_DATA u32 one;
};
@@ -24,23 +24,25 @@ struct JAUSoundTableItem {
template<typename Root, typename Section, typename Group, typename Typename_0>
struct JAUSoundTable_ {
JAUSoundTable_() {
field_0x0 = NULL;
field_0x4 = 0;
mData = NULL;
mRoot = 0;
}
void reset() {
field_0x0 = NULL;
field_0x4 = NULL;
mData = NULL;
mRoot = NULL;
}
void init(const void* param_0) {
field_0x0 = param_0;
mData = param_0;
// magic number is not in debug rom. I'm not sure what this comparison is (maybe some sort of '' number?)
// I also do not know how it is different between JAUSoundTable and JAUSoundNameTable
if (*(BE(u32)*)field_0x0 + 0xbdad0000 != Root::magicNumber()) {
field_0x0 = NULL;
// Future person here: This is checking for either "BST " or "BSTN", with the second two letters in Root::magicNumber().
// Idk why the operations here are all weird but I can't use objdiff right now.
if (*(BE(u32)*)mData + 0xbdad0000 != Root::magicNumber()) {
mData = NULL;
} else {
field_0x4 = (Root*)((u8*)field_0x0 + *((BE(u32)*)field_0x0 + 3));
mRoot = (Root*)((u8*)mData + *((BE(u32)*)mData + 3));
}
}
@@ -48,14 +50,14 @@ struct JAUSoundTable_ {
if (index < 0) {
return NULL;
}
if ((u32)index >= field_0x4->mSectionNumber) {
if ((u32)index >= mRoot->mSectionNumber) {
return NULL;
}
u32 offset = field_0x4->mSectionOffsets[index];
u32 offset = mRoot->mSectionOffsets[index];
if (offset == 0) {
return NULL;
}
return (Section*)((u8*)field_0x0 + offset);
return (Section*)((u8*)mData + offset);
}
Group* getGroup(Section* param_1, int index) const {
@@ -71,11 +73,11 @@ struct JAUSoundTable_ {
if (offset == 0) {
return NULL;
}
return (Group*)((u8*)field_0x0 + offset);
return (Group*)((u8*)mData + offset);
}
const void* field_0x0;
Root* field_0x4;
const void* mData;
Root* mRoot;
};
/**
@@ -83,7 +85,7 @@ struct JAUSoundTable_ {
*
*/
struct JAUSoundTableRoot {
static inline u32 magicNumber() { return 0x5420; }
static inline u32 magicNumber() { return 'T '; } // Second half of "BST "
BE(u32) mSectionNumber;
BE(u32) mSectionOffsets[0];
};
@@ -134,7 +136,7 @@ struct JAUSoundTableGroup {
BE(u32) mNumItems;
BE(u32) field_0x4;
u8 mTypeIds[0];
u8 mTypeIds[0]; // TODO: Should probably be BE(u32), but I can't objdiff rn.
};
/**
@@ -142,7 +144,7 @@ struct JAUSoundTableGroup {
*
*/
struct JAUSoundTable : public JASGlobalInstance<JAUSoundTable> {
JAUSoundTable(bool param_0) : JASGlobalInstance<JAUSoundTable>(param_0) {
JAUSoundTable(bool setInstance) : JASGlobalInstance<JAUSoundTable>(setInstance) {
}
~JAUSoundTable() {}
@@ -157,11 +159,11 @@ struct JAUSoundTable : public JASGlobalInstance<JAUSoundTable> {
if (offset == 0) {
return NULL;
}
return (JAUSoundTableItem*)((u8*)field_0x0.field_0x0 + offset);
return (JAUSoundTableItem*)((u8*)field_0x0.mData + offset);
}
const void* getResource() const { return field_0x0.field_0x0; }
bool isValid() const { return field_0x0.field_0x0 != NULL; }
const void* getResource() const { return field_0x0.mData; }
bool isValid() const { return field_0x0.mData != NULL; }
JAUSoundTable_<JAUSoundTableRoot,JAUSoundTableSection,JAUSoundTableGroup,void> field_0x0;
};
@@ -171,7 +173,7 @@ struct JAUSoundTable : public JASGlobalInstance<JAUSoundTable> {
*
*/
struct JAUSoundNameTableRoot {
static inline u32 magicNumber() { return 0x544e; }
static inline u32 magicNumber() { return 'TN'; } // Second half of "BSTN"
BE(u32) mSectionNumber;
BE(u32) mSectionOffsets[0];
};
+1 -1
View File
@@ -713,7 +713,7 @@ void JASAramStream::channelStart() {
wave_info.mpPenult = 0;
// probably a fake match, this should be set in the JASWaveInfo constructor
static u32 const one = 1;
wave_info.field_0x20 = &one;
wave_info.mpLoaded = &one;
JASChannel* jc = JKR_NEW JASChannel(channelCallback, this);
JUT_ASSERT(963, jc);
jc->setPriority(0x7f7f);
+15 -15
View File
@@ -11,7 +11,7 @@ JASBasicWaveBank::JASBasicWaveBank() {
mWaveGroupArray = NULL;
mHandleCount = 0;
mGroupCount = 0;
OSInitMutex(&field_0x4);
OSInitMutex(&mWaveTableMutex);
}
JASBasicWaveBank::~JASBasicWaveBank() {
@@ -44,13 +44,13 @@ void JASBasicWaveBank::setWaveTableSize(u32 param_0, JKRHeap* param_1) {
}
void JASBasicWaveBank::incWaveTable(JASBasicWaveBank::TWaveGroup const* param_0) {
JASMutexLock lock(&field_0x4);
JASMutexLock lock(&mWaveTableMutex);
for (u32 i = 0; i < param_0->getWaveCount(); i++) {
TWaveHandle* handle = mWaveTable + param_0->getWaveID(i);
if (!handle->mHeap) {
handle->mHeap = &param_0->mHeap;
handle->field_0x4.field_0x20 = &param_0->_48;
handle->field_0x4.mOffsetStart = param_0->mCtrlWaveArray[i].field_0x4;
handle->mWaveInfo.mpLoaded = &param_0->mCurrentlyLoaded;
handle->mWaveInfo.mOffsetStart = param_0->mCtrlWaveArray[i].mOffsetStart;
}
}
}
@@ -58,13 +58,13 @@ void JASBasicWaveBank::incWaveTable(JASBasicWaveBank::TWaveGroup const* param_0)
DUSK_GAME_DATA u32 JASBasicWaveBank::mNoLoad;
void JASBasicWaveBank::decWaveTable(JASBasicWaveBank::TWaveGroup const* param_0) {
JASMutexLock lock(&field_0x4);
JASMutexLock lock(&mWaveTableMutex);
for (u32 i = 0; i < param_0->getWaveCount(); i++) {
TWaveHandle* handle = mWaveTable + param_0->getWaveID(i);
if (handle->mHeap == &param_0->mHeap) {
handle->mHeap = NULL;
handle->field_0x4.field_0x20 = &mNoLoad;
handle->field_0x4.mOffsetStart = -1;
handle->mWaveInfo.mpLoaded = &mNoLoad;
handle->mWaveInfo.mOffsetStart = -1;
}
}
}
@@ -80,15 +80,15 @@ JASWaveHandle* JASBasicWaveBank::getWaveHandle(u32 param_0) const {
}
void JASBasicWaveBank::setWaveInfo(JASBasicWaveBank::TWaveGroup* wgrp, int index,
u16 param_2, JASWaveInfo const& param_3) {
u16 waveId, JASWaveInfo const& param_3) {
JUT_ASSERT(204, wgrp);
JUT_ASSERT(205, index < wgrp->mWaveCount);
JUT_ASSERT(206, index >= 0);
mWaveTable[param_2].field_0x4 = param_3;
mWaveTable[param_2].field_0x4.field_0x20 = &mNoLoad;
mWaveTable[param_2].field_0x4.mOffsetStart = -1;
wgrp->mCtrlWaveArray[index].field_0x0 = param_2;
wgrp->mCtrlWaveArray[index].field_0x4 = param_3.mOffsetStart;
mWaveTable[waveId].mWaveInfo = param_3;
mWaveTable[waveId].mWaveInfo.mpLoaded = &mNoLoad;
mWaveTable[waveId].mWaveInfo.mOffsetStart = -1;
wgrp->mCtrlWaveArray[index].waveId = waveId;
wgrp->mCtrlWaveArray[index].mOffsetStart = param_3.mOffsetStart;
}
JASBasicWaveBank::TWaveGroup::TWaveGroup() {
@@ -122,7 +122,7 @@ void JASBasicWaveBank::TWaveGroup::onEraseDone() {
u32 JASBasicWaveBank::TWaveGroup::getWaveID(int index) const {
JUT_ASSERT(298, index < mWaveCount);
JUT_ASSERT(299, index >= 0);
return mCtrlWaveArray[index].field_0x0;
return mCtrlWaveArray[index].waveId;
}
intptr_t JASBasicWaveBank::TWaveHandle::getWavePtr() const {
@@ -131,5 +131,5 @@ intptr_t JASBasicWaveBank::TWaveHandle::getWavePtr() const {
if (base == 0) {
return 0;
}
return (intptr_t)base + field_0x4.mOffsetStart;
return (intptr_t)base + mWaveInfo.mOffsetStart;
}
+2 -2
View File
@@ -237,7 +237,7 @@ s32 JASChannel::initialUpdateDSPChannel(JASDsp::TChannel* i_channel) {
mCallback(CB_START, this, i_channel, mCallbackData);
}
if (field_0xdc.mWaveInfo.field_0x20[0] == 0) {
if (field_0xdc.mWaveInfo.mpLoaded[0] == 0) {
JUT_WARN_DEVICE(346, 2, "%s", "Lost wave data while playing");
mDspCh->free();
mDspCh = NULL;
@@ -315,7 +315,7 @@ s32 JASChannel::updateDSPChannel(JASDsp::TChannel* i_channel) {
mCallback(CB_PLAY, this, i_channel, mCallbackData);
}
if (field_0xdc.mWaveInfo.field_0x20[0] == 0) {
if (field_0xdc.mWaveInfo.mpLoaded[0] == 0) {
JUT_WARN_DEVICE(456, 2, "%s","Lost wave data while playing");
mDspCh->free();
mDspCh = NULL;
@@ -28,7 +28,7 @@ JASWaveHandle* JASSimpleWaveBank::getWaveHandle(u32 no) const {
void JASSimpleWaveBank::setWaveInfo(u32 no, JASWaveInfo const& waveInfo) {
mWaveTable[no].mWaveInfo = waveInfo;
mWaveTable[no].mWaveInfo.field_0x20 = &_48;
mWaveTable[no].mWaveInfo.mpLoaded = &mCurrentlyLoaded;
mWaveTable[no].mHeap = &mHeap;
}
+4 -4
View File
@@ -60,7 +60,7 @@ JASBasicWaveBank* JASWSParser::createBasicWaveBank(void const* stream, JKRHeap*
wave_info.mpLast = wave->mpLast;
wave_info.mpPenult = wave->mpPenult;
TCtrlWave* ctrl_wave = ctrl->mCtrlWaveOffsets[j].ptr(header);
u16 local_74 = JSULoHalf(ctrl_wave->_00);
u16 local_74 = JSULoHalf(ctrl_wave->mWaveAndGroupId);
wave_bank->setWaveInfo(wave_group, j, local_74, wave_info);
}
wave_group->setFileName(archive->mFileName);
@@ -94,7 +94,7 @@ JASSimpleWaveBank* JASWSParser::createSimpleWaveBank(void const* stream, JKRHeap
TWaveArchive* archive = archiveBank->mArchiveOffsets[0].ptr(header);
for (int i = 0; i < ctrl->mWaveCount; i++) {
TCtrlWave* ctrlWave = ctrl->mCtrlWaveOffsets[i].ptr(header);
u32 tmp = JSULoHalf(ctrlWave->_00);
u32 tmp = JSULoHalf(ctrlWave->mWaveAndGroupId);
if (max < tmp) {
max = tmp;
}
@@ -116,8 +116,8 @@ JASSimpleWaveBank* JASWSParser::createSimpleWaveBank(void const* stream, JKRHeap
wave_info.mpLast = wave->mpLast;
wave_info.mpPenult = wave->mpPenult;
TCtrlWave* ctrl_wave = ctrl->mCtrlWaveOffsets[i].ptr(header);
u32 tmp = JSULoHalf(ctrl_wave->_00);
wave_bank->setWaveInfo(tmp, wave_info);
u32 waveId = JSULoHalf(ctrl_wave->mWaveAndGroupId);
wave_bank->setWaveInfo(waveId, wave_info);
}
wave_bank->setFileName(archive->mFileName);
@@ -38,7 +38,7 @@ char* JASWaveArcLoader::getCurrentDir() {
}
JASWaveArc::JASWaveArc() : mHeap(this) {
_48 = 0;
mCurrentlyLoaded = 0;
mStatus = 0;
mEntryNum = -1;
mFileLength = 0;
@@ -57,7 +57,7 @@ bool JASWaveArc::loadSetup(u32 param_0) {
if (mStatus != 1) {
return false;
}
_48 = 1;
mCurrentlyLoaded = 1;
mStatus = 2;
return true;
}
@@ -71,7 +71,7 @@ bool JASWaveArc::eraseSetup() {
mStatus = 0;
return false;
}
_48 = 0;
mCurrentlyLoaded = 0;
mStatus = 0;
return true;
}
@@ -91,7 +91,7 @@ void JASWaveArc::loadToAramCallback(void* this_) {
bool JASWaveArc::sendLoadCmd() {
JASMutexLock mutexLock(&mMutex);
_48 = 0;
mCurrentlyLoaded = 0;
mStatus = 1;
loadToAramCallbackParams commandInfo;
commandInfo.mWavArc = this;