Prev: 29003 Up: Map Next: 29051
29004: Check whether a character is immobilised by a blown fuse
Used by the routine at 61948. Returns with the carry flag set if the character is in an area affected by a blown fuse.
Input
H Character number (215-229)
29004 LD L,4 Point HL at byte 4 of the character's buffer
29006 BIT 0,(HL) Is the character indoors?
29008 RET Z Return if not
29009 LD L,1 Point HL at byte 1 of the character's buffer
29011 LD A,(HL) A=character's x-coordinate
29012 INC A Point DE at the entry in the table at 65472 that corresponds to the 8-tile wide column of the play area containing the character
29013 AND 248
29015 RRA
29016 RRA
29017 RRA
29018 ADD A,192
29020 LD E,A
29021 LD D,255
29023 LD A,(DE) Point DE at the delay counter for the fuse that is in the same building as the character (see 32674)
29024 LD E,A
29025 LD D,127
29027 LD A,(DE) Pick up the blown fuse delay counter in A
29028 AND A Return with the carry flag reset if there is no fuse here, or the fuse is not currently blown
29029 RET Z
29030 INC L L=2
29031 LD A,E A=162-167
29032 LD E,0 For no. 74 or the hotel, use this y-coordinate for comparison (the roofs of these buildings are inaccessible)
29034 CP 164 Is it the fuse at no. 74 or the hotel?
29036 JR C,29046 Jump if so
29038 LD E,16 For no. 31 or no. 19, use this y-coordinate for comparison (any character on the roof will be unaffected by a blown fuse)
29040 CP 166 Is it the fuse at no. 31 or no. 19?
29042 JR C,29046 Jump if so
29044 LD E,10 For no. 17 or no. 15, use this y-coordinate for comparison (any character on the roof will be unaffected by a blown fuse)
29046 LD A,E A=0 (no. 74 or the hotel), 16 (no. 31 or no. 19), or 10 (no. 17 or no. 15)
29047 CP (HL) Compare this value with the character's y-coordinate
29048 RET C Return with the carry flag set if the character is inside the building (as opposed to on the roof)
29049 XOR A Clear the carry flag
29050 RET
Prev: 29003 Up: Map Next: 29051