| Routines

63209: Make a character walk up or down

The address of this interruptible subcommand routine is placed into bytes 14 and 15 of a character's buffer by the routine at 63304. It makes a character start or continue walking up or down towards his walkabout destination, stopping occasionally on the way to flip a light switch or raise or lower a window blind.
Input
H | Character number (215-229)
63209 | CALL 63128 | Exit now if the character is midstride
63212 | BIT 2,(HL) | Is the character's arm raised?
63214 | JP NZ,62331 | Lower his arm if so
This entry point is used by the routine at 31319.
63217 | LD L,17 | The counter in byte 17 of the character's buffer determines the delay until the character will next consider flipping a light switch or raising or lowering a window blind
63219 | DEC (HL) | Decrement that counter
63220 | JR NZ,63266 | Jump unless the counter has reached 0
63222 | LD (HL),4 | Reset the counter to 4 (in case the character is not standing next to a light switch or window blind at the moment)
63224 | CALL 63152 | Is the character standing next to a light switch or window blind?
63227 | JR Z,63266 | Jump if not
The character is standing next to a light switch or window blind.
63229 | CP 64 | Is the character standing next to a window blind?
63231 | JR C,63242 | Jump if so
63233 | LD A,(DE) | A=fixture location flags
63234 | BIT 5,A | Does the light switch affect the lights in more than one window or window pair?
63236 | JR NZ,63266 | Jump if so (the character will not flip the switch)
63238 | LD A,32 | Bit 5 set: light switch toggle
63240 | JR 63250 |
63242 | CP 8 | Set the zero flag if the character standing next to the right-hand window of a pair
63244 | LD A,1 | Bit 0 set: right-hand window blind toggle
63246 | JR Z,63250 | Jump if the character is standing next to the right-hand window of a pair
63248 | LD A,64 | Bit 6 set: left-hand window blind toggle
63250 | CALL 62617 | Flip the light switch, or raise or lower the window blind
63253 | CALL 61823 | Get a random number between 32 and 159 in A
63256 | AND 127
63258 | ADD A,32
63260 | LD L,17 | Reset the counter in byte 17 of the character's buffer to this number
63262 | LD (HL),A
63263 | JP 62268 | Raise the character's arm
The character will not be flipping any light switches or raising or lowering any window blinds at this stage of his walkabout.
63266 | LD L,1 | Collect the character's x-coordinate from byte 1 of his buffer
63268 | LD A,(HL)
63269 | LD L,16 | Byte 16 of the character's buffer holds his walkabout destination x-coordinate
63271 | CP (HL) | Has the character reached his walkabout destination?
63272 | JP Z,62084 | Terminate this subcommand if so
63275 | JP C,60334 | Move the character right if he's still to the left of his destination
63278 | JP 60347 | Otherwise move him left