Prev: 31648 Up: Map Next: 31768
31739: Move a character looking for ERIC from the midstride position
Used by the routine at 63374. The address of this interruptible subcommand routine is also placed into bytes 105 and 106 of a character's buffer by the routine at 31768. It moves ERIC's chaser from the midstride position.
H Number of the character looking for ERIC (161, 163-166)
31739 LD L,105 Replace the address of this routine in bytes 105 and 106 of the character's buffer (if present) with that of 31648
31741 LD (HL),160
31743 CALL 25108 Update the SRB for the character's current location
31746 LD L,108 D=character's new y-coordinate (adjusted by the value in byte 108 of his buffer, placed there by the routine at 31768)
31748 LD B,A
31749 LD A,D
31750 ADD A,(HL)
31751 LD D,A
31752 DEC L E=character's new x-coordinate (adjusted by the value in byte 107 of his buffer, placed there by the routine at 31768)
31753 LD A,E
31754 ADD A,(HL)
31755 LD E,A
The character's post-midstride coordinates have been calculated; now we consider his post-midstride animatory state. Usually, a character's animatory state is incremented as he moves to or from the midstride position, which makes his walking animation cycle through phases 1, 2, 3 and 4. However, the next section of code - unlike its counterpart in the routine at 31768, which moves ERIC's chaser to the midstride position - decrements the animatory state if the character is moving leftwards, and increments it if the character is moving rightwards. So when a character is moving leftwards while chasing ERIC, his walking animation will cycle through phases 1 and 2 only, or 3 and 4 only. This is a bug.
31756 LD A,(HL) A=x-coordinate increment (-1 or +1)
31757 ADD A,B Add this to the character's current animatory state
31758 AND 3 Now C holds the new walking phase bits
31760 LD C,A
31761 LD A,B A=character's current animatory state
31762 AND 252 Clear the walking phase bits (bits 0 and 1)
31764 ADD A,C Set the walking phase to 1 (C=0) or 3 (C=2)
31765 JP 25008 Update the character's animatory state and location and update the SRB
Prev: 31648 Up: Map Next: 31768