🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc.rt
Article #1997

IBM 8514 source code (part 5 of 6) for X11 Release 4

#1997
From: Mark S. Lewis
Date: Mon, 12 Mar 1990 23:21
1972 lines
56652 bytes
Subject: IBM 8514 source code (part 5 of 6) for X11 Release 4
Index: ../mit/server/ddx/ibm/ibm8514

Description:	
IBM has decided to provide X11 source code for the 8514 display
adapter.  This is the same code used to build the object files
included in the X11 Release 4 distribution.  This code supports
servers for both AIX and IBM/4.3 on their respective platforms.

	V1.32_kit.1	59,103 Bytes
	V1.32_kit.2	61,796 Bytes
	V1.32_kit.3	60,982 Bytes
	V1.32_kit.4	62,729 Bytes
	V1.32_kit.5	54,871 Bytes
	V1.32_kit.6	29,170 Bytes

Installation:	
This code is provided in a 6-part shell archive.  Before you
install it, you should save your current code.  You should save
the Imakefile in the ibm server directory.  You also should save
the entire ibm8514 directory by moving and remaking it.

	cd ../mit/server/ddx/ibm
	cp Imakefile Imakefile.orig
	mv ibm8514 ibm8514.orig
	mkdir ibm8514
	
Next, edit this header from each part, and feed the rest to
/bin/sh.  Proceed to make the server as instructed in the
X11 release notes.

	sh < V1.32_kit.5

=====-----     Mark S. Lewis, IBM AWD Palo Alto    -----======
inet: mlewis%ibmsupt@uunet.uu.net		(415) 855-4486
uucp: uunet!ibmsupt!mlewis              IBM Tie Line: 465-4486

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
#
#	ibm8514/brcRect.c
#	ibm8514/brcScrInfo.c
#	ibm8514/brcStip.c
#	ibm8514/brcSuspScr.c
#	ibm8514/brcText.c
#
echo x - ibm8514/brcRect.c
sed 's/^X//' >ibm8514/brcRect.c << 'END-of-ibm8514/brcRect.c'
X/*
X * Copyright IBM Corporation 1987,1990
X *
X * All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that 
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of IBM not be
X * used in advertising or publicity pertaining to distribution of the
X * software without specific, written prior permission.
X *
X * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
X * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
X * SOFTWARE.
X *
X*/
X/*
X * PRPQ 5799-PFF (C) COPYRIGHT IBM CORPORATION 1987,1990
X * LICENSED MATERIALS - PROPERTY OF IBM
X * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
X */
X/*
X *  Hardware interface routines for IBM 8514/A adapter for
X *  X.11 server(s) on IBM equipment.
X *
X */
X/* $Header:
/andrew/X11/r3src/r3plus/server/ddx/ibm/ibm8514/RCS/brcRect.c,v 6.3
89/05/07 15:11:19 paul Exp $ */
X/* $Source:
/andrew/X11/r3src/r3plus/server/ddx/ibm/ibm8514/RCS/brcRect.c,v $ */
X
X#ifndef lint
Xstatic char *rcsid = "$Header:
/andrew/X11/r3src/r3plus/server/ddx/ibm/ibm8514/RCS/brcRect.c,v 6.3
89/05/07 15:11:19 paul Exp $" ;
X#endif
X
X#include "x8514.h"
X#include "ibmTrace.h"
X
Xextern int mergexlate[] ;
Xextern int ibm8514cursorSemaphore ;
X
Xvoid
Xibm8514DrawRectangle(color, merge, planes, x0, y0, lx, ly)
Xunsigned long int color ;
Xint merge ;
Xunsigned long int planes ;
Xshort  x0, y0, lx, ly ;
X{
Xint CursorIsSaved ;
XTRACE(("ibm8514DrawRectangle(color=%d, merge=x%x, planes=%02x, x=%d,
y=%d, lx=%d, ly=%d\n",
X	color, merge, planes, x0, y0, lx, ly)) ;
X
X   if ( ( lx <= 0 ) || ( ly <= 0 ) )
X	return ;
X   CursorIsSaved = !ibm8514cursorSemaphore && ibm8514CheckCursor(x0,
y0, lx, ly) ;
X
X   ibm8514ATRNotBusy ;
X   ibm8514CheckQueue(8) ;
X   SETFN1(FNCOLOR1, mergexlate[merge]) ;
X   SETCOL1(color) ;
X   PLNWENBL(planes) ;
X   SETY0(y0) ;
X   SETX0(x0) ;
X   SETLY(ly-1) ;
X   SETLX(lx-1) ;
X   COMMAND(0x80b3) ; /* Horizontal Rect operation, DX = DY = 'increasing'*/
X
X   ibm8514ClearQueue(2) ;
X   PLNWENBL( ibm8514ALLPLANES ) ;
X   SETFN1(FNCOLOR1, FNREPLACE) ;
X
X   if (CursorIsSaved)
X	ibm8514ReplaceCursor() ;
X   return ;
X}
END-of-ibm8514/brcRect.c
echo x - ibm8514/brcScrInfo.c
sed 's/^X//' >ibm8514/brcScrInfo.c << 'END-of-ibm8514/brcScrInfo.c'
X/*
X * Copyright IBM Corporation 1987,1990
X *
X * All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that 
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of IBM not be
X * used in advertising or publicity pertaining to distribution of the
X * software without specific, written prior permission.
X *
X * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
X * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
X * SOFTWARE.
X *
X*/
X/*
X * PRPQ 5799-PFF (C) COPYRIGHT IBM CORPORATION 1987,1990
X * LICENSED MATERIALS - PROPERTY OF IBM
X * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
X */
X#include "X.h"
X#include "misc.h"
X#include "miscstruct.h"
X#include "scrnintstr.h"
X#include "cursorstr.h"
X
X#include "ibmScreen.h"
X
X#include "x8514.h"
X
Xextern Bool ibm8514ScreenInit() ;
Xextern Bool ibm8514Probe() ;
Xextern void ibm8514RemoveCursor() ;
Xextern void ibm8514ShowCursor() ;
Xextern void ibm8514SuspendScreenAndSave() ;
Xextern void ibm8514RestoreScreenAndActivate() ;
Xextern PixmapFormatRec ibm8514Formats[] ;
X
XibmPerScreenInfo ibm8514ScreenInfoStruct = {
X
X	{ 0, 0,
X	  _8514_SCREENWIDTH - 1,
X	  _8514_SCREENHEIGHT - 1 },	/* BoxRec	 ibm_ScreenBounds ; */
X	1,			/* int		 ibm_NumFormats ; */
X	ibm8514Formats,		/* PixmapFormatRec	*ibm_ScreenFormats ; */
X	ibm8514ScreenInit,	/* Bool		(*ibm_InitFunc)() ; */
X	ibm8514Probe,		/* int		(*ibm_ProbeFunc)() ; */
X	ibm8514RemoveCursor,	/* void		(*ibm_HideCursor)() ; */
X	"-8514",		/* char		 *ibm_ScreenFlag ; */
X	IBM8514_DEV_FILE,		/* char		 *ibm_ScreenDevice ; */
X	"/dev/ms8514",			/* char		 *ibm_ScreenPointer ; */
X	ibm8514SuspendScreenAndSave,/* void		(*ibm_SaveFunc)() ; */
X	ibm8514RestoreScreenAndActivate,/* void	(*ibm_RestoreFunc)() ; */
X	(ScreenPtr) 0,		/* ScreenPtr	  ibm_Screen */
X	-1,			/* int		  ibm_ScreenFD */
X	0,			/* int		  ibm_Wanted */
X	0,			/* short	  ibm_CursorHotX */
X	0,			/* short	  ibm_CursorHotY */
X	ibm8514ShowCursor,	/* void		(*ibm_CursorShow)() */
X	(CursorPtr) 0,		/* CursorPtr	  ibm_CurrentCursor */
X	SCREEN_UNINITIALIZED	/* int		  ibm_ScreenState */
X} ;
END-of-ibm8514/brcScrInfo.c
echo x - ibm8514/brcStip.c
sed 's/^X//' >ibm8514/brcStip.c << 'END-of-ibm8514/brcStip.c'
X/*
X * Copyright IBM Corporation 1987,1990
X *
X * All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that 
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of IBM not be
X * used in advertising or publicity pertaining to distribution of the
X * software without specific, written prior permission.
X *
X * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
X * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
X * SOFTWARE.
X *
X*/
X/*
X * PRPQ 5799-PFF (C) COPYRIGHT IBM CORPORATION 1987,1990
X * LICENSED MATERIALS - PROPERTY OF IBM
X * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
X */
X/*
X *  Hardware interface routines for IBM 8514/A adapter for
X *  X.11 server(s) on IBM equipment.
X *
X */
X/* $Header:
/andrew/X11/r3src/release/server/ddx/ibm/ibm8514/RCS/brcStip.c,v 30.0
89/01/23 19:24:03 paul Exp $ */
X/* $Source:
/andrew/X11/r3src/release/server/ddx/ibm/ibm8514/RCS/brcStip.c,v $ */
X
X#ifndef lint
Xstatic char *rcsid = "$Header:
/andrew/X11/r3src/release/server/ddx/ibm/ibm8514/RCS/brcStip.c,v 30.0
89/01/23 19:24:03 paul Exp $" ;
X#endif
X
X
X/* DO STIPPLES!!!
X */
X
X#include "X.h"
X#include "servermd.h"
X#include "pixmap.h"
X#include "pixmapstr.h"
X#include "gcstruct.h"
X
X#include "OScompiler.h"
X
X#include "x8514.h"
X
X#include "ibmTrace.h"
X
Xextern int ibm8514cursorSemaphore ;
Xextern PixmapPtr ppcCopyPixmap() ;
X
Xvoid
Xibm8514UnnaturalOpStipple( pStipple, fg, bg, merge, planes,
X			   x, y, w, h, xSrc, ySrc )
XPixmapPtr pStipple ;
Xunsigned long int fg, bg ;
Xint merge ;
Xunsigned long int planes ;
Xint x ;
Xint y ;
Xint w ;
Xint h ;
Xint xSrc ;
Xint ySrc ;
X{
Xint hcount, vcount, vtarget, htarget, savehcount, savehtarget, tlx, tly ;
Xint maxwid, heightleft, tmp, CursorIsSaved, yoffset, this_height ;
Xunsigned char *data ;
X
Xif ( x < 0 ) {
X	w += x ;
X	x = 0 ;
X}
Xif ( y < 0 ) {
X	h += y ;
X	y = 0 ;
X}
Xw = MIN(_8514_SCREENWIDTH-x, w) ;
Xh = MIN(_8514_SCREENHEIGHT-y, h) ;
X
Xif ( ( w <= 0 ) || ( h <= 0 )  )
X	return ;
X
Xtlx = pStipple->drawable.width ;
Xtly = pStipple->drawable.height ;
X
XCursorIsSaved = !ibm8514cursorSemaphore
X		&& ibm8514CheckCursor( x, y, x + w, y + h ) ;
Xibm8514cursorSemaphore++ ;
X
Xheightleft = h ;
Xyoffset = 0 ;
X
Xdata = pStipple->devPrivate.ptr ;
Xwhile ( heightleft > 0 ) {
X	this_height = MIN( heightleft, MAXSTIPPLEHEIGHT ) ;
X	ibm8514StageMono( tlx, this_height, data ) ;
X	/*expand the tile to largest available size */
X	maxwid = MIN( MAXSTIPPLEWIDTH, w ) ;
X	while ( tlx * 2 <= maxwid ) {
X		ibm8514Bitblt( GXcopy, MONO_STAGE_RPLANE, MONO_STAGE_WPLANE,
X			       MONO_STAGE_X, MONO_STAGE_Y,
X			       tlx + MONO_STAGE_X, MONO_STAGE_Y,
X			       tlx, this_height ) ;
X		tlx *= 2 ;
X	}
X	tmp = ( x - xSrc ) % tlx ;
X	if ( tmp < 0  )
X		tmp += tlx ;
X	savehtarget = htarget = x - tmp ;
X
X	tmp = ( y - ySrc ) % tly ;
X	if ( tmp < 0  )
X		tmp += tly ;
X	vtarget = y - tmp + yoffset ;
X
X	/*tiles to fill horiz */
X	savehcount = hcount = ( ( x + w - htarget ) + tlx - 1 ) / tlx ;
X
X	/* tiles it will take to fill vert */
X	vcount = ( ( y + h - vtarget ) + tly - 1 ) / tly ;
X
X	ibm8514ClearQueue( 4 ) ;
X	SETXMAX( x + w - 1 ) ;
X	SETYMAX( y + h - 1 ) ;
X	SETXMIN( x ) ;
X	SETYMIN( y ) ;
X
X	while ( vcount-- ) {
X		while ( hcount-- ) {
X			ibm8514BlitFGBG( MONO_STAGE_RPLANE, planes,
X					 fg, bg, merge,
X					 MONO_STAGE_X, MONO_STAGE_Y,
X					 htarget, vtarget, tlx, this_height ) ;
X			htarget += tlx ;
X		}
X		vtarget += tly ;
X		htarget = savehtarget ;
X		hcount = savehcount ;
X	}
X	yoffset += this_height ;
X	heightleft -= this_height ;
X	data += this_height * pStipple->devKind ;
X
X	ibm8514ClearQueue( 4 ) ;
X	SETXMAX( _8514_SCREENWIDTH - 1 ) ;
X	SETYMAX( 1023 ) ;
X	SETXMIN( 0 ) ;
X	SETYMIN( 0 ) ;
X}
Xif ( !--ibm8514cursorSemaphore && CursorIsSaved  )
X	ibm8514ReplaceCursor() ;
X
Xreturn ;
X}
X
Xvoid
Xibm8514UnnaturalStipple(pStipple, fg, merge, planes, x, y, w, h, xSrc, ySrc )
XPixmapPtr pStipple ;
Xunsigned long int fg ;
Xint merge ;
Xunsigned long int planes ;
Xint x ;
Xint y ;
Xint w ;
Xint h ;
Xint xSrc ;
Xint ySrc ;
X{
Xint hcount, vcount, vtarget, htarget, savehcount, savehtarget, tlx, tly ;
Xint maxwid, heightleft, tmp, CursorIsSaved, yoffset, this_height ;
Xunsigned char *data ;
X
Xif ( x < 0 ) {
X	w += x ;
X	x = 0 ;
X}
Xif ( y < 0 ) {
X	h += y ;
X	y = 0 ;
X}
Xw = MIN( _8514_SCREENWIDTH - x, w ) ;
Xh = MIN( _8514_SCREENHEIGHT - y, h ) ;
X
Xif ( w <= 0 || h <= 0 )
X	return ;
X
Xtlx = pStipple->drawable.width ;
Xtly = pStipple->drawable.height ;
X
XCursorIsSaved = !ibm8514cursorSemaphore
X		&& ibm8514CheckCursor( x, y, x + w, y + h ) ;
Xibm8514cursorSemaphore++ ;
X
Xheightleft = h ;
Xyoffset = 0 ;
X
Xdata = pStipple->devPrivate.ptr ;
Xwhile ( heightleft > 0 ) {
X	this_height = MIN( heightleft, MAXSTIPPLEHEIGHT ) ;
X
X	ibm8514StageMono( tlx, this_height, data ) ;
X
X	/*expand the tile to largest available size */
X	maxwid = MIN( MAXSTIPPLEWIDTH, w ) ;
X	while ( tlx*2 <= maxwid ) {
X		ibm8514Bitblt( GXcopy, MONO_STAGE_RPLANE, MONO_STAGE_WPLANE,
X			       MONO_STAGE_X, MONO_STAGE_Y,
X			       tlx + MONO_STAGE_X, MONO_STAGE_Y,
X			       tlx, this_height ) ;
X		tlx *= 2 ;
X	}
X	tmp = ( x - xSrc ) % tlx ;
X	if ( tmp < 0  )
X		tmp += tlx ;
X	savehtarget = htarget = x - tmp ;
X
X	tmp = ( y - ySrc ) % tly ;
X	if ( tmp < 0  )
X		tmp += tly ;
X	vtarget =  y - tmp + yoffset ;
X
X	/* tiles to fill horiz */
X	savehcount = hcount = ( ( x + w - htarget ) + tlx - 1 ) / tlx ;
X
X	/* tiles it will take to fill vert */
X	vcount = ( ( y + h - vtarget ) + tly - 1 ) / tly ;
X
X	ibm8514ClearQueue( 4 ) ;
X	SETXMAX( x + w - 1 ) ;
X	SETYMAX( y + h - 1 ) ;
X	SETXMIN( x ) ;
X	SETYMIN( y ) ;
X
X	while ( vcount-- ) {
X		while ( hcount-- ) {
X			ibm8514BlitFG( MONO_STAGE_RPLANE, planes, fg, merge,
X				       MONO_STAGE_X, MONO_STAGE_Y,
X				       htarget, vtarget, tlx, this_height ) ;
X			htarget += tlx ;
X		}
X		vtarget += tly ;
X		htarget = savehtarget ;
X		hcount = savehcount ;
X	}
X	yoffset += this_height ;
X	heightleft -= this_height ;
X	data += this_height * pStipple->devKind ;
X
X	ibm8514ClearQueue( 4 ) ;
X	SETXMAX( _8514_SCREENWIDTH - 1 ) ;
X	SETYMAX( 1023 ) ;
X	SETXMIN( 0 ) ;
X	SETYMIN( 0 ) ;
X}
X
Xif ( !--ibm8514cursorSemaphore && CursorIsSaved  )
X	ibm8514ReplaceCursor() ;
Xreturn ;
X}
X
Xvoid
Xibm8514Stipple(pStipple, fg, merge, planes, x, y, w, h, xSrc, ySrc )
XPixmapPtr pStipple ;
Xunsigned long int fg ;
Xint merge ;
Xunsigned long int planes ;
Xint x, y, w, h, xSrc, ySrc ;
X{
Xint hcount, vcount, vtarget, htarget, savehcount, savehtarget, tlx, tly ;
Xint maxhite, maxwid ;
Xint tmp, CursorIsSaved ;
Xint xrot, yshift ;
X
XTRACE(("ibm8514Stipple(pStipple = x%x, fg=%d, merge= x%x, planes=x%02x,
x=%d, y=%d, w=%d, h=%d, xSrc=%d, ySrc=%d\n)",
X		pStipple, fg, merge, planes, x, y, w, h, xSrc, ySrc)) ;
Xtlx = pStipple->drawable.width ;
Xtly = pStipple->drawable.height ;
X
X{
X
Xif ((x%4 == 0) && (w<=tlx) && (h<=tly) )
X	{
X	PixmapPtr pTmpStipple ;
X	int destroy=FALSE ;
X
X	if (xrot = ((x-xSrc)%tlx) )
X		{
X		if (!(pTmpStipple = ppcCopyPixmap(pStipple)) )
X			{
X			ErrorF("Fail ppcCopyPixmap \"pTmpStipple\" \n") ;
X			return ;
X			}
X		destroy = TRUE ;
X		ppcRotBitmapRight(pTmpStipple, tlx-xrot) ;
X		}
X	  if (
X	      (
X		((w+BITMAP_SCANLINE_PAD-1) >> LOG2_BITMAP_PAD)
X		<< LOG2_BYTES_PER_SCANLINE_PAD
X	       )
X		   <      pStipple->devKind
X	     ) {
X		PixmapPtr ppcClipBitmap() ;
X		if (!destroy )
X			{
X			if (!(pTmpStipple = ppcClipBitmap(pStipple, w, h)) )
X				{
X				ErrorF("Fail ppcClipBitxmap\n") ;
X				return ;
X				}
X			destroy = TRUE ;
X			}
X		else {
X			PixmapPtr pNew ;
X			if (!(pNew = ppcClipBitmap(pTmpStipple, w, h)) )
X				{
X				ErrorF("Fail ppcClipBitxmap\n") ;
X				mfbDestroyPixmap(pTmpStipple) ;
X				return ;
X				}
X			mfbDestroyPixmap(pTmpStipple) ;
X			pTmpStipple = pNew ;
X			}
X		}
X	if (!destroy )
X		pTmpStipple = pStipple ;
X
X	yshift = ((y-ySrc)%tly) ;
X
X	if ( yshift > h )
X		{
X		ibm8514DrawMonoImage( pTmpStipple->devPrivate.ptr
X				      + (yshift*pTmpStipple->devKind),
X				      x, y, w, h, fg, merge, planes ) ;
X		}
X	else
X		{
X		ibm8514DrawMonoImage( pTmpStipple->devPrivate.ptr, x, y+yshift,
X					w, h-yshift, fg, merge, planes) ;
X		ibm8514DrawMonoImage( pTmpStipple->devPrivate.ptr
X			      + (yshift*pTmpStipple->devKind),
X			      x, y, w, yshift, fg, merge, planes ) ;
X		/*
X		WHATS WRONG WITH ALIGNMONOIMAGE HERE????
X		ALIGNMONOIMAGE DOESN'T TAKE A FG COLOR
X		*/
X		}
X	if (destroy )
X		mfbDestroyPixmap(pTmpStipple) ;
X
X	return ;
X	}
X}
X
Xif ( ( tlx > MAXSTIPPLEWIDTH ) || ( tly > MAXSTIPPLEHEIGHT ) ) {
X	ibm8514UnnaturalStipple( pStipple, fg, merge, planes,
X				 x, y, w, h, xSrc, ySrc) ;
X	return ;
X}
X
Xif ( x < 0 ) {
X	w += x ;
X	x = 0 ;
X}
Xif ( y < 0 ) {
X	h += y ;
X	y = 0 ;
X}
Xw = MIN(_8514_SCREENWIDTH-x, w) ;
Xh = MIN(_8514_SCREENHEIGHT-y, h) ;
X
Xif ( ( w <= 0) || (h <= 0)  )
X	return ;
X
Xibm8514StageMono(tlx, tly, pStipple->devPrivate.ptr) ;
X
X/*expand the tile to largest available size */
Xmaxwid = MIN(MAXSTIPPLEWIDTH, w) ;
Xwhile ( tlx * 2 <= maxwid ) {
X	ibm8514Bitblt( GXcopy, MONO_STAGE_RPLANE, MONO_STAGE_WPLANE,
X		MONO_STAGE_X, MONO_STAGE_Y,
X		tlx + MONO_STAGE_X, MONO_STAGE_Y,
X		tlx, tly ) ;
X	tlx *= 2 ;
X}
Xmaxhite = MIN(MAXSTIPPLEHEIGHT, h) ;
Xwhile ( tly*2 <= maxhite ) {
X	ibm8514Bitblt( GXcopy, MONO_STAGE_RPLANE, MONO_STAGE_WPLANE,
X		MONO_STAGE_X, MONO_STAGE_Y,
X		MONO_STAGE_X, tly+MONO_STAGE_Y,
X		tlx, tly) ;
X	tly *= 2 ;
X}
X
Xtmp = ( x - xSrc ) % tlx ;
Xif ( tmp < 0  )
X	tmp += tlx ;
Xsavehtarget = htarget = x - tmp ;
Xtmp = ( y - ySrc ) % tly ;
Xif ( tmp < 0  )
X	tmp += tly ;
Xvtarget = y - tmp ;
X
Xsavehcount = hcount = ((x+w-htarget)+tlx-1)/tlx ; /*tiles to fill horiz */
Xvcount = ((y+h-vtarget)+tly-1)/tly ; /*tiles it will take to fill vert */
X
XCursorIsSaved = !ibm8514cursorSemaphore
X     && ibm8514CheckCursor(htarget, vtarget, hcount*tlx, vcount*tly) ;
Xibm8514cursorSemaphore++ ;
X
Xibm8514ClearQueue(4) ;
XSETXMAX(x+w-1) ;
XSETYMAX(y+h-1) ;
XSETXMIN(x) ;
XSETYMIN(y) ;
X
Xwhile ( vcount-- ) {
X	while ( hcount-- ) {
X		ibm8514BlitFG( MONO_STAGE_RPLANE, planes, fg, merge,
X				MONO_STAGE_X, MONO_STAGE_Y,
X				htarget, vtarget, tlx, tly) ;
X		htarget += tlx ;
X	}
X	vtarget += tly ;
X	htarget = savehtarget ;
X	hcount = savehcount ;
X}
X
Xibm8514ClearQueue(4) ;
XSETXMAX(_8514_SCREENWIDTH-1) ;
XSETYMAX( 1023 ) ;
XSETXMIN(0) ;
XSETYMIN(0) ;
Xif ( !(--ibm8514cursorSemaphore) && CursorIsSaved  )
X	ibm8514ReplaceCursor() ;
Xreturn ;
X}
X
Xvoid
Xibm8514OpStipple(pStipple, fg, bg, merge, planes, x, y, w, h, xSrc, ySrc )
XPixmapPtr pStipple ;
Xunsigned long int fg, bg ;
Xint merge ;
Xunsigned long int planes ;
Xint x, y, w, h, xSrc, ySrc ;
X{
Xint hcount, vcount, vtarget, htarget, savehcount, savehtarget, tlx, tly ;
Xint maxhite, maxwid ;
Xint tmp, CursorIsSaved ;
X
XTRACE(("ibm8514Stipple(pStipple = x%x, fg=%d, merge= x%x, planes=x%02x,
x=%d, y=%d, w=%d, h=%d, xSrc=%d, ySrc=%d\n",
X		pStipple, fg, merge, planes, x, y, w, h, xSrc, ySrc)) ;
X
Xtlx = pStipple->drawable.width ;
Xtly = pStipple->drawable.height ;
X
Xif ( ( tlx > MAXSTIPPLEWIDTH ) || ( tly > MAXSTIPPLEHEIGHT ) ) {
X       ibm8514UnnaturalOpStipple( pStipple, fg, bg, merge, planes,
X				  x, y, w, h, xSrc, ySrc ) ;
X	return ;
X}
X
Xif ( x < 0 ) {
X	w += x ;
X	x = 0 ;
X}
Xif ( y < 0 ) {
X	h += y ;
X	y = 0 ;
X}
Xw = MIN(_8514_SCREENWIDTH-x, w) ;
Xh = MIN(_8514_SCREENHEIGHT-y, h) ;
X
Xif ( (w <= 0) || (h <= 0 )  )
X	return ;
X
Xibm8514StageMono(tlx, tly, pStipple->devPrivate.ptr) ;
X
X/*expand the tile to largest available size */
Xmaxwid = MIN(MAXSTIPPLEWIDTH, w) ;
Xwhile ( tlx*2 <= maxwid )
X	{
X	ibm8514Bitblt(GXcopy, MONO_STAGE_RPLANE, MONO_STAGE_WPLANE,
X		MONO_STAGE_X, MONO_STAGE_Y,
X		tlx+MONO_STAGE_X, MONO_STAGE_Y,
X		tlx, tly) ;
X	tlx *= 2 ;
X	}
Xmaxhite = MIN(MAXSTIPPLEHEIGHT, h) ;
Xwhile ( tly*2 <= maxhite )
X	{
X	ibm8514Bitblt(GXcopy, MONO_STAGE_RPLANE, MONO_STAGE_WPLANE,
X		MONO_STAGE_X, MONO_STAGE_Y,
X		MONO_STAGE_X, tly+MONO_STAGE_Y,
X		tlx, tly) ;
X	tly *= 2 ;
X	}
X
Xtmp = ( x - xSrc ) % tlx ;
Xif ( tmp < 0  )
X	tmp += tlx ;
Xsavehtarget = htarget =  x - tmp ;
Xtmp = ((y-ySrc)%tly) ;
Xif ( tmp < 0  )
X	tmp += tly ;
Xvtarget =  y - tmp ;
X
Xsavehcount = hcount = ((x+w-htarget)+tlx-1)/tlx ; /*tiles to fill horiz */
Xvcount = ((y+h-vtarget)+tly-1)/tly ; /*tiles it will take to fill vert */
X
XCursorIsSaved = !ibm8514cursorSemaphore
X     && ibm8514CheckCursor(htarget, vtarget, hcount*tlx, vcount*tly) ;
Xibm8514cursorSemaphore++ ;
X
Xibm8514ClearQueue(4) ;
XSETXMAX(x+w-1) ;
XSETYMAX(y+h-1) ;
XSETXMIN(x) ;
XSETYMIN(y) ;
X
Xwhile ( vcount-- ) {
X	while ( hcount-- ) {
X		ibm8514BlitFGBG(MONO_STAGE_RPLANE, planes, fg, bg, merge,
X				MONO_STAGE_X, MONO_STAGE_Y,
X				htarget, vtarget, tlx, tly) ;
X		htarget += tlx ;
X	}
X	vtarget += tly ;
X	htarget = savehtarget ;
X	hcount = savehcount ;
X}
X
Xibm8514ClearQueue(4) ;
XSETXMAX(_8514_SCREENWIDTH-1) ;
XSETYMAX( 1023 ) ;
XSETXMIN(0) ;
XSETYMIN(0) ;
Xif ( !(--ibm8514cursorSemaphore) && CursorIsSaved  )
X	ibm8514ReplaceCursor() ;
Xreturn ;
X}
END-of-ibm8514/brcStip.c
echo x - ibm8514/brcSuspScr.c
sed 's/^X//' >ibm8514/brcSuspScr.c << 'END-of-ibm8514/brcSuspScr.c'
X/*
X * Copyright IBM Corporation 1987,1990
X *
X * All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that 
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of IBM not be
X * used in advertising or publicity pertaining to distribution of the
X * software without specific, written prior permission.
X *
X * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
X * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
X * SOFTWARE.
X *
X*/
X/*
X * PRPQ 5799-PFF (C) COPYRIGHT IBM CORPORATION 1987,1990
X * LICENSED MATERIALS - PROPERTY OF IBM
X * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
X */
X/*
X *  Hardware interface routines for IBM 8514/A adapter for
X *  X.11 server(s) on IBM equipment.
X *
X */
X
X#include "X.h"
X#include "windowstr.h"
X#include "window.h"
X#include "pixmapstr.h"
X#include "scrnintstr.h"
X#include "gcstruct.h"
X#include "cursorstr.h"
X
X#include "OScompiler.h"
X
X#include "ibmIOArch.h"
X#include "ibmScreen.h"
X
X#include "ppcGCstr.h"
X#include "ppcScrn.h"
X
X#include "x8514.h"
X
X#define CURSOR_ONLY
X#include "brcProcs.h"
X
X#if defined(ibm032) && defined(BSDrt)
X#define ATR
X#include <sys/ioctl.h>
X#include <machinecons/buf_emul.h>
X#else
X#ifdef i386
X        /* Nothing Yet */
X#else
X        ******** ERROR ********
X#endif
X#endif
X
X#if defined(IBM_OS_HAS_HFT) && !defined(IBM_OS_HAS_X_QUEUE)
X#define HFT_HACKS "Oh no. The hack is here!"
X#endif
X
X#if !defined(HFT_HACKS)
Xextern WindowPtr ObscureEntireScreen() ;
X#else
Xextern void ibmSaveScreenData() ;
Xextern void ibmRestoreScreenData() ;
Xextern void ppcSaveAreas() ;
Xextern void ppcRestoreAreas() ;
X#endif
X
X/* Data from brcScrInfo.c */
Xextern ibmPerScreenInfo ibm8514ScreenInfoStruct ;
X
X/* Data from brcData.c */
Xextern ppcScrnPriv ibm8514ScrnPriv ;
X
X/* Procedures from brcCurs.c */
Xextern void ibm8514RemoveCursor() ;
Xextern void ibm8514ShowCursor() ;
X
X/* Procedures from brcutils.c */
Xextern void ibm8514InitializeHardwareState() ;
Xextern int ibm8514FD ;
X
X/*
************************************************************************** */
X
Xint ibm8514Disabled = 0 ;
X
X/* Private State Variables */
Xstatic int CursorWasActive = 0 ;
Xstatic ppcScrnPriv savedibm8514ScrnPriv ;
Xstatic WindowPtr coveringWindow = (WindowPtr) 0 ;
X
Xstatic int
XDoNaught()
X{
Xreturn 0 ;
X}
X
X#if !defined(HFT_HACKS)
Xvoid
Xibm8514SuspendScreenAndSave( index )
Xint index ;
X#else /* erik's hft hack */
Xvoid
Xibm8514SuspendScreenAndSave( pScreen, saveBits )
XScreenPtr pScreen ;
Xint saveBits ;
X#endif
X{
Xif ( ibm8514ScreenInfoStruct.ibm_ScreenState == SCREEN_ACTIVE ) {
X	/* Now Disable any further screen writes
X	 * by preventing call though the screen-priv
X	 */
X	savedibm8514ScrnPriv = ibm8514ScrnPriv ;
X	CursorWasActive = !ibm8514cursorSemaphore
X			&& ibm8514CheckCursor( 0, 0, _8514_SCREENWIDTH,
X					       _8514_SCREENHEIGHT ) ;
X	ibm8514cursorSemaphore++ ;
X
X	/* Fields in the ibmPerScreenInfo Structure */
X	ibm8514ScreenInfoStruct.ibm_HideCursor = (void (*)()) DoNaught ;
X	ibm8514ScreenInfoStruct.ibm_CursorShow = (void (*)()) DoNaught ;
X
X#if !defined(HFT_HACKS)
X	coveringWindow =
X		ObscureEntireScreen( ibm8514ScreenInfoStruct.ibm_Screen ) ;
X#else /* erik's hft hack */
X	if ( saveBits )
X		ibmSaveScreenData( pScreen, ppcSaveAreas ) ;
X#endif
X
X	/* Fields in the ppcScrnPriv Structure */
X	ibm8514ScrnPriv.blit = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.solidFill = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.tileFill = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.stipFill = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.opstipFill = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.imageFill = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.imageRead = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.lineBres = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.lineHorz = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.lineVert = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.setColor = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.RecolorCursor = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.monoFill = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.glyphFill = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.planeRead = (unsigned long int *(*)()) DoNaught ;
X	ibm8514ScrnPriv.replicateArea = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.DestroyGCPriv = (void (*)()) DoNaught ;
X	ibm8514ScrnPriv.CheckCursor = (int (*)()) DoNaught ;
X	ibm8514ScrnPriv.ReplaceCursor = (void (*)()) DoNaught ;
X
X	/* Make the list of cached fonts */
X	ibm8514CreateSavedFontList() ;
X
X	ibm8514ScreenInfoStruct.ibm_ScreenState = SCREEN_INACTIVE ;
X	ibm8514Disabled = 1 ;
X}
Xelse if ( ibm8514ScreenInfoStruct.ibm_ScreenState == SCREEN_INACTIVE ) {
X	ErrorF(
X	  "ibm8514SuspendScreenAndSave: ibm8514 State Is Already Inactive!" ) ;
X}
Xelse if ( ibm8514ScreenInfoStruct.ibm_ScreenState == SCREEN_UNINITIALIZED ) {
X	ErrorF( "ibm8514SuspendScreenAndSave: ibm8514 Still uninitialized!" ) ;
X}
X
Xreturn ;
X}
X
X#if !defined(HFT_HACKS)
Xvoid
Xibm8514RestoreScreenAndActivate( index )
Xint index ;
X#else /* erik's hft hack */
Xibm8514RestoreScreenAndActivate( pScreen, restoreBits )
XScreenPtr pScreen ;
Xint restoreBits ;
X#endif
X{
XColormapPtr currentColormap ;
X
Xif ( ibm8514ScreenInfoStruct.ibm_ScreenState == SCREEN_INACTIVE ) {
X
X#if defined(ibm032) && defined(BSDrt)
X	(void) ioctl( ibm8514FD, BUFINIT8514, 0 ) ;
X#else
X#ifdef i386
X        /* Nothing Yet */
X#else
X	********* ERROR ********
X#endif
X#endif
X	ibm8514InitializeHardwareState() ;
X	/* Magic Hardware Initialization */
X	ibm8514outw( ibm8514_MiscIO, 0x0005 ) ;
X
X	/* Re-enable Cursor Fields in the ibmPerScreenInfo Structure */
X	ibm8514ScreenInfoStruct.ibm_HideCursor = ibm8514RemoveCursor ;
X	ibm8514ScreenInfoStruct.ibm_CursorShow = ibm8514ShowCursor ;
X
X	/* Now Re-Enable any screen writes by restoring the screen-priv */
X	currentColormap = ibm8514ScrnPriv.InstalledColormap ;
X	ibm8514ScrnPriv = savedibm8514ScrnPriv ;
X
X	/* Now Re-Realize any Cache-able Fonts !! */
X
X	/* Now We Are Free to Draw Again !! */
X	ibm8514Disabled = 0 ;
X#if !defined(HFT_HACKS)
X	FreeResource( coveringWindow->drawable.id, RT_NONE ) ;
X	coveringWindow = (WindowPtr) 0 ;
X#else /* erik's hft hack */
X	if ( restoreBits )
X		ibmRestoreScreenData( pScreen, ppcRestoreAreas ) ;
X#endif
X
X	/* Now Reinstall the current Colormap !! */
X	ppcInstallColormap( currentColormap ) ;
X
X	if ( !--ibm8514cursorSemaphore && CursorWasActive )
X		ibm8514ReplaceCursor() ;
X
X	ibm8514ScreenInfoStruct.ibm_ScreenState = SCREEN_ACTIVE ;
X#if !defined(HFT_HACKS)
X	ibm8514RestoreOffScreenFonts( ibmScreen( index ) ) ;
X#else /* erik's hft hack */
X	ibm8514RestoreOffScreenFonts( pScreen ) ;
X#endif
X}
Xelse if ( ibm8514ScreenInfoStruct.ibm_ScreenState == SCREEN_ACTIVE ) {
X	ErrorF(
X	  "ibm8514SuspendScreenAndSave: ibm8514 State Is Still Active!" ) ;
X}
Xelse if ( ibm8514ScreenInfoStruct.ibm_ScreenState == SCREEN_UNINITIALIZED ) {
X	ErrorF( "ibm8514SuspendScreenAndSave: ibm8514 Still uninitialized!" ) ;
X}
X
Xreturn ;
X}
END-of-ibm8514/brcSuspScr.c
echo x - ibm8514/brcText.c
sed 's/^X//' >ibm8514/brcText.c << 'END-of-ibm8514/brcText.c'
X/*
X * Copyright IBM Corporation 1987,1990
X *
X * All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that 
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of IBM not be
X * used in advertising or publicity pertaining to distribution of the
X * software without specific, written prior permission.
X *
X * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
X * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
X * SOFTWARE.
X *
X*/
X/*
X * PRPQ 5799-PFF (C) COPYRIGHT IBM CORPORATION 1987,1990
X * LICENSED MATERIALS - PROPERTY OF IBM
X * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
X */
X/*
X *  Hardware interface routines for IBM 8514/A adapter for
X *  X.11 server(s) on IBM equipment.
X *
X */
X/* $Header:
/andrew/X11/r3src/r3plus/server/ddx/ibm/ibm8514/RCS/brcText.c,v 6.4
89/05/18 15:05:05 jeff Exp $ */
X/* $Source:
/andrew/X11/r3src/r3plus/server/ddx/ibm/ibm8514/RCS/brcText.c,v $ */
X
X#ifndef lint
Xstatic char *rcsid = "$Header:
/andrew/X11/r3src/r3plus/server/ddx/ibm/ibm8514/RCS/brcText.c,v 6.4
89/05/18 15:05:05 jeff Exp $";
X#endif
X
X/* Draw character glyphs on the screen, knowing that they have been
X * cached offscreen.  Worry about traditional X clipping and such.
X * 
X * You may wonder why I figure the background rectangle size every
X * time this is called, rather than just multiplying some font-specific
X * char size times the number of glyphs and using that.  The protocol
X * evidently has other views of this issue, so we do what it says;
X * the protocol is the bible here.  If the glyphs vary widely in size,
X * we come through with flying colors. (figuratively)
X * 
X */
X#include	"X.h"
X#include	"Xproto.h"
X#include	"fontstruct.h"
X#include	"dixfontstr.h"
X#include	"gcstruct.h"
X#include	"windowstr.h"
X#include	"scrnintstr.h"
X#include	"pixmapstr.h"
X#include	"regionstr.h"
X
X#include	"mfb.h"
X
X#include	"OScompiler.h"
X
X#include	"ppc.h"
X
X#include	"x8514.h"
X#include 	"brcFonts.h"
X
X#include	"ibmTrace.h"
X
Xextern int ibm8514Disabled ;
X
Xextern ibm8514FontCacheRec ibm8514FontCacheEntry[];
Xextern int ibm8514cursorSemaphore ;
Xextern int mfbGCPrivateIndex ;
X
Xstatic unsigned int
XmiWidth(n, charinfo)
X    register unsigned int n;
X    register CharInfoPtr charinfo[];
X{
X    register unsigned int w = 0;
X
X    while ( n-- )
X	w += charinfo[n]->metrics.characterWidth ;
X
X    return w;
X}
X
Xstatic int 
Xibm8514CachedPolyText( pDraw, pGC, x, y, count, chars, fontEncoding)
X    DrawablePtr pDraw;
X    GCPtr	pGC;
X    int		x, y;
X    int		count;
X    char	*chars;
X    FontEncoding fontEncoding;
X{
X    CharInfoPtr 	*ppci;
X    ExtentInfoRec 	info;
X    RegionPtr		prgnClip, pCC;
X    int			CursorIsSaved,i, alu ;
X    unsigned long int	rPM, wPM ;
X    int			index, nbox, x0, y0;
X    unsigned long int	fg ;
X    ScreenPtr		pscr;
X    FontPtr		pFont;
X    InstalledFontPtr	pInFont;
X    InstalledCharPtr	pChar;
X    xRectangle		backrect;
X    BoxRec		*pbox, bbox, cbox;
X    xCharInfo		*pBig, *pMetrics;
X    int			maxw, maxh, charoffset, lineoffset;
X    int			charFirst, charLast;
X    unsigned short 	*chars16 = (unsigned short *) chars;
X
XpCC = ((ppcPrivGC *)pGC->devPrivates[mfbGCPrivateIndex].ptr)->pCompositeClip;
Xif ( !( nbox = REGION_NUM_RECTS(pCC) ) )
X	return 0 ;
Xpbox = REGION_RECTS(pCC);
X
Xpscr = pGC->pScreen;
XpFont = pGC->font;
Xindex = pscr->myNum;
XpInFont = (InstalledFontPtr) pFont->devPriv[index];
XrPM = ibm8514FontCacheEntry[pInFont->CacheIndex].RPlaneMask;
X
Xalu = pGC->alu;
XwPM = pGC->planemask;
Xfg  = pGC->fgPixel;
X  
Xx += pDraw->x;
Xy += pDraw->y;
X
Xlineoffset = pInFont->startline;
XcharFirst  = charoffset = pInFont->firstchar;
XcharLast   = pInFont->lastchar;
X
Xppci = (CharInfoPtr *) ALLOCATE_LOCAL(count*sizeof(CharInfoPtr));
Xswitch ( fontEncoding)
X	{
X		{
X		for (i = 0 ; i <count; i++) 
X			if ( (charFirst <= chars16[i]) &&  
X	     		(charLast  >= chars16[i]) )
X	   		then	ppci[i] = pInFont->
X					ppCharacter[chars16[i]-charoffset]->
X					pInfo;
X	   		else 	{ i--; count--; } /* ignore this character */
X		break;
X		}
X		for (i = 0 ; i <count; i++) 
X			if ( (charFirst <= chars[i]) &&  
X	     		(charLast  >= chars[i]) )
X	   		then	ppci[i] = pInFont->
X					ppCharacter[chars[i]-charoffset]->
X					pInfo;
X	   		else 	{ i--; count--; } /* ignore this character */
X		break;
X		ErrorF("ibm8514CachedPolyText: bad font encoding");
X		return 0;
X	}
X
XQueryGlyphExtents(pFont,ppci,count,&info);
XDEALLOCATE_LOCAL(ppci);
X
Xbackrect.x = x + info.overallLeft;
Xbackrect.y = y - pFont->pFI->fontAscent;
Xbackrect.width = info.overallRight - info.overallLeft;
Xbackrect.width = MAX( backrect.width, info.overallWidth );
Xbackrect.height = pFont->pFI->fontAscent + pFont->pFI->fontDescent;
X
XpBig = &(pFont->pFI->maxbounds.metrics);
Xmaxw = count * (pBig->rightSideBearing - pBig->leftSideBearing);
Xmaxh =  (pBig->ascent + pBig->descent);
X
XCursorIsSaved = !ibm8514cursorSemaphore
X     && ( ibm8514CheckCursor( backrect.x, backrect.y,
X			      backrect.width, backrect.height )
X/* if fonts are correct, the next line may get deleted someday */
X       || ibm8514CheckCursor(x, y, maxw, maxh) ) ;
Xibm8514cursorSemaphore++ ;
X
Xbbox.x1 = x + info.overallLeft;
Xbbox.y1 = y - info.overallAscent;
Xbbox.x2 = x + info.overallRight;
Xbbox.y2 = y + info.overallDescent;
X
Xswitch ( (*pscr->RectIn)(pCC, &bbox))
X	{
X		break;
X		while ( count--)
X			{
X			if (fontEncoding == Linear8Bit)
X				index = *chars++ - charoffset;
X			   else index = *chars16++ - charoffset;
X
X			pChar=(InstalledCharPtr)pInFont->ppCharacter[index];
X			pMetrics = (xCharInfo *)(&(pChar->pInfo->metrics));
X			if (pChar->pInfo->exists)
X				{
X				x0 = x + pMetrics->leftSideBearing;
X				y0 = y - pMetrics->ascent;
Xif ( !ibm8514Disabled )
X				ibm8514BlitFG(rPM,wPM,fg,alu,
X					pChar->x, lineoffset + pChar->y, 
X					x0, y0, pChar->w, pChar->h);
X				}
X			x += pMetrics->characterWidth;
X			}	 
X		break;
X		prgnClip = (*(pscr->RegionCreate))((BoxRec *)NULL,1);
X		while ( count--)
X			{
X			index = *chars++ - charoffset;
X			pChar=(InstalledCharPtr)pInFont->ppCharacter[index];
X			pMetrics = (xCharInfo *)(&(pChar->pInfo->metrics));
X			if (pChar->pInfo->exists)
X				{
X				cbox.x1 = x0 = x + pMetrics->leftSideBearing;
X				cbox.y1 = y0 = y - pMetrics->ascent;
X				cbox.x2 = cbox.x1 + pChar->w;
X				cbox.y2 = cbox.y1 + pChar->h;
X
X				switch ( (*pscr->RectIn)(pCC, &cbox))
X					{
X						break;
Xif ( !ibm8514Disabled )
X						ibm8514BlitFG(rPM,wPM,fg,alu,
X							pChar->x, 
X							lineoffset+pChar->y, 
X							x0, y0, 
X							pChar->w, pChar->h);
X						break;
X						(*(pscr->RegionReset))(
X						   prgnClip, &cbox);
X						(*(pscr->Intersect))(
X						   prgnClip,prgnClip,pCC);
X						pbox = REGION_RECTS(prgnClip);
X						nbox = REGION_NUM_RECTS(prgnClip);
X						if (nbox==0) break;
Xif ( !ibm8514Disabled )
X						for (i = 0 ; i <nbox; i++, pbox++)
X							{
X							ibm8514ClearQueue(4);
X							SETXMIN(pbox->x1);
X							SETYMIN(pbox->y1);
X							SETXMAX(pbox->x2-1);
X							SETYMAX(pbox->y2-1);
X							ibm8514BlitFG(
X								rPM,
X								wPM,
X								fg,
X								alu,
X								pChar->x, 
X								lineoffset +
X								pChar->y, 
X								x0, 
X								y0, 
X								pChar->w, 
X								pChar->h);
X							}
Xif ( !ibm8514Disabled ) {
X						ibm8514ClearQueue(4);
X						SETXMIN(0);
X						SETYMIN(0);
X						SETXMAX(_8514_SCREENWIDTH-1);
X						SETYMAX( 1023 );
X}
X						break;
X					} /* end second switch */
X				}
X			x += pMetrics->characterWidth;
X			}
X		(*(pscr->RegionDestroy))(prgnClip);
X		break;
X	}/* end main switch */
Xif ( !(--ibm8514cursorSemaphore) && CursorIsSaved )
X	ibm8514ReplaceCursor();
X
Xreturn x- pDraw->x;
X}
X
Xstatic int
Xibm8514CachedImageText( pDraw, pGC, x, y, count, chars, fontEncoding)
X    DrawablePtr pDraw;
X    GCPtr	pGC;
X    int		x, y;
X    int		count;
X    char	*chars;
X    FontEncoding fontEncoding;
X{
X    CharInfoPtr 	*ppci;
X    ExtentInfoRec 	info;
X    RegionPtr		prgnClip, pCC;
X    int			CursorIsSaved,i ;
X    unsigned long int	rPM, wPM ;
X    int			index, nbox, x0, y0;
X    unsigned long int	fg, bg;
X    ScreenPtr		pscr;
X    FontPtr		pFont;
X    InstalledFontPtr	pInFont;
X    InstalledCharPtr	pChar;
X    xRectangle		backrect;
X    BoxRec		*pbox, bbox, cbox;
X    xCharInfo		*pBig, *pMetrics;
X    int			maxw, maxh, charoffset, lineoffset;
X    int			charFirst, charLast;
X    unsigned short 	*chars16 = (unsigned short *) chars;
X
X
XpCC = ((ppcPrivGC *)pGC->devPrivates[mfbGCPrivateIndex].ptr)->pCompositeClip;
Xif ( !( nbox = REGION_NUM_RECTS(pCC) ) )
X	return 0 ;
Xpbox = REGION_RECTS(pCC);
X
Xpscr = pGC->pScreen;
XpFont = pGC->font;
Xindex = pscr->myNum;
XpInFont = (InstalledFontPtr) pFont->devPriv[index];
XrPM = ibm8514FontCacheEntry[pInFont->CacheIndex].RPlaneMask;
X
XwPM = pGC->planemask;
Xbg  = pGC->bgPixel;
Xfg  = pGC->fgPixel;
X  
Xx += pDraw->x;
Xy += pDraw->y;
X
Xlineoffset = pInFont->startline;
XcharFirst  = charoffset = pInFont->firstchar;
XcharLast   = pInFont->lastchar;
X
X
Xppci = (CharInfoPtr *) ALLOCATE_LOCAL(count*sizeof(CharInfoPtr));
Xswitch ( fontEncoding)
X	{
X		{
X		for (i = 0 ; i <count; i++) 
X			if ( (charFirst <= chars16[i]) &&  
X	     		(charLast  >= chars16[i]) )
X	   		then	ppci[i] = pInFont->
X					ppCharacter[chars16[i]-charoffset]->
X					pInfo;
X	   		else 	{ i--; count--; } /* ignore this character */
X		break;
X		}
X		for (i = 0 ; i <count; i++) 
X			if ( (charFirst <= chars[i]) &&  
X	     		(charLast  >= chars[i]) )
X	   		then	ppci[i] = pInFont->
X					ppCharacter[chars[i]-charoffset]->
X					pInfo;
X	   		else 	{ i--; count--; } /* ignore this character */
X		break;
X		ErrorF("ibm8514CachedImageText: bad font encoding");
X		return 0;
X	}
X
XQueryGlyphExtents(pFont,ppci,count,&info);
XDEALLOCATE_LOCAL(ppci);
X
Xbackrect.x = x + info.overallLeft;
Xbackrect.y = y - pFont->pFI->fontAscent;
Xbackrect.width = info.overallRight - info.overallLeft;
Xbackrect.width = MAX( backrect.width, info.overallWidth );
Xbackrect.height = pFont->pFI->fontAscent + pFont->pFI->fontDescent;
X
XpBig = &(pFont->pFI->maxbounds.metrics);
Xmaxw = count * (pBig->rightSideBearing - pBig->leftSideBearing);
Xmaxh =  (pBig->ascent + pBig->descent);
X
XCursorIsSaved = !ibm8514cursorSemaphore
X     && ( ibm8514CheckCursor( backrect.x, backrect.y,
X			      backrect.width, backrect.height )
X/* if fonts are correct, the next line may get deleted someday */
X       || ibm8514CheckCursor(x, y, maxw, maxh) ) ;
Xibm8514cursorSemaphore++ ;
X
Xif ( !ibm8514Disabled ) {
Xfor ( i = 0 ; i <nbox; i++, pbox++)
X	{
X	ibm8514ClearQueue(4);
X	SETXMIN(pbox->x1);
X	SETYMIN(pbox->y1);
X	SETXMAX(pbox->x2-1);
X	SETYMAX(pbox->y2-1);
X	ibm8514DrawRectangle(bg,GXcopy,wPM, backrect.x, backrect.y,
X				backrect.width, backrect.height);
X	}
Xibm8514ClearQueue(4);
XSETXMIN(0);
XSETYMIN(0);
XSETXMAX(_8514_SCREENWIDTH-1);
XSETYMAX( 1023 );
X}
X
Xbbox.x1 = x + info.overallLeft;
Xbbox.y1 = y - info.overallAscent;
Xbbox.x2 = x + info.overallRight;
Xbbox.y2 = y + info.overallDescent;
X
Xswitch ( (*pscr->RectIn)(pCC, &bbox))
X	{
X		break;
X		while (count--)
X			{
X				/* 2d16bit already bombed */
X			if (fontEncoding == Linear8Bit)
X				index = *chars++ - charoffset;
X			   else index = *chars16++ - charoffset;
X
X			pChar=(InstalledCharPtr)pInFont->ppCharacter[index];
X			pMetrics = (xCharInfo *)(&(pChar->pInfo->metrics));
X			if (pChar->pInfo->exists)
X				{
X				x0 = x + pMetrics->leftSideBearing;
X				y0 = y - pMetrics->ascent;
Xif ( !ibm8514Disabled )
X				ibm8514BlitFG(rPM,wPM,fg,GXcopy,
X					pChar->x, lineoffset + pChar->y, 
X					x0, y0, pChar->w, pChar->h);
X				}
X			x += pMetrics->characterWidth;
X			}	 
X		break;
X		prgnClip = (*(pscr->RegionCreate))((BoxRec *)NULL,REGION_NUM_RECTS(pCC));
X		while ( count--)
X			{
X			index = *chars++ - charoffset;
X			pChar=(InstalledCharPtr)pInFont->ppCharacter[index];
X			pMetrics = (xCharInfo *)(&(pChar->pInfo->metrics));
X			if (pChar->pInfo->exists)
X				{
X				cbox.x1 = x0 = x + pMetrics->leftSideBearing;
X				cbox.y1 = y0 = y - pMetrics->ascent;
X				cbox.x2 = cbox.x1 + pChar->w;
X				cbox.y2 = cbox.y1 + pChar->h;
X
X				switch ( (*pscr->RectIn)(pCC, &cbox))
X					{
X						break;
Xif ( !ibm8514Disabled )
X						ibm8514BlitFG(rPM,wPM,fg,GXcopy,
X							pChar->x, 
X							lineoffset+pChar->y, 
X							x0, y0, 
X							pChar->w, pChar->h);
X						break;
X						(*(pscr->RegionReset))(
X						   prgnClip,&cbox);
X						(*(pscr->Intersect))(
X						   prgnClip,prgnClip,pCC);
X						pbox = REGION_RECTS(prgnClip);
X						nbox = REGION_NUM_RECTS(prgnClip);
X						if (nbox==0) break;
Xif ( !ibm8514Disabled ) {
X						for (i = 0 ; i <nbox; i++, pbox++)
X							{
X							ibm8514ClearQueue(4);
X							SETXMIN(pbox->x1);
X							SETYMIN(pbox->y1);
X							SETXMAX(pbox->x2-1);
X							SETYMAX(pbox->y2-1);
X							ibm8514BlitFG(
X								rPM,
X								wPM,
X								fg,
X								GXcopy,
X								pChar->x, 
X								lineoffset +
X								pChar->y, 
X								x0, 
X								y0, 
X								pChar->w, 
X								pChar->h);
X							}
X						ibm8514ClearQueue(4);
X						SETXMIN(0);
X						SETYMIN(0);
X						SETXMAX(_8514_SCREENWIDTH-1);
X						SETYMAX( 1023 );
X}
X						break;
X					} /* end second switch */
X				}
X			x += pMetrics->characterWidth;
X			}
X		(*(pscr->RegionDestroy))(prgnClip);
X		break;
X	}/* end main switch */
Xif ( !(--ibm8514cursorSemaphore) && CursorIsSaved )
X	ibm8514ReplaceCursor();
X
Xreturn x - pDraw->x;
X}
X
Xstatic int
Xibm8514PolyText(pDraw, pGC, x, y, count, chars, fontEncoding )
X    DrawablePtr pDraw;
X    GCPtr	pGC;
X    int		x, y;
X    int		count;
X    char 	*chars;
X    FontEncoding fontEncoding;
X{
X    CharInfoPtr *charinfo;
X    unsigned int n, w = 0;
X
Xswitch ( (long) pGC->font->devPriv[pDraw->pScreen->myNum] )
X	{
X		break;
X		switch (pGC->fillStyle )
X			{
X				return ibm8514CachedPolyText(pDraw, pGC, 
X					x, y, count, chars, fontEncoding);
X				return ibm8514StipCachedText( pDraw, pGC, 
X					x, y, count, chars, fontEncoding);
X				break;
X			}
X	}
X
Xif ( !(charinfo = (CharInfoPtr *)ALLOCATE_LOCAL(
X		count*sizeof(CharInfoPtr ))))
X	return x ;
XGetGlyphs(pGC->font, count, chars, fontEncoding, &n, charinfo);
Xif ( n ) {
X	w = miWidth(n, charinfo);
X	(*pGC->ops->PolyGlyphBlt)(
X	pDraw, pGC, x, y, n, charinfo, pGC->font->pGlyphs);
X}
X
XDEALLOCATE_LOCAL(charinfo);
Xreturn x + w ;
X}
X
Xstatic int
Xibm8514ImageText(pDraw, pGC, x, y, count, chars, fontEncoding)
X    DrawablePtr pDraw;
X    GCPtr	pGC;
X    int 	x, y;
X    int 	count;
X    char 	*chars;
X    FontEncoding fontEncoding;
X{
XCharInfoPtr *charinfo;
Xunsigned int n, w = 0;
X
Xswitch ( (long) pGC->font->devPriv[pDraw->pScreen->myNum] )
X	{
X    		if ( !(charinfo = (CharInfoPtr *)ALLOCATE_LOCAL(
X				count*sizeof(CharInfoPtr ))))
X			return x ;
X    		GetGlyphs(pGC->font, count, chars, fontEncoding, &n, charinfo);
X    		if ( n ) {
X    			w = miWidth(n, charinfo);
X        		(*pGC->ops->ImageGlyphBlt)(
X	    		pDraw, pGC, x, y, n, charinfo, pGC->font->pGlyphs);
X		}
X		
X    		DEALLOCATE_LOCAL(charinfo);
X    		return x + w ;
X	}
Xreturn ibm8514CachedImageText(pDraw, pGC, x, y, count, chars, fontEncoding);
X}
X
Xint
Xibm8514PolyText8(pDraw, pGC, x, y, count, chars)
X    DrawablePtr pDraw;
X    GCPtr	pGC;
X    int		x, y;
X    int 	count;
X    char	*chars;
X{
X    return ibm8514PolyText(pDraw, pGC, x, y, count, chars, Linear8Bit);
X}
X
Xint
Xibm8514PolyText16(pDraw, pGC, x, y, count, chars)
X    DrawablePtr pDraw;
X    GCPtr	pGC;
X    int		x, y;
X    int		count;
X    unsigned short *chars;
X{
Xreturn ibm8514PolyText( pDraw, pGC, x, y, count, (char *)chars,
X			( (pGC->font->pFI->lastRow == 0)
X			? Linear16Bit : TwoD16Bit ) ) ;
X}
X
Xvoid
Xibm8514ImageText8(pDraw, pGC, x, y, count, chars)
X    DrawablePtr pDraw;
X    GCPtr	pGC;
X    int		x, y;
X    int		count;
X    char	*chars;
X{
X    ibm8514ImageText(pDraw, pGC, x, y, count, chars, Linear8Bit);
X}
X
Xvoid
Xibm8514ImageText16(pDraw, pGC, x, y, count, chars)
X    DrawablePtr pDraw;
X    GCPtr	pGC;
X    int		x, y;
X    int		count;
X    unsigned short *chars;
X{
Xibm8514ImageText( pDraw, pGC, x, y, count, (char *)chars,
X			( (pGC->font->pFI->lastRow == 0)
X			? Linear16Bit : TwoD16Bit ) ) ;
Xreturn ;
X}
X
Xstatic int 
Xibm8514StipCachedText( pDraw, pGC, x, y, count, chars, fontEncoding)
X    DrawablePtr pDraw;
X    GCPtr	pGC;
X    int		x, y;
X    int		count;
X    char	*chars;
X    FontEncoding fontEncoding;
X{
X    CharInfoPtr 	*ppci;
X    ExtentInfoRec 	info;
X    RegionPtr		prgnDst, pCC;
X    int			CursorIsSaved,i, alu ;
X    unsigned long int	rPM, wPM ;
X    int			index, nbox, x0, y0, icount;
X    char*               ichars = chars;
X    unsigned long int	fg , bg;
X    ScreenPtr		pscr;
X    FontPtr		pFont;
X    InstalledFontPtr	pInFont;
X    InstalledCharPtr	pChar;
X    BoxRec		*pbox, bbox ;
X    xCharInfo		*pBig, *pMetrics;
X    int			maxw, maxh, charoffset, lineoffset;
X    int			charFirst, charLast;
X    unsigned short 	*chars16 = (unsigned short *) chars;
X    int			stageX, stageY;
X    void		GetStippleOnStage();
X
XpCC = ((ppcPrivGC *)pGC->devPrivates[mfbGCPrivateIndex].ptr)->pCompositeClip;
X
Xpscr = pGC->pScreen;
XpFont = pGC->font;
Xindex = pscr->myNum;
XpInFont = (InstalledFontPtr) pFont->devPriv[index];
XrPM = ibm8514FontCacheEntry[pInFont->CacheIndex].RPlaneMask;
X
Xx += pDraw->x;
Xy += pDraw->y;
X
Xif (!( REGION_NUM_RECTS(pCC))) return x- pDraw->x;
Xif ((alu = pGC->alu) == GXnoop) return x- pDraw->x;
XwPM = pGC->planemask;
Xfg  = pGC->fgPixel;
Xbg  = pGC->bgPixel;
X
Xlineoffset = pInFont->startline;
XcharFirst  = charoffset = pInFont->firstchar;
XcharLast   = pInFont->lastchar;
X
Xppci = (CharInfoPtr *) ALLOCATE_LOCAL(count*sizeof(CharInfoPtr));
Xswitch ( fontEncoding)
X	{
X		{
X		for (i = 0 ; i <count; i++) 
X			if ( (charFirst <= chars16[i]) &&  
X	     		(charLast  >= chars16[i]) )
X	   		then	ppci[i] = pInFont->
X					ppCharacter[chars16[i]-charoffset]->
X					pInfo;
X	   		else 	{ i--; count--; } /* ignore this character */
X		break;
X		}
X		for (i = 0 ; i <count; i++) 
X			if ( (charFirst <= chars[i]) &&  
X	     		(charLast  >= chars[i]) )
X	   		then	ppci[i] = pInFont->
X					ppCharacter[chars[i]-charoffset]->
X					pInfo;
X	   		else 	{ i--; count--; } /* ignore this character */
X		break;
X		ErrorF("ibm8514CachedPolyText: bad font encoding");
X		return 0;
X	}
X
XQueryGlyphExtents(pFont,ppci,count,&info);
XDEALLOCATE_LOCAL(ppci);
X
XpBig = &(pFont->pFI->maxbounds.metrics);
Xmaxw = count * (pBig->rightSideBearing - pBig->leftSideBearing);
Xmaxh =  (pBig->ascent + pBig->descent);
X
Xbbox.x1 = x + info.overallLeft;
Xbbox.y1 = y - info.overallAscent;
Xbbox.x2 = x + info.overallRight;
Xbbox.y2 = y + info.overallDescent;
X
X
XprgnDst = (* pscr->RegionCreate )( &bbox, REGION_NUM_RECTS(pCC)) ;
X(* pscr->Intersect)( prgnDst, prgnDst, pCC ) ;
X
Xif (!( REGION_NUM_RECTS(prgnDst)))
X	return x- pDraw->x;
X
XCursorIsSaved = !ibm8514cursorSemaphore
X     && ( ibm8514CheckCursor( bbox.x1, bbox.y1,
X			      bbox.x2 - bbox.x1, bbox.x2 - bbox.x1 )
X/* if fonts are correct, the next line may get deleted someday */
X       || ibm8514CheckCursor(x, y, maxw, maxh) ) ;
Xibm8514cursorSemaphore++ ;
X
Xswitch (pGC->fillStyle)
X	{
X		stageX = 0;
X		stageY = MONO_STAGE_Y + info.overallAscent;
X		GetStippleOnStage(pGC, &bbox);
X		icount = count;
X		while ( icount--)
X			{
X			if (fontEncoding == Linear8Bit)
X				index = *chars++ - charoffset;
X	   		else index = *chars16++ - charoffset;
X		
X			pChar=(InstalledCharPtr)pInFont->ppCharacter[index];
X			pMetrics = (xCharInfo *)(&(pChar->pInfo->metrics));
X			if ((pChar->pInfo->exists) && 
X					(stageX+x+pChar->w >= bbox.x1))
X				{
X				x0 = stageX + pMetrics->leftSideBearing;
X				y0 = stageY - pMetrics->ascent;
Xif ( !ibm8514Disabled )
X				ibm8514BlitFGBG(
X					rPM, MONO_STAGE_WPLANE,
X					255,0,GXandInverted,
X					pChar->x, lineoffset + pChar->y, 
X					x0, y0, 
X					pChar->w, pChar->h);
X				}
X			stageX += pMetrics->characterWidth;
X			if (stageX + x > bbox.x2) break;
X			}	 
Xif ( !ibm8514Disabled )
X		for (nbox = REGION_NUM_RECTS(prgnDst), pbox = REGION_RECTS(prgnDst);
X				nbox--;
X				pbox++)
X			{
X			x0 = pbox->x1;
X			y0 = pbox->y1;
X			ibm8514BlitFG(
X				MONO_STAGE_RPLANE, wPM, bg, alu,
X				MONO_STAGE_X + x0 - x,
X				stageY +y0-y,
X				x0, y0,
X				pbox->x2 - x0,
X				pbox->y2 - y0 );
X			}
X
X		/* fall through to do the foreground */
X		stageX = 0;
X		stageY = MONO_STAGE_Y + info.overallAscent;
Xif ( !ibm8514Disabled )
X		GetStippleOnStage(pGC, &bbox);
X		icount = count;
X		if (fontEncoding == Linear8Bit)
X			chars = ichars;
X	   	else chars16 = (unsigned int*)ichars;
X		while ( icount--)
X			{
X			if (fontEncoding == Linear8Bit)
X				index = *chars++ - charoffset;
X	   		else index = *chars16++ - charoffset;
X		
X			pChar=(InstalledCharPtr)pInFont->ppCharacter[index];
X			pMetrics = (xCharInfo *)(&(pChar->pInfo->metrics));
X			if ((pChar->pInfo->exists) && 
X					(stageX+x+pChar->w >= bbox.x1))
X				{
X				x0 = stageX + pMetrics->leftSideBearing;
X				y0 = stageY - pMetrics->ascent;
Xif ( !ibm8514Disabled )
X				ibm8514BlitFGBG(
X					rPM, MONO_STAGE_WPLANE,
X					255,0,GXand,
X					pChar->x, lineoffset + pChar->y, 
X					x0, y0, 
X					pChar->w, pChar->h);
X				}
X			stageX += pMetrics->characterWidth;
X			if (stageX + x > bbox.x2) break;
X			}	 
Xif ( !ibm8514Disabled )
X		for (nbox = REGION_NUM_RECTS(prgnDst), pbox = REGION_RECTS(prgnDst);
X				nbox--;
X				pbox++)
X			{
X			x0 = pbox->x1;
X			y0 = pbox->y1;
X			ibm8514BlitFG(
X				MONO_STAGE_RPLANE, wPM, fg, alu,
X				MONO_STAGE_X + x0 - x,
X				stageY +y0-y,
X				x0, y0,
X				pbox->x2 - x0,
X				pbox->y2 - y0 );
X			}
X
X		break;
X	}
Xif ( !(--ibm8514cursorSemaphore) && CursorIsSaved )
X	ibm8514ReplaceCursor();
X
Xreturn x- pDraw->x;
X}
X
X
Xstatic void
XGetStippleOnStage(pGC, pbox)
XGCPtr	pGC;
XBoxRec *pbox;
X{
XPixmapPtr 	pStipple;
Xregister int j;
Xint tlx, tly, boxW, boxH, drawW, drawH, grow;
Xint hoffset, voffset, vremaining, hremaining;
Xint xSrc, ySrc;
X
XpStipple = pGC->stipple;
X
Xtlx = pStipple->drawable.width;
Xtly = pStipple->drawable.height;
XxSrc = pGC->patOrg.x;
XySrc = pGC->patOrg.y;
X
XboxH = pbox->y2 - pbox->y1;
XboxW = pbox->x2 - pbox->x1;
XdrawW = MIN(boxW, tlx);
XdrawH = MIN(boxH, tly);
X
Xif ((hoffset = ((pbox->x1-xSrc)%tlx)) < 0)
X		hoffset += tlx;
Xhremaining = tlx-hoffset;
X
Xif ((voffset = ((pbox->y1-ySrc)%tly)) < 0)
X		voffset += tly;
Xvremaining = tly-voffset;
X
X#define FILL_STAGE_X 0
X#define FILL_STAGE_Y 802
Xif (hoffset)
X	{
X	ibm8514AlignMonoImage(FILL_STAGE_WPLANE, GXcopy,
X			FILL_STAGE_X, FILL_STAGE_Y,
X			tlx, drawH, pStipple->devPrivate.ptr );
X	/* LOWER RIGHT RECTANGLE */
X        ibm8514Bitblt
X                (
X                GXcopy, RPLANE1, MONO_STAGE_WPLANE,
X                FILL_STAGE_X+hoffset, FILL_STAGE_Y+voffset,
X                MONO_STAGE_X, MONO_STAGE_Y,
X                MIN(hremaining,drawW), MIN(vremaining,drawH)
X                );
X
X        /* LOWER LEFT RECTANGLE */
X        if (drawW > hremaining)
X        ibm8514Bitblt
X                (
X                GXcopy, RPLANE1, MONO_STAGE_WPLANE,
X                FILL_STAGE_X, FILL_STAGE_Y+voffset,
X                MONO_STAGE_X+hremaining, MONO_STAGE_Y,
X                drawW-hremaining, MIN(vremaining,drawH)
X                );
X
X        /* UPPER RIGHT RECTANGLE */
X        if (drawH > vremaining)
X            {
X            ibm8514Bitblt
X                (
X                GXcopy, RPLANE1, MONO_STAGE_WPLANE,
X                FILL_STAGE_X+hoffset, FILL_STAGE_Y,
X                MONO_STAGE_X, MONO_STAGE_Y+vremaining,
X                MIN(hremaining,drawW), drawH - vremaining
X                );
X
X        /* UPPER LEFT RECTANGLE */
X            if (drawW > hremaining)
X                ibm8514Bitblt
X                        (
X                        GXcopy, RPLANE1, MONO_STAGE_WPLANE,
X                        FILL_STAGE_X, FILL_STAGE_Y,
X                        MONO_STAGE_X+hremaining, MONO_STAGE_Y+vremaining,
X                        drawW-hremaining, drawH-vremaining
X                        );
X	     }
X	}
X   else {
X	if (voffset)
X		{
X		j = MIN(vremaining,drawH); 
X		ibm8514AlignMonoImage(MONO_STAGE_WPLANE, GXcopy,
X			MONO_STAGE_X, MONO_STAGE_Y,
X			tlx, j,
X			pStipple->devPrivate.ptr +
X				voffset*pStipple->devKind);
X		if (j<drawH)
X			ibm8514AlignMonoImage(MONO_STAGE_WPLANE, GXcopy,
X				MONO_STAGE_X, MONO_STAGE_Y + j,
X				tlx, drawH-j,
X				pStipple->devPrivate.ptr );
X			
X		}
X	   else ibm8514AlignMonoImage(MONO_STAGE_WPLANE, GXcopy,
X			MONO_STAGE_X, MONO_STAGE_Y,
X			tlx, drawH, pStipple->devPrivate.ptr );
X	}
Xwhile (  drawW < boxW)
X	{
X	grow = MIN(drawW, boxW-drawW);
X	ibm8514Bitblt(GXcopy,MONO_STAGE_RPLANE, MONO_STAGE_WPLANE,
X		0, MONO_STAGE_Y,
X		drawW, MONO_STAGE_Y,
X		grow, drawH);
X	drawW += grow;
X	}
Xwhile ( drawH < boxH)
X	{
X	grow = MIN(drawH, boxH-drawH);
X	ibm8514Bitblt(GXcopy,MONO_STAGE_RPLANE, MONO_STAGE_WPLANE,
X		0, MONO_STAGE_Y,
X		0, drawH,
X		drawW, grow);
X	drawH += grow;
X	}
X
Xreturn ;
X}
END-of-ibm8514/brcText.c
exit
Technical Details
Message-ID: <4475@ibmpa.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!ibmpa!dolphin.tcspa.ibm.com!mlewis

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!ibmpa!dolphin.tcspa.ibm.com!mlewis
From: mlewis@dolphin.tcspa.ibm.com (Mark S. Lewis)
Newsgroups: comp.sys.ibm.pc.rt
Subject: IBM 8514 source code (part 5 of 6) for X11 Release 4
Keywords: V1.32_kit.5 8514 X11R4
Message-ID: <4475@ibmpa.UUCP>
Date: 12 Mar 90 23:21:29 GMT
Sender: news@ibmpa.UUCP
Reply-To: mlewis@ibmsupt.UUCP
Followup-To: comp.sys.ibm.pc.rt
Organization: IBM AWD, Palo Alto
Lines: 1972