Prev: C9E0 Up: Map Next: CA30
C9EC: Fire Revolver
Used by the routines at HandleCrosshair and HandleSheriff.
Fires the revolver if the fire control is pressed, BulletsLoaded is not zero, and neither ReloadingFlag nor FireHeldFlag is set. It calls MakeShot, takes one from BulletsLoaded, and colours the chamber unless there were six. FireTimer and FireHeldFlag are then set.
Input
E The controls
IX The address of the object which fires
Return unless a new shot can be made.
FireRevolver C9EC LD A,($A244) Jump to FireRevolver_Held if FireHeldFlag is set.
C9EF AND A
C9F0 JR NZ,FireRevolver_Held
C9F2 BIT 3,E Return if the fire control is not pressed.
C9F4 RET Z
C9F5 LD A,($A246) Return if ReloadingFlag is set.
C9F8 AND A
C9F9 RET NZ
C9FA LD A,($A262) Return if BulletsLoaded is zero.
C9FD AND A
C9FE RET Z
Make the shot and take a bullet.
C9FF CALL MakeShot Call MakeShot.
CA02 RET NC Return if no shot was made.
CA03 LD A,($A262) Take one from BulletsLoaded.
CA06 DEC A
CA07 LD ($A262),A
CA0A INC A Make it the number there were.
CA0B CP $06 Jump to FireRevolver_Fired if there were six.
CA0D JR Z,FireRevolver_Fired
Colour the chamber for the number there were.
CA0F LD BC,$C9E0 Point BC at ChamberAddresses.
CA12 CALL GetTableEntry Call GetTableEntry.
CA15 CALL AddTownOffsetToHL Call AddTownOffsetToHL.
CA18 LD A,$41 Call FillChamber with BLUE (BRIGHT).
CA1A CALL FillChamber
Start the firing pose and hold the fire control.
FireRevolver_Fired CA1D LD A,$05 Set FireTimer to 05.
CA1F LD ($A245),A
CA22 LD A,$01 Set FireHeldFlag to 01 and return.
CA24 LD ($A244),A
CA27 RET
Clear FireHeldFlag when the fire control is released.
FireRevolver_Held CA28 BIT 3,E Return if the fire control is still pressed.
CA2A RET NZ
CA2B XOR A Clear FireHeldFlag and return.
CA2C LD ($A244),A
CA2F RET
Prev: C9E0 Up: Map Next: CA30