; ---------------------------------------------------------------------------
; Subroutine to check if Tails wants to begin flying mid-jump
; ---------------------------------------------------------------------------
Tails_CheckFlight:
btst #1,flight_property(a0) ; are we flying?
bne.s Tails_FlyingSwimming ; if yes, branch to the subroutine handling Tails' flight logic
btst #2,flight_property(a0) ; are we tired while flying?
bne.s Tails_FlyingSwimming ; if yes, branch to the subroutine handling Tails' flight logic
tst.b (Two_player_mode).w ; are we in two player mode?
bne.w + ; if so, skip the following check
cmpa.w #MainCharacter,a0 ; is Tails the main character?
bne.w return_1C83D ; if not, return
+
cmpi.b #1,jumping(a0) ; are we jumping?
bne.w return_1C83D ; if not, return
move.b (Ctrl_1_Press_Logical).w,d0
andi.b #button_B_mask|button_C_mask,d0 ; is B or C pressed?
beq.w return_1C83D ; if not, return
; if all of these conditions are met, do the following:
move.b #AniIDTailsAni_Fly,anim(a0) ; begin flying
move.b #$4B,flight_time(a0) ; set the amount of time Tails can fly for (this is needed later, in Tails_FlyingSwimming)
move.w #$C,y_vel(a0) ; set Tails' y-velocity to something reasonable (again, needed later, in Tails_FlyingSwimming)
bset #1,flight_property(a0) ; tell the game that Tails is flying (part 1)
bclr #0,flight_property(a0) ; tell the game that Tails is flying (part 2)
return_1C83D:
rts
; ---------------------------------------------------------------------------
; Subroutine doing the extra logic for Tails' flight
; ---------------------------------------------------------------------------
Tails_FlyingSwimming:
jsr (ObjectMove).l
addi.w #5,y_vel(a0)
moveq #0,d0
move.b ($FFFFFE05).w,d0
andi.b #9,d0
bne.s +
subq.b #1,flight_time(a0)
bne.s +
btst #2,flight_property(a0) ; Did we already tell the game that Tails is tired?
bne.s + ; If so, don't keep telling it, since that's completely pointless and just wastes CPU cycles.
bset #2,flight_property(a0) ; If we haven't yet, tell the game that Tails is tired.
+
rts
Comments