Prev: C583 Up: Map Next: C5EB
C58B: Run the state machine on a dueller
This entry point is used by the routine in Duel_Start.
Input
IX Pointer to dueller data.
C58B LD A,(IX+$08) If the dueller is shot and has hit the floor, there's nothing to do.
C58E AND A
C58F RET Z
C590 LD A,(IX+$09) If state 1 (stand off) then jump to C5A1.
C593 DEC A
C594 JR Z,$C5A1
C596 DEC A If state 2 (draw) then jump to C5B5.
C597 JR Z,$C5B5
C599 DEC A If state 3 (shooting) then jump to C5BD.
C59A JR Z,$C5BD
C59C DEC A If state 4 (bonus) then jump to C5CF.
C59D JR Z,$C5CF
C59F JR $C5DD State must be 5 (shot) so jump to C5DD.
State 1
C5A1 LD HL,$C6E5 If the player shot this dueller, call Dueller_Shot and exit. Oops, too early!
C5A4 CALL Dueller_Down
C5A7 DEC (IX+$01) Decrease the time left in this state.
C5AA RET NZ Return if not there yet.
C5AB INC (IX+$09) Otherwise move to the next state.
C5AE LD A,(IX+$0B) Redraw the dueller as drawing and return.
C5B1 CALL Duel_Draw_Bandit_Prep
C5B4 RET
State 2
C5B5 DEC (IX+$10) Decrease the time left in this state.
C5B8 RET NZ Return if not there yet.
C5B9 INC (IX+$09) Move to the next state.
C5BC RET
State 3
C5BD LD HL,$C5F6 If the player shot this dueller, call Print_BonusScore and exit. Nice one!
C5C0 CALL Dueller_Down
C5C3 DEC (IX+$02) Decrease the time left in this state.
C5C6 RET NZ Return if not there yet.
C5C7 LD (IX+$08),A Reset the "dueller standing" flag
C5CA INC A Set the "player shot" flag which will cause a BANG! then return
C5CB LD ($C6E2),A
C5CE RET
State 4
C5CF DEC (IX+$0E) Decrease the time left in this state.
C5D2 RET NZ Return if not there yet.
C5D3 INC (IX+$09) Move state between draw and shot.
C5D6 LD A,(IX+$0C) Redraw the dueller as shot and return.
C5D9 CALL Duel_Draw_Bandit_Prep
C5DC RET
State 5
C5DD DEC (IX+$0F) Decrease the time left in this state.
C5E0 RET NZ Return if not there yet.
C5E1 LD A,$02 Redraw the dueller as "floor" All characters use the same sprite ID 02.
C5E3 CALL Duel_Draw_Bandit_Prep
C5E6 LD (IX+$08),$00 Reset the "dueller still standing" flag and return.
C5EA RET
Prev: C583 Up: Map Next: C5EB