Prev: A625 Up: Map Next: A656
A626: Fire Weapon A
Used by the routine at MoveRobotHorizontally.
Fires a spark, which is the first weapon of the robot. It costs eight units of energy and needs the battery to have at least 10 units.
Input
A Controls that are being pressed
IX Robot
FireWeaponA A626 RES 4,A Clear the flag that says that the first weapon has been fired...
A628 LD ($9625),A ...and store the controls.
A62B LD HL,$96A0 Point HL at the first of the three entities that are used for shots.
A62E LD DE,$0010 Each entity is 10 bytes long.
A631 LD B,$03 There are three entities to check.
FireWeaponA_Check A633 LD A,(HL) Fetch the type of the entity.
A634 SUB $58 Return if it is one of the sprites 58 to 5B (the shots never use these types, so this never stops the weapon).
A636 CP $04
A638 RET C
A639 ADD HL,DE Move on to the next entity.
A63A DJNZ FireWeaponA_Check Loop back until all three have been checked.
A63C LD BC,$0800 Set the cost of the shot to 0800...
A63F LD ($963F),BC ...and store it.
A643 LD HL,$96A0 Point HL at the first of the entities for shots again.
A646 LD BC,$033C Use three entities, and use type 3C for the sprite.
A649 LD A,$03 Use the lowest two bits of the type of the robot...
A64B LD ($A68A),A ...to choose the sprite of the shot (this changes the mask used by the instruction at A689).
A64E LD A,($963B) Fetch the level of the battery.
A651 CP $10 Return if it is below 10.
A653 RET C
A654 JR FireWeapon_Find Jump to fire the shot.
Prev: A625 Up: Map Next: A656