Prev: 51559 Up: Map Next: 51663
51575: Reload Revolver
Used by the routines at HandleCrosshair and HandleSheriff.
Loads one bullet on every even frame while FireTimer is zero and BulletUnpaidFlag is clear. Reloading starts when BulletsLoaded is empty and ReloadingFlag is then set until the cylinder holds six. Each bullet takes BulletPrice from Bounty. If the bounty cannot pay, BulletUnpaidFlag is set.
Return unless it is time to load a bullet.
ReloadRevolver 51575 LD A,(41577) Return if BulletUnpaidFlag is set.
51578 AND A
51579 RET NZ
51580 LD A,(41494) Fetch FrameCounter.
51583 AND %00000001 Keep the lowest bit.
51585 RET NZ Return if this is an odd frame.
51586 LD A,(41541) Return if FireTimer is set.
51589 AND A
51590 RET NZ
Start reloading if the cylinder is empty.
51591 LD HL,41542 Point HL at ReloadingFlag.
51594 LD A,(HL) Fetch ReloadingFlag and test it.
51595 AND A
51596 LD A,(41570) Fetch BulletsLoaded.
51599 JR NZ,ReloadRevolver_Bullet Jump to ReloadRevolver_Bullet if ReloadingFlag is set.
51601 AND A Return if BulletsLoaded is not zero.
51602 RET NZ
51603 LD (HL),1 Set ReloadingFlag to 1.
Take the price and add a bullet.
ReloadRevolver_Bullet 51605 LD BC,(41566) Fetch BulletPrice.
51609 CALL SubtractFromBounty Call SubtractFromBounty.
51612 JR C,ReloadRevolver_TooPoor Jump to ReloadRevolver_TooPoor if there is not enough.
51614 LD A,(41570) Add one to BulletsLoaded.
51617 INC A
51618 LD (41570),A
51621 CP 6 Jump to ReloadRevolver_Show if it is not six.
51623 JR NZ,ReloadRevolver_Show
51625 LD HL,41542 Clear ReloadingFlag.
51628 LD (HL),0
Colour the chamber and draw the bounty.
ReloadRevolver_Show 51630 DEC A Make it the chamber number.
51631 LD BC,51680 Point BC at ChamberAddresses.
51634 CALL GetTableEntry Call GetTableEntry.
51637 CALL AddTownOffsetToHL Call AddTownOffsetToHL.
51640 LD A,113 Call FillChamber with INK:BLUE, PAPER:YELLOW (BRIGHT).
51642 CALL FillChamber
51645 CALL PlayBuzz Call PlayBuzz.
51648 JP DrawBountyDigits Jump to DrawBountyDigits.
Put the price back and stop reloading.
ReloadRevolver_TooPoor 51651 CALL AddToBounty Call AddToBounty.
51654 XOR A Clear ReloadingFlag.
51655 LD (41542),A
51658 INC A Set BulletUnpaidFlag to 1 and return.
51659 LD (41577),A
51662 RET
Prev: 51559 Up: Map Next: 51663