Prev: 9724 Up: Map Next: 97DF
97BD: 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 97BD LD B,$09 Set a counter for nine slots.
97BF LD IX,$9974 Use the first enemy slot.
97C3 LD DE,$0018 Set the length of a slot.
FindFreeEnemySlot_Loop 97C6 LD A,(IX+$00) Fetch the type of the object in the slot.
97C9 INC A Increment it.
97CA RET Z Return if the slot is free.
97CB ADD IX,DE Move on to the next slot.
97CD DJNZ FindFreeEnemySlot_Loop Decrease the counter by one and loop back to FindFreeEnemySlot_Loop until none remain.
97CF LD IX,$9974 Use the first enemy slot.
97D3 LD B,$08 Set a counter for eight slots.
FindFreeEnemySlot_Flags 97D5 BIT 7,(IX+$10) Test bit 7 of the flags of the object.
97D9 RET Z Return if it is clear.
97DA ADD IX,DE Move on to the next slot.
97DC DJNZ FindFreeEnemySlot_Flags Decrease the counter by one and loop back to FindFreeEnemySlot_Flags until none remain.
97DE RET Return.
Prev: 9724 Up: Map Next: 97DF