Routines
 Prev: 70CA Up: Map Next: 7118
70CD: Close any temporarily open doors if necessary
 Used by the routine at F6B4. 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). 70CD LD A,(\$7FF6) Return unless 7FF6 (which is decremented on every pass through the main loop, and cycles through the values 0x01-0x0F) holds 0x04 at the moment 70D0 CP \$04 70D2 RET NZ 70D3 LD A,(\$7FF4) 7FF4 holds the doors flags 70D6 LD HL,\$013E H=0x01 (left study door), L=0x3E 70D9 BIT 0,A Is the left study door open? 70DB CALL NZ,\$70EC If so, close it if possible 70DE LD HL,\$0240 H=0x02 (right study door), L=0x40 70E1 BIT 1,A Is the right study door open? 70E3 CALL NZ,\$70EC If so, close it if possible 70E6 BIT 2,A Is the Science Lab storeroom door open? 70E8 RET Z Return if not 70E9 LD HL,\$0442 H=0x04 (Science Lab storeroom door), L=0x42 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 B93E containing the location of the door. 70EC PUSH HL Save the door identifier briefly 70ED LD H,\$B9 Point HL at the door location table entry 70EF LD A,(HL) A=x-coordinate of the door 70F0 INC L 70F1 LD D,(HL) D=y-coordinate of the door 70F2 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 70F3 LD C,A 70F4 ADD A,\$03 70F6 LD E,A 70F7 LD HL,\$B701 L=0x01, H=0xB7 (little girl no. 1) 70FA LD B,\$20 32 game characters (0xB7-0xD6) 70FC LD A,(HL) A=character's x-coordinate 70FD CP C Is the character to the left of the door? 70FE JR C,\$710B Jump if so 7100 CP E Is the character to the right of the door? 7101 JR NC,\$710B Jump if so 7103 INC L L=0x02 7104 LD A,D A=y-coordinate of the door 7105 SUB (HL) Subtract the character's y-coordinate 7106 DEC L L=0x01 7107 CP \$02 Is the character standing in the doorway? 7109 JR C,\$710F Jump if so 710B INC H Next character 710C DJNZ \$70FC Jump back until all 32 characters have been checked 710E AND A Reset the carry flag: no one is standing in the doorway 710F POP HL Restore the door identifier to H 7110 LD A,H Copy it to A 7111 CALL NC,\$7040 Close the door if no one's in the way 7114 LD A,(\$7FF4) Pick up the doors flags in A before returning (ignored by the caller) 7117 RET
 Prev: 70CA Up: Map Next: 7118