Skool Daze Routines
25404: Guide character to intermediate destination
Used by the routines at 27772 and 31854 (and indirectly by the routines at 25303, 25534 and 32048) to guide a character to a location that doesn't require going up or down any staircases.
H Character number (152-169)
25404 LD L,108 The counter at byte 108 of the character's buffer is initialised by the calling routine; hand control back to that routine if this counter is now zero
25406 DEC (HL)
25407 JP Z,25252
25410 DEC L L=107
25411 LD A,(HL) A=x-coordinate of intermediate destination
25412 LD L,98 Byte 98 holds the character's x-coordinate
25414 CP (HL) Has the character reached the intermediate destination?
25415 JR NZ,25423 Jump if not
25417 LD L,96 Byte 96 holds the character's animatory state
25419 BIT 0,(HL) Is the character midstride?
25421 JR Z,25407 Jump if not (nothing left to do)
25423 CALL 25108 Update SRB for current location of character
25426 LD C,A Store character's animatory state in C
25427 LD L,107
25429 LD A,(HL) A=x-coordinate of intermediate destination
25430 CP E E holds the character's x-coordinate
25431 LD A,C A=character's animatory state
25432 JR NZ,25440 Jump unless the character has reached the destination
25434 BIT 7,A Is the character facing left?
25436 JR Z,25449 Jump if so
25438 JR 25471
25440 BIT 7,A Set the zero flag if the character is facing left
25442 JR NC,25466 Jump if the character is to the left of his destination
The character is to the right of his destination, and must proceed leftwards.
25444 RES 7,A Make sure the character is facing left
25446 JP NZ,25008 Update character's animatory state and location and update SRB if he was facing right
25449 INC A A=character's next animatory state
25450 BIT 0,A Will the character be midstride?
25452 JP NZ,25008 Update character's animatory state and location and update SRB if so
25455 DEC E E=character's next x-coordinate (one to the left)
25456 AND 3 Calculate the character's next animatory state in A
25458 LD B,A
25459 LD A,C
25460 AND 252
25462 ADD A,B
25463 JP 25008 Update character's animatory state and location and update SRB
The character is to the left of his destination, and must proceed rightwards.
25466 SET 7,A Make sure the character is facing right
25468 JP Z,25008 Update character's animatory state and location and update SRB if the character was facing left
25471 INC A A=character's next animatory state
25472 BIT 0,A Will the character be midstride?
25474 JP NZ,25008 Update character's animatory state and location and update SRB if so
25477 INC E E=character's next x-coordinate (one to the right)
25478 JR 25456 Jump back to update animatory state and SRB