diff --git a/include/d/d_msg_class.h b/include/d/d_msg_class.h index 4d4b6700b6..d1478f6b43 100644 --- a/include/d/d_msg_class.h +++ b/include/d/d_msg_class.h @@ -4,6 +4,7 @@ #include "JSystem/JMessage/control.h" #include "JSystem/JMessage/JMessage.h" #include "SSystem/SComponent/c_xyz.h" +#include "dusk/endian.h" #if REGION_JPN #define D_MSG_CLASS_PAGE_CNT_MAX 30 @@ -38,8 +39,8 @@ public: class JMSMesgInfo_c { public: /* 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 + /* 0x08 */ BE(u16) entry_num; // number of entries in this section + /* 0x0A */ BE(u16) entry_size; // size of an entry /* 0x0C */ u8 padding[4]; // padding /* 0x10 */ JMSMesgEntry_c entries[0]; }; diff --git a/libs/JSystem/include/JSystem/JMessage/JMessage.h b/libs/JSystem/include/JSystem/JMessage/JMessage.h index dee1ada133..0b3d1c64c8 100644 --- a/libs/JSystem/include/JSystem/JMessage/JMessage.h +++ b/libs/JSystem/include/JSystem/JMessage/JMessage.h @@ -6,30 +6,31 @@ #else #include #endif +#include "dusk/endian.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 + /* 0x08 */ BE(u32) size; // total size of file not including FLW1/FLI1 sections + /* 0x0C */ BE(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 + /* 0x0 */ BE(u32) magic; // four character magic string + /* 0x4 */ BE(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 + /* 0x0 */ BE(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 + /* 0x08 */ BE(u16) entry_num; // number of entries in this section + /* 0x0A */ BE(u16) entry_size; // size of an entry /* 0x0C */ u8 padding[4]; // padding } inf1_section_t; diff --git a/src/d/d_meter2_info.cpp b/src/d/d_meter2_info.cpp index dba0acf6fb..a0963a31a5 100644 --- a/src/d/d_meter2_info.cpp +++ b/src/d/d_meter2_info.cpp @@ -369,8 +369,8 @@ void dMeter2Info_c::getString(u32 i_stringID, char* o_string, JMSMesgEntry_c* i_ u8* entry = ((u8*)bmg_inf + (i * sizeof(JMSMesgEntry_c))); // check if i_stringID equals the message entry "Message ID" - if (i_stringID == *(u16*)(entry + 0x14)) { - string_ptr = (char*)(bmg_data + *(u32*)(entry + 0x10)); // use entry "String Offset" to get string pointer + if (i_stringID == *(BE(u16)*)(entry + 0x14)) { + string_ptr = (char*)(bmg_data + *(BE(u32)*)(entry + 0x10)); // use entry "String Offset" to get string pointer strcpy(o_string, string_ptr); if (i_msgEntry != NULL) {