Files
tp/include/JSystem/JAudio2/JAUSoundTable.h
T

202 lines
4.4 KiB
C++
Raw Normal View History

2021-03-28 22:49:05 +02:00
#ifndef JAUSOUNDTABLE_H
#define JAUSOUNDTABLE_H
#include "JSystem/JAudio2/JAISound.h"
#include "JSystem/JAudio2/JASGadget.h"
2024-04-12 00:10:30 -06:00
/**
* @ingroup jsystem-jaudio
*
*/
2024-01-13 15:41:29 +02:00
struct JAUSoundTableItem {
u8 mPriority;
u8 field_0x1;
u16 mResourceId;
u32 field_0x4;
f32 field_0x8;
};
2024-04-12 00:10:30 -06:00
/**
* @ingroup jsystem-jaudio
*
*/
2023-09-19 13:45:39 +03:00
template<typename Root, typename Section, typename Group, typename Typename_0>
struct JAUSoundTable_ {
JAUSoundTable_() {
2023-09-15 05:20:09 -07:00
field_0x0 = NULL;
field_0x4 = 0;
}
2023-09-19 13:45:39 +03:00
void reset() {
field_0x0 = NULL;
field_0x4 = NULL;
}
void init(const void* param_0) {
field_0x0 = 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 (*(u32*)field_0x0 + 0xbdad0000 != Root::magicNumber()) {
field_0x0 = NULL;
} else {
field_0x4 = (Root*)((u8*)field_0x0 + *((u32*)field_0x0 + 3));
}
}
Section* getSection(int index) const {
if (index < 0) {
return NULL;
}
if ((u32)index >= field_0x4->mSectionNumber) {
return NULL;
}
u32 offset = field_0x4->mSectionOffsets[index];
if (offset == 0) {
return NULL;
}
return (Section*)((u8*)field_0x0 + offset);
}
Group* getGroup(Section* param_1, int index) const {
int iVar1;
if (index < 0) {
return NULL;
}
if ((u32)index >= param_1->mNumGroups) {
return NULL;
}
u32 offset = param_1->getGroupOffset(index);
if (offset == 0) {
return NULL;
}
return (Group*)((u8*)field_0x0 + offset);
}
const void* field_0x0;
Root* field_0x4;
u32 field_0x8;
u32 field_0xc;
};
2024-04-12 00:10:30 -06:00
/**
* @ingroup jsystem-jaudio
*
*/
2023-09-19 13:45:39 +03:00
struct JAUSoundTableRoot {
static inline u32 magicNumber() { return 0x5420; }
u32 mSectionNumber;
u32 mSectionOffsets[0];
};
2024-04-12 00:10:30 -06:00
/**
* @ingroup jsystem-jaudio
*
*/
2023-09-19 13:45:39 +03:00
struct JAUSoundTableSection {
int getGroupOffset(int index) const {
if (index < 0) {
return 0;
}
if (index >= mNumGroups) {
return 0;
}
return mGroupOffsets[index];
}
u32 mNumGroups;
u32 mGroupOffsets[0];
};
2024-04-12 00:10:30 -06:00
/**
* @ingroup jsystem-jaudio
*
*/
2023-09-19 13:45:39 +03:00
struct JAUSoundTableGroup {
u8 getTypeID(int index) const {
if (index < 0) {
return 0;
}
if (index >= mNumItems) {
return 0xff;
}
return mTypeIds[index * 4];
}
u32 getItemOffset(int index) const {
if (index < 0) {
return 0;
}
if (index >= mNumItems) {
return 0;
}
return *(u32*)(mTypeIds + index * 4) & 0xffffff;
}
u32 mNumItems;
u32 field_0x4;
u8 mTypeIds[0];
};
2024-04-12 00:10:30 -06:00
/**
* @ingroup jsystem-jaudio
*
*/
2023-09-19 13:45:39 +03:00
struct JAUSoundTable : public JASGlobalInstance<JAUSoundTable> {
JAUSoundTable(bool param_0) : JASGlobalInstance<JAUSoundTable>(param_0) {
}
2023-09-15 05:20:09 -07:00
~JAUSoundTable() {}
2023-09-19 13:45:39 +03:00
/* 802A7114 */ void init(void const*);
2023-09-15 05:20:09 -07:00
/* 802A7160 */ u8 getTypeID(JAISoundID) const;
2024-01-13 15:41:29 +02:00
/* 802A728C */ JAUSoundTableItem* getData(JAISoundID) const;
2023-09-15 05:20:09 -07:00
2024-01-13 15:41:29 +02:00
JAUSoundTableItem* getItem(JAUSoundTableGroup* group, int index) const {
2023-09-19 13:45:39 +03:00
u32 offset = group->getItemOffset(index);
if (offset == 0) {
return NULL;
}
2024-01-13 15:41:29 +02:00
return (JAUSoundTableItem*)((u8*)field_0x0.field_0x0 + offset);
2023-09-19 13:45:39 +03:00
}
2024-01-13 15:41:29 +02:00
const void* getResource() { return field_0x0.field_0x0; }
2023-09-19 13:45:39 +03:00
JAUSoundTable_<JAUSoundTableRoot,JAUSoundTableSection,JAUSoundTableGroup,void> field_0x0;
};
2024-04-12 00:10:30 -06:00
/**
* @ingroup jsystem-jaudio
*
*/
2023-09-19 13:45:39 +03:00
struct JAUSoundNameTableRoot {
static inline u32 magicNumber() { return 0x544e; }
u32 mSectionNumber;
u32 mSectionOffsets[0];
};
2024-04-12 00:10:30 -06:00
/**
* @ingroup jsystem-jaudio
*
*/
2023-09-19 13:45:39 +03:00
struct JAUSoundNameTableSection {};
2024-04-12 00:10:30 -06:00
/**
* @ingroup jsystem-jaudio
*
*/
2023-09-19 13:45:39 +03:00
struct JAUSoundNameTableGroup {};
2024-04-12 00:10:30 -06:00
/**
* @ingroup jsystem-jaudio
*
*/
struct JAUSoundNameTable : public JASGlobalInstance<JAUSoundNameTable> {
2023-09-15 05:20:09 -07:00
JAUSoundNameTable(bool param_0) : JASGlobalInstance<JAUSoundNameTable>(param_0) {
}
~JAUSoundNameTable() {}
/* 802A73D4 */ void init(void const*);
2023-09-15 05:20:09 -07:00
2023-09-19 13:45:39 +03:00
JAUSoundTable_<JAUSoundNameTableRoot,JAUSoundNameTableSection,JAUSoundNameTableGroup,void> field_0x0;
};
2021-03-28 22:49:05 +02:00
#endif /* JAUSOUNDTABLE_H */