Prev: 37718 Up: Map Next: 37798
37781: Find Unused Alien Slot
Scan the six alien slots at Alien_Slot_1 and return the first unused one.
Output
F Z: slot available
F NZ: no available slots
HL The alien slot address
Scan the six alien slots and return the first free one.
FindSlotAlien 37781 LD HL,25008 HL=Alien_Slot_1.
There are a maximum of 6 aliens on screen at a time.
37784 LD B,6 Set an alien slot counter in B for 6 loops.
37786 LD DE,24 DE=0024 (the length of each slot).
FindSlotAlien_Loop 37789 LD A,(HL) Jump to FindSlotAlien_Return if this slot is unused.
37790 AND A
37791 JR Z,FindSlotAlien_Return
37793 ADD HL,DE Move onto the next slot.
37794 DJNZ FindSlotAlien_Loop Decrease the alien counter by one and loop back to FindSlotAlien_Loop until every slot has been checked.
37796 AND A Leave the Z flag unset as no free slot was found.
FindSlotAlien_Return 37797 RET Return.
Prev: 37718 Up: Map Next: 37798