| Routines

29578: Check whether Sam or a gangster is inside a region

Used by the routines at 29597 and 31362. On entry, HL points at the first or second entry in a table of region definitions (at 64780, 64806, 64836, 64868 or 64892) used by a gangster who is on the lookout for Sam. On exit, the carry flag is set if Sam or the gangster is outside the region.
Input
D | Gangster's character number (215-224), or 230 (Sam)
HL | Address of a region definition
29578 | LD E,1 | A=Sam's or the gangster's x-coordinate
29580 | LD A,(DE)
29581 | CP (HL) | Is Sam or the gangster to the left of the region?
29582 | RET C | Return with the carry flag set if so
29583 | INC HL | Point HL at the upper x-coordinate
29584 | CP (HL) | Is Sam or the gangster to the right of the region?
29585 | CCF | Return with the carry flag set if so
29586 | RET C
29587 | INC HL | Point HL at the lower y-coordinate
29588 | INC E | A=Sam's or the gangster's y-coordinate
29589 | LD A,(DE)
29590 | CP (HL) | Is Sam or the gangster above the region?
29591 | RET C | Return with the carry flag set if so
29592 | INC HL | Point HL at the upper y-coordinate
29593 | CP (HL) | Compare it with Sam's or the gangster's y-coordinate
29594 | INC HL | Point HL at either the disguise ID, or the first byte of the second entry in the table of region definitions
29595 | CCF | Set the carry flag if Sam or the gangster is below the region
29596 | RET |