Prev: 28760 Up: Map Next: 28841
28803: Check whether a character is on a roof with edges on each side
Used by the routine at 60812. Returns to the caller of that routine with A holding 1 (go right), 2 (go left) or 3 (go up) if the character is on the roof of the police station or the apartment building next to no. 19 and is heading for the edge of that roof. Otherwise returns with the zero flag set if the character is standing outside the entrance to a shop or other building.
Input
A Identifier for the character's current location (see 60726)
H Character number (215-230)
L 12
28803 CP 252 Is the character on the roof of the apartment building next to no. 19?
28805 JR Z,28811 Jump if so
28807 CP 108 Is the character on the roof of the police station?
28809 JR NZ,28816 Jump if not
28811 INC A A=109 (police station) or 253 (apartment building next to no. 19)
28812 CP (HL) Is the character's destination on the edge of the roof of either the police station or the apartment building next to no. 19?
28813 JR Z,28821 Jump if so
28815 DEC A A=108 or 252
28816 AND 15 Keep only bits 0-3 of the location identifier
28818 CP 2 Set the zero flag if the character is standing outside the entrance to a shop or other building
28820 RET
The character is on the roof of the apartment building next to no. 19 or on the roof of the police station, and his destination is on the edge of that roof.
28821 POP BC Drop the return address from the stack
28822 LD L,10 Point HL at byte 10 of the character's buffer
28824 LD A,(HL) A=character's destination x-coordinate
28825 LD L,1 Compare this with the character's current x-coordinate
28827 CP (HL)
28828 DEC HL Point HL at byte 0 of the character's buffer
28829 BIT 7,(HL) Set the zero flag if the character is facing left
28831 LD A,3 A=3 (go up)
28833 JR C,28838 Jump if the character is to the right of his destination
28835 RET NZ Return to the caller of 60812 with A=3 (go up) if the character is to the left of his destination and facing right
28836 LD A,1 A=1 (go right)
28838 RET Z Return to the caller of 60812 with A=1 (go right) if the character is to the left of his destination and facing left, or with A=3 (go up) if the character is to the right of his destination and facing left
28839 DEC A Return to the caller of 60812 with A=2 (go left) if the character is to the right of his destination and facing right
28840 RET
Prev: 28760 Up: Map Next: 28841