Prev: 87F5 Up: Map Next: 8813
87F6: Find a free object record
Used by the routines at spawn_cloud, spawn_attacker and fire_from.
Looks along B records of 24 bytes from IX for one whose type (+0) is $FF. Gives up at once while the load (object_load) is 7 or more or the ship is dying (death_count not 0).
Input
A How many records to look at
IX The first
Output
F Z set if one was found
IX The free record
DE $0018 when one was found (start_attacker relies on D being 0)
find_free_record 87F6 LD B,A None when the load is 7 or more, or while dying
87F7 LD A,(object_load)
87FA CP $07
87FC JR NC,find_free_record_1
87FE LD A,(death_count)
8801 AND A
8802 JR NZ,find_free_record_1
8804 LD DE,$0018 Find one with type $FF
find_free_record_0 8807 LD A,(IX+$00)
880A INC A
880B RET Z
880C ADD IX,DE
880E DJNZ find_free_record_0
find_free_record_1 8810 OR $01 None: NZ
8812 RET
Prev: 87F5 Up: Map Next: 8813