Prev: 34735 Up: Map Next: 34835
34806: Find Free Slot
Used by the routines at SpawnSpecialEnemy, UpdateEnemySpawning and FireShot.
Searches for a free enemy slot (one with type 255) by stepping IX through the slots, which are 24 bytes long. No slot is returned if too many enemies are alive or if the player's ship is exploding.
Input
A Number of slots to search
IX Address of the first slot to try
Output
IX Address of the free slot
F The zero flag is set if a free slot was found
FindFreeSlot 34806 LD B,A Store the number of slots in B.
34807 LD A,(36395) Fetch the number of enemies that are alive from 36395.
34810 CP 7 Jump to FindFreeSlot_None if it is 7 or more.
34812 JR NC,FindFreeSlot_None
34814 LD A,(36691) Fetch the death counter from 36691.
34817 AND A Test it.
34818 JR NZ,FindFreeSlot_None Jump to FindFreeSlot_None if the ship is exploding.
34820 LD DE,24 Set the size of a slot in DE.
FindFreeSlot_Loop 34823 LD A,(IX+0) Fetch the type of the object in the slot.
34826 INC A Increment it.
34827 RET Z Return with the zero flag set if the type was 255.
34828 ADD IX,DE Move on to the next slot.
34830 DJNZ FindFreeSlot_Loop Decrease the slot counter by one and loop back to FindFreeSlot_Loop until none remain.
FindFreeSlot_None 34832 OR %00000001 Clear the zero flag.
34834 RET Return.
Prev: 34735 Up: Map Next: 34835