![]() |
Routines |
| Prev: 42582 | Up: Map | Next: 42720 |
|
Used by the routines at FireWeaponB and GetRobotSpeed.
Takes an amount of energy out of the battery. If there is not enough then the battery is empty and the robot is destroyed, along with all of the enemies. The energy is free once every sector has been either activated or destroyed.
|
||||||||||||
| UseEnergy | 42670 | LD A,(38488) | Fetch the number of sectors that have been activated. | |||||||||
| 42673 | LD L,A | Keep the number of activated sectors. | ||||||||||
| 42674 | LD A,(38489) | Fetch the number of sectors that have been destroyed. | ||||||||||
| 42677 | ADD A,L | Add the number that have been activated... | ||||||||||
| 42678 | LD (38490),A | ...and store the number of sectors that have been dealt with. | ||||||||||
| 42681 | CP 9 | Jump if some sectors have not been dealt with. | ||||||||||
| 42683 | JR NZ,UseEnergy_Take | |||||||||||
| 42685 | AND A | Otherwise clear the carry flag and return, as the energy is free. | ||||||||||
| 42686 | RET | |||||||||||
| UseEnergy_Take | 42687 | LD HL,(38458) | Fetch the energy of the battery. | |||||||||
|
See Infinite Energy.
|
||||||||||||
| 42690 | AND A | Subtract the energy that is to be used. | ||||||||||
| 42691 | SBC HL,DE | |||||||||||
| 42693 | JR C,UseEnergy_Empty | Jump if there is not enough energy. | ||||||||||
| 42695 | LD (38458),HL | Otherwise store the new energy... | ||||||||||
| 42698 | RET | ...and return. | ||||||||||
| UseEnergy_Empty | 42699 | LD HL,0 | The battery is empty. | |||||||||
| 42702 | LD (38458),HL | Store that. | ||||||||||
| 42705 | PUSH AF | Save the carry flag. | ||||||||||
| 42706 | LD A,56 | Turn the robot into smoke... | ||||||||||
| 42708 | LD (38544),A | ...by setting its type to 56. | ||||||||||
| 42711 | XOR A | Clear the controls... | ||||||||||
| 42712 | LD (38437),A | ...so that nothing is fired. | ||||||||||
| 42715 | CALL ExplodeEnemies | Turn all of the enemies into smoke using ExplodeEnemies. | ||||||||||
| 42718 | POP AF | Restore the carry flag... | ||||||||||
| 42719 | RET | ...and return. | ||||||||||
| Prev: 42582 | Up: Map | Next: 42720 |