Prev: AAE3 Up: Map Next: AB38
AAF1: Create enemy sprite from map entry
Search for value >= $80 in map and deallocate if found. Then allocate a sprite with data from map. Used by the routine at main_loop.
create_sprite_from_map_entry AAF1 LD A,(status_flags) Is all waves completed flag set?
AAF4 BIT 1,A ...
AAF6 RET Z Return if not
AAF7 BIT 2,A Is died flag set?
AAF9 RET NZ Return if so
AAFA CALL stage_data_addr Get stage data address in IY
AAFD LD A,(active_enemies) Get number of active enemies
AB00 CP (IY+$04) Compare with byte 4 of stage data
AB03 RET NC Return if active enemies >= byte 4
AB04 LD A,(center_map_entries) Get number of map entries
AB07 OR A Return if zero
AB08 RET Z ...
AB09 LD HL,$722A End of center_enemy_map
AB0C LD B,$24 Size of map
AB0E LD A,$80 Value to compare with
create_sprite_from_map_entry_0 AB10 CP (HL) Test map byte
AB11 JR NC,create_sprite_from_map_entry_1 If map byte <= $80 then found
AB13 DEC HL Previous byte
AB14 DJNZ create_sprite_from_map_entry_0 Loop through whole map
AB16 RET Not found - return
Create sprite
create_sprite_from_map_entry_1 AB17 LD A,(HL) Get value from map
AB18 PUSH AF Save it
AB19 CALL deallocate_map_entry Deallocate map entry
AB1C CALL polar_coord_from_map Now DE contains polar y,x
AB1F RST $28 Allocate sprite
AB20 LD (IX+$02),E Set polar x
AB23 LD (IX+$01),D Set polar x
AB26 LD (IX+$00),$10 Set sprite type
AB2A POP AF Restore value from map
AB2B LD (IX+$0B),A Use it as color (maybe temporary since it's >= $80?)
AB2E SET 0,(IX+$07) Set flag
AB32 RST $30 Load sprite pattern
AB33 LD HL,active_enemies Increment number of active enemies
AB36 INC (HL) ...
AB37 RET
Prev: AAE3 Up: Map Next: AB38