Software: BattleWing

Lanuage: AMOSPro; Size: 78.012 bytes;


Set Buffer 64

Rem -------------------Varinit---------------------------------------

L=Length(1)+1
Dim HSPX(L),HSPY(L)
Global HSPX(),HSPY()
Dim GAD$(20)
Dim PTR(5)
I=20
Dim SENERGY(I),SSHIELD(I,4),SHULL(I,4,4),SMISS(I),SDATA(I,4),SPT(I),SCARGO$(I)
Dim SSKILL(I)
Dim ST(I),SR(I),SM(I),SL(I),SS(I),SC(I),SP(I),SLASTHIT(I),RELEVANZ(I),SWEAPON(I)
Dim SVX(I),SVY(I),SVZ(I)
Dim IDENT$(I)
Dim SI(I)

Global PTR()


I=200
Dim OX(I),OY(I),OZ(I),OT(I),OL(I),OART(I),OE(I),OC(I),OSOURCE(I)
Dim OVX(I),OVY(I),OVZ(I),OS(I)

Dim ROCKETTYPE(5)
Global ROCKETTYPE()

Dim ENERGY(4)
Dim STATUS(10)

T=40
Dim TE(T),TS(T)
Dim TSA(T),OANZ(T),NAME$(T),TL(T)
Dim THA(T,4),TSX(T,4),TSY(T,4),TSZ(T,4),TSE(T,4),TSS(T,4)
Dim THX(T,4,4),THY(T,4,4),THZ(T,4,4),THE(T,4,4),THS(T,4,4),THB(T,4,4)
Dim TKILLS(T)
Dim PILOT(10)

Global SENERGY(),SSHIELD(),SHULL(),ST(),SR(),SM(),SL(),SS(),SP(),SLASTHIT(),SWEAPON(),SI(),SDATA(),SPT(),SC(),SMISS(),SCARGO$()
Global SVX(),SVY(),SVZ()
Global OX(),OY(),OZ(),OT(),OL(),OART(),OE(),OS(),OC(),OSOURCE(),OVX(),OVY(),OVZ()
Global TS(),TL(),THA(),TSX(),TSY(),TSZ(),TSE(),TSA(),OANZ(),NAME$(),IDENT$(),THX(),THY(),THZ(),THE(),TE(),TSS(),THS(),THB(),TKILLS()
Global OWNLOOSE,ENEMYLOOSE,VORNAME$,NACHNAME$,MISSION,YOURKILLS,YOURHITS,YOUROWNHITS,YOURFIRED,SCORE
Global MOWNLOOSE,MENEMYLOOSE,MYOURKILLS,MYOURHITS,MYOUROWNHITS,MYOURFIRED,MSCORE
Global OPTR,SSKILL()
Global SANZ,OANZ,SPANZ
Global PX,PY,PZ
Global CHEAT,COUNT,LEVEL

Rem -----------------------Init--------------------------------------- 
INIT
LEVEL=1
STATUS=0
Rem----------------------------Outer Loop----------------------- 
Do 
   MENU
   TSS(0,0)=200+LEVEL*30
   Screen Close 4
   Screen 1
   ROCKETGAUGE
   WEAPONGAUGE
   Screen 0
   Timer=0
   Rem   SS(0)=100
   Rem   SET=128
   ST(0)=0
   Rem--------------------------Main Loop-------------------------- 
   Do 
      ZIEL=-1
      RAND=Rnd(5)+1
      SECS=Timer/50
      
      Inc COUNT
      COUNT=COUNT and $FF
      
      Put Block 1
      
      PX=Td Position X(0)
      PY=Td Position Y(0)
      PZ=Td Position Z(0)
      GSV[0]
      
      Dec RELOAD
      RELOAD=Max(RELOAD,-50)
      
      Add BLASTER,ENERGY(1)-3
      BLASTER=Min(BLASTER,2800)
      BLASTER=Max(BLASTER,0)
      
      If STATUS=0
         I$=Inkey$
         If I$<>""
            KEYS
            If Param
               Exit 
            End If 
         End If 
         M=Mouse Click
         If M and 2 or GLOCK
            LOCK
            LOCK=Param
            If LOCK=0
               If M and 2
                  GLOCK= Not GLOCK
               End If 
            Else 
               GLOCK=0
            End If 
            SHIPINF[LOCK]
         End If 
         CONTROL
         Td Forward 0,SPEED
         If Fire(0) or Fire(1)
            If BLASTER>400 and RELOAD<0
               LASERFIRE
            End If 
         End If 
      Else If STATUS=-1
         If SENERGY(19)<=0
            Exit 
         End If 
      Else If STATUS=1
         If SET>0
            SET=0
            MESSAGE[48]
         End If 
         FACE[0,0,200,0]
         If SPEED=0
            Exit 
         End If 
      End If 
      
      If CAMERA
         If SENERGY(CAMERA)>0
            OSWAP[0,CAMERA]
            Td Redraw 
            OSWAP[0,CAMERA]
         Else 
            CAMERA=0
         End If 
      Else 
         Td Redraw 
      End If 
      
      For I=0 To 5
         PTR=PTR(I)
         If PTR>0
            PROG
            PTR(I)=PTR
         End If 
      Next 
      
      If LOCK>0
         If SENERGY(LOCK)<=0
            Screen 1
            Put Block 7
            Screen 0
            LOCK=0
         Else 
            MARKLOCK[LOCK]
         End If 
      End If 
      
      For I=1 To 20
         S=ST(I)
         If SENERGY(I)>0
            If Td Visible(I)
               For B=0 To 15
                  If OART(B)=2
                     HIT[B,I]
                  End If 
               Next 
            End If 
            On S Proc TIE,TIE,AWING,AMBOSS,HWING,NOP,NOP,SENTINEL,SPLITTER,SHUTTLE
            On S-10 Proc CORVETTEC,CORVETTE,CORVETTEB,STREITSCHIFF,KAMPFSCHIFF,TRäGER,FLAGGSCHIFF,FRACHTER,FRACHTER,LASERMINE
            On S-20 Proc MOV,MOV,MOV,STATION,NOP,FRACHTER,NOP,TRäGER
            On S-30 Proc AMBOSS,AMBOSS,AMBOSSC,AMBOSSE
            CRASH[I]
         Else 
            If S>0
               If SMISS(I) and 1
                  SMISS(I)=SMISS(I) and Not 1
                  SMISS(I)=SMISS(I) or 2
               End If 
               On S Proc ZER,BUMM,ZER,BUMM,ZER,NOP,NOP,ZER,BUMM,ZER
               On S-10 Proc BANG,BANG,BANG,BANG,BANG,BANG,BANG,BANG,BANG,BUMM
               On S-20 Proc BUMM,BUMM,BUMM,BANG,BANG,BANG,BANG,BANG
               On S-30 Proc ZER,ZER,ZER,BUMM,BUMM
            End If 
         End If 
      Next 
      
      If SENERGY(CAMERA)<=0 Then CAMERA=0
      
      If CAMERA
         OSWAP[0,CAMERA]
      End If 
      For I=0 To OANZ
         On OART(I) Proc OBDRAW,LASERBEAM,SPARK,HOMING,ROCKET,JUMPGATE
      Next 
      If CAMERA
         OSWAP[0,CAMERA]
      End If 
      
      If STATUS=0
         CROSSHAIR
         Paste Bob 0,108,48
         Paste Bob 256,108,49
      End If 
      
      Screen Swap 
      Wait Vbl 
      
      SPEED=Max(SS(0)+Sgn((((ENERGY(0)-STATUS(3))*4+60)*SET)/128-SPEED),0)
      SS(0)=SPEED
      
      If STATUS=0 and(SENERGY(0)<=0 or STATUS(2)>4)
         DIE : STATUS=-1
      End If 
      
      If COUNT mod 2=0
         Screen 1
         SHIELDGAUGE
         Put Block 4
         If STATUS(5)<RAND
            RADAR
         End If 
         If SPEED<>OLDSPEED
            OLDSPEED=SPEED
            Put Block 2
            Ink 0
            Draw 118,4 To 118,4+Max(64-SET/2,0)
         End If 
         LASERGAUGE
         If BABBEL
            BABBELGAUGE
         End If 
         
         If COUNT mod 4=0
            Ink 8
            Text 40,55,Str$(SECS/60)+":"+Str$(SECS mod 60)+"  "
            Text 90,55,Str$(SPEED)+"  "
            If LOCK
               R=Td Range(0,LOCK)
               If R>2000
                  Text 134,67,"Dist:"+Str$(Td Range(0,LOCK)/128)+"    "
                  SCAN=0
               Else 
                  If SMISS(LOCK) and %1000
                     Text 136,67,"Ready       "
                  Else 
                     Inc SCAN
                     Text 136,67,"Scanning"
                     If SCAN>4
                        SHIPINF[LOCK]
                        SMISS(LOCK)=SMISS(LOCK) or %1000
                     End If 
                  End If 
               End If 
            End If 
            If COUNT mod 8=0
               Add SSHIELD(0,0),ENERGY(2)-3
               SSHIELD(0,0)=Min(Max(SSHIELD(0,0),0),TSE(0,0)-STATUS(2)*50)
            End If 
         End If 
      End If 
      Screen 0
   Loop 
   
   Screen Show 1
   STATUS=0
   DEBRIEF
   LOOSE=Param
   Inc MISSION
   Add MISSION,LOOSE
   SAV
Loop 

Rem Verwaltung:
Rem ===============================
Procedure INIT
   Degree 
   Set Input 10,-1
   Td Dir Dir$+"objs"
   INITRAMLOAD
   INITHOTSPOT
   INITTEMPLATES
   INITSCREEN
   INITCOCKPIT
   Led Off 
End Proc
Procedure INITSCREEN
   Screen Open 0,320,200,32,Lowres
   Hide On 
   Flash Off 
   Get Bob Palette 
   Cls 0
   Make Icon Mask 
   Get Block 1,0,0,320,200
   Wait Vbl 
   Double Buffer 
   Autoback 0
   Bob Update Off 
   Td Screen Height 200
   Set Bob 1,-1,%10000,
   Screen Open 2,64,32,32,Lowres
   Flash Off 
   Get Palette 0
   Screen Hide 2
   Screen 0
End Proc
Procedure INITCOCKPIT
   Unpack 6 To 1
   Ink ,0
   Get Block 2,112,4,16,68
   Get Block 3,88,6,16,20
   Get Block 4,192,0,48,48
   Get Block 5,35,20,32,30
   Get Block 6,80,31,32,12
   Get Block 7,130,5,64,64
   Get Block 8,32,4,48,6
   Get Block 9,64,16,16,32
   Screen Display 1,,234,,
   Get Icon Palette 
   Jd Textfont Dir$+"fonts/battlewing.font",6
End Proc
Procedure INITHOTSPOT
   S=Start(1)
   For I=0 To Length(1)-1
      PTR=S+2+I*8
      SPTR=Leek(PTR)
      HSPX(I+1)=Deek(SPTR+6)
      HSPY(I+1)=Deek(SPTR+8)
   Next I
End Proc
Procedure INITRAMLOAD
   If Not Exist("ram:objs")
      Mkdir "ram:objs"
      Exec "copy "+Dir$+"objs/#? ram:objs"
   End If 
   Td Dir "ram:objs"
End Proc
Procedure INITOBJECTLOAD
   Td Load "a-wingspl"
   Td Load "amboßspl"
   Td Load "amboßcspl"
   Td Load "amboßbspl"
   Td Load "h-wingspl"
   Td Load "spinnespl"
   Td Load "tiefighterspl"
   Td Load "comm satspl"
   Td Load "shuttlespl"
   Td Load "spl"
   Td Load "sentinelspl"
   Td Load "faces"
End Proc

Procedure MENU
   Shared PILOT()
   ROCKETTYPE(1)=1
   ROCKETTYPE(2)=2
   ROCKETTYPE(3)=3
   ROCKETTYPE(4)=2
   ROCKETTYPE(5)=2
   Shared GAD$()
   Screen Open 4,320,256,4,Lowres
   Curs Off 
   Show On 
   Reserve Zone 20
   Centre "Willkommen bei Battlewing!"
   Print 
   Print 
   Repeat 
      Cls 0
      Paper 0
      Pen 1
      OPTION["Neues Spiel",1,10,1]
      OPTION["Laden",2,10,2]
      OPTION["Holo-Screen",3,10,3]
      OPTION["Statistik",4,10,4]
      OPTION["Options",5,10,5]
      OPTION["Start",6,10,6]
      Limit Mouse 
      Locate 0,12
      Print "Wilkommen "+VORNAME$+" "+NACHNAME$+" in Mission",MISSION
      ERFOLG[PILOT(1),PILOT(2),PILOT(3),PILOT(4),PILOT(5),PILOT(6),PILOT(7)]
      MOUSE
      M=Param
      On M Proc NEW,LAD,HOLO,STATISTIK,OPTIONS,INITMISSION
      Screen 4
   Until M=6 or M=7
   Reset Zone 
   Hide On 
End Proc
Procedure STATISTIK
   Reset Zone 
   Cls 0
   Paper 0
   Pen 1
   Repeat 
      
      OPTION["Erfolge",1,10,1]
      OPTION["Kills",2,10,2]
      OPTION["Zurück",4,10,4]
      MOUSE
      M=Param
      Locate 1,10
      If M=1
         ERFOLG[ENEMYLOOSE,OWNLOOSE,YOURKILLS,YOURFIRED,YOURHITS,YOUROWNHITS,SCORE]
      Else If M=2
         LISTKILLS
      End If 
      M=Param
   Until M=4
   Reset Zone 
End Proc
Procedure LEVEL
   Add LEVEL,1,1 To 3
End Proc
Procedure HOLO
   Shared GAD$()
   OPTION["Zoom +",7,10,27]
   OPTION["Zoom -",8,18,27]
   OPTION["Nächster",9,8,28]
   OPTION["Letzter",10,16,28]
   OPTION["Schluß",11,20,29]
   Td Move 0,0,0,0
   Td Angle 0,0,0,0
   TYP=1
   Screen To Front 0
   Td Load Lower$(NAME$(TYP))
   Td Object 1,Lower$(NAME$(TYP)),0,0,2000,0,0,0
   Screen 4
   Do 
      M=Mouse Zone
      If M<>OLD
         Pen 1
         Print GAD$(OLD)
         Pen 2
         Print GAD$(M)
      End If 
      OLD=M
      If REDRAW or Mouse Key and 2
         Screen 0
         Td Redraw 
         OOX=OX
         OOY=OY
         OX=X Mouse
         OY=Y Mouse
         X=OX-OOX
         Y=OY-OOY
         Td Angle Rel 1,Y*200,X*200,0
         X=X*0.8
         Y=Y*0.8
         Screen Swap 
         Wait Vbl 
         Put Block 1
         REDRAW=False
         Screen 4
      Else If Mouse Click
         If M=7
            Td Move Rel 1,0,0,-100
            REDRAW=True
         Else If M=8
            Td Move Rel 1,0,0,100
            REDRAW=True
         Else If M=9
            Repeat 
               Inc TYP
            Until Exist("ram:objs/"+NAME$(TYP)+".3do")
            Td Clear All 
            Td Load NAME$(TYP)
            Td Object 1,NAME$(TYP),0,0,2000,0,0,0
            REDRAW=True
            Locate 7,29
            Print NAME$(TYP)
         Else If M=10
            Repeat 
               Dec TYP
            Until Exist("ram:objs/"+NAME$(TYP)+".3do")
            Td Clear All 
            Td Load NAME$(TYP)
            Td Object 1,NAME$(TYP),0,0,2000,0,0,0
            Locate 7,29
            Print NAME$(TYP)
            REDRAW=True
         Else If M=11
            Screen To Front 4 : Pop Proc
         End If 
      End If 
   Loop 
End Proc
Procedure OPTIONS
   Shared STANZ,MISSION
   Reset Zone 
   Repeat 
      Cls 0
      Paper 0
      Pen 1
      OPTION["+ Mission:",1,10,1]
      OPTION["- "+Str$(MISSION),2,10,2]
      OPTION["Level "+Str$(LEVEL)+" ",3,10,3]
      OPTION["Zurück",4,10,4]
      MOUSE
      M=Param
      If M=1
         Inc MISSION
      Else If M=2
         Dec MISSION
      Else If M=3
         LEVEL
      End If 
   Until M=4
   Reset Zone 
End Proc

Procedure ERFOLG[K0,K1,KY,LF,LH,LOH,SCO]
   Print "Deine Wenigkeit hat:"
   Print KY,"Popel demontiert."
   Print LF,"mal feuea geschnupft."
   Print LH,"mal Organe gerupft."
   Print LOH,"mal eigene Hühner gerupft."
   Print 
   Print "Feuea Akkurands:"
   If LF>0
      Print(100*LH)/LF,"% im Fackel-Beam"
   End If 
   Print 
   Print "Spüddel:"
   Print "Geloost |";K1;" :";K0;" | Gemurkst"
   Print 
   Print "Kontostand:"
   Print SCO," Brutalo-Punkte geschäffelt."
End Proc
Procedure LISTKILLS
   For I=0 To 40
      K=TKILLS(I)
      If K
         Print NAME$(I);":";K;" ";
      End If 
   Next 
End Proc
Procedure NEW
   Shared PILOT()
   For I=0 To 10
      PILOT(I)=0
   Next 
   Input "Vorname(Rufname):";VORNAME$
   Input "Nachname:";NACHNAME$
End Proc
Procedure SAV
   Shared PILOT()
   FILE$="saves/"+NACHNAME$+".pilot"
   If Exist(FILE$) Then Kill FILE$
   Open Out 1,FILE$
   Print #1,"bw_pilot"
   Print #1,VORNAME$
   Print #1,NACHNAME$
   For I=1 To 7
      Print #1,PILOT(I)
   Next 
   Print #1,MISSION
   For I=1 To 30
      Print #1,TKILLS(I)
   Next 
   Close 1
End Proc
Procedure LAD
   Shared PILOT()
   Set Input 13,10
   ODIR$=Dir$
   Dir$=Dir$+"saves/"
   Shared CODE$
   FILE$=Fsel$("*.pilot")
   Open In 1,FILE$
   Input #1,CODE$
   If CODE$<>"bw_pilot" Then Bell : End 
   Input #1,VORNAME$
   Input #1,NACHNAME$
   For I=1 To 7
      Input #1,PILOT(I)
   Next 
   Input #1,MISSION
   
   For I=1 To 30
      Input #1,TKILLS(I)
   Next 
   Close 1
   Dir$=ODIR$
   Set Input 10,-1
End Proc
Procedure RESET
   Shared ENERGY(),HULL,SHIELD,STATUS(),SET,OWNHITS,TRAITOR,BLASTER
   
   TRAITOR=0
   
   For I=1 To OANZ
      OT(I)=0
      OART(I)=0
      OC(I)=0
      OE(I)=0
   Next 
   
   PPTR=0
   
   OART(16)=-1
   OE(16)=500
   
   For I=1 To 20
      ST(I)=0
      SL(I)=0
      SPT(I)=-1
      SS(I)=0
      SENERGY(I)=0
      SR(I)=0
      SM(I)=0
      SC(I)=0
      SP(I)=0
      SLASTHIT(I)=-1
   Next 
   
   For I=0 To 5
      PTR(I)=0
   Next 
   
   SSHIELD(0,0)=TSE(0,0)
   SSHIELD(0,1)=TSE(0,1)
   SENERGY(0)=TE(0)
   
   X Mouse=200
   Y Mouse=150
   
   SC(0)=1
   
   ENERGY(1)=10
   ENERGY(2)=6
   ENERGY(3)=0
   ENERGY(0)=4
   
   Td Move 0,0,0,-10000
   Td Angle 0,0,0,0
   
   
   
   For I=0 To 10
      STATUS(I)=0
   Next 
   For I=0 To 5
      STATUSGAUGE[I]
   Next 
   
   SET=0
   SS(0)=0
   ROCKETGAUGE
   ENERGAUGE
   BLASTER=4000
End Proc
Procedure BRIEF
   Screen 4
   Cls 0
   Locate 1,1
   Repeat 
      Line Input #1,T$
      If T$="END" Then EVENT : Pop Proc
      Print T$
   Until Eof(1)
End Proc

Procedure CREATE[I,X,Y,Z,A,B,C]
   If SENERGY(I)>0 Then Pop Proc
   NAME$=NAME$(ST(I))
   Td Object I,NAME$,X,Y,Z,A,B,C
   SL(I)=-1
   SMISS(I)=9
   SM(I)=0
   For J=0 To TSA(ST(I))-1
      SSHIELD(I,J)=TSE(ST(I),J)
      For K=0 To THA(ST(I),J)-1
         SHULL(I,J,K)=THE(ST(I),J,K)
      Next 
   Next J
   SENERGY(I)=TE(ST(I))
End Proc
Procedure INITTEMPLATES
   Open In 1,"ships.dta"
   Input #1,CODE$
   If CODE$<>"bw_shiptemp" Then Bell : End 
   I=0
   While Not Eof(1)
      Input #1,A$
      If A$="end" Then Exit 
      NAME$(I)=Mid$(A$,4,255)
      Input #1,TE(I),TSA(I)
      If TSA(I)>0
         For J=0 To TSA(I)-1
            Input #1,TSX(I,J),TSY(I,J),TSZ(I,J),TSS(I,J),TSE(I,J),THA(I,J)
            If THA(I,J)>0
               For K=0 To THA(I,J)-1
                  Input #1,THX(I,J,K),THY(I,J,K),THZ(I,J,K),THS(I,J,K),THE(I,J,K),THB(I,J,K)
               Next 
            End If 
         Next 
      End If 
      Input #1,OANZ(I)
      Inc I
   Wend 
   Close 1
End Proc
Procedure INITMISSION
   Shared OANZ,RELEVANZ(),METEOR,MISSION,I,NAME$
   RESET
   INITOBJECTLOAD
   OPTR=50
   Dim T(40)
   N=MISSION
   Open In 1,"mission/mission"+Str$(N)-" "+".dta"
   Input #1,CODE$
   If CODE$<>"bw_mission" Then Bell : End 
   Input #1,SANZ
   For I=1 To SANZ
      Input #1,NAME$,SC(I),RELEVANZ(I)
      For J=1 To 40
         If Upper$(NAME$-"+")=Upper$(NAME$(J))
            If Left$(NAME$,1)="+"
               ST(I)=J
            Else 
               ST(I)=-J
            End If 
         End If 
      Next 
      If ST(I)=0
         Bell 
         Default 
         Print I,NAME$
         End 
      End If 
      If Not T(Abs(ST(I)))
         Td Load NAME$(Abs(ST(I)))
         T(Abs(ST(I)))=-1
      End If 
      SP(I)=OPTR
      SWEAPON(I)=4
      Add OPTR,OANZ(Abs(ST(I)))
      If Left$(NAME$,1)="+"
         Input #1,X,Y,Z
         CREATE[I,X*128,Y*128,Z*128,0,0,0]
      End If 
   Next 
   INITPROGRAM
   Close 1
   Add OPTR,2
   If T(20)=0
      Td Load NAME$(20)
   End If 
   OANZ=OPTR+50
End Proc
Procedure INITPROGRAM
   Shared SCARGO$(),TEST$,TEST
   On Error Proc FELER
   If Eof(1) Then Pop Proc
   Dim C$(30)
   Erase 4
   Reserve As Work 4,2048
   PTR=Start(4)
   PTR(0)=PTR
   Repeat 
      Inc N
      Read C$(N)
   Until C$(N)="#"
   
   Repeat 
      Input #1,I$
      Inc TEST
      L$=Left$(I$,4)
      If L$="PROG"
         Input #1,I
         PTR(I)=PTR
      Else If L$="PLAY"
         Input #1,X,Y,Z
         Td Move 0,X,Y,Z
      Else If L$="BRIE"
         BRIEF
      Else If L$="WEAP"
         For I=1 To 5
            Input #1,ROCKETTYPE(I)
         Next 
      Else If L$="REPE"
         LABEL=PTR
      Else 
         If PTR+16>Start(4)+Length(4)
            FEHLER["Zu viele Programm-Schritte"]
         End If 
         For I=1 To N
            If Instr(I$,Left$(C$(I),4))
               COMMAND=I
            End If 
         Next 
         C$=C$(COMMAND)
         Poke PTR,COMMAND
         Inc PTR
         P=Instr(C$,",")+1
         While P<=Len(C$)
            A$=Mid$(C$,P,1)
            If A$="b"
               Input #1,I
               Poke PTR,I
               Inc PTR
            Else If A$="w"
               Input #1,I
               Doke PTR,I
               Add PTR,2
            Else If A$="s"
               Input #1,I$
               L=Len(I$)
               If L+PTR>Start(4)+Length(4)
                  FEHLER["Zu langer String"]
               End If 
               If L mod 2=0
                  Inc L
               End If 
               Poke PTR,L
               Inc PTR
               Poke$ PTR,I$
               Add PTR,L
            Else If A$="0"
               Poke PTR,0
               Inc PTR
            Else If A$="c"
               If LABEL>PTR or LABEL=0
                  FEHLER["REPEAT nicht korrekt."]
               End If 
               Doke PTR,PTR-LABEL
               Add PTR,2
            End If 
            Inc P
         Wend 
      End If 
   Until Eof(1)
   Data "STAT,bw","WAIT,0w","JUMP,bwww","LAUNCH,bb0","TARGET,bb0"
   Data "ESCAPE,b","FACE,bb0","SPEED,bw","PAUSE,0w","BABBEL,b"
   Data "ENERGY,bw","DAMAGE,bw","RANGE,bwb0","ENDP,b","COMMAND,bb0"
   Data "INFO,s","CARGO,b,0,s","SETS,b,w","SKILL,b,w","UNTIL,bwc","#"
End Proc
Procedure DEBRIEF
   Shared RELEVANZ(),TKILLS(),PILOT()
   Td Clear All 
   Screen Open 4,320,200,4,Lowres
   For I=1 To SANZ
      If RELEVANZ(I)
         If(SMISS(I) and RELEVANZ(I))=RELEVANZ(I)
            Print I,"Ok."
            Add MSCORE,1000
         Else 
            Print I,"Nicht Ok:",SMISS(I),RELEVANZ(I)
            LOOSE=-1
         End If 
      End If 
      Rem      Print "wurde ausgelirbt." 
      Rem         Print "Das durfte nicht sein!"   
      Rem            Print "Er hätte outlirbed sein müssen, mein Bester!"
   Next 
   Add MSCORE,MYOURHITS*5
   Add MSCORE,-MYOUROWNHITS*50
   Add MSCORE,MENEMYLOOSE*100
   Add MSCORE,-MOWNLOOSE*100
   ERFOLG[MENEMYLOOSE,MOWNLOOSE,MYOURKILLS,MYOURFIRED,MYOURHITS,MYOUROWNHITS,MSCORE]
   Add PILOT(1),MENEMYLOOSE
   Add PILOT(2),MOWNLOOSE
   Add PILOT(3),MYOURKILLS
   Add PILOT(4),MYOURFIRED
   Add PILOT(5),MYOURHITS
   Add PILOT(6),MYOUROWNHITS
   Add PILOT(7),MSCORE
   
   MYOURKILLS=0
   MYOURFIRED=0
   MYOURHITS=0
   MYOUROWNHITS=0
   MOWNHITS=0
   MOWNLOOSE=0
   MENEMYLOOSE=0
   MSCORE=0
   
   Wait Key 
   Screen Close 4
End Proc[LOOSE]
Procedure MOUSE
   Shared GAD$()
   Repeat 
      If Joy(1)
         Wait Vbl 
         X Mouse=X Mouse+Jleft(1)*2-Jright(1)*2
         Y Mouse=Y Mouse-Jdown(1)*2+Jup(1)*2
      End If 
      M=Mouse Zone
      If M<>OLD
         Pen 1
         Print GAD$(OLD)
         Pen 2
         Print GAD$(M)
      End If 
      OLD=M
   Until Mouse Click or Fire(1)
End Proc[M]
Procedure SETWEAPONS
   Shared ROCKETTYPE()
   For I=1 To 5
      Input ROCKETTYPE(I)
   Next 
End Proc

Procedure PROG
   Shared SECS,PTR
   C=Peek(PTR)
   If C=1
      A=(SMISS(Peek(PTR+1)) and Deek(PTR+2))
      If A>0
         Add PTR,4
         Pop Proc
      Else 
         Pop Proc
      End If 
   Else If C=2
      A=Deek(PTR+2)
      If SECS>A
         Add PTR,4
      End If 
      Pop Proc
   Else If C=3
      I=Peek(PTR+1)
      If ST(I)<0
         ST(I)=-ST(I)
         X=Deek(PTR+2)
         Y=Deek(PTR+4)
         Z=Deek(PTR+6)
         If X>$7FFF
            Add X,-$FFFF
         End If 
         If Y>$7FFF
            Add Y,-$FFFF
         End If 
         If Z>$7FFF
            Add Z,-$FFFF
         End If 
         CREATE[I,X*128,Y*128,Z*128,0,0,0]
         JUMP[X*128,Y*128,Z*128]
         Add PTR,8
      End If 
   Else If C=4
      I=Peek(PTR+1)
      S=Peek(PTR+2)
      Add PTR,4
      If ST(S)>0
         If ST(I)<0
            ST(I)=-ST(I)
            CREATE[I,Td Position X(S),Td Position Y(S),Td Position Z(S),0,0,0]
         End If 
      End If 
   Else If C=5
      I=Peek(PTR+1)
      T=Peek(PTR+2)
      Add PTR,4
      SPT(I)=T
      SL(I)=T
   Else If C=6
      I=Peek(PTR+1)
      Add PTR,2
      If ST(I)>0
         If SS(I)>0
            JUMP[Td Position X(I),Td Position Y(I),Td Position Z(I)]
            Td Kill I
            ST(I)=-ST(I)
            SENERGY(I)=-1
         End If 
      End If 
   Else If C=7
      I=Peek(PTR+1)
      If ST(I)>0
         J=Peek(PTR+2)
         If ST(J)>0
            FACE[I,J,200,Td Range(I,J)]
            If Param<20
               Add PTR,4
            End If 
         End If 
      Else 
         Add PTR,4
      End If 
   Else If C=8
      SS(Peek(PTR+1))=Deek(PTR+2)
      Add PTR,4
   Else If C=9
      A=Deek(PTR+2)
      Poke PTR,2
      Doke PTR+2,SECS+A
   Else If C=10
      I=Peek(PTR+1)
      Add PTR,2
      BABBEL[I,""]
   Else If C=11
      I=Peek(PTR+1)
      T=Deek(PTR+2)
      Add PTR,4
      SENERGY(I)=T
   Else If C=12
      I=Peek(PTR+1)
      T=Deek(PTR+2)
      If SENERGY(I)<T
         Add PTR,4
      End If 
   Else If C=13
      I=Peek(PTR+1)
      J=Deek(PTR+2)
      K=Peek(PTR+4)
      If SENERGY(I)>0
         If SENERGY(K)>0
            If Td Range(I,K)<J*128
               Add PTR,6
            End If 
         End If 
      End If 
   Else If C=14
      I=Peek(PTR+1)
      PTR=0
   Else If C=15
      I=Peek(PTR+1)
      T=Peek(PTR+2)
      Add PTR,4
      SC(I)=T
   Else If C=16
      L=Peek(PTR+1)
      I$=Peek$(PTR+2,L)
      INFO[I$]
      Add PTR,L+2
   Else If C=17
      I=Peek(PTR+1)
      L=Peek(PTR+3)
      I$=Peek$(PTR+4,L)
      SCARGO$(I)=I$
      Add PTR,L+4
   Else If C=18
      I=Peek(PTR+1)
      J=Deek(PTR+2)
      SMISS(I)=J
      Add PTR,4
   Else If C=19
      I=Peek(PTR+1)
      J=Deek(PTR+2)
      SSKILL(I)=J
      Add PTR,4
   Else If C=20
      A=(SMISS(Peek(PTR+1)) and Deek(PTR+2))
      If A>0
         Add PTR,6
         Pop Proc
      Else 
         Add PTR,4
         Add PTR,-Deek(PTR)
      End If 
   End If 
End Proc

Rem Treffertests 
Rem=============================== 

Procedure HIT[B,I]
   Shared DEAD,HITS,OWNHITS,TRAITOR
   If SENERGY(I)<=0 Then Pop Proc
   OX=OX(B)
   OY=OY(B)
   OZ=OZ(B)
   D=Abs(Td Position X(I)-OX)
   If D>1500 Then Pop Proc
   Add D,Abs(Td Position Y(I)-OY)
   If D>1500 Then Pop Proc
   Add D,Abs(Td Position Z(I)-OZ)
   If D>1500 Then Pop Proc
   LOOSE=-OE(B)
   T=ST(I)
   For J=0 To TSA(T)-1
      X=Td World X(I,TSX(T,J),TSY(T,J),TSZ(T,J))
      Y=Td World Y
      Z=Td World Z
      D=Abs(X-OX)
      Add D,Abs(Y-OY)
      Add D,Abs(Z-OZ)
      If D<TSS(T,J)
         GLAREABS[X,Y,Z,3000]
         SPL[B,%10,3]
         OART(B)=0
         Add SSHIELD(I,J),LOOSE
         If I=0
            Paste Bob Rnd(320),Rnd(200),41
            BLAST[$A]
         End If 
         If OSOURCE(B)=0
            If SS(I)>35
               Td Move Rel I,OVX(B)/4,OVY(B)/4,OVZ(B)/4
               Td Angle Rel I,LOOSE*(Rnd(50)-25),-LOOSE*32,0
            End If 
         End If 
         If SSHIELD(I,J)<0
            If I=0
               BLAST[$A00]
            End If 
            BRONF[B,OX,OY,OZ,LOOSE*-16,I]
            Add SENERGY(I),SSHIELD(I,J)
            For K=0 To THA(T,J)
               X=Td World X(I,THX(T,J,K),THY(T,J,K),THZ(T,J,K))
               Y=Td World Y
               Z=Td World Z
               D=Abs(X-OX)
               Add D,Abs(Y-OY)
               Add D,Abs(Z-OZ)
               If D<THS(T,J,K)
                  Add SHULL(I,J,K),SSHIELD(I,J)
                  If SHULL(I,J,K)<0
                     SPL[I,%10,7]
                     BRONF[B,X,Y,Z,1000,I]
                     SPARKY[X,Y,Z,10,50]
                     DESTRUCT[I,THB(T,J,K)]
                  End If 
               End If 
            Next 
            SSHIELD(I,J)=0
            If I=0
               If SENERGY(I)>100
                  MESSAGE[50]
               Else 
                  MESSAGE[49]
               End If 
               DAMAGE
               DAMAGE
            End If 
         End If 
         If OSOURCE(B)=0
            If SC(I)=1
               Inc MYOUROWNHITS
               Add TRAITOR,-LOOSE
               If TRAITOR>190
                  SC(0)=2
                  INFO["Gedammter Räter!"]
               End If 
            End If 
            Inc MYOURHITS
         End If 
         SLASTHIT(I)=OSOURCE(B)
         FLAREABS[OX(B),OY(B),OZ(B),-LOOSE*15]
         If SENERGY(I)<=0
            If SC(I)=1
               Inc MOWNLOOSE
            Else 
               If OSOURCE(B)=0
                  Inc MYOURKILLS
                  Inc TKILLS(Abs(ST(I)))
               End If 
               Inc MENEMYLOOSE
            End If 
         End If 
         Pop Proc[B]
      End If 
   Next 
End Proc
Procedure CRASH[I]
   Shared DEAD,HITS
   OX=PX
   OY=PY
   OZ=PZ
   If SENERGY(I)<=0 Then Pop Proc
   If SS(I)>30 Then Pop Proc
   D=Abs(Td Position X(I)-OX)
   Add D,Abs(Td Position Y(I)-OY)
   Add D,Abs(Td Position Z(I)-OZ)
   If D>2000 Then Pop Proc
   USEDCHAN
   If(Param and %100)=0
      VECSUM[0,I]
      If Param>12000
         Sam Play 5
      End If 
   End If 
   T=ST(I)
   For J=0 To TSA(T)-1
      X=Td World X(I,TSX(T,J),TSY(T,J),TSZ(T,J))
      Y=Td World Y
      Z=Td World Z
      D=Abs(X-OX)
      Add D,Abs(Y-OY)
      Add D,Abs(Z-OZ)
      If D<TSS(T,J)
         OART(B)=0
         LOOSE=-SS(0)*5
         Add SSHIELD(I,J),LOOSE
         Add SSHIELD(0,0),LOOSE
         Td Angle Rel I,400,-400,0
         Add SENERGY(I),SSHIELD(I,J)
         SSHIELD(I,J)=0
         Add SENERGY(0),SSHIELD(0,0)
         SSHIELD(0,0)=0
         If SENERGY(I)<=0
            Inc DEAD
         End If 
         Pop Proc[B]
      End If 
   Next 
End Proc

Procedure RELSHIELDS[N]
   For I=0 To TSA(ST(N))-1
      If SSHIELD(N,I)<TSE(ST(N),I)
         Inc SSHIELD(N,I)
      End If 
   Next 
End Proc
Procedure POWERSHIELDS[N,P]
   For I=0 To TSA(ST(N))-1
      If SSHIELD(N,I)<TSE(ST(N),I)
         Add SSHIELD(N,I),P
      End If 
   Next 
End Proc

Rem Objekt-Module
Rem================================
Procedure DISTANCE[B]
   Shared PX,PY,PZ
   D=Abs(PX-OX(B))
   Add D,Abs(PY-OY(B))
   Add D,Abs(PZ-OZ(B))
End Proc[D]
Procedure LASERBEAM
   Shared I,X,Y,Z,X1,X2,Y1,Y2,XD,YD,YP,XP
   X=OVX(I)
   Y=OVY(I)
   Z=OVZ(I)
   Dec OC(I)
   If OC(I)=1
      OART(I)=0
   End If 
   X2=Td Screen X(OX(I)-X,OY(I)-Y,OZ(I)-Z)
   Y2=Td Screen Y
   
   Add OX(I),X
   Add OY(I),Y
   Add OZ(I),Z
   T=OT(I)
   If OL(I)>-1
      HIT[I,OL(I)]
   End If 
   
   If X2<0 Then Pop Proc
   If Y2<0 Then Pop Proc
   
   X1=Td Screen X(OX(I),OY(I),OZ(I))
   If X1<0 Then Pop Proc
   Y1=Td Screen Y
   If Y1<0 Then Pop Proc
   
   XD=X2-X1
   YD=Y2-Y1
   
   D=Abs(XD)+Abs(YD)
   
   If D>20
      XP=(7*X1)/8+X2/8
      YP=(7*Y1)/8+Y2/8+1
      If D>50
         Ink T+2
         Polygon X1,Y1 To XP+YD/32,YP-XD/32 To X2,Y2 To XP-YD/32,YP+XD/32
      End If 
      Ink T+1
      Polygon X1,Y1 To XP+YD/64,YP-XD/64 To X2,Y2 To XP-YD/64,YP+XD/64
   End If 
   Ink T
   If D>2
      Draw X1,Y1 To X2,Y2
   Else 
      Plot X1,Y1
   End If 
End Proc
Procedure HOMING
   Shared I
   T=OL(I)
   S=Abs(OVX(I))+Abs(OVY(I))+Abs(OVZ(I))
   M=$100000/OE(I)
   S=S*256
   If SENERGY(T)>0
      OVX(I)=(OVX(I)*$9000+(Td Position X(T)-OX(I))*M)/S
      OVY(I)=(OVY(I)*$9000+(Td Position Y(T)-OY(I))*M)/S
      OVZ(I)=(OVZ(I)*$9000+(Td Position Z(T)-OZ(I))*M)/S
   Else 
      OART(I)=0
   End If 
   ROCKET
   RADARROCKET[I]
End Proc
Procedure OBDRAW
   Shared I
   Dec OC(I)
   If OC(I)=1
      OART(I)=0
   End If 
   Add OX(I),OVX(I)
   Add OY(I),OVY(I)
   Add OZ(I),OVZ(I)
   X=Td Screen X(OX(I),OY(I),OZ(I))
   Y=Td Screen Y
   If X>0 and Y>0
      If OS(I)>0
         SIZE[OX(I),OY(I),OZ(I),OS(I)]
         OS(I)=OS(I)-(OS(I)/OC(I)*4)
         T=OT(I)+Param
      Else If OS(I)<0
         SIZEB[OX(I),OY(I),OZ(I),-OS(I)]
         OS(I)=OS(I)-(OS(I)/OC(I)*4)
         T=OT(I)+Param
      Else 
         Inc OT(I)
         T=OT(I)
      End If 
      Paste Bob X-HSPX(T),Y-HSPY(T),T
   End If 
End Proc
Procedure ROCKET
   Shared X,Y,Z,X1,X2,Y1,Y2,XD,YD,YP,XP,I,LROS
   RADARROCKET[I]
   Dec OC(I)
   If OC(I)=1
      OART(I)=0
   End If 
   X=OVX(I)
   Y=OVY(I)
   Z=OVZ(I)
   
   X2=Td Screen X(OX(I)-3*X,OY(I)-3*Y,OZ(I)-3*Z)
   Y2=Td Screen Y
   
   Add OX(I),X
   Add OY(I),Y
   Add OZ(I),Z
   
   If OL(I)>-1 : HIT[I,OL(I)] : End If 
   
   If X2<0 Then Pop Proc
   If Y2<0 Then Pop Proc
   LROS=I
   X1=Td Screen X(OX(I),OY(I),OZ(I))
   If X1<0 Then Pop Proc
   Y1=Td Screen Y
   If Y1<0 Then Pop Proc
   XD=X2-X1
   YD=Y2-Y1
   D=Abs(XD)+Abs(YD)
   If D>15
      XP=((3*X1)+X2)/4
      YP=((3*Y1)+Y2)/4
      LPX=XP+YD/32
      LPY=YP-XD/32
      RPX=XP-YD/32
      RPY=YP+XD/32
      Ink 12
      Polygon X1,Y1 To LPX,LPY To RPX,RPY
      Ink 16
      Polygon X2,Y2 To LPX,LPY To RPX,RPY
      S=D/20
      T=Max(64+S-4,63)
      Paste Bob XP-HSPX(T),YP-HSPY(T),T
      T=64+S
      Bob 1,XP,YP,T
      Bob Draw 
   Else 
      If D>1
         Ink 16
         Draw X1,Y1 To X2,Y2
      End If 
      Ink 1
      Plot X1,Y1
   End If 
   
   For J=0 To 15
      If OART(J)>0
         D=Abs(OX(J)-OX(I))
         Add D,Abs(OX(J)-OX(I))
         Add D,Abs(OX(J)-OX(I))
         If D<100
            BRONF[I,0,0,0,OE(I)*4,J]
            OART(J)=0
         End If 
      End If 
   Next 
End Proc
Procedure SPARK
   Shared I
   Dec OT(I)
   X2=Td Screen X(OX(I),OY(I),OZ(I))
   If X2<0 Then OART(I)=0 : Pop Proc
   Y2=Td Screen Y
   If Y2<0 Then OART(I)=0 : Pop Proc
   Add OX(I),OVX(I)
   Add OY(I),OVY(I)
   Add OZ(I),OVZ(I)
   X1=Td Screen X(OX(I),OY(I),OZ(I))
   Y1=Td Screen Y
   If X1>0 and Y1>0
      Ink OT(I)/2
      Draw X1,Y1 To X2,Y2
   End If 
   Dec OC(I)
   If OC(I)=1
      OART(I)=0
   End If 
End Proc
Procedure JUMPGATE
   Shared I
   X=OX(I)
   Y=OY(I)
   Z=OZ(I)
   S=Min(OC(I)*50000/Td Bearing R(0,X,Y,Z),200)
   X=Td Screen X(X,Y,Z)
   Y=Td Screen Y
   If X>0 and Y>0
      Ink 30
      For N=1 To 10
         DX=Rnd(S+1)-S/2
         DY=Rnd(S+1)-S/2
         Ink 25
         MX=X+DX/2
         MY=Y+DY/2
         X1=MX+DY/16
         Y1=MY-DX/16
         X2=MX-DY/16
         Y2=MY+DX/16
         Polygon X,Y To X1,Y1 To X+DX,Y+DY To X2,Y2
         Ink 30
         Plot X+DX,Y+DY
      Next 
   End If 
   RADARROCKET[I]
   Dec OC(I)
   If OC(I)=1
      OART(I)=0
   End If 
End Proc
Procedure SIZE[X,Y,Z,SIZE]
   Shared PX,PY,PZ
   D=Abs(PX-X)
   Add D,Abs(PY-Y)
   Add D,Abs(PZ-Z)
   SIZE=Max(1,SIZE)
   D=D/SIZE
   D=Min(D,7)
   D=7-D
End Proc[D]
Procedure SIZEB[X,Y,Z,SIZE]
   Shared PX,PY,PZ
   D=Abs(PX-X)
   Add D,Abs(PY-Y)
   Add D,Abs(PZ-Z)
   SIZE=Max(1,SIZE)
   D=D/SIZE
   D=Min(D,15)
   D=15-D
End Proc[D]
Procedure FLARE[I,X,Y,Z,S]
   If Td Visible(I)
      X=Td World X(I,X,Y,Z)
      Y=Td World Y
      Z=Td World Z
      XS=Td Screen X(X,Y,Z)
      YS=Td Screen Y
      If XS>0 and YS>0
         SIZEB[X,Y,Z,S/2]
         T=63+Param/3
         Paste Bob XS-HSPX(T),YS-HSPY(T),T
         T=63+Param
         Bob 1,XS,YS,T
         Bob Draw 
      End If 
   End If 
End Proc
Procedure FLAREABS[X,Y,Z,S]
   XS=Td Screen X(X,Y,Z)
   YS=Td Screen Y
   If XS>0 and YS>0
      SIZEB[X,Y,Z,S/2]
      T=64+Param/3
      Paste Bob XS-HSPX(T),YS-HSPY(T),T
      T=64+Param
      Bob 1,XS,YS,T
      Bob Draw 
   End If 
End Proc
Procedure GLAREABS[X,Y,Z,S]
   XS=Td Screen X(X,Y,Z)
   YS=Td Screen Y
   If XS>0 and YS>0
      SIZEB[X,Y,Z,S/2]
      T=64+Param
      Bob 1,XS,YS,T
      Bob Draw 
   End If 
End Proc
Procedure DEBRISREL[I,X,Y,Z,N]
   If Td Visible(I)
      X=Td World X(I,X,Y,Z)
      Y=Td World Y
      Z=Td World Z
      XS=Td Screen X(X,Y,Z)
      YS=Td Screen Y
      If XS>0 and YS>0
         SIZE[X,Y,Z,400]
         T=N+Param
         Paste Bob XS-HSPX(T),YS-HSPY(T),T
      End If 
   End If 
End Proc[O]
Procedure JUMP[X,Y,Z]
   I=OPTR+7
   OX(I)=0
   OY(I)=0
   OZ(I)=0
   OX(I)=X
   OY(I)=Y
   OZ(I)=Z
   OC(I)=50
   OART(I)=6
End Proc

Rem Pyro-Technik 
Rem==================================
Procedure BUMM
   Shared I
   X=Td Position X(I)
   Y=Td Position Y(I)
   Z=Td Position Z(I)
   SPARKY[X,Y,Z,20,50]
   SENERGY(I)=0
   Td Kill I
   ST(I)=-ST(I)
   N=SP(I)
   OART(N)=1
   OC(N)=10
   OS(N)=-1000
   OT(N)=1
   OX(N)=X
   OY(N)=Y
   OZ(N)=Z
   OVX(N)=0
   OVY(N)=0
   OVZ(N)=0
   SPL[I,%1111,7]
End Proc
Procedure BANG
   Shared I
   X=Td Position X(I)
   Y=Td Position Y(I)
   Z=Td Position Z(I)
   BLAST[$FB8]
   XS=Td Screen X(X,Y,Z)
   YS=Td Screen Y
   If XS>0 and YS>0
      N=41
      Paste Bob XS-30,YS-30,N
      Ink 24
      Polygon 0,YS To XS,YS+5 To 320,YS To XS,YS-5
   End If 
   For J=19 To 20
      If ST(J)<1
         SENERGY(J)=10+Rnd(30)
         Td Object J,"spl",X,Y,Z,Rnd(32000),Rnd(32000),Rnd(32000)
         ST(J)=9
         SS(J)=120
         Inc W
      End If 
   Next 
   BUMM
End Proc
Procedure ABWRACK
   Shared I
   X=Td Position X(I)
   Y=Td Position Y(I)
   Z=Td Position Z(I)
   A=Td Attitude A(I)
   B=Td Attitude B(I)
   C=Td Attitude C(I)
   Flash 0,"(CCC,1)(AAA,1)(888,3)(555,3)(333,3)(000,32000)"
   BROLL[X,Y,Z,1000]
   XS=Td Screen X(X,Y,Z)
   YS=Td Screen Y
   If XS>0 and YS>0
      Ink 24
      Polygon 0,YS To XS,YS+5 To 320,YS To XS,YS-5
   End If 
   SENERGY(I)=200
   ST(I)=6
   SS(I)=40
End Proc
Procedure ZER
   Shared I
   X=Td Position X(I)
   Y=Td Position Y(I)
   Z=Td Position Z(I)
   A=Td Attitude A(I)
   B=Td Attitude B(I)
   C=Td Attitude C(I)
   For J=19 To 20
      If ST(J)<1
         SENERGY(J)=25-(J=19)*4
         Td Object J,Lower$(NAME$(ST(I)))+"spl",X,Y,Z,A-2000+W*4000,B,C-2000+W*4000
         ST(J)=9
         SS(J)=120
         Inc W
      End If 
   Next 
   BUMM
End Proc
Procedure PLASMA[I,X,Y,Z,V,T]
   OART(I)=1
   OT(I)=T
   OX(I)=X
   OY(I)=Y
   OZ(I)=Z
   OVX(I)=VX+Rnd(V)-V/2
   OVY(I)=VY+Rnd(V)-V/2
   OVZ(I)=VZ+Rnd(V)-V/2
   OL(I)=-1
   OC(I)=7
   OS(I)=1
End Proc
Procedure DESTRUCT[I,B]
   For J=0 To 5
      Td Surface "faces",0,J To I,B,J,0
   Next 
End Proc
Procedure DIE
   I=0
   X=Td Position X(I)
   Y=Td Position Y(I)
   Z=Td Position Z(I)
   A=Td Attitude A(I)
   B=Td Attitude B(I)
   C=Td Attitude C(I)
   SENERGY(I)=-1
   ST(0)=5
   For J=19 To 20
      If ST(J)<1
         SENERGY(J)=25
         Td Object J,Lower$(NAME$(ST(I)))+"spl",X,Y,Z,A-2000+W*4000,B,C-2000+W*4000
         ST(J)=9
         SS(J)=120
         Inc W
      End If 
   Next 
   SP(19)=0
   SP(20)=1
   Sam Play 7
   Screen Hide 1
   Td Forward 0,-400
End Proc
Procedure BROLL[X,Y,Z,S]
   XS=Td Screen X(X,Y,Z)
   YS=Td Screen Y
   If XS>0 and YS>0
      SIZE[X,Y,Z,S]
      T=1+Param
      Paste Bob XS-HSPX(T),YS-HSPY(T),T
   End If 
End Proc
Procedure BRONF[I,X,Y,Z,S,B]
   OC(I)=8
   If X<>0
      OX(I)=X
      OY(I)=Y
      OZ(I)=Z
   End If 
   OART(I)=1
   OS(I)=S
   OT(I)=1
   If B>0
      OVX(I)=(SVX(B)*SS(B))/$1000
      OVY(I)=(SVY(B)*SS(B))/$1000
      OVZ(I)=(SVZ(B)*SS(B))/$1000
   End If 
End Proc
Procedure SPARKY[X,Y,Z,S,V]
   If Td Screen X(X,Y,Z)<0 Then Pop Proc
   For J=0 To S
      N=OPTR+J+8
      OT(N)=50-Rnd(4)
      OART(N)=3
      OX(N)=X
      OY(N)=Y
      OZ(N)=Z
      OVX(N)=Rnd(V)-V/2
      OVY(N)=Rnd(V)-V/2
      OVZ(N)=Rnd(V)-V/2
      OC(N)=OT(N)-34
   Next 
End Proc
Procedure SPARKYREL[J,ANZ,V]
   If Not Td Visible(J) Then Pop Proc
   X=Td Position X(J)
   Y=Td Position Y(J)
   Z=Td Position Z(J)
   Td Forward J,100
   VX=Td Position X(J)-X
   VY=Td Position Y(J)-Y
   VZ=Td Position Z(J)-Z
   Td Forward J,-100
   For J=0 To ANZ
      I=OPTR+J+8
      OART(I)=3
      OT(I)=50-Rnd(6)
      OX(I)=X
      OY(I)=Y
      OZ(I)=Z
      OVX(I)=VX+Rnd(V)-V/2
      OVY(I)=VY+Rnd(V)-V/2
      OVZ(I)=VZ+Rnd(V)-V/2
      OL(I)=-1
      OC(I)=OT(I)-34
   Next 
End Proc
Procedure BROCK[N,X,Y,Z,V]
   OART(N)=1
   OT(N)=2
   OS(N)=300
   OX(N)=X
   OY(N)=Y
   OZ(N)=Z
   OVX(N)=Rnd(V)-V/2
   OVY(N)=Rnd(V)-V/2
   OVZ(N)=Rnd(V)-V/2
   OC(N)=14
End Proc

Procedure BLAST[C]
   For I=0 To 31
      Colour I,Colour(I) or C
   Next 
   Fade 3 To 2
End Proc
Rem Modell-Module
Rem==================================
Procedure SEARCHENEMY[N]
   Shared RELEVANZ()
   For J=0 To SANZ
      I=Rnd(SANZ)
      If SENERGY(I)>0
         If SC(I)<>SC(N)
            If Td Range(I,N)<15000
               If(RELEVANZ(I) and 4)=0 or SC(N)=0
                  Pop Proc[I]
               End If 
            End If 
         End If 
      End If 
   Next 
End Proc[-1]
Procedure WINGMAN[I]
   Shared ZIEL,BABBEL
   If ZIEL=0
      If SL(I)
         BABBEL[12,NAME$(ST(I))]
      End If 
      SL(I)=0
   Else If ZIEL>0
      If ZIEL<>SL(I)
         If SC(ZIEL)<>1
            BABBEL[12,NAME$(ST(I))]
            SL(I)=ZIEL
         Else 
            BABBEL[13,NAME$(ST(I))]
         End If 
      End If 
   End If 
   
   If SL(I)>-1
      If SENERGY(SL(I))<1
         SEARCHENEMY[I]
         If Param>0
            SL(I)=Param
         Else 
            SL(I)=0
         End If 
      End If 
   Else 
      SL(I)=0
   End If 
   If SLASTHIT(I)=0
      BABBEL[17,NAME$(ST(I))]
   End If 
   SLASTHIT(I)=-1
End Proc
Procedure FIGHTER
   Shared I
   If SC(I)=1 and SPT(I)=0
      WINGMAN[I]
   Else 
      If SSHIELD(I,0)<=1
         SM(I)=0
         If SLASTHIT(I)>-1
            If SENERGY(I)<70
               If SC(I)=1
                  BABBEL[15,NAME$(ST(I))]
               End If 
            End If 
         End If 
         SLASTHIT(I)=-1
      End If 
      If SL(I)>-1
         If SENERGY(SL(I))>0
            Pop Proc
         End If 
      End If 
      SEARCHENEMY[I]
      SL(I)=Param
      If Param=-1
         If SPT(I)>-1
            If SENERGY(SPT(I))>0
               SL(I)=SPT(I)
            End If 
         End If 
      End If 
   End If 
End Proc
Procedure BATTLESHIP
   Shared I
   
   S=SPT(I)
   T=SL(I)
   M=SM(I)
   
   If S>-1
      If SENERGY(S)>0
         R=Td Range(S,I)
         FACE[I,S,400,R]
         If Param<200
            If R<10000
               SL(I)=S
               SM(I)=2
               If R<6000
                  SS(I)=20-(R-4000)/128
               End If 
            Else 
               SS(I)=20
               SEARCHENEMY[I]
               T=Param
               If T>-1
                  If SENERGY(T)>0
                     SL(I)=T
                  End If 
                  SM(I)=1
               Else 
                  SM(I)=0
               End If 
            End If 
         End If 
         Pop Proc
      End If 
   Else 
      If SSHIELD(I,0)<100
         Td Angle Rel I,0,0,200
      End If 
   End If 
   If T>-1
      If SENERGY(T)<=0
      Else If Td Range(I,T)>4000
      Else 
         Pop Proc
      End If 
   End If 
   SEARCHENEMY[I]
   T=Param
   If T>-1
      If SENERGY(T)>0
         SL(I)=T
         SM(I)=1
      Else 
         SM(I)=0
      End If 
   Else 
      SM(I)=0
   End If 

End Proc
Procedure WRACK
   Shared I
   Dec SENERGY(I)
   Td Angle Rel I,0,0,6000
   Td Move Rel I,SVX(I)/64,SVY(I)/64,SVZ(I)/64
End Proc
Procedure MOV
   Shared I
   If SS(I)>0
      Td Forward I,SS(I)
   End If 
End Proc

Procedure SPLITTER
   Shared I
   Dec SENERGY(I)
   DEBRISREL[I,0,0,0,79]
   Td Angle Rel I,0,0,(24-SENERGY(I))*7000
   Td Forward I,SS(I)
   Td Angle Rel I,0,0,(25-SENERGY(I))*-7000
End Proc

Procedure TIE
   Shared I,RAND
   If SSHIELD(I,0)>0
      GSV[I]
   Else 
      WRACK
      Pop Proc
   End If 
   FIGHTER
   RELSHIELDS[I]
   TARGET=SL(I)
   If TARGET=-1 Then TARGET=0
   R=Td Range(I,TARGET)
   If R>2000 and SM(I) and SSHIELD(I,0)>60
      FACE[I,TARGET,1000,R]
      F=R/400
      If SC(I)<>SC(TARGET) and R<10000 and Param<600
         If RAND>3
            If OART(SP(I)+SR(I))=0
               WEAPONREL[SP(I)+SR(I),I,30,TARGET,20,-30,0,F]
               Add SR(I),1,0 To 1
            End If 
         End If 
      End If 
      SS(I)=Min(Max((R-3000)/64+SS(TARGET),70),130)
      If SLASTHIT(I)>-1
         SLASTHIT(I)=-1
         SM(I)=0
      End If 
      Td Forward I,SS(I)
   Else 
      Td Forward I,90
      SS(I)=90
      If SSHIELD(I,0)>80
         If R>8000
            SM(I)=-1
         Else 
            SM(I)=0
         End If 
         DEFACE[I,TARGET,700]
      Else 
         EVASIVE[I,700]
      End If 
   End If 
End Proc
Procedure AWING
   Shared I
   GSV[I]
   RELSHIELDS[I]
   FIGHTER
   TARGET=SL(I)
   If TARGET=-1 Then TARGET=0
   R=Td Range(TARGET,I)
   F=R/400
   If SM(I) and SSHIELD(I,0)>50 and R>2000
      FACE[I,TARGET,900,R]
      If SR(I) mod 8=0
         If SC(I)<>SC(TARGET) and R<9000 and Param<600
            S=SR(I)/8+SP(I)
            If S and %1
               If OART(S)=0
                  WEAPONREL[S,I,40,TARGET,-60,0,0,F]
               End If 
            Else 
               If OART(S)=0
                  WEAPONREL[S,I,40,TARGET,60,0,0,F]
               End If 
            End If 
         End If 
      End If 
      Add SR(I),1,0 To 31
      SS(I)=Min(Max((R-4000)/64+SS(TARGET),70),100)
      Td Forward I,SS(I)
   Else 
      Td Forward I,90
      SS(I)=90
      If SSHIELD(I,0)>90
         If R>7000
            SM(I)=-1
         Else 
            SM(I)=0
         End If 
         DEFACE[I,TARGET,500]
      Else 
         EVASIVE[I,500]
      End If 
   End If 
End Proc
Procedure HWING
   Shared SPEED,I
   GSV[I]
   POWERSHIELDS[I,2]
   TYP=0
   FIGHTER
   TARGET=SL(I)
   If TARGET=-1 Then TARGET=0
   R=Td Range(TARGET,I)
   F=R/400
   If R>2500 and SM(I)
      SS(I)=80
      FACE[I,TARGET,1000,R]
      P=Param
      If(COUNT mod 4=0)
         S=SP(I)+SR(I)
         W=SR(I) mod 4
         If OART(S)=0 and SC(I)<>SC(TARGET) and R<12000 and P<500
            If(TARGET=SPT(I) or SPT(I)<1) and SWEAPON(I)>3
               If OART(S+4)<=0
                  ROCKETLAUNCH[S+4,I,TARGET,300]
                  SM(I)=0
               End If 
            Else 
               If W=0
                  WEAPONREL[S,I,30,TARGET,60,-20,0,F]
               Else If W=1
                  WEAPONREL[S,I,30,TARGET,-60,-20,0,F]
               Else If W=2
                  WEAPONREL[S,I,30,TARGET,60,20,0,F]
               Else If W=3
                  WEAPONREL[S,I,30,TARGET,-60,20,0,F]
               End If 
               Add SR(I),1,0 To 7
            End If 
         End If 
      End If 
      SS(I)=Min(Max((R-3000)/64+SS(TARGET),60),90-Min(P,40000)/10000)
      Td Forward I,SS(I)
      If SLASTHIT(I)>-1
         SLASTHIT(I)=-1
         SM(I)=0
      End If 
   Else 
      Td Forward I,90
      SS(I)=90
      If SSHIELD(I,0)>250
         DEFACE[I,TARGET,500]
         If R>6000
            SM(I)=-1
         Else 
            SM(I)=0
         End If 
      Else 
         EVASIVE[I,1000]
      End If 
   End If 
   '   If Td View Z(I,PX,PY,PZ)<-160
   '      FLARE[I,-100,50,-160,700] 
   '      FLARE[I,100,50,-160,700]
   '      FLARE[I,-100,-50,-160,700]
   '      FLARE[I,100,-50,-160,700] 
   '   End If 
End Proc
Procedure AMBOSS
   Shared I
   GSV[I]
   If Td Visible(I)
      If Td View Z(I,PX,PY,PZ)<-150
         FLARE[I,0,0,-150,600]
      End If 
   End If 
   FIGHTER
   TARGET=SL(I)
   RELSHIELDS[I]
   If TARGET<0 Then TARGET=0
   R=Td Range(TARGET,I)
   VECSUM[I,TARGET]
   Q=Max(Param,1)
   PR=Td Range(I,0)
   If SM(I)
      If R>Max(2500,Q/4)
         FACE[I,TARGET,700,R]
         P=Param
         S=SP(I)
         If SC(TARGET)<>SC(I)
            If(TARGET=SPT(I) or SPT(I)=0) and SWEAPON(I)>0
               If OART(S+4)<=0
                  If R<20000
                     ROCKETLAUNCH[S+2,I,TARGET,500]
                     SM(I)=0
                  End If 
               End If 
            Else 
               If SR(I)<0
                  If R<8000 and P<300
                     F=R/400
                     WEAPONREL[S,I,40,TARGET,-50,0,0,F]
                     WEAPONREL[S+1,I,40,TARGET,50,0,0,F]
                     SR(I)=F
                  End If 
               End If 
            End If 
         End If 
         SS(I)=Min(Max((R-3000)/64+SS(TARGET),60),80)
      Else 
         SM(I)=0
      End If 
   Else 
      SS(I)=70
      If R>7000
         SM(I)=-1
      Else 
         SM(I)=0
      End If 
      DEFACE[I,TARGET,300]
   End If 
   If SSHIELD(I,0)<100
      SM(I)=0
   End If 
   Dec SR(I)
   Td Forward I,SS(I)
End Proc
Procedure AMBOSSC
   Shared I
   If SHULL(I,1,0)<=0
      WRACK
      Pop Proc
   Else 
      GSV[I]
   End If 
   If Td View Z(I,PX,PY,PZ)<-150
      If SC(I)=0
         TURRET[SP(I)+2,I,0,40,-150,0,0]
      End If 
      If Td Visible(I)
         FLARE[I,0,0,-150,600]
      End If 
   End If 
   FIGHTER
   TARGET=SL(I)
   RELSHIELDS[I]
   If TARGET<0 Then TARGET=0
   R=Td Range(TARGET,I)
   VECSUM[I,TARGET]
   Q=Max(Param,1)
   PR=Td Range(I,0)
   
   If R>Max(2000,Q/4) and SM(I) and SSHIELD(I,0)>100
      F=R/400
      FACE[I,TARGET,700,P]
      S=SP(I)
      P=Param
      If SWEAPON(I)>0
         If OART(S+3)<=0
            If SC(TARGET)<>SC(I)
               If TARGET=SPT(I) or SPT(I)=0
                  If R<13000
                     ROCKETLAUNCH[S+2,I,TARGET,500]
                     SM(I)=0
                  End If 
               End If 
            End If 
         End If 
      End If 
      
      If SR(I)<0
         If SC(I)<>SC(TARGET) and R<8000 and P<300
            WEAPONREL[S,I,40,TARGET,-50,0,0,F]
            WEAPONREL[S+1,I,40,TARGET,50,0,0,F]
            SR(I)=F
         End If 
      End If 
      O=R-3000
      O=O/10
      S=O
      SS(I)=Min(Max(S,50),80)
      Td Forward I,SS(I)
   Else 
      Td Forward I,70
      SS(I)=70
      If SSHIELD(I,0)>100
         If R>6000
            SM(I)=-1
         Else 
            SM(I)=0
         End If 
      End If 
      DEFACE[I,TARGET,300]
   End If 
   Dec SR(I)
End Proc
Procedure AMBOSSE
   Shared I
   GSV[I]
   If Td Visible(I)
      If Td View Z(I,PX,PY,PZ)<-150
         FLARE[I,0,0,-150,600]
      End If 
   End If 
   FIGHTER
   TARGET=SL(I)
   RELSHIELDS[I]
   If TARGET<0 Then TARGET=0
   R=Td Range(TARGET,I)
   VECSUM[I,TARGET]
   Q=Max(Param,1)
   PR=Td Range(I,0)
   If R>Max(2000,Q/4) and SM(I) and SSHIELD(I,0)>100
      F=R/400
      FACE[I,TARGET,700,R]
      S=SP(I)
      P=Param
      If SR(I)<0
         If SC(I)<>SC(TARGET) and R<8000 and P<300
            WEAPONREL[SP(I),I,50,TARGET,40,-40,0,F+4]
            WEAPONREL[SP(I)+1,I,50,TARGET,-40,-40,0,F+4]
            WEAPONREL[SP(I)+2,I,50,TARGET,40,40,0,F+4]
            WEAPONREL[SP(I)+3,I,50,TARGET,-40,40,0,F+4]
            SR(I)=Max(F,20)
         End If 
      End If 
      O=R-3000
      O=O/10
      S=O
      SS(I)=Min(Max(S,40),85)
      Td Forward I,SS(I)
   Else 
      Td Forward I,80
      SS(I)=80
      If SSHIELD(I,0)>100
         If R>7000
            SM(I)=-1
         Else 
            SM(I)=0
         End If 
      End If 
      DEFACE[I,TARGET,300]
   End If 
   Dec SR(I)
End Proc

Procedure BRATHA
   Shared I
   GSV[I]
   FIGHTER
   If TARGET=-1 Then TARGET=0
   RELSHIELDS[I]
   R=Td Range(TARGET,I)
   If Td View Z(I,PX,PY,PZ)<-110
      FLARE[I,55,10,-110,600]
      FLARE[I,85,10,-110,600]
      TURRET=-1
   End If 
   If R>3000 and SM(I) and SSHIELD(I,0)>100
      F=R/400
      FACE[I,TARGET,600,R]
      O=R-7000
      O=O/10
      S=O
      SS(I)=Min(Max(S,15),50)
      Td Forward I,SS(I)
      If SR(I)<0 and SC(I)<>SC(TARGET) and R<12000
         WEAPONREL[SP(I),I,30,TARGET,-100,0,150,F+4]
         WEAPONREL[SP(I)+1,I,30,TARGET,-80,0,100,F+4]
         WEAPONREL[SP(I)+2,I,30,TARGET,60,0,100,F+4]
         WEAPONREL[SP(I)+3,I,30,TARGET,100,0,150,F+4]
         SR(I)=F+4
      End If 
   Else 
      Td Forward I,70
      SS(I)=70
      A=$7FFFF/R
      Td Angle Rel I,A,A+I*5,0
      If SC(I)<>SC(TARGET)
         If TURRET
            DTURRET[SP(I),I,80,0,-110,TARGET,0]
         End If 
      End If 
      If R>6000
         SM(I)=-1
      Else 
         SM(I)=0
      End If 
   End If 
   Dec SR(I)
End Proc
Procedure SENTINEL
   Shared SPEED,I
   GSV[I]
   FIGHTER
   TARGET=SL(I)
   If TARGET=-1 Then Pop Proc
   RELSHIELDS[I]
   R=Td Range(TARGET,I)
   If R>2000 and SM(I)
      F=R/400
      FACE[I,TARGET,400,R]
      If SC(I)<>SC(TARGET) and R<10000
         If Rnd(10)>6
            If OART(SP(I)+SR(I))=0
               WEAPONREL[SP(I)+SR(I),I,30,TARGET,20,-30,0,F+30]
               Add SR(I),1,0 To 1
            End If 
         End If 
      End If 
      O=R-4000
      O=O/10
      S=O
      SS(I)=Min(Max(S,40),70)
      Td Forward I,SS(I)
   Else 
      Td Forward I,80
      SS(I)=80
      If SC(I)<>SC(TARGET)
         TURRET[SP(I),I,0,0,0,TARGET,0]
      End If 
      If R>7000
         SM(I)=-1
      Else 
         SM(I)=0
      End If 
      DEFACE[I,TARGET,500]
   End If 
End Proc
Procedure SHUTTLE
   Shared I,RELEVANZ()
   GSV[I]
   FIGHTER
   TARGET=SL(I)
   
   If TARGET=-1 Then Pop Proc
   RELSHIELDS[I]
   R=Td Range(TARGET,I)
   Dec SR(I)
   VECSUM[I,TARGET]
   Q=Max(Param,1)
   
   If SM(I)=-1
      If R>Max(3500,Q/4)
         F=R/400
         FACE[I,TARGET,500,R]
         If(RELEVANZ(TARGET) and 4)=0
            If SR(I)<0 and SC(I)<>SC(TARGET) and R<9000 and Param<500
               WEAPONREL[SP(I),I,30,TARGET,-60,0,0,F+5]
               WEAPONREL[SP(I)+1,I,30,TARGET,60,0,0,F+5]
               WEAPONREL[SP(I)+2,I,30,TARGET,0,-60,0,F+5]
               SR(I)=F+4
            End If 
         Else 
            SM(I)=1
         End If 
         O=R-2000
         O=O/10
         S=O
         SS(I)=Min(Max(S,10),40)
         Td Forward I,SS(I)
      Else 
         SM(I)=0
      End If 
   Else If SM(I)=0
      Td Forward I,60
      SS(I)=60
      A=300000/Max(R,0)
      Td Angle Rel I,A,A,0
      If R>6000
         SM(I)=-1
      Else 
         SM(I)=0
      End If 
   Else If SM(I)=1
      If(RELEVANZ(TARGET) and 4)>0 and((SMISS(TARGET) and 4)=0)
         Td Forward I,50
         Td Face I,TARGET
         If R<200
            SM(I)=2
            SR(I)=300
         End If 
      End If 
   Else If SM(I)=2
      Dec SR(I)
      X=Td World X(TARGET,0,0,0)
      Y=Td World Y
      Z=Td World Z
      Td Move I,X,Y,Z
      Td Angle I,Td Attitude A(TARGET),Td Attitude B(TARGET),Td Attitude C(TARGET)
      If ST(TARGET)=0
         BUMM
      End If 
      If SR(I)<0
         BABBEL[25,NAME$(ST(I))]
         SMISS(TARGET)=SMISS(TARGET)+4
         SC(TARGET)=SC(I)
         SM(I)=0
         Td Move Rel I,10,-10,2
      End If 
   End If 
End Proc
Procedure FRACHTER
   Shared I
   RELSHIELDS[I]
   If SHULL(I,3,0)>0
      Td Forward I,SS(I)
   End If 
   If SENERGY(I)>500
   Else 
      Td Angle Rel I,0,0,200
   End If 
End Proc

Procedure FLAGGSCHIFF
   Shared I
   BATTLESHIP
   POWERSHIELDS[I,5]
   Td Angle Rel I,0,30,0
   If SL(I)>-1
      T=SL(I)
      '      For G=0 To 3
      Inc SR(I)
      SR(I)=SR(I) mod 4
      TURRET[SP(I)+SR(I),I,-0,500,-1500,T,0]
      TURRET[SP(I)+SR(I)+4,I,0,500,1500,T,0]
      If Param
         SL(I)=-1
      End If 
   Else 
      SEARCHENEMY[I]
      SL(I)=Param
      Td Forward I,SS(I)
   End If 
End Proc
Procedure KAMPFSCHIFF
   Shared I
   BATTLESHIP
   POWERSHIELDS[I,2]
   If SHULL(I,1,0)>0
      Td Forward I,SS(I)
      If Td View Z(I,PX,PY,PZ)<-1650
         S=SP(I)
         FLARE[I,-300,0,-1650,3000]
         FLARE[I,300,0,-1650,3000]
         FLARE[I,-100,100,-1650,3000]
         FLARE[I,100,100,-1650,3000]
         FLARE[I,-100,-100,-1650,3000]
         FLARE[I,100,-100,-1650,3000]
      End If 
   Else 
      SS(I)=0
   End If 
   M=SM(I)
   L=SL(I)
   If M=1
      X=Td View X(I,PX,PY,PZ)
      If X>200
         If SHULL(I,0,0)>0
            DTURRET[SP(I),I,400,0,50,L,0]
         End If 
         If SHULL(I,1,0)>0
            DTURRET[SP(I)+2,I,400,0,-750,L,0]
         End If 
      Else If X<-200
         If SHULL(I,0,1)>0
            DTURRET[SP(I)+0,I,-400,0,50,L,0]
         End If 
         If SHULL(I,1,1)>0
            DTURRET[SP(I)+2,I,-400,0,-750,L,0]
         End If 
      End If 
   Else If M=2
      If SHULL(I,0,0)>0
         DTURRET[SP(I),I,400,0,50,L,0]
      End If 
      If SHULL(I,1,0)>0
         DTURRET[SP(I)+2,I,400,0,-750,L,0]
      End If 
      If SHULL(I,0,1)>0
         DTURRET[SP(I)+4,I,-400,0,50,L,0]
      End If 
      If SHULL(I,1,1)>0
         DTURRET[SP(I)+6,I,-400,0,-750,L,0]
      End If 
   End If 
   
   Td Forward I,SS(I)
   
   If SENERGY(I)<1200
      If SSHIELD(I,0)<120
         Td Angle Rel I,70,130,110
         Add SR(I),1,0 To 3
         If OART(SR(I)+SP(I))<=0
            X=Td World X(I,Rnd(600)-300,Rnd(400)-200,Rnd(3000)-2000)
            Y=Td World Y
            Z=Td World Z
            SPL[I,%10,7]
            BRONF[SR(I)+SP(I),X,Y,Z,1500,I]
         End If 
      End If 
   End If 
   
End Proc
Procedure STREITSCHIFF
   Shared I
   BATTLESHIP
   POWERSHIELDS[I,2]
   If SHULL(I,1,0)>0
      Td Forward I,SS(I)
      If Td View Z(I,PX,PY,PZ)<-1250
         S=SP(I)
         FLARE[I,-300,0,-1250,3000]
         FLARE[I,300,0,-1250,3000]
         FLARE[I,-100,100,-1250,3000]
         FLARE[I,100,100,-1250,3000]
         FLARE[I,-100,-100,-1250,3000]
         FLARE[I,100,-100,-1250,3000]
      End If 
   Else 
      SS(I)=0
   End If 
   L=SL(I)
   M=SM(I)
   
   If M=1
      X=Td View X(I,PX,PY,PZ)
      If X>200
         If SHULL(I,0,0)>0
            DTURRET[SP(I),I,400,0,50,L,0]
         End If 
      Else If X<-200
         If SHULL(I,0,1)>0
            DTURRET[SP(I)+2,I,-400,0,50,L,0]
         End If 
      End If 
   Else If M=2
      If SHULL(I,0,0)>0
         DTURRET[SP(I),I,400,0,50,L,0]
      End If 
      If SHULL(I,0,1)>0
         DTURRET[SP(I)+2,I,-400,0,50,L,0]
      End If 
   Else 
   End If 
   If SENERGY(I)<1200
      If SSHIELD(I,0)<30
         Td Angle Rel I,70,130,110
         Add SR(I),1,0 To 3
         If OART(SR(I)+SP(I))<=0
            X=Td World X(I,Rnd(600)-300,Rnd(400)-200,Rnd(2000)-1000)
            Y=Td World Y
            Z=Td World Z
            SPL[I,%10,7]
            BRONF[SR(I)+SP(I),X,Y,Z,1000,I]
         End If 
      End If 
   End If 
End Proc

Procedure CORVETTE
   Shared I
   RELSHIELDS[I]
   If SENERGY(I)>300
      BATTLESHIP
      M=SM(I)
      If M=1 or M=2
         DTURRET[SP(I),I,0,-200,100,SL(I),0]
      End If 
      Td Forward I,SS(I)
   Else 
      SS(I)=0
      Td Angle Rel I,70,130,110
      If Rnd(10)>9
         X=Td Position X(I)
         Y=Td Position Y(I)
         Z=Td Position Z(I)
         SPARKY[X+Rnd(200)-100,Y+Rnd(200)-100,Z+Rnd(500)-250,10,50]
         BROLL[X+Rnd(200)-100,Y+Rnd(200)-100,Z+Rnd(500)-250,300]
         BROCK[SP(I),X,Y,Z,400]
         SPL[I,%10,7]
      End If 
   End If 
End Proc
Procedure CORVETTEC
   Shared I
   RELSHIELDS[I]
   If SENERGY(I)>500
      Td Forward I,SS(I)
   Else 
      Td Angle Rel I,70,130,110
      If Rnd(10)>9
         X=Td Position X(I)
         Y=Td Position Y(I)
         Z=Td Position Z(I)
         SPARKY[X+Rnd(200)-100,Y+Rnd(200)-100,Z+Rnd(500)-250,10,50]
         BROLL[X+Rnd(200)-100,Y+Rnd(200)-100,Z+Rnd(500)-250,300]
         BROCK[SP(I),X,Y,Z,400]
         SPL[I,%10,7]
      End If 
   End If 
End Proc
Procedure CORVETTEB
   Shared I
   RELSHIELDS[I]
   If SENERGY(I)>500
      BATTLESHIP
      M=SM(I)
      If M=1 or M=2
         DTURRET[SP(I),I,-100,0,-700,SL(I),0]
         DTURRET[SP(I)+2,I,100,0,-700,SL(I),0]
      End If 
      Td Forward I,SS(I)
   Else 
      Td Angle Rel I,70,130,110
      If Rnd(10)>9
         X=Td Position X(I)
         Y=Td Position Y(I)
         Z=Td Position Z(I)
         SPARKY[X+Rnd(200)-100,Y+Rnd(200)-100,Z+Rnd(500)-250,10,50]
         BROLL[X+Rnd(200)-100,Y+Rnd(200)-100,Z+Rnd(500)-250,300]
         BROCK[SP(I),X,Y,Z,400]
         SPL[I,%10,7]
      End If 
   End If 
End Proc

Procedure STATION
   Shared I
   POWERSHIELDS[I,4]
   If SENERGY(I)>6000
      Td Angle Rel I,0,200,0
      If SL(I)>-1
         M=Td View X(I,PX,PY,PZ)
         L=SL(I)
         For N=I+1 To I+3
            If ST(N)<1
               If SENERGY(N)<0
                  ST(N)=-ST(N)
                  CREATE[N,Td Position X(I),Td Position Y(I),Td Position Z(I),0,0,0]
                  SL(N)=L
               End If 
            End If 
         Next 
         DTURRET[SP(I),I,0,0,0,L,0]
         If Param
            SL(I)=-1
         End If 
      Else 
         SEARCHENEMY[I]
         SL(I)=Param
      End If 
   Else 
      Add SR(I),1,0 To 3
      If OART(SR(I)+SP(I))<=0
         X=Td World X(I,-700,Rnd(100),Rnd(100))
         Y=Td World Y
         Z=Td World Z
         SPL[I,%10,7]
         If Rnd(1)
            BRONF[SR(I)+SP(I),X,Y,Z,1000,I]
         Else 
            PLASMA[SP(I)+SR(I),X,Y,Z,300,30+Rnd(1)*3]
         End If 
      End If 
      If SENERGY(I)<4000
         If Rnd(100)>90
            X=Td Position X(I)
            Y=Td Position Y(I)
            Z=Td Position Z(I)
            SPARKY[X+Rnd(500)-300,Y+Rnd(200)-100,Z+Rnd(500)-300,10,200]
            Td Angle Rel I,200,300,200
            If SENERGY<2000
               Td Angle Rel I,500,500,500
            End If 
         End If 
      End If 
   End If 
End Proc
Procedure LASERMINE
   Shared I
   GSV[I]
   If SL(I)>-1
      TARGET=SL(I)
      If SENERGY(TARGET)>0
         R=Td Range(I,TARGET)
         S=SR(I)/4+SP(I)
         If OART(S)=0
            TURRET[S,I,0,0,0,TARGET,0]
         End If 
         Add SR(I),1,0 To 15
         If R>5000
            SL(I)=-1
         End If 
      Else 
         SL(I)=-1
      End If 
   Else 
      SEARCHENEMY[I]
      SL(I)=Param
   End If 
End Proc
Procedure TRäGER
   Shared I
   POWERSHIELDS[I,4]
   BATTLESHIP
   If SM(I)>0
      If SL(I)>-1
         TARGET=SL(I)
         If OART(SP(I))=0 and SC(I)<>SC(TARGET) and R<10000
            If SR(I) mod 3=0
               TURRET[SP(I)+SR(I)/3,I,0,-200,0,TARGET,0]
            End If 
            Add SR(I),1,0 To 29
         End If 
      End If 
   End If 
   Td Forward I,SS(I)
End Proc
Procedure SPINNE
   Shared I
   FIGHTER
   RELSHIELDS[I]
   TARGET=SL(I)
   If TARGET=-1 Then TARGET=0
   R=Td Range(TARGET,I)
   If R>3000 and SM(I)
      F=R/400-1
      FACE[I,TARGET,5000,R]
      If SC(I)<>SC(TARGET) and R<10000
         If Rnd(10)>6
            If OART(SP(I)+SR(I))=0
               WEAPONREL[SP(I)+SR(I),I,30,TARGET,20,-30,0,F+15]
               Add SR(I),1,0 To 2
            End If 
         End If 
      End If 
      O=R-7000
      O=O/10
      S=O
      SS(I)=Min(Max(S,20),80)
      If SLASTHIT(I)>-1
         SLASTHIT(I)=-1
         SM(I)=0
      End If 
      Td Forward I,SS(I)
   Else 
      Td Forward I,120
      SS(I)=120
      A=$FFFFF/Max(R,500)
      Td Angle Rel I,A,A+I*5,0
      If R>8000
         SM(I)=-1
      Else 
         SM(I)=0
      End If 
   End If 
End Proc
Procedure STERN
   Shared I
   POWERSHIELDS[I,4]
   GSV[I]
   Inc SWEAPON(I)
   If SL(I)>-1
      TARGET=SL(I)
      If SENERGY(TARGET)>0
         R=Td Range(I,TARGET)
         F=R/400
         FACE[I,TARGET,1000,R]
         If SR(I)<0
            If OART(SP(I))=0
               If Param<300
                  WEAPONREL[SP(I),I,50,TARGET,40,-80,0,F+4]
                  WEAPONREL[SP(I)+1,I,50,TARGET,-40,-80,0,F+4]
                  WEAPONREL[SP(I)+2,I,50,TARGET,40,80,0,F+4]
                  WEAPONREL[SP(I)+3,I,50,TARGET,-40,80,0,F+4]
                  SR(I)=10
               End If 
            End If 
         End If 
         If TARGET=SPT(I)
            If SWEAPON(I)>150
               SWEAPON(I)=0
               ROCKETLAUNCH[SP(I)+5,I,TARGET,500]
            End If 
         End If 
         If R>5000
            SL(I)=-1
         End If 
      Else 
         SL(I)=-1
      End If 
      Td Forward I,SS(I)
   Else 
      SEARCHENEMY[I]
      SL(I)=Param
   End If 
   Dec SR(I)
End Proc

Rem Bewegungstrategien 
Rem===================================== 
Procedure FACE[I,J,R,D]
   V=SS(J)*D/400
   If Td Range(I,0)>30000
      Td Face I,Td World X(J,0,0,V),Td World Y,Td World Z
      Pop Proc
   End If 
   X=Td World X(J,0,0,V)
   Y=Td World Y
   Z=Td World Z
   A=(Td Bearing A(I,X,Y,Z)+$FFFF) mod $FFFF-Td Attitude A(I)
   B=(Td Bearing B+$FFFF) mod $FFFF-Td Attitude B(I)
   H=Abs(A)+Abs(B)
   A=Min(Max(A,-R),R)
   B=Min(Max(B,-R),R)
   Td Angle Rel I,A,B,0
End Proc[H]
Procedure DEFACE[I,J,R]
   X=Td Position X(J)
   Y=Td Position Y(J)
   Z=Td Position Z(J)
   A=Td Bearing A(I,X,Y,Z)
   B=Td Bearing B
   TA=Td Attitude A(I)
   TB=Td Attitude B(I)
   A=(A+$7FFF) mod $FFFF
   B=(B+$7FFF) mod $FFFF
   A=A-TA
   B=B-TB
   A=Min(Max(A,-R),R)
   B=Min(Max(B,-R),R)
   Td Angle Rel I,A,B,0
End Proc
Procedure EVASIVE[I,R]
   R=R/(4-LEVEL)
   Td Angle Rel I,R,-R,0
End Proc

Rem Waffensysteme
Rem ==================================== 
Procedure TURRET[I,D,X,Y,Z,ZIEL,T]
   If OART(I)>0 Then Pop Proc[0]
   If SENERGY(ZIEL)<=0 Then Pop Proc[-1]
   X=Td World X(D,X,Y,Z)
   Y=Td World Y
   Z=Td World Z
   FLAREABS[X,Y,Z,1000]
   R=Td Bearing R(ZIEL,X,Y,Z)
   If R>20000 Then Pop Proc[-1]
   R=R/400
   R=Max(1,R)
   DX=(Td World X(ZIEL,0,0,SS(ZIEL)*R)-X)/R
   DY=(Td World Y-Y)/R
   DZ=(Td World Z-Z)/R
   R=Max(R,1)
   SPL[D,%10,2]
   OART(I)=2
   OT(I)=27
   OX(I)=X+DX
   OY(I)=Y+DY
   OZ(I)=Z+DZ
   OE(I)=30
   OL(I)=ZIEL
   OVX(I)=DX
   OVY(I)=DY
   OVZ(I)=DZ
   OC(I)=Max(R+4,10)+Rnd(2)
   OSOURCE(I)=D
End Proc[0]
Procedure DTURRET[N,D,X,Y,Z,ZIEL,T]
   If OART(N)>0 Then Pop Proc[0]
   If SENERGY(ZIEL)<=0 Then Pop Proc[-1]
   X=Td World X(D,X,Y,Z)
   Y=Td World Y
   Z=Td World Z
   FLAREABS[X,Y,Z,1000]
   R=Td Bearing R(ZIEL,X,Y,Z)
   If R>20000 Then Pop Proc[-1]
   R=R/400
   R=Max(1,R)
   DX=(Td World X(ZIEL,0,0,SS(ZIEL)*R)-X)/R
   DY=(Td World Y-Y)/R
   DZ=(Td World Z-Z)/R
   R=Max(R,1)
   SPL[D,%10,2]
   For I=N To N+1
      OART(I)=2
      OT(I)=27
      OX(I)=X+DX
      OY(I)=Y+DY+100*(N=I)
      OZ(I)=Z+DZ
      OE(I)=30
      OL(I)=ZIEL
      OVX(I)=DX
      OVY(I)=DY
      OVZ(I)=DZ
      OC(I)=Max(R+4,10)+Rnd(2)
      OSOURCE(I)=D
   Next 
End Proc[0]
Procedure ROCKETLAUNCH[I,J,T,POWER]
   If OART(I)>0 Then Pop Proc
   OART(I)=4
   Dec SWEAPON(J)
   OE(I)=POWER
   OX(I)=Td Position X(J)
   OY(I)=Td Position Y(J)
   OZ(I)=Td Position Z(J)
   OC(I)=150
   OSOURCE(I)=J
   OL(I)=T
   If T=0
      MESSAGE[51]
   End If 
   Td Forward J,80
   OVX(I)=Td Position X(J)-OX(I)
   OVY(I)=Td Position Y(J)-OY(I)
   OVZ(I)=Td Position Z(J)-OZ(I)
   Td Forward J,-80
   SPL[J,%100,8]
End Proc
Procedure WEAPONREL[I,J,P,T,X,Y,Z,D]
   OART(I)=2
   If SC(J)=1
      OT(I)=2
      SPL[I,1,1]
   Else 
      OT(I)=5
      SPL[I,1,2]
   End If 
   OX(I)=Td World X(J,X,Y,Z+400)
   OY(I)=Td World Y
   OZ(I)=Td World Z
   OVX(I)=Td World X(J,X,Y,Z+800)-OX(I)
   OVY(I)=Td World Y-OY(I)
   OVZ(I)=Td World Z-OZ(I)
   OL(I)=T
   OC(I)=D+7
   OE(I)=P
   OSOURCE(I)=J
End Proc
Procedure SHOT[N,P]
   Shared SHOT,CHEAT,BLASTER,ROUNDS,STATUS()
   If N<STATUS(0)/2 Then Pop Proc
   Inc MYOURFIRED
   Inc SHOT
   SHOT=SHOT mod 16
   Add BLASTER,-P
   
   L=60-120*(N and 1)
   H=-30+30*(N and 2)
   
   I=SHOT
   
   OT(I)=2
   OART(I)=2
   OX(I)=Td World X(0,L,H,500)
   OY(I)=Td World Y
   OZ(I)=Td World Z
   OVX(I)=Td World X(0,L,H,900)-OX(I)
   OVY(I)=Td World Y-OY(I)
   OVZ(I)=Td World Z-OZ(I)
   OC(I)=30
   OE(I)=P
   OL(I)=-1
End Proc
Procedure LASERFIRE
   Shared WEPCON,LASER,RELOAD
   Volume %1,63
   Sam Play %1,1
   Inc LASER
   LASER=LASER mod 8
   If WEPCON=1
      SHOT[LASER mod 4,50]
      RELOAD=3
   Else If WEPCON=2
      If LASER and 1
         SHOT[0,40]
         SHOT[3,40]
      Else 
         SHOT[1,40]
         SHOT[2,40]
      End If 
      RELOAD=6
   Else 
      SHOT[0,35]
      SHOT[1,35]
      SHOT[2,35]
      SHOT[3,35]
      RELOAD=12
   End If 
End Proc
Procedure CLUSTER
   Shared LOCK
   Td Forward J,200
   For I=OPTR+5 To OPTR+8
      Inc P
      OART(I)=4
      OE(I)=500+P*20
      OX(I)=Td Position X(J)
      OY(I)=Td Position Y(J)
      OZ(I)=Td Position Z(J)
      OC(I)=250
      OSOURCE(I)=J
      OL(I)=LOCK
      OVX(I)=Td Position X(J)-OX(I)+P*10
      OVY(I)=Td Position Y(J)-OY(I)-P*10
      OVZ(I)=Td Position Z(J)-OZ(I)
   Next 
   Td Forward J,-200
End Proc
Procedure ROCKETFIRE
   Shared TARGET,LOCK,LAFETTE,TARGETING,LROS
   R=ROCKETTYPE(LAFETTE)
   If(R>0 and TARGET<10) and OART(OPTR)=0
      I=OPTR+LAFETTE
      
      X=-150+LAFETTE*60
      OX(I)=Td World X(0,X,-30,500)
      OY(I)=Td World Y
      OZ(I)=Td World Z
      OVX(I)=Td World X(0,X,-30,700)-OX(I)
      OVY(I)=Td World Y-OY(I)
      OVZ(I)=Td World Z-OZ(I)
      
      If R=1
         OE(I)=500
         OART(I)=5
      Else If R=2
         OE(I)=300
         OART(I)=4
      Else If R=3
         OE(I)=700
         OART(I)=4
      Else If R=4
         OE(I)=1500
         OART(I)=5
      Else If R=5
         OE(I)=5000
         OART(I)=5
      Else If R=6
         CLUSTER
      End If 
      
      OL(I)=LOCK
      OSOURCE(I)=0
      
      OC(I)=500
      
      If Not CHEAT
         ROCKETTYPE(LAFETTE)=0
      End If 
      
      TARGET=0
      TARGETING=0
      ROCKETGAUGE
      Volume %1,63
      Sam Play %1,4
   End If 
End Proc

Rem Cockpit-Instrumente
Rem=================================== 
Procedure ENERGAUGE
   Shared ENERGY()
   Screen 1
   Put Block 6
   X=78
   Y=32
   Ink 0
   For I=1 To 2
      If ENERGY(I)<10 Then Bar X+I*5,Y To X+I*5+4,Y+10-ENERGY(I)
   Next 
   If ENERGY(0)<20 Then Bar X+15,Y To X+18,Y+10-ENERGY(0)/2
   Screen 0
End Proc
Procedure LASERGAUGE
   Shared BLASTER
   Put Block 8
   B=BLASTER/128
   Ink 0
   Draw 35,6 To 57-B,6
   Draw 53+B,6 To 75,6
   Draw 35,8 To 57-B,8
   Draw 53+B,8 To 75,8
End Proc
Procedure ROCKETGAUGE
   Shared LOCK
   Screen 1
   X=40
   Y=24
   Put Block 5
   Ink 8
   Shared ROCKETTYPE(),LAFETTE
   For I=1 To 5
      T=ROCKETTYPE(I)
      If T>0
         Paste Icon X+I*4,Y+2*(I=LAFETTE),T+1
      End If 
   Next 
   Screen 0
End Proc
Procedure WEAPONGAUGE
   Shared WEPCON
   Screen 1
   Put Block 9
   Paste Icon 69,16+WEPCON*8,5
   Screen 0
End Proc
Procedure RADAR
   Shared LOCK
   For I=1 To SANZ
      If SENERGY(I)>0
         X=Td Position X(I)
         Y=Td Position Y(I)
         Z=Td Position Z(I)
         X=Td View X(0,X,Y,Z)
         Y=Td View Y
         Z=Td View Z
         N=Abs(X)+Abs(Y)+Abs(Z)
         N=N/20+1
         Ink 3+SC(I)*4+(Z>1)
         Plot 218+X/N,26-Y/N
         If LOCK=I
            Paste Icon 217+X/N,25-Y/N,1
         End If 
      End If 
   Next 
End Proc
Procedure RADARROCKET[I]
   Screen 1
   X=Td View X(0,OX(I),OY(I),OZ(I))
   Y=Td View Y
   Z=Td View Z
   N=Abs(X)+Abs(Y)+Abs(Z)
   N=N/20+1
   Ink 5+(Z>1)
   Plot 218+X/N,26-Y/N
   Screen 0
End Proc
Procedure SHIELDGAUGE
   Put Block 3
   S=Max(SSHIELD(0,0),0)
   S=S/32
   Ink 0
   X=96
   Y=6
   If S<9 Then Bar X-6,Y To X+6,Y+9-S
   Y=25
   If S<9 Then Bar X-6,Y-9+S To X+6,Y
End Proc
Procedure SHIPINF[N]
   Shared SCARGO$(),BABBEL
   If BABBEL Then Pop Proc
   Screen 1
   Put Block 7
   If N<1 Then Screen 0 : Pop Proc
   X=134
   Y=17
   Paste Icon X,Y,ST(N)+10
   Ink 8
   Text X,Y-5,NAME$(ST(N))
   Jd Textfont "math1.font",15
   Text X+44,Y+10,Chr$(N+96)
   Jd Textfont "battlewing.font",6
   If SMISS(N) and 8
      Text X,Y+42,SCARGO$(N)
   End If 
   Screen 0
End Proc
Procedure BABBELGAUGE
   Shared BABBEL,LOCK
   X=130
   Y=15
   USEDCHAN
   If Param and %100
      If BABBEL=-1
         Paste Icon X,Y,7+Rnd(3)
      Else 
         Paste Icon X,Y,BABBEL
      End If 
   Else 
      BABBEL=0
      SHIPINF[LOCK]
   End If 
End Proc
Procedure BABBEL[I,I$]
   Shared BABBEL
   BABBEL=-1
   Volume %100,63
   Sam Play %100,I
   Rem 13000
   Screen 1
   Put Block 7
   Text 134,12,I$
   Screen 0
End Proc
Procedure MESSAGE[I]
   Shared BABBEL
   BABBEL=I
   Sam Play %100,4
   Screen 1
   Put Block 7
   Text 134,12,I$
   Screen 0
End Proc
Procedure CROSSHAIR
   Shared LOCK,GLOCK
   If LOCK
      F=Td Range(0,LOCK)/400
      If F<30
         X=Td Screen X(Td World X(LOCK,0,0,SS(LOCK)*F),Td World Y,Td World Z)
         Y=Td Screen Y
         D=Abs(X-160)+Abs(Y-100)
      Else 
         D=100
      End If 
   Else 
      D=100
   End If 
   If D<15
      Paste Bob 153,93,27
   Else If GLOCK
      Paste Bob 153,93,25
   Else 
      Paste Bob 153,93,26
   End If 
End Proc
Procedure TARGETVIEW
   Shared LOCKHULL
   X=160
   Y=100
   Screen Copy 0,X-24,Y-25,X+24,Y+125 To 1,160-24,5
   T=ST(LOCK)
   I=LOCKHULL/4
   J=LOCKHULL mod 4
   X=Td Screen X(Td World X(LOCK,THX(T,I,J),THY(T,I,J),THZ(T,I,J)),Td World Y,Td World Z)
   Y=Td Screen Y
   Print X,Y
   Screen 1
   Text X,Y-70,"HIER!"
   Screen 0
End Proc
Procedure STATUSGAUGE[I]
   Shared STATUS()
   X=247
   Y=12
   Screen 1
   N=Y+I*9
   If STATUS(I)>5
      Ink 2
   Else If STATUS(I)>0
      Ink 4
   Else 
      Ink 6
   End If 
   If I<3
      Draw X,N To X+15,N
   Else If I<7
      N=N-27
      Draw X+20,N To X+35,N
   End If 
   Screen 0
End Proc
Procedure INFO[I$]
   Screen Copy 1,200,64,286,70 To 1,200,56
   Screen 1
   Ink 0
   Bar 200,64 To 286,70
   Ink 8
   Text 200,70,I$
   Screen 0
End Proc
Procedure LOCK
   DM=50
   For I=1 To SANZ
      If SENERGY(I)>0
         X=Td Position X(I)
         Y=Td Position Y(I)
         Z=Td Position Z(I)
         X=Td Screen X(X,Y,Z)
         Y=Td Screen Y
         D=Abs(X-160)+Abs(Y-100)
         If D<DM
            DM=D
            S=I
         End If 
      End If 
   Next 
   If Td Range(S,0)>35000 and SC(S)<>1
      S=0
   End If 
End Proc[S]
Procedure MARKLOCK[I]
   Shared TARGET,TARGETING
   X=Td Position X(I)
   Y=Td Position Y(I)
   Z=Td Position Z(I)
   X=Td Screen X(X,Y,Z)
   Y=Td Screen Y
   If X>0 and Y>0
      If SC(I)=1
         Paste Bob X-3,Y-3,28
      Else 
         Paste Bob X-3,Y-3,29
      End If 
      If TARGET and Td Range(0,I)<20000
         Add TARGET,-20
         Add TARGET,Abs(160-X)/4
         Add TARGET,Abs(128-Y)/4
         TARGET=Min(TARGET,1000)
         TARGET=Max(TARGET,8)
         X1=X-TARGET/10-10
         Y1=Y-TARGET/10-10
         X2=X+TARGET/10+5
         Y2=Y+TARGET/10+5
         Paste Bob X1,Y1,21
         Paste Bob X2,Y1,22
         Paste Bob X2,Y2,23
         Paste Bob X1,Y2,24
         Screen 0
      End If 
   Else If TARGET
      TARGET=TARGETING
   End If 
   Screen 1
   
   For J=0 To TSA(ST(I))-1
      T=TSE(ST(I),J)
      If T>0
         If SSHIELD(I,J)
            C=(SSHIELD(I,J)*15)/T
         Else 
            C=$FFF
         End If 
         Colour 16+J,C*16
      End If 
   Next 
   Screen 0
End Proc
Procedure LOCKATTACKER
   D=10000
   For I=1 To SANZ
      If ST(I)>0
         If SL(I)=0
            If SC(I)<>1
               R=Td Range(0,I)
               If R<D
                  D=R
                  A=I
               End If 
            End If 
         End If 
      End If 
   Next 
End Proc[A]

Rem Sound-Prozeduren 
Rem===================================== 
Procedure USEDCHAN
   BITMAP=Deek($2+$DFF000) and %1111
End Proc[BITMAP]
Procedure TRACK[FILE$]
   Track Load "music/"+FILE$,4
   Track Play 4
End Proc
Procedure MUSI
   If MUSI
      Sam Bank 4
      Sam Loop On 
      Sam Loop On %11
      Volume %1100,MUSI
      Sam Play %1100,1
      Sam Bank 5
   End If 
End Proc
Procedure SAMINIT[FILE$,FREQ,BL]
   Shared _BL,_SL,_SS
   _BL=BL
   Reserve As Chip Work 10,_BL
   Reserve As Chip Work 11,_BL
   Open In 1,FILE$
   _SL=Lof(1)
   Sload 1 To Start(10),_BL
   Sload 1 To Start(11),_BL
   Sam Raw %1111,Start(10),_BL,FREQ
   Sam Swap %1111 To Start(11),_BL
   _SS=0
End Proc
Procedure SAMLOAD
   Shared _SL,_BL,_SS
   
   '   If _SL-Pof(1)<_BL
   '     Pof(1)=0 
   ' End If 
   
   Sload 1 To Start(10+_SS),_BL
   Sam Swap %1111 To Start(10+_SS),_BL
   _SS=1-_SS
End Proc
Procedure SPL[I,CHAN,S]
   DISTANCE[I]
   LEISER=Param/2000
   LEISER=Max(LEISER,1)*$100
   If LEISER<$F0000
      Sam Stop CHAN
      Volume CHAN,Max($4000/LEISER-1,0)
      Sam Play CHAN,S
   End If 
End Proc

Rem Sonstiges
Procedure NOP
End Proc
Procedure STARFIELD
   STANZ=20
   Dim STX(STANZ),STY(STANZ),STT(STANZ)
   
   For I=0 To STANZ
      STX(I)=Rnd(1000)
      STY(I)=Rnd(1000)
      STT(I)=2
   Next 
   GANZ=10
   Dim GAX(GANZ),GAY(GANZ),GAT(GANZ)
   For I=0 To GANZ
      GAX(I)=Rnd(1000)
      GAY(I)=-Rnd(1000)
      GAT(I)=95+Rnd(4)
   Next 
   
   DANZ=100
   Dim DX(DANZ),DY(DANZ)
   For I=1 To DANZ
      DX(I)=(Rnd(320)-160)*256
      DY(I)=(Rnd(200)-100)*256
   Next 

   A=AW/41
   B=BW/41
   For I=1 To STANZ
         Plot(STX(I)-B) mod 320,(STY(I)+A) mod 200,STT(I)
   Next 
End Proc
Procedure GALAXY
   '   Shared GAX(),GAY(),GAT(),GANZ,AW,BW
   '   For I=0 To GANZ
   '      Paste Bob GAX(I)-BW/40,GAY(I)+AW/40,GAT(I)
   '   Next 
End Proc
Procedure OSWAP[I,J]
   X=Td Position X(I)
   Y=Td Position Y(I)
   Z=Td Position Z(I)
   A=Td Attitude A(I)
   B=Td Attitude B(I)
   C=Td Attitude C(I)
   Td Move I,Td Position X(J),Td Position Y(J),Td Position Z(J)
   Td Angle I,Td Attitude A(J),Td Attitude B(J),Td Attitude C(J)
   Td Move J,X,Y,Z
   Td Angle J,A,B,C
End Proc
Procedure OPTION[NAME$,I,X,Y]
   Shared GAD$()
   GAD$(I)=At(X,Y)+Zone$(NAME$,I)
   Print GAD$(I)
End Proc
Procedure DAMAGE
   Shared STATUS()
   I=Rnd(10)
   P=Rnd(3)
   Add STATUS(I),P
   STATUS(I)=Min(STATUS(I),10)
   If I<6 Then STATUSGAUGE[I]
End Proc
Procedure EVENT
   Repeat 
      Multi Wait 
   Until Fire(0) or Fire(1) or Inkey$<>""
End Proc
Procedure GSV[I]
   X=Td Position X(I)
   Y=Td Position Y(I)
   Z=Td Position Z(I)
   Td Forward I,SS(I)
   SVX(I)=Td Position X(I)-X
   SVY(I)=Td Position Y(I)-Y
   SVZ(I)=Td Position Z(I)-Z
   Td Forward I,-SS(I)
End Proc
Procedure VECSUM[I,J]
   D=Abs(SVX(I)-SVX(J))
   Add D,Abs(SVY(I)-SVY(J))
   Add D,Abs(SVZ(I)-SVZ(J))
End Proc[D]

Rem Fehler-Bearbeitung 
Procedure FEHLER[A$]
   Track Stop 
   Sam Stop 
   Bell 
   Default 
   Print A$
   Wait Key 
   End 
End Proc
Procedure FELER
   Shared TEST,TEST$
   Bell 
   Default 
   Print TEST,TEST$
Close 
   End 
End Proc

Rem Steuerung
Rem========================= 
Procedure CONTROL
   Shared AV,BV,AW,BW,STATUS()
   E=1000-STATUS(4)*100
   BVM=X Mouse-200
   AVM=Y Mouse-150
   X Mouse=200
   Y Mouse=150
   Add AV,AVM*20
   Add BV,BVM*20
   Add AV,Jdown(1)*-90+Jup(1)*90
   Add BV,Jleft(1)*90+Jright(1)*-90
   
   AV=Max(Min(AV,E),-E)
   BV=Max(Min(BV,E),-E)
   AV=(AV*$FFFF)/70000
   BV=(BV*$FFFF)/70000
   AW=Td Attitude A(0)
   Add BW,BV
   
   E=(Td Attitude A(0)*360)/$FFFF
   E=Abs(90-E mod 180)*Sgn(90-E)*Sgn(270-E)
   
   F=(Td Attitude A(0)*360)/$FFFF
   F=Abs(90-(F+90) mod 180)*Sgn(180-F)*Sgn(-F)

   RB=(BV*E)/90
   RC=(BV*F)/90
   
   Td Angle Rel 0,AV,RB,RC
End Proc
Procedure KEYS
   Shared WEPCON,LASER,RELOAD,LOCK,LAFETTE,TARGET,TARGETING,CAMERA,STATUS
   Shared SET,ZIEL,ENERGY(),I$,DIE,STATUS(),LOCKHULL
   If Key State(94)
      Add SET,10
      SET=Min(SET,128)
      SET=Max(SET,0)
   Else If Key State(74)
      Add SET,-10
      SET=Min(SET,128)
      SET=Max(SET,0)
   Else If Key State(93)
      SET=128
   Else If Key State(67)
      ROCKETFIRE
   Else If Key State(69)
      DIE
      DIE=-1
   Else If Key State(66)
      If STATUS(5)<3
         STATUS=1
      End If 
   Else If Key State(95)
      ZIEL=0
   Else If Key State(80)
      Td Angle 0,0,0,0
   Else If Key State(70)
      ZIEL=LOCK
   Else If I$="["
      CAMERA=0
   Else If I$="]"
      If LOCK
         CAMERA=LOCK
      End If 
   Else If I$="a"
      LOCKATTACKER
      LOCK=Param
      SHIPINF[LOCK]
   Else If Val(I$)>0
      V=Val(I$)
      If V>0 and V<3
         Add ENERGY(V),2,0 To 10
         ENERGY(0)=20
         If Not CHEAT
            For I=1 To 3
               Add ENERGY(0),-ENERGY(I)
            Next 
         End If 
         ENERGAUGE
      End If 
   Else If I$="p"
      Clear Key 
      Wait 50
      Repeat 
         Multi Wait 
         Multi Wait 
         Multi Wait 
         Clear Key 
      Until Mouse Key
   Else If I$="c"
      TSE(0,0)=20000
      SSHIELD(0,0)=20000
      CHEAT=-1
      Bell 
   Else If Key State(60)
      Inc LAFETTE
      LAFETTE=LAFETTE mod 6
      ROCKETGAUGE
      If ROCKETTYPE(LAFETTE)=2
         TARGETING=150
      Else If ROCKETTYPE(LAFETTE)=3
         TARGETING=600
      Else If ROCKETTYPE(LAFETTE)=6
         TARGETING=600
      Else 
         TARGETING=0
      End If 
      TARGET=TARGETING
   Else If Key State(15)
      Inc WEPCON
      WEPCON=WEPCON mod 3
      LASER=0
      WEAPONGAUGE
   End If 
End Proc[0]
Procedure JOPAD
   'Joypad
   Dreg(0)=1
   Z=Lib Call(1,-30)
   If Z and __JPF_BUTTON_FORWARD
      Add SET,10
   Else If Z and __JPF_BUTTON_REVERSE
      Add SET,-10
   Else If 0
      SET=300
   Else If Z and __JPF_BUTTON_GREEN
      ROCKETFIRE
   Else If Key State(17)
      Inc WEPCON
      WEPCON=WEPCON mod 3
      LASER=0
   Else If Z and __JPF_BUTTON_PLAY
      Clear Key 
      Text 100,100,"Pause... "
      Screen Swap 
      Wait 50
      Repeat 
         Multi Wait 
         Multi Wait 
         Multi Wait 
         Clear Key 
      Until Mouse Key
   End If 
   
End Proc
Procedure JOCONST
   Lib Open 1,"lowlevel.library",40
   'Joypad-Konstanten 
   Global __JPF_BUTTON_FORWARD,__JPF_LEFT,__JPF_JOY_UP
   __JPF_BUTTON_FORWARD=524288 : __JPF_LEFT=2 : __JPF_JOY_UP=8
   Global __JPF_BUTTON_REVERSE,__JPF_DOWN,__JPF_JOY_RIGHT
   __JPF_BUTTON_REVERSE=262144 : __JPF_DOWN=4 : __JPF_JOY_RIGHT=1
   Global __JPF_JOY_LEFT,__JPF_BUTTON_GREEN,__JPF_BUTTON_YELLOW
   __JPF_JOY_LEFT=2 : __JPF_BUTTON_GREEN=1048576 : __JPF_BUTTON_YELLOW=2097152
   Global __JPF_JOY_DOWN,__JPF_BUTTON_BLUE,__JPF_UP
   __JPF_JOY_DOWN=4 : __JPF_BUTTON_BLUE=8388608 : __JPF_UP=8
   Global __JPF_BUTTON_PLAY,__JPF_BTN1,__JPF_BTN2
   __JPF_BUTTON_PLAY=131072 : __JPF_BTN1=8388608 : __JPF_BTN2=4194304
   Global __JPF_BTN3,__JPF_BTN4,__JPF_BTN5,__JPF_RIGHT
   __JPF_BTN3=2097152 : __JPF_BTN4=1048576 : __JPF_BTN5=524288 : __JPF_RIGHT=1
   Global __JPF_BTN6,__JPF_BTN7,__JPF_BUTTON_RED
   __JPF_BTN6=262144 : __JPF_BTN7=131072 : __JPF_BUTTON_RED=4194304
End Proc