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