Prev: 64218 Up: Map Next: 64323
64227: Move a falling character to the next point in his descent
Used by the routines at 64331 and 64338. 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 (215-230)
64227 LD L,2 Point HL at byte 2 of the character's buffer
64229 LD A,(HL) A=character's y-coordinate
64230 LD L,21 Byte 21 of the character's buffer holds his landing y-coordinate
64232 CP (HL) Has the character landed yet?
64233 JR NZ,64246 Jump if not
64235 LD L,13 Is the character Sam, and should he be knocked out upon landing?
64237 BIT 0,(HL)
64239 RET Z Return with the carry flag reset (the character has landed) and the zero flag set (he was not knocked out) if not
64240 CALL 63954 Knock Sam out
64243 LD A,H Reset the carry flag (Sam has landed) and the zero flag (he was knocked out upon landing)
64244 AND A
64245 RET
The character has not landed yet.
64246 ADD A,3 Set the zero flag if the character is at the right height above the roof or ground to hit another character
64248 CP (HL)
64249 PUSH HL Save the character number briefly
64250 CALL Z,64162 Check whether the character has landed on someone
64253 POP HL Restore the character number to H
64254 JR NZ,64260 Jump unless the character has landed on someone
64256 LD L,13 Set byte 13 of the character's buffer to 0: he will not be knocked out upon landing
64258 LD (HL),0
64260 LD L,13 Is the character Sam, and was he dropped from a great enough height that he could be knocked out upon landing?
64262 BIT 0,(HL)
64264 JR Z,64269 Jump if not
64266 LD L,4 Set Sam's z-coordinate to 4 (outside)
64268 LD (HL),L
64269 LD L,20 Pick up byte 20 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
64271 LD A,(HL)
64272 AND A Set the zero flag if byte 20 is zero
64273 LD DE,256 D=1 (default y-coordinate increment), E=0 (default x-coordinate increment)
64276 JR Z,64302 Jump if the character is falling straight downwards now
64278 DEC (HL) Decrement byte 20 of the character's buffer
64279 DEC A Set the carry flag if byte 20 is less than 5
64280 CP 5
64282 LD L,E L=0
64283 JR C,64295 Jump if byte 20 of the character's buffer is less than 5
64285 LD D,0 Set the y-coordinate increment to 0
64287 JR Z,64295 Jump if byte 20 of the character's buffer is 5
64289 CALL 59848 Update the SRB for the character's current animatory state and location
64292 INC A A=character's next animatory state (midstride)
64293 JR 64317 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.
64295 INC E E=1
64296 BIT 7,(HL) Is the character facing right?
64298 JR NZ,64302 Jump if so
64300 LD E,255 E=-1
Now D holds the y-coordinate increment (0 or 1), and E holds the x-coordinate increment (-1, 0 or 1).
64302 PUSH DE Save the x- and y-coordinate increments
64303 CALL 59848 Update the SRB for the character's current animatory state and location
64306 AND 248 A=character's base animatory state
64308 LD L,A Copy this to L
64309 POP BC Restore the x- and y-coordinate increments to C and B
64310 LD A,B D=character's next y-coordinate
64311 ADD A,D
64312 LD D,A
64313 LD A,C E=character's next x-coordinate
64314 ADD A,E
64315 LD E,A
64316 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.
64317 CALL 59861 Update the character's animatory state and location and update the SRB
64320 LD A,H A=character number (215-230)
64321 ADD A,A Set the carry flag (the character has not landed yet)
64322 RET
Prev: 64218 Up: Map Next: 64323