Prev: A007 Up: Map Next: A035
A01A: Within camp bounds
This returns whether the given position is within the indexed area's bounds.
Used by the routine at solitary.
Input
A Index (0..2) into permitted_bounds[] table.
DE Pointer to position (type: tinypos_t).
Output
F Z set if position is within the area specified.
Point HL at permitted_bounds[A]
within_camp_bounds A01A ADD A,A Multiply A by 4
A01B ADD A,A
A01C LD C,A Move it into BC
A01D LD B,$00
A01F LD HL,$9F15 Point HL at permitted_bounds
A022 ADD HL,BC Add
Test position against bounds
A023 LD B,$02 Iterate twice - first checking the X axis, then the Y axis
Start loop
within_camp_bounds_0 A025 LD A,(DE) Fetch a position byte
A026 CP (HL) Is A less than the lower bound?
A027 RET C Return with flags NZ if so (outside area)
A028 INC HL Move to x1, or y1 on second iteration
A029 CP (HL) Is A less than the upper bound?
A02A JR C,within_camp_bounds_1 Jump to the next loop iteration if so (inside area)
A02C OR $01 Otherwise return with flags NZ (outside area)
A02E RET
within_camp_bounds_1 A02F INC DE Advance to second axis for position
A030 INC HL Advance to second axis for bounds
A031 DJNZ within_camp_bounds_0 ...loop
A033 AND B Return with flags Z (within area)
A034 RET
Prev: A007 Up: Map Next: A035