Prev: 64004 Up: Map Next: 64121
64005: Deal with a character who has been knocked over
The address of this uninterruptible subcommand routine is placed into bytes 18 and 19 of a character's buffer (by the routine at 64162) when he's been hit on the head by a falling character with an x-coordinate that differs from his by 1. It controls the character from the moment he is knocked over until he has finished staggering from being dazed by the collision.
Input
H Character number (215-229)
64005 LD A,138 A=10 (short knockout delay) + 128 (quick recovery)
64007 JR 64011
The address of this entry point is placed into bytes 18 and 19 of a character's buffer (by the routine at 64162) when he's been hit on the head by a falling character with the same x-coordinate.
64009 LD A,20 A=20 (long knockout delay) + 0 (slow recovery)
64011 LD L,20 Initialise the character's knockout delay counter in byte 20 of his buffer
64013 LD (HL),A
64014 LD L,0 Point HL at byte 0 of the character's buffer
64016 LD E,(HL) E=character's animatory state
64017 INC L L=1
64018 LD D,(HL) D=character's x-coordinate
64019 LD L,13 Store the character's pre-knockout animatory state in byte 13 of his buffer
64021 LD (HL),E
64022 LD L,21 Store the character's current x-coordinate in byte 21 of his buffer
64024 LD (HL),D
64025 CALL 63954 Knock the character over
64028 CALL 63997 Place the address of the following instruction into bytes 18 and 19 of the character's buffer
This entry point is used after the character has been knocked over and until he stands up again.
64031 LD L,20 Byte 20 of the character's buffer holds the knockout delay counter
64033 DEC (HL) Decrement it
64034 LD A,(HL) Pick up the current value in A
64035 AND 127 Is it time for the character to stand up?
64037 RET NZ Return if not
64038 LD A,L A=20
64039 BIT 7,(HL) Is bit 7 of the knockout delay counter set?
64041 JR NZ,64044 Jump if so
64043 ADD A,A A=40
64044 LD (HL),A Initialise the recovery delay counter (in byte 20 of the character's buffer) to 40 (if the character was hit by another with the same x-coordinate) or 20
64045 CALL 60300 Make the character stand up
64048 CALL 63997 Place the address of the following instruction into bytes 18 and 19 of the character's buffer
This entry point is used after the character has stood up again and while he is still dazed from the collision.
64051 LD L,20 Decrement the recovery delay counter
64053 DEC (HL)
64054 JR Z,64131 Jump if it has reached 0
64056 LD L,0 Point HL at byte 0 of the character's buffer
64058 BIT 0,(HL) Is the character facing right?
64060 JR NZ,64075 Jump if so
64062 PUSH HL Save the character number briefly
64063 CALL 60179 Obtain descriptors for the character's current location
64066 POP HL Restore the character number to H
64067 BIT 7,C Can the character move left?
64069 JR Z,64080 Jump if not
64071 BIT 6,C Can the character move right?
64073 JR Z,64080 Jump if not
64075 CALL 61823 Get a random number in A
64078 RRCA Rotate bit 0 into bit 7 for no apparent reason
64079 LD C,A Bit 7 of C will be used to decide whether the character should move left next
This entry point is used by the routine at 64131.
64080 LD DE,59861 Load the address of the routine at 59861 onto the stack
64083 PUSH DE
64084 PUSH BC Save the direction descriptor (in C)
64085 CALL 59848 Update the SRB for the character's current animatory state and location
64088 POP BC Restore the direction descriptor to C
64089 RLC C Set the carry flag if the character is going to move left
64091 BIT 7,A Is the character facing right?
64093 JR NZ,64109 Jump if so
The character is facing left.
64095 JR NC,64111 Jump if the character is going to move right (take a step backwards)
The character is going to take a step forwards.
64097 INC A A=character's next animatory state
64098 BIT 0,A Is it midstride?
64100 RET NZ Return (to 59861) if so
The character has just moved from the midstride position. Adjust his x-coordinate as appropriate.
64101 DEC E E=x-1 (where x is the character's x-coordinate)
64102 JR C,64106 Jump if the character is moving left
64104 INC E E=x+1 (the character is moving right)
64105 INC E
64106 AND 251 Make sure that bit 2 of the character's animatory state is reset
64108 RET To 59861, to update the character's animatory state and location and update the SRB
The character is facing right.
64109 JR NC,64097 Jump if the character is going to move right (take a step forwards)
The character is going to take a step backwards.
64111 DEC A A=character's next animatory state
64112 BIT 0,A Is it midstride?
64114 RET Z Return (to 59861) if not
64115 INC A Add 4 to A (without affecting the carry flag) to obtain the correct midstride animatory state (though bit 2 may need to be reset)
64116 INC A
64117 INC A
64118 INC A
64119 JR 64101
Prev: 64004 Up: Map Next: 64121