From 13cd2a41f03ca56f45cab6769cb2738070cc5cf2 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 30 Oct 2021 16:19:10 -0400 Subject: [PATCH] Better braille support --- asm/macros/event.inc | 6 + data/maps/AncientTomb/scripts.inc | 8 +- data/maps/DesertRuins/scripts.inc | 8 +- data/maps/SealedChamber_InnerRoom/scripts.inc | 28 +- data/maps/SealedChamber_OuterRoom/scripts.inc | 48 +-- .../maps/Underwater_SealedChamber/scripts.inc | 4 +- data/text/braille.inc | 4 + gflib/characters.h | 350 ++++++++++++++++++ gflib/string_util.c | 8 +- gflib/text.h | 268 +------------- src/contest.c | 8 +- src/pokedex.c | 4 +- src/union_room_chat.c | 8 +- tools/preproc/asm_file.cpp | 137 +++++-- tools/preproc/asm_file.h | 1 + 15 files changed, 502 insertions(+), 388 deletions(-) create mode 100644 gflib/characters.h diff --git a/asm/macros/event.inc b/asm/macros/event.inc index 480684ef6e..62437ccb8a 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -1792,3 +1792,9 @@ setfieldeffectargument 2, \priority dofieldeffect FLDEFF_SPARKLE .endm + + .macro braillemsgbox text:req + braillemessage \text + waitbuttonpress + closebraillemessage + .endm diff --git a/data/maps/AncientTomb/scripts.inc b/data/maps/AncientTomb/scripts.inc index 40d9f0dff0..edbb75ccc5 100644 --- a/data/maps/AncientTomb/scripts.inc +++ b/data/maps/AncientTomb/scripts.inc @@ -40,9 +40,7 @@ AncientTomb_EventScript_HideRegiEntrance:: AncientTomb_EventScript_CaveEntranceMiddle:: lockall goto_if_set FLAG_SYS_REGISTEEL_PUZZLE_COMPLETED, AncientTomb_EventScript_BigHoleInWall - braillemessage AncientTomb_Braille_ShineInTheMiddle - waitbuttonpress - closebraillemessage + braillemsgbox AncientTomb_Braille_ShineInTheMiddle releaseall end @@ -53,9 +51,7 @@ AncientTomb_EventScript_BigHoleInWall:: AncientTomb_EventScript_CaveEntranceSide:: lockall - braillemessage AncientTomb_Braille_ShineInTheMiddle - waitbuttonpress - closebraillemessage + braillemsgbox AncientTomb_Braille_ShineInTheMiddle releaseall end diff --git a/data/maps/DesertRuins/scripts.inc b/data/maps/DesertRuins/scripts.inc index 414dbfc572..1bcaa23bff 100644 --- a/data/maps/DesertRuins/scripts.inc +++ b/data/maps/DesertRuins/scripts.inc @@ -40,9 +40,7 @@ DesertRuins_EventScript_ShowRegirock:: DesertRuins_EventScript_CaveEntranceMiddle:: lockall goto_if_set FLAG_SYS_REGIROCK_PUZZLE_COMPLETED, DesertRuins_EventScript_BigHoleInWall - braillemessage DesertRuins_Braille_UseRockSmash - waitbuttonpress - closebraillemessage + braillemsgbox DesertRuins_Braille_UseRockSmash releaseall end @@ -53,9 +51,7 @@ DesertRuins_EventScript_BigHoleInWall:: DesertRuins_EventScript_CaveEntranceSide:: lockall - braillemessage DesertRuins_Braille_UseRockSmash - waitbuttonpress - closebraillemessage + braillemsgbox DesertRuins_Braille_UseRockSmash releaseall end diff --git a/data/maps/SealedChamber_InnerRoom/scripts.inc b/data/maps/SealedChamber_InnerRoom/scripts.inc index 8c45c81ca2..7d240535ca 100644 --- a/data/maps/SealedChamber_InnerRoom/scripts.inc +++ b/data/maps/SealedChamber_InnerRoom/scripts.inc @@ -3,9 +3,7 @@ SealedChamber_InnerRoom_MapScripts:: SealedChamber_InnerRoom_EventScript_BrailleBackWall:: lockall - braillemessage SealedChamber_InnerRoom_Braille_FirstWailordLastRelicanth - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_InnerRoom_Braille_FirstWailordLastRelicanth goto_if_set FLAG_REGI_DOORS_OPENED, SealedChamber_InnerRoom_EventScript_NoEffect specialvar VAR_RESULT, CheckRelicanthWailord compare VAR_RESULT, FALSE @@ -40,49 +38,37 @@ SealedChamber_InnerRoom_EventScript_NoEffect:: SealedChamber_InnerRoom_EventScript_BrailleStoryPart1:: lockall - braillemessage SealedChamber_InnerRoom_Braille_InThisCaveWeHaveLived - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_InnerRoom_Braille_InThisCaveWeHaveLived releaseall end SealedChamber_InnerRoom_EventScript_BrailleStoryPart2:: lockall - braillemessage SealedChamber_InnerRoom_Braille_WeOweAllToThePokemon - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_InnerRoom_Braille_WeOweAllToThePokemon releaseall end SealedChamber_InnerRoom_EventScript_BrailleStoryPart3:: lockall - braillemessage SealedChamber_InnerRoom_Braille_ButWeSealedThePokemonAway - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_InnerRoom_Braille_ButWeSealedThePokemonAway releaseall end SealedChamber_InnerRoom_EventScript_BrailleStoryPart4:: lockall - braillemessage SealedChamber_InnerRoom_Braille_WeFearedIt - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_InnerRoom_Braille_WeFearedIt releaseall end SealedChamber_InnerRoom_EventScript_BrailleStoryPart5:: lockall - braillemessage SealedChamber_InnerRoom_Braille_ThoseWithCourageHope - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_InnerRoom_Braille_ThoseWithCourageHope releaseall end SealedChamber_InnerRoom_EventScript_BrailleStoryPart6:: lockall - braillemessage SealedChamber_InnerRoom_Braille_OpenDoorEternalPokemonWaits - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_InnerRoom_Braille_OpenDoorEternalPokemonWaits releaseall end diff --git a/data/maps/SealedChamber_OuterRoom/scripts.inc b/data/maps/SealedChamber_OuterRoom/scripts.inc index 2e80d06c82..7d57ea5449 100644 --- a/data/maps/SealedChamber_OuterRoom/scripts.inc +++ b/data/maps/SealedChamber_OuterRoom/scripts.inc @@ -28,90 +28,68 @@ SealedChamber_OuterRoom_EventScript_CloseInnerRoomEntrance:: SealedChamber_OuterRoom_EventScript_BrailleABC:: lockall - braillemessage SealedChamber_OuterRoom_Braille_ABC - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_OuterRoom_Braille_ABC releaseall end SealedChamber_OuterRoom_EventScript_BrailleGHI:: lockall - braillemessage SealedChamber_OuterRoom_Braille_GHI - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_OuterRoom_Braille_GHI releaseall end SealedChamber_OuterRoom_EventScript_BrailleMNO:: lockall - braillemessage SealedChamber_OuterRoom_Braille_MNO - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_OuterRoom_Braille_MNO releaseall end SealedChamber_OuterRoom_EventScript_BrailleTUV:: lockall - braillemessage SealedChamber_OuterRoom_Braille_TUV - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_OuterRoom_Braille_TUV releaseall end SealedChamber_OuterRoom_EventScript_BrailleDEF:: lockall - braillemessage SealedChamber_OuterRoom_Braille_DEF - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_OuterRoom_Braille_DEF releaseall end SealedChamber_OuterRoom_EventScript_BrailleJKL:: lockall - braillemessage SealedChamber_OuterRoom_Braille_JKL - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_OuterRoom_Braille_JKL releaseall end SealedChamber_OuterRoom_EventScript_BraillePQRS:: lockall - braillemessage SealedChamber_OuterRoom_Braille_PQRS - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_OuterRoom_Braille_PQRS releaseall end SealedChamber_OuterRoom_EventScript_BraillePeriod:: lockall - braillemessage SealedChamber_OuterRoom_Braille_Period - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_OuterRoom_Braille_Period releaseall end SealedChamber_OuterRoom_EventScript_BrailleWXYZ:: lockall - braillemessage SealedChamber_OuterRoom_Braille_WXYZ - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_OuterRoom_Braille_WXYZ releaseall end SealedChamber_OuterRoom_EventScript_BrailleComma:: lockall - braillemessage SealedChamber_OuterRoom_Braille_Comma - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_OuterRoom_Braille_Comma releaseall end SealedChamber_OuterRoom_EventScript_InnerRoomEntranceWall:: lockall goto_if_set FLAG_SYS_BRAILLE_DIG, SealedChamber_OuterRoom_EventScript_HoleInWall - braillemessage SealedChamber_OuterRoom_Braille_DigHere - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_OuterRoom_Braille_DigHere releaseall end @@ -122,9 +100,7 @@ SealedChamber_OuterRoom_EventScript_HoleInWall:: SealedChamber_OuterRoom_EventScript_BrailleDigHere:: lockall - braillemessage SealedChamber_OuterRoom_Braille_DigHere - waitbuttonpress - closebraillemessage + braillemsgbox SealedChamber_OuterRoom_Braille_DigHere releaseall end diff --git a/data/maps/Underwater_SealedChamber/scripts.inc b/data/maps/Underwater_SealedChamber/scripts.inc index 3d8aaf979f..2b3fe5e0de 100644 --- a/data/maps/Underwater_SealedChamber/scripts.inc +++ b/data/maps/Underwater_SealedChamber/scripts.inc @@ -20,9 +20,7 @@ Underwater_SealedChamber_EventScript_SurfaceSealedChamber:: Underwater_SealedChamber_EventScript_Braille:: lockall - braillemessage Underwater_SealedChamber_Braille_GoUpHere - waitbuttonpress - closebraillemessage + braillemsgbox Underwater_SealedChamber_Braille_GoUpHere releaseall end diff --git a/data/text/braille.inc b/data/text/braille.inc index 69f0a81e38..4518c5769d 100644 --- a/data/text/braille.inc +++ b/data/text/braille.inc @@ -1,3 +1,7 @@ +@ NOTE: The brailleformat macro in this file is leftover from RS. +@ The numbers are simply skipped over. If you'd like to omit +@ this macro you must also stop it from skipping over this +@ section by editing ScrCmd_braillemessage. Underwater_SealedChamber_Braille_GoUpHere: brailleformat 4, 6, 26, 13, 7, 9 .braille "GO UP HERE.$" diff --git a/gflib/characters.h b/gflib/characters.h new file mode 100644 index 0000000000..ab003a3e3d --- /dev/null +++ b/gflib/characters.h @@ -0,0 +1,350 @@ +#ifndef GUARD_CHARACTERS_H +#define GUARD_CHARACTERS_H + +#define CHAR_SPACE 0x00 +#define CHAR_A_GRAVE 0x01 +#define CHAR_A_ACUTE 0x02 +#define CHAR_A_CIRCUMFLEX 0x03 +#define CHAR_C_CEDILLA 0x04 +#define CHAR_E_GRAVE 0x05 +#define CHAR_E_ACUTE 0x06 +#define CHAR_E_CIRCUMFLEX 0x07 +#define CHAR_E_DIAERESIS 0x08 +#define CHAR_I_GRAVE 0x09 +//#define CHAR_I_ACUTE 0x0A // Is 0x5A instead +#define CHAR_I_CIRCUMFLEX 0x0B +#define CHAR_I_DIAERESIS 0x0C +#define CHAR_O_GRAVE 0x0D +#define CHAR_O_ACUTE 0x0E +#define CHAR_O_CIRCUMFLEX 0x0F +#define CHAR_OE 0x10 +#define CHAR_U_GRAVE 0x11 +#define CHAR_U_ACUTE 0x12 +#define CHAR_U_CIRCUMFLEX 0x13 +#define CHAR_N_TILDE 0x14 +#define CHAR_ESZETT 0x15 +#define CHAR_a_GRAVE 0x16 +#define CHAR_a_ACUTE 0x17 +//#define CHAR_a_CIRCUMFLEX 0x18 // Is 0x68 instead +#define CHAR_c_CEDILLA 0x19 +#define CHAR_e_GRAVE 0x1A +#define CHAR_e_ACUTE 0x1B +#define CHAR_e_CIRCUMFLEX 0x1C +#define CHAR_e_DIAERESIS 0x1D +#define CHAR_i_GRAVE 0x1E +//#define CHAR_i_ACUTE 0x1F // Is 0x6F instead +#define CHAR_i_CIRCUMFLEX 0x20 +#define CHAR_i_DIAERESIS 0x21 +#define CHAR_o_GRAVE 0x22 +#define CHAR_o_ACUTE 0x23 +#define CHAR_o_CIRCUMFLEX 0x24 +#define CHAR_oe 0x25 +#define CHAR_u_GRAVE 0x26 +#define CHAR_u_ACUTE 0x27 +#define CHAR_u_CIRCUMFLEX 0x28 +#define CHAR_n_TILDE 0x29 +#define CHAR_MASCULINE_ORDINAL 0x2A +#define CHAR_FEMININE_ORDINAL 0x2B +#define CHAR_SUPER_ER 0x2C +#define CHAR_AMPERSAND 0x2D +#define CHAR_PLUS 0x2E +// +#define CHAR_LV 0x34 +#define CHAR_EQUALS 0x35 +#define CHAR_SEMICOLON 0x36 +#define CHAR_BARD_WORD_DELIMIT 0x37 // Empty space to separate words in Bard's song +#define CHAR_INV_QUESTION_MARK 0x51 +#define CHAR_INV_EXCL_MARK 0x52 +#define CHAR_PK 0x53 +#define CHAR_MN 0x54 +#define CHAR_PO 0x55 +#define CHAR_KE 0x56 +#define CHAR_BLOCK_1 0x57 // Each of these 3 +#define CHAR_BLOCK_2 0x58 // chars contains 1/3 +#define CHAR_BLOCK_3 0x59 // of the word BLOCK +#define CHAR_I_ACUTE 0x5A +#define CHAR_PERCENT 0x5B +#define CHAR_LEFT_PAREN 0x5C +#define CHAR_RIGHT_PAREN 0x5D +// +#define CHAR_a_CIRCUMFLEX 0x68 +// +#define CHAR_i_ACUTE 0x6F +// +#define CHAR_SPACER 0x77 // Empty space +// +#define CHAR_UP_ARROW 0x79 +#define CHAR_DOWN_ARROW 0x7A +#define CHAR_LEFT_ARROW 0x7B +#define CHAR_RIGHT_ARROW 0x7C +// +#define CHAR_SUPER_E 0x84 +#define CHAR_LESS_THAN 0x85 +#define CHAR_GREATER_THAN 0x86 +// +#define CHAR_SUPER_RE 0xA0 +#define CHAR_0 0xA1 +#define CHAR_1 0xA2 +#define CHAR_2 0xA3 +#define CHAR_3 0xA4 +#define CHAR_4 0xA5 +#define CHAR_5 0xA6 +#define CHAR_6 0xA7 +#define CHAR_7 0xA8 +#define CHAR_8 0xA9 +#define CHAR_9 0xAA +#define CHAR_EXCL_MARK 0xAB +#define CHAR_QUESTION_MARK 0xAC +#define CHAR_PERIOD 0xAD +#define CHAR_HYPHEN 0xAE +#define CHAR_BULLET 0xAF +#define CHAR_ELLIPSIS 0xB0 +#define CHAR_DBL_QUOTE_LEFT 0xB1 +#define CHAR_DBL_QUOTE_RIGHT 0xB2 +#define CHAR_SGL_QUOTE_LEFT 0xB3 +#define CHAR_SGL_QUOTE_RIGHT 0xB4 +#define CHAR_MALE 0xB5 +#define CHAR_FEMALE 0xB6 +#define CHAR_CURRENCY 0xB7 +#define CHAR_COMMA 0xB8 +#define CHAR_MULT_SIGN 0xB9 +#define CHAR_SLASH 0xBA +#define CHAR_A 0xBB +#define CHAR_B 0xBC +#define CHAR_C 0xBD +#define CHAR_D 0xBE +#define CHAR_E 0xBF +#define CHAR_F 0xC0 +#define CHAR_G 0xC1 +#define CHAR_H 0xC2 +#define CHAR_I 0xC3 +#define CHAR_J 0xC4 +#define CHAR_K 0xC5 +#define CHAR_L 0xC6 +#define CHAR_M 0xC7 +#define CHAR_N 0xC8 +#define CHAR_O 0xC9 +#define CHAR_P 0xCA +#define CHAR_Q 0xCB +#define CHAR_R 0xCC +#define CHAR_S 0xCD +#define CHAR_T 0xCE +#define CHAR_U 0xCF +#define CHAR_V 0xD0 +#define CHAR_W 0xD1 +#define CHAR_X 0xD2 +#define CHAR_Y 0xD3 +#define CHAR_Z 0xD4 +#define CHAR_a 0xD5 +#define CHAR_b 0xD6 +#define CHAR_c 0xD7 +#define CHAR_d 0xD8 +#define CHAR_e 0xD9 +#define CHAR_f 0xDA +#define CHAR_g 0xDB +#define CHAR_h 0xDC +#define CHAR_i 0xDD +#define CHAR_j 0xDE +#define CHAR_k 0xDF +#define CHAR_l 0xE0 +#define CHAR_m 0xE1 +#define CHAR_n 0xE2 +#define CHAR_o 0xE3 +#define CHAR_p 0xE4 +#define CHAR_q 0xE5 +#define CHAR_r 0xE6 +#define CHAR_s 0xE7 +#define CHAR_t 0xE8 +#define CHAR_u 0xE9 +#define CHAR_v 0xEA +#define CHAR_w 0xEB +#define CHAR_x 0xEC +#define CHAR_y 0xED +#define CHAR_z 0xEE +#define CHAR_BLACK_TRIANGLE 0xEF +#define CHAR_COLON 0xF0 +#define CHAR_A_DIAERESIS 0xF1 +#define CHAR_O_DIAERESIS 0xF2 +#define CHAR_U_DIAERESIS 0xF3 +#define CHAR_a_DIAERESIS 0xF4 +#define CHAR_o_DIAERESIS 0xF5 +#define CHAR_u_DIAERESIS 0xF6 +#define CHAR_DYNAMIC 0xF7 +#define CHAR_KEYPAD_ICON 0xF8 +#define CHAR_EXTRA_SYMBOL 0xF9 +#define CHAR_PROMPT_SCROLL 0xFA // waits for button press and scrolls dialog +#define CHAR_PROMPT_CLEAR 0xFB // waits for button press and clears dialog +#define EXT_CTRL_CODE_BEGIN 0xFC // extended control code +#define PLACEHOLDER_BEGIN 0xFD // string placeholder +#define CHAR_NEWLINE 0xFE +#define EOS 0xFF // end of string + +// CHAR_KEYPAD_ICON chars +#define CHAR_A_BUTTON 0x00 +#define CHAR_B_BUTTON 0x01 +#define CHAR_L_BUTTON 0x02 +#define CHAR_R_BUTTON 0x03 +#define CHAR_START_BUTTON 0x04 +#define CHAR_SELECT_BUTTON 0x05 +#define CHAR_DPAD_UP 0x06 +#define CHAR_DPAD_DOWN 0x07 +#define CHAR_DPAD_LEFT 0x08 +#define CHAR_DPAD_RIGHT 0x09 +#define CHAR_DPAD_UPDOWN 0x0A +#define CHAR_DPAD_LEFTRIGHT 0x0B +#define CHAR_DPAD_NONE 0x0C + +// CHAR_EXTRA_SYMBOL chars +#define CHAR_UP_ARROW_2 0x00 +#define CHAR_DOWN_ARROW_2 0x01 +#define CHAR_LEFT_ARROW_2 0x02 +#define CHAR_RIGHT_ARROW_2 0x03 +#define CHAR_PLUS_2 0x04 +#define CHAR_LV_2 0x05 +#define CHAR_PP 0x06 +#define CHAR_ID 0x07 +#define CHAR_NO 0x08 +#define CHAR_UNDERSCORE 0x09 + +#define EXT_CTRL_CODE_COLOR 0x01 +#define EXT_CTRL_CODE_HIGHLIGHT 0x02 +#define EXT_CTRL_CODE_SHADOW 0x03 +#define EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW 0x04 +#define EXT_CTRL_CODE_PALETTE 0x05 +#define EXT_CTRL_CODE_FONT 0x06 +#define EXT_CTRL_CODE_RESET_SIZE 0x07 +#define EXT_CTRL_CODE_PAUSE 0x08 +#define EXT_CTRL_CODE_PAUSE_UNTIL_PRESS 0x09 +#define EXT_CTRL_CODE_WAIT_SE 0x0A +#define EXT_CTRL_CODE_PLAY_BGM 0x0B +#define EXT_CTRL_CODE_ESCAPE 0x0C +#define EXT_CTRL_CODE_SHIFT_TEXT 0x0D +#define EXT_CTRL_CODE_SHIFT_DOWN 0x0E +#define EXT_CTRL_CODE_FILL_WINDOW 0x0F +#define EXT_CTRL_CODE_PLAY_SE 0x10 +#define EXT_CTRL_CODE_CLEAR 0x11 +#define EXT_CTRL_CODE_SKIP 0x12 +#define EXT_CTRL_CODE_CLEAR_TO 0x13 +#define EXT_CTRL_CODE_MIN_LETTER_SPACING 0x14 +#define EXT_CTRL_CODE_JPN 0x15 +#define EXT_CTRL_CODE_ENG 0x16 +#define EXT_CTRL_CODE_PAUSE_MUSIC 0x17 +#define EXT_CTRL_CODE_RESUME_MUSIC 0x18 + +#define TEXT_COLOR_TRANSPARENT 0x0 +#define TEXT_COLOR_WHITE 0x1 +#define TEXT_COLOR_DARK_GRAY 0x2 +#define TEXT_COLOR_LIGHT_GRAY 0x3 +#define TEXT_COLOR_RED 0x4 +#define TEXT_COLOR_LIGHT_RED 0x5 +#define TEXT_COLOR_GREEN 0x6 +#define TEXT_COLOR_LIGHT_GREEN 0x7 +#define TEXT_COLOR_BLUE 0x8 +#define TEXT_COLOR_LIGHT_BLUE 0x9 +#define TEXT_DYNAMIC_COLOR_1 0xA // Usually white +#define TEXT_DYNAMIC_COLOR_2 0xB // Usually white w/ tinge of green +#define TEXT_DYNAMIC_COLOR_3 0xC // Usually white +#define TEXT_DYNAMIC_COLOR_4 0xD // Usually aquamarine +#define TEXT_DYNAMIC_COLOR_5 0xE // Usually blue-green +#define TEXT_DYNAMIC_COLOR_6 0xF // Usually cerulean + +#define FONT_0 0 +#define FONT_1 1 +#define FONT_2 2 +#define FONT_3 3 +#define FONT_4 4 +#define FONT_5 5 +#define FONT_6 6 +#define FONT_7 7 +#define FONT_8 8 + + +#define PLACEHOLDER_ID_UNKNOWN 0x0 +#define PLACEHOLDER_ID_PLAYER 0x1 +#define PLACEHOLDER_ID_STRING_VAR_1 0x2 +#define PLACEHOLDER_ID_STRING_VAR_2 0x3 +#define PLACEHOLDER_ID_STRING_VAR_3 0x4 +#define PLACEHOLDER_ID_KUN 0x5 +#define PLACEHOLDER_ID_RIVAL 0x6 +#define PLACEHOLDER_ID_VERSION 0x7 +#define PLACEHOLDER_ID_AQUA 0x8 +#define PLACEHOLDER_ID_MAGMA 0x9 +#define PLACEHOLDER_ID_ARCHIE 0xA +#define PLACEHOLDER_ID_MAXIE 0xB +#define PLACEHOLDER_ID_KYOGRE 0xC +#define PLACEHOLDER_ID_GROUDON 0xD + +// battle placeholders are located in battle_message.h + +// Hiragana from 0x1-0x50, Katakana from 0x51-0xA0. +// This excludes Japanese punctuation, which end at 0xB0 +#define JAPANESE_CHAR_END 0xA0 + +// Note that while all dot combinations are represented in +// the Braille font, they are not all meaningful characters. +// Only those that have direct single-character translations are listed. +#define BRAILLE_CHAR_SPACE 0x00 +#define BRAILLE_CHAR_A 0x01 +// +#define BRAILLE_CHAR_C 0x03 +#define BRAILLE_CHAR_COMMA 0x04 +#define BRAILLE_CHAR_B 0x05 +#define BRAILLE_CHAR_I 0x06 +#define BRAILLE_CHAR_F 0x07 +// +#define BRAILLE_CHAR_E 0x09 +// +#define BRAILLE_CHAR_D 0x0B +#define BRAILLE_CHAR_COLON 0x0C +#define BRAILLE_CHAR_H 0x0D +#define BRAILLE_CHAR_J 0x0E +#define BRAILLE_CHAR_G 0x0F +#define BRAILLE_CHAR_APOSTROPHE 0x10 +#define BRAILLE_CHAR_K 0x11 +#define BRAILLE_CHAR_SLASH 0x12 +#define BRAILLE_CHAR_M 0x13 +#define BRAILLE_CHAR_SEMICOLON 0x14 +#define BRAILLE_CHAR_L 0x15 +#define BRAILLE_CHAR_S 0x16 +#define BRAILLE_CHAR_P 0x17 +// +#define BRAILLE_CHAR_O 0x19 +// +#define BRAILLE_CHAR_N 0x1B +#define BRAILLE_CHAR_EXCL_MARK 0x1C +#define BRAILLE_CHAR_R 0x1D +#define BRAILLE_CHAR_T 0x1E +#define BRAILLE_CHAR_Q 0x1F +// +#define BRAILLE_CHAR_PERIOD 0x2C +// +#define BRAILLE_CHAR_W 0x2E +// +#define BRAILLE_CHAR_HYPHEN 0x30 +#define BRAILLE_CHAR_U 0x31 +// +#define BRAILLE_CHAR_X 0x33 +#define BRAILLE_CHAR_QUESTION_MARK 0x34 // Also double quote left +#define BRAILLE_CHAR_V 0x35 +// +#define BRAILLE_CHAR_DBL_QUOTE_RIGHT 0x38 +#define BRAILLE_CHAR_Z 0x39 +#define BRAILLE_CHAR_NUMBER 0x3A +#define BRAILLE_CHAR_Y 0x3B +#define BRAILLE_CHAR_PAREN 0x3C +// +#define NUM_BRAILLE_CHARS 0x40 + +// Digits must be preceded by BRAILLE_CHAR_NUMBER +#define BRAILLE_CHAR_1 BRAILLE_CHAR_A +#define BRAILLE_CHAR_2 BRAILLE_CHAR_B +#define BRAILLE_CHAR_3 BRAILLE_CHAR_C +#define BRAILLE_CHAR_4 BRAILLE_CHAR_D +#define BRAILLE_CHAR_5 BRAILLE_CHAR_E +#define BRAILLE_CHAR_6 BRAILLE_CHAR_F +#define BRAILLE_CHAR_7 BRAILLE_CHAR_G +#define BRAILLE_CHAR_8 BRAILLE_CHAR_H +#define BRAILLE_CHAR_9 BRAILLE_CHAR_I +#define BRAILLE_CHAR_0 BRAILLE_CHAR_J + +#endif // GUARD_CHARACTERS_H diff --git a/gflib/string_util.c b/gflib/string_util.c index 4bf0d2ae9b..9463b4a7b4 100644 --- a/gflib/string_util.c +++ b/gflib/string_util.c @@ -206,7 +206,7 @@ u8 *ConvertIntToDecimalStringN(u8 *dest, s32 value, enum StringConvertMode mode, } else if (state == WRITING_SPACES) { - *dest++ = 0x77; + *dest++ = CHAR_SPACER; } value = temp; @@ -262,7 +262,7 @@ u8 *ConvertUIntToDecimalStringN(u8 *dest, u32 value, enum StringConvertMode mode } else if (state == WRITING_SPACES) { - *dest++ = 0x77; + *dest++ = CHAR_SPACER; } value = temp; @@ -322,7 +322,7 @@ u8 *ConvertIntToHexStringN(u8 *dest, s32 value, enum StringConvertMode mode, u8 } else if (state == WRITING_SPACES) { - *dest++ = 0x77; + *dest++ = CHAR_SPACER; } value = temp; @@ -414,7 +414,7 @@ u8 *StringBraille(u8 *dest, const u8 *src) break; default: *dest++ = c; - *dest++ = c + 0x40; + *dest++ = c + NUM_BRAILLE_CHARS; break; } } diff --git a/gflib/text.h b/gflib/text.h index 9bb07580e0..91b9ef77ff 100644 --- a/gflib/text.h +++ b/gflib/text.h @@ -1,273 +1,7 @@ #ifndef GUARD_TEXT_H #define GUARD_TEXT_H -#define CHAR_SPACE 0x00 -#define CHAR_A_GRAVE 0x01 -#define CHAR_A_ACUTE 0x02 -#define CHAR_A_CIRCUMFLEX 0x03 -#define CHAR_C_CEDILLA 0x04 -#define CHAR_E_GRAVE 0x05 -#define CHAR_E_ACUTE 0x06 -#define CHAR_E_CIRCUMFLEX 0x07 -#define CHAR_E_DIAERESIS 0x08 -#define CHAR_I_GRAVE 0x09 -//#define CHAR_I_ACUTE 0x0A // Is 0x5A instead -#define CHAR_I_CIRCUMFLEX 0x0B -#define CHAR_I_DIAERESIS 0x0C -#define CHAR_O_GRAVE 0x0D -#define CHAR_O_ACUTE 0x0E -#define CHAR_O_CIRCUMFLEX 0x0F -#define CHAR_OE 0x10 -#define CHAR_U_GRAVE 0x11 -#define CHAR_U_ACUTE 0x12 -#define CHAR_U_CIRCUMFLEX 0x13 -#define CHAR_N_TILDE 0x14 -#define CHAR_ESZETT 0x15 -#define CHAR_a_GRAVE 0x16 -#define CHAR_a_ACUTE 0x17 -//#define CHAR_a_CIRCUMFLEX 0x18 // Is 0x68 instead -#define CHAR_c_CEDILLA 0x19 -#define CHAR_e_GRAVE 0x1A -#define CHAR_e_ACUTE 0x1B -#define CHAR_e_CIRCUMFLEX 0x1C -#define CHAR_e_DIAERESIS 0x1D -#define CHAR_i_GRAVE 0x1E -//#define CHAR_i_ACUTE 0x1F // Is 0x6F instead -#define CHAR_i_CIRCUMFLEX 0x20 -#define CHAR_i_DIAERESIS 0x21 -#define CHAR_o_GRAVE 0x22 -#define CHAR_o_ACUTE 0x23 -#define CHAR_o_CIRCUMFLEX 0x24 -#define CHAR_oe 0x25 -#define CHAR_u_GRAVE 0x26 -#define CHAR_u_ACUTE 0x27 -#define CHAR_u_CIRCUMFLEX 0x28 -#define CHAR_n_TILDE 0x29 -#define CHAR_MASCULINE_ORDINAL 0x2A -#define CHAR_FEMININE_ORDINAL 0x2B -#define CHAR_SUPER_ER 0x2C -#define CHAR_AMPERSAND 0x2D -#define CHAR_PLUS 0x2E -// -#define CHAR_LV 0x34 -#define CHAR_EQUALS 0x35 -#define CHAR_SEMICOLON 0x36 -#define CHAR_BARD_WORD_DELIMIT 0x37 // Empty space to separate words in Bard's song -#define CHAR_INV_QUESTION_MARK 0x51 -#define CHAR_INV_EXCL_MARK 0x52 -#define CHAR_PK 0x53 -#define CHAR_MN 0x54 -#define CHAR_PO 0x55 -#define CHAR_KE 0x56 -#define CHAR_BLOCK_1 0x57 // Each of these 3 -#define CHAR_BLOCK_2 0x58 // chars contains 1/3 -#define CHAR_BLOCK_3 0x59 // of the word BLOCK -#define CHAR_I_ACUTE 0x5A -#define CHAR_PERCENT 0x5B -#define CHAR_LEFT_PAREN 0x5C -#define CHAR_RIGHT_PAREN 0x5D -// -#define CHAR_a_CIRCUMFLEX 0x68 -// -#define CHAR_i_ACUTE 0x6F -// -#define CHAR_SPACER 0x77 // Empty space -// -#define CHAR_UP_ARROW 0x79 -#define CHAR_DOWN_ARROW 0x7A -#define CHAR_LEFT_ARROW 0x7B -#define CHAR_RIGHT_ARROW 0x7C -// -#define CHAR_SUPER_E 0x84 -#define CHAR_LESS_THAN 0x85 -#define CHAR_GREATER_THAN 0x86 -// -#define CHAR_SUPER_RE 0xA0 -#define CHAR_0 0xA1 -#define CHAR_1 0xA2 -#define CHAR_2 0xA3 -#define CHAR_3 0xA4 -#define CHAR_4 0xA5 -#define CHAR_5 0xA6 -#define CHAR_6 0xA7 -#define CHAR_7 0xA8 -#define CHAR_8 0xA9 -#define CHAR_9 0xAA -#define CHAR_EXCL_MARK 0xAB -#define CHAR_QUESTION_MARK 0xAC -#define CHAR_PERIOD 0xAD -#define CHAR_HYPHEN 0xAE -#define CHAR_BULLET 0xAF -#define CHAR_ELLIPSIS 0xB0 -#define CHAR_DBL_QUOT_LEFT 0xB1 -#define CHAR_DBL_QUOT_RIGHT 0xB2 -#define CHAR_SGL_QUOT_LEFT 0xB3 -#define CHAR_SGL_QUOT_RIGHT 0xB4 -#define CHAR_MALE 0xB5 -#define CHAR_FEMALE 0xB6 -#define CHAR_CURRENCY 0xB7 -#define CHAR_COMMA 0xB8 -#define CHAR_MULT_SIGN 0xB9 -#define CHAR_SLASH 0xBA -#define CHAR_A 0xBB -#define CHAR_B 0xBC -#define CHAR_C 0xBD -#define CHAR_D 0xBE -#define CHAR_E 0xBF -#define CHAR_F 0xC0 -#define CHAR_G 0xC1 -#define CHAR_H 0xC2 -#define CHAR_I 0xC3 -#define CHAR_J 0xC4 -#define CHAR_K 0xC5 -#define CHAR_L 0xC6 -#define CHAR_M 0xC7 -#define CHAR_N 0xC8 -#define CHAR_O 0xC9 -#define CHAR_P 0xCA -#define CHAR_Q 0xCB -#define CHAR_R 0xCC -#define CHAR_S 0xCD -#define CHAR_T 0xCE -#define CHAR_U 0xCF -#define CHAR_V 0xD0 -#define CHAR_W 0xD1 -#define CHAR_X 0xD2 -#define CHAR_Y 0xD3 -#define CHAR_Z 0xD4 -#define CHAR_a 0xD5 -#define CHAR_b 0xD6 -#define CHAR_c 0xD7 -#define CHAR_d 0xD8 -#define CHAR_e 0xD9 -#define CHAR_f 0xDA -#define CHAR_g 0xDB -#define CHAR_h 0xDC -#define CHAR_i 0xDD -#define CHAR_j 0xDE -#define CHAR_k 0xDF -#define CHAR_l 0xE0 -#define CHAR_m 0xE1 -#define CHAR_n 0xE2 -#define CHAR_o 0xE3 -#define CHAR_p 0xE4 -#define CHAR_q 0xE5 -#define CHAR_r 0xE6 -#define CHAR_s 0xE7 -#define CHAR_t 0xE8 -#define CHAR_u 0xE9 -#define CHAR_v 0xEA -#define CHAR_w 0xEB -#define CHAR_x 0xEC -#define CHAR_y 0xED -#define CHAR_z 0xEE -#define CHAR_BLACK_TRIANGLE 0xEF -#define CHAR_COLON 0xF0 -#define CHAR_A_DIAERESIS 0xF1 -#define CHAR_O_DIAERESIS 0xF2 -#define CHAR_U_DIAERESIS 0xF3 -#define CHAR_a_DIAERESIS 0xF4 -#define CHAR_o_DIAERESIS 0xF5 -#define CHAR_u_DIAERESIS 0xF6 -#define CHAR_DYNAMIC 0xF7 -#define CHAR_KEYPAD_ICON 0xF8 -#define CHAR_EXTRA_SYMBOL 0xF9 -#define CHAR_PROMPT_SCROLL 0xFA // waits for button press and scrolls dialog -#define CHAR_PROMPT_CLEAR 0xFB // waits for button press and clears dialog -#define EXT_CTRL_CODE_BEGIN 0xFC // extended control code -#define PLACEHOLDER_BEGIN 0xFD // string placeholder -#define CHAR_NEWLINE 0xFE -#define EOS 0xFF // end of string - -// CHAR_KEYPAD_ICON chars -#define CHAR_A_BUTTON 0x00 -#define CHAR_B_BUTTON 0x01 -#define CHAR_L_BUTTON 0x02 -#define CHAR_R_BUTTON 0x03 -#define CHAR_START_BUTTON 0x04 -#define CHAR_SELECT_BUTTON 0x05 -#define CHAR_DPAD_UP 0x06 -#define CHAR_DPAD_DOWN 0x07 -#define CHAR_DPAD_LEFT 0x08 -#define CHAR_DPAD_RIGHT 0x09 -#define CHAR_DPAD_UPDOWN 0x0A -#define CHAR_DPAD_LEFTRIGHT 0x0B -#define CHAR_DPAD_NONE 0x0C - -// CHAR_EXTRA_SYMBOL chars -#define CHAR_UP_ARROW_2 0x00 -#define CHAR_DOWN_ARROW_2 0x01 -#define CHAR_LEFT_ARROW_2 0x02 -#define CHAR_RIGHT_ARROW_2 0x03 -#define CHAR_PLUS_2 0x04 -#define CHAR_LV_2 0x05 -#define CHAR_PP 0x06 -#define CHAR_ID 0x07 -#define CHAR_NO 0x08 -#define CHAR_UNDERSCORE 0x09 - -#define EXT_CTRL_CODE_COLOR 0x01 -#define EXT_CTRL_CODE_HIGHLIGHT 0x02 -#define EXT_CTRL_CODE_SHADOW 0x03 -#define EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW 0x04 -#define EXT_CTRL_CODE_PALETTE 0x05 -#define EXT_CTRL_CODE_FONT 0x06 -#define EXT_CTRL_CODE_RESET_SIZE 0x07 -#define EXT_CTRL_CODE_PAUSE 0x08 -#define EXT_CTRL_CODE_PAUSE_UNTIL_PRESS 0x09 -#define EXT_CTRL_CODE_WAIT_SE 0x0A -#define EXT_CTRL_CODE_PLAY_BGM 0x0B -#define EXT_CTRL_CODE_ESCAPE 0x0C -#define EXT_CTRL_CODE_SHIFT_TEXT 0x0D -#define EXT_CTRL_CODE_SHIFT_DOWN 0x0E -#define EXT_CTRL_CODE_FILL_WINDOW 0x0F -#define EXT_CTRL_CODE_PLAY_SE 0x10 -#define EXT_CTRL_CODE_CLEAR 0x11 -#define EXT_CTRL_CODE_SKIP 0x12 -#define EXT_CTRL_CODE_CLEAR_TO 0x13 -#define EXT_CTRL_CODE_MIN_LETTER_SPACING 0x14 -#define EXT_CTRL_CODE_JPN 0x15 -#define EXT_CTRL_CODE_ENG 0x16 -#define EXT_CTRL_CODE_PAUSE_MUSIC 0x17 -#define EXT_CTRL_CODE_RESUME_MUSIC 0x18 - -#define TEXT_COLOR_TRANSPARENT 0x0 -#define TEXT_COLOR_WHITE 0x1 -#define TEXT_COLOR_DARK_GRAY 0x2 -#define TEXT_COLOR_LIGHT_GRAY 0x3 -#define TEXT_COLOR_RED 0x4 -#define TEXT_COLOR_LIGHT_RED 0x5 -#define TEXT_COLOR_GREEN 0x6 -#define TEXT_COLOR_LIGHT_GREEN 0x7 -#define TEXT_COLOR_BLUE 0x8 -#define TEXT_COLOR_LIGHT_BLUE 0x9 -#define TEXT_DYNAMIC_COLOR_1 0xA // Usually white -#define TEXT_DYNAMIC_COLOR_2 0xB // Usually white w/ tinge of green -#define TEXT_DYNAMIC_COLOR_3 0xC // Usually white -#define TEXT_DYNAMIC_COLOR_4 0xD // Usually aquamarine -#define TEXT_DYNAMIC_COLOR_5 0xE // Usually blue-green -#define TEXT_DYNAMIC_COLOR_6 0xF // Usually cerulean - -#define PLACEHOLDER_ID_UNKNOWN 0x0 -#define PLACEHOLDER_ID_PLAYER 0x1 -#define PLACEHOLDER_ID_STRING_VAR_1 0x2 -#define PLACEHOLDER_ID_STRING_VAR_2 0x3 -#define PLACEHOLDER_ID_STRING_VAR_3 0x4 -#define PLACEHOLDER_ID_KUN 0x5 -#define PLACEHOLDER_ID_RIVAL 0x6 -#define PLACEHOLDER_ID_VERSION 0x7 -#define PLACEHOLDER_ID_AQUA 0x8 -#define PLACEHOLDER_ID_MAGMA 0x9 -#define PLACEHOLDER_ID_ARCHIE 0xA -#define PLACEHOLDER_ID_MAXIE 0xB -#define PLACEHOLDER_ID_KYOGRE 0xC -#define PLACEHOLDER_ID_GROUDON 0xD - -// battle placeholders are located in battle_message.h - -// Hiragana from 0x1-0x50, Katakana from 0x51-0xA0. -// This excludes Japanese punctuation, which end at 0xB0 -#define JAPANESE_CHAR_END 0xA0 +#include "characters.h" #define NUM_TEXT_PRINTERS 32 diff --git a/src/contest.c b/src/contest.c index 05dd394832..aebe437e69 100644 --- a/src/contest.c +++ b/src/contest.c @@ -6031,10 +6031,10 @@ static u8 GetMonNicknameLanguage(u8 *nickname) || *nickname == CHAR_SLASH || *nickname == CHAR_HYPHEN || *nickname == CHAR_ELLIPSIS - || *nickname == CHAR_DBL_QUOT_LEFT - || *nickname == CHAR_DBL_QUOT_RIGHT - || *nickname == CHAR_SGL_QUOT_LEFT - || *nickname == CHAR_DBL_QUOT_LEFT) // Most likely a typo, CHAR_SGL_QUOT_RIGHT should be here instead. + || *nickname == CHAR_DBL_QUOTE_LEFT + || *nickname == CHAR_DBL_QUOTE_RIGHT + || *nickname == CHAR_SGL_QUOTE_LEFT + || *nickname == CHAR_DBL_QUOTE_LEFT) // Most likely a typo, CHAR_SGL_QUOTE_RIGHT should be here instead. { nickname++; } diff --git a/src/pokedex.c b/src/pokedex.c index 81d7c67305..d56b301833 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -4167,10 +4167,10 @@ static void PrintMonHeight(u16 height, u8 left, u8 top) buffer[i++] = feet / 10 + CHAR_0; buffer[i++] = (feet % 10) + CHAR_0; } - buffer[i++] = CHAR_SGL_QUOT_RIGHT; + buffer[i++] = CHAR_SGL_QUOTE_RIGHT; buffer[i++] = (inches / 10) + CHAR_0; buffer[i++] = (inches % 10) + CHAR_0; - buffer[i++] = CHAR_DBL_QUOT_RIGHT; + buffer[i++] = CHAR_DBL_QUOTE_RIGHT; buffer[i++] = EOS; PrintInfoScreenText(buffer, left, top); } diff --git a/src/union_room_chat.c b/src/union_room_chat.c index 7debe3cd4f..cb9b2f6a4b 100755 --- a/src/union_room_chat.c +++ b/src/union_room_chat.c @@ -458,10 +458,10 @@ static const u8 sCaseToggleTable[256] = { [CHAR_LEFT_PAREN] = CHAR_LEFT_PAREN, [CHAR_RIGHT_PAREN] = CHAR_RIGHT_PAREN, [CHAR_AMPERSAND] = CHAR_AMPERSAND, - [CHAR_DBL_QUOT_LEFT] = CHAR_DBL_QUOT_LEFT, - [CHAR_DBL_QUOT_RIGHT] = CHAR_DBL_QUOT_RIGHT, - [CHAR_SGL_QUOT_LEFT] = CHAR_SGL_QUOT_LEFT, - [CHAR_SGL_QUOT_RIGHT] = CHAR_SGL_QUOT_RIGHT, + [CHAR_DBL_QUOTE_LEFT] = CHAR_DBL_QUOTE_LEFT, + [CHAR_DBL_QUOTE_RIGHT] = CHAR_DBL_QUOTE_RIGHT, + [CHAR_SGL_QUOTE_LEFT] = CHAR_SGL_QUOTE_LEFT, + [CHAR_SGL_QUOTE_RIGHT] = CHAR_SGL_QUOTE_RIGHT, [CHAR_MASCULINE_ORDINAL] = CHAR_MASCULINE_ORDINAL, [CHAR_FEMININE_ORDINAL] = CHAR_FEMININE_ORDINAL, [CHAR_BULLET] = CHAR_BULLET, diff --git a/tools/preproc/asm_file.cpp b/tools/preproc/asm_file.cpp index 7756cadc52..be8d54fc4c 100644 --- a/tools/preproc/asm_file.cpp +++ b/tools/preproc/asm_file.cpp @@ -26,6 +26,7 @@ #include "char_util.h" #include "utf8.h" #include "string_parser.h" +#include "../../gflib/characters.h" AsmFile::AsmFile(std::string filename) : m_filename(filename) { @@ -281,7 +282,7 @@ int AsmFile::ReadString(unsigned char* s) while (length < padLength) { - s[length++] = 0; + s[length++] = CHAR_SPACE; } } @@ -290,40 +291,92 @@ int AsmFile::ReadString(unsigned char* s) return length; } +void AsmFile::VerifyStringLength(int length) +{ + if (length == kMaxStringLength) + RaiseError("mapped string longer than %d bytes", kMaxStringLength); +} + int AsmFile::ReadBraille(unsigned char* s) { static std::map encoding = { - { 'A', 0x01 }, - { 'B', 0x05 }, - { 'C', 0x03 }, - { 'D', 0x0B }, - { 'E', 0x09 }, - { 'F', 0x07 }, - { 'G', 0x0F }, - { 'H', 0x0D }, - { 'I', 0x06 }, - { 'J', 0x0E }, - { 'K', 0x11 }, - { 'L', 0x15 }, - { 'M', 0x13 }, - { 'N', 0x1B }, - { 'O', 0x19 }, - { 'P', 0x17 }, - { 'Q', 0x1F }, - { 'R', 0x1D }, - { 'S', 0x16 }, - { 'T', 0x1E }, - { 'U', 0x31 }, - { 'V', 0x35 }, - { 'W', 0x2E }, - { 'X', 0x33 }, - { 'Y', 0x3B }, - { 'Z', 0x39 }, - { ' ', 0x00 }, - { ',', 0x04 }, - { '.', 0x2C }, - { '$', 0xFF }, + { 'A', BRAILLE_CHAR_A }, + { 'B', BRAILLE_CHAR_B }, + { 'C', BRAILLE_CHAR_C }, + { 'D', BRAILLE_CHAR_D }, + { 'E', BRAILLE_CHAR_E }, + { 'F', BRAILLE_CHAR_F }, + { 'G', BRAILLE_CHAR_G }, + { 'H', BRAILLE_CHAR_H }, + { 'I', BRAILLE_CHAR_I }, + { 'J', BRAILLE_CHAR_J }, + { 'K', BRAILLE_CHAR_K }, + { 'L', BRAILLE_CHAR_L }, + { 'M', BRAILLE_CHAR_M }, + { 'N', BRAILLE_CHAR_N }, + { 'O', BRAILLE_CHAR_O }, + { 'P', BRAILLE_CHAR_P }, + { 'Q', BRAILLE_CHAR_Q }, + { 'R', BRAILLE_CHAR_R }, + { 'S', BRAILLE_CHAR_S }, + { 'T', BRAILLE_CHAR_T }, + { 'U', BRAILLE_CHAR_U }, + { 'V', BRAILLE_CHAR_V }, + { 'W', BRAILLE_CHAR_W }, + { 'X', BRAILLE_CHAR_X }, + { 'Y', BRAILLE_CHAR_Y }, + { 'Z', BRAILLE_CHAR_Z }, + { 'a', BRAILLE_CHAR_A }, + { 'b', BRAILLE_CHAR_B }, + { 'c', BRAILLE_CHAR_C }, + { 'd', BRAILLE_CHAR_D }, + { 'e', BRAILLE_CHAR_E }, + { 'f', BRAILLE_CHAR_F }, + { 'g', BRAILLE_CHAR_G }, + { 'h', BRAILLE_CHAR_H }, + { 'i', BRAILLE_CHAR_I }, + { 'j', BRAILLE_CHAR_J }, + { 'k', BRAILLE_CHAR_K }, + { 'l', BRAILLE_CHAR_L }, + { 'm', BRAILLE_CHAR_M }, + { 'n', BRAILLE_CHAR_N }, + { 'o', BRAILLE_CHAR_O }, + { 'p', BRAILLE_CHAR_P }, + { 'q', BRAILLE_CHAR_Q }, + { 'r', BRAILLE_CHAR_R }, + { 's', BRAILLE_CHAR_S }, + { 't', BRAILLE_CHAR_T }, + { 'u', BRAILLE_CHAR_U }, + { 'v', BRAILLE_CHAR_V }, + { 'w', BRAILLE_CHAR_W }, + { 'x', BRAILLE_CHAR_X }, + { 'y', BRAILLE_CHAR_Y }, + { 'z', BRAILLE_CHAR_Z }, + { '0', BRAILLE_CHAR_0 }, + { '1', BRAILLE_CHAR_1 }, + { '2', BRAILLE_CHAR_2 }, + { '3', BRAILLE_CHAR_3 }, + { '4', BRAILLE_CHAR_4 }, + { '5', BRAILLE_CHAR_5 }, + { '6', BRAILLE_CHAR_6 }, + { '7', BRAILLE_CHAR_7 }, + { '8', BRAILLE_CHAR_8 }, + { '9', BRAILLE_CHAR_9 }, + { ' ', BRAILLE_CHAR_SPACE }, + { ',', BRAILLE_CHAR_COMMA }, + { '.', BRAILLE_CHAR_PERIOD }, + { '?', BRAILLE_CHAR_QUESTION_MARK }, + { '!', BRAILLE_CHAR_EXCL_MARK }, + { ':', BRAILLE_CHAR_COLON }, + { ';', BRAILLE_CHAR_SEMICOLON }, + { '-', BRAILLE_CHAR_HYPHEN }, + { '/', BRAILLE_CHAR_PAREN }, + { '(', BRAILLE_CHAR_PAREN }, + { ')', BRAILLE_CHAR_PAREN }, + { '\'', BRAILLE_CHAR_APOSTROPHE }, + { '#', BRAILLE_CHAR_NUMBER }, + { '$', EOS }, }; SkipWhitespace(); @@ -335,14 +388,13 @@ int AsmFile::ReadBraille(unsigned char* s) m_pos++; + bool inNumber = false; while (m_buffer[m_pos] != '"') { - if (length == kMaxStringLength) - RaiseError("mapped string longer than %d bytes", kMaxStringLength); - if (m_buffer[m_pos] == '\\' && m_buffer[m_pos + 1] == 'n') { - s[length++] = 0xFE; + VerifyStringLength(length); + s[length++] = CHAR_NEWLINE; m_pos += 2; } else @@ -357,6 +409,21 @@ int AsmFile::ReadBraille(unsigned char* s) RaiseError("character '\\x%02X' not valid in braille string", m_buffer[m_pos]); } + if (!inNumber && c >= '0' && c <= '9' ) + { + // Output number indicator at start of a number + inNumber = true; + VerifyStringLength(length); + s[length++] = BRAILLE_CHAR_NUMBER; + } + else if (inNumber && encoding[c] == BRAILLE_CHAR_SPACE) + { + // Number ends at a space. + // Non-number characters encountered before a space will simply be output as is. + inNumber = false; + } + + VerifyStringLength(length); s[length++] = encoding[c]; m_pos++; } diff --git a/tools/preproc/asm_file.h b/tools/preproc/asm_file.h index d73b36e90b..29435f76a4 100644 --- a/tools/preproc/asm_file.h +++ b/tools/preproc/asm_file.h @@ -67,6 +67,7 @@ private: void ReportDiagnostic(const char* type, const char* format, std::va_list args); void RaiseError(const char* format, ...); void RaiseWarning(const char* format, ...); + void VerifyStringLength(int length); }; #endif // ASM_FILE_H