Prev: 28736 Up: Map Next: 28812
28767: Check for a closed door in front of a character
Used by the routines at 25843 and 28814. Returns with the carry flag set if the character is facing a closed door, and C holding the door identifier:
ID Door
1 Left study door
2 Right study door
4 Science Lab storeroom door
8 Boys' skool door
16 Skool gate
Input
H Character number (183-210)
28767 LD L,0 Pick up the character's animatory state in A
28769 LD A,(HL)
28770 RLCA Set A=-1 if the character is facing left, 1 if facing right
28771 CCF
28772 SBC A,A
28773 ADD A,A
28774 INC A
28775 INC L Byte 1 of the character's buffer holds his x-coordinate
28776 ADD A,(HL) Add this to A
28777 LD E,A E=x-coordinate of the location directly in front of the character
28778 INC L L=2
28779 LD D,(HL) Pick up the character's y-coordinate in D
28780 PUSH HL
28781 LD HL,47422 47422 is the address of the door location table
28784 LD BC,1281 B=5 (there are 5 doors), C=1 (the left study door is the first one)
28787 LD A,E A=x-coordinate of the location directly in front of the character
28788 CP (HL) Compare this with the x-coordinate of the door
28789 INC HL
28790 JR NZ,28796 Jump if the x-coordinates don't match
28792 LD A,D A=character's y-coordinate
28793 CP (HL) Compare this with the y-coordinate of the door
28794 JR Z,28804 Jump if they match (the character is standing at this door)
28796 INC HL
28797 RLC C Move the set bit in C one place to the left
28799 DJNZ 28787 Jump back to consider the remaining doors
28801 POP HL
28802 XOR A Reset the carry flag: there is no door in front of the character
28803 RET
The character is standing in front of a door.
28804 LD A,(32756) Pick up the doors flags from 32756
28807 AND C Check the bit corresponding to the door
28808 POP HL
28809 RET NZ Return with the carry flag reset if the door is open
28810 SCF Set the carry flag: the door is closed
28811 RET
Prev: 28736 Up: Map Next: 28812