xref: /csrg-svn/usr.bin/tn3270/ctlr/screen.h (revision 62331)
148756Sbostic /*-
2*62331Sbostic  * Copyright (c) 1988, 1993
3*62331Sbostic  *	The Regents of the University of California.  All rights reserved.
433816Sbostic  *
548756Sbostic  * %sccs.include.redist.c%
633816Sbostic  *
7*62331Sbostic  *	@(#)screen.h	8.1 (Berkeley) 06/06/93
830024Sminshall  */
930024Sminshall 
1030024Sminshall #define	INCLUDED_SCREEN
1130024Sminshall 
1230024Sminshall /* defines and defines to describe how to deal with the screen */
1330024Sminshall 
1431134Sminshall #if	!defined(MSDOS)
1530024Sminshall #define	MAXNUMBERLINES		43		/* 3278-4 */
1630024Sminshall #define	MAXNUMBERCOLUMNS	132		/* 3278-5 */
1730024Sminshall #define	MAXSCREENSIZE		3564		/* (27*132) 3278-5 */
1831134Sminshall #else	/* !defined(MSDOS) */	/* MSDOS has memory constraints */
1931134Sminshall #define	MAXNUMBERLINES		25		/* XXX */
2031134Sminshall #define	MAXNUMBERCOLUMNS	80
2131134Sminshall #define	MAXSCREENSIZE		(MAXNUMBERLINES*MAXNUMBERCOLUMNS)
2231134Sminshall #endif	/* !defined(MSDOS) */	/* MSDOS has memory constraints */
2330024Sminshall #define LowestScreen()	0
2430024Sminshall #define HighestScreen()	(ScreenSize-1)
2530024Sminshall 
2630024Sminshall #define ScreenLineOffset(x)	((x)%NumberColumns)
2730024Sminshall #define ScreenLine(x)	((int)((x)/NumberColumns))
2830024Sminshall #define ScreenInc(x)	(((x)==HighestScreen())? LowestScreen():x+1)
2930024Sminshall #define ScreenDec(x)	(((x)==LowestScreen())? HighestScreen():x-1)
3030024Sminshall #define ScreenUp(x)	(((x)+(ScreenSize-NumberColumns))%ScreenSize)
3130024Sminshall #define ScreenDown(x)	(((x)+NumberColumns)%ScreenSize)
3230024Sminshall #define	IsOrder(x)	(Orders[x])
3330024Sminshall #define BAIC(x)		((x)&0x3f)
3430024Sminshall #define CIAB(x)		(CIABuffer[(x)&0x3f])
3530024Sminshall #define BufferTo3270_0(x)	(CIABuffer[(int)((x)/0x40)])
3630024Sminshall #define BufferTo3270_1(x)	(CIABuffer[(x)&0x3f])
3730024Sminshall #define Addr3270(x,y)	(BAIC(x)*64+BAIC(y))
3830024Sminshall #define SetBufferAddress(x,y)	((x)*NumberColumns+(y))
3930024Sminshall 
4030024Sminshall /* These know how fields are implemented... */
4130024Sminshall 
4230024Sminshall #define WhereAttrByte(p)	(IsStartField(p)? p: FieldDec(p))
4330024Sminshall #define	WhereHighByte(p)	ScreenDec(FieldInc(p))
4430024Sminshall #define WhereLowByte(p)		ScreenInc(WhereAttrByte(p))
4531146Sminshall #define FieldAttributes(x)	(IsStartField(x)? GetHost(x) : \
4631146Sminshall 				    GetHost(WhereAttrByte(x)))
4731146Sminshall #define FieldAttributesPointer(p)	(IsStartFieldPointer(p)? \
4831146Sminshall 				    GetHostPointer(p): \
4931146Sminshall 				    GetHost(WhereAttrByte((p)-&Host[0])))
5030024Sminshall 
5133752Sminshall /*
5233752Sminshall  * The MDT functions need to protect against the case where the screen
5333752Sminshall  * is unformatted (sigh).
5433752Sminshall  */
5533752Sminshall 
5633752Sminshall /* Turn off the Modified Data Tag */
5733752Sminshall #define TurnOffMdt(x) \
5833752Sminshall     if (HasMdt(WhereAttrByte(x))) { \
5933752Sminshall 	ModifyMdt(x, 0); \
6033752Sminshall     }
6133752Sminshall 
6233752Sminshall /* Turn on the Modified Data Tag */
6333752Sminshall #define TurnOnMdt(x) \
6433752Sminshall     if (!HasMdt(WhereAttrByte(x))) { \
6533752Sminshall 	ModifyMdt(x, 1); \
6633752Sminshall     }
6733752Sminshall 
6833752Sminshall /* If this location has the MDT bit turned on (implies start of field) ... */
6933752Sminshall #define HasMdt(x) \
7033752Sminshall     ((GetHost(x)&(ATTR_MDT|ATTR_MASK)) == (ATTR_MDT|ATTR_MASK))
7133752Sminshall 
7230024Sminshall 	/*
7330024Sminshall 	 * Is the screen formatted?  Some algorithms change depending
7430024Sminshall 	 * on whether there are any attribute bytes lying around.
7530024Sminshall 	 */
7630024Sminshall #define	FormattedScreen() \
7731146Sminshall 	    ((WhereAttrByte(0) != 0) || ((GetHost(0)&ATTR_MASK) == ATTR_MASK))
7830024Sminshall 
7930053Sminshall 					    /* field starts here */
8031146Sminshall #define IsStartField(x)	((GetHost(x)&ATTR_MASK) == ATTR_MASK)
8131146Sminshall #define IsStartFieldPointer(p)	((GetHostPointer(p)&ATTR_MASK) == ATTR_MASK)
8230053Sminshall 
8331146Sminshall #define NewField(p,a)	SetHost(p, (a)|ATTR_MASK)
8431146Sminshall #define DeleteField(p)	SetHost(p, 0)
8531066Sminshall #define	DeleteAllFields()
8630024Sminshall 
8730024Sminshall /* The following are independent of the implementation of fields */
8830024Sminshall #define IsProtectedAttr(p,a)	(IsStartField(p) || ((a)&ATTR_PROT))
8930024Sminshall #define IsProtected(p)	IsProtectedAttr(p,FieldAttributes(p))
9030024Sminshall 
9130024Sminshall #define IsUnProtected(x)	(!IsProtected(x))
9230024Sminshall 
9330024Sminshall #define IsAutoSkip(x)	(FieldAttributes(x)&ATTR_AUTO_SKIP)
9430024Sminshall 
9530024Sminshall #define IsNonDisplayAttr(c)	(((c)&ATTR_DSPD_MASK) == ATTR_DSPD_NONDISPLAY)
9630024Sminshall #define	IsNonDisplay(p)	IsNonDisplayAttr(FieldAttributes(p))
9730024Sminshall 
9830024Sminshall #define IsHighlightedAttr(c) \
9930024Sminshall 		(((c)&ATTR_DSPD_MASK) == ATTR_DSPD_HIGH)
10030024Sminshall #define	IsHighlighted(p) \
10130024Sminshall 		(IsHighlightedAttr(FieldAttributes(p)) && !IsStartField(p))
10230024Sminshall 
10331146Sminshall typedef unsigned char ScreenImage;
10430024Sminshall 
10530024Sminshall extern int
10630024Sminshall 	FieldFind();
10730024Sminshall 
10830024Sminshall extern char
10930024Sminshall 	CIABuffer[];
11030024Sminshall 
11131146Sminshall #define	GetGeneric(i,h)		(h)[i]
11231146Sminshall #define	GetGenericPointer(p)	(*(p))
11331146Sminshall #define	SetGeneric(i,c,h)	((h)[i] = (c))
11431146Sminshall #define	ModifyGeneric(i,what,h)	{(h)[i] what;}
11531146Sminshall 
11631146Sminshall #define GetHost(i)		GetGeneric(i,Host)
11731146Sminshall #define GetHostPointer(p)	GetGenericPointer(p)
11831146Sminshall #define	SetHost(i,c)		SetGeneric(i,c,Host)
11931146Sminshall #define	ModifyHost(i,what)	ModifyGeneric(i,what,Host)
120