lorom ;90BECF missile shot code ;90AF68 running code for Missiles ;90AFE5 running code for Super Missiles !enemynum = $0E4E ;Number of enemies in the room !prox = $0B64,x ;Projectile X position in pixels !proy = $0B78,x ;Projectile Y position in pixels !proindex = $0DDE ;index !xenemy = $0F7A,x ;- enemy X pos (from room pop) !yenemy = $0F7E,x ;- enemy Y pos (from room pop) !radius = #$0080 !acceleration = #$0030 !difference = #$8000 !horspeed = $0BDC,x !verspeed = $0BF0,x !detectedenemy = $1750 !timer = $1760 !time = #$00F0 ;4 seconds ;JSL $938000 ;routine to update Graphics org $90B352 ADC $0000,y org $90B35C ADC $0002,y org $90BF03 JSR ZERO org $90AF70 DELETE: org $90AF87 JMP SEEK BACK: org $90C353 ;X acceleration ; DW $0000 ; DW $0010 ; DW $0010 ; DW $0010 ; DW $0000 ; DW $0000 ; DW $FF0F ; DW $FF0F ; DW $FF0F ; DW $0000 DW $0000 DW $0001 DW $0001 DW $0001 DW $0000 DW $0000 DW $FFFE DW $FFFE DW $FFFE DW $0000 org $90C367 ;Y acceleration DW $FFFE DW $FFFE DW $0000 DW $0001 DW $0001 DW $0001 DW $0001 DW $0000 DW $FFFE DW $FFFE ; DW $FF0F ; DW $FF0F ; DW $0000 ; DW $0010 ; DW $0010 ; DW $0010 ; DW $0010 ; DW $0000 ; DW $FF0F ; DW $FF0F org $90AFA5 NOACC: org $90AFB3 ;running code ; DW $AFC7 ; DW $AFCF ; DW $AFDD ; DW $AFCF ; DW $AFC7 ; DW $AFC7 ; DW $AFCF ; DW $AFDD ; DW $AFCF ; DW $AFC7 DW $AFCF DW $AFCF DW $AFCF DW $AFCF DW $AFCF DW $AFCF DW $AFCF DW $AFCF DW $AFCF DW $AFCF ;array to determine every enemy within radius org $90F640 ZERO: PHX LDX #$0000 again: STZ !detectedenemy,x STZ !timer,x INX INX CPX #$000C BNE again PLX LDA #$AF68 RTS SEEK: INC !timer,x LDA !timer,x CMP !time BCC ALIVE STZ !timer,x LDA !prox STA $12 LDA !proy STA $14 LDA #$0003 STA $16 STZ $18 JSL $B4BC26 LDA #$0008 JSL $8090C1 LDX !proindex LDA #$0010 STA $0C04,x JMP DELETE ALIVE: LDA !enemynum BNE $03 JMP NORMAL LDX !proindex LDA !detectedenemy,x BEQ $03 JMP FOLLOW LDA $05B6 BIT #$0008 BEQ NOSOUND1 BIT #$0007 BNE NOSOUND1 LDA #$0036 JSL $80903F NOSOUND1: STZ $12 LDY #$0000 AGAIN: TYA ASL ASL ;this -should- multiply with $40 ASL ASL ASL ASL TAX STX $12 LDA $0F78,x BMI EXISTS PHX LDX !proindex STZ !detectedenemy,x PLX EXISTS: LDA !xenemy BEQ NOENEMY LDA !yenemy BEQ NOENEMY LDA $0F86,x BIT #$0400 BNE NOENEMY LDX !proindex LDA !prox CLC LDX $12 ADC !radius CMP !xenemy BMI NOENEMY LDX !proindex LDA !prox SEC LDX $12 SBC !radius CMP !xenemy BPL NOENEMY LDX !proindex LDA !proy CLC LDX $12 ADC !radius CMP !yenemy BMI NOENEMY LDX !proindex LDA !proy SEC LDX $12 SBC !radius CMP !yenemy BPL NOENEMY LDX !proindex LDA $12 STA !detectedenemy,x ;so the indexarray holds the index of the enemy that is within the radius BNE FOLLOW INC STA !detectedenemy,x ;if the index is 0000 BRA FOLLOW NOENEMY: INY CPY !enemynum BEQ $03 JMP AGAIN LDX !proindex LDA !detectedenemy,x BNE FOLLOW JMP NORMAL FOLLOW: LDA $05B6 BIT #$0004 BEQ NOSOUND BIT #$0003 BNE NOSOUND LDA #$0036 JSL $80903F NOSOUND: LDX !proindex ;90F765 LDA !detectedenemy,x AND #$FFF0 STA $12 TAX LDA $0F78,x BMI NONEW LDX !proindex STZ !detectedenemy,x JMP NORMAL NONEW: LDA !proindex LDA !prox SEC LDX $12 SBC !xenemy BPL $04 EOR #$FFFF INC ASL ASL CLC ADC #$0020 STA $16 LDX !proindex LDA !proy SEC LDX $12 SBC !yenemy BPL $04 EOR #$FFFF INC ASL ASL CLC ADC #$0020 STA $18 ; LDA $16 ; CLC ; ADC $18 ; LSR ; STA $14 LDX !proindex LDA !proy LDX $12 CMP !yenemy BMI UPPER LOWER: LDX !proindex LDA !prox LDX $12 CMP !xenemy BMI SECTORIII SECTORIV: ;D X- Y- LDX !proindex LDA !horspeed SEC SBC $14 LDA $16 EOR #$FFFF INC a STA !horspeed LDA !verspeed SEC SBC $14 LDA $18 EOR #$FFFF INC a STA !verspeed BRA COMPARE SECTORIII: ;C X+ Y- LDX !proindex LDA !horspeed CLC ADC $14 LDA $16 STA !horspeed LDA !verspeed SEC SBC $14 LDA $18 STA !verspeed BRA COMPARE ;=============================== UPPER: LDX !proindex LDA !prox LDX $12 CMP !xenemy BMI SECTORII SECTORI: ;90F7EC A X- Y+ LDX !proindex LDA !horspeed SEC SBC $14 LDA $16 EOR #$FFFF INC a STA !horspeed LDA !verspeed CLC ADC $14 LDA $18 STA !verspeed BRA COMPARE SECTORII: ;B X+ Y+ LDX !proindex LDA !horspeed CLC ADC $14 LDA $16 STA !horspeed LDA !verspeed CLC ADC $14 LDA $18 STA !verspeed COMPARE: JMP DIRECTIONS DIRECTIONCHANGE: LDX !proindex STA $0C04,x JSL $938000 END: LDX !proindex LDA $0C04,x AND #$000F JMP NOACC NORMAL: LDX !proindex LDA $0C04,x AND #$000F JMP BACK DIRECTIONS: LDX !proindex LDA !verspeed BMI MINUS LDA !horspeed BMI PLUSMINUS PLUSPLUS: LDA !horspeed CMP !verspeed BCS CASETHREE ;this branches if hor >= ver LDY #$0006 ;4 BRA STORE CASETHREE: LDY #$0004 ;3 BRA STORE PLUSMINUS: EOR #$FFFF INC CMP !verspeed BCS CASESIX ;branches, if hor >= ver CASEFIVE: LDY #$0008 ;5 BRA STORE CASESIX: LDY #$000A ;6 BRA STORE MINUS: LDA !horspeed BMI MINUSMINUS MINUSPLUS: LDA !verspeed EOR #$FFFF INC a CMP !horspeed BCS CASEONE ;ver >= hor CASETWO: LDY #$0002 ;3 BRA STORE CASEONE: LDY #$0000 ;4 BRA STORE MINUSMINUS: EOR #$FFFF INC STA $12 LDA !verspeed EOR #$FFFF INC CMP $12 BCS CASEEIGHT CASESEVEN: LDY #$000C ;7 BRA STORE CASEEIGHT: LDY #$000E ;8 STORE: LDA $0C04,x ASL A STA $12 LDA CASES,y CLC ADC $12 TAY LDA $0000,y CMP $0C04,x BNE $03 JMP END STA $0C04,x JMP DIRECTIONCHANGE CASES: DW CASE1 DW CASE2 DW CASE3 DW CASE4 DW CASE5 DW CASE6 DW CASE7 DW CASE8 CASE1: DW $0000 ;U 0 DW $0000 ;UR 1 DW $0001 ;R 2 DW $0002 ;DR 3 DW $0003 ;D 4 DW $0006 ;D 5 DW $0007 ;DL 6 DW $0008 ;L 7 DW $0000 ;UL 8 DW $0000 ;U 9 CASE2: DW $0001 ;U 0 DW $0001 ;UR 1 DW $0002 ;R 2 DW $0002 ;DR 3 DW $0003 ;D 4 DW $0003 ;D 5 DW $0004 ;DL 6 DW $0008 ;L 7 DW $0000 ;UL 8 DW $0001 ;U 9 CASE3: DW $0001 ;U 0 DW $0002 ;UR 1 DW $0003 ;R 2 DW $0003 ;DR 3 DW $0003 ;D 4 DW $0003 ;D 5 DW $0004 ;DL 6 DW $0006 ;L 7 DW $0000 ;UL 8 DW $0001 ;U 9 CASE4: DW $0001 ;U 0 DW $0002 ;UR 1 DW $0003 ;R 2 DW $0004 ;DR 3 DW $0004 ;D 4 DW $0005 ;D 5 DW $0004 ;DL 6 DW $0006 ;L 7 DW $0007 ;UL 8 DW $0001 ;U 9 CASE5: DW $0008 ;U 0 DW $0000 ;UR 1 DW $0003 ;R 2 DW $0004 ;DR 3 DW $0004 ;D 4 DW $0005 ;D 5 DW $0004 ;DL 6 DW $0006 ;L 7 DW $0007 ;UL 8 DW $0008 ;U 9 CASE6: DW $0008 ;U 0 DW $0000 ;UR 1 DW $0003 ;R 2 DW $0004 ;DR 3 DW $0006 ;D 4 DW $0006 ;D 5 DW $0006 ;DL 6 DW $0006 ;L 7 DW $0007 ;UL 8 DW $0008 ;U 9 CASE7: DW $0008 ;U 0 DW $0000 ;UR 1 DW $0001 ;R 2 DW $0004 ;DR 3 DW $0006 ;D 4 DW $0006 ;D 5 DW $0007 ;DL 6 DW $0007 ;L 7 DW $0007 ;UL 8 DW $0008 ;U 9 CASE8: DW $0000 ;U 0 DW $0001 ;UR 1 DW $0001 ;R 2 DW $0002 ;DR 3 DW $0006 ;D 4 DW $0006 ;D 5 DW $0007 ;DL 6 DW $0008 ;L 7 DW $0000 ;UL 8 DW $0000 ;U 9