pmd-red/src/text_util.c
2025-06-10 14:10:32 +02:00

79 lines
1.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "global.h"
#include "globaldata.h"
#include "text_util.h"
// Not sure what the deal is with these two funcs. GetCharId is mostly used alongside GetCharacter function, which gets char info, such as width, etc.
s32 ReturnIntFromChar(u8 c)
{
return c;
}
// arm9.bin::020614D0
u32 GetCharId(u8 c)
{
return c;
}
UNUSED static void sub_8092290(u8 *buffer, u8 *string)
{
while( *string != '\0' ) {
*buffer++ = GetCharId(*string++);
}
*buffer = '\0'; // append terminating char
}
void StrncpyCustom(u8 *buffer, const u8 *string, s32 n)
{
while(1) {
if (n-- <= 0 || *string == '\0') {
break;
}
*buffer++ = GetCharId(*string++);
}
*buffer = '\0'; // append terminating char
}
// Inverted font block - maybe used in international/Japanese games?
static const u8 *const sInvertedFontDigits[] = {
_(""),
_(""),
_(""),
_(""),
_(""),
_(""),
_(""),
_(""),
_(""),
_(""),
};
UNUSED static const u8 *GetDigitInvertedFontStr(u32 digit)
{
return sInvertedFontDigits[digit];
}
void CopyStringtoBuffer(u8 *buffer, const u8 *string)
{
while( *string != '\0' ) {
*buffer++ = *string++;
}
*buffer = '\0'; // append a terminating char
}
void BoundedCopyStringtoBuffer(u8 *buffer, u8 *string, s32 size)
{
while( 1 ) {
if (size-- < 1) {
break;
}
if (*string == '\0') {
*buffer = '\0'; // append a terminating char and break
break;
}
// NOTE: *buffer++ = *string++ cases register flip
*buffer = *string;
buffer++;
string++;
}
}