Prev: 38811 Up: Map Next: 38830
38815: Find Free Entity
Used by the routines at CreatePickup, UpdateSpawnPoints and UpdateSaucerEntity.
Looks for an unused entity (one with the type 0) 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 38815 LD DE,38 DE is 38 the size of an entity.
FindFreeEntity_Loop 38818 LD A,(IX+0) Fetch the type of the entity.
38821 AND A Test it.
38822 RET Z Return with the zero flag set if the entity is unused.
38823 ADD IX,DE Move onto the next entity.
38825 DJNZ FindFreeEntity_Loop Decrease the entity counter by one and jump back to FindFreeEntity_Loop until all of the entities have been looked at.
38827 OR %00000001 Reset the zero flag, as no unused entity was found.
38829 RET Return.
Prev: 38811 Up: Map Next: 38830