Prev: D45E Up: Map Next: D5A3
D48F: Customer Logic
Character state variables/ flags.
Customer_Frame_01 D48F DEFB $03 Character frame index 1.
Customer_Frame_02 D490 DEFB $04 Character frame index 2.
Customer_Frame_03 D491 DEFB $05 Character frame index 3.
Customer_Frame_04 D492 DEFB $06 Character frame index 4.
Customer_Frame_05 D493 DEFB $07 Character frame index 5.
Customer_Flag_Uncover D494 DEFB $01 Represents whether the customer will move to uncover a bandit ($00 "normal" / $01 "uncover" action).
Customer_State_Ref D495 DEFB $02 The current character state.
Customer_Timer_01 D496 DEFB $0B Character timer 1.
Customer_Timer_02 D497 DEFB $00 Character timer 2.
Customer_Timer_03 D498 DEFB $00 Character timer 3.
Customer_Timer_04 D499 DEFB $1E Character timer 4.
Customer_Timer_05 D49A DEFB $0C Character timer 5.
Customer_Timer_06 D49B DEFB $06 Character timer 6.
Customer_Timer_07 D49C DEFB $08 Character timer 7.
Customer_Timer_08 D49D DEFB $08 Character timer 8.
This routine looks at the current character state and routes to the correct subroutine.
Customer_Routing D49E LD HL,$D495 A=Customer_State_Ref.
D4A1 LD A,(HL)
D4A2 DEC A Work out which routine to use based on the current state.
A Routine
01 Customer_Open_01
02 Customer_Open_02
03 Customer_Open_03
04 Customer_Open_04
05 Customer_Uncover
06 Customer_Close_03
07 Customer_Close_02
08 Customer_Close_01
D4A3 JR Z,Customer_Open_01
D4A5 DEC A
D4A6 JR Z,Customer_Open_02
D4A8 DEC A
D4A9 JR Z,Customer_Open_03
D4AB DEC A
D4AC JR Z,Customer_Open_04
D4AE DEC A
D4AF JP Z,Customer_Uncover
D4B2 DEC A
D4B3 JP Z,Customer_Close_03
D4B6 DEC A
D4B7 JP Z,Customer_Close_02
D4BA JP Customer_Close_01
Handle door frame 1 countdown/ transition to door frame 2.
Customer_Open_01 D4BD LD A,($D496) Decrease Customer_Timer_01 by one, return if result is not zero.
D4C0 DEC A
D4C1 LD ($D496),A
D4C4 RET NZ
D4C5 INC (HL) Move onto next character state.
D4C6 LD A,($D48F) Grab the character frame index from Customer_Frame_01.
D4C9 CALL Draw_DoorFrame02 Call Draw_DoorFrame02 and return.
D4CC RET
Handle door frame 2 countdown/ transition to door frame 3.
Customer_Open_02 D4CD LD A,($D497) Decrease Customer_Timer_02 by one, return if result is not zero.
D4D0 DEC A
D4D1 LD ($D497),A
D4D4 RET NZ
D4D5 INC (HL) Move onto next character state.
D4D6 LD A,($D48F) Grab the character frame index from Customer_Frame_01.
D4D9 CALL Draw_DoorFrame03 Call Draw_DoorFrame03 and return.
D4DC RET
Handle door frame 3 countdown/ transition to door frame 4.
Customer_Open_03 D4DD LD A,($D498) Decrease Customer_Timer_03 by one, return if result is not zero.
D4E0 DEC A
D4E1 LD ($D498),A
D4E4 RET NZ
D4E5 INC (HL) Move onto next character state.
D4E6 LD A,($D48F) Grab the character frame index from Customer_Frame_01.
D4E9 CALL Draw_DoorFrame04 Call Draw_DoorFrame04 and return.
D4EC RET
Handle door frame 4 timer...
Customer_Open_04 D4ED LD DE,$CF91 Calls Hit_Detection with DE=Init_Customer_Shot.
D4F0 CALL Hit_Detection
D4F3 LD A,($D499) Decrease Customer_Timer_04 by one, return if result is not zero.
D4F6 DEC A
D4F7 LD ($D499),A
D4FA RET NZ
D4FB LD A,($D494) Jump to Customer_HandsUp if Customer_Flag_Uncover is not zero.
D4FE AND A
D4FF JR NZ,Customer_HandsUp
D501 LD (HL),$07 Set Customer_State_Ref to use state $07 (Customer_Close_02 on the next call to Customer_Routing).
D503 LD A,($D48F) Call Draw_DoorFrame03 using the character frame index from Customer_Frame_01.
D506 CALL Draw_DoorFrame03
D509 LD (IX+$06),$05 Issue 500 points (by writing $05 to the high order byte of, e.g. Door_Scoring_01).
D50D LD A,$01 Register this as a deposit (by writing $01 to e.g. Door_Cash_Action_01).
D50F LD (IX+$08),A
D512 LD ($D190),A Writes $01 to D190.
D515 RET Return.
Handle customer putting their hands up.
Customer_HandsUp D516 LD A,($D495) Increase Customer_State_Ref by one.
D519 INC A
D51A LD ($D495),A
D51D LD A,($D490) Grab the character frame index from Customer_Frame_02.
D520 CALL Draw_DoorFrame04 Call Draw_DoorFrame04 and return.
D523 RET
Handles customer uncovering a "hidden" bandit action.
Customer_Uncover D524 LD DE,$CF91 Calls Hit_Detection with DE=Init_Customer_Shot.
D527 CALL Hit_Detection
D52A LD A,($D49A) Decrease Customer_Timer_05 by one, return if result is not zero.
D52D DEC A
D52E LD ($D49A),A
D531 RET NZ
D532 LD A,($D495) Increase Customer_State_Ref by one.
D535 INC A
D536 LD ($D495),A
D539 LD A,($D491) Grab the character frame index from Customer_Frame_03.
D53C CALL Draw_DoorFrame04 Call Draw_DoorFrame04 and return.
D53F RET
Handle door frame 4 countdown/ transition to door frame 3.
Customer_Close_03 D540 LD A,($D49B) Decrease Customer_Timer_06 by one, return if result is not zero.
D543 DEC A
D544 LD ($D49B),A
D547 RET NZ
D548 CALL Init_Bandit_Open Call Init_Bandit_Open.
D54B LD L,(IX+$02) Load, e.g. Door_Source_01 (bandit source data) into HL, and write $03 to the address contained in it.
D54E LD H,(IX+$03)
D551 LD (HL),$03
D553 INC HL Increase the pointer to the bandit source data by 3 and write $04 to this byte.
D554 INC HL
D555 INC HL
D556 LD (HL),$04
D558 RET Return.
Handle door frame 3 countdown/ transition to door frame 2.
Customer_Close_02 D559 LD A,($D49C) Decrease Customer_Timer_07 by one, return if result is not zero.
D55C DEC A
D55D LD ($D49C),A
D560 RET NZ
D561 LD HL,$D495 Increase Customer_State_Ref by one.
D564 INC (HL)
D565 LD A,($D48F) Grab the character frame index from Customer_Frame_01.
D568 CALL Draw_DoorFrame02 Call Draw_DoorFrame02 and return.
D56B RET
Handle door frame 2 countdown/ transition to door frame 1.
Customer_Close_01 D56C LD A,($D49D) Decrease Customer_Timer_08 by one, return if result is not zero.
D56F DEC A
D570 LD ($D49D),A
D573 RET NZ
D574 CALL Draw_DoorFrame1 Call Draw_DoorFrame1 (i.e. no character/ door is shut).
D577 CALL Reset___ Call Reset___ and return.
D57A RET
Handles customer being shot.
Customer_Shot D57B LD HL,$D495 If Customer_State_Ref is zero then jump to Customer_Shot_MidAir else jump to Customer_Shot_Floor.
D57E LD A,(HL)
D57F DEC A
D580 JR Z,Customer_Shot_MidAir
D582 JR Customer_Shot_Floor
Customer_Shot_MidAir D584 INC (HL) Move onto next character state.
D585 LD A,($D492) Grab the character frame index from Customer_Frame_04.
D588 CALL Draw_DoorFrame04 Call Draw_DoorFrame04 and return.
D58B RET
Customer_Shot_Floor D58C LD A,($D497) Decrease Customer_Timer_02 by one, return if result is not zero.
D58F DEC A
D590 LD ($D497),A
D593 RET NZ
D594 LD A,($D493) Grab the character frame index from Customer_Frame_05.
D597 CALL Draw_DoorFrame04 Call Draw_DoorFrame04.
D59A LD A,$02 Writes $02 to D2FE.
D59C LD ($D2FE),A
D59F CALL Reset___ Call Reset___ and return.
D5A2 RET
Prev: D45E Up: Map Next: D5A3