Prev: 9356 Up: Map Next: 93A6
9395: 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 9395 LD HL,$61B0 HL=Alien_Slot_1.
There are a maximum of 6 aliens on screen at a time.
9398 LD B,$06 Set an alien slot counter in B for 06 loops.
939A LD DE,$0018 DE=0018 (the length of each slot).
FindSlotAlien_Loop 939D LD A,(HL) Jump to FindSlotAlien_Return if this slot is unused.
939E AND A
939F JR Z,FindSlotAlien_Return
93A1 ADD HL,DE Move onto the next slot.
93A2 DJNZ FindSlotAlien_Loop Decrease the alien counter by one and loop back to FindSlotAlien_Loop until every slot has been checked.
93A4 AND A Leave the Z flag unset as no free slot was found.
FindSlotAlien_Return 93A5 RET Return.
Prev: 9356 Up: Map Next: 93A6