Match dMsgUnit_c::setTag (#2974)

* Match dMsgUnit_c::setTag for GCN USA

Co-authored-by: Cuyler36 <Cuyler36@users.noreply.github.com>

* Match dMsgUnit_c::setTag for debug

* Minor cleanup

---------

Co-authored-by: Cuyler36 <Cuyler36@users.noreply.github.com>
This commit is contained in:
LagoLunatic 2025-12-20 02:00:17 -05:00 committed by GitHub
parent 0395053737
commit 917d93664d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 15 deletions

View File

@ -825,7 +825,7 @@ config.libs = [
Object(MatchingFor(ALL_GCN), "d/d_msg_out_font.cpp"),
Object(MatchingFor(ALL_GCN), "d/d_msg_class.cpp"),
Object(Equivalent, "d/d_msg_object.cpp"), # weak func order
Object(MatchingFor("GZ2P01", "GZ2J01"), "d/d_msg_unit.cpp"),
Object(MatchingFor(ALL_GCN), "d/d_msg_unit.cpp"),
Object(MatchingFor(ALL_GCN), "d/d_msg_scrn_3select.cpp"),
Object(MatchingFor(ALL_GCN), "d/d_msg_scrn_arrow.cpp"),
Object(MatchingFor(ALL_GCN), "d/d_msg_scrn_base.cpp"),

View File

@ -33,14 +33,13 @@ typedef struct dMsgUnit_inf1_section_t {
/* 0x08 */ u16 entryCount;
/* 0x0A */ u16 entryLength;
/* 0x0C */ u16 msgArchiveId;
/* 0x0E */ dMsgUnit_inf1_entry entries[0];
/* 0x10 */ dMsgUnit_inf1_entry entries[0];
} dMsgUnit_inf1_section_t;
dMsgUnit_c::dMsgUnit_c() {}
dMsgUnit_c::~dMsgUnit_c() {}
// NONMATCHING - regalloc
#if REGION_JPN
void dMsgUnit_c::setTag(int i_type, int i_value, char* o_buffer, bool param_4) {
*o_buffer = 0;
@ -245,7 +244,6 @@ void dMsgUnit_c::setTag(int i_type, int i_value, char* o_buffer, bool param_4) {
}
if (i_type == 3 && param_4 == true) {
(void)seconds; // dummy use to force into register instead of stack
f32 iVar8b;
f32 dayTime = g_env_light.getDaytime();
f32 hour = dayTime / 15.0f;
@ -265,21 +263,21 @@ void dMsgUnit_c::setTag(int i_type, int i_value, char* o_buffer, bool param_4) {
if (!stack9) {
bmg_header_t* pHeader = (bmg_header_t*)dMeter2Info_getMsgUnitResource();
dMsgUnit_inf1_section_t* pInfoBlock = NULL;
bmg_section_t* pInfoBlock = NULL;
const void* pMsgDataBlock = NULL;
str1_section_t* pStrAttributeBlock = NULL;
int filepos = sizeof(bmg_header_t);
u32 filesize = pHeader->size;
bmg_section_t* pSection = (bmg_section_t*)(((u8*)pHeader) + filepos);
u8* pSection = ((u8*)pHeader) + filepos;
for (; filepos < filesize; filepos += pSection->size) {
switch (pSection->magic) {
for (; filepos < filesize; filepos += ((bmg_section_t*)pSection)->size) {
switch (((bmg_section_t*)pSection)->magic) {
case 'FLW1':
break;
case 'FLI1':
break;
case 'INF1':
pInfoBlock = (dMsgUnit_inf1_section_t*)pSection;
pInfoBlock = (bmg_section_t*)pSection;
break;
case 'DAT1':
pMsgDataBlock = pSection;
@ -288,27 +286,26 @@ void dMsgUnit_c::setTag(int i_type, int i_value, char* o_buffer, bool param_4) {
pStrAttributeBlock = (str1_section_t*)pSection;
break;
}
pSection = (bmg_section_t*)((u8*)pSection + pSection->size);
pSection += ((bmg_section_t*)pSection)->size;
}
// This section is weird. The debug seems like entriesStr is outside the condition
// but the normal build doesn't really work with that. Same for pInfoBlock->entries.
#if DEBUG
dMsgUnit_inf1_entry* entriesInf = &pInfoBlock->entries[i_type];
dMsgUnit_inf1_entry* entriesInf = &((dMsgUnit_inf1_section_t*)pInfoBlock)->entries[i_type];
u32 dat1EntryOffset = entriesInf->dat1EntryOffset;
const char* uVar5;
u16 vals[14];
vals[0] = entriesInf->startFrame;
vals[1] = entriesInf->endFrame;
(void)entriesInf; // dummy use to force into register instead of stack
str1_entry_t* entriesStr = pStrAttributeBlock->entries;
#else
u32 dat1EntryOffset = pInfoBlock->entries[i_type].dat1EntryOffset;
u32 dat1EntryOffset = ((dMsgUnit_inf1_section_t*)pInfoBlock)->entries[i_type].dat1EntryOffset;
const char* uVar5;
u16 vals[14];
vals[0] = pInfoBlock->entries[i_type].startFrame;
vals[1] = pInfoBlock->entries[i_type].endFrame;
vals[0] = ((dMsgUnit_inf1_section_t*)pInfoBlock)->entries[i_type].startFrame;
vals[1] = ((dMsgUnit_inf1_section_t*)pInfoBlock)->entries[i_type].endFrame;
#endif
#if REGION_PAL