Prev: A656 Up: Map Next: A6E0
A6AE: Use Energy
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.
Input
DE Energy to use
Output
F The carry flag is set if there was not enough energy
UseEnergy A6AE LD A,($9658) Fetch the number of sectors that have been activated.
A6B1 LD L,A Keep the number of activated sectors.
A6B2 LD A,($9659) Fetch the number of sectors that have been destroyed.
A6B5 ADD A,L Add the number that have been activated...
A6B6 LD ($965A),A ...and store the number of sectors that have been dealt with.
A6B9 CP $09 Jump if some sectors have not been dealt with.
A6BB JR NZ,UseEnergy_Take
A6BD AND A Otherwise clear the carry flag and return, as the energy is free.
A6BE RET
UseEnergy_Take A6BF LD HL,($963A) Fetch the energy of the battery.
A6C2 AND A Subtract the energy that is to be used.
A6C3 SBC HL,DE
A6C5 JR C,UseEnergy_Empty Jump if there is not enough energy.
A6C7 LD ($963A),HL Otherwise store the new energy...
A6CA RET ...and return.
UseEnergy_Empty A6CB LD HL,$0000 The battery is empty.
A6CE LD ($963A),HL Store that.
A6D1 PUSH AF Save the carry flag.
A6D2 LD A,$38 Turn the robot into smoke...
A6D4 LD ($9690),A ...by setting its type to 38.
A6D7 XOR A Clear the controls...
A6D8 LD ($9625),A ...so that nothing is fired.
A6DB CALL ExplodeEnemies Turn all of the enemies into smoke using ExplodeEnemies.
A6DE POP AF Restore the carry flag...
A6DF RET ...and return.
Prev: A656 Up: Map Next: A6E0