m_string OK (#162)

* m_string OK

* replace with defines
This commit is contained in:
Prakxo
2024-04-03 00:09:06 +02:00
committed by GitHub
parent d8789801b8
commit 1ffded6b49
9 changed files with 209 additions and 34 deletions
+1 -1
View File
@@ -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
-17
View File
@@ -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
+1 -1
View File
@@ -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();
+19
View File
@@ -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
+11 -11
View File
@@ -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
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+173
View File
@@ -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);
}
+2 -2
View File
@@ -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]