Prev: 79D1 Up: Map Next: 7AC3
79D2: Handler: Parachute Descent
Used by the routines at Handler_Room02, Handler_Room08 and Handler_Room09.
Controls the paratrooper's parachute descent. The paratrooper descends under a parachute canopy, and upon reaching the bottom boundary the parachute folds up and detaches, drifting sideways while the paratrooper separates. The bottom boundary varies by room, and on room 08 it is extended to 88. Uses two sprite entries: the canopy (*IX+00 to *IX+03) and the body (*IX+04 to *IX+07).
Input
IX Pointer to the parachute sprite data
Set up initial state and check for respawn.
Handler_Parachute_Descent 79D2 LD A,($5FBB) Fetch the respawn flag from *RespawnFlag.
79D5 LD B,$70 Set the default bottom boundary to 70 in B.
79D7 LD IY,$7AC3 Point IY at Parachute_State_Data.
79DB OR A Jump to Reset_Parachute if the respawn flag is non-zero (reset the parachute).
79DC JP NZ,Reset_Parachute
79DF LD A,($5FC5) If *CurrentRoom is not equal to 08 skip over setting it below.
79E2 CP $08
79E4 JR NZ,Check_Parachute_State
79E6 LD B,$88 Set the bottom boundary to 88.
Check the parachute's current state.
Check_Parachute_State 79E8 BIT 7,(IY+$00) Jump to Parachute_Stunned if bit 7 of *IY+00 is set (parachute is stunned by egg).
79EC JP NZ,Parachute_Stunned
79EF LD A,(IY+$01) Jump to Animate_Parachute_Fold if *IY+01 (landing counter) is non-zero (parachute is folding).
79F2 OR A
79F3 JR NZ,Animate_Parachute_Fold
79F5 LD A,(IY+$02) Jump to Parachute_Detach if *IY+02 (detach flag) is non-zero (parachute has detached).
79F8 OR A
79F9 JR NZ,Parachute_Detach
Descent phase: move the paratrooper downward by 02 pixels per frame.
Parachute_Descend 79FB LD A,(IX+$01) Load A with the canopy Y position from *IX+01.
79FE ADD A,$02 Add 02 to the canopy Y position.
7A00 CP B Jump to Begin_Parachute_Fold if the canopy Y position has reached the bottom boundary in B.
7A01 JR NC,Begin_Parachute_Fold
7A03 LD (IX+$01),A Write the updated Y position to *IX+01 (canopy Y).
7A06 ADD A,$10 Set the body Y position to the canopy Y plus 10.
7A08 LD (IX+$05),A
7A0B LD (IX+$03),$5B Set the canopy sprite frame to 5B (open parachute).
Set_Body_Frame_And_Check 7A0F LD (IX+$07),$52 Set the body sprite frame to 52 (paratrooper under parachute).
7A13 CALL Check_Hazard_Collision Call Check_Hazard_Collision to check for collision with Percy or egg (canopy sprite).
7A16 INC IX Advance IX by four to the body sprite entry.
7A18 INC IX
7A1A INC IX
7A1C INC IX
7A1E JP Check_Hazard_Collision Jump to Check_Hazard_Collision to check for collision with Percy or egg (body sprite).
Paratrooper has reached the bottom boundary; begin folding the parachute.
Begin_Parachute_Fold 7A21 LD A,$01 Set the landing counter to 01.
7A23 LD (IY+$01),A Write the counter to *IY+01.
Animate_Parachute_Fold 7A26 CP $07 Jump to Continue_Fold if the landing counter has not reached 07.
7A28 JR NZ,Continue_Fold
7A2A LD (IY+$01),$00 Reset the landing counter to 00 and set the detach flag at *IY+02 to 01 (parachute fully folded).
7A2E LD (IY+$02),$01
7A32 JR Parachute_Detach Jump to Parachute_Detach.
Continue_Fold 7A34 INC A Increment the landing counter and write it back to *IY+01.
7A35 LD (IY+$01),A
7A38 SRL A Divide by two and add 5B to calculate the folding parachute frame.
7A3A ADD A,$5B
7A3C LD (IX+$03),A Write the frame to *IX+03 (canopy sprite).
7A3F JR Set_Body_Frame_And_Check Jump to Set_Body_Frame_And_Check to set the body frame and check for collisions.
Detach phase: the parachute drifts sideways while the paratrooper separates.
Parachute_Detach 7A41 LD A,(IY+$03) Increment the animation counter at *IY+03 wrapping at 07.
7A44 INC A
7A45 AND %00000111
7A47 LD (IY+$03),A
7A4A SRL A Divide by two and add 57 to calculate the drifting paratrooper walking frame.
7A4C ADD A,$57
7A4E LD (IX+$07),A Write the frame to *IX+07 (body sprite frame).
7A51 LD A,(IX+$04) Load A with the body X position from *IX+04.
7A54 CP $80 If the body X position is less than 80 it is drifting left; jump to Drift_Right if drifting right.
7A56 JR NC,Drift_Right
Drifting left: subtract 02 from the body X position.
Drift_Left 7A58 SUB $02 Subtract 02 from the X position.
7A5A CP $04 Jump to Reset_Parachute if it has gone below 04 (off-screen to the left).
7A5C JR C,Reset_Parachute
7A5E LD (IX+$04),A Write the updated X position to *IX+04 (body X).
7A61 JP Check_Hazard_Collision Jump to Check_Hazard_Collision to check for collision with Percy or egg.
Drifting right: add 02 to the body X position.
Drift_Right 7A64 ADD A,$02 Add 02 to the body X position.
7A66 CP $EE Jump to Reset_Parachute if the body X position has reached EE (off-screen to the right).
7A68 JR NC,Reset_Parachute
7A6A LD (IX+$04),A Write the updated X position to *IX+04 (body X).
7A6D LD A,(IX+$07) Subtract 04 from the body sprite frame to get the opposite facing walking frame.
7A70 SUB $04
7A72 LD (IX+$07),A
7A75 INC IX Advance IX by four to the body sprite entry.
7A77 INC IX
7A79 INC IX
7A7B INC IX
7A7D JP Check_Hazard_Collision Jump to Check_Hazard_Collision to check for collision with Percy or egg.
Parachute has been stunned by Percy's egg; animate the stunned state.
Parachute_Stunned 7A80 LD A,(IY+$03) Jump to Animate_Stunned_Body if *IY+03 is non-zero (skip canopy animation).
7A83 OR A
7A84 JR NZ,Animate_Stunned_Body
7A86 CALL Animate_Stunned_Hazard Call Animate_Stunned_Hazard to animate the stunned canopy.
7A89 INC IX Advance IX by four to the body sprite entry.
7A8B INC IX
7A8D INC IX
7A8F INC IX
Animate_Stunned_Body 7A91 JP Animate_Stunned_Hazard Jump to Animate_Stunned_Hazard to animate the stunned body.
Reset the parachute to its starting position for this room.
Reset_Parachute 7A94 LD A,($5FC5) Look up the starting X position for the current room from the table at Table_ParachuteXPosition and write to both the canopy (*IX+00) and body (*IX+04) X positions.
7A97 DEC A
7A98 LD E,A
7A99 LD D,$00
7A9B LD HL,$7B04
7A9E ADD HL,DE
7A9F LD A,(HL)
7AA0 LD (IX+$00),A
7AA3 LD (IX+$04),A
7AA6 LD A,$04 Set both Y positions: canopy to 04 body to 14.
7AA8 LD (IX+$01),A
7AAB ADD A,$10
7AAD LD (IX+$05),A
7AB0 LD (IX+$02),$07 Set both sprite active flags to 07.
7AB4 LD (IX+$06),$07
7AB8 XOR A Write 00 to *IY+00 *IY+01 and *IY+02 to clear the stunned flag, landing counter and detach flag.
7AB9 LD (IY+$00),A
7ABC LD (IY+$01),A
7ABF LD (IY+$02),A
7AC2 RET Return.
Prev: 79D1 Up: Map Next: 7AC3