| Routines

26136: Check whether a chair is occupied

Used by the routine at 26175. Returns with the zero flag set if the chair beside the character looking for a seat is already occupied by one of the potential occupants being checked.
Input
B | Number of potential occupants to check
C | Animatory state mask (135 or 143)
D | Number of the first potential occupant to check
H | Number of the character looking for a seat (183-209)
L | 1
26136 | CALL 26145 | Are any of the first B potential occupants sitting here?
26139 | RET Z | Return if so
26140 | LD BC,655 | B=2 (BOY WANDER and ANGELFACE), C=143
26143 | LD D,206 | 206=BOY WANDER
This entry point also is used by the routine at 26175.
26145 | LD E,1 |
26147 | LD A,(DE) | A=x-coordinate of the potential occupant
26148 | CP (HL) | Compare with that of the character looking for a seat
26149 | JR NZ,26171 | Jump ahead to consider the next potential occupant if they don't match
26151 | INC E | E=2
26152 | INC L | L=2
26153 | LD A,(DE) | A=y-coordinate of the potential occupant
26154 | DEC E | E=1
26155 | CP (HL) | Compare with the y-coordinate of the character looking for a seat
26156 | DEC HL | L=1
26157 | JR NZ,26171 | Jump if the potential occupant is not in the same location as the character looking for a seat
26159 | DEC E | E=0
26160 | LD A,(DE) | A=potential occupant's animatory state
26161 | AND C | Discard the character-identifying bits and keep only the 'direction' bit and 'action' bits (C=10001111 for BOY WANDER, ANGELFACE or ERIC, and 10000111 for anybody else)
26162 | CP 4 | Is the potential occupant sitting in the chair here?
26164 | JR NZ,26171 | Jump if not
26166 | LD E,18 | Is there an uninterruptible subcommand routine address in bytes 17 and 18 of the potential occupant's buffer?
26168 | LD A,(DE)
26169 | AND A
26170 | RET Z | Return if not
26171 | INC D | Next potential occupant to test
26172 | DJNZ 26145 | Jump back until done
26174 | RET |