]> git.sur5r.net Git - c128-kasse/blob - include/general.h
kasse: use cgetn_input() to simplify logic
[c128-kasse] / include / general.h
1 #ifndef GENERAL_H_
2 #define GENERAL_H_
3
4 #include <peekpoke.h>
5
6 typedef unsigned char BYTE;
7 typedef enum {
8   INPUT_TERMINATOR_RETURN = (1 << 0),
9   INPUT_TERMINATOR_SPACE = (1 << 1),
10 } input_terminator_t;
11 typedef input_terminator_t input_terminator_mask_t;
12 input_terminator_t get_input_terminated_by(input_terminator_mask_t terminators,
13                                            char *out, BYTE outlen);
14 char *get_input(void);
15 BYTE cgetn_input(char *s, BYTE len);
16 void cget_return(void);
17 char retry_or_quit(void);
18 char *format_euro(char *s, int maxlen, int cent);
19 void c128_perror(BYTE, char *);
20 extern BYTE _oserror;
21
22 /* C128 color codes, see PDF page 127 of
23  * http://www.pagetable.com/docs/Commodore%20128%20Programmer%27s%20Reference%20Guide.pdf
24  */
25 #define TC_BLACK 0
26 #define TC_WHITE 1
27 #define TC_RED 2
28 #define TC_CYAN 3
29 #define TC_PURPLE 4
30 #define TC_GREEN 5
31 #define TC_BLUE 6
32 #define TC_YELLOW 7
33 #define TC_ORANGE 8
34 #define TC_BROWN 9
35 /* This is the good red */
36 #define TC_LIGHT_RED 10
37 #define TC_DARK_GRAY 11
38 #define TC_MEDIUM_GRAY 12
39 /* This is the good green */
40 #define TC_LIGHT_GREEN 13
41 #define TC_LIGHT_BLUE 14
42 #define TC_LIGHT_GRAY 15
43
44 /* Carriage return */
45 #define PETSCII_CR 13
46 /* Delete */
47 #define PETSCII_DEL 20
48 /* Escape */
49 #define PETSCII_ESC 27
50 /* Space */
51 #define PETSCII_SP 32
52 #define PETSCII_0 48
53 #define PETSCII_1 49
54 #define PETSCII_2 50
55 #define PETSCII_3 51
56 #define PETSCII_4 52
57 #define PETSCII_5 53
58 #define PETSCII_6 54
59 #define PETSCII_7 55
60 #define PETSCII_8 56
61 #define PETSCII_9 57
62
63 #define VIDEOMODE (((*(BYTE *)0xD7) == 0x80) ? 80 : 40)
64
65 /* because there is no macro expansion when stringifying, we need to use two
66  * levels of macros to stringify the value of a macro (for example
67  * MAX_ITEM_NAME_LENGTH) */
68 #define xstr(s) str(s)
69 #define str(s) #s
70
71 #define max(a, b) ((a) > (b) ? (a) : (b))
72 #define min(a, b) ((a) > (b) ? (b) : (a))
73
74 #endif /*GENERAL_H_*/