Prev: 979B Up: Map Next: 97AE
979F: Find Free Entity
Used by the routines at CreatePickup, UpdateSpawnPoints and UpdateSaucerEntity.
Looks for an unused entity (one with the type 00) in a run of entities.
Input
IX The first entity
B The number of entities to look at
Output
IX The unused entity, if one was found
F Zero flag set if an unused entity was found
FindFreeEntity 979F LD DE,$0026 DE is 26 the size of an entity.
FindFreeEntity_Loop 97A2 LD A,(IX+$00) Fetch the type of the entity.
97A5 AND A Test it.
97A6 RET Z Return with the zero flag set if the entity is unused.
97A7 ADD IX,DE Move onto the next entity.
97A9 DJNZ FindFreeEntity_Loop Decrease the entity counter by one and jump back to FindFreeEntity_Loop until all of the entities have been looked at.
97AB OR %00000001 Reset the zero flag, as no unused entity was found.
97AD RET Return.
Prev: 979B Up: Map Next: 97AE