Prev: FC9C Up: Map Next: FCDC
FCA5: Find a record whose box overlaps a given box
Used by the routines at CREATURE_UPDATE, PICK_UP and ANIMATE_AND_MOVE.
Walks the records in use from the last down to the first -- the six fixed ones at FIXED_RECORDS, the room's floor, ceiling and four walls, included -- and stops at the first that overlaps the box, the mover's own record and hidden things aside (TEST_ONE_RECORD). Used for a move (ANIMATE_AND_MOVE), for the place a thing would be dropped (CREATURE_UPDATE), and by the pick-up (PICK_UP), which carries on down the list from NEXT_OBSTACLE (PICK_UP_LOOK_ON) until it finds a thing it can take.
On the way it deals out the strike counters. IY+2 starts at $9E and goes down by one at each fighter (bit 7 of +12), but no lower than $98: the first six fighters from the top of the list have the counters at $9D down to $98 in STRIKES_LEFT, and any more share the last. The count depends only on the order of the records, so a fighter has the same counter for as long as the room lasts, and when a fighter is found IY+2 holds the low byte of its counter, for OBJECTS_MEET.
Input
B, D, H x, y and z of the box (y its top)
C, E, L its x length, height and z length
Output
F Carry set if a record was found
IX The record found; FOUND_RECORD its number
FIND_OBSTACLE FCA5 LD IX,(FREE_RECORD) IX = the next free record
FCA9 LD A,(OBJECT_COUNT) FOUND_RECORD counts down from the number of records in use
FCAC LD (IY+FOUND_RECORD-V),A
FCAF LD (IY+STRIKES_AT-V),$9E The strike counters from the top
FCB3 EXX DE' = minus 20; IX = the last record in use
FCB4 LD DE,$FFEC
FCB7 ADD IX,DE
FIND_OBSTACLE_0 FCB9 EXX A fighter?
FCBA BIT 7,(IX+OBJ_KIND)
FCBE JR Z,FIND_OBSTACLE_1
FCC0 DEC (IY+STRIKES_AT-V) The next counter down, the sixth at most
FCC3 LD A,(STRIKES_AT)
FCC6 CP $98
FCC8 JR NC,FIND_OBSTACLE_1
FCCA INC (IY+STRIKES_AT-V)
FIND_OBSTACLE_1 FCCD CALL TEST_ONE_RECORD Overlapping: found
FCD0 RET C
This entry point is used by the routine at PICK_UP_LOOK_ON.
NEXT_OBSTACLE FCD1 EXX NEXT_OBSTACLE: on down the list
FCD2 ADD IX,DE
FCD4 DEC (IY+FOUND_RECORD-V)
FCD7 JR NZ,FIND_OBSTACLE_0
FCD9 AND A None: carry clear
FCDA EXX
FCDB RET
Prev: FC9C Up: Map Next: FCDC