From 7be6c7fa74c4981617f808907a41175fd791d1f6 Mon Sep 17 00:00:00 2001 From: MysterD Date: Fri, 24 Nov 2023 23:20:49 -0800 Subject: [PATCH] Prevent translation of characters that don't exist in the menu font --- src/game/level_info.c | 105 +++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/src/game/level_info.c b/src/game/level_info.c index 25d8d9cd..ab72cff1 100644 --- a/src/game/level_info.c +++ b/src/game/level_info.c @@ -19,67 +19,68 @@ extern u8 *seg2_course_name_table[]; extern u8 *seg2_act_name_table[]; #endif -static const struct { const char *str; u8 c; } sSm64CharMap[] = { +static const struct { const char *str; u8 c; u8 menu; } sSm64CharMap[] = { // Digits - { "0", 0x00 }, { "1", 0x01 }, { "2", 0x02 }, { "3", 0x03 }, { "4", 0x04 }, - { "5", 0x05 }, { "6", 0x06 }, { "7", 0x07 }, { "8", 0x08 }, { "9", 0x09 }, + { "0", 0x00, 1 }, { "1", 0x01, 1 }, { "2", 0x02, 1 }, { "3", 0x03, 1 }, { "4", 0x04, 1 }, + { "5", 0x05, 1 }, { "6", 0x06, 1 }, { "7", 0x07, 1 }, { "8", 0x08, 1 }, { "9", 0x09, 1 }, // Capital letters - { "A", 0x0A }, { "B", 0x0B }, { "C", 0x0C }, { "D", 0x0D }, { "E", 0x0E }, - { "F", 0x0F }, { "G", 0x10 }, { "H", 0x11 }, { "I", 0x12 }, { "J", 0x13 }, - { "K", 0x14 }, { "L", 0x15 }, { "M", 0x16 }, { "N", 0x17 }, { "O", 0x18 }, - { "P", 0x19 }, { "Q", 0x1A }, { "R", 0x1B }, { "S", 0x1C }, { "T", 0x1D }, - { "U", 0x1E }, { "V", 0x1F }, { "W", 0x20 }, { "X", 0x21 }, { "Y", 0x22 }, - { "Z", 0x23 }, + { "A", 0x0A, 1 }, { "B", 0x0B, 1 }, { "C", 0x0C, 1 }, { "D", 0x0D, 1 }, { "E", 0x0E, 1 }, + { "F", 0x0F, 1 }, { "G", 0x10, 1 }, { "H", 0x11, 1 }, { "I", 0x12, 1 }, { "J", 0x13, 1 }, + { "K", 0x14, 1 }, { "L", 0x15, 1 }, { "M", 0x16, 1 }, { "N", 0x17, 1 }, { "O", 0x18, 1 }, + { "P", 0x19, 1 }, { "Q", 0x1A, 1 }, { "R", 0x1B, 1 }, { "S", 0x1C, 1 }, { "T", 0x1D, 1 }, + { "U", 0x1E, 1 }, { "V", 0x1F, 1 }, { "W", 0x20, 1 }, { "X", 0x21, 1 }, { "Y", 0x22, 1 }, + { "Z", 0x23, 1 }, // Letters - { "a", 0x24 }, { "b", 0x25 }, { "c", 0x26 }, { "d", 0x27 }, { "e", 0x28 }, - { "f", 0x29 }, { "g", 0x2A }, { "h", 0x2B }, { "i", 0x2C }, { "j", 0x2D }, - { "k", 0x2E }, { "l", 0x2F }, { "m", 0x30 }, { "n", 0x31 }, { "o", 0x32 }, - { "p", 0x33 }, { "q", 0x34 }, { "r", 0x35 }, { "s", 0x36 }, { "t", 0x37 }, - { "u", 0x38 }, { "v", 0x39 }, { "w", 0x3A }, { "x", 0x3B }, { "y", 0x3C }, - { "z", 0x3D }, + { "a", 0x24, 0 }, { "b", 0x25, 0 }, { "c", 0x26, 0 }, { "d", 0x27, 0 }, { "e", 0x28, 0 }, + { "f", 0x29, 0 }, { "g", 0x2A, 0 }, { "h", 0x2B, 0 }, { "i", 0x2C, 0 }, { "j", 0x2D, 0 }, + { "k", 0x2E, 0 }, { "l", 0x2F, 0 }, { "m", 0x30, 0 }, { "n", 0x31, 0 }, { "o", 0x32, 0 }, + { "p", 0x33, 0 }, { "q", 0x34, 0 }, { "r", 0x35, 0 }, { "s", 0x36, 0 }, { "t", 0x37, 0 }, + { "u", 0x38, 0 }, { "v", 0x39, 0 }, { "w", 0x3A, 0 }, { "x", 0x3B, 0 }, { "y", 0x3C, 0 }, + { "z", 0x3D, 0 }, // Punctuation - { "...", 0xE6 }, // ellipsis - { ")(", 0xE2 }, // close-open parentheses - { "<<", 0xF5 }, // double quote open - { ">>", 0xF6 }, // double quote close - { "\'", 0x3E }, // apostrophe - { ".", 0x3F }, // period - { ",", 0x6F }, // comma - { " ", 0x9E }, // space - { "-", 0x9F }, // dash - { "(", 0xE1 }, // open parentheses - { ")", 0xE3 }, // close parentheses - { "&", 0xE5 }, // ampersand - { "!", 0xF2 }, // exclamation mark - { "%", 0xF3 }, // percent - { "?", 0xF4 }, // question mark - { "~", 0xF7 }, // tilde + { "...", 0xE6, 0 }, // ellipsis + { ")(", 0xE2, 0 }, // close-open parentheses + { "<<", 0xF5, 0 }, // double quote open + { ">>", 0xF6, 0 }, // double quote close + { "\'", 0x3E, 1 }, // apostrophe + { ".", 0x3F, 1 }, // period + { ",", 0x6F, 1 }, // comma + { " ", 0x9E, 1 }, // space + { "-", 0x9F, 1 }, // dash + { "(", 0xE1, 0 }, // open parentheses + { ")", 0xE3, 0 }, // close parentheses + { "&", 0xE5, 1 }, // ampersand + { "!", 0xF2, 1 }, // exclamation mark + { "%", 0xF3, 0 }, // percent + { "?", 0xF4, 1 }, // question mark + { "~", 0xF7, 0 }, // tilde // Symbols - { "[A]", 0x54 }, // bold A - { "[B]", 0x55 }, // bold B - { "[C]", 0x56 }, // bold C - { "[Z]", 0x57 }, // bold Z - { "[R]", 0x58 }, // bold R - { "<->", 0xE4 }, // left-right arrow - { "^", 0x50 }, // up arrow - { "|", 0x51 }, // down arrow - { "<", 0x52 }, // left arrow - { ">", 0x53 }, // right arrow - { "+", 0xF9 }, // coin - { "@", 0xFA }, // star filled - { "*", 0xFB }, // multiply - { "$", 0xFD }, // star empty - { "\n", 0xFE }, // New line - { NULL, 0xFF }, // Null terminator + { "[A]", 0x54, 0 }, // bold A + { "[B]", 0x55, 0 }, // bold B + { "[C]", 0x56, 0 }, // bold C + { "[Z]", 0x57, 0 }, // bold Z + { "[R]", 0x58, 0 }, // bold R + { "<->", 0xE4, 0 }, // left-right arrow + { "^", 0x50, 0 }, // up arrow + { "|", 0x51, 0 }, // down arrow + { "<", 0x52, 0 }, // left arrow + { ">", 0x53, 0 }, // right arrow + { "+", 0xF9, 1 }, // coin + { "@", 0xFA, 1 }, // star filled + { "*", 0xFB, 1 }, // multiply + { "$", 0xFD, 0 }, // star empty + { "\n", 0xFE, 1 }, // New line + { NULL, 0xFF, 1 }, // Null terminator }; -static const char *ascii_to_sm64_char(u8 *str64, const char *strAscii) { +static const char *ascii_to_sm64_char(u8 *str64, const char *strAscii, bool menu) { for (s32 i = 0; sSm64CharMap[i].str != NULL; ++i) { + if (menu && !sSm64CharMap[i].menu) { continue; } if (strstr(strAscii, sSm64CharMap[i].str) == strAscii) { *str64 = sSm64CharMap[i].c; return strAscii + strlen(sSm64CharMap[i].str); @@ -101,9 +102,9 @@ static char *sm64_to_ascii_char(char *strAscii, const u8 *str64) { return strAscii + 1; } -static void convert_string_ascii_to_sm64(u8 *str64, const char *strAscii) { +static void convert_string_ascii_to_sm64(u8 *str64, const char *strAscii, bool menu) { for (; *strAscii != 0; str64++) { - strAscii = ascii_to_sm64_char(str64, strAscii); + strAscii = ascii_to_sm64_char(str64, strAscii, menu); } *str64 = 0xFF; } @@ -248,7 +249,7 @@ const u8 *get_level_name_sm64(s16 courseNum, s16 levelNum, s16 areaIndex, s16 ch static u8 output[256]; char levelName[256]; snprintf(levelName, 256, " %d %s", courseNum, get_level_name_ascii(courseNum, levelNum, areaIndex, charCase)); - convert_string_ascii_to_sm64(output, levelName); + convert_string_ascii_to_sm64(output, levelName, false); return output; } @@ -314,7 +315,7 @@ const char *get_star_name_ascii(s16 courseNum, s16 starNum, s16 charCase) { const u8 *get_star_name_sm64(s16 courseNum, s16 starNum, s16 charCase) { static u8 output[256]; const char *starName = get_star_name_ascii(courseNum, starNum, charCase); - convert_string_ascii_to_sm64(output, starName); + convert_string_ascii_to_sm64(output, starName, true); return output; }