mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-10 04:46:48 -04:00
cleanup d_meter2_info / little JMessage work (#2460)
* d_meter2_info cleanup * parseBlock_next matching
This commit is contained in:
@@ -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 */
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user