%begin
   %include "level1:graphinc.imp"
   %include "inc:maths.imp"
   %include "inc:util.imp"
   %include "inc:atdecs.imp"

   %const %integer noseg = 256

   %integer d, i, t, j, k, s, sym, ns, setting
   %integer c, cb, cd, cdb, ct, ctb, z=0
   %short Sh
   %half %array CM(0:511)
   %string (30) IFile,As,Bs

   %shortfn Get Short
   %byte a,b
      Read Symbol (a); Read Symbol (b)
      %result = a<<8 ! b
   %end

   %on %event 3,4,9 %start
      IFile = ""
      PrintString(Event_Message);Newline
      %cycle; %repeat %until TestSymbol = -1
      Close Input
      Select Input (0)
      -> Stahrt
   %finish

   IFile = CliParam
Stahrt:
   %if IFile = "" %start
      Newline
      Prompt ("Map File : ")
      ReadLine (Ifile); -> EOP %if IFile = ""
      %if Ifile -> As.(".").Bs %then IFile = As.".".Bs %else IFile = Ifile.".Map"
   %finish
   CM(i) = 0 %for i = 0, 1, 511
   Open Input (3,IFile)
   Select Input (3)
   %for i = 0,1,255 %cycle
      Get Short(sh)
      CM(i) = sh
      CM(i+256) = sh
   %repeat
   Close Input
   Select Input (0)

   print string("speed (>0) : ")
   s = 0
   ns = 0
   t = cpu time+s
   k = 0
   %cycle
      i = CM(k)
      CM(k) = 0
      update colour map(CM(k))
      CM(k) = i
      k = rem(k+1, no seg)
      %cycle
         sym = test symbol
         %while sym>=0 %cycle
            %if sym=nl %start
               new line
               print string("Speed (>0) : ")
               t = t-s+ns %and s = ns %unless setting=0
               ns = 0
               setting = 0
            %else
               print symbol(sym)
               %if '0'<=sym<='9' %start
                  setting = 1
                  ns = ns*10+sym-'0'
               %else
                  IFile = ""
                  -> Stahrt
!                  t = t-s+ns %and s = ns %unless setting=0
!                  ns = 0
!                  setting = 0
               %finish
            %finish
            sym = test symbol
         %repeat
      %repeat %until cpu time>=t
      t = cpu time+s
   %repeat
EOP:
%end %of %program
