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