Add Bocfel interpreter
[projects/chimara/chimara.git] / interpreters / bocfel / unicode.h
1 #ifndef ZTERP_TABLES_H
2 #define ZTERP_TABLES_H
3
4 #include <stdint.h>
5
6 #ifdef ZTERP_GLK
7 #include <glk.h>
8 #endif
9
10 #define UNICODE_LINEFEED        10
11 #define UNICODE_SPACE           32
12 #define UNICODE_QUESTIONMARK    63
13
14 #define ZSCII_NEWLINE           13
15 #define ZSCII_SPACE             32
16 #define ZSCII_QUESTIONMARK      63
17
18 /* This variable controls whether Unicode is used for screen
19  * output.  This affects @check_unicode as well as the ZSCII to
20  * Unicode table.  With Glk it is set based on whether the Glk
21  * implementation supports Unicode (checked with the Unicode
22  * gestalt), and determines whether Unicode IO functions should
23  * be used; otherwise, it is kept in parallel with use_utf8_io.
24  */
25 extern int have_unicode;
26
27 extern uint16_t zscii_to_unicode[];
28 extern uint8_t unicode_to_zscii[];
29 extern uint8_t unicode_to_zscii_q[];
30 extern uint8_t unicode_to_latin1[];
31 extern uint16_t zscii_to_font3[];
32 extern int atable_pos[];
33
34 void parse_unicode_table(uint16_t);
35 void setup_tables(void);
36
37 uint16_t unicode_tolower(uint16_t);
38
39 /* Standard 1.1 notes that Unicode characters 0–31 and 127–159
40  * are invalid due to the fact that they’re control codes.
41  */
42 static inline int valid_unicode(uint16_t c) { return (c >= 32 && c <= 126) || c >= 160; }
43
44 #endif