summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Roncace <me@caseif.net>2025-11-22 21:40:49 -0500
committerGitHub <noreply@github.com>2025-11-22 18:40:49 -0800
commit24c1bf1723facc75b841ef68d523573797efb445 (patch)
treea6c86b614160acfb346a153f704feb1ebe1f33cb /src
parent5dce13b8c6b4ea0ffa0650f273154dbaf1cc4d15 (diff)
Clean up d_msg_unit, misc fixes for PAL and JPN (#2848)
Diffstat (limited to 'src')
-rw-r--r--src/d/actor/d_a_mg_rod.cpp12
-rw-r--r--src/d/d_menu_collect.cpp85
-rw-r--r--src/d/d_msg_object.cpp8
-rw-r--r--src/d/d_msg_unit.cpp128
-rw-r--r--src/m_Do/m_Do_ext.cpp9
5 files changed, 185 insertions, 57 deletions
diff --git a/src/d/actor/d_a_mg_rod.cpp b/src/d/actor/d_a_mg_rod.cpp
index ff3bf2fdae..d844107206 100644
--- a/src/d/actor/d_a_mg_rod.cpp
+++ b/src/d/actor/d_a_mg_rod.cpp
@@ -5720,12 +5720,16 @@ static int dmg_rod_Execute(dmg_rod_class* i_this) {
} else {
data_804BBBD4 = 0;
}
- #elif VERSION == VERSION_GCN_PAL
+ #elif VERSION == VERSION_SHIELD
+ data_804BBBD4 = 0;
+ #elif REGION_PAL
if (dComIfGs_getPalLanguage() == 0) {
data_804BBBD4 = 2;
} else {
data_804BBBD4 = 0;
}
+ #elif REGION_JPN
+ data_804BBBD4 = 0;
#else
data_804BBBD4 = 1;
#endif
@@ -6283,12 +6287,16 @@ static int dmg_rod_Create(fopAc_ac_c* i_this) {
} else {
data_804BBBD4 = 0;
}
- #elif VERSION == VERSION_GCN_PAL
+ #elif VERSION == VERSION_SHIELD
+ data_804BBBD4 = 0;
+ #elif REGION_PAL
if (dComIfGs_getPalLanguage() == 0) {
data_804BBBD4 = 2;
} else {
data_804BBBD4 = 0;
}
+ #elif REGION_JPN
+ data_804BBBD4 = 0;
#else
data_804BBBD4 = 1;
#endif
diff --git a/src/d/d_menu_collect.cpp b/src/d/d_menu_collect.cpp
index 9d84c4a134..f82896114b 100644
--- a/src/d/d_menu_collect.cpp
+++ b/src/d/d_menu_collect.cpp
@@ -273,13 +273,33 @@ void dMenu_Collect2D_c::screenSet() {
static const u64 text_a_tag[5] = {'atext1_1', 'atext1_2', 'atext1_3', 'atext1_4', 'atext1_5'};
static const u64 text_b_tag[5] = {'btext1_1', 'btext1_2', 'btext1_3', 'btext1_4', 'btext1_5'};
+#if REGION_JPN
+ static_cast<J2DTextBox*>(mpScreen->search('t_t00'))->setFont(mDoExt_getRubyFont());
+ static_cast<J2DTextBox*>(mpScreen->search('t_t00'))->setString(0x20, "");
+ dMeter2Info_getStringKanji(
+ 0x3E1, static_cast<J2DTextBox*>(mpScreen->search('t_t00'))->getStringPtr(), NULL);
+ mpScreen->search('f_t00')->hide();
+#else
static_cast<J2DTextBox*>(mpScreen->search('f_t00'))->setFont(mDoExt_getRubyFont());
static_cast<J2DTextBox*>(mpScreen->search('f_t00'))->setString(0x20, "");
dMeter2Info_getStringKanji(
0x3E1, static_cast<J2DTextBox*>(mpScreen->search('f_t00'))->getStringPtr(), NULL);
mpScreen->search('t_t00')->hide();
+#endif
for (int i = 0; i < 3; i++) {
+#if REGION_JPN
+ static_cast<J2DTextBox*>(mpScreen->search(text_sv[i]))->setFont(mDoExt_getMesgFont());
+ static_cast<J2DTextBox*>(mpScreen->search(text_op[i]))->setFont(mDoExt_getMesgFont());
+ static_cast<J2DTextBox*>(mpScreen->search(text_sv[i]))->setString(0x20, "");
+ static_cast<J2DTextBox*>(mpScreen->search(text_op[i]))->setString(0x20, "");
+ dMeter2Info_getStringKanji(
+ 0x60, static_cast<J2DTextBox*>(mpScreen->search(text_sv[i]))->getStringPtr(), NULL);
+ dMeter2Info_getStringKanji(
+ 0x5F, static_cast<J2DTextBox*>(mpScreen->search(text_op[i]))->getStringPtr(), NULL);
+ mpScreen->search(ftext_sv[i])->hide();
+ mpScreen->search(ftext_op[i])->hide();
+#else
static_cast<J2DTextBox*>(mpScreen->search(ftext_sv[i]))->setFont(mDoExt_getMesgFont());
static_cast<J2DTextBox*>(mpScreen->search(ftext_op[i]))->setFont(mDoExt_getMesgFont());
static_cast<J2DTextBox*>(mpScreen->search(ftext_sv[i]))->setString(0x20, "");
@@ -290,6 +310,7 @@ void dMenu_Collect2D_c::screenSet() {
0x5F, static_cast<J2DTextBox*>(mpScreen->search(ftext_op[i]))->getStringPtr(), NULL);
mpScreen->search(text_sv[i])->hide();
mpScreen->search(text_op[i])->hide();
+#endif
}
for (int i = 0; i < 5; i++) {
@@ -301,6 +322,27 @@ void dMenu_Collect2D_c::screenSet() {
static_cast<J2DTextBox*>(mpScreenIcon->search(text_b_tag[i]))->setString(0x20, "");
}
+#if REGION_JPN
+ static_cast<J2DTextBox*>(mpScreen->search('item_n00'))->setFont(mDoExt_getMesgFont());
+ static_cast<J2DTextBox*>(mpScreen->search('item_n01'))->setFont(mDoExt_getMesgFont());
+ static_cast<J2DTextBox*>(mpScreen->search('item_n02'))->setFont(mDoExt_getMesgFont());
+ static_cast<J2DTextBox*>(mpScreen->search('item_n03'))->setFont(mDoExt_getMesgFont());
+ static_cast<J2DTextBox*>(mpScreen->search('item_n00'))->setString(0x20, "");
+ static_cast<J2DTextBox*>(mpScreen->search('item_n01'))->setString(0x20, "");
+ static_cast<J2DTextBox*>(mpScreen->search('item_n02'))->setString(0x20, "");
+ static_cast<J2DTextBox*>(mpScreen->search('item_n03'))->setString(0x20, "");
+ static_cast<J2DTextBox*>(mpScreen->search('i_text1'))->setFont(mDoExt_getMesgFont());
+ static_cast<J2DTextBox*>(mpScreen->search('i_text0'))->setFont(mDoExt_getMesgFont());
+ static_cast<J2DTextBox*>(mpScreen->search('i_text1'))->setString(0x100, "");
+ static_cast<J2DTextBox*>(mpScreen->search('i_text0'))->setString(0x100, "");
+
+ mpScreen->search('item_n04')->hide();
+ mpScreen->search('item_n05')->hide();
+ mpScreen->search('item_n06')->hide();
+ mpScreen->search('item_n07')->hide();
+ mpScreen->search('f_text1')->hide();
+ mpScreen->search('f_text0')->hide();
+#else
static_cast<J2DTextBox*>(mpScreen->search('item_n04'))->setFont(mDoExt_getMesgFont());
static_cast<J2DTextBox*>(mpScreen->search('item_n05'))->setFont(mDoExt_getMesgFont());
static_cast<J2DTextBox*>(mpScreen->search('item_n06'))->setFont(mDoExt_getMesgFont());
@@ -320,6 +362,7 @@ void dMenu_Collect2D_c::screenSet() {
mpScreen->search('item_n03')->hide();
mpScreen->search('i_text1')->hide();
mpScreen->search('i_text0')->hide();
+#endif
field_0x22d[0][0] = 0;
field_0x22d[1][0] = 0;
@@ -2072,19 +2115,39 @@ void dMenu_Collect2D_c::_draw() {
mpScreen->draw(0.0f, 0.0f, grafPort);
if (mItemNameString == 0) {
+#if REGION_JPN
+ char* stringPtr1 = static_cast<J2DTextBox*>(mpScreen->search('i_text1'))->getStringPtr();
+#else
char* stringPtr1 = static_cast<J2DTextBox*>(mpScreen->search('f_text1'))->getStringPtr();
+#endif
strcpy(stringPtr1, "");
+#if REGION_JPN
+ char* stringPtr0 = static_cast<J2DTextBox*>(mpScreen->search('i_text0'))->getStringPtr();
+#else
char* stringPtr0 = static_cast<J2DTextBox*>(mpScreen->search('f_text0'))->getStringPtr();
+#endif
strcpy(stringPtr0, "");
} else {
+#if REGION_JPN
+ J2DTextBox* textBox1 = static_cast<J2DTextBox*>(mpScreen->search('i_text1'));
+#else
J2DTextBox* textBox1 = static_cast<J2DTextBox*>(mpScreen->search('f_text1'));
+#endif
mpString->getString(mItemNameString, textBox1, NULL, NULL, NULL, 0);
+#if REGION_JPN
+ J2DTextBox* textBox0 = static_cast<J2DTextBox*>(mpScreen->search('i_text0'));
+#else
J2DTextBox* textBox0 = static_cast<J2DTextBox*>(mpScreen->search('f_text0'));
+#endif
mpString->getString(mItemNameString, textBox0, NULL, NULL, NULL, 0);
+#if REGION_JPN
+ textBox0 = static_cast<J2DTextBox*>(mpScreen->search('i_text0'));
+#else
textBox0 = static_cast<J2DTextBox*>(mpScreen->search('f_text0'));
+#endif
mpString->drawOutFontLocal(textBox0, -1.0f);
}
mpDrawCursor->draw();
@@ -2174,6 +2237,17 @@ void dMenu_Collect2D_c::setItemNameString(u8 param_0, u8 param_1) {
if (uVar6 == 0) {
setItemNameStringNull();
} else {
+#if REGION_JPN
+ char* stringPtr =
+ static_cast<J2DTextBox*>(mpScreen->search('item_n00'))->getStringPtr();
+ dMeter2Info_getStringKanji(uVar6, stringPtr, NULL);
+ stringPtr = static_cast<J2DTextBox*>(mpScreen->search('item_n01'))->getStringPtr();
+ dMeter2Info_getStringKanji(uVar6, stringPtr, NULL);
+ stringPtr = static_cast<J2DTextBox*>(mpScreen->search('item_n02'))->getStringPtr();
+ dMeter2Info_getStringKanji(uVar6, stringPtr, NULL);
+ stringPtr = static_cast<J2DTextBox*>(mpScreen->search('item_n03'))->getStringPtr();
+ dMeter2Info_getStringKanji(uVar6, stringPtr, NULL);
+#else
char* stringPtr =
static_cast<J2DTextBox*>(mpScreen->search('item_n04'))->getStringPtr();
dMeter2Info_getStringKanji(uVar6, stringPtr, NULL);
@@ -2183,6 +2257,7 @@ void dMenu_Collect2D_c::setItemNameString(u8 param_0, u8 param_1) {
dMeter2Info_getStringKanji(uVar6, stringPtr, NULL);
stringPtr = static_cast<J2DTextBox*>(mpScreen->search('item_n07'))->getStringPtr();
dMeter2Info_getStringKanji(uVar6, stringPtr, NULL);
+#endif
}
}
}
@@ -2191,6 +2266,15 @@ void dMenu_Collect2D_c::setItemNameString(u8 param_0, u8 param_1) {
*/
void dMenu_Collect2D_c::setItemNameStringNull() {
mItemNameString = 0;
+#if REGION_JPN
+ J2DTextBox* textBox = (J2DTextBox*)mpScreen->search('item_n00');
+ strcpy(textBox->getStringPtr(), "");
+ textBox = (J2DTextBox*)mpScreen->search('item_n01');
+ strcpy(textBox->getStringPtr(), "");
+ textBox = (J2DTextBox*)mpScreen->search('item_n02');
+ strcpy(textBox->getStringPtr(), "");
+ textBox = (J2DTextBox*)mpScreen->search('item_n03');
+#else
J2DTextBox* textBox = (J2DTextBox*)mpScreen->search('item_n04');
strcpy(textBox->getStringPtr(), "");
textBox = (J2DTextBox*)mpScreen->search('item_n05');
@@ -2198,6 +2282,7 @@ void dMenu_Collect2D_c::setItemNameStringNull() {
textBox = (J2DTextBox*)mpScreen->search('item_n06');
strcpy(textBox->getStringPtr(), "");
textBox = (J2DTextBox*)mpScreen->search('item_n07');
+#endif
strcpy(textBox->getStringPtr(), "");
}
diff --git a/src/d/d_msg_object.cpp b/src/d/d_msg_object.cpp
index 98cb3cf055..f421607502 100644
--- a/src/d/d_msg_object.cpp
+++ b/src/d/d_msg_object.cpp
@@ -134,7 +134,11 @@ dMsgObject_HIO_c::dMsgObject_HIO_c() {
mBoxMidnaHaloAlpha = 1.0f;
mBoxWolfHaloAlpha = 0.3f;
mBoxTalkHaloAlpha = 1.0f;
+#if REGION_JPN
+ mBoxTalkScaleX = 1.1f;
+#else
mBoxTalkScaleX = 1.2f;
+#endif
mBoxNaviScaleX = 1.0f;
mBoxMidnaScaleX = 1.0f;
mBoxItemScaleX = 1.05f;
@@ -1652,7 +1656,7 @@ void dMsgObject_c::readMessageGroupLocal(mDoDvdThd_mountXArchive_c** p_arcMount)
static char arcName[22];
int msgGroup = dStage_stagInfo_GetMsgGroup(dComIfGp_getStage()->getStagInfo());
- #if VERSION == VERSION_GCN_PAL
+ #if REGION_PAL
switch (dComIfGs_getPalLanguage()) {
case dSv_player_config_c::LANGAUGE_GERMAN:
sprintf(arcName, "/res/Msgde/bmgres%d.arc", msgGroup);
@@ -1669,6 +1673,8 @@ void dMsgObject_c::readMessageGroupLocal(mDoDvdThd_mountXArchive_c** p_arcMount)
default:
sprintf(arcName, "/res/Msguk/bmgres%d.arc", msgGroup);
}
+ #elif REGION_JPN
+ sprintf(arcName, "/res/Msgjp/bmgres%d.arc", msgGroup);
#else
sprintf(arcName, "/res/Msgus/bmgres%d.arc", msgGroup);
#endif
diff --git a/src/d/d_msg_unit.cpp b/src/d/d_msg_unit.cpp
index d816398ff1..9708ad3316 100644
--- a/src/d/d_msg_unit.cpp
+++ b/src/d/d_msg_unit.cpp
@@ -219,17 +219,27 @@ 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;
+ int param_2b = i_value; // sp40
+ int tens_digit; // sp3C
+ int ones_digit; // sp38
+ int seconds; // r27
+ int minutes; // sp34
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;
+ return;
+ }
+
+ if (i_type == 0x10001) {
+ tens_digit = i_value / 10;
+ 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;
+ return;
+ }
+
+ if (i_type == 4 && param_4 == true) {
+ seconds = i_value / 1000;
+ minutes = seconds / 60;
seconds -= minutes * 60;
if (minutes > 99) {
minutes = 99;
@@ -238,7 +248,12 @@ void dMsgUnit_c::setTag(int i_type, int i_value, char* o_buffer, bool param_4) {
if (minutes != 0 || seconds != 0) {
sprintf(o_buffer, "%d:%02d", minutes, seconds);
}
- } else if (i_type == 3 && param_4 == true) {
+
+ return;
+ }
+
+ 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;
@@ -266,20 +281,20 @@ void dMsgUnit_c::setTag(int i_type, int i_value, char* o_buffer, bool param_4) {
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;
+ 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);
}
@@ -287,39 +302,45 @@ void dMsgUnit_c::setTag(int i_type, int i_value, char* o_buffer, bool param_4) {
// 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
-
+#ifdef DEBUG
+ dMsgUnit_inf1_entry* entriesInf = &pInfoBlock->entries[i_type];
+ u32 dat1EntryOffset = entriesInf->dat1EntryOffset;
const char* uVar5;
- if (i_value == 1
- #ifdef DEBUG
- || (dComIfGs_getPalLanguage() == dSv_player_config_c::LANGAUGE_SPANISH && i_value == 0)
- #elif VERSION == VERSION_GCN_PAL
- || (dComIfGs_getPalLanguage() == dSv_player_config_c::LANGAUGE_FRENCH && i_value == 0)
- #endif
- ) {
- #ifdef DEBUG
- uVar5 = entriesStr + endFrame;
- } else {
- uVar5 = entriesStr + startFrame;
- #elif VERSION == VERSION_GCN_PAL
- uVar5 = pStrAttributeBlock->entries->str + startFrame;
- } else {
- uVar5 = pStrAttributeBlock->entries->str + endFrame;
- #else
- uVar5 = pStrAttributeBlock->entries->str + endFrame;
+ 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;
+ const char* uVar5;
+ u16 vals[14];
+ vals[0] = pInfoBlock->entries[i_type].startFrame;
+ vals[1] = pInfoBlock->entries[i_type].endFrame;
+#endif
+
+#if REGION_PAL
+ if (i_value == 1 ||
+ (dComIfGs_getPalLanguage() == dSv_player_config_c::LANGAUGE_FRENCH &&
+ i_value == 0)) {
+#elif !REGION_USA
+ if (i_value == 1 ||
+ (dComIfGs_getPalLanguage() == dSv_player_config_c::LANGAUGE_SPANISH &&
+ i_value == 0)) {
+#else
+ if (i_value == 1) {
+#endif
+#ifdef DEBUG
+ uVar5 = entriesStr->str + vals[0];
+#else
+ uVar5 = pStrAttributeBlock->entries->str + vals[0];
+#endif
} else {
- uVar5 = pStrAttributeBlock->entries->str + startFrame;
- #endif
+#ifdef DEBUG
+ uVar5 = entriesStr->str + vals[1];
+#else
+ uVar5 = pStrAttributeBlock->entries->str + vals[1];
+#endif
}
if (strcmp(uVar5, "") == 0) {
@@ -328,7 +349,6 @@ void dMsgUnit_c::setTag(int i_type, int i_value, char* o_buffer, bool param_4) {
sprintf(o_buffer, "%d %s", i_value, uVar5);
}
}
-
if (i_type == 3 && param_4 == true) {
char buffer[20];
setTag(4, 0, buffer, false);
diff --git a/src/m_Do/m_Do_ext.cpp b/src/m_Do/m_Do_ext.cpp
index 132edace67..3b23d8abd0 100644
--- a/src/m_Do/m_Do_ext.cpp
+++ b/src/m_Do/m_Do_ext.cpp
@@ -3540,8 +3540,13 @@ static ResFONT* mDoExt_resfont0;
/* 80014994-800149F0 00F2D4 005C+00 1/1 0/0 0/0 .text mDoExt_initFont0__Fv */
static void mDoExt_initFont0() {
static char const fontdata[] = "rodan_b_24_22.bfn";
+#if REGION_JPN
+ mDoExt_initFontCommon(&mDoExt_font0, &mDoExt_resfont0, mDoExt_getZeldaHeap(),
+ fontdata, dComIfGp_getFontArchive(), 0, 200, 512);
+#else
mDoExt_initFontCommon(&mDoExt_font0, &mDoExt_resfont0, mDoExt_getZeldaHeap(),
fontdata, dComIfGp_getFontArchive(), 1, 0, 0);
+#endif
}
/* 800149F0-80014A2C 00F330 003C+00 0/0 51/51 2/2 .text mDoExt_getMesgFont__Fv */
@@ -3564,7 +3569,11 @@ void mDoExt_removeMesgFont() {
delete mDoExt_font0;
mDoExt_font0 = NULL;
if (mDoExt_resfont0 != NULL) {
+#if REGION_JPN
+ JKRFileLoader::removeResource(mDoExt_resfont0, NULL);
+#else
JKRFree(mDoExt_resfont0);
+#endif
mDoExt_resfont0 = NULL;
}
}