Prev: 54153 Up: Map Next: 54251
54185: Find Path At Position
Used by the routine at TestGroupObjects.
Looks through the entries of the level data, which are found just before the level header at LevelHeaderAddress, for one whose position matches the position of the entity. If one is found the entity is set to follow it by setting fields 36 and 37.
Input
IX The entity
The list is walked backwards from just before the level header. Each entry is a pointer to four position bytes. A match stores the index in field 36 and 72 in field 37.
FindPathAtPosition 54185 LD HL,(23806) The path list sits just before the level header.
54188 DEC HL
54189 DEC HL
54190 DEC HL
54191 LD C,65 The first index is 65.
FindPathAtPosition_Loop 54193 PUSH HL Remember this point in the list.
54194 LD E,(HL) Read the pointer to the entry's position.
54195 INC HL
54196 LD D,(HL)
54197 PUSH DE Use that position.
54198 POP IY
54200 LD A,(IX+2) The high byte of x has to match.
54203 CP (IY+0)
54206 JR NZ,FindPathAtPosition_Next
54208 LD A,(IX+3) Read the low byte of x.
54211 AND %11110000 Use its high nibble.
54213 CP (IY+1) That nibble has to match the entry.
54216 JR NZ,FindPathAtPosition_Next
54218 LD A,(IX+5) The high byte of y has to match.
54221 CP (IY+2)
54224 JR NZ,FindPathAtPosition_Next
54226 LD A,(IX+6) Read the low byte of y.
54229 AND %11110000 Use its high nibble.
54231 CP (IY+3) That nibble has to match the entry.
54234 JR NZ,FindPathAtPosition_Next
54236 LD (IX+36),C The index becomes field 36.
54239 LD (IX+37),72 Field 37 becomes 72.
54243 POP HL Restore the list and return.
54244 RET
FindPathAtPosition_Next 54245 POP HL Step back to the previous entry and take the next index.
54246 DEC HL
54247 DEC HL
54248 INC C
54249 JR FindPathAtPosition_Loop Try that entry.
Prev: 54153 Up: Map Next: 54251