// is_dot not yet done

#pragma message ( "including line_aa.cc" );
{
#ifdef DEBUG_MSG
 T_PUCHAR  back=back_pic->mem_zeiger;
 #ifndef LINE_WITH_COLOR
  T_UCHAR  pixel;
 #endif
#endif

#ifndef BANKED
 T_PUCHAR  dest=(T_PUCHAR )svdc->videoMem;
#endif

  static T_SWORD dx=0,dy=0,err=0,inc=0;
  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
/**************************/
/* Do straight line cases */
/**************************/
 if (iX1==iX2)
 {
  if (iY1==iY2)
  {
   static T_INT q1;
   static T_UCHAR T_COLOR;
   if (is_dot==T_TRUE)
   {
    T_COLOR=(T_UWORD)(iColour>>2);
    q1=-1;
    while (q1<2)
    {
     static T_INT q2;
     offset=vlinestartpos[(T_UWORD)iY1+q1]+(T_ULONG)iX1-1;
     q2=0;
     while (q2<3)
     {
      if ((q1==0)&&(q2==1))
       T_COLOR=iColour;
      #include "pwritea.cc"
      if ((q1==0)&&(q2==1))
       T_COLOR=(T_UWORD)(iColour>>2);
      offset++;
      q2++;
     }
     q1++;
    }
   }
   else
   {
    offset=vlinestartpos[(T_UWORD)iY1]+(T_ULONG)iX1;
    T_COLOR=iColour;
    #include "pwritea.cc"
   }
  }
  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;
    #define T_COLOR max_col
    #include "pwritea.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
  {
#define T_COLOR max_col
#include "pwritea.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;
#define T_COLOR (min_col+(inc*(err>>11)))
#include "pwritea.cc"
#undef T_COLOR
     offset-=vesa_bytes_per_scanline;
#define T_COLOR (max_col-(inc*(err>>11)))
#include "pwritea.cc"
#undef T_COLOR
//     offset+=vesa_bytes_per_scanline;
     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;
#define T_COLOR (min_col+(inc*(err>>11)))
#include "pwritea.cc"
#undef T_COLOR
     offset--;
#define T_COLOR (max_col-(inc*(err>>11)))
#include "pwritea.cc"
#undef T_COLOR
     if (err<w)
     {
      err+=m;
     }
     else
     {
      iX1+=inc;
      err=err-w;
     }
    }
    while(iY1++!=iY2);
   }
  } //else if (abs(dx)>=abs(dy))
 }
}
