Prev: 7BFB Up: Map Next: 7C3F
7C18: Move a character looking for ERIC to the midstride position
Continues from 7BA0. Moves the character looking for ERIC to the midstride position in the appropriate direction.
Input
A 1 if the character's going upstairs, 2 if going down
BC 0000
DE 0000
H Number of the character looking for ERIC (0xA1, 0xA3-0xA6)
L 0x60
The main entry point is used when the character is on a staircase.
7C18 INC B B=1
7C19 DEC A Is the chaser going downstairs?
7C1A JR NZ,$7C1E Jump if so
7C1C DEC B B=0
7C1D DEC D D=-1
7C1E INC C C=1
7C1F BIT 7,(HL) Is the chaser facing right?
7C21 JR NZ,$7C25 Jump if so
7C23 DEC C C=-1
7C24 DEC C
This entry point is used by the routine at 7BA0 when the character looking for ERIC is not on a staircase; in this case B=D=E=0, and C=-1 if the chaser is to ERIC's left, or 1 if he is to ERIC's right.
7C25 LD L,$6B C=-1 if the chaser is to ERIC's left, or 1 if to his right; B=1 if the chaser is going downstairs, 0 otherwise; place these values into bytes 0x6B and 0x6C of the chaser's buffer
7C27 LD (HL),C
7C28 INC L
7C29 LD (HL),B
7C2A LD L,$69 Change the interruptible subcommand routine address in bytes 0x69 and 0x6A of the chaser's buffer from 7BA0 to 7BFB
7C2C LD (HL),$FB
7C2E PUSH DE Save the x- and y-coordinate increments for the chaser's next move
7C2F CALL $6214 Update the SRB for the chaser's current location
7C32 INC A A=chaser's next animatory state (midstride)
7C33 LD L,A Store this in L briefly
7C34 POP BC Get the appropriate y- and x-coordinate increments for the chaser's move to the midstride position in BC
7C35 LD A,B Get the chaser's new y-coordinate in D (which is the same as his current y-coordinate unless he's going up a staircase)
7C36 ADD A,D
7C37 LD D,A
7C38 LD A,C Get the chaser's new x-coordinate in E (which is the same as his current x-coordinate, because C is always 0)
7C39 ADD A,E
7C3A LD E,A
7C3B LD A,L Restore the chaser's new animatory state to A
7C3C JP $61B0 Update the chaser's animatory state and location and update the SRB
Prev: 7BFB Up: Map Next: 7C3F