Prev: 35523 Up: Map Next: 35687
35577: Change direction Berk is facing depending upon relative position of Drutt
Used by the routine at 35735.
Input
IX Address of complex state data (current level) for Berk
35577 LD A,(34218) If Drutt's current room...
35580 CP (IX+0) ...is not the same as Berk's current room...
35583 JP NZ,35786 ...then jump to 35786 (terminate Berk's flight, or have him (turn to) face out of screen as appropriate)
35586 LD A,(IX+11) Reset Berk's walking-right, walking-left, unused-(11,2) and unused-(11,3) flags...
35589 AND 240 ...
35591 LD (IX+11),A ...
35594 LD E,(IX+9) Load Berk's flags into E
35597 LD IY,(34242) Load IY with address of complex state data (current level) for Drutt
35601 LD A,(IY+7) Load A with x-coordinate of Drutt's right side...
35604 INC A ...and increase by one
35605 CP (IX+5) If x-coordinate of Berk's left side is greater than this (i.e. Drutt is to the left of Berk)...
35608 JR C,35653 ...then skip ahead to 35653
35610 LD A,(IX+7) Load A with x-coordinate of Berk's right side
35613 INC A Increase A by one
35614 CP (IY+5) If x-coordinate of Drutt's left side is greater than this (i.e. Drutt is to the right of Berk)...
35617 JR C,35670 ...then skip ahead to 35670
Drutt is between Berk's left and right sides
35619 LD A,(IY+1) If Drutt's depth is 1...
35622 CP 1 ...
35624 JP Z,35642 ...then skip ahead to 35642
Drutt is behind Berk
35627 LD A,E Load A with Berk's flags
35628 AND 14 If Berk's facing-into-screen, facing-left and facing-right flags are all reset...
35630 JP Z,35636 ...then skip ahead to 35636
Drutt is behind Berk and at least one of Berk's facing-into-screen, facing-left and facing-right flags is set
35633 JP 35815 Point HL at script data for Berk facing into screen, ready to respond to control input and execute
Drutt is behind Berk and Berk's facing-into-screen, facing-left and facing-right flags are all reset
35636 LD HL,35105 Point HL at script data for Berk turning (facing out of screen to facing into screen)...
35639 JP 48098 ...and execute
Drutt is in front of Berk
35642 BIT 1,E If Berk's facing-into-screen flag is reset...
35644 JP Z,35821 ...then point HL at script data for Berk facing out of screen, ready to respond to control input and execute
Drutt is in front of Berk and Berk's facing-into-screen flag is set
35647 LD HL,35073 Point HL at script data for Berk turning (facing into screen to facing out of screen)...
35650 JP 48098 ...and execute
Drutt is to the left of Berk
35653 LD A,E Load A with Berk's flags
35654 AND 6 If either of Berk's facing-into-screen or facing-left flags are set...
35656 JR NZ,35664 ...then skip ahead to 35664
Drutt is to the left of Berk, and Berk's facing-into-screen and facing-left flags are both reset
35658 LD HL,34977 Point HL at script data for Berk turning to face left...
35661 JP 48098 ...and execute
Drutt is to the left of Berk and either of Berk's facing-into-screen or facing-left flags are set
35664 LD HL,34985 Point HL at script data for Berk facing left...
35667 JP 48098 ...and execute
Drutt is to the right of Berk
35670 LD A,E Load A with Berk's flags
35671 AND 10 If either of Berk's facing-into-screen or facing-right flags are set...
35673 JR NZ,35681 ...then skip ahead to 35681
Drutt is to the right of Berk, and Berk's facing-into-screen and facing-right flags are both reset
35675 LD HL,34997 Point HL at script data for Berk turning to face right...
35678 JP 48098 ...and execute
Drutt is to the right of Berk and either of Berk's facing-into-screen or facing-right flags are set
35681 LD HL,35005 Point HL at script data for Berk facing right...
35684 JP 48098 ...and execute
Prev: 35523 Up: Map Next: 35687