Prev: 38692 Up: Map Next: 38879
38845: Find Free Enemy Slot
Used by the routine at StartCrystalObject.
Looks for a free slot among the nine enemy slots. If there is not one, it looks for an object with bit 7 of its flags set among the first eight.
Output
IX Address of the slot
FindFreeEnemySlot 38845 LD B,9 Set a counter for nine slots.
38847 LD IX,39284 Use the first enemy slot.
38851 LD DE,24 Set the length of a slot.
FindFreeEnemySlot_Loop 38854 LD A,(IX+0) Fetch the type of the object in the slot.
38857 INC A Increment it.
38858 RET Z Return if the slot is free.
38859 ADD IX,DE Move on to the next slot.
38861 DJNZ FindFreeEnemySlot_Loop Decrease the counter by one and loop back to FindFreeEnemySlot_Loop until none remain.
38863 LD IX,39284 Use the first enemy slot.
38867 LD B,8 Set a counter for eight slots.
FindFreeEnemySlot_Flags 38869 BIT 7,(IX+16) Test bit 7 of the flags of the object.
38873 RET Z Return if it is clear.
38874 ADD IX,DE Move on to the next slot.
38876 DJNZ FindFreeEnemySlot_Flags Decrease the counter by one and loop back to FindFreeEnemySlot_Flags until none remain.
38878 RET Return.
Prev: 38692 Up: Map Next: 38879