1 /*- 2 * Copyright (c) 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)screen.h 8.1 (Berkeley) 06/06/93 8 */ 9 10 #define INCLUDED_SCREEN 11 12 /* defines and defines to describe how to deal with the screen */ 13 14 #if !defined(MSDOS) 15 #define MAXNUMBERLINES 43 /* 3278-4 */ 16 #define MAXNUMBERCOLUMNS 132 /* 3278-5 */ 17 #define MAXSCREENSIZE 3564 /* (27*132) 3278-5 */ 18 #else /* !defined(MSDOS) */ /* MSDOS has memory constraints */ 19 #define MAXNUMBERLINES 25 /* XXX */ 20 #define MAXNUMBERCOLUMNS 80 21 #define MAXSCREENSIZE (MAXNUMBERLINES*MAXNUMBERCOLUMNS) 22 #endif /* !defined(MSDOS) */ /* MSDOS has memory constraints */ 23 #define LowestScreen() 0 24 #define HighestScreen() (ScreenSize-1) 25 26 #define ScreenLineOffset(x) ((x)%NumberColumns) 27 #define ScreenLine(x) ((int)((x)/NumberColumns)) 28 #define ScreenInc(x) (((x)==HighestScreen())? LowestScreen():x+1) 29 #define ScreenDec(x) (((x)==LowestScreen())? HighestScreen():x-1) 30 #define ScreenUp(x) (((x)+(ScreenSize-NumberColumns))%ScreenSize) 31 #define ScreenDown(x) (((x)+NumberColumns)%ScreenSize) 32 #define IsOrder(x) (Orders[x]) 33 #define BAIC(x) ((x)&0x3f) 34 #define CIAB(x) (CIABuffer[(x)&0x3f]) 35 #define BufferTo3270_0(x) (CIABuffer[(int)((x)/0x40)]) 36 #define BufferTo3270_1(x) (CIABuffer[(x)&0x3f]) 37 #define Addr3270(x,y) (BAIC(x)*64+BAIC(y)) 38 #define SetBufferAddress(x,y) ((x)*NumberColumns+(y)) 39 40 /* These know how fields are implemented... */ 41 42 #define WhereAttrByte(p) (IsStartField(p)? p: FieldDec(p)) 43 #define WhereHighByte(p) ScreenDec(FieldInc(p)) 44 #define WhereLowByte(p) ScreenInc(WhereAttrByte(p)) 45 #define FieldAttributes(x) (IsStartField(x)? GetHost(x) : \ 46 GetHost(WhereAttrByte(x))) 47 #define FieldAttributesPointer(p) (IsStartFieldPointer(p)? \ 48 GetHostPointer(p): \ 49 GetHost(WhereAttrByte((p)-&Host[0]))) 50 51 /* 52 * The MDT functions need to protect against the case where the screen 53 * is unformatted (sigh). 54 */ 55 56 /* Turn off the Modified Data Tag */ 57 #define TurnOffMdt(x) \ 58 if (HasMdt(WhereAttrByte(x))) { \ 59 ModifyMdt(x, 0); \ 60 } 61 62 /* Turn on the Modified Data Tag */ 63 #define TurnOnMdt(x) \ 64 if (!HasMdt(WhereAttrByte(x))) { \ 65 ModifyMdt(x, 1); \ 66 } 67 68 /* If this location has the MDT bit turned on (implies start of field) ... */ 69 #define HasMdt(x) \ 70 ((GetHost(x)&(ATTR_MDT|ATTR_MASK)) == (ATTR_MDT|ATTR_MASK)) 71 72 /* 73 * Is the screen formatted? Some algorithms change depending 74 * on whether there are any attribute bytes lying around. 75 */ 76 #define FormattedScreen() \ 77 ((WhereAttrByte(0) != 0) || ((GetHost(0)&ATTR_MASK) == ATTR_MASK)) 78 79 /* field starts here */ 80 #define IsStartField(x) ((GetHost(x)&ATTR_MASK) == ATTR_MASK) 81 #define IsStartFieldPointer(p) ((GetHostPointer(p)&ATTR_MASK) == ATTR_MASK) 82 83 #define NewField(p,a) SetHost(p, (a)|ATTR_MASK) 84 #define DeleteField(p) SetHost(p, 0) 85 #define DeleteAllFields() 86 87 /* The following are independent of the implementation of fields */ 88 #define IsProtectedAttr(p,a) (IsStartField(p) || ((a)&ATTR_PROT)) 89 #define IsProtected(p) IsProtectedAttr(p,FieldAttributes(p)) 90 91 #define IsUnProtected(x) (!IsProtected(x)) 92 93 #define IsAutoSkip(x) (FieldAttributes(x)&ATTR_AUTO_SKIP) 94 95 #define IsNonDisplayAttr(c) (((c)&ATTR_DSPD_MASK) == ATTR_DSPD_NONDISPLAY) 96 #define IsNonDisplay(p) IsNonDisplayAttr(FieldAttributes(p)) 97 98 #define IsHighlightedAttr(c) \ 99 (((c)&ATTR_DSPD_MASK) == ATTR_DSPD_HIGH) 100 #define IsHighlighted(p) \ 101 (IsHighlightedAttr(FieldAttributes(p)) && !IsStartField(p)) 102 103 typedef unsigned char ScreenImage; 104 105 extern int 106 FieldFind(); 107 108 extern char 109 CIABuffer[]; 110 111 #define GetGeneric(i,h) (h)[i] 112 #define GetGenericPointer(p) (*(p)) 113 #define SetGeneric(i,c,h) ((h)[i] = (c)) 114 #define ModifyGeneric(i,what,h) {(h)[i] what;} 115 116 #define GetHost(i) GetGeneric(i,Host) 117 #define GetHostPointer(p) GetGenericPointer(p) 118 #define SetHost(i,c) SetGeneric(i,c,Host) 119 #define ModifyHost(i,what) ModifyGeneric(i,what,Host) 120