program plasma;

uses crush13h,crt;

var
  i,j,k:word;
  Q:Array[0..255]Of Integer;

begin

     video_mode ( $13);
     initvirt;

     for i:=0 to 255 do q[i]:=round(31*sin(i*pi/128)+32);
     for i:=0 to 255 do Setcolor(i,q[lo(i)],q[lo(i-40)],q[lo(2*i+40)]);
     k:=0;

     repeat
      for i:=0 to 255 do putpixel (i,0,i,vga);
      for i:=0 to 199 do for j:=0 to 319 do
      mem[$a000:i*320+j]:=lo(i+j+2*q[lo(j-2*k+q[lo(i-k)])]+q[lo(2*i+k+20)]);
{      for i:=0 to 255 do
      Setcolor(i,q[lo(i+k)],q[lo(i-k-40)],q[lo(2*i-k+40)]);}
      inc(k);
     until keypressed;

     closevirt;
     video_mode ( 03);

end.

