program MGDEMO1 (input,output);

(* Dies ist ein kleines Demonstrationsprogramm *)
(* fuer die Anwendung von TURBO.GRAF. Diese    *)
(* Version zeigt die Verwendung des Treibers   *)
(* auf der LOW LEVEL Ebene                     *)
(*                                             *)
(*      DEMOVERSION 3.0 ( C ) ComSoft          *)
(*      f}r TURBOGRAF V 2.0 / 16.09.84         *)

(*$IMGRAF.LIB*)   (* Durch Verwendung von MGRAF wird MONOCHROME selektiert *)

procedure BEGRUESSUNG;
begin
ClrScr;
Writeln ; Writeln ; Writeln;
Writeln ('Demonstration - Program for');
Writeln ('      Turbograf V 2.0');
Writeln ('MONOCHROME LOW LEVEL VERSION');
Writeln ('     (C) ComSoft  1984');
DELAY (500);
end;

procedure DISTR;
begin
SELCHAR (1,1);
GCOLOR (6);
GZOOM (0);
GPOINT (0,0);
GMODE (0);
GTEXT (' Turbograf V 2.0 / ComSoft D-8901 Stadtbergen 2, Fuggerstr. 4 ',0);
SELCHAR (1,0);
end;

procedure VIELECK;
var
X   :array [0 .. 18] of integer;
Y   :array [0 .. 18] of integer;

A,B :integer;

begin
    for A:=0 to 18 do
       begin
          X[A] := ROUND (((COS ((6.28/360) * A*20)) * 180) + 320);
          Y[A] := ROUND (((SIN ((6.28/360) * A*20)) * 180) + 200);
       end;

    GINIT;
    DISTR;
    GMODE (0);
    GCOLOR (2);
       for B:=0 to 17 do
          for A:=B+1 to 18 do
             begin
                GPOINT (X[B],Y[B]);
                GLINE (X[A],Y[A]);
             end;
DELAY (800);
end;


procedure CIRCLES;

var A:integer;
begin
A:=180;
GINIT;
DISTR;
GCOLOR (1);
repeat
    GPOINT (450-A,290-TRUNC(A/2));
    GCIRCL (A);
    GPOINT (190+A,290-TRUNC(A/2));
    GCIRCL (A);
    A:=A-3;
until A=3;
end;


procedure MUCHLINES;
VAR A:INTEGER;
BEGIN
GINIT;
GMODE (1);
FOR A:=0 TO 639 DO
    BEGIN
       GPOINT (320,200);
       GLINE (A,399);
       GPOINT (320,200);
       GLINE (A,0);
    END;
DISTR;
GMODE (1);
FOR A:=0 TO 399 DO
    BEGIN
       GPOINT (320,200);
       GLINE (0,A);
       GPOINT (320,200);
       GLINE (639,A);
    END;
DELAY (400);
END;

procedure RECT;

var N   :integer;

begin
GINIT;
GCOLOR (7);
GPOINT (50,350);
GZOOM (2);
GTEXT ('Fast Rectangle Drawing',0);
DISTR;
GCOLOR (4);
GZOOM (0);
for N:=1 to 15 do
       begin
         GPOINT (100+N*6,50+N*6);
         GRECT (20+N*20,8+N*10,0);
       end;
DELAY (1500);
GCLEAR;
GCOLOR (3);
GZOOM (0);
for N:=0 to 7 do
    begin
       GPOINT (320,200);
       GRECT (60,60,N);
    end;
DELAY (600);
end;


procedure BOX;

var N    :integer;
M        :array [ 0 .. 3 ] of array [ 1 .. 2 ] OF INTEGER;
begin
M [ 0,1 ] := 50; M [ 0,2 ] := 50;
M [ 1,1 ] :=350; M [ 1,2 ] := 50;
M [ 2,1 ] := 50; M [ 2,2 ] := 180;
M [ 3,1 ] :=350; M [ 3,2 ] := 180;
GINIT;
GCOLOR (7);
GPOINT (50,350);
GZOOM (2);
GTEXT ('Fast Box Drawing',0);
GCOLOR (7);
GPOINT (70,300);
GTEXT ('With 16 Patterns',0);
DISTR;
DELAY (600);
GMODE (0);
GCOLOR (1);
GZOOM (4);
for N:=0 to 15 do
       begin
          GPATT (N);
          GPOINT (M [ N AND 3,1 ], M [ N AND 3,2 ]);
          GBOX (50,20,0);
          DELAY (100);
       end;
DELAY (500);
end;

procedure TEXT;

var N:CHAR;
    A:integer;

begin
GINIT;
GMODE (0);
selchar (1,1);
GCOLOR (5);
GPOINT (50,350);
GZOOM (2);
GTEXT ('Fully implemented',0);
GPOINT (70,310);
GTEXT ('Graphic Charakters',0);
DISTR;
GZOOM (12);
GCOLOR (4);
for N:=' ' to 'z' do
      begin
      SELCHAR (1,1);
      GPOINT (50,100);
      GTEXT (N,0);
      SELCHAR (1,0);
      GPOINT (370,100);
      GTEXT (N,0);
      DELAY (40);
      end;
GPOINT (370,100);
GTEXT (' ',0);
SELCHAR (1,1);
GPOINT (50,100);
GTEXT (' ',0);
GZOOM (0);
GCOLOR (1);
for A:=0 to 7 do
    begin
    GPOINT (320,170);
    GTEXT ('In 8 Directions',A);
    DELAY (400);
    end;
SELCHAR (0,0);
end;


procedure ARC;
var A,B,C  :integer;

begin
GINIT;
GMODE (1);
DISTR;
B:=0;
C:=0;
GCOLOR (7);
for A:=20 to 40 do
    begin
    GPOINT (320,200);
    GARC (A*4,B,B+100);
    B:=B+36;
    if B>260 then B:=0;
    end;
DELAY (500);
end;

procedure INOUT;

begin
GINIT;
GCOLOR (3);
GZOOM (1);
GPOINT (10,50);
GTEXT ('Read Data from Disk ',0);
DISTR;
READSCREEN ('FELD.PIX');
DELAY (400);
end;

begin
BEGRUESSUNG;
repeat
   if not Keypressed then VIELECK;
   if not Keypressed then CIRCLES;
   if not Keypressed then MUCHLINES;
   if not Keypressed then RECT;
   if not Keypressed then BOX;
   if not Keypressed then ARC;
   if not Keypressed then TEXT;
   if not Keypressed then INOUT;
until Keypressed;
GEXIT;
end.
