Guest User

Another Glitch

a guest
Dec 25th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.00 KB | None | 0 0
  1. !RAM_HP = $1528
  2. !RAM_Timer = $1534
  3. !RAM_Proj = $1540
  4. !RAM_State = $C2
  5. !RAM_Status = $14C8
  6.  
  7. !Phase_Blks = $01
  8. !HP = $02
  9. !Proj_1 = $50
  10. !Proj_2 = $51
  11. !Proj_3 = $18
  12.  
  13. print "INIT ",pc
  14. LDA #!HP
  15. STA !RAM_HP,x
  16. STZ !RAM_State,x
  17. STZ $1594,x
  18. RTL
  19.  
  20. print "MAIN ",pc
  21. PHB
  22. PHK
  23. PLB
  24.  
  25. JSR CodeMain
  26.  
  27. PLB
  28. RTL
  29.  
  30. Phases:
  31. dw Wait
  32. dw Hover
  33. dw TwoFireballs
  34. dw FourBills
  35. dw FireRain
  36. dw GotHit
  37. dw FinalRage
  38. dw Die
  39.  
  40. GFXPhases:
  41. dw WaitGFX
  42. dw HoverGFX
  43. dw FireGFX
  44. dw BillGFX
  45. dw FireGFX
  46. dw HurtGFX
  47. dw RageGFX
  48. dw DieGFX
  49.  
  50. Die:
  51. LDX $15E9
  52. RTS
  53.  
  54. CodeMain:
  55.  
  56. JSR Graphics
  57. LDA $9D
  58. BNE .Return_0
  59. LDA !RAM_State,x
  60. STA $0EF9
  61. LDA !RAM_HP,x
  62. STA $0F2F
  63. JSL $019138
  64. JSR SPRITE_INTERACT
  65.  
  66. LDA !RAM_State,x
  67. CMP #$07
  68. BNE .Normal
  69.  
  70.  
  71. LDA $1594,x
  72. BNE +
  73. DEC $13C6 ; prevent Mario from walking at the level end
  74. LDA #$FF ; \ set goal
  75. STA $1493 ; /
  76. LDA #$0B ; \ set ending music
  77. STA $1DFB ; /
  78. STA $1594,x
  79. + RTS ; return
  80.  
  81. .Normal
  82. LDA !RAM_State,x
  83. .Gotophase
  84. ASL A
  85. PHX
  86. TAX
  87. JSR (Phases,x)
  88. PLX
  89. .Return_0
  90. RTS
  91.  
  92. Wait: ;Wait till mario approaches the boss
  93. !MaxLeft = $0080
  94. !MaxRight = $0080
  95.  
  96. LDX $15E9
  97. LDA $14E0,x
  98. XBA
  99. LDA $E4,x
  100. REP #$20
  101. SBC $94
  102. ADC.w #!MaxLeft
  103. CMP.w #!MaxLeft+!MaxRight
  104. SEP #$20
  105. BCS NotCloseEnough
  106.  
  107. LDA $77
  108. AND #$04
  109. BEQ NotCloseEnough
  110.  
  111. LDA #$FF ;hurf durf spin around
  112. STA !RAM_Timer,x
  113. INC !RAM_State,x
  114. ;LDA #$05
  115. ;STA $1DFB
  116.  
  117. NotCloseEnough:
  118. RTS
  119.  
  120. XSpd: db $2C,$2C^$FF-$01
  121. XAcc: db $02,$01^$FF
  122. YSpd: db $18,$E8
  123. YAcc: db $01,$FF
  124.  
  125. Hover:
  126. LDX $15E9
  127. JSL $03B664
  128. JSR GetSpriteClipping
  129. JSL $03B72B
  130. BCC ++
  131.  
  132. LDA $7D
  133. BMI +
  134.  
  135. LDA $140D
  136. ORA $187A
  137. BEQ +
  138.  
  139. LDA #$02
  140. STA $1DF9
  141. JSL $01AA33
  142. JSL $01AB99
  143. BRA ++
  144. + JSL $00F5B7
  145. RTS
  146.  
  147. ++ LDA !RAM_Timer,x
  148. CMP #$80
  149. BCS .End
  150. LDA !RAM_Timer,x
  151. BEQ .Nomove
  152. JSR SUB_HORZ_POS
  153. LDA $B6,x
  154. CMP XSpd,y
  155. BEQ .gravity
  156. CLC
  157. ADC XAcc,y
  158. STA $B6,x
  159.  
  160. .gravity
  161. JSL $018022
  162. LDA $1510,x ;Load... something
  163. AND #$01 ;AND #$01
  164. TAY ;Use as index for acceleration table
  165. LDA $AA,x ;\
  166. CLC ; |Load Y speed
  167. ADC YAcc,y ; |Accelerate it
  168. STA $AA,x ;/
  169. CMP YSpd,y ;If it didn't reach the desired Y speed
  170. BNE .Next ;Continue processing the sprite
  171. INC $1510,x ;If it reached the desired speed, change Y direction
  172.  
  173. .Next JSL $01801A ;Update Y pos without gravity
  174.  
  175. LDA $1588,x
  176. AND #$03
  177. BEQ .Nomove
  178. LDA $157C,x
  179. EOR #$01
  180. STA $157C,x
  181. RTS
  182.  
  183. .Nomove
  184. .End STZ $B6,x
  185. JSR NextPhase
  186. RTS
  187.  
  188. TwoFireballs:
  189. FourBills:
  190. FireRain:
  191. JSR NextPhase
  192. RTS
  193.  
  194. GotHit: LDX $15E9
  195. JSL $03B664
  196. JSR GetSpriteClipping
  197. JSL $03B72B
  198. BCC ++
  199.  
  200. LDA $7D
  201. BMI +
  202.  
  203. LDA $140D
  204. ORA $187A
  205. BEQ +
  206.  
  207. LDA #$02
  208. STA $1DF9
  209. JSL $01AA33
  210. JSL $01AB99
  211. BRA ++
  212. + JSL $00F5B7
  213. RTS
  214.  
  215. ++ LDA !RAM_Timer,x
  216. CMP #$F0
  217. BNE +
  218. JSR .Fire
  219. JSR .Fire
  220. JSR .Fire
  221. LDA !RAM_Timer,x
  222. BNE ++
  223. RTS
  224. + LDA !RAM_HP,x
  225. CMP #$01
  226. BNE ++
  227. LDA #$06
  228. STA !RAM_State,x
  229. RTS
  230. ++ JSR NextPhase
  231. RTS
  232.  
  233. .Fire TXY
  234. STA $00
  235. LDX #$0B
  236. .GLoop LDA $14C8,X
  237. BEQ .Cont
  238. DEX
  239. BPL .GLoop
  240. RTS
  241.  
  242. .Cont LDA #$08 ;set to main
  243. STA $14C8,x ;status
  244.  
  245. LDA #!Proj_3 ;sprite to generate
  246. STA $7FAB9E,x ;custom sprite
  247. PHY
  248. JSL $07F7D2 ;clear
  249. JSL $0187A7
  250. PLY
  251. LDA #$88
  252. STA $7FAB10,x
  253.  
  254. LDA $00E4,y
  255. STA $E4,x
  256. LDA $14E0,y
  257. STA $14E0,x
  258.  
  259. LDA $00D8,y
  260. CLC
  261. ADC #$10
  262. STA $D8,x
  263. LDA $14D4,y
  264. ADC #$00
  265. STA $14D4,x
  266.  
  267. LDA #$17
  268. STA $1DFC
  269.  
  270. PHY
  271. JSR CALCFULLFRAME ;y is unchanged
  272. TAY
  273. LDA XSPEEDS,y
  274. STA $B6,x
  275. LDA YSPEEDS,y
  276. CLC
  277. ADC #$07
  278. STA $AA,x
  279. PLX
  280. RTS
  281.  
  282. FinalRage:
  283. LDX $15E9
  284. .clipping
  285. JSL $03B664
  286. JSR GetSpriteClipping
  287. JSL $03B72B
  288. BCC ++
  289.  
  290. LDA $7D
  291. BMI +
  292.  
  293. LDA $140D
  294. ORA $187A
  295. BEQ +
  296.  
  297. LDA #$02
  298. STA $1DF9
  299. JSL $01AA33
  300. JSL $01AB99
  301. BRA ++
  302. + JSL $00F5B7
  303. RTS
  304.  
  305. ++ LDA !RAM_Timer,x
  306. CMP #$E0
  307. BEQ .FireRage
  308. LDA !RAM_Timer,x
  309. CMP #$80
  310. BEQ .FireRage
  311. .GetOut LDX $15E9
  312. JSR .FireRage
  313. LDA #$01
  314. STA !RAM_State,x
  315. RTS
  316.  
  317. .FireRage TXY
  318. LDX #$0B
  319. .GLoop LDA $14C8,X
  320. BEQ .Cont
  321. DEX
  322. BPL .GLoop
  323. RTS
  324.  
  325. .Cont LDA #$08 ;set to main
  326. STA $14C8,x ;status
  327.  
  328. LDA #!Proj_3 ;sprite to generate
  329. STA $7FAB9E,x ;custom sprite
  330. PHY
  331. JSL $07F7D2 ;clear
  332. JSL $0187A7
  333. PLY
  334. LDA #$88
  335. STA $7FAB10,x
  336.  
  337. LDA $00E4,y
  338. STA $E4,x
  339. LDA $14E0,y
  340. STA $14E0,x
  341.  
  342. LDA $00D8,y
  343. CLC
  344. ADC #$10
  345. STA $D8,x
  346. LDA $14D4,y
  347. ADC #$00
  348. STA $14D4,x
  349.  
  350. LDA #$17
  351. STA $1DFC
  352.  
  353. PHY
  354. JSR CALCFULLFRAME ;y is unchanged
  355. TAY
  356. LDA XSPEEDS,y
  357. STA $B6,x
  358. LDA YSPEEDS,y
  359. CLC
  360. ADC #$07
  361. STA $AA,x
  362. PLX
  363. RTS
  364.  
  365. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  366. ;;; GRAPHICS ROUTINES ;;
  367. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  368.  
  369.  
  370. Graphics:
  371. JSR GET_DRAW_INFO
  372. LDA !RAM_State,x
  373. ASL A
  374. TAX
  375. JSR (GFXPhases,x)
  376. RTS
  377.  
  378. PROPERTIES: db $47,$07
  379.  
  380. TILEMAP:
  381. db $80,$82,$A0,$A2 ; FRAME 1 ;\ RIGHT
  382. db $84,$86,$A4,$A6 ; FRAME 2 ;/ RIGHT
  383.  
  384.  
  385. db $80,$82,$A0,$A2 ; FRAME 1 ;\ LEFT
  386. db $84,$86,$A4,$A6 ; FRAME 2 ;/ RIGHT
  387.  
  388.  
  389. YDISP: db $F0,$F0,$00,$00 ; FRAME 1 ;\ RIGHT
  390. db $F0,$F0,$00,$00 ; FRAME 2 ;/ RIGHT
  391.  
  392.  
  393. db $F0,$F0,$00,$00 ; FRAME 1 ;\ RIGHT
  394. db $F0,$F0,$00,$00 ; FRAME 2 ;/ RIGHT
  395.  
  396.  
  397. XDISP: db $00,$10,$00,$10 ; FRAME 1 ;\ RIGHT
  398. db $00,$10,$00,$10 ; FRAME 2 ;/ RIGHT
  399.  
  400.  
  401. db $10,$00,$10,$00 ; FRAME 1 ;\ LEFT
  402. db $10,$00,$10,$00 ; FRAME 2 ;/ LEFT
  403.  
  404. WaitGFX:
  405. HoverGFX:
  406. FireGFX:
  407. BillGFX:
  408. HurtGFX:
  409. RageGFX:
  410. DieGFX:
  411. LDX $15E9
  412.  
  413. LDA $14 ;\ Frame counter ..
  414. LSR A ; |
  415. LSR A ; | Add in frame animation rate; More LSRs for slower animation.
  416. AND #$02 ; | 01 means we animate between 2 frames (00 and 01).
  417. ASL A ; |
  418. ASL A ; | ASL x2 (0-4) makes it switch between the first byte and fifth byte,
  419. STA $03 ;/ i.e. first animation and second animation. The result is stored into $03.
  420.  
  421. LDA $157C,x
  422. STA $02 ; Store direction to $02 for use with property routine later.
  423. BNE NoAdd
  424. LDA $03 ;\
  425. CLC ; | If sprite faces left ..
  426. ADC #$08 ; | Adding 8 more bytes to the table.
  427. STA $03 ;/ So we can invert XDISP to not mess up the sprite's appearance.
  428. NoAdd:
  429. PHX ;\ Push sprite index ..
  430. LDX #$03 ;/ And load X with number of tiles to loop through.
  431. Loop:
  432. PHX ; Push number of tiles to loop through.
  433. TXA ;\
  434. ORA $03 ;/ Transfer it to X and add in the "left displacement" if necessary.
  435. TAX ;\ Get it back into X for an index.
  436.  
  437. LDA $00 ;\
  438. CLC ; | Apply X displacement of the sprite.
  439. ADC XDISP,x ; |
  440. STA $0300,y ;/
  441.  
  442. LDA $01 ;\
  443. CLC ; | Y displacement is added for the Y position, so one tile is higher than the other.
  444. ADC YDISP,x ; | Otherwise, both tiles would have been drawn to the same position!
  445. STA $0301,y ; | If X is 00, i.e. first tile, then load the first value from the table and apply that
  446. ;/ as the displacement. For the second tile, F0 is added to make it higher than the first.
  447.  
  448. LDA TILEMAP,x
  449. STA $0302,y
  450.  
  451. PHX ; Push number of times to go through loop + "left" displacement if necessary.
  452. LDX $02 ;\
  453. LDA PROPERTIES,x ; | Set properties based on direction.
  454. STA $0303,y ;/
  455. PLX ; Pull number of times to go through loop.
  456.  
  457. INY ;\
  458. INY ; | The OAM is 8x8, but our sprite is 16x16 ..
  459. INY ; | So increment it 4 times.
  460. INY ;/
  461.  
  462. PLX ; Pull current tile back.
  463. DEX ; After drawing this tile, decrease number of tiles to go through loop. If the second tile
  464. ; is drawn, then loop again to draw the first tile.
  465.  
  466. BPL Loop ; Loop until X becomes negative (FF).
  467.  
  468. PLX ; Pull back the sprite index! We pushed it at the beginning of the routine.
  469.  
  470. LDY #$02 ; Y ends with the tile size .. 02 means it's 16x16
  471. LDA #$03 ; A -> number of tiles drawn - 1.
  472. ; I drew 2 tiles, so 2-1 = 1. A = 01.
  473.  
  474. JSL $01B7B3 ; Call the routine that draws the sprite.
  475. RTS ; Never forget this!
  476. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  477. ; GET_DRAW_INFO
  478. ; This is a helper for the graphics routine. It sets off screen flags, and sets up
  479. ; variables. It will return with the following:
  480. ;
  481. ; Y = index to sprite OAM ($300)
  482. ; $00 = sprite x position relative to screen boarder
  483. ; $01 = sprite y position relative to screen boarder
  484. ;
  485. ; It is adapted from the subroutine at $03B760
  486. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  487.  
  488. SPR_T1: db $0C,$1C
  489. SPR_T2: db $01,$02
  490.  
  491. GET_DRAW_INFO:
  492. STZ $186C,x ; reset sprite offscreen flag, vertical
  493. STZ $15A0,x ; reset sprite offscreen flag, horizontal
  494. LDA $E4,x ; \
  495. CMP $1A ; | set horizontal offscreen if necessary
  496. LDA $14E0,x ; |
  497. SBC $1B ; |
  498. BEQ ON_SCREEN_X ; |
  499. INC $15A0,x ; /
  500.  
  501. ON_SCREEN_X:
  502. LDA $14E0,x ; \
  503. XBA ; |
  504. LDA $E4,x ; |
  505. REP #$20 ; |
  506. SEC ; |
  507. SBC $1A ; | mark sprite invalid if far enough off screen
  508. CLC ; |
  509. ADC.w #$0040 ; |
  510. CMP.w #$0180 ; |
  511. SEP #$20 ; |
  512. ROL A ; |
  513. AND #$01 ; |
  514. STA $15C4,x ; /
  515. BNE INVALID ;
  516.  
  517. LDY #$00 ; \ set up loop:
  518. LDA $1662,x ; |
  519. AND #$20 ; | if not smushed (1662 & 0x20), go through loop twice
  520. BEQ ON_SCREEN_LOOP ; | else, go through loop once
  521. INY ; /
  522. ON_SCREEN_LOOP:
  523. LDA $D8,x ; \
  524. CLC ; | set vertical offscreen if necessary
  525. ADC SPR_T1,y ; |
  526. PHP ; |
  527. CMP $1C ; | (vert screen boundry)
  528. ROL $00 ; |
  529. PLP ; |
  530. LDA $14D4,x ; |
  531. ADC #$00 ; |
  532. LSR $00 ; |
  533. SBC $1D ; |
  534. BEQ ON_SCREEN_Y ; |
  535. LDA $186C,x ; | (vert offscreen)
  536. ORA SPR_T2,y ; |
  537. STA $186C,x ; |
  538. ON_SCREEN_Y:
  539. DEY ; |
  540. BPL ON_SCREEN_LOOP ; /
  541.  
  542. LDY $15EA,x ; get offset to sprite OAM
  543. LDA $E4,x ; \
  544. SEC ; |
  545. SBC $1A ; | $00 = sprite x position relative to screen boarder
  546. STA $00 ; /
  547. LDA $D8,x ; \
  548. SEC ; |
  549. SBC $1C ; | $01 = sprite y position relative to screen boarder
  550. STA $01 ; /
  551. RTS ; return
  552.  
  553. INVALID: PLA ; \ return from *main gfx routine* subroutine...
  554. PLA ; | ...(not just this subroutine)
  555. RTS ; /
  556.  
  557. ;--------------------------;
  558. ; Sprite Clipping Routine ;
  559. ; Mostly borrowed from SMW ;
  560. ;--------------------------;
  561.  
  562. GetSpriteClipping:
  563. LDA $E4,x
  564. CLC
  565. ADC #$03
  566. STA $04
  567. LDA $14E0,x
  568. ADC #$00
  569. STA $0A
  570. LDA.b #$1F-$03 ; Width of sprite clipping
  571. STA $06
  572. LDA $D8,x
  573. CLC
  574. ADC #$06
  575. STA $05
  576. LDA $14D4,x
  577. ADC #$00
  578. STA $0B
  579. LDA #$19 ; Height of sprite clipping
  580. STA $07
  581. RTS
  582.  
  583.  
  584. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  585. ; SUB_VERT_POS
  586. ; This routine determines if Mario is above or below the sprite. It sets the Y register
  587. ; to the direction such that the sprite would face Mario
  588. ; It is ripped from $03B829
  589. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  590.  
  591. SUB_VERT_POS: LDY #$00
  592. LDA $96
  593. SEC
  594. SBC $D8,x
  595. STA $0F
  596. LDA $97
  597. SBC $14D4,x
  598. BPL SPR_L11
  599. INY
  600. SPR_L11: RTS
  601.  
  602. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  603. ; SUB_HORZ_POS
  604. ; This routine determines which side of the sprite Mario is on. It sets the Y register
  605. ; to the direction such that the sprite would face Mario
  606. ; It is ripped from $03B817
  607. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  608.  
  609. SUB_HORZ_POS: LDY #$00
  610. LDA $94
  611. SEC
  612. SBC $E4,x
  613. STA $0F
  614. LDA $95
  615. SBC $14E0,x
  616. BPL SPR_L16
  617. INY
  618. SPR_L16: RTS
  619.  
  620.  
  621. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  622.  
  623. !FC_TEMP1 = $00 ; will use 2 bytes
  624. !FC_TEMP2 = $02 ; will use 2 bytes
  625. !FC_TEMP3 = $04 ; will use 2 bytes
  626. !FC_TEMP4 = $06 ; will use 2 bytes
  627.  
  628. CALCFULLFRAME: JSR CALCFRAME
  629. JSR CALCQUADFLIP
  630. RTS
  631.  
  632. CALCQUADFLIP: PHA
  633. JSR SUB_VERT_POS
  634. PLA
  635. CPY #$00
  636. BNE CHKHORZ
  637. EOR #$FF
  638. CLC
  639. ADC #$1F
  640. CHKHORZ: PHA
  641. JSR SUB_HORZ_POS
  642. PLA
  643. CPY #$00
  644. BEQ ENDQUADCHK
  645. EOR #$FF
  646. CLC
  647. ADC #$3E
  648. ENDQUADCHK: RTS
  649.  
  650. CALCFRAME: LDA $D8,x
  651. SEC
  652. SBC $96
  653. STA !FC_TEMP2
  654. LDA $14D4,x
  655. SBC $97
  656. STA !FC_TEMP2+1
  657. BNE HORZDIST
  658. LDA !FC_TEMP2
  659. BNE HORZDIST
  660. BRA SETHORZ
  661. HORZDIST: LDA $E4,x
  662. SEC
  663. SBC $94
  664. STA !FC_TEMP1
  665. LDA $14E0,x
  666. SBC $95
  667. STA !FC_TEMP1+1
  668. BNE BEGINMATH
  669. LDA !FC_TEMP1
  670. BNE BEGINMATH
  671. BRA SETVERT
  672. BEGINMATH: PHP
  673. REP #$20
  674. LDA !FC_TEMP2
  675. BPL CHKXDIST
  676. EOR #$FFFF
  677. INC A
  678. STA !FC_TEMP2
  679. CHKXDIST: LDA !FC_TEMP1
  680. BPL MULT
  681. EOR #$FFFF
  682. INC A
  683. STA !FC_TEMP1
  684. MULT: ASL A
  685. ASL A
  686. ASL A
  687. ASL A
  688. STA !FC_TEMP3
  689. LDA !FC_TEMP1
  690. CLC
  691. ADC !FC_TEMP2
  692. STA !FC_TEMP4
  693. LDY #$00
  694. LDA !FC_TEMP4
  695. DEC A
  696. DIVLOOP: CMP !FC_TEMP3
  697. BCS END_DIVIDE
  698. INY
  699. CLC
  700. ADC !FC_TEMP4
  701. BRA DIVLOOP
  702. END_DIVIDE: TYA
  703. PLP
  704. RTS
  705. SETHORZ: LDA #$0F
  706. RTS
  707. SETVERT: LDA #$00
  708. RTS
  709.  
  710.  
  711. ;; PROJECTILE SPEEDS FOR EACH ANGLE
  712. ;; you can make your own speeds with, using http://smwedit.awardspace.com/_TEMP2.php as an aid,
  713. ;; but that tool won't do all the calculations for you (it'll only calculate the second half of X and Y)
  714. ;; Default settings:
  715. ;; Degrees: 180 (don't change)
  716. ;; Frames: 30 (don't change)
  717. ;; Radius: 64 (CHANGE THIS, THIS IS THE BASE SPEED)
  718. ;; Bytes: 1 (don't change)
  719. ;; #'s/line: 4 (don't change)
  720. ;; Add end frame: YES
  721.  
  722. XSPEEDS: db $00,$07,$0D,$14
  723. db $1A,$20,$26,$2B
  724. db $30,$34,$37,$3A
  725. db $3D,$3F,$40,$40
  726. db $40,$3F,$3D,$3A
  727. db $37,$34,$30,$2B
  728. db $26,$20,$1A,$14
  729. db $0D,$07,$00
  730. db $00,$F9,$F3,$EC
  731. db $E6,$E0,$DA,$D5
  732. db $D0,$CC,$C9,$C6
  733. db $C3,$C1,$C0,$C0
  734. db $C0,$C1,$C3,$C6
  735. db $C9,$CC,$D0,$D5
  736. db $DA,$E0,$E6,$EC
  737. db $F3,$F9,$00
  738.  
  739. YSPEEDS: db $C0,$C0,$C1,$C3
  740. db $C6,$C9,$CC,$D0
  741. db $D5,$DA,$E0,$E6
  742. db $EC,$F3,$F9,$00
  743. db $07,$0D,$14,$1A
  744. db $20,$26,$2B,$30
  745. db $34,$37,$3A,$3D
  746. db $3F,$40,$40
  747. db $40,$40,$3F,$3D
  748. db $3A,$37,$34,$30
  749. db $2B,$26,$20,$1A
  750. db $14,$0D,$07,$00
  751. db $F9,$F3,$EC,$E6
  752. db $E0,$DA,$D5,$D0
  753. db $CC,$C9,$C6,$C3
  754. db $C1,$C0,$C0
  755.  
  756. ;;;;;;;;;;;;;;;;;;
  757. ; Interaction ;;
  758. ;;;;;;;;;;;;;;;;;;
  759. KILLED_X_SPEED: db $F0,$10
  760.  
  761.  
  762. SPRITE_INTERACT: LDY #$0B ; sprite is being kicked
  763. INTERACT_LOOP: LDA $14C8,y ; \ if the sprite status is..
  764. CMP #$09 ; | ...shell-like
  765. BCS PROCESS_SPRITE ; /
  766. NEXT_SPRITE: DEY
  767. BPL INTERACT_LOOP
  768. RTS
  769.  
  770. PROCESS_SPRITE: PHX
  771. TYX
  772. JSL $03B6E5 ; get sprite clipping B routine
  773. PLX
  774. JSR GetSpriteClipping ; get sprite clipping A routine
  775. JSL $03B72B ; check for contact routine
  776. BCC NEXT_SPRITE
  777.  
  778. PHX
  779. TYX
  780.  
  781. JSL $01AB72 ; show sprite contact gfx routine
  782.  
  783. LDA #$02 ; \ Kill thrown sprite
  784. STA $14C8,x ; /
  785.  
  786. LDA #$D0 ; \ Set killed Y speed
  787. STA $AA,x ; /
  788.  
  789. LDY #$00 ; Set killed X speed
  790. LDA $B6,x
  791. BPL SET_SPEED
  792. INY
  793.  
  794. SET_SPEED: LDA KILLED_X_SPEED,y
  795. STA $B6,x
  796.  
  797. NO_KILL: PLX
  798.  
  799. HANDLE_HIT: LDA #$28 ; \ Play sound effect
  800. STA $1DFC ; /
  801.  
  802. LDA #$01 ; \ Set stunned state
  803. STA $C2,x ; /
  804.  
  805. LDA #$20 ; \ Set stunned timer
  806. STA $1564,x ; /
  807.  
  808. DEC !RAM_HP,x ; Increase hit counter and...
  809. LDA !RAM_HP,x ; \ Check if the sprite has been hit 3 times
  810. BNE JustHit
  811.  
  812. LDA #$08
  813. STA $1DF9
  814. LDA #$02 ; \ Kill sprite
  815. STA $14C8,x ;
  816. LDA #$10
  817. STA $1DF9
  818. LDA #$D0
  819. STA $AA,x
  820. LDA #$10
  821. STA $B6,x
  822. LDA $1588,x
  823. AND #$0F
  824. BNE .Kill
  825. LDA #$07
  826. STA !RAM_State,x
  827. RTS
  828.  
  829. .Kill
  830.  
  831.  
  832. LDA #$04
  833. STA $14C8,x
  834.  
  835. JSL $07FC3B
  836. RTS
  837.  
  838. JustHit: LDA #$FF
  839. STA !RAM_Timer,x
  840. LDA #$05
  841. STA !RAM_State,x
  842.  
  843. LDA #$20
  844. STA $1DF9
  845. RTS
  846.  
  847. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  848. ;; PHASE SWITCHER ;;;
  849. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  850.  
  851. PhaseDurationTable: db $69,$FF,$FF,$FF,$FF,$69,$FF,$69
  852.  
  853. NextPhase:
  854. JSL $01ACF9
  855. LDA $148D
  856. AND #$07
  857. STA $00
  858. JSL $01ACF9
  859. LDA $148D
  860. AND #$01
  861. CLC
  862. ADC $00
  863. STA !RAM_State,x
  864. AND #$07
  865. TAY
  866. LDA PhaseDurationTable,y
  867. CMP #$69
  868. BEQ NextPhase ;try again until you fetch a valid count
  869. LDA PhaseDurationTable,y
  870. STA !RAM_Timer,x
  871.  
  872. INC !RAM_Proj,x
  873. LDA !RAM_Proj,x
  874. CMP #!Phase_Blks
  875. BNE +
  876. STZ !RAM_Proj,x
  877. JSR GenerateThrowBlockAtTop
  878. + RTS
  879.  
  880.  
  881. ;====================================
  882. GenerateThrowBlockAtTop:
  883. .GenFire TXY
  884. LDX #$0B
  885. .GLoop LDA $14C8,X
  886. BEQ .Cont
  887. DEX
  888. BPL .GLoop
  889. RTS
  890.  
  891. .Cont PHY
  892. LDA #$09 ;set to main
  893. STA $14C8,x ;status
  894.  
  895. LDA #$53 ;sprite to generate
  896. STA $9E,x ;custom sprite
  897. PHY
  898. JSL $07F7D2 ;clear
  899. PLY
  900.  
  901. LDA #$78
  902. STA $E4,x
  903. LDA $95
  904. STA $14E0,x
  905.  
  906. LDA #$FF
  907. STA $1540,x
  908.  
  909. LDA #$00
  910. STA $D8,x
  911.  
  912. LDA #$00
  913. STA $14D4,x
  914.  
  915. STZ $B6,x
  916. STZ $AA,x
  917. PLX
  918. RTS
Advertisement
Add Comment
Please, Sign In to add comment