Set Buffer 20

DPATH$=Resource$(0)
CNAME$=DPATH$+"AMOSPro_Compiler_Config"
'lkflkdlfk xxxx  
Dim ANM_IC_T(11),XZ(6),YZ(6)
Dim LST$(NLST)
Global PATH$,DPATH$,PRAM$,CNAME$,FACC,CFLASH$,VER$
Global FLAG$,ANM$,ANM_NF,SND$,LST$(),NLST
Global ANM_IC_T(),XZ(),YZ()
Global SCR,SCX,SCY,SCSX,SCSY,DY,SOP

TIMING=3
ZAP=1 : VZAP=1

If Length(16)=0
   Load DPATH$+"AMOSPro_Compiler_resource.Abk",16
End If 
Resource Bank 16
VER$=Resource$(1)
'
_LOAD_CONFIG[CNAME$,0]
'
'FLAG$="2100101100000110100000001000000001111000000" 
'
'       0  0     1   1     2        3   3     4    
'       1234567890123456789012345678901234567890123    
'      / |||         |         |         | 
'     / / | \Compiled \         \Compiler \      
'    S  D T  \program  \         \Setup    \   
'    o  e y   \setup 1  \   2     \      1  \      2 
'    u  s p  
'    r  t e  
'    c  i    
'    e  n  
'
'   VAR(1,1->44:flag$)   
'   VAR(1,51->53:rotbutt pointer & 61->89:rotbutt offset)  

Set Accessory 

' Colour to flash when un-squashing compiled programs. >31 for no flash
CFLASH$="-Z32"

' Enough RAM?

Close Workbench 
'Close Editor  
Set Sprite Buffer 48

If Chip Free+Fast Free<80*1024
   Screen Open 0,640,24,2,Hires : Colour 1,$FFF : Curs Off 
   Centre ">> Sorry, AMOS-Compiler "+VER$+" needs at least 80 Kbytes free to run. <<"
   Print : Print : Centre "Press any key"
   Wait Key : Edit 
End If 

' screens definitions  

If Prg Under=1
   For S=0 To 7
      Trap Screen Close S
   Next 
   Set Sprite Buffer 40
End If 

ADAT=Leek(Dreg(3))
If ADAT Then SCSX=Deek(ADAT) : SCX=Deek(ADAT+4)
If SCSX<640 Then SCSX=640 : SCX=128

SCY=75 : SCSY=160
Auto View Off : SCR=-1
_OPEN_FREE_SCREEN[SCSX,SCSY]
If Param<0 Then _OMM
SCR=Param
'_GRAB_EDITOR_PALETTE
_INIT_MENU
_INIT_ZONES
_INIT_DISPLAY

' open screen

Screen Show SCR : Auto View On 
For Y=1 To SCSY Step SOP
   Screen Display SCR,SCX,SCY,,Y
   Wait Vbl 
Next 
Screen Display SCR,,SCY,,SCSY
Limit Mouse 64,25 To 512,310 : Show On 

_LOAD_BANKS[15]

' Get the directories

If Exist(PRAM$+"/"+CNAME$)
   DPATH$=PRAM$
   Open In 1,PRAM$+"/Compiler_Origin"
   Input #1,PATH$
   Close 
End If 

' Load ACmp program

'If Not Comp Here
'   _INFO[resource$(25)]   
'   If PATH$<>"" 
'      Comp Load PATH$+"/APcmp"  
'   Else 
'      Comp Load DPATH$+"/APcmp" 
'   End If 
'   _NOINFO  
'End If  


' --- Main --- 

X=Free
Menu On 

Do 
   MN_ABOUT
   Do 
      Multi Wait 
      If Choice
         If Choice(1)=1
            On Choice(2) Proc MN_ABOUT,MN_VERSIONS,_SETUP,_NOP,_COMPILE,_NOP,_QUIT
         Else 
            If Choice(1)=2
               'On Choice(2) Proc _NOP  
            Else 
               If Choice(1)=3
                  'On Choice(2) Proc _NOP  
               Else 
                  If Choice(1)=4
                     'On Choice(2) Proc _NOP  
                  End If 
               End If 
            End If 
         End If 
      End If 
      
      _DISPLAY_VDIALOG
      
      DIAL=Dialog(1)
      If DIAL
         If DIAL=6
            _COMPILE
         End If 
         If DIAL>=2 and DIAL<=4
            _SETFLAG[DIAL-1,Vdialog(1,50+DIAL-1)+3*(DIAL=3)+5*(DIAL=4)]
            _UPDATE_BUTTONS[DIAL]
         End If 
         If DIAL=1 : _QUIT : End If 
         If DIAL=5 : _SETUP : End If 
      Else 
         _GETFLAG[37]
         If Param
            MZ_OLD=MZ
            MZ=Mouse Zone
            If MZ<>MZ_OLD
               If IC
                  If IC<10
                     Resource Unpack 91+IC,XZ(MZ_OLD)+XO,YZ(MZ_OLD)+YO
                  Else 
                     Resource Unpack 105,XZ(MZ_OLD)+XO,YZ(MZ_OLD)+YO
                     '
                     '  ** à revoir... ^ ** 
                     '                 |
                  End If 
               End If 
            End If 
            If MZ
               Inc TIME
               If TIME=TIMING
                  TIME=0
                  If MZ=1
                     IC=9 : XO=0 : YO=0
                  Else 
                     If MZ=5
                        IC=8 : XO=16 : YO=4
                     Else 
                        If MZ=6
                           IC=10 : XO=120 : YO=4
                        Else 
                           If MZ>=2
                              IC=Vdialog(1,50+MZ-1) : XO=48 : YO=4
                           End If 
                        End If 
                     End If 
                  End If 
                  If ANM_IC_T(IC)=0
                     Add ZAP,1,1 To 5
                  Else 
                     Add ZAP,VZAP
                     If ZAP=0 : ZAP=1 : VZAP=1 : End If 
                     If ZAP=6 : ZAP=5 : VZAP=-1 : End If 
                  End If 
                  Resource Bank 15
                  Resource Unpack IC*5+ZAP,XZ(MZ)+XO,YZ(MZ)+YO
                  Resource Bank 16
               End If 
            Else 
               IC=0
            End If 
         End If 
      End If 
   Loop 
Loop 


' --- Procedures --- 

Procedure _COMPILE
   '
   Menu Off 
   On Error Proc _GEST_ERR
   Resume Label _FINISH_COMPILE
   '
   
   _GETFLAG[1] : SRCE=Param : C$=" -?"+Mid$(Str$(P),2)
   If SRCE=0
      S$="__Current__" : Rem *** GRAB FROM EDITOR   
   Else If SRCE=1
      S$=Fsel$("*.AMOS","",Resource$(27))
   Else If SRCE=2
      _EDIT_LIST
      If Param=True
         NL=0
         S$=LST$(NL)
      End If 
   End If 
   
   If S$=""
      _INFO[Resource$(112)] : _WAIT[50]
      _NOINFO : Goto _FINISH_COMPILE
   End If 
   '
   _GETFLAG[2] : DEST=Param : C$=C$+Mid$(Str$(DEST),2)
   If DEST=0
      D$="__Current__" : Rem *** SEND TO EDITOR 
      TYPE=3
   Else 
      If DEST=1
         If SRCE<2
            D$=Fsel$("**","",Resource$(30),Resource$(33))
         End If 
         If D$=""
            _GETFLAG[3] : TYPE=Param
            If Upper$(Right$(S$,5))=".AMOS"
               If TYPE>0
                  D$=Left$(S$,Len(S$)-5)
                  If TYPE=2 : TYPE=0 : End If 
                  If TYPE=1 : TYPE=1 : End If 
                  '
                  '  ** à revoir... ^ ** 
                  '                 |
               Else 
                  D$=Left$(S$,Len(S$)-5)+"_C.AMOS"
                  TYPE=3
               End If 
            End If 
         End If 
      End If 
   End If 
   If D$=""
      _INFO[Resource$(112)] : _WAIT[50]
      _NOINFO : Goto _FINISH_COMPILE
   End If 
   C$='"'+S$+'"'+C$+" -O"+'"'+D$+'"'
   _GETFLAG[5] : C$=C$+" -S"+Mid$(Str$(Param),2)
   _GETFLAG[4] : C$=C$+" -E"+Mid$(Str$(Param),2)
   _GETFLAG[6] : C$=C$+" -W"+Mid$(Str$(Param),2)
   _GETFLAG[14] : If Param : C$=C$+" -L" : End If 
   _GETFLAG[7] : If TYPE=1 : Add TYPE,Param : End If 
   C$=C$+" -T"+Mid$(Str$(TYPE),2)
   C$=C$+" -F"+DPATH$+"/"+" -C"+DPATH$+"/"+CNAME$
   C$=C$+" "+CFLASH$
   
   Timer=0
   'Compile C$,$12345678  
   'E$=Comp Err$  
   
   Trap Dialog Close 1
   STATUS=0
   
   _GETFLAG[34]
   If Param<>0 and Length(10)>0
      
      ' Play Animation!
      For S=0 To 7
         Trap Screen S
         If Errtrap
            SCR_ANIM=S : Exit 
         End If 
      Next 
      ' hide all screens 
      Screen Hide SCR
      If Prg Under
         Trap Screen Hide 8 : Rem *** Try to Hide the editor (Don't Works!!!) ***
      End If 
      _GETFLAG[35] : If Param : _PLAY_SND : End If 
      
      Do 
         F=Frame Play(10,1,SCR_ANIM)
         Colour Back Colour(0)
         Trap Double Buffer 
         If Errtrap : Proc _GEST_ERR : End If 
         E$="" : STATUS=0 : CF=0
         Clear Key 
         Repeat 
            Add STATUS,1,0 To 100
            C=(STATUS*ANM_NF)/100
            If C-CF>0
               F=Frame Play(F,1) : CF=C
               Screen Swap : Wait Vbl 
            End If 
            Exit If STATUS=100
            Multi Wait 
            K$=Inkey$
         Until K$=Chr$(27)
         If K$=Chr$(27) : E$="< User Interruption >" : End If 
         _OPEN_FREE_SCREEN[SCSX,60-(SRCE<>2)*24]
         '_GRAB_EDITOR_PALETTE
         SCR_2=Param
         Screen SCR_2 : Cls 0 : Flash Off 
         Screen Display SCR_2,SCX,180,,
         Screen Show SCR_2 : Screen To Front SCR_2
         Wait Vbl 
         _END_COMPILE[SCSX,60-(SRCE<>2)*24,Comp Size,Timer,D$,E$,-(SRCE<>2)]
         
         ' squash the prog? 
         _GETFLAG[28]
         If Param<>0 and TYPE<>3
            _WAIT[50]
            DD$=D$+"_Temp"
            _SQUASH_A_PROG[D$,DD$,1]
         End If 
         
         Screen Close SCR_2
         
         ' List of Progs Looping? 
         If SRCE<>2 : Exit : End If 
         Inc NL : S$=LST$(NL)
         If S$="" : Exit : End If 
         
         F=FF
         
      Loop 
      
      Screen SCR : Colour Back Colour(0)
      Screen Close SCR_ANIM
   Else 
      
      ' pas d'animation! 
      Do 
         _DISPLAY_VUMETER
         Set Slider 2,2,2,0,4,4,4,0
         _EXTRACT_PATH[S$]
         A$=Resource$(14)+(S$-Param$)
         Cls 6,SCSX/2-216,112 To SCSX/2+216,124
         Ink 3 : Text SCSX/2-Len(A$)*4,120,A$
         HSX1=SCSX/2-240+32+10 : HSY1=67+6
         HSX2=SCSX/2+240-32-10 : HSY2=SCSY/2+60-40-6
         _GETFLAG[35] : If Param : _PLAY_SND : End If 
         E$="" : STATUS=0
         Clear Key 
         Repeat 
            Add STATUS,1,0 To 100
            Hslider HSX1,HSY1 To HSX2,HSY2,100,0,STATUS
            Exit If STATUS=100
            Multi Wait 
            K$=Inkey$
         Until K$=Chr$(27)
         If K$=Chr$(27) : E$="< User Interruption >" : End If 
         Hslider HSX1,HSY1 To HSX2,HSY2,100,0,0
         _EXTRACT_PATH[D$]
         _END_COMPILE[480,60-(SRCE<>2)*24,Comp Size,Timer,D$-Param$,E$,-(SRCE<>2)]
         
         ' Squash the prog? 
         _GETFLAG[28]
         If Param<>0 and TYPE<>3
            _WAIT[50]
            DD$=D$+"_Temp"
            _SQUASH_A_PROG[D$,DD$,1]
         End If 
         
         ' List of Progs Looping? 
         If SRCE<>2 : Exit : End If 
         Inc NL : S$=LST$(NL)
         If TYPE<3
            D$=Left$(S$,Len(S$)-5)
         Else 
            D$=Left$(S$,Len(S$)-5)+"_C.AMOS"
         End If 
         If S$="" : Exit : End If 
         
      Loop 
      
   End If 
   
   _FINISH_COMPILE:
   _GETFLAG[35] : If Param : _STOP_SND : End If 
   _INIT_DISPLAY
   Menu On 
   
End Proc
Procedure _DISPLAY_VUMETER
   VU$="SIze     480,120;"
   VU$=VU$+"BAse     SW SX -2/,SH SY -2/;"
   VU$=VU$+"BOx      0,0,1,SX,SY;"
   VU$=VU$+"BOx      16,8,1,SX 16-,32;"
   VU$=VU$+"BOx      16,40,1,SX 16-,SY 8-;"
   VU$=VU$+"POutilne 13ME CentreX,8 TH+,13ME,0,7;"
   VU$=VU$+"BOx      32,48,67,SX 32-,SY 40-;"
   VU$=VU$+"PRint    32,SY 44- TH+,'0%',5;"
   VU$=VU$+"PRint    SX 64-,SY 44- TH+,'100%',5;"
   VU$=VU$+"EXit;"
   D=Dialog Box(VU$)
End Proc
Procedure _EDIT_LIST
   Dim LST2$(NLST)
   Trap Dialog Close 1
   NL=0
   While LST$(NL)<>"" and NL<NLST
      _EXTRACT_PATH[LST$(NL)] : PAT$=Param$
      LST2$(NL)=Left$(" "+LST$(NL)-PAT$,30)
      Inc NL
   Wend 
   If ED$=""
      ED$="    SIze     586,144;"
      ED$=ED$+"BAse     SW SX -2/,SH SY -2/;"
      ED$=ED$+"BOx      0,0,1,SX,SY;"
      ED$=ED$+"BOx      8,8,1,256 8-,32;"
      ED$=ED$+"POutline 20,16,15ME,0,7;"
      ED$=ED$+"BOx      280,8,67,580,120;"
      ED$=ED$+"BUtton   0,0,0,SX,32,0,0,0;[][SM;]"
      ED$=ED$+"BUtton   1,16,SY24-,64,16,0,0,1;[UNpack 0,0,13BP+; PRint 4ME CX BP+,4,4ME,3;][BR0;]"
      ED$=ED$+"KY       27,0;"
      ED$=ED$+"BUtton   2,256 64- 16-,SY24-,64,16,0,0,1;[UNpack 0,0,13BP+; PRint 3ME CX BP+,4,3ME,3;][BR0;]"
      ED$=ED$+"BUtton   3,16,48,256 32-,24,0,0,1;[LIne 0,0,79 3BP*+,256 32-; PRint 16ME CX BP+,8,16ME,3;][BR0;]"
      ED$=ED$+"BUtton   4,16,80,256 32-,24,0,0,1;[LIne 0,0,79 3BP*+,256 32-; PRint 17ME CX BP+,8,17ME,3;][BR0;]"
      ED$=ED$+"BUtton   5,256,SY24-,160,16,0,0,1;[LIne 0,0,114 3BP*+,160; PRint 18ME CX BP+,4,18ME,3;][BR0;]"
      ED$=ED$+"BUtton   6,416,SY24-,160,16,0,0,1;[LIne 0,0,114 3BP*+,160; PRint 19ME CX BP+,4,19ME,3;][BR0;]"
      ED$=ED$+"VLine    256,8,76,120;"
      ED$=ED$+"VSlider  7,264,12,8,104,0,12,1VA,1;[ZChange 8,ZPos;]"
      ED$=ED$+"AList    8,304,16,256 8/,100 8/,0VA,0,4,2,3;[]"
      ED$=ED$+"EXit;"
   End If 
   Dialog Open 2,ED$
   Vdialog(2,0)=Array(LST2$(0))
   Vdialog(2,1)=NL
   POSL=0
   D=Dialog Run(2)
   Dialog Update 2,8,,NLST+1,NL
   Do 
      D=Dialog(2)
      Multi Wait 
      If D
         Exit If D=2 or D=1
         If D=3
            If NL<NLST
               F$=Fsel$(PAT$+"*.AMOS","",Resource$(27))
               If F$<>""
                  If Exist(F$)
                     _MATCH[F$]
                     If Param=False
                        LST$(NL)=F$
                        _EXTRACT_PATH[F$] : PAT$=Param$
                        LST2$(NL)=Left$(" "+LST$(NL)-PAT$,30)
                        Inc NL
                        Dialog Update 2,8,,NLST+1,NL
                        If(Rdialog(2,7)<NL-12 or Rdialog(2,7)>=NL) and NL>=12
                           Dialog Update 2,7,NL-12,,NL
                        Else 
                           Dialog Update 2,7,0,,NL
                        End If 
                     Else 
                        _WARN[Err$(79),0]
                     End If 
                  Else 
                     _WARN[Err$(81),0]
                  End If 
               End If 
            Else 
               _WARN[Resource$(30),0]
            End If 
         Else If D=4
            If NL<NLST
               F$=Fsel$(PAT$+"*.AMOS","",Resource$(28),Resource$(29))
               If F$<>""
                  If Exist(F$)
                     _EXTRACT_PATH[F$] : PAT$=Param$
                     F$=Dir First$(PAT$+"*.AMOS")
                     While F$<>""
                        If NL<NLST
                           If Left$(F$,1)<>"*"
                              _STRING_FILTER[F$] : F$=PAT$+Param$
                              _MATCH[F$]
                              If Param=False
                                 LST$(NL)=F$
                                 LST2$(NL)=Left$(" "+LST$(NL)-PAT$,30)
                                 Inc NL
                              End If 
                           End If 
                           F$=Dir Next$
                        Else 
                           _WARN[Resource$(31),0]
                           Exit 
                        End If 
                     Wend 
                     Dialog Update 2,8,,NLST+1,NL
                     If(Rdialog(2,7)<NL-12 or Rdialog(2,7)>=NL) and NL>=12
                        Dialog Update 2,7,NL-12,,NL
                     Else 
                        Dialog Update 2,7,0,,NL
                     End If 
                  Else 
                     _WARN[Err$(81),0]
                  End If 
               End If 
            Else 
               _WARN[Resource$(31),0]
            End If 
         Else If D=5
            If POSL>=0
               For I=POSL To NL-1
                  LST$(I)=LST$(I+1)
                  LST2$(I)=LST2$(I+1)
               Next I
               LST$(NL)="" : LST2$(NL)=""
               Dec NL
               If POSL>=NL : POSL=NL-1 : End If 
               Dialog Update 2,7,0,,NL
               Dialog Update 2,8,,POSL,NL
            End If 
         Else If D=6
            If NL>0
               _WARN[Resource$(32),1]
               If Param=True
                  For I=0 To NL
                     LST$(I)=""
                     LST2$(I)=""
                  Next I
                  NL=0
                  Dialog Update 2,7,0,,NL
                  Dialog Update 2,8,,NLST+1,NL
               End If 
            End If 
         Else If D=8
            POSL=Rdialog(2,8)
            If POSL>=NL
               Dialog Update 2,8,,NLST+1,NL
            End If 
         End If 
      End If 
   Loop 
   Dialog Close 2
End Proc[(D=2)]
Procedure _END_COMPILE[W,H,SZ,T,D$,E$,REQUESTER]
   C$="   SIze     0VA,1VA;"
   C$=C$+"BAse     SW SX -2/,SH SY -2/;"
   C$=C$+"BOx      0,0,1,SX,SY;"
   C$=C$+"BOx      8,4,1,SX 8-,20;"
   C$=C$+"POutline 3VA CentreX,8,3VA,0,7;"
   C$=C$+"PRint    4VA CentreX,28,4VA,3;"
   C$=C$+"PRint    5VA CentreX,40,5VA,3;"
   C$=C$+"BUtton   0,0,0,SX,20,0,0,0;[][SM;]"
   C$=C$+"IF       2VA1=; ["
   C$=C$+"  BUtton 1,SX 2/ 32-,SY24-,64,16,0,0,1;[UNpack 0,0,13BP+; PRint 3ME CX BP+,4,3ME,3;][BR0;]"
   C$=C$+"KY       27,0;  ]"
   C$=C$+"EXit;"
   Dialog Open 2,C$
   Vdialog(2,0)=W
   Vdialog(2,1)=H
   Vdialog(2,2)=REQUESTER
   If E$=""
      Vdialog$(2,3)=Resource$(110)
      T=T/50 : M=T/60 : S=T mod 60
      Vdialog$(2,4)=D$
      Vdialog$(2,5)=Resource$(121)+Str$(SZ)+" "+Resource$(12)+".   "+Resource$(120)+Str$(M)+"m"+Str$(S)+"s."
   Else 
      Vdialog$(2,3)=Resource$(112)
      Vdialog$(2,4)=D$
      Vdialog$(2,5)=E$
   End If 
   
   ' bell warning!
   _GETFLAG[36]
   If Param
      If Length(3)
         T$=Peek$(Start(3)-8,8)
         If T$="Music   " or T$="Samples "
            Play 3,70,0
         End If 
      Else 
         Play 3,70,0
      End If 
   End If 
   
   D=Dialog Run(2)
   Timer=0
   Do 
      Multi Wait 
      Exit If Dialog(2)=1 and REQUESTER=1
      Exit If REQUESTER=0 and Timer>100
   Loop 
   
   _GETFLAG[35]
   If Param : _STOP_SND : End If 
   Dialog Close 2
   
End Proc
Procedure _EXTRACT_PATH[A$]
   If A$<>""
      I=Len(A$)+1
      Repeat 
         Dec I : B$=Mid$(A$,I,1)
      Until B$="/" or B$=":" or I=1
      If I>1
         A$=Left$(A$,I)
      Else 
         A$=""
      End If 
   End If 
End Proc[A$]
Procedure _GETFLAG[N]
End Proc[Asc(Mid$(FLAG$,N,1))-48]
Procedure _GRAB_EDITOR_PALETTE
   ADAT=Leek(Dreg(3))
   If ADAT=0
      Palette 0,$6F,$77,$EEE,$F00,$DD,$AA,$FF3
   Else 
      For C=0 To 7
         Colour C,Deek(ADAT+28+C*2)
      Next 
      Colour 1,(Colour(2) and $EEE)/2
   End If 
End Proc
Procedure _INFO[A$]
   Trap Dialog Freeze 1
   L=Len(A$)*8
   I$="SIze     "+Str$(L+64)+",48;"
   I$=I$+"BAse     SW SX -2/,SH SY -2/; SA 1;"
   I$=I$+"BOx      0,0,1,SX,SY;"
   I$=I$+"SetVar   2,'"+A$+"';"
   I$=I$+"PRint    2 VA CentreX,20,2 VA,7;"
   I$=I$+"EXit;"
   Dialog Open 2,I$
   D=Dialog Run(2)
End Proc
Procedure _INIT_DISPLAY
   Menu Off 
   _INIT_WORK
   Trap D=Dialog Run(1,1)
   _UPDATE_BUTTONS[0]
   Screen Show SCR
   Menu On 
End Proc
Procedure _INIT_MENU
   Paper 0 : Pen 3
   I=40 : J=0
   A$=Resource$(I)
   Repeat 
      If Left$(A$,1)=" "
         Inc J
         Menu$(J)=A$+"  "
         Inc I
         LMAX=0 : I0=I : I1=I
         Repeat 
            Inc I1 : A$=Resource$(I1)
            If Len(A$)>LMAX : LMAX=Len(A$) : End If 
         Until Left$(A$,1)=" "
         
         K=0
         For I=I0 To I1-1
            Inc K : A$=Left$(Resource$(I),1)
            If A$<>"-"
               Menu$(J,K)=Left$(" "+Resource$(I)+Space$(LMAX+1),LMAX+2)
            Else 
               Menu$(J,K)="(INk 1,2)"+String$("-",LMAX+2)
               Menu Inactive(J,K)
            End If 
         Next I
         I=I1 : A$=Resource$(I)
      End If 
   Until A$=" end"
End Proc
Procedure _INIT_WORK
   
   If DB$=""
      DB$=DB$+"LA 1;"
      DB$=DB$+"SIze   SW,SH;"
      DB$=DB$+"BAse   SWidth SX -2/,SHeight SY -2/;"
      DB$=DB$+"SetVar 0,SX 640- 16/ 8*;"
      DB$=DB$+"BOx    0,0,1,SX,SY;"
      DB$=DB$+"LIne   416,0,107,SX;"
      DB$=DB$+"PRint  500,4,1ME,7;"
      DB$=DB$+"UNpack 40,0,106;"
      DB$=DB$+"BUtton 0,40,0,SX,16,0,0,0;[][SM;]"
      DB$=DB$+"BUtton 1,0,0,40,16,0,0,1;[UNpack 0,0,100 BP+;][BR0;]"
      DB$=DB$+"KY     27,0;"
      DB$=DB$+"BOx    8 0VA+,28,1,8 216+ 0VA+,110;"
      DB$=DB$+"UNpack 72 0VA+,40,102;"
      DB$=DB$+"RotBut 2,8 8+ 0VA+,68,200;"
      DB$=DB$+"BOx    232 0VA+,28,1,232 216+ 0VA+,110;"
      DB$=DB$+"UNpack 200 0VA+,40,110;"
      DB$=DB$+"UNpack 264 0VA+,40,103;"
      DB$=DB$+"RotBut 3,232 8+ 0VA+,68,200;"
      DB$=DB$+"BOx    456 0VA+,28,1,SX 0VA- 8-,110;"
      DB$=DB$+"UNpack 512 0VA+,40,104;"
      DB$=DB$+"RotBut 4,456 8+ 0VA+,68,160;"
      DB$=DB$+"BUtton 5,24 0VA+,120,184,24,0,0,1;[LIne 0,0,79   3BP*+ ,184; UN 16,4BP+,99;PR 56,THBP+,99ME,3;][BR0;]"
      DB$=DB$+"BUtton 6,SX 384- 0VA- 24-,120,384,24,0,0,1;[LI0,0,79 3BP*+,384;UN 120,4BP+,105;][BR0;]"
      DB$=DB$+"EXit;"
      DB$=DB$+"UI RotatingButton,4;"
      '        RotBut ZN, X, Y, W  
      _START_ICON_BUTT=91
      _START_TEXT_BUTT=91
      DB$=DB$+"["
      DB$=DB$+"SetZon P4;"
      DB$=DB$+"BUtton P1,P2,P3,P4,24,0,0,1;"
      DB$=DB$+"       [LIne 0,0,85 3BP*+,SX; UN 48,4BP+,"+Str$(_START_ICON_BUTT)+" ZN50+1-VA+;"
      DB$=DB$+"       PRint 88,THBP+,"+Str$(_START_TEXT_BUTT)+" ZN50+1-VA+ ME,3;]"
      DB$=DB$+"       [BR0; SV ZN50+1-,ZN10* 40+ ZN50+1-VA+ VA;]"
      DB$=DB$+"]"
   End If 
   Trap Dialog Close 1
   Dialog Open 1,DB$,99,1024*12
   For I=1 To Len(FLAG$)
      _GETFLAG[I]
      Vdialog(1,I)=Param
   Next I
   _GETFLAG[1] : Vdialog(1,51)=Param
   _GETFLAG[2] : Vdialog(1,52)=Param+3
   _GETFLAG[3] : Vdialog(1,53)=Param+5
End Proc[Errtrap]
Procedure _INIT_ZONES
   NZ=6
   VA0=((SCSX-640)/16)*8
   ' Set up zones 
   Restore DAT0
   Reserve Zone NZ
   For Z=1 To NZ
      Read XZ(Z),YZ(Z),A,B : Set Zone Z,XZ(Z),YZ(Z) To XZ(Z)+A,YZ(Z)+B
   Next 
   DAT0:
   Data 0,0,40,16
   Data 16+VA0,68,200,24
   Data 240+VA0,68,200,24
   Data 464+VA0,68,160,24
   Data 24+VA0,120,184,24
   Data SCSX-384-VA0-24,120,384,24
   Restore DAT1
   For I=0 To 10
      Read ANM_IC_T(I)
   Next I
   DAT1:
   Data 0,1,0,0,1,1,1,1,1,1,1,1
End Proc
Procedure _LOAD_BANKS[A]
   
   If A
      Timer=0
      _INFO[Resource$(24)] : _WAIT[50]
      If A and 1
         _GETFLAG[37] : Rem *** animated buttons *** 
         If Param
            If Length(15)=0
               Trap Load DPATH$+"AMOSPro_CompilerA_resource.Abk",15
               If Errtrap
                  _NOINFO
                  _INFO[Resource$(70)] : _WAIT[50]
                  _SETFLAG[37,0] : Erase 15
                  _NOINFO
               End If 
            End If 
         Else 
            Erase 15
         End If 
      End If 
      
      If A and 2
         _GETFLAG[34] : Rem *** iff animation ***  
         Erase 10
         If Param
            If ANM$<>""
               Trap Open In 1,ANM$
               If Errtrap
                  _NOINFO
                  _INFO[Resource$(71)] : _WAIT[50]
                  _SETFLAG[34,0] : Erase 10
                  _NOINFO
               Else 
                  L=Frame Length(1)
                  Trap Reserve As Work 10,L
                  If Errtrap
                     _NOINFO
                     _INFO[Resource$(71)] : _WAIT[50]
                     _SETFLAG[34,0] : Erase 10
                     _NOINFO
                  Else 
                     ANM_NF=Frame Load(1 To 10,100)-3
                  End If 
                  Close 1
               End If 
            End If 
         End If 
      End If 
      
      If A and 4
         _GETFLAG[35] : Rem *** Soundtrack *** 
         Erase 3
         If Param
            If SND$<>""
               If Length(3)=0
                  Trap Load SND$,3
                  If Errtrap
                     Trap Med Load SND$,3
                     If Errtrap
                        Trap Track Load SND$,3
                        If Errtrap
                           _NOINFO
                           _INFO[Resource$(72)] : _WAIT[50]
                           _SETFLAG[35,0] : Erase 3
                        End If 
                     End If 
                  End If 
               End If 
            End If 
         End If 
      End If 
      Repeat : Multi Wait : Until Timer>50
      _NOINFO
   End If 
   
End Proc
Procedure _LOAD_CONFIG[F$,REQ]
   
   On Error Proc _GEST_ERR
   Resume Label _END
   If F$=""
      F$=Fsel$(Dir$+"**","",Resource$(22))
   End If 
   If F$<>""
      Trap Open In 1,F$
      If Errtrap
         If REQ
            _WARN[Resource$(73),1]
            If Param=True
               F$=Fsel$(Dir$+"**","",Resource$(22))
               _LOAD_CONFIG[F$,1]
               Pop Proc
            End If 
         End If 
         _WARN[Resource$(74),0]
         FLAG$="2100101100000000000000001100000000000000000"
         ANM$="" : SND$=""
         Pop Proc
      End If 
      Input #1,FL$
      Input #1,A$
      Input #1,S$
      Close 1
      If Len(FL$)<>43
         Error 95
      Else 
         FLAG$=FL$
         ANM$=A$
         SND$=S$
      End If 
   End If 
   _END:
   
End Proc
Procedure _MATCH[A$]
   A=0 : F=False
   Repeat 
      If A$=LST$(A) : F=True : Exit : End If 
      Inc A
   Until LST$(A)=""
End Proc[F]
Procedure _NOINFO
   Trap Dialog Close 2
   Trap Dialog Unfreeze 1
End Proc
Procedure _NOP
   Multi Wait 
End Proc
Procedure _OPEN_FREE_SCREEN[SX,SY]
   For S=0 To 7
      Trap Screen S
      If Errtrap
         Trap Resource Screen Open S,SX,SY,0
         If Errtrap : Pop Proc[-1] : End If 
         Screen Hide S
         Cls 0 : Paper 0 : Pen 0
         Wait Vbl 
         Pop Proc[S]
      End If 
   Next 
End Proc[-1]
Procedure _OMM
   Auto View On 
   If SCR>=0
      Trap Screen Close SCR
      Trap Screen Open SCR,640,8,2,Hires
      If Errtrap=0
         Curs Off 
         Screen Display SCR,,78,,
         Palette $777,$FFF
         Centre Resource$(14) : Rem **** à changer ! ****  
         Clear Key : While Mouse Key : Multi Wait : Wend 
         Repeat : Multi Wait : Until Inkey$<>"" or Mouse Key<>0
         Screen Close SCR
      End If 
   End If 
   _QUIT
   Error 24
End Proc
Procedure _PLAY_SND
   On Error Proc _GEST_ERR
   Resume Label _END
   If Length(3)
      T$=Peek$(Start(3)-8,8)
      If T$="Music   "
         Trap Music 1
      Else If T$="Tracker "
         Track Loop On 
         Trap Track Play 3
      Else If T$="Med     "
         Trap Med Play 3
      Else If T$="Samples "
         Sam Bank 3
         Sam Loop On 
         Trap Sam Play 12,1
      End If 
   End If 
   _END:
End Proc
Procedure _STOP_SND
   On Error Proc _GEST_ERR
   Resume Label _END
   If Length(3)
      T$=Peek$(Start(3)-8,8)
      If T$="Music   "
         Trap Music Off 
      Else If T$="Tracker "
         Trap Track Stop 
      Else If T$="Med     "
         Trap Med Stop 
      Else If T$="Samples "
         Trap Sam Stop 
      End If 
   End If 
   _END:
End Proc
Procedure _QUIT
   _WARN[Resource$(20),1]
   If Param=True
      Trap Dialog Close 
      Trap Screen SCR
      If Errtrap=0
         For Y=1 To SCSY Step SOP
            Screen Offset SCR,,Y
            Screen Display SCR,,,,SCSY-Y
            Wait Vbl 
         Next 
         Screen Close SCR
      End If 
      Trap Close 
      Erase All 
      Edit 
   End If 
End Proc
Procedure _SETFLAG[N,V]
   
   Mid$(FLAG$,N,1)=Chr$(48+V)
   
End Proc
Procedure _SETUP
   
   Dialog Close 1
   FLAG_OLD$=FLAG$
   ANM_OLD$=ANM$
   SND_OLD$=SND$
   SU$="    LAbel 1;"
   SU$=SU$+"SIze     560,140;"
   SU$=SU$+"BAse     SW SX-2/,SH SY-2/;"
   SU$=SU$+"BOx      0,0,1,SX,SY;"
   SU$=SU$+"BOx      8,4,1,SX 8-,20;"
   SU$=SU$+"POutline 130MECX,8,130ME,0,7;"
   SU$=SU$+"BUtton   0,0,0,SX,16,0,0,0;[][SM;]"
   SU$=SU$+"BUtton   3,32,32,SX 32-,24,0,0,1;[LIne 0,0,79 3BP*+,SX 32-; PRint 131ME CX,8,131ME,3;][BR0;]"
   SU$=SU$+"BUtton   4,32,60,SX 32-,24,0,0,1;[LIne 0,0,79 3BP*+,SX 32-; PRint 132ME CX,8,132ME,3;][BR0;]"
   SU$=SU$+"BUtton   5,32,SY48-,135METL 8*16+,16,0,0,1;[LIne 0,0,114 3BP*+,135METL8*16+; PRint 135MECX BP+,4,135ME,3;][BR0;]"
   SU$=SU$+"BUtton   6,SX 136METL8*- 16- 2/,SY 48-,136METL 8*16+,16,0,0,1;[LIne 0,0,114 3BP*+,136METL8*16+; PRint 136MECX4- BP+,4,136ME,3;][BR0;]"
   SU$=SU$+"BUtton   7,SX 137METL8*-48-,SY48-,137METL 8*16+,16,0,0,1;[LIne 0,0,114 3BP*+,137METL8*16+; PRint 137MECX4- BP+,4,137ME,3;][BR0;]"
   SU$=SU$+"BUtton   1,32,SY28-,64,16,0,0,1;[UNpack 0,0,13BP+; PRint 4MECX BP+,4,4ME,3;][BR0;]"
   '   SU$=SU$+"KY       27,0;" 
   SU$=SU$+"BUtton   2,SX96-,SY28-,64,16,0,0,1;[UNpack 0,0,13BP+; PRint 5MECX BP+,4,5ME,3;][BR0;]"
   '   SU$=SU$+"KY       13,0;" : Rem  *** Selecteur Fichier perturbateur! ***  
   SU$=SU$+"EXit;"
   
   SU$=SU$+"LAbel 2;"
   SU$=SU$+"SIze     560,140;"
   SU$=SU$+"BAse     SW SX-2/,SH SY-2/;"
   SU$=SU$+"BOx      0,0,1,SX,SY;"
   SU$=SU$+"BOx      8,4,1,SX 8-,20;"
   SU$=SU$+"POutline 140MECX16-,8,140ME' - 1'!,0,7;"
   SU$=SU$+"BUtton   0,0,0,SX,16,0,0,0;[][SM;]"
   SU$=SU$+"DOption  3,16,32,SX16-,141,4VA;"
   SU$=SU$+"DOption  4,16,44,SX16-,142,5VA;"
   SU$=SU$+"DOption  5,16,56,SX16-,143,6VA;"
   SU$=SU$+"DOption  6,16,68,SX16-,144,7VA;"
   SU$=SU$+"BUtton   1,16,SY20-,64,16,0,0,1;[UNpack 0,0,13BP+; PRint 4MECX BP+,4,4ME,3;][BR0;]"
   SU$=SU$+"KY       27,0;"
   SU$=SU$+"BUtton   2,SX80-,SY20-,64,16,0,0,1;[UNpack 0,0,13BP+; PRint 3MECX BP+,4,3ME,3;][BR0;]"
   SU$=SU$+"KY       13,0;"
   SU$=SU$+"BUtton   8,SX 8METL8*- 16- 2/,SY20-,8METL 8*16+,16,0,0,1;[LIne 0,0,114 3BP*+,8METL8*16+; PRint 8MECX BP+,4,8ME,3;][BR0;]"
   SU$=SU$+"EXit;"
   
   SU$=SU$+"LAbel 3;"
   SU$=SU$+"SIze     560,140;"
   SU$=SU$+"BAse     SW SX-2/,SH SY-2/;"
   SU$=SU$+"BOx      0,0,1,SX,SY;"
   SU$=SU$+"BOx      8,4,1,SX 8-,20;"
   SU$=SU$+"POutline 140MECX16-,8,140ME' - 2'!,0,7;"
   SU$=SU$+"BUtton   0,0,0,SX,16,0,0,0;[][SM;]"
   SU$=SU$+"DOption  3,16,32,SX16-,151,14VA;"
   SU$=SU$+"DOption  4,16,44,SX16-,152,15VA;"
   SU$=SU$+"DOption  5,16,56,SX16-,153,16VA;"
   SU$=SU$+"DOption  6,16,68,SX16-,154,17VA;"
   SU$=SU$+"BUtton   1,SX 9METL8*- 16- 2/,SY20-,9METL 8*16+,16,0,0,1;[LIne 0,0,114 3BP*+,9METL8*16+; PRint 9MECX BP+,4,9ME,3;][BR0;]"
   SU$=SU$+"KY       27,0;"
   SU$=SU$+"EXit;"
   
   SU$=SU$+"LAbel 4;"
   SU$=SU$+"SIze     560,140;"
   SU$=SU$+"BAse     SW SX-2/,SH SY-2/;"
   SU$=SU$+"BOx      0,0,1,SX,SY;"
   SU$=SU$+"BOx      8,4,1,SX 8-,20;"
   SU$=SU$+"POutline 160MECX16-,8,160ME' - 1'!,0,7;"
   SU$=SU$+"BUtton   0,0,0,SX,16,0,0,0;[][SM;]"
   SU$=SU$+"DOption  3,16,32,SX16-,161,24VA;"
   SU$=SU$+"DOption  4,16,44,SX16-,162,25VA;"
   SU$=SU$+"DOption  5,16,56,SX16-,163,26VA;"
   SU$=SU$+"DOption  6,16,68,SX16-,164,27VA;"
   SU$=SU$+"BUtton   1,16,SY20-,64,16,0,0,1;[UNpack 0,0,13BP+; PRint 4MECX BP+,4,4ME,3;][BR0;]"
   SU$=SU$+"KY       27,0;"
   SU$=SU$+"BUtton   2,SX80-,SY20-,64,16,0,0,1;[UNpack 0,0,13BP+; PRint 3MECX BP+,4,3ME,3;][BR0;]"
   SU$=SU$+"KY       13,0;"
   SU$=SU$+"BUtton   8,SX8METL8*- 16- 2/,SY20-,8METL8*16+,16,0,0,1;[LIne 0,0,114 3BP*+,8METL8*16+; PRint 8MECX BP+,4,8ME,3;][BR0;]"
   SU$=SU$+"EXit;"
   
   SU$=SU$+"LAbel 5;"
   SU$=SU$+"SIze     560,140;"
   SU$=SU$+"BAse     SW SX-2/,SH SY-2/;"
   SU$=SU$+"BOx      0,0,1,SX,SY;"
   SU$=SU$+"BOx      8,4,1,SX 8-,20;"
   SU$=SU$+"SetVar   0,SW SX- 2/;"
   SU$=SU$+"SetVar   1,SH SY- 2/;"
   SU$=SU$+"POutline 160MECX16-,8,160ME' - 2'!,0,7;"
   SU$=SU$+"BUtton   0,0,0,SX,16,0,0,0;[][SM;]"
   SU$=SU$+"DOption  3,16,32,SX16-,171,34VA;"
   SU$=SU$+"DSelect  7,16,44,SX16-;"
   SU$=SU$+"DOption  4,16,56,SX16-,172,35VA;"
   SU$=SU$+"DSelect  8,16,68,SX16-;"
   SU$=SU$+"DOption  5,16,80,SX16-,173,36VA;"
   SU$=SU$+"DOption  6,16,92,SX16-,174,37VA;"
   SU$=SU$+"BUtton   1,SX9METL8*- 16- 2/,SY20-,9METL8*16+,16,0,0,1;[LIne 0,0,114 3BP*+,9METL8*16+; PRint 9MECX BP+,4,9ME,3;][BR0;]"
   SU$=SU$+"KY       27,0;"
   SU$=SU$+"EXit;"
   
   SU$=SU$+"UI       DO,6;"
   '                 DrawOption P1:ZN, P2:X, P3:Y, P4:W, P5:ME, P6:BP   
   SU$=SU$+"["
   SU$=SU$+"LIne     P2,P3,111,P4 68-;"
   SU$=SU$+"PRint    P2 16+,P3 1+,P5ME,3;"
   SU$=SU$+"BUtton   P1,P4 64-,P3,64,10,P6,0,1;"
   SU$=SU$+"         [LIne 0,0,41 3BP*+,64; PRint 6BP+MECX BP+,1,6BP+ME,3;][]"
   SU$=SU$+"]"
   
   SU$=SU$+"UI       DS,4;"
   '                 Drawselect P1:ZN, P2:X, P3:Y, P4:W 
   SU$=SU$+"["
   SU$=SU$+"LIne     P2,P3,111,P4 28-;"
   SU$=SU$+"BUtton   P1,P4 24-,P3,24,10,0,0,1;"
   SU$=SU$+"         [UNpack 0,0,120BP+;][BR0;]"
   SU$=SU$+"]"
   
   Dialog Open 1,SU$,60,1024*12
   Do 
      For I=4 To Len(FLAG$)
         _GETFLAG[I]
         Vdialog(1,I)=Param
      Next I
      Do 
         D1=Dialog Run(1,1)
         Do 
            Multi Wait 
            D1=Dialog(1)
            If D1=1
               FLAG$=FLAG_OLD$
               ANM$=ANM_OLD$
               SND$=SND_OLD$
               Exit 3
            Else If D1=2
               A=0
               If Vdialog(1,37)<>Asc(Mid$(FLAG_OLD$,37,1))-48 : A=1 : End If 
               If Vdialog(1,34)<>Asc(Mid$(FLAG_OLD$,34,1))-48 or ANM$<>ANM_OLD$ : A=A+2 : End If 
               If Vdialog(1,35)<>Asc(Mid$(FLAG_OLD$,35,1))-48 or SND$<>SND_OLD$ : A=A+4 : End If 
               _LOAD_BANKS[A]
               Exit 3
            Else If D1=3
               
               ' -- Compiled prog setup 1 --  
               
               FLAG_OLD2$=FLAG$
               ANM_OLD2$=ANM$
               SND_OLD2$=SND$
               Wait Vbl 
               D2=Dialog Run(1,2)
               Do 
                  Multi Wait 
                  D2=Dialog(1)
                  _DISPLAY_VDIALOG
                  If D2=1
                     FLAG$=FLAG_OLD2$
                     Exit 3
                  Else If D2=2
                     Exit 3
                  Else If D2>=3 and D2<8
                     D=D2+1
                     Vdialog(1,D)=Abs(Vdialog(1,D)-1)
                     _SETFLAG[D,Vdialog(1,D)]
                  Else If D2=8
                     
                     ' -- Compiled prog setup 2 --  
                     
                     D3=Dialog Run(1,3)
                     Do 
                        Multi Wait 
                        _DISPLAY_VDIALOG
                        D3=Dialog(1)
                        If D3=1
                           Exit 
                        Else If D3>=3
                           D=D3+11
                           Vdialog(1,D)=Abs(Vdialog(1,D)-1)
                           _SETFLAG[D,Vdialog(1,D)]
                        End If 
                     Loop 
                     D2=Dialog Run(1,2)
                  End If 
               Loop 
            Else If D1=4
               
               ' -- Compiler setup 1 -- 
               
               FLAG_OLD2$=FLAG$
               Wait Vbl 
               D2=Dialog Run(1,4)
               Do 
                  Multi Wait 
                  D2=Dialog(1)
                  _DISPLAY_VDIALOG
                  
                  If D2=1
                     FLAG$=FLAG_OLD2$
                     ANM$=ANM_OLD2$
                     SND$=SND_OLD2$
                     Exit 3
                  Else If D2=2
                     Exit 3
                  Else If D2>=3 and D2<8
                     D=D2+21
                     Vdialog(1,D)=Abs(Vdialog(1,D)-1)
                     _SETFLAG[D,Vdialog(1,D)]
                  Else If D2=8
                     
                     ' -- Compiler setup 2 -- 
                     
                     D3=Dialog Run(1,5)
                     LMAX=(SCSX-Vdialog(1,0)*2-88)/8
                     Ink 5 : Text Vdialog(1,0)+24,Vdialog(1,1)+51,Left$(ANM$,LMAX)
                     Text Vdialog(1,0)+24,Vdialog(1,1)+75,Left$(SND$,LMAX)
                     Do 
                        Multi Wait 
                        D3=Dialog(1)
                        _DISPLAY_VDIALOG
                        If D3=1
                           Exit 
                        Else If D3=7
                           If Vdialog(1,3+31)
                              _EXTRACT_PATH[ANM$]
                              A$=Fsel$(Param$,ANM$-Param$,Resource$(2))
                              If A$<>""
                                 ANM$=A$
                                 Cls 6,Vdialog(1,0)+24,Vdialog(1,1)+45 To Vdialog(1,0)+24+LMAX*8,Vdialog(1,1)+53
                                 Ink 5 : Text Vdialog(1,0)+24,Vdialog(1,1)+51,Left$(ANM$,LMAX)
                              End If 
                           End If 
                        Else If D3=8
                           If Vdialog(1,4+31)
                              _EXTRACT_PATH[SND$]
                              A$=Fsel$(Param$,SND$-Param$,Resource$(2))
                              If A$<>""
                                 SND$=A$
                                 Cls 6,Vdialog(1,0)+24,Vdialog(1,1)+69 To Vdialog(1,0)+24+LMAX*8,Vdialog(1,1)+77
                                 Ink 5 : Text Vdialog(1,0)+24,Vdialog(1,1)+75,Left$(SND$,LMAX)
                              End If 
                           End If 
                        Else If D3>=3
                           D=D3+31
                           Vdialog(1,D)=Abs(Vdialog(1,D)-1)
                           _SETFLAG[D,Vdialog(1,D)]
                        End If 
                     Loop 
                     D2=Dialog Run(1,4)
                  End If 
               Loop 
            Else If D1=5
               _LOAD_CONFIG["",1]
            Else If D1=6
               _SAVE_CONFIG[CNAME$]
            Else If D1=7
               _SAVE_CONFIG[""]
            End If 
         Loop 
      Loop 
   Loop 
   Dialog Close 1
   _INIT_DISPLAY
   
End Proc
Procedure _SAVE_CONFIG[F$]
   If F$=""
      F$=Fsel$("**","",Resource$(23))
   End If 
   If F$<>""
      Trap Open Out 1,F$
      Trap Print #1,FLAG$
      Trap Print #1,ANM$
      Trap Print #1,SND$
      Trap Close 1
      If Errtrap
         _WARN[Resource$(27),0]
      End If 
   End If 
End Proc
Procedure _SQUASH_A_PROG[A$,B$,A]
   '      If Param>0
   '         A$="Successfull squash! Final size:"+Str$(Param)+","+Str$(SZ-Param)+" bytes saved."
   '         _INFO[A$]
   '      Else  
   '         If Param=0 
   '            _INFO["Squash interrupted."]  
   '         End If 
   '         If Param<0 
   '            _INFO["Un-successfull Squash, No object file on disc."] 
   '         End If 
   '      End If  
   '      _WAIT[50] : _NOINFO 
   '      trap Kill D$  
   '      trap Rename DD$ To D$ 
End Proc
Procedure _STRING_FILTER[A$]
   A$=Mid$(A$,2,Len(A$)-9)
   For I=Len(A$) To 1 Step -1
      Exit If Mid$(A$,I,1)<>" "
   Next I
   A$=Left$(A$,I)
End Proc[A$]
Procedure _UPDATE_BUTTONS[A]
   If A=0
      Restore "DAT"+Right$("0"+(Str$(10*Vdialog(1,51)+Vdialog(1,52))-" "),2)
      DAT03:
      Data 1,2,0,-1
      Data 0,0,0,4,3,-1
      Data 0,0,0,0,0,5,-1
      DAT04:
      Data 1,2,0,-1
      Data 0,0,0,4,3,-1
      Data 0,0,0,0,0,6,7,5,-1
      DAT13:
      Data 1,2,0,-1
      Data 0,0,0,4,3,-1
      Data 0,0,0,0,0,5,-1
      DAT14:
      Data 1,2,0,-1
      Data 0,0,0,4,3,-1
      Data 0,0,0,0,0,6,7,5,-1
      DAT24:
      Data 1,2,0,-1
      Data 0,0,0,0,4,-1
      Data 0,0,0,0,0,6,7,5,-1
      For BUTT=2 To 4
         I=0
         Do 
            Read VA
            Exit If VA<0
            Vdialog(1,40+BUTT*10+I)=VA
            Inc I
         Loop 
      Next BUTT
   Else 
      If A=2
         If Vdialog(1,51)<=1
            If Vdialog(1,52)=3
               Restore DAT20
               DAT20:
               Data 2
               Data 3,0,0,0,4,3,-1
               Data 4,0,0,0,0,0,5,-1
            Else 
               Restore DAT21
               DAT21:
               Data 2
               Data 3,0,0,0,4,3,-1
               Data 4,0,0,0,0,0,6,7,5,-1
            End If 
         Else 
            Restore DAT22
            DAT22:
            Data 2
            Data 3,0,0,0,0,4,-1
            Data 4,0,0,0,0,0,6,7,5,-1
         End If 
      Else 
         If A=3
            If Vdialog(1,52)=3
               Restore DAT30
               DAT30:
               Data 1
               Data 4,0,0,0,0,0,5,-1
            Else 
               Restore DAT31
               DAT31:
               Data 1
               Data 4,0,0,0,0,0,6,7,5,-1
            End If 
         Else 
            Pop Proc
         End If 
      End If 
      Read NB_LIST
      For J=1 To NB_LIST
         FLAG=True
         Read BUTT
         I=0
         Do 
            Read V
            Exit If V<0
            VA=V
            If VA=Vdialog(1,50+BUTT-1) : FLAG=False : End If 
            Vdialog(1,40+BUTT*10+I)=VA
            Inc I
         Loop 
         If FLAG
            Vdialog(1,50+BUTT-1)=VA
            _SETFLAG[BUTT-1,Vdialog(1,50+BUTT-1)+5*(BUTT=4)+3*(BUTT=3)]
            Dialog Update 1,BUTT
         End If 
      Next J
   End If 
End Proc
Procedure _WAIT[T]
   For I=1 To T
      Multi Wait 
   Next I
End Proc
Procedure _WARN[A$,REQUESTER]
   Trap Dialog Freeze 1
   Trap Dialog Freeze 2
   L=Len(A$)*8
   WA$="    SIze     1VA TL8* 32+, 48 0VA 24*+;"
   WA$=WA$+"BAse     SW SX -2/,SH SY -2/; SA 1;"
   WA$=WA$+"BOx      0,0,1,SX,SY;"
   WA$=WA$+"BOx      8,4,1,SX 8-,20;"
   WA$=WA$+"POutline 21ME CentreX,8,21ME,0,7;"
   WA$=WA$+"PRint    1VA CentreX,20 TH+,1VA,3;"
   WA$=WA$+"BUtton   0,0,0,SX,32,0,0,0;[][SM;]"
   WA$=WA$+"IF       0VA 1=;["
   WA$=WA$+"BUtton   1,16,SY24-,64,16,0,0,1;[UNpack 0,0,13BP+; PRint 4ME CX BP+,4,4ME,3;][BR0;]"
   WA$=WA$+"KY       27,0;"
   WA$=WA$+"BUtton   2,SX80-,SY24-,64,16,0,0,1;[UNpack 0,0,13BP+; PRint 3ME CX BP+,4,3ME,3;][BR0;]"
   WA$=WA$+"KY       13,0;  ]"
   WA$=WA$+"EXit;"
   Dialog Open 3,WA$
   Vdialog(3,0)=REQUESTER
   Vdialog$(3,1)=A$
   D=Dialog Run(3)
   Timer=0
   Repeat 
      Multi Wait 
      D=Dialog(3)
      Exit If Timer>200 and REQUESTER=0
   Until D=1 or D=2
   Dialog Close 3
   Trap Dialog Unfreeze 1
   Trap Dialog Unfreeze 2
End Proc[(D=2)]
Procedure MN_ABOUT
   Dialog Freeze 1
   AB$="SIze     480,100;"
   AB$=AB$+"BAse     SW SX -2/,SH SY -2/; SA 1;"
   AB$=AB$+"BOx      0,0,1,SX,SY;"
   AB$=AB$+"BOx      16,8,1,SX 16-,72;"
   AB$=AB$+"SVar     2,'AMOS Compiler  "+VER$+"';"
   AB$=AB$+"POutilne 2 VA CentreX,8 TH+,2VA,0,7;"
   AB$=AB$+"SVar     2,10ME ' Francois LIONET'!;"
   AB$=AB$+"PRint    2VA CentreX,24 TH+,2VA,7;"
   AB$=AB$+"SVar     2,11ME ' Jean-Baptiste BOLCATO'!;"
   AB$=AB$+"PRint    2VA CentreX,36 TH+,2VA,7;"
   AB$=AB$+"SVar     2,'© 1993 Europress Software Ltd.';"
   AB$=AB$+"PRint    2VA CentreX,48 TH+,2VA,7;"
   AB$=AB$+"PRint    1VA CentreX,78 TH+,1 VA,3;"
   AB$=AB$+"RUn      250,%1111;"
   AB$=AB$+"EXit;"
   D=Dialog Box(AB$,1,"Chip:"+Str$(Chip Free)+"   Fast:"+Str$(Fast Free))
   Dialog Unfreeze 1
End Proc
Procedure MN_VERSIONS
End Proc

' *** debug!!... *** 

Procedure _MON
   Monitor 
   Resume Next 
End Proc
Procedure _GEST_ERR
   _WARN[Err$(Errn),0]
   Resume Label 
End Proc
Procedure _DISPLAY_VDIALOG
   'Home  
   'Print Chip Free+Fast Free 
   Pop Proc
   Trap D=Dialog(1)
   If Errtrap=0
      For I=1 To Len(FLAG$) : Print Using "#";Vdialog(1,I); : Next I
   End If 
   Print : Print FLAG$
   For I=1 To Len(FLAG$) : Print Right$(Str$(I),1); : Next I
End Proc
