--- vide:Amiga-GS510/gs5.03/gdevamiga.c	Tue Nov 25 19:03:30 1997
+++ vide:gs5.10/gdevamiga.c	Sat Sep 23 12:38:08 2000
@@ -42,7 +42,7 @@
  *
  *	Internet:   opel@rumms.uni-mannheim.de
  */
-
+#define IXEMUL
 #include <clib/macros.h>
 #include <datatypes/pictureclass.h>
 #include <dos/dostags.h>
@@ -62,17 +62,17 @@
 #include <intuition/icclass.h>
 #include <libraries/asl.h>
 #include <libraries/iffparse.h>
+#include <cybergraphics/cybergraphics.h>
 
 #include <proto/asl.h>
 #include <proto/dos.h>
 #include <proto/exec.h>
-#define BltBitMap BlitBitMap	/* Hide weird compiler error! */
 #include <proto/graphics.h>
-#undef BltBitMap
 #include <proto/iffparse.h>
 #include <proto/intuition.h>
 #include <proto/layers.h>
 #include <proto/utility.h>
+#include <proto/cybergraphics.h>
 
 #include "gscdefs.h"
 #include "gserrors.h"
@@ -238,6 +238,8 @@
 	struct RastPort	*temp_rport;	/* Temporary raster port for pixmap imaging. */
 	UBYTE		*temp_array;	/* Temporary colour manipulation array. */
 	LONG		*pens;
+	struct Library  *CyberGfxBase;
+	BOOL		 true_color;	/* Is the screen a True/Hi Color one */
 } gx_device_amiga;
 
 	/* Cheap, but effective macro for casting the device argument ;-) */
@@ -271,7 +273,6 @@
 	UWORD X_DPI, UWORD Y_DPI);
 private BOOL SaveBitMap(STRPTR Name, struct BitMap *BitMap, LONG Width, 
 	LONG Height, UWORD X_DPI, UWORD Y_DPI);
-private VOID DispatchTask(VOID);
 private VOID DeleteScrollers(gx_device *dev);
 private BOOL CreateScrollers(gx_device *dev, struct Screen *Screen);
 private VOID WindowResize(gx_device *dev);
@@ -318,12 +319,17 @@
 
 	/* Set stack to a resonable large value, GS really needs it */
 	/* 50Kb should cover almost all usages */
+#ifdef __MORPHOS__
+unsigned long __stack=100000;
+#else
 unsigned long __stack=50000;
+#endif
 
 	/* External reference to some libraries, required for version checking, etc. */
 
 extern struct GfxBase *GfxBase;
 extern struct Library *AslBase;
+private struct Library *CyberGfxBase;
 
 	/* Detect wether user has set -g and/or -r at the command line */
 
@@ -337,9 +343,22 @@
 
 	/* Bit masks. */
 
+#ifdef __PPC__
+
+#define SHIFT(x) (1 << (7 - (x)))
+#define MASKS(x) (~(1 << (7 - (x))))
+
+#else
+
 private UBYTE shift[8] = { 128, 64, 32, 16,  8,  4,  2,  1 };
 private UBYTE masks[8] = { 127,191,223,239,247,251,253,254 };
 
+#define SHIFT(x) shift[x]
+#define MASKS(x) masks[x]
+
+#endif
+
+
 	/* Dark (black) and light (white) rendering colours; the default device
 	 * determines the actual colours to be used by looking into the screen
 	 * colour lookup table, the other device drivers leave these values
@@ -546,7 +565,9 @@
 	0,				/* cube_size */
 	NULL,				/* temp_rport */
 	NULL,				/* temp_array */
-	NULL				/* pens */
+	NULL,				/* pens */
+	NULL,				/* CyberGfxBase */
+	0                               /* true_color */
 };
 
 	/* Custom device: opens a custom screen, will ask for screen mode or check env variable. */
@@ -584,7 +605,9 @@
 	0,				/* cube_size */
 	NULL,				/* temp_rport */
 	NULL,				/* temp_array */
-	NULL				/* pens */
+	NULL,				/* pens */
+	NULL,				/* CyberGfxBase */
+	0                               /* true_color */
 };
 
 	/* Printer device: renders the imagery and sends it to the printer */
@@ -622,7 +645,9 @@
 	0,				/* cube_size */
 	NULL,				/* temp_rport */
 	NULL,				/* temp_array */
-	NULL				/* pens */
+	NULL,				/* pens */
+	NULL,				/* CyberGfxBase */
+	0                               /* true_color */
 };
 
 	/* ILBM device: renders the imagery and saves it to an IFF-ILBM file. */
@@ -660,7 +685,9 @@
 	0,				/* cube_size */
 	NULL,				/* temp_rport */
 	NULL,				/* temp_array */
-	NULL				/* pens */
+	NULL,				/* pens */
+	NULL,				/* CyberGfxBase */
+	0                               /* true_color */
 };
 
 	/* set_mono_device(gx_device_amiga *dev,int cube_size,LONG *pens):
@@ -1306,14 +1333,23 @@
 	 *	Asynchronous window message dispatcher.
 	 */
 
+#ifdef __MORPHOS__
+private void DispatchTaskFunc(void);
+static const struct { UWORD x; UWORD y; APTR func; } DispatchTask = {
+    0xff05,0,DispatchTaskFunc
+};
+private void
+DispatchTaskFunc()
+#else
 private VOID
 DispatchTask()
+#endif
 {
 	struct Task	*me;
 	gx_device	*dev;
 
 		/* Set up global data area base register. */
-#ifdef IXEMUL
+#if defined(IXEMUL) && !defined(__MORPHOS__)
 	ix_geta4();
 #endif
 		/* Who am I? */
@@ -2238,6 +2274,10 @@
 
 		/* Get a lock on the default public screen. */
 
+	xdev -> CyberGfxBase = OpenLibrary("cybergraphics.library", 0);
+	if(xdev -> CyberGfxBase)
+		CyberGfxBase = xdev -> CyberGfxBase;
+
 	DefaultScreen = LockPubScreen(NULL);
 	if(DefaultScreen)
 	{
@@ -2375,8 +2415,9 @@
 							xdev -> window -> RPort);
 						if(xdev -> temp_rport)
 						{
+							xdev -> true_color = xdev -> CyberGfxBase && GetBitMapAttr(xdev -> window -> RPort -> BitMap, BMA_DEPTH);
 							xdev -> temp_array = (UBYTE *)AllocVec(
-								(xdev -> window -> WScreen -> Width + 15) & ~15, 
+								((xdev -> window -> WScreen -> Width + 15) & ~15) * (xdev->true_color ? 3 : 1),
 								MEMF_ANY);
 							if(xdev -> temp_array)
 							{
@@ -2403,9 +2444,16 @@
 								if (127 < TaskPri)	/* Ouch... */
 									TaskPri = 127;	/* ;-) */
 								
-								Task = CreateTask(
-									"Ghostscript window dispatcher", 
-									TaskPri, DispatchTask, 8192);
+#ifdef __MORPHOS__
+								Task = CreateNewProcTags(NP_Entry,&DispatchTask,
+											 NP_Name,"Ghostscript window dispatcher",
+											 NP_Priority,TaskPri,
+											 NP_StackSize,16384,
+											 TAG_END);
+#else
+								Task = CreateTask("Ghostscript window dispatcher",
+										  TaskPri, (APTR)&DispatchTask, 8192);
+#endif
 								if(Task)
 								{
 										/* Cheap... */
@@ -3170,6 +3218,10 @@
 	struct DisplayInfo	DisplayInfo;
 	struct DimensionInfo	DimensionInfo;
 
+	xdev -> CyberGfxBase = OpenLibrary("cybergraphics.library", 0);
+	if(xdev -> CyberGfxBase)
+		CyberGfxBase = xdev -> CyberGfxBase;
+
 		/* Get the display dimensions. */
 
 	if(GetDisplayInfoData(NULL,(APTR)&DisplayInfo,sizeof(struct DisplayInfo),DTAG_DISP,Mode) && GetDisplayInfoData(NULL,(APTR)&DimensionInfo,sizeof(struct DimensionInfo),DTAG_DIMS,Mode))
@@ -3339,6 +3391,7 @@
 			{
 				xdev -> rport	= &xdev -> screen -> RastPort;
 			}
+			xdev -> true_color = CyberGfxBase && GetBitMapAttr(xdev->rport->BitMap, BMA_DEPTH);
 
 				/* Establish defaults. */
 
@@ -3353,8 +3406,8 @@
 			xdev -> temp_rport = CreateTempRPort(xdev -> rport);
 			if(xdev -> temp_rport)
 			{
-				xdev -> temp_array = (UBYTE *)AllocVec((dev -> width + 15) 
-					& ~15, MEMF_ANY);
+				xdev -> temp_array = (UBYTE *)AllocVec(((dev -> width + 15)
+					& ~15) * (xdev -> true_color ? 3 : 1), MEMF_ANY);
 				if(xdev -> temp_array)
 				{
 						/* Colour output enabled? */
@@ -3518,6 +3571,8 @@
 		xdev -> screen = NULL;
 	}
 
+	CloseLibrary(xdev -> CyberGfxBase);
+
 	return(0);
 }
 
@@ -3558,13 +3613,49 @@
 	{
 		if(one != gx_no_color_index)
 		{
+			if(xdev -> true_color)
+			{
+				UBYTE r, g, b;
+				gx_color_value color[3];
+
+				dev_proc(dev, map_color_rgb)(dev, one, color);
+				r = gx_color_value_to_byte(color[0]);
+				g = gx_color_value_to_byte(color[1]);
+				b = gx_color_value_to_byte(color[2]);
+
+				do
+				{
+					UBYTE *p = xdev -> temp_array;
+
+					ReadPixelArray(xdev -> temp_array,0,0,w*3,xdev -> rport,x,y,w,1,RECTFMT_RGB);
+
+					for(i = sourcex, j = 0 ; i < sourcex + w ; i++, j++, p += 3)
+					{
+						if(base[i >> 3] & SHIFT(i & 7))
+						{
+							p[0] = r;
+							p[1] = g;
+							p[2] = b;
+						}
+					}
+
+					WritePixelArray(xdev -> temp_array,0,0,w*3,xdev -> rport,x,y,w,1,RECTFMT_RGB);
+
+					base += raster;
+
+					y++;
+				}
+				while(--h);
+			}
+			else
+			{
 			do
 			{
 				ReadPixelLine8(xdev -> rport,x,y,w,xdev -> temp_array,xdev -> temp_rport);
 
 				for(i = sourcex, j = 0 ; i < sourcex + w ; i++, j++)
 				{
-					if(base[i >> 3] & shift[i & 7])
+						if(base[i >> 3] & SHIFT(i & 7))
 						xdev -> temp_array[j] = one;
 				}
 
@@ -3577,17 +3668,54 @@
 			while(--h);
 		}
 	}
+	}
 	else
 	{
 		if(one == gx_no_color_index)
 		{
+			if(xdev -> true_color)
+			{
+				UBYTE r, g, b;
+				gx_color_value color[3];
+
+				dev_proc(dev, map_color_rgb)(dev, one, color);
+				r = gx_color_value_to_byte(color[0]);
+				g = gx_color_value_to_byte(color[1]);
+				b = gx_color_value_to_byte(color[2]);
+
+				do
+				{
+					UBYTE *p = xdev -> temp_array;
+
+					ReadPixelArray(xdev -> temp_array,0,0,w*3,xdev -> rport,x,y,w,1,RECTFMT_RGB);
+
+					for(i = sourcex, j = 0 ; i < w + sourcex ; i++, j++, p += 3)
+					{
+						if(!(base[i >> 3] & SHIFT(i & 7)))
+						{
+							p[0] = r;
+							p[1] = g;
+							p[2] = b;
+						}
+					}
+
+					WritePixelArray(xdev -> temp_array,0,0,w*3,xdev -> rport,x,y,w,1,RECTFMT_RGB);
+
+					base += raster;
+
+					y++;
+				}
+				while(--h);
+			}
+			else
+			{
 			do
 			{
 				ReadPixelLine8(xdev -> rport,x,y,w,xdev -> temp_array,xdev -> temp_rport);
 
 				for(i = sourcex, j = 0 ; i < w + sourcex ; i++, j++)
 				{
-					if(!(base[i >> 3] & shift[i & 7]))
+						if(!(base[i >> 3] & SHIFT(i & 7)))
 						xdev -> temp_array[j] = zero;
 				}
 
@@ -3599,13 +3727,14 @@
 			}
 			while(--h);
 		}
+		}
 		else
 		{
 			do
 			{
 				for(i = sourcex, j = 0 ; i < w + sourcex ; i++, j++)
 				{
-					if(base[i >> 3] & shift[i & 7])
+					if(base[i >> 3] & SHIFT(i & 7))
 						xdev -> temp_array[j] = one;
 					else
 						xdev -> temp_array[j] = zero;
@@ -3641,7 +3770,7 @@
 	{
 		for(i = sourcex, j = 0 ; i < w + sourcex ; i++, j++)
 		{
-			if(base[i >> 3] & shift[i & 7])
+			if(base[i >> 3] & SHIFT(i & 7))
 				xdev -> temp_array[j] = DarkPen;
 			else
 				xdev -> temp_array[j] = LightPen;
@@ -3672,6 +3801,9 @@
 	{
 		LONG pen;
 
+		if(xdev -> true_color)
+			pen = ReadRGBPixel(xdev -> rport,x1,y1);
+		else
 		pen = ReadPixel(xdev -> rport,x1,y1);
 
 		amiga_set_pen(dev,color);
@@ -3679,10 +3811,11 @@
 		Move(xdev -> rport,x0,y0);
 		Draw(xdev -> rport,x1,y1);
 
-		if(pen == color)
+		if(xdev -> true_color)
+			WriteRGBPixel(xdev -> rport,x1,y1,pen);
+		else if(pen != color)
 		{
 			amiga_set_pen(dev,pen);
-
 			WritePixel(xdev -> rport,x1,y1);
 		}
 	}
@@ -3718,8 +3851,8 @@
 				{
 					for(i = sourcex, j = x ; i < w ; i++, j++)
 					{
-						if(base[i >> 3] & shift[i & 7])
-							line[j >> 3] |= shift[j & 7];
+						if(base[i >> 3] & SHIFT(i & 7))
+							line[j >> 3] |= SHIFT(j & 7);
 					}
 
 					base += raster;
@@ -3734,8 +3867,8 @@
 				{
 					for(i = sourcex, j = x ; i < w ; i++, j++)
 					{
-						if(base[i >> 3] & shift[i & 7])
-							line[j >> 3] &= masks[j & 7];
+						if(base[i >> 3] & SHIFT(i & 7))
+							line[j >> 3] &= MASKS(j & 7);
 					}
 						base += raster;
 						line += modulo;
@@ -3754,8 +3887,8 @@
 				{
 					for(i = sourcex, j = x ; i < w ; i++, j++)
 					{
-						if(!(base[i >> 3] & shift[i & 7]))
-							line[j >> 3] |= shift[j & 7];
+						if(!(base[i >> 3] & SHIFT(i & 7)))
+							line[j >> 3] |= SHIFT(j & 7);
 					}
 
 					base += raster;
@@ -3770,8 +3903,8 @@
 				{
 					for(i = sourcex, j = x ; i < w ; i++, j++)
 					{
-						if(!(base[i >> 3] & shift[i & 7]))
-							line[j >> 3] &= masks[j & 7];
+						if(!(base[i >> 3] & SHIFT(i & 7)))
+							line[j >> 3] &= MASKS(j & 7);
 					}
 
 					base += raster;
@@ -3789,10 +3922,10 @@
 				{
 					for(i = sourcex, j = x ; i < w ; i++, j++)
 					{
-						if(base[i >> 3] & shift[i & 7])
-							line[j >> 3] |= shift[j & 7];
+						if(base[i >> 3] & SHIFT(i & 7))
+							line[j >> 3] |= SHIFT(j & 7);
 						else
-							line[j >> 3] &= masks[j & 7];
+							line[j >> 3] &= MASKS(j & 7);
 					}
 
 					base += raster;
@@ -3807,10 +3940,10 @@
 				{
 					for(i = sourcex, j = x ; i < w ; i++, j++)
 					{
-						if(base[i >> 3] & shift[i & 7])
-							line[j >> 3] &= masks[j & 7];
+						if(base[i >> 3] & SHIFT(i & 7))
+							line[j >> 3] &= MASKS(j & 7);
 						else
-							line[j >> 3] |= shift[j & 7];
+							line[j >> 3] |= SHIFT(j & 7);
 					}
 
 					base += raster;
@@ -3847,10 +3980,10 @@
 	{
 		for(i = sourcex, j = x ; i < w ; i++, j++)
 		{
-			if(base[i >> 3] & shift[i & 7])
-				line[j >> 3] |= shift[j & 7];
+			if(base[i >> 3] & SHIFT(i & 7))
+				line[j >> 3] |= SHIFT(j & 7);
 			else
-				line[j >> 3] &= masks[j & 7];
+				line[j >> 3] &= MASKS(j & 7);
 		}
 
 		base += raster;
@@ -4008,7 +4141,7 @@
 
 		if(color)
 		{
-			line[x >> 3] |= shift[x & 7];
+			line[x >> 3] |= SHIFT(x & 7);
 
 			xstep = ystep = 0;
 
@@ -4037,7 +4170,7 @@
 							if(y1 != last)
 								line = &plane[(last = y1) * modulo];
 
-							line[x1 >> 3] |= shift[x1 & 7];
+							line[x1 >> 3] |= SHIFT(x1 & 7);
 						}
 					}
 					while(xstep < dx);
@@ -4068,7 +4201,7 @@
 							if(y1 != last)
 								line = &plane[(last = y1) * modulo];
 
-							line[x1 >> 3] |= shift[x1 & 7];
+							line[x1 >> 3] |= SHIFT(x1 & 7);
 						}
 					}
 					while(ystep > dy);
@@ -4099,7 +4232,7 @@
 							if(y1 != last)
 								line = &plane[(last = y1) * modulo];
 
-							line[x1 >> 3] |= shift[x1 & 7];
+							line[x1 >> 3] |= SHIFT(x1 & 7);
 						}
 					}
 					while(xstep < dx);
@@ -4130,7 +4263,7 @@
 							if(y1 != last)
 								line = &plane[(last = y1) * modulo];
 
-							line[x1 >> 3] |= shift[x1 & 7];
+							line[x1 >> 3] |= SHIFT(x1 & 7);
 						}
 					}
 					while(ystep < dy);
@@ -4142,12 +4275,12 @@
 				if(y1 != last)
 					line = &plane[(last = y1) * modulo];
 
-				line[x1 >> 3] &= masks[x1 & 7];
+				line[x1 >> 3] &= MASKS(x1 & 7);
 			}
 		}
 		else
 		{
-			line[x >> 3] &= masks[x & 7];
+			line[x >> 3] &= MASKS(x & 7);
 
 			xstep = ystep = 0;
 
@@ -4176,7 +4309,7 @@
 							if(y1 != last)
 								line = &plane[(last = y1) * modulo];
 
-							line[x1 >> 3] &= masks[x1 & 7];
+							line[x1 >> 3] &= MASKS(x1 & 7);
 						}
 					}
 					while(xstep < dx);
@@ -4207,7 +4340,7 @@
 							if(y1 != last)
 								line = &plane[(last = y1) * modulo];
 
-							line[x1 >> 3] &= masks[x1 & 7];
+							line[x1 >> 3] &= MASKS(x1 & 7);
 						}
 					}
 					while(ystep > dy);
@@ -4238,7 +4371,7 @@
 							if(y1 != last)
 								line = &plane[(last = y1) * modulo];
 
-							line[x1 >> 3] &= masks[x1 & 7];
+							line[x1 >> 3] &= MASKS(x1 & 7);
 						}
 					}
 					while(xstep < dx);
@@ -4269,7 +4402,7 @@
 							if(y1 != last)
 								line = &plane[(last = y1) * modulo];
 
-							line[x1 >> 3] &= masks[x1 & 7];
+							line[x1 >> 3] &= MASKS(x1 & 7);
 						}
 					}
 					while(ystep < dy);
@@ -4730,14 +4863,14 @@
 			{
 				for(i = sourcex, j = x ; i < w ; i++, j++)
 				{
-					if(base[i >> 3] & shift[i & 7])
+					if(base[i >> 3] & SHIFT(i & 7))
 					{
 						for(k = 0 ; k < depth ; k++)
 						{
 							if(one & (1 << k))
-								line[k][j >> 3] |= shift[j & 7];
+								line[k][j >> 3] |= SHIFT(j & 7);
 							else
-								line[k][j >> 3] &= masks[j & 7];
+								line[k][j >> 3] &= MASKS(j & 7);
 						}
 					}
 				}
@@ -4757,14 +4890,14 @@
 				{
 					for(i = sourcex, j = x ; i < w ; i++, j++)
 					{
-						if(base[i >> 3] & shift[i & 7])
+						if(base[i >> 3] & SHIFT(i & 7))
 						{
 							for(k = 0 ; k < depth ; k++)
 							{
 								if(zero & (1 << k))
-									line[k][j >> 3] |= shift[j & 7];
+									line[k][j >> 3] |= SHIFT(j & 7);
 								else
-									line[k][j >> 3] &= masks[j & 7];
+									line[k][j >> 3] &= MASKS(j & 7);
 							}
 						}
 					}
@@ -4782,14 +4915,14 @@
 				{
 					for(i = sourcex, j = x ; i < w ; i++, j++)
 					{
-						if(base[i >> 3] & shift[i & 7])
+						if(base[i >> 3] & SHIFT(i & 7))
 						{
 							for(k = 0 ; k < depth ; k++)
 							{
 								if(one & (1 << k))
-									line[k][j >> 3] |= shift[j & 7];
+									line[k][j >> 3] |= SHIFT(j & 7);
 								else
-									line[k][j >> 3] &= masks[j & 7];
+									line[k][j >> 3] &= MASKS(j & 7);
 							}
 						}
 						else
@@ -4797,9 +4930,9 @@
 							for(k = 0 ; k < depth ; k++)
 							{
 								if(zero & (1 << k))
-									line[k][j >> 3] |= shift[j & 7];
+									line[k][j >> 3] |= SHIFT(j & 7);
 								else
-									line[k][j >> 3] &= masks[j & 7];
+									line[k][j >> 3] &= MASKS(j & 7);
 							}
 						}
 					}
@@ -4848,9 +4981,9 @@
 			for(k = 0 ; k < depth ; k++)
 			{
 				if(wordbase[i] & (1 << k))
-					line[k][j >> 3] |= shift[j & 7];
+					line[k][j >> 3] |= SHIFT(j & 7);
 				else
-					line[k][j >> 3] &= masks[j & 7];
+					line[k][j >> 3] &= MASKS(j & 7);
 			}
 		}
 
@@ -4991,7 +5124,7 @@
 
 			if(color & (1 << i))
 			{
-				line[x >> 3] |= shift[x & 7];
+				line[x >> 3] |= SHIFT(x & 7);
 
 				xstep = ystep = 0;
 
@@ -5020,7 +5153,7 @@
 								if(y1 != last)
 									line = &plane[(last = y1) * modulo];
 
-								line[x1 >> 3] |= shift[x1 & 7];
+								line[x1 >> 3] |= SHIFT(x1 & 7);
 							}
 						}
 						while(xstep < dx);
@@ -5051,7 +5184,7 @@
 								if(y1 != last)
 									line = &plane[(last = y1) * modulo];
 
-								line[x1 >> 3] |= shift[x1 & 7];
+								line[x1 >> 3] |= SHIFT(x1 & 7);
 							}
 						}
 						while(ystep > dy);
@@ -5082,7 +5215,7 @@
 								if(y1 != last)
 									line = &plane[(last = y1) * modulo];
 
-								line[x1 >> 3] |= shift[x1 & 7];
+								line[x1 >> 3] |= SHIFT(x1 & 7);
 							}
 						}
 						while(xstep < dx);
@@ -5113,7 +5246,7 @@
 								if(y1 != last)
 									line = &plane[(last = y1) * modulo];
 
-								line[x1 >> 3] |= shift[x1 & 7];
+								line[x1 >> 3] |= SHIFT(x1 & 7);
 							}
 						}
 						while(ystep < dy);
@@ -5125,12 +5258,12 @@
 					if(y1 != last)
 						line = &plane[(last = y1) * modulo];
 
-					line[x1 >> 3] &= masks[x1 & 7];
+					line[x1 >> 3] &= MASKS(x1 & 7);
 				}
 			}
 			else
 			{
-				line[x >> 3] &= masks[x & 7];
+				line[x >> 3] &= MASKS(x & 7);
 
 				xstep = ystep = 0;
 
@@ -5159,7 +5292,7 @@
 								if(y1 != last)
 									line = &plane[(last = y1) * modulo];
 
-								line[x1 >> 3] &= masks[x1 & 7];
+								line[x1 >> 3] &= MASKS(x1 & 7);
 							}
 						}
 						while(xstep < dx);
@@ -5190,7 +5323,7 @@
 								if(y1 != last)
 									line = &plane[(last = y1) * modulo];
 
-								line[x1 >> 3] &= masks[x1 & 7];
+								line[x1 >> 3] &= MASKS(x1 & 7);
 							}
 						}
 						while(ystep > dy);
@@ -5221,7 +5354,7 @@
 								if(y1 != last)
 									line = &plane[(last = y1) * modulo];
 
-								line[x1 >> 3] &= masks[x1 & 7];
+								line[x1 >> 3] &= MASKS(x1 & 7);
 							}
 						}
 						while(xstep < dx);
@@ -5252,7 +5385,7 @@
 								if(y1 != last)
 									line = &plane[(last = y1) * modulo];
 
-								line[x1 >> 3] &= masks[x1 & 7];
+								line[x1 >> 3] &= MASKS(x1 & 7);
 							}
 						}
 						while(ystep < dy);
