| Routines

7BFB: Move a character looking for ERIC from the midstride position

Used by the routine at F78E. The address of this interruptible subcommand routine is also placed into bytes 0x69 and 0x6A of a character's buffer by the routine at 7C18. It moves ERIC's chaser from the midstride position.
Input
H | Number of the character looking for ERIC (0xA1, 0xA3-0xA6)
7BFB | LD L,$69 | Replace the address of this routine in bytes 0x69 and 0x6A of the character's buffer (if present) with that of 7BA0
7BFD | LD (HL),$A0
7BFF | CALL $6214 | Update the SRB for the character's current location
7C02 | LD L,$6C | D=character's new y-coordinate (adjusted by the value in byte 0x6C of his buffer, placed there by the routine at 7C18)
7C04 | LD B,A
7C05 | LD A,D
7C06 | ADD A,(HL)
7C07 | LD D,A
7C08 | DEC L | E=character's new x-coordinate (adjusted by the value in byte 0x6B of his buffer, placed there by the routine at 7C18)
7C09 | LD A,E
7C0A | ADD A,(HL)
7C0B | 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 7C18, 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.
7C0C | LD A,(HL) | A=x-coordinate increment (-1 or +1)
7C0D | ADD A,B | Add this to the character's current animatory state
7C0E | AND $03 | Now C holds the new walking phase bits
7C10 | LD C,A
7C11 | LD A,B | A=character's current animatory state
7C12 | AND $FC | Clear the walking phase bits (bits 0 and 1)
7C14 | ADD A,C | Set the walking phase to 1 (C=0) or 3 (C=2)
7C15 | JP $61B0 | Update the character's animatory state and location and update the SRB