mirror of
https://github.com/zeldaret/tww.git
synced 2026-10-28 11:29:19 -04:00
97 lines
3.2 KiB
C++
97 lines
3.2 KiB
C++
#ifndef JMESSAGE_DATA_H
|
|
#define JMESSAGE_DATA_H
|
|
|
|
#include "JSystem/JGadget/binary.h"
|
|
#include "JSystem/JUtility/JUTDataHeader.h"
|
|
|
|
namespace JMessage {
|
|
namespace data {
|
|
extern const char ga4cSignature[4];
|
|
|
|
// TParse_THeader handles parsing the BMG file header data
|
|
struct TParse_THeader : public JGadget::binary::TParseData_aligned<4> {
|
|
TParse_THeader(const void* pData) : TParseData_aligned(pData) {}
|
|
|
|
// TODO: create a struct for this content (BMG header)
|
|
char* get() const { return (char*)getRaw(); }
|
|
const void* getContent() const { return (char*)getRaw() + 0x20; }
|
|
|
|
char* get_signature() const { return (char*)(get() + 0x0); }
|
|
u32 get_type() const { return *(u32*)(get() + 0x4); }
|
|
u32 get_blockNumber() const { return *(u32*)(get() + 0xC); }
|
|
u32 get_encoding() const { return *(u8*)(get() + 0x10); }
|
|
};
|
|
|
|
// TParse_TBlock handles parsing the generic section header data
|
|
struct TParse_TBlock : public JGadget::binary::TParseData_aligned<4> {
|
|
TParse_TBlock(const void* pData) : TParseData_aligned(pData) {}
|
|
|
|
const char* get() const { return (char*)getRaw(); }
|
|
const void* getNext() const { return (char*)getRaw() + get_size(); }
|
|
|
|
u32 get_type() const { return *(u32*)(get() + 0x0); }
|
|
u32 get_size() const { return *(u32*)(get() + 0x4); }
|
|
};
|
|
|
|
// INF1
|
|
struct JUTMesgInfo {
|
|
public:
|
|
/* 0x00 */ JUTDataBlockHeader header;
|
|
/* 0x08 */ u16 messageEntryNumber;
|
|
/* 0x0A */ u16 messageEntrySize;
|
|
/* 0x0C */ u16 groupID;
|
|
/* 0x0E */ u8 defaultColor;
|
|
/* 0x0F */ u8 reserved;
|
|
/* 0x10 */ char messageEntryTable[];
|
|
};
|
|
|
|
// TParse_TBlock_info handles parsing INF1 section data
|
|
struct TParse_TBlock_info : public TParse_TBlock {
|
|
TParse_TBlock_info(const void* pData) : TParse_TBlock(pData) {}
|
|
|
|
char* get() const { return (char*)getRaw(); }
|
|
|
|
u32 get_messageEntryNumber() const { return *(u16*)(get() + 0x8); }
|
|
u32 get_messageEntrySize() const { return *(u16*)(get() + 0xA); }
|
|
u16 get_groupID() const { return *(u16*)(get() + 0xC); }
|
|
char* getContent() const { return (char*)getRaw() + 0x10; }
|
|
};
|
|
|
|
// MID1
|
|
struct JUTMesgIDData {
|
|
public:
|
|
/* 0x00 */ JUTDataBlockHeader mHeader;
|
|
/* 0x08 */ u16 numEntries;
|
|
/* 0x0A */ u8 format;
|
|
/* 0x0B */ u8 info;
|
|
/* 0x0C */ u8 reserved[4];
|
|
/* 0x10 */ u32 messageIDTable[];
|
|
};
|
|
|
|
// TParse_TBlock_messageID handles parsing MID1 section data
|
|
struct TParse_TBlock_messageID : public TParse_TBlock {
|
|
TParse_TBlock_messageID(const void* pData) : TParse_TBlock(pData) {}
|
|
};
|
|
|
|
// TParse_TBlock_messageData handles parsing DAT1 section data
|
|
struct TParse_TBlock_messageData : public TParse_TBlock {
|
|
TParse_TBlock_messageData(const void* pData) : TParse_TBlock(pData) {}
|
|
|
|
char* getContent() const { return (char*)getRaw() + 0x8; }
|
|
};
|
|
|
|
// TParse_TBlock_stringAttribute handles parsing STR1 section data
|
|
struct TParse_TBlock_stringAttribute : public TParse_TBlock {
|
|
TParse_TBlock_stringAttribute(const void* pData) : TParse_TBlock(pData) {}
|
|
|
|
char* getContent() const { return (char*)getRaw() + 0x8; }
|
|
};
|
|
|
|
inline u16 getTagCode(u32 tag) { return tag & 0xFFFF; }
|
|
inline u8 getTagGroup(u32 tag) { return (tag >> 0x10) & 0xFF; }
|
|
|
|
} // namespace data
|
|
} // namespace JMessage
|
|
|
|
#endif /* JMESSAGE_DATA_H */
|