summaryrefslogtreecommitdiff
path: root/arm9/src
diff options
context:
space:
mode:
Diffstat (limited to 'arm9/src')
-rw-r--r--arm9/src/font.c2
-rw-r--r--arm9/src/script_buffers.c3
-rw-r--r--arm9/src/unk_02021590.c50
-rw-r--r--arm9/src/unk_02021934.c94
-rw-r--r--arm9/src/unk_02021FF8.c40
5 files changed, 92 insertions, 97 deletions
diff --git a/arm9/src/font.c b/arm9/src/font.c
index 537a7337..a0d1057b 100644
--- a/arm9/src/font.c
+++ b/arm9/src/font.c
@@ -179,7 +179,7 @@ THUMB_FUNC s32 FUN_02002F08(u32 param0, struct String *str, u32 param2)
{
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
- return StringGetWidth(UNK_02106FC8->unk94[param0], String_c_str(str), param2);
+ return GetStringWidthMultiline(UNK_02106FC8->unk94[param0], String_c_str(str), param2);
}
THUMB_FUNC u32 FUN_02002F40(u32 param0, struct String *str, u32 param2, u32 param3)
diff --git a/arm9/src/script_buffers.c b/arm9/src/script_buffers.c
index 550dcab5..37df6a71 100644
--- a/arm9/src/script_buffers.c
+++ b/arm9/src/script_buffers.c
@@ -13,6 +13,7 @@
#include "script_buffers.h"
#include "unk_02024E64.h"
#include "text.h"
+#include "string16.h"
#include "msgdata/msg.naix"
#include "graphic/font.naix"
@@ -20,8 +21,6 @@
extern u32 GetCityNamesMsgdataIdByCountry(u32);
extern void GetECWordIntoStringByIndex(u32 a0, struct String * a1);
-extern void StringCat_HandleTrainerName(struct String * dest, const struct String * src);
-extern void StrAddChar(struct String * str, u16 val);
extern void * GfGfxLoader_GetCharData(NarcId, s32, s32, struct UnkStruct_0200B870_sub **, u32);
extern void * GfGfxLoader_LoadFromNarc(NarcId narcId, s32 memberNo, BOOL isCompressed, u32 heap_id, BOOL allocAtEnd);
diff --git a/arm9/src/unk_02021590.c b/arm9/src/unk_02021590.c
index e6a3d690..c37ce589 100644
--- a/arm9/src/unk_02021590.c
+++ b/arm9/src/unk_02021590.c
@@ -210,3 +210,53 @@ THUMB_FUNC int GetGlyphWidth_FixedWidth(struct FontData * ptr, int a1)
#pragma unused(a1)
return ptr->gfxHeader.fixedWidth;
}
+
+THUMB_FUNC s32 GetStringWidthMultiline(struct FontData * r7, const u16 * arr, u32 r6)
+{
+ s32 ret = 0;
+ u32 r4 = 0;
+ while (*arr != 0xFFFF)
+ {
+ if (*arr == 0xFFFE)
+ {
+ arr = MsgArray_SkipControlCode(arr);
+ }
+ else if (*arr == 0xE000) // newline
+ {
+ if (ret < r4 - r6)
+ ret = (int)(r4 - r6);
+ r4 = 0;
+ arr++;
+ }
+ else
+ {
+ r4 += (r6 + r7->glyphWidthFunc(r7, *arr - 1));
+ arr++;
+ }
+ }
+ if (ret < r4 - r6)
+ ret = (int)(r4 - r6);
+ return ret;
+}
+
+THUMB_FUNC s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct FontData * r6, const u16 * arr)
+{
+ s32 ret = 0;
+ while (*arr != 0xFFFF)
+ {
+ if (*arr == 0xFFFE)
+ {
+ if (MsgArray_GetControlCode(arr) == 515)
+ {
+ ret = MsgArray_ControlCodeGetField(arr, 0) - 12;
+ }
+ arr = MsgArray_SkipControlCode(arr);
+ }
+ else
+ {
+ ret += r6->glyphWidthFunc(r6, *arr - 1);
+ arr++;
+ }
+ }
+ return ret;
+}
diff --git a/arm9/src/unk_02021934.c b/arm9/src/unk_02021934.c
index 07ddde87..e87016c4 100644
--- a/arm9/src/unk_02021934.c
+++ b/arm9/src/unk_02021934.c
@@ -2,65 +2,11 @@
#include "string16.h"
#include "heap.h"
#include "string_util.h"
-#include "unk_0201B8B8.h"
-#include "unk_02021590.h"
#pragma thumb on
#define ASSERT_STR16(_str) ({ GF_ASSERT(_str != NULL); GF_ASSERT(_str->magic == STR16_MAGIC); })
-void StrAddChar(struct String * str, u16 val);
-
-s32 StringGetWidth(struct FontData * r7, const u16 * arr, u32 r6)
-{
- s32 ret = 0;
- u32 r4 = 0;
- while (*arr != 0xFFFF)
- {
- if (*arr == 0xFFFE)
- {
- arr = MsgArray_SkipControlCode(arr);
- }
- else if (*arr == 0xE000) // newline
- {
- if (ret < r4 - r6)
- ret = (int)(r4 - r6);
- r4 = 0;
- arr++;
- }
- else
- {
- r4 += (r6 + r7->glyphWidthFunc(r7, *arr - 1));
- arr++;
- }
- }
- if (ret < r4 - r6)
- ret = (int)(r4 - r6);
- return ret;
-}
-
-s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct FontData * r6, const u16 * arr)
-{
- s32 ret = 0;
- while (*arr != 0xFFFF)
- {
- if (*arr == 0xFFFE)
- {
- if (MsgArray_GetControlCode(arr) == 515)
- {
- ret = MsgArray_ControlCodeGetField(arr, 0) - 12;
- }
- arr = MsgArray_SkipControlCode(arr);
- }
- else
- {
- ret += r6->glyphWidthFunc(r6, *arr - 1);
- arr++;
- }
- }
- return ret;
-}
-
struct String * String_ctor(u32 length, u32 heap_id)
{
struct String * ret = AllocFromHeap(heap_id, length * 2 + 10);
@@ -366,3 +312,43 @@ void StrUpperFirstChar(struct String * str)
str->data[0] -= 26;
}
}
+
+BOOL String_IsTrainerName(struct String * string)
+{
+ return string->size != 0 && string->data[0] == 0xF100;
+}
+
+void StringCat_HandleTrainerName(struct String * dest, struct String * src)
+{
+ if (String_IsTrainerName(src))
+ {
+ u16 * dest_p = &dest->data[dest->size];
+ u16 * src_p = &src->data[1];
+ s32 bit = 0;
+ u32 outsize = 0;
+ u16 cur_char = 0;
+
+ while (1)
+ {
+ cur_char = (u16)((*src_p >> bit) & 0x1FF);
+ bit += 9;
+ if (bit >= 15)
+ {
+ src_p++;
+ bit -= 15;
+ if (bit != 0)
+ {
+ cur_char |= (*src_p << (9 - bit)) & 0x1FF;
+ }
+ }
+ if (cur_char == 0x1FF)
+ break;
+ *dest_p++ = cur_char;
+ outsize++;
+ }
+ *dest_p = EOS;
+ dest->size += outsize;
+ }
+ else
+ StringCat(dest, src);
+}
diff --git a/arm9/src/unk_02021FF8.c b/arm9/src/unk_02021FF8.c
index 2fe37556..d578bba5 100644
--- a/arm9/src/unk_02021FF8.c
+++ b/arm9/src/unk_02021FF8.c
@@ -5,46 +5,6 @@
#pragma thumb on
-BOOL String_IsTrainerName(struct String * string)
-{
- return string->size != 0 && string->data[0] == 0xF100;
-}
-
-void StringCat_HandleTrainerName(struct String * dest, struct String * src)
-{
- if (String_IsTrainerName(src))
- {
- u16 * dest_p = &dest->data[dest->size];
- u16 * src_p = &src->data[1];
- s32 bit = 0;
- u32 outsize = 0;
- u16 cur_char = 0;
-
- while (1)
- {
- cur_char = (u16)((*src_p >> bit) & 0x1FF);
- bit += 9;
- if (bit >= 15)
- {
- src_p++;
- bit -= 15;
- if (bit != 0)
- {
- cur_char |= (*src_p << (9 - bit)) & 0x1FF;
- }
- }
- if (cur_char == 0x1FF)
- break;
- *dest_p++ = cur_char;
- outsize++;
- }
- *dest_p = EOS;
- dest->size += outsize;
- }
- else
- StringCat(dest, src);
-}
-
struct UnkStruct_020220C4 * FUN_020220C4(u8 * a0, u32 a1, void (*a2)(s32, s32, u32), u32 a3, u32 a4)
{
struct UnkStruct_020220C4 * ret;