;;; $B6B9: Pre-instruction - eye door projectile - moving ;;;
{
; BUG: the $B707 branch assumes the enemy projectile index is in X, but this is only true if the branch on $B6BC/C1 is taken,
; otherwise the enemy projectile index is in Y, and the door bit array index is in X,
; causing misaligned writes to enemy projectile RAM if X is odd, eventually causing a crash when the garbage instruction pointer gets executed
; (which happens after a delay of 100h+ frames due to the misaligned write to the instruction timer)

; The X/Y velocity calculations were already done as a part of calculating the angle to Samus in $82A5,
; they don't need to be here

$86:B6B9 20 B6 88 JSR $88B6 [$86:88B6] ; Move enemy projectile horizontally
$86:B6BC B0 49 BCS $49 [$B707] ; If collision: go to BRANCH_COLLISION
$86:B6BE 20 7B 89 JSR $897B [$86:897B] ; Move enemy projectile vertically
$86:B6C1 B0 44 BCS $44 [$B707] ; If collision: go to BRANCH_COLLISION
$86:B6C3 9B TXY ; Y = [enemy projectile index]
$86:B6C4 BD FF 1A LDA $1AFF,x[$7E:1B21] ;\
$86:B6C7 AA TAX ;} X = [enemy projectile angle to Samus]
$86:B6C8 BF 43 B4 A0 LDA $A0B443,x[$A0:B5B3];\
$86:B6CC 4A LSR A ;|
$86:B6CD 4A LSR A ;|
$86:B6CE 4A LSR A ;|
$86:B6CF 4A LSR A ;|
$86:B6D0 89 00 08 BIT #$0800 ;|
$86:B6D3 F0 03 BEQ $03 [$B6D8] ;} Enemy projectile X velocity = 10h * sin([A] * pi / 80h)
$86:B6D5 09 00 F0 ORA #$F000 ;|
;|
$86:B6D8 18 CLC ;|
$86:B6D9 79 B7 1A ADC $1AB7,y[$7E:1AD9] ;|
$86:B6DC 99 B7 1A STA $1AB7,y[$7E:1AD9] ;/
$86:B6DF BF C3 B3 A0 LDA $A0B3C3,x[$A0:B533];\
$86:B6E3 4A LSR A ;|
$86:B6E4 4A LSR A ;|
$86:B6E5 4A LSR A ;|
$86:B6E6 4A LSR A ;|
$86:B6E7 89 00 08 BIT #$0800 ;|
$86:B6EA F0 03 BEQ $03 [$B6EF] ;} Enemy projectile Y velocity = 10h * -cos([A] * pi / 80h)
$86:B6EC 09 00 F0 ORA #$F000 ;|
;|
$86:B6EF 18 CLC ;|
$86:B6F0 79 DB 1A ADC $1ADB,y[$7E:1AFD] ;|
$86:B6F3 99 DB 1A STA $1ADB,y[$7E:1AFD] ;/
$86:B6F6 B9 23 1B LDA $1B23,y[$7E:1B45] ;\
$86:B6F9 22 8E 81 80 JSL $80818E[$80:818E] ;|
$86:B6FD BF B0 D8 7E LDA $7ED8B0,x[$7E:D8B8];} If enemy projectile PLM room argument door is not marked:
$86:B701 2D E7 05 AND $05E7 [$7E:05E7] ;|
$86:B704 D0 01 BNE $01 [$B707] ;/
$86:B706 60 RTS ; Return
; BRANCH_COLLISION
$86:B707 A9 F3 B5 LDA #$B5F3 ;\
$86:B70A 9D 47 1B STA $1B47,x[$7E:1B67] ;} Enemy projectile instruction list pointer = $B5F3 (explode)
$86:B70D A9 01 00 LDA #$0001 ;\
$86:B710 9D 8F 1B STA $1B8F,x[$7E:1BAF] ;} Enemy projectile instruction timer = 1
$86:B713 60 RTS
}