Commit | Line | Data |
---|---|---|
23d0e88a GM |
1 | /* |
2 | * @(#)screen.h 3.1 10/29/86 | |
3 | */ | |
4 | ||
5 | #define INCLUDED_SCREEN | |
6 | ||
7 | /* defines and defines to describe how to deal with the screen */ | |
8 | ||
9 | #define MAXNUMBERLINES 43 /* 3278-4 */ | |
10 | #define MAXNUMBERCOLUMNS 132 /* 3278-5 */ | |
11 | #define MAXSCREENSIZE 3564 /* (27*132) 3278-5 */ | |
12 | #define LowestScreen() 0 | |
13 | #define HighestScreen() (ScreenSize-1) | |
14 | ||
15 | #define ScreenLineOffset(x) ((x)%NumberColumns) | |
16 | #define ScreenLine(x) ((int)((x)/NumberColumns)) | |
17 | #define ScreenInc(x) (((x)==HighestScreen())? LowestScreen():x+1) | |
18 | #define ScreenDec(x) (((x)==LowestScreen())? HighestScreen():x-1) | |
19 | #define ScreenUp(x) (((x)+(ScreenSize-NumberColumns))%ScreenSize) | |
20 | #define ScreenDown(x) (((x)+NumberColumns)%ScreenSize) | |
21 | #define IsOrder(x) (Orders[x]) | |
22 | #define BAIC(x) ((x)&0x3f) | |
23 | #define CIAB(x) (CIABuffer[(x)&0x3f]) | |
24 | #define BufferTo3270_0(x) (CIABuffer[(int)((x)/0x40)]) | |
25 | #define BufferTo3270_1(x) (CIABuffer[(x)&0x3f]) | |
26 | #define Addr3270(x,y) (BAIC(x)*64+BAIC(y)) | |
27 | #define SetBufferAddress(x,y) ((x)*NumberColumns+(y)) | |
28 | \f | |
29 | /* These know how fields are implemented... */ | |
30 | ||
31 | #define FieldInc(p) FieldFind(FieldForward, p, LowestScreen()) | |
32 | #define FieldDec(p) (HighestScreen() - \ | |
33 | FieldFind(FieldReverse, \ | |
34 | HighestScreen()-p, HighestScreen())) | |
35 | #define WhereAttrByte(p) (IsStartField(p)? p: FieldDec(p)) | |
36 | #define WhereHighByte(p) ScreenDec(FieldInc(p)) | |
37 | #define WhereLowByte(p) ScreenInc(WhereAttrByte(p)) | |
38 | #define FieldAttributes(x) (IsStartField(x)? Host[x].field&0xff : \ | |
39 | Host[WhereAttrByte(x)].field&0xff) | |
40 | #define TurnOffMdt(x) (Host[WhereAttrByte(x)].field &= ~ATTR_MDT) | |
41 | #define TurnOnMdt(x) (Host[WhereAttrByte(x)].field |= ATTR_MDT) | |
42 | #define HasMdt(x) (Host[x].field&ATTR_MDT) /* modified tag */ | |
43 | ||
44 | /* | |
45 | * Is the screen formatted? Some algorithms change depending | |
46 | * on whether there are any attribute bytes lying around. | |
47 | */ | |
48 | #define FormattedScreen() \ | |
49 | ((WhereAttrByte(0) != 0) || ((Host[0].field&ATTR_MASK) != 0)) | |
50 | ||
51 | #define IsStartField(x) (Host[x].field&ATTR_MASK) /* field starts here */ | |
52 | #define NewField(p,a) (Host[p].field = (a)|ATTR_MASK, \ | |
53 | FieldForward[p] = FieldReverse[ScreenSize-p-1] = 1) | |
54 | #define DeleteField(p) (Host[p].field = 0, \ | |
55 | FieldForward[p] = FieldReverse[ScreenSize-p-1] = 0) | |
56 | #define DeleteAllFields() (bzero(FieldForward, sizeof FieldForward), \ | |
57 | bzero(FieldReverse, sizeof FieldReverse)) | |
58 | ||
59 | \f | |
60 | /* The following are independent of the implementation of fields */ | |
61 | #define IsProtectedAttr(p,a) (IsStartField(p) || ((a)&ATTR_PROT)) | |
62 | #define IsProtected(p) IsProtectedAttr(p,FieldAttributes(p)) | |
63 | ||
64 | #define IsUnProtected(x) (!IsProtected(x)) | |
65 | ||
66 | #define IsAutoSkip(x) (FieldAttributes(x)&ATTR_AUTO_SKIP) | |
67 | ||
68 | #define IsNonDisplayAttr(c) (((c)&ATTR_DSPD_MASK) == ATTR_DSPD_NONDISPLAY) | |
69 | #define IsNonDisplay(p) IsNonDisplayAttr(FieldAttributes(p)) | |
70 | ||
71 | #define IsHighlightedAttr(c) \ | |
72 | (((c)&ATTR_DSPD_MASK) == ATTR_DSPD_HIGH) | |
73 | #define IsHighlighted(p) \ | |
74 | (IsHighlightedAttr(FieldAttributes(p)) && !IsStartField(p)) | |
75 | ||
76 | ||
77 | #define MAX(x,y) ((x)<(y)? (y):(x)) | |
78 | #define MIN(x,y) ((x)<(y)? x:(y)) | |
79 | ||
80 | typedef struct { | |
81 | unsigned char data, /* data at this position */ | |
82 | field; /* field attributes if ATTR_MASK */ | |
83 | } ScreenImage; | |
84 | ||
85 | extern int | |
86 | FieldFind(); | |
87 | ||
88 | extern char | |
89 | CIABuffer[]; | |
90 | ||
91 | #define GetHost(i) Host[i].data | |
92 | #define SetHost(p,c) (Host[p].data = c) |