%include "irg:imgraph.inc"
%include "utils:region"

%begin
%integer ref,size,i,j,k,c
%bytearray epic(0:128*512)
%string(255) file

prompt("Input File:");read(file)

accessfile(file,0,ref,size)
readregion(ref,0,size,epic(0))
deaccessfile(ref)

prompt("Output File:");read(file)
openoutput(1,file)
selectoutput(1)

printstring("     ")
%for i=0,1,128 %cycle
  j=i//100
  %if j=0 %then printsymbol(' ') %else write(j,0)
%repeat
newline
printstring("     ")
%for i=0,1,128 %cycle
  j=(i-(i//100)*100)//10
  write(j,0)
%repeat
newline
printstring("     ")
%for i=0,1,128 %cycle
  j=i-(i//10)*10
  write(j,0)
%repeat
newline
%for i=0,1,512 %cycle
  write(i,4)
  %for j=0,1,128 %cycle
     c=epic(j*512+i)
     %if c=0 %then printsymbol('-') %else %c
     %if c=1 %then printsymbol('*') %else %c
     printsymbol('.')
  %repeat
  newline
%repeat
closeoutput
%endofprogram
