| Routines

6464: Guide a character from the bottom floor to another floor

Used by the routine at 63BE when the character under consideration is on the bottom floor but is destined for another floor.
Input
BC | 633C
E | Character's x-coordinate
H | Character number (0x98-0xA9)
L | 0x65
6464 | LD A,(HL) | A=destination y-coordinate
6465 | CP $A2 | Set the zero flag if the character is going to the middle floor
6467 | LD A,$26 | This is the x-coordinate of the wall between the White and Exam Rooms
6469 | JR Z,$646D | Jump if the character is going to the middle floor
646B | LD A,$39 | This is the x-coordinate of the wall between the Map and Reading Rooms
646D | INC L | Set the carry flag if the character is destined for some place to the right of the wall referred to by A
646E | CP (HL)
646F | LD A,$46 | This is the x-coordinate of the bottoms of the staircases at the right of the skool
6471 | JR C,$6475 | Jump if the character must go to a staircase on the right
6473 | LD A,$13 | This is the x-coordinate of the bottoms of the staircases at the left of the skool
6475 | CP E | Is the character at the bottom of the staircase he must climb?
6476 | JP NZ,$641B | Jump if not (to send the character there)
6479 | LD L,$60 | Byte 0x60 of the character's buffer holds his animatory state
647B | BIT 0,(HL) | Is the character midstride?
647D | JP NZ,$641B | Jump if so (to finish the stride)
6480 | CP $30 | Is the character at the bottom of a staircase at the right of the skool?
6482 | JR NC,$648B | Jump if so
6484 | BIT 7,(HL) | Is the character facing right?
6486 | JP NZ,$640F | Turn him round if so
6489 | JR $6490 |
648B | BIT 7,(HL) | Is the character facing left?
648D | JP Z,$640F | Turn him round if so
6490 | LD C,$8C | Set BC=638C (guide character up stairs) and place this interruptible subcommand routine address into bytes 0x69 and 0x6A of the character's buffer
6492 | JP $6419