summaryrefslogtreecommitdiff
path: root/include/JSystem
diff options
context:
space:
mode:
authorhatal175 <hatal175@users.noreply.github.com>2023-09-19 13:45:39 +0300
committerGitHub <noreply@github.com>2023-09-19 03:45:39 -0700
commite5cb9ce472674fbb385bb909005dacbd3576e681 (patch)
tree45cf88e27de779d1bb80b3692d0af30b80947368 /include/JSystem
parent6726d1cf475c2ea193b5c2a63938e6869b21e10d (diff)
JAUSeqCollection, JAUSoundTable OK (#1932)
Diffstat (limited to 'include/JSystem')
-rw-r--r--include/JSystem/J3DGraphBase/J3DStruct.h18
-rw-r--r--include/JSystem/JAudio2/JAISeqDataMgr.h8
-rw-r--r--include/JSystem/JAudio2/JAUSeqCollection.h14
-rw-r--r--include/JSystem/JAudio2/JAUSoundTable.h135
4 files changed, 161 insertions, 14 deletions
diff --git a/include/JSystem/J3DGraphBase/J3DStruct.h b/include/JSystem/J3DGraphBase/J3DStruct.h
index 9063658da9..2e2eef1b2b 100644
--- a/include/JSystem/J3DGraphBase/J3DStruct.h
+++ b/include/JSystem/J3DGraphBase/J3DStruct.h
@@ -40,6 +40,24 @@ struct J3DTextureSRTInfo {
/* 0x08 */ s16 mRotation;
/* 0x0C */ f32 mTranslationX;
/* 0x10 */ f32 mTranslationY;
+
+ inline void operator=(J3DTextureSRTInfo const& other) {
+ register const f32* src = &other.mScaleX;
+ register f32* dst = &mScaleX;
+ register f32 xy;
+ asm {
+ psq_l xy, 0(src), 0, 0
+ psq_st xy, 0(dst), 0, 0
+ };
+ // Unclear why there's a 4 byte copy here.
+ *(u32*)&mRotation = *(u32*)&other.mRotation;
+ src = &other.mTranslationX;
+ dst = &mTranslationX;
+ asm {
+ psq_l xy, 0(src), 0, 0
+ psq_st xy, 0(dst), 0, 0
+ };
+ }
}; // Size: 0x14
struct J3DTexMtxInfo {
diff --git a/include/JSystem/JAudio2/JAISeqDataMgr.h b/include/JSystem/JAudio2/JAISeqDataMgr.h
index 8ef945dee4..ed8ce8d14e 100644
--- a/include/JSystem/JAudio2/JAISeqDataMgr.h
+++ b/include/JSystem/JAudio2/JAISeqDataMgr.h
@@ -9,6 +9,11 @@ struct JAISeqData {
field_0x4 = param_1;
}
+ void set(void* param_0, u32 param_1) {
+ field_0x0 = param_0;
+ field_0x4 = param_1;
+ }
+
/* 0x00 */ void* field_0x0;
/* 0x04 */ u32 field_0x4;
};
@@ -36,8 +41,9 @@ struct JAISeqDataUser {
};
struct JAISeqDataMgr {
+ enum SeqDataReturnValue{ SeqDataReturnValue_0 = 0, SeqDataReturnValue_1 = 1, SeqDataReturnValue_2 = 2};
virtual ~JAISeqDataMgr();
- virtual s32 getSeqData(JAISoundID, JAISeqData*) = 0;
+ virtual SeqDataReturnValue getSeqData(JAISoundID, JAISeqData*) = 0;
virtual int releaseSeqData() = 0;
virtual bool setSeqDataUser(JAISeqDataUser*) = 0;
};
diff --git a/include/JSystem/JAudio2/JAUSeqCollection.h b/include/JSystem/JAudio2/JAUSeqCollection.h
index 837a4b83d1..61afc9ad6b 100644
--- a/include/JSystem/JAudio2/JAUSeqCollection.h
+++ b/include/JSystem/JAudio2/JAUSeqCollection.h
@@ -6,18 +6,26 @@
class JAISeqData;
class JAISeqDataRegion;
+struct JAUSeqCollectionData {
+ s8 field_0x0;
+ s8 field_0x1;
+ u16 field_0x2;
+ u32 field_0x4;
+ u32 field_0x8;
+};
+
class JAUSeqCollection {
public:
/* 802A66A0 */ JAUSeqCollection();
/* 802A66AC */ void init(void const*);
/* 802A66FC */ bool getSeqData(int, int, JAISeqData*);
- /* 802A6754 */ void getSeqDataRegion(JAISeqDataRegion*);
+ /* 802A6754 */ bool getSeqDataRegion(JAISeqDataRegion*);
bool isValid() { return field_0x8; }
/* 0x00 */ u16 field_0x0;
/* 0x04 */ const u32* field_0x4;
- /* 0x08 */ const void* field_0x8;
+ /* 0x08 */ const JAUSeqCollectionData* field_0x8;
/* 0x0C */ int field_0xc;
};
@@ -26,7 +34,7 @@ public:
/* 802A677C */ JAUSeqDataMgr_SeqCollection();
/* 802A67D0 */ bool setSeqDataUser(JAISeqDataUser*);
/* 802A67DC */ int releaseSeqData();
- /* 802A683C */ s32 getSeqData(JAISoundID, JAISeqData*);
+ /* 802A683C */ SeqDataReturnValue getSeqData(JAISoundID, JAISeqData*);
/* 802A6894 */ ~JAUSeqDataMgr_SeqCollection();
/* 0x14 */ JAISeqDataUser* user_;
diff --git a/include/JSystem/JAudio2/JAUSoundTable.h b/include/JSystem/JAudio2/JAUSoundTable.h
index 7f8b9f1243..a91f711118 100644
--- a/include/JSystem/JAudio2/JAUSoundTable.h
+++ b/include/JSystem/JAudio2/JAUSoundTable.h
@@ -4,31 +4,146 @@
#include "JSystem/JAudio2/JAISound.h"
#include "JSystem/JAudio2/JASGadget.h"
-class JAUSoundTable : public JASGlobalInstance<JAUSoundTable> {
-public:
- JAUSoundTable(bool param_0) : JASGlobalInstance<JAUSoundTable>(param_0) {
+template<typename Root, typename Section, typename Group, typename Typename_0>
+struct JAUSoundTable_ {
+ JAUSoundTable_() {
field_0x0 = NULL;
field_0x4 = 0;
}
+
+ 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;
+};
+
+struct JAUSoundTableRoot {
+ static inline u32 magicNumber() { return 0x5420; }
+ u32 mSectionNumber;
+ u32 mSectionOffsets[0];
+};
+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];
+};
+
+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];
+};
+
+struct JAUSoundTable : public JASGlobalInstance<JAUSoundTable> {
+ JAUSoundTable(bool param_0) : JASGlobalInstance<JAUSoundTable>(param_0) {
+ }
~JAUSoundTable() {}
+
/* 802A7114 */ void init(void const*);
/* 802A7160 */ u8 getTypeID(JAISoundID) const;
- /* 802A728C */ void getData(JAISoundID) const;
+ /* 802A728C */ void* getData(JAISoundID) const;
+
+ void* getItem(JAUSoundTableGroup* group, int index) const {
+ u32 offset = group->getItemOffset(index);
+ if (offset == 0) {
+ return NULL;
+ }
+ return (void*)((u8*)field_0x0.field_0x0 + offset);
+ }
- void* field_0x0;
- int field_0x4;
+ JAUSoundTable_<JAUSoundTableRoot,JAUSoundTableSection,JAUSoundTableGroup,void> field_0x0;
};
+struct JAUSoundNameTableRoot {
+ static inline u32 magicNumber() { return 0x544e; }
+ u32 mSectionNumber;
+ u32 mSectionOffsets[0];
+};
+struct JAUSoundNameTableSection {};
+struct JAUSoundNameTableGroup {};
+
struct JAUSoundNameTable : public JASGlobalInstance<JAUSoundNameTable> {
JAUSoundNameTable(bool param_0) : JASGlobalInstance<JAUSoundNameTable>(param_0) {
- field_0x0 = NULL;
- field_0x4 = 0;
}
~JAUSoundNameTable() {}
/* 802A73D4 */ void init(void const*);
- void* field_0x0;
- int field_0x4;
+ JAUSoundTable_<JAUSoundNameTableRoot,JAUSoundNameTableSection,JAUSoundNameTableGroup,void> field_0x0;
};
#endif /* JAUSOUNDTABLE_H */