Prev: FADA Up: Map Next: FB43
FAE3: Move a falling character to the next point in his descent
Used by the routines at FB4B and FB52. Moves the character to the next point in his descent from the roof of a building. Returns with the carry flag reset if the character has landed, and then with the zero flag reset if he was knocked out by the landing.
Input
H Character number (0xD7-0xE6)
FAE3 LD L,$02 Point HL at byte 0x02 of the character's buffer
FAE5 LD A,(HL) A=character's y-coordinate
FAE6 LD L,$15 Byte 0x15 of the character's buffer holds his landing y-coordinate
FAE8 CP (HL) Has the character landed yet?
FAE9 JR NZ,$FAF6 Jump if not
FAEB LD L,$0D Is the character Sam, and should he be knocked out upon landing?
FAED BIT 0,(HL)
FAEF RET Z Return with the carry flag reset (the character has landed) and the zero flag set (he was not knocked out) if not
FAF0 CALL $F9D2 Knock Sam out
FAF3 LD A,H Reset the carry flag (Sam has landed) and the zero flag (he was knocked out upon landing)
FAF4 AND A
FAF5 RET
The character has not landed yet.
FAF6 ADD A,$03 Set the zero flag if the character is at the right height above the roof or ground to hit another character
FAF8 CP (HL)
FAF9 PUSH HL Save the character number briefly
FAFA CALL Z,$FAA2 Check whether the character has landed on someone
FAFD POP HL Restore the character number to H
FAFE JR NZ,$FB04 Jump unless the character has landed on someone
FB00 LD L,$0D Set byte 0x0D of the character's buffer to 0: he will not be knocked out upon landing
FB02 LD (HL),$00
FB04 LD L,$0D Is the character Sam, and was he dropped from a great enough height that he could be knocked out upon landing?
FB06 BIT 0,(HL)
FB08 JR Z,$FB0D Jump if not
FB0A LD L,$04 Set Sam's z-coordinate to 4 (outside)
FB0C LD (HL),L
FB0D LD L,$14 Pick up byte 0x14 of the character's buffer; this will be non-zero if the character is still moving to the left or right just after stepping off the roof of a building
FB0F LD A,(HL)
FB10 AND A Set the zero flag if byte 0x14 is zero
FB11 LD DE,$0100 D=1 (default y-coordinate increment), E=0 (default x-coordinate increment)
FB14 JR Z,$FB2E Jump if the character is falling straight downwards now
FB16 DEC (HL) Decrement byte 0x14 of the character's buffer
FB17 DEC A Set the carry flag if byte 0x14 is less than 5
FB18 CP $05
FB1A LD L,E L=0
FB1B JR C,$FB27 Jump if byte 0x14 of the character's buffer is less than 5
FB1D LD D,$00 Set the y-coordinate increment to 0
FB1F JR Z,$FB27 Jump if byte 0x14 of the character's buffer is 5
FB21 CALL $E9C8 Update the SRB for the character's current animatory state and location
FB24 INC A A=character's next animatory state (midstride)
FB25 JR $FB3D Make the character take the first step off the edge of the roof
The character is midstride on the edge of the roof. The next step (to the left or right) will place him in mid-air.
FB27 INC E E=1
FB28 BIT 7,(HL) Is the character facing right?
FB2A JR NZ,$FB2E Jump if so
FB2C LD E,$FF E=-1
Now D holds the y-coordinate increment (0 or 1), and E holds the x-coordinate increment (-1, 0 or 1).
FB2E PUSH DE Save the x- and y-coordinate increments
FB2F CALL $E9C8 Update the SRB for the character's current animatory state and location
FB32 AND $F8 A=character's base animatory state
FB34 LD L,A Copy this to L
FB35 POP BC Restore the x- and y-coordinate increments to C and B
FB36 LD A,B D=character's next y-coordinate
FB37 ADD A,D
FB38 LD D,A
FB39 LD A,C E=character's next x-coordinate
FB3A ADD A,E
FB3B LD E,A
FB3C LD A,L A=character's base animatory state
Now A, E and D hold the character's new animatory state and x- and y-coordinates.
FB3D CALL $E9D5 Update the character's animatory state and location and update the SRB
FB40 LD A,H A=character number (0xD7-0xE6)
FB41 ADD A,A Set the carry flag (the character has not landed yet)
FB42 RET
Prev: FADA Up: Map Next: FB43