Add ROPs for 1, 8, 16, 24 and 32 bpp
authorGé van Geldorp <ge@gse.nl>
Tue, 12 Aug 2003 21:55:47 +0000 (21:55 +0000)
committerGé van Geldorp <ge@gse.nl>
Tue, 12 Aug 2003 21:55:47 +0000 (21:55 +0000)
svn path=/trunk/; revision=5548

reactos/subsys/win32k/dib/dib.c
reactos/subsys/win32k/dib/dib.h
reactos/subsys/win32k/dib/dib16bpp.c
reactos/subsys/win32k/dib/dib1bpp.c
reactos/subsys/win32k/dib/dib24bpp.c
reactos/subsys/win32k/dib/dib32bpp.c
reactos/subsys/win32k/dib/dib4bpp.c
reactos/subsys/win32k/dib/dib8bpp.c

index 5ab46bc..43656ba 100644 (file)
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dib.c,v 1.2 2003/05/18 17:16:17 ea Exp $ */
+/* $Id: dib.c,v 1.3 2003/08/12 21:55:47 gvg Exp $ */
+
+#include <windows.h>
+#include <ddk/winddi.h>
+#include <win32k/debug.h>
+#include <debug.h>
+#include "../eng/objects.h"
+#include "dib.h"
 
 /* Static data */
 
@@ -24,4 +31,141 @@ unsigned char notmask[2] = { 0x0f, 0xf0 };
 unsigned char altnotmask[2] = { 0xf0, 0x0f };
 unsigned char mask1Bpp[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
 
+ULONG
+DIB_GetSource(SURFOBJ* SourceSurf, SURFGDI* SourceGDI, ULONG sx, ULONG sy, XLATEOBJ* ColorTranslation)
+{
+  switch (SourceGDI->BitsPerPixel)
+    {
+    case 1:
+      if (DIB_1BPP_GetPixel(SourceSurf, sx, sy))
+       {
+         return(XLATEOBJ_iXlate(ColorTranslation, 0));
+       }
+      else
+       {
+         return(XLATEOBJ_iXlate(ColorTranslation, 1));
+       }
+    case 4:
+      if (ColorTranslation != NULL)
+       {
+         return(XLATEOBJ_iXlate(ColorTranslation, DIB_4BPP_GetPixel(SourceSurf, sx, sy)));
+       }
+      else
+       {
+         return(DIB_4BPP_GetPixel(SourceSurf, sx, sy));
+       }
+    case 8:
+      return(XLATEOBJ_iXlate(ColorTranslation, DIB_8BPP_GetPixel(SourceSurf, sx, sy)));
+    case 16:
+      return(XLATEOBJ_iXlate(ColorTranslation, DIB_16BPP_GetPixel(SourceSurf, sx, sy)));
+    case 24:
+      return(XLATEOBJ_iXlate(ColorTranslation, DIB_24BPP_GetPixel(SourceSurf, sx, sy)));
+    case 32:
+      return(XLATEOBJ_iXlate(ColorTranslation, DIB_32BPP_GetPixel(SourceSurf, sx, sy)));
+    default:
+      DPRINT1("DIB_16BPP_ExpandSource: Unhandled number of bits per pixel in source.\n");
+      return(0);
+    }
+}
+
+ULONG
+DIB_DoRop(ULONG Rop, ULONG Dest, ULONG Source, ULONG Pattern)
+{
+  ULONG ResultNibble;
+  ULONG Result;
+  ULONG i;
+  static const ULONG ExpandDest[16] = 
+    {
+      0x55555555 /* 0000 */,
+      0x555555AA /* 0001 */,
+      0x5555AA55 /* 0010 */,
+      0x5555AAAA /* 0011 */,
+      0x55AA5555 /* 0100 */,
+      0x55AA55AA /* 0101 */,
+      0x55AAAA55 /* 0110 */,
+      0x55AAAAAA /* 0111 */,
+      0xAA555555 /* 1000 */,
+      0xAA5555AA /* 1001 */,
+      0xAA55AA55 /* 1010 */,
+      0xAA55AAAA /* 1011 */,
+      0xAAAA5555 /* 1100 */,
+      0xAAAA55AA /* 1101 */,
+      0xAAAAAA55 /* 1110 */,
+      0xAAAAAAAA /* 1111 */,
+    };
+  static const ULONG ExpandSource[16] = 
+    {
+      0x33333333 /* 0000 */,
+      0x333333CC /* 0001 */,
+      0x3333CC33 /* 0010 */,
+      0x3333CCCC /* 0011 */,
+      0x33CC3333 /* 0100 */,
+      0x33CC33CC /* 0101 */,
+      0x33CCCC33 /* 0110 */,
+      0x33CCCCCC /* 0111 */,
+      0xCC333333 /* 1000 */,
+      0xCC3333CC /* 1001 */,
+      0xCC33CC33 /* 1010 */,
+      0xCC33CCCC /* 1011 */,
+      0xCCCC3333 /* 1100 */,
+      0xCCCC33CC /* 1101 */,
+      0xCCCCCC33 /* 1110 */,
+      0xCCCCCCCC /* 1111 */,
+    };
+  static const ULONG ExpandPattern[16] = 
+    {
+      0x0F0F0F0F /* 0000 */,
+      0x0F0F0FF0 /* 0001 */,
+      0x0F0FF00F /* 0010 */,
+      0x0F0FF0F0 /* 0011 */,
+      0x0FF00F0F /* 0100 */,
+      0x0FF00FF0 /* 0101 */,
+      0x0FF0F00F /* 0110 */,
+      0x0FF0F0F0 /* 0111 */,
+      0xF00F0F0F /* 1000 */,
+      0xF00F0FF0 /* 1001 */,
+      0xF00FF00F /* 1010 */,
+      0xF00FF0F0 /* 1011 */,
+      0xF0F00F0F /* 1100 */,
+      0xF0F00FF0 /* 1101 */,
+      0xF0F0F00F /* 1110 */,
+      0xF0F0F0F0 /* 1111 */,
+    };
+
+  /* Optimized code for the various named rop codes. */
+  switch (Rop)
+    {
+    case BLACKNESS:   return(0);
+    case NOTSRCERASE: return(~(Dest | Source));
+    case NOTSRCCOPY:  return(~Source);
+    case SRCERASE:    return((~Dest) & Source);
+    case DSTINVERT:   return(~Dest);
+    case PATINVERT:   return(Dest ^ Pattern);
+    case SRCINVERT:   return(Dest ^ Source);
+    case SRCAND:      return(Dest & Source);
+    case MERGEPAINT:  return(Dest & (~Source));
+    case SRCPAINT:    return(Dest | Source);
+    case MERGECOPY:   return(Source & Pattern);
+    case SRCCOPY:     return(Source);
+    case PATCOPY:     return(Pattern);
+    case PATPAINT:    return(Dest | (~Source) | Pattern);
+    case WHITENESS:   return(0xFFFFFFFF);
+    }
+  /* Expand the ROP operation to all four bytes */
+  Rop &= 0x00FF0000;
+  Rop = (Rop << 8) | (Rop) | (Rop >> 8) | (Rop >> 16);
+  /* Do the operation on four bits simultaneously. */
+  Result = 0;
+  for (i = 0; i < 8; i++)
+    {
+      ResultNibble = Rop & ExpandDest[Dest & 0xF] & ExpandSource[Source & 0xF] & ExpandPattern[Pattern & 0xF];
+      Result |= (((ResultNibble & 0xFF000000) ? 0x8 : 0x0) | ((ResultNibble & 0x00FF0000) ? 0x4 : 0x0) | 
+       ((ResultNibble & 0x0000FF00) ? 0x2 : 0x0) | ((ResultNibble & 0x000000FF) ? 0x1 : 0x0)) << (i * 4);
+      Dest >>= 4;
+      Source >>= 4;
+      Pattern >>= 4;
+    }
+  return(Result);
+}
+
 /* EOF */
index 81b49d4..e618b89 100644 (file)
@@ -1,6 +1,8 @@
 extern unsigned char notmask[2];
 extern unsigned char altnotmask[2];
 extern unsigned char mask1Bpp[8];
+ULONG   DIB_DoRop(ULONG Rop, ULONG Dest, ULONG Source, ULONG Pattern);
+ULONG   DIB_GetSource(SURFOBJ* SourceSurf, SURFGDI* SourceGDI, ULONG sx, ULONG sy, XLATEOBJ* ColorTranslation);
 
 VOID    DIB_1BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c);
 ULONG   DIB_1BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y);
index 78b14d4..ffb4566 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dib16bpp.c,v 1.5 2003/07/27 18:37:23 dwelch Exp $ */
+/* $Id: dib16bpp.c,v 1.6 2003/08/12 21:55:47 gvg Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
@@ -75,12 +75,11 @@ DIB_16BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
   }
 }
 
-BOOLEAN
-DIB_16BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
-                SURFGDI *DestGDI,  SURFGDI *SourceGDI,
-                PRECTL  DestRect,  POINTL  *SourcePoint,
-                PBRUSHOBJ BrushObj, PPOINTL BrushOrigin,
-                XLATEOBJ *ColorTranslation, ULONG Rop4)
+BOOLEAN STATIC
+DIB_16BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
+                       SURFGDI *DestGDI,  SURFGDI *SourceGDI,
+                       PRECTL  DestRect,  POINTL  *SourcePoint,
+                       XLATEOBJ *ColorTranslation)
 {
   LONG     i, j, sx, sy, xColor, f1;
   PBYTE    SourceBits, DestBits, SourceLine, DestLine;
@@ -156,13 +155,27 @@ DIB_16BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
     case 16:
       if (NULL == ColorTranslation || 0 != (ColorTranslation->flXlate & XO_TRIVIAL))
       {
-       SourceBits = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 2 * SourcePoint->x;
-       for (j = DestRect->top; j < DestRect->bottom; j++)
-       {
-         RtlCopyMemory(DestBits, SourceBits, 2 * (DestRect->right - DestRect->left));
-         SourceBits += SourceSurf->lDelta;
-         DestBits += DestSurf->lDelta;
-       }
+       if (DestRect->top < SourcePoint->y)
+         {
+           SourceBits = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 2 * SourcePoint->x;
+           for (j = DestRect->top; j < DestRect->bottom; j++)
+             {
+               RtlMoveMemory(DestBits, SourceBits, 2 * (DestRect->right - DestRect->left));
+               SourceBits += SourceSurf->lDelta;
+               DestBits += DestSurf->lDelta;
+             }
+         }
+       else
+         {
+           SourceBits = SourceSurf->pvScan0 + ((SourcePoint->y + DestRect->bottom - DestRect->top - 1) * SourceSurf->lDelta) + 2 * SourcePoint->x;
+           DestBits = DestSurf->pvScan0 + ((DestRect->bottom - 1) * DestSurf->lDelta) + 2 * DestRect->left;
+           for (j = DestRect->bottom - 1; DestRect->top <= j; j--)
+             {
+               RtlMoveMemory(DestBits, SourceBits, 2 * (DestRect->right - DestRect->left));
+               SourceBits -= SourceSurf->lDelta;
+               DestBits -= DestSurf->lDelta;
+             }
+         }
       }
       else
       {
@@ -224,4 +237,74 @@ DIB_16BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
 
   return TRUE;
 }
+
+BOOLEAN
+DIB_16BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
+                SURFGDI *DestGDI,  SURFGDI *SourceGDI,
+                PRECTL  DestRect,  POINTL  *SourcePoint,
+                PBRUSHOBJ Brush, PPOINTL BrushOrigin,
+                XLATEOBJ *ColorTranslation, ULONG Rop4)
+{
+  LONG     i, j, k, sx, sy;
+  ULONG    Dest, Source, Pattern;
+  PULONG   DestBits;
+  BOOL     UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
+  BOOL     UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
+  ULONG    RoundedRight = DestRect->right - (DestRect->right & 0x1);
+
+  if (Rop4 == SRCCOPY)
+    {
+      return(DIB_16BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation));
+    }
+  else
+    {
+      sy = SourcePoint->y;
+
+      for (j=DestRect->top; j<DestRect->bottom; j++)
+      {
+        sx = SourcePoint->x;
+       DestBits = (PULONG)(DestSurf->pvScan0 + 2 * DestRect->left + j * DestSurf->lDelta);
+        for (i=DestRect->left; i<RoundedRight; i+=2, DestBits++)
+         {
+           Dest = *DestBits;
+           if (UsesSource)
+             {
+               Source = 0;
+               for (k = 0; k < 2; k++)
+                 {
+                   Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) << (k * 16));
+                 }
+             }
+           if (UsesPattern)
+             {
+               /* FIXME: No support for pattern brushes. */
+               Pattern = (Brush->iSolidColor & 0xFFFF) |
+                          ((Brush->iSolidColor & 0xFFFF) << 16);
+             }
+           *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);     
+         }
+       if (i < DestRect->right)
+         {
+           Dest = *DestBits;
+           for (; i < DestRect->right; i++)
+             {
+               if (UsesSource)
+                 {
+                   Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation);
+                 }
+               if (UsesPattern)
+                 {
+                   /* FIXME: No support for pattern brushes. */
+                   Pattern = (Brush->iSolidColor & 0xFFFF) |
+                              ((Brush->iSolidColor & 0xFFFF) << 16);
+                 }                             
+               DIB_16BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xFFFF);
+               Dest >>= 16;
+             }  
+         }
+      }
+    }
+  return TRUE;
+}
+
 /* EOF */
index afa1657..80c1a6d 100644 (file)
@@ -16,7 +16,8 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dib1bpp.c,v 1.7 2003/07/27 18:37:23 dwelch Exp $ */
+/* $Id: dib1bpp.c,v 1.8 2003/08/12 21:55:47 gvg Exp $ */
+
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
@@ -71,32 +72,95 @@ DIB_1BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
 }
 
 BOOLEAN
-DIB_1BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
-               SURFGDI *DestGDI,  SURFGDI *SourceGDI,
-               PRECTL  DestRect,  POINTL  *SourcePoint,
-               PBRUSHOBJ BrushObj, PPOINTL BrushOrigin,
-               XLATEOBJ *ColorTranslation, ULONG Rop4)
+DIB_1BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
+                      SURFGDI *DestGDI,  SURFGDI *SourceGDI,
+                      PRECTL  DestRect,  POINTL  *SourcePoint,
+                      XLATEOBJ *ColorTranslation)
 {
   LONG    i, j, sx, sy = SourcePoint->y;
 
   switch(SourceGDI->BitsPerPixel)
   {
     case 1:
-      for (j=DestRect->top; j<DestRect->bottom; j++)
-      {
-        sx = SourcePoint->x;
-        for (i=DestRect->left; i<DestRect->right; i++)
-        {
-          if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
-          {
-            DIB_1BPP_PutPixel(DestSurf, i, j, 0);
-          } else {
-            DIB_1BPP_PutPixel(DestSurf, i, j, 1);
-          }
-          sx++;
-        }
-        sy++;
-      }
+      if (DestRect->top < SourcePoint->y)
+       {
+         for (j = DestRect->top; j < DestRect->bottom; j++)
+           {
+             if (DestRect->left < SourcePoint->x)
+               {
+                 sx = SourcePoint->x;
+                 for (i=DestRect->left; i<DestRect->right; i++)
+                   {
+                     if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
+                       {
+                         DIB_1BPP_PutPixel(DestSurf, i, j, 0);
+                       }
+                     else
+                       {
+                         DIB_1BPP_PutPixel(DestSurf, i, j, 1);
+                       }
+                     sx++;
+                   }
+               }
+             else
+               {
+                 sx = SourcePoint->x + DestRect->right - DestRect->left - 1;
+                 for (i = DestRect->right - 1; DestRect->left <= i; i--)
+                   {
+                     if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
+                       {
+                         DIB_1BPP_PutPixel(DestSurf, i, j, 0);
+                       }
+                     else
+                       {
+                         DIB_1BPP_PutPixel(DestSurf, i, j, 1);
+                       }
+                     sx--;
+                   }
+               }
+             sy++;
+           }
+       }
+      else
+       {
+         sy = SourcePoint->y + DestRect->bottom - DestRect->top - 1;
+         for (j = DestRect->bottom - 1; DestRect->top <= j; j++)
+           {
+             if (DestRect->left < SourcePoint->x)
+               {
+                 sx = SourcePoint->x;
+                 for (i=DestRect->left; i<DestRect->right; i++)
+                   {
+                     if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
+                       {
+                         DIB_1BPP_PutPixel(DestSurf, i, j, 0);
+                       }
+                     else
+                       {
+                         DIB_1BPP_PutPixel(DestSurf, i, j, 1);
+                       }
+                     sx++;
+                   }
+               }
+             else
+               {
+                 sx = SourcePoint->x + DestRect->right - DestRect->left - 1;
+                 for (i = DestRect->right - 1; DestRect->left <= i; i--)
+                   {
+                     if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
+                       {
+                         DIB_1BPP_PutPixel(DestSurf, i, j, 0);
+                       }
+                     else
+                       {
+                         DIB_1BPP_PutPixel(DestSurf, i, j, 1);
+                       }
+                     sx--;
+                   }
+               }
+             sy++;
+           }
+       }
       break;
 
     case 4:
@@ -196,4 +260,72 @@ DIB_1BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
 
   return TRUE;
 }
+
+BOOLEAN
+DIB_1BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
+               SURFGDI *DestGDI,  SURFGDI *SourceGDI,
+               PRECTL  DestRect,  POINTL  *SourcePoint,
+               PBRUSHOBJ Brush, PPOINTL BrushOrigin,
+               XLATEOBJ *ColorTranslation, ULONG Rop4)
+{
+  LONG     i, j, k, sx, sy;
+  ULONG    Dest, Source, Pattern;
+  PULONG   DestBits;
+  BOOL     UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
+  BOOL     UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
+  ULONG    RoundedRight = DestRect->right - (DestRect->right & 0x7);
+
+  if (Rop4 == SRCCOPY)
+    {
+      return(DIB_1BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation));
+    }
+  else
+    {
+      sy = SourcePoint->y;
+
+      for (j=DestRect->top; j<DestRect->bottom; j++)
+      {
+        sx = SourcePoint->x;
+       DestBits = (PULONG)(DestSurf->pvScan0 + (DestRect->left>>3) + j * DestSurf->lDelta);
+        for (i=DestRect->left; i<RoundedRight; i+=32, DestBits++)
+         {
+           Dest = *DestBits;
+           if (UsesSource)
+             {
+               Source = 0;
+               for (k = 0; k < 32; k++)
+                 {
+                   Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) << k);
+                 }
+             }
+           if (UsesPattern)
+             {
+               /* FIXME: No support for pattern brushes. */
+               Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000;
+             }
+           *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);     
+         }
+       if (i < DestRect->right)
+         {
+           Dest = *DestBits;
+           for (; i < DestRect->right; i++)
+             {
+               if (UsesSource)
+                 {
+                   Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation);
+                 }
+               if (UsesPattern)
+                 {
+                   /* FIXME: No support for pattern brushes. */
+                   Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000;
+                 }                             
+               DIB_1BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF);
+               Dest >>= 1;
+             }  
+         }
+      }
+    }
+  return TRUE;
+}
+
 /* EOF */
index e6723a6..3a6daeb 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dib24bpp.c,v 1.12 2003/07/27 18:37:23 dwelch Exp $ */
+/* $Id: dib24bpp.c,v 1.13 2003/08/12 21:55:47 gvg Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
@@ -76,11 +76,10 @@ DIB_24BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
 }
 
 BOOLEAN
-DIB_24BPP_BitBlt(  SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
-                  SURFGDI *DestGDI,  SURFGDI *SourceGDI,
-                  PRECTL  DestRect,  POINTL  *SourcePoint,
-                  PBRUSHOBJ BrushObj, PPOINTL BrushOrigin,
-                  XLATEOBJ *ColorTranslation, ULONG Rop4)
+DIB_24BPP_BitBltSrcCopy(  SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
+                         SURFGDI *DestGDI,  SURFGDI *SourceGDI,
+                         PRECTL  DestRect,  POINTL  *SourcePoint,
+                         XLATEOBJ *ColorTranslation)
 {
   LONG     i, j, sx, sy, xColor, f1;
   PBYTE    SourceBits, DestBits, SourceLine, DestLine;
@@ -186,13 +185,27 @@ DIB_24BPP_BitBlt(  SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
     case 24:
       if (NULL == ColorTranslation || 0 != (ColorTranslation->flXlate & XO_TRIVIAL))
       {
-       SourceBits = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 3 * SourcePoint->x;
-       for (j = DestRect->top; j < DestRect->bottom; j++)
-       {
-         RtlCopyMemory(DestBits, SourceBits, 3 * (DestRect->right - DestRect->left));
-         SourceBits += SourceSurf->lDelta;
-         DestBits += DestSurf->lDelta;
-       }
+       if (DestRect->top < SourcePoint->y)
+         {
+           SourceBits = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 3 * SourcePoint->x;
+           for (j = DestRect->top; j < DestRect->bottom; j++)
+             {
+               RtlMoveMemory(DestBits, SourceBits, 3 * (DestRect->right - DestRect->left));
+               SourceBits += SourceSurf->lDelta;
+               DestBits += DestSurf->lDelta;
+             }
+         }
+       else
+         {
+           SourceBits = SourceSurf->pvScan0 + ((SourcePoint->y + DestRect->bottom - DestRect->top - 1) * SourceSurf->lDelta) + 3 * SourcePoint->x;
+           DestBits = DestSurf->pvScan0 + ((DestRect->bottom - 1) * DestSurf->lDelta) + 3 * DestRect->left;
+           for (j = DestRect->bottom - 1; DestRect->top <= j; j--)
+             {
+               RtlMoveMemory(DestBits, SourceBits, 3 * (DestRect->right - DestRect->left));
+               SourceBits -= SourceSurf->lDelta;
+               DestBits -= DestSurf->lDelta;
+             }
+         }
       }
       else
       {
@@ -232,4 +245,51 @@ DIB_24BPP_BitBlt(  SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
 
   return TRUE;
 }
+
+BOOLEAN
+DIB_24BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
+                SURFGDI *DestGDI,  SURFGDI *SourceGDI,
+                PRECTL  DestRect,  POINTL  *SourcePoint,
+                PBRUSHOBJ Brush, PPOINTL BrushOrigin,
+                XLATEOBJ *ColorTranslation, ULONG Rop4)
+{
+  LONG     i, j, k, sx, sy;
+  ULONG    Dest, Source, Pattern;
+  PULONG   DestBits;
+  BOOL     UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
+  BOOL     UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
+
+  if (Rop4 == SRCCOPY)
+    {
+      return(DIB_24BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation));
+    }
+  else
+    {
+      sy = SourcePoint->y;
+
+      for (j = DestRect->top; j < DestRect->bottom; j++)
+      {
+        sx = SourcePoint->x;
+       DestBits = (PULONG)(DestSurf->pvScan0 + 3 * DestRect->left + j * DestSurf->lDelta);
+        for (i=DestRect->left; i<DestRect->right; i++, DestBits++)
+         {
+           Dest = *DestBits & 0x00ffffff;
+           if (UsesSource)
+             {
+               Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) & 0x00ffffff;
+             }
+           if (UsesPattern)
+             {
+               /* FIXME: No support for pattern brushes. */
+               Pattern = Brush->iSolidColor;
+             }
+           Dest = DIB_DoRop(Rop4, Dest, Source, Pattern);          
+           *(PBYTE)DestBits = Dest & 0xff;
+            *(PWORD)(DestBits + 1) = Dest >> 8;
+         }
+      }
+    }
+  return TRUE;
+}
+
 /* EOF */
index 591e2d5..3b93159 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dib32bpp.c,v 1.3 2003/07/27 18:37:23 dwelch Exp $ */
+/* $Id: dib32bpp.c,v 1.4 2003/08/12 21:55:47 gvg Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
@@ -75,11 +75,10 @@ DIB_32BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
 }
 
 BOOLEAN
-DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
-                SURFGDI *DestGDI,  SURFGDI *SourceGDI,
-                PRECTL  DestRect,  POINTL  *SourcePoint,
-                PBRUSHOBJ BrushObj, PPOINTL BrushOrigin,
-                XLATEOBJ *ColorTranslation, ULONG Rop4)
+DIB_32BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
+                       SURFGDI *DestGDI,  SURFGDI *SourceGDI,
+                       PRECTL  DestRect,  POINTL  *SourcePoint,
+                       XLATEOBJ *ColorTranslation)
 {
   ULONG     i, j, sx, sy, xColor, f1;
   PBYTE    SourceBits, DestBits, SourceLine, DestLine;
@@ -203,13 +202,27 @@ DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
     case 32:
       if (NULL == ColorTranslation || 0 != (ColorTranslation->flXlate & XO_TRIVIAL))
       {
-       SourceBits = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 4 * SourcePoint->x;
-       for (j = DestRect->top; j < DestRect->bottom; j++)
-       {
-         RtlCopyMemory(DestBits, SourceBits, 4 * (DestRect->right - DestRect->left));
-         SourceBits += SourceSurf->lDelta;
-         DestBits += DestSurf->lDelta;
-       }
+       if (DestRect->top < SourcePoint->y)
+         {
+           SourceBits = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 4 * SourcePoint->x;
+           for (j = DestRect->top; j < DestRect->bottom; j++)
+             {
+               RtlMoveMemory(DestBits, SourceBits, 4 * (DestRect->right - DestRect->left));
+               SourceBits += SourceSurf->lDelta;
+               DestBits += DestSurf->lDelta;
+             }
+         }
+       else
+         {
+           SourceBits = SourceSurf->pvScan0 + ((SourcePoint->y + DestRect->bottom - DestRect->top - 1) * SourceSurf->lDelta) + 4 * SourcePoint->x;
+           DestBits = DestSurf->pvScan0 + ((DestRect->bottom - 1) * DestSurf->lDelta) + 4 * DestRect->left;
+           for (j = DestRect->bottom - 1; DestRect->top <= j; j--)
+             {
+               RtlMoveMemory(DestBits, SourceBits, 4 * (DestRect->right - DestRect->left));
+               SourceBits -= SourceSurf->lDelta;
+               DestBits -= DestSurf->lDelta;
+             }
+         }
       }
       else
       {
@@ -226,4 +239,49 @@ DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
 
   return TRUE;
 }
+
+BOOLEAN
+DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
+                SURFGDI *DestGDI,  SURFGDI *SourceGDI,
+                PRECTL  DestRect,  POINTL  *SourcePoint,
+                PBRUSHOBJ Brush, PPOINTL BrushOrigin,
+                XLATEOBJ *ColorTranslation, ULONG Rop4)
+{
+  LONG     i, j, k, sx, sy;
+  ULONG    Dest, Source, Pattern;
+  PULONG   DestBits;
+  BOOL     UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
+  BOOL     UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
+
+  if (Rop4 == SRCCOPY)
+    {
+      return(DIB_32BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation));
+    }
+  else
+    {
+      sy = SourcePoint->y;
+
+      for (j=DestRect->top; j<DestRect->bottom; j++)
+      {
+        sx = SourcePoint->x;
+       DestBits = (PULONG)(DestSurf->pvScan0 + 4 * DestRect->left + j * DestSurf->lDelta);
+        for (i=DestRect->left; i<DestRect->right; i++, DestBits++)
+         {
+           Dest = *DestBits;
+           if (UsesSource)
+             {
+               Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation);
+             }
+           if (UsesPattern)
+             {
+               /* FIXME: No support for pattern brushes. */
+               Pattern = Brush->iSolidColor;
+             }
+           *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);     
+         }
+      }
+    }
+  return TRUE;
+}
+
 /* EOF */
index 86d86de..08a6d9b 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dib4bpp.c,v 1.16 2003/08/02 19:46:52 dwelch Exp $ */
+/* $Id: dib4bpp.c,v 1.17 2003/08/12 21:55:47 gvg Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
@@ -71,143 +71,6 @@ DIB_4BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
   }
 }
 
-ULONG
-DIB_DoRop(ULONG Rop, ULONG Dest, ULONG Source, ULONG Pattern)
-{
-  ULONG ResultNibble;
-  ULONG Result;
-  ULONG i;
-  static const ULONG ExpandDest[16] = 
-    {
-      0x55555555 /* 0000 */,
-      0x555555AA /* 0001 */,
-      0x5555AA55 /* 0010 */,
-      0x5555AAAA /* 0011 */,
-      0x55AA5555 /* 0100 */,
-      0x55AA55AA /* 0101 */,
-      0x55AAAA55 /* 0110 */,
-      0x55AAAAAA /* 0111 */,
-      0xAA555555 /* 1000 */,
-      0xAA5555AA /* 1001 */,
-      0xAA55AA55 /* 1010 */,
-      0xAA55AAAA /* 1011 */,
-      0xAAAA5555 /* 1100 */,
-      0xAAAA55AA /* 1101 */,
-      0xAAAAAA55 /* 1110 */,
-      0xAAAAAAAA /* 1111 */,
-    };
-  static const ULONG ExpandSource[16] = 
-    {
-      0x33333333 /* 0000 */,
-      0x333333CC /* 0001 */,
-      0x3333CC33 /* 0010 */,
-      0x3333CCCC /* 0011 */,
-      0x33CC3333 /* 0100 */,
-      0x33CC33CC /* 0101 */,
-      0x33CCCC33 /* 0110 */,
-      0x33CCCCCC /* 0111 */,
-      0xCC333333 /* 1000 */,
-      0xCC3333CC /* 1001 */,
-      0xCC33CC33 /* 1010 */,
-      0xCC33CCCC /* 1011 */,
-      0xCCCC3333 /* 1100 */,
-      0xCCCC33CC /* 1101 */,
-      0xCCCCCC33 /* 1110 */,
-      0xCCCCCCCC /* 1111 */,
-    };
-  static const ULONG ExpandPattern[16] = 
-    {
-      0x0F0F0F0F /* 0000 */,
-      0x0F0F0FF0 /* 0001 */,
-      0x0F0FF00F /* 0010 */,
-      0x0F0FF0F0 /* 0011 */,
-      0x0FF00F0F /* 0100 */,
-      0x0FF00FF0 /* 0101 */,
-      0x0FF0F00F /* 0110 */,
-      0x0FF0F0F0 /* 0111 */,
-      0xF00F0F0F /* 1000 */,
-      0xF00F0FF0 /* 1001 */,
-      0xF00FF00F /* 1010 */,
-      0xF00FF0F0 /* 1011 */,
-      0xF0F00F0F /* 1100 */,
-      0xF0F00FF0 /* 1101 */,
-      0xF0F0F00F /* 1110 */,
-      0xF0F0F0F0 /* 1111 */,
-    };
-
-  /* Optimized code for the various named rop codes. */
-  switch (Rop)
-    {
-    case BLACKNESS:   return(0);
-    case NOTSRCERASE: return(~(Dest | Source));
-    case NOTSRCCOPY:  return(~Source);
-    case SRCERASE:    return((~Dest) & Source);
-    case DSTINVERT:   return(~Dest);
-    case PATINVERT:   return(Dest ^ Pattern);
-    case SRCINVERT:   return(Dest ^ Source);
-    case SRCAND:      return(Dest & Source);
-    case MERGEPAINT:  return(Dest & (~Source));
-    case SRCPAINT:    return(Dest | Source);
-    case MERGECOPY:   return(Source & Pattern);
-    case SRCCOPY:     return(Source);
-    case PATCOPY:     return(Pattern);
-    case PATPAINT:    return(Dest | (~Source) | Pattern);
-    case WHITENESS:   return(0xFFFFFFFF);
-    }
-  /* Expand the ROP operation to all four bytes */
-  Rop &= 0x00FF0000;
-  Rop = (Rop << 8) | (Rop) | (Rop >> 8) | (Rop >> 16);
-  /* Do the operation on four bits simultaneously. */
-  Result = 0;
-  for (i = 0; i < 8; i++)
-    {
-      ResultNibble = Rop & ExpandDest[Dest & 0xF] & ExpandSource[Source & 0xF] & ExpandPattern[Pattern & 0xF];
-      Result |= (((ResultNibble & 0xFF000000) ? 0x8 : 0x0) | ((ResultNibble & 0x00FF0000) ? 0x4 : 0x0) | 
-       ((ResultNibble & 0x0000FF00) ? 0x2 : 0x0) | ((ResultNibble & 0x000000FF) ? 0x1 : 0x0)) << (i * 4);
-      Dest >>= 4;
-      Source >>= 4;
-      Pattern >>= 4;
-    }
-  return(Result);
-}
-
-ULONG
-DIB_4BPP_GetSource(SURFOBJ* SourceSurf, SURFGDI* SourceGDI, ULONG sx, ULONG sy, XLATEOBJ* ColorTranslation)
-{
-  switch (SourceGDI->BitsPerPixel)
-    {
-    case 1:
-      if (DIB_1BPP_GetPixel(SourceSurf, sx, sy))
-       {
-         return(XLATEOBJ_iXlate(ColorTranslation, 0));
-       }
-      else
-       {
-         return(XLATEOBJ_iXlate(ColorTranslation, 1));
-       }
-    case 4:
-      if (ColorTranslation != NULL)
-       {
-         return(XLATEOBJ_iXlate(ColorTranslation, DIB_4BPP_GetPixel(SourceSurf, sx, sy)));
-       }
-      else
-       {
-         return(DIB_4BPP_GetPixel(SourceSurf, sx, sy));
-       }
-    case 8:
-      return(XLATEOBJ_iXlate(ColorTranslation, DIB_8BPP_GetPixel(SourceSurf, sx, sy)));
-    case 16:
-      return(XLATEOBJ_iXlate(ColorTranslation, DIB_16BPP_GetPixel(SourceSurf, sx, sy)));
-    case 24:
-      return(XLATEOBJ_iXlate(ColorTranslation, DIB_24BPP_GetPixel(SourceSurf, sx, sy)));
-    case 32:
-      return(XLATEOBJ_iXlate(ColorTranslation, DIB_8BPP_GetPixel(SourceSurf, sx, sy)));
-    default:
-      DbgPrint("DIB_4BPP_ExpandSource: Unhandled number of bits per pixel in source.\n");
-      return(0);
-    }
-}
-
 BOOLEAN STATIC
 DIB_4BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
                       SURFGDI *DestGDI,  SURFGDI *SourceGDI,
@@ -422,7 +285,7 @@ DIB_4BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
                Source = 0;
                for (k = 0; k < 8; k++)
                  {
-                   Source |= (DIB_4BPP_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) << (k * 4));
+                   Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) << (k * 4));
                  }
              }
            if (UsesPattern)
@@ -439,7 +302,7 @@ DIB_4BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
              {
                if (UsesSource)
                  {
-                   Source = DIB_4BPP_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation);
+                   Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation);
                  }
                if (UsesPattern)
                  {
index eb70bae..4a4e0cb 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dib8bpp.c,v 1.3 2003/07/27 18:37:23 dwelch Exp $ */
+/* $Id: dib8bpp.c,v 1.4 2003/08/12 21:55:47 gvg Exp $ */
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>
@@ -73,11 +73,10 @@ DIB_8BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
 }
 
 BOOLEAN
-DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
-               SURFGDI *DestGDI,  SURFGDI *SourceGDI,
-               PRECTL  DestRect,  POINTL  *SourcePoint,
-               PBRUSHOBJ BrushObj, PPOINTL BrushOrigin,
-               XLATEOBJ *ColorTranslation, ULONG Rop4)
+DIB_8BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
+                      SURFGDI *DestGDI,  SURFGDI *SourceGDI,
+                      PRECTL  DestRect,  POINTL  *SourcePoint,
+                      XLATEOBJ *ColorTranslation)
 {
   ULONG     i, j, sx, sy, xColor, f1;
   PBYTE    SourceBits, DestBits, SourceLine, DestLine;
@@ -133,13 +132,27 @@ DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
     case 8:
       if (NULL == ColorTranslation || 0 != (ColorTranslation->flXlate & XO_TRIVIAL))
       {
-       SourceBits = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + SourcePoint->x;
-       for (j = DestRect->top; j < DestRect->bottom; j++)
-       {
-         RtlCopyMemory(DestBits, SourceBits, DestRect->right - DestRect->left);
-         SourceBits += SourceSurf->lDelta;
-         DestBits += DestSurf->lDelta;
-       }
+       if (DestRect->top < SourcePoint->y)
+         {
+           SourceBits = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + SourcePoint->x;
+           for (j = DestRect->top; j < DestRect->bottom; j++)
+             {
+               RtlMoveMemory(DestBits, SourceBits, DestRect->right - DestRect->left);
+               SourceBits += SourceSurf->lDelta;
+               DestBits += DestSurf->lDelta;
+             }
+         }
+       else
+         {
+           SourceBits = SourceSurf->pvScan0 + ((SourcePoint->y + DestRect->bottom - DestRect->top - 1) * SourceSurf->lDelta) + SourcePoint->x;
+           DestBits = DestSurf->pvScan0 + ((DestRect->bottom - 1) * DestSurf->lDelta) + DestRect->left;
+           for (j = DestRect->bottom - 1; DestRect->top <= j; j--)
+             {
+               RtlMoveMemory(DestBits, SourceBits, DestRect->right - DestRect->left);
+               SourceBits -= SourceSurf->lDelta;
+               DestBits -= DestSurf->lDelta;
+             }
+         }
       }
       else
       {
@@ -224,4 +237,78 @@ DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
 
   return TRUE;
 }
+
+BOOLEAN
+DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
+                SURFGDI *DestGDI,  SURFGDI *SourceGDI,
+                PRECTL  DestRect,  POINTL  *SourcePoint,
+                PBRUSHOBJ Brush, PPOINTL BrushOrigin,
+                XLATEOBJ *ColorTranslation, ULONG Rop4)
+{
+  LONG     i, j, k, sx, sy;
+  ULONG    Dest, Source, Pattern;
+  PULONG   DestBits;
+  BOOL     UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
+  BOOL     UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);  
+  ULONG    RoundedRight = DestRect->right - (DestRect->right & 0x3);
+
+  if (Rop4 == SRCCOPY)
+    {
+      return(DIB_8BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation));
+    }
+  else
+    {
+      sy = SourcePoint->y;
+
+      for (j=DestRect->top; j<DestRect->bottom; j++)
+      {
+        sx = SourcePoint->x;
+       DestBits = (PULONG)(DestSurf->pvScan0 + DestRect->left + j * DestSurf->lDelta);
+        for (i=DestRect->left; i<RoundedRight; i+=4, DestBits++)
+         {
+           Dest = *DestBits;
+           if (UsesSource)
+             {
+               Source = 0;
+               for (k = 0; k < 4; k++)
+                 {
+                   Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) << (k * 8));
+                 }
+             }
+           if (UsesPattern)
+             {
+               /* FIXME: No support for pattern brushes. */
+               Pattern = (Brush->iSolidColor & 0xFF) |
+                          ((Brush->iSolidColor & 0xFF) << 8) |
+                          ((Brush->iSolidColor & 0xFF) << 16) |
+                          ((Brush->iSolidColor & 0xFF) << 24);
+             }
+           *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);     
+         }
+       if (i < DestRect->right)
+         {
+           Dest = *DestBits;
+           for (; i < DestRect->right; i++)
+             {
+               if (UsesSource)
+                 {
+                   Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation);
+                 }
+               if (UsesPattern)
+                 {
+                   /* FIXME: No support for pattern brushes. */
+                   Pattern = (Brush->iSolidColor & 0xFF) |
+                              ((Brush->iSolidColor & 0xFF) << 8) |
+                              ((Brush->iSolidColor & 0xFF) << 16) |
+                              ((Brush->iSolidColor & 0xFF) << 24);
+                 }                             
+               DIB_8BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xFFFF);
+               Dest >>= 8;
+             }  
+         }
+      }
+    }
+  return TRUE;
+}
+
 /* EOF */