Skool Daze Routines
63374: Make character find ERIC
Used by command lists 208, 210, 214, 218 and 222.
H Character number (152-169)
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 in 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 places 251 (the LSB of the routine at 31739) in byte 105. On the next pass through this routine, byte 105 is checked, and if it holds 251, a jump to 31739 is made to actually move the character one step in the right direction towards ERIC; 31739 also sets byte 105 back to 160. Thus subsequent calls to 63390 will alternate between comparing ERIC's location with that of the character looking for him, and actually moving the character who is looking for him.
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 in bytes 111 and 112 of the character's buffer
63385 LD (HL),158
63387 INC L
63388 LD (HL),247
Future calls to this routine will enter at this point, by virtue of its address being placed in bytes 111 and 112 of the character's buffer.
63390 LD A,H A=number of 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 it time to make the character looking for ERIC move one step closer to him?
63398 LD A,(HL)
63399 CP 251
63401 JP Z,31739 Jump if so
63404 CALL 31229 Get ERIC's coordinates in DE
63407 LD L,97 Byte 97 holds the character's 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 either on a staircase or on a different floor from ERIC
63416 INC L L=98
63417 LD A,(HL) A=character's x-coordinate
63418 SUB E Are ERIC and this character in exactly the same location?
63419 JR NZ,63436 Jump if not
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 any routine address from bytes 111 and 112 of the character's buffer
63429 LD (HL),A
63430 LD L,106 Remove any routine address from bytes 105 and 106 of the character's buffer
63432 LD (HL),A
63433 JP 25256 Move to the next instruction in the command list
The character looking for ERIC is not in exactly the same location as ERIC. But is he close enough?
63436 JR NC,63440 Jump if character is to the right of ERIC
63438 NEG
63440 CP 4 Is ERIC less than 4 spaces away?
63442 JR C,63421 Jump if so
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