![]() |
Routines |
| Prev: 98AE | Up: Map | Next: 990C |
|
Used by the routines at CreateShot, UpdatePickupEntity, UpdateFoamEntity, UpdateWhirlerEntity, UpdateBatEntity and UpdateSaucerEntity.
Chooses the direction in which an entity should head to move towards the player. If the direction (bits 4 and 5 of field 20 of the entity) is already the right one it is left alone, otherwise the new direction is set along with a random value in bits 1-3.
|
||||||||
| FacePlayer | 98D3 | LD B,$00 | Clear the direction bits in B. | |||||
| 98D5 | LD A,($B542) | Fetch the first byte of the first coordinate of the player from B542. | ||||||
| 98D8 | SUB (IX+$02) | Subtract the first byte of the first coordinate of the entity. | ||||||
| 98DB | JR NZ,FacePlayer_FirstDone | Jump to FacePlayer_FirstDone if they are different. | ||||||
| 98DD | LD A,($B543) | Fetch the second byte of the first coordinate of the player from B543. | ||||||
| 98E0 | SUB (IX+$03) | Subtract the second byte of the first coordinate of the entity. | ||||||
| FacePlayer_FirstDone | 98E3 | JR NC,FacePlayer_Second | Jump to FacePlayer_Second if the player is not before the entity on the first coordinate. | |||||
| 98E5 | LD B,$10 | Set bit 4 of the direction. | ||||||
| FacePlayer_Second | 98E7 | LD A,($B545) | Fetch the first byte of the second coordinate of the player from B545. | |||||
| 98EA | SUB (IX+$05) | Subtract the first byte of the second coordinate of the entity. | ||||||
| 98ED | JR NZ,FacePlayer_SecondDone | Jump to FacePlayer_SecondDone if they are different. | ||||||
| 98EF | LD A,($B546) | Fetch the second byte of the second coordinate of the player from B546. | ||||||
| 98F2 | SUB (IX+$06) | Subtract the second byte of the second coordinate of the entity. | ||||||
| FacePlayer_SecondDone | 98F5 | LD A,B | Fetch the direction. | |||||
| 98F6 | JR NC,FacePlayer_Compare | Jump to FacePlayer_Compare if the player is not before the entity on the second coordinate. | ||||||
| 98F8 | XOR %00110000 | Flip bits 4 and 5 of the direction. | ||||||
| FacePlayer_Compare | 98FA | LD B,A | Keep the direction in B. | |||||
| 98FB | LD A,(IX+$20) | Read field 20 of the entity. | ||||||
| 98FE | AND %00110000 | Use bits 4 and 5. | ||||||
| 9900 | XOR B | Compare them with the new direction. | ||||||
| 9901 | RET Z | Return if the entity is already heading that way. | ||||||
| 9902 | LD A,($5F9A) | Fetch the low byte of the random seed from RandomNumber_Seed. | ||||||
| 9905 | AND %00001110 | Use bits 1-3. | ||||||
| 9907 | OR B | Add the new direction. | ||||||
| 9908 | LD (IX+$20),A | Store it in field 20 of the entity. | ||||||
| 990B | RET | Return. | ||||||
| Prev: 98AE | Up: Map | Next: 990C |