1 /* $NetBSD: screen.h,v 1.4 1998/03/04 13:16:08 christos Exp $ */
4 * Copyright (c) 1988 The Regents of the University of California.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * from: @(#)screen.h 4.3 (Berkeley) 4/26/91
34 #define INCLUDED_SCREEN
36 /* defines and defines to describe how to deal with the screen */
39 #define MAXNUMBERLINES 43 /* 3278-4 */
40 #define MAXNUMBERCOLUMNS 132 /* 3278-5 */
41 #define MAXSCREENSIZE 3564 /* (27*132) 3278-5 */
42 #else /* !defined(MSDOS) */ /* MSDOS has memory constraints */
43 #define MAXNUMBERLINES 25 /* XXX */
44 #define MAXNUMBERCOLUMNS 80
45 #define MAXSCREENSIZE (MAXNUMBERLINES*MAXNUMBERCOLUMNS)
46 #endif /* !defined(MSDOS) */ /* MSDOS has memory constraints */
47 #define LowestScreen() 0
48 #define HighestScreen() (ScreenSize-1)
50 #define ScreenLineOffset(x) ((x)%NumberColumns)
51 #define ScreenLine(x) ((int)((x)/NumberColumns))
52 #define ScreenInc(x) (((x)==HighestScreen())? LowestScreen():x+1)
53 #define ScreenDec(x) (((x)==LowestScreen())? HighestScreen():x-1)
54 #define ScreenUp(x) (((x)+(ScreenSize-NumberColumns))%ScreenSize)
55 #define ScreenDown(x) (((x)+NumberColumns)%ScreenSize)
56 #define IsOrder(x) (Orders[x])
57 #define BAIC(x) ((x)&0x3f)
58 #define CIAB(x) (CIABuffer[(x)&0x3f])
59 #define BufferTo3270_0(x) (CIABuffer[(int)((x)/0x40)])
60 #define BufferTo3270_1(x) (CIABuffer[(x)&0x3f])
61 #define Addr3270(x,y) (BAIC(x)*64+BAIC(y))
62 #define SetBufferAddress(x,y) ((x)*NumberColumns+(y))
64 /* These know how fields are implemented... */
66 #define WhereAttrByte(p) (IsStartField(p)? p: FieldDec(p))
67 #define WhereHighByte(p) ScreenDec(FieldInc(p))
68 #define WhereLowByte(p) ScreenInc(WhereAttrByte(p))
69 #define FieldAttributes(x) (IsStartField(x)? GetHost(x) : \
70 GetHost(WhereAttrByte(x)))
71 #define FieldAttributesPointer(p) (IsStartFieldPointer(p)? \
73 GetHost(WhereAttrByte((p)-&Host[0])))
76 * The MDT functions need to protect against the case where the screen
77 * is unformatted (sigh).
80 /* Turn off the Modified Data Tag */
81 #define TurnOffMdt(x) \
82 if (HasMdt(WhereAttrByte(x))) { \
86 /* Turn on the Modified Data Tag */
87 #define TurnOnMdt(x) \
88 if (!HasMdt(WhereAttrByte(x))) { \
92 /* If this location has the MDT bit turned on (implies start of field) ... */
94 ((GetHost(x)&(ATTR_MDT|ATTR_MASK)) == (ATTR_MDT|ATTR_MASK))
97 * Is the screen formatted? Some algorithms change depending
98 * on whether there are any attribute bytes lying around.
100 #define FormattedScreen() \
101 ((WhereAttrByte(0) != 0) || ((GetHost(0)&ATTR_MASK) == ATTR_MASK))
103 /* field starts here */
104 #define IsStartField(x) ((GetHost(x)&ATTR_MASK) == ATTR_MASK)
105 #define IsStartFieldPointer(p) ((GetHostPointer(p)&ATTR_MASK) == ATTR_MASK)
107 #define NewField(p,a) SetHost(p, (a)|ATTR_MASK)
108 #define DeleteField(p) SetHost(p, 0)
109 #define DeleteAllFields()
111 /* The following are independent of the implementation of fields */
112 #define IsProtectedAttr(p,a) (IsStartField(p) || ((a)&ATTR_PROT))
113 #define IsProtected(p) IsProtectedAttr(p,FieldAttributes(p))
115 #define IsUnProtected(x) (!IsProtected(x))
117 #define IsAutoSkip(x) (FieldAttributes(x)&ATTR_AUTO_SKIP)
119 #define IsNonDisplayAttr(c) (((c)&ATTR_DSPD_MASK) == ATTR_DSPD_NONDISPLAY)
120 #define IsNonDisplay(p) IsNonDisplayAttr(FieldAttributes(p))
122 #define IsHighlightedAttr(c) \
123 (((c)&ATTR_DSPD_MASK) == ATTR_DSPD_HIGH)
124 #define IsHighlighted(p) \
125 (IsHighlightedAttr(FieldAttributes(p)) && !IsStartField(p))
127 typedef unsigned char ScreenImage
;
132 #define GetGeneric(i,h) (h)[i]
133 #define GetGenericPointer(p) (*(p))
134 #define SetGeneric(i,c,h) ((h)[i] = (c))
135 #define ModifyGeneric(i,what,h) {(h)[i] what;}
137 #define GetHost(i) GetGeneric(i,Host)
138 #define GetHostPointer(p) GetGenericPointer(p)
139 #define SetHost(i,c) SetGeneric(i,c,Host)
140 #define ModifyHost(i,what) ModifyGeneric(i,what,Host)