Prev: A2AD Up: Map Next: A320
A2B5: Move Destroyer
The handler for entity types 64 to 67, the enemies that destroy the programs that have been installed. They fly in a straight line until their time runs out. When one of them hits an installed program in a sector that has not been activated, the program is removed and the sector loses a unit of energy.
Input
IX Entity
MoveDestroyer A2B5 CALL NextSpriteNumber Move on to the next sprite using NextSpriteNumber.
A2B8 CALL GetPosition Fetch the position of the enemy.
A2BB LD B,$80 The enemy can take up to 80 steps in this frame.
MoveDestroyer_Step A2BD CALL MoveEntity Take a step using MoveEntity.
A2C0 JR NZ,MoveDestroyer_HitCell Jump if the enemy has hit a cell.
MoveDestroyer_Store A2C2 CALL SetPosition Store the new position of the enemy.
A2C5 DEC (IX+$09) Count down the time that the enemy has left, and draw it using AddEntity if there is any.
A2C8 JP NZ,AddEntity
A2CB LD (IX+$00),$38 Otherwise turn it into smoke by changing its type to 38...
A2CF JP AddEntity ...and draw it.
MoveDestroyer_HitCell A2D2 PUSH HL Save the Y position.
A2D3 LD HL,($962E) Fetch the address of the cell that the enemy hit...
A2D6 LD A,(HL) ...and its type.
A2D7 AND $0F Keep the current type of the cell.
A2D9 CP $02 Jump unless the cell holds an installed program (type 02).
A2DB JR NZ,MoveDestroyer_NotProgram
A2DD PUSH DE Save the X position.
A2DE CALL FindSector Find the sector that the cell is in using FindSector.
A2E1 LD E,D Use the sector number as an index.
A2E2 LD D,$00
A2E4 PUSH HL Save the address of the cell.
A2E5 LD HL,$965B Point HL at SectorFlags.
A2E8 ADD HL,DE Add the index.
A2E9 LD A,(HL) Fetch the flag.
A2EA POP HL Restore the address of the cell.
A2EB POP DE Restore the X position.
A2EC AND A Jump if the sector has been activated, as its programs are safe.
A2ED JR NZ,MoveDestroyer_Safe
A2EF LD A,(HL) Fetch the contents of the cell...
A2F0 AND $F0 ...and keep its initial type in B.
A2F2 LD B,A
A2F3 LD A,(HL) Fetch the contents of the cell again...
A2F4 ADD A,$0D ...and change the current type from 02 to 0F.
A2F6 AND $0F
A2F8 OR B Combine it with the initial type...
A2F9 LD (HL),A ...and store it.
A2FA PUSH DE Save the X position.
A2FB CALL ReduceSectorEnergy Take one unit of energy off the sector using ReduceSectorEnergy.
A2FE POP DE Restore the X position.
A2FF POP HL Restore the Y position.
A300 JR MoveDestroyer_Store Carry on.
MoveDestroyer_NotProgram A302 POP HL Restore the Y position.
A303 CP $04 Jump to turn the enemy into smoke if the cell is type 04.
A305 JR Z,MoveDestroyer_Smoke
A307 CP $05 Jump to turn the enemy into smoke if the cell is type 05.
A309 JR Z,MoveDestroyer_Smoke
A30B CP $0C Jump if the cell is not type 0C, to carry on.
A30D JR NZ,MoveDestroyer_Undo
MoveDestroyer_Smoke A30F LD (IX+$00),$38 Turn the enemy into smoke by changing its type to 38...
A313 JP AddEntity ...and draw it.
MoveDestroyer_Safe A316 POP HL Restore the Y position.
MoveDestroyer_Undo A317 LD DE,($9653) Restore the position that the enemy had before the step...
A31B LD HL,($9655) ...and carry on.
A31E JR MoveDestroyer_Store
Prev: A2AD Up: Map Next: A320