%begin
%integer index, i, j
%integer %array font(0:4999)
%half %integer %array junk(1:12)
%external %routine %spec gen %alias "FRED_GRAPHICS_GENSYM" %c
      (%integer ch, %half %integer %name st)
%routine read font
  %integer char,num,i,n,min,max,height=0


  font(i) = 520 %for i=0,1,255; !Default: null character
  font(i) = 0 %for i=262, 1, 4999
  font(256) = 12; font(257) = 0; font(258) = 8; font(259) = 0;
  font(260) = 0; font(261) = 0; !This is the null character
  index = 262;                  !This is where the rest starts
  %for char=0,1,255 %cycle
    font(char)=index<<1
    num = 12
    height = num %if num>height;     !Note highest character
    font(index+1) = 8
    junk(i) = 0 %for i=1, 1, 12
    gen(char, junk(1))
    num = num-1 %while num>0 %and junk(num)=0
    i = 1
    i = i+1 %while i<=num %and junk(i)=0
    font(index) = num-i+1
    index = index+3
    font(index-1) = i-1
    %while i<=num %cycle
       font(index) = junk(i)
       i = i+1
       index = index+1
    %repeat
  %repeat
  index = index-1
  closeinput; selectinput(0)
%end
%routine pnib(%integer n)
   n = n&15
   %if n>9 %then printsymbol('A'+n-10) %else printsymbol('0'+n)
%end
%routine pbyte(%integer b)
   pnib(b>>4)
   pnib(b)
%end
%routine pword(%integer w)
   pbyte(w>>8)
   pbyte(w)
%end
%routine pint(%integer i)
   pword(i>>16)
   pword(i)
%end
readfont
openoutput(1,"level1:hexfont.asm")
select output(1)
%for i = 0, 1, index//8 %cycle
   print string("         dc.w    $")
   pword(font(i<<3))
   %for j = i<<3+1, 1, i<<3+7 %cycle
      print string(",$")
      pword(font(j))
   %repeat
   new line
%repeat
%end %of %program
