| Routines

7CAB: Check whether a character should continue walking up and down

Used by the routines at 7CD0 and 7CE1 after a character has reached a walkabout destination. It checks the signal for the event specified by byte 0x06 of the character's buffer, and returns with the carry flag reset if the signal has been raised and the character has returned to the walkabout origin.
Input
H | Character number (0xB7-0xD1)
7CAB | LD L,$06 | Pick up the event identifier in A
7CAD | LD A,(HL)
7CAE | DEC L | L=0x05
7CAF | CALL $7C8F | Has the signal been raised for this event?
7CB2 | JR Z,$7CC6 | Jump if not
This entry point is used by the routine at 7CE1.
7CB4 | LD A,(HL) | A=x-coordinate of the location relative to which the character is performing his walkabout (the 'walkabout origin'), stored in byte 0x05
7CB5 | LD L,$01 | Byte 0x01 of the character's buffer holds his current x-coordinate
7CB7 | CP (HL) | Is the character at the walkabout origin (and therefore ready to respond to the signal)?
7CB8 | JR NZ,$7CBE | Return him to the walkabout origin if not
7CBA | DEC L | Point HL at byte 0x00 of the character's buffer
7CBB | BIT 0,(HL) | Is the character midstride?
7CBD | RET Z | Return with the carry flag reset if not
7CBE | SCF | Signal: not ready to advance in the command list yet
7CBF | LD L,$0B | Fill in the new walkabout destination (either the origin or some location within 7 spaces to the left of the origin)
7CC1 | LD (HL),A
7CC2 | LD BC,$63ED | Return with BC holding the address of the routine at 63ED
7CC5 | RET
The time hasn't come or the event hasn't happened yet, so set the character off on another mini-jaunt.
7CC6 | CALL $6291 | A=random number
7CC9 | AND $07 | 0<=A<=7
7CCB | SUB $07 | -7<=A<=0
7CCD | ADD A,(HL) | Add the x-coordinate of the walkabout origin to give the new walkabout destination
7CCE | JR $7CBE |