Routines
 Prev: 28874 Up: Map Next: 28952
28877: Close any temporarily open doors if necessary
 Used by the routine at 63156. Checks the left study door, right study door, and Science Lab storeroom door, and closes any that are open (provided nobody is standing in the doorway). 28877 LD A,(32758) Return unless 32758 (which is decremented on every pass through the main loop, and cycles through the values 1-15) holds 4 at the moment 28880 CP 4 28882 RET NZ 28883 LD A,(32756) 32756 holds the doors flags 28886 LD HL,318 H=1 (left study door), L=62 28889 BIT 0,A Is the left study door open? 28891 CALL NZ,28908 If so, close it if possible 28894 LD HL,576 H=2 (right study door), L=64 28897 BIT 1,A Is the right study door open? 28899 CALL NZ,28908 If so, close it if possible 28902 BIT 2,A Is the Science Lab storeroom door open? 28904 RET Z Return if not 28905 LD HL,1090 H=4 (Science Lab storeroom door), L=66 At this point H holds the identifier of a door that is open, and L holds the LSB of the address of the entry in the table at 47422 containing the location of the door. 28908 PUSH HL Save the door identifier briefly 28909 LD H,185 Point HL at the door location table entry 28911 LD A,(HL) A=x-coordinate of the door 28912 INC L 28913 LD D,(HL) D=y-coordinate of the door 28914 DEC A Set C=X-1 and E=X+2, where X is the x-coordinate of the door; any character whose x-coordinate is in this range will prevent the door from closing 28915 LD C,A 28916 ADD A,3 28918 LD E,A 28919 LD HL,46849 L=1, H=183 (little girl no. 1) 28922 LD B,32 32 game characters (183-214) 28924 LD A,(HL) A=character's x-coordinate 28925 CP C Is the character to the left of the door? 28926 JR C,28939 Jump if so 28928 CP E Is the character to the right of the door? 28929 JR NC,28939 Jump if so 28931 INC L L=2 28932 LD A,D A=y-coordinate of the door 28933 SUB (HL) Subtract the character's y-coordinate 28934 DEC L L=1 28935 CP 2 Is the character standing in the doorway? 28937 JR C,28943 Jump if so 28939 INC H Next character 28940 DJNZ 28924 Jump back until all 32 characters have been checked 28942 AND A Reset the carry flag: no one is standing in the doorway 28943 POP HL Restore the door identifier to H 28944 LD A,H Copy it to A 28945 CALL NC,28736 Close the door if no one's in the way 28948 LD A,(32756) Pick up the doors flags in A before returning (ignored by the caller) 28951 RET
 Prev: 28874 Up: Map Next: 28952