Prev: 30211 Up: Map Next: 30429
30396: Deal with a character who is at the entrance to a building
Used by the routine at 60347. On entry, the bit set in A indicates the direction in which the character is going to move next:
Bit Direction
7 Left
6 Right
5 Up and to the left
4 Up and to the right
3 Down and to the left
2 Down and to the right
Also on entry, the zero flag is set if the character is indoors. If the character is Sam, we also check whether he's entering a house other than no. 19 without a key.
A Direction indicator (128, 64, 32, 16, 8 or 4)
B Third byte of the character's location descriptor (see 60179)
H Character number (215-230)
L 4
30396 JR NZ,30402 Jump unless the character is indoors
30398 AND B Is the character going to leave the building?
30399 RET NZ Return if not
30400 INC (HL) Set the character's z-coordinate to 2
30401 RET
30402 AND B Is the character going to enter the building?
30403 JR Z,30400 Jump if not
30405 LD A,H A=character number
30406 CP 230 Is this Sam?
30408 RET NZ Return if not
30409 BIT 0,B Does the entrance have a door?
30411 RET Z Return if not
30412 CALL 62099 Point HL at the status flags for the door that Sam is standing next to (see 32752)
30415 LD A,L A=LSB of the address of the door status flags (240-249)
30416 CP 245 Is Sam standing in the doorway of no. 19?
30418 JR Z,30423 Jump if so
30420 LD A,(HL) Pick up the door status flags for the doorway Sam is standing in
30421 AND 248 Set the zero flag if the door requires no key to unlock it
30423 LD H,230 230=Sam
30425 RET Z Return if the door requires no key to unlock it
30426 JP 31289 Check whether Sam has entered a house through the front door without a key
Prev: 30211 Up: Map Next: 30429