![]() |
Routines |
Prev: 62518 | Up: Map |
Used by the routines at 62892 and 62976. If the character is standing next to a light switch, this routine makes him flip the switch on (if it's off and affects the lights in more than one window or window-pair), or consider flipping the switch off (if it's on and affects the lights in only one window or window-pair).
|
|||||||||
62597 | CALL 62518 | Is the character standing next to a light switch? | |||||||
62600 | RET Z | Return if not | |||||||
62601 | BIT 5,A | Does the light switch affect lights in more than one window or window-pair? | |||||||
62603 | JR NZ,62626 | Jump if so | |||||||
This entry point is used by the routine at 62880.
|
|||||||||
62605 | LD A,(BC) | A=window flags for the character's location | |||||||
62606 | BIT 5,A | Is the light switch here in the 'off' position? | |||||||
62608 | RET NZ | Return if so | |||||||
This entry point is used by the routine at 62694.
|
|||||||||
62609 | CALL 61823 | Get a random number in A | |||||||
62612 | CP 110 | Is it greater than 109? | |||||||
62614 | RET NC | Return if so | |||||||
62615 | LD A,32 | Bit 5 set: light switch toggle | |||||||
62617 | PUSH BC | Push the address of the window flags onto the stack | |||||||
62618 | EX (SP),HL | Transfer this address into HL | |||||||
62619 | XOR (HL) | Flip bit 1, 5 or 6 of the window flags, thus flipping the light switch that affects the window, or raising or lowering the blind | |||||||
62620 | LD (HL),A | ||||||||
62621 | CALL 62368 | Update the SRB for the window | |||||||
62624 | POP HL | Restore the character number to H | |||||||
62625 | RET | ||||||||
The character is standing next to a light switch that affects lights in more than one window or window-pair.
|
|||||||||
62626 | LD A,(BC) | A=window flags for the character's location | |||||||
This entry point is used by the routine at 29052.
|
|||||||||
62627 | BIT 5,A | Is the light switch here in the 'on' position? | |||||||
62629 | RET Z | Return if so | |||||||
62630 | PUSH BC | Push the address of the window flags onto the stack | |||||||
62631 | EX (SP),HL | Transfer this address into HL | |||||||
62632 | LD A,C | A=LSB of the address of the window flags | |||||||
62633 | LD BC,1056 | B=4 (the four central windows on a floor of the hotel span four 8-tile wide segments), C=32 (bit 5 set: light switch toggle) | |||||||
62636 | CP 72 | Are we dealing with a window that is second from the left in the hotel? | |||||||
62638 | JR NZ,62657 | Jump if not | |||||||
A light switch that affects the lights in the the four central windows on one of the floors of the hotel has been flipped.
|
|||||||||
62640 | LD L,72 | Point HL at the window flags for the leftmost of the four central windows | |||||||
62642 | PUSH HL | Save the window flags pointer | |||||||
62643 | PUSH BC | Save the segment counter | |||||||
62644 | LD A,(HL) | Flip bit 5 of the window flags, thus flipping the light switch into the 'on' or 'off' position | |||||||
62645 | XOR C | ||||||||
62646 | LD (HL),A | ||||||||
62647 | CALL 62368 | Update the SRB for the window | |||||||
62650 | POP BC | Restore the segment counter | |||||||
62651 | POP HL | Restore the window flags pointer to HL | |||||||
62652 | INC L | Move to the next window along | |||||||
62653 | DJNZ 62642 | Jump back until all four windows have been done | |||||||
62655 | POP HL | Restore the character number to H | |||||||
62656 | RET | ||||||||
62657 | CP 75 | Are we dealing with a window that is second from the right in the hotel? | |||||||
62659 | JR Z,62640 | Jump if so | |||||||
A light switch that affects the lights in the windows on more than one floor of a building other than the hotel has been flipped.
|
|||||||||
62661 | SUB C | Subtract 32 from the LSB of the window flags address | |||||||
62662 | DEC B | B=3 (there are three floors to consider) | |||||||
62663 | NOP | ||||||||
62664 | LD E,A | Point DE at the fixture location flags for the area on the fourth floor (if any) above the light switch | |||||||
62665 | LD H,186 | The fourth floor window flags are in bytes 64-95 of page 186 (at 47680) | |||||||
62667 | LD A,(DE) | Collect the fixture location flags for the fourth floor | |||||||
62668 | BIT 5,A | Does the light switch affect any windows on this floor? | |||||||
62670 | JR Z,62685 | Jump if not | |||||||
62672 | PUSH HL | Save the window flags pointer | |||||||
62673 | PUSH DE | Save the fixture location flags pointer | |||||||
62674 | PUSH BC | Save the floor counter | |||||||
62675 | LD A,(HL) | Flip bit 5 of the window flags, thus flipping the light switch into the 'on' or 'off' position | |||||||
62676 | XOR 32 | ||||||||
62678 | LD (HL),A | ||||||||
62679 | CALL 62368 | Update the SRB for the windows on this floor | |||||||
62682 | POP BC | Restore the floor counter to B | |||||||
62683 | POP DE | Restore the fixture location flags pointer to DE | |||||||
62684 | POP HL | Restore the window flags pointer to HL | |||||||
62685 | INC H | Point HL at the window flags for the next floor down | |||||||
62686 | LD A,E | Point DE at the fixture location flags for the next floor down | |||||||
62687 | ADD A,32 | ||||||||
62689 | LD E,A | ||||||||
62690 | DJNZ 62667 | Jump back until the windows on the fourth, third and second floors have been dealt with | |||||||
62692 | POP HL | Restore the character number to H | |||||||
62693 | RET |
Prev: 62518 | Up: Map |