program firestarter;

{Firestarter by Crush,D UNT}

uses crt,crush13h;  {crt for readkey; crush13h for the rest}

var a,b,c,d,e,f,g,h,i,j,k,l,x,y:integer;

begin

     video_mode ( $13);
     initvirt;

     cls (0,vga);
     cls (0,vp[1]);
     cls (0,vp[2]);

     for a:=0 to 255 do                      { orange palette }
         begin
         setcolor (a,a shr 2,a shr 4,0);
         end;

     x:=0;
     repeat

     for x:=100 to 105 do                           { random hotspots }
         begin
         b:=random (2);
         if b=0 then putpixel (x,199,255,vp[1]);
         end;

     b:=b+1;
     if b=320 then b:=0;

     x:=random (3);
     if x=0 then putpixel (b,199,255,vp[1]);
     if x=0 then putpixel (b+1,199,255,vp[1]);
     if x=0 then putpixel (b-1,199,255,vp[1]);

     for x:=0 to 319 do
         begin
              for y:=100 to 199 do
                  begin
                  {c:= getpixel (x-1,y-1,vp[1]);     {       }
                  {d:= getpixel (x,y-1,vp[1]);       { 000   }
                  {e:= getpixel (x+1,y-1,vp[1]);     { 0x0   }
                  {f:= getpixel (x-1,y,vp[1]);       { xxx   }
                  g:= getpixel (x,y,vp[1]);         {       }
                  {h:= getpixel (x+1,y,vp[1]);       {  :)   }
                  i:= getpixel (x-1,y+1,vp[1]);     {       }
                  j:= getpixel (x,y+1,vp[1]);
                  k:= getpixel (x+1,y+1,vp[1]);
                  l:= round((g+i+j+k)/4);      { average of the pixel }
                  if l>0 then l:=l-1;
                  putpixel (x,y,l,vp[2]);
                  end;
         end;

     copypage (vp[2],vp[1],0);
     copypage (vp[2],vga,0);

     until keypressed;
     readkey;

     closevirt;
     video_mode ( 03);

end.