0110 ; 0120 ; Game Interrupt Service Routine 0130 ; ------------------------------ 0140 ; 0150 GISR PHA ;save Acc 0160 JSR SMASH ;test collisions 0170 JSR ROTOR ;animate ships 0180 INC CLOCK ;increment clock 0190 CLC ;clear carry 0200 LDA UNIVS ;universe sound 0210 ADC #$30 ;change sound 0220 STA UNIVS ;replace sound 0230 STA AUDF2 ;make sound 0240 LDA ENDGAM ;game end flag 0250 BNE GI7 ;game over? No. 0260 JMP GI99 ;end it now! 0270 ; 0280 ; Ship Noise Generation 0290 ; --------------------- 0300 ; 0310 GI7 LDA #8 ;medium grey 0320 STA COLPF1 ;set color 0330 TXA ;move X to Acc 0340 PHA ;save X 0350 LDX #15 ;neutral stick 0360 LDA DEAD ;player 0 status 0370 BNE GI70 ;dead? No. 0380 STX STICK ;stick to center 0390 GI70 LDA DEAD+1 ;player 1 status 0400 BNE GI71 ;dead? No. 0410 STX STICK+1 ;stick to center 0420 GI71 LDA STICK ;check if either 0430 AND STICK+1 ;stick pushed by 0440 CMP #15 ;comparing w/15 0450 LDA #$81 ;rumble noise 0460 BCS GI03 ;both 15? Yes. 0470 LDA TRIGN ;trigger opt 0 0480 ORA TRIGN+1 ;trigger opt 1 0490 CMP #3 ;warp speed test 0500 LDA #$88 ;loud warp sound 0510 BCS GI03 ;warp? Yes. 0520 LDA #$84 ;med engine roar 0530 GI03 STA AUDC4 ;make engine snd 0540 LDA #24 ;warp frequency 0550 BCS GI30 ;warp? Yes. 0560 LDA #32 ;normal rockets 0570 GI30 STA AUDF4 ;set frequency 0580 LDX #0 ;init value for 0590 STX VDEL ;vertical delay 0600 INX ;make X = 1 0610 LDA M0PL ;missile 0 to 0620 STA M0PLS ;PL collisions 0630 LDA M0PL+1 ;missile 1 to 0640 STA M0PLS+1 ;PL collisions 0650 LDA TRIGN ;trigger opt 0 0660 ORA TRIGN+1 ;trigger opt 1 0670 CMP #1 ;check shields 0680 BNE MOVE2 ;shields on? No. 0690 LDA RANDOM ;random number 0700 AND #$1F ;only 0..31 0710 ORA #$20 ;only 32..63 0720 STA AUDF4 ;shield sound 0730 LDA #$A6 ;value for 0740 STA AUDC4 ;shield volume 0750 MOVE2 JSR TRIGR ;read trigger 0760 LDA DEAD,X ;player status 0770 BEQ MOVEX ;dead? Yes. 0780 LDA TRIGN,X ;trigger value 0790 CMP #1 ;shields in use? 0800 BEQ MOVEX ;Yes. skip next 0810 JSR MISFLY ;move missile 0820 LDA CLOCK ;get clock value 0830 ROR A ;bit 0 to carry 0840 BCC MOVE2X ;even? Yes. 0850 LDA TRIGN,X ;trigger value 0860 CMP #3 ;warp drive? 0870 BNE MOVEX ;No. skip next 0880 ; 0890 ; Joystick Handler 0900 ; ---------------- 0910 ; 0920 MOVE2X LSR STICK,X ;check joystick 0930 BCS MOVED ;stick up? No. 0940 DEC YPLR,X ;move ship up 0950 MOVED LSR STICK,X ;check joystick 0960 BCS MOVEL ;stick down? No. 0970 INC YPLR,X ;move ship down 0980 MOVEL LDA SHIP ;get ship type 0990 BEQ MOVEX ;U/D rocket? Yes. 1000 LSR STICK,X ;check joystick 1010 BCS MOVER ;stick left? No. 1020 DEC XPLR,X ;move ship left 1030 MOVER LSR STICK,X ;check joystick 1040 BCS MOVEX ;stick right? No. 1050 INC XPLR,X ;move ship right 1060 MOVEX LDA XPLR,X ;ship X coord 1070 CMP #$30 ;past left 1080 BCS MOVEX3 ;border? No. 1090 LDA #$30 ;set to border 1100 MOVEX3 CMP #$C8 ;past right 1110 BCC MOVEX4 ;border? No. 1120 LDA #$C7 ;set to border 1130 MOVEX4 STA XPLR,X ;save X coord 1140 STA HPOSP0,X ;position ship 1150 STY TEMP+3 ;save Y 1160 LDA DEAD,X ;ship status 1170 BMI MOVX4 ;alive? Yes. 1180 LDA CLOCK ;get clock value 1190 ROR A ;test bit 0 1200 BCS MOV4 ;clock odd? Yes. 1210 ASL A ;restore clock 1220 AND #$F6 ;max 7 brightness 1230 STA PCOLR0,X ;make ship color 1240 LDA SCLOCK ;score snd count 1250 BNE MOV4 ;sound on? Yes. 1260 LDA CLOCK ;get clock value 1270 AND #$07 ;make 0..7 1280 ORA #$C8 ;make $C8..$CF 1290 STA AUDC3 ;sound volume 1300 LDA RANDOM ;random number 1310 AND #$1F ;make 0..31 1320 ORA #$20 ;make 32..63 1330 STA AUDF3 ;weird sound 1340 MOV4 INC YPLR,X ;move ship down 1350 MOVX4 LDA YPLR,X ;ship Y coord 1360 BNE MOVEX6 ;screen top? No. 1370 JSR SCORE ;increment score 1380 MOVEX6 CMP #192 ;screen bottom? 1390 BCC MOVEX5 ;No. skip next 1400 LDA DEAD,X ;ship status 1410 BNE MOVX6 ;ship dead? No. 1420 LDA XPLR,X ;ship X coord 1430 CMP XSTRT,X ;compare w/start 1440 BEQ MOVX6A ;equal? Yes. 1450 INC XPLR,X ;move ship right 1460 BCC MOVX6 ;ok? Yes. else 1470 DEC XPLR,X ;move ship left 1480 DEC XPLR,X ;move ship left 1490 BNE MOVX6 ;skip next 1500 MOVX6A LDA #$FF ;value for 1510 STA DEAD,X ;working ship 1520 STA HITCLR ;clr collisions 1530 LDA PCOLRS,X ;value for 1540 STA PCOLR0,X ;ship color 1550 LDA SCLOCK ;score snd clock 1560 BNE MOVX6 ;sound on? Yes. 1570 STA AUDC3 ;zero sound 1580 MOVX6 LDA #191 ;value for 1590 MOVEX5 STA YPLR,X ;init Y coord 1600 CPX #1 ;ship 1? 1610 ROR A ;carry=1 if Yes. 1620 STA GRPX ;PM graphic pntr 1630 BCC MOVEX7 ;coord even? Yes. 1640 LDA VDEL ;vertical delay 1650 ORA VDMSK,X ;delay mask 1660 STA VDEL ;new V.delay 1670 MOVEX7 TXA ;move X to Acc 1680 PHA ;save X 1690 CLC ;clear carry 1700 LDA DEAD,X ;ship status 1710 BEQ MOVX7A ;ship dead? Yes. 1720 LDA RANDOM ;random number 1730 AND #$0F ;make 0..15 1740 ORA PCOLRS,X ;add ship color 1750 STA PCOLR0,X ;new ship color 1760 LDA TRIGN,X ;check trigger 1770 CMP #1 ;for shields 1780 SEC ;set carry 1790 BEQ MOVX7A ;shields? Yes. 1800 CLC ;clear carry 1810 LDA PCOLRS,X ;ship color 1820 STA PCOLR0,X ;set color 1830 MOVX7A LDY #9 ;do 10 bytes 1840 LDX #9 ;rocket offset 1850 LDA SHIP ;get ship type 1860 BEQ MOVEXD ;rocket? Yes. 1870 LDX #18 ;saucer offset 1880 MOVEXD LDA SHIPS,X ;ship graphic 1890 BCC MVXD ;shields on? No. 1900 AND RANDOM ;shield effect 1910 MVXD STA (GRPX),Y ;put ship 1920 DEX ;graphic index 1930 DEY ;PM index 1940 BPL MOVEXD ;done? No. 1950 PLA ;pull X 1960 TAX ;move Acc to X 1970 LDA MISSLE,X ;missile status 1980 BEQ MVXDM ;active? No. 1990 LDY #1 ;missile launcher 2000 LDA #0 ;no shot graphic 2010 STA (GRPX),Y ;put ship 2020 MVXDM LDY TEMP+3 ;restore Y index 2030 DEX ;next ship 2040 BMI MOVEX0 ;done? Yes. 2050 JMP MOVE2 ;No. continue 2060 MOVEX0 LDA VDEL ;V.delay shadow 2070 STA VDELAY ;vertical delay 2080 LDA ENDGAM ;game status 2090 BEQ MOVXE2 ;game over? Yes. 2100 JSR TIMER ;decrement time 2110 BPL GI9 ;time up? No. 2120 LDA #N7C+$C0 ;zero graphic 2130 STA TRAM+7 ;minutes display 2140 STA TRAM+9 ;10 sec display 2150 STA TRAM+10 ;seconds display 2160 STA TRAM+12 ;.1 sec display 2170 MOVXE2 LDA #121 ;goto attract 2180 STA ATRACT ;in 30 seconds 2190 LDA #0 ;get zero 2200 STA ENDGAM ;end game 2210 STA AUDC3 ;sound off 2220 STA AUDC4 ;sound off 2230 ; 2240 ; Comet Mover Routine 2250 ; ------------------- 2260 ; 2270 GI9 PLA ;pull X 2280 TAX ;move Acc to X 2290 GI99 LDA HINC ;comet H speed 2300 AND CLOCK ;mask with clock 2310 BEQ GI91 ;move comet? Yes. 2320 GI90 PLA ;restore Acc 2330 RTI ;return 2340 GI91 LDA COMETF ;comet status 2350 BEQ GI90 ;active? No. 2360 TYA ;move Y to Acc 2370 PHA ;save Y 2380 TXA ;move X to Acc 2390 PHA ;save X 2400 LDA HPOS ;comet H coord 2410 AND VINC ;and w/V speed 2420 BNE GI5 ;move vert? No. 2430 LDA VPOS ;comet V coord 2440 CLC ;clear carry 2450 ADC VDIR ;add V direction 2460 AND #$7F ;make 0..127 only 2470 STA VPOS ;replace V coord 2480 ; 2490 ; Draw Comet Graphics 2500 ; ------------------- 2510 ; 2520 GI5 LDY #13 ;do 14 bytes 2530 LDX VPOS ;comet V coord 2540 GI0 LDA RANDOM ;random number 2550 AND COMETM,Y ;mask w/comet 2560 STA PM2,X ;put player 2 2570 LDA RANDOM ;random number 2580 AND COMETM,Y ;do same thing 2590 STA PM3,X ;put player 3 2600 INX ;inc player addr 2610 TXA ;move X to Acc 2620 AND #$7F ;make 0..127 2630 TAX ;replace X 2640 DEY ;dec byte count 2650 BPL GI0 ;pic done? No. 2660 LDA RANDOM ;random number 2670 AND #$F0 ;color only 2680 ORA #$04 ;brightness 4 2690 STA PCOLR2 ;player 2 color 2700 LDA RANDOM ;random number 2710 AND #$F0 ;color only 2720 ORA #$08 ;brightness 8 2730 STA PCOLR3 ;player 3 color 2740 CLC ;clear carry 2750 LDA HPOS ;comet H coord 2760 ADC HDIR ;add H direction 2770 STA HPOS ;new H coord 2780 STA HPOSP2 ;player 2 H pos 2790 STA HPOSP3 ;player 3 H pos 2800 STA COMETF ;non 0 = enabled 2810 ; 2820 ; Generate Comet Sound 2830 ; -------------------- 2840 ; 2850 INC CSOUND ;comet snd freq 2860 LDA ENDGAM ;game status 2870 BEQ GIS ;game over? Yes. 2880 LDA CSOUND ;comet snd freq 2890 CMP #125 ;value < 125 2900 BCS GI2 ;No. skip next 2910 LSR A ;freq/2 2920 LSR A ;freq/4 2930 STA AUDF1 ;set frequency 2940 CMP #$18 ;past peak? 2950 BCC GI2 ;No. skip next 2960 EOR #$9F ;reverse volume 2970 GIS STA AUDC1 ;set volume 2980 GI2 PLA ;pull X 2990 TAX ;move Acc to X 3000 PLA ;pull Y 3010 TAY ;move Acc to Y 3020 PLA ;pull Acc 3030 RTI ;return 3040 ; 3050 ; Joystick Trigger Processor 3060 ; -------------------------- 3070 ; 3080 TRIGR LDA STRIG,X ;get trigger 3090 LSR A ;move to carry 3100 BCS TRIGX ;pressed? No. 3110 LDA TRIG ;trigger option 3120 TRIGX AND DEAD,X ;ship status 3130 CMP TRIGN,X ;same as last? 3140 BEQ TRIG2 ;Yes. skip next 3150 STA HITCLR ;clr collisions 3160 TRIG2 STA TRIGN,X ;trig option 3170 ; 3180 ; Missile Mover Routine 3190 ; --------------------- 3200 ; 3210 LDA MISSLE,X ;missile status 3220 BEQ MMX ;fired? No. 3230 LDA ROWCRS,X ;missile Y coord 3240 BNE MM0 ;zero? No. 3250 STA MISSLE,X ;disable missile 3260 MMX RTS ;return 3270 ; 3280 MM0 CLC ;clear carry 3290 LDA DELTAR,X ;add delta Y 3300 ADC ROWAC,X ;to Y Acc 3310 STA ROWAC,X ;new Y Acc 3320 CMP ENDPT,X ;cmp w/endpoint 3330 BCC MM1 ;change Y? No. 3340 SBC ENDPT,X ;sub endpoint 3350 STA ROWAC,X ;new Y Acc value 3360 CLC ;clear carry 3370 LDA ROWINC,X ;add shot Y inc 3380 ADC ROWCRS,X ;to Y coord 3390 STA ROWCRS,X ;new Y coord 3400 MM1 CLC ;clear carry 3410 LDA DELTAC,X ;add delta X 3420 ADC COLAC,X ;to X Acc 3430 STA COLAC,X ;new X Acc 3440 CMP ENDPT,X ;cmp w/endpoint 3450 BCC MMP ;change X? No. 3460 SBC ENDPT,X ;sub endpoint 3470 STA COLAC,X ;new X Acc value 3480 CLC ;clear carry 3490 LDA COLINC,X ;add shot X inc 3500 ADC COLCRS,X ;to X coord 3510 STA COLCRS,X ;new X coord 3520 MMP LDA COUNTR,X ;iteration cnt 3530 BEQ MMP1 ;cnt done? Yes. 3540 LSR A ;cnt div 2 3550 ORA #$88 ;weird sound 3560 STA AUDC3 ;make sound FX 3570 LDA COUNTR,X ;get cnt again 3580 EOR #$0F ;very weird FX 3590 ASL A ;times 2 3600 ASL A ;times 4 3610 ASL A ;times 8 3620 STA AUDF3 ;set frequency 3630 DEC COUNTR,X ;decrement cnt 3640 MMP1 LDA COLCRS,X ;shot X coord 3650 STA HPOSM0,X ;PM horiz pos 3660 LDA ROWCRS,X ;shot Y coord 3670 LSR A ;2 line res 3680 BCC MM00 ;even line? Yes. 3690 PHA ;save PM Y coord 3700 LDA VDEL ;VDELAY shadow 3710 ORA VDMSK+2,X ;odd scan line 3720 STA VDEL ;new shadow val 3730 PLA ;restore Y coord 3740 MM00 ORA #