ThomasSpeedrunner

Tails Flying Code v4

May 3rd, 2013
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.95 KB | None | 0 0
  1. ; Here we have the actual flight routine itself...
  2. ; ---------------------------------------------------------------------------
  3. ; Subroutine to check if Tails wants to begin flying mid-jump
  4. ; ---------------------------------------------------------------------------
  5. Tails_CheckFlight:
  6. btst #1,flight_property(a0) ; are we flying?
  7. bne.s Tails_FlyingSwimming ; if yes, branch to the subroutine handling Tails' flight logic
  8. btst #2,flight_property(a0) ; are we tired while flying?
  9. bne.s Tails_FlyingSwimming ; if yes, branch to the subroutine handling Tails' flight logic
  10.  
  11. tst.b (Two_player_mode).w ; are we in two player mode?
  12. bne.w + ; if so, skip the following check
  13.  
  14. cmpa.w #MainCharacter,a0 ; is Tails the main character?
  15. bne.w return_1C83D ; if not, return
  16. +
  17. cmpi.b #1,jumping(a0) ; are we jumping?
  18. bne.w return_1C83D ; if not, return
  19.  
  20. move.b (Ctrl_1_Press_Logical).w,d0
  21. andi.b #button_B_mask|button_C_mask,d0 ; is B or C pressed?
  22. beq.w return_1C83D ; if not, return
  23. ; if all of these conditions are met, do the following:
  24. move.b #AniIDTailsAni_Fly,anim(a0) ; begin flying
  25. move.b #$4B,flight_time(a0) ; set the amount of time Tails can fly for (this is needed later, in Tails_FlyingSwimming)
  26. move.w #$C,y_vel(a0) ; set Tails' y-velocity to something reasonable (again, needed later, in Tails_FlyingSwimming)
  27. bset #1,flight_property(a0) ; tell the game that Tails is flying (part 1)
  28. bclr #0,flight_property(a0) ; tell the game that Tails is flying (part 2)
  29.  
  30. return_1C83D:
  31. rts
  32.  
  33. ; ---------------------------------------------------------------------------
  34. ; Subroutine doing the extra logic for Tails' flight
  35. ; ---------------------------------------------------------------------------
  36. Tails_FlyingSwimming:
  37. jsr (ObjectMove).l
  38. cmpi.b #death_egg_zone,(Current_Zone).w ; are we in Death Egg Zone?
  39. bne.s + ; if not, skip the reverse gravity check
  40. moveq #0,d0 ; clear d0
  41. move.b (Reverse_gravity_flag).w,d0 ; move the value in Reverse_gravity_flag into d0
  42. cmpi.b #1,d0 ; is the reverse gravity gimmick on?
  43. bne.s + ; No? Branch then
  44. subi.w #4,y_vel(a0) ; If so, SUBTRACT from Tails' y_vel instead
  45. bra.s ++
  46. +
  47. addi.w #4,y_vel(a0) ; slowly increase Tails' gravity
  48. +
  49. moveq #0,d0
  50. move.b ($FFFFFE05).w,d0
  51. andi.b #9,d0
  52. bne.s +
  53. subq.b #1,flight_time(a0)
  54. bne.s +
  55. btst #2,flight_property(a0) ; Did we already tell the game that Tails is tired?
  56. bne.s + ; If so, don't keep telling it, since that's completely pointless and just wastes CPU cycles.
  57. bset #2,flight_property(a0) ; If we haven't yet, tell the game that Tails is tired.
  58. +
  59. rts
  60.  
  61. ; ...and the modified Obj02_MdJump routine...
  62. ; ===========================================================================
  63. ; Start of subroutine Obj02_MdJump
  64. ; Called if Tails is in a ball and airborne (he could be jumping but not necessarily)
  65. Obj02_MdJump:
  66. bsr.w Tails_CheckFlight
  67. bsr.w Tails_JumpHeight
  68. bsr.w Tails_ChgJumpDir
  69. bsr.w Tails_LevelBound
  70. btst #1,flight_property(a0) ; is Tails flying?
  71. bne.s + ; if so, skip ObjectMoveAndFall and related commands (the gravity for Tails' flying is handled in Tails_FlyingSwimming)
  72. btst #2,flight_property(a0) ; is Tails in a tired state while flying?
  73. bne.s + ; if so, skip ObjectMoveAndFall and related commands (the gravity for Tails' flying is handled in Tails_FlyingSwimming)
  74. jsr (ObjectMoveAndFall).l
  75. btst #6,status(a0) ; is Tails underwater?
  76. beq.s + ; if not, branch
  77. subi.w #$28,y_vel(a0) ; reduce gravity by $28 ($38-$28=$10)
  78. +
  79. bsr.w Tails_JumpAngle
  80. bsr.w Tails_DoLevelCollision
  81. rts
  82. ; End of subroutine Obj02_MdJump
  83. ; ===========================================================================
  84. ; ...the modified Obj02_ResetOnFloor_Part3...
  85. ; loc_1CB80:
  86. Tails_ResetOnFloor_Part3:
  87. bclr #1,status(a0)
  88. bclr #5,status(a0)
  89. bclr #4,status(a0)
  90. move.b #0,jumping(a0)
  91. move.w #0,(Chain_Bonus_counter).w
  92. move.b #0,flip_angle(a0)
  93. move.b #0,flip_turned(a0)
  94. move.b #0,flips_remaining(a0)
  95. btst #0,flight_property(a0) ; Test the not-flying bit...
  96. bne.s + ; ...and if we didn't fly since the last time we hit the floor, skip the flying section
  97. ; Section for Tails' flight:
  98. move.b #0,flight_time(a0) ; Reset our flight time...
  99. bclr #1,flight_property(a0) ; ...clear the flying bit...
  100. bclr #2,flight_property(a0) ; ...clear the tired-while-flying bit...
  101. bset #0,flight_property(a0) ; ...and set the not-flying bit.
  102. + ; Rest of original subroutine:
  103. move.w #0,(Tails_Look_delay_counter).w
  104. cmpi.b #AniIDTailsAni_Hang2,anim(a0)
  105. bne.s return_1CBC4
  106. move.b #AniIDTailsAni_Walk,anim(a0)
  107.  
  108. return_1CBC4:
  109. rts
  110. ; ...and the modified section of Level_FromCheckpoint (this was done to fix a bug).
  111. move.b #1,(Level_started_flag).w
  112. cmpi.w #2,(Player_mode).w
  113. bne.s +
  114. bset #0,flight_property(a0)
  115. bclr #1,flight_property(a0)
  116. bclr #2,flight_property(a0)
  117. ; Level_StartGame: loc_435A:
  118. + bclr #GameModeFlag_TitleCard,(Game_Mode).w ; clear $80 from the game mode
Advertisement
Add Comment
Please, Sign In to add comment