Prev: 62468 Up: Map Next: 62597
62518: Check whether a character is standing next to a light switch
Used by the routines at 29052, 29218, 29733, 30070, 62597, 62694 and 62880. Returns with the zero flag reset if the character is standing next to a light switch.
Input
H Character number (215-230)
62518 LD L,4 Point HL at byte 4 of the character's buffer
62520 BIT 0,(HL) Is the character indoors?
62522 RET Z Return if not
62523 LD L,0 Point HL at byte 0 of the character's buffer
62525 LD A,(HL) A=character's animatory state
62526 RLCA Set the carry flag if the character is facing left, reset it if he's facing right
62527 CCF
62528 SBC A,A Now A=0 if the character is facing left, or 2 if he's facing right
62529 INC A
62530 ADD A,A
62531 INC L Point HL at byte 1 of the character's buffer
62532 ADD A,(HL) Add the character's x-coordinate
62533 LD B,128 Bit 7 set: check for a light switch at the left side of the room
62535 LD C,A C=x-coordinate of the front column of the character's sprite
62536 AND 7 Is C=0 mod 8?
62538 JR Z,62548 Jump if so (left-hand light switches are at such coordinates)
62540 LD B,64 Bit 6 set: check for a light switch at the right side of the room
62542 SUB 7 Is C=7 mod 8?
62544 JR Z,62548 Jump if so (right-hand light switches are at such coordinates)
62546 XOR A Set the zero flag (no target object here)
62547 RET
This entry point is used by the routines at 29854 (with B=2 to check for the presence of a telephone), 30822 (with B=192 to check for a light switch) and 63152 (with B=4, 8, 16, 64 or 128 to check for a light switch or window blind).
62548 LD A,C A=x-coordinate of the front column of the character's sprite
62549 AND 248 C=INT(C/8)
62551 RRCA
62552 RRCA
62553 RRCA
62554 LD C,A
62555 INC L Point HL at byte 2 of the character's buffer
62556 LD A,(HL) A=character's y-coordinate
62557 CP 33 This is the y-coordinate of a character who's in a shop
62559 JR NZ,62563 Jump if the character's not in a shop
62561 SUB 2 Adjust a y-coordinate of 33 down to 31
62563 LD L,254 L=INT(A/6)-1 (0-4)
62565 INC L
62566 SUB 6
62568 JR NC,62565
62570 CP 251 Is the character's y-coordinate 7, 13, 19, 25, 31 or 33?
62572 JR NZ,62546 Jump if not (he's not on a floor)
62574 LD A,L A=0-4
62575 CP 5 Is the character's y-coordinate >= 36?
62577 JR NC,62546 Jump if so
62579 RRCA A=0 (5th floor), 32 (4th floor), 64, 96 or 128 (1st floor)
62580 RRCA
62581 RRCA
62582 ADD A,C Add INT(x/8) (where x is the x-coordinate of the front column of the character's sprite)
62583 LD E,A Transfer this to E
62584 LD D,245 Point DE at an entry in the fixture location table at 62720
62586 LD A,(DE) Pick up the entry
62587 AND B Is there an object of the desired type here?
62588 RET Z Return if not
62589 LD A,L A=0-4
62590 ADD A,185 B=185-189
62592 LD B,A
62593 LD A,(DE) Pick up the entry from the fixture location table at 62720
62594 SET 6,C Point BC at the window flags for the character's location (in one of the data blocks at 47424, 47680, 47936, 48192, or 48448)
62596 RET Return with the zero flag reset
Prev: 62468 Up: Map Next: 62597