Prev: DD99 Up: Map Next: DDFC
DDCF: Now and then give a wanderer a new random step
Used by the routines at WANDERING_MONSTER and FIND_WANDER.
For the finds (FIND_WANDER, B=4) and the monsters of graphics 64-79 (WANDERING_MONSTER, B=7). The low six bits of +6 count turns down; when they run out, or when the step has become 0 both ways, a new step is drawn for U and V from the random number's two bytes (RANDOM_STEP: up to twice B either way, those near B likeliest) and a new count of 0-63 from R. The facing's top two bits are set again from the step by MOVE_SPLIT, which follows.
Input
B The number of random bits to a step
IX The record
WANDER_STEP DDCF DEC (IX+$06) Count down; a new step when the count runs out...
DDD2 LD A,(IX+$06)
DDD5 AND $3F
DDD7 JR Z,WANDER_STEP_0
DDD9 LD A,(IX+$0A) ...or when the old one is 0 both ways
DDDC OR (IX+$0B)
DDDF RET NZ
WANDER_STEP_0 DDE0 LD A,(RANDOM) The U step, from the random number's low byte
DDE3 LD C,A
DDE4 CALL RANDOM_STEP
DDE7 LD (IX+$0A),A
DDEA LD A,($BBAB) The V step, from its high byte
DDED LD C,A
DDEE CALL RANDOM_STEP
DDF1 LD (IX+$0B),A
DDF4 LD A,R A new count of 0-63
DDF6 AND $3F
DDF8 LD (IX+$06),A
DDFB RET
Prev: DD99 Up: Map Next: DDFC