Prev: F404 Up: Map Next: F485
F436: Check whether a character is standing next to a light switch
Used by the routines at 717C, 7222, 7425, 7576, F485, F4E6 and F5A0. Returns with the zero flag reset if the character is standing next to a light switch.
Input
H Character number (0xD7-0xE6)
F436 LD L,$04 Point HL at byte 0x04 of the character's buffer
F438 BIT 0,(HL) Is the character indoors?
F43A RET Z Return if not
F43B LD L,$00 Point HL at byte 0x00 of the character's buffer
F43D LD A,(HL) A=character's animatory state
F43E RLCA Set the carry flag if the character is facing left, reset it if he's facing right
F43F CCF
F440 SBC A,A Now A=0 if the character is facing left, or 2 if he's facing right
F441 INC A
F442 ADD A,A
F443 INC L Point HL at byte 0x01 of the character's buffer
F444 ADD A,(HL) Add the character's x-coordinate
F445 LD B,$80 Bit 7 set: check for a light switch at the left side of the room
F447 LD C,A C=x-coordinate of the front column of the character's sprite
F448 AND $07 Is C=0 mod 8?
F44A JR Z,$F454 Jump if so (left-hand light switches are at such coordinates)
F44C LD B,$40 Bit 6 set: check for a light switch at the right side of the room
F44E SUB $07 Is C=7 mod 8?
F450 JR Z,$F454 Jump if so (right-hand light switches are at such coordinates)
F452 XOR A Set the zero flag (no target object here)
F453 RET
This entry point is used by the routines at 749E (with B=0x02 to check for the presence of a telephone), 7866 (with B=0xC0 to check for a light switch) and F6B0 (with B=0x04, 0x08, 0x10, 0x40 or 0x80 to check for a light switch or window blind).
F454 LD A,C A=x-coordinate of the front column of the character's sprite
F455 AND $F8 C=INT(C/8)
F457 RRCA
F458 RRCA
F459 RRCA
F45A LD C,A
F45B INC L Point HL at byte 0x02 of the character's buffer
F45C LD A,(HL) A=character's y-coordinate
F45D CP $21 This is the y-coordinate of a character who's in a shop
F45F JR NZ,$F463 Jump if the character's not in a shop
F461 SUB $02 Adjust a y-coordinate of 33 down to 31
F463 LD L,$FE L=INT(A/6)-1 (0-4)
F465 INC L
F466 SUB $06
F468 JR NC,$F465
F46A CP $FB Is the character's y-coordinate 7, 13, 19, 25, 31 or 33?
F46C JR NZ,$F452 Jump if not (he's not on a floor)
F46E LD A,L A=0-4
F46F CP $05 Is the character's y-coordinate >= 36?
F471 JR NC,$F452 Jump if so
F473 RRCA A=0x00 (5th floor), 0x20 (4th floor), 0x40, 0x60 or 0x80 (1st floor)
F474 RRCA
F475 RRCA
F476 ADD A,C Add INT(x/8) (where x is the x-coordinate of the front column of the character's sprite)
F477 LD E,A Transfer this to E
F478 LD D,$F5 Point DE at an entry in the fixture location table at F500
F47A LD A,(DE) Pick up the entry
F47B AND B Is there an object of the desired type here?
F47C RET Z Return if not
F47D LD A,L A=0-4
F47E ADD A,$B9 B=0xB9-0xBD
F480 LD B,A
F481 LD A,(DE) Pick up the entry from the fixture location table at F500
F482 SET 6,C Point BC at the window flags for the character's location (in one of the data blocks at B940, BA40, BB40, BC40, or BD40)
F484 RET Return with the zero flag reset
Prev: F404 Up: Map Next: F485