summaryrefslogtreecommitdiff
path: root/src/unk_text_util.c
diff options
context:
space:
mode:
authorDiegoisawesome <Diegoisawesome@users.noreply.github.com>2017-11-27 18:39:50 -0600
committerGitHub <noreply@github.com>2017-11-27 18:39:50 -0600
commit18c6b8efc21a509121ab4d6f5b9c8523689d27a2 (patch)
tree5bb4654fc046f43f0cc3a24ac0f919512afda810 /src/unk_text_util.c
parentdb87e2db4cba56a78842f4f651656c0ed62ab27b (diff)
parente8b1059345c87b15c74262b2a761e5c7be526a5f (diff)
Merge pull request #120 from PikalaxALT/unk_text_util
Decompile asm/unk_text_util.s
Diffstat (limited to 'src/unk_text_util.c')
-rw-r--r--src/unk_text_util.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/unk_text_util.c b/src/unk_text_util.c
new file mode 100644
index 000000000..2773522b2
--- /dev/null
+++ b/src/unk_text_util.c
@@ -0,0 +1,56 @@
+#include "global.h"
+#include "text.h"
+#include "unk_text_util.h"
+#include "string_util.h"
+
+static EWRAM_DATA const u8 *sStringPointers[8] = {};
+
+void UnkTextUtil_Reset(void)
+{
+ const u8 **ptr;
+ u8 *fillval;
+ const u8 **ptr2;
+
+ ptr = sStringPointers;
+ fillval = NULL;
+ ptr2 = ptr + (ARRAY_COUNT(sStringPointers) - 1);
+ do
+ {
+ *ptr2-- = fillval;
+ } while ((int)ptr2 >= (int)ptr);
+}
+
+void UnkTextUtil_SetPtrI(u8 idx, const u8 *ptr)
+{
+ if (idx < ARRAY_COUNT(sStringPointers))
+ {
+ sStringPointers[idx] = ptr;
+ }
+}
+
+u8 *UnkTextUtil_StringExpandPlaceholders(u8 *dest, const u8 *src)
+{
+ while (*src != EOS)
+ {
+ if (*src != CHAR_SPECIAL_F7)
+ {
+ *dest++ = *src++;
+ }
+ else
+ {
+ src++;
+ if (sStringPointers[*src] != NULL)
+ {
+ dest = StringCopy(dest, sStringPointers[*src]);
+ }
+ src++;
+ }
+ }
+ *dest = EOS;
+ return dest;
+}
+
+const u8 *UnkTextUtil_GetPtrI(u8 idx)
+{
+ return sStringPointers[idx];
+}