1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;
  3. ;; Piranha Plant/Venus Fire Trap, by imamelia
  4. ;;
  5. ;; This sprite encompasses all 48 Classic Piranha Plants and Venus Fire Traps,
  6. ;; using the extra property bytes to determine which sprite to act like.
  7. ;;
  8. ;; Uses first extra bit: YES
  9. ;; Uses extra property bytes: YES
  10. ;;
  11. ;; If the first extra bit is clear, the sprite will use the first extra property byte.
  12. ;; If the first extra bit is set, the sprite will use the second extra property byte.
  13. ;;
  14. ;; Extra Property Bytes:
  15. ;;
  16. ;; Bit 0: Direction. 0 = up/left, 1 = right/down.
  17. ;; Bit 1: Orientation. 0 = vertical, 1 = horizontal.
  18. ;; Bit 2: Stem length. 0 = long, 1 = short.
  19. ;; Bit 3: Color. 0 = green, 1 = red.
  20. ;; Bit 4: Sprite type. 0 = Piranha Plant, 1 = Venus Fire Trap.
  21. ;; Bit 5: Number of fireballs. 0 = spit 1, 1 = spit 2. This is used only if bit 4 is set.
  22. ;;
  23. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  24. ;incsrc subroutinedefsx.asm
  25. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  26. ;;
  27. ;; defines and tables
  28. ;;
  29. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  30. ; $151C,x = holder for the sprite's initial Y position low byte
  31. ; $1528,x = holder for the sprite's initial X position low byte
  32. Speed: ; the Piranha Plant's speed for each sprite state (inverted for down and right plants)
  33. db $00,$F0,$00,$10 ; in the pipe, moving forward, resting at the apex, moving backward
  34. TimeInState: ; the time the sprite will spend in each sprite state, indexed by bits 2, 4, and 5 of the behavior table
  35. db $30,$20,$30,$20 ; long Piranha Plants
  36. db $30,$18,$30,$18 ; short Piranha Plants
  37. db $30,$20,$60,$20 ; long Venus Fire Traps spitting 1 fireball
  38. db $30,$18,$60,$18 ; short Venus Fire Traps spitting 1 fireball
  39. db $FF,$FF,$FF,$FF ; null
  40. db $FF,$FF,$FF,$FF ; null
  41. db $30,$20,$90,$20 ; long Venus Fire Traps spitting 2 fireballs
  42. db $30,$18,$90,$18 ; short Venus Fire Traps spitting 2 fireballs
  43. ; All of these tables are indexed by ----todf,
  44. ; where f = frame, d = direction, o = orientation, and t = type.
  45. HeadXOffset:
  46. db $00,$00,$00,$00,$00,$00,$10,$10,$00,$00,$00,$00,$00,$00,$10,$10
  47. HeadYOffset:
  48. db $00,$00,$10,$10,$00,$00,$00,$00,$00,$00,$10,$10,$00,$00,$00,$00
  49. StemXOffset:
  50. db $00,$00,$00,$00,$10,$10,$00,$00,$00,$00,$00,$00,$10,$10,$00,$00
  51. StemYOffset:
  52. db $10,$10,$00,$00,$00,$00,$00,$00,$10,$10,$00,$00,$00,$00,$00,$00
  53. ; up, down, left, right
  54. ; head:
  55. ; X=00/Y=00, X=00/Y=10, X=00/Y=00, X=10/Y=00
  56. ; stem:
  57. ; X=00/Y=10, X=00/Y=00, X=10/Y=00, X=00/Y=10
  58. StemTilemap: ; the tiles used by the stem
  59. db $CE,$CE,$CE,$CE,$E6,$E6,$E6,$E6,$CE,$CE,$CE,$CE,$E6,$E6,$E6,$E6
  60. HeadTilemap: ; the tiles used by the head
  61. db $AE,$AC,$AE,$AC,$80,$88,$80,$88,$C0,$C2,$C0,$C2,$C0,$C2,$C0,$C2
  62. TileFlip: ; the X- and Y-flip of each tile
  63. db $00,$00,$80,$80,$00,$00,$40,$40,$00,$00,$80,$80,$00,$00,$40,$40
  64. ; These two are different. They are indexed by ------lc, where c = color and l = length.
  65. ; Add 1 to each of these values if you want the tile to use the second graphics page.
  66. StemPalette: ; the palette of the stem tiles
  67. db $0A,$08,$0A,$08
  68. HeadPalette: ; the palette of the head tiles
  69. db $08,$08,$0A,$08
  70. ; This tile will be invisible because it has sprite priority setting 0,
  71. ; but it will go in front of the plant tiles to cover it up when it is in a pipe.
  72. ; That way, the plant tiles don't need to have hardcoded priority.
  73. ; This tile should be as close to square as possible.
  74. ; Note: The default value WILL NOT completely hide the tiles unless you have changed its graphics!
  75. ; But the only completely square tile in a vanilla GFX00/01 is the message box tile, which is set to be overwritten by default.
  76. !CoverUpTile = $40 ; the invisible tile used to cover up the sprite when it is in a pipe
  77. ; these two tables are indexed by the direction and orientation
  78. CoverUpXOffset: ;
  79. db $00,$00,$00,$10 ;
  80. CoverUpYOffset: ;
  81. db $00,$10,$00,$00 ;
  82. InitOffsetYLo:
  83. db $FF,$EF,$08,$08
  84. InitOffsetYHi:
  85. db $FF,$FF,$00,$00
  86. InitOffsetXLo:
  87. db $08,$08,$FF,$EF
  88. InitOffsetXHi:
  89. db $00,$00,$FF,$FF
  90. VenusFrames: ; which head tile the Venus Fire Trap should use for each sprite state
  91. db $00,$00,$01,$00
  92. Clipping:
  93. db $01,$14
  94. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  95. ;;
  96. ;; init routine wrapper
  97. ;;
  98. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  99. print "INIT ",pc
  100. PHB
  101. PHK
  102. PLB
  103. JSR PiranhaInit
  104. PLB
  105. RTL
  106. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  107. ;;
  108. ;; init routine
  109. ;;
  110. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  111. PiranhaInit:
  112. LDA !extra_bits,x ; check the extra bit
  113. AND #$04 ; if the extra bit is clear...
  114. BNE EP2 ;
  115. LDA !extra_prop_1,x ; use the extra property byte 1
  116. BRA StoreEP ;
  117. EP2: ;
  118. LDA !extra_prop_2,x ;
  119. StoreEP: ;
  120. STA !1510,x ;
  121. AND #$03 ;
  122. TAY ; direction and orientation used to index inital offsets
  123. LDA !D8,x ;
  124. CLC ;
  125. ADC InitOffsetYLo,y ; Y position low byte
  126. STA !D8,x ;
  127. LDA !14D4,x ;
  128. ADC InitOffsetYHi,y ; Y position high byte
  129. STA !14D4,x ;
  130. LDA !E4,x ;
  131. CLC ;
  132. ADC InitOffsetXLo,y ; X position low byte
  133. STA !E4,x ;
  134. LDA !14E0,x ;
  135. ADC InitOffsetXHi,y ; X position high byte
  136. STA !14E0,x ;
  137. TYA ;
  138. LSR ;
  139. TAY ;
  140. LDA Clipping,y ;
  141. STA !1662,x ;
  142. LDA !1510,x ; get the bits for the sprite state timer index
  143. AND #$04 ; bit 2
  144. STA !1504,x ;
  145. LDA !1510,x ;
  146. AND #$10 ; bit 4
  147. LSR ;
  148. ORA !1504,x ;
  149. STA !1504,x ;
  150. LDA !1510,x ;
  151. AND #$30 ; bits 4 and 5
  152. CMP #$30 ; if the sprite is a Venus Fire Trap that spits 2 fireballs...
  153. BNE No2Fireballs ;
  154. LDA !1504,x ; then add another 4 to the index
  155. CLC ;
  156. ADC #$04 ;
  157. STA !1504,x ;
  158. No2Fireballs: ;
  159. EndInit1: ;
  160. LDA !D8,x ;
  161. STA !151C,x ; back up the sprite's initial XY position (low bytes)
  162. LDA !E4,x ;
  163. STA !1528,x ;
  164. RTS
  165. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  166. ;;
  167. ;; main routine wrapper
  168. ;;
  169. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  170. print "MAIN ",pc
  171. PHB
  172. PHK
  173. PLB
  174. JSR PiranhaPlantsMain
  175. PLB
  176. RTL
  177. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  178. ;;
  179. ;; main routine
  180. ;;
  181. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  182. EndMain:
  183. RTS
  184. PiranhaPlantsMain:
  185. ;LDA $1594,x ; if the sprite is in a pipe and the player is near...
  186. ;BNE NoGFX ; don't draw the sprite
  187. LDA !C2,x ;
  188. BEQ NoGFX ;
  189. JSR PiranhaPlantGFX ; draw the sprite
  190. NoGFX: ;
  191. LDA #$00
  192. %SubOffScreen() ;
  193. LDA $9D ; if sprites are locked...
  194. BNE EndMain ; terminate the main routine right here
  195. LDA !1510,x ;
  196. AND #$10 ; if the sprite is a Venus Fire Trap...
  197. BEQ PiranhaAnimation ; use a different routine for its animation
  198. LDY !C2,x ;
  199. LDA VenusFrames,y ;
  200. STA !1602,x ;
  201. CPY #$02 ;
  202. BNE SkipPiranhaAnimation ;
  203. JSR FacePlayer ; always face the player if the Venus Fire Trap is out of the pipe
  204. BRA SkipPiranhaAnimation ;
  205. Fire: ;
  206. JMP SpitFireball ;
  207. PiranhaAnimation: ;
  208. JSR SetAnimationFrame ; determine which frame the plant should show
  209. SkipPiranhaAnimation: ;
  210. LDA !1594,x ; if the plant is in a pipe...
  211. BNE NoInteraction ; don't let it interact with the player
  212. JSL $01803A|!BankB ; interact with the player and other sprites
  213. NoInteraction: ;
  214. LDA !1510,x ;
  215. AND #$10 ; if the sprite isn't a Venus Fire Trap...
  216. BEQ NoFireCheck ; don't check to see if it should spit a fireball
  217. LDA !C2,x ; if the sprite is a Venus Fire Trap...
  218. CMP #$02 ; then make sure it's in the correct sprite state (resting at the apex)
  219. BNE NoFireCheck ;
  220. LDA !1540,x ;
  221. CMP #$61 ; if the fire timer
  222. BEQ Fire ; is at certain numbers...
  223. CMP #$19 ; spit a fireball
  224. BEQ Fire ;
  225. NoFireCheck:
  226. LDA !C2,x ; use the sprite state
  227. AND #$03 ; to determine what the sprite's speed should be
  228. TAY ;
  229. LDA !1540,x ; if the timer for changing states has run out...
  230. BEQ ChangePiranhaState ;
  231. LDA !1510,x ; check whether the sprite is rightside-up/left or upside-down/right
  232. LSR ;
  233. LDA Speed,y ; load the base speed
  234. BCC StoreSpeed ; if upside-down/right...
  235. EOR #$FF ; flip its speed
  236. INC ;
  237. StoreSpeed: ;
  238. TAY ; transfer the speed value to Y because we need to use A
  239. LDA !1510,x ; check the secondary sprite state
  240. AND #$02 ; check whether the sprite is vertical or horizontal
  241. BNE MoveHorizontally ;
  242. STY !AA,x ; store the speed value to the sprite Y speed table
  243. JSL $01801A|!BankB ; update sprite Y position without gravity
  244. RTS ;
  245. MoveHorizontally: ;
  246. STY !B6,x ; store the speed value to the sprite X speed table
  247. JSL $018022|!BankB ; update sprite X position without gravity
  248. RTS ;
  249. ChangePiranhaState: ;
  250. LDA !1510,x ;
  251. AND #$10 ; if the sprite is a Venus Fire Trap...
  252. BEQ NoFacePlayer ;
  253. LDA !C2,x ; and it is about to come out of the pipe...
  254. BNE NoFacePlayer ;
  255. JSR FacePlayer ;
  256. NoFacePlayer: ;
  257. LDA !C2,x ; sprite state
  258. AND #$03 ; 4 possible states, so we need only 2 bits
  259. STA $00 ; store to scratch RAM for subsequent use
  260. LDA !1510,x ;
  261. AND #$08 ; if the plant is a red one...
  262. ORA $00 ; or the sprite isn't in the pipe...
  263. BNE NoProximityCheck ; don't check to see if the player is near
  264. %SubHorzPos() ; get the horizontal distance between the player and the sprite
  265. LDA #$01 ;
  266. STA !1594,x ; set the invisibility flag if necessary
  267. LDA $0E ;
  268. CLC ;
  269. ADC #$1B ; if the sprite is within a certain distance...
  270. CMP #$37 ;
  271. BCC EndStateChange ; don't change the sprite state
  272. NoProximityCheck: ;
  273. STZ !1594,x ; if the sprite is out of range, clear the invisibility flag
  274. LDA !C2,x ;
  275. INC ; increment the sprite state
  276. AND #$03 ;
  277. STA !C2,x ;
  278. STA $00 ;
  279. LDA !1510,x ;
  280. AND #$04 ; use the stem length bit
  281. TSB $00 ;
  282. LDA !1510,x ;
  283. AND #$30 ; and the Venus Fire Trap bits
  284. LSR ;
  285. ORA $00
  286. TAY ; to set the timer for changing sprite state
  287. LDA TimeInState,y ;
  288. STA !1540,x ; set the time to change state
  289. EndStateChange: ;
  290. RTS
  291. SetAnimationFrame: ;
  292. INC !1570,x ; $1570,x - individual sprite frame counter, in this context
  293. LDA !1570,x ;
  294. LSR #3 ; change image every 8 frames
  295. AND #$01 ;
  296. STA !1602,x ; set the resulting image
  297. RTS
  298. FacePlayer: ;
  299. %SubVertPos() ;
  300. TYA ;
  301. ASL ;
  302. STA !157C,x ;
  303. LDA !1510,x ;
  304. AND #$02 ;
  305. BNE FixedH ; the sprite's horizontal direction is always the same if it is a horizontally-moving Venus Fire Trap
  306. %SubHorzPos() ;
  307. TYA ; make it face the player
  308. ORA !157C,x ;
  309. STA !157C,x ;
  310. RTS ;
  311. FixedH:
  312. LDA !1510,x ;
  313. AND #$01 ;
  314. EOR #$01 ;
  315. STA $00 ;
  316. LDA !157C,x ;
  317. AND #$02 ;
  318. ORA $00 ;
  319. STA !157C,x ;
  320. RTS
  321. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  322. ;;
  323. ;; graphics routine
  324. ;;
  325. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  326. PiranhaPlantGFX: ; I made my own graphics routine, since the Piranha Plant uses a shared routine.
  327. %GetDrawInfo() ; set some variables up for writing to OAM
  328. LDA !1510,x ;
  329. AND #$04 ; stem length
  330. LSR ;
  331. STA $04 ;
  332. LDA !1510,x ;
  333. AND #$08 ;
  334. LSR #3 ; plus color
  335. TSB $04 ;
  336. LDA !1602,x ;
  337. STA $03 ; frame = bit 0 of the index
  338. LDA !1510,x ;
  339. AND #$03 ; direction and orientation
  340. ASL ;
  341. TSB $03 ; bits 1 and 2 of the index
  342. LDA !1510,x ;
  343. AND #$10 ; type
  344. LSR ;
  345. ORA $03 ; bit 3 of the index
  346. STA $03 ;
  347. LDA !1510,x ;
  348. AND #$04 ; if the plant has a short stem...
  349. BNE AlwaysCovered ; then the stem is always partially obscured by the cover-up tile
  350. LDA !C2,x ;
  351. CMP #$02 ; if the sprite is all the way out of the pipe...
  352. BEQ StemOnly ; then draw just the stem
  353. AlwaysCovered: ;
  354. LDA !1510,x ;
  355. AND #$01 ;
  356. STA $08 ; save the direction bit for use with the cover-up routine
  357. LDA !D8,x ;
  358. SEC ;
  359. SBC !151C,x ;
  360. STA $06 ;
  361. LDA !E4,x ;
  362. SEC ;
  363. SBC !1528,x ;
  364. CLC ;
  365. ADC $06 ;
  366. LDX $08 ;
  367. BEQ NoFlipCheckVal ;
  368. EOR #$FF ;
  369. INC ;
  370. NoFlipCheckVal: ;
  371. CLC ;
  372. ADC #$10 ;
  373. CMP #$20 ;
  374. BCC CoverUpTileOnly ;
  375. StemAndCoverUpTile: ;
  376. JSR DrawCoverUpTile ;
  377. INY #4 ;
  378. JSR DrawStem ;
  379. LDA #$02 ;
  380. EndGFX: ;
  381. PHA ;
  382. INY #4 ;
  383. LDX $03 ;
  384. JSR DrawHead ; the head tile is always drawn
  385. PLA ;
  386. LDY #$02 ;
  387. LDX $15E9|!Base2 ;
  388. JSL $01B7B3|!BankB ;
  389. RTS ;
  390. StemOnly: ;
  391. JSR DrawStem ;
  392. LDA #$01 ;
  393. BRA EndGFX ;
  394. CoverUpTileOnly: ;
  395. JSR DrawCoverUpTile ;
  396. LDA #$01 ;
  397. BRA EndGFX ;
  398. DrawHead:
  399. LDA $00 ;
  400. CLC ;
  401. ADC HeadXOffset,x ; set the X offset for the head tile
  402. STA $0300|!Base2,y ;
  403. LDA $01 ;
  404. CLC ;
  405. ADC HeadYOffset,x ; set the Y offset for the head tile
  406. STA $0301|!Base2,y ;
  407. LDA HeadTilemap,x ; set the tile for the head
  408. STA $0302|!Base2,y
  409. LDX $15E9|!Base2 ;
  410. LDA !1510,x ;
  411. AND #$10 ;
  412. BNE VenusFlip ;
  413. LDX $03 ;
  414. LDA TileFlip,x ; load the XY flip for the tiles
  415. LDX $04 ; load the palette index
  416. ORA HeadPalette,x ; add in the palette/GFX page bits
  417. ORA $64 ; and the level's sprite priority
  418. STA $0303|!Base2,y ;
  419. RTS
  420. VenusFlip: ;
  421. LDA !157C,x ;
  422. ROR #3 ;
  423. AND #$C0 ;
  424. EOR #$40 ;
  425. LDX $04 ;
  426. ORA HeadPalette,x ;
  427. ORA $64 ;
  428. STA $0303|!Base2,y ;
  429. RTS ;
  430. DrawStem:
  431. LDX $03
  432. LDA $00 ;
  433. CLC ;
  434. ADC StemXOffset,x ; set the X offset for the stem tile
  435. STA $0300|!Base2,y ;
  436. LDA $01 ;
  437. CLC ;
  438. ADC StemYOffset,x ; set the Y offset for the stem tile
  439. STA $0301|!Base2,y ;
  440. LDA StemTilemap,x ; set the tile for the stem
  441. STA $0302|!Base2,y
  442. LDA TileFlip,x ; load the XY flip for the tiles
  443. LDX $04 ; load the palette index
  444. ORA StemPalette,x ; add in the palette/GFX page bits
  445. ORA $64 ; and the level's sprite priority
  446. STA $0303|!Base2,y ;
  447. RTS ;
  448. DrawCoverUpTile: ;
  449. LDX $15E9|!Base2 ;
  450. LDA !1528,x ;
  451. STA $09 ;
  452. LDA !151C,x ; make backups of the XY init positions
  453. STA $0A ;
  454. LDA !1510,x ;
  455. AND #$03 ;
  456. TAX
  457. LDA $09 ;
  458. SEC ;
  459. SBC $1A ;
  460. CLC ;
  461. ADC CoverUpXOffset,x ;
  462. STA $0300|!Base2,y ;
  463. LDA $0A ;
  464. SEC ;
  465. SBC $1C ;
  466. CLC ;
  467. ADC CoverUpYOffset,x ;
  468. STA $0301|!Base2,y ;
  469. LDA #!CoverUpTile ;
  470. STA $0302|!Base2,y ;
  471. LDA #$00 ;
  472. STA $0303|!Base2,y ;
  473. RTS ;
  474. LDX $15E9|!Base2 ; sprite index back into X
  475. LDY #$02 ; the tiles were 16x16
  476. LDA $05 ; we drew 2 or 3 tiles
  477. JSL $01B7B3|!BankB ;
  478. RTS ;
  479. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  480. ;;
  481. ;; Venus Fire Trap fireball-spit routine
  482. ;;
  483. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  484. FireXOffsetsLo:
  485. db $0F,$FA,$0E,$00,$0E,$FE,$0D,$FE,$FB,$FB,$FE,$FE,$1D,$1D,$1D,$1D
  486. FireXOffsetsHi:
  487. db $00,$FF,$00,$00,$00,$FF,$00,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00
  488. FireYOffsetsLo:
  489. db $09,$09,$FF,$FF,$18,$18,$13,$13,$06,$06,$01,$01,$0A,$0A,$01,$01
  490. FireYOffsetsHi:
  491. db $00,$00,$FF,$FF,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  492. FireXSpeeds:
  493. db $08,$F8,$08,$F8
  494. FireYSpeeds:
  495. db $06,$06,$FA,$FA
  496. SpitFireball:
  497. LDY #$07
  498. ExSpriteLoop:
  499. LDA !extended_num,y
  500. BEQ FoundExSlot
  501. DEY
  502. BPL ExSpriteLoop
  503. RTS
  504. FoundExSlot:
  505. STY $00
  506. LDA #$02
  507. STA !extended_num,y
  508. LDA !1510,x
  509. AND #$03
  510. ASL
  511. ASL
  512. STA $01
  513. LDA !157C,x
  514. TSB $01
  515. LDA !157C,x
  516. STA $02
  517. LDA !E4,x
  518. LDY $01
  519. CLC
  520. ADC FireXOffsetsLo,y
  521. LDY $00
  522. STA !extended_x_low,y
  523. LDA !14E0,x
  524. LDY $01
  525. ADC FireXOffsetsHi,y
  526. LDY $00
  527. STA !extended_x_high,y
  528. LDA !D8,x
  529. LDY $01
  530. CLC
  531. ADC FireYOffsetsLo,y
  532. LDY $00
  533. STA !extended_y_low,y
  534. LDA !14D4,x
  535. LDY $01
  536. ADC FireYOffsetsHi,y
  537. LDY $00
  538. STA !extended_y_high,y
  539. LDY $02
  540. LDA FireXSpeeds,y
  541. LDY $00
  542. STA !extended_y_speed,y
  543. LDY $02
  544. LDA FireYSpeeds,y
  545. LDY $00
  546. STA !extended_x_speed,y
  547. LDA #$FF
  548. STA !extended_timer,y
  549. RTSRedPiranhaHorizontalShort