Prev: 63373 Up: Map Next: 63450
63374: Make a character find ERIC
Used by command lists 208, 210, 214, 218 and 222 to make little boy no. 10, MR WACKER or MR ROCKITT track down ERIC (to deliver a message).
Input
H Character number (161, 163, 164)
63374 LD A,255 Adjust the length of the lesson to allow the character enough time to find ERIC
63376 CALL 64004
This routine places 63390 into bytes 111 and 112 of the character's buffer, but also uses byte 105 (which normally holds the LSB of a routine address) for coordination. When byte 105 holds 160 (the LSB of the routine at 31648), ERIC's coordinates are compared with those of the character looking for him, and the decision is made whether to keep moving. If the character does need to keep moving, 31711 is called, which either (a) turns the character round, or (b) puts the character midstride, and places 251 (the LSB of the routine at 31739) into byte 105. When byte 105 holds 251, this routine jumps to 31739 to move the character from the midstride position, and set byte 105 back to 160.
63379 LD L,105 Initialise byte 105 to 160, so on this first pass we compare ERIC's location with that of his chaser
63381 LD (HL),160
63383 LD L,111 Place 63390 into bytes 111 and 112 of the character's buffer (thus setting the character's uninterruptible subcommand)
63385 LD (HL),158
63387 INC L
63388 LD (HL),247
Subsequent calls to this routine will enter at this point, by virtue of its address being placed into bytes 111 and 112 of the character's buffer.
63390 LD A,H A=number of the character looking for ERIC
63391 CP 163 Is MR WACKER looking for ERIC?
63393 CALL Z,32234 If so, make him walk fast
63396 LD L,105 Is the character midstride?
63398 LD A,(HL)
63399 CP 251
63401 JP Z,31739 Finish the stride if so
The character looking for ERIC is not midstride at the moment. Decide which way (if any) he should go to find ERIC.
63404 CALL 31229 Get ERIC's coordinates in DE
63407 LD L,97 Byte 97 of the character's buffer holds his y-coordinate
63409 LD A,(HL) Pick this up in A
63410 CP D Set the zero flag if ERIC is on same floor
63411 CALL 63973 Compare this character's coordinates with ERIC's
63414 JR NZ,63444 Jump if this character is on a staircase or more than 3 y-coordinates away from ERIC
63416 INC L L=98
63417 LD A,(HL) A=character's x-coordinate
63418 SUB E Does it match ERIC's x-coordinate?
63419 JR NZ,63436 Jump if not
The character looking for ERIC is within 3 x-coordinates and 3 y-coordinates of ERIC's location, and is not on a staircase. In other words, ERIC has been found.
63421 LD A,(32763) Check ERIC's status flags at 32763, and return if ERIC is firing, hitting, jumping, being spoken to by a little boy, knocked out, or writing on a blackboard
63424 AND 127
63426 RET NZ
63427 LD L,112 Remove the address of the entry point at 63390 from bytes 111 and 112 of the character's buffer
63429 LD (HL),A
63430 LD L,106 Remove any interruptible subcommand routine address from bytes 105 and 106 of the character's buffer
63432 LD (HL),A
63433 JP 25256 Move to the next command in the command list
The character looking for ERIC is within 3 y-coordinates of ERIC's location, but not at the same x-coordinate. Is he close enough, though?
63436 JR NC,63440 Jump if the character is to the right of ERIC
63438 NEG Get the absolute x-coordinate distance between the character and ERIC
63440 CP 4 Is ERIC less than 4 x-coordinates away?
63442 JR C,63421 Jump if so (that's close enough)
The character has not yet found ERIC.
63444 CALL 31452 Determine this character's next move
63447 JP 31711 Set him off in the appropriate direction
Prev: 63373 Up: Map Next: 63450