Prev: 27450 Up: Map Next: 27557
27504: Fire Weapon
Used by the routine at Robbie_CarryingCan.
Fires a weapon from Robbie's spray can into an empty weapon slot, but only on every eighth frame. The colour in State_Robbie_Colour decides which weapon it is: 66 fires a streamer, 70 fires the repellent spray and anything else fires a smoke bomb.
FireWeapon 27504 LD A,(23672) A=FRAMES.
27507 AND %00000111 Keep only bits 0-2.
27509 RET NZ Return if the frame is not a multiple of eight.
27510 LD HL,24188 HL=State_Weapon_1 (the first weapon object).
27513 LD DE,8 DE=8 (the size of an object).
27516 LD B,2 Set the weapon counter to 2.
FireWeapon_Loop 27518 LD A,(HL) Jump to FireWeapon_Slot if the weapon slot is empty.
27519 AND A
27520 JR Z,FireWeapon_Slot
27522 ADD HL,DE Move onto the next weapon object.
27523 DJNZ FireWeapon_Loop Decrease the weapon counter by one and loop back to FireWeapon_Loop until both weapon slots have been checked.
27525 RET Return.
FireWeapon_Slot 27526 LD (24092),HL Write the weapon slot to FreeWeaponSlot.
27529 LD DE,24175 DE=State_Robbie_Colour (the colour of Robbie).
27532 LD A,(DE) A=the colour of Robbie (which tells us which weapon he has).
27533 CP 66 Jump to FireStreamer to fire a streamer if it matches.
27535 JP Z,FireStreamer
27538 CP 70 Jump to FireRepellentSpray to fire the repellent spray if it matches.
27540 JP Z,FireRepellentSpray
Fire a smoke bomb.
27543 CALL GetRobbieDirection Get the X position and the direction using GetRobbieDirection.
27546 JR Z,FireSmokeBomb_Right Jump to FireSmokeBomb_Right if the smoke bomb goes to the right.
27548 CP 48 Return if Robbie is too close to the left edge.
27550 RET C
27551 SUB 12 Subtract 12 from the X position (so it starts to the left of Robbie).
27553 LD (HL),68 Write 68 (a smoke bomb moving left) to the state of the weapon.
This entry point is used by the routine at FireSmokeBomb_Right.
FireWeapon_SmokeColour 27555 LD B,71 B=71 (the colour of the smoke bomb).
Prev: 27450 Up: Map Next: 27557