chiark / gitweb /
*** empty log message ***
[sympathy.git] / src / crt.h
1 /*
2  * crt.h:
3  *
4  * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
5  * All rights reserved.
6  *
7  */
8
9 /*
10  * $Id$
11  */
12
13 /*
14  * $Log$
15  * Revision 1.5  2008/02/07 12:41:06  james
16  * *** empty log message ***
17  *
18  * Revision 1.4  2008/02/07 12:16:04  james
19  * *** empty log message ***
20  *
21  * Revision 1.3  2008/02/06 11:30:37  james
22  * *** empty log message ***
23  *
24  * Revision 1.2  2008/02/04 20:23:55  james
25  * *** empty log message ***
26  *
27  * Revision 1.1  2008/02/03 23:31:25  james
28  * *** empty log message ***
29  *
30  */
31
32 #ifndef __CRT_H__
33 #define __CRT_H__
34
35 #define CRT_ROWS 25
36 #define CRT_COLS 80
37
38 #define CRT_CELS (CRT_ROWS*CRT_COLS)
39 #define CRT_ADDR(r,c) (((r)*CRT_COLS)+(c))
40 #define CRT_ADDR_POS(p) ((((p)->y)*CRT_COLS)+((p)->x))
41
42 #define CRT_ATTR_NORMAL    0x0
43 #define CRT_ATTR_UNDERLINE 0x1
44 #define CRT_ATTR_REVERSE   0x2
45 #define CRT_ATTR_BLINK     0x4
46 #define CRT_ATTR_BOLD      0x8
47
48
49 #define CRT_COLOR_BLACK         0x0     
50 #define CRT_COLOR_RED           0x1
51 #define CRT_COLOR_GREEN         0x2
52 #define CRT_COLOR_YELLOW        0x3
53 #define CRT_COLOR_BLUE          0x4
54 #define CRT_COLOR_MAGENTA       0x5
55 #define CRT_COLOR_CYAN          0x6
56 #define CRT_COLOR_WHITE         0x7
57 #define CRT_COLOR_INTENSITY     0x8
58
59 #define CRT_COLOR_FG_MASK       0xf0
60 #define CRT_COLOR_FG_SHIFT      4
61
62 #define CRT_COLOR_BG_MASK       0xf
63 #define CRT_COLOR_BG_SHIFT      0
64
65 #define CRT_COLOR_BG(a)         (((a) & CRT_COLOR_BG_MASK) >> CRT_COLOR_BG_SHIFT)
66 #define CRT_COLOR_FG(a)         (((a) & CRT_COLOR_FG_MASK) >> CRT_COLOR_FG_SHIFT)
67
68 #define CRT_MAKE_COLOR(f,b)     (((f) << CRT_COLOR_FG_SHIFT)|(b))
69
70 #define CRT_BGCOLOR_NORMAL      CRT_COLOR_BLACK
71 #define CRT_FGCOLOR_NORMAL      CRT_COLOR_WHITE
72
73 #define CRT_COLOR_NORMAL        CRT_MAKE_COLOR(CRT_FGCOLOR_NORMAL,CRT_BGCOLOR_NORMAL)
74
75 typedef struct
76 {
77   uint8_t chr;
78   uint8_t attr;
79   uint8_t color;
80 } CRT_CA;
81
82 typedef struct
83 {
84   int x;
85   int y;
86 } CRT_Pos;
87
88
89 typedef struct {
90   CRT_Pos s;
91   CRT_Pos e;
92   int dir;
93 } CRT_ScrollHint;
94
95 typedef struct
96 {
97   CRT_CA screen[CRT_CELS];
98   CRT_Pos pos;
99   CRT_ScrollHint sh;
100   int hide_cursor;
101 } CRT;
102
103
104 static inline
105 crt_ca_cmp (CRT_CA a, CRT_CA b)
106 {
107   return memcmp (&a, &b, sizeof (a));
108 }
109
110 #endif /* __CRT_H__ */