; ; Shooting stars by Dennis Fox ; ; Page zero usage PBASE = $CB ;POINTERS TO... MBASE = $CD ;MISSILES, BASE2 = $CF ;PLAYER1, BASE3 = $D1 ;PLAYER2, BASE4 = $D3 ;PLAYER3 ADDR = $D5 ;2-BYTE POINTER ; Page 6 usage X = $600 Y = $601 XM = $610 YM = $620 DM = $630 T1 = $640 T2 = $641 TI1 = $642 TI2 = $643 HIT = $645 LIFE = $650 TI3 = $660 TI4 = $6A0 ELF = $6A1 SF1 = $6A2 STIME = $6A3 ; Operating system equates ATTRAC = $4D ;ATTRACT MODE POINTER PCOLR0 = $2C0 ;PLAYER COLORS PCOLR1 = $2C1 PCOLR2 = $2C2 PCOLR3 = $2C3 COLOR0 = $2C4 ;PLAYFIELD COLORS COLOR1 = $2C5 COLOR2 = $2C6 COLOR3 = $2C7 COLOR4 = $2C8 SDMCTL = $22F ;DMA CONTROL SDLSTL = $230 ;DISP LIST POINTER SDLSTH = $231 STICK0 = $278 ;JOYSTICK STRIG0 = $284 ;STICK BUTTON HITCLR = $D01E ;COLLISION CLEAR HPOSP0 = $D000 ;P/M HOR. POSITIONS HPOSP1 = $D001 HPOSP2 = $D002 HPOSP3 = $D003 HPOSM0 = $D004 HPOSM1 = $D005 HPOSM2 = $D006 HPOSM3 = $D007 M1PL = $D009 ;COLLISION REGISTERS M2PL = $D00A M3PL = $D00B P1PL = $D00D P2PL = $D00E P3PL = $D00F GRACTL = $D01D ;GRAPHIC CONTROL CONSOL = $D01F ;CONSOLE BUTTONS AUDF1 = $D200 ;AUDIO CONTROLS AUDC1 = $D201 AUDF2 = $D202 AUDC2 = $D203 RANDOM = $D20A ;RANDOM # PMBASE = $D407 ;P/M START ADDR SETVBV = $E45C ;VERT BLANK SET VECTOR XITVBV = $E462 ;VERT BLANK EXIT ; set up screen and display list ORG $2000 SSTAR LDX #9 LDA #$FF SETTB STA SCRNA,X ;SET TOP... STA SCRNC,X ;AND BOTTOM... DEX ;OF SCREEN BPL SETTB LDX #41 LDA #SCRNB/256 ;POINT TO... STA ADDR+1 ;MIDDLE OF SCREEN LDA #SCRNB&255 STA ADDR SETMID LDY #9 MIDLP LDA MIDBYT,Y ;COPY MIDDLE BYTES... STA (ADDR),Y ;TO SCREEN RAM DEY BPL MIDLP LDA ADDR ;NOW ADD 10 BYTES... CLC ;TO POINT TO... ADC #10 ;NEXT LINE STA ADDR LDA ADDR+1 ADC #0 STA ADDR+1 DEX ;ANOTHER LINE? BPL SETMID ;YES! LDA #DLIST&255 ;POINT TO STA SDLSTL ;DISPLAY LDA #DLIST/256 ;LIST STA SDLSTH LDA #$00 ;SET LOW BYTES... STA MBASE ;OF P/M POINTERS STA PBASE STA BASE2 STA BASE3 STA BASE4 LDA #$33 ;NOW SET HI BYTES STA MBASE+1 ;TO POINT TO LDA #$34 ;VARIOUS P/M AREAS STA PBASE+1 LDA #$35 STA BASE2+1 LDA #$36 STA BASE3+1 LDA #$37 STA BASE4+1 ; Set players starting position START2 LDA #16 ;INITIALIZE TIMERS STA TI1 STA TI2 STA TI4 LDA #$00 STA ELF STA SF1 STA STIME STA TI3 LDA #5 ;START W/5 LIVES STA LIFE START LDA #180 ;SET UP... STA X ;ASTRONAUT X LDA RANDOM ;NOW GET... LSR A ;RANDOM # CLC ;AND SET UP ADC #55 ;ASTRONAUT Y STA Y ; Set missles horizontal position LDX #$00 ;GET RANDOM... L1 LDA RANDOM ;HORIZONTAL LSR A ;POSITION, LSR A ;MAKE SURE IT'S ADC #50 ;ON SCREEN, STA XM,X ;STORE IT INX ;NEXT MISSILE CPX #6 ;ALL DONE? BNE L1 ;NOT YET! ; Set missles vertical position LDX #$00 ;START W/MISSILE 0 L2 TXA ;GET MISSILE # ASL A ;MULTIPLY... ASL A ;MISSILE... ASL A ;NUMBER... ASL A ;BY 32, ASL A ;MAKE SURE IT'S... ADC #55 ;ON SCREEN, STA YM,X ;AND STORE IT! INX ;NEXT MISSILE CPX #6 ;ALL DONE? BNE L2 ;NOT YET! ; Set missiles' starting directions LDX #$00 L3 LDA RANDOM ;GET RANDOM... AND #$03 ;DIRECTION STA DM,X ;AND STORE INX ;NEXT MISSILE CPX #6 ;ALL DONE? BNE L3 ;NOT YET! ; Set up player missile graphics ; Single line resolution LDA #$30 ;POINT TO P/M AREA STA PMBASE LDA #62 ;TURN ON SCREEN STA SDMCTL LDA #3 ;SET P/M GRAPHICS STA GRACTL LDA #$00 ;NOW CLEAR OUT... TAY ;ALL MISSILES A1 STA (PBASE),Y ;AND PLAYERS STA (MBASE),Y STA (BASE2),Y STA (BASE3),Y STA (BASE4),Y INY BNE A1 LDA #$00 ;NO COLLISION! STA HIT STA HITCLR LDA #$46 ;SET UP COLORS STA PCOLR0 LDA #15 STA PCOLR1 STA PCOLR2 STA PCOLR3 LDA #150 STA COLOR1 LDA #54 STA COLOR2 LDA #$F8 STA COLOR0 LDA #3 STA T2 LDA #$07 ;NOW START UP... LDX #VBI/256 ;OUR VERTICAL BLANK... LDY #VBI&255 ;INTERRUPT! JSR SETVBV ; The game begins here BACK LDA CONSOL ;CHECK CONSOLE KEYS CMP #6 ;START PRESSED? BNE JOY2 ;NOPE! JMP DEATH ;GO TO RESTART! ; Read joystick JOY2 LDA STICK0 ;GET ASTRONAUT... AND #1 ;DIRECTION BNE O1 DEC Y ;UP O1 LDA STICK0 AND #$08 BNE O2 INC X ;RIGHT O2 LDA STICK0 AND #$02 BNE O3 INC Y ;DOWN O3 LDA STICK0 AND #$04 BNE O4 DEC X ;LEFT O4 LDA X ;GET ASTRO. X CMP #200 ;TOO FAR RIGHT? BNE O5 ;IT'S OK DEC X ;TOO FAR! O5 LDA X CMP #50 ;TOO FAR LEFT? BNE O6 ;OK. INC X ;TOO FAR! O6 LDA Y ;GET ASTRO. Y CMP #52 ;TOO FAR UP? BNE O7 ;OK. INC Y ;TOO FAR! O7 LDA Y CMP #200 ;TOO FAR DOWN? BNE O8 ;OK. DEC Y ;TOO FAR! ; Put astronaut on playfield O8 LDA X ;GO AHEAD AND SET... STA HPOSP0 ;HOR. POSITION LDX #$00 ;NOW COPY THE... LDY Y ;ASTRONAUT IMAGE... B1 LDA ANAUT,X ;INTO PLAYER 1 STA (PBASE),Y INX INY CPX #19 BNE B1 ; Move missiles LDX #$00 D0 LDA DM,X ;GET MISSILE DIR. BNE D1 INC XM,X ;RIGHT... DEC YM,X ;AND UP D1 LDA DM,X CMP #1 BNE D2 INC XM,X ;RIGHT... INC YM,X ;AND DOWN! D2 LDA DM,X CMP #2 BNE D3 DEC XM,X ;LEFT... INC YM,X ;AND DOWN! D3 LDA DM,X CMP #3 BNE DO1 DEC XM,X ;LEFT... DEC YM,X ;AND UP! DO1 INX ;NEXT MISSILE CPX #6 ;ALL DONE? BNE D0 ;NO, DO OTHERS! ; Check if missile has hit wall LDX #$00 C0 LDA XM,X ;GET X POS. CMP #202 ;TOO FAR RIGHT? BNE C1 ;IT'S OK. LDA DM,X ;IT'S TOO FAR, BNE DI1 ;WE MUST REVERSE LDA #3 ;THE DIRECTION! STA DM,X CLC BCC C1 DI1 LDA #2 STA DM,X C1 LDA XM,X ;GET X POS. CMP #48 ;TOO FAR LEFT? BNE C2 ;OK. LDA DM,X ;REVERSE DIRECTION! CMP #2 BEQ DI2 LDA #0 STA DM,X CLC BCC C2 DI2 LDA #1 STA DM,X C2 LDA YM,X ;GET Y POS. CMP #52 ;TOO FAR UP? BNE C3 ;OK. LDA DM,X ;REVERSE! BNE DI3 LDA #1 STA DM,X CLC BCC C3 DI3 LDA #2 STA DM,X C3 LDA YM,X ;GET Y POS. CMP #213 ;TOO FAR DOWN? BNE C4 ;OK. LDA DM,X ;REVERSE! CMP #1 BNE DY2 LDA #$00 STA DM,X CLC BCC C4 DY2 LDA #3 STA DM,X C4 INX ;NEXT MISSILE CPX #6 ;ALL DONE? BNE C0 ;NO, DO OTHERS! ; Plot missiles on playfield LDA XM ;SET ALL MISSILES... STA HPOSP1 ;HORIZONTAL... LDA XM+1 ;POSITIONS! STA HPOSP2 LDA XM+2 STA HPOSP3 LDA XM+3 STA HPOSM1 LDA XM+4 STA HPOSM2 LDA XM+5 STA HPOSM3 LDA #$00 ;PLOT 1ST MISSILE LDY YM ;IN PLAYER 1 STA (BASE2),Y LDA #$10 INY STA (BASE2),Y INY STA (BASE2),Y LDA #$00 INY STA (BASE2),Y LDA #$00 ;PLOT 2ND MISSILE LDY YM+1 ;IN PLAYER 2 STA (BASE3),Y LDA #$10 INY STA (BASE3),Y INY STA (BASE3),Y LDA #$00 INY STA (BASE3),Y LDA #$00 ;PLOT 3RD MISSILE LDY YM+2 ;IN PLAYER 3 STA (BASE4),Y LDA #$10 INY STA (BASE4),Y INY STA (BASE4),Y LDA #$00 INY STA (BASE4),Y LDA #$EF ;PLOT 4TH MISSILE LDY YM+3 ;IN MISSILE 1 AND (MBASE),Y STA (MBASE),Y LDA #$10 INY ORA (MBASE),Y STA (MBASE),Y LDA #$10 INY ORA (MBASE),Y STA (MBASE),Y LDA #$EF ;PLOT 5TH MISILE INY ;IN MISSILE 2 AND (MBASE),Y STA (MBASE),Y LDA #$FB LDY YM+4 AND (MBASE),Y STA (MBASE),Y LDA #$04 INY ORA (MBASE),Y STA (MBASE),Y LDA #$04 INY ORA (MBASE),Y STA (MBASE),Y LDA #$FB ;PLOT 6TH MISSILE INY ;IN MISSILE 3 AND (MBASE),Y STA (MBASE),Y LDA #$BF LDY YM+5 AND (MBASE),Y STA (MBASE),Y LDA #$40 INY ORA (MBASE),Y STA (MBASE),Y LDA #$40 INY ORA (MBASE),Y STA (MBASE),Y LDA #$BF INY AND (MBASE),Y STA (MBASE),Y ; Create sound INC T1 LDA T1 CMP #$10 BNE SO1 LDA #$00 STA T1 DEC T2 LDA T2 BNE SO2 LDA #3 STA T2 SO2 LDA #$C8 ;SET SOUND CONTROL STA AUDC2 LDA T2 ;GET SOUND NUMBER CMP #3 ;SOUND 3? BNE S2 ;NO! LDA #120 ;SET 3RD... STA AUDF2 ;SOUND FREQUENCY CLC BCC SO1 ;GO SHOW TIME S2 LDA T2 CMP #2 ;SOUND 2? BNE S3 ;NO! LDA #100 ;SET 2ND... STA AUDF2 ;SOUND FREQUENCY CLC BCC SO1 ;AND SHOW TIME S3 LDA #85 ;SET 1ST STA AUDF2 ;SOUND FREQUENCY SO1 LDA TI1 ;SHOW DIGIT 1... STA SCREEN+9 ;OF SECONDS LDA TI2 ;SHOW DIGIT 2... STA SCREEN+10 ;OF SECONDS LDA TI4 ;SHOW MINUTES! STA SCREEN+7 ; Check for extra life LDA TI4 ;GET MINUTES CMP #19 ;3 MINUTES? BNE OELC ;NO! LDA ELF ;DONE EXTRA LIFE YET? BNE OELC ;YES, NO MORE! INC LIFE ;ANOTHER LIFE INC ELF ;SET EXTRA LIFE FLAG LDA #$A4 ;SET UP FOR... STA AUDC1 ;EXTRA LIFE SOUND LDA #$01 STA SF1 OELC LDA TI4 ;GET MINUTES CMP #21 ;5 MINUTES? BNE OEL ;NO! LDA ELF ;GOT 2ND EXTRA? CMP #1 BNE OEL ;NO MORE! INC LIFE ;ANOTHER LIFE! INC ELF ;INC EXTRA LIFE FLAG LDA #$A4 ;SET UP FOR... STA AUDC1 ;EXTRA LIFE SOUND LDA #$01 STA SF1 ; Check for ending sequence OEL LDA HIT ;ASTRO HIT DEBRIS? BEQ NEND ;NO, HE'S OK. JMP END ;UH-OH! NEND LDA #80 ;THIS SECTION LSR TI1 ;CREATES A TIME PHP ;DELAY USING SEC ;THE TIME VARIABLES SBC TI1 ;TI1 AND TI4 PLP ROL TI1 LDX #$00 SMOR SBC TI4 INX CPX #3 BNE SMOR TAX TD1 LDY #$00 ;THIS IS A TD2 INY ;TIME DELAY BNE TD2 ;ROUTINE! DEX BNE TD1 ; Play extra life sound LDA SF1 ;GET BONUS SOUND FLAG CMP #1 ;FIRST FREQ? BNE SC2 ;NO! LDA #50 ;SET 1ST BONUS FREQ. STA AUDF1 INC STIME ;INC SOUND TIMER LDA STIME CMP #$25 ;END OF SOUND? BNE SC2 ;NOT YET! INC SF1 ;NEXT FREQ LDA #$00 ;NO MORE SOUND! STA STIME SC2 LDA SF1 ;GET BONUS SOUND FLAG CMP #2 ;SECOND FREQ? BNE SC3 ;NO! LDA #40 ;SET FREQ. STA AUDF1 INC STIME ;INCREMENT TIMER LDA STIME CMP #$25 ;SOUND DONE? BNE SC3 ;NO! INC SF1 ;NEXT FREQ LDA #$00 ;ALL DONE! STA STIME SC3 LDA SF1 ;GET BONUS SOUND FLAG CMP #3 ;3RD FREQ? BNE SC4 ;NO! LDA #32 ;SET FREQ. STA AUDF1 INC STIME ;INC SOUND TIMER LDA STIME CMP #$25 ;SOUND DONE? BNE SC4 ;NO! INC SF1 ;SET FOR END LDA #$00 ;ALL DONE! STA STIME SC4 LDA SF1 ;GET BONUS SOUND FLAG CMP #4 ;END OF SOUND? BNE SC5 ;NO! LDA #00 ;SHUT OFF SOUND! STA AUDF1 STA AUDC1 LDA #$00 ;ALL DONE! STA STIME SC5 LDA #138 ;UPDATE LIVES... LDX #$00 ;DISPLAY DMORE STA SCREEN+13,X ;ALL LIVES INX CPX LIFE BNE DMORE JMP BACK END DEC LIFE ;1 LESS LIFE LDA #$A8 ;INIT DEATH SOUND STA AUDC1 STA AUDC2 LDA #50 ;INIT FREQ. SA STA AUDF1 PHA CLC ADC #100 ;INCREMENT SOUND STA AUDF2 STA PCOLR0 ;FLASH ASTRONAUT PLA LDY #$00 ;TIME DELAY DLY2 LDX #$00 DLY1 INX BNE DLY1 INY CPY #25 BNE DLY2 CLC ADC #$01 CMP #100 ;END OF DEATH? BNE SA ;NO, LOOP BACK LDA #$00 ;SHUT OFF SOUND STA AUDF1 STA AUDC1 STA AUDF2 STA AUDC2 LDA #$46 ;RESET... STA PCOLR0 ;ASTRONAUT COLOR LDA #$00 ;REMOVE... LDY LIFE ;LIFE INDICATOR... STA SCREEN+13,Y ;FROM SCREEN LDA LIFE ;ANY MORE LIVES? BEQ DEATH ;NO! END OF GAME! JMP START ;ANOTHER LIFE. DEATH LDA #00 ;ZERO LIVES STA LIFE AGAIN LDA STRIG0 ;STICK TRIGGER PRESSED? BEQ RESTRT ;YES! LDA CONSOL ;GET CONSOLE KEY CMP #6 ;START PRESSED? BNE AGAIN ;NO! RESTRT LDA #$00 ;RESET... STA ATTRAC ;ATTRACT MODE JMP START2 ;RESTART GAME. ; Vertical blank interrupt VBI LDA M1PL ;GET... ORA M2PL ;ALL... ORA M3PL ;COLLISION... ORA P1PL ;REGISTERS... ORA P2PL ;AND CHECK... ORA P3PL ;FOR... AND #1 ;ASTRONAUT... STA HIT ;COLLISION! INC TI3 ;INCREMENT 1/60 SEC. LDA TI3 ;TIMER CMP #60 ;ANOTHER SECOND? BNE TOVR ;NO! LDA #$00 ;RESET 60THS OF SEC STA TI3 INC TI2 ;ANOTHER SECOND LDA TI2 CMP #26 ;10 SECS? BNE TOVR ;NO! LDA #16 ;RESET 2ND SECOND... STA TI2 ;DIGIT TO 0 INC TI1 ;INCREMENT 1ST... LDA TI1 ;SECOND DIGIT CMP #22 ;GOT A MINUTE? BNE TOVR ;NO! INC TI4 ;INCREMENT MINUTES LDA #16 ;RESET 1ST SECOND... STA TI1 ;DIGIT TO 0 TOVR JMP XITVBV ;EXIT VERT BLANK! ; Set up display list DLIST DB 112,112,112,71 DW SCREEN DB 9,9,9,9,9,9,9,9,9,9 DB 9,9,9,9,9,9,9,9,9,9 DB 9,9,9,9,9,9,9,9,9,9 DB 9,9,9,9,9,9,9,9,9,9 DB 9,9,9,9 DB 65 DW DLIST ; Data for astronaut image ANAUT DB $00,$7C,$54,$6C,$7C,$44,$7C,$10,$10,$FE,$BA,$BA DB $BA,$38,$38,$28,$28,$EE,$00 ; Set up screen memory MIDBYT DB 128,0,0,0,0,0,0,0,0,1 SCREEN DB 0,0,116,105,109,101,0,0,26,0,0,0,0,0,0,0,0,0,0,0 SCRNA DS 10 SCRNB DS 420 SCRNC DS 10 END SSTAR