Prev: D8E5 Up: Map Next: DAEF
DA0C: Drawing Bandit Logic
Character state variables/ flags.
Bandit_Draw DA0C DEFB $00
Bandit_Draw_Frame_01 DA0D DEFB $08 Character frame index 1.
Bandit_Draw_Frame_02 DA0E DEFB $08 Character frame index 2.
Bandit_Draw_Frame_03 DA0F DEFB $09 Character frame index 3.
Bandit_Draw_Frame_04 DA10 DEFB $07 Character frame index 4.
Bandit_Draw_State_Reference DA11 DEFB $05 The current character state.
Bandit_Draw_Timer_01 DA12 DEFB $00 Character timer 1.
Bandit_Draw_Timer_02 DA13 DEFB $00 Character timer 2.
Bandit_Draw_Timer_03 DA14 DEFB $00 Character timer 3.
Bandit_Draw_Timer_04 DA15 DEFB $00 Character timer 4.
Bandit_Draw_Timer_05 DA16 DEFB $00 Character timer 5.
This routine looks at the current character state and routes to the correct subroutine.
Bandit_Draw_Open_Routing DA17 LD HL,$DA11 A=Bandit_Draw_State_Reference.
DA1A LD A,(HL)
DA1B DEC A Work out which routine to use based on the current state.
A Routine
01 Bandit_Draw_Open_01
02 Bandit_Draw_Open_02
03 Bandit_Draw_Open_03
04 Bandit_Draw_Open_04
05 Bandit_Draw_Open_05
DA1C JR Z,Bandit_Draw_Open_01
DA1E DEC A
DA1F JR Z,Bandit_Draw_Open_02
DA21 DEC A
DA22 JR Z,Bandit_Draw_Open_03
DA24 DEC A
DA25 JR Z,Bandit_Draw_Open_04
DA27 JR Bandit_Draw_Open_05
Handle door frame 1 countdown/ transition to door frame 2.
Bandit_Draw_Open_01 DA29 LD A,($DA12) Decrease Bandit_Draw_Timer_01 by one, return if result is not zero.
DA2C DEC A
DA2D LD ($DA12),A
DA30 RET NZ
DA31 INC (HL) Move onto next character state.
DA32 LD A,($DA0D) Grab the character frame index from Bandit_Draw_Frame_01.
DA35 CALL Draw_DoorFrame02 Call Draw_DoorFrame02 and return.
DA38 RET
Handle door frame 2 countdown/ transition to door frame 3.
Bandit_Draw_Open_02 DA39 LD A,($DA13) Decrease Bandit_Draw_Timer_02 by one, return if result is not zero.
DA3C DEC A
DA3D LD ($DA13),A
DA40 RET NZ
DA41 INC (HL) Move onto next character state.
DA42 LD A,($DA0D) Grab the character frame index from Bandit_Draw_Frame_01.
DA45 CALL Draw_DoorFrame03 Call Draw_DoorFrame03 and return.
DA48 RET
Handle door frame 3 countdown/ transition to door frame 4.
Bandit_Draw_Open_03 DA49 LD A,($DA14) Decrease Bandit_Draw_Timer_03 by one, return if result is not zero.
DA4C DEC A
DA4D LD ($DA14),A
DA50 RET NZ
DA51 INC (HL) Move onto next character state.
DA52 LD A,($DA0D) Grab the character frame index from Bandit_Draw_Frame_01.
DA55 CALL Draw_DoorFrame04 Call Draw_DoorFrame04 and return.
DA58 RET
Handles state countdown.
Bandit_Draw_Open_04 DA59 LD DE,$D037 Call Hit_Detection with a callback to Todo_Door_Reset.
DA5C CALL Hit_Detection
DA5F LD A,($DA15) Decrease Bandit_Draw_Timer_04 by one, return if result is not zero.
DA62 DEC A
DA63 LD ($DA15),A
DA66 RET NZ
DA67 INC (HL) Move onto next character state.
DA68 LD A,($DA0E) Grab the character frame index from Bandit_Draw_Frame_02.
DA6B CALL Draw_DoorFrame04 Call Draw_DoorFrame04 and return.
DA6E RET
Handles state countdown.
Bandit_Draw_Open_05 DA6F LD DE,$D040 Call Hit_Detection with a callback to D040.
DA72 CALL Hit_Detection
DA75 LD A,($DA16) Decrease Bandit_Draw_Timer_05 by one, return if result is not zero.
DA78 DEC A
DA79 LD ($DA16),A
DA7C RET NZ
DA7D INC A Else write $01 to D2FE, call Reset___ and return.
DA7E LD ($D2FE),A
DA81 CALL Reset___
DA84 RET
This routine looks at the current character state and routes to the correct subroutine.
Bandit_Draw_Close_Routing DA85 LD HL,$DA11 A=Bandit_Draw_State_Reference.
DA88 LD A,(HL)
DA89 DEC A Work out which routine to use based on the current state.
A Routine
01 Bandit_Draw_Close_01
02 Bandit_Draw_Close_02
03 Bandit_Draw_Close_03
04 Bandit_Draw_Close_04
05 Bandit_Draw_Close_05
DA8A JR Z,Bandit_Draw_Close_01
DA8C DEC A
DA8D JR Z,Bandit_Draw_Close_02
DA8F DEC A
DA90 JR Z,Bandit_Draw_Close_03
DA92 DEC A
DA93 JR Z,Bandit_Draw_Close_04
DA95 JR Bandit_Draw_Close_05
Handles state countdown.
Bandit_Draw_Close_01 DA97 LD A,($DA12) Decrease Bandit_Draw_Timer_01 by one, return if result is not zero.
DA9A DEC A
DA9B LD ($DA12),A
DA9E RET NZ
DA9F INC (HL) Move onto next character state.
DAA0 LD A,($DA0F) Grab the character frame index from Bandit_Draw_Frame_03.
DAA3 CALL Draw_DoorFrame04 Call Draw_DoorFrame04 and return.
DAA6 RET
Handles state countdown.
Bandit_Draw_Close_02 DAA7 LD A,($DA13) Decrease Bandit_Draw_Timer_02 by one, return if result is not zero.
DAAA DEC A
DAAB LD ($DA13),A
DAAE RET NZ
DAAF INC (HL) Move onto next character state.
DAB0 LD A,($DA10) Grab the character frame index from Bandit_Draw_Frame_04.
DAB3 CALL Draw_DoorFrame04 Call Draw_DoorFrame04.
DAB6 LD A,($DA0C) Return if Bandit_Draw is zero.
DAB9 AND A
DABA RET Z
DABB INC A Else write $01 to D2FE and return.
DABC LD ($D2FE),A
DABF RET
Handle door frame 4 countdown/ transition to door frame 3.
Bandit_Draw_Close_03 DAC0 LD A,($DA14) Decrease Bandit_Draw_Timer_03 by one, return if result is not zero.
DAC3 DEC A
DAC4 LD ($DA14),A
DAC7 RET NZ
DAC8 INC (HL) Move onto next character state.
DAC9 LD A,($DA10) Grab the character frame index from Bandit_Draw_Frame_04.
DACC CALL Draw_DoorFrame03 Call Draw_DoorFrame03 and return.
DACF RET
Handle door frame 3 countdown/ transition to door frame 2.
Bandit_Draw_Close_04 DAD0 LD A,($DA15) Decrease Bandit_Draw_Timer_04 by one, return if result is not zero.
DAD3 DEC A
DAD4 LD ($DA15),A
DAD7 RET NZ
DAD8 INC (HL) Move onto next character state.
DAD9 LD A,($DA10) Grab the character frame index from Bandit_Draw_Frame_04.
DADC CALL Draw_DoorFrame02 Call Draw_DoorFrame02 and return.
DADF RET
Handle door frame 2 countdown/ transition to door frame 1.
Bandit_Draw_Close_05 DAE0 LD A,($DA16) Decrease Bandit_Draw_Timer_05 by one, return if result is not zero.
DAE3 DEC A
DAE4 LD ($DA16),A
DAE7 RET NZ
DAE8 CALL Draw_DoorFrame1 Call Draw_DoorFrame1 (i.e. no character/ door is shut).
DAEB CALL Reset___ Call Reset___ and return.
DAEE RET
Prev: D8E5 Up: Map Next: DAEF