Here's an implementation of the bresenham line drawing algorithm for a Heath-19 terminal (IIRC.) This is very old and part of my "learn C" period, so it's probably not ideal! BillW --------------- /* Test routine for Bresenham line drawing code */ /* this program is an aid to debugging HPGRAPH.ASM */ #include main() { int x1,y1, x2,y2, ttystat, i,ii; int line1[4], delta1[4],limits[4]; limits[1]=limits[3]=79; limits[2]=limits[4]=23; while (1) { for (i=1;i<=4;i++) line1[i]=0; delta1[1] = nread(); delta1[2] = nread(); delta1[3] = nread(); delta1[4] = nread(); ttystat= binon(); printf ("\033H\033J"); for (i=1; i<=99; i++) { for (ii=1; ii<=4; ii++) { line1[ii] += delta1[ii]; if (line1[ii] < 0) { line1[ii]=0; delta1[ii] = -delta1[ii]; }; if (line1[ii] > limits[ii]) {line1[ii]=limits[ii]; delta1[ii]= -delta1[ii]; }; }; DrawLine(line1[1],line1[2],line1[3],line1[4],'*'); DrawLine(line1[1],line1[2],line1[3],line1[4],' '); } binoff(ttystat); } } int nread() { int c,n; n = 0; while ((c=getchar()) >= '0') n= n*10 + (c - '0'); return n; } xchg(i,j) int i,j; { int temp; temp=i; i=j; j=temp; } int binon() { int ablock[5],t; ablock[1]=0101; jsys(0107,ablock); /* rfmod */ t= ablock[2]; ablock[2]=0; jsys(0110,ablock); /* sfmod */ return t; } binoff(t) int t; {int ablock[5]; ablock[1]=0101; ablock[2]=t; jsys(0110,ablock); /* sfmod */ } DrawLine (xin1,yin1, xin2,yin2,pchr) int xin1,yin1, xin2,yin2, pchr; { #define DXgtDY 0 #define DYgtDX 1 int x, y, x1, y1, dx,dy, e, e1, e2, foo, i; if (xin1>xin2) {x=xin2; x1=xin1; y=yin2; y1=yin1;} /* swap so that dx >0 */ else {x=xin1; x1=xin2; y=yin1; y1=yin2;}; dx= x1-x; /* dx is always > 0 */ dy= y1-y; foo=DXgtDY; if (dy > 0) { if (dy > dx) foo= DYgtDX; } else { if (-dy > dx) foo= DYgtDX; } printf ("\033Y%c%c", y+32,x+32); /* initial position */ switch (foo) { case DXgtDY : e = 2*dy - dx; e1 = 2*dy; e2 = 2*dy - 2*dx; if ( dy > 0) { for (i=1; i<=dx; i++) { putchar(pchr); /* plot x,y */ if (e > 0) { e-= 2*dx; y+=1; printf("\033B"); } e+= 2*dy; x += 1; }; } else { for (i=1; i<=dx; i++) { putchar(pchr); /* plot(x,y) */ if (e < 0) { e+= 2*dx; y-=1; printf("\033A"); }; e += 2*dy; x += 1; }; }; break; case DYgtDX: i=dy; dy=dx; dx=i; e = 2*dy - dx; e1 = 2*dy; e2 = 2*dy - 2*dx; if ( dx > 0) { for (i=1; i<=dx; i++) { putchar(pchr); /* plot(x,y) */ if (e > 0) { e-= 2*dx; x+=1; } else {putchar(8);}; e += 2*dy; y += 1; printf("\033B"); }; } else { dx = -dx; /* make a positive count of points */ for (i=1; i<=dx; i++) { putchar(pchr); /* plot(x,y) */ if (e > 0) { e+= 2*dx; x+=1; } else {putchar(8);}; e += 2*dy; y -= 1; printf("\033A"); }; }; break; }; printf("\n"); /* print buffer */ }