#define ABS(x) ((x) > 0 ? (x) : (-x)) void linedraw(int x0, int y0, int x1, int y1, int *xout, int *yout) { int x = x0, y = y0; int dx = ABS(x1-x0), sx = x0dy) ? dx : -dy)/2, e2; for (;;) { *xout = x; *yout = y; // SETPIXEL(x, y); if (x==x1 && y==y1) { break; } e2 = err; if (e2 >-dx) { err -= dy; x += sx; } if (e2 < dy) { err += dx; y += sy; } } }