home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug013.arc / PLOT.PRO < prev    next >
Text File  |  1979-12-31  |  2KB  |  52 lines

  1. procedure PLOT(x1,y1,x2,y2 : real);
  2.  
  3. { Procedure developed in Turbo Pascal to
  4.   PLOT in LORES Graphics on the MicroBee
  5.             by Bob Burt                   }
  6.  
  7. { This version uses real variables and so
  8.   is suitable to operate for both 64 X 16
  9.   and 80 X 24 screens, but is slower than
  10.   PLOTI.PRO (integer version for 64 X 16
  11.   screens) and PLOTI2.PRO (mixed real/
  12.   integer version for 80 X 24 screens     }
  13.  
  14. label 99;
  15. var
  16.   dx,dy,x,y,xi,yi : real;
  17.   count : integer;
  18. begin
  19.   dx := x2 - x1;
  20.   dy := y2 - y1;
  21.   if (dx = 0) and (dy = 0) then
  22.     begin
  23.       xi := 0; yi := 0; count := 1; goto 99
  24.     end; {if}
  25.   if abs(dx) > abs(dy) then
  26.     begin
  27.       xi := 256; count := trunc(abs(dx) + 1); yi := abs(dy*256/dx)
  28.     end; {if}
  29.   if abs(dx) <= abs(dy) then
  30.     begin
  31.       yi := 256; count := trunc(abs(dy) + 1); xi := abs(dx*256/dy)
  32.     end; {if}
  33.   if abs(dx) <> (count - 1)*xi/256 then xi := xi + 1;
  34.   if abs(dy) <> (count - 1)*yi/256 then yi := yi + 1;
  35.   99 :
  36.   if dx < 0 then mem[addr(draw)+11] := 1
  37.             else mem[addr(draw)+11] := 0;
  38.   if dy < 0 then mem[addr(draw)+12] := 1
  39.             else mem[addr(draw)+12] := 0;
  40.   x := x1*256; y := y1*256;
  41.   mem[addr(draw)+2]  := trunc(x - int(x/256)*256);
  42.   mem[addr(draw)+3]  := trunc(x/256);
  43.   mem[addr(draw)+4]  := trunc(y - int(y/256)*256);
  44.   mem[addr(draw)+5]  := trunc(y/256);
  45.   mem[addr(draw)+6]  := trunc(xi - int(xi/256)*256);
  46.   mem[addr(draw)+7]  := trunc(xi/256);
  47.   mem[addr(draw)+8]  := trunc(yi - int(yi/256)*256);
  48.   mem[addr(draw)+9]  := trunc(yi/256);
  49.   mem[addr(draw)+10] := count;
  50.   draw
  51. end; {procedure plot}
  52.