#pragma message ( "including mlineaal.cc (line algorithm aa)" );
{ // new on
 // in (T_UCHAR) iColour steht der 4 bit farb wert!
 // es reicht iColour anzupassen
 // iColour is auch IMMER max_col
 static T_INT I; // Intervall
 static T_SWORD m;
 static T_SWORD w;
 static T_INT min_col;
 static T_INT max_col;

 min_col=0;
 max_col=iColour;
 I=iColour+1; // intervall length is number of colour


 if (iX1==iX2)
 {
  if (iY1==iY2)
  {
   static T_SWORD q1;
   static T_UCHAR T_COLOR;
   if (is_dot==T_TRUE)
   {
    q1=-1;
    T_COLOR=(T_UWORD)(iColour>>2);
    while (q1<2)
    {
     static T_SWORD q2;
     q2=0;
     offset=vlinestartpos[(T_UWORD)(iY1+q1)]+(T_ULONG)(iX1-1);
     while (q2<3)
     {
 //     if ((q1==0)&&(q2==1))
      if ((q1==0)||(q2==1))
       T_COLOR=iColour;
 //      T_COLOR=iColour;
      if (!(*(clip_memory+offset)))
      {
 #define TRICKY
       #include "pmwritea.cc"
 #undef TRICKY
      }
 //     if ((q1==0)&&(q2==1))
      if ((q1==0)||(q2==1))
       T_COLOR=(T_UWORD)(iColour>>2);
      offset++;
      q2++;
     }
     q1++;
    }
   }
   else
   {
    T_COLOR=iColour;
    offset=vlinestartpos[(T_UWORD)(iY1)]+(T_ULONG)(iX1);
// #define TRICKY
      if (!(*(clip_memory+offset)))
      {
       #include "pmwritea.cc"
      }
// #undef TRICKY
   }
  }
  else
  {
   if (iY1>iY2)
   {
    fSwap(&iY1,&iY2);
   }
   do
   {
    /******************************************************************************************/
    /* not to be put out of loop, offset can get to high... (high iY1 are pointing to maxline)*/
    /******************************************************************************************/
    offset=vlinestartpos[(T_UWORD)iY1]+(T_ULONG)iX1;
    if (!(*(clip_memory+offset)))
    {
     #define T_COLOR max_col
     #include "pmwritea.cc"
     #undef T_COLOR
    }
   }
   while (iY1++!=iY2);
  }
 }
 else if (iY1==iY2)
 {
  if (iX1>iX2)
  {
   fSwap(&iX1,&iX2);
  }
  offset=vlinestartpos[(T_UWORD)iY1]+(T_ULONG)iX1;
  do
  {
   if (!(*(clip_memory+offset)))
   {
    #define T_COLOR max_col
    #include "pmwritea.cc"
    #undef T_COLOR
   }
   offset++;
  }
  while(iX1++!=iX2);
 }
 else
 {
  /*************/
  /* X Variant */
  /*************/
  dx=iX2-iX1;
  dy=iY2-iY1;
  if (abs(dx)>=abs(dy))
  {
   if (iY1==1) iY1++;
   if (iY2==1) iY2++;
   if (iX1>iX2)
   {
    fSwap(&iX1,&iX2);
    fSwap(&iY1,&iY2);
    dx=iX2-iX1;
    dy=iY2-iY1;
   }
   if (dy>0)
    inc=1;
   else
   {
    inc=-1;
    dy=-dy;
    fSwap(&max_col,&min_col);
   }
   { // a small I or dy can result in m = 0
     // scale everything up, this should work up to
     // 1 pixel and 1 Color Intervall on a resolution of 2048 pixels...
    m=((I<<11)*dy)/dx;
    w=(I<<11)-m;
    err=((I<<11)>>1);
    do
    {
     offset=vlinestartpos[(T_UWORD)iY1]+(T_ULONG)iX1;
     if (!(*(clip_memory+offset)))
     {
#define T_COLOR (min_col+(inc*(err>>11)))
#include "pmwritea.cc"
#undef T_COLOR
     }
     offset-=vesa_bytes_per_scanline;
     if (!(*(clip_memory+offset)))
     {
#define T_COLOR (max_col-(inc*(err>>11)))
#include "pmwritea.cc"
#undef T_COLOR
     }
     if (err<w)
     {
      err+=m;
     }
     else
     {
      iY1+=inc;
      err=err-w;
     }
    }
    while(iX1++!=iX2);
   }  // else if (m)
  } //if (abs(dx)>=abs(dy))
  else
  {
   if (iX1==0) iX1++;
   if (iX2==0) iX2++;
   if (iY1>iY2)
   {
    fSwap(&iX1,&iX2);
    fSwap(&iY1,&iY2);
    dx=iX2-iX1;
    dy=iY2-iY1;
   }
   if (dx>0)
   {
    inc=1;
   }
   else
   {
    inc=-1;
    dx=-dx;
    fSwap(&max_col,&min_col);
   }
   {
    // see x...
    m=((I<<11)*dx)/dy;
    w=(I<<11)-m;
    err=((I<<11)>>1);
    do
    {
     offset=vlinestartpos[(T_UWORD)iY1]+(T_ULONG)iX1;
     if (!(*(clip_memory+offset)))
     {
#define T_COLOR (min_col+(inc*(err>>11)))
#include "pmwritea.cc"
#undef T_COLOR
     }
     offset--;
     if (!(*(clip_memory+offset)))
     {
#define T_COLOR (max_col-(inc*(err>>11)))
#include "pmwritea.cc"
#undef T_COLOR
     }
     if (err<w)
     {
      err+=m;
     }
     else
     {
      iX1+=inc;
      err=err-w;
     }
    }
    while(iY1++!=iY2);
   }
  } //else if (abs(dx)>=abs(dy))
 }
}
