| Routines

62694: Make a character flip a light switch on or off occasionally

Used by the routine at 62926. If the character is standing next to a light switch, this routine makes him flip the switch off (if it's on and affects the lights in more than one window or window-pair), or consider flipping the switch on (if it's off and affects the lights in only one window or window-pair).
Input
H | Character number (215-229)
62694 | CALL 62518 | Is the character standing next to a light switch?
62697 | RET Z | Return if not
62698 | BIT 5,A | Reset the zero flag if the light switch affects the lights in more than one window or window-pair
This entry point is used by the routine at 62880.
62700 | LD A,(BC) | A=window flags
62701 | JR NZ,62709 | Jump if the light switch affects the lights in more than one window or window-pair
62703 | BIT 5,A | Is the light switch in the 'on' position?
62705 | RET Z | Return if so
62706 | JP 62609 | Flip the light switch on 109 times out of 256
62709 | BIT 5,A | Is the light switch in the 'off' position?
62711 | RET NZ | Return if so
62712 | JP 62630 | Flip the light switch off