|
|
1.1 ! root 1: /* ! 2: * Copyright 1984, 1985 by the Regents of the University of ! 3: * California and by Gregory Glenn Minshall. ! 4: * ! 5: * Permission to use, copy, modify, and distribute these ! 6: * programs and their documentation for any purpose and ! 7: * without fee is hereby granted, provided that this ! 8: * copyright and permission appear on all copies and ! 9: * supporting documentation, the name of the Regents of ! 10: * the University of California not be used in advertising ! 11: * or publicity pertaining to distribution of the programs ! 12: * without specific prior permission, and notice be given in ! 13: * supporting documentation that copying and distribution is ! 14: * by permission of the Regents of the University of California ! 15: * and by Gregory Glenn Minshall. Neither the Regents of the ! 16: * University of California nor Gregory Glenn Minshall make ! 17: * representations about the suitability of this software ! 18: * for any purpose. It is provided "as is" without ! 19: * express or implied warranty. ! 20: */ ! 21: ! 22: ! 23: /* defines and defines to describe how to deal with the screen */ ! 24: ! 25: #define LINESIZE 80 ! 26: #define NUMBERLINES 24 ! 27: #define SCREENSIZE (LINESIZE*NUMBERLINES) ! 28: #define LowestScreen() 0 ! 29: #define HighestScreen() (SCREENSIZE-1) ! 30: ! 31: #define ScreenLineOffset(x) ((x)%LINESIZE) ! 32: #define ScreenLine(x) ((int)((x)/LINESIZE)) ! 33: #define ScreenInc(x) (((x)==HighestScreen())? LowestScreen():x+1) ! 34: #define ScreenDec(x) (((x)==LowestScreen())? HighestScreen():x-1) ! 35: #define ScreenUp(x) (((x)+(SCREENSIZE-LINESIZE))%SCREENSIZE) ! 36: #define ScreenDown(x) (((x)+LINESIZE)%SCREENSIZE) ! 37: #define IsOrder(x) ((x) && ((x) < 0x40) && (\ ! 38: ((x) == ORDER_SF) || \ ! 39: ((x) == ORDER_SBA) || \ ! 40: ((x) == ORDER_IC) || \ ! 41: ((x) == ORDER_PT) || \ ! 42: ((x) == ORDER_RA) || \ ! 43: ((x) == ORDER_EUA) || \ ! 44: ((x) == ORDER_YALE))) ! 45: #define BAIC(x) ((x)&0x3f) ! 46: #define CIAB(x) (CIABuffer[(x)&0x3f]) ! 47: #define BufferTo3270_0(x) (CIABuffer[(int)((x)/0x40)]) ! 48: #define BufferTo3270_1(x) (CIABuffer[(x)&0x3f]) ! 49: #define Addr3270(x,y) (BAIC(x)*64+BAIC(y)) ! 50: #define SetBufferAddress(x,y) ((x)*LINESIZE+(y)) ! 51: ! 52: /* These know how fields are implemented... */ ! 53: ! 54: #define FieldInc(p) FieldFind(FieldForward, p, LowestScreen()) ! 55: #define FieldDec(p) (HighestScreen() - \ ! 56: FieldFind(FieldReverse, \ ! 57: HighestScreen()-p, HighestScreen())) ! 58: #define WhereAttrByte(p) (IsStartField(p)? p: FieldDec(p)) ! 59: #define WhereHighByte(p) ScreenDec(FieldInc(p)) ! 60: #define WhereLowByte(p) ScreenInc(WhereAttrByte(p)) ! 61: #define FieldAttributes(x) (IsStartField(x)? Host[x].field&0xff : \ ! 62: Host[WhereAttrByte(x)].field&0xff) ! 63: #define TermAttributes(x) (TermIsStartField(x)? Terminal[x].field&0xff : \ ! 64: Terminal[WhereTermAttrByte(x)].field&0xff) ! 65: #define TurnOffMdt(x) (Host[WhereAttrByte(x)].field &= ~ATTR_MDT) ! 66: #define TurnOnMdt(x) (Host[WhereAttrByte(x)].field |= ATTR_MDT) ! 67: #define HasMdt(x) (Host[x].field&ATTR_MDT) /* modified tag */ ! 68: ! 69: #define IsStartField(x) (Host[x].field&ATTR_MASK) /* field starts here */ ! 70: #define TermIsStartField(x) (Terminal[x].field&ATTR_MASK) ! 71: #define NewField(p,a) (Host[p].field = (a)|ATTR_MASK, \ ! 72: FieldForward[p] = FieldReverse[SCREENSIZE-p-1] = 1) ! 73: #define TermNewField(p,a) (Terminal[p].field = (a)|ATTR_MASK) ! 74: #define DeleteField(p) (Host[p].field = 0, \ ! 75: FieldForward[p] = FieldReverse[SCREENSIZE-p-1] = 0) ! 76: #define TermDeleteField(p) (Terminal[p].field = 0) ! 77: #define DeleteAllFields() (bzero(FieldForward, sizeof FieldForward), \ ! 78: bzero(FieldReverse, sizeof FieldReverse)) ! 79: ! 80: ! 81: /* The following are independent of the implementation of fields */ ! 82: #define IsProtectedAttr(p,a) (IsStartField(p) || ((a)&ATTR_PROT)) ! 83: #define IsProtected(p) IsProtectedAttr(p,FieldAttributes(p)) ! 84: ! 85: #define IsUnProtected(x) (!IsProtected(x)) ! 86: ! 87: #define IsAutoSkip(x) (FieldAttributes(x)&ATTR_AUTO_SKIP) ! 88: ! 89: #define IsNonDisplayAttr(c) (((c)&ATTR_DSPD_MASK) == ATTR_DSPD_NONDISPLAY) ! 90: #define IsNonDisplay(p) IsNonDisplayAttr(FieldAttributes(p)) ! 91: ! 92: #define IsHighlightedAttr(c) \ ! 93: (((c)&ATTR_DSPD_MASK) == ATTR_DSPD_HIGH) ! 94: #define IsHighlighted(p) \ ! 95: (IsHighlightedAttr(FieldAttributes(p)) && !IsStartField(p)) ! 96: ! 97: #define TermIsNonDisplay(x) \ ! 98: ((TermAttributes(x)&ATTR_DSPD_MASK) == ATTR_DSPD_NONDISPLAY) ! 99: #define TermIsHighlighted(x) \ ! 100: (((TermAttributes(x)&ATTR_DSPD_MASK) == ATTR_DSPD_HIGH) \ ! 101: && !TermIsStartField(x)) ! 102: ! 103: #define TerminalCharacterAttr(c,p,a) (IsNonDisplayAttr(a) ? ' ':c) ! 104: #define TerminalCharacter(c,p) TerminalCharacterAttr(c,p,FieldAttributes(p)) ! 105: ! 106: #define NeedToRedisplayFields(p) ((TermIsNonDisplay(p) != IsNonDisplay(p)) || \ ! 107: (TermIsHighlighted(p) != IsHighlighted(p))) ! 108: #define NeedToRedisplayFieldsAttr(p,c) ( \ ! 109: (TermIsNonDisplay(p) != IsNonDisplayAttr(c)) || \ ! 110: (TermIsHighlighted(p) != IsHighlightedAttr(c))) ! 111: ! 112: #define NotVisuallyCompatibleAttributes(p,c,d) ( \ ! 113: (IsNonDisplayAttr(c) != IsNonDisplayAttr(d)) || \ ! 114: (IsHighlightedAttr(c) != IsHighlightedAttr(d))) ! 115: ! 116: #define NeedToRedisplayAttr(c,p,a) \ ! 117: ((c != GetTerminal(p)) || NeedToRedisplayFieldsAttr(p,a)) ! 118: #define NeedToRedisplay(c,p) NeedToRedisplayAttr(c,p,FieldAttributes(p)) ! 119: ! 120: #define MAX(x,y) ((x)<(y)? (y):(x)) ! 121: #define MIN(x,y) ((x)<(y)? x:(y)) ! 122: ! 123: #define GetHost(i) Host[i].data ! 124: #define SetHost(i,c) (Host[i].data = c) ! 125: ! 126: #define GetTerminal(i) Terminal[i].data ! 127: #define SetTerminal(i,c) (Terminal[i].data = c) ! 128: ! 129: struct { ! 130: char data, /* data at this position */ ! 131: field; /* field attributes of this location if ATTR_MASK */ ! 132: } Host[SCREENSIZE], /* host view of screen */ ! 133: Terminal[SCREENSIZE]; ! 134: ! 135: char FieldForward[SCREENSIZE], /* non-zero for SF, 0..1919 */ ! 136: FieldReverse[SCREENSIZE]; /* non-zero for SF, 1919..0 */ ! 137: ! 138: ! 139: int CursorAddress; /* where cursor is */ ! 140: int BufferAddress; /* where writes are going */ ! 141: ! 142: int Lowest, Highest; ! 143: ! 144: /* the Following are globals */ ! 145: ! 146: extern char CIABuffer[]; ! 147: ! 148: int UnLocked; /* is the keyboard unlocked */ ! 149: int AidByte; ! 150: ! 151: int Initialized; /* are we initialized? */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.