From 26d2aefec319366764f546146320526d6fc53b6a Mon Sep 17 00:00:00 2001 From: Pk11 Date: Wed, 4 Aug 2021 15:13:51 -0500 Subject: [PATCH] Convert old escapes to Unicode Only does the ones below ASCII (0x00 - 0x1F), hopefully none of the high ones are important because they'll conflict with Unicode codepoints --- arm9/source/common/ui.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arm9/source/common/ui.c b/arm9/source/common/ui.c index 63805f8..0900106 100644 --- a/arm9/source/common/ui.c +++ b/arm9/source/common/ui.c @@ -69,12 +69,19 @@ static const u16 cp437_sorted_map[0x100] = { 0x25BC, 0x25C4, 0x25CB, 0x25D8, 0x25D9, 0x263A, 0x263B, 0x263C, 0x2640, 0x2642, 0x2660, 0x2663, 0x2665, 0x2666, 0x266A, 0x266B }; +// lookup table to convert the old CP-437 escapes to Unicode +static const u16 cp437_escapes[0x20] = { + 0x0000, 0x263A, 0x263B, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022, 0x25D8, 0x25CB, 0x25D9, 0x2642, 0x2640, 0x266A, 0x266B, 0x263C, + 0x25BA, 0x25C4, 0x2195, 0x203C, 0x00B6, 0x00A7, 0x25AC, 0x21A8, 0x2191, 0x2193, 0x2192, 0x2190, 0x221F, 0x2194, 0x25B2, 0x25BC +}; + #define PIXEL_OFFSET(x, y) (((x) * SCREEN_HEIGHT) + (SCREEN_HEIGHT - (y) - 1)) u16 GetFontIndex(u16 c, bool use_ascii_lut) { - if (use_ascii_lut && c >= 0x20 && c <= 0x7F) return ascii_lut[c - 0x20]; + if (c < 0x20) return GetFontIndex(cp437_escapes[c], use_ascii_lut); + else if (use_ascii_lut && c < 0x80) return ascii_lut[c - 0x20]; int left = 0; int right = font_count;