Uses Crt,ModeXLib;
var y1,                         {y-location Copper 1}
    y1_dir,                     {y-direction Copper 1}
    Mask:Word;                  {overlay mask, for overlaying the copper}

Procedure MakeCopper(y_pos1,y_pos2,overlay_mask:word);external;
{$l copper}

begin
  TextMode(3);                  {Copper functions in EVERY video mode ! }
  y1:=Port[$3da];               {switch ATC to Index-Mode}
  Port[$3c0]:=$11 or 32;        {select Register 11h}
  Port[$3c0]:=255;              {frame color 255}
  y1:=0;                        {Start at upper screen border}
  y1_dir:=2;                    {first movement down}
  Mask:=$00ff;                  {first Copper 1 (red) in foreground}
  Repeat
    Inc(y1,y1_dir);             {Copper-movement}
    If (y1<=0) or (y1>=150)     {at border : }
      then Begin
      y1_dir:=-y1_dir;          {reverse direction}
      Mask:=Swap(Mask);         {each time a different copper in foreground}
    End;
    Write('T h  i  s   i  s  d  e  m  o   t  e  x  t  ');
    MakeCopper(y1,150-y1,Mask); {Draw copper}
  Until KeyPressed;
End.
