Back to Skool Routines
Prev: 28736 Up: Map Next: 28812
28767: Check for 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
H Character number (183-214)
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 Now E=x-coordinate of location directly in front of 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, C=1
28787 LD A,E A=x-coordinate of location directly in front of 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=y-coordinate of character
28793 CP (HL) Do the y-coordinates match?
28794 JR Z,28804 Jump if so (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 remaining doors
28801 POP HL
28802 XOR A Reset the carry flag: no door in front of 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: door is closed
28811 RET
Prev: 28736 Up: Map Next: 28812