Prev: D71E Up: Map Next: D8A1
D7C5: Bowie logic
Handles all the logic around drawing Bowie and handling his "special" logic.
Bowie state variables/ flags.
Bowie_Good_Bad D7C5 DEFB $01 If this is $00 then Bowie is "good". If this is $01 then he is "bad" (i.e. there's a bomb under his hat).
Bowie_Frame_Reference D7C6 DEFB $22 The current character frame index reference.
Bowie_State_Reference D7C7 DEFB $06 The current character state.
Bowie_Timer_01 D7C8 DEFB $00 Character timer 1.
Bowie_Timer_02 D7C9 DEFB $00 Character timer 2.
Bowie_Timer_03 D7CA DEFB $00 Character timer 3.
Bowie_Timer_04 D7CB DEFB $00 Character timer 4.
Bowie_Timer_05 D7CC DEFB $00 Character timer 5.
Bowie_Timer_06 D7CD DEFB $00 Character timer 6.
This routine looks at the current character state and routes to the correct subroutine.
Bowie_Routing D7CE LD HL,$D7C7 A=Bowie_State_Reference.
D7D1 LD A,(HL)
D7D2 DEC A Work out which routine to jump to based on the current state.
A Routine
01 Bowie_Open_01
02 Bowie_Open_02
03 Bowie_Open_03
04 Bowie_Open_04
05 Bowie_Close_02
06 Bowie_Close_01
D7D3 JR Z,Bowie_Open_01
D7D5 DEC A
D7D6 JR Z,Bowie_Open_02
D7D8 DEC A
D7D9 JR Z,Bowie_Open_03
D7DB DEC A
D7DC JR Z,Bowie_Open_04
D7DE DEC A
D7DF JR Z,Bowie_Close_02
D7E1 JR Bowie_Close_01
Handle door frame 1 countdown/ transition to door frame 2.
Bowie_Open_01 D7E3 LD A,($D7C8) Decrease Bowie_Timer_01 by one, return if result is not zero.
D7E6 DEC A
D7E7 LD ($D7C8),A
D7EA RET NZ
D7EB INC (HL) Move onto next character state.
D7EC LD A,$1B Pass character index $1B to Draw_DoorFrame02 and return.
D7EE CALL Draw_DoorFrame02
D7F1 RET
Handle door frame 2 countdown/ transition to door frame 3.
Bowie_Open_02 D7F2 LD A,($D7C9) Decrease Bowie_Timer_02 by one, return if result is not zero.
D7F5 DEC A
D7F6 LD ($D7C9),A
D7F9 RET NZ
D7FA INC (HL) Move onto next character state.
D7FB LD A,$1B Pass character index $1B to Draw_DoorFrame03 and return.
D7FD CALL Draw_DoorFrame03
D800 RET
Handle door frame 3 countdown/ transition to door frame 4.
Bowie_Open_03 D801 LD A,($D7CA) Decrease Bowie_Timer_03 by one, return if result is not zero.
D804 DEC A
D805 LD ($D7CA),A
D808 RET NZ
D809 INC (HL) Move onto next character state.
D80A LD A,$1B Pass character frame index $1B to Draw_DoorFrame04 and return.
D80C CALL Draw_DoorFrame04
D80F RET
Handle door frame 4 countdown/ transition to door frame 3.
Bowie_Open_04 D810 LD E,(IX+$04) Call Hit_Detection with a callback to either Bowie_Cash_Action or Bowie_Bomb_Action.
D813 LD D,(IX+$05)
D816 CALL Hit_Detection
D819 LD A,($D7CB) Decrease Bowie_Timer_04 by one, return if result is not zero.
D81C DEC A
D81D LD ($D7CB),A
D820 RET NZ
Bowie_Close_03 D821 LD HL,$D7C7 Move onto next character state (Bowie_State_Reference).
D824 INC (HL)
D825 LD A,($D7C6) Load the character frame index from Bowie_Frame_Reference, pass it to Draw_DoorFrame03 and return.
D828 CALL Draw_DoorFrame03
D82B RET
Handle door frame 3 countdown/ transition to door frame 2.
Bowie_Close_02 D82C LD A,($D7CC) Decrease Bowie_Timer_05 by one, return if result is not zero.
D82F DEC A
D830 LD ($D7CC),A
D833 RET NZ
D834 INC (HL) Move onto next character state.
D835 LD A,($D7C6) Load the character frame index from Bowie_Frame_Reference, pass it to Draw_DoorFrame02 and return.
D838 CALL Draw_DoorFrame02
D83B RET
Handle door frame 2 countdown/ transition to door frame 1.
Bowie_Close_01 D83C LD A,($D7CD) Decrease Bowie_Timer_06 by one, return if result is not zero.
D83F DEC A
D840 LD ($D7CD),A
D843 RET NZ
D844 CALL Draw_DoorFrame1 Call Draw_DoorFrame1 (i.e. no character/ door is shut).
D847 CALL Reset___ Call Reset___.
D84A RET Return.
Handles marking this as something shootable.
Bowie_Cash_Action D84B LD (IX+$06),$05 Writes $05 to IX+$06 and $01 to IX+$07.
D84F LD (IX+$07),$01
D853 LD A,$01 Writes $01 to IX+$08 and D190.
D855 LD (IX+$08),A
D858 LD ($D190),A
D85B JR Bowie_Close_03 Jump to Bowie_Close_03.
Handles marking this as something unshootable.
Bowie_Bomb_Action D85D LD A,$05 Writes $05 to D2FE and return.
D85F LD ($D2FE),A
D862 RET
Handles both shooting the hats off Bowie's head, and checking/ routing on the last frame for the "surprise".
Bowie_Shot_Action D863 LD HL,$D7C6 A=Bowie_Frame_Reference.
D866 LD A,(HL)
D867 CP $21 Is it character frame reference (1 hat | 21)?
D869 LD (IX+$06),$01 Writes $01 to IX+$06.
D86D JR NC,Bowie_Check If Bowie is on the last frame then jump forward to Bowie_Check.
D86F INC A Else update Bowie_Frame_Reference to point at the next frame, call Draw_DoorFrame04 and return.
D870 LD (HL),A
D871 CALL Draw_DoorFrame04
D874 RET
Checks the "good/ bad" flag and routes the gameplay accordingly.
Bowie_Check D875 LD A,($D7C5) If Bowie_Good_Bad is zero jump to Bowie_State_Cash.
D878 AND A
D879 JR Z,Bowie_State_Cash
D87B JR Bowie_State_Bomb Jump to Bowie_State_Bomb.
Handle displaying cash character frame.
Bowie_State_Cash D87D LD A,$23 Writes character frame reference cash | 23 to Bowie_Frame_Reference, and pass it to Draw_DoorFrame04.
D87F LD ($D7C6),A
D882 CALL Draw_DoorFrame04
D885 LD HL,$D84B Writes Bowie_Cash_Action to the current door flags (e.g. Door_Bowie_Action_01, Door_Bowie_Action_02 or Door_Bowie_Action_03).
D888 LD (IX+$04),L
D88B LD (IX+$05),H
D88E RET Return.
Handle displaying bomb character frame.
Bowie_State_Bomb D88F LD A,$22 Writes character frame reference bomb | 22 to Bowie_Frame_Reference, and pass it to Draw_DoorFrame04.
D891 LD ($D7C6),A
D894 CALL Draw_DoorFrame04
D897 LD HL,$D85D Writes Bowie_Bomb_Action to the current door flags (e.g. Door_Bowie_Action_01, Door_Bowie_Action_02 or Door_Bowie_Action_03).
D89A LD (IX+$04),L
D89D LD (IX+$05),H
D8A0 RET Return.
Prev: D71E Up: Map Next: D8A1