'chdir "cc:"
CHDIR"b"
LIBRARY "intuition.library"
LIBRARY "graphics.library"
LIBRARY "dos.library"
chdir "df0:"
'CHDIR "dd:tdb_grafik/"
'DECLARE FUNCTION OpenDiskFont&() LIBRARY
DECLARE FUNCTION AllocRemember&() LIBRARY
DECLARE FUNCTION GetSprite&() LIBRARY
REM ^  =  28  f1-f10=129-138
REM => =  30  help  =139
REM <= =  31
REM \/ =  29
'
REM-Functionen aus dos.library                   
DECLARE FUNCTION xOpen&  LIBRARY
DECLARE FUNCTION xRead&  LIBRARY
DECLARE FUNCTION xWrite& LIBRARY
DECLARE FUNCTION seek& LIBRARY
REM-xClose returns no value
DECLARE FUNCTION ViewPortaddress&()LIBRARY
SCREEN 1,328,204,4,1
WINDOW 2,,,0,1
win&=WINDOW(7)
rp&=WINDOW(8)
vp&=ViewPortaddress&(win&)
POKE win&+98,0
POKE win&+99,0
POKEL(win&+24),PEEKL(win&+24) XOR 2048
CALL RefreshWindowFrame(win&)
DEF FN max%(a%,b%)=-a%*(a% >= b%)-b%*(a% < b%)
DEF FN min%(a%,b%)=-a%*(a% <= b%)-b%*(a% > b%)

DIM farb%(31)
dim aed%(4383)
farb%(0)=&h000
farb%(1)=&hAAA
farb%(2)=&h666
farb%(3)=&h444
farb%(4)=&h222
farb%(5)=&h080
farb%(6)=&hA00
farb%(7)=&hCA0
farb%(8)=&h260
farb%(9)=&h222
farb%(10)=&h444
farb%(11)=&h666
farb%(12)=&h888
farb%(13)=&hAAA
farb%(14)=&hCCC
farb%(15)=&hFFF
CALL loadrgb4&(vp&,VARPTR(farb%(0)),16)
f$="aep.put"+CHR$(0)
fhandle&=xOpen&(SADD(f$),1005)
IF fhandle&<>0 THEN
  ok&=xRead&(fhandle&,VARPTR(aed%(0)),8766&)
  CALL xClose&(fhandle&)
end if
line (0,0)-(319,199),15,bf
put (47,63),aed%,pset
erase aed%
farb%(0)=&h000
farb%(1)=&h4C2
farb%(2)=&hC00
farb%(3)=&hEE2
farb%(4)=&h840
farb%(5)=&hA00
farb%(6)=&hEA4
farb%(7)=&hC60
 
'grafik 

DIM burgs%(579)
DIM burgc%(579)
DIM castell%(435,11)
DIM burgteil1%(91,9)
DIM burgteil2%(91,9)
DIM burgteil3%(59,9)
DIM burgteil4%(59,9)
DIM burgteil5%(119,9)
DIM reiter%(51,7)
DIM hof%(51,39)
DIM wald%(51,2)
DIM b.men%(195,19)
DIM kugel%(67,4)
DIM schleu%(723,7)
DIM b1%(8004,1)
DIM b1d%(7243)
DIM b.ani1%(467,4)
DIM b.ani2%(403,4)
DIM b.ani3%(731,4)
DIM b.ani4%(667,4)
DIM b.ani5%(659,4)
DIM ritter0%(3754)
DIM ritter1%(3586)

DIM temps%(50)
DIM tempc%(50)
DIM tempo%(35)
DIM temp%(4000)
DIM t2%(2800)
DIM cur%(386)

' OPEN "i",1,"amiga_s4.b"
'  ass$=input$(180,#1)
' CLOSE 1
'Routinen in sound.ass
' s.ass&=SADD(ass$)         'Basis der assembler-routine
' s.ein&=s.ass&+4       'Sound einschalten
' s.aus&=s.ass&+8       'Sound ausschalten
' s.mem.frei&=s.ass&+12 'Speicher wieder freigeben
' DIM sp&(7)
' sp&(1)=0     'Adresse Sound
' sp&(2)=0     'Länge
' sp&(3)=64    'Volume volle Lautstärke
' sp&(4)=508   'Sampling Periode
' sp&(5)=255   'MOD 
' sp&(6)=33281& 'DMA on
' sp&(7)=15    'DMA off
neustart:
 DIM spname$(1)
 DIM sp.eingabe%(1)
 DIM feld%(25,14)
 DIM fws%(20)
 DIM fwc%(20)
 DIM c.cast.pos%(5,1)
 DIM s.cast.pos%(5,1)
 DIM s.cast.zust%(5)
 DIM c.cast.zust%(5)
 DIM stein%(5)
 DIM burg.treff%(1,4)
 DIM b.treffxy%(1,9)
 DIM c.wiederhol%(6)
 DIM xp%(4),yp%(4)
 DIM sname$(9)
 DIM hisc%(9)
 DIM zuege%(10)
 DIM su$(5)
 DIM kn$(5),k.zahl%(5)
 DIM farb$(1)
 RANDOMIZE TIMER

f$="titel.put"+CHR$(0)
fhandle&=xOpen&(SADD(f$),1005)
IF fhandle&<>0 THEN
  ok&=xRead&(fhandle&,VARPTR(b1%(0,0)),16006&)
  ok&=xRead&(fhandle&,VARPTR(b1%(0,1)),16006&)
  ok&=xRead&(fhandle&,VARPTR(ritter0%(0)),7510&)
  ok&=xRead&(fhandle&,VARPTR(ritter1%(0)),7174&)
  CALL xClose&(fhandle&)
  cls
  farb%(16)=&h000
  farb%(17)=&hC22
  farb%(18)=&h064
  farb%(19)=&h242
  farb%(20)=&h0A4
  farb%(21)=&h864
  farb%(22)=&h446
  farb%(23)=&h777
  farb%(24)=&h66A
  farb%(25)=&hC80
  farb%(26)=&h999
  farb%(27)=&h8AE
  farb%(28)=&hBBB
  farb%(29)=&hACE
  farb%(30)=&h640
  farb%(31)=&hFFF
  CALL loadrgb4&(vp&,VARPTR(farb%(16)),16)
  put (0,0),b1%(0,0)
  put (160,0),b1%(0,1)
  PUT (47, 116), ritter0%, AND
  PUT (47, 116), ritter1%, OR
end if
'farb%(1)=&h4A2 'burg
'farb%(3)=&h8EE 'burg
REM $OPTION +A
call pause(500)
GOSUB g.laden.c
GOSUB init
GOSUB anfangswerte
GOSUB hisc.laden
GOSUB hisc.sort
'
LINE (0,0)-(23,23),1,BF
GET (0,0)-(23,23),cur%
cls
CALL loadrgb4&(vp&,VARPTR(farb%(0)),16)
neufrag:
a$="Altes Spiel laden?| Ja *Nein*2"
al.neu (a$)
while strig(3)<>0 or strig(2)<>0:wend
IF but%=2 THEN
 GOSUB computersteuerung
 GOSUB spielereingabe
 GOSUB restau.feld
ELSE
 GOSUB laden
 if fehl%=1 then goto neufrag
 c.spst%=computer%*sp.staerke%*2
END IF
'
'while inkey$<>"a"
'  spieler%=1
'  GOSUB belager
'  while inkey$<>"w":wend
  'spieler%=0
  'GOSUB belager
  'while inkey$<>"w":wend
'wend
REM $OPTION -A
'
WHILE 0<>1
 me%=0
 spieler%=0
 GOSUB spieler
 GOSUB s.spielstand
 s.geld%=s.geld%+s.cast%*2
 me%=0
 spieler%=1
 GOSUB computer
 GOSUB c.spielstand
 c.geld%=c.geld%+c.cast%*2
WEND
'
spieler:
 belager%=0
 IF s.geld%<0 THEN
REM $OPTION +A
   GOSUB s.steuer.rein
REM $OPTION -A
   GOSUB s.spielstand
 END IF
 GOSUB taste.auswerten.spieler
 IF rsfeld%=1 THEN
   PUT (4+saltx%*12,salty%*12),temps%,PSET
 END IF
 sx%=sx%+rx%
 sy%=sy%+ry%
 sx%=FNmin%(25,sx%)
 sx%=FNmax%(0,sx%)
 sy%=FNmin%(14,sy%)
 sy%=FNmax%(0,sy%)
 ' alten aktiven punkt markieren
 ' feld mit gegner besetzt
 IF ABS(feld%(saltx%,salty%)+1) >= 0 AND ABS(feld%(saltx%,salty%)+1) < 22 THEN
   IF feld%(saltx%,salty%) > 0 AND feld%(saltx%,sy%) < 22 THEN
     PUT (4+saltx%*12,salty%*12),hof%(0,(19+feld%(saltx%,salty%)) ),PSET
   ELSE
     PUT (4+saltx%*12,salty%*12),hof%(0,(ABS(feld%(saltx%,salty%)+1)) ),PSET
   END IF
 END IF
 IF feld%(saltx%,salty%)=-20 THEN
   PUT (4+saltx%*12,salty%*12),hof%(0,19 ),PSET
 END IF
 IF feld%(saltx%,salty%) > 252 THEN
   PUT (4+saltx%*12,salty%*12),wald%(0,(255-feld%(saltx%,salty%)) ),PSET
 END IF
 IF feld%(saltx%,salty%)=0 THEN
   PUT (4+saltx%*12,salty%*12),wald%(0,2 ),PSET
 END IF
 saltx%=sx%
 salty%=sy%
 zug%=0
 GOSUB kasten
 sx%=saltx%
 sy%=salty%
 CALL m.reiter(saltx%*12,salty%*12,sxm%*12,sym%*12,sr.num%)
 sxm%=sx%
 sym%=sy%
 ' aktiven punkt setzen
 rsfeld%=0
 IF feld%(saltx%,salty%)=-100 OR feld%(saltx%,salty%)=-101 THEN
   rsfeld%=1
   GET (4+saltx%*12,salty%*12)-(4+saltx%*12+11,salty%*12+11),temps%
 END IF
 PUT (4+saltx%*12,salty%*12),reiter%(0,sr.num% ),PSET
 GOSUB s.gegnerburg
RETURN
s.gegnerburg:
 gruppe%=0
 IF sx% < 25 THEN
   IF feld%(sx%+1,sy%)=101 THEN
     gruppe%=1
   END IF
 END IF
 IF sy% > 0 THEN
   IF feld%(sx%,sy%-1)=101 THEN
     gruppe%=1
   END IF
 END IF
 IF gruppe%=1 AND feld%(sx%,sy%) < 0 AND feld%(sx%,sy%) > -21 THEN
   belager%=0
   a$="  Belagern |  | Ja *Nein*1"
   al.neu (a$)
   IF but%=1 THEN
     belager%=1
     IF s.geld% < 200 THEN
       WHILE s.geld% < 200 AND s.felder.ges% > 0
         GET (4,4)-(104,92),temp%
REM $OPTION +A
         GOSUB s.steuern
REM $OPTION -A
         GOSUB s.spielstand
       WEND
     END IF
     IF s.geld% >= 200 THEN
       s.geld%=s.geld%-200
REM $OPTION +A
       GOSUB belager
REM $OPTION -A
     END IF
   END IF
 END IF
RETURN
'
kasten:    REM(sx%,sy%)
 zug%=zug%+1
 GOSUB balken
 zz%=(c.spst%*-(durchgang% MOD (sp.staerke%*2) <> 0))
 '  PRINT AT(1,1);zug%'20-zz%-computer%*2'" "
 IF sx% > -1 AND sy% > -1 AND sx% < 26 AND sy% < 15 AND zug% < 20-zz%-computer%*2 THEN
       CALL m.reiter(sx%*12,sy%*12,sxm%*12,sym%*12,sr.num%)
       sxm%=sx%
       sym%=sy%
   IF feld%(sx%,sy%)=100 THEN
     GOSUB auf.c.castell
   END IF
   IF feld%(sx%,sy%) > -21 THEN
     IF feld%(sx%,sy%)=-20 THEN
       s.geld%=s.geld%+1
'        SOUND 1,8,#428
'        WAVE 1,1,9,20831
'       PAUSE(30)
       '        PRINT AT(1,1);kling$
     END IF
     IF sx%=cx% AND sy%=cy% THEN
     ELSE
       'hier call m.reiter
       ' wald
       IF feld%(sx%,sy%) > 253 THEN
         feld%(sx%,sy%)=feld%(sx%,sy%)-1
         PUT (4+sx%*12,sy%*12),wald%(0,(255-feld%(sx%,sy%)) ),PSET
       END IF
       ' feld besetzt
       IF feld%(sx%,sy%) < 20 AND feld%(sx%,sy%) > -20 THEN
         feld%(sx%,sy%)=feld%(sx%,sy%)-1
         s.feldp.ges%=s.feldp.ges%+1
       END IF
       IF feld%(sx%,sy%) < 254 AND feld%(sx%,sy%) > 200 THEN
         feld%(sx%,sy%)=0
       END IF
       ' feld mit gegner besetzt
       IF feld%(sx%,sy%) > 0 AND feld%(sx%,sy%) < 21 THEN
         IF s.truppe% > 1 THEN
           feld%(sx%,sy%)=feld%(sx%,sy%)-s.truppe%
           c.feldp.ges%=c.feldp.ges%-s.truppe%
           s.truppe%=s.truppe%-1
           s.truppe%=FNmax%(1,s.truppe%)
           r.start%=(320-s.truppe%*12) \ 2
           LINE (0,181)-(319,193+1),0 ,BF
           GOSUB s.trupp
           '            PRINT AT(1,1);feld%(sx%,sy%)
           IF feld%(sx%,sy%) > 0 THEN
             ' PRINT AT(1,2);19+feld%(sx%,sy%)
             PUT (4+sx%*12,sy%*12),hof%(0,(19+feld%(sx%,sy%)) ),PSET
           ELSE
             IF feld%(sx%,sy%) < 0 THEN
               PUT (4+sx%*12,sy%*12),hof%(0,(ABS(feld%(sx%,sy%))-1) ),PSET
               s.feldp.ges%=s.feldp.ges%+ABS(feld%(sx%,sy%))
             END IF
           END IF
         ELSE
            LOCATE 1,1: PRINT ; kling$;
           s.geld%=s.geld%-ABS(feld%(sx%,sy%) \ 2)
         END IF
       END IF
       ' holz
       IF feld%(sx%,sy%)=0 THEN
         PUT (4+sx%*12,sy%*12),wald%(0,2 ),PSET
       END IF
       IF feld%(sx%,sy%) < 0 AND feld%(sx%,sy%) > -21 THEN
         PUT (4+sx%*12,sy%*12),hof%(0,(ABS(feld%(sx%,sy%))-1) ),PSET
         IF feld%(sx%,sy%) < -1 THEN
           streux%=-(rx%=0)
           streuy%=-(ry%=0)
           FOR i%=0 TO 2
             sxm%=sx%
             sym%=sy%
             sx%=sx%+(RND*(2*rx%+(INT(RND*streux%*5)-2*streux%)))
             sy%=sy%+(RND*(2*ry%+(INT(RND*streuy%*5)-2*streuy%)))
             GOSUB kasten
           NEXT i%
         END IF
       ELSE
         IF feld%(sx%,sy%) > 0 AND feld%(sx%,sy%) < 21 THEN
           PUT (4+sx%*12,sy%*12),hof%(0,(19+feld%(sx%,sy%)) ),PSET
         END IF
       END IF
     END IF
   END IF
 END IF
RETURN
balken:
 c.teil% = c.feldp.ges% + c.geld%
 IF c.teil% < 0 THEN c.teil% = 0
 s.teil% = s.feldp.ges% + s.geld%
 IF s.teil% < 0 THEN s.teil% = 0
 teiler = 159 / (c.teil% + s.teil% + 1)
 LINE (0,195)-(159-(teiler*(s.feldp.ges%+s.geld%)),199),0,BF
 LINE (160+(teiler*(c.feldp.ges%+c.geld%)),195)-(319,199),0 ,BF
 LINE (159-(teiler*(s.feldp.ges%+s.geld%)),195)-(159,199),3 ,BF
 LINE (160,195)-(160+(teiler*(c.feldp.ges%+c.geld%)),199),5 ,BF
RETURN
'
computer:
neu.cw:
 belager%=0
 durchgang%=durchgang%+1
 IF computer%=1 THEN
   IF durchgang% MOD (50-sp.staerke%*5)=0 THEN
     c.rueck%=0
     IF (s.feldp.ges%+s.geld%+(s.truppe%*20))-s.stand% > (c.feldp.ges%+c.geld%+(c.truppe%*20))-c.stand% THEN
       c.rueck%=1
     END IF
     IF c.rueck%=1 THEN
       c.rueck2%=c.rueck2%+1
     ELSE
       c.rueck2%=0
     END IF
     IF c.rueck2% > 3 THEN
       c.rueck2%=0
     END IF
     c.stand%=c.feldp.ges%+c.geld%+(c.truppe%*20)
     s.stand%=s.feldp.ges%+s.geld%+(s.truppe%*20)
   END IF
 END IF
 IF c.geld% < 0 THEN
   keine.c.pferde%=5
REM $OPTION +A
   GOSUB c.steuer.rein
REM $OPTION -A
   GOSUB c.spielstand
 END IF
 IF computer%=1 THEN
   GOSUB c.steuer
REM $OPTION +A
   GOSUB c.castel
REM $OPTION -A
 ELSE
   GOSUB taste.auswerten.computer
 END IF
 cx%=cx%+cwx%
 cy%=cy%+cwy%
 cx%=FNmin%(25,cx%)
 cx%=FNmax%(0,cx%)
 cy%=FNmin%(14,cy%)
 cy%=FNmax%(0,cy%)
 IF rcfeld%=1 THEN
   PUT (4+altcx%*12,altcy%*12),tempc%,PSET
 END IF
 IF ABS(feld%(altcx%,altcy%)+1) >= 0 AND ABS(feld%(altcx%,altcy%)+1) < 22 THEN
   IF feld%(altcx%,altcy%) > 0 AND feld%(altcx%,altcy%) < 22 THEN
     PUT (4+altcx%*12,altcy%*12),hof%(0,(19+feld%(altcx%,altcy%)) ),PSET
   ELSE
     PUT (4+altcx%*12,altcy%*12),hof%(0,(ABS(feld%(altcx%,altcy%)+1)) ),PSET
   END IF
 END IF
 IF feld%(altcx%,altcy%) > 252 THEN
   PUT (4+altcx%*12,altcy%*12),wald%(0,(255-feld%(altcx%,altcy%)) ),PSET
 END IF
 IF feld%(altcx%,altcy%)=0 THEN
   PUT (4+altcx%*12,altcy%*12),wald%(0,2 ),PSET
 END IF
 altcx%=cx%
 altcy%=cy%
 zug%=0
 GOSUB ckasten
 cx%=altcx%
 cy%=altcy%
 CALL m.reiter(altcx%*12,altcy%*12,cxm%*12,cym%*12,cr.num%+4)
 cxm%=cx%
 cym%=cy%
 rcfeld%=0
 IF feld%(altcx%,altcy%)=100 OR feld%(altcx%,altcy%)=101 THEN
   rcfeld%=1
   GET (4+altcx%*12,altcy%*12)-(4+altcx%*12+11,altcy%*12+11),tempc%
 END IF
 PUT (4+altcx%*12,altcy%*12),reiter%(0,(cr.num%+4) ),PSET
 GOSUB c.gegnerburg
RETURN
ckasten:    REM(cx%,cy%)
 zug%=zug%+1
 GOSUB balken
 IF cx% > -1 AND cy% > -1 AND cx% < 26 AND cy% < 15 AND zug% < 20+c.spst%+computer%*2 THEN
   IF feld%(cx%,cy%)=-100 THEN
     GOSUB auf.s.castell
   END IF
   IF feld%(cx%,cy%) > -21 THEN
     IF feld%(cx%,cy%)=20 THEN
       c.geld%=c.geld%+1
'        SOUND 1,8,#428
'        WAVE 1,1,9,20831
       '       PAUSE 1
       '        SOUND 2,8,#1470
       '        WAVE 2,1,9,20831
       PAUSE(10)
       '        PRINT AT(1,1);kling$
     END IF
     IF cx%=sx% AND cy%=sy% THEN
     ELSE
      CALL m.reiter(cx%*12,cy%*12,cxm%*12,cym%*12,cr.num%+4)
      cxm%=cx%
      cym%=cy%
       ' wald
       IF feld%(cx%,cy%) > 253 THEN
         feld%(cx%,cy%)=feld%(cx%,cy%)-1
         PUT (4+cx%*12,cy%*12),wald%(0,(255-feld%(cx%,cy%)) ),PSET
       END IF
       ' feld besetzt
       IF feld%(cx%,cy%) < 20 AND feld%(cx%,cy%) > -20 THEN
         feld%(cx%,cy%)=feld%(cx%,cy%)+1
         c.feldp.ges%=c.feldp.ges%+1
       END IF
       IF feld%(cx%,cy%) < 254 AND feld%(cx%,cy%) > 200 THEN
         feld%(cx%,cy%)=0
       END IF
       ' feld mit gegner besetzt
       IF feld%(cx%,cy%) < 0 AND feld%(cx%,cy%) > -21 THEN
         IF c.truppe% > 1 THEN
           feld%(cx%,cy%)=feld%(cx%,cy%)+c.truppe%
           s.feldp.ges%=s.feldp.ges%-c.truppe%
           c.truppe%=c.truppe%-1
           c.truppe%=FNmax%(1,c.truppe%)
           r.start%=(320-c.truppe%*12) \ 2
           LINE (0,181)-(319,193+1),0 ,BF
           GOSUB c.trupp
           IF feld%(cx%,cy%) > 0 THEN
             PUT (4+cx%*12,cy%*12),hof%(0,(19+feld%(cx%,cy%)) ),PSET
             c.feldp.ges%=c.feldp.ges%+feld%(cx%,cy%)
           ELSE
             IF feld%(cx%,cy%) < 0 THEN
               PUT (4+cx%*12,cy%*12),hof%(0,(ABS(feld%(cx%,cy%)+1)) ),PSET
             END IF
           END IF
         ELSE
           LOCATE 1,1: PRINT ; kling$
           c.geld%=c.geld%-ABS(feld%(cx%,cy%) \ 2)
         END IF
       END IF
       ' holz
       IF feld%(cx%,cy%)=0 THEN
         PUT (4+cx%*12,cy%*12),wald%(0,2 ),PSET
       END IF
       IF feld%(cx%,cy%) > 0 AND feld%(cx%,cy%) < 21 THEN
         PUT (4+cx%*12,cy%*12),hof%(0,(19+feld%(cx%,cy%)) ),PSET
         IF feld%(cx%,cy%) > 1 THEN
           streux%=-(cwx%=0)
           streuy%=-(cwy%=0)
           FOR i%=0 TO 2
             cxm%=cx%
             cym%=cy%
             cx%=cx%+(RND*(2*cwx%+(INT(RND*streux%*5)-2*streux%)))
             cy%=cy%+(RND*(2*cwy%+(INT(RND*streuy%*5)-2*streuy%)))
             GOSUB ckasten
           NEXT i%
         END IF
       ELSE
         IF feld%(cx%,cy%) < 0 AND feld%(cx%,cy%) > -21 THEN
           PUT (4+cx%*12,cy%*12),hof%(0,(ABS(feld%(cx%,cy%)+1)) ),PSET
         END IF
       END IF
     END IF
   END IF
 END IF
RETURN
c.gegnerburg:
 GOSUB c.gegnerburg.test
 IF gruppe% > 0 AND feld%(cx%,cy%) > 0 AND feld%(cx%,cy%) < 21 THEN
   belager%=0
   IF computer%=0 THEN
     a$="  Belagern |  | Ja *Nein*1"
     al.neu (a$)
   ELSE
     but%=0
     IF (c.feldp.ges%+c.geld% > 300+sp.staerke%*40) OR (c.feldp.ges%+c.geld% > s.feldp.ges%+s.geld%) THEN
       keine.c.pferde%=5
       but%=1
     END IF
   END IF
   IF but%=1 THEN
     belager%=1
     IF c.geld% < 200 THEN
       WHILE c.geld% < 200 AND c.felder.ges% > 0
         IF computer%=0 THEN
           GET (213,84)-(314,172),temp%
         END IF
         GOSUB c.steuern
         GOSUB c.spielstand
       WEND
     END IF
     IF c.geld% >= 200 THEN
       c.geld%=c.geld%-200
REM $OPTION +A
       GOSUB belager
REM $OPTION -A
     END IF
   END IF
 END IF
RETURN
c.gegnerburg.test:
 gruppe%=0
 IF cx% > 0 THEN
   IF feld%(cx%-1,cy%)=-101 THEN
     gruppe%=1
   END IF
 END IF
 IF cy% < 14 THEN
   IF feld%(cx%,cy%+1)=-101 THEN
     gruppe%=2
   END IF
 END IF
RETURN
'
c.steuer:
 cwx%=0
 cwy%=0
 i%=0
 IF durchgang%=1 THEN
   cwx%=0
   cwy%=1
   GOTO cs.raus
 END IF
 GOSUB c.trupp.staerke
 LINE (0,181)-(319,193+1),0 ,BF
 r.start%=(320-c.truppe%*12) \ 2
 FOR i%=0 TO c.truppe%-1
   PUT (r.start%+i%*12,182),reiter%(0,(cr.num%+4) ),PSET
 NEXT i%
 i%=0
c.steu.neu:
 IF i% > 6 THEN
   GOSUB c.klemme
   GOTO cs.raus
 END IF
 GOSUB c.gegnerburg.test
 IF gruppe% > 0 THEN
   IF (c.feldp.ges%+c.geld% > 300+sp.staerke%*40) OR (c.feldp.ges%+c.geld% > s.feldp.ges%+s.geld%) THEN
     IF gruppe%=1 THEN
       cwy%=1+(cy%=14)*2
       GOTO cs.raus
     END IF
     IF gruppe%=2 THEN
       cwx%=-1-(cx%=0)*2
       GOTO cs.raus
     END IF
   END IF
 END IF
 IF durchgang% < sp.staerke% THEN
   cwx%=1
   cwy%=0
   GOTO cs.raus
 END IF
 ' RÜckzug
 IF (c.feldp.ges%+c.geld% < 100+sp.staerke%*20 AND durchgang% > 70+sp.staerke%*10) OR c.rueck2% > 1 THEN
   GOSUB c.opti2
   IF opti%=0 THEN
     IF feld%(cx%+1,cy%) <> -100 AND feld%(cx%+1,cy%) <> -101 THEN
       IF cx% < 18 THEN
         cwx%=1
         cwy%=0
         GOTO cs.raus
       END IF
     END IF
     if cy%>0 then
     IF feld%(cx%,cy%-1) <> -100 AND feld%(cx%,cy%-1) <> -101 THEN
       IF cy% > 6 THEN
         cwy%=-1
         cwx%=0
         GOTO cs.raus
       END IF
     END IF
     end if
   ELSE
     IF opti%=2 OR opti%=4 THEN
       GOTO cs.raus
     END IF
   END IF
 END IF
 ' fÜr Angriff aufbauen
 IF c.cast% < 2 OR c.feldp.ges%+c.geld% < 380+sp.staerke%*40 OR c.rueck%=1 THEN
   GOSUB c.opti
   '   PRINT "in 1 ";
   IF cy% < 2 THEN
     cwy%=1
     cwx%=0
     GOTO cs.raus
   END IF
   IF cy% > 13 THEN
     cwy%=-1
     cwx%=0
     GOTO cs.raus
   END IF
   IF durchgang% < 30+sp.staerke%*10 AND opti% > 2 THEN
     IF cy% > 9-sp.staerke% THEN
       cwy%=-1
       cwx%=0
     END IF
   END IF
   IF opti% > 2 THEN
     GOTO cs.raus
   END IF
   ' PRINT AT(60,1);opti%
   IF durchgang% < 60+sp.staerke%*10 THEN
     IF cx% < 15+sp.staerke% AND opti% < 4 THEN
       cwy%=0
       cwx%=1
       ' PRINT AT(60,2);"cwx% =1"
       GOTO cs.raus
     END IF
   END IF
   IF cx% < 16 AND opti% < 4 THEN
     cwy%=0
     cwx%=1
     '      PRINT "x2"'
     GOTO cs.raus
   END IF
 END IF
 cwx%=0
 cwy%=0
 ' PRINT "cs2 ";
 IF cx% < 6 AND c.truppe% < 6 THEN
   IF RND < .3 THEN
     cwx%=1
     GOTO cs.raus
   END IF
 END IF
 ' PRINT "cs3 ";
 IF cx% < 6 AND cy% < 12 THEN
   IF RND < .3 THEN
     cwy%=1
     GOTO cs.raus
   END IF
 END IF
 '  PRINT "cs4 ";
 IF cx% < 1 THEN
   cwx%=1
   GOTO cs.raus
 END IF
 ' PRINT "cs5 ";
 IF cy% < 1 THEN
   cwy%=1
   GOTO cs.raus
 END IF
 ' PRINT "cs6 ";
 IF cx% > 23 THEN
   cwx%=-1
   GOTO cs.raus
 END IF
 '  PRINT "cs7 ";
 IF cy% > 13 AND c.feldp.ges%+c.geld% > 500 THEN
   cwx%=-1
   cwy%=0
   GOTO cs.raus
 END IF
 IF cy% > 13 THEN
   cwy%=-1
   GOTO cs.raus
 END IF
 '  PRINT "cs8 ";
 IF INT(RND*10)=1 THEN
   cwy%=int(RND*3)-1
   cwx%=(cwy%=0)*int(RND*3)-(cwy%=0)
   GOTO cs.raus
 END IF
 ' PRINT "cs9 ";
 if cx>0 then
 IF feld%(cx%-1,cy%) <> 255 AND ABS(feld%(cx%-1,cy%)) < 20 AND feld%(cx%-1,cy%) <> -100 THEN
   cwy%=0
   cwx%=-1
   GOTO cs.raus
 END IF
 end if
 ' PRINT "cs10 ";
 IF feld%(cx%,cy%+1) <> 255 AND ABS(feld%(cx%,cy%+1)) < 20 AND feld%(cx%,cy%+1) <> -100 THEN
   cwx%=0
   cwy%=1
   GOTO cs.raus
 END IF
 '  PRINT "cs11 ";
 IF feld%(cx%+1,cy%) <> 255 AND ABS(feld%(cx%+1,cy%)) < 20 AND feld%(cx%+1,cy%) <> -100 THEN
   cwy%=0
   cwx%=1
   GOTO cs.raus
 END IF
 ' PRINT "cs12 ";
 if cy>0 then
 IF feld%(cx%,cy%-1) <> 255 AND ABS(feld%(cx%,cy%-1)) < 20 AND feld%(cx%,cy%-1) <> -100 THEN
   cwx%=0
   cwy%=-1
   GOTO cs.raus
 END IF
 end if
 ' PRINT "cs13 ";
c0.0:
 IF cwx%=0 AND cwy%=0 THEN
   ' cwx%=RND*2-2
   ' cwy%=(cwx%=0)*RND*2-2*(cwx%=0)
   GOSUB c.wahl.zufall
   GOTO c0.0
 END IF
cs.raus:
 IF cx%+cwx% > 25 OR cx%+cwx% < 0 OR cy%+cwy% > 14 OR cy%+cwy% < 0 THEN
 LOCATE 1,1: PRINT ; kling$
   i%=i%+1
   GOTO c.steu.neu
 END IF
 IF feld%(cx%+cwx%,cy%+cwy%)=-100 OR feld%(cx%+cwx%,cy%+cwy%)=-101 THEN
   CALL fehler(10,"Geht nicht!")
   i%=i%+1
   GOTO c.steu.neu
 END IF
 IF feld%(cx%+cwx%,cy%+cwy%)=100 OR feld%(cx%+cwx%,cy%+cwy%)=101 THEN
   GOSUB c.opti
 END IF
 '  PRINT ''cwx%'cwy%
 c.wiederhol%(6)=cwx%+10*cwy%
 ii%=0
 FOR i%=0 TO 6 STEP 2
   IF c.wiederhol%(i%)=c.wiederhol%(6) THEN
     ii%=ii%+1
   END IF
 NEXT i%
 IF ii% > 3 AND RND*2 > 1 THEN
   GOSUB c.wahl.zufall
   c.wiederhol%(0)=RND*10
   c.wiederhol%(1)=RND*10
 END IF
 FOR i%=0 TO 5
   c.wiederhol%(i%)=c.wiederhol%(i%+1)
 NEXT i%
 IF cx%+cwx%=sx% AND cy%+cwy%=sy% THEN
   cwx%=0
   cwy%=0
 END IF
 GOSUB c.trupp
RETURN
c.opti:
 opti%=0
 IF cx%-1 > 0 THEN
   IF feld%(cx%-1,cy%) > 0 AND feld%(cx%-1,cy%) < 21 THEN
     cwy%=0
     cwx%=-1
     opti%=1
   END IF
 END IF
 IF cx%+1 < 25 THEN
   IF feld%(cx%+1,cy%) > 0 AND feld%(cx%+1,cy%) < 21 THEN
     cwy%=0
     cwx%=1
     opti%=2
   END IF
 END IF
 IF cy%-1 > 0 THEN
   IF feld%(cx%,cy%-1) > 0 AND feld%(cx%,cy%-1) < 21 THEN
     cwx%=0
     cwy%=-1
     opti%=4
   END IF
 END IF
 IF cy%+1 < 15 THEN
   IF feld%(cx%,cy%+1) > 0 AND feld%(cx%,cy%+1) < 21 THEN
     cwx%=0
     cwy%=1
     opti%=8
   END IF
 END IF
 IF sy% < 8 THEN
   IF cy%+1 < 15 THEN
     IF feld%(cx%,cy%+1) > 0 AND feld%(cx%,cy%+1) < 21 THEN
       cwx%=0
       cwy%=1
       opti%=8
     END IF
   END IF
   IF cy%-1 > 0 THEN
     IF feld%(cx%,cy%-1) > 0 AND feld%(cx%,cy%-1) < 21 THEN
       cwx%=0
       cwy%=-1
       opti%=4
     END IF
   END IF
 END IF
 IF sx% > 14 OR durchgang% < sp.staerke%*10 THEN
   IF cx%+1 < 25 THEN
     IF feld%(cx%+1,cy%) > 0 AND feld%(cx%+1,cy%) < 21 THEN
       cwy%=0
       cwx%=1
       opti%=2
     END IF
   END IF
   IF cx%-1 > 0 THEN
     IF feld%(cx%-1,cy%) > 0 AND feld%(cx%-1,cy%) < 21 THEN
       cwy%=0
       cwx%=-1
       opti%=1
     END IF
   END IF
 END IF
RETURN
c.opti2:
 opti%=0
 IF cy%+1 < 15 THEN
   IF feld%(cx%,cy%+1)=0 OR feld%(cx%,cy%+1) > 250 THEN
     cwx%=0
     cwy%=1
     opti%=8
   END IF
 END IF
 IF cy%-1 > 0 THEN
   IF feld%(cx%,cy%-1)=0 OR feld%(cx%,cy%-1) > 250 THEN
     cwx%=0
     cwy%=-1
     opti%=4
   END IF
 END IF
 IF cx%-1 > 0 THEN
   IF feld%(cx%-1,cy%)=0 OR feld%(cx%-1,cy%) > 250 THEN
     cwy%=0
     cwx%=-1
     opti%=1
   END IF
 END IF
 IF cx%+1 < 25 THEN
   IF feld%(cx%+1,cy%)=0 OR feld%(cx%+1,cy%) > 250 THEN
     cwy%=0
     cwx%=1
     opti%=2
   END IF
 END IF
 '  PRINT AT(1,24)'cwx%'cwy%''opti%'
RETURN
c.wahl.zufall:
zufall.neu:
 zufall%=RND*4+1
 cwx%=(zufall%=1)-(zufall%=2)
 cwy%=(zufall%=3)-(zufall%=4)
 IF cx%+cwx% < 0 OR cx%+cwx% > 24 THEN
   GOTO zufall.neu
 END IF
 IF cy%+cwy% < 0 OR cy%+cwy% > 14 THEN
   GOTO zufall.neu
 END IF
 IF feld%(cx%+cwx%,cy%+cwy%)=-100 OR feld%(cx%+cwx%,cy%+cwy%)=-101 THEN
   GOTO zufall.neu
 END IF
 ' PRINT AT(1,3);cwx%'cwy%
RETURN
c.klemme:
 cwx%=0
 cwy%=0
 GOSUB c.opti2
 IF opti% > 0 THEN
   GOTO c.klemm.end
 END IF
 IF cx% > 0 AND i% < 8 THEN
   wert%=feld%(cx%-1,cy%)
   IF wert% > -100 THEN
     cwx%=-1
     GOTO c.klemm.end
   END IF
 END IF
 IF cx% < 24 AND i% < 10 THEN
   wert%=feld%(cx%+1,cy%)
   IF wert% > -100 THEN
     cwx%=1
     GOTO c.klemm.end
   END IF
 END IF
 IF cy% > 0 AND i% < 12 THEN
   wert%=feld%(cx%,cy%-1)
   IF wert% > -100 THEN
     cwy%=-1
     GOTO c.klemm.end
   END IF
 END IF
 IF cy% < 24 AND i% < 14 THEN
   wert%=feld%(cx%,cy%+1)
   IF wert% > -100 THEN
     cwy%=1
     GOTO c.klemm.end
   END IF
 END IF
c.klemm.end:
RETURN
c.trupp.staerke:
 IF c.feldp.ges%+c.geld% > 300+sp.staerke%*20 THEN
   IF keine.c.pferde%=0 THEN
     WHILE c.geld% > 20 AND c.truppe% < 21-c.spst%
       GOSUB c.ruesten
     WEND
   ELSE
     keine.c.pferde%=keine.c.pferde%-1
   END IF
 END IF
RETURN
'
auf.s.castell:
 ij%=-1
 gefunden%=0
 WHILE gefunden%=0 AND ij% < 16
   ij%=ij%+1
   IF s.cast.pos%(ij%,0) > -1 THEN
     IF INT(s.cast.pos%(ij%,0) \ 3)=INT((cx%-(s.cast.pos%(ij%,0) MOD 3)) \ 3) THEN
       IF INT(s.cast.pos%(ij%,1) \ 3)=INT((cy%-(s.cast.pos%(ij%,1) MOD 3)) \ 3) THEN
         gefunden%=1
       END IF
     END IF
   END IF
 WEND
 k%=(c.truppe%+1) \ 2
 WHILE k% > 0
   s.cast.zust%(ij%)=s.cast.zust%(ij%)-1
   IF s.cast.zust%(ij%) > 0 THEN
     IF s.cast.zust%(ij%) MOD 5=0 THEN
LOCATE 1,1: PRINT kling$
       IF c.truppe% > 1 THEN
         c.truppe%=c.truppe%-1
         c.truppe%=FNmax%(1,c.truppe%)
         GOSUB c.trupp
       ELSE
LOCATE 1,1: PRINT kling$;
         c.geld%=c.geld%-2
       END IF
       PUT (4+s.cast.pos%(ij%,0)*12,s.cast.pos%(ij%,1)*12),castell%(0,11-(s.cast.zust%(ij%)\6)),PSET
     END IF
   END IF
   k%=k%-1
 WEND
 IF s.cast.zust%(ij%) <= 0 AND gefunden%=1 THEN
   FOR ii%=0 TO 2
     FOR jj%=0 TO 2
       feld%(s.cast.pos%(ij%,0)+ii%,s.cast.pos%(ij%,1)+jj%)=255
       PUT (4+(s.cast.pos%(ij%,0)+ii%)*12,(s.cast.pos%(ij%,1)+jj%)*12),wald%(0,0),PSET
     NEXT jj%
   NEXT ii%
   s.cast.pos%(ij%,0)=-1
   s.cast.pos%(ij%,1)=-1
   s.cast%=s.cast%-1
 END IF
RETURN
auf.c.castell:
 ij%=-1
 gefunden%=0
 WHILE gefunden%=0 AND ij% < 16
   ij%=ij%+1
   IF c.cast.pos%(ij%,0) > -1 THEN
     IF INT(c.cast.pos%(ij%,0) \ 3)=INT((sx%-(c.cast.pos%(ij%,0) MOD 3)) \ 3) THEN
       IF INT(c.cast.pos%(ij%,1) \ 3)=INT((sy%-(c.cast.pos%(ij%,1) MOD 3)) \ 3) THEN
         gefunden%=1
       END IF
     END IF
   END IF
 WEND
 k%=(s.truppe%+1) \ 2
 WHILE k% > 0
   c.cast.zust%(ij%)=c.cast.zust%(ij%)-1
   IF c.cast.zust%(ij%) > 0 THEN
     IF c.cast.zust%(ij%) MOD 5=0 THEN
 LOCATE 1,1: PRINT kling$
       IF s.truppe% > 1 THEN
         s.truppe%=s.truppe%-1
         s.truppe%=FNmax%(1,s.truppe%)
         GOSUB s.trupp
       ELSE
 LOCATE 1,1: PRINT  kling$;
         s.geld%=s.geld%-2
       END IF
       IF 5-INT(c.cast.zust%(ij%) \ 6) > 0 THEN
         PUT (4+c.cast.pos%(ij%,0)*12,c.cast.pos%(ij%,1)*12),castell%(0,5-(c.cast.zust%(ij%)\6)),PSET
       END IF
     END IF
   END IF
   k%=k%-1
 WEND
 IF c.cast.zust%(ij%) <= 0 AND gefunden%=1 THEN
   FOR ii%=0 TO 2
     FOR jj%=0 TO 2
       feld%(c.cast.pos%(ij%,0)+ii%,c.cast.pos%(ij%,1)+jj%)=255
       PUT (4+(c.cast.pos%(ij%,0)+ii%)*12,(c.cast.pos%(ij%,1)+jj%)*12),wald%(0,0),PSET
     NEXT jj%
   NEXT ii%
   c.cast.pos%(ij%,0)=-1
   c.cast.pos%(ij%,1)=-1
   c.cast%=c.cast%-1
 END IF
RETURN
'
s.spielstand:
 FOR i%=0 TO 20
   fws%(i%)=0
 NEXT i%
 FOR j%=0 TO 14
   FOR i%=0 TO 25
     IF feld%(i%,j%) < 0 AND feld%(i%,j%) > -21 THEN
       fws%(ABS(feld%(i%,j%)))=fws%(ABS(feld%(i%,j%)))+1
     END IF
   NEXT i%
 NEXT j%
 s.felder.ges%=0
 s.feldp.ges%=0
 FOR i%=0 TO 19
   s.felder.ges%=s.felder.ges%+fws%(i%)
   s.feldp.ges%=s.feldp.ges%+fws%(i%)*(i%+1)
 NEXT i%
RETURN
c.spielstand:
 FOR i%=0 TO 20
   fwc%(i%)=0
 NEXT i%
 FOR j%=0 TO 14
   FOR i%=0 TO 25
     IF feld%(i%,j%) > 0 AND feld%(i%,j%) < 21 THEN
       fwc%(ABS(feld%(i%,j%)))=fwc%(ABS(feld%(i%,j%)))+1
     END IF
   NEXT i%
 NEXT j%
 c.felder.ges%=0
 c.feldp.ges%=0
 FOR i%=0 TO 19
   c.felder.ges%=c.felder.ges%+fwc%(i%)
   c.feldp.ges%=c.feldp.ges%+fwc%(i%)*(i%+1)
 NEXT i%
RETURN
'
s.trupp:
 sr.num.a%=sr.num%
 sr.num%=-(rx%=-1)*2-(ry%=1)-(ry%=-1)*3
 j%=1
 IF ABS(sr.num%-sr.num.a%)=2 THEN
   j%=2
 END IF
 WHILE j%>0
   j%=j%-1
   jj%=((sr.num%+j%) MOD 4) 
   FOR i%=0 TO s.truppe%-1
     PUT (r.start%+i%*12,182),reiter%(0,jj%),PSET
     IF ruesten%=0 THEN
       PUT (4+sx%*12,sy%*12),reiter%(0,jj%),PSET
     END IF
   NEXT i%
   PAUSE(10)
 WEND
RETURN
c.trupp:
 cr.num.a%=cr.num%
 cr.num%=-(cwx%=-1)*2-(cwy%=1)-(cwy%=-1)*3
 j%=1
 IF ABS(cr.num%-cr.num.a%)=2 THEN
   j%=2
 END IF
 WHILE j%>0
   j%=j%-1
   jj%=(((cr.num%+j%) MOD 4)+4) 
   FOR i%=0 TO c.truppe%-1
     PUT (r.start%+i%*12,182),reiter%(0,jj%),PSET
     IF ruesten%=0 THEN
       PUT (4+cx%*12,cy%*12),reiter%(0,jj%),PSET
     END IF
   NEXT i%
   PAUSE(10)
 WEND
RETURN
'
t.puffer:
  pause(50)
  GOSUB e.leer
  while strig(3)<>0 or strig(2)<>0:wend
return
taste.auswerten.spieler:
 ' Spielervars fÜr Zug auf 0
 ' x-y-Pfeiltasten
 ' ESC-MenÜ
 ' Help-toggle computer
 r.start%=(320-s.truppe%*12) \ 2
 LINE (0,181)-(319,194),0 ,BF
 FOR i%=0 TO s.truppe%-1
   PUT (r.start%+i%*12,182),reiter%(0,sr.num% ),PSET
 NEXT i%
 GOSUB e.leer
 WHILE (ta% <> 13 AND sp.eingabe%(0)=2) OR (mk% <> -1 AND sp.eingabe%(0)=0) OR (mk%<>-2 AND sp.eingabe%(0)=1)
   joy%=0
   Joy.ab
REM $OPTION +A
   ' F1 - Taste
   IF ta%=129 THEN
     GOSUB computersteuerung
     IF computer%=0 THEN
       GOSUB c.name
     END IF
     gosub t.puffer
   END IF
   IF ta%=130 THEN
     GOSUB schnell
     gosub t.puffer
   END IF
   IF ta% = 131 THEN
     GOSUB hisc.zeig
     gosub t.puffer
     CLS
     GOSUB restau.feld
   END IF
  IF ta%=138 THEN
     GOsub zuende
     gosub t.puffer
   END IF
REM $OPTION -A
   IF mk%<>0 AND sp.eingabe%(0)=0 THEN
     IF mx%<52 AND my%>120 AND my%<168 THEN
       GOSUB s.men
       GOSUB e.leer
     END IF
   END IF
   IF sp.eingabe%(0)=1 AND Joy%<>0 and mk%=-2 THEN
     GOSUB s.men
     GOSUB e.leer
   END IF
   '    PRINT AT(1,1);sp.eingabe%(0)'mk%'joy%;" "
   IF sp.eingabe%(0)=0 THEN
     IF INT(mx% \ 64) <> INT(mx.a% \ 64) THEN
       ry%=0
       rx%=(mx% < mx.a%)-(mx% > mx.a%)
       GOSUB s.trupp
     END IF
     IF INT(my% \ 64) <> INT(my.a% \ 64) THEN
       rx%=0
       ry%=(my% < my.a%)-(my% > my.a%)
       GOSUB s.trupp
     END IF
     mx.a%=mx%
     my.a%=my%
   END IF
   ' ta%=ASC(RIGHT$(INKEY$))
   IF ta%=27 AND sp.eingabe%(0)=2 THEN
     GOSUB s.men
     GOSUB e.leer
   END IF
   IF sp.eingabe%(0)=2 THEN
     IF ta% <> 13 THEN
       IF ta% > 27 AND ta% < 32 THEN
         rx%=-(ta%=30)+(ta%=31)
         ry%=-(ta%=29)+(ta%=28)
         GOSUB s.trupp
       END IF
     END IF
   END IF
   IF sp.eingabe%(0)=1 THEN
     IF Joy%=1 OR Joy%=2 OR Joy%=4 OR Joy%=8 THEN
       rx%=(Joy%=4)-(Joy%=8)
       ry%=(Joy%=1)-(Joy%=2)
       GOSUB s.trupp
       pause(50)
       gosub e.leer
     END IF
   END IF
   IF sx%+rx% > 25 OR sx%+rx% < 0 OR sy%+ry% > 14 OR sy%+ry% < 0 THEN
     IF ta%=13 OR mk%<>0 THEN
       LOCATE 1,1: PRINT ; kling$
       GOSUB e.leer
     END IF
   END IF
   IF ta%=13 OR mk% <> 0 THEN
     IF feld%(sx%+rx%,sy%+ry%)=100 OR feld%(sx%+rx%,sy%+ry%)=101 THEN
       CALL fehler(4,"Geht nicht!")
       GOSUB e.leer
     END IF
     IF rx%=0 AND ry%=0 THEN
       rx%=-(sr.num%=0)+(sr.num%=2)
       ry%=-(sr.num%=1)+(sr.num%=3)
     END IF
   END IF
   IF sx%+rx%=cx% AND sy%+ry%=cy% THEN
     rx%=0
     ry%=0
   END IF
 WEND
 gosub e.leer
RETURN
taste.auswerten.computer:
 ' tastenauswertung
 r.start%=(320-c.truppe%*12) \ 2
 LINE (0,181)-(319,194),0 ,BF
 FOR i%=0 TO c.truppe%-1
   PUT (r.start%+i%*12,182),reiter%(0,(cr.num%+4) ),PSET
 NEXT i%
 GOSUB e.leer
 WHILE (ta% <> 13 AND sp.eingabe%(1)=2) OR (mk% <> -1 AND sp.eingabe%(1)=0) OR (mk%<>-2 AND sp.eingabe%(1)=1)
   Joy%=0
   Joy.ab
   IF mk%<>0 AND sp.eingabe%(1)=0 THEN
     IF mx%>256 AND my%<48 THEN
       GOSUB c.men
       GOSUB e.leer
     END IF
   END IF
   '    PRINT AT(60,1);sp.eingabe%(1)=1 AND mk%=1 AND joy%=2'sp.eingabe%(1)=1'mk%=1'joy%=2;"   "
   IF sp.eingabe%(1)=1 AND mk%=-2 AND Joy%<>0 THEN
     GOSUB c.men
     GOSUB e.leer
   END IF
   IF sp.eingabe%(1)=0 THEN
     IF INT(mx% \ 48) <> INT(mx.a% \ 48) THEN
       cwy%=0
       cwx%=(mx% < mx.a%)-(mx% > mx.a%)
       GOSUB c.trupp
     END IF
     IF INT(my% \ 48) <> INT(my.a% \ 48) THEN
       cwx%=0
       cwy%=(my% < my.a%)-(my% > my.a%)
       GOSUB c.trupp
     END IF
     mx.a%=mx%
     my.a%=my%
   END IF
   ' ta%=ASC(RIGHT$(INKEY$))
   IF ta%=27 AND sp.eingabe%(1)=2 THEN
     GOSUB c.men
     GOSUB e.leer
   END IF
REM $OPTION +A
   IF ta%=131 THEN
     GOSUB zuende
     GOSUB e.leer
   END IF
REM $OPTION -A
   IF sp.eingabe%(1)=2 THEN
     IF ta% <> 13 THEN
       IF ta% > 27 AND ta% < 32 THEN
         cwx%=-(ta%=30)+(ta%=31)
         cwy%=-(ta%=29)+(ta%=28)
         GOSUB c.trupp
       END IF
     END IF
   END IF
   IF sp.eingabe%(1)=1 THEN
     IF Joy%=1 OR Joy%=2 OR Joy%=4 OR Joy%=8 THEN
       cwx%=(Joy%=4)-(Joy%=8)
       cwy%=(Joy%=1)-(Joy%=2)
       PAUSE(20)
       GOSUB c.trupp
     END IF
   END IF
'locate 1,1:? cx%;cy%;cwx%;cwy%;feld%(cx%,cy%)"  "
   IF cx%+cwx% > 25 OR cx%+cwx% < 0 OR cy%+cwy% > 14 OR cy%+cwy% < 0 THEN
     IF ta%=13 OR mk%<>0 THEN
: LOCATE 1,1: PRINT ; kling$
       GOSUB e.leer
     END IF
   END IF
   IF ta%=13 OR mk% <> 0 THEN
'locate 2,1:? cx%;cy%;cwx%;cwy%;feld%(cx%+cwx%,cy%+cwy%)"  "
     IF feld%(cx%+cwx%,cy%+cwy%)=-100 OR feld%(cx%+cwx%,cy%+cwy%)=-101 THEN
       CALL fehler(4,"Geht nicht!")
       GOSUB e.leer
     END IF
     IF cwx%=0 AND cwy%=0 THEN
       cwx%=-(cr.num%=0)+(cr.num%=2)
       cwy%=-(cr.num%=1)+(cr.num%=3)
     END IF
   END IF
   IF cx%+cwx%=sx% AND cy%+cwy%=sy% THEN
     '      @fehler(0,"Geht nicht!")
     cwx%=0
     cwy%=0
   END IF
  WEND
 gosub e.leer
RETURN
'
e.leer:
 joy%=0
 mk%=0
 ta%=0
' while strig(3)=-1:wend
 WHILE MOUSE(0)<>0 OR INKEY$>"" OR STRIG(2)<>0:WEND
 while strig(3)<>0:wend
RETURN

s.men:
 GOSUB s.men.restau
 mk%=0
 w%=0
 ta%=0
 WHILE ta% <> 27 AND w% <> 7
   CALL SetApen&(rp&,15)
   LOCATE 2,2: PRINT ; USING "Felder: ###"; s.felder.ges%;
   LOCATE 3,2: PRINT ; USING "Punkte:####"; s.feldp.ges%;
   LOCATE 4,2: PRINT ; USING "Ritter:  ##"; s.truppe%;
   LOCATE 5,2: PRINT ; USING "Kasse :####"; s.geld%;
   CALL bmen(0,6,42,66,24,4)
'   IF sp.eingabe%(0)=1 AND mk%=-1 THEN
'     mk%=1
'   END IF
   IF (mk%<>0 AND sp.eingabe%(0) <> 2) OR (ta%=13 AND sp.eingabe%(0)=2) THEN
     ON w%+1 GOSUB vergleich,s.steuern,s.ruesten,s.castel,s.legende,cast.zust,disk.op
   END IF
   GOSUB e.leer
 WEND
 PUT (4,4),temp%,PSET
 GOSUB e.leer
RETURN
s.men.restau:
 GET (4,4)-(104,92),temp%
 LINE (4,4)-(104,92),0,BF
 CALL rand(4,4,104,92,1)
 FOR i%=0 TO 3
   PUT (6+i%*24,42),b.men%(0,i%),PSET
   PUT (6+i%*24,66),b.men%(0,(i%+4) ),PSET
 NEXT i%
RETURN
'
c.men:
 GOSUB c.men.restau
 mk%=0
 w%=0
 ta%=0
 WHILE ta% <> 27 AND w% <> 7
   CALL SetApen&(rp&,15)
   LOCATE 12,28: PRINT  USING "Felder: ###"; c.felder.ges%;
   LOCATE 13,28: PRINT  USING "Punkte:####"; c.feldp.ges%;
   LOCATE 14,28: PRINT  USING "Ritter:  ##"; c.truppe%;
   LOCATE 15,28: PRINT  USING "Kasse :####"; c.geld%;
   CALL bmen(0,216,122,146,24,4)
'   IF sp.eingabe%(1)=1 AND mk%=2 THEN
'     mk%=1
'   END IF
   IF (mk%<>0 AND sp.eingabe%(1) <> 2) OR (ta%=13 AND sp.eingabe%(1)=2) THEN
     ON w%+1 GOSUB vergleich,c.steuern,c.ruesten,c.castel,c.legende,cast.zust,disk.op
   END IF
   GOSUB e.leer
 WEND
 PUT (213,84),temp%,PSET
 GOSUB e.leer
RETURN
c.men.restau:
 GET (213,84)-(314,172),temp%
 LINE (213,84)-(314,172),0 ,BF
   CALL rand(213,84,314,172,1)
   FOR i%=0 TO 3
     PUT (216+i%*24,122),b.men%(0,i% ),PSET
     PUT (216+i%*24,146),b.men%(0,(i%+4) ),PSET
   NEXT i%
RETURN
'
s.steuern:
 PUT (4,4),temp%,PSET
 GOSUB s.steuer.rein
 GOSUB s.spielstand
 PUT (4+sx%*12,sy%*12),reiter%(0,sr.num% ),PSET
 IF belager%=0 THEN
   GOSUB s.men.restau
 END IF
RETURN
s.steuer.rein:
 PUT (4,4),temp%,PSET
 FOR j%=0 TO 14
   FOR i%=0 TO 25
     IF feld%(i%,j%) < 0 AND feld%(i%,j%) > -21 THEN
       feld%(i%,j%)=feld%(i%,j%)+1
       s.geld%=s.geld%+1
       PUT (4+i%*12,j%*12),reiter%(0,sr.num% ),PSET
       IF feld%(i%,j%)=0 THEN
         PUT (4+i%*12,j%*12),wald%(0,2 ),PSET
       ELSE
         PUT (4+i%*12,j%*12),hof%(0,(ABS(feld%(i%,j%))-1) ),PSET
       END IF
     END IF
   NEXT i%
 NEXT j%
 PUT (4+sx%*12,sy%*12),reiter%(0,sr.num% ),PSET
RETURN
c.steuern:
 IF computer%=0 THEN
   PUT (213,84),temp%,PSET
 END IF
 GOSUB c.steuer.rein
 GOSUB c.spielstand
 PUT (4+cx%*12,cy%*12),reiter%(0,(cr.num%+4) ),PSET
 IF computer%=0 THEN
   IF belager%=0 THEN
     GOSUB c.men.restau
   END IF
 END IF
RETURN
c.steuer.rein:
 FOR j%=0 TO 14
   FOR i%=0 TO 25
     IF feld%(i%,j%) > 0 AND feld%(i%,j%) < 21 THEN
       feld%(i%,j%)=feld%(i%,j%)-1
       c.geld%=c.geld%+1
       PUT (4+i%*12,j%*12),reiter%(0,(cr.num%+4) ),PSET
       IF feld%(i%,j%)=0 THEN
         PUT (4+i%*12,j%*12),wald%(0,2 ),PSET
       ELSE
         PUT (4+i%*12,j%*12),hof%(0,(19+feld%(i%,j%)) ),PSET
       END IF
     END IF
   NEXT i%
 NEXT j%
 PUT (4+cx%*12,cy%*12),reiter%(0,(cr.num%+4) ),PSET
RETURN
'
s.castel:
 IF s.cast% < 5 THEN
   PUT (4,4),temp%,PSET
   FOR px%=1 TO 22
     FOR py%=1 TO 11
       gruppe%=1
       IF feld%(px%,py%) < 0 AND feld%(px%,py%) > -21 THEN
         FOR gx%=0 TO 2
           FOR gy%=0 TO 2
             IF feld%(px%+gx%,py%+gy%) >= 0 OR feld%(px%+gx%,py%+gy%) < -99 THEN
               gruppe%=0
               gx%=2
               gy%=2
             END IF
             IF cx%=px%+gx% AND cy%=py%+gy% THEN
               gruppe%=0
               gx%=2
               gy%=2
             END IF
           NEXT gy%
         NEXT gx%
         GOSUB umfeld.castell
         ii%=0
         IF gruppe%=1 AND s.cast% < 5 THEN
           WHILE s.cast.pos%(ii%,0) > -1
             ii%=ii%+1
           WEND
           s.cast.pos%(ii%,0)=px%
           s.cast.pos%(ii%,1)=py%
           s.cast.zust%(ii%)=30
           s.cast%=s.cast%+1
           PUT (4+px%*12,py%*12),castell%(0,6),PSET
           FOR gx%=0 TO 2
             FOR gy%=0 TO 2
               feld%(px%+gx%,py%+gy%)=-100
             NEXT gy%
           NEXT gx%
           IF feld%(sx%,sy%)=-100 OR feld%(sx%,sy%)=-101 THEN
             rsfeld%=1
             GET (4+sx%*12,sy%*12)-(4+sx%*12+12-1,sy%*12+12-1),temps%
         END IF
         END IF
       END IF
     NEXT py%
   NEXT px%
   PUT (4+sx%*12,sy%*12),reiter%(0,sr.num%),PSET
   gruppe%=0
   GOSUB s.spielstand
   GOSUB s.men.restau
 ELSE
   CALL fehler(0,"Max. 5 Castelle")
 END IF
RETURN
c.castel:
 IF c.cast% < 5 THEN
   IF computer%=0 THEN
     PUT (213,84),temp%,PSET
   END IF
   FOR px%=1 TO 22
     FOR py%=1 TO 11
       gruppe%=1
       IF feld%(px%,py%) > 0 AND feld%(px%,py%) < 21 THEN
         FOR gx%=0 TO 2
           FOR gy%=0 TO 2
             IF (feld%(px%+gx%,py%+gy%) <= 0) OR (feld%(px%+gx%,py%+gy%) > 20) THEN
               gruppe%=0
               gx%=2
               gy%=2
             END IF
             IF sx%=px%+gx% AND sy%=py%+gy% THEN
               gruppe%=0
               gx%=2
               gy%=2
             END IF
           NEXT gy%
         NEXT gx%
         GOSUB umfeld.castell
         ii%=0
         IF gruppe%=1 AND c.cast% < 5 THEN
           WHILE c.cast.pos%(ii%,0) > -1
             ii%=ii%+1
           WEND
           c.cast.pos%(ii%,0)=px%
           c.cast.pos%(ii%,1)=py%
           c.cast.zust%(ii%)=30
           c.cast%=c.cast%+1
           PUT (4+px%*12,py%*12),castell%(0,0),PSET
           FOR gx%=0 TO 2
             FOR gy%=0 TO 2
               feld%(px%+gx%,py%+gy%)=100
             NEXT gy%
           NEXT gx%
           IF feld%(cx%,cy%)=100 OR feld%(cx%,cy%)=101 THEN
             rcfeld%=1
             GET (4+cx%*12,cy%*12)-(4+cx%*12+12-1,cy%*12+12-1),tempc%
           END IF
         END IF
       END IF
     NEXT py%
   NEXT px%
   gruppe%=0
   PUT (4+cx%*12,cy%*12),reiter%(0,(cr.num%+4) ),PSET
   IF computer%=0 THEN
     GOSUB c.spielstand
     GOSUB c.men.restau
   END IF
 ELSE
   IF computer%=0 THEN
     CALL fehler(0,"Max. 5 Castelle")
   END IF
 END IF
RETURN
umfeld.castell:
 IF gruppe%=1 THEN
   px0%=-(px% > 0)
   py0%=-(py% > 0)
   px1%=3+(px% > 21)
   py1%=3+(py% > 11)
   FOR gx%=px%-px0% TO px%+px1%
     IF ABS(feld%(gx%,py%-py0%))=100 OR ABS(feld%(gx%,py%-py0%))=101 THEN
       gruppe%=0
     END IF
     IF ABS(feld%(gx%,py%+py1%))=100 OR ABS(feld%(gx%,py%+py1%))=101 THEN
       gruppe%=0
     END IF
   NEXT gx%
   FOR gy%=py%-py0% TO py%+py1%
     IF ABS(feld%(px%-px0%,gy%))=100 OR ABS(feld%(px%-px0%,gy%))=101 THEN
       gruppe%=0
     END IF
     IF ABS(feld%(px%+px1%,gy%))=100 OR ABS(feld%(px%+px1%,gy%))=101 THEN
       gruppe%=0
     END IF
   NEXT gy%
 END IF
RETURN
'
s.ruesten:
 IF s.truppe% < 21 THEN
   IF s.geld% > 19 THEN
     s.truppe%=s.truppe%+1
     s.geld%=s.geld%-20
   ELSE
     CALL fehler(0,"Geld reicht nicht!")
   END IF
 ELSE
  CALL fehler(0,"Maximale Ritterzahl!")
 END IF
 r.start%=(320-s.truppe%*12) \ 2
 ruesten%=1
 GOSUB s.trupp
 ruesten%=0
RETURN
c.ruesten:
 IF c.truppe% < 21 THEN
   IF c.geld% > 19 THEN
     c.truppe%=c.truppe%+1
     c.geld%=c.geld%-20
   ELSE
     CALL fehler(0,"Geld reicht nicht!")
   END IF
 ELSE
   CALL fehler(0,"Maximale Ritterzahl!")
 END IF
 r.start%=(320-c.truppe%*12) \ 2
 ruesten%=1
 GOSUB c.trupp
 ruesten%=0
RETURN
'
vergleich:
 GET (84,68)-(238,136),t2%
 CALL rand(84,68,238,136,1)
 PUT (156+16,72),reiter%(0,0),PSET
 PUT (178+40,72),reiter%(0,6 ),PSET
 CALL SetApen&(rp&,15)
 LOCATE 12,12: PRINT  USING "Felder:  ###   ###"; s.felder.ges%,c.felder.ges%
 LOCATE 13,12: PRINT  USING "Punkte: ####  ####"; s.feldp.ges%,c.feldp.ges%
 LOCATE 14,12: PRINT  USING "Ritter:   ##    ##"; s.truppe%,c.truppe%
 LOCATE 15,12: PRINT  USING "Kasse : ####  ####"; s.geld%,c.geld%
 LOCATE 16,12: PRINT  USING "Castelle: ##    ##"; s.cast%,c.cast%
 GOSUB e.leer
REM $OPTION +A
 GOSUB warte
REM $OPTION -A
 PUT (84,68),t2%,PSET
RETURN
'
belager:
 CLS
farb%(1)=&h4A2 'burg
farb%(3)=&h8EE 'burg
CALL loadrgb4&(vp&,VARPTR(farb%(0)),16)
REM $OPTION +A
 GOSUB lad.belager
REM $OPTION -A
 vertei%=1-spieler%
 PUT (160*vertei%,0),b1%(0,vertei%),PSET
 PUT (160*spieler%,0),b1d%(0),PSET
 bo%=215*spieler%
 IF spieler%=1 THEN
   PUT (245,126),schleu%(0,0),PSET
   x.off%=-8
 ELSE
   PUT (15,126),schleu%(0,0),PSET
   x.off%=8
 END IF
 CALL rand(0,181,319,199,1)
 FOR ii%=0 TO 5
   stein%(ii%)=120-30*(ii% \ 2)-RND*30
 NEXT ii%
 w%=0
 ww%=0
 ww.alt%=1
 kugel%=6
 WHILE kugel% > 0
   GOSUB belager.men
'   ww%=ww%+1
 WEND
REM $OPTION +A
 GOSUB warte
REM $OPTION -A
 IF spieler%=1 THEN
   GET (0,0)-(159,180),b1%(0,0)
 ELSE
   GET (160,0)-(319,180),b1%(0,1)
 END IF
 CLS
farb%(1)=&h4C2
farb%(3)=&hEE2
CALL loadrgb4&(vp&,VARPTR(farb%(0)),16)
 f.ani%=1
 GOSUB restau.feld
 f.ani%=0
RETURN
wurf:
 GOSUB schleuder
 POKEW sp.struc&+6,x1%
 POKEW sp.struc&+8,y1%
 num&=GetSprite&(sp.struc&,2)
 IF num&=-1 THEN PRINT "kein freier Sprite":BEEP
 CALL ChangeSprite(0,sp.struc&,sp.dat&)
 stein%(ww%)=-1
 kugel%=kugel%-1
 IF spieler%=0 THEN
   weite%=20+((ww% \ 2)+1)*70+RND*70
 ELSE
   weite%=20+((ww% \ 2)+1)*70+RND*70+sp.staerke%*computer%*4
 END IF
 x%=258
 x1%=319-x%
 IF spieler%=1 THEN
   x1%=x%
 END IF
 y%=75
 y1%=199-y%
 weite%=weite% \ 2
 alpha.cos=2*(v0% ^ 2)*(COS(alpha) ^ 2)
 alpha.tan=TAN(alpha)
' PUT (x1%,y1%),kugel%(0,0),xor
 CALL MoveSprite&(0,sp.struc&,x1%,y1%)  
w.flug:
 WHILE x% > weite%
   xa%=x1%
   ya%=y1%
   xw%=258-x%
   y%=75+xw%*alpha.tan-10 / alpha.cos*xw% ^ 2
   IF y% > 32 AND y% < 199 THEN
     PAUSE(10)
     x1%=319-x%
     IF spieler%=1 THEN
       x1%=x%
     END IF
     y1%=199-y%
     CALL MoveSprite&(0,sp.struc&,x1%,y1%)  
     'PUT (xa%,ya%),kugel%(0,0),xor
     'PUT (x1%,y1%),kugel%(0,0),xor
'      SOUND 1,12,per%
   END IF
   x%=x%-1
 WEND
' PUT (x1%,y1%),kugel%(0,0),xor
'  WAVE 0,0
' PUT (x1%,y1%),tempo%,PSET
 CALL FreeSprite&(num&)
 GOSUB p.test
 IF p%<2 or p1%<2 THEN
   weite%=weite%-10
   IF weite% > 0 THEN
     GOTO w.flug
   END IF
 END IF
'  SOUND 1,15,#per,1
'  WAVE 31*256+9,1,9,65535
 PAUSE(10)
'  WAVE 0,0
RETURN
p.test:
 p%=0
 p1%=0
 IF y1% > 5 THEN
   FOR i%=0 TO 5
     p%=p%-(POINT(x1%+4,y1%+i%-3)<>3)
     p1%=p1%-(POINT(x1%+10,y1%+i%-3)<>3)
   NEXT i%
 END IF
 IF p% > 1 AND p1% > 1 AND y1% < 140 and x% < 150 THEN
   GOSUB trefferloch
   GOSUB treffer
 END IF
RETURN
trefferloch:   
 CIRCLE (x1%+9+(spieler%=0)*2,y1%+5),3,15,,,3  
 FOR i%=0 TO 3
   CIRCLE (x1%+8,y1%+5),i%,0,,,3
 NEXT i%
 FOR i%=0 TO 60
   xi%=RND*4-10
   yi%=10+RND*(i% \ 2)
   PSET (x1%-xi%,y1%+yi%),0
 NEXT i%
RETURN

treffer:
 IF burg.treff%(vertei%,0)=0 AND x% > 1 AND x% < 32+x.off% AND y1% > 4 AND y1% < 49 THEN
   burg.treff%(vertei%,0)=1
   FOR jji%=0 TO 4
     IF spieler%=1 THEN
       PUT (6,9),b.ani2%(0,jji%),PSET
       LINE (5, 37)-(5, 39), 3
       LINE (15, 7)-(25, 9), 3, BF
     ELSE
       PUT (288,9),b.ani2%(0,jji%),PSET
       LINE (314, 37)-(314, 39), 3
       LINE (304, 7)-(294, 9), 3, BF
     END IF
     GOSUB treff.sound
   NEXT jji%
REM $OPTION +A
   GOSUB pruef.ende
REM $OPTION -A
 END IF
 IF burg.treff%(vertei%,1)=0 AND x% > 48+x.off% AND x% < 78+x.off% AND y1% > 8 AND y1% < 41 THEN
   burg.treff%(vertei%,1)=1
   FOR jji%=0 TO 4
     IF spieler%=1 THEN
       LINE (49,0)-(91,3),3 ,BF
       PUT (49,1),b.ani5%(0,jji%),PSET
     ELSE
       LINE (239,0)-(281,3),3 ,BF
       PUT (239,1),b.ani5%(0,jji%),PSET
     END IF
     GOSUB treff.sound
   NEXT jji%
REM $OPTION +A
   GOSUB pruef.ende
REM $OPTION -A
 END IF
 IF burg.treff%(vertei%,2)=0 AND x% > 100+x.off% AND x% < 130+x.off% AND y1% > 20 AND y1% < 53 THEN
   burg.treff%(vertei%,2)=1
   FOR jji%=0 TO 4
       IF spieler%=1 THEN
         LINE (105,4)-(147,9),3 ,BF
         PUT (105,9),b.ani3%(0,jji%),PSET
       ELSE
         LINE (183,4)-(225,9),3,BF
         PUT (183,9),b.ani3%(0,jji%),PSET
       END IF
     GOSUB treff.sound
   NEXT jji%
REM $OPTION +A
   GOSUB pruef.ende
REM $OPTION -A
 END IF
 IF burg.treff%(vertei%,3)=0 AND x% > 129+x.off% AND x% < 159+x.off% AND y1% > 81 AND y1% < 115 THEN
   burg.treff%(vertei%,3)=1
   FOR jji%=0 TO 4
       IF spieler%=1 THEN
         PUT (137,73),b.ani1%(0,jji%),PSET
       ELSE
         PUT (160,73),b.ani1%(0,jji%),PSET
       END IF
     GOSUB treff.sound
   NEXT jji%
REM $OPTION +A
   GOSUB pruef.ende
REM $OPTION -A
 END IF
 IF burg.treff%(vertei%,4)=0 AND x% > 79+x.off% AND x% < 109+x.off% AND y1% > 83 AND y1% < 117 THEN
   burg.treff%(vertei%,4)=1
   FOR jji%=0 TO 4
       IF spieler%=1 THEN
         PUT (81,71),b.ani4%(0,jji%),PSET
       ELSE
         PUT (207,71),b.ani4%(0,jji%),PSET
       END IF
     GOSUB treff.sound
   NEXT jji%
   GOSUB pruef.ende
 END IF
RETURN
treff.sound:
'  SOUND 1,15,#per,1
'  WAVE (31-i%)*256+9,1,9,65535
 PAUSE(300)
'  WAVE 0,0
RETURN
belager.men:
 GET (2+bo%,1)-(103+bo%,78),temp%
 CALL rand(2+bo%,1,103+bo%,78,1)
 FOR ii%=0 TO 5
   IF stein%(ii%) > 0 THEN
     PUT (5+bo%+ii%*16,59),kugel%(0,(ii%\2))
   END IF
 NEXT ii%
 PUT (5+bo%,28),b.men%(0,13 ),PSET
 PUT (5+bo%+24,28),b.men%(0,12),PSET
 PUT (5+bo%+48,28),b.men%(0,11),PSET
 PUT (5+bo%+72,28),b.men%(0,10),PSET
 LINE (5+bo%,27)-(100+bo%,27),15
 LINE (5+bo%,52)-(100+bo%,52),15
 LINE (61+bo%,4)-(61+bo%,28),15
 GOSUB winkel
 GOSUB steine
 raus%=0
 IF computer%=0 OR spieler%=0 THEN
   WHILE raus%<>2
     CALL bmen(2,5+bo%,28,0,24,4)
     IF raus%=1 THEN
       IF w% < 2 THEN
         ws%=ws%+(w%=1)-(w%=0)
         GOSUB winkel
       ELSE
         GOSUB steine
       END IF
     END IF
   WEND
 ELSE
   GOSUB computer.belagert
 END IF
   PUT (2+bo%,1),temp%,PSET
 GOSUB wurf
RETURN
computer.belagert:
 w%=2
 ww.alt%=ww%
 ww.alt%=ww.alt% MOD 6
 GOSUB steine
 c.winkel% =65-v0%*(.35-(sp.staerke%>3)*.03)
 IF burg.treff%(0,0)=1 AND burg.treff%(0,1)=1 AND burg.treff%(0,2)=1 THEN
   c.winkel%=(c.winkel% \ 2)-(ww% > 3)*2.5
 END IF
 c.winkel%=FNmin%(c.winkel%,60)
 c.winkel%=FNmax%(c.winkel%,10)
 WHILE c.winkel% <> ws%
   w%=-(c.winkel% < ws%)
   ws%=ws%+(w%=1)-(w%=0)
   GOSUB winkel
 WEND
RETURN
winkel:
 ws%=FNmin%(ws%,60)
 ws%=FNmax%(ws%,10)
 alpha=ws%*3.14 / 180
 LINE (13+bo%,4)-(60+bo%,25),0 ,BF
 LINE (20+bo%,25)-(54+bo%,25),15
 IF spieler%=1 THEN
   LINE (270-COS(alpha)*22,25-SIN(alpha)*22)-(270,25),15
   LOCATE 2,29: PRINT RIGHT$(STR$(ws%),2);CHR$(176);
 ELSE
   LINE (20,25)-(33+COS(alpha)*20,25-SIN(alpha)*22),15
   LOCATE 2,2: PRINT RIGHT$(STR$(ws%),2);CHR$(176);
 END IF
 PAUSE(180)
RETURN
steine:
 IF w% < 2 THEN
   w%=3
 END IF
erhoehe:
 ww%=ww%-(w%=3)+(w%=2)
 ww%=ww% MOD 6
 IF ww% < 0 THEN
   ww%=5
 END IF
 IF stein%(ww%)=-1 THEN
   GOTO erhoehe
 END IF
 IF ww% <> ww.alt% AND stein%(ww.alt%) > -1 THEN
   PUT (5+bo%+ww.alt%*16,59),kugel%(0,ww.alt%\2)
 END IF
 v0%=(stein%(ww%)+RND*40)*.7
 LINE (5+bo%+ww%*16,59)-(20+ww%*16+bo%,74),0 ,BF
 LINE (62+bo%,4)-(100+bo%,26),0 ,BF
 PUT (69+bo%,10),kugel%(0,ww%\2)
 PAUSE(300)
 ww.alt%=ww%
 ww.alt%=ww.alt% MOD 6
RETURN
schleuder:
 FOR i%=7 TO 0 STEP -1
   PAUSE(i%*50)
     IF spieler%=1 THEN
       PUT (245,126),schleu%(0,i%),PSET
     ELSE
       PUT (15,126),schleu%(0,i%),PSET
     END IF
 NEXT i%
'  SOUND 1,15,100,1
'  WAVE i%*256+9,1,9,65535
 FOR i%=0 TO 2
   PAUSE(i%*75)
     IF spieler%=1 THEN
       PUT (245,126),schleu%(0,i%),PSET
     ELSE
       PUT (15,126),schleu%(0,i%),PSET
     END IF
 NEXT i%
'  WAVE 0,0
RETURN
'
disk.op:
 GET (134,74)-(186,102),t2%
 CALL rand(134,74,186,102,1)
 PUT (136,76),b.men%(0,14 ),PSET
 PUT (160,76),b.men%(0,15 ),PSET
 w%=0
 gosub e.leer
 CALL bmen(1,136,76,0,24,2)
 PUT (134,74),t2%,PSET
 IF spieler%=0 THEN
   PUT (4,4),temp%,PSET
 ELSE
   PUT (213,84),temp%,PSET
 END IF
 jj%=spieler%
 IF mk%<>0 OR ta%=13 THEN
   a$=" Datendisk einlegen!| Ok *1"
   al.neu (a$)
   pause(4000)
   ON w%+1 GOSUB laden,speichern
   a$=" Programmdisk zurÜck | Ok *1"
   al.neu (a$)
   pause(4000)
 END IF
 IF jj%=0 THEN
   GOSUB s.men.restau
 ELSE
   GOSUB c.men.restau
 END IF
 w%=0
 gosub e.leer
RETURN
speichern:
 e$=""
 GET(68,69)-(235,83),temp%
 CALL rand(68,69,235,83,1)
 CALL eingabe(10,10,12)
 f$=e$
 i%=0
 if f$="" then goto sp.end
 IF INSTR(f$,":") THEN
   i%=INSTR(f$,":")
   a$=UCASE$(LEFT$(f$,i%))
 END IF
 IF i%=0 THEN
   f$="DF0:"+f$
   a$="DF0:"
 END IF 
 IF a$="DF0:" OR a$="DF1:" OR a$="DF2:" OR a$="DH0:" OR a$="DH1:" OR a$="DH2:" THEN
   OPEN "o",#1,f$
   PRINT #1,spieler%
   PRINT #1,computer%
   PRINT #1,sx%
   PRINT #1,sp.staerke%
   PRINT #1,sy%
   PRINT #1,rsfeld%

   PRINT #1,saltx%
   PRINT #1,salty%
   PRINT #1,sxm%
   PRINT #1,sym%
   PRINT #1,sr.num%
   PRINT #1,cx%
   PRINT #1,cy%
   PRINT #1,s.truppe%
   PRINT #1,s.felder.ges%
   PRINT #1,s.feldp.ges%
   '    PRINT #1,n.s.felder%
   PRINT #1,s.felder.ges.alt%
   '    PRINT #1,n.s.punkte%
   PRINT #1,s.feldp.ges.alt%
   PRINT #1,s.geld%
   PRINT #1,c.felder.ges%
   PRINT #1,c.feldp.ges%
   PRINT #1,c.truppe%
   PRINT #1,c.geld%
   '    PRINT #1,r.start%
   '    PRINT #1,sr.num.a%
   PRINT #1,durchgang%
   PRINT #1,altcx%
   PRINT #1,altcy%
   PRINT #1,cxm%
   PRINT #1,cym%
   PRINT #1,cr.num%
   '    PRINT #1,cr.num.a%
   '    PRINT #1,n.c.felder%
   PRINT #1,c.felder.ges.alt%
   PRINT #1,rcfeld%
   PRINT #1,c.feldp.ges.alt%
   PRINT #1,c.cast%
   PRINT #1,s.cast%
   PRINT #1,spname$(0)
   PRINT #1,spname$(1)
   PRINT #1,sp.eingabe%(0)
   PRINT #1,sp.eingabe%(1)
   FOR j%=0 TO 14
     FOR i%=0 TO 25
     PRINT #1, feld%(i%,j%)
     NEXT i%
   NEXT j%
   FOR i%=0 TO 20
     PRINT #1, fws%(i%)
     PRINT #1, fwc%(i%)
   NEXT i%
   FOR i%=0 TO 4
     PRINT #1, s.cast.zust%(i%)
     PRINT #1, c.cast.zust%(i%)
     FOR j%=0 TO 1
       PRINT #1, s.cast.pos%(i%,j%)
       PRINT #1, c.cast.pos%(i%,j%)
       PRINT #1, burg.treff%(j%,i%)
     NEXT j%
   NEXT i%
   CLOSE #1
 f$=f$+".pic"+CHR$(0)
 fhandle&=xOpen&(SADD(f$),1006)
 IF fhandle&>0 THEN
  ok&=xWrite&(fhandle&,VARPTR(b1%(0,0)),14486&)
  ok&=xWrite&(fhandle&,VARPTR(b1%(0,1)),14486&)
  CALL xClose&(fhandle&)
 END IF
 END IF
 sp.end:
 puT(68,69),temp%,pset
RETURN
laden:
 GET(68,69)-(235,83),temp%
 CALL rand(68,69,235,83,1)
 fehl%=0
 e$=""
 CALL eingabe(10,10,12)
 if e$="" then 
   fehl%=1
   puT(68,69),temp%,pset
   goto la.end
 end if
 f1$=e$+".pic"+CHR$(0)
 f$=e$+CHR$(0)
 fhandle&=xOpen&(SADD(f$),1005)
 IF fhandle&>0 THEN
   CALL xClose&(fhandle&)
   OPEN "i",#1,f$
   INPUT #1,spieler%
   CLOSE #1
   IF spieler%=jj% THEN
     OPEN "i",#1,f$
     INPUT #1,spieler%
     INPUT #1,computer%
     INPUT #1,sx%
     INPUT #1,sp.staerke%
     INPUT #1,sy%
     INPUT #1,rsfeld%
     INPUT #1,saltx%
     INPUT #1,salty%
     INPUT #1,sxm%
     INPUT #1,sym%
     INPUT #1,sr.num%
     INPUT #1,cx%
     INPUT #1,cy%
     INPUT #1,s.truppe%
     INPUT #1,s.felder.ges%
     INPUT #1,s.feldp.ges%
     '      INPUT #1,n.s.felder%
     INPUT #1,s.felder.ges.alt%
     '     INPUT #1,n.s.punkte%
     INPUT #1,s.feldp.ges.alt%
     INPUT #1,s.geld%
     INPUT #1,c.felder.ges%
     INPUT #1,c.feldp.ges%
     INPUT #1,c.truppe%
     INPUT #1,c.geld%
     '      INPUT #1,r.start%
     '      INPUT #1,sr.num.a%
     INPUT #1,durchgang%
     INPUT #1,altcx%
     INPUT #1,altcy%
     INPUT #1,cxm%
     INPUT #1,cym%
     INPUT #1,cr.num%
     '      INPUT #1,cr.num.a%
     '      INPUT #1,n.c.felder%
     INPUT #1,c.felder.ges.alt%
     INPUT #1,rcfeld%
     INPUT #1,c.feldp.ges.alt%
     INPUT #1,c.cast%
     INPUT #1,s.cast%
     LINE INPUT #1,spname$(0)
     LINE INPUT #1,spname$(1)
     INPUT #1,sp.eingabe%(0)
     INPUT #1,sp.eingabe%(1)
   FOR j%=0 TO 14
     FOR i%=0 TO 25
     INPUT #1, feld%(i%,j%)
     NEXT i%
   NEXT j%
   FOR i%=0 TO 20
     INPUT #1, fws%(i%)
     INPUT #1, fwc%(i%)
   NEXT i%
   FOR i%=0 TO 4
     INPUT #1, s.cast.zust%(i%)
     INPUT #1, c.cast.zust%(i%)
     FOR j%=0 TO 1
       INPUT #1, s.cast.pos%(i%,j%)
       INPUT #1, c.cast.pos%(i%,j%)
       INPUT #1, burg.treff%(j%,i%)
     NEXT j%
   NEXT i%
   CLOSE #1
   fhandle&=xOpen&(SADD(f1$),1005)
   IF fhandle&>0 THEN
     ok&=xRead&(fhandle&,VARPTR(b1%(0,0)),14486&)
     ok&=xRead&(fhandle&,VARPTR(b1%(0,1)),14486&)
     CALL xClose&(fhandle&)
   END IF
   LINE (0,181)-(319,193+1),0 ,BF
   puT(68,69),temp%,pset
   GOSUB restau.feld
   ELSE
     puT(68,69),temp%,pset
     a$=" Dieser Spielstand muß | von "+spname$(spieler%)+" | geladen werden."
     a$=a$+"|Weiter*1"
     al.neu (a$)
     spieler%=jj%
   END IF
 END IF
 la.end:
RETURN
'
restau.feld:
 cls
 LINE(0,0)-(3,180),11 ,BF
 LINE (316,0)-(319,180),11 ,BF
 LINE (0,180)-(319,180),11
 FOR j%=0 TO 14
   FOR i%=0 TO 25
     IF feld%(i%,j%) > 253 THEN
       PUT (4+i%*12,j%*12),wald%(0,(255-feld%(i%,j%)) ),PSET
     END IF
     IF ABS(feld%(i%,j%)) < 100 THEN
       IF feld%(i%,j%)=0 THEN
         PUT (4+i%*12,j%*12),wald%(0,2 ),PSET
       ELSE
         IF feld%(i%,j%) > 0 THEN
           PUT (4+i%*12,j%*12),hof%(0,(19+feld%(i%,j%)) ),PSET
         ELSE
           PUT (4+i%*12,j%*12),hof%(0,(ABS(feld%(i%,j%))-1) ),PSET
         END IF
       END IF
     END IF
   NEXT i% 
 NEXT j%
 PUT (268,0),burgc%,PSET
 PUT (4,132),burgs%,PSET
 i%=0
 WHILE i% <= 4
   IF s.cast.pos%(i%,0) > -1 THEN
     ij%=11-(s.cast.zust%(i%) \ 6)
     PUT (4+s.cast.pos%(i%,0)*12,s.cast.pos%(i%,1)*12),castell%(0,ij%),PSET
   END IF
   i%=i%+1
 WEND
 i%=0
 WHILE i% <= 4
   IF c.cast.pos%(i%,0) > -1 THEN
     ij%=5-(c.cast.zust%(i%) \ 6)
     PUT (4+c.cast.pos%(i%,0)*12,c.cast.pos%(i%,1)*12),castell%(0,ij%),PSET
   END IF
   i%=i%+1
 WEND
 IF feld%(sx%,sy%)=-100 OR feld%(sx%,sy%)=-101 THEN
   rsfeld%=1
   GET (4+sx%*12,sy%*12)-(4+sx%*12+11,sy%*12+11),temps%
 END IF
 IF feld%(cx%,cy%)=100 OR feld%(cx%,cy%)=101 THEN
   rcfeld%=1
   GET (4+cx%*12,cy%*12)-(4+cx%*12+11,cy%*12+11),tempc%
 END IF
 PUT (4+cx%*12,cy%*12),reiter%(0,(cr.num%+4) ),PSET
 PUT (4+sx%*12,sy%*12),reiter%(0,sr.num% ),PSET
 FOR i%=0 TO 4
   IF burg.treff%(0,i%)=1 THEN
     ix%=b.treffxy%(0,i%*2)
     iy%=b.treffxy%(0,i%*2+1)
     IF f.ani%=1 THEN
       GOSUB treff.sound
       FOR j%=0 TO 4
        if i%=0 then PUT (ix%,iy%),burgteil1%(0,j%),pset
        if i%=1 then PUT (ix%,iy%),burgteil2%(0,j%),pset
        if i%=2 then PUT (ix%,iy%),burgteil3%(0,j%),pset
        if i%=3 then PUT (ix%,iy%),burgteil4%(0,j%),pset
        if i%=4 then PUT (ix%,iy%),burgteil5%(0,j%),pset
        PAUSE(250)
       NEXT j%
     ELSE
       if i%=0 then PUT (ix%,iy%),burgteil1%(0,4),pset
       if i%=1 then PUT (ix%,iy%),burgteil2%(0,4),pset
       if i%=2 then PUT (ix%,iy%),burgteil3%(0,4),pset
       if i%=3 then PUT (ix%,iy%),burgteil4%(0,4),pset
       if i%=4 then PUT (ix%,iy%),burgteil5%(0,4),pset
       PAUSE(250)
     END IF
   END IF
 NEXT i%
 FOR i%=0 TO 4
   IF burg.treff%(1,i%)=1 THEN
     ix%=b.treffxy%(1,i%*2)
     iy%=b.treffxy%(1,i%*2+1)
     IF f.ani%=1 THEN
       GOSUB treff.sound
       FOR j%=9 TO 5 STEP -1
         if i%=0 then PUT (ix%,iy%),burgteil1%(0,j%),pset
         if i%=1 then PUT (ix%,iy%),burgteil2%(0,j%),pset
         if i%=2 then PUT (ix%,iy%),burgteil3%(0,j%),pset
         if i%=3 then PUT (ix%,iy%),burgteil4%(0,j%),pset
         if i%=4 then PUT (ix%,iy%),burgteil5%(0,j%),pset
         PAUSE(250)
       NEXT j%
     ELSE
       if i%=0 then PUT (ix%,iy%),burgteil1%(0,5),pset
       if i%=1 then PUT (ix%,iy%),burgteil2%(0,5),pset
       if i%=2 then PUT (ix%,iy%),burgteil3%(0,5),pset
       if i%=3 then PUT (ix%,iy%),burgteil4%(0,5),pset
       if i%=4 then PUT (ix%,iy%),burgteil5%(0,5),pset
       PAUSE(250)
     END IF
   END IF
 NEXT i%
gosub balken
RETURN

f.seek:
  ok&=seek&(fhandle&,position&,offset&)
RETURN  

g.laden.c:
f$="tdb_put"+CHR$(0)
fhandle&=xOpen&(SADD(f$),1005)
IF fhandle&<>0 THEN
ok&=xRead&(fhandle&,VARPTR(burgs%(0)),1158&)
ok&=xRead&(fhandle&,VARPTR(burgc%(0)),1158&)
FOR i%=0 TO 5
  ok&=xRead&(fhandle&,VARPTR(castell%(0,i%)),870&)
NEXT i%
FOR i%=0 TO 5
  ok&=xRead&(fhandle&,VARPTR(castell%(0,11-i%)),870&)
NEXT i%
FOR i%=0 TO 9
  ok&=xRead&(fhandle&,VARPTR(burgteil1%(0,i%)),182&)
NEXT i%
FOR i%=0 TO 9
  ok&=xRead&(fhandle&,VARPTR(burgteil2%(0,i%)),182&)
NEXT i%
FOR i%=0 TO 9
  ok&=xRead&(fhandle&,VARPTR(burgteil3%(0,i%)),118&)
NEXT i%
FOR i%=0 TO 9
  ok&=xRead&(fhandle&,VARPTR(burgteil4%(0,i%)),118&)
NEXT i%
FOR i%=0 TO 9
  ok&=xRead&(fhandle&,VARPTR(burgteil5%(0,i%)),238&)
NEXT i%
FOR i%=0 TO 7
  ok&=xRead&(fhandle&,VARPTR(reiter%(0,i%)),102&)
NEXT i%
FOR i%=0 TO 19
  ok&=xRead&(fhandle&,VARPTR(hof%(0,i%)),102&)
  ok&=xRead&(fhandle&,VARPTR(hof%(0,20+i%)),102&)
NEXT i%
FOR i%=0 TO 2
  ok&=xRead&(fhandle&,VARPTR(wald%(0,i%)),102&)
NEXT i%
FOR i%=0 TO 19
  ok&=xRead&(fhandle&,VARPTR(b.men%(0,i%)),390&)
NEXT i%
FOR i%=0 TO 4
  ok&=xRead&(fhandle&,VARPTR(kugel%(0,i%)),134&)
NEXT i%
  ok&=xRead&(fhandle&,VARPTR(b1%(0,0)),14486&)
  ok&=xRead&(fhandle&,VARPTR(b1%(0,1)),14486&)
CALL xClose&(fhandle&)
ELSE
  CALL fehler(0,"keine Datei")
END IF
RETURN
'
lad.belager:
teil%=0
f$="bani0"+CHR$(0)
IF spieler%=1 THEN
 teil%=1
 f$="bani1"+CHR$(0)
END IF
fhandle&=xOpen&(SADD(f$),1005)
IF fhandle&<>0 THEN
  FOR i%=0 TO 7
    ok&=xRead&(fhandle&,VARPTR(schleu%(0,i%)),1446&)
  NEXT i%
  ok&=xRead&(fhandle&,VARPTR(b1d%(0)),14486&)
  FOR i%=0 TO 4
    ok&=xRead&(fhandle&,VARPTR(b.ani1%(0,i%)),934&)
  NEXT i%
  FOR i%=0 TO 4
    ok&=xRead&(fhandle&,VARPTR(b.ani2%(0,i%)),806&)
  NEXT i%
  FOR i%=0 TO 4
    ok&=xRead&(fhandle&,VARPTR(b.ani3%(0,i%)),1462&)
  NEXT i%
  FOR i%=0 TO 4
    ok&=xRead&(fhandle&,VARPTR(b.ani4%(0,i%)),1334&)
  NEXT i%
  FOR i%=0 TO 4
    ok&=xRead&(fhandle&,VARPTR(b.ani5%(0,i%)),1318&)
  NEXT i%
  CALL xClose&(fhandle&)
END IF
RETURN
'
computersteuerung:
 ' ALERT 0,"  Computersteuerung  ",1," Ja |Nein",but%
 a$=" Computersteuerung | | Ja *Nein*1"
 al.neu (a$)
 computer%=ABS(but%-2)
 while strig(3)<>0 or strig(2)<>0:wend
 IF computer%=1 THEN
   a$="         Level|1*2*3*4*5*5"
   CALL al.neu(a$)
   sp.staerke%=but%+1
   c.spst%=sp.staerke%*2
 ELSE
   c.spst%=0
 END IF
 gosub e.leer
RETURN
schnell:
 a$="         Speed|1*2*3*4*5*"+STR$(5-speed%)
 CALL al.neu(a$)
 speed%=5-but%
RETURN
'
init:
 kling$=CHR$(7)
 sp.staerke%=1
 art&=3+(2^16)
 rek&=0:rk&=VARPTR(rek&)
 sp.struc&=AllocRemember&(rk&,24,art&)
IF sp.struc&=0 THEN PRINT "memory-FEHLER":BEEP
sp.dat&=AllocRemember&(rk&,400,art&)
IF sp.dat&=0 THEN PRINT "memory-FEHLER":BEEP
kugel:
DATA &h0,&h0,&h3C0,&h0,&h7E0,&h100,&h07E0,&h200
DATA &h07E0,&h40,&h0720,&hC0,&h3C0,&h0
RESTORE kugel
FOR i% = 0 TO 27 STEP 2
  READ sd%
  POKEW sp.dat&+i%,sd% AND 65535&
NEXT i%
  spriteStruktur:
  POKEL sp.struc&,0       'SpriteDaten
  POKEW sp.struc&+4,6     'SpriteHoehe
  POKEW sp.struc&+6,10     'PositionX
  POKEW sp.struc&+8,40    'PositionY
  POKEW sp.struc&+10,0    'wird SpriteNummer
RETURN
'
anfangswerte:
 FOR j%=0 TO 14
   FOR i%=0 TO 25
     feld%(i%,j%)=255
   NEXT i%
 NEXT j%
 FOR i%=0 TO 5
    s.cast.pos%(i%,0)=-1
    s.cast.pos%(i%,1)=-1
    c.cast.pos%(i%,0)=-1
    c.cast.pos%(i%,1)=-1
 NEXT i%
 s.truppe%=2
 sx%=4
 sy%=10
 sxm%=4
 sym%=10
 saltx%=4
 salty%=10
 c.truppe%=2
 cx%=21
 cy%=4
 cxm%=21
 cym%=4
 altcx%=21
 altcy%=4
 speed%=0
 ruesten%=0
 FOR i%=0 TO 3
   FOR j%=0 TO 3
     feld%(i%+22,j%)=101
     feld%(i%,j%+11)=-101
   NEXT j%
 NEXT i%
 spname$(1)="SIEGFRIED"
 farb$(0)="Weißer"
 farb$(1)="Schwarzer"
banic:
  DATA 41,155,6,155,11,133,39,133,17,134
  DATA 272,23,306,23,302,1,275,1,292,2
   RESTORE banic
   FOR i%=0 TO 9
     READ b.treffxy%(0,i%)
   NEXT i%
   FOR i%=0 TO 9
     READ b.treffxy%(1,i%)
   NEXT i%
RETURN
'
pruef.ende:
 jj% = 0
 FOR ii% = 0 TO 4
   jj% = jj% + burg.treff%(vertei%, ii%)
 NEXT ii%
 IF jj% = 5 THEN
 cls
farb%(0)=&h000
farb%(1)=&h444
farb%(2)=&hCCC
farb%(3)=&hEEE
farb%(4)=&h664
farb%(5)=&h686
farb%(6)=&hA86
farb%(7)=&hB13
farb%(8)=&hC66
farb%(9)=&hC86
farb%(10)=&hEA6
farb%(11)=&hECA
farb%(12)=&h668
farb%(13)=&h88A
farb%(14)=&hAAA
farb%(15)=&h864
CALL loadrgb4&(vp&,VARPTR(farb%(0)),16)
 erase b1%,b1d%
 dim endpic%(14403)
 f$="rittend.put"+CHR$(0)
 fhandle&=xOpen&(SADD(f$),1005)
 IF fhandle&<>0 THEN
   ok&=xRead&(fhandle&,VARPTR(ENDPIC%(0)),28806&)
   CALL xClose&(fhandle&)
   put(23,0),endpic%,pset
   s$ = spname$(spieler%)+", Ritter des Thales"
   LOCATE 24,(40-LEN(s$))\2:PRINT s$;
 end if
 GOSUB E.LEER
 GOSUB warte
 IF spieler% = 0 THEN
   hisc% = s.feldp.ges% + s.geld%
 ELSE
   hisc% = c.feldp.ges% + c.geld%
 END IF
 GOSUB hisc.laden
 GOSUB Hisc.sort
 GOSUB hisc.speichern
 GOSUB warte
 CLS
 a$ = "Nächste Runde?| Ja *Nein*1"
 CALL al.neu(a$)
 IF but% = 2 THEN
   SYSTEM
 ELSE
 erase spname$,sp.eingabe%,feld%,fws%,fwc%,c.cast.pos%,s.cast.pos%
 erase s.cast.zust%,c.cast.zust%,stein%,burg.treff%,b.treffxy%,ENDPIC%
 erase c.wiederhol%,xp%,yp%,sname$,hisc%,zuege%,su$,kn$,k.zahl%,farb$
 DIM b1%(8004,1)
 DIM b1d%(7243)
 cls
REM $OPTION +A
   goto neustart
REM $OPTION -A
 END IF
END IF
RETURN
'
zuende:
 a$ = " ENDE |  | JA *NEIN*2"
 CALL al.neu(a$)
 IF but%=1 THEN
   STOP
 END IF
RETURN
'
warte: 
 ta%=0
 mk%=0
 WHILE ta%=0 AND mk%=0 
  Joy.ab
 WEND
RETURN
s.legende:
 GOSUB legende.c
 GOSUB s.men.restau
RETURN
c.legende:
 GOSUB legende.c
 GOSUB c.men.restau
RETURN
legende.c:
 CALL rand(0,0,319,180,1)
 LOCATE 21,6: PRINT "FeldÜbersicht nach"; STR$(durchgang%); " ZÜgen"
 LINE (15,24)-(15,136)
 LINE (15,137)-(315,137)
 FOR jj%=0 TO 22 STEP 2
   'TEXT 3,136-jj%*5,STR$(jj%)
   LINE (14,136-jj%*5)-(15,136-jj%*5)
 NEXT jj%
 s.durchschn%=s.feldp.ges% \ 10
 c.durchschn%=c.feldp.ges% \ 10
 IF s.durchschn%>110 THEN s.durchschn%=110
 IF c.durchschn%>110 THEN c.durchschn%=110
 IF s.durchschn% >= c.durchschn% THEN
   y1%=131-s.durchschn%
   LINE (20,y1%)-(311,131),3 ,BF
   LINE (312,y1%-1)-(312,130),9
   LINE (313,y1%-1)-(313,130),9
   LINE (314,y1%-2)-(314,129),9
   LINE (315,y1%-2)-(315,129),9
'
   LINE (22,y1%-1)-(312,y1%-1),12
   LINE (24,y1%-2)-(314,y1%-2),12
   y1%=134-c.durchschn%
   LINE (18,y1%)-(307,134),5 ,BF
   LINE (308,y1%-1)-(308,133),9
   LINE (309,y1%-1)-(309,133),9
   LINE (310,y1%-2)-(310,132),9
   LINE (311,y1%-2)-(311,132),9
'
   LINE (20,y1%-1)-(308,y1%-1),12
   LINE (22,y1%-2)-(310,y1%-2),12
 ELSE
   y1%=131-c.durchschn%
   LINE (22,y1%)-(311,131),5 ,BF
   LINE (312,y1%-1)-(312,130),9
   LINE (313,y1%-1)-(313,130),9
   LINE (314,y1%-2)-(314,129),9
   LINE (315,y1%-2)-(315,129),9
'
   LINE (22,y1%-1)-(313,y1%-1),12
   LINE (24,y1%-2)-(315,y1%-2),12
   y1%=133-s.durchschn%
   LINE (18,y1%)-(307,133),3 ,BF
   LINE (308,y1%-1)-(308,133),9
   LINE (309,y1%-1)-(309,133),9
   LINE (310,y1%-2)-(310,132),9
   LINE (311,y1%-2)-(311,132),9
'
   LINE (20,y1%-1)-(309,y1%-1),12
   LINE (22,y1%-2)-(311,y1%-2),12
 END IF
 FOR jj%=0 TO 19
   IF spieler%=0 THEN
     hoch1%=fws%(jj%+1)*5
     hoch2%=fwc%(jj%+1)*5
     PUT (16+jj%*15,138),hof%(0,jj%),PSET
     IF hoch1%>100 THEN hoch1%=100
     IF hoch2%>100 THEN hoch2%=100
     vor%=3
     neben%=5
   ELSE
     hoch1%=fwc%(jj%+1)*5
     hoch2%=fws%(jj%+1)*5
     PUT (16+jj%*15,138),hof%(0,jj%+20),PSET
     IF hoch1%>100 THEN hoch1%=100
     IF hoch2%>100 THEN hoch1%=100
     vor%=5
     neben%=3
   END IF
   x1%=16+jj%*15
   y1%=136-hoch1%
   x2%=23+jj%*15
   y2%=136
   LINE (x1%,y1%)-(x2%,y2%),vor% ,BF
   LINE (x2%+1,y1%-1)-(x2%+1,y2%-1),9
   LINE (x2%+2,y1%-1)-(x2%+2,y2%-1),9
   LINE (x2%+3,y1%-2)-(x2%+3,y2%-2),9
   LINE (x2%+4,y1%-2)-(x2%+4,y2%-2),9
'
   LINE (x1%+2,y1%-1)-(x2%+1,y1%-1),12
   LINE (x1%+4,y1%-2)-(x2%+3,y1%-2),12
   x1%=24+jj%*15
   y1%=136-hoch2%
   x2%=27+jj%*15
   y2%=136
   LINE (x1%,y1%)-(x2%,y2%),neben% ,BF
   LINE (x2%+1,y1%-1)-(x2%+1,y2%-1),9
   LINE (x2%+2,y1%-1)-(x2%+2,y2%-1),9
   LINE (x2%+3,y1%-2)-(x2%+3,y2%-2),9
   LINE (x2%+4,y1%-2)-(x2%+4,y2%-2),9
'
   LINE (x1%+2,y1%-1)-(x2%+1,y1%-1),12
   LINE (x1%+4,y1%-2)-(x2%+3,y1%-2),12
 NEXT jj%
 GOSUB e.leer
 GOSUB warte
 GOSUB restau.feld
RETURN
'
cast.zust:
 IF spieler%=0 THEN
   PUT (4,4),temp%,PSET
 ELSE
   PUT (213,84),temp%,PSET
 END IF
 gosub e.leer
 FOR ii%=0 TO 5
   IF s.cast.zust%(ii%) > 0 THEN
     px%=9+s.cast.pos%(ii%,0)*12
     py%=s.cast.pos%(ii%,1)*12
     CALL rand(px%-5,py%,px%+31,py%+12,1)
     LINE (px%-2,py%+3)-(px%+s.cast.zust%(ii%)-2,py%+9),3,BF
   END IF
   IF c.cast.zust%(ii%) > 0 THEN
     px%=9+c.cast.pos%(ii%,0)*12
     py%=c.cast.pos%(ii%,1)*12
     CALL rand(px%-5,py%,px%+31,py%+12,1)
     LINE (px%-2,py%+3)-(px%+c.cast.zust%(ii%)-2,py%+9),5,BF
   END IF
 NEXT ii%
 gosub e.leer
 GOSUB warte
 f.ani%=1
 GOSUB restau.feld
 f.ani%=0
 IF spieler%=0 THEN
   GOSUB s.men.restau
 ELSE
   GOSUB c.men.restau
 END IF
RETURN
'
spielereingabe:
 CALL rand(24,27,296,68-computer%*8,2)
 LOCATE 5,17
 IF computer%=1 THEN
   PRINT "Ihr Name:"
 ELSE
   PRINT "Ihre Namen:"
 END IF
 FOR i%=0 TO 1-computer%
   spname$(i%)=""
   WHILE spname$(i%)=""
     LOCATE 7+i%,5: PRINT farb$(i%);" Ritter";
     locate 7+i%,21:PRINT ":";
     e$=""
     CALL eingabe(23,7+i%,12)
     spname$(i%)=UCASE$(e$)
     IF LEN(spname$(i%)) < 1 THEN
       a$=" 1 Buchstaben mindestens |Ok*1)
       CALL al.neu(a$)
     END IF
   WEND
   GOSUB e.wahl
 NEXT i%
RETURN
c.name:
 GET (72,27)-(248,52),temp%
 CALL rand(72,27,248,52,2)
 LOCATE 5,16: PRINT "Ihr Name:"
 e$=spname$(1)
 spname$(1)=""
 WHILE spname$(1)=""
   CALL eingabe(14,6,12)
   spname$(1)=UCASE$(e$)
   IF LEN(spname$(1)) < 1 THEN
     a$=" 1 Buchstaben mindestens |Ok*1"
     CALL al.neu(a$)
   END IF
 WEND
 PUT (72,27),temp%,PSET
 i%=1
 gosub e.wahl
RETURN
Hisc.sort:
  i% = 0
  hu%=0
  WHILE durchgang% >= zuege%(i%) and hu%=0
    IF durchgang% = zuege%(i%) THEN
      IF hisc% < hisc%(i%) THEN
        i%=i%+1
      END IF
    ELSE
      i%=i%+1
    END IF
    if i%=10 then hu%=1
  WEND
  ii% = i%
  IF i% < 10 THEN
    FOR j% = 8 TO i% STEP -1
      hisc%(j% + 1) = hisc%(j%)
      sname$(j% + 1) = sname$(j%)
      zuege%(j% + 1) = zuege%(j%)
    NEXT j%
    hisc%(ii%) = hisc%
    sname$(ii%) = spname$(spieler%)
    zuege%(ii%) = durchgang%
  END IF
  gosub hisc.zeig
return
hisc.zeig:
  cls
  CALL loadrgb4&(vp&,VARPTR(farb%(16)),16)
  CALL rand(2, 1, 317, 197, 3)
  PUT (47, 116), ritter0%, AND
  PUT (47, 116), ritter1%, OR
  LOCATE 2, 8: PRINT "Ritter"
  LOCATE 2, 20: PRINT "Punkte"
  LOCATE 2, 27: PRINT "ZÜge"
  FOR i% = 0 TO 9
    LOCATE i% + 4, 4: PRINT USING "##"; i% + 1;
    PRINT ".";
'hisc%(i%)
    IF hisc%(i%) > 0 THEN
      LOCATE i% + 4, 8: PRINT sname$(i%)
      LOCATE i% + 4, 20: PRINT USING "#####"; hisc%(i%);
      LOCATE i% + 4, 27: PRINT USING "####"; zuege%(i%)
    END IF
  NEXT i%
  gosub e.leer
  GOSUB warte
  LINE (7, 7)-(312, 115), 0, BF
  CALL loadrgb4&(vp&,VARPTR(farb%(0)),16)
RETURN
hisc.laden:
 speicher%=0
 e$="Df0:TDB.HTB"
' cls
 call setapen&(rp&,15)
 CALL rand(60, 27, 243, 43, 1)
 LOCATE 5, 14: PRINT "Score laden"
 CALL rand(60, 67, 243, 83, 1)
 CALL eingabe(10, 10, 18)
 a$=" Datendisk einlegen| OK *1"
 al.neu (a$)
 e$=e$+chr$(0)
 fhandle&=xOpen&(SADD(e$),1005)
 if fhandle&<0 then
   speicher%=1
   CALL xClose&(fhandle&)
 end if
 IF speicher% THEN
    OPEN "i", #1, e$
    FOR i% = 0 TO 9
      INPUT #1, sname$(i%)
      INPUT #1, hisc%(i%)
      INPUT #1, zuege%(i%)
    NEXT i%
    CLOSE
  ELSE
    FOR i% = 0 TO 9
      sname$(i%) = ""
      hisc%(i%) = 0
      zuege%(i%) = 10000
    NEXT i%
  END IF
  window 2
  cls
RETURN
hisc.speichern:
  CALL rand(68, 29, 235, 43, 1)
  LOCATE 5, 12: PRINT "Score speichern"
  CALL rand(68, 69, 235, 83, 1)
  e$="Df0:TDB.HTB"
  CALL eingabe(10,10,16)
  a$="Datendisk einlegen| OK *1"
  al.neu (a$)
  IF e$>"" THEN
    OPEN "o", #1, e$
    FOR i% = 0 TO 9
      PRINT #1, sname$(i%)
      PRINT #1, hisc%(i%)
      PRINT #1, zuege%(i%)
    NEXT i%
    CLOSE
  END IF
  cls
RETURN
'
e.wahl:
 get (122,74)-(198,102),temp%
 CALL rand(122,74,198,102,1)
 PUT (124,76),b.men%(0,17),PSET
 PUT (148,76),b.men%(0,16),PSET
 PUT (172,76),b.men%(0,18),PSET
 IF i%=1 THEN
   LINE (124+sp.eingabe%(0)*24+1,76+1)-(124+sp.eingabe%(0)*24+23,76+23),3 ,BF
 END IF
e.wahl.neu:
 GOSUB e.leer
 w%=0
 CALL bmen(3,124,76,0,24,3)
 IF i%=1 THEN
   IF w%=sp.eingabe%(0) THEN
     CALL fehler(0,"Schon vergeben")
     GOTO e.wahl.neu
   END IF
 END IF
 sp.eingabe%(i%)=w%
 GOSUB e.leer
 w%=0
 put (122,74),temp%,pset
RETURN

SUB al.neu (a$) STATIC
 SHARED su$(),kn$(),k.zahl%(),but%,temp%(),ta%,ta$,mx%,my%,mk%,rp&,joy%
 wahlbuchst$=""
 knopflaenge%=0
 a%=1
 b%=1
 su%=-1
 lg%=1
 WHILE INSTR(b%,a$,"|") > 0
   su%=su%+1
   a%=INSTR(b%,a$,"|")
   su$(su%)=MID$(a$,b%,a%-b%)
   b%=a%+1
   IF LEN(su$(su%)) > lg% THEN
     lg%=LEN(su$(su%))
   END IF
 WEND
 k.zahl%=-1
 wahlbuchst$=""
 a%=b%-1
 kwahl%=VAL(RIGHT$(a$,1))-1
 WHILE INSTR(b%,a$,"*") > 0
   k.zahl%=k.zahl%+1
   a%=INSTR(b%,a$,"*")
   kn$(k.zahl%)=MID$(a$,b%,a%-b%)
   b%=a%+1
   ai%=1
   WHILE MID$(kn$(k.zahl%),ai%,1)=" "
     ai%=ai%+1
   WEND
   wahlbuchst$=wahlbuchst$+MID$(kn$(k.zahl%),ai%,1)
   IF LEN(kn$(k.zahl%)) > knopflaenge% THEN
     knopflaenge%=LEN(kn$(k.zahl%))
   END IF
 WEND
 wahlbuchst$=UCASE$(wahlbuchst$)
 knopflaenge%=knopflaenge%+2
 breite%=lg%+2
 IF (knopflaenge%+2)*(k.zahl%+1) > breite% THEN
   breite%=(knopflaenge%+2)*(k.zahl%+1)-1
 END IF
 breite% = breite%-(k.zahl% MOD 2=0)
 bx%=(40-breite%) / 2 
 by%=(12-su% \ 2)-1
 bx1%=bx%*8-16
 by1%=by%*8-16
 GET (bx1%,by1%)-(bx%*8+breite%*8+2,by%*8+su%*8+25),temp%
 LINE (bx1%,by1%)-(bx%*8+breite%*8,by%*8+su%*8+24),0,BF
 call rand(bx1%,by1%,bx%*8+breite%*8,by%*8+su%*8+24,2)
' LINE (bx1%,by1%)-(bx%*8+breite%*8,by%*8+su%*8+24),15,b
' LINE (bx1%+2,by1%+2)-(bx%*8+breite%*8-2,by%*8+su%*8+22),15,b
' schatten oben
' LINE (bx1%+3,by1%+3)-(bx%*8+breite%*8-3,by1%+3),13
' LINE (bx1%+3,by1%+3)-(bx1%+3,by%*8+su%*8+21),13
' schatten unten
' LINE (bx1%+1,by%*8+su%*8+25)-(bx%*8+breite%*8+1,by%*8+su%*8+25),13
' LINE (bx%*8+breite%*8+1,by1%+2)-(bx%*8+breite%*8+1,by%*8+su%*8+25),13
 CALL SetApen&(rp&,15)
 FOR ai%=0 TO su%
   LOCATE by%+ai%,bx%+1: PRINT su$(ai%)
 NEXT ai%
 by%=by%+ai%
 bx%=(40-(knopflaenge%+2)*(k.zahl%)) \ 2 +k.zahl%\2
 FOR ai%=0 TO k.zahl%
   hix%=bx%+(knopflaenge%+2)*ai%-1
   k.zahl%(ai%)=hix%*8-24
   LINE (k.zahl%(ai%),by%*8-2)-(k.zahl%(ai%)+knopflaenge%*8,by%*8+9),15,b
   LINE (k.zahl%(ai%)-2,by%*8-4)-(k.zahl%(ai%)+knopflaenge%*8+2,by%*8+11),15,b
   LOCATE by%+1,hix%-1: PRINT kn$(ai%)
   bpos%=INSTR(UCASE$(kn$(ai%)),MID$(wahlbuchst$,ai%+1,1))
   CALL SetApen&(rp&,2)
   LOCATE by%+1,hix%+bpos%-2: PRINT MID$(wahlbuchst$,ai%+1,1)
   CALL SetApen&(rp&,15)
 NEXT ai%
 LINE (k.zahl%(kwahl%)-1,by%*8-3)-(k.zahl%(kwahl%)+knopflaenge%*8+1,by%*8+10),2,b
 LINE (k.zahl%(kwahl%),by%*8-2)-(k.zahl%(kwahl%)+knopflaenge%*8,by%*8+9),2,b
 kwahl.alt%=kwahl%
 raus%=0
 WHILE MOUSE(0)<>0 OR INKEY$>"" OR STRIG(2)<>0:WEND
 WHILE raus%=0
   Joy.ab
   IF LEN(ta$)=1 THEN
   IF INSTR(wahlbuchst$,UCASE$(ta$)) > 0 THEN
     kwahl%=INSTR(wahlbuchst$,UCASE$(ta$))-1
     raus%=1
   END IF
   END IF
   raus%=raus%-(ta%=13)-(mk%=-2)
   IF my% > by%*8-4 AND my% < by%*8+9 THEN
     FOR ai%=0 TO k.zahl%
       IF mx% > k.zahl%(ai%)-3 AND mx% < k.zahl%(ai%)+knopflaenge%*8+6 THEN
         kwahl%=ai%
         GOSUB al.ref
     kwahl.alt%=kwahl%
         ai%=k.zahl%
         raus%=raus%-(mk%<>0)
       END IF
     NEXT ai%
   END IF
   IF ta%>29 AND ta%<32 THEN
     kwahl%=kwahl%-(ta%=30)+(ta%=31)
     IF kwahl% < 0 THEN kwahl%=0
     IF kwahl% > k.zahl% THEN kwahl%=k.zahl%
     GOSUB al.ref
     kwahl.alt%=kwahl%
   END IF
   IF Joy%=8 OR Joy%=4 THEN
     kwahl%=kwahl%-(Joy%=8)+(Joy%=4)
     IF kwahl% < 0 THEN kwahl%=0
     IF kwahl% > k.zahl% THEN kwahl%=k.zahl%
     GOSUB al.ref
     kwahl.alt%=kwahl%
   END IF
 WEND
 but%=kwahl%+1
 PUT (bx1%,by1%),temp%,PSET
 GOTO al.end
 al.ref:
 IF kwahl.alt% <> kwahl% THEN
   LINE (k.zahl%(kwahl.alt%)-1,by%*8-3)-(k.zahl%(kwahl.alt%)+knopflaenge%*8+1,by%*8+10),0,b
   LINE (k.zahl%(kwahl.alt%),by%*8-2)-(k.zahl%(kwahl.alt%)+knopflaenge%*8,by%*8+9),15,b
   LINE (k.zahl%(kwahl%)-1,by%*8-3)-(k.zahl%(kwahl%)+knopflaenge%*8+1,by%*8+10),2,b
   LINE (k.zahl%(kwahl%),by%*8-2)-(k.zahl%(kwahl%)+knopflaenge%*8,by%*8+9),2,b
   PAUSE(500)
 END IF
RETURN
raus%=0
mk%=0
WHILE MOUSE(0)<>0 OR INKEY$>"" OR STRIG(2)<>0:WEND
al.end:
END SUB

SUB bmen (id%,x1%,y1%,y1.1%,breit%,ml%)STATIC
 SHARED spieler%,sp.eingabe%(),ta%,w%,b.men%(),mx%,my%,mk%,cur%(),Joy%,raus%
 xb%=x1%+breit%*ml%
 w.a%=w%
 raus%=0
 y%=-(w.a% < ml%)*y1%-(w.a% >= ml%)*y1.1%
 PUT ((w.a% MOD ml%)*breit%+x1%,y%),cur%
 WHILE MOUSE(0)<>0 AND INKEY$>"":WEND
 WHILE raus%=0
 WHILE STRIG(2)<>0:WEND
   oben%=-1
   raus%=0
   Joy.ab
   IF id% <> 2 THEN
     IF sp.eingabe%(spieler%)=2 OR id%=3 THEN
       raus%=raus%-(ta%=13)*2
       IF ta% >27 AND ta%<32  THEN
         w%=w%-(ta%=29 AND w% < ml%)*ml%+(ta%=28 AND w% >= ml%)*ml%-(ta%=30)+(ta%=31)
         w%=FNmax%(0,w%)
         w%=FNmin%(w%,ml%-ml%*(y1.1% > 0)-1)
         GOSUB bmen2
       END IF
     END IF
     IF sp.eingabe%(spieler%)=1 OR id%=3 THEN
       raus%=raus%-(mk%=-2)*2
       IF Joy%=1 OR Joy%=2 OR Joy%=4 OR Joy%=8 THEN
         w%=w%-(Joy%=2 AND w% < ml%)*ml%+(Joy%=1 AND w% >= ml%)*ml%-(Joy%=8)+(Joy%=4)
         w%=FNmax%(0,w%)
         w%=FNmin%(w%,ml%-ml%*(y1.1% > 0)-1)
         Joy%=0
         GOSUB bmen2
       END IF
     END IF
   ELSE
     IF sp.eingabe%(spieler%)=2 THEN
       raus%=-(ta%=13)*2
       IF ta%=28 THEN
         w%=0
         raus%=1
         GOSUB bmen2
       END IF
       IF ta%=29 THEN
         w%=1
         raus%=1
         GOSUB bmen2
       END IF
       IF ta%=31 THEN
         w%=2
         raus%=1
         GOSUB bmen2
       END IF
       IF ta%=30 THEN
         w%=3
         raus%=1
         GOSUB bmen2
       END IF
     END IF
     IF sp.eingabe%(spieler%)=1 THEN
       raus%=raus%-(mk%=-2)*2
       IF Joy%=1 THEN
         w%=0
         raus%=1
         GOSUB bmen2
       END IF
       IF Joy%=2 THEN
         w%=1
         raus%=1
         GOSUB bmen2
       END IF
       IF Joy%=4 THEN
         w%=2
         raus%=1
         GOSUB bmen2
       END IF
       IF Joy%=8 THEN
         w%=3
         raus%=1
         GOSUB bmen2
       END IF
     END IF
   END IF
   IF (sp.eingabe%(spieler%)=0 OR id%=3) then
     IF mx%>x1% AND mx%<xb% then
       raus%=raus%-(mk%<>0)*2
       IF my% > y1% AND my% < y1%+breit% THEN
         oben%=0
       END IF
       IF my% > y1.1% AND my% < y1.1%-breit%*(y1.1% > 0) THEN
         oben%=ml%
       END IF
       IF oben% > -1 THEN
         w%=(mx%-x1%) \ breit%+oben%
         raus%=-(mk%<>0)
         GOSUB bmen2
       END IF
     end if
   END IF
   IF (sp.eingabe%(spieler%)=0 OR id%=3) AND raus%=0 THEN
     raus%=raus%-(mk%<>0)*2 
   END IF
 WEND
 y%=-(w.a% < ml%)*y1%-(w.a% >= ml%)*y1.1%
 PUT ((w.a% MOD ml%)*breit%+x1%,y%),cur%
  GOTO b.end
bmen2:
 IF w.a% <> w% THEN
   y%=-(w.a% < ml%)*y1%-(w.a% >= ml%)*y1.1%
   PUT ((w.a% MOD ml%)*breit%+x1%,y%),cur%
   y%=-(w% < ml%)*y1%-(w% >= ml%)*y1.1%
   IF w%=7 THEN
     PUT ((7 MOD ml%)*breit%+x1%,y1.1%),b.men%(0,8),PSET
   END IF
   IF w.a%=7 THEN
     PUT ((7 MOD ml%)*breit%+x1%,y1.1%),b.men%(0,7),PSET
   END IF
   PUT ((w% MOD ml%)*breit%+x1%,y%),cur%
   w.a%=w%
   PAUSE(300)
 END IF
RETURN
b.end:
WHILE MOUSE(0)<>0 OR INKEY$>"" OR STRIG(2)<>0:WEND
END SUB

SUB fehler (j%,ftext$)STATIC
 SHARED rp&,t2%()
 z%=LEN(ftext$)-1
 x%=INT((41-z%)\2)+1
 GET ((x%-1)*8-4,173)-((x%+z%)*8+3,186),t2%
 CALL SetApen&(rp&,15)
 LOCATE 23,x%: PRINT ftext$;
 SOUND 700,1,255
 CALL rand((x%-1)*8-4,173,(x%+z%)*8+3,186,1)
 FOR i%=j% TO 10
   PAUSE(550-i%*50)
   CALL SetApen(rp&,15-(i% MOD 2=0)*11)
   SOUND 350,1,255-i%*10
   LOCATE 23,x%: PRINT ftext$;
 NEXT i%
 CALL SetApen&(rp&,15)
 PUT ((x%-1)*8-4,173),t2%,PSET
END SUB

SUB Joy.ab STATIC
 SHARED ta%,ta$,mx%,my%,mk%,Joy%
 ta%=0
 mk%=0
 Joy%=0
 ta$=INKEY$
 IF LEN(ta$)=2 THEN ta%=ASC(RIGHT$(ta$,1))
 IF LEN(ta$)=1 THEN ta%=ASC(ta$)
 mx%=MOUSE(1)
 my%=MOUSE(2)
 mk%=MOUSE(0)
 Joy%=-(STICK(3)=-1)-2*(STICK(3)=1)-4*(STICK(2)=-1)-8*(STICK(2)=1)
 mk%=mk%+strig(2)*2
END SUB

SUB m.reiter (lx%,ly%,lxm%,lym%,ln%)STATIC
 SHARED reiter%(),speed%
 dx%=lxm%-lx%
 dy%=lym%-ly%
 IF lxm%+dx% <> 0 or lym%+dy% <> 0 THEN
   PUT (4+lx%+dx%,ly%+dy%),reiter%(0,ln%)
   WHILE dx% <> 0 OR dy% <> 0
     PAUSE(speed%*20)
     ax%=((dx% > 0)-(dx% < 0))
     ay%=((dy% > 0)-(dy% < 0))
     PUT (4+lx%+dx%,ly%+dy%),reiter%(0,ln%)
     PUT (4+lx%+dx%+ax%,ly%+dy%+ay%),reiter%(0,ln%)
     dx%=dx%+ax%
     dy%=dy%+ay%
   WEND
   PUT (4+lx%+dx%,ly%+dy%),reiter%(0,ln%)
 END IF
END SUB

SUB rand(x%,y%,x1%,y1%,dick%)STATIC
 LINE (x%,y%)-(x1%,y1%),0 ,BF
 f2%=11:f1%=15
 i%=0
 GOSUB schatten
 FOR i%=1 TO dick%
  LINE(x%+i%,y%+i%)-(x1%-i%,y1%-i%),13,b
 NEXT i%
 f1%=11:f2%=15
 GOSUB schatten
 GOTO rand.end
 schatten:
   LINE (x%+i%,y%+i%)-(x1%-i%,y%+i%),f1%     'oben
   LINE (x%+i%,y%+i%)-(x%+i%,y1%-i%),f1%     'links
   LINE (x%+i%,y1%-i%)-(x1%-i%,y1%-i%),f2%   'unten
   LINE (x1%-i%,y%+i%)-(x1%-i%,y1%-i%),f2%   'rechts
 RETURN
 rand.end:
END SUB

SUB eingabe(x%,y%,lg%)STATIC
 SHARED e$
 a$=""
 LOCATE y%,x%:PRINT e$;" "
 WHILE a$<>CHR$(13)
   a$=INKEY$
   IF LEN(a$) THEN 
     GOSUB i.test
     LOCATE y%,x%:PRINT e$;" "
   END IF
 WEND
 GOTO e.end
 i.test:
   IF a$=CHR$(8) AND LEN(e$)>0 THEN
     if len(e$)=1 then
       e$=""
     else
       e$=LEFT$(e$,LEN(e$)-1)
     end if
     a$=""
   end if
   IF (LEN(e$)<=lg%) AND (a$<>CHR$(13)) and (a$<>chr$(8)) THEN 
     e$=e$+a$
   end if
 RETURN    
 e.end:
END SUB  
  
sub pause(ti%)static
  FOR P%=0 TO ti%:t=(ti%/100)*100:NEXT P%
end sub

