home *** CD-ROM | disk | FTP | other *** search
/ The Party 1994: Try This At Home / disk_image.bin / source / gallery / subdirs.exe / MAP / MAPDATA.PAS < prev    next >
Pascal/Delphi Source File  |  1993-07-10  |  1KB  |  70 lines

  1.  
  2. var
  3.    MAP : array[0..63,0..63] of byte;
  4.    T : text;
  5.  
  6. procedure MakeMap;
  7. var x,y : integer;
  8.     CharMap, s : string;
  9.     I : Text;
  10. begin
  11.   assign(I,'map.gri'); reset(I);
  12.   y := 0;
  13.   repeat
  14.     readln(I,s);
  15.     if s<>'' then
  16.     if s[1]<>';' then begin
  17.       if length(s)<>64 then CharMap := ' '+s
  18.       else begin
  19.         for x := 0 to 63 do
  20.           MAP[y,x] := Pos(s[x+1],CharMap)-1;
  21.         inc(y)
  22.       end;
  23.     end;
  24.   until eof(I);
  25.   close(I);
  26.   writeln(y,' map lines processed.');
  27.   writeln('Map codes: "',CharMap,'".');
  28. end;
  29.  
  30. Function Hex( x : byte ) : string;
  31. const HexDigits : string = '0123456789abcdef';
  32. var s : string;
  33.     b,a : char;
  34. begin
  35.    s := HexDigits[ x div 16 +1 ] + HexDigits[ x mod 16 +1 ];
  36.    b := ' '; a := ' ';
  37.    if s[1] in ['a'..'f'] then b := '0';
  38.    if s[2] in ['a'..'f'] then  a := 'h';
  39.    Hex := b+s+a;
  40. end;
  41.  
  42. var x,y : integer;
  43.  
  44. begin
  45.   writeln('Reads MAP.GRI and creates MAPDATA.INC include file // A.R-M. 7/93');
  46.   writeln;
  47.   MakeMap;
  48.  
  49.   assign(T, 'mapdata.inc'); rewrite(T);
  50.   writeln(T,'; map data include file');
  51.   writeln(T);
  52.  
  53.   for y := 0 to 63 do begin
  54.     write(T,'    DB   ');
  55.     for x := 0 to 63 do begin
  56.       write(T,Hex(Map[y,x]));
  57.       if x <> 63 then write(T,',');
  58.     end;
  59.     writeln(T);
  60.   end;
  61.  
  62.   writeln(T);
  63.  
  64.   close(T);
  65.  
  66.   writeln;
  67.   writeln('MAPDATA.INC successfully created.')
  68. end.
  69.  
  70.