Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
640 changes: 314 additions & 326 deletions include/constants/charcode.h

Large diffs are not rendered by default.

522 changes: 261 additions & 261 deletions src/applications/naming_screen.c

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/charcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

charcode_t *CharCode_SkipFormatArg(const charcode_t *cstr)
{
GF_ASSERT(*cstr == CHAR_FORMAT_ARG);
GF_ASSERT(*cstr == CHAR_CONTROL_CODE_ARG);

if (*cstr == CHAR_FORMAT_ARG) {
if (*cstr == CHAR_CONTROL_CODE_ARG) {
cstr += 2;
u32 skip = *cstr++;
cstr += skip;
Expand All @@ -19,7 +19,7 @@ charcode_t *CharCode_SkipFormatArg(const charcode_t *cstr)

u32 CharCode_FormatArgType(const charcode_t *cstr)
{
GF_ASSERT(*cstr == CHAR_FORMAT_ARG);
GF_ASSERT(*cstr == CHAR_CONTROL_CODE_ARG);
return *(cstr + 1);
}

Expand All @@ -38,7 +38,7 @@ BOOL CharCode_IsFormatArg(const charcode_t *cstr)

u32 CharCode_FormatArgParam(const charcode_t *cstr, u32 paramIdx)
{
GF_ASSERT(*cstr == CHAR_FORMAT_ARG);
GF_ASSERT(*cstr == CHAR_CONTROL_CODE_ARG);

cstr += 2;
u32 skip = *cstr++;
Expand Down
38 changes: 19 additions & 19 deletions src/charcode_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
#include "charcode.h"

static const charcode_t sHexadecimalDigits[] = {
CHAR_WIDE_0,
CHAR_WIDE_1,
CHAR_WIDE_2,
CHAR_WIDE_3,
CHAR_WIDE_4,
CHAR_WIDE_5,
CHAR_WIDE_6,
CHAR_WIDE_7,
CHAR_WIDE_8,
CHAR_WIDE_9,
CHAR_WIDE_A,
CHAR_WIDE_B,
CHAR_WIDE_C,
CHAR_WIDE_D,
CHAR_WIDE_E,
CHAR_WIDE_F,
CHAR_JP_0,
CHAR_JP_1,
CHAR_JP_2,
CHAR_JP_3,
CHAR_JP_4,
CHAR_JP_5,
CHAR_JP_6,
CHAR_JP_7,
CHAR_JP_8,
CHAR_JP_9,
CHAR_JP_A,
CHAR_JP_B,
CHAR_JP_C,
CHAR_JP_D,
CHAR_JP_E,
CHAR_JP_F,
};

static const int sPowersOfTen[] = {
Expand Down Expand Up @@ -129,14 +129,14 @@ charcode_t *CharCode_FromInt(charcode_t *str, s32 i, enum PaddingMode paddingMod
diff = i - (j * digit);

if (paddingMode == PADDING_MODE_ZEROES) {
*str = digit >= 10 ? CHAR_WIDE_QUESTION : sHexadecimalDigits[digit];
*str = digit >= 10 ? CHAR_JP_QMARK : sHexadecimalDigits[digit];
str++;
} else if (digit != 0 || j == 1) {
paddingMode = PADDING_MODE_ZEROES;
*str = digit >= 10 ? CHAR_WIDE_QUESTION : sHexadecimalDigits[digit];
*str = digit >= 10 ? CHAR_JP_QMARK : sHexadecimalDigits[digit];
str++;
} else if (paddingMode == PADDING_MODE_SPACES) {
*str = CHAR_WIDE_SPACE;
*str = CHAR_JP_SPACE;
str++;
}

Expand Down
14 changes: 7 additions & 7 deletions src/font_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void FontManager_TryLoadGlyph(const FontManager *fontManager, charcode_t c, Text
if (c <= fontManager->header.numGlyphs) {
c--;
} else {
c = CHAR_QUESTION - 1;
c = CHAR_QMARK - 1;
}

fontManager->glyphBitmapFunc(fontManager, c, outGlyph);
Expand Down Expand Up @@ -229,7 +229,7 @@ u32 FontManager_CalcStringWidth(const FontManager *fontManager, const charcode_t
u32 len = 0;

while (*str != CHAR_EOS) {
if (*str == CHAR_FORMAT_ARG) {
if (*str == CHAR_CONTROL_CODE_ARG) {
str = CharCode_SkipFormatArg(str);
if (*str == CHAR_EOS) {
break;
Expand All @@ -246,7 +246,7 @@ u32 FontManager_CalcStringWidth(const FontManager *fontManager, const charcode_t
BOOL FontManager_AreAllCharsValid(const FontManager *fontManager, const charcode_t *str)
{
while (*str != CHAR_EOS) {
if (*str == CHAR_FORMAT_ARG) {
if (*str == CHAR_CONTROL_CODE_ARG) {
str = CharCode_SkipFormatArg(str);
if (*str == CHAR_EOS) {
return TRUE;
Expand All @@ -268,7 +268,7 @@ static u8 GlyphWidthFunc_VariableWidth(const FontManager *fontManager, u32 glyph
if (glyphIdx < fontManager->header.numGlyphs) {
return fontManager->glyphWidths[glyphIdx];
} else {
return fontManager->glyphWidths[CHAR_QUESTION - 1];
return fontManager->glyphWidths[CHAR_QMARK - 1];
}
}

Expand All @@ -282,9 +282,9 @@ u32 FontManager_CalcMaxLineWidth(const FontManager *fontManager, const charcode_
u32 maxLen = 0, lineLen = 0;

while (*str != CHAR_EOS) {
if (*str == CHAR_FORMAT_ARG) {
if (*str == CHAR_CONTROL_CODE_ARG) {
str = CharCode_SkipFormatArg(str);
} else if (*str == CHAR_CR) {
} else if (*str == CHAR_LINE_BREAK) {
if (maxLen < lineLen - letterSpacing) {
maxLen = lineLen - letterSpacing;
}
Expand All @@ -309,7 +309,7 @@ u32 FontManager_CalcStringWidthWithCursorControl(const FontManager *fontManager,
u32 len = 0;

while (*str != CHAR_EOS) {
if (*str == CHAR_FORMAT_ARG) {
if (*str == CHAR_CONTROL_CODE_ARG) {
if (CharCode_FormatArgType(str) == CHAR_CONTROL_CURSOR_X) {
len = CharCode_FormatArgParam(str, 0) - 12;
}
Expand Down
8 changes: 4 additions & 4 deletions src/font_special_chars.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ void FontSpecialChars_DrawPartyScreenHPText(FontSpecialCharsContext *context, s3
CharCode_FromInt(context->charcodes, displayValue, paddingMode, digits);

for (idx = 0; context->charcodes[idx] != CHAR_EOS; idx++) {
if ((context->charcodes[idx] >= CHAR_WIDE_0) && (context->charcodes[idx] <= CHAR_WIDE_9)) {
if ((context->charcodes[idx] >= CHAR_JP_0) && (context->charcodes[idx] <= CHAR_JP_9)) {
Window_BlitBitmapRect(
window,
(u8 *)(context->charData->pRawData) + ((context->charcodes[idx] - CHAR_WIDE_0) * TILE_SIZE_4BPP),
(u8 *)(context->charData->pRawData) + ((context->charcodes[idx] - CHAR_JP_0) * TILE_SIZE_4BPP),
0,
0,
TILE_WIDTH_PIXELS,
Expand Down Expand Up @@ -153,8 +153,8 @@ void FontSpecialChars_DrawBattleScreenText(FontSpecialCharsContext *context, s32
CharCode_FromInt(context->charcodes, displayNum, paddingMode, numDigits);

for (idx = 0; context->charcodes[idx] != CHAR_EOS; idx++) {
if ((context->charcodes[idx] >= CHAR_WIDE_0) && (context->charcodes[idx] <= CHAR_WIDE_9)) {
MI_CpuCopy32((u8 *)(context->charData->pRawData) + ((context->charcodes[idx] - CHAR_WIDE_0) * TILE_SIZE_4BPP), &displayPtrBytes[idx * TILE_SIZE_4BPP], TILE_SIZE_4BPP);
if ((context->charcodes[idx] >= CHAR_JP_0) && (context->charcodes[idx] <= CHAR_JP_9)) {
MI_CpuCopy32((u8 *)(context->charData->pRawData) + ((context->charcodes[idx] - CHAR_JP_0) * TILE_SIZE_4BPP), &displayPtrBytes[idx * TILE_SIZE_4BPP], TILE_SIZE_4BPP);
} else {
MI_CpuFill8(&displayPtrBytes[idx * TILE_SIZE_4BPP], bgColor, TILE_SIZE_4BPP);
}
Expand Down
7 changes: 3 additions & 4 deletions src/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <nitro.h>
#include <string.h>

#include "constants/charcode.h"
#include "generated/badges.h"
#include "generated/journal_location_events.h"
#include "generated/journal_online_events.h"
Expand All @@ -25,8 +26,6 @@
#define LOCATION_EVENT_LOCATION_ID(locationEvent) ((locationEvent >> 16) & 0xffff)
#define LOCATION_EVENT_ITEM(locationEvent) ((locationEvent >> 16) & 0xffff)

#define CHAR_NONE 0xffff

#define GYM_NONE 0xff

#define TRAINER_TYPE_ELITE_FOUR 8
Expand Down Expand Up @@ -875,11 +874,11 @@ static void JournalEntry_StringCopy(const u16 *src, u16 *dst, u32 strLength)
u32 i;

for (i = 0; i < strLength; i++) {
dst[i] = CHAR_NONE;
dst[i] = CHAR_EOS;
}

for (i = 0; i < strLength; i++) {
if (src[i] == CHAR_NONE) {
if (src[i] == CHAR_EOS) {
break;
}

Expand Down
Loading