diff options
author | Garak <garakmon@gmail.com> | 2018-08-07 22:21:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-07 22:21:10 -0400 |
commit | 96ab357bedfb7d4e07a52b518e2bd02375b1f5f5 (patch) | |
tree | 92c8775f554e682a05c5995c7baa2d130ebd8aa3 /src/dynamic_placeholder_text_util.c | |
parent | 1ab872c68e951837b6925dbbdf25c4e8d0b63c82 (diff) | |
parent | 85ebd76cd03e1ee84f182585060b3a79b8653e85 (diff) |
Merge pull request #3 from pret/master
syncing with source repo
Diffstat (limited to 'src/dynamic_placeholder_text_util.c')
-rw-r--r-- | src/dynamic_placeholder_text_util.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/dynamic_placeholder_text_util.c b/src/dynamic_placeholder_text_util.c new file mode 100644 index 000000000..bdfcf6653 --- /dev/null +++ b/src/dynamic_placeholder_text_util.c @@ -0,0 +1,56 @@ +#include "global.h" +#include "text.h" +#include "dynamic_placeholder_text_util.h" +#include "string_util.h" + +static EWRAM_DATA const u8 *sStringPointers[8] = {}; + +void DynamicPlaceholderTextUtil_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 DynamicPlaceholderTextUtil_SetPlaceholderPtr(u8 idx, const u8 *ptr) +{ + if (idx < ARRAY_COUNT(sStringPointers)) + { + sStringPointers[idx] = ptr; + } +} + +u8 *DynamicPlaceholderTextUtil_ExpandPlaceholders(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 *DynamicPlaceholderTextUtil_GetPlaceholderPtr(u8 idx) +{ + return sStringPointers[idx]; +} |