home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / System / MorphOS / GhostScript / gdevamiga.c.diff < prev    next >
Encoding:
Text File  |  2000-09-25  |  18.2 KB  |  752 lines

  1. --- vide:Amiga-GS510/gs5.03/gdevamiga.c    Tue Nov 25 19:03:30 1997
  2. +++ vide:gs5.10/gdevamiga.c    Sat Sep 23 12:38:08 2000
  3. @@ -42,7 +42,7 @@
  4.   *
  5.   *    Internet:   opel@rumms.uni-mannheim.de
  6.   */
  7. -
  8. +#define IXEMUL
  9.  #include <clib/macros.h>
  10.  #include <datatypes/pictureclass.h>
  11.  #include <dos/dostags.h>
  12. @@ -62,17 +62,17 @@
  13.  #include <intuition/icclass.h>
  14.  #include <libraries/asl.h>
  15.  #include <libraries/iffparse.h>
  16. +#include <cybergraphics/cybergraphics.h>
  17.  
  18.  #include <proto/asl.h>
  19.  #include <proto/dos.h>
  20.  #include <proto/exec.h>
  21. -#define BltBitMap BlitBitMap    /* Hide weird compiler error! */
  22.  #include <proto/graphics.h>
  23. -#undef BltBitMap
  24.  #include <proto/iffparse.h>
  25.  #include <proto/intuition.h>
  26.  #include <proto/layers.h>
  27.  #include <proto/utility.h>
  28. +#include <proto/cybergraphics.h>
  29.  
  30.  #include "gscdefs.h"
  31.  #include "gserrors.h"
  32. @@ -238,6 +238,8 @@
  33.      struct RastPort    *temp_rport;    /* Temporary raster port for pixmap imaging. */
  34.      UBYTE        *temp_array;    /* Temporary colour manipulation array. */
  35.      LONG        *pens;
  36. +    struct Library  *CyberGfxBase;
  37. +    BOOL         true_color;    /* Is the screen a True/Hi Color one */
  38.  } gx_device_amiga;
  39.  
  40.      /* Cheap, but effective macro for casting the device argument ;-) */
  41. @@ -271,7 +273,6 @@
  42.      UWORD X_DPI, UWORD Y_DPI);
  43.  private BOOL SaveBitMap(STRPTR Name, struct BitMap *BitMap, LONG Width, 
  44.      LONG Height, UWORD X_DPI, UWORD Y_DPI);
  45. -private VOID DispatchTask(VOID);
  46.  private VOID DeleteScrollers(gx_device *dev);
  47.  private BOOL CreateScrollers(gx_device *dev, struct Screen *Screen);
  48.  private VOID WindowResize(gx_device *dev);
  49. @@ -318,12 +319,17 @@
  50.  
  51.      /* Set stack to a resonable large value, GS really needs it */
  52.      /* 50Kb should cover almost all usages */
  53. +#ifdef __MORPHOS__
  54. +unsigned long __stack=100000;
  55. +#else
  56.  unsigned long __stack=50000;
  57. +#endif
  58.  
  59.      /* External reference to some libraries, required for version checking, etc. */
  60.  
  61.  extern struct GfxBase *GfxBase;
  62.  extern struct Library *AslBase;
  63. +private struct Library *CyberGfxBase;
  64.  
  65.      /* Detect wether user has set -g and/or -r at the command line */
  66.  
  67. @@ -337,9 +343,22 @@
  68.  
  69.      /* Bit masks. */
  70.  
  71. +#ifdef __PPC__
  72. +
  73. +#define SHIFT(x) (1 << (7 - (x)))
  74. +#define MASKS(x) (~(1 << (7 - (x))))
  75. +
  76. +#else
  77. +
  78.  private UBYTE shift[8] = { 128, 64, 32, 16,  8,  4,  2,  1 };
  79.  private UBYTE masks[8] = { 127,191,223,239,247,251,253,254 };
  80.  
  81. +#define SHIFT(x) shift[x]
  82. +#define MASKS(x) masks[x]
  83. +
  84. +#endif
  85. +
  86. +
  87.      /* Dark (black) and light (white) rendering colours; the default device
  88.       * determines the actual colours to be used by looking into the screen
  89.       * colour lookup table, the other device drivers leave these values
  90. @@ -546,7 +565,9 @@
  91.      0,                /* cube_size */
  92.      NULL,                /* temp_rport */
  93.      NULL,                /* temp_array */
  94. -    NULL                /* pens */
  95. +    NULL,                /* pens */
  96. +    NULL,                /* CyberGfxBase */
  97. +    0                               /* true_color */
  98.  };
  99.  
  100.      /* Custom device: opens a custom screen, will ask for screen mode or check env variable. */
  101. @@ -584,7 +605,9 @@
  102.      0,                /* cube_size */
  103.      NULL,                /* temp_rport */
  104.      NULL,                /* temp_array */
  105. -    NULL                /* pens */
  106. +    NULL,                /* pens */
  107. +    NULL,                /* CyberGfxBase */
  108. +    0                               /* true_color */
  109.  };
  110.  
  111.      /* Printer device: renders the imagery and sends it to the printer */
  112. @@ -622,7 +645,9 @@
  113.      0,                /* cube_size */
  114.      NULL,                /* temp_rport */
  115.      NULL,                /* temp_array */
  116. -    NULL                /* pens */
  117. +    NULL,                /* pens */
  118. +    NULL,                /* CyberGfxBase */
  119. +    0                               /* true_color */
  120.  };
  121.  
  122.      /* ILBM device: renders the imagery and saves it to an IFF-ILBM file. */
  123. @@ -660,7 +685,9 @@
  124.      0,                /* cube_size */
  125.      NULL,                /* temp_rport */
  126.      NULL,                /* temp_array */
  127. -    NULL                /* pens */
  128. +    NULL,                /* pens */
  129. +    NULL,                /* CyberGfxBase */
  130. +    0                               /* true_color */
  131.  };
  132.  
  133.      /* set_mono_device(gx_device_amiga *dev,int cube_size,LONG *pens):
  134. @@ -1306,14 +1333,23 @@
  135.       *    Asynchronous window message dispatcher.
  136.       */
  137.  
  138. +#ifdef __MORPHOS__
  139. +private void DispatchTaskFunc(void);
  140. +static const struct { UWORD x; UWORD y; APTR func; } DispatchTask = {
  141. +    0xff05,0,DispatchTaskFunc
  142. +};
  143. +private void
  144. +DispatchTaskFunc()
  145. +#else
  146.  private VOID
  147.  DispatchTask()
  148. +#endif
  149.  {
  150.      struct Task    *me;
  151.      gx_device    *dev;
  152.  
  153.          /* Set up global data area base register. */
  154. -#ifdef IXEMUL
  155. +#if defined(IXEMUL) && !defined(__MORPHOS__)
  156.      ix_geta4();
  157.  #endif
  158.          /* Who am I? */
  159. @@ -2238,6 +2274,10 @@
  160.  
  161.          /* Get a lock on the default public screen. */
  162.  
  163. +    xdev -> CyberGfxBase = OpenLibrary("cybergraphics.library", 0);
  164. +    if(xdev -> CyberGfxBase)
  165. +        CyberGfxBase = xdev -> CyberGfxBase;
  166. +
  167.      DefaultScreen = LockPubScreen(NULL);
  168.      if(DefaultScreen)
  169.      {
  170. @@ -2375,8 +2415,9 @@
  171.                              xdev -> window -> RPort);
  172.                          if(xdev -> temp_rport)
  173.                          {
  174. +                            xdev -> true_color = xdev -> CyberGfxBase && GetBitMapAttr(xdev -> window -> RPort -> BitMap, BMA_DEPTH);
  175.                              xdev -> temp_array = (UBYTE *)AllocVec(
  176. -                                (xdev -> window -> WScreen -> Width + 15) & ~15, 
  177. +                                ((xdev -> window -> WScreen -> Width + 15) & ~15) * (xdev->true_color ? 3 : 1),
  178.                                  MEMF_ANY);
  179.                              if(xdev -> temp_array)
  180.                              {
  181. @@ -2403,9 +2444,16 @@
  182.                                  if (127 < TaskPri)    /* Ouch... */
  183.                                      TaskPri = 127;    /* ;-) */
  184.                                  
  185. -                                Task = CreateTask(
  186. -                                    "Ghostscript window dispatcher", 
  187. -                                    TaskPri, DispatchTask, 8192);
  188. +#ifdef __MORPHOS__
  189. +                                Task = CreateNewProcTags(NP_Entry,&DispatchTask,
  190. +                                             NP_Name,"Ghostscript window dispatcher",
  191. +                                             NP_Priority,TaskPri,
  192. +                                             NP_StackSize,16384,
  193. +                                             TAG_END);
  194. +#else
  195. +                                Task = CreateTask("Ghostscript window dispatcher",
  196. +                                          TaskPri, (APTR)&DispatchTask, 8192);
  197. +#endif
  198.                                  if(Task)
  199.                                  {
  200.                                          /* Cheap... */
  201. @@ -3170,6 +3218,10 @@
  202.      struct DisplayInfo    DisplayInfo;
  203.      struct DimensionInfo    DimensionInfo;
  204.  
  205. +    xdev -> CyberGfxBase = OpenLibrary("cybergraphics.library", 0);
  206. +    if(xdev -> CyberGfxBase)
  207. +        CyberGfxBase = xdev -> CyberGfxBase;
  208. +
  209.          /* Get the display dimensions. */
  210.  
  211.      if(GetDisplayInfoData(NULL,(APTR)&DisplayInfo,sizeof(struct DisplayInfo),DTAG_DISP,Mode) && GetDisplayInfoData(NULL,(APTR)&DimensionInfo,sizeof(struct DimensionInfo),DTAG_DIMS,Mode))
  212. @@ -3339,6 +3391,7 @@
  213.              {
  214.                  xdev -> rport    = &xdev -> screen -> RastPort;
  215.              }
  216. +            xdev -> true_color = CyberGfxBase && GetBitMapAttr(xdev->rport->BitMap, BMA_DEPTH);
  217.  
  218.                  /* Establish defaults. */
  219.  
  220. @@ -3353,8 +3406,8 @@
  221.              xdev -> temp_rport = CreateTempRPort(xdev -> rport);
  222.              if(xdev -> temp_rport)
  223.              {
  224. -                xdev -> temp_array = (UBYTE *)AllocVec((dev -> width + 15) 
  225. -                    & ~15, MEMF_ANY);
  226. +                xdev -> temp_array = (UBYTE *)AllocVec(((dev -> width + 15)
  227. +                    & ~15) * (xdev -> true_color ? 3 : 1), MEMF_ANY);
  228.                  if(xdev -> temp_array)
  229.                  {
  230.                          /* Colour output enabled? */
  231. @@ -3518,6 +3571,8 @@
  232.          xdev -> screen = NULL;
  233.      }
  234.  
  235. +    CloseLibrary(xdev -> CyberGfxBase);
  236. +
  237.      return(0);
  238.  }
  239.  
  240. @@ -3558,13 +3613,49 @@
  241.      {
  242.          if(one != gx_no_color_index)
  243.          {
  244. +            if(xdev -> true_color)
  245. +            {
  246. +                UBYTE r, g, b;
  247. +                gx_color_value color[3];
  248. +
  249. +                dev_proc(dev, map_color_rgb)(dev, one, color);
  250. +                r = gx_color_value_to_byte(color[0]);
  251. +                g = gx_color_value_to_byte(color[1]);
  252. +                b = gx_color_value_to_byte(color[2]);
  253. +
  254. +                do
  255. +                {
  256. +                    UBYTE *p = xdev -> temp_array;
  257. +
  258. +                    ReadPixelArray(xdev -> temp_array,0,0,w*3,xdev -> rport,x,y,w,1,RECTFMT_RGB);
  259. +
  260. +                    for(i = sourcex, j = 0 ; i < sourcex + w ; i++, j++, p += 3)
  261. +                    {
  262. +                        if(base[i >> 3] & SHIFT(i & 7))
  263. +                        {
  264. +                            p[0] = r;
  265. +                            p[1] = g;
  266. +                            p[2] = b;
  267. +                        }
  268. +                    }
  269. +
  270. +                    WritePixelArray(xdev -> temp_array,0,0,w*3,xdev -> rport,x,y,w,1,RECTFMT_RGB);
  271. +
  272. +                    base += raster;
  273. +
  274. +                    y++;
  275. +                }
  276. +                while(--h);
  277. +            }
  278. +            else
  279. +            {
  280.              do
  281.              {
  282.                  ReadPixelLine8(xdev -> rport,x,y,w,xdev -> temp_array,xdev -> temp_rport);
  283.  
  284.                  for(i = sourcex, j = 0 ; i < sourcex + w ; i++, j++)
  285.                  {
  286. -                    if(base[i >> 3] & shift[i & 7])
  287. +                        if(base[i >> 3] & SHIFT(i & 7))
  288.                          xdev -> temp_array[j] = one;
  289.                  }
  290.  
  291. @@ -3577,17 +3668,54 @@
  292.              while(--h);
  293.          }
  294.      }
  295. +    }
  296.      else
  297.      {
  298.          if(one == gx_no_color_index)
  299.          {
  300. +            if(xdev -> true_color)
  301. +            {
  302. +                UBYTE r, g, b;
  303. +                gx_color_value color[3];
  304. +
  305. +                dev_proc(dev, map_color_rgb)(dev, one, color);
  306. +                r = gx_color_value_to_byte(color[0]);
  307. +                g = gx_color_value_to_byte(color[1]);
  308. +                b = gx_color_value_to_byte(color[2]);
  309. +
  310. +                do
  311. +                {
  312. +                    UBYTE *p = xdev -> temp_array;
  313. +
  314. +                    ReadPixelArray(xdev -> temp_array,0,0,w*3,xdev -> rport,x,y,w,1,RECTFMT_RGB);
  315. +
  316. +                    for(i = sourcex, j = 0 ; i < w + sourcex ; i++, j++, p += 3)
  317. +                    {
  318. +                        if(!(base[i >> 3] & SHIFT(i & 7)))
  319. +                        {
  320. +                            p[0] = r;
  321. +                            p[1] = g;
  322. +                            p[2] = b;
  323. +                        }
  324. +                    }
  325. +
  326. +                    WritePixelArray(xdev -> temp_array,0,0,w*3,xdev -> rport,x,y,w,1,RECTFMT_RGB);
  327. +
  328. +                    base += raster;
  329. +
  330. +                    y++;
  331. +                }
  332. +                while(--h);
  333. +            }
  334. +            else
  335. +            {
  336.              do
  337.              {
  338.                  ReadPixelLine8(xdev -> rport,x,y,w,xdev -> temp_array,xdev -> temp_rport);
  339.  
  340.                  for(i = sourcex, j = 0 ; i < w + sourcex ; i++, j++)
  341.                  {
  342. -                    if(!(base[i >> 3] & shift[i & 7]))
  343. +                        if(!(base[i >> 3] & SHIFT(i & 7)))
  344.                          xdev -> temp_array[j] = zero;
  345.                  }
  346.  
  347. @@ -3599,13 +3727,14 @@
  348.              }
  349.              while(--h);
  350.          }
  351. +        }
  352.          else
  353.          {
  354.              do
  355.              {
  356.                  for(i = sourcex, j = 0 ; i < w + sourcex ; i++, j++)
  357.                  {
  358. -                    if(base[i >> 3] & shift[i & 7])
  359. +                    if(base[i >> 3] & SHIFT(i & 7))
  360.                          xdev -> temp_array[j] = one;
  361.                      else
  362.                          xdev -> temp_array[j] = zero;
  363. @@ -3641,7 +3770,7 @@
  364.      {
  365.          for(i = sourcex, j = 0 ; i < w + sourcex ; i++, j++)
  366.          {
  367. -            if(base[i >> 3] & shift[i & 7])
  368. +            if(base[i >> 3] & SHIFT(i & 7))
  369.                  xdev -> temp_array[j] = DarkPen;
  370.              else
  371.                  xdev -> temp_array[j] = LightPen;
  372. @@ -3672,6 +3801,9 @@
  373.      {
  374.          LONG pen;
  375.  
  376. +        if(xdev -> true_color)
  377. +            pen = ReadRGBPixel(xdev -> rport,x1,y1);
  378. +        else
  379.          pen = ReadPixel(xdev -> rport,x1,y1);
  380.  
  381.          amiga_set_pen(dev,color);
  382. @@ -3679,10 +3811,11 @@
  383.          Move(xdev -> rport,x0,y0);
  384.          Draw(xdev -> rport,x1,y1);
  385.  
  386. -        if(pen == color)
  387. +        if(xdev -> true_color)
  388. +            WriteRGBPixel(xdev -> rport,x1,y1,pen);
  389. +        else if(pen != color)
  390.          {
  391.              amiga_set_pen(dev,pen);
  392. -
  393.              WritePixel(xdev -> rport,x1,y1);
  394.          }
  395.      }
  396. @@ -3718,8 +3851,8 @@
  397.                  {
  398.                      for(i = sourcex, j = x ; i < w ; i++, j++)
  399.                      {
  400. -                        if(base[i >> 3] & shift[i & 7])
  401. -                            line[j >> 3] |= shift[j & 7];
  402. +                        if(base[i >> 3] & SHIFT(i & 7))
  403. +                            line[j >> 3] |= SHIFT(j & 7);
  404.                      }
  405.  
  406.                      base += raster;
  407. @@ -3734,8 +3867,8 @@
  408.                  {
  409.                      for(i = sourcex, j = x ; i < w ; i++, j++)
  410.                      {
  411. -                        if(base[i >> 3] & shift[i & 7])
  412. -                            line[j >> 3] &= masks[j & 7];
  413. +                        if(base[i >> 3] & SHIFT(i & 7))
  414. +                            line[j >> 3] &= MASKS(j & 7);
  415.                      }
  416.                          base += raster;
  417.                          line += modulo;
  418. @@ -3754,8 +3887,8 @@
  419.                  {
  420.                      for(i = sourcex, j = x ; i < w ; i++, j++)
  421.                      {
  422. -                        if(!(base[i >> 3] & shift[i & 7]))
  423. -                            line[j >> 3] |= shift[j & 7];
  424. +                        if(!(base[i >> 3] & SHIFT(i & 7)))
  425. +                            line[j >> 3] |= SHIFT(j & 7);
  426.                      }
  427.  
  428.                      base += raster;
  429. @@ -3770,8 +3903,8 @@
  430.                  {
  431.                      for(i = sourcex, j = x ; i < w ; i++, j++)
  432.                      {
  433. -                        if(!(base[i >> 3] & shift[i & 7]))
  434. -                            line[j >> 3] &= masks[j & 7];
  435. +                        if(!(base[i >> 3] & SHIFT(i & 7)))
  436. +                            line[j >> 3] &= MASKS(j & 7);
  437.                      }
  438.  
  439.                      base += raster;
  440. @@ -3789,10 +3922,10 @@
  441.                  {
  442.                      for(i = sourcex, j = x ; i < w ; i++, j++)
  443.                      {
  444. -                        if(base[i >> 3] & shift[i & 7])
  445. -                            line[j >> 3] |= shift[j & 7];
  446. +                        if(base[i >> 3] & SHIFT(i & 7))
  447. +                            line[j >> 3] |= SHIFT(j & 7);
  448.                          else
  449. -                            line[j >> 3] &= masks[j & 7];
  450. +                            line[j >> 3] &= MASKS(j & 7);
  451.                      }
  452.  
  453.                      base += raster;
  454. @@ -3807,10 +3940,10 @@
  455.                  {
  456.                      for(i = sourcex, j = x ; i < w ; i++, j++)
  457.                      {
  458. -                        if(base[i >> 3] & shift[i & 7])
  459. -                            line[j >> 3] &= masks[j & 7];
  460. +                        if(base[i >> 3] & SHIFT(i & 7))
  461. +                            line[j >> 3] &= MASKS(j & 7);
  462.                          else
  463. -                            line[j >> 3] |= shift[j & 7];
  464. +                            line[j >> 3] |= SHIFT(j & 7);
  465.                      }
  466.  
  467.                      base += raster;
  468. @@ -3847,10 +3980,10 @@
  469.      {
  470.          for(i = sourcex, j = x ; i < w ; i++, j++)
  471.          {
  472. -            if(base[i >> 3] & shift[i & 7])
  473. -                line[j >> 3] |= shift[j & 7];
  474. +            if(base[i >> 3] & SHIFT(i & 7))
  475. +                line[j >> 3] |= SHIFT(j & 7);
  476.              else
  477. -                line[j >> 3] &= masks[j & 7];
  478. +                line[j >> 3] &= MASKS(j & 7);
  479.          }
  480.  
  481.          base += raster;
  482. @@ -4008,7 +4141,7 @@
  483.  
  484.          if(color)
  485.          {
  486. -            line[x >> 3] |= shift[x & 7];
  487. +            line[x >> 3] |= SHIFT(x & 7);
  488.  
  489.              xstep = ystep = 0;
  490.  
  491. @@ -4037,7 +4170,7 @@
  492.                              if(y1 != last)
  493.                                  line = &plane[(last = y1) * modulo];
  494.  
  495. -                            line[x1 >> 3] |= shift[x1 & 7];
  496. +                            line[x1 >> 3] |= SHIFT(x1 & 7);
  497.                          }
  498.                      }
  499.                      while(xstep < dx);
  500. @@ -4068,7 +4201,7 @@
  501.                              if(y1 != last)
  502.                                  line = &plane[(last = y1) * modulo];
  503.  
  504. -                            line[x1 >> 3] |= shift[x1 & 7];
  505. +                            line[x1 >> 3] |= SHIFT(x1 & 7);
  506.                          }
  507.                      }
  508.                      while(ystep > dy);
  509. @@ -4099,7 +4232,7 @@
  510.                              if(y1 != last)
  511.                                  line = &plane[(last = y1) * modulo];
  512.  
  513. -                            line[x1 >> 3] |= shift[x1 & 7];
  514. +                            line[x1 >> 3] |= SHIFT(x1 & 7);
  515.                          }
  516.                      }
  517.                      while(xstep < dx);
  518. @@ -4130,7 +4263,7 @@
  519.                              if(y1 != last)
  520.                                  line = &plane[(last = y1) * modulo];
  521.  
  522. -                            line[x1 >> 3] |= shift[x1 & 7];
  523. +                            line[x1 >> 3] |= SHIFT(x1 & 7);
  524.                          }
  525.                      }
  526.                      while(ystep < dy);
  527. @@ -4142,12 +4275,12 @@
  528.                  if(y1 != last)
  529.                      line = &plane[(last = y1) * modulo];
  530.  
  531. -                line[x1 >> 3] &= masks[x1 & 7];
  532. +                line[x1 >> 3] &= MASKS(x1 & 7);
  533.              }
  534.          }
  535.          else
  536.          {
  537. -            line[x >> 3] &= masks[x & 7];
  538. +            line[x >> 3] &= MASKS(x & 7);
  539.  
  540.              xstep = ystep = 0;
  541.  
  542. @@ -4176,7 +4309,7 @@
  543.                              if(y1 != last)
  544.                                  line = &plane[(last = y1) * modulo];
  545.  
  546. -                            line[x1 >> 3] &= masks[x1 & 7];
  547. +                            line[x1 >> 3] &= MASKS(x1 & 7);
  548.                          }
  549.                      }
  550.                      while(xstep < dx);
  551. @@ -4207,7 +4340,7 @@
  552.                              if(y1 != last)
  553.                                  line = &plane[(last = y1) * modulo];
  554.  
  555. -                            line[x1 >> 3] &= masks[x1 & 7];
  556. +                            line[x1 >> 3] &= MASKS(x1 & 7);
  557.                          }
  558.                      }
  559.                      while(ystep > dy);
  560. @@ -4238,7 +4371,7 @@
  561.                              if(y1 != last)
  562.                                  line = &plane[(last = y1) * modulo];
  563.  
  564. -                            line[x1 >> 3] &= masks[x1 & 7];
  565. +                            line[x1 >> 3] &= MASKS(x1 & 7);
  566.                          }
  567.                      }
  568.                      while(xstep < dx);
  569. @@ -4269,7 +4402,7 @@
  570.                              if(y1 != last)
  571.                                  line = &plane[(last = y1) * modulo];
  572.  
  573. -                            line[x1 >> 3] &= masks[x1 & 7];
  574. +                            line[x1 >> 3] &= MASKS(x1 & 7);
  575.                          }
  576.                      }
  577.                      while(ystep < dy);
  578. @@ -4730,14 +4863,14 @@
  579.              {
  580.                  for(i = sourcex, j = x ; i < w ; i++, j++)
  581.                  {
  582. -                    if(base[i >> 3] & shift[i & 7])
  583. +                    if(base[i >> 3] & SHIFT(i & 7))
  584.                      {
  585.                          for(k = 0 ; k < depth ; k++)
  586.                          {
  587.                              if(one & (1 << k))
  588. -                                line[k][j >> 3] |= shift[j & 7];
  589. +                                line[k][j >> 3] |= SHIFT(j & 7);
  590.                              else
  591. -                                line[k][j >> 3] &= masks[j & 7];
  592. +                                line[k][j >> 3] &= MASKS(j & 7);
  593.                          }
  594.                      }
  595.                  }
  596. @@ -4757,14 +4890,14 @@
  597.                  {
  598.                      for(i = sourcex, j = x ; i < w ; i++, j++)
  599.                      {
  600. -                        if(base[i >> 3] & shift[i & 7])
  601. +                        if(base[i >> 3] & SHIFT(i & 7))
  602.                          {
  603.                              for(k = 0 ; k < depth ; k++)
  604.                              {
  605.                                  if(zero & (1 << k))
  606. -                                    line[k][j >> 3] |= shift[j & 7];
  607. +                                    line[k][j >> 3] |= SHIFT(j & 7);
  608.                                  else
  609. -                                    line[k][j >> 3] &= masks[j & 7];
  610. +                                    line[k][j >> 3] &= MASKS(j & 7);
  611.                              }
  612.                          }
  613.                      }
  614. @@ -4782,14 +4915,14 @@
  615.                  {
  616.                      for(i = sourcex, j = x ; i < w ; i++, j++)
  617.                      {
  618. -                        if(base[i >> 3] & shift[i & 7])
  619. +                        if(base[i >> 3] & SHIFT(i & 7))
  620.                          {
  621.                              for(k = 0 ; k < depth ; k++)
  622.                              {
  623.                                  if(one & (1 << k))
  624. -                                    line[k][j >> 3] |= shift[j & 7];
  625. +                                    line[k][j >> 3] |= SHIFT(j & 7);
  626.                                  else
  627. -                                    line[k][j >> 3] &= masks[j & 7];
  628. +                                    line[k][j >> 3] &= MASKS(j & 7);
  629.                              }
  630.                          }
  631.                          else
  632. @@ -4797,9 +4930,9 @@
  633.                              for(k = 0 ; k < depth ; k++)
  634.                              {
  635.                                  if(zero & (1 << k))
  636. -                                    line[k][j >> 3] |= shift[j & 7];
  637. +                                    line[k][j >> 3] |= SHIFT(j & 7);
  638.                                  else
  639. -                                    line[k][j >> 3] &= masks[j & 7];
  640. +                                    line[k][j >> 3] &= MASKS(j & 7);
  641.                              }
  642.                          }
  643.                      }
  644. @@ -4848,9 +4981,9 @@
  645.              for(k = 0 ; k < depth ; k++)
  646.              {
  647.                  if(wordbase[i] & (1 << k))
  648. -                    line[k][j >> 3] |= shift[j & 7];
  649. +                    line[k][j >> 3] |= SHIFT(j & 7);
  650.                  else
  651. -                    line[k][j >> 3] &= masks[j & 7];
  652. +                    line[k][j >> 3] &= MASKS(j & 7);
  653.              }
  654.          }
  655.  
  656. @@ -4991,7 +5124,7 @@
  657.  
  658.              if(color & (1 << i))
  659.              {
  660. -                line[x >> 3] |= shift[x & 7];
  661. +                line[x >> 3] |= SHIFT(x & 7);
  662.  
  663.                  xstep = ystep = 0;
  664.  
  665. @@ -5020,7 +5153,7 @@
  666.                                  if(y1 != last)
  667.                                      line = &plane[(last = y1) * modulo];
  668.  
  669. -                                line[x1 >> 3] |= shift[x1 & 7];
  670. +                                line[x1 >> 3] |= SHIFT(x1 & 7);
  671.                              }
  672.                          }
  673.                          while(xstep < dx);
  674. @@ -5051,7 +5184,7 @@
  675.                                  if(y1 != last)
  676.                                      line = &plane[(last = y1) * modulo];
  677.  
  678. -                                line[x1 >> 3] |= shift[x1 & 7];
  679. +                                line[x1 >> 3] |= SHIFT(x1 & 7);
  680.                              }
  681.                          }
  682.                          while(ystep > dy);
  683. @@ -5082,7 +5215,7 @@
  684.                                  if(y1 != last)
  685.                                      line = &plane[(last = y1) * modulo];
  686.  
  687. -                                line[x1 >> 3] |= shift[x1 & 7];
  688. +                                line[x1 >> 3] |= SHIFT(x1 & 7);
  689.                              }
  690.                          }
  691.                          while(xstep < dx);
  692. @@ -5113,7 +5246,7 @@
  693.                                  if(y1 != last)
  694.                                      line = &plane[(last = y1) * modulo];
  695.  
  696. -                                line[x1 >> 3] |= shift[x1 & 7];
  697. +                                line[x1 >> 3] |= SHIFT(x1 & 7);
  698.                              }
  699.                          }
  700.                          while(ystep < dy);
  701. @@ -5125,12 +5258,12 @@
  702.                      if(y1 != last)
  703.                          line = &plane[(last = y1) * modulo];
  704.  
  705. -                    line[x1 >> 3] &= masks[x1 & 7];
  706. +                    line[x1 >> 3] &= MASKS(x1 & 7);
  707.                  }
  708.              }
  709.              else
  710.              {
  711. -                line[x >> 3] &= masks[x & 7];
  712. +                line[x >> 3] &= MASKS(x & 7);
  713.  
  714.                  xstep = ystep = 0;
  715.  
  716. @@ -5159,7 +5292,7 @@
  717.                                  if(y1 != last)
  718.                                      line = &plane[(last = y1) * modulo];
  719.  
  720. -                                line[x1 >> 3] &= masks[x1 & 7];
  721. +                                line[x1 >> 3] &= MASKS(x1 & 7);
  722.                              }
  723.                          }
  724.                          while(xstep < dx);
  725. @@ -5190,7 +5323,7 @@
  726.                                  if(y1 != last)
  727.                                      line = &plane[(last = y1) * modulo];
  728.  
  729. -                                line[x1 >> 3] &= masks[x1 & 7];
  730. +                                line[x1 >> 3] &= MASKS(x1 & 7);
  731.                              }
  732.                          }
  733.                          while(ystep > dy);
  734. @@ -5221,7 +5354,7 @@
  735.                                  if(y1 != last)
  736.                                      line = &plane[(last = y1) * modulo];
  737.  
  738. -                                line[x1 >> 3] &= masks[x1 & 7];
  739. +                                line[x1 >> 3] &= MASKS(x1 & 7);
  740.                              }
  741.                          }
  742.                          while(xstep < dx);
  743. @@ -5252,7 +5385,7 @@
  744.                                  if(y1 != last)
  745.                                      line = &plane[(last = y1) * modulo];
  746.  
  747. -                                line[x1 >> 3] &= masks[x1 & 7];
  748. +                                line[x1 >> 3] &= MASKS(x1 & 7);
  749.                              }
  750.                          }
  751.                          while(ystep < dy);
  752.