summaryrefslogtreecommitdiff
path: root/src/image.h
blob: fa0f79e6ef3907b0fb7459d07c3df52fc8a556eb (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* Copyright (c) 2008, 2009
 *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
 *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
 *      Micah Cowan (micah@cowan.name)
 *      Sadrul Habib Chowdhury (sadrul@users.sourceforge.net)
 * Copyright (c) 1993-2002, 2003, 2005, 2006, 2007
 *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
 *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
 * Copyright (c) 1987 Oliver Laumann
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program (see the file COPYING); if not, see
 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 *
 ****************************************************************
 * $Id$ GNU
 */

struct mchar {
	unsigned char image;
	unsigned char attr;
	unsigned char font;
	unsigned char fontx;
	unsigned char color;
	unsigned char colorx;
	unsigned char mbcs;
};

struct mline {
	unsigned char *image;
	unsigned char *attr;
	unsigned char *font;
	unsigned char *fontx;
	unsigned char *color;
	unsigned char *colorx;
};



#define save_mline(ml, n) do { \
	memmove((char *)mline_old.image, (char *)(ml)->image, (n)); \
	memmove((char *)mline_old.attr,  (char *)(ml)->attr,  (n)); \
	memmove((char *)mline_old.font,  (char *)(ml)->font,  (n)); \
	memmove((char *)mline_old.fontx, (char *)(ml)->fontx, (n)); \
	memmove((char *)mline_old.color, (char *)(ml)->color, (n)); \
	memmove((char *)mline_old.colorx,(char *)(ml)->colorx,(n)); \
} while (0)

#define bcopy_mline(ml, xf, xt, n) do { \
	memmove((char *)(ml)->image + (xt), (char *)(ml)->image + (xf), (n)); \
	memmove((char *)(ml)->attr  + (xt), (char *)(ml)->attr  + (xf), (n)); \
	memmove((char *)(ml)->font  + (xt), (char *)(ml)->font  + (xf), (n)); \
	memmove((char *)(ml)->fontx + (xt), (char *)(ml)->fontx + (xf), (n)); \
	memmove((char *)(ml)->color + (xt), (char *)(ml)->color + (xf), (n)); \
	memmove((char *)(ml)->colorx + (xt),(char *)(ml)->colorx + (xf),(n)); \
} while (0)

#define clear_mline(ml, x, n) do { \
	bclear((char *)(ml)->image + (x), (n)); \
	if ((ml)->attr != null) memset((char *)(ml)->attr  + (x), 0, (n));   \
	if ((ml)->font != null) memset((char *)(ml)->font  + (x), 0, (n));   \
	if ((ml)->fontx != null) memset((char *)(ml)->fontx + (x), 0, (n));  \
	if ((ml)->color!= null) memset((char *)(ml)->color + (x), 0, (n));   \
	if ((ml)->colorx!= null) memset((char *)(ml)->colorx + (x), 0, (n)); \
} while (0)

#define cmp_mline(ml1, ml2, x) (		\
	   (ml1)->image[x] == (ml2)->image[x]	\
	&& (ml1)->attr[x]  == (ml2)->attr[x]	\
	&& (ml1)->font[x]  == (ml2)->font[x]	\
	&& (ml1)->fontx[x] == (ml2)->fontx[x]	\
	&& (ml1)->color[x] == (ml2)->color[x]	\
	&& (ml1)->colorx[x] == (ml2)->colorx[x]	\
)

#define cmp_mchar(mc1, mc2) (			\
	   (mc1)->image == (mc2)->image		\
	&& (mc1)->attr  == (mc2)->attr		\
	&& (mc1)->font  == (mc2)->font		\
	&& (mc1)->fontx == (mc2)->fontx		\
	&& (mc1)->color == (mc2)->color		\
	&& (mc1)->colorx == (mc2)->colorx	\
)

#define cmp_mchar_mline(mc, ml, x) (		\
	   (mc)->image == (ml)->image[x]	\
	&& (mc)->attr  == (ml)->attr[x]		\
	&& (mc)->font  == (ml)->font[x]		\
	&& (mc)->fontx == (ml)->fontx[x]	\
	&& (mc)->color == (ml)->color[x]	\
	&& (mc)->colorx == (ml)->colorx[x]	\
)

#define copy_mchar2mline(mc, ml, x) do {	\
	(ml)->image[x] = (mc)->image;		\
	(ml)->attr[x]  = (mc)->attr;		\
	(ml)->font[x]  = (mc)->font;		\
	(ml)->fontx[x] = (mc)->fontx;		\
	(ml)->color[x] = (mc)->color;		\
	(ml)->colorx[x] = (mc)->colorx;		\
} while (0)

#define copy_mline2mchar(mc, ml, x) do {	\
	(mc)->image = (ml)->image[x];		\
	(mc)->attr  = (ml)->attr[x];		\
	(mc)->font  = (ml)->font[x];		\
	(mc)->fontx = (ml)->fontx[x];		\
	(mc)->color = (ml)->color[x];		\
	(mc)->colorx = (ml)->colorx[x];		\
	(mc)->mbcs  = 0;			\
} while (0)

#define rend_getbg(mc) (((mc)->color & 0xf0) >> 4 | ((mc)->attr & A_BBG ? 0x100 : 0) | ((mc)->colorx & 0xf0))
#define rend_setbg(mc, c) ((mc)->color = ((mc)->color & 0x0f) | (c << 4 & 0xf0), (mc)->colorx = ((mc)->colorx & 0x0f) | (c & 0xf0), (mc)->attr = ((mc)->attr | A_BBG) ^ (c & 0x100 ? 0 : A_BBG))
#define rend_getfg(mc) (((mc)->color & 0x0f) | ((mc)->attr & A_BFG ? 0x100 : 0) | (((mc)->colorx & 0x0f) << 4))
#define rend_setfg(mc, c) ((mc)->color = ((mc)->color & 0xf0) | (c & 0x0f), (mc)->colorx = ((mc)->colorx & 0xf0) | ((c & 0xf0) >> 4), (mc)->attr = ((mc)->attr | A_BFG) ^ (c & 0x100 ? 0 : A_BFG))
#define rend_setdefault(mc) ((mc)->color = (mc)->colorx = 0, (mc)->attr &= ~(A_BBG|A_BFG))

#define coli2e(c) ((((c) & 0x1f8) == 0x108 ? (c) ^ 0x108 : (c & 0xff)) ^ 9)
#define cole2i(c) ((c) >= 8 && (c) < 16 ? (c) ^ 0x109 : (c) ^ 9)
enum
{
  REND_BELL = 0,
  REND_MONITOR,
  REND_SILENCE,
  NUM_RENDS
};