Prev: 7058 Up: Map Next: 70A9
7083: Check whether a character is on a roof with edges on each side
Used by the routine at ED8C. 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 ED36)
H Character number (0xD7-0xE6)
L 0x0C
7083 CP $FC Is the character on the roof of the apartment building next to no. 19?
7085 JR Z,$708B Jump if so
7087 CP $6C Is the character on the roof of the police station?
7089 JR NZ,$7090 Jump if not
708B INC A A=0x6D (police station) or 0xFD (apartment building next to no. 19)
708C 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?
708D JR Z,$7095 Jump if so
708F DEC A A=0x6C or 0xFC
7090 AND $0F Keep only bits 0-3 of the location identifier
7092 CP $02 Set the zero flag if the character is standing outside the entrance to a shop or other building
7094 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.
7095 POP BC Drop the return address from the stack
7096 LD L,$0A Point HL at byte 0x0A of the character's buffer
7098 LD A,(HL) A=character's destination x-coordinate
7099 LD L,$01 Compare this with the character's current x-coordinate
709B CP (HL)
709C DEC HL Point HL at byte 0x00 of the character's buffer
709D BIT 7,(HL) Set the zero flag if the character is facing left
709F LD A,$03 A=3 (go up)
70A1 JR C,$70A6 Jump if the character is to the right of his destination
70A3 RET NZ Return to the caller of ED8C with A=3 (go up) if the character is to the left of his destination and facing right
70A4 LD A,$01 A=1 (go right)
70A6 RET Z Return to the caller of ED8C 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
70A7 DEC A Return to the caller of ED8C with A=2 (go left) if the character is to the right of his destination and facing right
70A8 RET
Prev: 7058 Up: Map Next: 70A9