home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / MBUG / MBUG013.ARC / PLOTI.PRO < prev    next >
Text File  |  1979-12-31  |  2KB  |  50 lines

  1. procedure PLOT(x1,y1,x2,y2 : integer);
  2.  
  3. { Procedure developed in Turbo Pascal
  4.     for the MicroBee by Bob Burt       }
  5.  
  6. { This version  written using integer
  7.   variables, which speeds up plotting
  8.   rate by a factor of at least 3, but
  9.   restricts  the  maximum  acceptable
  10.       coordinate value to 128          }
  11.  
  12. label 99;
  13. var
  14.   dx,dy,x,y,xi,yi : integer;
  15.   count : integer;
  16. begin
  17.   dx := x2 - x1;
  18.   dy := y2 - y1;
  19.   if (dx = 0) and (dy = 0) then
  20.     begin
  21.       xi := 0; yi := 0; count := 1; goto 99
  22.     end; {if}
  23.   if abs(dx) > abs(dy) then
  24.     begin
  25.       xi := 256; count := abs(dx) + 1; yi := abs(dy*256 div dx)
  26.     end; {if}
  27.   if abs(dx) <= abs(dy) then
  28.     begin
  29.       yi := 256; count := abs(dy) + 1; xi := abs(dx*256 div dy)
  30.     end; {if}
  31.   if abs(dx) <> ((count - 1)*xi div 256) then xi := xi + 1;
  32.   if abs(dy) <> ((count - 1)*yi div 256) then yi := yi + 1;
  33.   99 :
  34.   if dx < 0 then mem[addr(draw)+11] := 1
  35.             else mem[addr(draw)+11] := 0;
  36.   if dy < 0 then mem[addr(draw)+12] := 1
  37.             else mem[addr(draw)+12] := 0;
  38.   x := x1*256; y := y1*256;
  39.   mem[addr(draw)+2]  := x - (x div 256)*256;
  40.   mem[addr(draw)+3]  := x div 256;
  41.   mem[addr(draw)+4]  := y - (y div 256)*256;
  42.   mem[addr(draw)+5]  := y div 256;
  43.   mem[addr(draw)+6]  := xi - (xi div 256)*256;
  44.   mem[addr(draw)+7]  := xi div 256;
  45.   mem[addr(draw)+8]  := yi - (yi div 256)*256;
  46.   mem[addr(draw)+9]  := yi div 256;
  47.   mem[addr(draw)+10] := count;
  48.   draw
  49. end; {procedure plot}
  50.