{$i-}

program ICO2DAT (input, output);

uses crt;

  var
    buffer    : array [0..4003] of shortint;
    x, y, C   : integer;
    Ch        : char;
    F         : file;
    T         : text;
    TEKST     : string;
    a, b      : integer;
    TEKST2    : string;

  var
    ICON : array[0..15, 0..15] of integer;

  procedure SaveScreen;
    begin
      move (mem[$b800:0], buffer, 4000);
      x:= wherex;
      y:= wherey;
    end;

  procedure RestoreScreen;
    begin
      textmode (CO80);
      textbackground (BLACK);
      textcolor (LIGHTGRAY);
      clrscr;
      move (buffer, mem[$b800:0], 4000);
      gotoxy (x, y);
    end;


begin
  if paramcount < 1 then begin
    writeln;
    writeln ('Dit programma zet een icoontje in .ico om in een getallenreeks.');
    writeln ('Uw icoontje is best afkomstig van ICONMAKER.EXE ...');
    writeln ('Om te gebruiken met ULTRABASIC of TURBO FORTH, QBASIC ... ...');
    writeln;
    writeln ('Gebruik: ', paramstr(0), ' <iconfile[.ico]> .... ...');
    halt (9);
  end;
  SaveScreen;
  Tekst:= paramstr(1);
  for C:= 1 to length (TEKST) do TEKST[C]:= upcase (TEKST[C]);
  if pos('.', TEKST) = 0 then TEKST:= TEKST+'.ICO';
  TEKST2:= TEKST;
  delete (TEKST2, pos('.', TEKST2), 255);
  TEKST2:= TEKST2 + '.DAT';
  assign (F, TEKST);
  reset (F, 1);
  assign (T, TEKST2);
  rewrite (T);
  blockread (F, ICON, 16*16*sizeof (integer));
  close (F);
  for a:= 0 to 15 do
    for b:= 0 to 15 do
      writeln (T, ICON[a,b]);
  close (T);
  writeln ('Converted 512 Bytes .... ... Press any key .... ... ..');
end.