0110 ; 0120 ; Initialize Playfield 0130 ; -------------------- 0140 ; 0150 PLAYGM JSR AUDOFF ;turn snd off 0160 STA HITCLR ;clr collisions 0170 LDA #$FF ;value for 0180 STA DEAD ;ship 1 alive 0190 STA DEAD+1 ;ship 2 alive 0200 LDA #$40 ;value to 0210 STA NMIEN ;enable VBI's 0220 LDA #PAGES*2 ;pages to zero 0230 STA TEMP+2 ;save in counter 0240 LDA # DRAM ;display addr hi 0270 STA GRPAGE+1 ;displa pntr hi 0280 LDA # >PMM ;PM addr hi 0290 STA GRPM+1 ;PM pointer hi 0300 LDA #$21 ;value for 0310 STA GPRIOR ;mulit-color PL 0320 STA AUDF4 ;engine sound 0330 LDA #1 ;value for 0340 STA SIZEP2 ;double width 0350 STA SIZEP3 ;comets enabled 0360 STA ENDGAM ;game on 0370 LDA #99 ;max score value 0380 STA SCORES ;player 1 0390 STA SCORES+1 ;player 2 0400 LDX #24 ;move 25 bytes 0410 PLA3 LDA TRAMI,X ;from TRAMI 0420 STA TRAM,X ;to TRAM 0430 DEX ;dec index 0440 BPL PLA3 ;done? No. 0450 LDA # >PM0 ;player addr hi 0460 STA GRPX+1 ;pntr hi byte 0470 JSR SCRCLR ;clear inverse 0480 LDA #$05 ;value for 0490 STA SIZEM ;missile sizes 0500 LDA #0 ;get zero 0510 STA HPOS ;comet X coord 0520 STA FLASHF ;inverse flag 0530 STA COMETF ;comet flag 0540 STA ATRACT ;attract mode 0550 STA SCLOCK ;score sound 0560 STA MISSLE ;missile 0 flag 0570 STA MISSLE+1 ;missile 1 flag 0580 TAY ;zero Y index 0590 PLA0 STA (GRPAGE),Y ;scrn byte=0 0600 INY ;inc Y index 0610 BNE PLA0 ;page done? No. 0620 INC GRPAGE+1 ;do next page 0630 DEC TEMP+2 ;page count 0640 BNE PLA0 ;all done? No. 0650 LDA #191 ;init Y coord of 0660 STA YPLR ;ship 1 0670 STA YPLR+1 ;ship 2 0680 TYA ;get zero 0690 PLA1 STA PMM,Y ;zero missiles 0700 STA PM0,Y ;player 0+1 0710 STA PM2,Y ;player 2+3 0720 INY ;next byte 0730 BNE PLA1 ;page done? No. 0740 JSR RANFIL ;put asteroids 0750 LDX #1 ;do 2 players 0760 PLA11 LDA XSTRT,X ;ship X start 0770 STA HPOSP0,X ;set hardware 0780 STA XPLR,X ;and shadow 0790 DEX ;next ship 0800 BPL PLA11 ;done? No. 0810 INX ;make it a one 0820 STX COLOR2 ;black 0830 STX TEMP+1 ;zero temporary 0840 LDA #$2E ;value for 0850 STA SDMCTL ;P/M enable 0860 STA COLOR1 ;bright orange 0870 LDA # >PM ;set up P/M 0880 STA PMBASE ;base address 0890 LDA #3 ;value to 0900 STA GRACTL ;enable P/M 0910 LDA #$C4 ;green for 0920 STA PCOLR0 ;first ship 0930 LDA #$34 ;red/orange for 0940 STA PCOLR1 ;second ship 0950 LDA # GISR ;DLI addr hi 0980 STA VDSLST+1 ;DLI pntr hi 0990 LDA # DISPG ;DL addr hi 1020 STA SDLSTL+1 ;DL pntr hi 1030 LDA #$C0 ;value to 1040 STA NMIEN ;enable DLI's 1050 ; 1060 ; Game Loops Here, Loops Here... 1070 ; ------------------------------ 1080 ; 1090 ASHIFT JSR LDGRRT ;set up pointers 1100 ROR TEMP+1 ;get saved carry 1110 BCC ART0 ;bit #1=0? Yes. 1120 LDA (GRPAGE),Y ;get byte 1130 ORA #$80 ;set high bit 1140 CLC ;clear carry 1150 BCC ART2 ;skip next 1160 ART0 LDA (GRPAGE),Y ;get byte 1170 ART2 ROR A ;rotate right 1180 STA (GRPAGE),Y ;replace byte 1190 INY ;next byte 1200 BNE ART0 ;page done? No. 1210 INC GRPAGE+1 ;inc page addr 1220 DEC TEMP+2 ;dec page count 1230 BNE ART0 ;pages done? No. 1240 LDA #PAGES ;pages to rotate 1250 STA TEMP+2 ;put someplace 1260 LDA # ASTL ;hi addr 1290 STA GRPAGE+1 ;gr pntr hi 1300 ALF1 DEY ;dec Y index 1310 LDA (GRPAGE),Y ;get graphic 1320 ROL A ;move to left 1330 STA (GRPAGE),Y ;replace byte 1340 TYA ;test Y index 1350 BNE ALF1 ;Zero? No. 1360 DEC GRPAGE+1 ;dec hi addr 1370 DEC TEMP+2 ;dec page count 1380 BNE ALF1 ;pages done? No. 1390 ROL TEMP+1 ;save carry bit 1400 STA GRP1 ;zero low bytes 1410 STA GRP2 ;of these three 1420 STA GRPAGE ;page zero pntrs 1430 LDA # >ASTL ;scrn lf addr hi 1440 STA GRP1+1 ;scrn fl pntr hi 1450 LDA # >ASTR ;scrn rt addr hi 1460 STA GRP2+1 ;scrn rt pntr hi 1470 LDA # >DRAM ;display addr hi 1480 STA GRPAGE+1 ;displa pntr hi 1490 LDA # DRAM-20 ;w/offset hi 1520 STA GRP20P+1 ;offset pntr hi 1530 LDX #76 ;76 scan lines 1540 ORA0 LDY #19 ;do 20 bytes 1550 ORA1 LDA (GRP1),Y ;to left field 1560 ORA (GRP2),Y ;to right field 1570 STA (GRPAGE),Y ;lf half scrn 1580 STA (GRP20P),Y ;rt half scrn 1590 DEY ;dec index 1600 BPL ORA1 ;line done? No. 1610 LDA GRP1 ;lf field lo 1620 CLC ;clear carry 1630 ADC #20 ;20 byte offset 1640 STA GRP1 ;do next line of 1650 STA GRP2 ;asteroid fields 1660 BCC ORA2 ;overflow? No. 1670 INC GRP1+1 ;inc left, right 1680 INC GRP2+1 ;asteroid pntrs 1690 ORA2 CLC ;clear carry 1700 LDA GRPAGE ;graphic addr lo 1710 ADC #40 ;line offset 1720 STA GRPAGE ;new lo addr 1730 BCC ORA3 ;overflow? No. 1740 INC GRPAGE+1 ;inc hi addr 1750 ORA3 CLC ;clear carry 1760 LDA GRP20P ;gr addr2 lo 1770 ADC #40 ;line offset 1780 STA GRP20P ;new lo addr2 1790 BCC ORA4 ;overflow? No. 1800 INC GRP20P+1 ;inc high addr2 1810 ORA4 DEX ;decrement index 1820 BNE ORA0 ;done? No. 1830 JSR CONC ;check console 1840 BCC FLASH ;OPTION key? No. 1850 JMP STOPTS ;run option menu 1860 ; 1870 ; Inverse Universe Handler 1880 ; ------------------------ 1890 ; 1900 FLASH ROR A ;START -> carry 1910 BCC FL0 ;START pressed? 1920 JMP PLAYGM ;Yes. restart 1930 FL0 LDA UNIV ;univ flag 1940 BEQ COMET ;inverse? No. 1950 LDA FLASHF ;flash flag 1960 BEQ TRYFLA ;flash on? No. 1970 JSR REVSCR ;flash screen 1980 DEC FLASHC ;decrement count 1990 LDA ENDGAM ;game over flag 2000 BEQ FL1 ;game over? Yes. 2010 LDA FLASHC ;flash count 2020 LSR A ;make volume 2030 ORA #$A0 ;make pure tone 2040 FL1 STA AUDC2 ;universe sound 2050 LDA FLASHC ;flash count 2060 BEQ FLAEND ;done? Yes. 2070 ASL A ;times 2 2080 ASL A ;times 4 2090 ASL A ;times 8 2100 EOR #$FF ;flip bits 2110 STA UNIVS ;save univ sound 2120 BNE COMET ;continue 2130 ; 2140 SCRCLR LDA REVF ;reverse flag 2150 ROR A ;check bit 0 2160 BCC SC9 ;zero? Yes. 2170 REVSCR LDX #4 ;do colors 0..4 2180 REV0 LDA #$0F ;flip brightness 2190 EOR COLOR0,X ;of colors 2200 STA COLOR0,X ;replace values 2210 DEX ;decrement index 2220 BPL REV0 ;done? No. 2230 DEC REVF ;clear flag 2240 SC9 RTS ;return 2250 ; 2260 TRYFLA LDA RANDOM ;random number 2270 AND #$3F ;make 0..63 2280 BNE COMET ;do flash? No. 2290 JSR REVSCR ;Yes. flash scrn 2300 LDA #$1F ;value for 2310 STA FLASHC ;flash count 2320 STA FLASHF ;flash flag 2330 BNE COMET ;continue 2340 ; 2350 FLAEND STA FLASHF ;flash univ off 2360 STA AUDC2 ;flash sound off 2370 ; 2380 ; Comet Mover 2390 ; ----------- 2400 ; 2410 COMET LDA COME ;comet flag 2420 BEQ COMETX ;comets? No. 2430 LDA COMETF ;comet on flag 2440 BEQ TRYCOM ;on? No. 2450 COMETX JMP ASHIFT ;continue 2460 ; 2470 TRYCOM LDA RANDOM ;random number 2480 AND #$3F ;make 0..63 2490 BNE COMETX ;enable? No. 2500 STA HINC ;comet H speed=0 2510 TAX ;initialize X=0 2520 TRY0 STA PM2,X ;clr players 2+3 2530 DEX ;decrement index 2540 BNE TRY0 ;done? No. 2550 STA HPOSP2 ;zero players 23 2560 STA HPOSP3 ;horizontal pos 2570 STA CSOUND ;zero comet snd 2580 TRY5 LDA RANDOM ;random number 2590 AND #3 ;make 0..3 2600 CMP #3 ;allow only 0..2 2610 BCS TRY5 ;3? Yes, repeat 2620 STA VDIR ;save 0..2 2630 DEC VDIR ;make -1..1 2640 LDA RANDOM ;random number 2650 AND #3 ;make 0..3 2660 TAX ;use as index 2670 LDA #$1F ;init increment 2680 TRY6 LSR A ;divide by 2 2690 DEX ;decrement index 2700 BPL TRY6 ;done? No. 2710 STA VINC ;vert increment 2720 LDA ENDGAM ;end game flag 2730 BEQ TRY7 ;game over? Yes. 2740 LDA #$88 ;No. make sound 2750 TRY7 STA AUDC1 ;comet sound 2760 LDA RANDOM ;random number 2770 AND #$3F ;make 0..63 2780 ADC #16 ;sorta 16..79 2790 STA VPOS ;vert start pos 2800 LDX #$FE ;value -2 2810 STX COMETF ;comet on flag 2820 LDA RANDOM ;random number 2830 BPL TRY1 ;flip a coin! 2840 LDX #$02 ;value +2 2850 TRY1 STX HDIR ;horiz direction 2860 LDA RANDOM ;random number 2870 BPL COMETX ;another coin! 2880 INC HINC ;change speed 2890 JMP ASHIFT ;continue 2900 ; 2910 ; Relocate program 2920 ; ---------------- 2930 ; 2940 RELOC LDA #$20 ;$2000 load addr 2950 STA GRP1+1 ;from pntr hi 2960 LDA #$10 ;to $1000 addr 2970 STA GRP2+1 ;to pntr hi 2980 TAX ;move 16 pages 2990 LDA #0 ;value for 3000 STA GRP1 ;from pntr lo 3010 STA GRP2 ;to pntr lo 3020 TAY ;zero index 3030 REL0 LDA (GRP1),Y ;from byte 3040 STA (GRP2),Y ;to byte 3050 DEY ;dec index 3060 BNE REL0 ;page done? No. 3070 INC GRP1+1 ;inc from hi 3080 INC GRP2+1 ;inc to hi 3090 DEX ;page count 3100 BNE REL0 ;done? No. 3110 JMP RIS ;run program 3120 ; 3130 *= $02E0 ;RUN address 3140 .WORD RELOC+$1000 3150 ; 3160 .END