summaryrefslogtreecommitdiffstats
path: root/include/zx/charset.h
blob: 003e5f0f2ca0f47b32ff5cab318ccca1d1bdb890 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef _ZX_CHARSET_H
#define _ZX_CHARSET_H

#include <stdio.h>
#include <inttypes.h>

#define ZX81_CHARSET_LEN 64

#define ZX81_CHAR_TOKEN_LOW_START 0x40
#define ZX81_CHAR_TOKEN_LOW_END   0x42

#define ZX81_CHAR_TOKEN_HIGH_START 0xc0
#define ZX81_CHAR_TOKEN_HIGH_END   0xff

#define ZX81_CHAR_LOW(c) \
    (c < ZX81_CHARSET_LEN)

#define ZX81_CHAR_INVERSE_START 0x80
#define ZX81_CHAR_INVERSE_END   0xbf

#define ZX81_CHAR_INVERSE(c) \
    (c >= ZX81_CHAR_INVERSE_START && c <= ZX81_CHAR_INVERSE_END)

#define ZX81_CHAR_TOKEN_LOW(c) \
    (c >= ZX81_CHAR_TOKEN_LOW_START && c <= ZX81_CHAR_TOKEN_LOW_END)

#define ZX81_CHAR_NEWLINE(c) \
    (c == 0x76)

#define ZX81_CHAR_TOKEN_HIGH(c) \
    (c >= 0xc0)

#define ZX81_CHAR_TOKEN(c) \
    (ZX81_CHAR_TOKEN_LOW(c) || ZX81_CHAR_TOKEN_HIGH(c))

#define ZX81_CHAR_TOKEN_INTEGRAL(c) \
    (c == 0x0e)

#define ZX81_CHAR_TOKEN_FLOAT(c) \
    (c == 0x7e)

extern uint32_t zx81_charset[ZX81_CHARSET_LEN];

int zx81_fputc(uint8_t c, int inverse, FILE *stream);

#endif /* _ZX_CHARSET_H */