cleanup d_meter2_info / little JMessage work (#2460)

* d_meter2_info cleanup

* parseBlock_next matching
This commit is contained in:
TakaRikka
2025-05-28 04:04:30 -07:00
committed by GitHub
parent ed7b4d1879
commit 3af421d7b6
15 changed files with 1243 additions and 744 deletions
+7
View File
@@ -231,6 +231,7 @@ struct TLinkList_factory : public TLinkList<T, I> {
inline virtual ~TLinkList_factory() = 0;
virtual T* Do_create() = 0;
virtual void Do_destroy(T*) = 0;
void Clear_destroy() {
while (!this->empty()) {
T* item = &this->front();
@@ -238,6 +239,12 @@ struct TLinkList_factory : public TLinkList<T, I> {
Do_destroy(item);
}
}
TLinkList<T, I>::iterator Erase_destroy(T* param_0) {
TLinkList<T, I>::iterator spC(Erase(param_0));
Do_destroy(param_0);
return spC;
}
};
template <typename T, int I>
+2 -2
View File
@@ -247,8 +247,8 @@ inline void JKRUnmountArchive(JKRArchive* arc) {
arc->unmount();
}
inline void JKRReadIdxResource(void* param_1, u32 param_2, u32 param_3, JKRArchive* param_4) {
param_4->readIdxResource(param_1, param_2, param_3);
inline u32 JKRReadIdxResource(void* buffer, u32 bufsize, u32 resIdx, JKRArchive* archive) {
return archive->readIdxResource(buffer, bufsize, resIdx);
}
#endif
+41
View File
@@ -0,0 +1,41 @@
#ifndef JMESSAGE_H
#define JMESSAGE_H
#include <dolphin.h>
// Struct definitions might be wrong
typedef struct bmg_header_t {
/* 0x00 */ char magic[8]; // "MESGbmg1"
/* 0x08 */ u32 size; // total size of file not including FLW1/FLI1 sections
/* 0x0C */ u32 n_sections; // number of sections
/* 0x10 */ u8 encoding; // text encoding
/* 0x11 */ u8 padding[0x20 - 0x11]; // padding
} bmg_header_t;
typedef struct bmg_section_t {
/* 0x0 */ u32 magic; // four character magic string
/* 0x4 */ u32 size; // total size of the section
} bmg_section_t;
typedef struct inf1_entry_t {
/* 0x0 */ u32 string_offset; // offset into DAT1 section entries, pointing to where message text starts
/* 0x4 */ // attributes // attribute data. size fills up the rest of defined INF1 "entry_size"
} inf1_entry_t;
typedef struct inf1_section_t {
/* 0x00 */ bmg_section_t header; // section header
/* 0x08 */ u16 entry_num; // number of entries in this section
/* 0x0A */ u16 entry_size; // size of an entry
/* 0x0C */ u8 padding[4]; // padding
} inf1_section_t;
typedef struct str1_entry_t {
char str[0];
} str1_entry_t;
typedef struct str1_section_t {
/* 0x00 */ bmg_section_t header; // section header
/* 0x08 */ str1_entry_t entries[0];
} str1_section_t;
#endif /* JMESSAGE_H */
+17
View File
@@ -24,6 +24,11 @@ struct data {
struct TParse_TBlock : public JGadget::binary::TParseData_aligned<4> {
TParse_TBlock(const void* data) : TParseData_aligned(data) {}
const char* get() const { return (char*)getRaw(); }
u32 get_size() const { return *(u32*)(get() + 0x4); }
const void* getNext() const { return (char*)getRaw() + get_size(); }
u32 get_type() const { return *(u32*)(get() + 0x0); }
};
struct TParse_TBlock_info : public TParse_TBlock {
@@ -55,6 +60,18 @@ struct data {
TParse_TBlock_color(const void* data) : TParse_TBlock(data) {}
};
struct TParse_TBlock_messageText : public TParse_TBlock {
TParse_TBlock_messageText(const void* data) : TParse_TBlock(data) {}
char* getContent() const { return (char*)getRaw() + 0x8; }
};
struct TParse_TBlock_stringAttribute : public TParse_TBlock {
TParse_TBlock_stringAttribute(const void* data) : TParse_TBlock(data) {}
char* getContent() const { return (char*)getRaw() + 0x8; }
};
static u32 getTagCode(u32 tag) { return tag & 0xFFFF; }
static u32 getTagGroup(u32 tag) { return (tag >> 0x10) & 0xFF; }
+19 -2
View File
@@ -13,7 +13,7 @@ namespace JMessage {
*/
struct TResource {
TResource()
: field_0x8(NULL), field_0xc(NULL), field_0x10(NULL), field_0x14(0), mMessageID(NULL) {}
: field_0x8(NULL), field_0xc(NULL), field_0x10(NULL), field_0x14(NULL), mMessageID(NULL) {}
/* 802A8CDC */ u16 toMessageIndex_messageID(u32, u32, bool*) const;
@@ -50,11 +50,28 @@ struct TResource {
void setData_header(const void* pData) {
field_0x8.setRaw(pData);
}
void setData_block_info(const void* pData) {
field_0xc.setRaw(pData);
}
void setData_block_messageText(const void* pData) {
field_0x10 = data::TParse_TBlock_messageText(pData).getContent();
}
void setData_block_stringAttribute(const void* pData) {
field_0x14 = data::TParse_TBlock_stringAttribute(pData).getContent();
}
void setData_block_messageID(const void* pData) {
mMessageID.setRaw(pData);
}
JGadget::TLinkListNode ocObject_;
/* 0x08 */ data::TParse_THeader field_0x8;
/* 0x0C */ data::TParse_TBlock_info field_0xc;
/* 0x10 */ char* field_0x10;
/* 0x14 */ int field_0x14;
/* 0x14 */ char* field_0x14;
/* 0x18 */ data::TParse_TBlock_messageID mMessageID;
};