Sunday, April 26, 2020

LINES.PA

[Table of Contents]
LINES.ATR Disk Image



The LINES.PA program was extracted from a German language Kyan Pascal Tutorial disk.

I made the following modifications:

  • Moved all the required files to a single DOS 2.5 disk image
  • Modified LINES.PA to look for include files in the root directory
  • Remove special ATASCII characters from the program listing so it could be listed here
  • Translated the German text to English text
  • Commented out the CHAIN command near the end of the program
  • Compiled with “pc lines.pa -o lines -p"

Source Code


#i graphics.h

program Lines;

#i inline.h

const maxLines     =20;
      maxLines_1   =19;
      maxDrawLines =500;
      maxX         =319;
      maxY         =191;

type  LineDescr  = array [0..3] of integer;

var   Ball,
      Vel,
      max          : LineDescr;
      Lines        : array [0..maxLines] of LineDescr;
      index, t,
      i, new, old  : integer;

#i rnd.f
#i consol.f

#i plot.p
#i drawto.p
#i setcolor.p
#i graphics.p
#i textmode.p

begin
  setcolor(2,0,0);
  setcolor(1,0,7);
  setcolor(4,0,7);
  write(chr(125));
  write('Kyan Pascal Graphics Demo QX-Lines      ');
  write('    (c) 1985, 1986 by TDI Software Inc.');
  writeln('              (c) 1988 by Martin Krischik');
  writeln('This Demo is written in Kyan Pascal');
  writeln;
  writeln;
  writeln('The QX-Lines are drawn with the DRAWTO');
  writeln('command. Quicker execution can be');
  writeln('attained by writing your own Fast Line');
  writeln('routines in Assembly Language, but then');
  writeln('the program will no longer be easily');
  writeln('portable to other computer systems.');
  writeln;
  writeln('Press START to Begin and End.');
  repeat until consol<>7;
  graphics(8+16);
  setcolor(2,0,0);
  setcolor(1,0,7);
  setcolor(4,0,7);
  max[0]:=maxX;
  max[1]:=maxY;
  max[2]:=maxX;
  max[3]:=maxY;
  for i := 0 to 3 do
    begin
      Vel[i] :=rnd(16)-8;
      Ball[i]:=rnd(max[i]-100)+50;
    end;
  new   := 0;
  old   := 0;
  index :=0;
  repeat
    for i := 0 to 3 do
      begin 
        t:=Ball[i]+Vel[i];
        if t>=max[i] then
          begin
            t     :=max[i]*2 - Vel[i] - Ball[i];
            Vel[i]:=-Vel[i];
          end;
        if t<0 then
          begin
            t:=-t;
            Vel[i]:=-Vel[i];
          end;
        Ball[i]:=t;
      end; 
    if (index>=maxLines) then
      begin
        plot  (lines[old,0], lines[old,1],0);
        drawto(lines[old,2], lines[old,3],0);
        old:=(old+1) mod maxLines;
      end;
    Lines[new MOD maxLines]:=Ball;
    new:=(new+1) mod maxLines;
    Plot  (ball[0], ball[1],1);
    drawto(ball[2], ball[3],1);
    index:=index+1;
  until (consol<>7) or (index=MaxDrawLines);
  repeat until consol<>7;
  textmode;
  setcolor(2,0,0);
  setcolor(1,0,7);
  setcolor(4,0,7);
(*  chain('grdemo'); *)
end.



Sample Run



No comments:

Post a Comment