Routines
 Prev: 62B2 Up: Map Next: 6317
62D7: Make a character walk up and down until a certain time
Used by command lists 0x88, 0x8C, 0x8E, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9A, 0x9C, 0x9E, 0xA0, 0xA2, 0xA4, 0xA6, 0xA8, 0xAA, 0xAC, 0xAE, 0xB0, 0xB2, 0xB4, 0xBA, 0xBC, 0xC6, 0xC8, 0xCA, 0xCE, 0xD0, 0xD2, 0xD4, 0xD6, 0xD8, 0xDA and 0xDE to make a character walk up and down within 7 spaces to the left of a fixed location (the 'walkabout origin') until a specified time, e.g. the end of the lesson or when a teacher arrives at the doorway of the classroom.
Input
H Character number (0x98-0xA9)
L 0x7A
62D7 LD A,(HL) Reset bits 5 and 6 of byte 0x7A of the character's buffer, indicating that he should no longer walk fast or slow continuously (if he was doing so)
62D8 AND \$9F
62DA LD (HL),A
62DB CALL \$618C Collect the signal byte from the command list
62DE LD L,\$65 Place the signal byte in byte 0x65 of the character's buffer
62E0 LD (HL),A
62E1 LD L,\$63 Change the address in bytes 0x63 and 0x64 of the character's buffer from 62D7 to 62E5 (below)
62E3 LD (HL),\$E5
This entry point is used by the routines at 6B32 and 6B3D.
62E5 LD L,\$65 Collect the signal byte from byte 0x65 of the character's buffer
62E7 LD A,(HL)
62E8 CALL \$631E Has this signal been raised?
62EB JR Z,\$630C Jump if not
The time has come to stop moving about. However, before we move on in the command list, the character needs to return to the walkabout origin.
62ED INC L Collect the x-coordinate of the walkabout origin from byte 0x66 of the character's buffer
62EE LD A,(HL)
62EF LD L,\$62 Byte 0x62 holds the character's x-coordinate
62F1 CP (HL) Is the character at the walkabout origin?
62F2 JR NZ,\$62FB Jump if not
62F4 LD L,\$60 Byte 0x60 holds the character's animatory state
62F6 BIT 0,(HL) Is the character midstride?
62F8 JP Z,\$62A8 Move to the next command in the command list if not
62FB LD L,\$6B Fill in the new walkabout destination (either the origin or some location within 7 spaces to the left of the origin)
62FD LD (HL),A
62FE INC L Initialise the counter at byte 0x6C to 0x1E, which will give the character enough time to get to the destination
62FF LD (HL),\$1E
6301 LD BC,\$633C Place the address of the interruptible subcommand routine at 633C (guide character to destination) into bytes 0x69 and 0x6A of the character's buffer
6304 LD L,\$69
6306 LD (HL),C
6307 INC L
6308 LD (HL),B
6309 INC L
630A PUSH BC