tp/src/d/d_msg_unit.cpp

162 lines
5.5 KiB
C++

//
// Generated By: dol2asm
// Translation Unit: d/d_msg_unit
//
#include "d/dolzel.h"
#include "d/d_msg_unit.h"
#include "d/d_com_inf_game.h"
#include "stdio.h"
#include "d/d_kankyo.h"
#include "d/d_meter2_info.h"
// temporary until a better solution is found
typedef struct dMsgUnit_inf1_entry {
u32 dat1EntryOffset;
u16 startFrame;
u16 endFrame;
} dMsgUnit_inf1_entry;
typedef struct dMsgUnit_inf1_section_t {
/* 0x00 */ u32 msgType; // sectionType
/* 0x04 */ u32 size; // total size of the section
/* 0x08 */ u16 entryCount;
/* 0x0A */ u16 entryLength;
/* 0x0C */ u16 msgArchiveId;
/* 0x0E */ dMsgUnit_inf1_entry entries[0];
} dMsgUnit_inf1_section_t;
/* 80238C94-80238CA4 2335D4 0010+00 1/1 0/0 0/0 .text __ct__10dMsgUnit_cFv */
dMsgUnit_c::dMsgUnit_c() {}
/* 80238CA4-80238CEC 2335E4 0048+00 2/1 0/0 0/0 .text __dt__10dMsgUnit_cFv */
dMsgUnit_c::~dMsgUnit_c() {}
/* 80238CEC-8023907C 23362C 0390+00 0/0 5/5 0/0 .text setTag__10dMsgUnit_cFiiPcb */
// NONMATCHING - regalloc
void dMsgUnit_c::setTag(int i_type, int i_value, char* o_buffer, bool param_4) {
*o_buffer = 0;
bool stack9 = false;
bool stack8 = false;
int param_2b = i_value;
if (i_type == 0x10000) {
sprintf(o_buffer, "%d", i_value);
} else if (i_type == 0x10001) {
int tens_digit = i_value / 10;
int ones_digit = i_value % 10;
sprintf(o_buffer, "%d-%d", tens_digit, ones_digit);
} else if (i_type == 4 && param_4 == true) {
int seconds = i_value / 1000;
int minutes = seconds / 60;
seconds -= minutes * 60;
if (minutes > 99) {
minutes = 99;
seconds = 59;
}
if (minutes != 0 || seconds != 0) {
sprintf(o_buffer, "%d:%02d", minutes, seconds);
}
} else if (i_type == 3 && param_4 == true) {
f32 iVar8b;
f32 dayTime = g_env_light.getDaytime();
f32 hour = dayTime / 15.0f;
iVar8b = ((s32)(1000000.0f * dayTime) % 15000000) / 1000000.0f;
f32 minute = 60.0f * (iVar8b / 15.0f);
iVar8b = ((s32)(1000000.0f * dayTime) % 250000) / 1000000.0f;
f32 iVar9 = 60.0f * (iVar8b / 0.25f);
sprintf(o_buffer, "%d:%02d", (s32)hour, (s32)minute);
} else {
if (i_type == 9 && param_4 == true) {
int value = i_value;
sprintf(o_buffer, "%d", value);
stack8 = true;
}
if (!stack9) {
bmg_header_t* pHeader = (bmg_header_t*)dMeter2Info_getMsgUnitResource();
dMsgUnit_inf1_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);
for (; filepos < filesize; filepos += pSection->size) {
switch(pSection->magic) {
case 'FLW1':
break;
case 'FLI1':
break;
case 'INF1':
pInfoBlock = (dMsgUnit_inf1_section_t*)pSection;
break;
case 'DAT1':
pMsgDataBlock = pSection;
break;
case 'STR1':
pStrAttributeBlock = (str1_section_t*)pSection;
break;
}
pSection = (bmg_section_t*)((u8*)pSection + 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.
#ifdef DEBUG
dMsgUnit_inf1_entry* entry = &pInfoBlock->entries[i_type];
u32 dat1EntryOffset = entry->dat1EntryOffset;
u16 startFrame = entry->startFrame;
u16 endFrame = entry->endFrame;
const char* entriesStr = pStrAttributeBlock->entries->str;
#else
u16 startFrame = pInfoBlock->entries[i_type].startFrame;
u16 endFrame = pInfoBlock->entries[i_type].endFrame;
const char* entriesStr;
#endif
const char* uVar5;
if (i_value == 1
#ifdef DEBUG
|| (dComIfGs_getPalLanguage() == 3 && i_value == 0)
#endif
) {
#ifdef DEBUG
uVar5 = entriesStr + endFrame;
} else {
uVar5 = entriesStr + startFrame;
#else
uVar5 = pStrAttributeBlock->entries->str + endFrame;
} else {
uVar5 = pStrAttributeBlock->entries->str + startFrame;
#endif
}
if (strcmp(uVar5, "") == 0) {
sprintf(o_buffer, "%d%s", i_value, uVar5);
} else {
sprintf(o_buffer, "%d %s", i_value, uVar5);
}
}
if (i_type == 3 && param_4 == true) {
char buffer[20];
setTag(4, 0, buffer, false);
strcat(o_buffer, buffer);
}
if (i_type == 4 && param_4 == true) {
char buffer[20];
setTag(5, param_2b, buffer, false);
strcat(o_buffer, buffer);
}
}
}
/* 804510D0-804510D8 0005D0 0004+04 1/1 5/5 0/0 .sbss g_msg_unit */
dMsgUnit_c g_msg_unit;