pokeemerald/src/unk_text_util.c

57 lines
1.0 KiB
C
Raw Normal View History

2017-11-23 17:23:05 +01:00
#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)
2017-11-23 17:23:05 +01:00
{
*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];
}