| Routines

31969: Make a character walk up and down a few times or until a certain time

Used by command lists 18, 42 and 44 to make a character walk about a fixed location until a specified time, or until a certain number of walkabouts have been performed.
Input
H | Character number (183-209)
31969 | LD L,6 | Collect the event ID (always 0, denoting the end of the lesson) and the maximum walkabout count from the command list and copy them into bytes 6 and 7 of the character's buffer
31971 | CALL 25188
31974 | LD L,7 | Decrease the walkabout counter at byte 7 of the character's buffer
31976 | DEC (HL)
31977 | JR NZ,31993 | If the character has not yet performed the maximum number of walkabouts, check whether the specified time has arrived
31979 | INC (HL) | Set the walkabout counter back to 1 to ensure that we return to this execution path next time (to check whether the character has returned to the walkabout origin)
31980 | LD L,5 | Byte 5 holds the x-coordinate of the walkabout origin
31982 | CALL 31924 | Reset the carry flag if the character is at the walkabout origin
31985 | JP NC,25484 | Move to the next command in the command list if the specified time has arrived or the character has completed all his walkabouts
31988 | CALL 25503 | Otherwise send the character off to another walkabout destination via the routine at 25581, and return to the instruction at 31991 (below) when done
31991 | JR 31974 |
31993 | CALL 31915 | Reset the carry flag if the specified time has arrived and the character is at the walkabout origin
31996 | JR 31985 |