![]() |
Routines |
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 |
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 door |
28912 | INC L | |
28913 | LD D,(HL) | D=y-coordinate of door |
28914 | DEC A | Set C=X-1, 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 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 |
28951 | RET |