![]() |
Routines |
| Prev: D389 | Up: Map | Next: D3EB |
|
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 24 and 25.
|
||||||||
|
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 24 and 48 in field 25.
|
||||||||
| FindPathAtPosition | D3A9 | LD HL,($5CFE) | The path list sits just before the level header. | |||||
| D3AC | DEC HL | |||||||
| D3AD | DEC HL | |||||||
| D3AE | DEC HL | |||||||
| D3AF | LD C,$41 | The first index is 41. | ||||||
| FindPathAtPosition_Loop | D3B1 | PUSH HL | Remember this point in the list. | |||||
| D3B2 | LD E,(HL) | Read the pointer to the entry's position. | ||||||
| D3B3 | INC HL | |||||||
| D3B4 | LD D,(HL) | |||||||
| D3B5 | PUSH DE | Use that position. | ||||||
| D3B6 | POP IY | |||||||
| D3B8 | LD A,(IX+$02) | The high byte of x has to match. | ||||||
| D3BB | CP (IY+$00) | |||||||
| D3BE | JR NZ,FindPathAtPosition_Next | |||||||
| D3C0 | LD A,(IX+$03) | Read the low byte of x. | ||||||
| D3C3 | AND %11110000 | Use its high nibble. | ||||||
| D3C5 | CP (IY+$01) | That nibble has to match the entry. | ||||||
| D3C8 | JR NZ,FindPathAtPosition_Next | |||||||
| D3CA | LD A,(IX+$05) | The high byte of y has to match. | ||||||
| D3CD | CP (IY+$02) | |||||||
| D3D0 | JR NZ,FindPathAtPosition_Next | |||||||
| D3D2 | LD A,(IX+$06) | Read the low byte of y. | ||||||
| D3D5 | AND %11110000 | Use its high nibble. | ||||||
| D3D7 | CP (IY+$03) | That nibble has to match the entry. | ||||||
| D3DA | JR NZ,FindPathAtPosition_Next | |||||||
| D3DC | LD (IX+$24),C | The index becomes field 24. | ||||||
| D3DF | LD (IX+$25),$48 | Field 25 becomes 48. | ||||||
| D3E3 | POP HL | Restore the list and return. | ||||||
| D3E4 | RET | |||||||
| FindPathAtPosition_Next | D3E5 | POP HL | Step back to the previous entry and take the next index. | |||||
| D3E6 | DEC HL | |||||||
| D3E7 | DEC HL | |||||||
| D3E8 | INC C | |||||||
| D3E9 | JR FindPathAtPosition_Loop | Try that entry. | ||||||
| Prev: D389 | Up: Map | Next: D3EB |