Prev: 633A Up: Map Next: 6388
633C: Guide a character to an intermediate destination
The address of this interruptible subcommand routine is placed into bytes 0x69 and 0x6A of the character's buffer by the routines at 62D7, 63BE, 7C6E and 7D30. It is used to make a character go straight to a destination (or intermediate destination) that is reachable without negotiating any staircases.
Input
H Character number (0x98-0xA9)
633C LD L,$6C The counter at byte 0x6C of the character's buffer is initialised by the calling routine to limit the amount of time that this routine has control; terminate this interruptible subcommand if the counter is now zero
633E DEC (HL)
633F JP Z,$62A4
6342 DEC L Collect the x-coordinate of the intermediate destination from byte 0x6B of the character's buffer
6343 LD A,(HL)
6344 LD L,$62 Byte 0x62 of the character's buffer holds his x-coordinate
6346 CP (HL) Has the character reached the intermediate destination?
6347 JR NZ,$634F Jump if not
6349 LD L,$60 Byte 0x60 of the character's buffer holds his animatory state
634B BIT 0,(HL) Is the character midstride?
634D JR Z,$633F Jump if not (nothing left to do)
634F CALL $6214 Update the SRB for the character's current location
6352 LD C,A Store the character's animatory state in C
6353 LD L,$6B Collect the x-coordinate of the intermediate destination from byte 0x6B of the character's buffer
6355 LD A,(HL)
6356 CP E E holds the character's x-coordinate
6357 LD A,C A=character's animatory state
6358 JR NZ,$6360 Jump unless the character has reached the destination
The character has reached the destination, but he is midstride. To complete the journey, he must finish his stride. This entry point is also used by the routine at 6C7C.
635A BIT 7,A Is the character facing left?
635C JR Z,$6369 Jump if so
635E JR $637F
The character has not yet reached the destination. Figure out his next move.
6360 BIT 7,A Now the zero flag indicates which way the character is facing: set=left, reset=right
6362 JR NC,$637A Jump if the character is to the left of his destination
The character is to the right of his destination, and so must proceed leftwards.
6364 RES 7,A Make sure the character is facing left
6366 JP NZ,$61B0 Update the character's animatory state and update the SRB if he was facing right
6369 INC A A=character's next animatory state
636A BIT 0,A Will the character be midstride?
636C JP NZ,$61B0 Update the character's animatory state and update the SRB if so
636F DEC E E=character's next x-coordinate (one to the left)
6370 AND $03 Calculate the character's next animatory state in A
6372 LD B,A
6373 LD A,C
6374 AND $FC
6376 ADD A,B
6377 JP $61B0 Update the character's animatory state and location and update the SRB
The character is to the left of his destination, and so must proceed rightwards.
637A SET 7,A Make sure the character is facing right
637C JP Z,$61B0 Update the character's animatory state and update the SRB if the character was facing left
637F INC A A=character's next animatory state
6380 BIT 0,A Will the character be midstride?
6382 JP NZ,$61B0 Update the character's animatory state and update the SRB if so
6385 INC E E=character's next x-coordinate (one to the right)
6386 JR $6370 Jump back to update the character's animatory state and location and update the SRB
Prev: 633A Up: Map Next: 6388