Prev: AA7D Up: Map Next: AAE3
AAA6: Allocate map entry
Used by the routines at move_towards_center and reset_outcoming_enemies.
Input
A value to place in center_enemy_map at an unused spot
allocate_map_entry AAA6 PUSH HL
AAA7 PUSH DE
AAA8 PUSH BC
AAA9 PUSH AF Save value to write
AAAA LD A,(center_map_entries) Get number of entries
AAAD CP $24 If map is full
AAAF JR Z,allocate_map_entry_5 Then return
AAB1 LD A,(status_flags) If all waves completed flag is set
AAB4 BIT 1,A The search backwards
AAB6 JR NZ,allocate_map_entry_2 Else search forwards
AAB8 LD HL,$722A Start at end of center_enemy_map
AABB LD A,$FF Byte to search for
allocate_map_entry_0 AABD CP (HL) Check byte
AABE JR NZ,allocate_map_entry_1 Break out if not $FF
AAC0 DEC HL Previous address
AAC1 JR allocate_map_entry_0 Loop forever
allocate_map_entry_1 AAC3 INC HL HL now points to group of $FF at the end of buffer
AAC4 JR allocate_map_entry_4 Skip next loop
allocate_map_entry_2 AAC6 LD HL,center_enemy_map Start at beginning of center_enemy_map
AAC9 LD A,$FF Byte to search for
allocate_map_entry_3 AACB CP (HL) Check byte
AACC JR Z,allocate_map_entry_4 Break out if found HL now points to first $FF in buffer
AACE INC HL Next address
AACF JR allocate_map_entry_3 Loop forever
allocate_map_entry_4 AAD1 POP AF Restore value to write
AAD2 LD (HL),A Set byte to A
AAD3 LD HL,center_map_entries Increment number of entries
AAD6 INC (HL) ...
AAD7 LD HL,center_enemies_redraw Set flag
AADA SET 0,(HL) ...
AADC JR allocate_map_entry_6 Skip popping AF
allocate_map_entry_5 AADE POP AF
allocate_map_entry_6 AADF POP BC
AAE0 POP DE
AAE1 POP HL
AAE2 RET
Prev: AA7D Up: Map Next: AAE3