home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 52 / af052sub.adf / buzzbar / listing < prev    next >
Text File  |  1993-06-18  |  17KB  |  702 lines

  1. ;
  2. ;     PROJECT BUZZ BAR
  3. ;
  4.  
  5. #reload=4       ;time till next bullet
  6. #around=4       ;num bullets in one auto fire
  7. #mythrust=4     ;5=nice and fast
  8. #bthrust=4      ;anti thrust when firing
  9. #mydrag=6
  10. #bspeed=9       ;bullet speed
  11.  
  12. #upd=7          ;number of frames for scanner and alien changes
  13. #xcntr=160+32
  14. #ycntr=100+32
  15.  
  16. #shield=128      ;shape numbers
  17. #hume=112
  18. #thrst=131
  19. #title=135
  20.  
  21. #nmetypes=48
  22.  
  23. ;
  24. ; machine code /x*x+y*y
  25. ;
  26.  
  27. Function.w distance{x1.w,y1.w,x2.w,y2.w}
  28.  UNLK a4                               ;unlink (no recursion)
  29.  SUB d2,d0:BPL xpos:NEG d0:xpos        ;d0=width
  30.  SUB d3,d1:BPL ypos:NEG d1:ypos        ;d1=height
  31.  CMP d0,d1:BEQ kludge                  ;kludge if equal
  32.  BMI ygtx:EXG d0,d1:ygtx               ;d0=greater side
  33.  TST d1:BNE yne:RTS:yne                ;if short side 0 len=other
  34.  SWAP d1:CLR d1:DIVU d0,d1:LSR#7,d1    ;look up=short/long
  35.  ADD d1,d1:SWAP d0
  36.  DIVU lvals(pc,d1.w),d0:RTS
  37.  kludge:MULU #27146,d0:SWAP d0:ADD d1,d0:RTS ;multiply by sqrt(2)
  38.  lvals:IncBin "len.inc"
  39. End Function
  40.  
  41. ;
  42. ; machine code arctan(x,y)
  43. ;
  44.  
  45. Function.w angle{x1.w,y1.w}
  46.   UNLK a4                                     ;unlink
  47.   MOVEQ#0,d2                                  ;d2=quadrant
  48.   TST d1:BPL hpos:MOVEQ#16,d2:NEG d1:hpos     ;y positive
  49.   TST d0:BPL wpos:EOR#8,d2:NEG d0:wpos        ;x positive
  50.   CMP d1,d0:BMI notsteep:BNE neq
  51.   MOVE#$2000,d1:BRA flow:neq
  52.   EOR #4,d2:EXG d1,d0:notsteep
  53.   TST d1:BNE noflow:MOVEQ#0,d1:BRA flow:noflow
  54.   EXT.ld0:SWAP d0:DIVU d1,d0:LSR#6,d0:AND#1022,d0
  55.   MOVE arc(pc,d0),d1
  56.   flow:MOVE.l oct(pc,d2),d0:EOR d0,d1:SWAP d0:ADD d1,d0:RTS
  57.   oct:Dc.w 0,0,$4000,-1,0,-1,$c000,0
  58.       Dc.w $8000,-1,$4000,0,$8000,0,$C000,-1
  59.   arc:IncBin "arc.inc"
  60. End Function
  61.  
  62. Macro ssin qsin((`1 LSR 6)&1023):End Macro
  63. Macro ccos qcos((`1 LSR 6)&1023):End Macro
  64. Macro onscreen RectsHit(`1,`2,1,1,12,12,320+32,220+32):End Macro
  65.  
  66.  
  67. NEWTYPE .nmedata
  68.   frame.w         ;shape number
  69.   numrots         ;number of roatations
  70.   thrust          ;amount of thrust 1-8
  71.   rspeed          ;max turning speed
  72.   drag            ;drag coefficient
  73.   thrusttime      ;alternate timing for thrust and fire
  74.   firepower       ;percentage liklihood of firing
  75.   points          ;score
  76.   reload          ;time to reload bullet
  77.   color           ;color on scanner
  78. End NEWTYPE
  79.  
  80. NEWTYPE .nmewave
  81.   *nme.nmedata    ;type of nme as above
  82.   start.w         ;time that first wave appears
  83.   num             ;number of waves
  84.   apart           ;time between waves
  85.   count           ;number of aliens in wave
  86.   neces           ;flag if required to finish patern
  87.   tot             ;total number
  88. End NEWTYPE
  89.  
  90. NEWTYPE .ship
  91.   x.w:y:rot:frame  ;position
  92.   xv:yv:px:py:upd  ;& speed
  93.   thcount          ;count for fire thrust alternate
  94.   fcount           ;count for
  95.   bcount
  96.   *parent.nmewave  ;points back to wave he came from
  97.   *nme.nmedata     ;points to nmetype
  98. End NEWTYPE
  99.  
  100. NEWTYPE .paterndata
  101.   pcol.w:numhumes
  102.   waves.nmewave[10]
  103. End NEWTYPE
  104.  
  105. NEWTYPE .playerdata
  106.   score.l:lives.w:shield:patern:status:xpos
  107.   ptimer:totwaves:tothumes:numhumes
  108.   nme.nmewave[10]
  109. End NEWTYPE
  110.  
  111. NEWTYPE .hume
  112.   x.w:y:rot
  113.   xv:yv:rv:frame:upd:px:py
  114. End NEWTYPE
  115.  
  116. NEWTYPE .rgb
  117.   r.w:g:b
  118. End NEWTYPE
  119.  
  120. Dim List nme.ship(50)      ;enemy
  121. Dim List bul.ship(16)      ;bullets
  122. Dim List bng.ship(50)      ;explosions
  123. Dim List fire.ship(32)     ;nme fire
  124. Dim List astro.hume(32)    ;astronauts
  125.  
  126. Dim alien.nmedata(#nmetypes) ;nme information
  127. Dim patern.paterndata(200)   ;patern information
  128. Dim player.playerdata(1)     ;2 players
  129. Dim pcols.rgb(4)
  130.  
  131. Dim a$(1000)                 ;listing
  132.  
  133. Dim qsin.q(1023),qcos(1023)   ;look up tables
  134.  
  135. me.ship\x=0,0,0,0,0,0,0
  136.  
  137. BitMap 0,320+64,220+64,3  ;doublebuffered front playfield
  138. BitMap 1,320+64,220+64,3
  139. BitMap 2,832,768,3        ;background
  140. BitMap 3,320,32,3         ;double buffered scanner
  141. BitMap 4,320,32,3
  142.  
  143. If ReadFile(0,"text")
  144.   FileInput 0:numl=0
  145.   While NOT Eof(0)
  146.     a$(numl)=Left$(Edit$(100),38):numl+1
  147.   Wend
  148.   CloseFile 0
  149.   DefaultInput
  150. EndIf
  151.  
  152. LoadSound 0,"shoot1"
  153. LoadSound 1,"shoot2"
  154. LoadSound 2,"explo1"
  155. LoadSound 3,"explo2"
  156. LoadSound 4,"thrust1"
  157. LoadSound 5,"tankoo"
  158. LoadSound 6,"freemun"
  159. LoadSound 7,"intromusic"
  160.  
  161. LoadShapes 0,"ships.shapes"     ;8 color
  162. LoadShapes 160,"bombs.shapes"    ;2 color
  163. LoadShapes 192,"shards.shapes"   ;4 color
  164.  
  165. LoadPalette 1,"ships.iff"
  166.  
  167. LoadBitMap 2,"moon.iff"         ;back drop
  168. Use BitMap 2
  169. Scroll 0,0,320,512,512,0
  170. Scroll 0,0,832,256,0,512
  171. Use BitMap 0
  172.  
  173. Queue 0,100
  174. Queue 1,100
  175.  
  176. Gosub setuppcols
  177. Gosub setupsincos
  178. Gosub setupnme
  179. Gosub setuppaterns
  180.  
  181. BLITZ
  182. Mouse On
  183. BlitzKeys On:BitMapInput
  184. Gosub setuppalette
  185.  
  186. Slice 0,44,320,32,$fff8,3,8,8,320,320:Use Palette 1
  187. Slice 1,78,320,220,$fffa,6,8,32,320+64,832:Use Palette 1
  188.  
  189. sdb=3
  190.  
  191. .titledisplay
  192.   LoopSound 7,4:Volume 4,64
  193.   Use BitMap sdb:Cls:BitMapOutput sdb
  194.   Blit #title,160,11
  195.   Use Slice 0:Show sdb:Use Slice 1
  196.   ShowB 2,(me\x LSR 6)&511,(me\y LSR 6)&511
  197.   Use BitMap 1-db:Cls:Use BitMap db:Cls
  198.   cc=0:ci=0:l=0:db=0
  199.   Repeat
  200.     VWait
  201.     ShowF db:db=1-db:BitMapOutput db:Colour 1,0
  202.     Poke Addr BitMap(db)+4,1
  203.     Use BitMap db:Scroll 0,4,320,224,0,0,1-db:WaitBlit_
  204.     If db=0
  205.       Locate 1,27:Print a$(l):l+1:If l>numl Then l=1
  206.     EndIf
  207.     cc-1
  208.     If cc<0
  209.       cc=100:BitMapOutput sdb:Locate 1,3
  210.       Select ci
  211.         Case 0:Print "WRITTEN BY SIMON ARMSTRONG IN BLITZ 2 "
  212.         Case 1:Print " F1-1 PLAYER   F2-2 PLAYER  F10-EXIT  "
  213.         Case 2:Print "      KEYBOARD CONTROLS Z X , . /     "
  214.         Case 3:Print "      CURRENT HIGH SCORE = ",hiscore.l,"     "
  215.       End Select
  216.       ci+1:If ci=4 Then ci=0
  217.     EndIf
  218.     Poke Addr BitMap(db)+4,3
  219.     If (RawStatus($50) OR Joyx(1)=-1) Then nump=1:Gosub playgame
  220.     If (RawStatus($51) OR Joyx(1)=1) Then nump=2:Gosub playgame
  221.     If RawStatus($59) Then End
  222.   Forever
  223.  
  224. .playgame
  225.   Use Palette 1
  226.   ShowF db,32,32
  227.   ShowB 2,(me\x LSR 6)&511,(me\y LSR 6)&511
  228.   Use BitMap 1-db:Cls:Use BitMap db:Cls
  229.   player(0)\score=0,3,600,0,-1,1,0,0
  230.   player(1)\score=0,3,600,0,-1,23,0,0
  231.   If nump=1 Then player(1)\score=0,0,0,0
  232.   currp=0
  233.   While player(0)\lives>0 OR player(1)\lives>0
  234.     *p.playerdata=player(currp)
  235.     If *p\lives>0 Then Gosub newlife
  236.     If *p\score>hiscore Then hiscore=*p\score
  237.     currp=1-currp
  238.   Wend
  239.   Goto titledisplay
  240.  
  241. .newlife
  242.   Gosub initscanner:Gosub initscanner
  243.   *p\status=0
  244.   upd=0:updcount=1  ;frame update and new alien update counters
  245.   ShowF db,32,32
  246.   i=patern(*p\patern)\pcol:r=pcols(i)\r:g=pcols(i)\g:b=pcols(i)\b
  247.   Gosub planetcolor:Use Palette 1
  248.   Use BitMap db:Cls:BitMapOutput db
  249.   Locate 20,15:Colour 1:Print "PLAYER ",currp+1
  250.   Gosub oldaliens
  251.   VWait 100:Cls
  252.   LoopSound 4,4:Volume 4,0
  253.  
  254. .mainloop
  255.   Repeat
  256.     If RawStatus($45) Then End
  257.     VWait
  258.     ShowF db,32,32
  259.     ShowB 2,(me\x LSR 6)&511,(me\y LSR 6)&511
  260.     If *p\totwaves=0 AND numexp=0 Then Gosub newpatern
  261.     Gosub newaliens
  262.     If upd=0 Then Gosub doscanner
  263.     db=1-db
  264.     Use BitMap db
  265.     UnQueue db
  266.     Gosub drawnme
  267.     Gosub drawfire
  268.     Gosub astromen
  269.     If *p\status=0 Then Gosub moveship
  270.     Gosub drawbullets
  271.     Gosub moveexplosions
  272.     upd+1:If upd>#upd Then upd=0
  273.     *p\ptimer+1
  274.     If (*p\ptimer AND 7)=0 Then ct3+1:If ct3=3 Then ct3=0
  275.   Until *p\status=-1 AND numexp=0
  276.   ClearList nme()
  277.   ClearList bul()
  278.   ClearList fire()
  279.   ClearList astro()
  280.   *p\lives-1
  281.   Volume 4,0
  282.   Return
  283.  
  284. .oldaliens
  285.   USEPATH *p\nme[i]
  286.   i=0
  287.   While \nme AND i<10
  288.     j=0:While j<\tot:Gosub addalien:j+1:Wend
  289.     i+1
  290.   Wend
  291.   Gosub addhumes
  292.   Return
  293.  
  294. .addhumes
  295.   i=0
  296.   While i<*p\tothumes
  297.     AddItem astro()
  298.     astro()\x=Rnd($ffff),Rnd($ffff),0
  299.     astro()\xv=Rnd(200)-100,Rnd(200)-100,Rnd(16384)-8192,0
  300.     astro()\upd=updcount
  301.     updcount+1:If updcount>#upd Then updcount=1
  302.     i+1
  303.   Wend
  304.   Return
  305.  
  306. .newaliens
  307.   USEPATH *p\nme[i]
  308.   i=0
  309.   While \nme AND i<10
  310.     If *p\ptimer=\start   ;time for a new wave
  311.       For j=1 To \count
  312.         Gosub addalien
  313.         \tot+1
  314.       Next
  315.       If \num>0 Then \num-1
  316.       If \num<>0 Then \start+\apart Else \start=0
  317.     EndIf
  318.     i+1
  319.   Wend
  320.   Return
  321.  
  322. .addalien
  323.   AddItem nme()
  324.   nme()\x=me\x+Rnd($c000)+$2000
  325.   nme()\y=me\y+Rnd($c000)+$2000
  326.   nme()\rot=Rnd(65535),0,0,0,0,0,0,0,0
  327.   nme()\upd=updcount
  328.   nme()\parent=*p\nme[i]
  329.   nme()\nme=\nme
  330.   updcount+1:If updcount>#upd Then updcount=1
  331.   nme()\thcount=0,0
  332.   Return
  333.  
  334. .newpatern
  335.   ClearList nme()
  336.   ClearList bul()
  337.   ClearList fire()
  338.   ClearList astro()
  339.   Use BitMap db:BitMapOutput db
  340.   *p\patern+1:pat=*p\patern
  341.   Colour 1:Locate 16,15:Print "ATTACK WAVE ",pat
  342.   USEPATH patern(pat)
  343.   i=\pcol:r=pcols(i)\r:g=pcols(i)\g:b=pcols(i)\b
  344.   Gosub planetcolor:Use Palette 1
  345.   USEPATH patern(pat)\waves[i]
  346.   For i=0 To 9                    ;copy patern data to player
  347.     *p\nme[i]\nme=\nme,\start,\num,\apart,\count,0,0
  348.     *p\totwaves+\neces
  349.   Next
  350.   *p\tothumes=patern(pat)\numhumes:Gosub addhumes
  351.   *p\ptimer=0
  352.   VWait 100:Cls
  353.   Return
  354.  
  355.  
  356. .initscanner
  357.   sdb=7-sdb
  358.   Use BitMap sdb:BitMapOutput sdb:Cls
  359.   Box 0,0,319,31,1
  360.   Box 160-16,0,160+16,31,2
  361.   USEPATH player(i)
  362.   For i=0 To 1
  363.     c=2:If player(i)=*p Then c=1
  364.     Locate \xpos,.3:Colour c:Print i+1,"UP"
  365.     Locate \xpos,1.5:Print \score
  366.     Boxf \xpos*8,22,\xpos*8+100,28,0
  367.     If \shield Then Boxf \xpos*8,22,\xpos*8+\shield LSR 4,28,4
  368.     s=1
  369.     While s<\lives AND s<6
  370.       Blit 0,\xpos*8+s*14+50,8
  371.       s+1
  372.     Wend
  373.   Next
  374.   Return
  375.  
  376. .doscanner
  377.   Use Slice 0:Show sdb:Use Slice 1
  378.   sdb=7-sdb
  379.   Use BitMap sdb:BitMapOutput sdb
  380.   Boxf 160-16,0,160+16,31,0
  381.   Box 160-16,0,160+16,31,2
  382.   Blit 164+(me\rot ASR 13 AND 7),160,16
  383.   Locate *p\xpos,1.5:Colour 1:Print *p\score
  384.   Boxf *p\xpos*8,22,*p\xpos*8+100,28,0
  385.   If *p\shield Then Boxf *p\xpos*8,22,*p\xpos*8+*p\shield LSR 4,28,4
  386.   If *p\lives>1 AND *p\lives<6 Then Blit 0,*p\xpos*8+*p\lives*14+50-14,8
  387.   Return
  388.  
  389. .moveship
  390.   If (RawStatus($3a) OR Joyy(1)=1) AND *p\shield>0
  391.     If BlitColl (#shield,#xcntr,#ycntr)
  392.       px=#xcntr:py=#ycntr:sh=#shield
  393.       Gosub checknme
  394.     EndIf
  395.     QBlit db,#shield+ct3,#xcntr,#ycntr
  396.     *p\shield-2
  397.   Else
  398.     If BlitColl (0,#xcntr,#ycntr)
  399.       *p\status=-1
  400.       Sound 3,2
  401.       For i=1 To 15
  402.         If AddItem(bng())
  403.           bng()\x=me\x,me\y,31
  404.           bng()\xv=me\xv/2+Rnd(128)-64
  405.           bng()\yv=me\yv/2+Rnd(128)-64
  406.           numexp+1
  407.         EndIf
  408.       Next
  409.       Return
  410.     EndIf
  411.   EndIf
  412.   If RawStatus($31) OR Joyx(1)=-1 Then me\rot-1400
  413.   If RawStatus($32) OR Joyx(1)=1 Then me\rot+1400
  414.   me\rot+(MouseXSpeed*200)
  415.   If RawStatus($38) OR Joyb(0)&2 OR Joyy(1)=-1      ;thrust
  416.     Volume 4,63
  417.     me\xv+!ssin{me\rot} ASL #mythrust
  418.     me\yv-!ccos{me\rot} ASL #mythrust
  419.     QBlit db,#thrst+thanim,#xcntr-!ssin{me\rot}*6,#ycntr+!ccos{me\rot}*6
  420.     thanim-1:If thanim<0 Then thanim=3
  421.   Else
  422.     Volume 4,0
  423.   EndIf
  424.   If RawStatus($39) OR Joyb(0)&1 OR Joyb(1)&1      ;fire
  425.     If rl=0 AND nb>0
  426.       If AddItem(bul())
  427.         Sound 1,1
  428.         bul()\x=me\x,me\y,me\rot
  429.         bul()\xv=!ssin{me\rot} ASL #bspeed+me\xv
  430.         bul()\yv=-!ccos{me\rot} ASL #bspeed+me\yv
  431.         rl=#reload
  432.         me\xv-!ssin{me\rot} ASL #bthrust         ;reverse thrust
  433.         me\yv+!ccos{me\rot} ASL #bthrust
  434.         nb-1
  435.       EndIf
  436.     EndIf
  437.   Else
  438.     rl=0:nb=#around
  439.   EndIf
  440.   me\xv-me\xv ASR #mydrag
  441.   me\yv-me\yv ASR #mydrag
  442.   me\x+me\xv
  443.   me\y+me\yv
  444.   QBlit db,((me\rot+2048) LSR 12)&15,#xcntr,#ycntr
  445.   If rl>0 Then rl-1
  446.   Return
  447.  
  448.  
  449. .moveexplosions
  450.   ResetList bng()
  451.   USEPATH bng()
  452.   While NextItem(bng())
  453.     \rot-1
  454.     If \rot>-1
  455.       \x+\xv:\y+\yv
  456.       px=((\x-me\x) ASR 6)+#xcntr
  457.       py=((\y-me\y) ASR 6)+#ycntr
  458.       If !onscreen{px,py}
  459.         QBlit db,192+\rot/4,px,py
  460.       EndIf
  461.     Else
  462.       KillItem bng()
  463.       numexp-1
  464.     EndIf
  465.   Wend
  466.   Return
  467.  
  468. .drawnme
  469.   ResetList nme()
  470.   USEPATH nme()
  471.   While NextItem(nme())
  472.     If \upd=upd
  473.       ang.w=32768-angle{me\x-\x,me\y-\y}-\rot
  474.       s=Sgn(ang):ang=Abs(ang)
  475.       If ang>\nme\rspeed Then ang=\nme\rspeed
  476.       \rot+s*ang                       ;rotate towards me
  477.  
  478.       \thcount-1
  479.       If \thcount>0
  480.         \xv+!ssin{\rot} * \nme\thrust        ;thrust
  481.         \yv-!ccos{\rot} * \nme\thrust
  482.       Else
  483.         If \thcount<-\nme\thrusttime Then \thcount=\nme\thrusttime
  484.       EndIf
  485.       \xv-\xv ASR \nme\drag
  486.       \yv-\yv ASR \nme\drag
  487.       Use BitMap sdb
  488.       Plot ((\x-me\x) ASR 11)+160,((\y-me\y) ASR 11)+16,\nme\color
  489.       Use BitMap db
  490.       \frame=(\rot LSR 12)&15+\nme\frame
  491.     EndIf
  492.     \x+\xv                                 ;speed
  493.     \y+\yv
  494.     \px=((\x-me\x) ASR 6)+#xcntr
  495.     \py=((\y-me\y) ASR 6)+#ycntr
  496.     If !onscreen{\px,\py}
  497.       QBlit db,\frame,\px,\py
  498.       If \thcount<0              ;if not thrusting
  499.         If \fcount=0             ;and not fired
  500.           If \nme\firepower>Rnd(100) Then Gosub nmefire
  501.         Else
  502.           \fcount-1
  503.         EndIf
  504.       EndIf
  505.     EndIf
  506.   Wend
  507.   Return
  508.  
  509. .astromen
  510.   ResetList astro()
  511.   USEPATH astro()
  512.   While NextItem(astro())
  513.     If \upd=upd
  514.       \rot+\rv
  515.       Use BitMap sdb
  516.       Plot ((\x-me\x) ASR 11)+160,((\y-me\y) ASR 11)+16,1
  517.       Use BitMap db
  518.       \frame=(\rot LSR 12)&15+#hume
  519.     EndIf
  520.     \x+\xv:\y+\yv
  521.     \px=((\x-me\x) ASR 6)+#xcntr
  522.     \py=((\y-me\y) ASR 6)+#ycntr
  523.     If !onscreen{\px,\py}
  524.       If BlitColl (\frame,\px,\py)
  525.         KillItem astro():*p\tothumes-1
  526.       Else
  527.         If ShapesHit(\frame,\px,\py,0,#xcntr,#ycntr)
  528.           KillItem astro():*p\tothumes-1
  529.           oldscore.l=*p\score
  530.           *p\score+1000:Sound 5,2
  531.           If Int(*p\score/10000)>Int(oldscore/10000)
  532.             *p\lives+1:*p\shield+200:Sound 6,2
  533.           EndIf
  534.         Else
  535.           QBlit db,\frame,\px,\py
  536.         EndIf
  537.       EndIf
  538.     EndIf
  539.   Wend
  540.   Return
  541.  
  542. .nmefire
  543.   USEPATH nme()
  544.   If AddItem(fire())
  545.     Sound 0,1
  546.     fire()\x=\x,\y,\rot
  547.     fire()\xv=!ssin{\rot} ASL 7+\xv
  548.     fire()\yv=-!ccos{\rot} ASL 7+\yv
  549.     \fcount=\nme\reload
  550.   EndIf
  551.   Return
  552.  
  553. .drawfire
  554.   ResetList fire()
  555.   USEPATH fire()
  556.   While NextItem(fire())
  557.     \x+\xv                                 ;speed
  558.     \y+\yv
  559.     px=((\x-me\x) ASR 6)+#xcntr
  560.     py=((\y-me\y) ASR 6)+#ycntr
  561.     If !onscreen{px,py}
  562.       QBlit db,161,px,py
  563.     Else
  564.       KillItem fire()
  565.     EndIf
  566.   Wend
  567.   Return
  568.  
  569. .drawbullets
  570.   ResetList bul()
  571.   USEPATH bul()
  572.   While NextItem(bul())
  573.     \x+\xv                                 ;speed
  574.     \y+\yv
  575.     px=((\x-me\x) ASR 6)+#xcntr
  576.     py=((\y-me\y) ASR 6)+#ycntr
  577.     If !onscreen{px,py}
  578.       If BlitColl(64,px,py) Then sh=64:Gosub checknme
  579.       QBlit db,160,px,py
  580.     Else
  581.       KillItem bul()
  582.     EndIf
  583.   Wend
  584.   Return
  585.  
  586. .checknme:
  587.   ResetList nme()
  588.   USEPATH nme()
  589.   While NextItem(nme())
  590.     If ShapesHit(\frame,\px,\py,sh,px,py)
  591.       Sound 2,2
  592.       oldscore.l=*p\score
  593.       *p\score+\nme\points
  594.       If Int(*p\score/10000)>Int(oldscore/10000)
  595.         *p\lives+1:*p\shield+200:Sound 6,2
  596.       EndIf
  597.       For i=1 To 4
  598.         If AddItem(bng())
  599.           bng()\x=\x,\y,31
  600.           bng()\xv=\xv/2+Rnd(64)-32
  601.           bng()\yv=\yv/2+Rnd(64)-32
  602.           numexp+1
  603.         EndIf
  604.       Next
  605.       USEPATH nme()\parent
  606.       \tot-1
  607.       If \tot=0
  608.         If \start>0
  609.           \start=*p\ptimer+1
  610.         Else
  611.           *p\totwaves-1
  612.         EndIf
  613.       EndIf
  614.       KillItem nme()
  615.     EndIf
  616.   Wend
  617.   Return
  618.  
  619. .setupsincos
  620.   For i=0 To 1023
  621.     rad.f=i*Pi/512
  622.     qsin(i)=Sin(rad)
  623.     qcos(i)=Cos(rad)
  624.   Next
  625.   Return
  626.  
  627. .setuppalette
  628.   Restore scanpalette
  629.   For i=0 To 7:Read r,g,b:PalRGB 0,i,r,g,b:Next
  630.   r=14:g=12:b=12:Gosub planetcolor
  631.   Return
  632.  
  633. .scanpalette:
  634.   Data 0,0,0,15,15,15,14,0,0,0,8,0,3,6,13
  635.   Data 15,14,0,13,6,11,4,4,9
  636.  
  637. .planetcolor:
  638.   PalRGB 1,9,r,g,b
  639.   r=QLimit(r-3,0,15):g=QLimit(g-3,0,15):b=QLimit(b-3,0,15)
  640.   For i=0 To 5
  641.     PalRGB 1,10+i,r,g,b
  642.     r=QLimit(r-1,0,15):g=QLimit(g-1,0,15):b=QLimit(b-1,0,15)
  643.   Next
  644.   Return
  645.  
  646. ;frame,numrots,thrust,rspeed,drag,thrusttime,firpower,pts,reload,col=3
  647.  
  648. .setupnme:
  649.   For i=0 To 7
  650.     alien(00+i)\frame=16,16,40+i*20,4096+i*64,3,8-i/3,5+i*3,150,50-i,7
  651.     alien(08+i)\frame=32,16,20+i,3048+i*160,7,10-i/3,5+i*3,150,50-i,7
  652.     alien(16+i)\frame=48,16,10+i,5048+i*500,6,8,10+i*2,200,40-i/2,6
  653.     alien(24+i)\frame=64,16,6+i,2048+i*500,8,8,20+i*3,200,40-i/2,6
  654.     alien(32+i)\frame=80,16,70+i*10,8000+i*32,4,2,8+i,300,30-i*2,3
  655.     alien(40+i)\frame=96,16,90+i*14,6000+i*24,2,2,8+i,300,30-i*2,3
  656.   Next
  657.   Return
  658.  
  659. .setuppcols
  660.   Restore pcolors
  661.   For i=0 To 4:Read r,g,b:pcols(i)\r=r,g,b:Next
  662.   Return
  663.  
  664. pcolors:
  665.   Data 9,7,7
  666.   Data 9,9,9
  667.   Data 7,9,7
  668.   Data 7,7,9
  669.   Data 9,9,7
  670.  
  671. .setuppaterns
  672.   USEPATH patern(i)
  673.   d=-1:n=2
  674.   For i=1 To 199
  675.     prpt=i MOD 5
  676.     If prpt=1
  677.       Restore patdata
  678.       If d<7 Then d+1 Else n+1          ;increase difficulty
  679.     EndIf
  680.     \pcol=prpt
  681.     Read acode
  682.     \numhumes=acode
  683.     j=0
  684.     Repeat
  685.       Read acode
  686.       If acode>-1
  687.         \waves[j]\nme=alien(acode+d),0,3,500,n,1,0
  688.         j+1
  689.       EndIf
  690.     Until acode=-1
  691.     \waves[j]\nme=0
  692.   Next
  693.   Return
  694.  
  695. .patdata
  696.   Data 5,0,16,-1
  697.   Data 5,0,8,16,-1
  698.   Data 5,0,8,16,24,-1
  699.   Data 5,8,24,32,40,-1
  700.   Data 15,24,40,-1
  701.   Data -1
  702.