Routines

31915: Check whether character should continue walkabout


Used by routines at 31952 and 31969 after a character has reached a walkabout destination or returned to the walkabout origin. It checks for the arrival/occurrence of a time/event specified by byte 6 of the character's buffer, and returns with the carry flag reset if the character is ready to respond to it.

H Character number (183-214)

31915 2E06 LD L,6
31917 7E LD A,(HL) Pick up the time/event identifier in A
31918 2D DEC L
31919 CD8F7C CALL 31887 Has the time come or event happened?
31922 2812 JR Z,31942 Jump if not

This entry point is used by the routine at 31969:
31924 7E LD A,(HL) A=x-coordinate of original location relative to which the character is performing his walkabout
31925 2E01 LD L,1
31927 BE CP (HL) Is the character at the walkabout "origin" (and therefore ready to respond to the arrival/occurrence of the time/event)?
31928 2004 JR NZ,31934 Jump to return him to the origin if not
31930 2D DEC L HL points to byte 0 of character's buffer
31931 CB46 BIT 0,(HL) Is the character midstride?
31933 C8 RET Z Return with carry flag reset if not
31934 37 SCF Signal: Not ready to advance in table of A&P yet
31935 2E0B LD L,11 Fill in new walkabout destination (either the origin or some new location within 7 spaces to the left of the origin)
31937 77 LD (HL),A
31938 01ED63 LD BC,25581 See routine at 25581
31941 C9 RET

The time/event hasn't come/happened yet, so set the character off on another mini-jaunt.
31942 CD9162 CALL 25233 Get random number in A
31945 E607 AND 7 0≤A≤7
31947 D607 SUB 7 -7≤A≤0
31949 86 ADD A,(HL) Add x-coordinate of walkabout origin to give new walkabout destination
31950 18EE JR 31934