Prev: 54366 Up: Map Next: 54691
54415: Customer Logic
Character state variables/ flags.
Customer_Frame_01 54415 DEFB 3 Character frame index 1.
Customer_Frame_02 54416 DEFB 4 Character frame index 2.
Customer_Frame_03 54417 DEFB 5 Character frame index 3.
Customer_Frame_04 54418 DEFB 6 Character frame index 4.
Customer_Frame_05 54419 DEFB 7 Character frame index 5.
Customer_Flag_Uncover 54420 DEFB 1 Represents whether the customer will move to uncover a bandit ($00 "normal" / $01 "uncover" action).
Customer_State_Ref 54421 DEFB 2 The current character state.
Customer_Timer_01 54422 DEFB 11 Character timer 1.
Customer_Timer_02 54423 DEFB 0 Character timer 2.
Customer_Timer_03 54424 DEFB 0 Character timer 3.
Customer_Timer_04 54425 DEFB 30 Character timer 4.
Customer_Timer_05 54426 DEFB 12 Character timer 5.
Customer_Timer_06 54427 DEFB 6 Character timer 6.
Customer_Timer_07 54428 DEFB 8 Character timer 7.
Customer_Timer_08 54429 DEFB 8 Character timer 8.
This routine looks at the current character state and routes to the correct subroutine.
Customer_Routing 54430 LD HL,54421 A=Customer_State_Ref.
54433 LD A,(HL)
54434 DEC A Work out which routine to use based on the current state.
A Routine
1 Customer_Open_01
2 Customer_Open_02
3 Customer_Open_03
4 Customer_Open_04
5 Customer_Uncover
6 Customer_Close_03
7 Customer_Close_02
8 Customer_Close_01
54435 JR Z,Customer_Open_01
54437 DEC A
54438 JR Z,Customer_Open_02
54440 DEC A
54441 JR Z,Customer_Open_03
54443 DEC A
54444 JR Z,Customer_Open_04
54446 DEC A
54447 JP Z,Customer_Uncover
54450 DEC A
54451 JP Z,Customer_Close_03
54454 DEC A
54455 JP Z,Customer_Close_02
54458 JP Customer_Close_01
Handle door frame 1 countdown/ transition to door frame 2.
Customer_Open_01 54461 LD A,(54422) Decrease Customer_Timer_01 by one, return if result is not zero.
54464 DEC A
54465 LD (54422),A
54468 RET NZ
54469 INC (HL) Move onto next character state.
54470 LD A,(54415) Grab the character frame index from Customer_Frame_01.
54473 CALL Draw_DoorFrame02 Call Draw_DoorFrame02 and return.
54476 RET
Handle door frame 2 countdown/ transition to door frame 3.
Customer_Open_02 54477 LD A,(54423) Decrease Customer_Timer_02 by one, return if result is not zero.
54480 DEC A
54481 LD (54423),A
54484 RET NZ
54485 INC (HL) Move onto next character state.
54486 LD A,(54415) Grab the character frame index from Customer_Frame_01.
54489 CALL Draw_DoorFrame03 Call Draw_DoorFrame03 and return.
54492 RET
Handle door frame 3 countdown/ transition to door frame 4.
Customer_Open_03 54493 LD A,(54424) Decrease Customer_Timer_03 by one, return if result is not zero.
54496 DEC A
54497 LD (54424),A
54500 RET NZ
54501 INC (HL) Move onto next character state.
54502 LD A,(54415) Grab the character frame index from Customer_Frame_01.
54505 CALL Draw_DoorFrame04 Call Draw_DoorFrame04 and return.
54508 RET
Handle door frame 4 timer...
Customer_Open_04 54509 LD DE,53137 Calls Hit_Detection with DE=Init_Customer_Shot.
54512 CALL Hit_Detection
54515 LD A,(54425) Decrease Customer_Timer_04 by one, return if result is not zero.
54518 DEC A
54519 LD (54425),A
54522 RET NZ
54523 LD A,(54420) Jump to Customer_HandsUp if Customer_Flag_Uncover is not zero.
54526 AND A
54527 JR NZ,Customer_HandsUp
54529 LD (HL),7 Set Customer_State_Ref to use state $07 (Customer_Close_02 on the next call to Customer_Routing).
54531 LD A,(54415) Call Draw_DoorFrame03 using the character frame index from Customer_Frame_01.
54534 CALL Draw_DoorFrame03
54537 LD (IX+6),5 Issue 500 points (by writing $05 to the high order byte of, e.g. Door_Scoring_01).
54541 LD A,1 Register this as a deposit (by writing $01 to e.g. Door_Cash_Action_01).
54543 LD (IX+8),A
54546 LD (53648),A Writes $01 to 53648.
54549 RET Return.
Handle customer putting their hands up.
Customer_HandsUp 54550 LD A,(54421) Increase Customer_State_Ref by one.
54553 INC A
54554 LD (54421),A
54557 LD A,(54416) Grab the character frame index from Customer_Frame_02.
54560 CALL Draw_DoorFrame04 Call Draw_DoorFrame04 and return.
54563 RET
Handles customer uncovering a "hidden" bandit action.
Customer_Uncover 54564 LD DE,53137 Calls Hit_Detection with DE=Init_Customer_Shot.
54567 CALL Hit_Detection
54570 LD A,(54426) Decrease Customer_Timer_05 by one, return if result is not zero.
54573 DEC A
54574 LD (54426),A
54577 RET NZ
54578 LD A,(54421) Increase Customer_State_Ref by one.
54581 INC A
54582 LD (54421),A
54585 LD A,(54417) Grab the character frame index from Customer_Frame_03.
54588 CALL Draw_DoorFrame04 Call Draw_DoorFrame04 and return.
54591 RET
Handle door frame 4 countdown/ transition to door frame 3.
Customer_Close_03 54592 LD A,(54427) Decrease Customer_Timer_06 by one, return if result is not zero.
54595 DEC A
54596 LD (54427),A
54599 RET NZ
54600 CALL Init_Bandit_Open Call Init_Bandit_Open.
54603 LD L,(IX+2) Load, e.g. Door_Source_01 (bandit source data) into HL, and write $03 to the address contained in it.
54606 LD H,(IX+3)
54609 LD (HL),3
54611 INC HL Increase the pointer to the bandit source data by 3 and write $04 to this byte.
54612 INC HL
54613 INC HL
54614 LD (HL),4
54616 RET Return.
Handle door frame 3 countdown/ transition to door frame 2.
Customer_Close_02 54617 LD A,(54428) Decrease Customer_Timer_07 by one, return if result is not zero.
54620 DEC A
54621 LD (54428),A
54624 RET NZ
54625 LD HL,54421 Increase Customer_State_Ref by one.
54628 INC (HL)
54629 LD A,(54415) Grab the character frame index from Customer_Frame_01.
54632 CALL Draw_DoorFrame02 Call Draw_DoorFrame02 and return.
54635 RET
Handle door frame 2 countdown/ transition to door frame 1.
Customer_Close_01 54636 LD A,(54429) Decrease Customer_Timer_08 by one, return if result is not zero.
54639 DEC A
54640 LD (54429),A
54643 RET NZ
54644 CALL Draw_DoorFrame1 Call Draw_DoorFrame1 (i.e. no character/ door is shut).
54647 CALL Reset___ Call Reset___ and return.
54650 RET
Handles customer being shot.
Customer_Shot 54651 LD HL,54421 If Customer_State_Ref is zero then jump to Customer_Shot_MidAir else jump to Customer_Shot_Floor.
54654 LD A,(HL)
54655 DEC A
54656 JR Z,Customer_Shot_MidAir
54658 JR Customer_Shot_Floor
Customer_Shot_MidAir 54660 INC (HL) Move onto next character state.
54661 LD A,(54418) Grab the character frame index from Customer_Frame_04.
54664 CALL Draw_DoorFrame04 Call Draw_DoorFrame04 and return.
54667 RET
Customer_Shot_Floor 54668 LD A,(54423) Decrease Customer_Timer_02 by one, return if result is not zero.
54671 DEC A
54672 LD (54423),A
54675 RET NZ
54676 LD A,(54419) Grab the character frame index from Customer_Frame_05.
54679 CALL Draw_DoorFrame04 Call Draw_DoorFrame04.
54682 LD A,2 Writes $02 to 54014.
54684 LD (54014),A
54687 CALL Reset___ Call Reset___ and return.
54690 RET
Prev: 54366 Up: Map Next: 54691