mirror of
https://github.com/pret/pmd-red.git
synced 2026-08-09 04:06:47 -05:00
79 lines
1.7 KiB
C
79 lines
1.7 KiB
C
#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[] = {
|
||
_("0"),
|
||
_("1"),
|
||
_("2"),
|
||
_("3"),
|
||
_("4"),
|
||
_("5"),
|
||
_("6"),
|
||
_("7"),
|
||
_("8"),
|
||
_("9"),
|
||
};
|
||
|
||
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++;
|
||
}
|
||
}
|