
!14/05
%begin
%constbyte yes= 1,
           no=  0
%constinteger find size= 2
%constinteger no switch= 248
%integer x1,x2,y1,y2

%integer new func= no switch,
         Tcell= no,
         Tzoom= no,
         Tsize= no,
         switch released= yes,
         moving= no,
         moved= no,
         flip screen= 0,
         offset x= 0,
         offset y= 0,
         compacted= no,
         compiled= no
! >>>>>>>>>>>>>>>>>>>>>>>>>>
%include "i:vtlib.inc"
%include "fmacs:frame"
%include "icd:declarations"
%include "icd:ext"
%include "icd:heaps"
%include "icd:values"
%include "icd:hardgraphic"
%include "icd:editor4"
%include "compoST"
%include "icd:filehandler"
%include "icd:compact6"
! >>>>>>>>>>>>>>>>>>>>>>>>>>
%begin
!%onevent 2,9 %start
! OUT(event_message)
!%finish


%ownstring(255) target

%constinteger no of menu options = 13

%constinteger %array menu coords(2:2*no of menu options+1)=%c
                                              0,
                                              screen y+7,
                                              55,
                                              screen y+44,
                                              55,
                                              screen y+25,
                                              55,
                                              screen y+7,
                                              115,
                                              screen y +44,
                                              115,
                                              screen y+25,
                                              115,
                                              screen y+7,
                                              185,
                                              screen y+44,
                                              185,
                                              screen y+25,
                                              185,
                                              screen y+7,
                                              275,
                                              screen y+44,
                                              275,
                                              screen y+25,
                                              275,
                                              screen y+7
                                              

%constinteger xoff= mouse display x//((no of menu options//2)+4),
              yoff= (screen top-screeny)//3-3

%integer %function FIND FUNCTION
%integer i,
         out= switches
  %for i=1,1,no of menu options %cycle
    %if menu coords(2*i) <= x %and menu coords(2*i+1)-5 <= y %and %c
       x < menu coords(2*i) + x off %and y < menu coords(2*i+1) + y off %c
            %then out= i
  %repeat
%result= out
%end

!____________________________________________________________________

%routine MENU(%integer which,select)
%integer off
%integer x= menu coords(2*which),
         y= menu coords(2*which+1)
%conststring(7) %array menu(1:no of menu options)= %c
                                              "Clear  ",
                                              " Stop  ",
                                              " Cell  ",
                                              "Compile",
                                              " Flesh ",
                                              " Reset ",
                                              "  Zoom ",
                                              "Layout ",
                                              "Compact",
                                              " Size  ",
                                              " Name  ",
                                              "Input  ",
                                              "Output "
 enable reg= any colour       
  %for off= 0, screen top, screen top %cycle
    at(x,off+y)
    %if select= no  %then set colour(green) %else set colour(cyan)
    show string(menu(which))
  %repeat
%end
!_________________________________________________________________________

%routine RESET(%integername origin x,origin y)
 MENU(freset,yes)
 origin x= 0
 origin y= 0
 DRAW(0)
 MENU(freset,no)
comp no= 0           {************
%end

!_________________________________________________________________________
%routine SETUPP
%integer i,off
 SETUP
 INIT
 INIT2
 OFFSET(0,0)
 enable reg= any colour
 SETCOLOUR(black)
 FILL(0,0,1023,1023)
 new x= 0;  new y= 0 
 set video mode (0)
 change TOGGLE(no,no,no,"")
 newlines(2)
 enable reg= any colour

%for off= 0,screen top,screen top %cycle
 set colour(white)
 at(381,off+screeny+ 44)
 showstring("mouse:")
 at(0,off+screen y+44)
 showstring("menu:")
 setcolour(yellow)
 at(screen x-40,off+screen y+44)
 showstring("STIC")
%repeat

%for i= 1,1,no of menu options %cycle
 MENU(i,no)
%repeat
i= testsymbol %until i= -1
 SET TERMINAL MODE(NO PAGE)
%end


!_________________________________________________________________________
READFONT
SETUPP
SIMPLEHELP
THE LONG AND THE SHORT
%cycle
  
     MOVE SCREEN(origin x,origin y,start x,start y,moving,moved,tsize)

     TRACE CURSOR(x,y,moving,tsize)

  %if Twire= yes %then TRACE WIRE(start x,start y,%c
                                  trace x,trace y,moved,settings_start,no)
  %if Tcell= yes %then TRACE CELL(current cell,current rot,no)

  %if switches= no switch %then switch released= yes
  %if switch released= yes %and switches# no switch %start


     new func= FIND FUNCTION
     %if new func= fstop %start
          MENU(fstop,yes)
          %stop
     %else %if new func= flayout
          MENU(flayout,yes)
          CIF VIEW("ill")
          MENU(flayout,no)
     %else %if new func= fclear
             MENU(fclear,yes)
             CLEAN DATA(yes)
             MENU(fclear,no)
     %else %if new func= fcompile
             MENU(fcompile,yes)
             COMPILE
             MENU(fcompile,no)
     %else %if new func= freset 
             RESET(origin x,origin y) 
     %else %if new func= fcell
          current rot= 0
          %if Tcell= yes %then Tcell= no %else Tcell= yes
          MENU(fcell,tcell)
          %if Tcell= yes %start
                  GET DESIRED CELL(current cell,current rot)
                  SIMPLE HELP
          %finish
          CHANGE TOGGLE(Tcell,tzoom,tsize,"")
          CLEAR TRACE
     %else %if new func= fcompact
          MENU(fcompact,yes)
          COMPACT
          MENU(fcompact,no)
     %else %if new func= fsize 
          %if tsize= no  %start
             CHANGE TOGGLE(no,no,yes,"")
             tsize= yes
          %else
             CHANGE TOGGLE(no,no,no,"")
             tsize= no
          %finish
          MENU(fsize,tsize)
     %else %if new func= foutput 
          MENU(foutput,yes)
          compiled= no
          compacted= no
          PROCESS FILE(foutput)
          MENU(foutput,no)
     %else %if new func= finput
          MENU(finput,yes)
          PROCESS FILE(finput)
          MENU(finput,no)
     %else %if new func= fname
          MENU(Fname,yes)
          NAME PORTS(no)
          MENU(fname,no)
     %else %if new func= fflesh
          MENU(fflesh,yes)
          %if compacted= yes %start
             target= GET INPUT("Target Language")
             %if target= "scale" %or target= "SCALE" %start
                  OUT(" Writing SCALE")
                  SCALE OUT
             %else %c
             %if target= "ilap" %or  target= "ILAP"  
                  OUT(" Writing ILAP")
                  ILAP OUT
             %else
                 OUT("Language not known")
             %finish
          %else
             OUT("Please Compact First")
          %finish
          MENU(fflesh,no)
     %else %if new func= fzoom 
          MENU(fzoom,1-tzoom)
          %if tzoom= yes %start
               DO ZOOM(origin x,origin y,zoom,offset x,offset y,zoom,-1,1)
               tzoom= no
          %finish %else %start
               tzoom= yes
               DO ZOOM(origin x,origin y,zoom,offset x,offset y,2,1,6)
          %finish
          CHANGE TOGGLE(tcell,tzoom,tsize,"")
      %else %if Tzoom= no %or Tcell= yes 
          settings_wire= twire
          settings_cell= tcell
          settings_size= tsize
          settings_ratio= ignore
          settings== SWITCH OP(switches,toggle,x,y,start x,start y,settings)
          twire= settings_wire
          tsize= settings_size
      %finish
      switch released= no
   %finish

 %repeat
%end
%endofprogram
