summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrakxo <87568477+Prakxo@users.noreply.github.com>2024-04-03 00:09:06 +0200
committerGitHub <noreply@github.com>2024-04-02 15:09:06 -0700
commit1ffded6b490c23db809aa46c5c186dd8d554b271 (patch)
treee7b151646dc53d793c931f8f60107e1aa112a8d6
parentd8789801b89077422faa376de4bb7f2d564c1103 (diff)
m_string OK (#162)
* m_string OK * replace with defines
-rw-r--r--include/6B3DC0.h2
-rw-r--r--include/6E7AD0.h17
-rw-r--r--include/m_msg_main.h2
-rw-r--r--include/m_string.h19
-rw-r--r--linker_scripts/jp/symbol_addrs_code.txt22
-rw-r--r--src/code/m_npc.c2
-rw-r--r--src/code/m_start_data_init.c2
-rw-r--r--src/code/m_string.c173
-rw-r--r--yamls/jp/code.yaml4
9 files changed, 209 insertions, 34 deletions
diff --git a/include/6B3DC0.h b/include/6B3DC0.h
index 04d1df6..37e5715 100644
--- a/include/6B3DC0.h
+++ b/include/6B3DC0.h
@@ -67,6 +67,6 @@ void func_80091074_jp(struct GraphicsContext* gfxCtx);
// void func_80092468_jp();
// void func_800924CC_jp();
// void func_80092538_jp();
-// void func_8009264C_jp();
+s32 mFont_UnintToString(char*, u32, s32, s32, s32);
#endif
diff --git a/include/6E7AD0.h b/include/6E7AD0.h
deleted file mode 100644
index 00d74f5..0000000
--- a/include/6E7AD0.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef C_6E7AD0_H
-#define C_6E7AD0_H
-
-#include "ultra64.h"
-
-// void func_800C3E30_jp();
-void mString_Load_StringFromRom(char* buffer, s32 buffer_len, s32 arg2);
-// void func_800C4084_jp();
-// void func_800C40F8_jp();
-// void func_800C4168_jp();
-// void func_800C41B8_jp();
-// void func_800C4228_jp();
-// void func_800C42E8_jp();
-// void func_800C4350_jp();
-// void func_800C43B8_jp();
-
-#endif
diff --git a/include/m_msg_main.h b/include/m_msg_main.h
index 2fbefee..fbb49f2 100644
--- a/include/m_msg_main.h
+++ b/include/m_msg_main.h
@@ -76,7 +76,7 @@ void mMsg_Set_mail_str(UNK_PTR arg0, s32 arg1, char* str, s32 size);
// void func_8009E6C4_jp();
// void func_8009E6D4_jp();
// void func_8009E6F8_jp();
-// void func_8009E8D0_jp();
+size_t mMsg_Get_Length_String(char*, s32);
// void func_8009E908_jp();
// void func_8009E94C_jp();
// void func_8009E970_jp();
diff --git a/include/m_string.h b/include/m_string.h
new file mode 100644
index 0000000..f336639
--- /dev/null
+++ b/include/m_string.h
@@ -0,0 +1,19 @@
+#ifndef C_6E7AD0_H
+#define C_6E7AD0_H
+
+#include "ultra64.h"
+#include "lb_rtc.h"
+#include "libc/stdint.h"
+
+void mString_Get_StringDataAddressAndSize(s32 idx, uintptr_t* vramp, size_t* size);
+void mString_Load_StringFromRom(char* dst, s32 dstLen, s32 strIdx);
+s32 mString_Load_YearStringFromRom(char* dst, lbRTC_year_t year);
+s32 mString_Load_MonthStringFromRom(char* dst, lbRTC_month_t month);
+s32 mString_Load_WeekStringFromRom(char* dst, lbRTC_weekday_t weekday);
+s32 mString_Load_DayStringFromRom(char* dst, lbRTC_day_t day);
+s32 mString_Load_HourStringFromRom(char* dst, lbRTC_hour_t hour);
+s32 mString_Load_MinStringFromRom(char* dst, lbRTC_min_t min);
+s32 mString_Load_SecStringFromRom(char* dst, lbRTC_sec_t sec);
+s32 mString_Load_NumberStringAddUnitFromRom(char* dst, u16 num, s32 idx);
+
+#endif
diff --git a/linker_scripts/jp/symbol_addrs_code.txt b/linker_scripts/jp/symbol_addrs_code.txt
index 911175f..cc2d283 100644
--- a/linker_scripts/jp/symbol_addrs_code.txt
+++ b/linker_scripts/jp/symbol_addrs_code.txt
@@ -1587,7 +1587,7 @@ func_80092440_jp = 0x80092440; // type:func
func_80092468_jp = 0x80092468; // type:func
func_800924CC_jp = 0x800924CC; // type:func
func_80092538_jp = 0x80092538; // type:func
-func_8009264C_jp = 0x8009264C; // type:func
+mFont_UnintToString = 0x8009264C; // type:func
Balloon_init = 0x800928C0; // type:func
Balloon_move = 0x800928E8; // type:func
func_80092B7C_jp = 0x80092B7C; // type:func
@@ -1971,7 +1971,7 @@ func_8009E6B8_jp = 0x8009E6B8; // type:func
func_8009E6C4_jp = 0x8009E6C4; // type:func
func_8009E6D4_jp = 0x8009E6D4; // type:func
func_8009E6F8_jp = 0x8009E6F8; // type:func
-func_8009E8D0_jp = 0x8009E8D0; // type:func
+mMsg_Get_Length_String = 0x8009E8D0; // type:func
func_8009E908_jp = 0x8009E908; // type:func
func_8009E94C_jp = 0x8009E94C; // type:func
func_8009E970_jp = 0x8009E970; // type:func
@@ -3024,16 +3024,16 @@ mSDI_StartInitErr = 0x800C3BB4; // type:func
mSDI_StartInitAfter = 0x800C3BCC; // type:func
mSDI_StartInitBefore = 0x800C3D50; // type:func
mSDI_StartDataInit = 0x800C3DA8; // type:func
-func_800C3E30_jp = 0x800C3E30; // type:func
+mString_Get_StringDataAddressAndSize = 0x800C3E30; // type:func
mString_Load_StringFromRom = 0x800C3F70; // type:func
-func_800C4084_jp = 0x800C4084; // type:func
-func_800C40F8_jp = 0x800C40F8; // type:func
-func_800C4168_jp = 0x800C4168; // type:func
-func_800C41B8_jp = 0x800C41B8; // type:func
-func_800C4228_jp = 0x800C4228; // type:func
-func_800C42E8_jp = 0x800C42E8; // type:func
-func_800C4350_jp = 0x800C4350; // type:func
-func_800C43B8_jp = 0x800C43B8; // type:func
+mString_Load_YearStringFromRom = 0x800C4084; // type:func
+mString_Load_MonthStringFromRom = 0x800C40F8; // type:func
+mString_Load_WeekStringFromRom = 0x800C4168; // type:func
+mString_Load_DayStringFromRom = 0x800C41B8; // type:func
+mString_Load_HourStringFromRom = 0x800C4228; // type:func
+mString_Load_MinStringFromRom = 0x800C42E8; // type:func
+mString_Load_SecStringFromRom = 0x800C4350; // type:func
+mString_Load_NumberStringAddUnitFromRom = 0x800C43B8; // type:func
SubmenuArea_IsPlayer = 0x800C4420; // type:func
mSM_load_player_anime = 0x800C4440; // type:func
SubmenuArea_DoLink = 0x800C453C; // type:func
diff --git a/src/code/m_npc.c b/src/code/m_npc.c
index b1e4347..f9e8fcd 100644
--- a/src/code/m_npc.c
+++ b/src/code/m_npc.c
@@ -6,7 +6,7 @@
#include "m_field_info.h"
#include "m_mail_check.h"
#include "6E30B0.h"
-#include "6E7AD0.h"
+#include "m_string.h"
#include "m_handbill.h"
#include "m_std_dma.h"
#include "6DA460.h"
diff --git a/src/code/m_start_data_init.c b/src/code/m_start_data_init.c
index 1fe8c87..115182b 100644
--- a/src/code/m_start_data_init.c
+++ b/src/code/m_start_data_init.c
@@ -8,7 +8,7 @@
#include "6D9D80.h"
#include "6DA460.h"
#include "6E30B0.h"
-#include "6E7AD0.h"
+#include "m_string.h"
#include "6ECD90.h"
#include "6EDD10.h"
#include "global.h"
diff --git a/src/code/m_string.c b/src/code/m_string.c
new file mode 100644
index 0000000..7b8e5b5
--- /dev/null
+++ b/src/code/m_string.c
@@ -0,0 +1,173 @@
+#include "m_string.h"
+#include "m_std_dma.h"
+#include "m_lib.h"
+
+#include "m_msg_main.h"
+#include "6B3DC0.h"
+
+extern u32 D_D18000[];
+extern u32 D_D16000;
+void mString_Get_StringDataAddressAndSize(s32 idx, uintptr_t* vramp, size_t* size) {
+ s32 sized;
+ uintptr_t offsetPtrs[5];
+
+ if (idx >= 0 && idx < 0x61A) {
+ uintptr_t vrom;
+ if (idx & 1) {
+ DmaMgr_RequestSyncDebug(offsetPtrs, (u32)&D_D18000[idx - 1], 8, "../m_string.c", 62);
+ vrom = offsetPtrs[0];
+ sized = offsetPtrs[1] - vrom;
+ } else if (idx == 0) {
+ DmaMgr_RequestSyncDebug(offsetPtrs, (u32)&D_D18000, 8, "../m_string.c", 69);
+ vrom = 0;
+ sized = offsetPtrs[0] - vrom;
+ } else {
+ DmaMgr_RequestSyncDebug(offsetPtrs, (u32)&D_D18000[idx - 2], 16, "../m_string.c", 75);
+ vrom = offsetPtrs[1];
+ sized = offsetPtrs[2] - vrom;
+ }
+ if (sized < 65) {
+ *vramp = (uintptr_t)vrom + (u32)&D_D16000;
+ *size = sized;
+ } else {
+ *vramp = NULL;
+ *size = 0;
+ }
+ } else {
+ *vramp = NULL;
+ *size = 0;
+ }
+}
+
+void mString_Load_StringFromRom(char* dst, s32 dstLen, s32 strIdx) {
+ uintptr_t stringAddr;
+ size_t stringSize;
+
+ if (strIdx >= 0 && strIdx < 0x61A) {
+ mString_Get_StringDataAddressAndSize(strIdx, &stringAddr, &stringSize);
+
+ if (stringSize == 0) {
+ mem_clear((u8*)dst, dstLen, ' ');
+ } else if (stringAddr != 0) {
+ char buff[80];
+ u32 baseAddr = stringAddr & ~7;
+ s32 ofs = stringAddr - baseAddr;
+ s32 i;
+ char* strSrc;
+ s32 sizeCopy;
+ char* strDst;
+ UNUSED s32 pad;
+
+ DmaMgr_RequestSyncDebug(buff, baseAddr, ALIGN8(ofs + stringSize), "../m_string.c", 153);
+ if (dstLen < (s32)stringSize) {
+ stringSize = dstLen;
+ }
+
+ strDst = dst;
+ sizeCopy = stringSize;
+ strSrc = &buff[ofs];
+ for (i = 0; i < sizeCopy; i++) {
+ *strDst++ = *strSrc++;
+ }
+
+ for (; i < dstLen; i++) {
+ *strDst++ = ' ';
+ }
+ }
+ }
+}
+
+s32 mString_Load_YearStringFromRom(char* dst, lbRTC_year_t year) {
+ s32 idx;
+
+ if (year < lbRTC_YEAR_MIN || year > lbRTC_YEAR_MAX) {
+ year = GAME_YEAR_MIN;
+ }
+
+ idx = mFont_UnintToString(dst, year, 6, TRUE, FALSE);
+ mString_Load_StringFromRom(&dst[idx], 6 - idx, 3);
+ return mMsg_Get_Length_String(dst, 6);
+}
+
+s32 mString_Load_MonthStringFromRom(char* dst, lbRTC_month_t month) {
+ s32 idx;
+
+ if (month < lbRTC_JANUARY || month > lbRTC_DECEMBER) {
+ month = lbRTC_JANUARY;
+ }
+
+ idx = mFont_UnintToString(dst, month, 4, TRUE, FALSE);
+ mString_Load_StringFromRom(&dst[idx], 4 - idx, 4);
+ return mMsg_Get_Length_String(dst, 4);
+}
+
+s32 mString_Load_WeekStringFromRom(char* dst, lbRTC_weekday_t weekday) {
+ if (weekday > lbRTC_SATURDAY) {
+ weekday = 0;
+ }
+
+ mString_Load_StringFromRom(dst, 5, weekday + 9);
+ return mMsg_Get_Length_String(dst, 4);
+}
+
+s32 mString_Load_DayStringFromRom(char* dst, lbRTC_day_t day) {
+ s32 idx;
+
+ if (day < 1 || day > 31) {
+ day = 1;
+ }
+
+ idx = mFont_UnintToString(dst, day, 4, TRUE, FALSE);
+ mString_Load_StringFromRom(&dst[idx], 4 - idx, 5);
+ return mMsg_Get_Length_String(dst, 4);
+}
+
+s32 mString_Load_HourStringFromRom(char* dst, lbRTC_hour_t hour) {
+ UNUSED s32 pad;
+ s32 specifier;
+ s32 len;
+
+ if (hour >= lbRTC_HOURS_PER_DAY) {
+ hour = 0;
+ }
+
+ specifier = hour < 12 ? 1 : 2;
+
+ mString_Load_StringFromRom(dst, 6, specifier);
+ len = mMsg_Get_Length_String(dst, 6);
+ len += mFont_UnintToString(dst + len, hour % 12, 6 - len, TRUE, FALSE);
+
+ mString_Load_StringFromRom(dst + len, 6 - len, 6);
+ return mMsg_Get_Length_String(dst, 6);
+}
+
+s32 mString_Load_MinStringFromRom(char* dst, lbRTC_min_t min) {
+ s32 idx;
+
+ if (min >= lbRTC_MINUTES_PER_HOUR) {
+ min = 0;
+ }
+
+ idx = mFont_UnintToString(dst, min, 4, TRUE, FALSE);
+ mString_Load_StringFromRom(&dst[idx], 4 - idx, 7);
+ return mMsg_Get_Length_String(dst, 4);
+}
+
+s32 mString_Load_SecStringFromRom(char* dst, lbRTC_sec_t sec) {
+ s32 idx;
+
+ if (sec >= lbRTC_MINUTES_PER_HOUR) {
+ sec = 0;
+ }
+
+ idx = mFont_UnintToString(dst, sec, 5, TRUE, FALSE);
+ mString_Load_StringFromRom(&dst[idx], 5 - idx, 8);
+ return mMsg_Get_Length_String(dst, 5);
+}
+
+s32 mString_Load_NumberStringAddUnitFromRom(char* dst, u16 num, s32 idx) {
+ s32 len = mFont_UnintToString(dst, num, 10, TRUE, FALSE);
+
+ mString_Load_StringFromRom(&dst[len], 10 - len, idx);
+ return mMsg_Get_Length_String(dst, 10);
+}
diff --git a/yamls/jp/code.yaml b/yamls/jp/code.yaml
index 90ca4f4..4468343 100644
--- a/yamls/jp/code.yaml
+++ b/yamls/jp/code.yaml
@@ -74,7 +74,7 @@
- [0x6E2300, asm, code/6E2300]
- [0x6E30B0, asm, code/6E30B0]
- [0x6E6C90, c, code/m_start_data_init]
- - [0x6E7AD0, asm, code/6E7AD0]
+ - [0x6E7AD0, c, code/m_string]
- [0x6E80C0, c, code/m_submenu]
- [0x6E9650, c, code/m_scene]
- [0x6EAB20, asm, code/m_skin_matrix]
@@ -229,7 +229,7 @@
- [0x73B360, rodata, code/73B360]
- [0x73B3E0, rodata, code/m_scene_ftr]
- [0x73B400, rodata, code/m_shop]
- - [0x73B580, rodata, code/m_string]
+ - [0x73B580, .rodata, code/m_string]
- [0x73B5C0, .rodata, code/m_submenu]
- [0x73B6D0, .rodata, code/m_scene]
- [0x73B700, rodata, code/73B700]