#include "vga.h"
/* int, dda */
void putpixel(int x, int y)
{
   graph_mem[x+y*320]=15;
   printf("%d,%d  ",x,y);
}

void drawline(int x1, int y1, int x2, int y2, int detail)
{
   int x,y,dx,dy,m;
   int count;
   dx=x2-x1;
   dy=y2-y1;
   if (abs(dx)>abs(dy)) count=abs(dx);
   else count=abs(dy);
   dx*=detail;
   dy*=detail;
   dx/=count;
   dy/=count;
   x=x1*detail;
   y=y1*detail;
   while(count-->=0)
     {
	x+=dx;
	y+=dy;
	putpixel(x/detail,y/detail);
     }
}

void main(void)
{
   vga_setmode(G320x200x256);
   drawline(10,10,40,100,10);
   sleep(3);
   drawline(10,10,100,40,10);
   sleep(3);
   drawline(310,190,270,100,10);
   sleep(3);
   drawline(310,190,210,160,10);
   sleep(3);
}
