Prev: 85DD Up: Map Next: 8654
85E6: Process sprites
Used by the routines at entry, died, stage_completed, stage_completed, perfect_bonus and explode.
process_sprites 85E6 LD HL,sprite_countdown Decrement counter 1
85E9 DEC (HL) ...
85EA LD HL,attack_countdown Decrement counter 2
85ED DEC (HL) ...
85EE LD A,(countdown_to_shoot) Decrement counter stopping at 0
85F1 DEC A ...
85F2 JP M,process_sprites_0 ...
85F5 LD (countdown_to_shoot),A ...
process_sprites_0 85F8 LD HL,other_flags Flags
85FB RES 4,(HL) Reset laser fence flag
85FD LD HL,$7185 Table address sprite_allocation_table+2 (skip ship sprites)
This entry point is used by the routine at return_from_sprite_handler.
process_sprites_1 8600 PUSH HL Save table address
8601 LD DE,sprite_allocation_table Sprite allocation table
8604 XOR A Clear carry
8605 SBC HL,DE HL = offset into table
8607 LD A,(allocated_sprites) Allocated sprites
860A CP L Compare to offset
860B POP HL Restore table address
860C JP Z,all_sprites_processed Jump when we have reached the last allocation
860F PUSH HL Push allocation table address
8610 LD L,(HL) Get sprite data table index
8611 LD H,$00 ...
8613 ADD HL,HL Multiply by 4
8614 ADD HL,HL ...
8615 LD D,H Store in DE
8616 LD E,L ...
8617 ADD HL,HL Multiplied by 8
8618 ADD HL,DE Multiplied by 12
8619 EX DE,HL DE = sprite data table offset
861A LD IX,sprite_data Base sprite data table address
861E ADD IX,DE IX = sprite data table address
8620 LD HL,return_from_sprite_handler Push return address of routine at return_from_sprite_handler
8623 PUSH HL ...
8624 LD A,(IX+$00) Get sprite type
8627 LD (IX+$05),A Copy it to byte 5
862A CP $7F Is it to be deallocated?
862C JP NZ,handle_sprite_type_02 If not, jump to handlers
This entry point is used by the routines at deallocate_enemy, handle_sprite_type_02_0, handle_sprite_types_04_0C and return_enemy_to_map.
deallocate_sprite 862F LD (IX+$00),$FF Set as not allocated
8633 POP HL Pop return address
8634 POP HL Restore allocation table address of sprite to be deallocated
8635 PUSH HL Push it again
8636 LD DE,sprite_allocation_table Sprite allocation table
8639 XOR A Clear carry
863A SBC HL,DE HL = offset into table
863C LD A,(allocated_sprites) Decrement number of allocated sprites
863F DEC A ...
8640 LD (allocated_sprites),A ...
8643 SUB L Allocated sprites - offset = number of allocations after this one
8644 JR Z,process_sprites_2 If it was the last one, there's nothing to do
8646 LD C,A BC = number of allocations to move
8647 LD B,$00 ...
8649 POP DE DE = allocation table address
864A PUSH DE ...
864B LD H,D HL = allocation table address
864C LD L,E ...
864D INC HL HL = allocation table address + 1
864E LDIR Copy allocations after to close hole
process_sprites_2 8650 POP HL Restore allocation table address
8651 JP process_sprites_1 Proceed with next sprite
Prev: 85DD Up: Map Next: 8654