Routines

28877: Close any temporarily open doors if necessary


Used by routine at 63156

28877 3AF67F LD A,(32758)
28880 FE04 CP 4
28882 C0 RET NZ
28883 3AF47F LD A,(32756) Doors flags
28886 213E01 LD HL,318 H=1, L=62
28889 CB47 BIT 0,A Is the left study door open?
28891 C4EC70 CALL NZ,28908 If so, close it if possible
28894 214002 LD HL,576 H=2, L=64
28897 CB4F BIT 1,A Is the right study door open?
28899 C4EC70 CALL NZ,28908 If so, close it if possible
28902 CB57 BIT 2,A Is the science lab storeroom door open?
28904 C8 RET Z Return if not
28905 214204 LD HL,1090 H=4, L=66
28908 E5 PUSH HL
28909 26B9 LD H,185 HL references table at 47422
28911 7E LD A,(HL) A=x-coordinate of door
28912 2C INC L
28913 56 LD D,(HL) D=y-coordinate of door
28914 3D DEC A
28915 4F LD C,A
28916 C603 ADD A,3
28918 5F LD E,A
28919 2101B7 LD HL,46849 L=1, H=183 (little girl no. 1)
28922 0620 LD B,32 32 game characters (183-214)
28924 7E LD A,(HL) A=character's x-coordinate
28925 B9 CP C Is the character to the left of the door?
28926 380B JR C,28939 Jump if so
28928 BB CP E Is the character to the right of the door?
28929 3008 JR NC,28939 Jump if so
28931 2C INC L
28932 7A LD A,D A=y-coordinate of door
28933 96 SUB (HL)
28934 2D DEC L
28935 FE02 CP 2 Is the character standing in the doorway?
28937 3804 JR C,28943 Jump if so
28939 24 INC H Next character
28940 10EE DJNZ 28924 Jump back until all 32 characters have been checked
28942 A7 AND A Reset carry: no one is standing in the doorway
28943 E1 POP HL
28944 7C LD A,H Bit set in A corresponds to door under consideration
28945 D44070 CALL NC,28736 Close the door if no one's in the way
28948 3AF47F LD A,(32756) Pick up the doors flags in A
28951 C9 RET