![]() |
Routines |
| Prev: 41645 | Up: Map | Next: 41760 |
|
The handler for entity types 100 to 103, 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.
|
||||||||
| MoveDestroyer | 41653 | CALL NextSpriteNumber | Move on to the next sprite using NextSpriteNumber. | |||||
| 41656 | CALL GetPosition | Fetch the position of the enemy. | ||||||
| 41659 | LD B,128 | The enemy can take up to 128 steps in this frame. | ||||||
| MoveDestroyer_Step | 41661 | CALL MoveEntity | Take a step using MoveEntity. | |||||
| 41664 | JR NZ,MoveDestroyer_HitCell | Jump if the enemy has hit a cell. | ||||||
| MoveDestroyer_Store | 41666 | CALL SetPosition | Store the new position of the enemy. | |||||
| 41669 | DEC (IX+9) | Count down the time that the enemy has left, and draw it using AddEntity if there is any. | ||||||
| 41672 | JP NZ,AddEntity | |||||||
| 41675 | LD (IX+0),56 | Otherwise turn it into smoke by changing its type to 56... | ||||||
| 41679 | JP AddEntity | ...and draw it. | ||||||
| MoveDestroyer_HitCell | 41682 | PUSH HL | Save the Y position. | |||||
| 41683 | LD HL,(38446) | Fetch the address of the cell that the enemy hit... | ||||||
| 41686 | LD A,(HL) | ...and its type. | ||||||
| 41687 | AND 15 | Keep the current type of the cell. | ||||||
| 41689 | CP 2 | Jump unless the cell holds an installed program (type 2). | ||||||
| 41691 | JR NZ,MoveDestroyer_NotProgram | |||||||
| 41693 | PUSH DE | Save the X position. | ||||||
| 41694 | CALL FindSector | Find the sector that the cell is in using FindSector. | ||||||
| 41697 | LD E,D | Use the sector number as an index. | ||||||
| 41698 | LD D,0 | |||||||
| 41700 | PUSH HL | Save the address of the cell. | ||||||
| 41701 | LD HL,38491 | Point HL at SectorFlags. | ||||||
| 41704 | ADD HL,DE | Add the index. | ||||||
| 41705 | LD A,(HL) | Fetch the flag. | ||||||
| 41706 | POP HL | Restore the address of the cell. | ||||||
| 41707 | POP DE | Restore the X position. | ||||||
| 41708 | AND A | Jump if the sector has been activated, as its programs are safe. | ||||||
| 41709 | JR NZ,MoveDestroyer_Safe | |||||||
| 41711 | LD A,(HL) | Fetch the contents of the cell... | ||||||
| 41712 | AND 240 | ...and keep its initial type in B. | ||||||
| 41714 | LD B,A | |||||||
| 41715 | LD A,(HL) | Fetch the contents of the cell again... | ||||||
| 41716 | ADD A,13 | ...and change the current type from 2 to 15. | ||||||
| 41718 | AND 15 | |||||||
| 41720 | OR B | Combine it with the initial type... | ||||||
| 41721 | LD (HL),A | ...and store it. | ||||||
| 41722 | PUSH DE | Save the X position. | ||||||
| 41723 | CALL ReduceSectorEnergy | Take one unit of energy off the sector using ReduceSectorEnergy. | ||||||
| 41726 | POP DE | Restore the X position. | ||||||
| 41727 | POP HL | Restore the Y position. | ||||||
| 41728 | JR MoveDestroyer_Store | Carry on. | ||||||
| MoveDestroyer_NotProgram | 41730 | POP HL | Restore the Y position. | |||||
| 41731 | CP 4 | Jump to turn the enemy into smoke if the cell is type 4. | ||||||
| 41733 | JR Z,MoveDestroyer_Smoke | |||||||
| 41735 | CP 5 | Jump to turn the enemy into smoke if the cell is type 5. | ||||||
| 41737 | JR Z,MoveDestroyer_Smoke | |||||||
| 41739 | CP 12 | Jump if the cell is not type 12, to carry on. | ||||||
| 41741 | JR NZ,MoveDestroyer_Undo | |||||||
| MoveDestroyer_Smoke | 41743 | LD (IX+0),56 | Turn the enemy into smoke by changing its type to 56... | |||||
| 41747 | JP AddEntity | ...and draw it. | ||||||
| MoveDestroyer_Safe | 41750 | POP HL | Restore the Y position. | |||||
| MoveDestroyer_Undo | 41751 | LD DE,(38483) | Restore the position that the enemy had before the step... | |||||
| 41755 | LD HL,(38485) | ...and carry on. | ||||||
| 41758 | JR MoveDestroyer_Store | |||||||
| Prev: 41645 | Up: Map | Next: 41760 |