[comp.windows.x] R3 fixes for RTs

Richard.Draves@o.gp.cs.cmu.EDU (12/28/88)

I have it working with APA-16, AED, and Megapel displays on RTs running Mach.
I still see display glitches, especially on my Megapel display,
but the server doesn't die very often.

I compile the server with hc1.4u, using "-g -DDEBUG -DTRACE_X"
for ServerCDebugFlags.  I compile everything else with hc2.1d -O.
I have the Purdue speedups installed (not because I think they help
the RT, but for Suns and Vaxen), and the last two patches here
make them compile on RTs.  A couple patches have code conditional
on VIKING.  This is for simple server extension I first wrote for R2
which provides the capability of resetting the Viking (AED) display.  
The Viking font store often gets confused when one is using several fonts
at once, and the extension adds a command to reset the font store.
I didn't include most of the code to support this.  There were also a few
additional Mach/CMU-specific changes (for things like include files
and Makefiles) that I'm not including.

The patches to make R3 usable on RTs are
1) work around SIGGRANT problem
	server/ddx/ibm/BSDrt/OSio.h
2) I needed a newer version of buf_emul.h because the released Mach version
was out of date.  Your mileage may vary.
	server/ddx/ibm/common/machinecons/buf_emul.h
3) fixes for variable-width text (from the ITC)
	server/ddx/ibm/apa16/apa16Text.c
4) added QUEUE_WAIT() calls to fix some display glitches (ITC)
	server/ddx/ibm/apa16/apa16{Tile,BBlt,PntA}.c
5) fixed cursor colors on Viking displays
	server/ddx/ibm/aed/aedCursor.c
6) fixed "char fault on unknown character" message
	server/ddx/ibm/aed/aedFont.c
7) fixed mpel/ppc tiling bug
	server/ddx/ibm/mpel/mpelScrInit.c
8) hack to miPolyGlyphBlt to work around mpel/ppc bug
	server/ddx/mi/miglblt.c
9) fixes to Megapel code to prevent null-pointer references.  (Actually,
these are normally innocuous, but I was debugging in a mode that trapped
all references to page zero.)
	server/ddx/ibm/mpel/mpel{Fifo.h,Font.c,Img.c,Tile.c,Util.c}
10) PURDUE: fixed DoRop usage
	server/ddx/ibm/apa16/apa16FlSp.c
11) PURDUE: ppc uses the startpartial/endpartial arrays
	server/ddx/mfb/maskbits.c

*** server/ddx/ibm/BSDrt/OSio.h.~1~	Mon Nov  7 11:56:19 1988
--- server/ddx/ibm/BSDrt/OSio.h	Mon Nov  7 11:57:47 1988
***************
*** 46,52 ****
--- 46,56 ----
  
  #define	OS_PreScreenInit()	BSDMachineDependentInit()
  #define	OS_PostScreenInit()	BSDInitEmulator()
+ #ifdef	SIGGRANT
  #define	OS_ScreenStateChange(e)	BSDScreenStateChange(e)
+ #else	SIGGRANT
+ #define	OS_ScreenStateChange(e)
+ #endif	SIGGRANT
  
  #define	OS_GetDefaultScreens()
  #define	OS_InitInput()
*** /dev/null	Fri Dec 23 13:52:49 1988
--- server/ddx/ibm/common/machinecons/buf_emul.h	Sat Dec 10 22:20:54 1988
***************
*** 0 ****
--- 1,91 ----
+ /* 
+  * Mach Operating System 
+  * Copyright (c) 1988 Carnegie-Mellon University 
+  * All rights reserved.  The CMU software License Agreement specifies 
+  * the terms and conditions for use and redistribution. 
+  */ 
+ /* 
+  * HISTORY $Log:	buf_emul.h,v $
+  * Revision 2.4  88/10/10  22:26:13  sanzi
+  * 	Remove include of vgaio.h.
+  * 
+  * Revision 2.3  88/10/06  17:34:24  sanzi
+  * 	Added include of "device_base.h".  Merge with ACIS to minimize differences.
+  * 
+  */ 
+ /*
+  * 5799-CGZ (C) COPYRIGHT IBM CORPORATION 1986,1987
+  * LICENSED MATERIALS - PROPERTY OF IBM
+  * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
+  */
+ /* $Header: buf_emul.h,v 2.4 88/10/10 22:26:13 sanzi Exp $ */
+ /* $Source: /afs/cs.cmu.edu/project/mach/member1/rpd/kernel/cacons/RCS/buf_emul.h,v $ */
+ 
+ #if !defined(lint) && !defined(LOCORE)	&& defined(RCS_HDRS)
+ static char *rcsidbuf_emul = "$Header: buf_emul.h,v 2.4 88/10/10 22:26:13 sanzi Exp $";
+ #endif
+ 
+ #define BUF_CMAX	2048	/* Size of circular buffer */
+ #define BUF_ISOPEN	1	/* flag that buf_emul is open */
+ 
+ #define BUFSETWIND	_IOWR(b,0,unsigned)	/* 6152 only */
+ #define BUFINITVGA	_IOW(b,1,int)		/* 6152 only */
+ #define BUFINIT8514	_IO(b,2)		/* 6152 only */
+ #define BUF8514CTRL	_IOW(b,3,unsigned)	/* 6152 only */
+ #define BUFDISPINFO	_IOR(b,4,unsigned)	/* RT & 6152 */
+ /*
+  * valid fields for BUFDISPINFO
+  *
+  * bit 31 is the CPU type (1=6152 (ATR), 0=RTPC)
+  * bits 3-0 on the RT is the EGA switch settings
+  * bits 3,2 on the 6152 are the 8512 display type
+  * bits 1,0 on the 6152 are the vga display type
+  * All other fields are reserved
+  */
+ #define	BUF_CPU		0x80000000	/* CPU field */
+ #define	 BUF_CPU_ATR	0x80000000	/* CPU is ATR */
+ #define	 BUF_CPU_RTPC	0x00000000	/* CPU is RTPC */
+ #define	 BUF_IS_ATR(x)	(((x) & BUF_CPU) == BUF_CPU_ATR)
+ #define	 BUF_IS_RTPC(x)	(((x) & BUF_CPU) == BUF_CPU_RTPC)
+ #define	BUF_8514_TYPE	0x0000000c	/* type of 8514 display */
+ #define  BUF_GET_8514(x) (((x) & BUF_8514_TYPE) >> 2)
+ #define BUF_VGA_TYPE	0x00000003	/* type of VGA display */
+ #define  BUF_GET_VGA(x)	 ((x) & BUF_VGA_TYPE)
+ #define BUF_EGA_TYPE	0x0000000f	/* ega switch settings */
+ #define  BUF_GET_EGA(x)	 ((x) & BUF_EGA_TYPE)
+ #ifdef KERNEL
+ #define	BUF_PUT_8514(x)	 (((x) & 0x3) << 2)
+ #define BUF_PUT_VGA(x)	 ((x) & BUF_VGA_TYPE)
+ #define BUF_PUT_EGA(x)	 ((x) & BUF_EGA_TYPE)
+ #endif
+ 
+ #define BUFSETWIND	_IOWR(b,0,unsigned)	/* 6152 only */
+ #define BUFINITVGA	_IOW(b,1,int)		/* 6152 only */
+ #define BUFINIT8514	_IO(b,2)		/* 6152 only */
+ #define BUF8514CTRL	_IOW(b,3,unsigned)	/* 6152 only */
+ #define BUFDISPINFO	_IOR(b,4,unsigned)	/* RT & 6152 */
+ /*
+  * valid fields for BUFDISPINFO
+  *
+  * bit 31 is the CPU type (1=6152 (ATR), 0=RTPC)
+  * bits 3-0 on the RT is the EGA switch settings
+  * bits 3,2 on the 6152 are the 8512 display type
+  * bits 1,0 on the 6152 are the vga display type
+  * All other fields are reserved
+  */
+ #define	BUF_CPU		0x80000000	/* CPU field */
+ #define	 BUF_CPU_ATR	0x80000000	/* CPU is ATR */
+ #define	 BUF_CPU_RTPC	0x00000000	/* CPU is RTPC */
+ #define	 BUF_IS_ATR(x)	(((x) & BUF_CPU) == BUF_CPU_ATR)
+ #define	 BUF_IS_RTPC(x)	(((x) & BUF_CPU) == BUF_CPU_RTPC)
+ #define	BUF_8514_TYPE	0x0000000c	/* type of 8514 display */
+ #define  BUF_GET_8514(x) (((x) & BUF_8514_TYPE) >> 2)
+ #define BUF_VGA_TYPE	0x00000003	/* type of VGA display */
+ #define  BUF_GET_VGA(x)	 ((x) & BUF_VGA_TYPE)
+ #define BUF_EGA_TYPE	0x0000000f	/* ega switch settings */
+ #define  BUF_GET_EGA(x)	 ((x) & BUF_EGA_TYPE)
+ #ifdef KERNEL
+ #define	BUF_PUT_8514(x)	 (((x) & 0x3) << 2)
+ #define BUF_PUT_VGA(x)	 ((x) & BUF_VGA_TYPE)
+ #define BUF_PUT_EGA(x)	 ((x) & BUF_EGA_TYPE)
+ #endif
*** server/ddx/ibm/apa16/apa16Text.c.~1~	Tue Oct 25 06:55:49 1988
--- server/ddx/ibm/apa16/apa16Text.c	Mon Nov 28 10:57:16 1988
***************
*** 218,228 ****
  			afMap(aFont,count,charsOut,tmpCinfo,
  						aFont->afFont->pGlyphs);
  		    }
- 		    if (afChMapped(aFont,*charsOut)) {
- 			metrics=	&tmpCinfo[0]->metrics;
- 			width=		metrics->rightSideBearing-
- 					metrics->leftSideBearing;
  
  			COPY_RECT(bltCmd,
  				x+metrics->rightSideBearing,
  				y+metrics->descent,
--- 218,229 ----
  			afMap(aFont,count,charsOut,tmpCinfo,
  						aFont->afFont->pGlyphs);
  		    }
  
+ 		    metrics=	&tmpCinfo[0]->metrics;
+ 		    width=	metrics->rightSideBearing-
+ 				metrics->leftSideBearing;
+ 
+ 		    if (afChMapped(aFont,*charsOut)) {
  			COPY_RECT(bltCmd,
  				x+metrics->rightSideBearing,
  				y+metrics->descent,
***************
*** 407,417 ****
  			afMap(aFont,count,charsOut,tmpCinfo,
  						aFont->afFont->pGlyphs);
  		    }
- 		    if (afChMapped(aFont,*charsOut)) {
- 			metrics=	&tmpCinfo[0]->metrics;
- 			width=		metrics->rightSideBearing-
- 					metrics->leftSideBearing;
  
  			COPY_RECT(bltCmd,
  				x+metrics->leftSideBearing+width,
  				y+metrics->descent,
--- 408,419 ----
  			afMap(aFont,count,charsOut,tmpCinfo,
  						aFont->afFont->pGlyphs);
  		    }
  
+ 		    metrics=	&tmpCinfo[0]->metrics;
+ 		    width=	metrics->rightSideBearing-
+                                 metrics->leftSideBearing;
+ 
+ 		    if (afChMapped(aFont,*charsOut)) {
  			COPY_RECT(bltCmd,
  				x+metrics->leftSideBearing+width,
  				y+metrics->descent,
*** server/ddx/ibm/apa16/apa16Tile.c.~1~	Tue Oct 25 06:56:02 1988
--- server/ddx/ibm/apa16/apa16Tile.c	Mon Nov 28 10:57:17 1988
***************
*** 163,170 ****
      tileWidth = ptile->width ;
  
      if ( pDraw->type != DRAWABLE_WINDOW ) {
! 	if ( tileWidth == 32 )
! 		mfbTileArea32( pDraw, nbox, pbox, alu, ptile ) ;
  	else
  puts( "Tile Width != 32. I give up!" ) ;
  /*		mfbTileAreaXX( pDraw, nbox, pbox, alu, ptile ) ; */
--- 163,172 ----
      tileWidth = ptile->width ;
  
      if ( pDraw->type != DRAWABLE_WINDOW ) {
!         if ( tileWidth == 32 ) {
!                 QUEUE_WAIT();
!                 mfbTileArea32( pDraw, nbox, pbox, alu, ptile ) ;
!         }
  	else
  puts( "Tile Width != 32. I give up!" ) ;
  /*		mfbTileAreaXX( pDraw, nbox, pbox, alu, ptile ) ; */
***************
*** 266,272 ****
  	    unsigned cmd;
  
  	    APA16_GET_CMD(ROP_RECT_COPY,alu,cmd);
! 	    if (cmd==0) {
  		mfbTileArea32( pDraw, nbox, pbox, alu, ptile );
  		return;
  	    }
--- 268,275 ----
  	    unsigned cmd;
  
  	    APA16_GET_CMD(ROP_RECT_COPY,alu,cmd);
!             if (cmd==0) {
!                 QUEUE_WAIT();
  		mfbTileArea32( pDraw, nbox, pbox, alu, ptile );
  		return;
  	    }
*** server/ddx/ibm/apa16/apa16BBlt.c.~1~	Tue Oct 25 06:56:03 1988
--- server/ddx/ibm/apa16/apa16BBlt.c	Mon Nov 28 10:57:18 1988
***************
*** 202,212 ****
      if (pGC->planemask&1)
  	apa16DoBitblt(pSrcDrawable, pDstDrawable, pGC->alu, prgnDst, pptSrc);
  
!     if (((mfbPrivGC *)(pGC->devPriv))->fExpose)
          prgnExposed= miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
  		          	origSource.x, origSource.y,
  		          	origSource.width, origSource.height,
! 		          	origDest.x, origDest.y);
  		
      DEALLOCATE_LOCAL(pptSrc);
  freeRegions:
--- 202,214 ----
      if (pGC->planemask&1)
  	apa16DoBitblt(pSrcDrawable, pDstDrawable, pGC->alu, prgnDst, pptSrc);
  
!     if (((mfbPrivGC *)(pGC->devPriv))->fExpose) {
!         QUEUE_WAIT();
          prgnExposed= miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
  		          	origSource.x, origSource.y,
  		          	origSource.width, origSource.height,
!                                 origDest.x, origDest.y);
!     }
  		
      DEALLOCATE_LOCAL(pptSrc);
  freeRegions:
***************
*** 260,266 ****
  
      if ((pSrcDrawable->type != DRAWABLE_WINDOW)||
  	(pDstDrawable->type != DRAWABLE_WINDOW)||
! 	(alu==GXorReverse)||(alu==GXequiv)) {
  	mfbDoBitblt(pSrcDrawable,pDstDrawable,alu,prgnDst,pptSrc);
  	return;
      }
--- 262,269 ----
  
      if ((pSrcDrawable->type != DRAWABLE_WINDOW)||
  	(pDstDrawable->type != DRAWABLE_WINDOW)||
!         (alu==GXorReverse)||(alu==GXequiv)) {
!         QUEUE_WAIT();
  	mfbDoBitblt(pSrcDrawable,pDstDrawable,alu,prgnDst,pptSrc);
  	return;
      }
*** server/ddx/ibm/apa16/apa16PntA.c.~1~	Tue Oct 25 06:55:51 1988
--- server/ddx/ibm/apa16/apa16PntA.c	Mon Nov 28 10:57:19 1988
***************
*** 90,95 ****
--- 90,96 ----
  
      if (pDraw->type != DRAWABLE_WINDOW)
      {
+         QUEUE_WAIT();
  	if (rrop==RROP_BLACK)	
  	    mfbSolidBlackArea(pDraw,nbox,pbox,rrop,nop);
  	else if (rrop==RROP_WHITE)
***************
*** 156,161 ****
--- 157,164 ----
  
  
      unsigned int *pbits;	/* pointer to start of drawable */
+ 
+     QUEUE_WAIT();
  
      if (pDraw->type == DRAWABLE_WINDOW)
      {
*** server/ddx/ibm/aed/aedCursor.c.~1~	Wed Nov 30 23:16:15 1988
--- server/ddx/ibm/aed/aedCursor.c	Thu Dec  1 01:12:05 1988
***************
*** 142,147 ****
--- 142,148 ----
      ScreenPtr	pScr;
      CursorPtr	pCurs;
  {
+     unsigned long int *pStart;
      register unsigned long int *pImage, *pMask;
      register unsigned long int *psrcImage, *psrcMask;
      register int srcHeight;
***************
*** 148,153 ****
--- 149,155 ----
      register unsigned long int endbits;
      int srcWidth;
      int srcRealWidth;
+     int i;
  
      TRACE(("aedRealizeCursor( pScr= 0x%x, pCurs= 0x%x)\n",pScr,pCurs));
  
***************
*** 156,162 ****
  	ErrorF("aedRealizeCursor: can't malloc\n");
  	return FALSE;
  	}
!     pMask = (unsigned long int *) pCurs->devPriv[pScr->myNum];
      pImage = pMask + 128;
      bzero((char *) pMask, 1024);
      psrcImage = pCurs->source;
--- 158,164 ----
  	ErrorF("aedRealizeCursor: can't malloc\n");
  	return FALSE;
  	}
!     pStart = pMask = (unsigned long int *) pCurs->devPriv[pScr->myNum];
      pImage = pMask + 128;
      bzero((char *) pMask, 1024);
      psrcImage = pCurs->source;
***************
*** 187,192 ****
--- 189,216 ----
  	    *pMask++  = *psrcMask++ ;
  	    *pImage++ = *psrcImage++ & endbits;
  	    *pMask++  = *psrcMask++  & endbits;
+ 	}
+ 
+     pMask = pStart;
+     pImage = pMask + 128;
+     if ((pCurs->foreRed + pCurs->foreGreen + pCurs->foreBlue) >
+ 	(pCurs->backRed + pCurs->backGreen + pCurs->backBlue))
+ 	for (i = 0; i < 128; i++)
+ 	{
+ 	    unsigned long int mask = *pMask;
+ 	    unsigned long int source = *pImage;
+ 
+ 	    *pMask++ = mask & ~source;
+ 	    *pImage++ = mask & source;
+ 	}
+     else
+ 	for (i = 0; i < 128; i++)
+ 	{
+ 	    unsigned long int mask = *pMask;
+ 	    unsigned long int source = *pImage;
+ 
+ 	    *pMask++ = mask & source;
+ 	    *pImage++ = mask & ~source;
  	}
  
      if (!ibmCurrentCursor(pScr->myNum)) {
*** server/ddx/ibm/aed/aedFont.c.~1~	Wed Nov 30 23:26:06 1988
--- server/ddx/ibm/aed/aedFont.c	Wed Nov 30 23:42:20 1988
***************
*** 152,158 ****
      TRACE(("aedUnrealizeFont( pscr=0x%x, pFont=0x%x)\n", pscr, pFont));
      if ( ( fontnum = (int)pFont->devPriv[ pscr->myNum ] ) != 0 )
      {
- #ifdef THISISDELETEDTOTRYANDFIXTHEAEDBUG
  	for ( i = 0 ; i < 256; i++ )
  	{
  	    vikint[1] = 6;	/* delete character */
--- 152,157 ----
***************
*** 164,170 ****
  	vikint[1] = 5;	/* delete font */
  	vikint[2] = fontnum;
  	command(2);
- #endif
  	aedRealizedFonts[fontnum] = (FontPtr)NULL;
      }
      TRACE(("unrealized font #%d\n",(int)pFont->devPriv[pscr->myNum]));
--- 163,168 ----
***************
*** 172,177 ****
--- 170,211 ----
      return(TRUE);
  }
  
+ /* This code is derived from the Linear8Bit case in GetGlyphs. */
+ 
+ static void
+ aedFontFault(font, vikptr)
+     FontPtr font;
+     register volatile unsigned short *vikptr;
+ {
+     CharInfoPtr		pCI = font->pCI;
+     FontInfoPtr		pFI = font->pFI;
+     unsigned int	firstCol = pFI->firstCol;
+     unsigned int	numCols = pFI->lastCol - firstCol + 1;
+     unsigned int	chDefault = pFI->chDefault;
+     unsigned int	cDef = chDefault - firstCol;
+     register unsigned int	i;
+ 
+     if (pFI->allExist && (cDef < numCols))
+     {
+         for (i = 0; i < 256; i++)
+ 	    VIKSTORE(*vikptr++, 0);
+     }
+     else
+     {
+ 	for (i = 0; i < 256; i++)
+ 	{
+ 	    register unsigned int c = i - firstCol;
+ 	    
+ 	    if ((c < numCols) && pCI[c].exists)
+ 		VIKSTORE(*vikptr++, 0);
+ 	    else if ((cDef < numCols) && pCI[cDef].exists)
+ 		VIKSTORE(*vikptr++, 0);
+ 	    else
+ 		VIKSTORE(*vikptr++, 1);
+ 	} 
+     }
+ }
+ 
  #define vikcmd ((volatile unsigned short *)(VIKROOT + 0x4002))
  aedCheckFault()
  {
***************
*** 198,210 ****
  	{
  	    case 1:
  		fontid = VIKLOAD(*(pvikcmd+1));
! 		if ( aedRealizedFonts[fontid] != 0 )
  		{
  		    TRACE(("Font fault on font #%d\n",fontid));
  		    VIKSTORE(*(pvikcmd) , 1);	/* font available */
! 		    vikptr = pvikcmd+1;
! 		    for ( i=0; i<256; i++ )
! 			VIKSTORE(*vikptr++ , 0);
  		    VIKSTORE(*semaphore , 0x0101);
  		}
  		else
--- 232,242 ----
  	{
  	    case 1:
  		fontid = VIKLOAD(*(pvikcmd+1));
! 		if ( (pFont = aedRealizedFonts[fontid]) != 0 )
  		{
  		    TRACE(("Font fault on font #%d\n",fontid));
  		    VIKSTORE(*(pvikcmd) , 1);	/* font available */
! 		    aedFontFault(pFont, pvikcmd+1);
  		    VIKSTORE(*semaphore , 0x0101);
  		}
  		else
***************
*** 226,261 ****
  		    {
  			pglyph = ((char *)pFont->pGlyphs)+ci->byteOffset;
  			vikptr = pvikcmd;
! 			w = GLYPHWIDTHPIXELS((ci));
! 			h = GLYPHHEIGHTPIXELS((ci));
! 			widthGlyph = GLYPHWIDTHBYTESPADDED((ci));
! 			widthShorts = widthGlyph >> 1;
! 			oddWidth = widthGlyph != ( widthShorts << 1 );
! 			len = h*((w+15)/16) + 9;
! 			VIKSTORE(*vikptr++ , 1);	/* char available */
! 			VIKSTORE(*vikptr++ , len);
! 			VIKSTORE(*vikptr++ , 6);	/* move relative order */
! 			VIKSTORE(*vikptr++ , ci->metrics.leftSideBearing);
! 			VIKSTORE(*vikptr++ , -ci->metrics.ascent);
! 			VIKSTORE(*vikptr++ , 9);	/* draw image */
! 			VIKSTORE(*vikptr++ , w);
! 			VIKSTORE(*vikptr++ , h);
! 			pdst = vikptr;	 
! 			for ( i=0; i<h; i++ )
  			{
! 			    for( j=0; j < widthGlyph; j++ )
! 				VIKSTOREB(*pdst++ , *pglyph++);
! 			    vikptr = vikptr + widthShorts;
! 			    if ( oddWidth )
  			    {
! 				vikptr++;
! 				VIKSTOREB(*pdst++ , (char)0);
  			    }
  			}
- 			VIKSTORE(*vikptr++ , 6);	/* move relative */
- 			VIKSTORE(*vikptr++ , ci->metrics.characterWidth - ci->metrics.leftSideBearing);
- 			VIKSTORE(*vikptr++ , ci->metrics.ascent);
- 			VIKSTORE(*semaphore , 0x0101);
  		    }
  		    else
  		    {
--- 258,305 ----
  		    {
  			pglyph = ((char *)pFont->pGlyphs)+ci->byteOffset;
  			vikptr = pvikcmd;
! 			if (((w = GLYPHWIDTHPIXELS(ci)) == 0) ||
! 			    ((h = GLYPHHEIGHTPIXELS(ci)) == 0))
  			{
! 			    /* no glyph, so just move right */
! 			    VIKSTORE(*vikptr++, 1); /* char available */
! 			    VIKSTORE(*vikptr++, 3);
! 			    VIKSTORE(*vikptr++, 6); /* move relative order */
! 			    VIKSTORE(*vikptr++, ci->metrics.characterWidth);
! 			    VIKSTORE(*vikptr++, 0);
! 			    VIKSTORE(*semaphore, 0x0101);
! 			}
! 			else
! 			{
! 			    widthGlyph = GLYPHWIDTHBYTESPADDED((ci));
! 			    widthShorts = widthGlyph >> 1;
! 			    oddWidth = widthGlyph != ( widthShorts << 1 );
! 			    len = h*((w+15)/16) + 9;
! 			    VIKSTORE(*vikptr++ , 1);	/* char available */
! 			    VIKSTORE(*vikptr++ , len);
! 			    VIKSTORE(*vikptr++ , 6);	/* move relative order */
! 			    VIKSTORE(*vikptr++ , ci->metrics.leftSideBearing);
! 			    VIKSTORE(*vikptr++ , -ci->metrics.ascent);
! 			    VIKSTORE(*vikptr++ , 9);	/* draw image */
! 			    VIKSTORE(*vikptr++ , w);
! 			    VIKSTORE(*vikptr++ , h);
! 			    pdst = vikptr;	 
! 			    for ( i=0; i<h; i++ )
  			    {
! 				for( j=0; j < widthGlyph; j++ )
! 				    VIKSTOREB(*pdst++ , *pglyph++);
! 				vikptr = vikptr + widthShorts;
! 				if ( oddWidth )
! 				{
! 				    vikptr++;
! 				    VIKSTOREB(*pdst++ , (char)0);
! 				}
  			    }
+ 			    VIKSTORE(*vikptr++ , 6);	/* move relative */
+ 			    VIKSTORE(*vikptr++ , ci->metrics.characterWidth - ci->metrics.leftSideBearing);
+ 			    VIKSTORE(*vikptr++ , ci->metrics.ascent);
+ 			    VIKSTORE(*semaphore , 0x0101);
  			}
  		    }
  		    else
  		    {
***************
*** 278,280 ****
--- 322,344 ----
      vikwait();
      }
  }
+ 
+ #ifdef	VIKING
+ 
+ void
+ aedResetViking(pScreen)
+     ScreenPtr pScreen;
+ {
+     volatile unsigned short *pvikcmd = vikcmd;
+ 
+     TRACE(("aedResetViking(pScreen=0x%x)\n", pScreen));
+ 
+     vforce();
+     vikwait();
+ 
+     VIKSTORE(*pvikcmd, 0);		/* reset font store */
+     VIKSTORE(*semaphore, 0x0101);
+     vikwait();
+ }
+ 
+ #endif	VIKING
*** server/ddx/ibm/mpel/mpelScrInit.c.~1~	Thu Dec  1 00:24:07 1988
--- server/ddx/ibm/mpel/mpelScrInit.c	Sat Dec  3 13:52:51 1988
***************
*** 171,176 ****
--- 171,177 ----
      devPriv->CheckCursor = mpelCheckCursor ;
      devPriv->ReplaceCursor = mpelReplaceCursor ;
      devPriv->DestroyGCPriv = mpelDestroyGCPriv;
+     devPriv->replicateArea = ppcReplicateArea;
  
      pPixmap = (PixmapPtr) pScreen->devPrivate;
  
***************
*** 242,247 ****
--- 243,252 ----
      pScreen->WakeupHandler = OS_WakeupHandler;
      pScreen->blockData = (pointer)0;
      pScreen->wakeupData = (pointer)0;
+ 
+ #ifdef	VIKING
+     pScreen->ResetViking = 0;
+ #endif	VIKING
  
      pVisual->vid = pScreen->rootVisual;
      pVisual->screen = index;
*** server/ddx/mi/miglblt.c.~1~	Sat Dec 10 15:24:58 1988
--- server/ddx/mi/miglblt.c	Sat Dec 10 15:27:14 1988
***************
*** 118,123 ****
--- 118,129 ----
  	nbyGlyphWidth = GLYPHWIDTHBYTESPADDED(pci);
  	nbyPadGlyph = PixmapBytePad(gWidth, 1);
  
+ 	if ((gWidth == 0) || (gHeight == 0)) {
+ 	    ErrorF("miPolyGlyphBlt: gWidth = %d, gHeight = %d\n",
+ 		   gWidth, gHeight);
+ 	    continue;
+ 	}
+ 
  	for (i=0, pb = pbits; i<gHeight; i++, pb = pbits+(i*nbyPadGlyph))
  	    for (j = 0; j < nbyGlyphWidth; j++)
  		*pb++ = *pglyph++;
*** server/ddx/ibm/mpel/mpelFifo.h.~1~	Tue Oct 25 22:25:15 1988
--- server/ddx/ibm/mpel/mpelFifo.h	Sat Dec 10 15:34:44 1988
***************
*** 60,65 ****
--- 60,67 ----
  extern	void	mfData();
  #endif /* PORTABLE */
  
+ extern int MPELNoOpData;
+ 
  #define	MPELSetLineType(t)			mfCmd1Arg(0x5040,(t))
  #define	MPELSetPolylineColor(i)			mfCmd1Arg(0x5042,(i))
  #define	MPELSetMarkerType(t)			mfCmd1Arg(0x5043,(t))
*** server/ddx/ibm/mpel/mpelFont.c.~1~	Tue Oct 25 22:25:16 1988
--- server/ddx/ibm/mpel/mpelFont.c	Sat Dec 10 15:33:08 1988
***************
*** 273,279 ****
  
      TRACE(("mpelCleanXFont(0x%x)\n",xFont));
  
!     MPELNoOp(2,0);
      MPELWaitFifo();
      /* First, free any bands the font is holding */
      band= xFont->currentBand;
--- 273,279 ----
  
      TRACE(("mpelCleanXFont(0x%x)\n",xFont));
  
!     MPELNoOp(2,&MPELNoOpData);
      MPELWaitFifo();
      /* First, free any bands the font is holding */
      band= xFont->currentBand;
*** server/ddx/ibm/mpel/mpelImg.c.~1~	Tue Oct 25 22:25:17 1988
--- server/ddx/ibm/mpel/mpelImg.c	Sat Dec 10 15:33:10 1988
***************
*** 134,140 ****
  	        MOVE( data, (volatile unsigned char *) MPEL_BLIT_STAGE, w*nh) ;
  
  	    MPELSrcBLTVPM( &blt ) ;
! 	    MPELNoOp( 2, 0 ) ;
  	} /* end while */
      } /* end else */
  
--- 134,140 ----
  	        MOVE( data, (volatile unsigned char *) MPEL_BLIT_STAGE, w*nh) ;
  
  	    MPELSrcBLTVPM( &blt ) ;
! 	    MPELNoOp( 2, &MPELNoOpData ) ;
  	} /* end while */
      } /* end else */
  
***************
*** 182,188 ****
  	/* do a DestBlt VPM */
  	MPELVPMBLTDest( &blt ) ;
  	/* Make Sure The Transfer is complete */
! 	MPELNoOp( 2, 0 ) ;
  	MPELWaitFifo() ;
  	/* NOW, read the data from the Stage */
  	if ( skip ) {
--- 182,188 ----
  	/* do a DestBlt VPM */
  	MPELVPMBLTDest( &blt ) ;
  	/* Make Sure The Transfer is complete */
! 	MPELNoOp( 2, &MPELNoOpData ) ;
  	MPELWaitFifo() ;
  	/* NOW, read the data from the Stage */
  	if ( skip ) {
***************
*** 210,216 ****
  	    /* do a DestBlt VPM */
  	    MPELVPMBLTDest( &blt ) ;
  	    /* Make Sure The Transfer is complete */
! 	    MPELNoOp( 2, 0 ) ;
  
  	    h -= nh ;
  
--- 210,216 ----
  	    /* do a DestBlt VPM */
  	    MPELVPMBLTDest( &blt ) ;
  	    /* Make Sure The Transfer is complete */
! 	    MPELNoOp( 2, &MPELNoOpData ) ;
  
  	    h -= nh ;
  
*** server/ddx/ibm/mpel/mpelTile.c.~1~	Tue Oct 25 22:25:20 1988
--- server/ddx/ibm/mpel/mpelTile.c	Sat Dec 10 15:33:11 1988
***************
*** 191,197 ****
      }
  
      if ( widthLeftOver ) {
! 	MPELNoOp( 2, 0 ) ;
  	pdst = ( (volatile unsigned char *)MPEL_BLIT_STAGE )
  	     + MPEL_BLIT_STAGE_SIZE/2;
  	psrc = psrcSave;
--- 191,197 ----
      }
  
      if ( widthLeftOver ) {
! 	MPELNoOp( 2, &MPELNoOpData ) ;
  	pdst = ( (volatile unsigned char *)MPEL_BLIT_STAGE )
  	     + MPEL_BLIT_STAGE_SIZE/2;
  	psrc = psrcSave;
*** server/ddx/ibm/mpel/mpelUtil.c.~1~	Tue Oct 25 22:25:20 1988
--- server/ddx/ibm/mpel/mpelUtil.c	Sat Dec 10 15:33:45 1988
***************
*** 61,66 ****
--- 61,68 ----
  
  #define MAXRETRY 500
  
+ int MPELNoOpData = 0;
+ 
  mpelRectangle mpelDfltScissor = {
  	{ 0, 0 }, { MPEL_WIDTH - 1, MPEL_HEIGHT - 1 }
  } ;
*** server/ddx/ibm/apa16/apa16FlSp.c.~1~	Sat Dec 10 22:52:28 1988
--- server/ddx/ibm/apa16/apa16FlSp.c	Sat Dec 10 22:53:09 1988
***************
*** 598,604 ****
--- 598,608 ----
  		    while(nlMiddle--)
  		    {
  			    getbits(psrc, nstart, 32, tmpSrc);
+ #ifdef	PURDUE
+ 			    DoRop(*pdst, rop, tmpSrc, *pdst);
+ #else	PURDUE
  			    *pdst = DoRop(rop, tmpSrc, *pdst);
+ #endif	PURDUE
  			    pdst++;
  			    psrc++;
  		    }
*** server/ddx/mfb/maskbits.c.~2~	Sat Dec 10 18:54:50 1988
--- server/ddx/mfb/maskbits.c	Sat Dec 10 22:37:13 1988
***************
*** 116,122 ****
  	0xFFFFFFFE
      };
  
! #ifndef PURDUE
  /* a hack, for now, since the entries for 0 need to be all
     1 bits, not all zeros.
     this means the code DOES NOT WORK for segments of length
--- 116,122 ----
  	0xFFFFFFFE
      };
  
! #if	!defined(PURDUE) || defined(romp)
  /* a hack, for now, since the entries for 0 need to be all
     1 bits, not all zeros.
     this means the code DOES NOT WORK for segments of length
***************
*** 193,199 ****
  	0xFFFFFFFC,
  	0xFFFFFFFE
      };
! #else  /* PURDUE */
  unsigned int partmasks[32][32] = {
       {0xFFFFFFFF, 0x80000000, 0xC0000000, 0xE0000000,
        0xF0000000, 0xF8000000, 0xFC000000, 0xFE000000,
--- 193,200 ----
  	0xFFFFFFFC,
  	0xFFFFFFFE
      };
! #endif
! #ifdef	PURDUE
  unsigned int partmasks[32][32] = {
       {0xFFFFFFFF, 0x80000000, 0xC0000000, 0xE0000000,
        0xF0000000, 0xF8000000, 0xFC000000, 0xFE000000,
***************
*** 532,538 ****
  	0x7FFFFFFF
  	};
  
! #ifndef PURDUE
  /* a hack, for now, since the entries for 0 need to be all
     1 bits, not all zeros.
     this means the code DOES NOT WORK for segments of length
--- 533,539 ----
  	0x7FFFFFFF
  	};
  
! #if	!defined(PURDUE) || defined(romp)
  /* a hack, for now, since the entries for 0 need to be all
     1 bits, not all zeros.
     this means the code DOES NOT WORK for segments of length
***************
*** 609,615 ****
  	0x3FFFFFFF,
  	0x7FFFFFFF
  	};
! #else  /* PURDUE */
  unsigned int partmasks[32][32] = {
       {0xFFFFFFFF, 0x00000001, 0x00000003, 0x00000007,
        0x0000000F, 0x0000001F, 0x0000003F, 0x0000007F,
--- 610,617 ----
  	0x3FFFFFFF,
  	0x7FFFFFFF
  	};
! #endif
! #ifdef	PURDUE
  unsigned int partmasks[32][32] = {
       {0xFFFFFFFF, 0x00000001, 0x00000003, 0x00000007,
        0x0000000F, 0x0000001F, 0x0000003F, 0x0000007F,

ehrlich@shire.cs.psu.edu (Dan Ehrlich) (01/12/89)

In article <8812280441.AA15432@ATHENA.MIT.EDU>, Richard.Draves@o.gp writes:
>I have it working with APA-16, AED, and Megapel displays on RTs running Mach.
>I still see display glitches, especially on my Megapel display,
>but the server doesn't die very often.
>

IBM has admitted that the megapel code 'sometimes uses the wrong value for the Y
coordinate when drawing'.  Try to get a copy of the Dec 22, 1988 distribution of
X11 R2 which has the corrected megapel code in it.  IBM has supposedly sent the
fixed code to the X consortium also.
-- 
Dan Ehrlich <ehrlich@shire.cs.psu.edu> | Disclaimer: The opinions expressed are
The Pennsylvania State University      | my own, and should not be attributed
Department of Computer Science         | to anyone else, living or dead.
University Park, PA   16802            |