Prev: 42533 Up: Map Next: 42582
42534: 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 16 units.
Input
A Controls that are being pressed
IX Robot
FireWeaponA 42534 RES 4,A Clear the flag that says that the first weapon has been fired...
42536 LD (38437),A ...and store the controls.
42539 LD HL,38560 Point HL at the first of the three entities that are used for shots.
42542 LD DE,16 Each entity is 16 bytes long.
42545 LD B,3 There are three entities to check.
FireWeaponA_Check 42547 LD A,(HL) Fetch the type of the entity.
42548 SUB 88 Return if it is one of the sprites 88 to 91 (the shots never use these types, so this never stops the weapon).
42550 CP 4
42552 RET C
42553 ADD HL,DE Move on to the next entity.
42554 DJNZ FireWeaponA_Check Loop back until all three have been checked.
42556 LD BC,2048 Set the cost of the shot to 2048...
42559 LD (38463),BC ...and store it.
42563 LD HL,38560 Point HL at the first of the entities for shots again.
42566 LD BC,828 Use three entities, and use type 60 for the sprite.
42569 LD A,3 Use the lowest two bits of the type of the robot...
42571 LD (42634),A ...to choose the sprite of the shot (this changes the mask used by the instruction at 42633).
42574 LD A,(38459) Fetch the level of the battery.
42577 CP 16 Return if it is below 16.
42579 RET C
42580 JR FireWeapon_Find Jump to fire the shot.
Prev: 42533 Up: Map Next: 42582