ThomasSpeedrunner

Tails Flight Code RELOADED - rev01

Apr 20th, 2015
611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.13 KB | None | 0 0
  1. ; ---------------------------------------------------------------------------
  2. ; Subroutine to check if Tails wants to fly
  3. ; ---------------------------------------------------------------------------
  4.  
  5. ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
  6.  
  7. Tails_CheckFlight:
  8. cmpi.b #1,jumping(a0) ; Is Tails jumping?
  9. bne.w Tails_NoFly ; If not, don't bother with checking for flying.
  10.  
  11. moveq #0,d0 ; Quickly clear d0.
  12. move.b (Ctrl_1_Press_Logical).w,d0 ; Read the first controller port.
  13. andi.b #$30,d0 ; Is B or C pressed?
  14. beq.w Tails_NoFly ; If not, return.
  15.  
  16. addq.l #4,sp ; Cause the 68k to force-skip any routines called after this one in Tails_MdJump.
  17. bclr #2,status(a0) ; Clear the "rolling" status bit.
  18. bclr #4,status(a0) ; Clear the "rolljumping" status bit.
  19. move.b #$F,y_radius(a0) ; this sets Tails' collision height (2*pixels) to less than Sonic's height
  20. move.b #9,x_radius(a0)
  21. move.b #0,jumping(a0) ; Clear Tails' jumping flag.
  22. move.b #$20,anim(a0) ; Tell Tails to use his flying animation.
  23. move.b #1,double_jump_flag(a0) ; Tell the game that Tails is flying.
  24. btst #6,status(a0) ; Hold it! Is Tails underwater?
  25. beq.w Tails_StartFlying_NotUnderWater ; If not, branch.
  26. move.b #3,double_jump_flag(a0) ; If he is, well, TELL THE GAME THAT, DAMNIT.
  27.  
  28. Tails_StartFlying_NotUnderWater:
  29. move.b #60,double_jump_meaning(a0) ; Set Tails' total flight time.
  30.  
  31. Tails_NoFly:
  32. rts
  33. ; End of subroutine Tails_CheckFlight
  34. ; ---------------------------------------------------------------------------
  35. ; Subroutine to do flight logic for Tails
  36. ; ---------------------------------------------------------------------------
  37. ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
  38.  
  39. Tails_DoFlightLogic:
  40. tst.b double_jump_flag(a0) ; Is Tails flying?
  41. beq.w Tails_FlightLogic_Done ; Nope? Well then, skip over this whole thing.
  42. move.b ($FFFFFE05).w,d0 ; Get the current frame number...I think.
  43. andi.b #9,d0 ; Are we on a frame that's a multiple of 10?
  44. bne.w + ; No? BRANCH.
  45. tst.b double_jump_meaning(a0) ; Is Tails already tired?
  46. beq.w + ; If he is, branch.
  47. subq.b #1,double_jump_meaning(a0) ; Subtract 1 from Tails' total flight time if we are.
  48. bne.w + ; If he still has flight time remaining, branch.
  49. move.b #2,double_jump_flag(a0) ; So Tails is tired? Well, tell the game that.
  50. btst #6,status(a0) ; Is Tails underwater?
  51. beq.w + ; If not, branch.
  52. move.b #4,double_jump_flag(a0) ; If he is, remind the game that he is.
  53. +
  54. jsr (ObjectMove).l
  55. moveq #0,d0 ; Quickly clear d0.
  56. move.w #$10,d0 ; Prepare to add 16 to Tails' vertical velocity.
  57. btst #6,status(a0) ; Is Tails underwater?
  58. beq.w + ; If not, branch.
  59. subi.w #6,d0 ; If he is, remind the game that 3/8 of flight/swimming gravity does not apply when Tails is underwater.
  60. +
  61. cmpi.b #1,(Reverse_Gravity_Flag).w ; Is reverse gravity activated?
  62. bne.w + ; If not, branch.
  63. neg.w d0 ; If yes, negate d0.
  64. +
  65. add.w d0,y_vel(a0)
  66.  
  67. moveq #0,d0 ; Quickly clear d0.
  68. move.b (Ctrl_1_Held_Logical).w,d0 ; Read the first controller port.
  69. andi.b #$30,d0 ; Is B or C pressed?
  70. beq.w Tails_FlightLogic_PrepareAnim ; If not, branch.
  71. tst.b double_jump_meaning(a0) ; Is Tails already tired?
  72. beq.w Tails_FlightLogic_PrepareAnim ; If he is, branch.
  73. cmpi.w #-$100,y_vel(a0) ; Is Tails' vertical velocity faster than -$100?
  74. blt.w Tails_FlightLogic_PrepareAnim ; If it is, branch.
  75. subi.w #$1F,y_vel(a0) ; Else, accelerate Tails upwards.
  76.  
  77. Tails_FlightLogic_PrepareAnim:
  78. move.b #$20,(Next_Flight_Anim).w ; Plan to use "flying" animation.
  79. btst #6,status(a0) ; Is Tails underwater?
  80. beq.w Tails_FlightLogic_CorrectAni_CheckTired ; If not, branch.
  81. move.b #$21,(Next_Flight_Anim).w ; Plan to use "swimming" animation.
  82.  
  83. Tails_FlightLogic_CorrectAni_CheckTired:
  84. tst.b double_jump_meaning(a0) ; Is Tails tired?
  85. bne.w Tails_FlightLogic_CompareAnims ; If not, branch.
  86. move.b #$22,(Next_Flight_Anim).w ; Plan to use "tired while flying" animation.
  87. btst #6,status(a0) ; Is Tails underwater?
  88. beq.w Tails_FlightLogic_CompareAnims ; If not, branch.
  89. move.b #$23,(Next_Flight_Anim).w ; Plan to use "tired while swimming" animation.
  90.  
  91. Tails_FlightLogic_CompareAnims:
  92. moveq #0,d0 ; Quickly clear d0.
  93. moveq #0,d1 ; Quickly clear d1.
  94. move.b (Next_Flight_Anim).w,d0
  95. move.b anim(a0),d1
  96. cmp.b d0,d1 ; Are the two anims identical?
  97. beq.w Tails_FlightLogic_PlayFlyingSound ; If they are, branch.
  98. move.b (Next_Flight_Anim).w,anim(a0) ; Otherwise, set Tails' animation to the flight animation.
  99.  
  100. Tails_FlightLogic_PlayFlyingSound:
  101. move.b ($FFFFFE05).w,d0 ; Get the current frame number...I think.
  102. andi.b #9,d0 ; Are we on a frame that's a multiple of 10?
  103. bne.w Tails_FlightLogic_Done ; No? BRANCH.
  104. move.w #$F1,d0 ; Prepare to play "flying" SFX.
  105. tst.b double_jump_meaning(a0) ; Is Tails tired?
  106. bne.w + ; If not, branch.
  107. move.w #$F2,d0 ; Prepare to play "tired while flying" SFX.
  108. +
  109. jsr (PlaySound).l
  110.  
  111. Tails_FlightLogic_Done:
  112. rts
  113. ; End of subroutine Tails_DoFlightLogic
Advertisement
Add Comment
Please, Sign In to add comment