chiark / gitweb /
serialmgrd: Support recent versions of perl
[sympathy.git] / src / crt.h
1 /* 
2  * crt.h:
3  *
4  * Copyright (c) 2008 James McKenzie <sympathy@madingley.org>,
5  * All rights reserved.
6  *
7  */
8
9 /* 
10  * $Id: crt.h,v 1.18 2008/03/10 11:49:33 james Exp $
11  */
12
13 /* 
14  * $Log: crt.h,v $
15  * Revision 1.18  2008/03/10 11:49:33  james
16  * *** empty log message ***
17  *
18  * Revision 1.17  2008/03/07 12:37:04  james
19  * *** empty log message ***
20  *
21  * Revision 1.16  2008/03/03 06:04:42  james
22  * *** empty log message ***
23  *
24  * Revision 1.15  2008/03/02 10:37:56  james
25  * *** empty log message ***
26  *
27  * Revision 1.14  2008/02/28 16:57:51  james
28  * *** empty log message ***
29  *
30  * Revision 1.13  2008/02/27 09:42:22  james
31  * *** empty log message ***
32  *
33  * Revision 1.12  2008/02/26 23:23:17  james
34  * *** empty log message ***
35  *
36  * Revision 1.11  2008/02/26 19:08:27  james
37  * *** empty log message ***
38  *
39  * Revision 1.10  2008/02/24 00:42:53  james
40  * *** empty log message ***
41  *
42  * Revision 1.9  2008/02/20 19:25:09  james
43  * *** empty log message ***
44  *
45  * Revision 1.8  2008/02/13 09:12:21  james
46  * *** empty log message ***
47  *
48  * Revision 1.7  2008/02/13 01:08:18  james
49  * *** empty log message ***
50  *
51  * Revision 1.6  2008/02/07 13:22:51  james
52  * *** empty log message ***
53  *
54  * Revision 1.5  2008/02/07 12:41:06  james
55  * *** empty log message ***
56  *
57  * Revision 1.4  2008/02/07 12:16:04  james
58  * *** empty log message ***
59  *
60  * Revision 1.3  2008/02/06 11:30:37  james
61  * *** empty log message ***
62  *
63  * Revision 1.2  2008/02/04 20:23:55  james
64  * *** empty log message ***
65  *
66  * Revision 1.1  2008/02/03 23:31:25  james
67  * *** empty log message ***
68  *
69  */
70
71 #ifndef __CRT_H__
72 #define __CRT_H__
73
74 #define CRT_ROWS 60
75 #define CRT_COLS 132
76
77 #define CRT_CELS (CRT_ROWS*CRT_COLS)
78 #define CRT_ADDR(r,c) (((r)*CRT_COLS)+(c))
79 #define CRT_ADDR_POS(p) ((((p)->y)*CRT_COLS)+((p)->x))
80
81 #define CRT_ATTR_NORMAL    0x0
82 #define CRT_ATTR_UNDERLINE 0x1
83 #define CRT_ATTR_REVERSE   0x2
84 #define CRT_ATTR_BLINK     0x4
85 #define CRT_ATTR_BOLD      0x8
86
87
88 #define CRT_COLOR_BLACK         0x0
89 #define CRT_COLOR_RED           0x1
90 #define CRT_COLOR_GREEN         0x2
91 #define CRT_COLOR_YELLOW        0x3
92 #define CRT_COLOR_BLUE          0x4
93 #define CRT_COLOR_MAGENTA       0x5
94 #define CRT_COLOR_CYAN          0x6
95 #define CRT_COLOR_WHITE         0x7
96 #define CRT_COLOR_INTENSITY     0x8
97
98 #define CRT_COLOR_FG_MASK       0xf0
99 #define CRT_COLOR_FG_SHIFT      4
100
101 #define CRT_COLOR_BG_MASK       0xf
102 #define CRT_COLOR_BG_SHIFT      0
103
104 #define CRT_COLOR_BG(a)         (((a) & CRT_COLOR_BG_MASK) >> CRT_COLOR_BG_SHIFT)
105 #define CRT_COLOR_FG(a)         (((a) & CRT_COLOR_FG_MASK) >> CRT_COLOR_FG_SHIFT)
106
107 #define CRT_MAKE_COLOR(f,b)     (((f) << CRT_COLOR_FG_SHIFT)|(b))
108
109 #define CRT_BGCOLOR_NORMAL      CRT_COLOR_BLACK
110 #define CRT_FGCOLOR_NORMAL      CRT_COLOR_WHITE
111
112 #define CRT_COLOR_NORMAL        CRT_MAKE_COLOR(CRT_FGCOLOR_NORMAL,CRT_BGCOLOR_NORMAL)
113
114 typedef struct __attribute__ ((packed)) {
115   uint32_t chr;
116   uint8_t attr;
117   uint8_t color;
118 } CRT_CA;
119
120 typedef struct {
121   int x;
122   int y;
123 } CRT_Pos;
124
125
126 typedef struct {
127   CRT_Pos s;
128   CRT_Pos e;
129   int dir;
130 } CRT_ScrollHint;
131
132 typedef struct CRT_struct {
133   CRT_CA screen[CRT_CELS];
134   CRT_Pos pos;
135   int hide_cursor;
136   CRT_Pos size;
137 } CRT;
138
139
140 static inline
141 crt_ca_cmp (CRT_CA a, CRT_CA b)
142 {
143   return memcmp (&a, &b, sizeof (a));
144 }
145
146 static inline
147 crt_pos_cmp (CRT_Pos a, CRT_Pos b)
148 {
149   return memcmp (&a, &b, sizeof (a));
150 }
151
152 #endif /* __CRT_H__ */