| Routines

6BF0: Check whether a character is beside a chair

Used by the routine at 6C7C. Returns with the zero flag set if the character is standing beside a chair. Returns with the carry flag set if the character should turn round.
Input
A | Character's animatory state
DE | Character's coordinates
H | Character number (0x98-0xA9)
6BF0 | BIT 7,A | Set the zero flag if the character is facing left
This entry point is used by the routine at 6CAF with H=0xAC (ERIC).
6BF2 | LD A,D | A=character's y-coordinate
6BF3 | JR NZ,$6C2E | Jump if the character is facing right
6BF5 | CP $9B | Set the zero flag if the character is on the top floor
6BF7 | LD A,E | A=character's x-coordinate
6BF8 | JR NZ,$6C12 | Jump if the character's on the middle floor
6BFA | CP $3A | Is the character to the right of the Map Room wall?
6BFC | JR NC,$6C0B | Jump if so
6BFE | CP $30 | This is the x-coordinate of the leftmost chair in the Reading Room
6C00 | RET C | Return if the character is to the left of this
6C01 | NOP |
6C02 | CP $38 | This is the x-coordinate of the rightmost chair in the Reading Room
6C04 | JR Z,$6C07 | Jump if the character is beside the rightmost chair in the room
6C06 | RET NC | Return if the character is to the right of this chair
6C07 | AND A |
6C08 | BIT 0,A | Return with the zero flag set if the character is standing beside a chair
6C0A | RET
The character is on the top floor to the right of the Map Room wall.
6C0B | CP $40 | This is the x-coordinate of the leftmost chair in the Map Room
6C0D | RET C | Return if the character is to the left of this
6C0E | CP $48 | This is the x-coordinate of the rightmost chair in the Map Room
6C10 | JR $6C04 |
The character is somewhere on the middle floor.
6C12 | CP $27 | Is the character to the right of the Exam Room wall?
6C14 | JR NC,$6C1E | Jump if so
6C16 | CP $1D | This is the x-coordinate of the leftmost chair in the White Room
6C18 | RET C | Return if the character is to the left of this
6C19 | INC A | This is the x-coordinate (+1) of the rightmost chair in the White Room
6C1A | CP $26
6C1C | JR $6C04 |
The character is on the middle floor to the right of the Exam Room wall.
6C1E | CP $2B | This is the x-coordinate of the leftmost chair in the Exam Room
6C20 | RET C | Return if the character is to the left of this
6C21 | CP $3C | This is the x-coordinate of the left end of the first set of chairs in the Exam Room
6C23 | JR C,$6C29 | Jump if the character is to the left of this
6C25 | CP $44 | This is the x-coordinate of the rightmost chair in the Exam Room
6C27 | JR $6C04 |
The character is in the Exam Room, to the left of the first set of chairs.
6C29 | INC A | This is the x-coordinate (+1) of the right end of the second set of chairs in the Exam Room
6C2A | CP $36
6C2C | JR $6C04 |
The character is facing right.
6C2E | CP $9B | Set the zero flag if the character is on the top floor
6C30 | LD A,E | A=character's x-coordinate
6C31 | JR NZ,$6C42 | Jump if the character is on the middle floor
6C33 | CP $3A | This is the x-coordinate of the wall between the Reading and Map Rooms
6C35 | JR NC,$6C3E | Jump if the character is to the right of this
6C37 | CP $37 | This is the x-coordinate of the spot between the two chairs at the right in the Reading Room; if this were 'CP $38' instead, kids would be able to find the rightmost seat in the room
6C39 | CCF | Clear the carry flag if the character is to the left of the rightmost chair in the room (i.e. he's still on his way there)
6C3A | RET NZ | Return unless the character is beside the rightmost chair in the room
6C3B | AND A | Reset the zero flag, and set the carry flag to indicate that the character should turn round
6C3C | CCF
6C3D | RET |
6C3E | CP $48 | This is the x-coordinate of the rightmost seat in the Map Room
6C40 | JR $6C39 |
6C42 | CP $27 | This is the x-coordinate of the wall between the White and Exam Rooms
6C44 | JR NC,$6C4A | Jump if the character is to the right of this
6C46 | CP $25 | This is the x-coordinate of the rightmost chair in the White Room
6C48 | JR $6C39 |
6C4A | CP $44 | This is the x-coordinate of the rightmost chair in the Exam Room
6C4C | JR $6C39 |