Prev: B8C3 Up: Map Next: B95E
B8E7: Handle Outlaw Gun
Type 0E: the gun of the outlaw in the duel, which is in the slot after the outlaw. It stays with the outlaw. When the outlaw is waiting it is not drawn, and when he has drawn it goes through its six frames, which raise the gun, and then it fires: it makes a muzzle flash (type 0F) in the next slot, and counts the shot in ShotsFiredCount. The duel ends when the outlaw has fired six shots. The gun is removed when the outlaw is dying.
HandleOutlawGun B8E7 LD A,(IX-$10) Fetch the type of the outlaw.
B8EA CP $12 Jump to HandleBody_Remove to remove the gun if the outlaw is dying.
B8EC JP Z,HandleBody_Remove
B8EF CP $11 Jump to HandleOutlawGun_Place if the outlaw has been shot.
B8F1 JR Z,HandleOutlawGun_Place
B8F3 CP $0C Jump to HandleOutlawGun_Place if the outlaw is waiting.
B8F5 JR Z,HandleOutlawGun_Place
B8F7 LD A,(IX+$0C) Fetch the frame of the gun.
B8FA CP $05 Jump to HandleOutlawGun_Fire if the gun is fully raised.
B8FC JR Z,HandleOutlawGun_Fire
B8FE CALL AdvanceGunFrame Advance the frame when it is time.
B901 LD A,(IX+$0C) Fetch the frame of the gun.
B904 LD BC,$B8C3 Point BC at GunSpriteLists.
B907 CALL GetTableEntry Point HL at the sprite list for the frame.
B90A LD (IX+$0E),L Store the low byte of the address.
B90D LD (IX+$0F),H Store the high byte of the address.
Put the gun next to the outlaw and draw it.
HandleOutlawGun_Place B910 LD A,(IX-$0E) Fetch the horizontal position of the outlaw.
B913 SUB $08 Move eight pixels to the left.
B915 LD (IX+$02),A Set the horizontal position of the gun.
B918 LD A,(IX-$10) Fetch the type of the outlaw.
B91B CP $11 Compare it with the type of a shot outlaw.
B91D LD A,(IX-$0C) Fetch the vertical position of the outlaw.
B920 JR Z,HandleOutlawGun_SetPosition Jump to HandleOutlawGun_SetPosition if he has been shot.
B922 ADD A,$0C Move the gun down twelve pixels.
HandleOutlawGun_SetPosition B924 LD (IX+$04),A Set the vertical position of the gun.
B927 JP DrawObject Jump to DrawObject.
The gun is fully raised, so fire it unless it has already fired.
HandleOutlawGun_Fire B92A LD A,(IX+$10) Fetch the type of the object in the next slot.
B92D AND A Test whether the slot is in use.
B92E JR NZ,HandleOutlawGun_Place Jump to HandleOutlawGun_Place if it is.
B930 LD HL,$A212 Point HL at ShotsFiredCount.
B933 LD A,(HL) Fetch the count.
B934 AND A Return if the outlaw has been hit.
B935 RET M
B936 INC A Add one to the count.
B937 CP $07 Jump to EndDuel to end the duel if the outlaw has fired six shots.
B939 JR Z,EndDuel
B93B LD (HL),A Store the count.
B93C PUSH IX Copy IX to HL (using the stack).
B93E POP HL
B93F LD BC,$0010 Set the size of an object slot.
B942 ADD HL,BC Point HL at the next slot.
B943 PUSH HL Copy HL to IY (using the stack).
B944 POP IY
B946 EX DE,HL Swap the address of the slot into DE.
B947 LD HL,$B95E Point HL at MuzzleFlashTemplate.
B94A LDIR Copy the template into the slot.
B94C LD A,(IX+$02) Fetch the horizontal position of the gun.
B94F ADD A,$08 Move eight pixels to the right.
B951 LD (IY+$02),A Set the horizontal position of the flash.
B954 LD A,(IX+$04) Fetch the vertical position of the gun.
B957 ADD A,$06 Move six pixels down.
B959 LD (IY+$04),A Set the vertical position of the flash.
Place and draw the gun.
B95C JR HandleOutlawGun_Place Jump to HandleOutlawGun_Place.
Prev: B8C3 Up: Map Next: B95E