program Prevod;
uses
  NumToStr;

var
 FS : File of Byte;
 FD : Text;
 b  : Byte;

const
 i  : Longint = 0;

begin
  WriteLn('Program prevodu bin -> pas');
  Assign(FS,ParamStr(1));
  Reset(FS);
  Assign(FD,ParamStr(2)+'.pas');
  ReWrite(FD);

  WriteLn(FD,'unit '+ParamStr(2)+';');
  WriteLn(FD);
  WriteLn(FD,'interface');
  WriteLn(FD);
  WriteLn(FD,'const');
  WriteLn(FD,'  Size'+ParamStr(3)+' = ',FileSize(FS),';');
  WriteLn(FD);
  WriteLn(FD,'type');
  WriteLn(FD,'  p'+ParamStr(3)+' =  ^t'+ParamStr(3)+';');
  WriteLn(FD,'  t'+ParamStr(3)+' =  array[0..Size'+ParamStr(3)+'-1]of Byte;');
  WriteLn(FD);
  WriteLn(FD,'const');
  WriteLn(FD,'  '+ParamStr(3)+': t'+ParamStr(3)+' = (');
  Write(FD,'    ');

  while not Eof(FS) do
  begin
    Read(FS,b);
    if i<>0 then
    begin
      Write(FD,',');

      if (i and $f)=0 then
      begin
        WriteLn(FD);
        Write(FD,'    ');
      end;
    end;

    Write(FD,'$'+ByteStrHex(b));
    Inc(i);
  end;

  WriteLn(FD,');');
  WriteLn(FD);
  WriteLn(FD,'implementation');
  WriteLn(FD);
  WriteLn(FD,'end.');

  Close(FS);
  Close(FD);
end.