Prev: 6B3A Up: Map Next: 6BA5
6B70: 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: 42 fires a streamer, 46 fires the repellent spray and anything else fires a smoke bomb.
FireWeapon 6B70 LD A,($5C78) A=FRAMES.
6B73 AND %00000111 Keep only bits 0-2.
6B75 RET NZ Return if the frame is not a multiple of eight.
6B76 LD HL,$5E7C HL=State_Weapon_1 (the first weapon object).
6B79 LD DE,$0008 DE=08 (the size of an object).
6B7C LD B,$02 Set the weapon counter to 02.
FireWeapon_Loop 6B7E LD A,(HL) Jump to FireWeapon_Slot if the weapon slot is empty.
6B7F AND A
6B80 JR Z,FireWeapon_Slot
6B82 ADD HL,DE Move onto the next weapon object.
6B83 DJNZ FireWeapon_Loop Decrease the weapon counter by one and loop back to FireWeapon_Loop until both weapon slots have been checked.
6B85 RET Return.
FireWeapon_Slot 6B86 LD ($5E1C),HL Write the weapon slot to FreeWeaponSlot.
6B89 LD DE,$5E6F DE=State_Robbie_Colour (the colour of Robbie).
6B8C LD A,(DE) A=the colour of Robbie (which tells us which weapon he has).
6B8D CP $42 Jump to FireStreamer to fire a streamer if it matches.
6B8F JP Z,FireStreamer
6B92 CP $46 Jump to FireRepellentSpray to fire the repellent spray if it matches.
6B94 JP Z,FireRepellentSpray
Fire a smoke bomb.
6B97 CALL GetRobbieDirection Get the X position and the direction using GetRobbieDirection.
6B9A JR Z,FireSmokeBomb_Right Jump to FireSmokeBomb_Right if the smoke bomb goes to the right.
6B9C CP $30 Return if Robbie is too close to the left edge.
6B9E RET C
6B9F SUB $0C Subtract 0C from the X position (so it starts to the left of Robbie).
6BA1 LD (HL),$44 Write 44 (a smoke bomb moving left) to the state of the weapon.
This entry point is used by the routine at FireSmokeBomb_Right.
FireWeapon_SmokeColour 6BA3 LD B,$47 B=47 (the colour of the smoke bomb).
Prev: 6B3A Up: Map Next: 6BA5