

Type
  VA = array [0..199,0..319] of byte;

var
  IM : ^VA;
  R : array [0..1699] of byte;

  ni, no : string;
  i, o : file;


procedure Convert;
var x, y, y1, x1, w : integer;
    b : byte;
begin
   FillChar( R, sizeof(R), 0 );
   b := $01;
   w := 0;
   for x := 0 to 159 do begin
     x1 := x + 73;
     for y := 84 downto 0 do begin
       y1 := y + 41;
       if (x>0) and (x<159) and (y>0) and (y<84)
       and (IM^[y1,x1] <> 0) then
         inc( R[ w shr 3 ], b );
       asm
         rol b,1
       end;
       inc( w );
     end;
   end;
end;

begin
  writeln('.RAW to .SRF converter  //  ARM 12/93');
  writeln;
  writeln('Usage:  RAW2SRF name  (converts name.raw to name.srf)');
  writeln;
  if ParamCount = 1 then
     ni := ParamStr(1)
  else begin
     write('File name (no extension): '); readln(ni);
  end;

  no := ni + '.srf';
  ni := ni + '.raw';

  GetMem( IM, sizeof(VA) );
  Assign( i, ni ); reset( i,1 );
  blockread( i, IM^, sizeof(VA) );
  close( i );

  Convert;

  Assign( o, no ); rewrite( o,1 );
  blockwrite( o, R, sizeof(R) );
  close(o);

end.

