mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-05-26 15:24:30 -04:00
3af421d7b6
* d_meter2_info cleanup * parseBlock_next matching
152 lines
5.3 KiB
C++
152 lines
5.3 KiB
C++
//
|
|
// Generated By: dol2asm
|
|
// Translation Unit: d/d_msg_unit
|
|
//
|
|
|
|
#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 param_1, int param_2, char* param_3, bool param_4) {
|
|
*param_3 = 0;
|
|
bool stack9 = false;
|
|
bool stack8 = false;
|
|
int param_2b = param_2;
|
|
if (param_1 == 0x10000) {
|
|
sprintf(param_3, "%d", param_2);
|
|
} else if (param_1 == 0x10001) {
|
|
int tens_digit = param_2 / 10;
|
|
int ones_digit = param_2 % 10;
|
|
sprintf(param_3, "%d-%d", tens_digit, ones_digit);
|
|
} else if (param_1 == 4 && param_4 == true) {
|
|
int r6 = param_2 / 1000;
|
|
int r5 = r6 / 60;
|
|
r6 -= r5 * 60;
|
|
if (r5 > 99) {
|
|
r5 = 99;
|
|
r6 = 59;
|
|
}
|
|
if (r5 != 0 || r6 != 0) {
|
|
sprintf(param_3, "%d:%02d", r5, r6);
|
|
}
|
|
} else if (param_1 == 3 && param_4 == true) {
|
|
f32 iVar8b;
|
|
f32 dayTime = g_env_light.getDaytime();
|
|
f32 fVar1 = dayTime / 15.0f;
|
|
iVar8b = ((s32)(1000000.0f * dayTime) % 15000000) / 1000000.0f;
|
|
f32 iVar8c = 60.0f * (iVar8b / 15.0f);
|
|
iVar8b = ((s32)(1000000.0f * dayTime) % 250000) / 1000000.0f;
|
|
f32 iVar9 = 60.0f * (iVar8b / 0.25f);
|
|
sprintf(param_3, "%d:%02d", (s32)(fVar1), (s32)iVar8c);
|
|
} else {
|
|
if (param_1 == 9 && param_4 == true) {
|
|
int param_2c = param_2;
|
|
sprintf(param_3, "%d", param_2c);
|
|
stack8 = true;
|
|
}
|
|
|
|
if (!stack9) {
|
|
bmg_header_t* iVar9 = (bmg_header_t*)dMeter2Info_getMsgUnitResource();
|
|
dMsgUnit_inf1_section_t* inf1 = NULL;
|
|
const void* dat1 = NULL;
|
|
str1_section_t* str1 = NULL;
|
|
int local_114 = sizeof(bmg_header_t);
|
|
u32 size = iVar9->size;
|
|
bmg_section_t* piVar12 = (bmg_section_t*)(((u8*)iVar9) + local_114);
|
|
for (; local_114 < size; local_114 += piVar12->size) {
|
|
switch(piVar12->magic) {
|
|
case 'FLW1':
|
|
break;
|
|
case 'FLI1':
|
|
break;
|
|
case 'INF1':
|
|
inf1 = (dMsgUnit_inf1_section_t*)piVar12;
|
|
break;
|
|
case 'DAT1':
|
|
dat1 = piVar12;
|
|
break;
|
|
case 'STR1':
|
|
str1 = (str1_section_t*)piVar12;
|
|
break;
|
|
}
|
|
piVar12 = (bmg_section_t*)((u8*)piVar12 + piVar12->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 inf1->entries.
|
|
|
|
#ifdef DEBUG
|
|
dMsgUnit_inf1_entry* entry = &inf1->entries[param_1];
|
|
u32 dat1EntryOffset = entry->dat1EntryOffset;
|
|
u16 startFrame = entry->startFrame;
|
|
u16 endFrame = entry->endFrame;
|
|
const char* entriesStr = str1->entries->str;
|
|
#else
|
|
u16 startFrame = inf1->entries[param_1].startFrame;
|
|
u16 endFrame = inf1->entries[param_1].endFrame;
|
|
const char* entriesStr;
|
|
#endif
|
|
const char* uVar5;
|
|
if (param_2 == 1
|
|
#ifdef DEBUG
|
|
|| (dComIfGs_getPalLanguage() == 3 && param_2 == 0)
|
|
#endif
|
|
) {
|
|
#ifdef DEBUG
|
|
uVar5 = entriesStr + endFrame;
|
|
} else {
|
|
uVar5 = entriesStr + startFrame;
|
|
#else
|
|
uVar5 = str1->entries->str + endFrame;
|
|
} else {
|
|
uVar5 = str1->entries->str + startFrame;
|
|
#endif
|
|
}
|
|
if (strcmp(uVar5, "") == 0) {
|
|
sprintf(param_3, "%d%s", param_2, uVar5);
|
|
} else {
|
|
sprintf(param_3, "%d %s", param_2, uVar5);
|
|
}
|
|
}
|
|
if (param_1 == 3 && param_4 == true) {
|
|
char acStack_d8[20];
|
|
setTag(4, 0, acStack_d8, false);
|
|
strcat(param_3, acStack_d8);
|
|
}
|
|
if (param_1 == 4 && param_4 == true) {
|
|
char acStack_ec[20];
|
|
setTag(5, param_2b, acStack_ec, false);
|
|
strcat(param_3, acStack_ec);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* 804510D0-804510D8 0005D0 0004+04 1/1 5/5 0/0 .sbss g_msg_unit */
|
|
dMsgUnit_c g_msg_unit;
|